@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.
- package/dist/cli/guide-commands.d.ts.map +1 -1
- package/dist/cli/guide-commands.js +38 -0
- package/dist/cli/guide-commands.js.map +1 -1
- package/dist/cli/senpi-commands.d.ts.map +1 -1
- package/dist/cli/senpi-commands.js +29 -1
- package/dist/cli/senpi-commands.js.map +1 -1
- package/dist/cli/update-command.d.ts +69 -0
- package/dist/cli/update-command.d.ts.map +1 -0
- package/dist/cli/update-command.js +153 -0
- package/dist/cli/update-command.js.map +1 -0
- package/dist/dsl/plugin/index.d.ts +35 -1
- package/dist/dsl/plugin/index.d.ts.map +1 -1
- package/dist/dsl/plugin/index.js +62 -7
- package/dist/dsl/plugin/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +195 -11
- package/dist/index.js.map +1 -1
- package/dist/runtime/effective-config.d.ts +67 -0
- package/dist/runtime/effective-config.d.ts.map +1 -0
- package/dist/runtime/effective-config.js +324 -0
- package/dist/runtime/effective-config.js.map +1 -0
- package/dist/runtime/lifecycle-events.d.ts +19 -0
- package/dist/runtime/lifecycle-events.d.ts.map +1 -1
- package/dist/runtime/lifecycle-events.js +27 -0
- package/dist/runtime/lifecycle-events.js.map +1 -1
- package/dist/runtime/rebuild-errors.d.ts +26 -0
- package/dist/runtime/rebuild-errors.d.ts.map +1 -0
- package/dist/runtime/rebuild-errors.js +36 -0
- package/dist/runtime/rebuild-errors.js.map +1 -0
- package/dist/runtime/run.d.ts +10 -0
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +13 -1
- package/dist/runtime/run.js.map +1 -1
- package/dist/runtime/runtime.d.ts +140 -1
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +494 -149
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/strategy-registry.d.ts +1 -0
- package/dist/runtime/strategy-registry.d.ts.map +1 -1
- package/dist/runtime/strategy-registry.js +19 -0
- package/dist/runtime/strategy-registry.js.map +1 -1
- package/dist/runtime/update-apply-deps.d.ts +101 -0
- package/dist/runtime/update-apply-deps.d.ts.map +1 -0
- package/dist/runtime/update-apply-deps.js +159 -0
- package/dist/runtime/update-apply-deps.js.map +1 -0
- package/dist/runtime/update-handler.d.ts +197 -0
- package/dist/runtime/update-handler.d.ts.map +1 -0
- package/dist/runtime/update-handler.js +381 -0
- package/dist/runtime/update-handler.js.map +1 -0
- package/dist/runtime/update-plan.d.ts +60 -0
- package/dist/runtime/update-plan.d.ts.map +1 -0
- package/dist/runtime/update-plan.js +203 -0
- package/dist/runtime/update-plan.js.map +1 -0
- package/dist/runtime/update-register.d.ts +67 -0
- package/dist/runtime/update-register.d.ts.map +1 -0
- package/dist/runtime/update-register.js +173 -0
- package/dist/runtime/update-register.js.map +1 -0
- package/dist/runtime/update-report.d.ts +125 -0
- package/dist/runtime/update-report.d.ts.map +1 -0
- package/dist/runtime/update-report.js +215 -0
- package/dist/runtime/update-report.js.map +1 -0
- package/dist/utils/event-catalog.d.ts +26 -0
- package/dist/utils/event-catalog.d.ts.map +1 -1
- package/dist/utils/event-catalog.js +1 -0
- package/dist/utils/event-catalog.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `senpi update --dry-run` — resolve the target, read both recipes, and produce the plan.
|
|
3
|
+
*
|
|
4
|
+
* The I/O lives in injected deps so the interesting parts — which runtime, which refusals, what the
|
|
5
|
+
* report ends up saying — are testable without a gateway, a registry on disk, or a running runtime.
|
|
6
|
+
* The gateway registration is then a thin adapter, which is the same shape `senpi deploy` uses.
|
|
7
|
+
*
|
|
8
|
+
* ## Dry run only
|
|
9
|
+
*
|
|
10
|
+
* Nothing here tears anything down. That is not merely "not implemented yet": the verb's one safety
|
|
11
|
+
* property is that a refusal changes nothing, so the decision half is worth having — and shipping —
|
|
12
|
+
* before the half that can leave a strategy with no scanners and an open book.
|
|
13
|
+
*
|
|
14
|
+
* ## What it reports rather than refuses
|
|
15
|
+
*
|
|
16
|
+
* A missing or stale proof will refuse the APPLY, exactly as it refuses a deploy. On a dry run it is
|
|
17
|
+
* reported instead: the run changes nothing, so refusing costs the reader the information they came
|
|
18
|
+
* for, and they would have to fix the proof before they could even see whether the change was worth
|
|
19
|
+
* applying.
|
|
20
|
+
*
|
|
21
|
+
* Guardrail state is deliberately NOT gathered. Every gate is derived from live venue history — the
|
|
22
|
+
* per-asset cooldown alone pages through trader history until it finds a close — so collecting them
|
|
23
|
+
* turns a plan into a network round trip per gate. The report says so rather than staying silent,
|
|
24
|
+
* because silence there reads as "all clear".
|
|
25
|
+
*/
|
|
26
|
+
import type { RuntimeConfig } from "./runtime-schema.js";
|
|
27
|
+
import type { DslState } from "../types/dsl/index.js";
|
|
28
|
+
import type { Finding } from "../validate/types.js";
|
|
29
|
+
import { type UpdatePlan } from "./update-plan.js";
|
|
30
|
+
/** Where a recipe is being read from — mirrors `senpi.installRuntime`'s parameter shape. */
|
|
31
|
+
export interface RecipeSource {
|
|
32
|
+
path?: string;
|
|
33
|
+
content?: string;
|
|
34
|
+
/** Directory relative scanner paths resolve against, when reading content. */
|
|
35
|
+
dir?: string;
|
|
36
|
+
}
|
|
37
|
+
/** One installed runtime, as the registry knows it. */
|
|
38
|
+
export interface RegisteredRuntime {
|
|
39
|
+
id: string;
|
|
40
|
+
wallet: string;
|
|
41
|
+
/** Where the recipe it is CURRENTLY running came from. */
|
|
42
|
+
source: RecipeSource;
|
|
43
|
+
}
|
|
44
|
+
export interface UpdateHandlerDeps {
|
|
45
|
+
/** Every installed runtime. Resolution and the ambiguity refusal are decided here, not by the caller. */
|
|
46
|
+
listRuntimes(): Promise<RegisteredRuntime[]>;
|
|
47
|
+
parseConfig(source: RecipeSource): Promise<RuntimeConfig>;
|
|
48
|
+
/** Active DSL states for a runtime; empty when it has no DSL or is not currently running. */
|
|
49
|
+
activePositions(runtimeId: string): Promise<DslState[]>;
|
|
50
|
+
/** Static recipe findings, for the install gate. */
|
|
51
|
+
recipeFindings(source: RecipeSource): Promise<Finding[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Blocking subset of those findings. Async only because `index.ts` loads the validate modules
|
|
54
|
+
* lazily to keep the boot path light — the gate itself is pure.
|
|
55
|
+
*/
|
|
56
|
+
installGate(findings: Finding[]): Promise<{
|
|
57
|
+
ok: boolean;
|
|
58
|
+
blocking: Finding[];
|
|
59
|
+
}>;
|
|
60
|
+
/**
|
|
61
|
+
* Pure observation; never enforced here.
|
|
62
|
+
*
|
|
63
|
+
* `appliedRecipe` is the recipe text as the CALLER supplied it, before the wallet placeholder is
|
|
64
|
+
* bound — the proof describes bytes on disk, and binding happens after, so the bound form would
|
|
65
|
+
* never match a package that uses `${WALLET}`. Passing it lets the check answer the question that
|
|
66
|
+
* matters: does the proof cover the recipe about to be applied, or merely some recipe that lives
|
|
67
|
+
* in the same directory?
|
|
68
|
+
*/
|
|
69
|
+
verifyProof(packageDir: string, appliedRecipe?: string): Promise<{
|
|
70
|
+
ok: boolean;
|
|
71
|
+
finding?: Finding;
|
|
72
|
+
}>;
|
|
73
|
+
}
|
|
74
|
+
export interface UpdateRequest {
|
|
75
|
+
/** Explicit target. Omit both when the box runs exactly one runtime. */
|
|
76
|
+
id?: string;
|
|
77
|
+
address?: string;
|
|
78
|
+
recipe: RecipeSource;
|
|
79
|
+
/**
|
|
80
|
+
* "I changed only scanner code, not the recipe."
|
|
81
|
+
*
|
|
82
|
+
* A guard rather than a shortcut: an apply reloads scanner code either way, because the scanner
|
|
83
|
+
* module is rebuilt and the apply restarts every external scanner, which re-reads its entrypoint
|
|
84
|
+
* at spawn. What this adds is
|
|
85
|
+
* the refusal when the claim is false — an edit that also touched the recipe is exactly the one a
|
|
86
|
+
* user did not mean to ship, and without the flag it would apply silently alongside the code.
|
|
87
|
+
*/
|
|
88
|
+
codeOnly?: boolean;
|
|
89
|
+
}
|
|
90
|
+
export type UpdateOutcome = {
|
|
91
|
+
ok: true;
|
|
92
|
+
plan: Extract<UpdatePlan, {
|
|
93
|
+
ok: true;
|
|
94
|
+
}>;
|
|
95
|
+
} | {
|
|
96
|
+
ok: false;
|
|
97
|
+
refusals: Finding[];
|
|
98
|
+
};
|
|
99
|
+
export declare const UPDATE_HANDLER_CODE: {
|
|
100
|
+
readonly noSuchRuntime: "E_UPDATE_NO_SUCH_RUNTIME";
|
|
101
|
+
readonly ambiguousTarget: "E_UPDATE_AMBIGUOUS_TARGET";
|
|
102
|
+
readonly noRuntimes: "E_UPDATE_NO_RUNTIMES";
|
|
103
|
+
readonly unreadableRecipe: "E_UPDATE_UNREADABLE_RECIPE";
|
|
104
|
+
/** Apply refused: the package carries no proof of a passing validation. */
|
|
105
|
+
readonly proofRequired: "E_UPDATE_PROOF_REQUIRED";
|
|
106
|
+
/**
|
|
107
|
+
* Apply refused: a proof exists, but it covers different bytes than the ones being applied.
|
|
108
|
+
*
|
|
109
|
+
* Distinct from {@link proofRequired} because the fix differs — there IS a passing validation, it
|
|
110
|
+
* just does not describe this recipe, so the caller has to reconcile the two rather than run
|
|
111
|
+
* validate for the first time.
|
|
112
|
+
*/
|
|
113
|
+
readonly proofCoversOtherBytes: "E_UPDATE_PROOF_MISMATCH";
|
|
114
|
+
/** `--code-only` was passed, but the recipe changed too. */
|
|
115
|
+
readonly recipeChangedUnderCodeOnly: "E_UPDATE_RECIPE_CHANGED";
|
|
116
|
+
/** The proposed recipe still carries a `${VAR}` that nothing in the environment resolves. */
|
|
117
|
+
readonly unresolvedPlaceholder: "E_UPDATE_UNRESOLVED_PLACEHOLDER";
|
|
118
|
+
/** The swap failed and the runtime was restored to the recipe it was already running. */
|
|
119
|
+
readonly rebuildFailed: "E_UPDATE_REBUILD_FAILED";
|
|
120
|
+
/** The swap failed AND the restore failed. Nothing is managing the book. */
|
|
121
|
+
readonly unmanaged: "E_UPDATE_ROLLBACK_FAILED";
|
|
122
|
+
/** Applied to the live runtime, but not persisted — a restart would revert it. */
|
|
123
|
+
readonly registryDiverged: "E_UPDATE_REGISTRY_DIVERGED";
|
|
124
|
+
};
|
|
125
|
+
export declare function runUpdateDryRun(deps: UpdateHandlerDeps, req: UpdateRequest): Promise<UpdateOutcome>;
|
|
126
|
+
/** What an apply needs on top of the plan: something to swap, and somewhere to record it. */
|
|
127
|
+
export interface UpdateApplyDeps extends UpdateHandlerDeps {
|
|
128
|
+
/**
|
|
129
|
+
* Swap the running runtime onto the new recipe.
|
|
130
|
+
*
|
|
131
|
+
* Throws on failure. Recovery is the runtime's job, not this handler's: `rebuildComponents` does
|
|
132
|
+
* its fallible work before tearing anything down and rolls back to the previous recipe if the
|
|
133
|
+
* swap itself fails, so a throw here means the runtime is either back on its old recipe or — for
|
|
134
|
+
* a `RuntimeRebuildRollbackFailedError` — down with an unmanaged book.
|
|
135
|
+
*/
|
|
136
|
+
/**
|
|
137
|
+
* Swap the runtime onto the new recipe and restart its external scanners.
|
|
138
|
+
*
|
|
139
|
+
* Resolves with `scannersUnwired` set when the recipe DID apply but the scanner children could
|
|
140
|
+
* not be restarted. That is not a failed apply — the new configuration is live in-process — but
|
|
141
|
+
* it is not a clean one either: the outgoing children were already stopped, so a strategy whose
|
|
142
|
+
* entries come from an external scanner has silently stopped taking them. Reporting it as success
|
|
143
|
+
* with no qualification is how a trading halt gets mistaken for a normal day.
|
|
144
|
+
*/
|
|
145
|
+
applyToRuntime(runtimeId: string, next: RuntimeConfig, recipe: RecipeSource): Promise<void | {
|
|
146
|
+
scannersUnwired?: string;
|
|
147
|
+
}>;
|
|
148
|
+
/**
|
|
149
|
+
* Persist the recipe a restart should replay.
|
|
150
|
+
*
|
|
151
|
+
* Called ONLY after the swap succeeded. The two writes cannot be atomic, and this order is the
|
|
152
|
+
* deliberate one: if this fails, a restart reverts to a recipe known to work, where the reverse
|
|
153
|
+
* order would have a restart apply a recipe that had just failed to build.
|
|
154
|
+
*/
|
|
155
|
+
writeRegistry(runtimeId: string, recipe: RecipeSource): Promise<void>;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The outcome of an apply.
|
|
159
|
+
*
|
|
160
|
+
* Three arms rather than two, because "nothing happened" and "something happened and then broke"
|
|
161
|
+
* need different responses from whoever is reading. `refused` means the runtime is untouched and
|
|
162
|
+
* the caller should fix their recipe; `failed` means an apply was attempted, and the finding says
|
|
163
|
+
* what state the runtime is in now.
|
|
164
|
+
*/
|
|
165
|
+
export type UpdateApplyOutcome = {
|
|
166
|
+
ok: true;
|
|
167
|
+
plan: Extract<UpdatePlan, {
|
|
168
|
+
ok: true;
|
|
169
|
+
}>;
|
|
170
|
+
/**
|
|
171
|
+
* Exactly what was written to the registry.
|
|
172
|
+
*
|
|
173
|
+
* The audit event hashes THIS rather than the request: `runtime.updated`'s
|
|
174
|
+
* `senpi.config.hash` is meant to be comparable with the one `runtime.started` stamps on the
|
|
175
|
+
* next boot, and the next boot reads the stored bytes. Hashing the unbound request would
|
|
176
|
+
* make an update look like a different recipe from the one it installed.
|
|
177
|
+
*/
|
|
178
|
+
stored?: RecipeSource;
|
|
179
|
+
} | {
|
|
180
|
+
ok: false;
|
|
181
|
+
stage: "refused";
|
|
182
|
+
refusals: Finding[];
|
|
183
|
+
} | {
|
|
184
|
+
ok: false;
|
|
185
|
+
stage: "failed";
|
|
186
|
+
refusals: Finding[];
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* `senpi update --apply` — plan it, then actually do it.
|
|
190
|
+
*
|
|
191
|
+
* Every refusal the dry run can produce applies here unchanged and still changes nothing. Beyond
|
|
192
|
+
* those, one refusal exists only on this path: a missing or stale proof. A dry run reports it,
|
|
193
|
+
* because refusing would cost the reader the information they came for; an apply enforces it,
|
|
194
|
+
* because otherwise the blocker the dry run printed was decorative.
|
|
195
|
+
*/
|
|
196
|
+
export declare function runUpdateApply(deps: UpdateApplyDeps, req: UpdateRequest): Promise<UpdateApplyOutcome>;
|
|
197
|
+
//# sourceMappingURL=update-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-handler.d.ts","sourceRoot":"","sources":["../../src/runtime/update-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI/D,4FAA4F;AAC5F,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,uDAAuD;AACvD,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,MAAM,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,yGAAyG;IACzG,YAAY,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAC7C,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1D,6FAA6F;IAC7F,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACxD,oDAAoD;IACpD,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACzD;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,EAAE,CAA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S,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IACE,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE;QAAE,EAAE,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;IACxC;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GACD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;CAAE,GACpD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC;AAExD;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,eAAe,EACrB,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,kBAAkB,CAAC,CA4F7B"}
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `senpi update --dry-run` — resolve the target, read both recipes, and produce the plan.
|
|
3
|
+
*
|
|
4
|
+
* The I/O lives in injected deps so the interesting parts — which runtime, which refusals, what the
|
|
5
|
+
* report ends up saying — are testable without a gateway, a registry on disk, or a running runtime.
|
|
6
|
+
* The gateway registration is then a thin adapter, which is the same shape `senpi deploy` uses.
|
|
7
|
+
*
|
|
8
|
+
* ## Dry run only
|
|
9
|
+
*
|
|
10
|
+
* Nothing here tears anything down. That is not merely "not implemented yet": the verb's one safety
|
|
11
|
+
* property is that a refusal changes nothing, so the decision half is worth having — and shipping —
|
|
12
|
+
* before the half that can leave a strategy with no scanners and an open book.
|
|
13
|
+
*
|
|
14
|
+
* ## What it reports rather than refuses
|
|
15
|
+
*
|
|
16
|
+
* A missing or stale proof will refuse the APPLY, exactly as it refuses a deploy. On a dry run it is
|
|
17
|
+
* reported instead: the run changes nothing, so refusing costs the reader the information they came
|
|
18
|
+
* for, and they would have to fix the proof before they could even see whether the change was worth
|
|
19
|
+
* applying.
|
|
20
|
+
*
|
|
21
|
+
* Guardrail state is deliberately NOT gathered. Every gate is derived from live venue history — the
|
|
22
|
+
* per-asset cooldown alone pages through trader history until it finds a close — so collecting them
|
|
23
|
+
* turns a plan into a network round trip per gate. The report says so rather than staying silent,
|
|
24
|
+
* because silence there reads as "all clear".
|
|
25
|
+
*/
|
|
26
|
+
import { isScalar, parseDocument } from "yaml";
|
|
27
|
+
import { planUpdate } from "./update-plan.js";
|
|
28
|
+
import { isRollbackFailure } from "./rebuild-errors.js";
|
|
29
|
+
export const UPDATE_HANDLER_CODE = {
|
|
30
|
+
noSuchRuntime: "E_UPDATE_NO_SUCH_RUNTIME",
|
|
31
|
+
ambiguousTarget: "E_UPDATE_AMBIGUOUS_TARGET",
|
|
32
|
+
noRuntimes: "E_UPDATE_NO_RUNTIMES",
|
|
33
|
+
unreadableRecipe: "E_UPDATE_UNREADABLE_RECIPE",
|
|
34
|
+
/** Apply refused: the package carries no proof of a passing validation. */
|
|
35
|
+
proofRequired: "E_UPDATE_PROOF_REQUIRED",
|
|
36
|
+
/**
|
|
37
|
+
* Apply refused: a proof exists, but it covers different bytes than the ones being applied.
|
|
38
|
+
*
|
|
39
|
+
* Distinct from {@link proofRequired} because the fix differs — there IS a passing validation, it
|
|
40
|
+
* just does not describe this recipe, so the caller has to reconcile the two rather than run
|
|
41
|
+
* validate for the first time.
|
|
42
|
+
*/
|
|
43
|
+
proofCoversOtherBytes: "E_UPDATE_PROOF_MISMATCH",
|
|
44
|
+
/** `--code-only` was passed, but the recipe changed too. */
|
|
45
|
+
recipeChangedUnderCodeOnly: "E_UPDATE_RECIPE_CHANGED",
|
|
46
|
+
/** The proposed recipe still carries a `${VAR}` that nothing in the environment resolves. */
|
|
47
|
+
unresolvedPlaceholder: "E_UPDATE_UNRESOLVED_PLACEHOLDER",
|
|
48
|
+
/** The swap failed and the runtime was restored to the recipe it was already running. */
|
|
49
|
+
rebuildFailed: "E_UPDATE_REBUILD_FAILED",
|
|
50
|
+
/** The swap failed AND the restore failed. Nothing is managing the book. */
|
|
51
|
+
unmanaged: "E_UPDATE_ROLLBACK_FAILED",
|
|
52
|
+
/** Applied to the live runtime, but not persisted — a restart would revert it. */
|
|
53
|
+
registryDiverged: "E_UPDATE_REGISTRY_DIVERGED",
|
|
54
|
+
};
|
|
55
|
+
/** Apply {@link bindWalletPlaceholder} to a recipe source, leaving a path-based source untouched. */
|
|
56
|
+
function bindSourceWallet(source, wallet) {
|
|
57
|
+
return source.content !== undefined
|
|
58
|
+
? { ...source, content: bindWalletPlaceholder(source.content, wallet) }
|
|
59
|
+
: source;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Substitute an unresolved `${VAR}` standing in for `strategy.wallet` with the wallet the target
|
|
63
|
+
* runtime actually runs. Leaves a resolvable variable, and every other placeholder, alone.
|
|
64
|
+
*
|
|
65
|
+
* YAML-aware, addressing `strategy.wallet` by node rather than by text. A line regex over
|
|
66
|
+
* `wallet:` cannot be scoped by indentation — deploy-rendered packages legitimately carry the
|
|
67
|
+
* placeholder indented under `strategy:` — so it also matched a `wallet` key ANYWHERE in the
|
|
68
|
+
* document. Scanner `inputs` is a free-form record, and a copy-trading recipe legitimately carries
|
|
69
|
+
* `inputs: { wallet: ${TRACKED_TRADER} }`: with that variable unset, the regex rebound the tracked
|
|
70
|
+
* trader to this runtime's OWN wallet, the unresolved-placeholder refusal then found nothing, and
|
|
71
|
+
* the corrupted bound form was persisted to the registry for every restart to replay.
|
|
72
|
+
*/
|
|
73
|
+
function bindWalletPlaceholder(content, wallet) {
|
|
74
|
+
if (wallet.length === 0)
|
|
75
|
+
return content;
|
|
76
|
+
const doc = parseDocument(content);
|
|
77
|
+
const node = doc.getIn(["strategy", "wallet"], true);
|
|
78
|
+
if (!isScalar(node) || typeof node.value !== "string")
|
|
79
|
+
return content;
|
|
80
|
+
const name = /^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/.exec(node.value.trim())?.[1];
|
|
81
|
+
// A resolvable variable is the env-resolution layer's job; an absent or literal wallet is not a
|
|
82
|
+
// placeholder. Only the unresolved-placeholder case is bound here.
|
|
83
|
+
if (name === undefined || process.env[name] !== undefined)
|
|
84
|
+
return content;
|
|
85
|
+
node.value = wallet;
|
|
86
|
+
return doc.toString();
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* `${VAR}` occurrences that the environment does not define.
|
|
90
|
+
*
|
|
91
|
+
* `${VAR:-default}` is deliberately NOT reported: it resolves to its default, so it is not a fault.
|
|
92
|
+
*/
|
|
93
|
+
function findUnresolvedPlaceholders(content) {
|
|
94
|
+
if (content === undefined)
|
|
95
|
+
return [];
|
|
96
|
+
const seen = new Set();
|
|
97
|
+
for (const m of content.matchAll(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g)) {
|
|
98
|
+
const name = m[1];
|
|
99
|
+
if (name !== undefined && process.env[name] === undefined)
|
|
100
|
+
seen.add(`\${${name}}`);
|
|
101
|
+
}
|
|
102
|
+
return [...seen];
|
|
103
|
+
}
|
|
104
|
+
function refusal(code, what, why, fix) {
|
|
105
|
+
return { code, severity: "error", stage: "invocation", actor: "agent", fix_kind: "command", what, why, fix };
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Which runtime is meant.
|
|
109
|
+
*
|
|
110
|
+
* Inference is allowed only when there is exactly one candidate. An update rebuilds a live
|
|
111
|
+
* strategy's components, so guessing at the target is not a convenience — it is picking someone's
|
|
112
|
+
* position book at random.
|
|
113
|
+
*/
|
|
114
|
+
function resolveTarget(runtimes, req) {
|
|
115
|
+
if (runtimes.length === 0) {
|
|
116
|
+
return {
|
|
117
|
+
ok: false,
|
|
118
|
+
refusal: refusal(UPDATE_HANDLER_CODE.noRuntimes, "No runtimes are installed on this box", "There is nothing to update. A strategy has to be deployed before its recipe can be changed.", "Deploy it first: senpi deploy -p <package-dir> --budget <usd>"),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
const wanted = req.id ?? req.address;
|
|
122
|
+
if (wanted !== undefined) {
|
|
123
|
+
const match = runtimes.find((r) => r.id === req.id || (req.address !== undefined && r.wallet.toLowerCase() === req.address.toLowerCase()));
|
|
124
|
+
if (!match) {
|
|
125
|
+
return {
|
|
126
|
+
ok: false,
|
|
127
|
+
refusal: refusal(UPDATE_HANDLER_CODE.noSuchRuntime, `No installed runtime matches '${wanted}'`, "The update would have nothing to act on.", `Installed runtimes: ${runtimes.map((r) => r.id).join(", ")}. Check the id with: openclaw senpi runtime list`),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return { ok: true, runtime: match };
|
|
131
|
+
}
|
|
132
|
+
if (runtimes.length > 1) {
|
|
133
|
+
return {
|
|
134
|
+
ok: false,
|
|
135
|
+
refusal: refusal(UPDATE_HANDLER_CODE.ambiguousTarget, `This box runs ${runtimes.length} runtimes and none was named`, "An update rebuilds a live strategy's components. Choosing one by guessing is choosing someone's open position book by guessing.", `Name one with --id: ${runtimes.map((r) => r.id).join(", ")}`),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
return { ok: true, runtime: runtimes[0] };
|
|
139
|
+
}
|
|
140
|
+
/** The report needs a stop price and who owns it; the rest of DslState is noise here. */
|
|
141
|
+
function toReportedPosition(state) {
|
|
142
|
+
return {
|
|
143
|
+
asset: state.asset,
|
|
144
|
+
direction: state.direction,
|
|
145
|
+
entryPrice: state.entryPrice,
|
|
146
|
+
floorPrice: state.floorPrice,
|
|
147
|
+
phase: state.phase,
|
|
148
|
+
// Once handed off, the backend ratchet owns the venue stop and the runtime cannot re-configure
|
|
149
|
+
// it — which is exactly what the reader needs to know before believing a preset change reaches
|
|
150
|
+
// this position.
|
|
151
|
+
backendManaged: state.handoffStatus === "ok",
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Everything both the plan and the apply must agree on: which runtime, both recipes, the gate, the
|
|
156
|
+
* report, and whatever would block an apply.
|
|
157
|
+
*
|
|
158
|
+
* Shared rather than duplicated so a plan cannot describe one thing and an apply do another — the
|
|
159
|
+
* property a test already pins by asserting the two reports differ only in `applied`.
|
|
160
|
+
*/
|
|
161
|
+
async function prepare(deps, req, applied) {
|
|
162
|
+
const target = resolveTarget(await deps.listRuntimes(), req);
|
|
163
|
+
if (!target.ok)
|
|
164
|
+
return { ok: false, refusals: [target.refusal] };
|
|
165
|
+
const runtime = target.runtime;
|
|
166
|
+
let current;
|
|
167
|
+
let next;
|
|
168
|
+
try {
|
|
169
|
+
// The STORED recipe gets the same binding as the proposed one. A registry entry can itself
|
|
170
|
+
// hold an unresolved `${WALLET}` — either because an older build persisted the raw request, or
|
|
171
|
+
// because a deploy stored a form it could not re-read — and without this the runtime becomes
|
|
172
|
+
// permanently un-updatable: every call refuses with "the recipe it is currently running could
|
|
173
|
+
// not be parsed", including the call that would replace it.
|
|
174
|
+
//
|
|
175
|
+
// Binding here makes the verb self-healing: the update proceeds, and the apply persists the
|
|
176
|
+
// bound form, so the corrupted entry is corrected by the first successful update.
|
|
177
|
+
current = await deps.parseConfig(bindSourceWallet(runtime.source, runtime.wallet));
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
// The recipe the runtime is RUNNING failed to parse. That is not the user's edit being wrong —
|
|
181
|
+
// it is the stored copy being unreadable, which they cannot fix by editing their package.
|
|
182
|
+
return {
|
|
183
|
+
ok: false,
|
|
184
|
+
refusals: [
|
|
185
|
+
refusal(UPDATE_HANDLER_CODE.unreadableRecipe, `The recipe '${runtime.id}' is currently running could not be parsed`, "Without it there is nothing to compare the change against, so the update cannot say what it would alter.", `This is a stored-state problem rather than a problem with your edit. Reinstall the runtime: ${String(err)}`),
|
|
186
|
+
],
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
// `strategy.wallet: "${SOME_VAR}"` is what a deploy.py package carries on disk: `strategy.yaml`
|
|
190
|
+
// declares `wallet_env: SOME_VAR`, and the deploy renderer substitutes the wallet it created at
|
|
191
|
+
// install time, storing only the RESULT in the registry. The variable never exists at runtime, so
|
|
192
|
+
// the on-disk recipe is unloadable by anything afterwards — which made `senpi update ./pkg`, the
|
|
193
|
+
// documented invocation, impossible for every deployed strategy.
|
|
194
|
+
//
|
|
195
|
+
// Bind it to the wallet this runtime is already known to run. That is not a guess: the wallet is
|
|
196
|
+
// the deployment's identity, changing it is refused outright a few lines below, and substituting
|
|
197
|
+
// any OTHER value could only produce that refusal. Anything else left unresolved is still an
|
|
198
|
+
// error, because nothing here knows what it was meant to be.
|
|
199
|
+
const recipeSource = {
|
|
200
|
+
...req.recipe,
|
|
201
|
+
...(req.recipe.content !== undefined
|
|
202
|
+
? { content: bindWalletPlaceholder(req.recipe.content, runtime.wallet) }
|
|
203
|
+
: {}),
|
|
204
|
+
};
|
|
205
|
+
// A package deployed by `deploy.py` keeps `${VAR}` placeholders in its on-disk recipe — the
|
|
206
|
+
// renderer substitutes them at install time and stores only the RESULT in the registry, so the
|
|
207
|
+
// file on disk cannot be loaded by anything afterwards unless that variable is still exported.
|
|
208
|
+
// Without this, the failure surfaces as "strategy.wallet: strategy must have a wallet", which
|
|
209
|
+
// sends the reader looking for a missing field that is plainly present in the file.
|
|
210
|
+
const unresolved = findUnresolvedPlaceholders(recipeSource.content);
|
|
211
|
+
if (unresolved.length > 0) {
|
|
212
|
+
return {
|
|
213
|
+
ok: false,
|
|
214
|
+
refusals: [
|
|
215
|
+
refusal(UPDATE_HANDLER_CODE.unresolvedPlaceholder, `The recipe still contains ${unresolved.length === 1 ? "an unresolved placeholder" : "unresolved placeholders"}: ${unresolved.join(", ")}`, "Nothing in the environment resolves it, so the recipe cannot be read. A package deployed " +
|
|
216
|
+
"through deploy.py keeps these placeholders on disk — the rendered recipe, with the values " +
|
|
217
|
+
"already substituted, lives in the runtime registry rather than in the package.", `Export the variable and re-run (e.g. ${unresolved[0]?.replace(/[${}]/g, "")}=…), or update from a recipe that has the values in it.`),
|
|
218
|
+
],
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
try {
|
|
222
|
+
next = await deps.parseConfig(recipeSource);
|
|
223
|
+
}
|
|
224
|
+
catch (err) {
|
|
225
|
+
return {
|
|
226
|
+
ok: false,
|
|
227
|
+
refusals: [
|
|
228
|
+
refusal(UPDATE_HANDLER_CODE.unreadableRecipe, "The proposed recipe could not be parsed", "Nothing is changed; the runtime keeps running its current recipe.", `Fix the YAML and re-run: ${String(err)}`),
|
|
229
|
+
],
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
// The same gate `senpi.installRuntime` applies, run BEFORE anything is torn down — which is the
|
|
233
|
+
// whole reason an update can refuse safely where a boot loop cannot.
|
|
234
|
+
const gate = await deps.installGate(await deps.recipeFindings(recipeSource));
|
|
235
|
+
if (!gate.ok)
|
|
236
|
+
return { ok: false, refusals: gate.blocking };
|
|
237
|
+
// Compared as PARSED configs rather than raw text: a reformatted comment or a changed line
|
|
238
|
+
// ending is not a change to what the strategy does, and refusing over one would teach users to
|
|
239
|
+
// stop passing the flag.
|
|
240
|
+
const recipeUnchanged = JSON.stringify(current) === JSON.stringify(next);
|
|
241
|
+
if (req.codeOnly === true && !recipeUnchanged) {
|
|
242
|
+
return {
|
|
243
|
+
ok: false,
|
|
244
|
+
refusals: [
|
|
245
|
+
refusal(UPDATE_HANDLER_CODE.recipeChangedUnderCodeOnly, "--code-only was passed, but the recipe changed as well", "The flag asserts that only scanner code differs. Applying anyway would ship a recipe " +
|
|
246
|
+
"change the caller did not mean to make, alongside the code they did.", "Re-run without --code-only to see what the recipe change would do, or revert the recipe " +
|
|
247
|
+
"and re-run with it."),
|
|
248
|
+
],
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
const plan = planUpdate({
|
|
252
|
+
runtimeId: runtime.id,
|
|
253
|
+
current,
|
|
254
|
+
next,
|
|
255
|
+
// Read BEFORE anything is swapped: these are the positions the change is being judged against.
|
|
256
|
+
openPositions: (await deps.activePositions(runtime.id)).map(toReportedPosition),
|
|
257
|
+
closedGates: [],
|
|
258
|
+
applied,
|
|
259
|
+
});
|
|
260
|
+
if (!plan.ok)
|
|
261
|
+
return { ok: false, refusals: plan.refusals };
|
|
262
|
+
const packageDir = recipeSource.dir ?? (recipeSource.path !== undefined ? recipeSource.path : undefined);
|
|
263
|
+
const applyBlockers = [];
|
|
264
|
+
if (packageDir !== undefined) {
|
|
265
|
+
// `req.recipe.content`, not `recipeSource.content`: the latter has had the wallet placeholder
|
|
266
|
+
// bound into it and would not match the file the proof was taken over.
|
|
267
|
+
const proof = await deps.verifyProof(packageDir, req.recipe.content);
|
|
268
|
+
if (!proof.ok && proof.finding)
|
|
269
|
+
applyBlockers.push(proof.finding);
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
// A recipe that arrives as content with no directory has nothing to check a proof against, and
|
|
273
|
+
// an apply that cannot be checked is precisely the one that must not proceed. Leaving this case
|
|
274
|
+
// silent meant the gate every other invocation passes through simply did not run: no proof was
|
|
275
|
+
// read, none was required, and the swap went ahead on unvalidated bytes.
|
|
276
|
+
//
|
|
277
|
+
// Recorded as an applyBlocker rather than a plan refusal so `--dry-run` keeps working — the
|
|
278
|
+
// plan still renders, with the gate named as the thing standing between it and an apply.
|
|
279
|
+
applyBlockers.push(refusal(UPDATE_HANDLER_CODE.proofRequired, "This update cannot be checked against a validation proof", "A proof is a claim about the exact contents of a package on disk. This recipe arrived as " +
|
|
280
|
+
"content with no directory, so there is nothing to verify it against and nothing is " +
|
|
281
|
+
"known about how it behaves.", "Re-run against the package directory: openclaw senpi update <package-dir> --apply"));
|
|
282
|
+
}
|
|
283
|
+
return {
|
|
284
|
+
ok: true,
|
|
285
|
+
runtime,
|
|
286
|
+
next,
|
|
287
|
+
plan: { ok: true, report: { ...plan.report, applyBlockers, recipeUnchanged } },
|
|
288
|
+
applyBlockers,
|
|
289
|
+
recipeUnchanged,
|
|
290
|
+
recipeSource,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
export async function runUpdateDryRun(deps, req) {
|
|
294
|
+
const prepared = await prepare(deps, req, false);
|
|
295
|
+
if (!prepared.ok)
|
|
296
|
+
return { ok: false, refusals: prepared.refusals };
|
|
297
|
+
return { ok: true, plan: prepared.plan };
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* `senpi update --apply` — plan it, then actually do it.
|
|
301
|
+
*
|
|
302
|
+
* Every refusal the dry run can produce applies here unchanged and still changes nothing. Beyond
|
|
303
|
+
* those, one refusal exists only on this path: a missing or stale proof. A dry run reports it,
|
|
304
|
+
* because refusing would cost the reader the information they came for; an apply enforces it,
|
|
305
|
+
* because otherwise the blocker the dry run printed was decorative.
|
|
306
|
+
*/
|
|
307
|
+
export async function runUpdateApply(deps, req) {
|
|
308
|
+
const prepared = await prepare(deps, req, true);
|
|
309
|
+
if (!prepared.ok)
|
|
310
|
+
return { ok: false, stage: "refused", refusals: prepared.refusals };
|
|
311
|
+
// The proof gate. `senpi validate` writes the proof, and an update is a change to the same bytes
|
|
312
|
+
// a deploy would have had to validate, so applying without one would let an update install
|
|
313
|
+
// something `senpi deploy` would have refused.
|
|
314
|
+
if (prepared.applyBlockers.length > 0) {
|
|
315
|
+
return {
|
|
316
|
+
ok: false,
|
|
317
|
+
stage: "refused",
|
|
318
|
+
refusals: prepared.applyBlockers.map((blocker) => ({
|
|
319
|
+
...blocker,
|
|
320
|
+
code: blocker.code,
|
|
321
|
+
what: blocker.what,
|
|
322
|
+
why: `${blocker.why} Nothing has been changed — the runtime keeps running its current recipe.`,
|
|
323
|
+
})),
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
let scannersUnwired;
|
|
327
|
+
try {
|
|
328
|
+
// The bound form here too. Nothing reads this argument today, but handing a consumer the
|
|
329
|
+
// unresolved recipe is the same trap that corrupted stored state.
|
|
330
|
+
const applied = await deps.applyToRuntime(prepared.runtime.id, prepared.next, prepared.recipeSource);
|
|
331
|
+
if (applied && applied.scannersUnwired)
|
|
332
|
+
scannersUnwired = applied.scannersUnwired;
|
|
333
|
+
}
|
|
334
|
+
catch (err) {
|
|
335
|
+
// The runtime distinguishes the two failure shapes, and they need different reactions: one is a
|
|
336
|
+
// failed change on a healthy runtime, the other is an open book with nothing watching it.
|
|
337
|
+
if (isRollbackFailure(err)) {
|
|
338
|
+
return {
|
|
339
|
+
ok: false,
|
|
340
|
+
stage: "failed",
|
|
341
|
+
refusals: [
|
|
342
|
+
refusal(UPDATE_HANDLER_CODE.unmanaged, `Runtime '${prepared.runtime.id}' is DOWN and its positions are unmanaged`, "The updated recipe failed to build and the previous one could not be restored, so no " +
|
|
343
|
+
"exit engine is running. Open positions are not being watched and no stop is being maintained.", `Restart the runtime, then check this wallet's positions at the venue: ${err.address}`),
|
|
344
|
+
],
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
return {
|
|
348
|
+
ok: false,
|
|
349
|
+
stage: "failed",
|
|
350
|
+
refusals: [
|
|
351
|
+
refusal(UPDATE_HANDLER_CODE.rebuildFailed, `The update to '${prepared.runtime.id}' could not be applied`, `The runtime was restored to the recipe it was already running and is still trading on it. ${String(err)}`, "Fix the recipe and re-run. Nothing about the running strategy has changed."),
|
|
352
|
+
],
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
try {
|
|
356
|
+
// `prepared.recipeSource`, NOT `req.recipe`: the bound form. Persisting the raw request stores
|
|
357
|
+
// an unresolved `${WALLET}` as the recipe a restart replays — the apply succeeds, the runtime
|
|
358
|
+
// keeps running, and the next boot cannot parse its own stored recipe. Found on a live box.
|
|
359
|
+
await deps.writeRegistry(prepared.runtime.id, prepared.recipeSource);
|
|
360
|
+
}
|
|
361
|
+
catch (err) {
|
|
362
|
+
// The change IS live. What failed is the record of it, which is what a restart replays — so
|
|
363
|
+
// this cannot be reported as success, and it cannot be reported as "nothing happened" either.
|
|
364
|
+
return {
|
|
365
|
+
ok: false,
|
|
366
|
+
stage: "failed",
|
|
367
|
+
refusals: [
|
|
368
|
+
refusal(UPDATE_HANDLER_CODE.registryDiverged, `Runtime '${prepared.runtime.id}' is running the new recipe, but it was not recorded`, `The swap succeeded and the strategy is trading the updated recipe now. Saving it as the ` +
|
|
369
|
+
`recipe to replay failed, so a restart would silently revert to the previous one. ${String(err)}`, "Re-run the update to record it. Do not restart the runtime until it succeeds."),
|
|
370
|
+
],
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
return {
|
|
374
|
+
ok: true,
|
|
375
|
+
plan: scannersUnwired
|
|
376
|
+
? { ...prepared.plan, report: { ...prepared.plan.report, scannersUnwired } }
|
|
377
|
+
: prepared.plan,
|
|
378
|
+
stored: prepared.recipeSource,
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
//# sourceMappingURL=update-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-handler.js","sourceRoot":"","sources":["../../src/runtime/update-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAI/C,OAAO,EAAE,UAAU,EAAmB,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAmExD,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,aAAa,EAAE,0BAA0B;IACzC,eAAe,EAAE,2BAA2B;IAC5C,UAAU,EAAE,sBAAsB;IAClC,gBAAgB,EAAE,4BAA4B;IAC9C,2EAA2E;IAC3E,aAAa,EAAE,yBAAyB;IACxC;;;;;;OAMG;IACH,qBAAqB,EAAE,yBAAyB;IAChD,4DAA4D;IAC5D,0BAA0B,EAAE,yBAAyB;IACrD,6FAA6F;IAC7F,qBAAqB,EAAE,iCAAiC;IACxD,yFAAyF;IACzF,aAAa,EAAE,yBAAyB;IACxC,4EAA4E;IAC5E,SAAS,E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