@saltcorn/agents 0.7.12 → 0.7.14

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/agent-view.js CHANGED
@@ -1475,10 +1475,15 @@ const execute_user_action = async (
1475
1475
  const dyn_updates = getState().getConfig("enable_dynamic_updates", true);
1476
1476
 
1477
1477
  if (dyn_updates && uadata.click_replace_text) {
1478
+ const { layout } = config;
1479
+
1480
+ const resp = JSON.stringify(
1481
+ wrapSegment(uadata.click_replace_text, "You", true, layout),
1482
+ );
1478
1483
  getState().emitDynamicUpdate(
1479
1484
  db.getTenantSchema(),
1480
1485
  {
1481
- eval_js: `spin_send_button();${`$("button[data-useraction-id=${uadata.rndid}]").replaceWith("${uadata.click_replace_text}")`}`,
1486
+ eval_js: `spin_send_button();$("button[data-useraction-id=${uadata.rndid}]").replaceWith("");processCopilotResponse({response: ${resp}, run_id: ${run.id}}, true)`,
1482
1487
  page_load_tag: req?.headers?.["page-load-tag"],
1483
1488
  },
1484
1489
  [req.user.id],
@@ -1498,13 +1503,20 @@ const execute_user_action = async (
1498
1503
  );
1499
1504
  await run.update({ context: run.context });
1500
1505
  }
1506
+ let row = {};
1507
+ if (run.context.triggering_row_id) {
1508
+ const table = Table.findOne(table_id);
1509
+ const pk = table?.pk_name;
1510
+ if (table)
1511
+ row = await table.getRow({ [pk]: run.context.triggering_row_id });
1512
+ }
1501
1513
  await process_interaction(
1502
1514
  run,
1503
1515
  action.configuration,
1504
1516
  req,
1505
1517
  action.name,
1506
1518
  [],
1507
- {}, //row?
1519
+ row,
1508
1520
  config,
1509
1521
  dyn_updates,
1510
1522
  );
package/common.js CHANGED
@@ -407,7 +407,12 @@ const process_interaction = async (
407
407
  if (rendered)
408
408
  add_response(
409
409
  wrapSegment(
410
- wrapCard(response_label, rendered),
410
+ wrapCard(
411
+ response_label,
412
+ typeof rendered === "string"
413
+ ? md.render(rendered)
414
+ : rendered,
415
+ ),
411
416
  agent_label,
412
417
  false,
413
418
  layout,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/agents",
3
- "version": "0.7.12",
3
+ "version": "0.7.14",
4
4
  "description": "AI agents for Saltcorn",
5
5
  "main": "index.js",
6
6
  "dependencies": {
@@ -64,8 +64,6 @@ class PlanApprovalSkill {
64
64
  return {
65
65
  type: "function",
66
66
  process: async (row) => {
67
- console.log("process plan row", row);
68
-
69
67
  return {
70
68
  stop: true,
71
69
  add_response: row.plan,