@lobu/runtime-device 20.0.0 → 20.0.1

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 (59) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +5 -5
  3. package/npm-shrinkwrap.json +23 -23
  4. package/package.json +1 -1
  5. package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +14 -4
  6. package/vendor/cli/dist/commands/_lib/apply/deployment.js +1 -1
  7. package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +10 -3
  8. package/vendor/cli/dist/commands/_lib/apply/desired-state.js +45 -6
  9. package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +3 -0
  10. package/vendor/cli/dist/commands/_lib/apply/diff.js +10 -3
  11. package/vendor/cli/dist/commands/_lib/apply/map-config.js +17 -12
  12. package/vendor/cli/dist/commands/_lib/apply/shared.d.ts +6 -2
  13. package/vendor/cli/dist/commands/_lib/apply/shared.js +11 -4
  14. package/vendor/cli/dist/commands/call.js +9 -3
  15. package/vendor/cli/dist/commands/dev.js +2 -1
  16. package/vendor/cli/dist/commands/doctor.d.ts +6 -0
  17. package/vendor/cli/dist/commands/doctor.js +26 -0
  18. package/vendor/cli/dist/commands/init.d.ts +3 -1
  19. package/vendor/cli/dist/commands/init.js +26 -15
  20. package/vendor/cli/dist/commands/memory/_lib/mcp.d.ts +0 -6
  21. package/vendor/cli/dist/commands/memory/_lib/mcp.js +1 -14
  22. package/vendor/cli/dist/commands/org.js +8 -0
  23. package/vendor/cli/dist/commands/whoami.d.ts +1 -0
  24. package/vendor/cli/dist/commands/whoami.js +10 -4
  25. package/vendor/cli/dist/config/define.d.ts +21 -6
  26. package/vendor/cli/dist/config/define.js +4 -0
  27. package/vendor/cli/dist/connectors/chat-automation-events.ts +33 -0
  28. package/vendor/cli/dist/connectors/discord.ts +2 -0
  29. package/vendor/cli/dist/connectors/gchat.ts +2 -0
  30. package/vendor/cli/dist/connectors/google_drive.ts +210 -40
  31. package/vendor/cli/dist/connectors/slack-automation-events.ts +0 -31
  32. package/vendor/cli/dist/connectors/slack.ts +2 -2
  33. package/vendor/cli/dist/connectors/teams.ts +2 -0
  34. package/vendor/cli/dist/connectors/telegram.ts +2 -0
  35. package/vendor/cli/dist/connectors/whatsapp.ts +2 -0
  36. package/vendor/cli/dist/index.js +3 -1
  37. package/vendor/cli/dist/internal/gateway-url.d.ts +4 -4
  38. package/vendor/cli/dist/internal/gateway-url.js +4 -4
  39. package/vendor/cli/dist/mac-auth.js +3 -1
  40. package/vendor/cli/dist/runtime-components.json +4 -4
  41. package/vendor/cli/package.json +1 -1
  42. package/vendor/connector-sdk/dist/index.d.ts +1 -1
  43. package/vendor/connector-sdk/dist/logger.js +4 -1
  44. package/vendor/connector-sdk/dist/reaction-sdk.d.ts +9 -0
  45. package/vendor/connector-sdk/package.json +1 -1
  46. package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +13 -1
  47. package/vendor/connector-worker/dist/agent-turn/workspace.d.ts +9 -0
  48. package/vendor/connector-worker/dist/agent-turn/workspace.js +27 -1
  49. package/vendor/connector-worker/dist/daemon/client.d.ts +8 -2
  50. package/vendor/connector-worker/dist/daemon/client.js +3 -2
  51. package/vendor/connector-worker/dist/daemon/poll-loop.d.ts +1 -0
  52. package/vendor/connector-worker/dist/daemon/poll-loop.js +20 -2
  53. package/vendor/connector-worker/package.json +1 -1
  54. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +16 -0
  55. package/vendor/core/dist/contracts/tools/manage-automations.js +12 -3
  56. package/vendor/core/dist/contracts/worker/protocol.d.ts +9 -0
  57. package/vendor/core/dist/contracts/worker/protocol.js +10 -1
  58. package/vendor/core/dist/logger.js +4 -2
  59. package/vendor/core/package.json +1 -1
@@ -6,6 +6,6 @@
6
6
  "connector": "node_modules/@lobu/cli/dist/commands/connector.js",
7
7
  "worker": "node_modules/@lobu/connector-worker/dist/bin.js"
8
8
  },
9
- "version": "20.0.0",
9
+ "version": "20.0.1",
10
10
  "verify": "dist/verify.mjs"
11
11
  }
@@ -64,9 +64,9 @@
64
64
 
65
65
  "@borewit/text-codec": ["@borewit/text-codec@0.2.2", "", {}, "sha512-DDaRehssg1aNrH4+2hnj1B7vnUGEjU6OIlyRdkMd0aUdIUvKXrJfXsy8LVtXAy7DRvYVluWbMspsRhz2lcW0mQ=="],
66
66
 
