Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"dependencies": {
"@codemirror/commands": "^6.10.0",
"@codemirror/lang-javascript": "^6.2.4",
"@codemirror/lang-json": "^6.0.2",
"@codemirror/lang-python": "^6.2.1",
"@codemirror/language": "^6.11.3",
"@codemirror/state": "^6.5.2",
Expand Down
7 changes: 5 additions & 2 deletions src/lib/common/modals/PlainModal.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import { Modal, ModalBody, ModalHeader } from "@sveltestrap/sveltestrap";
import { Modal, ModalBody } from "@sveltestrap/sveltestrap";

/** @type {boolean} */
export let isOpen;
Expand All @@ -16,6 +16,9 @@
/** @type {string} */
export let containerStyles = '';

/** @type {string} */
export let bodyStyles = '';

/** @type {() => void} */
export let toggleModal;
</script>
Expand All @@ -30,7 +33,7 @@
toggle={() => toggleModal()}
unmountOnClose
>
<ModalBody>
<ModalBody style={bodyStyles}>
<slot />
</ModalBody>
</Modal>
27 changes: 24 additions & 3 deletions src/lib/common/shared/CodeScript.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
import { onMount, createEventDispatcher } from "svelte";
import CodeMirror from "svelte-codemirror-editor";
import { keymap } from "@codemirror/view";
import { keymap, lineNumbers } from "@codemirror/view";
import { indentUnit, indentOnInput, indentService } from "@codemirror/language";
import { defaultKeymap, history, indentWithTab, historyKeymap } from "@codemirror/commands";
import { EditorState } from "@codemirror/state";
Expand All @@ -20,14 +20,23 @@
/** @type {string} */
export let containerClasses = '';

/** @type {boolean} */
export let useDarkTheme = true;

/** @type {boolean} */
export let hideLineNumber = false;

/** @type {boolean} */
export let editable = true;


/** @type {import("@codemirror/state").Extension[]} */
const baseExtensions = [
indentUnit.of(" "),
EditorState.tabSize.of(4),
indentOnInput(),
history(),
keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab])
keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]),
];

/** @type {import("@codemirror/state").Extension[]} */
Expand Down Expand Up @@ -59,6 +68,17 @@
javascript(),
...baseExtensions
];
} else {
extensions = [
...baseExtensions
];
}

if (hideLineNumber) {
extensions = [
lineNumbers({ formatNumber: () => "" }),
...extensions
];
}
});

Expand All @@ -73,8 +93,9 @@

