@openclaw-cloud/agent-controller 3.0.0-beta.2 → 3.0.0-beta.20

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 (166) hide show
  1. package/bin/agent-controller.js +5 -9
  2. package/dist/api.d.ts +16 -0
  3. package/dist/api.js.map +1 -1
  4. package/dist/commands/agent-update-cli.js +23 -38
  5. package/dist/commands/agent-update-cli.js.map +1 -1
  6. package/dist/commands/backup-cli.js +6 -4
  7. package/dist/commands/backup-cli.js.map +1 -1
  8. package/dist/commands/bootstrap.d.ts +10 -1
  9. package/dist/commands/bootstrap.js +33 -73
  10. package/dist/commands/bootstrap.js.map +1 -1
  11. package/dist/commands/channel-server.js +4 -3
  12. package/dist/commands/channel-server.js.map +1 -1
  13. package/dist/commands/heartbeat-cli.js +2 -6
  14. package/dist/commands/heartbeat-cli.js.map +1 -1
  15. package/dist/commands/install-deps.d.ts +10 -0
  16. package/dist/commands/install-deps.js +33 -43
  17. package/dist/commands/install-deps.js.map +1 -1
  18. package/dist/commands/knowledge-sync-cli.js +6 -4
  19. package/dist/commands/knowledge-sync-cli.js.map +1 -1
  20. package/dist/commands/plugin-update-cli.js +4 -8
  21. package/dist/commands/plugin-update-cli.js.map +1 -1
  22. package/dist/commands/self-update.d.ts +1 -0
  23. package/dist/commands/self-update.js +76 -37
  24. package/dist/commands/self-update.js.map +1 -1
  25. package/dist/commands/update-skills.js +7 -6
  26. package/dist/commands/update-skills.js.map +1 -1
  27. package/dist/config-file.d.ts +24 -0
  28. package/dist/config-file.js +56 -20
  29. package/dist/config-file.js.map +1 -1
  30. package/dist/config.d.ts +4 -0
  31. package/dist/config.js +12 -0
  32. package/dist/config.js.map +1 -1
  33. package/dist/connection.d.ts +4 -0
  34. package/dist/connection.js +50 -5
  35. package/dist/connection.js.map +1 -1
  36. package/dist/handlers/agent-update.d.ts +4 -0
  37. package/dist/handlers/agent-update.js +16 -44
  38. package/dist/handlers/agent-update.js.map +1 -1
  39. package/dist/handlers/deploy.d.ts +1 -2
  40. package/dist/handlers/deploy.js +4 -20
  41. package/dist/handlers/deploy.js.map +1 -1
  42. package/dist/handlers/diagnostics.js +0 -12
  43. package/dist/handlers/diagnostics.js.map +1 -1
  44. package/dist/handlers/file-delete.js +4 -5
  45. package/dist/handlers/file-delete.js.map +1 -1
  46. package/dist/handlers/file-write.js +4 -4
  47. package/dist/handlers/file-write.js.map +1 -1
  48. package/dist/handlers/knowledge-sync.js +2 -14
  49. package/dist/handlers/knowledge-sync.js.map +1 -1
  50. package/dist/handlers/memory.d.ts +11 -1
  51. package/dist/handlers/memory.js.map +1 -1
  52. package/dist/handlers/onboarding.d.ts +1 -2
  53. package/dist/handlers/onboarding.js +3 -20
  54. package/dist/handlers/onboarding.js.map +1 -1
  55. package/dist/handlers/package-install.js +1 -1
  56. package/dist/handlers/package-install.js.map +1 -1
  57. package/dist/handlers/pair.js +0 -12
  58. package/dist/handlers/pair.js.map +1 -1
  59. package/dist/handlers/restart.d.ts +1 -2
  60. package/dist/handlers/restart.js +3 -8
  61. package/dist/handlers/restart.js.map +1 -1
  62. package/dist/handlers/slack-event.d.ts +13 -0
  63. package/dist/handlers/slack-event.js +40 -0
  64. package/dist/handlers/slack-event.js.map +1 -0
  65. package/dist/handlers/stop.js +0 -7
  66. package/dist/handlers/stop.js.map +1 -1
  67. package/dist/handlers/telegram-webhook.js +3 -22
  68. package/dist/handlers/telegram-webhook.js.map +1 -1
  69. package/dist/handlers/update-config.js +4 -13
  70. package/dist/handlers/update-config.js.map +1 -1
  71. package/dist/heartbeat.d.ts +7 -1
  72. package/dist/heartbeat.js +35 -6
  73. package/dist/heartbeat.js.map +1 -1
  74. package/dist/index.d.ts +0 -8
  75. package/dist/index.js +87 -119
  76. package/dist/index.js.map +1 -1
  77. package/dist/lockfile.js +2 -1
  78. package/dist/lockfile.js.map +1 -1
  79. package/dist/platform/linux.js +6 -5
  80. package/dist/platform/linux.js.map +1 -1
  81. package/dist/platform/macos.js +3 -2
  82. package/dist/platform/macos.js.map +1 -1
  83. package/dist/platform/windows.js +3 -2
  84. package/dist/platform/windows.js.map +1 -1
  85. package/dist/providers/claude-code/channel-server.js +2 -1
  86. package/dist/providers/claude-code/channel-server.js.map +1 -1
  87. package/dist/providers/claude-code/settings-writer.d.ts +3 -2
  88. package/dist/providers/claude-code/settings-writer.js +6 -15
  89. package/dist/providers/claude-code/settings-writer.js.map +1 -1
  90. package/dist/providers/index.d.ts +13 -0
  91. package/dist/providers/index.js +25 -0
  92. package/dist/providers/index.js.map +1 -1
  93. package/dist/providers/openclaw/gateway-adapter.js +2 -0
  94. package/dist/providers/openclaw/gateway-adapter.js.map +1 -1
  95. package/dist/providers/openclaw/gateway-client.js +6 -1
  96. package/dist/providers/openclaw/gateway-client.js.map +1 -1
  97. package/dist/providers/openclaw/index.js +11 -13
  98. package/dist/providers/openclaw/index.js.map +1 -1
  99. package/dist/slack-relay-server.d.ts +48 -0
  100. package/dist/slack-relay-server.js +197 -0
  101. package/dist/slack-relay-server.js.map +1 -0
  102. package/dist/types.d.ts +16 -1
  103. package/dist/utils/anthropic-auth.d.ts +14 -0
  104. package/dist/utils/anthropic-auth.js +24 -0
  105. package/dist/utils/anthropic-auth.js.map +1 -1
  106. package/dist/utils/apply-config.d.ts +65 -12
  107. package/dist/utils/apply-config.js +295 -100
  108. package/dist/utils/apply-config.js.map +1 -1
  109. package/dist/utils/claude-env.d.ts +6 -0
  110. package/dist/utils/claude-env.js +29 -28
  111. package/dist/utils/claude-env.js.map +1 -1
  112. package/dist/utils/config-merge-paths.d.ts +15 -1
  113. package/dist/utils/config-merge-paths.js +17 -3
  114. package/dist/utils/config-merge-paths.js.map +1 -1
  115. package/dist/utils/deploy-type.d.ts +16 -0
  116. package/dist/utils/deploy-type.js +34 -0
  117. package/dist/utils/deploy-type.js.map +1 -0
  118. package/dist/utils/env.d.ts +0 -1
  119. package/dist/utils/env.js +0 -8
  120. package/dist/utils/env.js.map +1 -1
  121. package/dist/utils/exec.d.ts +11 -0
  122. package/dist/utils/exec.js +47 -1
  123. package/dist/utils/exec.js.map +1 -1
  124. package/dist/utils/gateway-restart-handler.d.ts +6 -2
  125. package/dist/utils/gateway-restart-handler.js +11 -2
  126. package/dist/utils/gateway-restart-handler.js.map +1 -1
  127. package/dist/utils/gateway-restart.d.ts +7 -0
  128. package/dist/utils/gateway-restart.js +12 -4
  129. package/dist/utils/gateway-restart.js.map +1 -1
  130. package/dist/utils/knowledge-graph.d.ts +13 -1
  131. package/dist/utils/knowledge-graph.js +75 -29
  132. package/dist/utils/knowledge-graph.js.map +1 -1
  133. package/dist/utils/legacy-mcp-servers.d.ts +12 -0
  134. package/dist/utils/legacy-mcp-servers.js +37 -0
  135. package/dist/utils/legacy-mcp-servers.js.map +1 -0
  136. package/dist/utils/log-collector.js +2 -1
  137. package/dist/utils/log-collector.js.map +1 -1
  138. package/dist/utils/openclaw-ops.d.ts +45 -3
  139. package/dist/utils/openclaw-ops.js +94 -15
  140. package/dist/utils/openclaw-ops.js.map +1 -1
  141. package/dist/utils/openclaw-stack-update.d.ts +31 -0
  142. package/dist/utils/openclaw-stack-update.js +50 -0
  143. package/dist/utils/openclaw-stack-update.js.map +1 -0
  144. package/dist/utils/package-install.js +4 -12
  145. package/dist/utils/package-install.js.map +1 -1
  146. package/dist/utils/package-version.d.ts +10 -0
  147. package/dist/utils/package-version.js +18 -0
  148. package/dist/utils/package-version.js.map +1 -0
  149. package/dist/utils/parse-id-at-version.d.ts +15 -0
  150. package/dist/utils/parse-id-at-version.js +22 -0
  151. package/dist/utils/parse-id-at-version.js.map +1 -0
  152. package/dist/utils/plugin-reconcile.d.ts +46 -0
  153. package/dist/utils/plugin-reconcile.js +201 -0
  154. package/dist/utils/plugin-reconcile.js.map +1 -0
  155. package/dist/utils/response.js +1 -0
  156. package/dist/utils/response.js.map +1 -1
  157. package/dist/utils/write-home-files.d.ts +27 -0
  158. package/dist/utils/write-home-files.js +72 -0
  159. package/dist/utils/write-home-files.js.map +1 -0
  160. package/dist/utils/write-workspace-files.d.ts +1 -1
  161. package/dist/utils/write-workspace-files.js +19 -7
  162. package/dist/utils/write-workspace-files.js.map +1 -1
  163. package/dist/workspace.d.ts +11 -0
  164. package/dist/workspace.js +20 -0
  165. package/dist/workspace.js.map +1 -1
  166. package/package.json +9 -4
