@saltcorn/agents 0.6.6 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/skills/RunJsCode.js +17 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/agents",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "description": "AI agents for Saltcorn",
5
5
  "main": "index.js",
6
6
  "dependencies": {
@@ -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
- ? [userIds]
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 || []).forEach((arg) => {
195
- properties[arg.name] = {
196
- description: arg.description,
197
- type: arg.argtype,
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.req });
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" ? response : JSON.stringify(response)
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
  },