67
- "@clack/core": ["@clack/core@1.5.0", "", { "dependencies": { "fast-wrap-ansi": "^0.2.0", "sisteransi": "^1.0.5" } }, "sha512-zNikCcd8BbcEvzzG1sbXFrRHFk5kHPrpwZwksPvf9qyQO1Teb7JaXaOAxXZei9nZLDW0gaZawiuTCji88bTBhw=="],
67
+ "@clack/core": ["@clack/core@1.5.1", "", { "dependencies": { "fast-wrap-ansi": "^0.2.0", "sisteransi": "^1.0.5" } }, "sha512-iHTrHA8MtVuLl2TfZySmcKv1qO2PoyC9Z7pfSDozEuV5vtY3/wcOPKJXlqJ5Oq2Cx5DDGQGAMVx6HZfRRoVEbQ=="],
68
68
 
69
- "@clack/prompts": ["@clack/prompts@1.8.0", "", { "dependencies": { "@clack/core": "1.5.0", "fast-string-width": "^3.0.2", "fast-wrap-ansi": "^0.2.0", "sisteransi": "^1.0.5" } }, "sha512-PXzLZ8N34rxmuo4dJg3xtOXhcBse94qGjDqsteoEYrFrrZ5FSjIGwMAuOcv64ln8rHVBBD06XeVGr+/JX+plcA=="],
69
+ "@clack/prompts": ["@clack/prompts@1.8.1", "", { "dependencies": { "@clack/core": "1.5.1", "fast-string-width": "^3.0.2", "fast-wrap-ansi": "^0.2.0", "sisteransi": "^1.0.5" } }, "sha512-dlT1m5e/0yUL0kRNcQn7yGLVThkgbB0Ga/1AmfDDC/8ik6AIiSf2QLQO2zPYvefsHP0aFgxO93cVLCCfDp7kzQ=="],
70
70
 
71
71
  "@colors/colors": ["@colors/colors@1.6.1", "", {}, "sha512-dTmUJzXSuayBK+hZydEaXd2mhx61qWQwkwaBBY6LyEOVx/L9aQU5ac8eFNEsd9nrD1+zb9zvDCphLSe8g1F4Qw=="],
72
72
 
@@ -282,7 +282,7 @@
282
282
 
283
283
  "@tootallnate/quickjs-emscripten": ["@tootallnate/quickjs-emscripten@0.23.0", "", {}, "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA=="],
284
284
 