@@ -10,4 +10,28 @@ export function classifyAnthropicAuth(input) {
10
10
  return { kind: 'auth_token', value: apiKey };
11
11
  return { kind: 'api_key', value: apiKey };
12
12
  }
13
+ /** The permissions block both Claude settings writers emit, verbatim. */
14
+ export const CLAUDE_PERMISSIONS = {
15
+ allow: ['Bash(*)', 'Read(*)', 'Write(*)', 'Edit(*)', 'mcp__*'],
16
+ };
17
+ /**
18
+ * The settings.json base shared by both writers: the permissions block plus the
19
+ * `env` entry the auth classification implies.
20
+ *
21
+ * `providers/claude-code/settings-writer.ts` uses this as its complete output;
22
+ * `utils/claude-env.ts` uses it for the OAuth branch and composes its own
23
+ * apiKeyHelper variant for the API-key branch (that flow reads the key out of
24
+ * the VM `.env` at runtime instead of embedding it).
25
+ */
26
+ export function buildClaudeSettings(auth) {
27
+ switch (auth.kind) {
28
+ case 'auth_token':
29
+ return { permissions: CLAUDE_PERMISSIONS, env: { ANTHROPIC_AUTH_TOKEN: auth.value } };
30
+ case 'api_key':
31
+ return { permissions: CLAUDE_PERMISSIONS, env: { ANTHROPIC_API_KEY: auth.value } };
32
+ case 'none':
33
+ // No static credentials: rely on ~/.claude/.credentials.json (subscription login).
34
+ return { permissions: CLAUDE_PERMISSIONS };
35
+ }
36
+ }
13
37
  //# sourceMappingURL=anthropic-auth.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic-auth.js","sourceRoot":"","sources":["../../src/utils/anthropic-auth.ts"],"names":[],"mappings":"AAiBA,MAAM,UAAU,qBAAqB,CAAC,KAGrC;IACC,MAAM,SAAS,GAAG,KAAK,CAAC,kBAAkB,EAAE,IAAI,EAAE,CAAC;IACnD,IAAI,SAAS;QAAE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;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAmB;IACrD,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,YAAY;YACf,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,GAAG,EAAE,EAAE,oBAAoB,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;QACxF,KAAK,SAAS;YACZ,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,GAAG,EAAE,EAAE,iBAAiB,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;QACrF,KAAK,MAAM;YACT,mFAAmF;YACnF,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAC/C,CAAC;AACH,CAAC"}
