@senpi/runtime 3.0.237 → 3.0.239
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/actions/close-position/close-position.action.d.ts.map +1 -1
- package/dist/actions/close-position/close-position.action.js +15 -0
- package/dist/actions/close-position/close-position.action.js.map +1 -1
- package/dist/actions/llm-decision/openclaw-llm-decision.d.ts +25 -1
- package/dist/actions/llm-decision/openclaw-llm-decision.d.ts.map +1 -1
- package/dist/actions/llm-decision/openclaw-llm-decision.js +83 -15
- package/dist/actions/llm-decision/openclaw-llm-decision.js.map +1 -1
- package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
- package/dist/actions/open-position/open-position.action.js +15 -0
- package/dist/actions/open-position/open-position.action.js.map +1 -1
- package/dist/adapter/api-wrapper.d.ts +61 -0
- package/dist/adapter/api-wrapper.d.ts.map +1 -0
- package/dist/adapter/api-wrapper.js +92 -0
- package/dist/adapter/api-wrapper.js.map +1 -0
- package/dist/adapter/approvals-file.d.ts +35 -0
- package/dist/adapter/approvals-file.d.ts.map +1 -0
- package/dist/adapter/approvals-file.js +80 -0
- package/dist/adapter/approvals-file.js.map +1 -0
- package/dist/adapter/busy-file.d.ts +56 -0
- package/dist/adapter/busy-file.d.ts.map +1 -0
- package/dist/adapter/busy-file.js +86 -0
- package/dist/adapter/busy-file.js.map +1 -0
- package/dist/adapter/daemon-client.d.ts +37 -0
- package/dist/adapter/daemon-client.d.ts.map +1 -0
- package/dist/adapter/daemon-client.js +74 -0
- package/dist/adapter/daemon-client.js.map +1 -0
- package/dist/adapter/mode.d.ts +28 -0
- package/dist/adapter/mode.d.ts.map +1 -0
- package/dist/adapter/mode.js +42 -0
- package/dist/adapter/mode.js.map +1 -0
- package/dist/adapter/passthrough-cli.d.ts +30 -0
- package/dist/adapter/passthrough-cli.d.ts.map +1 -0
- package/dist/adapter/passthrough-cli.js +44 -0
- package/dist/adapter/passthrough-cli.js.map +1 -0
- package/dist/adapter/runtime-skill-cap.d.ts +13 -0
- package/dist/adapter/runtime-skill-cap.d.ts.map +1 -0
- package/dist/adapter/runtime-skill-cap.js +17 -0
- package/dist/adapter/runtime-skill-cap.js.map +1 -0
- package/dist/approvals/tool-approval-gate.d.ts +2 -0
- package/dist/approvals/tool-approval-gate.d.ts.map +1 -1
- package/dist/approvals/tool-approval-gate.js +5 -2
- package/dist/approvals/tool-approval-gate.js.map +1 -1
- package/dist/cli/daemon-call.d.ts +50 -0
- package/dist/cli/daemon-call.d.ts.map +1 -0
- package/dist/cli/daemon-call.js +165 -0
- package/dist/cli/daemon-call.js.map +1 -0
- package/dist/cli/guide-commands.d.ts.map +1 -1
- package/dist/cli/guide-commands.js +64 -24
- package/dist/cli/guide-commands.js.map +1 -1
- package/dist/cli/senpi-commands.d.ts +8 -6
- package/dist/cli/senpi-commands.d.ts.map +1 -1
- package/dist/cli/senpi-commands.js +102 -68
- package/dist/cli/senpi-commands.js.map +1 -1
- package/dist/cli/standalone.d.ts +24 -0
- package/dist/cli/standalone.d.ts.map +1 -0
- package/dist/cli/standalone.js +111 -0
- package/dist/cli/standalone.js.map +1 -0
- package/dist/cli/update-command.d.ts +7 -8
- package/dist/cli/update-command.d.ts.map +1 -1
- package/dist/cli/update-command.js +8 -33
- package/dist/cli/update-command.js.map +1 -1
- package/dist/daemon/api-version.d.ts +3 -0
- package/dist/daemon/api-version.d.ts.map +1 -0
- package/dist/daemon/api-version.js +3 -0
- package/dist/daemon/api-version.js.map +1 -0
- package/dist/daemon/errors.d.ts +36 -0
- package/dist/daemon/errors.d.ts.map +1 -0
- package/dist/daemon/errors.js +97 -0
- package/dist/daemon/errors.js.map +1 -0
- package/dist/daemon/host.d.ts +130 -0
- package/dist/daemon/host.d.ts.map +1 -0
- package/dist/daemon/host.js +202 -0
- package/dist/daemon/host.js.map +1 -0
- package/dist/daemon/http-routes.d.ts +37 -0
- package/dist/daemon/http-routes.d.ts.map +1 -0
- package/dist/daemon/http-routes.js +233 -0
- package/dist/daemon/http-routes.js.map +1 -0
- package/dist/daemon/main.d.ts +93 -0
- package/dist/daemon/main.d.ts.map +1 -0
- package/dist/daemon/main.js +308 -0
- package/dist/daemon/main.js.map +1 -0
- package/dist/daemon/mcp-endpoint.d.ts +55 -0
- package/dist/daemon/mcp-endpoint.d.ts.map +1 -0
- package/dist/daemon/mcp-endpoint.js +178 -0
- package/dist/daemon/mcp-endpoint.js.map +1 -0
- package/dist/daemon/memory.d.ts +29 -0
- package/dist/daemon/memory.d.ts.map +1 -0
- package/dist/daemon/memory.js +74 -0
- package/dist/daemon/memory.js.map +1 -0
- package/dist/daemon/owner-lock.d.ts +44 -0
- package/dist/daemon/owner-lock.d.ts.map +1 -0
- package/dist/daemon/owner-lock.js +149 -0
- package/dist/daemon/owner-lock.js.map +1 -0
- package/dist/daemon/request-ids.d.ts +48 -0
- package/dist/daemon/request-ids.d.ts.map +1 -0
- package/dist/daemon/request-ids.js +123 -0
- package/dist/daemon/request-ids.js.map +1 -0
- package/dist/daemon/route-table.d.ts +51 -0
- package/dist/daemon/route-table.d.ts.map +1 -0
- package/dist/daemon/route-table.js +120 -0
- package/dist/daemon/route-table.js.map +1 -0
- package/dist/daemon/telemetry-ws.d.ts +60 -0
- package/dist/daemon/telemetry-ws.d.ts.map +1 -0
- package/dist/daemon/telemetry-ws.js +166 -0
- package/dist/daemon/telemetry-ws.js.map +1 -0
- package/dist/daemon/update-request.d.ts +145 -0
- package/dist/daemon/update-request.d.ts.map +1 -0
- package/dist/daemon/update-request.js +250 -0
- package/dist/daemon/update-request.js.map +1 -0
- package/dist/deploy/messages.d.ts.map +1 -1
- package/dist/deploy/messages.js +15 -9
- package/dist/deploy/messages.js.map +1 -1
- package/dist/deploy/orchestrator.d.ts.map +1 -1
- package/dist/deploy/orchestrator.js +32 -8
- package/dist/deploy/orchestrator.js.map +1 -1
- package/dist/deploy/package.d.ts +8 -0
- package/dist/deploy/package.d.ts.map +1 -1
- package/dist/deploy/package.js +8 -0
- package/dist/deploy/package.js.map +1 -1
- package/dist/deploy/recheck-commands.d.ts +2 -0
- package/dist/deploy/recheck-commands.d.ts.map +1 -1
- package/dist/deploy/recheck-commands.js +4 -0
- package/dist/deploy/recheck-commands.js.map +1 -1
- package/dist/deploy/scanner-class.d.ts +16 -1
- package/dist/deploy/scanner-class.d.ts.map +1 -1
- package/dist/deploy/scanner-class.js +49 -0
- package/dist/deploy/scanner-class.js.map +1 -1
- package/dist/deploy/sim-admission.d.ts +94 -0
- package/dist/deploy/sim-admission.d.ts.map +1 -0
- package/dist/deploy/sim-admission.js +138 -0
- package/dist/deploy/sim-admission.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +185 -15
- package/dist/index.js.map +1 -1
- package/dist/runtime/agent-wake.d.ts +116 -0
- package/dist/runtime/agent-wake.d.ts.map +1 -0
- package/dist/runtime/agent-wake.js +181 -0
- package/dist/runtime/agent-wake.js.map +1 -0
- package/dist/runtime/auto-update/coordinator.d.ts +18 -0
- package/dist/runtime/auto-update/coordinator.d.ts.map +1 -1
- package/dist/runtime/auto-update/coordinator.js +80 -2
- package/dist/runtime/auto-update/coordinator.js.map +1 -1
- package/dist/runtime/auto-update/idle-gate.d.ts +12 -1
- package/dist/runtime/auto-update/idle-gate.d.ts.map +1 -1
- package/dist/runtime/auto-update/idle-gate.js +7 -4
- package/dist/runtime/auto-update/idle-gate.js.map +1 -1
- package/dist/runtime/create-actions.d.ts +5 -1
- package/dist/runtime/create-actions.d.ts.map +1 -1
- package/dist/runtime/create-actions.js +17 -2
- package/dist/runtime/create-actions.js.map +1 -1
- package/dist/runtime/decision-errors.d.ts +5 -0
- package/dist/runtime/decision-errors.d.ts.map +1 -1
- package/dist/runtime/decision-errors.js +10 -0
- package/dist/runtime/decision-errors.js.map +1 -1
- package/dist/runtime/live-class-backfill.d.ts +10 -0
- package/dist/runtime/live-class-backfill.d.ts.map +1 -0
- package/dist/runtime/live-class-backfill.js +65 -0
- package/dist/runtime/live-class-backfill.js.map +1 -0
- package/dist/runtime/recipe-file.d.ts +73 -0
- package/dist/runtime/recipe-file.d.ts.map +1 -0
- package/dist/runtime/recipe-file.js +194 -0
- package/dist/runtime/recipe-file.js.map +1 -0
- package/dist/runtime/runtime-descriptor.d.ts +23 -0
- package/dist/runtime/runtime-descriptor.d.ts.map +1 -1
- package/dist/runtime/runtime-descriptor.js +40 -0
- package/dist/runtime/runtime-descriptor.js.map +1 -1
- package/dist/runtime/runtime.d.ts +12 -0
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +109 -4
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/strategy-registry.d.ts +2 -2
- package/dist/runtime/update-apply-deps.d.ts +4 -2
- package/dist/runtime/update-apply-deps.d.ts.map +1 -1
- package/dist/runtime/update-apply-deps.js +4 -2
- package/dist/runtime/update-apply-deps.js.map +1 -1
- package/dist/runtime/update-handler.d.ts +6 -0
- package/dist/runtime/update-handler.d.ts.map +1 -1
- package/dist/runtime/update-handler.js +159 -12
- package/dist/runtime/update-handler.js.map +1 -1
- package/dist/runtime/update-register.d.ts.map +1 -1
- package/dist/runtime/update-register.js +18 -0
- package/dist/runtime/update-register.js.map +1 -1
- package/dist/runtime-api/extensions.d.ts +20 -0
- package/dist/runtime-api/extensions.d.ts.map +1 -0
- package/dist/runtime-api/extensions.js +28 -0
- package/dist/runtime-api/extensions.js.map +1 -0
- package/dist/runtime-api/intake/intake-mount.d.ts.map +1 -1
- package/dist/runtime-api/intake/intake-mount.js +3 -1
- package/dist/runtime-api/intake/intake-mount.js.map +1 -1
- package/dist/runtime-api/lifecycle.d.ts.map +1 -1
- package/dist/runtime-api/lifecycle.js +6 -0
- package/dist/runtime-api/lifecycle.js.map +1 -1
- package/dist/runtime-api/server.d.ts.map +1 -1
- package/dist/runtime-api/server.js +3 -0
- package/dist/runtime-api/server.js.map +1 -1
- package/dist/scanners/external-scanner-receiver.d.ts +2 -0
- package/dist/scanners/external-scanner-receiver.d.ts.map +1 -1
- package/dist/scanners/external-scanner-receiver.js +4 -0
- package/dist/scanners/external-scanner-receiver.js.map +1 -1
- package/dist/telemetry/context.d.ts +17 -0
- package/dist/telemetry/context.d.ts.map +1 -1
- package/dist/telemetry/context.js.map +1 -1
- package/dist/telemetry/otel-sdk.d.ts +2 -0
- package/dist/telemetry/otel-sdk.d.ts.map +1 -1
- package/dist/telemetry/otel-sdk.js +2 -0
- package/dist/telemetry/otel-sdk.js.map +1 -1
- package/dist/types/scanner.d.ts +6 -0
- package/dist/types/scanner.d.ts.map +1 -1
- package/dist/validate/package-gates-stage.d.ts +13 -1
- package/dist/validate/package-gates-stage.d.ts.map +1 -1
- package/dist/validate/package-gates-stage.js +3 -8
- package/dist/validate/package-gates-stage.js.map +1 -1
- package/dist/validate/target.d.ts +75 -1
- package/dist/validate/target.d.ts.map +1 -1
- package/dist/validate/target.js +94 -28
- package/dist/validate/target.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +8 -2
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a recipe given by path into the `{ content, dir }` an update carries.
|
|
3
|
+
*
|
|
4
|
+
* Shared by the `senpi update` CLI and the `senpi.update` gateway method: a directory resolves to
|
|
5
|
+
* the recipe inside it, and `dir` is the directory of the file actually read. A directory with a
|
|
6
|
+
* `strategy.yaml` at or above it resolves through that manifest, by the same resolver
|
|
7
|
+
* `senpi validate` uses; only a directory no manifest speaks for falls back to the filenames below. The CLI
|
|
8
|
+
* resolves a relative path against its own working directory, which is the caller's. The gateway
|
|
9
|
+
* cannot know the caller's, so it refuses a relative path before calling this (see
|
|
10
|
+
* `update-register.ts`) and `resolvePath` there only ever sees an absolute one.
|
|
11
|
+
*/
|
|
12
|
+
import { type ManifestDirectory } from "../validate/target.js";
|
|
13
|
+
/**
|
|
14
|
+
* Recipe filenames looked for inside a directory no manifest speaks for, in order.
|
|
15
|
+
*
|
|
16
|
+
* `runtime.yaml` first: that is what `deploy.py` renders into an instance directory, so it is the
|
|
17
|
+
* name a deployed package actually carries. `recipe.yaml` is what the shipped examples use.
|
|
18
|
+
*/
|
|
19
|
+
export declare const RECIPE_FILENAMES: readonly ["runtime.yaml", "recipe.yaml"];
|
|
20
|
+
/** The file-system calls the read needs. Injected so the CLI's resolution is testable without a disk. */
|
|
21
|
+
export interface RecipeFileIo {
|
|
22
|
+
resolvePath(p: string): string;
|
|
23
|
+
dirname(p: string): string;
|
|
24
|
+
readFile(p: string): string;
|
|
25
|
+
/** True when the path is a directory. */
|
|
26
|
+
isDirectory(p: string): boolean;
|
|
27
|
+
/** True when the path exists as a readable file. */
|
|
28
|
+
fileExists(p: string): boolean;
|
|
29
|
+
/** Names of the directory's subdirectories; empty when it cannot be listed. */
|
|
30
|
+
subdirectories(p: string): string[];
|
|
31
|
+
/**
|
|
32
|
+
* What a `strategy.yaml` at or above the directory says about it. The node implementation is
|
|
33
|
+
* validate's own resolver, so `senpi update` and `senpi validate` agree on which file a package's
|
|
34
|
+
* recipe is; a directory no manifest speaks for comes back as `filesystem`.
|
|
35
|
+
*/
|
|
36
|
+
manifestDirectory(dir: string): ManifestDirectory;
|
|
37
|
+
}
|
|
38
|
+
export declare const NODE_RECIPE_FILE_IO: RecipeFileIo;
|
|
39
|
+
export type RecipeFileRead = {
|
|
40
|
+
ok: true;
|
|
41
|
+
content: string;
|
|
42
|
+
dir: string;
|
|
43
|
+
} | {
|
|
44
|
+
ok: false;
|
|
45
|
+
message: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Read the recipe `pathArg` names, for an update: the bytes it carries and the directory its
|
|
49
|
+
* proof is checked over.
|
|
50
|
+
*
|
|
51
|
+
* Resolution order, for a directory:
|
|
52
|
+
* 1. The `strategy.yaml` at or above it ({@link RecipeFileIo.manifestDirectory}, validate's own
|
|
53
|
+
* resolver). An instance directory reads the file the manifest names for it, whatever it is
|
|
54
|
+
* called (nothing checks that it is the target runtime's). A directory several instances share
|
|
55
|
+
* is refused with the restructure fix, since no proof can be recorded there. A package root is
|
|
56
|
+
* refused with one command per instance; a root `strategy.yaml` that does not load is refused.
|
|
57
|
+
* 2. Only when no manifest speaks for the directory: `runtime.yaml`, then `recipe.yaml`
|
|
58
|
+
* ({@link RECIPE_FILENAMES}), and a refusal naming the subdirectories that hold one.
|
|
59
|
+
* A file is read as given.
|
|
60
|
+
*
|
|
61
|
+
* Guarantee: a recipe-named file left beside a readable or unreadable `strategy.yaml` at the
|
|
62
|
+
* package root is never read. Deploy never installs it and validate refuses to prove it, so step 2
|
|
63
|
+
* must not be reached for a directory step 1 has an answer for. Reordering the two is the bug this
|
|
64
|
+
* function exists to prevent: `senpi validate` and `senpi update` would then name different files
|
|
65
|
+
* as one package's recipe.
|
|
66
|
+
*
|
|
67
|
+
* Never throws; every failure is a `{ ok: false, message }` worded for the caller to act on.
|
|
68
|
+
*
|
|
69
|
+
* @param io The file-system calls, injected for tests.
|
|
70
|
+
* @param pathArg The path as the caller wrote it; refusals quote it back in that spelling.
|
|
71
|
+
*/
|
|
72
|
+
export declare function readRecipeAtPath(io: RecipeFileIo, pathArg: string): RecipeFileRead;
|
|
73
|
+
//# sourceMappingURL=recipe-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recipe-file.d.ts","sourceRoot":"","sources":["../../src/runtime/recipe-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAKL,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAE/B;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,0CAA2C,CAAC;AAEzE,yGAAyG;AACzG,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,yCAAyC;IACzC,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,oDAAoD;IACpD,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B,+EAA+E;IAC/E,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACpC;;;;OAIG;IACH,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAC;CACnD;AAED,eAAO,MAAM,mBAAmB,EAAE,YA4BjC,CAAC;AAOF,MAAM,MAAM,cAAc,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAgEzG;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CA0DlF"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a recipe given by path into the `{ content, dir }` an update carries.
|
|
3
|
+
*
|
|
4
|
+
* Shared by the `senpi update` CLI and the `senpi.update` gateway method: a directory resolves to
|
|
5
|
+
* the recipe inside it, and `dir` is the directory of the file actually read. A directory with a
|
|
6
|
+
* `strategy.yaml` at or above it resolves through that manifest, by the same resolver
|
|
7
|
+
* `senpi validate` uses; only a directory no manifest speaks for falls back to the filenames below. The CLI
|
|
8
|
+
* resolves a relative path against its own working directory, which is the caller's. The gateway
|
|
9
|
+
* cannot know the caller's, so it refuses a relative path before calling this (see
|
|
10
|
+
* `update-register.ts`) and `resolvePath` there only ever sees an absolute one.
|
|
11
|
+
*/
|
|
12
|
+
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
13
|
+
import path from "node:path";
|
|
14
|
+
import { runtimeIdFor } from "../deploy/package.js";
|
|
15
|
+
import { instanceTarget, manifestDirectory, sharedDirNote, sharesDir, } from "../validate/target.js";
|
|
16
|
+
/**
|
|
17
|
+
* Recipe filenames looked for inside a directory no manifest speaks for, in order.
|
|
18
|
+
*
|
|
19
|
+
* `runtime.yaml` first: that is what `deploy.py` renders into an instance directory, so it is the
|
|
20
|
+
* name a deployed package actually carries. `recipe.yaml` is what the shipped examples use.
|
|
21
|
+
*/
|
|
22
|
+
export const RECIPE_FILENAMES = ["runtime.yaml", "recipe.yaml"];
|
|
23
|
+
export const NODE_RECIPE_FILE_IO = {
|
|
24
|
+
resolvePath: (p) => path.resolve(process.cwd(), p),
|
|
25
|
+
dirname: (p) => path.dirname(p),
|
|
26
|
+
readFile: (p) => readFileSync(p, "utf8"),
|
|
27
|
+
isDirectory: (p) => {
|
|
28
|
+
try {
|
|
29
|
+
return statSync(p).isDirectory();
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
fileExists: (p) => {
|
|
36
|
+
try {
|
|
37
|
+
return statSync(p).isFile();
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
subdirectories: (p) => {
|
|
44
|
+
try {
|
|
45
|
+
return readdirSync(p, { withFileTypes: true })
|
|
46
|
+
.filter((e) => e.isDirectory())
|
|
47
|
+
.map((e) => e.name);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
manifestDirectory,
|
|
54
|
+
};
|
|
55
|
+
/** The recipe file inside a directory, if it holds one under a conventional name. */
|
|
56
|
+
function recipeIn(io, dir) {
|
|
57
|
+
return RECIPE_FILENAMES.map((n) => `${dir}/${n}`).find((f) => io.fileExists(f));
|
|
58
|
+
}
|
|
59
|
+
/** How a path under the caller's argument is written back to them: in their own spelling. */
|
|
60
|
+
function underArg(pathArg, resolved, target) {
|
|
61
|
+
const rel = path.relative(resolved, target);
|
|
62
|
+
return rel === "" ? pathArg : `${pathArg.replace(/\/+$/, "")}/${rel}`;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The recipe a directory resolves to through its manifest, or the refusal that says why it cannot.
|
|
66
|
+
* `undefined` when no manifest speaks for the directory and the filename rules apply.
|
|
67
|
+
*/
|
|
68
|
+
function readThroughManifest(io, pathArg, resolved) {
|
|
69
|
+
const manifest = io.manifestDirectory(resolved);
|
|
70
|
+
switch (manifest.kind) {
|
|
71
|
+
case "instance": {
|
|
72
|
+
const { pkg, instance } = manifest;
|
|
73
|
+
// No proof can be recorded in a directory several instances share, so no update from it can
|
|
74
|
+
// ever reach --apply. The fix is the restructure, not a recipe file inside it.
|
|
75
|
+
if (sharesDir(pkg, instance))
|
|
76
|
+
return { refusal: sharedDirNote(pkg, instance) };
|
|
77
|
+
// The manifest names the file, whatever it is called and whatever else sits beside it.
|
|
78
|
+
return { recipe: instance.runtimeYamlPath };
|
|
79
|
+
}
|
|
80
|
+
case "package-root": {
|
|
81
|
+
const { pkg } = manifest;
|
|
82
|
+
const leftover = recipeIn(io, resolved);
|
|
83
|
+
const own = pkg.instances.filter((inst) => !sharesDir(pkg, inst));
|
|
84
|
+
return {
|
|
85
|
+
refusal: `"${pathArg}" has no recipe of its own. Its strategy.yaml declares ${pkg.instances.length} ` +
|
|
86
|
+
`instance${pkg.instances.length === 1 ? "" : "s"}, each with its own recipe and its own runtime.\n` +
|
|
87
|
+
(leftover !== undefined
|
|
88
|
+
? `The ${path.basename(leftover)} beside strategy.yaml is not one of them, so it is not read.\n`
|
|
89
|
+
: "") +
|
|
90
|
+
(own.length > 0
|
|
91
|
+
? "Pick the instance matching the runtime you mean to change, and name that runtime with --id. " +
|
|
92
|
+
"A sibling's recipe looks alike and is not refused on the wrong runtime:\n" +
|
|
93
|
+
own
|
|
94
|
+
.map((inst) => ` openclaw senpi update ${underArg(pathArg, resolved, instanceTarget(inst, io.manifestDirectory))} --id ${runtimeIdFor(pkg, inst)}`)
|
|
95
|
+
.join("\n") +
|
|
96
|
+
"\nWhich of these are installed: openclaw senpi runtime list"
|
|
97
|
+
: "") +
|
|
98
|
+
(own.length < pkg.instances.length ? `\n${sharedDirNote(pkg)}` : ""),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
case "unreadable-root":
|
|
102
|
+
return {
|
|
103
|
+
refusal: `"${pathArg}" has a strategy.yaml that does not load: ${manifest.error}\n` +
|
|
104
|
+
"It names this package's recipes, so while it cannot be read any YAML beside it is a guess. " +
|
|
105
|
+
"Fix it (senpi deploy reads the same file and refuses for the same reason), or point at a recipe file itself.",
|
|
106
|
+
};
|
|
107
|
+
case "filesystem":
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Read the recipe `pathArg` names, for an update: the bytes it carries and the directory its
|
|
113
|
+
* proof is checked over.
|
|
114
|
+
*
|
|
115
|
+
* Resolution order, for a directory:
|
|
116
|
+
* 1. The `strategy.yaml` at or above it ({@link RecipeFileIo.manifestDirectory}, validate's own
|
|
117
|
+
* resolver). An instance directory reads the file the manifest names for it, whatever it is
|
|
118
|
+
* called (nothing checks that it is the target runtime's). A directory several instances share
|
|
119
|
+
* is refused with the restructure fix, since no proof can be recorded there. A package root is
|
|
120
|
+
* refused with one command per instance; a root `strategy.yaml` that does not load is refused.
|
|
121
|
+
* 2. Only when no manifest speaks for the directory: `runtime.yaml`, then `recipe.yaml`
|
|
122
|
+
* ({@link RECIPE_FILENAMES}), and a refusal naming the subdirectories that hold one.
|
|
123
|
+
* A file is read as given.
|
|
124
|
+
*
|
|
125
|
+
* Guarantee: a recipe-named file left beside a readable or unreadable `strategy.yaml` at the
|
|
126
|
+
* package root is never read. Deploy never installs it and validate refuses to prove it, so step 2
|
|
127
|
+
* must not be reached for a directory step 1 has an answer for. Reordering the two is the bug this
|
|
128
|
+
* function exists to prevent: `senpi validate` and `senpi update` would then name different files
|
|
129
|
+
* as one package's recipe.
|
|
130
|
+
*
|
|
131
|
+
* Never throws; every failure is a `{ ok: false, message }` worded for the caller to act on.
|
|
132
|
+
*
|
|
133
|
+
* @param io The file-system calls, injected for tests.
|
|
134
|
+
* @param pathArg The path as the caller wrote it; refusals quote it back in that spelling.
|
|
135
|
+
*/
|
|
136
|
+
export function readRecipeAtPath(io, pathArg) {
|
|
137
|
+
let resolved = io.resolvePath(pathArg);
|
|
138
|
+
// A package DIRECTORY is a documented target — the update verb's own help says "Package directory
|
|
139
|
+
// or recipe file", and the guide shows an instance directory. Reading it as a file failed with a
|
|
140
|
+
// raw `EISDIR`.
|
|
141
|
+
if (io.isDirectory(resolved)) {
|
|
142
|
+
// The manifest first, exactly as `senpi validate` resolves it: it, not the directory listing,
|
|
143
|
+
// says which file is a package's recipe and what its instances are.
|
|
144
|
+
const viaManifest = readThroughManifest(io, pathArg, resolved);
|
|
145
|
+
if (viaManifest !== undefined && "refusal" in viaManifest) {
|
|
146
|
+
return { ok: false, message: viaManifest.refusal };
|
|
147
|
+
}
|
|
148
|
+
const candidate = viaManifest?.recipe ?? recipeIn(io, resolved);
|
|
149
|
+
if (candidate === undefined) {
|
|
150
|
+
// No manifest here: an author's package before it has a strategy.yaml. Name the
|
|
151
|
+
// subdirectories that hold a recipe, since "point at the package directory" names what the
|
|
152
|
+
// caller believes they already did.
|
|
153
|
+
const base = pathArg.replace(/\/+$/, "");
|
|
154
|
+
const instances = io
|
|
155
|
+
.subdirectories(resolved)
|
|
156
|
+
.filter((name) => !name.startsWith(".") && recipeIn(io, `${resolved}/${name}`) !== undefined)
|
|
157
|
+
.sort();
|
|
158
|
+
if (instances.length > 0) {
|
|
159
|
+
return {
|
|
160
|
+
ok: false,
|
|
161
|
+
message: `"${pathArg}" has no recipe of its own. It holds ${instances.length} instance ` +
|
|
162
|
+
`director${instances.length === 1 ? "y" : "ies"}, each with its own recipe and its own runtime.\n` +
|
|
163
|
+
"Point at the one matching the runtime you mean to change, and name that runtime with " +
|
|
164
|
+
"--id <runtime_id> (openclaw senpi runtime list shows them):\n" +
|
|
165
|
+
instances.map((name) => ` ${base}/${name}`).join("\n"),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
ok: false,
|
|
170
|
+
message: `"${pathArg}" is a directory with no recipe in it, and none of its subdirectories holds one. ` +
|
|
171
|
+
`Expected one of: ${RECIPE_FILENAMES.join(", ")}.\n` +
|
|
172
|
+
"Point at the directory that holds runtime.yaml (the package root when runtime.yaml is there; " +
|
|
173
|
+
"otherwise the instance subdirectory that holds it), or at the recipe file itself.",
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
resolved = candidate;
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
// The directory is what lets an external scanner's relative `path: ./` resolve and what the
|
|
180
|
+
// proof is hashed over.
|
|
181
|
+
return { ok: true, content: io.readFile(resolved), dir: io.dirname(resolved) };
|
|
182
|
+
}
|
|
183
|
+
catch (err) {
|
|
184
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
185
|
+
const missing = msg.includes("ENOENT") || msg.includes("no such file");
|
|
186
|
+
return {
|
|
187
|
+
ok: false,
|
|
188
|
+
message: missing
|
|
189
|
+
? `Could not find "${pathArg}". Check the path points at the recipe file.`
|
|
190
|
+
: `Could not read "${pathArg}". ${msg}`,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=recipe-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recipe-file.js","sourceRoot":"","sources":["../../src/runtime/recipe-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAC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AE;SAC1C,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -41,6 +41,29 @@ export interface RuntimeDescriptor {
|
|
|
41
41
|
preset_name: string;
|
|
42
42
|
note: string;
|
|
43
43
|
} | null;
|
|
44
|
+
/**
|
|
45
|
+
* sha256 of the recipe text this runtime is RUNNING, normalized (`recipeHash`): blank and
|
|
46
|
+
* comment-only lines dropped, trailing whitespace stripped, and the `wallet:` / `model:` /
|
|
47
|
+
* `decision_model:` lines dropped — the lines deploy rewrites between the authored package and
|
|
48
|
+
* the installed text. Equal digests mean "the running recipe is the file on disk", which is
|
|
49
|
+
* the one question a `dslPreset` name and a collapsed `description` cannot answer (an edited
|
|
50
|
+
* inline ladder under an unchanged preset name is invisible to both). senpi-skills'
|
|
51
|
+
* `senpi-strategy-ops/scripts/_cli.py` (`recipe_hash`) computes the same digest for the file
|
|
52
|
+
* on disk and reports the drift as "an edit that was never applied".
|
|
53
|
+
*
|
|
54
|
+
* `null` for an entry installed by PATH: the engine read that file when it loaded, and this
|
|
55
|
+
* descriptor would re-read it now, so after an in-place edit the hash would match the file while
|
|
56
|
+
* the engine still runs the old text. Deploy installs by content, which is what the runtime runs.
|
|
57
|
+
*/
|
|
58
|
+
recipeHash: string | null;
|
|
44
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* The normalized-text digest of a recipe — see `RuntimeDescriptor.recipeHash`. Line-based on
|
|
62
|
+
* purpose (not a canonical-JSON hash like `computeConfigHash`): the skill side has only the
|
|
63
|
+
* authored YAML text and a stdlib-only reader, so text normalization is the one procedure both
|
|
64
|
+
* sides can run byte-identically. It mirrors `recipe_hash` in `_cli.py` step for step, including
|
|
65
|
+
* Python's line boundaries and whitespace.
|
|
66
|
+
*/
|
|
67
|
+
export declare function recipeHash(text: string): string;
|
|
45
68
|
export declare function describeRuntimeEntry(entry: InstalledRuntimeEntry): RuntimeDescriptor | null;
|
|
46
69
|
//# sourceMappingURL=runtime-descriptor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-descriptor.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime-descriptor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-descriptor.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime-descriptor.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;OASG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,kGAAkG;IAClG,KAAK,EAAE,KAAK,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3D,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAChC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;;;;;;;;;OAUG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;IACnC,GAAG,EAAE,gBAAgB,GAAG;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACrE;;;;;;;;;;;;;OAaG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAqBD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAU/C;AAiID,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,qBAAqB,GAAG,iBAAiB,GAAG,IAAI,CAsB3F"}
|
|
@@ -11,12 +11,51 @@
|
|
|
11
11
|
* `../deploy/package.ts`) rather than "any `exit:` block at all", because that predicate is the one
|
|
12
12
|
* `senpi deploy` actually funds against — see `package.ts:331`.
|
|
13
13
|
*/
|
|
14
|
+
import { createHash } from "node:crypto";
|
|
14
15
|
import { readFileSync } from "node:fs";
|
|
15
16
|
import { parse as parseYaml } from "yaml";
|
|
16
17
|
import { isTruthyPreset } from "../deploy/package.js";
|
|
17
18
|
import { CANONICAL_DSL_PRESET_NAME } from "../constants/dsl/index.js";
|
|
18
19
|
import { parseDslPluginConfig } from "../dsl/config/index.js";
|
|
19
20
|
import { mapRuntimeExitToDslConfig } from "./map-exit-config.js";
|
|
21
|
+
/**
|
|
22
|
+
* Python's whitespace (`str.isspace()`, which `str.strip()` and `re`'s `\s` use) and its
|
|
23
|
+
* `str.splitlines()` boundaries. JS `\s` / `trim()` also strip a BOM (U+FEFF) and do not strip
|
|
24
|
+
* \x1c-\x1f or \x85, and `split(/\r?\n/)` misses a lone \r, \v, \f, \x1c-\x1e, \x85, U+2028 and
|
|
25
|
+
* U+2029, so this side spells the skill side's rules out rather than using the JS built-ins.
|
|
26
|
+
*/
|
|
27
|
+
const PY_WS = "\\t\\n\\v\\f\\r\\x1c-\\x1f \\x85\\xa0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000";
|
|
28
|
+
const PY_LINE_BREAK = /\r\n|[\n\v\f\r\x1c-\x1e\x85\u2028\u2029]/;
|
|
29
|
+
const PY_TRAILING_WS = new RegExp(`[${PY_WS}]+$`);
|
|
30
|
+
const PY_ONLY_WS = new RegExp(`^[${PY_WS}]*$`);
|
|
31
|
+
const PY_COMMENT_LINE = new RegExp(`^[${PY_WS}]*#`);
|
|
32
|
+
/**
|
|
33
|
+
* Recipe lines that differ between the authored package and the installed text by construction:
|
|
34
|
+
* deploy substitutes the wallet it creates, and the decision model it injects for an `llm` action.
|
|
35
|
+
* Kept identical to `RECIPE_HASH_DROP_KEYS` in senpi-skills `senpi-strategy-ops/scripts/_cli.py`.
|
|
36
|
+
*/
|
|
37
|
+
const RECIPE_HASH_DROP_LINE = new RegExp(`^[${PY_WS}]*(wallet|model|decision_model)[${PY_WS}]*:`);
|
|
38
|
+
/**
|
|
39
|
+
* The normalized-text digest of a recipe — see `RuntimeDescriptor.recipeHash`. Line-based on
|
|
40
|
+
* purpose (not a canonical-JSON hash like `computeConfigHash`): the skill side has only the
|
|
41
|
+
* authored YAML text and a stdlib-only reader, so text normalization is the one procedure both
|
|
42
|
+
* sides can run byte-identically. It mirrors `recipe_hash` in `_cli.py` step for step, including
|
|
43
|
+
* Python's line boundaries and whitespace.
|
|
44
|
+
*/
|
|
45
|
+
export function recipeHash(text) {
|
|
46
|
+
const kept = [];
|
|
47
|
+
for (const raw of text.split(PY_LINE_BREAK)) {
|
|
48
|
+
const line = raw.replace(PY_TRAILING_WS, "");
|
|
49
|
+
if (PY_ONLY_WS.test(line))
|
|
50
|
+
continue;
|
|
51
|
+
if (PY_COMMENT_LINE.test(line))
|
|
52
|
+
continue;
|
|
53
|
+
if (RECIPE_HASH_DROP_LINE.test(line))
|
|
54
|
+
continue;
|
|
55
|
+
kept.push(line);
|
|
56
|
+
}
|
|
57
|
+
return createHash("sha256").update(kept.join("\n") + "\n", "utf8").digest("hex");
|
|
58
|
+
}
|
|
20
59
|
/** entry.runtimeYamlContent, else the file at entry.runtimeYamlPath, else null. Never throws. */
|
|
21
60
|
function readEntryYaml(entry) {
|
|
22
61
|
if (typeof entry.runtimeYamlContent === "string")
|
|
@@ -167,6 +206,7 @@ export function describeRuntimeEntry(entry) {
|
|
|
167
206
|
hasExit: exit !== null && hasDslExitBlock(exit),
|
|
168
207
|
dslPreset: presetSummary(exit),
|
|
169
208
|
dsl: ladder(exit),
|
|
209
|
+
recipeHash: typeof entry.runtimeYamlContent === "string" ? recipeHash(text) : null,
|
|
170
210
|
};
|
|
171
211
|
}
|
|
172
212
|
//# sourceMappingURL=runtime-descriptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-descriptor.js","sourceRoot":"","sources":["../../src/runtime/runtime-descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime-descriptor.js","sourceRoot":"","sources":["../../src/runtime/runtime-descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AA0DjE;;;;;GAKG;AACH,MAAM,KAAK,GAAG,gGAAgG,CAAC;AAC/G,MAAM,aAAa,GAAG,0CAA0C,CAAC;AACjE,MAAM,cAAc,GAAG,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC;AAClD,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;AAC/C,MAAM,eAAe,GAAG,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,CAAC,CA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,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC7C,OAAO,EAAE,IAAI,KAAK,IAAI,IAAI,eAAe,CAAC,IAAI,CAAC;QAC/C,SAAS,EAAE,aAAa,CAAC,IAAI,CAAC;QAC9B,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC;QACjB,UAAU,EAAE,OAAO,KAAK,CAAC,kBAAkB,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;KACnF,CAAC;AACJ,CAAC"}
|
|
@@ -68,6 +68,10 @@ export declare class Runtime {
|
|
|
68
68
|
/** Serial signal processing: queue and consumer so only one signal is handled at a time. */
|
|
69
69
|
private signalQueue;
|
|
70
70
|
private signalQueueWait;
|
|
71
|
+
/** Re-queue timers of deferred signals (agent asleep); cleared on stop. */
|
|
72
|
+
private readonly deferredSignalTimers;
|
|
73
|
+
/** Last enqueue time per scanner, so a deferred signal a newer one superseded is dropped. */
|
|
74
|
+
private readonly lastEnqueuedAtByScanner;
|
|
71
75
|
private signalConsumerStopped;
|
|
72
76
|
private signalConsumerDone;
|
|
73
77
|
/** Disposer for this runtime's `runtime.queue_depth` gauge observation; set on start, called on stop. */
|
|
@@ -376,6 +380,14 @@ export declare class Runtime {
|
|
|
376
380
|
* Single consumer: process one scanner:run:complete at a time so slot counts stay correct.
|
|
377
381
|
*/
|
|
378
382
|
private runSignalConsumer;
|
|
383
|
+
/**
|
|
384
|
+
* Re-queue a deferred signal once `etaMs` has passed (round-2 item 5). A timer, not a wait: the
|
|
385
|
+
* serial consumer moves on to the next signal at once.
|
|
386
|
+
*/
|
|
387
|
+
private scheduleDeferredSignal;
|
|
388
|
+
/** Why a re-queued deferred signal is stale, or null when it may still be acted on. */
|
|
389
|
+
private deferredSignalStaleReason;
|
|
390
|
+
private dropStaleDeferredSignal;
|
|
379
391
|
/**
|
|
380
392
|
* Resolve the reconcile gate on a SUCCESSFUL reconcile (boot loop OR a periodic monitor
|
|
381
393
|
* reconcile). Sets `gateResolvedAt` so stale-signal eviction works regardless of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI/E,OAAO,KAAK,EACV,4BAA4B,EAC5B,2BAA2B,EAC5B,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAE3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI/E,OAAO,KAAK,EACV,4BAA4B,EAC5B,2BAA2B,EAC5B,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAE3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AA8CjF,OAAO,EAAE,SAAS,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAetD,OAAO,KAAK,EAKV,mBAAmB,EACnB,kBAAkB,EAEnB,MAAM,oBAAoB,CAAC;A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
|
import { createScannerModuleFromRuntimeConfig } from "./create-scanner-module.js";
|
|
23
23
|
import { createRuntimeContext, createStrategyState, createStrategyStatesMap, } from "./create-runtime-context.js";
|
|
24
24
|
import { createActions } from "./create-actions.js";
|
|
25
|
+
import { deferredSignalStaleReason, earliestValidUntil } from "./agent-wake.js";
|
|
25
26
|
import { ActionRuntimeModule } from "../actions/action-runtime-module.js";
|
|
26
27
|
import { validateDslPositionTracking } from "./validate-dsl-position-tracking.js";
|
|
27
28
|
import { ScannerRegistry } from "./scanner-registry.js";
|
|
@@ -102,6 +103,10 @@ export class Runtime {
|
|
|
102
103
|
/** Serial signal processing: queue and consumer so only one signal is handled at a time. */
|
|
103
104
|
signalQueue = [];
|
|
104
105
|
signalQueueWait = null;
|
|
106
|
+
/** Re-queue timers of deferred signals (agent asleep); cleared on stop. */
|
|
107
|
+
deferredSignalTimers = new Set();
|
|
108
|
+
/** Last enqueue time per scanner, so a deferred signal a newer one superseded is dropped. */
|
|
109
|
+
lastEnqueuedAtByScanner = new Map();
|
|
105
110
|
signalConsumerStopped = false;
|
|
106
111
|
signalConsumerDone = null;
|
|
107
112
|
/** Disposer for this runtime's `runtime.queue_depth` gauge observation; set on start, called on stop. */
|
|
@@ -924,7 +929,10 @@ export class Runtime {
|
|
|
924
929
|
// pass land in one trace. Prefer the id minted at the scanner.run span so scan + pass
|
|
925
930
|
// share one senpi.run.id.
|
|
926
931
|
const runId = event.result.runId ?? randomUUID();
|
|
927
|
-
|
|
932
|
+
const enqueuedAt = Date.now();
|
|
933
|
+
this.signalQueue.push({ result: event.result, enqueuedAt, runId });
|
|
934
|
+
if (event.result.scannerId)
|
|
935
|
+
this.lastEnqueuedAtByScanner.set(event.result.scannerId, enqueuedAt);
|
|
928
936
|
// Edge-triggered backpressure alarm: depth rises one enqueue at a time, so `=== threshold`
|
|
929
937
|
// fires exactly once as it crosses up and re-arms only after the consumer drains back below.
|
|
930
938
|
if (this.signalQueue.length === SIGNAL_QUEUE_BACKPRESSURE_THRESHOLD) {
|
|
@@ -1183,7 +1191,8 @@ export class Runtime {
|
|
|
1183
1191
|
// Resolved once here so the same identity rides both the trace (via the span stamp)
|
|
1184
1192
|
// and the logs (via the context bag below) — one source, no drift.
|
|
1185
1193
|
const identity = this.resolveTraceIdentity();
|
|
1186
|
-
|
|
1194
|
+
// Kept by reference: a decision that found the agent asleep sets `deferral` on it.
|
|
1195
|
+
const flowContext = {
|
|
1187
1196
|
runId: queuedItem.runId,
|
|
1188
1197
|
address: queuedItem.result.address,
|
|
1189
1198
|
recipeName: this.config.name,
|
|
@@ -1193,7 +1202,8 @@ export class Runtime {
|
|
|
1193
1202
|
identityAttributes: identity
|
|
1194
1203
|
? identityTraceAttributes(identity)
|
|
1195
1204
|
: undefined,
|
|
1196
|
-
}
|
|
1205
|
+
};
|
|
1206
|
+
await trackingContext.run(flowContext, async () => {
|
|
1197
1207
|
// Block until the first boot reconcile succeeds (or runtime is stopped).
|
|
1198
1208
|
await this.reconcileGate?.promise;
|
|
1199
1209
|
// If stop() resolved the gate during shutdown, do NOT trade and do NOT
|
|
@@ -1221,6 +1231,14 @@ export class Runtime {
|
|
|
1221
1231
|
});
|
|
1222
1232
|
return;
|
|
1223
1233
|
}
|
|
1234
|
+
// A deferred signal (agent was asleep) that has gone stale is dropped, never acted on late.
|
|
1235
|
+
if (queuedItem.deferrals) {
|
|
1236
|
+
const stale = this.deferredSignalStaleReason(queuedItem, Date.now());
|
|
1237
|
+
if (stale) {
|
|
1238
|
+
this.dropStaleDeferredSignal(queuedItem, stale);
|
|
1239
|
+
return;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1224
1242
|
// Root span born at dequeue; spans for the action handlers nest beneath it.
|
|
1225
1243
|
// Identity (incl. strategy address) rides every span via the per-trace stamp below;
|
|
1226
1244
|
// run.id is the join key back to the producing scanner run.
|
|
@@ -1263,7 +1281,9 @@ export class Runtime {
|
|
|
1263
1281
|
};
|
|
1264
1282
|
this.bus.emit(HOOK_EVENT.ON_SIGNAL_DETECTED, hookEvent);
|
|
1265
1283
|
// Serialize trade loop vs reconcile — reconcileMutex outer, key-lock inner.
|
|
1266
|
-
|
|
1284
|
+
// A re-queued signal re-runs only the actions that deferred; the others already ran.
|
|
1285
|
+
const only = queuedItem.onlyActions ? { onlyActions: new Set(queuedItem.onlyActions) } : undefined;
|
|
1286
|
+
await this.reconcileMutex.withKeyLock("reconcile", () => this.runActionsForSignal(hookEvent, only));
|
|
1267
1287
|
console.info("[senpi-runtime] [ingest-trace] runActionsForSignal complete", JSON.stringify({ address: queuedItem.result.address, scannerId: queuedItem.result.scannerId }));
|
|
1268
1288
|
}
|
|
1269
1289
|
catch (err) {
|
|
@@ -1285,8 +1305,89 @@ export class Runtime {
|
|
|
1285
1305
|
}
|
|
1286
1306
|
});
|
|
1287
1307
|
});
|
|
1308
|
+
// A decision in this pass found the agent not awake: re-queue the signal after the wake ETA,
|
|
1309
|
+
// without holding the queue, for the actions that deferred only.
|
|
1310
|
+
const deferredActions = flowContext.deferredActions;
|
|
1311
|
+
if (deferredActions && deferredActions.size > 0) {
|
|
1312
|
+
const etaMs = Math.max(...[...deferredActions.values()].map((d) => d.etaMs));
|
|
1313
|
+
const reason = [...deferredActions.values()][0].reason;
|
|
1314
|
+
this.scheduleDeferredSignal(queuedItem, { reason, etaMs }, [...deferredActions.keys()]);
|
|
1315
|
+
}
|
|
1316
|
+
else if (flowContext.deferral) {
|
|
1317
|
+
// Deferred outside any action (no per-action record): re-run what this pass ran.
|
|
1318
|
+
this.scheduleDeferredSignal(queuedItem, flowContext.deferral, queuedItem.onlyActions);
|
|
1319
|
+
}
|
|
1288
1320
|
}
|
|
1289
1321
|
}
|
|
1322
|
+
/**
|
|
1323
|
+
* Re-queue a deferred signal once `etaMs` has passed (round-2 item 5). A timer, not a wait: the
|
|
1324
|
+
* serial consumer moves on to the next signal at once.
|
|
1325
|
+
*/
|
|
1326
|
+
scheduleDeferredSignal(item, deferral, onlyActions) {
|
|
1327
|
+
if (this.signalConsumerStopped)
|
|
1328
|
+
return;
|
|
1329
|
+
const firstEnqueuedAt = item.firstEnqueuedAt ?? item.enqueuedAt;
|
|
1330
|
+
const deferrals = (item.deferrals ?? 0) + 1;
|
|
1331
|
+
const etaMs = Math.max(1_000, deferral.etaMs);
|
|
1332
|
+
logger.info("[runtime] signal deferred (agent asleep); re-queued after the wake ETA", {
|
|
1333
|
+
address: item.result.address,
|
|
1334
|
+
scannerId: item.result.scannerId,
|
|
1335
|
+
runId: item.runId,
|
|
1336
|
+
reason: deferral.reason,
|
|
1337
|
+
etaMs,
|
|
1338
|
+
deferrals,
|
|
1339
|
+
...(onlyActions ? { actions: onlyActions } : {}),
|
|
1340
|
+
});
|
|
1341
|
+
this.bus.emit("signal_deferred", {
|
|
1342
|
+
address: item.result.address,
|
|
1343
|
+
scannerId: item.result.scannerId,
|
|
1344
|
+
runId: item.runId,
|
|
1345
|
+
reason: deferral.reason,
|
|
1346
|
+
etaMs,
|
|
1347
|
+
deferrals,
|
|
1348
|
+
...(onlyActions ? { actions: onlyActions } : {}),
|
|
1349
|
+
timestamp: new Date().toISOString(),
|
|
1350
|
+
});
|
|
1351
|
+
const timer = setTimeout(() => {
|
|
1352
|
+
this.deferredSignalTimers.delete(timer);
|
|
1353
|
+
if (this.signalConsumerStopped)
|
|
1354
|
+
return;
|
|
1355
|
+
this.signalQueue.push({
|
|
1356
|
+
result: item.result,
|
|
1357
|
+
runId: item.runId,
|
|
1358
|
+
enqueuedAt: Date.now(),
|
|
1359
|
+
firstEnqueuedAt,
|
|
1360
|
+
deferrals,
|
|
1361
|
+
...(onlyActions ? { onlyActions } : {}),
|
|
1362
|
+
});
|
|
1363
|
+
if (this.signalQueueWait) {
|
|
1364
|
+
const w = this.signalQueueWait;
|
|
1365
|
+
this.signalQueueWait = null;
|
|
1366
|
+
w();
|
|
1367
|
+
}
|
|
1368
|
+
}, etaMs);
|
|
1369
|
+
timer.unref?.();
|
|
1370
|
+
this.deferredSignalTimers.add(timer);
|
|
1371
|
+
}
|
|
1372
|
+
/** Why a re-queued deferred signal is stale, or null when it may still be acted on. */
|
|
1373
|
+
deferredSignalStaleReason(item, now) {
|
|
1374
|
+
const latest = item.result.scannerId ? this.lastEnqueuedAtByScanner.get(item.result.scannerId) : undefined;
|
|
1375
|
+
return deferredSignalStaleReason(item.firstEnqueuedAt ?? item.enqueuedAt, now, latest, undefined, earliestValidUntil(item.result.signals));
|
|
1376
|
+
}
|
|
1377
|
+
dropStaleDeferredSignal(item, reason) {
|
|
1378
|
+
const first = item.firstEnqueuedAt ?? item.enqueuedAt;
|
|
1379
|
+
const payload = {
|
|
1380
|
+
address: item.result.address,
|
|
1381
|
+
scannerId: item.result.scannerId,
|
|
1382
|
+
runId: item.runId,
|
|
1383
|
+
reason,
|
|
1384
|
+
ageMs: Date.now() - first,
|
|
1385
|
+
deferrals: item.deferrals ?? 0,
|
|
1386
|
+
timestamp: new Date().toISOString(),
|
|
1387
|
+
};
|
|
1388
|
+
logger.warn("[runtime] dropping stale deferred signal (never acted on late)", payload);
|
|
1389
|
+
this.bus.emit("signal_deferred_dropped", payload);
|
|
1390
|
+
}
|
|
1290
1391
|
// ─── boot reconcile loop ──────────────────────────────────────────────────────
|
|
1291
1392
|
/**
|
|
1292
1393
|
* Resolve the reconcile gate on a SUCCESSFUL reconcile (boot loop OR a periodic monitor
|
|
@@ -1420,6 +1521,10 @@ export class Runtime {
|
|
|
1420
1521
|
}
|
|
1421
1522
|
// Resolve the gate so the consumer doesn't hang waiting for a reconcile that won't come.
|
|
1422
1523
|
this.reconcileGate?.resolve();
|
|
1524
|
+
// Deferred signals (agent asleep) are not re-queued into a stopped runtime.
|
|
1525
|
+
for (const t of this.deferredSignalTimers)
|
|
1526
|
+
clearTimeout(t);
|
|
1527
|
+
this.deferredSignalTimers.clear();
|
|
1423
1528
|
const uptimeMs = Date.now() - (this.startedAt ?? Date.now());
|
|
1424
1529
|
// First-class event log. The build runs inside emitEvent's guard — telemetry never blocks shutdown.
|
|
1425
1530
|
emitEvent(logger, () => buildRuntimeStoppedEvent(VERSION, uptimeMs, this.strategyConfig.address, this.config.group));
|