@senpi-ai/runtime 3.0.70 → 3.0.78
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/README.md +76 -2
- package/dist/cli/deploy-render.d.ts +93 -0
- package/dist/cli/deploy-render.d.ts.map +1 -0
- package/dist/cli/deploy-render.js +438 -0
- package/dist/cli/deploy-render.js.map +1 -0
- package/dist/cli/guide-commands.d.ts.map +1 -1
- package/dist/cli/guide-commands.js +94 -9
- package/dist/cli/guide-commands.js.map +1 -1
- package/dist/cli/senpi-commands.d.ts +6 -1
- package/dist/cli/senpi-commands.d.ts.map +1 -1
- package/dist/cli/senpi-commands.js +290 -41
- package/dist/cli/senpi-commands.js.map +1 -1
- package/dist/cli/validate-command.d.ts.map +1 -1
- package/dist/cli/validate-command.js +10 -1
- package/dist/cli/validate-command.js.map +1 -1
- package/dist/deploy/deadlines.d.ts +107 -0
- package/dist/deploy/deadlines.d.ts.map +1 -0
- package/dist/deploy/deadlines.js +139 -0
- package/dist/deploy/deadlines.js.map +1 -0
- package/dist/deploy/error-text.d.ts +25 -0
- package/dist/deploy/error-text.d.ts.map +1 -0
- package/dist/deploy/error-text.js +42 -0
- package/dist/deploy/error-text.js.map +1 -0
- package/dist/deploy/funding.d.ts +125 -0
- package/dist/deploy/funding.d.ts.map +1 -0
- package/dist/deploy/funding.js +268 -0
- package/dist/deploy/funding.js.map +1 -0
- package/dist/deploy/install-gate-runner.d.ts +12 -0
- package/dist/deploy/install-gate-runner.d.ts.map +1 -0
- package/dist/deploy/install-gate-runner.js +17 -0
- package/dist/deploy/install-gate-runner.js.map +1 -0
- package/dist/deploy/job.d.ts +215 -0
- package/dist/deploy/job.d.ts.map +1 -0
- package/dist/deploy/job.js +484 -0
- package/dist/deploy/job.js.map +1 -0
- package/dist/deploy/messages.d.ts +603 -0
- package/dist/deploy/messages.d.ts.map +1 -0
- package/dist/deploy/messages.js +1388 -0
- package/dist/deploy/messages.js.map +1 -0
- package/dist/deploy/min-budget.d.ts +68 -0
- package/dist/deploy/min-budget.d.ts.map +1 -0
- package/dist/deploy/min-budget.js +297 -0
- package/dist/deploy/min-budget.js.map +1 -0
- package/dist/deploy/orchestrator.d.ts +314 -0
- package/dist/deploy/orchestrator.d.ts.map +1 -0
- package/dist/deploy/orchestrator.js +2171 -0
- package/dist/deploy/orchestrator.js.map +1 -0
- package/dist/deploy/package.d.ts +228 -0
- package/dist/deploy/package.d.ts.map +1 -0
- package/dist/deploy/package.js +542 -0
- package/dist/deploy/package.js.map +1 -0
- package/dist/deploy/proof-gate.d.ts +86 -0
- package/dist/deploy/proof-gate.d.ts.map +1 -0
- package/dist/deploy/proof-gate.js +278 -0
- package/dist/deploy/proof-gate.js.map +1 -0
- package/dist/deploy/python-float.d.ts +34 -0
- package/dist/deploy/python-float.d.ts.map +1 -0
- package/dist/deploy/python-float.js +46 -0
- package/dist/deploy/python-float.js.map +1 -0
- package/dist/deploy/recheck-commands.d.ts +50 -0
- package/dist/deploy/recheck-commands.d.ts.map +1 -0
- package/dist/deploy/recheck-commands.js +77 -0
- package/dist/deploy/recheck-commands.js.map +1 -0
- package/dist/deploy/register.d.ts +101 -0
- package/dist/deploy/register.d.ts.map +1 -0
- package/dist/deploy/register.js +714 -0
- package/dist/deploy/register.js.map +1 -0
- package/dist/deploy/taxonomy.d.ts +43 -0
- package/dist/deploy/taxonomy.d.ts.map +1 -0
- package/dist/deploy/taxonomy.js +59 -0
- package/dist/deploy/taxonomy.js.map +1 -0
- package/dist/dsl/events/handlers.d.ts +6 -4
- package/dist/dsl/events/handlers.d.ts.map +1 -1
- package/dist/dsl/events/handlers.js +29 -17
- package/dist/dsl/events/handlers.js.map +1 -1
- package/dist/dsl/events/initial-state.d.ts +21 -11
- package/dist/dsl/events/initial-state.d.ts.map +1 -1
- package/dist/dsl/events/initial-state.js +6 -0
- package/dist/dsl/events/initial-state.js.map +1 -1
- package/dist/dsl/notifications/floor-store.d.ts.map +1 -1
- package/dist/dsl/notifications/floor-store.js +34 -5
- package/dist/dsl/notifications/floor-store.js.map +1 -1
- package/dist/dsl/notifications/formatter.d.ts.map +1 -1
- package/dist/dsl/notifications/formatter.js +13 -5
- package/dist/dsl/notifications/formatter.js.map +1 -1
- package/dist/dsl/notifications/index.d.ts +18 -1
- package/dist/dsl/notifications/index.d.ts.map +1 -1
- package/dist/dsl/notifications/index.js +78 -11
- package/dist/dsl/notifications/index.js.map +1 -1
- package/dist/dsl/notifications/stop-raise-debounce.d.ts +113 -0
- package/dist/dsl/notifications/stop-raise-debounce.d.ts.map +1 -0
- package/dist/dsl/notifications/stop-raise-debounce.js +223 -0
- package/dist/dsl/notifications/stop-raise-debounce.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +467 -222
- package/dist/index.js.map +1 -1
- package/dist/runtime/env-resolve.d.ts +13 -0
- package/dist/runtime/env-resolve.d.ts.map +1 -1
- package/dist/runtime/env-resolve.js +14 -1
- package/dist/runtime/env-resolve.js.map +1 -1
- package/dist/runtime/runtime-descriptor.d.ts +37 -0
- package/dist/runtime/runtime-descriptor.d.ts.map +1 -0
- package/dist/runtime/runtime-descriptor.js +163 -0
- package/dist/runtime/runtime-descriptor.js.map +1 -0
- package/dist/runtime/runtime-schema.d.ts +100 -100
- package/dist/runtime/strategy-registry.d.ts +8 -0
- package/dist/runtime/strategy-registry.d.ts.map +1 -1
- package/dist/runtime/strategy-registry.js +14 -1
- package/dist/runtime/strategy-registry.js.map +1 -1
- package/dist/runtime-api/intake/intake-mount.d.ts.map +1 -1
- package/dist/runtime-api/intake/intake-mount.js +7 -4
- package/dist/runtime-api/intake/intake-mount.js.map +1 -1
- package/dist/scanners/external/scaffold/preflight.py +39 -0
- package/dist/scanners/implementations/market-regime.d.ts +1 -1
- package/dist/senpi/client.d.ts +58 -4
- package/dist/senpi/client.d.ts.map +1 -1
- package/dist/senpi/client.js +262 -18
- package/dist/senpi/client.js.map +1 -1
- package/dist/senpi/strategy-status.d.ts +32 -0
- package/dist/senpi/strategy-status.d.ts.map +1 -0
- package/dist/senpi/strategy-status.js +70 -0
- package/dist/senpi/strategy-status.js.map +1 -0
- package/dist/senpi/types.d.ts +65 -3
- package/dist/senpi/types.d.ts.map +1 -1
- package/dist/skills-manager/manifest.js +3 -3
- package/dist/skills-manager/skills-manifest.json +3 -3
- package/dist/telemetry/metrics.d.ts +30 -0
- package/dist/telemetry/metrics.d.ts.map +1 -1
- package/dist/telemetry/metrics.js +72 -0
- package/dist/telemetry/metrics.js.map +1 -1
- package/dist/types/dsl/index.d.ts +14 -0
- package/dist/types/dsl/index.d.ts.map +1 -1
- package/dist/types/strategy.d.ts +9 -1
- package/dist/types/strategy.d.ts.map +1 -1
- package/dist/universe/package-universe.d.ts +97 -0
- package/dist/universe/package-universe.d.ts.map +1 -0
- package/dist/universe/package-universe.js +304 -0
- package/dist/universe/package-universe.js.map +1 -0
- package/dist/validate/codes.d.ts +30 -0
- package/dist/validate/codes.d.ts.map +1 -1
- package/dist/validate/codes.js +74 -1
- package/dist/validate/codes.js.map +1 -1
- package/dist/validate/index.d.ts +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js.map +1 -1
- package/dist/validate/install-gate.d.ts.map +1 -1
- package/dist/validate/install-gate.js +10 -2
- package/dist/validate/install-gate.js.map +1 -1
- package/dist/validate/live-instruments.d.ts +44 -0
- package/dist/validate/live-instruments.d.ts.map +1 -0
- package/dist/validate/live-instruments.js +71 -0
- package/dist/validate/live-instruments.js.map +1 -0
- package/dist/validate/live-stage.d.ts +8 -0
- package/dist/validate/live-stage.d.ts.map +1 -1
- package/dist/validate/live-stage.js +87 -18
- package/dist/validate/live-stage.js.map +1 -1
- package/dist/validate/package-gates-stage.d.ts +61 -0
- package/dist/validate/package-gates-stage.d.ts.map +1 -0
- package/dist/validate/package-gates-stage.js +215 -0
- package/dist/validate/package-gates-stage.js.map +1 -0
- package/dist/validate/proof.d.ts +11 -1
- package/dist/validate/proof.d.ts.map +1 -1
- package/dist/validate/proof.js +10 -6
- package/dist/validate/proof.js.map +1 -1
- package/dist/validate/recipe-checks.d.ts.map +1 -1
- package/dist/validate/recipe-checks.js +6 -4
- package/dist/validate/recipe-checks.js.map +1 -1
- package/dist/validate/run.d.ts +29 -1
- package/dist/validate/run.d.ts.map +1 -1
- package/dist/validate/run.js +65 -6
- package/dist/validate/run.js.map +1 -1
- package/dist/validate/target.d.ts +41 -0
- package/dist/validate/target.d.ts.map +1 -1
- package/dist/validate/target.js +192 -16
- package/dist/validate/target.js.map +1 -1
- package/dist/validate/taxonomy-finding.d.ts +22 -0
- package/dist/validate/taxonomy-finding.d.ts.map +1 -0
- package/dist/validate/taxonomy-finding.js +25 -0
- package/dist/validate/taxonomy-finding.js.map +1 -0
- package/dist/validate/universe-stage.d.ts +71 -0
- package/dist/validate/universe-stage.d.ts.map +1 -0
- package/dist/validate/universe-stage.js +165 -0
- package/dist/validate/universe-stage.js.map +1 -0
- package/dist/validate/wallet-binding-stage.d.ts +44 -0
- package/dist/validate/wallet-binding-stage.d.ts.map +1 -0
- package/dist/validate/wallet-binding-stage.js +92 -0
- package/dist/validate/wallet-binding-stage.js.map +1 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strategy-package model for `senpi deploy` — the TS subset of the
|
|
3
|
+
* `strategy.yaml` + per-instance `runtime.yaml` layout that `deploy.py`'s
|
|
4
|
+
* `_pkg.py` owns on the skills side. Field names deliberately mirror the YAML
|
|
5
|
+
* so a reader can diff the two without a translation table.
|
|
6
|
+
*
|
|
7
|
+
* This module is pure: it reads files and throws teaching errors. It never
|
|
8
|
+
* touches the network, the registry, or money.
|
|
9
|
+
*/
|
|
10
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
11
|
+
import { basename, join, dirname, resolve, relative, isAbsolute } from "node:path";
|
|
12
|
+
import { parse as parseYaml } from "yaml";
|
|
13
|
+
import { ENV_VAR_PATTERN_SOURCE } from "../runtime/env-resolve.js";
|
|
14
|
+
import { pythonFloat } from "./python-float.js";
|
|
15
|
+
/** Platform cap on a strategy name; also the cap on a derived wallet/runtime id. */
|
|
16
|
+
const WALLET_NAME_MAX = 40;
|
|
17
|
+
/** Matches a whole-value `${TOKEN}` wallet binding in a flat package's runtime.yaml. */
|
|
18
|
+
const WALLET_TOKEN_RE = /^\$\{([A-Z0-9_]+)\}$/;
|
|
19
|
+
/**
|
|
20
|
+
* Any surviving `${...}` after render — an unresolved placeholder must never reach the runtime.
|
|
21
|
+
*
|
|
22
|
+
* Built from the EXPANDER's own grammar ({@link ENV_VAR_PATTERN_SOURCE}) rather than a local
|
|
23
|
+
* approximation of it. This gate used to be `\$\{[A-Z0-9_]+\}`, which cannot match `:` or `-`, so
|
|
24
|
+
* `${SENPI_API_KEY:-x}` — a form `resolveEnvInString` expands — passed it silently and installed
|
|
25
|
+
* verbatim, handing the box's credentials to author-written scanner code as an ordinary input
|
|
26
|
+
* value. Sharing the grammar is what makes the gate's stated purpose true: anything left as
|
|
27
|
+
* `${...}` is a packaging bug and throws rather than reaching the runtime.
|
|
28
|
+
*/
|
|
29
|
+
const LEFTOVER_TOKEN_RE = new RegExp(ENV_VAR_PATTERN_SOURCE);
|
|
30
|
+
/** Port of deploy.py `_sanitize_strategy_name`: whitespace→'-', keep [A-Za-z0-9_-], trim '-', cap 40. */
|
|
31
|
+
export function sanitizeStrategyName(name) {
|
|
32
|
+
const collapsed = name
|
|
33
|
+
.trim()
|
|
34
|
+
.replace(/\s+/g, "-")
|
|
35
|
+
.replace(/[^A-Za-z0-9_-]/g, "")
|
|
36
|
+
.replace(/^-+|-+$/g, "");
|
|
37
|
+
return collapsed.slice(0, WALLET_NAME_MAX);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The identity that has to ROUND-TRIP is the COMBINED `<id>-<instance>`: the runtime registers
|
|
41
|
+
* `sanitizeStrategyName("<id>-<instance>")` (the orchestrator's install id and register.ts's live
|
|
42
|
+
* read both derive it, for flat packages too) while `close.py --instance` looks up the raw
|
|
43
|
+
* `<id>-<instance>` by exact string match. Checking the instance name alone left two ways through:
|
|
44
|
+
* a package id sanitization would change, and a combined identity past the 40-char cap — which the
|
|
45
|
+
* sanitizer TRUNCATES rather than rejects, so the sleeve installs fine and can never be closed by
|
|
46
|
+
* instance. Load time is the one seam where both consumers' assumption is made true by
|
|
47
|
+
* construction; both refusals teach the edit, like the instance-name one does.
|
|
48
|
+
*/
|
|
49
|
+
function assertIdentityRoundTrips(id, name, manifestPath) {
|
|
50
|
+
if (sanitizeStrategyName(id) !== id) {
|
|
51
|
+
throw new Error(`strategy.yaml id "${id}" is not usable as a strategy/runtime id — use ` +
|
|
52
|
+
`"${sanitizeStrategyName(id)}" instead (letters, digits, "_" and "-" only, no spaces, no ` +
|
|
53
|
+
`leading/trailing "-") (${manifestPath}). The runtime registers the sanitized ` +
|
|
54
|
+
`"<id>-<instance>" while teardown looks up the raw one, so an id that changes here cannot ` +
|
|
55
|
+
`be closed by instance later — and the id is shell input in every emitted command.`);
|
|
56
|
+
}
|
|
57
|
+
const combined = `${id}-${name}`;
|
|
58
|
+
if (sanitizeStrategyName(combined) !== combined) {
|
|
59
|
+
throw new Error(`strategy.yaml id "${id}" + instance "${name}" combine to "${combined}" ` +
|
|
60
|
+
`(${combined.length} chars), over the ${WALLET_NAME_MAX}-char strategy/runtime id cap — ` +
|
|
61
|
+
`shorten the package id or the instance name so "<id>-<instance>" fits in ` +
|
|
62
|
+
`${WALLET_NAME_MAX} (${manifestPath}). The runtime would register a TRUNCATED id while ` +
|
|
63
|
+
`teardown looks up the full one, so this sleeve could never be closed by instance later.`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The package id when it is NOT already lowercase — the offending spelling, or null.
|
|
68
|
+
*
|
|
69
|
+
* `createWallet` stamps `skillName: pkg.id` VERBATIM at create while the backend stores what it is
|
|
70
|
+
* given case-normalized ("WARPATH" in, "warpath" back), so a mixed-case id is written under one
|
|
71
|
+
* spelling and read back under another. That is how `close.py '<id>'` came to report "no OPEN
|
|
72
|
+
* strategies to close." over a live, funded, trading wallet. Both sides now case-FOLD every stamp
|
|
73
|
+
* compare, which is the half that finds wallets already stamped in any case; requiring one
|
|
74
|
+
* canonical spelling is the half that keeps the next reader from having to remember to.
|
|
75
|
+
*
|
|
76
|
+
* Deliberately NOT a load refusal, and deliberately not part of {@link assertIdentityRoundTrips}:
|
|
77
|
+
* a mixed-case id round-trips through `sanitizeStrategyName` perfectly — capitals are legal there.
|
|
78
|
+
* What it breaks is the STAMP, which is minted on the deploy path, so that is where the gate goes
|
|
79
|
+
* (`register.ts`'s `localStartRefusal` and the orchestrator's own copy, both pre-money).
|
|
80
|
+
* `loadDeployPackage` is shared with two reads that are not creates: `senpi deploy status`'s
|
|
81
|
+
* interrupted render — the one surface that tells an operator which wallets a crashed deploy left
|
|
82
|
+
* FUNDED — and `senpi validate`'s target resolution. Refusing at load would blank that render for
|
|
83
|
+
* a package that already has money in the ground. Same call the skills side made for the same
|
|
84
|
+
* reason: the rule lives in `_pkg.validate`, which `deploy.py` runs before every money verb, and
|
|
85
|
+
* never in `_pkg.load`, which `close.py` needs in order to tear a package down.
|
|
86
|
+
*
|
|
87
|
+
* `senpi validate` reports it too, at static depth (`E_VALIDATE_PACKAGE_ID_CASE`), rendering its
|
|
88
|
+
* fix from {@link lowercasePackageIdFix} so both surfaces name the identical edit. Note the ops
|
|
89
|
+
* ordering that creates: the redeploy loop is `validate → close → create`, so the finding fires
|
|
90
|
+
* before anything is closed and the id is lowercased on a package that may already own funded
|
|
91
|
+
* wallets. That is safe only because both stamp comparisons case-FOLD.
|
|
92
|
+
*/
|
|
93
|
+
export function nonLowercasePackageId(pkg) {
|
|
94
|
+
return pkg.id !== pkg.id.toLowerCase() ? pkg.id : null;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The fix for a mixed-case id: the edit(s) to make, and the directory the package lives in once
|
|
98
|
+
* they are made. ONE producer of both, so a refusal's re-run command can never name a path that
|
|
99
|
+
* the same refusal's instruction just moved.
|
|
100
|
+
*
|
|
101
|
+
* The rename is emitted only when the directory IS this id in another case. The skills validator
|
|
102
|
+
* requires `id == package dir`, so lowercasing the id alone would trade this refusal for an
|
|
103
|
+
* `id != package dir` one over there, and an author must not have to guess which of the two to
|
|
104
|
+
* change. A directory that already differs from the id is a separate, pre-existing mismatch that
|
|
105
|
+
* this fix neither causes nor may claim to fix.
|
|
106
|
+
*/
|
|
107
|
+
export function lowercasePackageIdFix(id, packageDir) {
|
|
108
|
+
const lower = id.toLowerCase();
|
|
109
|
+
const dirName = basename(packageDir);
|
|
110
|
+
const renames = dirName !== lower && dirName.toLowerCase() === lower;
|
|
111
|
+
return {
|
|
112
|
+
instruction: `set \`id: ${lower}\` in ${join(packageDir, "strategy.yaml")}` +
|
|
113
|
+
(renames
|
|
114
|
+
? ` and rename the package directory "${dirName}" to "${lower}" — the id and the ` +
|
|
115
|
+
`directory name have to match`
|
|
116
|
+
: ""),
|
|
117
|
+
dirAfterFix: renames ? join(dirname(packageDir), lower) : packageDir,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function readYamlMapping(path) {
|
|
121
|
+
const parsed = parseYaml(readFileSync(path, "utf8"));
|
|
122
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
123
|
+
throw new Error(`${path} did not parse to a YAML mapping`);
|
|
124
|
+
}
|
|
125
|
+
return parsed;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* `funding_share` as a number, or null when it is absent or unreadable.
|
|
129
|
+
*
|
|
130
|
+
* A QUOTED share (`funding_share: "0.4"`) parses, because the number this field feeds is computed
|
|
131
|
+
* with Python's `float()` on the skills side: `gen_catalog.py` bakes the package's `min_budget`
|
|
132
|
+
* into the discovery card via `min_budget._f`. Reading a quoted share as undeclared here would put
|
|
133
|
+
* the card and the verb out of step on that figure, and would additionally make `planFunding` split
|
|
134
|
+
* the budget evenly when the author asked for 60/40 — a real money decision, not just a display.
|
|
135
|
+
*
|
|
136
|
+
* What the skills side does NOT do is accept it everywhere. `_pkg.py:62` reads this field RAW, so a
|
|
137
|
+
* quoted share reaches `_pkg.validate`'s `sum(shares)` as a `str` and raises `TypeError`; and
|
|
138
|
+
* `gen_catalog.derive_funding_split` filters `isinstance(x, (int, float))` and DROPS it, so the
|
|
139
|
+
* card's `funding_split` still falls back while its `min_budget` uses the value. Parsing it here is
|
|
140
|
+
* therefore the closest single behaviour to a divided reference, not agreement with all of it — a
|
|
141
|
+
* quoted share is a packaging bug that `deploy.py validate` catches loudly, and the verb's job is
|
|
142
|
+
* to not silently mis-split money in the meantime.
|
|
143
|
+
*
|
|
144
|
+
* Shared with the min-budget port so the two readers cannot drift ({@link pythonFloat}, whose two
|
|
145
|
+
* documented gaps from `float()` apply here and are pinned in `package.test.ts`). Anything that
|
|
146
|
+
* does not parse stays null — the honest "not declared", which callers treat as an even split.
|
|
147
|
+
* Never NaN: that would poison every downstream sum and max silently.
|
|
148
|
+
*/
|
|
149
|
+
const readFundingShare = pythonFloat;
|
|
150
|
+
function readDeclaredInstances(rawInstances, dir, manifestPath) {
|
|
151
|
+
const seen = new Set();
|
|
152
|
+
return rawInstances.map((entry) => {
|
|
153
|
+
const name = String(entry.name ?? "");
|
|
154
|
+
const rel = String(entry.runtime ?? "");
|
|
155
|
+
const walletEnv = String(entry.wallet_env ?? "");
|
|
156
|
+
if (!name || !rel || !walletEnv) {
|
|
157
|
+
throw new Error(`strategy.yaml instance entries need name, runtime, wallet_env (${manifestPath})`);
|
|
158
|
+
}
|
|
159
|
+
// A repeated name is not a cosmetic clash — it costs money twice over, and nothing downstream
|
|
160
|
+
// can recover from it. `planFunding` keys its amounts Map on this name, so two entries collapse
|
|
161
|
+
// into one and the preflight validates HALF the money that actually moves; both runs then read
|
|
162
|
+
// the same amount and issue two creates. At install both derive the same `<id>-<instance>`
|
|
163
|
+
// runtime id, so the second deletes the first's runtime and rebinds to its own wallet —
|
|
164
|
+
// leaving wallet #1 funded, live, and supervised by no runtime and no exit engine, with its
|
|
165
|
+
// install step reported `ok`. Refused in the loader, beside the sibling name rule above: unlike
|
|
166
|
+
// a mixed-case package id (which deploys coherently and only misstamps), there is no reading of
|
|
167
|
+
// a duplicated name any consumer can act on, so there is no recovery read to keep working.
|
|
168
|
+
if (seen.has(name)) {
|
|
169
|
+
throw new Error(`strategy.yaml declares instance "${name}" more than once (${manifestPath}). Instance ` +
|
|
170
|
+
`names must be unique within a package: the funding plan and the runtime id are both ` +
|
|
171
|
+
`keyed on this name, so a repeated one funds two wallets and then leaves one of them ` +
|
|
172
|
+
`with no runtime watching it. Give each instance its own name.`);
|
|
173
|
+
}
|
|
174
|
+
seen.add(name);
|
|
175
|
+
// An instance name has to survive `sanitizeStrategyName` UNCHANGED, because two different
|
|
176
|
+
// consumers disagree about it otherwise: the runtime registers the sanitized
|
|
177
|
+
// `<id>-<instance>`, while `close.py --instance <name>` looks the sleeve up under the RAW one.
|
|
178
|
+
// A name that changes under sanitization therefore installs fine and can never be torn down by
|
|
179
|
+
// instance — and, since deploy's own refusals emit that command, it would hand the reader
|
|
180
|
+
// something that cannot work. It is shell input there too, so spaces are doubly unwelcome.
|
|
181
|
+
if (sanitizeStrategyName(name) !== name) {
|
|
182
|
+
throw new Error(`strategy.yaml instance name "${name}" is not usable as a strategy/runtime id — use ` +
|
|
183
|
+
`"${sanitizeStrategyName(name)}" instead (letters, digits, "_" and "-" only, no spaces, ` +
|
|
184
|
+
`max ${WALLET_NAME_MAX} chars). The runtime registers the sanitized form while teardown ` +
|
|
185
|
+
`looks up the raw one, so a name that changes here cannot be closed by instance later.`);
|
|
186
|
+
}
|
|
187
|
+
const runtimeYamlPath = resolve(dir, rel);
|
|
188
|
+
// The user names ONE directory, and everything this deploy reads, funds and runs has to come
|
|
189
|
+
// from inside it. `resolve` + `existsSync` alone let `../../other/runtime.yaml` — or a bare
|
|
190
|
+
// absolute path, which has no `../` to notice — relocate every consumer at once: the pre-money
|
|
191
|
+
// gates would validate a foreign recipe, `checkPackageProof` would read a `.senpi-proof.json`
|
|
192
|
+
// recorded for a package nobody inspected (satisfying the funding gate), relative
|
|
193
|
+
// `scanners[].path` entrypoints would resolve and therefore EXECUTE from outside the package,
|
|
194
|
+
// and the refusals would print `openclaw senpi validate '<that outside dir>'` for the reader to
|
|
195
|
+
// run. One containment check upstream of all of them is the whole fix.
|
|
196
|
+
const inside = relative(dir, runtimeYamlPath);
|
|
197
|
+
if (inside.startsWith("..") || isAbsolute(inside)) {
|
|
198
|
+
throw new Error(`strategy.yaml instance "${name}" points at a runtime file outside the package: ` +
|
|
199
|
+
`"${rel}" resolves to ${runtimeYamlPath}, which is not under ${dir}. An instance's ` +
|
|
200
|
+
`runtime.yaml must live inside the package directory being deployed — move the file in, ` +
|
|
201
|
+
`or deploy the package that already contains it.`);
|
|
202
|
+
}
|
|
203
|
+
if (!existsSync(runtimeYamlPath)) {
|
|
204
|
+
throw new Error(`Instance "${name}" runtime file not found: ${runtimeYamlPath}`);
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
name,
|
|
208
|
+
runtimeYamlPath,
|
|
209
|
+
runtimeYamlDir: dirname(runtimeYamlPath),
|
|
210
|
+
walletEnv,
|
|
211
|
+
fundingShare: readFundingShare(entry.funding_share),
|
|
212
|
+
};
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Flat package: one `runtime.yaml` at the package root and no `instances[]` —
|
|
217
|
+
* the layout agents naturally scaffold. The wallet env is read back out of the
|
|
218
|
+
* `${...}` the runtime already binds (mirror of `_pkg._flat_instance`), so
|
|
219
|
+
* render substitutes the token the package actually uses.
|
|
220
|
+
*/
|
|
221
|
+
function synthesizeFlatInstance(dir) {
|
|
222
|
+
const flatPath = join(dir, "runtime.yaml");
|
|
223
|
+
if (!existsSync(flatPath)) {
|
|
224
|
+
throw new Error(`No instances[] in strategy.yaml and no root runtime.yaml (${dir})`);
|
|
225
|
+
}
|
|
226
|
+
const flat = readYamlMapping(flatPath);
|
|
227
|
+
const strategy = (flat.strategy ?? {});
|
|
228
|
+
const wallet = String(strategy.wallet ?? "");
|
|
229
|
+
const token = WALLET_TOKEN_RE.exec(wallet.trim());
|
|
230
|
+
if (!token) {
|
|
231
|
+
throw new Error(`Flat package runtime.yaml strategy.wallet must be a \${WALLET_ENV} placeholder, got "${wallet}"`);
|
|
232
|
+
}
|
|
233
|
+
return { name: "main", runtimeYamlPath: flatPath, runtimeYamlDir: dir, walletEnv: token[1], fundingShare: null };
|
|
234
|
+
}
|
|
235
|
+
export function loadDeployPackage(packageDir) {
|
|
236
|
+
const dir = resolve(packageDir);
|
|
237
|
+
const manifestPath = join(dir, "strategy.yaml");
|
|
238
|
+
if (!existsSync(manifestPath)) {
|
|
239
|
+
throw new Error(`No strategy.yaml in ${dir}. senpi deploy takes a strategy PACKAGE directory ` +
|
|
240
|
+
`(strategy.yaml + per-instance runtime.yaml). For a bare runtime.yaml, use the internal ` +
|
|
241
|
+
`runtime create only if you know what you are doing — packages are the supported path.`);
|
|
242
|
+
}
|
|
243
|
+
const manifest = readYamlMapping(manifestPath);
|
|
244
|
+
const id = String(manifest.id ?? "");
|
|
245
|
+
const version = String(manifest.version ?? "");
|
|
246
|
+
if (!id || !version)
|
|
247
|
+
throw new Error(`strategy.yaml must declare id and version (${manifestPath})`);
|
|
248
|
+
const defaults = (manifest.defaults ?? {});
|
|
249
|
+
const decisionModelEnv = typeof defaults.decision_model_env === "string" ? defaults.decision_model_env : null;
|
|
250
|
+
// A non-mapping `catalog:` is a packaging mistake, not a reason to fail the load — it reads as an
|
|
251
|
+
// absent block, which only costs the advisory `min_budget_floor` override.
|
|
252
|
+
const rawCatalog = manifest.catalog;
|
|
253
|
+
const catalog = typeof rawCatalog === "object" && rawCatalog !== null && !Array.isArray(rawCatalog)
|
|
254
|
+
? rawCatalog
|
|
255
|
+
: {};
|
|
256
|
+
const rawInstances = Array.isArray(manifest.instances)
|
|
257
|
+
? manifest.instances
|
|
258
|
+
: [];
|
|
259
|
+
const instances = rawInstances.length > 0
|
|
260
|
+
? readDeclaredInstances(rawInstances, dir, manifestPath)
|
|
261
|
+
: [synthesizeFlatInstance(dir)];
|
|
262
|
+
// After the per-instance name check: the combined identity covers the id and the length, for
|
|
263
|
+
// declared and flat (synthesized "main") instances alike.
|
|
264
|
+
for (const inst of instances)
|
|
265
|
+
assertIdentityRoundTrips(id, inst.name, manifestPath);
|
|
266
|
+
return { id, version, dir, decisionModelEnv, catalog, instances };
|
|
267
|
+
}
|
|
268
|
+
/** The backend strategy name for an instance — also the reconcile key. */
|
|
269
|
+
export function walletName(pkg, inst) {
|
|
270
|
+
const base = pkg.instances.length > 1 ? `${pkg.id}-${inst.name}` : pkg.id;
|
|
271
|
+
return sanitizeStrategyName(base);
|
|
272
|
+
}
|
|
273
|
+
/** The instance's runtime.yaml exactly as authored — pre-substitution, for pre-render inspection. */
|
|
274
|
+
export function readRuntimeYaml(inst) {
|
|
275
|
+
return readFileSync(inst.runtimeYamlPath, "utf8");
|
|
276
|
+
}
|
|
277
|
+
/** The `${TOKEN}` an instance's recipe must bind its wallet to, from the manifest's `wallet_env`. */
|
|
278
|
+
function expectedWalletBinding(inst) {
|
|
279
|
+
return `\${${inst.walletEnv}}`;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Instances whose recipe does not bind the wallet `strategy.yaml` says it binds.
|
|
283
|
+
*
|
|
284
|
+
* `wallet_env` is a promise the manifest makes on behalf of the recipe, and nothing used to check
|
|
285
|
+
* that the recipe keeps it. `renderRuntimeYaml` substitutes by string replacement, so a declared
|
|
286
|
+
* token that never appears substitutes NOTHING — silently, because the leftover-placeholder gate
|
|
287
|
+
* only looks for surviving `${...}` and a hardcoded address leaves none. A package declaring
|
|
288
|
+
* `wallet_env: UNUSED` beside a recipe pinning an address it chose therefore had `senpi deploy`
|
|
289
|
+
* create and fund a fresh wallet from the user's budget and then install the runtime — actions,
|
|
290
|
+
* DSL exit engine and all — against the OTHER address. The install step named the recipe's wallet,
|
|
291
|
+
* so the report read clean while the funded wallet sat with nothing watching it.
|
|
292
|
+
*
|
|
293
|
+
* Read from the PARSED recipe, not by searching its text: a token that appears anywhere at all
|
|
294
|
+
* satisfies a text search, substitutes harmlessly into some field nobody reads, and leaves the
|
|
295
|
+
* leftover gate with nothing to catch. Only `strategy.wallet` decides what the runtime binds.
|
|
296
|
+
*
|
|
297
|
+
* Flat packages cannot fault here and are not special-cased: `synthesizeFlatInstance` derives
|
|
298
|
+
* `walletEnv` from this very field, so the invariant holds by construction.
|
|
299
|
+
*
|
|
300
|
+
* Never throws. A recipe that will not parse is a fault the YAML-syntax gate already owns and
|
|
301
|
+
* words properly — restating it here in worse words helps nobody — and this check is called from
|
|
302
|
+
* places (validate's static depth, deploy's preflight) where taking the whole run down over one
|
|
303
|
+
* unreadable file would be the wrong answer.
|
|
304
|
+
*/
|
|
305
|
+
export function unboundWalletInstances(pkg) {
|
|
306
|
+
const faults = [];
|
|
307
|
+
for (const inst of pkg.instances) {
|
|
308
|
+
let declared;
|
|
309
|
+
try {
|
|
310
|
+
const parsed = parseYaml(readRuntimeYaml(inst));
|
|
311
|
+
const strategy = parsed?.strategy;
|
|
312
|
+
// A missing or non-mapping `strategy:` block is NOT skipped: it parses, so it can reach
|
|
313
|
+
// install, and it binds no wallet — which is exactly the fault this asks about. Only a file
|
|
314
|
+
// that will not parse at all is passed over, and that one cannot reach install because
|
|
315
|
+
// `renderRuntimeYaml` re-parses before it returns.
|
|
316
|
+
const wallet = strategy !== null && typeof strategy === "object" && !Array.isArray(strategy)
|
|
317
|
+
? strategy.wallet
|
|
318
|
+
: undefined;
|
|
319
|
+
declared = typeof wallet === "string" ? wallet.trim() : undefined;
|
|
320
|
+
}
|
|
321
|
+
catch {
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
const expected = expectedWalletBinding(inst);
|
|
325
|
+
if (declared !== expected)
|
|
326
|
+
faults.push({ instance: inst, declared, expected });
|
|
327
|
+
}
|
|
328
|
+
return faults;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Render an instance's runtime.yaml for install. Only the wallet token and (when
|
|
332
|
+
* supplied) the decision-model token are substituted; anything else left as
|
|
333
|
+
* `${...}` is a packaging bug and throws rather than reaching the runtime, where
|
|
334
|
+
* it would install as a literal.
|
|
335
|
+
*/
|
|
336
|
+
export function renderRuntimeYaml(inst, wallet, decisionModel) {
|
|
337
|
+
let text = readFileSync(inst.runtimeYamlPath, "utf8");
|
|
338
|
+
text = text.split(`\${${inst.walletEnv}}`).join(wallet);
|
|
339
|
+
if (decisionModel)
|
|
340
|
+
text = text.split(`\${${decisionModel.env}}`).join(decisionModel.model);
|
|
341
|
+
const leftover = LEFTOVER_TOKEN_RE.exec(text);
|
|
342
|
+
if (leftover) {
|
|
343
|
+
throw new Error(`Unresolved placeholder ${leftover[0]} in ${inst.runtimeYamlPath}. ` +
|
|
344
|
+
`Only \${${inst.walletEnv}}${decisionModel ? ` and \${${decisionModel.env}}` : ""} are substituted by deploy.`);
|
|
345
|
+
}
|
|
346
|
+
assertBindsFundedWallet(inst, text, wallet);
|
|
347
|
+
return text;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* The last gate before install: does the recipe about to be installed bind the wallet this run
|
|
351
|
+
* actually funded?
|
|
352
|
+
*
|
|
353
|
+
* Not redundant with the pre-money check in the preflight, for a reason that is a property of this
|
|
354
|
+
* function: it RE-READS the file. Whatever any earlier gate inspected is not provably these bytes
|
|
355
|
+
* (`runtime.yaml` is read several times across one deploy, and nothing pins the file between
|
|
356
|
+
* them). This is the one point where the funded wallet and the exact text that will be installed
|
|
357
|
+
* are both in hand, so it is the only place the invariant can actually be asserted rather than
|
|
358
|
+
* approximated.
|
|
359
|
+
*
|
|
360
|
+
* Compares the PARSED value — the runtime binds what the YAML parses to, not what the text looks
|
|
361
|
+
* like — and folds case, because a wallet address is one margin account however it is spelled
|
|
362
|
+
* (`findByWallet` folds for the same reason). An exact compare here would refuse correct deploys
|
|
363
|
+
* and, since this throw lands on the money path, roll their funded wallets back.
|
|
364
|
+
*
|
|
365
|
+
* Fails CLOSED on a rendered recipe that will not parse. The runtime would reject it anyway; the
|
|
366
|
+
* difference is that refusing here happens before the wallet is handed to an install.
|
|
367
|
+
*/
|
|
368
|
+
function assertBindsFundedWallet(inst, rendered, wallet) {
|
|
369
|
+
let bound;
|
|
370
|
+
try {
|
|
371
|
+
const parsed = parseYaml(rendered);
|
|
372
|
+
const strategy = parsed?.strategy;
|
|
373
|
+
bound =
|
|
374
|
+
strategy !== null && typeof strategy === "object" && !Array.isArray(strategy)
|
|
375
|
+
? strategy.wallet
|
|
376
|
+
: undefined;
|
|
377
|
+
}
|
|
378
|
+
catch (err) {
|
|
379
|
+
throw new Error(`Rendered recipe for instance "${inst.name}" (${inst.runtimeYamlPath}) is not parseable as ` +
|
|
380
|
+
`YAML: ${err instanceof Error ? err.message : String(err)}. Nothing was installed on the ` +
|
|
381
|
+
`wallet this run funded — a recipe that cannot be read cannot be confirmed to bind it.`);
|
|
382
|
+
}
|
|
383
|
+
const boundText = typeof bound === "string" ? bound.trim() : "";
|
|
384
|
+
if (boundText.toLowerCase() === wallet.trim().toLowerCase())
|
|
385
|
+
return;
|
|
386
|
+
throw new Error(`Instance "${inst.name}" would install against ${boundText === "" ? "no wallet" : `wallet ${boundText}`}, ` +
|
|
387
|
+
`but this deploy funded ${wallet}. Its recipe (${inst.runtimeYamlPath}) must bind ` +
|
|
388
|
+
`strategy.wallet to \${${inst.walletEnv}} — the token strategy.yaml declares for it — so ` +
|
|
389
|
+
`deploy can substitute the wallet it created. As written, the money this run moved and the ` +
|
|
390
|
+
`account the strategy would trade are two different wallets.`);
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* True iff the instance ships a DSL exit block — `exit.dsl_preset`, or `exit.engine: dsl`.
|
|
394
|
+
*
|
|
395
|
+
* A deployed strategy without one runs every position naked: no hard stop, no trailing floor. The
|
|
396
|
+
* skills-side `_pkg.validate` has always refused to fund such a package, and `senpi deploy` is now
|
|
397
|
+
* the taught path, so the same gate has to live here or the hole reopens on the direct-verb route.
|
|
398
|
+
*/
|
|
399
|
+
export function instanceHasDslExit(inst) {
|
|
400
|
+
return hasDslExitBlock(parseYaml(readRuntimeYaml(inst)));
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* True iff a PARSED recipe ships a DSL exit block — `exit.dsl_preset`, or `exit.engine: dsl`.
|
|
404
|
+
*
|
|
405
|
+
* Split from {@link instanceHasDslExit} so `senpi validate` can ask the same question of the config
|
|
406
|
+
* it has already parsed, rather than re-reading and re-parsing the file — and rather than growing a
|
|
407
|
+
* second predicate that could quietly disagree with this one about, say, `dsl_preset: true`. Same
|
|
408
|
+
* reason {@link isTruthyPreset} is exported for `runtime-descriptor.ts`.
|
|
409
|
+
*
|
|
410
|
+
* Takes `unknown` because its two callers hold different things: a `parseYaml` result here, and a
|
|
411
|
+
* schema-parsed `RuntimeConfig` in validate. Both are read the same way, and neither is trusted to
|
|
412
|
+
* have the shape — but note their INPUTS are not identical: validate resolves `${ENV}` before
|
|
413
|
+
* parsing (`recipe.ts`), deploy does not, so `exit: { engine: "${EXIT_ENGINE}" }` reads as `dsl`
|
|
414
|
+
* here only after substitution and as the literal token on the deploy path. Validate's reading is
|
|
415
|
+
* the more accurate one (that is what would install); the divergence is narrow and pre-existing,
|
|
416
|
+
* and this is the note that stops the next reader concluding the two can never disagree.
|
|
417
|
+
*/
|
|
418
|
+
export function hasDslExitBlock(parsed) {
|
|
419
|
+
const exit = parsed?.exit;
|
|
420
|
+
if (exit === null || typeof exit !== "object" || Array.isArray(exit))
|
|
421
|
+
return false;
|
|
422
|
+
const block = exit;
|
|
423
|
+
const engine = typeof block.engine === "string" ? block.engine.toLowerCase() : "";
|
|
424
|
+
// Mirror of `_pkg.Instance.has_dsl`: a truthy `dsl_preset` (real packages use a map, not a
|
|
425
|
+
// string) OR `engine: dsl`. Keeping the two predicates identical is why author-green stays
|
|
426
|
+
// deploy-green.
|
|
427
|
+
return isTruthyPreset(block.dsl_preset) || engine === "dsl";
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Python-`bool()` semantics for a YAML value: a non-empty string, map or list — and `true`, which
|
|
431
|
+
* `bool()` also accepts. Without the boolean arm a package written `dsl_preset: true` would validate
|
|
432
|
+
* green on the skills side and be refused here, and the two predicates must not disagree.
|
|
433
|
+
*
|
|
434
|
+
* Exported so `runtime-descriptor.ts` can reuse this exact predicate for `hasExit` rather than grow
|
|
435
|
+
* a second copy that could quietly drift from this one.
|
|
436
|
+
*/
|
|
437
|
+
export function isTruthyPreset(value) {
|
|
438
|
+
if (typeof value === "boolean")
|
|
439
|
+
return value;
|
|
440
|
+
if (typeof value === "number")
|
|
441
|
+
return value !== 0;
|
|
442
|
+
if (typeof value === "string")
|
|
443
|
+
return value.trim().length > 0;
|
|
444
|
+
if (Array.isArray(value))
|
|
445
|
+
return value.length > 0;
|
|
446
|
+
if (value !== null && typeof value === "object")
|
|
447
|
+
return Object.keys(value).length > 0;
|
|
448
|
+
return false;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Instances in `pkg` that ship no DSL exit block. Empty = every instance is protected.
|
|
452
|
+
*
|
|
453
|
+
* The instances themselves, not their names: both refusals built from this name the re-check
|
|
454
|
+
* command for each offender, and that command takes a directory the instance carries. A name is not
|
|
455
|
+
* a path, and re-deriving the instance from its name at the refusal site is a lookup that can fail.
|
|
456
|
+
*
|
|
457
|
+
* `senpi validate` reports the same fault at static depth (`E_VALIDATE_NO_DSL_EXIT`, via
|
|
458
|
+
* {@link hasDslExitBlock} in `validate/package-gates-stage.ts`), so the re-check command these
|
|
459
|
+
* refusals emit agrees with them. Do not add a third reading of this fact.
|
|
460
|
+
*/
|
|
461
|
+
export function instancesWithoutDslExit(pkg) {
|
|
462
|
+
return pkg.instances.filter((inst) => !instanceHasDslExit(inst));
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Scanner entries in `pkg` that declare an `enabled` key at all.
|
|
466
|
+
*
|
|
467
|
+
* Scanner-level `enabled` is NOT a supported key: `scannerEntrySchema` is `.passthrough()` and does
|
|
468
|
+
* not declare it, `buildScannerOverrides` (map-strategies-registration.ts) forwards only
|
|
469
|
+
* `interval_seconds`/`config`, and `StrategyScannerRegistry.register` derives `enabled` from
|
|
470
|
+
* `strategy.defaultEnabledScanners` — which nothing writes from a recipe. So the engine never reads
|
|
471
|
+
* it: a scanner written `enabled: false` registers ENABLED and ticks. Silently accepting the key
|
|
472
|
+
* means shipping a strategy that trades while its author believes it is switched off, which is why
|
|
473
|
+
* every value refuses (a `true` is just as unread as a `false`, and tomorrow's reader would take
|
|
474
|
+
* the accepted `true` as proof the key works).
|
|
475
|
+
*
|
|
476
|
+
* The live-state twin of this is the observe step's all-disabled branch, which reads engine rows
|
|
477
|
+
* rather than YAML — the runtime API can genuinely disable a scanner after install.
|
|
478
|
+
*
|
|
479
|
+
* `senpi validate` reports the same key at static depth (`E_VALIDATE_SCANNER_ENABLED`, via
|
|
480
|
+
* {@link scannerEnabledEntries}), one finding per offending entry, so an author never first learns
|
|
481
|
+
* about it from the money path.
|
|
482
|
+
*/
|
|
483
|
+
export function scannersDeclaringEnabled(pkg) {
|
|
484
|
+
return pkg.instances.flatMap((inst) => scannerEnabledEntries(parseYaml(readRuntimeYaml(inst))).map((entry) => ({
|
|
485
|
+
instance: inst.name,
|
|
486
|
+
scanner: entry.scanner,
|
|
487
|
+
value: entry.value,
|
|
488
|
+
runtimeYamlPath: inst.runtimeYamlPath,
|
|
489
|
+
})));
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Scanner entries in a PARSED recipe that declare an `enabled` key at all.
|
|
493
|
+
*
|
|
494
|
+
* The instance-free core of {@link scannersDeclaringEnabled}, so validate can ask it of a recipe
|
|
495
|
+
* that has no package around it yet — the mid-authoring case, where the fault is just as real and
|
|
496
|
+
* the author is exactly the person who should hear about it.
|
|
497
|
+
*/
|
|
498
|
+
export function scannerEnabledEntries(parsed) {
|
|
499
|
+
const scanners = parsed?.scanners;
|
|
500
|
+
if (!Array.isArray(scanners))
|
|
501
|
+
return [];
|
|
502
|
+
const found = [];
|
|
503
|
+
scanners.forEach((scanner, index) => {
|
|
504
|
+
// Key presence, not truthiness: a bare `enabled:` (null) is the same unsupported key.
|
|
505
|
+
if (scanner === null || typeof scanner !== "object" || !("enabled" in scanner))
|
|
506
|
+
return;
|
|
507
|
+
const entry = scanner;
|
|
508
|
+
const name = typeof entry.name === "string" ? entry.name : entry.id;
|
|
509
|
+
found.push({
|
|
510
|
+
scanner: typeof name === "string" && name.length > 0 ? name : `scanners[${index}]`,
|
|
511
|
+
index,
|
|
512
|
+
value: entry.enabled,
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
return found;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* One offense as an instruction: the key, the scanner, the instance, the file and the exact line to
|
|
519
|
+
* delete. Shared by both gate copies so the mechanical fix an agent reads is word-for-word the same
|
|
520
|
+
* wherever the refusal is raised.
|
|
521
|
+
*/
|
|
522
|
+
export function describeScannerEnabledOffense(entry) {
|
|
523
|
+
return (`instance "${entry.instance}", scanner "${entry.scanner}": delete the line ` +
|
|
524
|
+
`\`${renderScannerEnabledLine(entry.value)}\` from ${entry.runtimeYamlPath}`);
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* The offending line as it appears in the YAML — a bare `enabled:` has no value to echo.
|
|
528
|
+
*
|
|
529
|
+
* Exported so validate's finding quotes the author's own line with the same rendering deploy's
|
|
530
|
+
* refusal uses. Two surfaces telling someone to delete "the line `enabled: false`" must agree on
|
|
531
|
+
* what that line says, or one of them is describing a line that is not in the file.
|
|
532
|
+
*/
|
|
533
|
+
export function renderScannerEnabledLine(value) {
|
|
534
|
+
return value === null || value === undefined ? "enabled:" : `enabled: ${JSON.stringify(value)}`;
|
|
535
|
+
}
|
|
536
|
+
/** True iff any action runs `decision_mode: llm` — those installs need a decision model. */
|
|
537
|
+
export function runtimeUsesLlmDecisions(runtimeYamlText) {
|
|
538
|
+
const parsed = parseYaml(runtimeYamlText);
|
|
539
|
+
const actions = Array.isArray(parsed?.actions) ? parsed.actions : [];
|
|
540
|
+
return actions.some((action) => action?.decision_mode === "llm");
|
|
541
|
+
}
|
|
542
|
+
//# sourceMappingURL=package.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.js","sourceRoot":"","sources":["../../src/deploy/package.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,oFAAoF;AACpF,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,wFAAwF;AACxF,MAAM,eAAe,GAAG,sBAAsB,CAAC;AAE/C;;;;;;;;;GASG;AACH,MAAM,iBAAiB,GAAG,IAAI,MAAM,CAAC,sBAAsB,CAAC,CAAC;AA6B7D,yGAAyG;AACzG,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,MAAM,SAAS,GAAG,IAAI;SACnB,IAAI,EAAE;SACN,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC;SAC9B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC3B,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,e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M,GAAG,SAAS,CAAC,eAAe,CAAmC,CAAC;IAC5E,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAE,MAAM,CAAC,OAA0C,CAAC,CAAC,CAAC,EAAE,CAAC;IACzG,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,KAAK,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type ValidateCode, type VerifyResult } from "../validate/index.js";
|
|
2
|
+
import { type DeployInstance, type DeployPackage } from "./package.js";
|
|
3
|
+
export declare function checkPackageProof(pkg: DeployPackage): VerifyResult;
|
|
4
|
+
/** Instances that resolve to one directory — see {@link collidingInstanceDirs}. */
|
|
5
|
+
export interface InstanceDirCollision {
|
|
6
|
+
dir: string;
|
|
7
|
+
instances: DeployInstance[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The one package shape a proof cannot answer for, which therefore has to be refused rather than
|
|
11
|
+
* verified.
|
|
12
|
+
*
|
|
13
|
+
* A proof is one file per DIRECTORY — `writeProof` writes `dirname(recipePath)/.senpi-proof.json` —
|
|
14
|
+
* and it records the recipe it was made for, which `verifyProofInner` re-fingerprints. Nothing in
|
|
15
|
+
* `loadDeployPackage` requires instances to live in different directories: a manifest naming
|
|
16
|
+
* `aggressive.yaml` and `calm.yaml` at the package root is legal and gives both instances the same
|
|
17
|
+
* `runtimeYamlDir`. Verifying that package asks the same directory twice and gets the same answer
|
|
18
|
+
* twice, so a proof recorded for ONE recipe passes the other — a recipe nobody watched run reaches
|
|
19
|
+
* funding, which is the precise harm this gate exists to prevent.
|
|
20
|
+
*
|
|
21
|
+
* Fixing it inside `verifyProof` would mean teaching the proof format about instances; the deploy
|
|
22
|
+
* layer is the one that HAS the manifest and can see the collision, so it refuses here. Fail-closed
|
|
23
|
+
* on principle and free in practice: of the 103 packages in the shipped catalog, 21 are
|
|
24
|
+
* multi-instance and none shares a runtime directory.
|
|
25
|
+
*
|
|
26
|
+
* `senpi validate` calls this too, at static depth (`E_VALIDATE_INSTANCE_DIR_COLLISION`), scoped to
|
|
27
|
+
* the collision the validated recipe is IN — reporting a sibling pair the run never looked at would
|
|
28
|
+
* send an author to edit files outside the target.
|
|
29
|
+
*/
|
|
30
|
+
export declare function collidingInstanceDirs(pkg: DeployPackage): InstanceDirCollision[];
|
|
31
|
+
/**
|
|
32
|
+
* The collision as an instruction — deliberately an END STATE, not a command.
|
|
33
|
+
*
|
|
34
|
+
* The obvious rendering ("mv the recipe into its own directory") produces a package that does not
|
|
35
|
+
* validate: a relative `path:` resolves against the recipe's own directory, so moving the recipe
|
|
36
|
+
* alone re-points `./scanners` at a directory that does not exist and the very next validation
|
|
37
|
+
* fails on an unresolvable scanner path. Nor can the right move be computed here — two recipes that
|
|
38
|
+
* share a directory may well be sharing what is in it, and whether the tree moves, is copied, or is
|
|
39
|
+
* referenced from both is a decision about this package that this gate does not have the standing
|
|
40
|
+
* to make. So it names what will break (computed from each recipe, not templated), describes the
|
|
41
|
+
* state to reach, and emits no command whose preconditions it cannot check — the same rule
|
|
42
|
+
* `buildBudgetEscape` follows when a report cannot support a teardown.
|
|
43
|
+
*
|
|
44
|
+
* It also emits no post-move `senpi validate` path. Those directories do not exist yet, and a
|
|
45
|
+
* non-colliding sleeve's directory is not its manifest name — the exact trap this module exists to
|
|
46
|
+
* prevent, which is easy to walk back into while writing helpful-looking text. Re-running the
|
|
47
|
+
* deploy is the loop: it names any instance still unproven and carries the exact command for it.
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildInstanceDirCollisionRefusal(collisions: InstanceDirCollision[], pkg: DeployPackage): string;
|
|
50
|
+
/**
|
|
51
|
+
* The refusal's four parts, before rendering.
|
|
52
|
+
*
|
|
53
|
+
* Split from the renderer so the step row can take the `code` from the same producer that renders
|
|
54
|
+
* the `detail` — the two cannot disagree about which refusal this is. Only the code rides
|
|
55
|
+
* `evidence`: every sibling gate keeps `evidence` a small machine-readable bag and leaves the prose
|
|
56
|
+
* in `detail`, and duplicating multi-line teaching text into every journal event and instance row
|
|
57
|
+
* is weight without a reader.
|
|
58
|
+
*/
|
|
59
|
+
export interface ProofRefusalParts {
|
|
60
|
+
code: ValidateCode;
|
|
61
|
+
what: string;
|
|
62
|
+
why: string;
|
|
63
|
+
fix: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The three reasons, each with its own fix.
|
|
67
|
+
*
|
|
68
|
+
* A single generic "run senpi validate" would be a template hint rather than a computed one: the
|
|
69
|
+
* three states call for different reading. `no_proof` says nothing has ever been observed to run
|
|
70
|
+
* here; `content_changed` says the bytes moved and names which; `runtime_version_changed` says the
|
|
71
|
+
* package is unchanged and only the engine under it moved — the one case where editing the package
|
|
72
|
+
* would be exactly the wrong response.
|
|
73
|
+
*/
|
|
74
|
+
export declare function proofRefusalParts(result: VerifyResult, pkg: DeployPackage): ProofRefusalParts;
|
|
75
|
+
/**
|
|
76
|
+
* The refusal as the step row's `detail`.
|
|
77
|
+
*
|
|
78
|
+
* The bracketed code leads, and is not decoration: `taxonomy.ts` extracts it and the CLI uses it to
|
|
79
|
+
* exit 2 (obey this) rather than 1 (state unknown).
|
|
80
|
+
*
|
|
81
|
+
* It emits NO re-run command of its own. The report's `next` already ends a refused report with
|
|
82
|
+
* `openclaw senpi deploy -p '<dir>' --budget <the real figure>`; a copy here would carry a `<usd>` placeholder
|
|
83
|
+
* instead, which is a second, worse command competing with the authoritative one.
|
|
84
|
+
*/
|
|
85
|
+
export declare function buildProofRefusal(result: VerifyResult, pkg: DeployPackage): string;
|
|
86
|
+
//# sourceMappingURL=proof-gate.d.ts.map
|