Skip to content

Commit bb525b8

Browse files
authored
Merge pull request #432 from iceljc/features/graph-rule-engine
Features/graph rule engine
2 parents b776f71 + 58583ab commit bb525b8

File tree

25 files changed

+2161
-1551
lines changed

25 files changed

+2161
-1551
lines changed

package-lock.json

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"dependencies": {
4040
"@codemirror/commands": "^6.10.0",
4141
"@codemirror/lang-javascript": "^6.2.4",
42+
"@codemirror/lang-json": "^6.0.2",
4243
"@codemirror/lang-python": "^6.2.1",
4344
"@codemirror/language": "^6.11.3",
4445
"@codemirror/state": "^6.5.2",

src/lib/common/modals/PlainModal.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import { Modal, ModalBody, ModalHeader } from "@sveltestrap/sveltestrap";
2+
import { Modal, ModalBody } from "@sveltestrap/sveltestrap";
33
44
/** @type {boolean} */
55
export let isOpen;
@@ -16,6 +16,9 @@
1616
/** @type {string} */
1717
export let containerStyles = '';
1818
19+
/** @type {string} */
20+
export let bodyStyles = '';
21+
1922
/** @type {() => void} */
2023
export let toggleModal;
2124
</script>
@@ -30,7 +33,7 @@
3033
toggle={() => toggleModal()}
3134
unmountOnClose
3235
>
33-
<ModalBody>
36+
<ModalBody style={bodyStyles}>
3437
<slot />
3538
</ModalBody>
3639
</Modal>

src/lib/common/shared/CodeScript.svelte

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script>
22
import { onMount, createEventDispatcher } from "svelte";
33
import CodeMirror from "svelte-codemirror-editor";
4-
import { keymap } from "@codemirror/view";
4+
import { keymap, lineNumbers } from "@codemirror/view";
55
import { indentUnit, indentOnInput, indentService } from "@codemirror/language";
66
import { defaultKeymap, history, indentWithTab, historyKeymap } from "@codemirror/commands";
77
import { EditorState } from "@codemirror/state";
@@ -20,14 +20,23 @@
2020
/** @type {string} */
2121
export let containerClasses = '';
2222
23+
/** @type {boolean} */
24+
export let useDarkTheme = true;
25+
26+
/** @type {boolean} */
27+
export let hideLineNumber = false;
28+
29+
/** @type {boolean} */
30+
export let editable = true;
31+
2332
2433
/** @type {import("@codemirror/state").Extension[]} */
2534
const baseExtensions = [
2635
indentUnit.of(" "),
2736
EditorState.tabSize.of(4),
2837
indentOnInput(),
2938
history(),
30-
keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab])
39+
keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]),
3140
];
3241
3342
/** @type {import("@codemirror/state").Extension[]} */
@@ -59,6 +68,17 @@
5968
javascript(),
6069
...baseExtensions
6170
];
71+
} else {
72+
extensions = [
73+
...baseExtensions
74+
];
75+
}
76+
77+
if (hideLineNumber) {
78+
extensions = [
79+
lineNumbers({ formatNumber: () => "" }),
80+
...extensions
81+
];
6282
}
6383
});
6484
@@ -73,8 +93,9 @@
7393

7494
<CodeMirror
7595
class={`code-script-container ${containerClasses}`}
76-
theme={oneDark}
7796
lineWrapping
97+
theme={useDarkTheme ? oneDark : null}
98+
editable={editable}
7899
extensions={extensions}
79100
value={scriptText}
80101
on:change={e => handleChange(e)}