285
- "@types/node": ["@types/node@22.20.2", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-xlvWf4Vs9n1PEVYwP1n4vvG07M6y8WgvJ2t0vbrWTmijsIHp1cS+uJ2kMIRdY3nHZK0nCYKrPeD171+SzF4/zw=="],
285
+ "@types/node": ["@types/node@26.5.1", "", { "dependencies": { "undici-types": "~8.9.0" } }, "sha512-CzNm2FezW4VR/LjG6yUdiEgLE/rAQ9Slj5gCu/C2VrdcW7I0ahNZ8DRbHT7zOZ6r3ONgd/bsQIeSaoDGrd1C6g=="],
286
286
 
287
287
  "@types/retry": ["@types/retry@0.12.0", "", {}, "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA=="],
288
288
 
@@ -804,7 +804,7 @@
804
804
 
805
805
  "undici": ["undici@7.29.0", "", {}, "sha512-IDxfleLmmbSskfWSUATiN1nfn2rDuvnMOqb5CWR92iIfojA0Ud+ulOAAEQ57LPr9rWmsreUyf5lwyao+7GNNVw=="],
806
806
 
807
- "undici-types": ["undici-types@6.21.0", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="],
807
+ "undici-types": ["undici-types@8.9.0", "", {}, "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg=="],
808
808
 
809
809
  "unicode-emoji-modifier-base": ["unicode-emoji-modifier-base@1.0.0", "", {}, "sha512-yLSH4py7oFH3oG/9K+XWrz1pSi3dfUrWEnInbxMfArOfc1+33BlGPQtLsOYwvdMy11AwUBetYuaRxSPqgkq+8g=="],
810
810
 
@@ -840,7 +840,7 @@
840
840
 
841
841
  "yoctocolors-cjs": ["yoctocolors-cjs@2.1.3", "", {}, "sha512-U/PBtDf35ff0D8X8D0jfdzHYEPFxAI7jJlxZXwCSez5M3190m+QobIfh+sWDWSHMCWWJN2AWamkegn6vr6YBTw=="],
842
842
 
843
- "zod": ["zod@4.6.4", "", {}, "sha512-AXSD6hvGdvRjajG/l1cC+d6IrhH+sjmPKtYeQdJIK8MFJl3LyClzS+o/YsVC+zQZPupAaeH5skwwm8YqYH7BqA=="],
843
+ "zod": ["zod@4.6.5", "", {}, "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q=="],
844
844
 
845
845
  "zod-to-json-schema": ["zod-to-json-schema@3.25.2", "", { "peerDependencies": { "zod": "^3.25.28 || ^4" } }, "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA=="],
846
846
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@lobu/runtime-device",
3
- "version": "20.0.0",
3
+ "version": "20.0.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@lobu/runtime-device",
9
- "version": "20.0.0",
9
+ "version": "20.0.1",
10
10
  "license": "BUSL-1.1",
11
11
  "dependencies": {
12
12
  "@lobu/cli": "file:vendor/cli",
@@ -410,9 +410,9 @@
410
410
  }
411
411
  },
412
412
  "node_modules/@clack/core": {
413
- "version": "1.5.0",
414
- "resolved": "https://registry.npmjs.org/@clack/core/-/core-1.5.0.tgz",
415
- "integrity": "sha512-zNikCcd8BbcEvzzG1sbXFrRHFk5kHPrpwZwksPvf9qyQO1Teb7JaXaOAxXZei9nZLDW0gaZawiuTCji88bTBhw==",
413
+ "version": "1.5.1",
414
+ "resolved": "https://registry.npmjs.org/@clack/core/-/core-1.5.1.tgz",
415
+ "integrity": "sha512-iHTrHA8MtVuLl2TfZySmcKv1qO2PoyC9Z7pfSDozEuV5vtY3/wcOPKJXlqJ5Oq2Cx5DDGQGAMVx6HZfRRoVEbQ==",
416
416
  "license": "MIT",
417
417
  "dependencies": {
418
418
  "fast-wrap-ansi": "^0.2.0",
@@ -423,12 +423,12 @@
423
423
  }
424
424
  },
425
425
  "node_modules/@clack/prompts": {
426
- "version": "1.8.0",
427
- "resolved": "https://registry.npmjs.org/@clack/prompts/-/prompts-1.8.0.tgz",
428
- "integrity": "sha512-PXzLZ8N34rxmuo4dJg3xtOXhcBse94qGjDqsteoEYrFrrZ5FSjIGwMAuOcv64ln8rHVBBD06XeVGr+/JX+plcA==",
426
+ "version": "1.8.1",
427
+ "resolved": "https://registry.npmjs.org/@clack/prompts/-/prompts-1.8.1.tgz",
428
+ "integrity": "sha512-dlT1m5e/0yUL0kRNcQn7yGLVThkgbB0Ga/1AmfDDC/8ik6AIiSf2QLQO2zPYvefsHP0aFgxO93cVLCCfDp7kzQ==",
429
429
  "license": "MIT",
430
430
  "dependencies": {
431
- "@clack/core": "1.5.0",
431
+ "@clack/core": "1.5.1",
432
432
  "fast-string-width": "^3.0.2",
433
433
  "fast-wrap-ansi": "^0.2.0",
434
434
  "sisteransi": "^1.0.5"
@@ -2015,12 +2015,12 @@
2015
2015
  "license": "MIT"
2016
2016
  },
2017
2017
  "node_modules/@types/node": {
2018
- "version": "22.20.2",
2019
- "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.2.tgz",
2020
- "integrity": "sha512-xlvWf4Vs9n1PEVYwP1n4vvG07M6y8WgvJ2t0vbrWTmijsIHp1cS+uJ2kMIRdY3nHZK0nCYKrPeD171+SzF4/zw==",
2018
+ "version": "26.5.1",
2019
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-26.5.1.tgz",
2020
+ "integrity": "sha512-CzNm2FezW4VR/LjG6yUdiEgLE/rAQ9Slj5gCu/C2VrdcW7I0ahNZ8DRbHT7zOZ6r3ONgd/bsQIeSaoDGrd1C6g==",
2021
2021
  "license": "MIT",
2022
2022
  "dependencies": {
2023
- "undici-types": "~6.21.0"
2023
+ "undici-types": "~8.9.0"
2024
2024
  }
2025
2025
  },
2026
2026
  "node_modules/@types/retry": {
@@ -5466,9 +5466,9 @@
5466
5466
  }
5467
5467
  },
5468
5468
  "node_modules/undici-types": {
5469
- "version": "6.21.0",
5470
- "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
5471
- "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
5469
+ "version": "8.9.0",
5470
+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz",
5471
+ "integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==",
5472
5472
  "license": "MIT"
5473
5473
  },
5474
5474
  "node_modules/unicode-emoji-modifier-base": {
@@ -5754,9 +5754,9 @@
5754
5754
  }
5755
5755
  },
