@senpi-ai/runtime 3.0.104 → 3.0.105

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 (67) hide show
  1. package/dist/cli/guide-commands.d.ts.map +1 -1
  2. package/dist/cli/guide-commands.js +38 -0
  3. package/dist/cli/guide-commands.js.map +1 -1
  4. package/dist/cli/senpi-commands.d.ts.map +1 -1
  5. package/dist/cli/senpi-commands.js +29 -1
  6. package/dist/cli/senpi-commands.js.map +1 -1
  7. package/dist/cli/update-command.d.ts +69 -0
  8. package/dist/cli/update-command.d.ts.map +1 -0
  9. package/dist/cli/update-command.js +153 -0
  10. package/dist/cli/update-command.js.map +1 -0
  11. package/dist/dsl/plugin/index.d.ts +35 -1
  12. package/dist/dsl/plugin/index.d.ts.map +1 -1
  13. package/dist/dsl/plugin/index.js +62 -7
  14. package/dist/dsl/plugin/index.js.map +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +195 -11
  17. package/dist/index.js.map +1 -1
  18. package/dist/runtime/effective-config.d.ts +67 -0
  19. package/dist/runtime/effective-config.d.ts.map +1 -0
  20. package/dist/runtime/effective-config.js +324 -0
  21. package/dist/runtime/effective-config.js.map +1 -0
  22. package/dist/runtime/lifecycle-events.d.ts +19 -0
  23. package/dist/runtime/lifecycle-events.d.ts.map +1 -1
  24. package/dist/runtime/lifecycle-events.js +27 -0
  25. package/dist/runtime/lifecycle-events.js.map +1 -1
  26. package/dist/runtime/rebuild-errors.d.ts +26 -0
  27. package/dist/runtime/rebuild-errors.d.ts.map +1 -0
  28. package/dist/runtime/rebuild-errors.js +36 -0
  29. package/dist/runtime/rebuild-errors.js.map +1 -0
  30. package/dist/runtime/run.d.ts +10 -0
  31. package/dist/runtime/run.d.ts.map +1 -1
  32. package/dist/runtime/run.js +13 -1
  33. package/dist/runtime/run.js.map +1 -1
  34. package/dist/runtime/runtime.d.ts +140 -1
  35. package/dist/runtime/runtime.d.ts.map +1 -1
  36. package/dist/runtime/runtime.js +494 -149
  37. package/dist/runtime/runtime.js.map +1 -1
  38. package/dist/runtime/strategy-registry.d.ts +1 -0
  39. package/dist/runtime/strategy-registry.d.ts.map +1 -1
  40. package/dist/runtime/strategy-registry.js +19 -0
  41. package/dist/runtime/strategy-registry.js.map +1 -1
  42. package/dist/runtime/update-apply-deps.d.ts +101 -0
  43. package/dist/runtime/update-apply-deps.d.ts.map +1 -0
  44. package/dist/runtime/update-apply-deps.js +159 -0
  45. package/dist/runtime/update-apply-deps.js.map +1 -0
  46. package/dist/runtime/update-handler.d.ts +197 -0
  47. package/dist/runtime/update-handler.d.ts.map +1 -0
  48. package/dist/runtime/update-handler.js +381 -0
  49. package/dist/runtime/update-handler.js.map +1 -0
  50. package/dist/runtime/update-plan.d.ts +60 -0
  51. package/dist/runtime/update-plan.d.ts.map +1 -0
  52. package/dist/runtime/update-plan.js +203 -0
  53. package/dist/runtime/update-plan.js.map +1 -0
  54. package/dist/runtime/update-register.d.ts +67 -0
  55. package/dist/runtime/update-register.d.ts.map +1 -0
  56. package/dist/runtime/update-register.js +173 -0
  57. package/dist/runtime/update-register.js.map +1 -0
  58. package/dist/runtime/update-report.d.ts +125 -0
  59. package/dist/runtime/update-report.d.ts.map +1 -0
  60. package/dist/runtime/update-report.js +215 -0
  61. package/dist/runtime/update-report.js.map +1 -0
  62. package/dist/utils/event-catalog.d.ts +26 -0
  63. package/dist/utils/event-catalog.d.ts.map +1 -1
  64. package/dist/utils/event-catalog.js +1 -0
  65. package/dist/utils/event-catalog.js.map +1 -1
  66. package/openclaw.plugin.json +1 -1
  67. package/package.json +1 -1
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Decide whether a recipe change can be applied in place, and what it would do.
3
+ *
4
+ * Pure: the caller supplies the two recipes and the runtime facts, and gets back either a set of
5
+ * refusals or the report an update would produce. Nothing here reads disk, the venue, or the
6
+ * registry, so the whole decision is testable without standing a runtime up — and the same function
7
+ * backs both `--dry-run` and the real apply, which is what makes their output identical by
8
+ * construction rather than by discipline.
9
+ *
10
+ * ## Why refusals are computed BEFORE anything is torn down
11
+ *
12
+ * The update verb's one safety property is that a refusal changes nothing. The install gate exists
13
+ * but runs at install only, deliberately — the boot loop starts every runtime inside one `try`, so
14
+ * refusing there would stop every other strategy on the box over one bad recipe. An update has no
15
+ * such constraint and every reason to refuse loudly, because the alternative is a strategy left
16
+ * with no scanners and no actions but an open book.
17
+ *
18
+ * ## What counts as "not an update"
19
+ *
20
+ * Three changes are structural rather than configural: they would silently orphan state that the
21
+ * runtime keys on. They refuse with the remedy named, rather than proceeding and reporting the
22
+ * damage afterwards.
23
+ */
24
+ import type { RuntimeConfig } from "./runtime-schema.js";
25
+ import type { Finding } from "../validate/types.js";
26
+ import { type ReportedGate, type ReportedPosition, type UpdateReport } from "./update-report.js";
27
+ /** Codes this module raises. Distinct from validate's set: these are update-time decisions. */
28
+ export declare const UPDATE_CODE: {
29
+ readonly walletChanged: "E_UPDATE_WALLET_CHANGED";
30
+ readonly scannerRenamed: "E_UPDATE_SCANNER_RENAMED";
31
+ readonly scannerReordered: "E_UPDATE_SCANNER_REORDERED";
32
+ readonly actionTypeChanged: "E_UPDATE_ACTION_TYPE_CHANGED";
33
+ };
34
+ export interface UpdatePlanInputs {
35
+ runtimeId: string;
36
+ /** The recipe the runtime is running now, as stored in the registry. */
37
+ current: RuntimeConfig;
38
+ /** The recipe being proposed. */
39
+ next: RuntimeConfig;
40
+ openPositions: readonly ReportedPosition[];
41
+ closedGates: readonly ReportedGate[];
42
+ /** False produces the identical report minus the claim that anything happened. */
43
+ applied: boolean;
44
+ }
45
+ export type UpdatePlan = {
46
+ ok: true;
47
+ report: UpdateReport;
48
+ } | {
49
+ ok: false;
50
+ refusals: Finding[];
51
+ };
52
+ /**
53
+ * The whole decision, in one call.
54
+ *
55
+ * Refusals are returned rather than thrown: a caller must be able to render several at once, and an
56
+ * exception would stop at the first — leaving an agent to fix one problem, re-run, and discover the
57
+ * next, which is the loop this codebase's finding model exists to avoid.
58
+ */
59
+ export declare function planUpdate(inputs: UpdatePlanInputs): UpdatePlan;
60
+ //# sourceMappingURL=update-plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-plan.d.ts","sourceRoot":"","sources":["../../src/runtime/update-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAE5B,+FAA+F;AAC/F,eAAO,MAAM,WAAW;;;;;CAKd,CAAC;AAEX,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,OAAO,EAAE,aAAa,CAAC;IACvB,iCAAiC;IACjC,IAAI,EAAE,aAAa,CAAC;IACpB,aAAa,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC3C,WAAW,EAAE,SAAS,YAAY,EAAE,CAAC;IACrC,kFAAkF;IAClF,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,UAAU,GAClB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,YAAY,CAAA;CAAE,GAClC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC;AA8KvC;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,CAkB/D"}
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Decide whether a recipe change can be applied in place, and what it would do.
3
+ *
4
+ * Pure: the caller supplies the two recipes and the runtime facts, and gets back either a set of
5
+ * refusals or the report an update would produce. Nothing here reads disk, the venue, or the
6
+ * registry, so the whole decision is testable without standing a runtime up — and the same function
7
+ * backs both `--dry-run` and the real apply, which is what makes their output identical by
8
+ * construction rather than by discipline.
9
+ *
10
+ * ## Why refusals are computed BEFORE anything is torn down
11
+ *
12
+ * The update verb's one safety property is that a refusal changes nothing. The install gate exists
13
+ * but runs at install only, deliberately — the boot loop starts every runtime inside one `try`, so
14
+ * refusing there would stop every other strategy on the box over one bad recipe. An update has no
15
+ * such constraint and every reason to refuse loudly, because the alternative is a strategy left
16
+ * with no scanners and no actions but an open book.
17
+ *
18
+ * ## What counts as "not an update"
19
+ *
20
+ * Three changes are structural rather than configural: they would silently orphan state that the
21
+ * runtime keys on. They refuse with the remedy named, rather than proceeding and reporting the
22
+ * damage afterwards.
23
+ */
24
+ import { resolveEffectiveConfig } from "./effective-config.js";
25
+ import { buildUpdateReport, diffRecipes, } from "./update-report.js";
26
+ /** Codes this module raises. Distinct from validate's set: these are update-time decisions. */
27
+ export const UPDATE_CODE = {
28
+ walletChanged: "E_UPDATE_WALLET_CHANGED",
29
+ scannerRenamed: "E_UPDATE_SCANNER_RENAMED",
30
+ scannerReordered: "E_UPDATE_SCANNER_REORDERED",
31
+ actionTypeChanged: "E_UPDATE_ACTION_TYPE_CHANGED",
32
+ };
33
+ function refusal(code, parts) {
34
+ return {
35
+ code,
36
+ severity: "error",
37
+ stage: "static",
38
+ actor: "agent",
39
+ fix_kind: "edit",
40
+ ...(parts.yamlPath ? { where: { yaml_path: parts.yamlPath } } : {}),
41
+ what: parts.what,
42
+ why: parts.why,
43
+ fix: parts.fix,
44
+ };
45
+ }
46
+ function scannerNames(config) {
47
+ return (config.scanners ?? []).map((s) => String(s.name));
48
+ }
49
+ /**
50
+ * External scanners only, in declaration order.
51
+ *
52
+ * The index half of the state key counts external scanners alone — the launcher walks
53
+ * `ExternalScannerSpec[]`, not the whole `scanners` block — so an internal scanner added, removed
54
+ * or moved above them changes the recipe's array positions without changing any state directory.
55
+ * Comparing the full block would refuse edits that are entirely safe, and, worse, would report the
56
+ * wrong names for the ones that are not.
57
+ */
58
+ function externalScannerNames(config) {
59
+ return (config.scanners ?? [])
60
+ .filter((s) => {
61
+ const scanner = s;
62
+ if (String(scanner.type) !== "external_scanner")
63
+ return false;
64
+ // The SAME predicate `selectScanners` uses (intake-mount.ts): an external scanner missing
65
+ // `path` or `entrypoint` is skipped by the launcher, so it occupies no index and cannot
66
+ // orphan anything. Counting it here would model a different sequence from the one the state
67
+ // directories are named after — and the mismatch is silent in the dangerous direction:
68
+ // filling in a stub's `path` later shifts every scanner below it while this check, seeing
69
+ // the same names in the same order, reports no move at all.
70
+ return Boolean(scanner.path) && Boolean(scanner.entrypoint);
71
+ })
72
+ .map((s) => String(s.name));
73
+ }
74
+ /**
75
+ * Structural changes: the ones that orphan state the runtime keys on, rather than merely changing
76
+ * behaviour. Each names what would be orphaned, because "refused" without that is a dead end.
77
+ */
78
+ function structuralRefusals(current, next) {
79
+ const out = [];
80
+ const currentWallet = String(current.strategy.wallet ?? "");
81
+ const nextWallet = String(next.strategy.wallet ?? "");
82
+ if (currentWallet !== nextWallet) {
83
+ out.push(refusal(UPDATE_CODE.walletChanged, {
84
+ yamlPath: "strategy.wallet",
85
+ what: `The recipe changes strategy.wallet from ${currentWallet} to ${nextWallet}`,
86
+ why: "The wallet is the deployment's identity: the state directory is named for it, the backend " +
87
+ "strategy is it, and the venue book is it. Nothing on disk or at the venue carries across, " +
88
+ "so this is a new deployment wearing an old name — and the old wallet's positions would be " +
89
+ "left running with nothing managing them.",
90
+ fix: `Deploy this as a new strategy, and close the book on ${currentWallet} explicitly.`,
91
+ }));
92
+ }
93
+ // Scanner state lives at `scanner-state/{name}-{index}` for external scanners, so BOTH the name
94
+ // and the position in the array are load-bearing. A rename or a reorder silently repoints a
95
+ // scanner at an empty directory — losing cached cohorts, first-seen ledgers and dedup rings with
96
+ // no error anywhere.
97
+ const before = scannerNames(current);
98
+ const after = scannerNames(next);
99
+ const beforeSet = new Set(before);
100
+ const afterSet = new Set(after);
101
+ const removed = before.filter((n) => !afterSet.has(n));
102
+ const added = after.filter((n) => !beforeSet.has(n));
103
+ if (removed.length > 0 && added.length > 0) {
104
+ out.push(refusal(UPDATE_CODE.scannerRenamed, {
105
+ yamlPath: "scanners",
106
+ what: `Scanner ${removed.join(", ")} is gone and ${added.join(", ")} is new`,
107
+ why: "Scanner state is keyed on the scanner's name, so a rename starts it from empty — cached " +
108
+ "cohorts, first-seen ledgers and rotation state are all lost, silently. If this really is " +
109
+ "a rename rather than a replacement, the state should move with it.",
110
+ fix: `Keep the name \`${removed[0]}\`, or accept the reset explicitly by deleting its state ` +
111
+ `directory first.`,
112
+ }));
113
+ }
114
+ // The index half of the key, checked on the only thing that decides it: where each surviving
115
+ // external scanner sits now versus where it sat before.
116
+ //
117
+ // Comparing the survivors' RELATIVE order instead — which is what this did — cannot see an insert
118
+ // or a remove, because both leave the survivors in the same order as each other while moving
119
+ // every one of them. Inserting a scanner at the top of the block shifts all of them down a slot,
120
+ // silently repointing each at the previous occupant's state directory: cached cohorts, first-seen
121
+ // ledgers and dedup rings all read as another scanner's, with no error anywhere. An absolute
122
+ // comparison catches that, still catches a plain reorder, and still permits an append, which
123
+ // moves nobody.
124
+ const beforeExternal = externalScannerNames(current);
125
+ const afterExternal = externalScannerNames(next);
126
+ const moved = beforeExternal
127
+ .map((name, from) => ({ name, from, to: afterExternal.indexOf(name) }))
128
+ .filter((s) => s.to !== -1 && s.to !== s.from);
129
+ if (moved.length > 0) {
130
+ out.push(refusal(UPDATE_CODE.scannerReordered, {
131
+ yamlPath: "scanners",
132
+ what: `These external scanners change position in the block: ` +
133
+ moved.map((m) => `${m.name} (${m.from} → ${m.to})`).join(", "),
134
+ why: "External scanner state is keyed on the array index as well as the name, so a scanner " +
135
+ "that moves is repointed at another's state directory or at an empty one — losing cached " +
136
+ "cohorts, first-seen ledgers and dedup rings silently. Inserting or removing a scanner " +
137
+ "moves every external scanner below it, not only the one that was edited. It also " +
138
+ "changes the staggered start order.",
139
+ fix: "Keep each existing external scanner at its current position. Adding one at the END of " +
140
+ "the block moves nothing and is safe.",
141
+ }));
142
+ }
143
+ // Action state lives at `strategies/{address}/actions/{name}/`, so a type change under a stable
144
+ // name hands a different action class the previous one's persisted state.
145
+ const currentByName = new Map((current.actions ?? []).map((a) => [String(a.name), a]));
146
+ for (const action of next.actions ?? []) {
147
+ const name = String(action.name);
148
+ const prior = currentByName.get(name);
149
+ if (!prior)
150
+ continue;
151
+ const before_ = String(prior.action_type);
152
+ const after_ = String(action.action_type);
153
+ if (before_ === after_)
154
+ continue;
155
+ out.push(refusal(UPDATE_CODE.actionTypeChanged, {
156
+ yamlPath: `actions.${name}.action_type`,
157
+ what: `Action '${name}' changes type from ${before_} to ${after_}`,
158
+ why: "Action state is keyed on the action's name, so the new class would inherit the previous " +
159
+ "one's latest.json and execution history — records written by different code about a " +
160
+ "different thing.",
161
+ fix: `Give the ${after_} action a new name, or reset '${name}' state explicitly.`,
162
+ }));
163
+ }
164
+ return out;
165
+ }
166
+ /** Did the exit ladder change? Drives the report's forward-only wording. */
167
+ function exitPresetChanged(current, next) {
168
+ const a = current.exit?.dsl_preset;
169
+ const b = next.exit?.dsl_preset;
170
+ return JSON.stringify(a ?? null) !== JSON.stringify(b ?? null);
171
+ }
172
+ /** `slots` as the recipe declares it; the report needs the authored value, not the effective one. */
173
+ function slotsOf(config) {
174
+ const raw = config.strategy.slots;
175
+ return typeof raw === "number" && Number.isFinite(raw) ? raw : undefined;
176
+ }
177
+ /**
178
+ * The whole decision, in one call.
179
+ *
180
+ * Refusals are returned rather than thrown: a caller must be able to render several at once, and an
181
+ * exception would stop at the first — leaving an agent to fix one problem, re-run, and discover the
182
+ * next, which is the loop this codebase's finding model exists to avoid.
183
+ */
184
+ export function planUpdate(inputs) {
185
+ const refusals = structuralRefusals(inputs.current, inputs.next);
186
+ if (refusals.length > 0)
187
+ return { ok: false, refusals };
188
+ return {
189
+ ok: true,
190
+ report: buildUpdateReport({
191
+ runtimeId: inputs.runtimeId,
192
+ applied: inputs.applied,
193
+ before: resolveEffectiveConfig(inputs.current),
194
+ after: resolveEffectiveConfig(inputs.next),
195
+ openPositions: inputs.openPositions,
196
+ closedGates: inputs.closedGates,
197
+ exitPresetChanged: exitPresetChanged(inputs.current, inputs.next),
198
+ changedFields: diffRecipes(inputs.current, inputs.next),
199
+ ...(slotsOf(inputs.next) !== undefined ? { slots: slotsOf(inputs.next) } : {}),
200
+ }),
201
+ };
202
+ }
203
+ //# sourceMappingURL=update-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-plan.js","sourceRoot":"","sources":["../../src/runtime/update-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EACL,iBAAiB,EACjB,WAAW,GAIZ,MAAM,oBAAoB,CAAC;AAE5B,+FAA+F;AAC/F,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,aAAa,EAAE,yBAAyB;IACxC,cAAc,EAAE,0BAA0B;IAC1C,gBAAgB,EAAE,4BAA4B;IAC9C,iBAAiB,EAAE,8BAA8B;CACzC,CAAC;AAkBX,SAAS,OAAO,CACd,IAAY,EACZ,KAAoE;IAEpE,OAAO;QACL,IAAI;QACJ,QAAQ,EAAE,OAAO;QACjB,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,MAAM;QAChB,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnE,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,GAAG,EAAE,KAAK,CAAC,GAAG;KACf,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,MAAqB;IACzC,OAAO,CAAC,MAAM,CAAC,QAAQ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AAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,MAAwB;IACjD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACjE,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAExD,OAAO;QACL,EAAE,EAAE,IAAI;QACR,MAAM,EAAE,iBAAiB,CAAC;YACxB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,MAAM,EAAE,sBAAsB,CAAC,MAAM,CAAC,OAAO,CAAC;YAC9C,KAAK,EAAE,sBAAsB,CAAC,MAAM,CAAC,IAAI,CAAC;YAC1C,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,iBAAiB,EAAE,iBAAiB,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;YACjE,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;YACvD,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC/E,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Gateway wiring for `senpi update`.
3
+ *
4
+ * `senpi.update` is **internal transport** between the CLI verb and the plugin, deliberately absent
5
+ * from the cheatsheet, the README's agent-facing sections and the skills — the same treatment
6
+ * `senpi.deploy.*` gets, and for the same reason: one teaching surface wins routing, and naming the
7
+ * RPC too would invite raw calls that bypass the CLI-side validation.
8
+ *
9
+ * Named `senpi.update` rather than `senpi.update.start`: `.start` belongs to a verb with a matching
10
+ * `.status`, because deploy has to detach around multi-minute wallet funding. An update moves no
11
+ * money and has nothing to wait on, so it answers in one call.
12
+ *
13
+ * The module owns no logic beyond adapting a gateway context into the handler's dependencies, so
14
+ * everything worth testing lives in `update-handler.ts` and tests never drive a gateway.
15
+ */
16
+ import type { RuntimeConfig } from "./runtime-schema.js";
17
+ import { type RecipeSource, type UpdateHandlerDeps } from "./update-handler.js";
18
+ /**
19
+ * The plugin surface this needs. Explicit, so the module never reaches into the boot closure.
20
+ *
21
+ * Extends {@link UpdateHandlerDeps} rather than restating it. Restating it is what let the two
22
+ * drift: a gateway context that still declared the old one-argument `verifyProof` type-checked
23
+ * against a handler that had grown a second parameter, so the stricter check silently went unused
24
+ * on the only path a user can actually reach.
25
+ */
26
+ export interface UpdateGatewayContext extends UpdateHandlerDeps {
27
+ /**
28
+ * Swap a running runtime onto the new recipe, and record it.
29
+ *
30
+ * Optional: a gateway with no live runtimes to mutate (or a deployment that has not enabled the
31
+ * apply) simply omits them, and `dryRun: false` is refused as unsupported rather than silently
32
+ * planning. Present together or not at all — recording without swapping, or the reverse, is not a
33
+ * coherent half-state to offer.
34
+ */
35
+ applyToRuntime?(runtimeId: string, next: RuntimeConfig, recipe: RecipeSource): Promise<void | {
36
+ scannersUnwired?: string;
37
+ }>;
38
+ writeRegistry?(runtimeId: string, recipe: RecipeSource): Promise<void>;
39
+ /**
40
+ * Called once an apply has FULLY succeeded — swapped and recorded.
41
+ *
42
+ * Deliberately not called for a swap whose registry write failed: that outcome is reported as a
43
+ * failure, and an audit trail saying a strategy was updated when a restart would revert it is
44
+ * worse than no entry at all. Telemetry only; it must never fail the apply, so the implementation
45
+ * is expected to guard itself.
46
+ */
47
+ onApplied?(info: {
48
+ runtimeId: string;
49
+ address?: string;
50
+ recipe: RecipeSource;
51
+ previousRecipe: RecipeSource;
52
+ exitPresetChanged: boolean;
53
+ openPositions: number;
54
+ slots?: number;
55
+ }): void;
56
+ }
57
+ interface GatewayApi {
58
+ registerGatewayMethod(name: string, handler: (ctx: {
59
+ params?: Record<string, unknown>;
60
+ respond: (ok: boolean, payload?: unknown, error?: unknown) => void;
61
+ }) => Promise<void>, opts?: {
62
+ scope?: string;
63
+ }): void;
64
+ }
65
+ export declare function registerUpdateGatewayMethod(api: GatewayApi, ctxDeps: UpdateGatewayContext): void;
66
+ export {};
67
+ //# sourceMappingURL=update-register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-register.d.ts","sourceRoot":"","sources":["../../src/runtime/update-register.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAGL,KAAK,YAAY,EAEjB,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAG7B;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D;;;;;;;OAOG;IACH,cAAc,CAAC,CACb,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,IAAI,GAAG;QAAE,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD,aAAa,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvE;;;;;;;OAOG;IACH,SAAS,CAAC,CAAC,IAAI,EAAE;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,YAAY,CAAC;QACrB,cAAc,EAAE,YAAY,CAAC;QAC7B,iBAAiB,EAAE,OAAO,CAAC;QAC3B,aAAa,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,IAAI,CAAC;CACV;AAED,UAAU,UAAU;IAClB,qBAAqB,CACnB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjC,OAAO,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;KACpE,KAAK,OAAO,CAAC,IAAI,CAAC,EACnB,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GACxB,IAAI,CAAC;CACT;AAsDD,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,oBAAoB,GAAG,IAAI,CA8HhG"}
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Gateway wiring for `senpi update`.
3
+ *
4
+ * `senpi.update` is **internal transport** between the CLI verb and the plugin, deliberately absent
5
+ * from the cheatsheet, the README's agent-facing sections and the skills — the same treatment
6
+ * `senpi.deploy.*` gets, and for the same reason: one teaching surface wins routing, and naming the
7
+ * RPC too would invite raw calls that bypass the CLI-side validation.
8
+ *
9
+ * Named `senpi.update` rather than `senpi.update.start`: `.start` belongs to a verb with a matching
10
+ * `.status`, because deploy has to detach around multi-minute wallet funding. An update moves no
11
+ * money and has nothing to wait on, so it answers in one call.
12
+ *
13
+ * The module owns no logic beyond adapting a gateway context into the handler's dependencies, so
14
+ * everything worth testing lives in `update-handler.ts` and tests never drive a gateway.
15
+ */
16
+ import { runUpdateApply, runUpdateDryRun, } from "./update-handler.js";
17
+ import { renderUpdateReport } from "./update-report.js";
18
+ /**
19
+ * Render refusals for a human while keeping them machine-readable.
20
+ *
21
+ * Both, not either: every neighbouring gateway error carries a `message`, and anything rendering
22
+ * errors today expects one — but a caller that has to parse prose to find out which of four things
23
+ * went wrong is exactly what the finding model exists to prevent.
24
+ */
25
+ function renderRefusals(runtimeId, findings) {
26
+ const head = runtimeId ? `Cannot update ${runtimeId}:` : "Cannot update:";
27
+ const body = findings.map((f) => `${codeTag(f)}${f.what}\n ${f.fix}`).join("\n\n");
28
+ return `${head}\n\n${body}`;
29
+ }
30
+ /**
31
+ * `[E_…]` at the start of the line, which is how every refusal in this codebase identifies itself.
32
+ *
33
+ * Not decoration. The CLI decides its EXIT CODE by scanning the gateway's stderr for a line leading
34
+ * with a bracketed taxonomy code (`gatewayAnsweredRefusal` → `isRefusalMessage`). Without it, a
35
+ * refusal is indistinguishable from a transport failure and exits **1 instead of 2** — inverting the
36
+ * one distinction the exit-code contract exists to make, since 1 reads as "retry" and these refuse
37
+ * identically forever.
38
+ */
39
+ function codeTag(f) {
40
+ return f.code ? ` [${f.code}] ` : " ";
41
+ }
42
+ /**
43
+ * A failure is not a refusal, and must not borrow its wording.
44
+ *
45
+ * "Cannot update X" says nothing was attempted. On this path something was — and in the worst case
46
+ * the runtime is down with an unmanaged book, which is the single message an operator most needs to
47
+ * read correctly. The `why` is carried here and not in `renderRefusals` because on a failure it is
48
+ * the part that says what state the runtime is in NOW.
49
+ */
50
+ function renderFailure(runtimeId, findings) {
51
+ const head = runtimeId ? `Update to ${runtimeId} FAILED:` : "Update FAILED:";
52
+ // The code is named WITHOUT brackets here, unlike a refusal. `callGatewayJson` classifies any
53
+ // stderr containing a bracketed `[E_…]` as a REFUSAL and stamps exit 2 before this verb's own
54
+ // UPDATE_FAILED → exit 1 mapping can run. Tagging failures the same way as refusals therefore
55
+ // collapsed the one distinction the exit-code contract exists to make: 2 means nothing was
56
+ // touched, 1 means an apply was attempted and the runtime may not be where the caller left it.
57
+ // Measured on a live box — a rebuild that failed and rolled back reported exit 2.
58
+ const body = findings
59
+ .map((f) => ` ${f.code ? `${f.code}: ` : ""}${f.what}\n ${f.why}\n ${f.fix}`)
60
+ .join("\n\n");
61
+ return `${head}\n\n${body}`;
62
+ }
63
+ function asString(v) {
64
+ return typeof v === "string" && v.length > 0 ? v : undefined;
65
+ }
66
+ export function registerUpdateGatewayMethod(api, ctxDeps) {
67
+ api.registerGatewayMethod("senpi.update", async (ctx) => {
68
+ const { params, respond } = ctx;
69
+ const path = asString(params?.runtimeYamlPath);
70
+ const content = typeof params?.runtimeYamlContent === "string" ? params.runtimeYamlContent : undefined;
71
+ if (path === undefined && content === undefined) {
72
+ respond(false, undefined, {
73
+ code: "INVALID_REQUEST",
74
+ message: "Please provide the updated recipe: --path <file> or --content \"<yaml text>\".",
75
+ });
76
+ return;
77
+ }
78
+ if (path !== undefined && content !== undefined) {
79
+ respond(false, undefined, {
80
+ code: "INVALID_REQUEST",
81
+ message: "Please provide either a file path (--path) or YAML content (--content), not both.",
82
+ });
83
+ return;
84
+ }
85
+ // `dryRun: false` is the apply. A deployment that did not wire the two mutating dependencies
86
+ // must refuse it rather than quietly planning — a caller who asked to change something and
87
+ // got an exit 0 over a plan would believe it changed.
88
+ const wantsApply = params?.dryRun === false;
89
+ const canApply = ctxDeps.applyToRuntime != null && ctxDeps.writeRegistry != null;
90
+ if (wantsApply && !canApply) {
91
+ respond(false, undefined, {
92
+ code: "NOT_IMPLEMENTED",
93
+ message: "This gateway cannot apply updates — it can only plan them. " +
94
+ "Re-run without --apply to see what the change would do.",
95
+ });
96
+ return;
97
+ }
98
+ const recipe = {
99
+ ...(path !== undefined ? { path } : {}),
100
+ ...(content !== undefined ? { content } : {}),
101
+ ...(asString(params?.runtimeYamlDir) !== undefined ? { dir: asString(params?.runtimeYamlDir) } : {}),
102
+ };
103
+ // Resolved here only to stamp the wallet on the audit event; the handler does its own
104
+ // resolution and owns every refusal about it.
105
+ const runtimes = wantsApply ? await ctxDeps.listRuntimes().catch(() => []) : [];
106
+ const request = {
107
+ ...(asString(params?.id) !== undefined ? { id: asString(params?.id) } : {}),
108
+ ...(asString(params?.address) !== undefined ? { address: asString(params?.address) } : {}),
109
+ ...(params?.codeOnly === true ? { codeOnly: true } : {}),
110
+ recipe,
111
+ };
112
+ let outcome;
113
+ try {
114
+ outcome = wantsApply
115
+ ? await runUpdateApply(ctxDeps, request)
116
+ : await runUpdateDryRun(ctxDeps, request).then((o) => o.ok
117
+ ? { ok: true, plan: o.plan }
118
+ : { ok: false, stage: "refused", refusals: o.refusals });
119
+ }
120
+ catch (err) {
121
+ // `runUpdateApply` converts the failures it knows about into outcomes, so a throw escaping
122
+ // it is a defect here. On a plan that is unambiguous — nothing was touched. On an apply it
123
+ // is not, so the wording must not promise a state it cannot verify.
124
+ respond(false, undefined, {
125
+ code: "UNAVAILABLE",
126
+ message: wantsApply
127
+ ? `The update failed unexpectedly. This is a fault here rather than in your recipe, and ` +
128
+ `the runtime's state could not be determined from it — check it with ` +
129
+ `\`openclaw senpi runtime list\` before retrying.\n\n${String(err)}`
130
+ : `Could not plan the update. This is a fault in the planner, not in your recipe.\n\n${String(err)}`,
131
+ });
132
+ return;
133
+ }
134
+ if (!outcome.ok) {
135
+ // Two error codes, not one: a refusal changed nothing and the caller should fix their
136
+ // recipe, whereas a failure means an apply was attempted and the findings say what state
137
+ // the runtime is in now. Collapsing them would have a caller retry into a broken runtime.
138
+ // `{ code, message }` and nothing else. Every other gateway error in this plugin uses
139
+ // exactly that shape, and this method used to attach a `findings` array beside them: the
140
+ // response then never reached the caller at all — the CLI sat until its timeout while the
141
+ // handler had long since returned. The only refusal that ever worked was the one raised
142
+ // before this line, which carries no extra key. Structured findings stay available through
143
+ // `--json` on a plan; a refusal's `what`/`fix` are already rendered into the message.
144
+ respond(false, undefined, {
145
+ code: outcome.stage === "failed" ? "UPDATE_FAILED" : "UPDATE_REFUSED",
146
+ message: outcome.stage === "failed"
147
+ ? renderFailure(asString(params?.id), outcome.refusals)
148
+ : renderRefusals(asString(params?.id), outcome.refusals),
149
+ });
150
+ return;
151
+ }
152
+ if (wantsApply) {
153
+ const report = outcome.plan.report;
154
+ const target = runtimes.find((r) => r.id === report.runtimeId);
155
+ ctxDeps.onApplied?.({
156
+ runtimeId: report.runtimeId,
157
+ ...(target?.wallet ? { address: target.wallet } : {}),
158
+ // What was actually STORED, so the event's config hash describes the recipe a restart
159
+ // will replay rather than the request that produced it.
160
+ recipe: "stored" in outcome && outcome.stored ? outcome.stored : recipe,
161
+ previousRecipe: target?.source ?? {},
162
+ exitPresetChanged: report.exitPresetChanged,
163
+ openPositions: report.openPositions.length,
164
+ ...(report.slots !== undefined ? { slots: report.slots } : {}),
165
+ });
166
+ }
167
+ respond(true, {
168
+ report: outcome.plan.report,
169
+ rendered: renderUpdateReport(outcome.plan.report),
170
+ });
171
+ }, { scope: "operator.write" });
172
+ }
173
+ //# sourceMappingURL=update-register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-register.js","sourceRoot":"","sources":["../../src/runtime/update-register.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,EACL,cAAc,EACd,eAAe,GAIhB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAuDxD;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,SAA6B,EAAE,QAA4B;IACjF,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,iBAAiB,SAAS,GAAG,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAC1E,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtF,OAAO,GAAG,IAAI,OAAO,IAAI,EAAE,CAAC;AAC9B,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,OAAO,CAAC,CAAU;IACzB,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,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