Skip to content

Commit 02ae283

Browse files
author
Jicheng Lu
committed
add utility visbility
1 parent e60454e commit 02ae283

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/lib/helpers/types/agentTypes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@
132132
/**
133133
* @typedef {Object} AgentUtility
134134
* @property {string} name
135-
* @property {boolean} disabled
135+
* @property {boolean} disabled
136+
* @property {string?} [visibility_expression]
136137
* @property {import('$commonTypes').NameBase[]} functions
137138
* @property {import('$commonTypes').NameBase[]} templates
138139
*/

src/routes/page/agent/[agentId]/agent-components/agent-utility.svelte

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
return {
4343
name: x.name,
4444
disabled: x.disabled,
45+
visibility_expression: x.visibility_expression,
4546
functions: functions,
4647
templates: templates
4748
};
@@ -176,6 +177,19 @@
176177
handleAgentChange();
177178
}
178179
180+
/**
181+
* @param {any} e
182+
* @param {number} uid
183+
*/
184+
function changeUtilityVisibility(e, uid) {
185+
const found = innerUtilities.find((_, index) => index === uid);
186+
if (!found) return;
187+
188+
found.visibility_expression = e.target.value || null;
189+
innerRefresh(innerUtilities);
190+
handleAgentChange();
191+
}
192+
179193
/**
180194
* @param {number} uid
181195
* @param {number} id
@@ -246,6 +260,7 @@
246260
return {
247261
name: x.name,
248262
disabled: x.disabled,
263+
visibility_expression: x.visibility_expression,
249264
functions: x.functions.map(f => ({ ...f })),
250265
templates: x.templates.map(t => ({ ...t }))
251266
}
@@ -341,6 +356,25 @@
341356
</div>
342357
343358
<div class="utility-row utility-row-secondary">
359+
<div class="utility-content">
360+
<div class="utility-list-item">
361+
<div class="utility-label line-align-center">
362+
{'Visibility expression'}
363+
</div>
364+
<div class="utility-value">
365+
<div class="utility-input line-align-center">
366+
<Input
367+
type="text"
368+
disabled={utility.disabled}
369+
maxlength={1000}
370+
value={utility.visibility_expression}
371+
on:change={e => changeUtilityVisibility(e, uid)}
372+
/>
373+
</div>
374+
<div class="utility-delete line-align-center"></div>
375+
</div>
376+
</div>
377+
</div>
344378
<div class="utility-content">
345379
{#each utility.functions as fn, fid (fid)}
346380
<div class="utility-list-item">

0 commit comments

Comments
 (0)