@@ -1,14 +1,29 @@
1
- import type { BootstrapResult } from '../api.js';
1
+ import type { AgentApi, BootstrapResult } from '../api.js';
2
+ /** Canonical openclaw.json location — `<stateDir>/openclaw.json`. */
3
+ export declare function getOpenclawJsonPath(): string;
2
4
  /**
3
- * Apply config from bootstrap API response:
5
+ * The ONE writer for openclaw.json — atomic (tmp + rename) and mode 0600.
6
+ *
7
+ * Both properties are load-bearing and used to be split across three
8
+ * independent write sites: the full apply wrote 0600 but non-atomically (a
9
+ * reader could see a truncated file), the scoped merge wrote atomically but
10
+ * with no mode (tmp + rename RESETS a pre-existing 0600 file to 0644, leaking
11
+ * `models.providers[*].apiKey`), and the startup memory-MCP injection did
12
+ * neither. Everything goes through here now.
13
+ */
14
+ export declare function writeOpenclawJson(data: Record<string, unknown>): Promise<void>;
15
+ /**
16
+ * FULL apply — only ever legal on a managed install (see `isManagedDeploy`).
17
+ * Rewrites files wholesale:
4
18
  * 1. Write openclaw.json
5
- * 2. Write auth-profiles.json + settings.json (from envVars)
6
- * 3. Write .env (for VM agents)
7
- * 4. Restart gateway
19
+ * 2. Write workspace files + skills
20
+ * 3. Write auth-profiles.json + settings.json (from envVars)
21
+ * 4. MERGE .env (for VM agents) — never a wholesale replace, see step 4 below
22
+ * 5. Restart gateway
8
23
  */