src/lib/helpers/http.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ function skipLoader(config) {
233233
new RegExp('http(s*)://(.*?)/agent/labels', 'g'),
234234
new RegExp('http(s*)://(.*?)/agent/tasks', 'g'),
235235
new RegExp('http(s*)://(.*?)/agent/(.*?)/code-scripts', 'g'),
236+
new RegExp('http(s*)://(.*?)/rule/triggers', 'g'),
237+
new RegExp('http(s*)://(.*?)/rule/config/options', 'g'),
236238
new RegExp('http(s*)://(.*?)/conversation/state/keys', 'g'),
237239
new RegExp('http(s*)://(.*?)/conversation/(.*?)/files/(.*?)', 'g'),
238240
new RegExp('http(s*)://(.*?)/llm-configs', 'g'),

src/lib/helpers/types/agentTypes.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@
194194
* @property {boolean} disabled
195195
* @property {string?} [visibility_expression]
196196
* @property {UtilityItem[]} items
197+
* @property {boolean} [expanded]
197198
*/
198199

199200
/**
@@ -212,6 +213,7 @@
212213
* @property {string} server_id
213214
* @property {boolean} disabled
214215
* @property {import('$commonTypes').NameBase[]} functions
216+
* @property {boolean} [expanded]
215217
*/
216218

217219
/**
@@ -221,20 +223,21 @@
221223
* @property {string?} [displayName]
222224
* @property {boolean} disabled
223225
* @property {number?} [confidence]
226+
* @property {boolean} [expanded]
224227
*/
225228

226229
/**
227230
* @typedef {Object} AgentRule
228231
* @property {string} trigger_name
229-
* @property {string} criteria
230232
* @property {string?} [displayName]
231233
* @property {boolean} disabled
234+
* @property {any?} [config]
232235
* @property {any?} [output_args]
233236
* @property {string?} [json_args]
234237
* @property {string?} [statement]
238+
* @property {boolean} [expanded]
235239
*/
236240

237-
238241
/**
239242
* @typedef {Object} AgentTaskSearchOption
240243
* @property {string?} [agentId]

src/lib/scss/custom/common/_common.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,12 @@ button:focus {
225225
text-decoration: none !important;
226226
transform: none !important;
227227
}
228+
}
229+
230+
.collapse-toggle {
231+
transition: transform 0.2s ease-in-out;
232+
}
233+
234+
.collapse-toggle.rotated {
235+
transform: rotate(90deg);
228236
}

src/lib/scss/custom/pages/_agent.scss

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,16 @@
175175
border: 1px dashed var(--bs-primary);
176176
border-radius: 5px;
177177

178+
.config-header {
179+
cursor: pointer;
180+
user-select: none;
181+
outline: none;
182+
}
183+
184+
.config-header:hover h6 {
185+
opacity: 0.8;
186+
}
187+
178188
.llm-config-item {
179189
display: flex;
180190
flex-wrap: wrap;
@@ -323,6 +333,25 @@
323333
}
324334
}
325335

336+
.agent-rule-config {
337+
min-height: 0px;
338+
max-height: 200px;
339+
}
340+
341+
.rule-config-modal {
342+
.modal-content {
343+
width: 1400px;
344+
max-width: calc(100vw - 2rem);
345+
height: 80vh;
346+
margin: 0 auto;
347+
}
348+
349+
.modal-body {
350+
height: 100%;
351+
box-sizing: border-box;
352+
}
353+
}
354+
326355
.code-editor {
327356
max-height: 500px;
328357
overflow-y: auto;
@@ -339,6 +368,16 @@
339368
// Responsive adjustments for utility
340369
@media (max-width: 1250px) {
341370
.agent-config-container {
371+
.config-header {
372+
cursor: pointer;
373+
user-select: none;
374+
outline: none;
375+
}
376+
377+
.config-header:hover h6 {
378+
opacity: 0.8;
379+
}
380+
342381
.llm-config-item {
343382
flex-direction: column;
344383

src/lib/services/agent-service.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ export async function getAgentRuleOptions() {
115115
return response.data;
116116
}
117117

118+
/**
119+
* Get agent rule config options
120+
* @returns {Promise<any>}
121+
*/
122+
export async function getAgentRuleConfigOptions() {
123+
const url = endpoints.agentRuleConfigOptionsUrl;
124+
const response = await axios.get(url);
125+
return response.data;
126+
}
127+
118128
/**
119129
* Get agent labels
120130
* @param {number?} [size]

src/lib/services/api-endpoints.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const endpoints = {
4040
agentCreateUrl: `${host}/agent`,
4141
agentUtilityOptionsUrl: `${host}/agent/utility/options`,
4242
agentRuleOptionsUrl: `${host}/rule/triggers`,
43+
agentRuleConfigOptionsUrl: `${host}/rule/config/options`,
4344
agentLabelsUrl: `${host}/agent/labels`,
4445

4546
// agent code script:

0 commit comments

Comments
 (0)