@saltcorn/agents 0.6.5 → 0.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +14 -0
- package/package.json +1 -1
- package/skills/RunJsCode.js +17 -13
package/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const {
|
|
|
7
7
|
get_skills,
|
|
8
8
|
getCompletionArguments,
|
|
9
9
|
process_interaction,
|
|
10
|
+
get_skill_instances,
|
|
10
11
|
} = require("./common");
|
|
11
12
|
const { applyAsync } = require("@saltcorn/data/utils");
|
|
12
13
|
const WorkflowRun = require("@saltcorn/data/models/workflow_run");
|
|
@@ -49,9 +50,22 @@ module.exports = {
|
|
|
49
50
|
user,
|
|
50
51
|
row,
|
|
51
52
|
);
|
|
53
|
+
const skills = get_skill_instances(action.configuration);
|
|
54
|
+
const skill_tools = [];
|
|
55
|
+
for (const skill of skills) {
|
|
56
|
+
const skillTools = skill.provideTools?.();
|
|
57
|
+
const tools = !skillTools
|
|
58
|
+
? []
|
|
59
|
+
: Array.isArray(skillTools)
|
|
60
|
+
? skillTools
|
|
61
|
+
: [skillTools];
|
|
62
|
+
skill_tools.push(...tools);
|
|
63
|
+
}
|
|
52
64
|
return {
|
|
53
65
|
...complArgs,
|
|
54
66
|
action,
|
|
67
|
+
skills,
|
|
68
|
+
skill_tools,
|
|
55
69
|
};
|
|
56
70
|
},
|
|
57
71
|
isAsync: true,
|
package/package.json
CHANGED
package/skills/RunJsCode.js
CHANGED
|
@@ -48,15 +48,15 @@ class RunJsCodeSkill {
|
|
|
48
48
|
if (!enabled) {
|
|
49
49
|
sysState.log(
|
|
50
50
|
5,
|
|
51
|
-
"emit_to_client called, but dynamic updates are disabled"
|
|
51
|
+
"emit_to_client called, but dynamic updates are disabled",
|
|
52
52
|
);
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
const safeIds = Array.isArray(userIds)
|
|
56
56
|
? userIds
|
|
57
57
|
: userIds
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
? [userIds]
|
|
59
|
+
: [];
|
|
60
60
|
sysState.emitDynamicUpdate(db.getTenantSchema(), data, safeIds);
|
|
61
61
|
},
|
|
62
62
|
tryCatchInTransaction: db.tryCatchInTransaction,
|
|
@@ -184,23 +184,25 @@ class RunJsCodeSkill {
|
|
|
184
184
|
class: ["btn btn-outline-secondary btn-sm me-1", klass],
|
|
185
185
|
onclick: `view_post('${viewname}', 'skillroute', {skillid: '${this.skillid}', triggering_row_id: $('input[name=triggering_row_id').val(), run_id: get_run_id(this)});`,
|
|
186
186
|
},
|
|
187
|
-
this.button_label
|
|
187
|
+
this.button_label,
|
|
188
188
|
);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
provideTools = () => {
|
|
192
192
|
if (this.mode === "Button") return;
|
|
193
193
|
let properties = {};
|
|
194
|
-
(this.toolargs || [])
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
194
|
+
(this.toolargs || [])
|
|
195
|
+
.filter((arg) => arg.name)
|
|
196
|
+
.forEach((arg) => {
|
|
197
|
+
properties[arg.name] = {
|
|
198
|
+
description: arg.description,
|
|
199
|
+
type: arg.argtype,
|
|
200
|
+
};
|
|
201
|
+
});
|
|
200
202
|
return {
|
|
201
203
|
type: "function",
|
|
202
204
|
process: async (row, { req }) => {
|
|
203
|
-
return await this.runCode({ row, user: req.user
|
|
205
|
+
return await this.runCode({ row, user: req.user });
|
|
204
206
|
},
|
|
205
207
|
/*renderToolCall({ phrase }, { req }) {
|
|
206
208
|
return div({ class: "border border-primary p-2 m-2" }, phrase);
|
|
@@ -209,7 +211,9 @@ class RunJsCodeSkill {
|
|
|
209
211
|
? async (response, { req }) => {
|
|
210
212
|
return div(
|
|
211
213
|
{ class: "border border-success p-2 m-2" },
|
|
212
|
-
typeof response === "string"
|
|
214
|
+
typeof response === "string"
|
|
215
|
+
? response
|
|
216
|
+
: JSON.stringify(response),
|
|
213
217
|
);
|
|
214
218
|
}
|
|
215
219
|
: undefined,
|
|
@@ -218,7 +222,7 @@ class RunJsCodeSkill {
|
|
|
218
222
|
description: this.tool_description,
|
|
219
223
|
parameters: {
|
|
220
224
|
type: "object",
|
|
221
|
-
required: (this.toolargs || []).map((a) => a.name),
|
|
225
|
+
required: (this.toolargs || []).filter((arg) => arg.name).map((a) => a.name),
|
|
222
226
|
properties,
|
|
223
227
|
},
|
|
224
228
|
},
|