9
24
  export declare function applyBootstrapConfig(data: BootstrapResult): Promise<void>;
10
- type MergeOutcome = 'added' | 'equal' | 'conflict' | 'merged';
11
- interface MergeResult {
25
+ type MergeOutcome = 'added' | 'equal' | 'conflict' | 'merged' | 'overwritten';
26
+ export interface MergeResult {
12
27
  changed: boolean;
13
28
  outcomes: Array<{
14
29
  path: string;
@@ -26,12 +41,50 @@ interface MergeResult {
26
41
  * - Missing local value → remote is written.
27
42
  * - Equal values → no-op.
28
43
  * - Differing values → conflict, local wins, warn+skip logged.
29
- * - For `mcp.servers` (and other object paths): conflict detection is
30
- * per-key inside the dict.
31
- * - Does NOT restart the gateway (standalone owns their own lifecycle).
32
- * - Settings.json (~/.claude/settings.json) gets the same treatment for
33
- * `mcp.servers` and `env` only — apiKeyHelper/permissions/etc untouched.
44
+ * - For object paths: conflict detection is per-key inside the dict.
45
+ * - **Exception — `mcp.servers` in openclaw.json is REMOTE-wins per key.**
46
+ * That section is backend-managed: the URL, transport and bearer token of a
47
+ * backend-generated server (e.g. `openclaw-cloud`) change over time, and
48
+ * under local-wins an updated entry could never reach a standalone agent —
49
+ * a rotated token was skipped forever (observed live 2026-08-02). Every
50
+ * server NAME present in the payload is overwritten; names that exist only
51
+ * locally are left untouched.
52
+ * LIMITATION — no deletions. A server removed in the backend stays in the
53
+ * local openclaw.json: the payload cannot distinguish "removed upstream"
54
+ * from "never managed here", and dropping local-only entries would delete
55
+ * the user's own servers. Removal on standalone is a manual edit.
56
+ * - Restarts the gateway **iff** the `mcp.servers` subtree actually changed.
57
+ * This is a FALLBACK, not the primary delivery mechanism: openclaw 2026.7.1
58
+ * does self-reload this section (verified live 2026-08-03 — the gateway
59
+ * logged `[reload] config hot reload applied (mcp.servers.<name>.url,
60
+ * mcp.servers.<name>.headers)` on an overwrite, with no restart). The
61
+ * restart covers builds/paths where that self-reload does not fire, and
62
+ * mirrors what applyBootstrapConfig does on managed installs. It is
63
+ * best-effort: a failure is logged and does not fail the apply — on a
64
+ * launchd box where `openclaw` is not on the service PATH it never runs at
65
+ * all, and the merge still lands.
66
+ * - Settings.json (~/.claude/settings.json) keeps LOCAL-wins for
67
+ * `mcp.servers` ONLY — apiKeyHelper/permissions/env/etc untouched. `env` is
68
+ * never written here: it would redirect the user's own Claude Code sessions
69
+ * to the platform proxy (see MERGEABLE_SETTINGS_PATHS).
34
70
  * - auth-profiles.json and .env are NOT touched on standalone.
35
71
  */
36
72
  export declare function applyMergeableConfig(data: BootstrapResult): Promise<MergeResult>;
73
+ export interface ApplyConfigOutcome {
74
+ /** True when the full apply ran (managed install), false for scoped merge. */
75
+ managed: boolean;
76
+ /** Present only on the scoped-merge path. */
77
+ mergeResult?: MergeResult;
78
+ }
79
+ /**
80
+ * The one owner of "fetch bootstrap and apply it". Every caller — the
81
+ * `update_config` WS handler, the `bootstrap` CLI, the opt-in startup refresh —
82
+ * goes through here so the deploy-type decision cannot drift between them.
83
+ *
84
+ * Managed installs ('vm'/'k8s') are provisioned end to end by the platform and
85
+ * get the full apply. Anything else — 'standalone', 'external', or a payload
86
+ * from an older backend that omits `deploymentType` — is a third-party machine
87
+ * and gets the scoped, additive merge only. Never rewrite files we don't own.
88
+ */
89
+ export declare function fetchAndApplyConfig(api: AgentApi, agentId: string): Promise<ApplyConfigOutcome>;
37
90
  export {};