5756
5756
  "node_modules/zod": {
5757
- "version": "4.6.4",
5758
- "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.4.tgz",
5759
- "integrity": "sha512-AXSD6hvGdvRjajG/l1cC+d6IrhH+sjmPKtYeQdJIK8MFJl3LyClzS+o/YsVC+zQZPupAaeH5skwwm8YqYH7BqA==",
5757
+ "version": "4.6.5",
5758
+ "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz",
5759
+ "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==",
5760
5760
  "license": "MIT",
5761
5761
  "funding": {
5762
5762
  "url": "https://github.com/sponsors/colinhacks"
@@ -5773,7 +5773,7 @@
5773
5773
  },
5774
5774
  "vendor/cli": {
5775
5775
  "name": "@lobu/cli",
5776
- "version": "20.0.0",
5776
+ "version": "20.0.1",
5777
5777
  "license": "Apache-2.0",
5778
5778
  "dependencies": {
5779
5779
  "@clack/prompts": "^1.2.0",
@@ -5815,7 +5815,7 @@
5815
5815
  },
5816
5816
  "vendor/connector-sdk": {
5817
5817
  "name": "@lobu/connector-sdk",
5818
- "version": "20.0.0",
5818
+ "version": "20.0.1",
5819
5819
  "license": "BUSL-1.1",
5820
5820
  "dependencies": {
5821
5821
  "@lobu/core": "file:../core",
@@ -5830,7 +5830,7 @@
5830
5830
  },
5831
5831
  "vendor/connector-worker": {
5832
5832
  "name": "@lobu/connector-worker",
5833
- "version": "20.0.0",
5833
+ "version": "20.0.1",
5834
5834
  "license": "BUSL-1.1",
5835
5835
  "dependencies": {
5836
5836
  "@agentclientprotocol/sdk": "1.4.0",
@@ -5856,7 +5856,7 @@
5856
5856
  },
5857
5857
  "vendor/core": {
5858
5858
  "name": "@lobu/core",
5859
- "version": "20.0.0",
5859
+ "version": "20.0.1",
5860
5860
  "license": "Apache-2.0",
5861
5861
  "dependencies": {
5862
5862
  "@opentelemetry/api": "^1.9.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/runtime-device",
3
- "version": "20.0.0",
3
+ "version": "20.0.1",
4
4
  "type": "module",
5
5
  "license": "BUSL-1.1",
6
6
  "repository": {
@@ -670,8 +670,8 @@ export async function executePlan(ctx, pendingAuth) {
670
670
  min_cooldown_seconds: w.minCooldownSeconds,
671
671
  tags: w.tags,
672
672
  agent_kind: w.agentKind,
673
- execution_config: w.model !== undefined
674
- ? automationExecutionConfig(w.model)
673
+ execution_config: w.model !== undefined || w.executor !== undefined
674
+ ? automationExecutionConfig(w.model, undefined, w.executor)
675
675
  : undefined,
676
676
  outputs: w.outputs,
677
677
  classifiers: w.classifiers,
@@ -701,7 +701,8 @@ export async function executePlan(ctx, pendingAuth) {
701
701
  // (no prompt/skills) must install the reaction before the trigger
702
702
  // update reaches the server. Push first (idempotent, no drift signal
703
703
  // because it's not returned by Automation lists) so the rule sees it.
704
- // Reaction removal is never pushed — apply only ever sets scripts.
704
+ // Removal (`reaction: null`) is handled in step (b2) below, after the
705
+ // executor install — never here.
705
706
  if (w.reactionScript) {
706
707
  await ctx.client.setReactionScript(automationId, w.reactionScript.sourceCode);
707
708
  }
@@ -730,11 +731,20 @@ export async function executePlan(ctx, pendingAuth) {
730
731
  : {}),
731
732
  ...(scalarForUpdate.includes("execution_config")
732
733
  ? {
733
- execution_config: automationExecutionConfig(w.model, remote?.execution_config),
734
+ execution_config: automationExecutionConfig(w.model, remote?.execution_config, w.executor),
734
735
  }
735
736
  : {}),
736
737
  });
737
738
  }
739
+ // b2) Reaction removal — AFTER the scalar updates above so a stored
740
+ // script executor is installed first. An explicit `reaction: null`
741
+ // clears the row via set_reaction_script(""), so a reaction-driven
742
+ // job switching to a script executor never runs both paths.
743
+ // Omitted reactions are never touched: the diff only reports
744
+ // `reaction_script` when declared.
745
+ if (changed.has("reaction_script") && w.reactionScript === null) {
746
+ await ctx.client.setReactionScript(automationId, "");
747
+ }
738
748
  // c) Version-bound fields → manage_automations create_version (server
739
749
  // inherits unset fields from the previous version row, but we always
740
750
  // send the desired-side values for the changed keys). name/description
@@ -205,7 +205,7 @@ export function buildAttributionAndOwned(state, remote, orgId, prune = false) {
205
205
  // The three-way baseline must record the effective execution_config after
206
206
  // apply (including preserved remote keys), or a later model edit is
207
207
  // misclassified as "remote moved" blocking drift instead of an update.
208
- execution_config: automationExecutionConfig(d.model, r?.execution_config),
208
+ execution_config: automationExecutionConfig(d.model, r?.execution_config, d.executor),
209
209
  outputs: p.outputs,
210
210
  classifiers: p.classifiers,
211
211
  };
@@ -72,6 +72,11 @@ export interface DesiredAutomation {
72
72
  slug: string;
73
73
  /** Owning agent id. Every automation belongs to exactly one agent. */
74
74
  agent: string;
75
+ executor?: {
76
+ kind: "script";
77
+ source: string;
78
+ params?: Record<string, unknown>;
79
+ } | null;
75
80
  name?: string;
76
81
  description?: string;
77
82
  triggers?: DesiredAutomationTrigger[];
@@ -104,11 +109,13 @@ export interface DesiredAutomation {
104
109
  * automation-firing time. Authored as a sibling `.ts` file referenced by
105
110
  * `defineAutomation({ reaction: reactionFromFile("./reactions/foo.reaction.ts") })`;
106
111
  * the CLI reads it and pushes raw source via `set_reaction_script`.
112
+ * Omitted preserves a previously installed reaction; explicit `null`
113
+ * (from `defineAutomation({ reaction: null })`) removes it.
107
114
  */
108
115
  reactionScript?: {
109
116
  sourcePath: string;
110
117
  sourceCode: string;
111
- };
118
+ } | null;
112
119
  /** LLM guidance for the automation's downstream reaction agent. */
113
120
  reactionsGuidance?: string;
114
121
  /** UUID of a device worker to pin this automation's runs to (see `device_workers.id`). */
@@ -400,8 +407,8 @@ export declare function loadProjectConfig(cwd: string): Promise<{
400
407
  /**
401
408
  * Load desired state from a TypeScript entrypoint (`lobu.config.ts`): import the
402
409
  * `defineConfig()` project, map it to `DesiredState`, then attach the
403
- * file-based artifacts (agent-dir markdown + skills, automation reaction scripts,
404
- * local connector source).
410
+ * file-based artifacts (agent-dir markdown + skills, Automation executor and
411
+ * reaction scripts, local connector source).
405
412
  */
406
413
  export declare function loadDesiredStateFromConfig(opts: LoadDesiredStateOptions): Promise<{
407
414
  state: DesiredState;
@@ -574,8 +574,8 @@ export async function loadProjectConfig(cwd) {
574
574
  /**
575
575
  * Load desired state from a TypeScript entrypoint (`lobu.config.ts`): import the
576
576
  * `defineConfig()` project, map it to `DesiredState`, then attach the
577
- * file-based artifacts (agent-dir markdown + skills, automation reaction scripts,
578
- * local connector source).
577
+ * file-based artifacts (agent-dir markdown + skills, Automation executor and
578
+ * reaction scripts, local connector source).
579
579
  */
580
580
  export async function loadDesiredStateFromConfig(opts) {
581
581
  const env = opts.env ?? process.env;
@@ -605,11 +605,42 @@ export async function loadDesiredStateFromConfig(opts) {
605
605
  for (const automation of state.automations) {
606
606
  automation.skillSnapshots = resolveAutomationSkills(automation, skillsByAgentId.get(automation.agent) ?? []);
607
607
  }
608
- // Automation reaction scripts: a sibling `.ts` file referenced by path. The
609
- // mapper stays pure; resolve + read the source here (raw, server compiles
610
- // it) and attach it. state.automations[i] aligns with typedProject.automations[i]
611
- // (the mapper maps them in order).
608
+ // Automation executor and reaction scripts: sibling `.ts` files referenced
609
+ // by path. The mapper stays pure; resolve + read each raw source here for the
610
+ // server to compile. state.automations[i] aligns with
611
+ // typedProject.automations[i] (the mapper maps them in order).
612
612
  (typedProject.automations ?? []).forEach((automation, i) => {
613
+ if (automation.executor !== undefined && automation.executor !== "agent") {
614
+ const desired = state.automations[i];
615
+ if (!desired)
616
+ return;
617
+ if (!automation.executor ||
618
+ typeof automation.executor !== "object" ||
619
+ automation.executor.kind !== "scriptSource" ||
620
+ typeof automation.executor.path !== "string") {
621
+ throw new ValidationError(`Automation "${automation.slug}": use scriptFromFile("./job.ts") for a script executor.`);
622
+ }
623
+ if (automation.executor.params !== undefined &&
624
+ !isRecord(automation.executor.params)) {
625
+ throw new ValidationError(`Automation "${automation.slug}": scriptFromFile params must be an object, not an array.`);
626
+ }
627
+ const script = resolveLocalSourceFile({
628
+ cwd: opts.cwd,
629
+ owner: `Automation ${JSON.stringify(automation.slug)}`,
630
+ field: "executor",
631
+ example: 'scriptFromFile("./job.ts")',
632
+ rel: automation.executor.path,
633
+ maxBytes: 131072,
634
+ sizeHint: "Automation scripts must stay within the sandbox source limit",
635
+ });
636
+ desired.executor = {
637
+ kind: "script",
638
+ source: script.sourceCode,
639
+ ...(automation.executor.params
640
+ ? { params: automation.executor.params }
641
+ : {}),
642
+ };
643
+ }
613
644
  // Gate on absence, not truthiness — a present-but-empty
614
645
  // `reactionFromFile("")` must reach the validator (which rejects it),
615
646
  // matching parseAutomation.
@@ -618,6 +649,14 @@ export async function loadDesiredStateFromConfig(opts) {
618
649
  const dw = state.automations[i];
619
650
  if (!dw)
620
651
  return;
652
+ // Explicit `null` removes a previously installed reaction. Carried through
653
+ // the diff as declared and applied via set_reaction_script("") AFTER the
654
+ // executor install, so a reaction-driven job switching to a script
655
+ // executor never runs both paths. Omitted (`undefined`) preserves.
656
+ if (automation.reaction === null) {
657
+ dw.reactionScript = null;
658
+ return;
659
+ }
621
660
  // `reaction` is typed ReactionSource, but jiti evaluates the config without
622
661
  // typechecking, so a stale `reaction: "./x.reaction.ts"` string slips
623
662
  // through and would read `.path` as undefined. Reject it with a clear
@@ -62,6 +62,8 @@ export interface AutomationDiffRow extends ResourceRow<DesiredAutomation, Remote
62
62
  * True when the desired automation declares a `reaction_script` — server stores
63
63
  * it write-only, so the diff can't tell whether it changed; apply always
64
64
  * re-pushes (idempotent). Matches the auth-profile credentials pattern.
65
+ * An explicit `null` (reaction removal) also counts as declared; apply
66
+ * clears it via `set_reaction_script`.
65
67
  */
66
68
  reactionScriptDeclared?: boolean;
67
69
  }
@@ -273,6 +275,7 @@ export interface RelationshipTypeFacets {
273
275
  */
274
276
  export declare const effectiveRelationshipTypeAfterApply: (d: DesiredRelationshipType, r: RemoteRelationshipType | undefined) => RelationshipTypeFacets;
275
277
  interface AutomationProjection {
278
+ executor?: unknown;
276
279
  agent?: string | null;
277
280
  name?: string | null;
278
281
  description?: string | null;
@@ -847,6 +847,9 @@ function remoteOnlyDefinitionRow(kind, remote, baseline, prune, unchangedSinceBa
847
847
  * use the same defaults as `diffAutomation`.
848
848
  */
849
849
  export const projectDesiredAutomation = (d, remote) => ({
850
+ executor: d.executor !== undefined
851
+ ? d.executor
852
+ : (remote?.execution_config?.executor ?? null),
850
853
  agent: d.agent ?? null,
851
854
  // Name/description are optional in config; the server defaults name to the
852
855
  // slug. Inherit live remote when omitted so a second apply does not
@@ -880,6 +883,7 @@ export const projectDesiredAutomation = (d, remote) => ({
880
883
  classifiers: d.classifiers !== undefined ? d.classifiers : (remote?.classifiers ?? []),
881
884
  });
882
885
  const projectRemoteAutomation = (w) => ({
886
+ executor: w.execution_config?.executor ?? null,
883
887
  agent: w.managed_agent_id ?? null,
884
888
  // `?? null` mirrors projectDesiredAutomation: an unnamed remote Automation must
885
889
  // compare EQUAL to the desired side that inherited it, or deepEqual(null,
@@ -988,7 +992,8 @@ function diffAutomationWithBaseline(desired, remote, baseline) {
988
992
  * The diff returns both lists; apply-cmd routes accordingly.
989
993
  *
990
994
  * Reaction scripts aren't returned by Automation lists (write-only on the row),
991
- * so we can't compare them — apply always re-pushes when declared (idempotent).
995
+ * so we can't compare them — apply always re-pushes when declared (idempotent),
996
+ * and an explicit `null` is a declared removal routed to `set_reaction_script`.
992
997
  * Remote automations without a desired model are reported as drift, never deleted.
993
998
  */
994
999
  function diffAutomation(desired, remote) {
@@ -1025,8 +1030,10 @@ function diffAutomation(desired, remote) {
1025
1030
  desired.agentKind !== (remote.agent_kind ?? undefined)) {
1026
1031
  scalar.push("agent_kind");
1027
1032
  }
1028
- if (desired.model !== undefined &&
1029
- desired.model !== (remote.execution_config?.model ?? null)) {
1033
+ if ((desired.model !== undefined &&
1034
+ desired.model !== (remote.execution_config?.model ?? null)) ||
1035
+ (desired.executor !== undefined &&
1036
+ !deepEqual(desired.executor, remote.execution_config?.executor ?? null))) {
1030
1037
  scalar.push("execution_config");
1031
1038
  }
1032
1039
  const versionBound = [];
@@ -436,14 +436,14 @@ const MAX_AUTOMATION_SKILLS = 5;
436
436
  * content (the incoming message/event), so it may run with zero instructions on
437
437
  * the built-in default. Everything else — schedule triggers, event triggers with
438
438
  * execution "window", and Automations with no triggers at all (manual runs) —
439
- * needs a prompt, at least one skill, or a reaction script.
439
+ * needs a prompt, at least one skill, a reaction script, or a script executor.
440
440
  *
441
441
  * This CLI preflight mirrors the server rule, catching the error against the
442
442
  * config file (naming the slug) rather than as a 422 mid-apply. When both
443
443
  * triggers and instructions change, apply sends them together through
444
444
  * create_version so the final pair is validated atomically.
445
445
  */
446
- function assertAutomationSkills(automation, reactionDeclared) {
446
+ function assertAutomationSkills(automation, instructionSourceDeclared) {
447
447
  const skills = automation.skills ?? [];
448
448
  const duplicates = skills.filter((name, i) => skills.indexOf(name) !== i);
449
449
  if (duplicates.length > 0) {
@@ -462,19 +462,19 @@ function assertAutomationSkills(automation, reactionDeclared) {
462
462
  triggers.some((trigger) => trigger.kind === "schedule" ||
463
463
  (trigger.kind === "event" &&
464
464
  resolvedEventExecution(trigger) === "window"));
465
- // Any one of the three instruction sources satisfies the rule. An Automation
465
+ // Any instruction source satisfies the rule. An Automation
466
466
  // whose whole job is "run this skill" has no task statement to write, one
467
467
  // that spells its task out inline needs no skill, and one that runs entirely
468
- // as a reaction script needs neither — demanding two would be stricter than
469
- // the server and would reject configs the API accepts. The mapper runs
470
- // BEFORE the loader reads the reaction file, so `reactionDeclared` is the
471
- // config marker (present for `reactionFromFile(path)`); the loader validates
472
- // the file and the server enforces the final rule on its source.
468
+ // as a reaction or executor script needs neither — demanding two would be
469
+ // stricter than the server and would reject configs the API accepts. The
470
+ // mapper runs BEFORE the loader reads either file, so this boolean is the
471
+ // config marker; the loader validates the file and the server enforces the
472
+ // final rule on its source.
473
473
  if (requiresSkills &&
474
474
  skills.length === 0 &&
475
475
  !automation.prompt.trim() &&
476
- !reactionDeclared) {
477
- throw new ValidationError(`Automation "${automation.slug}" needs instructions: schedule triggers, event triggers with execution "window", and Automations with no triggers run on stored instructions alone, so give it a "prompt", at least one skill, or a reaction script. Only event triggers with execution "turn" may omit all three.`);
476
+ !instructionSourceDeclared) {
477
+ throw new ValidationError(`Automation "${automation.slug}" needs instructions: schedule triggers, event triggers with execution "window", and Automations with no triggers run on stored instructions alone, so give it a "prompt", at least one skill, a reaction script, or a script executor. Only event triggers with execution "turn" may omit all instruction sources.`);
478
478
  }
479
479
  }
480
480
  function mapAutomation(automation) {
@@ -546,6 +546,7 @@ function mapAutomation(automation) {
546
546
  return {
547
547
  slug: automation.slug,
548
548
  agent: agentId(automation.agent),
549
+ ...(automation.executor === "agent" ? { executor: null } : {}),
549
550
  // The author's task statement, carried straight through. Skill BODIES are
550
551
  // no longer folded in here — the loader resolves them into `skillSnapshots`
551
552
  // (see `resolveAutomationSkills` in desired-state.ts), because the mapper is
@@ -773,8 +774,12 @@ export function mapProjectToDesiredState(project, env = process.env, only) {
773
774
  // The config's `reaction` marker (from `reactionFromFile(path)`) drives the
774
775
  // instruction-presence preflight — the reaction SOURCE is only resolved
775
776
  // later by the loader. `automations` is index-aligned with
776
- // `project.automations` (the mapper maps in order).
777
- assertAutomationSkills(automation, project.automations?.[i]?.reaction !== undefined);
777
+ // `project.automations` (the mapper maps in order). An explicit
778
+ // `reaction: null` is a removal, not an instruction source.
779
+ assertAutomationSkills(automation, (project.automations?.[i]?.reaction !== undefined &&
780
+ project.automations?.[i]?.reaction !== null) ||
781
+ (project.automations?.[i]?.executor !== undefined &&
782
+ project.automations?.[i]?.executor !== "agent"));
778
783
  for (const trigger of automation.triggers ?? []) {
779
784
  if (trigger.kind !== "event" ||
780
785
  trigger.source === "workspace" ||
@@ -30,8 +30,12 @@ export interface AutomationSource {
30
30
  context?: boolean;
31
31
  }
32
32
  export declare function isRecord(value: unknown): value is Record<string, unknown>;
33
- /** A model declaration owns only the model key, preserving other execution options. */
34
- export declare function automationExecutionConfig(model: string | null | undefined, remote?: Record<string, unknown> | null): Record<string, unknown> | null;
33
+ /** Apply declared model/executor fields while preserving unmanaged execution options. */
34
+ export declare function automationExecutionConfig(model: string | null | undefined, remote?: Record<string, unknown> | null, executor?: {
35
+ kind: "script";
36
+ source: string;
37
+ params?: Record<string, unknown>;
38
+ } | null): Record<string, unknown> | null;
35
39
  /**
36
40
  * Keys of locally-declared connector definitions whose key is already known.
37
41
  * A `null` key (an auto-discovered `*.connector.ts` the server compiles) can't
@@ -9,14 +9,21 @@
9
9
  export function isRecord(value) {
10
10
  return typeof value === "object" && value !== null && !Array.isArray(value);
11
11
  }
12
- /** A model declaration owns only the model key, preserving other execution options. */
13
- export function automationExecutionConfig(model, remote) {
14
- if (model === undefined)
12
+ /** Apply declared model/executor fields while preserving unmanaged execution options. */
13
+ export function automationExecutionConfig(model, remote, executor) {
14
+ if (executor) {
15
+ if (model != null)
16
+ throw new Error("Script Automations do not use a model override.");
17
+ return { executor };
18
+ }
19
+ if (model === undefined && executor === undefined)
15
20
  return remote ?? null;
16
21
  const config = { ...remote };
22
+ if (executor === null)
23
+ delete config.executor;
17
24
  if (model === null)
18
25
  delete config.model;
19
- else
26
+ else if (model !== undefined)
20
27
  config.model = model;
21
28
  return Object.keys(config).length > 0 ? config : null;
22
29
  }
@@ -13,9 +13,10 @@
13
13
  * Errors go to stderr with exit code 1 (ApiError) / 2 (validation).
14
14
  */
15
15
  import { readFile } from "node:fs/promises";
16
+ import { resolveApiClient } from "../internal/api-client.js";
16
17
  import { printJson } from "../internal/output.js";
17
18
  import { parseJsonObject, ValidationError } from "./memory/_lib/errors.js";
18
- import { restGet, restToolCall } from "./memory/_lib/mcp.js";
19
+ import { restToolCall } from "./memory/_lib/mcp.js";
19
20
  import { getSessionForOrg, mcpUrlForOrg, resolveOrg, resolveServerUrl, } from "./memory/_lib/memory-auth.js";
20
21
  /** Parse a single `--arg key=value` or `key:=<json>` entry into a [key, value]. */
21
22
  export function parseArgEntry(entry) {
@@ -133,9 +134,13 @@ function printToolList(tools, options) {
133
134
  export async function callCommand(tool, options = {}) {
134
135
  const json = options.json === true;
135
136
  const raw = options.raw === true;
136
- const mcpUrl = await resolveCallEndpoint(options);
137
137
  if (options.list || !tool) {
138
- const result = await restGet(mcpUrl, "tools", options.context);
138
+ const { client, orgSlug } = await resolveApiClient({
139
+ context: options.context,
140
+ org: options.org,
141
+ apiUrl: options.url,
142
+ });
143
+ const result = await client.get(`/api/${encodeURIComponent(orgSlug)}/tools`);
139
144
  const tools = Array.isArray(result?.tools) ? result.tools : [];
140
145
  printToolList(tools, {
141
146
  json,
@@ -144,6 +149,7 @@ export async function callCommand(tool, options = {}) {
144
149
  });
145
150
  return;
146
151
  }
152
+ const mcpUrl = await resolveCallEndpoint(options);
147
153
  const args = await buildArgs(options);
148
154
  const result = await restToolCall(mcpUrl, tool, args, options.context);
149
155
  printJson(result, raw);
@@ -8,6 +8,7 @@ import { isHostedChatPlatform } from "@lobu/core";
8
8
  import chalk from "chalk";
9
9
  import ora from "ora";
10
10
  import { resolveApiClient } from "../internal/api-client.js";
11
+ import { agentApiBase } from "../internal/gateway-url.js";
11
12
  import { addContext, getCurrentContextName, getServerConfig, loadContextConfig, setActiveOrg, setCurrentContext, } from "../internal/context.js";
12
13
  import { saveCredentials } from "../internal/credentials.js";
13
14
  import { parseEnvContent } from "../internal/index.js";
@@ -206,7 +207,7 @@ export async function devCommand(cwd, options = {}) {
206
207
  console.log(chalk.dim(" database: local embedded Postgres"));
207
208
  console.log(chalk.dim(` data: ${join(embeddedDataRoot, ".lobu", "pgdata")}`));
208
209
  }
209
- console.log(chalk.dim(` api docs: ${gatewayUrl}/api/docs`));
210
+ console.log(chalk.dim(` api docs: ${agentApiBase(gatewayUrl)}/api/docs`));
210
211
  console.log();
211
212
  }
212
213
  const logLevel = resolveLogLevel(options);
@@ -1,3 +1,9 @@
1
+ interface Check {
2
+ name: string;
3
+ status: "ok" | "warn" | "fail";
4
+ detail: string;
5
+ }
6
+ export declare function checkInstalledNativeModule(name: string, resolveModule?: (id: string) => string, loadModule?: (id: string) => unknown): Check | null;
1
7
  interface DoctorOptions {
2
8
  memoryOnly?: boolean;
3
9
  cwd?: string;
@@ -1,6 +1,7 @@
1
1
  import { execFileSync } from "node:child_process";
2
2
  import { readFile, stat } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
+ import { createRequire } from "node:module";
4
5
  import chalk from "chalk";
5
6
  import postgres from "postgres";
6
7
  import { checkMemoryHealth } from "./memory/_lib/memory-health.js";
@@ -26,6 +27,28 @@ function checkBinaryExists(name) {
26
27
  return { name, status: "fail", detail: "not found" };
27
28
  }
28
29
  }
30
+ const moduleRequire = createRequire(import.meta.url);
31
+ export function checkInstalledNativeModule(name, resolveModule = moduleRequire.resolve, loadModule = moduleRequire) {
32
+ try {
33
+ resolveModule(`${name}/package.json`);
34
+ }
35
+ catch {
36
+ // Newer/minimal distributions may not include this optional dependency.
37
+ return null;
38
+ }
39
+ try {
40
+ loadModule(name);
41
+ return { name: `native:${name}`, status: "ok", detail: "loadable" };
42
+ }
43
+ catch (error) {
44
+ const detail = error instanceof Error ? error.message : String(error);
45
+ return {
46
+ name: `native:${name}`,
47
+ status: "fail",
48
+ detail: `installed but not loadable: ${detail}`,
49
+ };
50
+ }
51
+ }
29
52
  function checkNodeVersion() {
30
53
  const version = process.version;
31
54
  const support = checkNodeSupport();
@@ -183,6 +206,9 @@ export async function doctorCommand(options = {}) {
183
206
  const checks = [];
184
207
  checks.push(checkNodeVersion());
185
208
  checks.push(checkBinaryExists("git"));
209
+ const sharp = checkInstalledNativeModule("sharp");
210
+ if (sharp)
211
+ checks.push(sharp);
186
212
  const databaseUrl = env.DATABASE_URL ?? process.env.DATABASE_URL;
187
213
  if (databaseUrl && isExternalDatabaseUrl(databaseUrl)) {
188
214
  checks.push(...(await checkDatabaseAndPgvector(databaseUrl)));