<CodeMirror
class={`code-script-container ${containerClasses}`}
theme={oneDark}
lineWrapping
theme={useDarkTheme ? oneDark : null}
editable={editable}
extensions={extensions}
value={scriptText}
on:change={e => handleChange(e)}
Expand Down
2 changes: 2 additions & 0 deletions src/lib/helpers/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ function skipLoader(config) {
new RegExp('http(s*)://(.*?)/agent/labels', 'g'),
new RegExp('http(s*)://(.*?)/agent/tasks', 'g'),
new RegExp('http(s*)://(.*?)/agent/(.*?)/code-scripts', 'g'),
new RegExp('http(s*)://(.*?)/rule/triggers', 'g'),
new RegExp('http(s*)://(.*?)/rule/config/options', 'g'),
new RegExp('http(s*)://(.*?)/conversation/state/keys', 'g'),
new RegExp('http(s*)://(.*?)/conversation/(.*?)/files/(.*?)', 'g'),
new RegExp('http(s*)://(.*?)/llm-configs', 'g'),
Expand Down
7 changes: 5 additions & 2 deletions src/lib/helpers/types/agentTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
* @property {boolean} disabled
* @property {string?} [visibility_expression]
* @property {UtilityItem[]} items
* @property {boolean} [expanded]
*/

/**
Expand All @@ -212,6 +213,7 @@
* @property {string} server_id
* @property {boolean} disabled
* @property {import('$commonTypes').NameBase[]} functions
* @property {boolean} [expanded]
*/

/**
Expand All @@ -221,20 +223,21 @@
* @property {string?} [displayName]
* @property {boolean} disabled
* @property {number?} [confidence]
* @property {boolean} [expanded]
*/

/**
* @typedef {Object} AgentRule
* @property {string} trigger_name
* @property {string} criteria
* @property {string?} [displayName]
* @property {boolean} disabled
* @property {any?} [config]
* @property {any?} [output_args]
* @property {string?} [json_args]
* @property {string?} [statement]
* @property {boolean} [expanded]
*/


/**
* @typedef {Object} AgentTaskSearchOption
* @property {string?} [agentId]
Expand Down
8 changes: 8 additions & 0 deletions src/lib/scss/custom/common/_common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,12 @@ button:focus {
text-decoration: none !important;
transform: none !important;
}
}

.collapse-toggle {
transition: transform 0.2s ease-in-out;
}

.collapse-toggle.rotated {
transform: rotate(90deg);
}
39 changes: 39 additions & 0 deletions src/lib/scss/custom/pages/_agent.scss
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@
border: 1px dashed var(--bs-primary);
border-radius: 5px;

.config-header {
cursor: pointer;
user-select: none;
outline: none;
}

.config-header:hover h6 {
opacity: 0.8;
}

.llm-config-item {
display: flex;
flex-wrap: wrap;
Expand Down Expand Up @@ -323,6 +333,25 @@
}
}

.agent-rule-config {
min-height: 0px;
max-height: 200px;
}

.rule-config-modal {
.modal-content {
width: 1400px;
max-width: calc(100vw - 2rem);
height: 80vh;
margin: 0 auto;
}

.modal-body {
height: 100%;
box-sizing: border-box;
}
}

.code-editor {
max-height: 500px;
overflow-y: auto;
Expand All @@ -339,6 +368,16 @@
// Responsive adjustments for utility
@media (max-width: 1250px) {
.agent-config-container {
.config-header {
cursor: pointer;
user-select: none;
outline: none;
}

.config-header:hover h6 {
opacity: 0.8;
}

.llm-config-item {
flex-direction: column;

Expand Down
10 changes: 10 additions & 0 deletions src/lib/services/agent-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ export async function getAgentRuleOptions() {
return response.data;
}

/**
* Get agent rule criteria providers
* @returns {Promise<any[]>}
*/
export async function getAgentRuleConfigOptions() {
const url = endpoints.agentRuleConfigOptionsUrl;
const response = await axios.get(url);
return response.data;
}
Comment on lines +118 to +126

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

4. Rule config shape mismatch 🐞 Bug ✓ Correctness

getAgentRuleConfigOptions is documented as returning an array, but the rules UI treats it as an
object keyed by provider name; if the API actually returns an array, configOptions/ruleConfigs will
be built incorrectly and rule config modal cannot resolve provider configs.
Agent Prompt
### Issue description
The UI logic requires `ruleConfigs` to be a map keyed by provider name, but the service is documented to return an array. If the backend response is an array, `ruleConfigs[providerName]` will be `undefined` and the config modal flow breaks.

### Issue Context
This is a contract mismatch between `getAgentRuleConfigOptions()` and `agent-rule.svelte`.

### Fix Focus Areas
- src/lib/services/agent-service.js[118-126]
- src/routes/page/agent/[agentId]/agent-components/rules/agent-rule.svelte[123-136]
- src/routes/page/agent/[agentId]/agent-components/rules/agent-rule.svelte[378-386]

Suggested direction:
- If backend returns a map: update JSDoc to `Promise<Record<string, any>>` (or a typed interface).
- If backend returns an array: convert it in `loadAgentRuleConfigOptions()` into `{ [name]: config }` and build `configOptions` from those names.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


/**
* Get agent labels
* @param {number?} [size]
Expand Down
1 change: 1 addition & 0 deletions src/lib/services/api-endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const endpoints = {
agentCreateUrl: `${host}/agent`,
agentUtilityOptionsUrl: `${host}/agent/utility/options`,
agentRuleOptionsUrl: `${host}/rule/triggers`,
agentRuleConfigOptionsUrl: `${host}/rule/config/options`,
agentLabelsUrl: `${host}/agent/labels`,

// agent code script:
Expand Down
1 change: 1 addition & 0 deletions src/routes/chat/[agentId]/[conversationId]/chat-box.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,7 @@
<CodeScript
language={codeLanguage || 'python'}
scriptText={codeScript}
editable={false}
/>
</PlainModal>

Expand Down
Loading
Loading