Skip to content
Draft
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
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
3 changes: 3 additions & 0 deletions src/lib/helpers/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ 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/criteria-providers', 'g'),
new RegExp('http(s*)://(.*?)/rule/actions', '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
18 changes: 17 additions & 1 deletion src/lib/helpers/types/agentTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,30 @@
/**
* @typedef {Object} AgentRule
* @property {string} trigger_name
* @property {string} criteria
* @property {string?} [displayName]
* @property {boolean} disabled
* @property {AgentRuleCriteria?} [rule_criteria]
* @property {AgentRuleAction?} [rule_action]
* @property {any?} [output_args]
* @property {string?} [json_args]
* @property {string?} [statement]
*/

/**
* @typedef {Object} AgentRuleCriteria
* @property {string?} [name]
* @property {string?} [criteria_text]
* @property {boolean} disabled
* @property {any} [config]
*/

/**
* @typedef {Object} AgentRuleAction
* @property {string?} [name]
* @property {boolean} disabled
* @property {any} [config]
*/


/**
* @typedef {Object} AgentTaskSearchOption
Expand Down
5 changes: 5 additions & 0 deletions src/lib/scss/custom/pages/_agent.scss
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@
}
}

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

.code-editor {
max-height: 500px;
overflow-y: auto;
Expand Down
20 changes: 20 additions & 0 deletions src/lib/services/agent-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,26 @@ export async function getAgentRuleOptions() {
return response.data;
}

/**
* Get agent rule criteria providers
* @returns {Promise<string[]>}
*/
export async function getAgentRuleCriteriaProviders() {
const url = endpoints.agentRuleCriteriaProvidersUrl;
const response = await axios.get(url);
return response.data;
}

/**
* Get agent rule actions
* @returns {Promise<string[]>}
*/
export async function getAgentRuleActions() {
const url = endpoints.agentRuleActionsUrl;
const response = await axios.get(url);
return response.data;
}

/**
* Get agent labels
* @param {number?} [size]
Expand Down
2 changes: 2 additions & 0 deletions src/lib/services/api-endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export const endpoints = {
agentCreateUrl: `${host}/agent`,
agentUtilityOptionsUrl: `${host}/agent/utility/options`,
agentRuleOptionsUrl: `${host}/rule/triggers`,
agentRuleCriteriaProvidersUrl: `${host}/rule/criteria-providers`,
agentRuleActionsUrl: `${host}/rule/actions`,
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 @@ -1662,6 +1662,7 @@
<CodeScript
language={codeLanguage || 'python'}
scriptText={codeScript}
editable={false}
/>
</PlainModal>

Expand Down
Loading