@parcha/agentrun-serve 0.1.0-beta.59 → 0.1.0-beta.61
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/CHANGELOG.md +135 -0
- package/README.md +230 -120
- package/dist/acp-package.d.ts +4 -0
- package/dist/agent-delete.d.ts +6 -9
- package/dist/agent-delete.js +5 -3
- package/dist/agent-package.js +11 -1
- package/dist/api-only.d.ts +21 -3
- package/dist/api-only.js +41 -6
- package/dist/archil-routes.d.ts +4 -1
- package/dist/archil-routes.js +15 -12
- package/dist/archil-settings.d.ts +18 -8
- package/dist/archil-settings.js +35 -17
- package/dist/browser-person.d.ts +1 -1
- package/dist/browser-person.js +1 -1
- package/dist/calendar/tools.js +1 -1
- package/dist/chatgpt-plan.d.ts +4 -2
- package/dist/chatgpt-plan.js +13 -3
- package/dist/claude-login-token.d.ts +5 -0
- package/dist/claude-login-token.js +8 -0
- package/dist/claude-login.d.ts +49 -3
- package/dist/claude-login.js +140 -10
- package/dist/cli-learning/connections.js +1 -1
- package/dist/cli.js +42 -10
- package/dist/console/assets/{backend-BztxEAvb.js → backend-C9ffXUR5.js} +1 -1
- package/dist/console/assets/index-BnZV3lvW.js +639 -0
- package/dist/console/assets/{share-L84tlUDW.js → share-B1o5mJ56.js} +2 -2
- package/dist/console/assets/{styles-CaRKlHke.js → styles-D_znYrHR.js} +31 -31
- package/dist/console/assets/styles-fjQBFfMv.css +1 -0
- package/dist/console/index.html +3 -3
- package/dist/console/share.html +3 -3
- package/dist/decisions.d.ts +1 -1
- package/dist/decisions.js +2 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/factory-activity.d.ts +68 -0
- package/dist/factory-activity.js +153 -0
- package/dist/factory-runs.d.ts +11 -0
- package/dist/factory-runs.js +52 -0
- package/dist/filed-tool.d.ts +32 -0
- package/dist/filed-tool.js +122 -0
- package/dist/harness-check.js +2 -1
- package/dist/harness-keys.d.ts +1 -2
- package/dist/harness-keys.js +1 -2
- package/dist/harness-recipe.d.ts +13 -2
- package/dist/harness-recipe.js +30 -7
- package/dist/harness-sign-in.js +2 -1
- package/dist/harness-table.d.ts +9 -3
- package/dist/harness-table.js +11 -5
- package/dist/harness.js +6 -2
- package/dist/import-worker.js +2 -2
- package/dist/import.d.ts +9 -0
- package/dist/import.js +11 -1
- package/dist/key-refusal.d.ts +5 -0
- package/dist/key-refusal.js +30 -18
- package/dist/learn/audit.d.ts +20 -22
- package/dist/learn/audit.js +72 -55
- package/dist/learn/check.js +1 -1
- package/dist/learn/commit.d.ts +35 -43
- package/dist/learn/commit.js +62 -270
- package/dist/learn/compile.d.ts +4 -4
- package/dist/learn/compile.js +6 -7
- package/dist/learn/corrections.js +1 -1
- package/dist/learn/delete.d.ts +5 -12
- package/dist/learn/delete.js +17 -30
- package/dist/learn/forget-run.d.ts +16 -0
- package/dist/learn/forget-run.js +53 -0
- package/dist/learn/index.js +1 -1
- package/dist/learn/learning-of.d.ts +0 -4
- package/dist/learn/learning-of.js +0 -5
- package/dist/learn/{folder.d.ts → legacy/folder.d.ts} +2 -1
- package/dist/learn/{folder.js → legacy/folder.js} +4 -7
- package/dist/learn/legacy/place.d.ts +16 -0
- package/dist/{workspace/learning-workspace.js → learn/legacy/place.js} +12 -42
- package/dist/learn/legacy/scrub.d.ts +28 -0
- package/dist/learn/legacy/scrub.js +258 -0
- package/dist/learn/promote.d.ts +40 -66
- package/dist/learn/promote.js +69 -207
- package/dist/learn/reset-ledger.d.ts +18 -0
- package/dist/learn/reset-ledger.js +14 -0
- package/dist/learn/rows.d.ts +186 -0
- package/dist/learn/rows.js +376 -0
- package/dist/learn/secrets.d.ts +2 -1
- package/dist/learn/secrets.js +2 -2
- package/dist/learn/workflow-draft.d.ts +4 -1
- package/dist/learn/workflow-draft.js +12 -2
- package/dist/learned-nodes.d.ts +36 -0
- package/dist/learned-nodes.js +23 -0
- package/dist/learning-reset.d.ts +1 -1
- package/dist/learning-reset.js +9 -11
- package/dist/learning-routes.d.ts +60 -81
- package/dist/learning-routes.js +187 -360
- package/dist/learning-words.d.ts +2 -0
- package/dist/learning-words.js +2 -0
- package/dist/learning.d.ts +18 -24
- package/dist/learning.js +35 -66
- package/dist/local-model.d.ts +144 -0
- package/dist/local-model.js +214 -0
- package/dist/mcp-gateway.d.ts +6 -0
- package/dist/mcp-gateway.js +44 -8
- package/dist/mcp-probe.d.ts +7 -0
- package/dist/mcp-probe.js +7 -0
- package/dist/mcp-resources.d.ts +1 -1
- package/dist/native/discovery.d.ts +6 -0
- package/dist/native/discovery.js +14 -1
- package/dist/native/remote.d.ts +5 -0
- package/dist/native/remote.js +16 -0
- package/dist/native/runtime.js +3 -2
- package/dist/observation/observer.d.ts +6 -6
- package/dist/ollama-provider.d.ts +35 -0
- package/dist/ollama-provider.js +108 -2
- package/dist/openapi.js +147 -35
- package/dist/place-offers.d.ts +3 -0
- package/dist/place-offers.js +3 -0
- package/dist/place.d.ts +35 -12
- package/dist/place.js +67 -29
- package/dist/print.js +1 -1
- package/dist/purged-workflow.d.ts +0 -33
- package/dist/purged-workflow.js +3 -71
- package/dist/redact/match.d.ts +36 -8
- package/dist/redact/match.js +179 -44
- package/dist/run-export.js +4 -2
- package/dist/run-launch.d.ts +3 -3
- package/dist/run-learning-served.d.ts +3 -3
- package/dist/run-learning-served.js +1 -1
- package/dist/run-listing.d.ts +1 -1
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +6 -5
- package/dist/run-usage.js +3 -2
- package/dist/runnable.js +25 -8
- package/dist/runner/adapter-loop.d.ts +8 -1
- package/dist/runner/adapter-loop.js +100 -20
- package/dist/runner/adapter-run-spec.d.ts +3 -5
- package/dist/runner/adapter-run-spec.js +35 -61
- package/dist/runner/adapters/pi.d.ts +3 -2
- package/dist/runner/adapters/pi.js +3 -1
- package/dist/runner/audit.d.ts +3 -5
- package/dist/runner/audit.js +28 -51
- package/dist/runner/cli-run-spec.js +19 -22
- package/dist/runner/compare-end.d.ts +1 -3
- package/dist/runner/compare-end.js +6 -2
- package/dist/runner/disk-free.d.ts +15 -4
- package/dist/runner/disk-free.js +25 -7
- package/dist/runner/dispatch.js +2 -2
- package/dist/runner/feedback-round.d.ts +1 -1
- package/dist/runner/feedback-round.js +2 -2
- package/dist/runner/harness-loops.d.ts +9 -0
- package/dist/runner/harness-loops.js +49 -7
- package/dist/runner/held.d.ts +4 -11
- package/dist/runner/held.js +0 -25
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +1 -1
- package/dist/runner/learned-first.d.ts +0 -2
- package/dist/runner/learned-first.js +3 -3
- package/dist/runner/learning-end.d.ts +12 -16
- package/dist/runner/learning-end.js +41 -75
- package/dist/runner/learning-seed.d.ts +13 -16
- package/dist/runner/learning-seed.js +13 -23
- package/dist/runner/live-ticker.js +3 -4
- package/dist/runner/main.js +1 -1
- package/dist/runner/mcp-claim.js +3 -2
- package/dist/runner/mcp-run.d.ts +23 -4
- package/dist/runner/mcp-run.js +31 -2
- package/dist/runner/metrics.d.ts +4 -0
- package/dist/runner/metrics.js +9 -3
- package/dist/runner/monid-run.js +3 -1
- package/dist/runner/native-loop.js +3 -4
- package/dist/runner/promotion.d.ts +19 -28
- package/dist/runner/promotion.js +50 -69
- package/dist/runner/redact.d.ts +3 -0
- package/dist/runner/redact.js +7 -0
- package/dist/runner/reflect-hook.d.ts +2 -2
- package/dist/runner/reflect-hook.js +4 -1
- package/dist/runner/run-child-host.d.ts +1 -9
- package/dist/runner/run-child-host.js +12 -68
- package/dist/runner/runner.d.ts +1 -1
- package/dist/runner/sdk-loop.js +7 -7
- package/dist/runner/workflow-calls.d.ts +4 -1
- package/dist/runner/workflow-calls.js +35 -18
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +3 -1
- package/dist/runner/workflow-spec.d.ts +4 -0
- package/dist/runner/workflow-spec.js +18 -13
- package/dist/runs-over-store.d.ts +2 -2
- package/dist/runs-over-store.js +1 -1
- package/dist/sdk/check.d.ts +1 -4
- package/dist/sdk/check.js +2 -3
- package/dist/sdk/runs.d.ts +20 -7
- package/dist/sdk/runs.js +105 -68
- package/dist/secret-cut.js +7 -4
- package/dist/secret-rules.js +97 -83
- package/dist/secrets.d.ts +4 -0
- package/dist/secrets.js +44 -10
- package/dist/server-fs.d.ts +1 -1
- package/dist/server-fs.js +1 -1
- package/dist/server-keys.d.ts +6 -0
- package/dist/server-keys.js +12 -0
- package/dist/server.d.ts +22 -15
- package/dist/server.js +311 -198
- package/dist/slack.js +2 -1
- package/dist/source-sync/auxiliary.js +2 -2
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.js +1 -1
- package/dist/store/postgres/migrate.js +3 -1
- package/dist/store/postgres/migrations/0032_learning_rows.sql +65 -0
- package/dist/store/schema.d.ts +28 -2
- package/dist/store/schema.js +81 -5
- package/dist/store/sqlite/learning-rows.d.ts +23 -0
- package/dist/store/sqlite/learning-rows.js +559 -0
- package/dist/store/sqlite/store.d.ts +7 -1
- package/dist/store/sqlite/store.js +84 -18
- package/dist/store/store.d.ts +219 -6
- package/dist/store/store.js +13 -0
- package/dist/store-reads/journal.d.ts +33 -3
- package/dist/store-reads/journal.js +99 -4
- package/dist/store-reads/learning.d.ts +23 -26
- package/dist/store-reads/learning.js +42 -30
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-view.d.ts +24 -2
- package/dist/store-view.js +40 -11
- package/dist/templates.d.ts +10 -2
- package/dist/templates.js +31 -4
- package/dist/tool-plane.d.ts +27 -3
- package/dist/tool-plane.js +79 -4
- package/dist/tools.d.ts +12 -2
- package/dist/tools.js +42 -7
- package/dist/trigger-launch-hook.d.ts +2 -2
- package/dist/trigger-launch-hook.js +1 -1
- package/dist/triggers.d.ts +7 -4
- package/dist/triggers.js +4 -4
- package/dist/web-holds.d.ts +2 -0
- package/dist/web-holds.js +5 -2
- package/dist/web-run.js +2 -1
- package/dist/workspace/archil-exec.js +1 -1
- package/dist/workspace/archil.d.ts +1 -1
- package/dist/workspace/archil.js +1 -1
- package/dist/workspace/computer-deps.js +5 -3
- package/dist/workspace/computer-providers.d.ts +11 -1
- package/dist/workspace/computer-providers.js +29 -2
- package/dist/workspace/index.d.ts +1 -2
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/paths.d.ts +0 -4
- package/dist/workspace/paths.js +0 -6
- package/dist/workspace/workspace.d.ts +1 -1
- package/dist/workspace/workspace.js +1 -1
- package/package.json +13 -13
- package/templates/TOOLS.md +46 -0
- package/dist/console/assets/index-LwNL4L9q.js +0 -619
- package/dist/console/assets/styles-DQo8rzY-.css +0 -1
- package/dist/workspace/learning-workspace.d.ts +0 -24
- /package/dist/learn/{learning.sh → legacy/learning.sh} +0 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/** The most show paths, and the most segments of one. */
|
|
2
|
+
export const MAX_SHOW_PATHS = 8;
|
|
3
|
+
export const MAX_SHOW_SEGMENTS = 6;
|
|
4
|
+
/** The longest shown string, in characters. */
|
|
5
|
+
export const SHOWN_CHARS = 200;
|
|
6
|
+
/** A folder segment: no dot first (no `..`, no hidden folder), nothing that names another place. */
|
|
7
|
+
const FOLDER_SEGMENT = /^[A-Za-z0-9_][A-Za-z0-9_.-]{0,63}$/;
|
|
8
|
+
/** A show path's segment: a key's name, an array's index, or -1 (its last item). */
|
|
9
|
+
const SHOW_SEGMENT = /^(?:[A-Za-z_$][A-Za-z0-9_$-]{0,63}|0|[1-9][0-9]{0,8}|-1)$/;
|
|
10
|
+
const FOLDER_WORDS = "1 to 3 segments joined by /, each letters, digits, _, - or . and never starting with a dot (no .., no hidden folder)";
|
|
11
|
+
const PATH_WORDS = `a path of 1 to ${MAX_SHOW_SEGMENTS} segments joined by ., each a key (a letter, _ or $ first), an index (0, 1, ...) or -1 (the last item)`;
|
|
12
|
+
const isPlain = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13
|
+
/** The issues of `given` as a file setting, its fields under `at`: none when it is one. */
|
|
14
|
+
export function fileIssues(given, at) {
|
|
15
|
+
if (!isPlain(given) || Object.keys(given).some((key) => key !== "folder" && key !== "show") || given.folder === undefined || given.show === undefined) {
|
|
16
|
+
return [{ field: at, reason: "wrong_type", message: `${at} is {folder, show}: the folder of the run's files each answer of the tool is filed in, whole, and the paths of it the tool's result shows (at most ${MAX_SHOW_PATHS}); the result shows no other value of it` }];
|
|
17
|
+
}
|
|
18
|
+
const issues = [];
|
|
19
|
+
const folder = given.folder;
|
|
20
|
+
const segments = typeof folder === "string" ? folder.split("/") : [];
|
|
21
|
+
if (!(segments.length >= 1 && segments.length <= 3 && segments.every((segment) => FOLDER_SEGMENT.test(segment))))
|
|
22
|
+
issues.push({ field: `${at}.folder`, reason: "not_an_option", message: `${at}.folder is a folder in the run's files: ${FOLDER_WORDS}` });
|
|
23
|
+
const show = given.show;
|
|
24
|
+
if (!Array.isArray(show) || show.length > MAX_SHOW_PATHS) {
|
|
25
|
+
issues.push({ field: `${at}.show`, reason: "not_an_option", message: `${at}.show is a list of at most ${MAX_SHOW_PATHS} paths, each ${PATH_WORDS}` });
|
|
26
|
+
return issues;
|
|
27
|
+
}
|
|
28
|
+
show.forEach((path, i) => {
|
|
29
|
+
const parts = typeof path === "string" ? path.split(".") : [];
|
|
30
|
+
if (!(parts.length >= 1 && parts.length <= MAX_SHOW_SEGMENTS && parts.every((part) => SHOW_SEGMENT.test(part))))
|
|
31
|
+
issues.push({ field: `${at}.show[${i}]`, reason: "not_an_option", message: `${at}.show[${i}] ${JSON.stringify(path)} is ${PATH_WORDS}` });
|
|
32
|
+
});
|
|
33
|
+
const twice = show.find((path, i) => show.indexOf(path) !== i);
|
|
34
|
+
if (twice !== undefined)
|
|
35
|
+
issues.push({ field: `${at}.show`, reason: "not_an_option", message: `${at}.show names ${String(twice)} twice` });
|
|
36
|
+
return issues;
|
|
37
|
+
}
|
|
38
|
+
/** A stored file setting that does not read (a rule tightened since it was written, a runner older than the server that
|
|
39
|
+
* wrote it): every call of its tool is refused, never answered unfiled (mcp-gateway.ts unsendable). */
|
|
40
|
+
export const UNREADABLE = "unreadable";
|
|
41
|
+
/** The file setting of `server`'s `tool` in an agent's tool settings as its revision keeps them (body.toolSettings):
|
|
42
|
+
* undefined when it has none (the tool answers the model as it always has), UNREADABLE when it has one that does not
|
|
43
|
+
* read. */
|
|
44
|
+
export function filedBy(toolSettings) {
|
|
45
|
+
return (server, tool) => {
|
|
46
|
+
const key = `mcp:${server}/${tool}`;
|
|
47
|
+
const setting = isPlain(toolSettings) && Object.hasOwn(toolSettings, key) ? toolSettings[key] : undefined;
|
|
48
|
+
const file = isPlain(setting) ? setting.file : undefined;
|
|
49
|
+
if (file === undefined)
|
|
50
|
+
return undefined;
|
|
51
|
+
if (fileIssues(file, "file").length)
|
|
52
|
+
return UNREADABLE;
|
|
53
|
+
const { folder, show } = file;
|
|
54
|
+
return { folder, show: [...show] };
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** The value at `path` in `value`, as the model reads it: a scalar (a string cut at SHOWN_CHARS, … marking the cut),
|
|
58
|
+
* else null (absent, or an object or array). */
|
|
59
|
+
export function shownAt(value, path) {
|
|
60
|
+
let at = value;
|
|
61
|
+
for (const part of path.split(".")) {
|
|
62
|
+
if (Array.isArray(at))
|
|
63
|
+
at = part === "-1" ? at[at.length - 1] : /^\d+$/.test(part) ? at[Number(part)] : undefined;
|
|
64
|
+
else if (isPlain(at))
|
|
65
|
+
at = Object.hasOwn(at, part) ? at[part] : undefined;
|
|
66
|
+
else
|
|
67
|
+
at = undefined;
|
|
68
|
+
}
|
|
69
|
+
if (typeof at === "string") {
|
|
70
|
+
const chars = Array.from(at);
|
|
71
|
+
return chars.length > SHOWN_CHARS ? `${chars.slice(0, SHOWN_CHARS).join("")}…` : at;
|
|
72
|
+
}
|
|
73
|
+
return typeof at === "number" || typeof at === "boolean" ? at : null;
|
|
74
|
+
}
|
|
75
|
+
/** The most keys of one object the shape names, and the longest shape. */
|
|
76
|
+
const SHAPE_KEYS = 40;
|
|
77
|
+
const SHAPE_CHARS = 2_000;
|
|
78
|
+
/** A key the shape names: a short name. Any other key (an email, a person's name, an id) can be data, so it is counted,
|
|
79
|
+
* never named. */
|
|
80
|
+
const SHAPE_KEY = /^[A-Za-z_][A-Za-z0-9_]{0,31}$/;
|
|
81
|
+
/** `value`'s shape: types, each array's length and what it holds, an object's keys that are short names while `depth`
|
|
82
|
+
* is under 2 (the rest counted); never a value. */
|
|
83
|
+
export function shapeOf(value, depth = 0) {
|
|
84
|
+
if (value === null)
|
|
85
|
+
return "null";
|
|
86
|
+
if (Array.isArray(value)) {
|
|
87
|
+
const kinds = new Set(value.map((item) => (item === null ? "null" : Array.isArray(item) ? "array" : typeof item)));
|
|
88
|
+
const kind = kinds.size === 1 ? [...kinds][0] : "item";
|
|
89
|
+
return `[${value.length} ${kind}${value.length === 1 ? "" : "s"}]`;
|
|
90
|
+
}
|
|
91
|
+
if (isPlain(value)) {
|
|
92
|
+
if (depth >= 2)
|
|
93
|
+
return "object";
|
|
94
|
+
const keys = Object.keys(value);
|
|
95
|
+
const named = keys.filter((key) => SHAPE_KEY.test(key)).slice(0, SHAPE_KEYS).map((key) => `${JSON.stringify(key)}: ${shapeOf(value[key], depth + 1)}`);
|
|
96
|
+
const rest = keys.length - named.length;
|
|
97
|
+
const counted = rest ? `… ${rest} ${named.length ? "more " : ""}key${rest === 1 ? "" : "s"}` : "";
|
|
98
|
+
return `{${[...named, ...(counted ? [counted] : [])].join(", ")}}`;
|
|
99
|
+
}
|
|
100
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? typeof value : "unknown";
|
|
101
|
+
}
|
|
102
|
+
/** The tool's result for an answer filed at `path` (in the run's files): its bytes, where it is, the values `show`
|
|
103
|
+
* names, and its shape. */
|
|
104
|
+
export function filedSummary(tool, text, path, show) {
|
|
105
|
+
let value;
|
|
106
|
+
let json = true;
|
|
107
|
+
try {
|
|
108
|
+
value = JSON.parse(text);
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
json = false;
|
|
112
|
+
}
|
|
113
|
+
const shown = `{${show.map((one) => `${JSON.stringify(one)}: ${JSON.stringify(json ? shownAt(value, one) : null)}`).join(", ")}}`;
|
|
114
|
+
const shape = json ? shapeOf(value) : "text, not JSON";
|
|
115
|
+
return [
|
|
116
|
+
`${tool} answered ${Buffer.byteLength(text, "utf8").toLocaleString("en-US")} bytes, filed whole at ${path} for the skill's code; its values are not shown here (the agent's setting files this tool's answers); only these are:`,
|
|
117
|
+
shown,
|
|
118
|
+
`Shape: ${shape.length > SHAPE_CHARS ? `${shape.slice(0, SHAPE_CHARS)}…` : shape}`,
|
|
119
|
+
].join("\n");
|
|
120
|
+
}
|
|
121
|
+
/** The model's text when an answer could not be filed: none of it, the Workspace's words why. */
|
|
122
|
+
export const unfiledSummary = (tool, text, folder, why) => `${tool} answered ${Buffer.byteLength(text, "utf8").toLocaleString("en-US")} bytes, which could not be filed in ${folder}/ (${why}). The agent's setting files this tool's answers, so none of it is shown here.`;
|
package/dist/harness-check.js
CHANGED
|
@@ -24,7 +24,7 @@ import { modelPortFor, SessionFenced } from "@parcha/agentrun-kernel";
|
|
|
24
24
|
import { beforeRequestOf } from "@parcha/agentrun-kernel/kernel/cap";
|
|
25
25
|
import { archivePlatform } from "./harness-archive.js";
|
|
26
26
|
import { egressProxy, egressVars } from "./harness-egress.js";
|
|
27
|
-
import { AGENT_VARS, installHolds, loadRecipe, recipeInstall, RecipeRefused, writeChecked } from "./harness-recipe.js";
|
|
27
|
+
import { AGENT_VARS, installHolds, loadRecipe, recipeInstall, RecipeRefused, recipeSaid, writeChecked } from "./harness-recipe.js";
|
|
28
28
|
import { recipeEntryOf } from "./harness-recipe-entry.js";
|
|
29
29
|
import { providerModels } from "./model.js";
|
|
30
30
|
import { capModelOf } from "./runner/cli-run-spec.js";
|
|
@@ -154,6 +154,7 @@ async function checkRun(options, held) {
|
|
|
154
154
|
held.push(...recipe.keys.map((name) => options.env[name]).filter((value) => typeof value === "string"));
|
|
155
155
|
const head = { recipe: { id: recipe.id, label: recipe.label, file: loaded.file, sha256: loaded.sha256 }, checkedAt };
|
|
156
156
|
const refuse = (code, message) => ({ ok: false, ...head, refused: { code, message: `${code}: ${message}` }, failures: [`${code}: ${message}`] });
|
|
157
|
+
say(recipeSaid(recipe.label, loaded.file, loaded.bundled));
|
|
157
158
|
say(`${recipe.label}: the recipe holds the five rules (${loaded.file})`);
|
|
158
159
|
// What the agent runs on: the recipe's keys, read from this shell, alone (a proxy-billed one's: none, the model proxy's).
|
|
159
160
|
// A check never runs on its owner's own sign-in, which a schedule, a check and a shared server never take
|
package/dist/harness-keys.d.ts
CHANGED
|
@@ -114,8 +114,7 @@ export declare class HarnessKeysOverStore {
|
|
|
114
114
|
private kept;
|
|
115
115
|
/** GET: `recipe`'s keys, each by name, whether saved for it and when it changed, and those to enter again: never a value. */
|
|
116
116
|
view(recipe: PlanRecipe): HarnessKeysView;
|
|
117
|
-
/** Each id with keys saved whose recipe this server does not name, sorted:
|
|
118
|
-
* console offers the page that removes them. */
|
|
117
|
+
/** Each id with keys saved whose recipe this server does not name, sorted: the page lists them (list), to remove. */
|
|
119
118
|
unnamed(): string[];
|
|
120
119
|
/** GET /settings/harness-keys: every plan-billed recipe this server is started with, its keys by name; then each id
|
|
121
120
|
* with keys saved whose recipe it no longer names (unnamed), its keys kept. */
|
package/dist/harness-keys.js
CHANGED
|
@@ -253,8 +253,7 @@ export class HarnessKeysOverStore {
|
|
|
253
253
|
});
|
|
254
254
|
return { id: recipe.id, label: recipe.label, named: true, keys, kept: this.kept(recipe.id, recipe.keys), ready: this.saved(recipe), reenter };
|
|
255
255
|
}
|
|
256
|
-
/** Each id with keys saved whose recipe this server does not name, sorted:
|
|
257
|
-
* console offers the page that removes them. */
|
|
256
|
+
/** Each id with keys saved whose recipe this server does not name, sorted: the page lists them (list), to remove. */
|
|
258
257
|
unnamed() {
|
|
259
258
|
const named = new Set(this.recipes.map((recipe) => recipe.id));
|
|
260
259
|
return [...new Set([...this.current.keys()].flatMap((row) => rowParts(row)?.harness ?? []))].filter((id) => !named.has(id)).sort();
|
package/dist/harness-recipe.d.ts
CHANGED
|
@@ -136,15 +136,26 @@ export declare function recipeProblems(parsed: unknown): {
|
|
|
136
136
|
}[];
|
|
137
137
|
/** The recipe in `text`, or RecipeRefused with every problem. */
|
|
138
138
|
export declare function parseRecipe(text: string): Recipe;
|
|
139
|
-
/** The
|
|
139
|
+
/** The file `given` names, from `cwd`: the recipe the ACP package ships (bundledRecipePath: Google Antigravity's) when
|
|
140
|
+
* `given` is its name, else the file at that path. A name a file in `cwd` also holds is refused, saying both, so the
|
|
141
|
+
* owner's own file is never passed over silently (`./<name>` names the file). A bundled name is never a built-in
|
|
142
|
+
* harness's id: the recipe's own id is that name, and a built-in id is refused as a recipe's (parseRecipe). */
|
|
143
|
+
export declare function resolveRecipe(given: string, cwd?: string): {
|
|
144
|
+
file: string;
|
|
145
|
+
bundled: boolean;
|
|
146
|
+
};
|
|
147
|
+
/** Which recipe resolved, as a command says it before anything else: the one AgentRun ships, or the owner's file. */
|
|
148
|
+
export declare const recipeSaid: (label: string, file: string, bundled: boolean) => string;
|
|
149
|
+
/** The recipe at `path` (a file, or the name of a recipe AgentRun ships: resolveRecipe), read and loaded. */
|
|
140
150
|
export declare function loadRecipe(path: string): {
|
|
141
151
|
recipe: Recipe;
|
|
142
152
|
file: string;
|
|
143
153
|
sha256: string;
|
|
154
|
+
bundled: boolean;
|
|
144
155
|
};
|
|
145
156
|
/** The recipe's release for `platform` (this host's by default), or undefined where it lists none. */
|
|
146
157
|
export declare const releaseFor: (recipe: Recipe, platform?: string | undefined) => RecipeArchive | undefined;
|
|
147
|
-
/** The owner's command that installs the recipe at `file` into `data
|
|
158
|
+
/** The owner's command that installs the recipe at `file` into `data` (one AgentRun ships by its name, as goose's is). */
|
|
148
159
|
export declare const recipeInstallLine: (file: string, data: string, env?: NodeJS.ProcessEnv) => string;
|
|
149
160
|
/** Where the recipe's binary is once installed: `<data>/harnesses/<id>/<cmd>`. */
|
|
150
161
|
export declare const recipeBinaryOf: (data: string, recipe: Recipe, release: RecipeArchive) => string;
|
package/dist/harness-recipe.js
CHANGED
|
@@ -400,9 +400,32 @@ export function parseRecipe(text) {
|
|
|
400
400
|
...(r.signIn ? { signIn: Object.freeze({ args: Object.freeze([...r.signIn.args]), homeArg: r.signIn.homeArg, ...(r.signIn.terms ? { terms: r.signIn.terms } : {}) }) } : {}),
|
|
401
401
|
});
|
|
402
402
|
}
|
|
403
|
-
/** The
|
|
403
|
+
/** The file `given` names, from `cwd`: the recipe the ACP package ships (bundledRecipePath: Google Antigravity's) when
|
|
404
|
+
* `given` is its name, else the file at that path. A name a file in `cwd` also holds is refused, saying both, so the
|
|
405
|
+
* owner's own file is never passed over silently (`./<name>` names the file). A bundled name is never a built-in
|
|
406
|
+
* harness's id: the recipe's own id is that name, and a built-in id is refused as a recipe's (parseRecipe). */
|
|
407
|
+
export function resolveRecipe(given, cwd = process.cwd()) {
|
|
408
|
+
const local = resolve(cwd, given);
|
|
409
|
+
const shipped = acpPackage()?.bundledRecipePath?.(given);
|
|
410
|
+
// The shipped file named by its path is the shipped recipe too.
|
|
411
|
+
if (!shipped)
|
|
412
|
+
return { file: local, bundled: bundledName(local) !== undefined };
|
|
413
|
+
if (existsSync(local))
|
|
414
|
+
throw new RecipeRefused(RECIPE_CODES.invalid, [{ code: RECIPE_CODES.invalid, words: `${given} names both the recipe AgentRun ships (${shipped}) and the file ${local} in this directory: write ./${given} for your file, or name the shipped one from another directory` }]);
|
|
415
|
+
return { file: shipped, bundled: true };
|
|
416
|
+
}
|
|
417
|
+
/** The name of the recipe at `file` when the ACP package ships it, else undefined. */
|
|
418
|
+
const bundledName = (file) => {
|
|
419
|
+
const acp = acpPackage();
|
|
420
|
+
return acp?.BUNDLED_RECIPES?.find((each) => acp.bundledRecipePath?.(each) === resolve(file));
|
|
421
|
+
};
|
|
422
|
+
/** The word a printed command names the recipe at `file` by: its bundled name, else the file. */
|
|
423
|
+
const recipeWord = (file) => bundledName(file) ?? shellWord(file);
|
|
424
|
+
/** Which recipe resolved, as a command says it before anything else: the one AgentRun ships, or the owner's file. */
|
|
425
|
+
export const recipeSaid = (label, file, bundled) => `${label}: ${bundled ? `the recipe AgentRun ships (${file})` : `the recipe file ${file}`}`;
|
|
426
|
+
/** The recipe at `path` (a file, or the name of a recipe AgentRun ships: resolveRecipe), read and loaded. */
|
|
404
427
|
export function loadRecipe(path) {
|
|
405
|
-
const file =
|
|
428
|
+
const { file, bundled } = resolveRecipe(path);
|
|
406
429
|
let text;
|
|
407
430
|
try {
|
|
408
431
|
text = readFileSync(file, "utf8");
|
|
@@ -410,12 +433,12 @@ export function loadRecipe(path) {
|
|
|
410
433
|
catch (error) {
|
|
411
434
|
throw new RecipeRefused(RECIPE_CODES.invalid, [{ code: RECIPE_CODES.invalid, words: `the recipe file ${file} cannot be read (${error.code ?? error.message})` }]);
|
|
412
435
|
}
|
|
413
|
-
return { recipe: parseRecipe(text), file, sha256: createHash("sha256").update(text).digest("hex") };
|
|
436
|
+
return { recipe: parseRecipe(text), file, sha256: createHash("sha256").update(text).digest("hex"), bundled };
|
|
414
437
|
}
|
|
415
438
|
/** The recipe's release for `platform` (this host's by default), or undefined where it lists none. */
|
|
416
439
|
export const releaseFor = (recipe, platform = archivePlatform()) => (platform ? recipe.release.archives[platform] : undefined);
|
|
417
|
-
/** The owner's command that installs the recipe at `file` into `data
|
|
418
|
-
export const recipeInstallLine = (file, data, env = process.env) => `agentrun harness install
|
|
440
|
+
/** The owner's command that installs the recipe at `file` into `data` (one AgentRun ships by its name, as goose's is). */
|
|
441
|
+
export const recipeInstallLine = (file, data, env = process.env) => `agentrun harness install ${bundledName(file) ?? `--recipe ${shellWord(file)}`}${resolve(data) === commandData(env) ? "" : ` --data ${shellWord(data)}`}`;
|
|
419
442
|
/** Where the recipe's binary is once installed: `<data>/harnesses/<id>/<cmd>`. */
|
|
420
443
|
export const recipeBinaryOf = (data, recipe, release) => join(installDirOf(data, recipe.id), insideHome(release.cmd));
|
|
421
444
|
/** A first-seen digest record in a file of its own (one line, the sha256), written once and never over another's. */
|
|
@@ -482,7 +505,7 @@ export const signInHomeOf = (data, id) => join(harnessesOf(data), `${id}.sign-in
|
|
|
482
505
|
* `<data>/harnesses/<id>.signed-in`, holding when and on which version. It holds nothing of the sign-in. */
|
|
483
506
|
export const signedInNoteOf = (data, id) => join(harnessesOf(data), `${id}.signed-in`);
|
|
484
507
|
/** The owner's command that signs the recipe at `file` in, on `data`. */
|
|
485
|
-
export const recipeSignInLine = (file, data, env = process.env) => `agentrun harness sign-in --recipe ${
|
|
508
|
+
export const recipeSignInLine = (file, data, env = process.env) => `agentrun harness sign-in --recipe ${recipeWord(file)}${resolve(data) === commandData(env) ? "" : ` --data ${shellWord(data)}`}`;
|
|
486
509
|
/** Whether the agent's own sign-in ended well on `data` (signedInNoteOf): nothing in its folder is read to say so.
|
|
487
510
|
* Whether the sign-in still holds is the agent's to say when it runs (an ACP -32000, Authentication required). */
|
|
488
511
|
export const signedIn = (data, recipe) => recipe.signIn !== undefined && existsSync(signedInNoteOf(data, recipe.id));
|
|
@@ -521,4 +544,4 @@ export async function installRecipe(recipe, file, data, options = {}, env = proc
|
|
|
521
544
|
return { version: recipe.release.version, pinnedBy, ...done };
|
|
522
545
|
}
|
|
523
546
|
/** The owner's command that checks the recipe at `file`, installed into `data`. */
|
|
524
|
-
export const recipeCheckLine = (file, data, env = process.env) => `agentrun harness-check --recipe ${
|
|
547
|
+
export const recipeCheckLine = (file, data, env = process.env) => `agentrun harness-check --recipe ${recipeWord(file)}${resolve(data) === commandData(env) ? "" : ` --data ${shellWord(data)}`}`;
|
package/dist/harness-sign-in.js
CHANGED
|
@@ -11,7 +11,7 @@ import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:f
|
|
|
11
11
|
import { tmpdir } from "node:os";
|
|
12
12
|
import { join } from "node:path";
|
|
13
13
|
import { archivePlatform } from "./harness-archive.js";
|
|
14
|
-
import { AGENT_VARS, installHolds, loadRecipe, recipeInstall, RecipeRefused, signedInNoteOf, signInHomeOf } from "./harness-recipe.js";
|
|
14
|
+
import { AGENT_VARS, installHolds, loadRecipe, recipeInstall, RecipeRefused, recipeSaid, signedInNoteOf, signInHomeOf } from "./harness-recipe.js";
|
|
15
15
|
/** A recipe with no signIn: it runs on its keys alone, and has nothing to sign in. */
|
|
16
16
|
export const HARNESS_NO_SIGN_IN = "HARNESS_NO_SIGN_IN";
|
|
17
17
|
/** The agent's own sign-in did not end well: its exit status, a signal, or the time ran out. */
|
|
@@ -35,6 +35,7 @@ export async function signInHarness(options) {
|
|
|
35
35
|
return { ok: false, code: error.code, message: error.message };
|
|
36
36
|
}
|
|
37
37
|
const { recipe, file } = loaded;
|
|
38
|
+
say(recipeSaid(recipe.label, file, loaded.bundled));
|
|
38
39
|
if (!recipe.signIn)
|
|
39
40
|
return refuse(HARNESS_NO_SIGN_IN, `${recipe.label}'s recipe names no signIn: it runs on its keys (${recipe.keys.join(", ") || "none"}), and has nothing to sign in`);
|
|
40
41
|
// The installed binary and every file beside it, the pinned ones, as a check finds them (recipeInstall, installHolds):
|
package/dist/harness-table.d.ts
CHANGED
|
@@ -220,10 +220,12 @@ export declare const HARNESS_KEY_OWNED = "HARNESS_KEY_OWNED";
|
|
|
220
220
|
export declare const HARNESS_RECIPES_ENV = "AGENTRUN_HARNESS_RECIPES";
|
|
221
221
|
/** The owner's setting that names harness recipes when no option does: recipe files, comma-separated. */
|
|
222
222
|
export declare const HARNESS_RECIPES_SETTING = "AGENTRUN_SERVE_HARNESS_RECIPES";
|
|
223
|
-
/** The recipe files `given` names (a server's or a runner's `--harness-recipe`, else HARNESS_RECIPES_SETTING)
|
|
223
|
+
/** The recipe files `given` names (a server's or a runner's `--harness-recipe`, else HARNESS_RECIPES_SETTING): each a
|
|
224
|
+
* file, or the name of a recipe AgentRun ships (harness-recipe.ts resolveRecipe). */
|
|
224
225
|
export declare const harnessRecipesOf: (given: readonly string[] | undefined, env: NodeJS.ProcessEnv) => string[];
|
|
225
|
-
/** HARNESS_RECIPES_ENV for the
|
|
226
|
-
* server's start
|
|
226
|
+
/** HARNESS_RECIPES_ENV for the recipes `files` names (each resolved by resolveRecipe: a shipped one's name to its file, a
|
|
227
|
+
* name a file here also holds refused), installed into `data`: none for none. `signIn` only where the server's start
|
|
228
|
+
* proved --harness-sign-in. */
|
|
227
229
|
export declare const harnessRecipesEnv: (files: readonly string[], data: string, { signIn }?: {
|
|
228
230
|
signIn?: boolean;
|
|
229
231
|
}) => NodeJS.ProcessEnv;
|
|
@@ -268,6 +270,10 @@ export declare const harnessModulesEnv: (names: readonly string[], data: string)
|
|
|
268
270
|
/** The ids of the harnesses `env`'s table lists, in its order: the built-in ones (pi first), then those its modules add;
|
|
269
271
|
* not one its entry hides on `env` (HarnessEntry.hidden: Goose until it is installed). */
|
|
270
272
|
export declare const harnessIds: (env: NodeJS.ProcessEnv) => readonly string[];
|
|
273
|
+
/** The ids capabilities offer (harness.ts harnessOffers), in the table's order: harnessIds', and each recipe the server is
|
|
274
|
+
* started with though its entry hides it (not installed, not checked, keys not saved): its owner named it, so it is
|
|
275
|
+
* offered as not available, with why and the command that fixes it, never left out. */
|
|
276
|
+
export declare const offeredIds: (env: NodeJS.ProcessEnv) => readonly string[];
|
|
271
277
|
/** The ids of every harness `env`'s table has, hidden ones too: those a definition may name (a save warns of a hidden one,
|
|
272
278
|
* a run is refused with why). */
|
|
273
279
|
export declare const tableIds: (env: NodeJS.ProcessEnv) => readonly string[];
|
package/dist/harness-table.js
CHANGED
|
@@ -22,7 +22,7 @@ import { chooseModel, hostModel } from "./model.js";
|
|
|
22
22
|
import { HarnessUnavailable, modelOn, openRouterOnly, priceModelFor, providerFor } from "./provider.js";
|
|
23
23
|
import { modelWire, routedId, wireOf, WIRES } from "./wires.js";
|
|
24
24
|
import { PLAN_PROVIDER, signedIn } from "./chatgpt-plan.js";
|
|
25
|
-
import { loadRecipe } from "./harness-recipe.js";
|
|
25
|
+
import { loadRecipe, resolveRecipe } from "./harness-recipe.js";
|
|
26
26
|
import { recipeServerEntry } from "./harness-recipe-entry.js";
|
|
27
27
|
/** A module of entries a test merges over the built-in ones (HarnessTableModule), by absolute path. */
|
|
28
28
|
export const HARNESS_TABLE_ENV = "AGENTRUN_HARNESS_TABLE";
|
|
@@ -473,11 +473,13 @@ function recipesOf(env) {
|
|
|
473
473
|
}
|
|
474
474
|
/** The owner's setting that names harness recipes when no option does: recipe files, comma-separated. */
|
|
475
475
|
export const HARNESS_RECIPES_SETTING = "AGENTRUN_SERVE_HARNESS_RECIPES";
|
|
476
|
-
/** The recipe files `given` names (a server's or a runner's `--harness-recipe`, else HARNESS_RECIPES_SETTING)
|
|
476
|
+
/** The recipe files `given` names (a server's or a runner's `--harness-recipe`, else HARNESS_RECIPES_SETTING): each a
|
|
477
|
+
* file, or the name of a recipe AgentRun ships (harness-recipe.ts resolveRecipe). */
|
|
477
478
|
export const harnessRecipesOf = (given, env) => given?.length ? [...given] : (env[HARNESS_RECIPES_SETTING] ?? "").split(",").map((name) => name.trim()).filter(Boolean);
|
|
478
|
-
/** HARNESS_RECIPES_ENV for the
|
|
479
|
-
* server's start
|
|
480
|
-
|
|
479
|
+
/** HARNESS_RECIPES_ENV for the recipes `files` names (each resolved by resolveRecipe: a shipped one's name to its file, a
|
|
480
|
+
* name a file here also holds refused), installed into `data`: none for none. `signIn` only where the server's start
|
|
481
|
+
* proved --harness-sign-in. */
|
|
482
|
+
export const harnessRecipesEnv = (files, data, { signIn = false } = {}) => (files.length ? { [HARNESS_RECIPES_ENV]: JSON.stringify({ data: resolve(data), files: files.map((file) => resolveRecipe(file).file), ...(signIn ? { signIn: true } : {}) }) } : {});
|
|
481
483
|
/** The table `env` runs on: the built-in entries; then, only under a test runner (node --test's NODE_TEST_CONTEXT, which a
|
|
482
484
|
* server's and a run's processes there carry), a test's module's (HARNESS_TABLE_ENV) merged over them by id; then the
|
|
483
485
|
* harnesses each of the owner's harness modules adds (HARNESS_MODULES_ENV), under a test runner or not. A module adds
|
|
@@ -580,6 +582,10 @@ export const harnessModulesEnv = (names, data) => (names.length ? { [HARNESS_MOD
|
|
|
580
582
|
/** The ids of the harnesses `env`'s table lists, in its order: the built-in ones (pi first), then those its modules add;
|
|
581
583
|
* not one its entry hides on `env` (HarnessEntry.hidden: Goose until it is installed). */
|
|
582
584
|
export const harnessIds = (env) => Object.entries(harnessTable(env)).filter(([, entry]) => entry.hidden?.(env) === undefined).map(([id]) => id);
|
|
585
|
+
/** The ids capabilities offer (harness.ts harnessOffers), in the table's order: harnessIds', and each recipe the server is
|
|
586
|
+
* started with though its entry hides it (not installed, not checked, keys not saved): its owner named it, so it is
|
|
587
|
+
* offered as not available, with why and the command that fixes it, never left out. */
|
|
588
|
+
export const offeredIds = (env) => Object.entries(harnessTable(env)).filter(([, entry]) => entry.hidden?.(env) === undefined || madeByRecipe.has(entry)).map(([id]) => id);
|
|
583
589
|
/** The ids of every harness `env`'s table has, hidden ones too: those a definition may name (a save warns of a hidden one,
|
|
584
590
|
* a run is refused with why). */
|
|
585
591
|
export const tableIds = (env) => Object.keys(harnessTable(env));
|
package/dist/harness.js
CHANGED
|
@@ -41,11 +41,15 @@ export function harnessOffers(env) {
|
|
|
41
41
|
const { hostMemory, neverFits } = await import("./host.js");
|
|
42
42
|
const memory = hostMemory();
|
|
43
43
|
const { harnessInstalled } = await import("./adapters.js");
|
|
44
|
-
const {
|
|
45
|
-
const probed = await Promise.all(
|
|
44
|
+
const { harnessOf, NATIVE_PROMISES, offeredIds } = await import("./harness-table.js");
|
|
45
|
+
const probed = await Promise.all(offeredIds(env).map(async (id) => {
|
|
46
46
|
const entry = harnessOf(env, id);
|
|
47
47
|
const card = entry.card?.(env);
|
|
48
48
|
const named = { label: entry.label, promises: entry.promises ?? NATIVE_PROMISES, ...(card ? { card } : {}) };
|
|
49
|
+
// A recipe the server is started with that its entry hides (offeredIds): not available, with why.
|
|
50
|
+
const hidden = entry.hidden?.(env);
|
|
51
|
+
if (hidden !== undefined)
|
|
52
|
+
return { id, ...named, available: false, steer: entry.steer, reason: hidden };
|
|
49
53
|
// The start's probe: these offers hold until a restart (server.ts), so the reason says so where installing fixes it.
|
|
50
54
|
// Claude Code not installed yet says so (its install probes the offers again).
|
|
51
55
|
const firstUse = entry.installs && !(await harnessInstalled(entry, env)) ? { installs: "on_first_use" } : {};
|
package/dist/import-worker.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// Before anything loads node:sqlite, as in the server's own thread: its ExperimentalWarning is not the server's to print.
|
|
8
8
|
import "./quiet-sqlite-warning.js";
|
|
9
9
|
import { parentPort, workerData } from "node:worker_threads";
|
|
10
|
-
import { candidatesOf, ownSecrets, planImport, runImport, sessionsOf } from "./import.js";
|
|
10
|
+
import { candidatesOf, ownSecrets, planImport, runImport, sessionsOf, wrappedReading } from "./import.js";
|
|
11
11
|
import { importStoreProxy } from "./import-proxy.js";
|
|
12
12
|
import { catalogPrices } from "./model.js";
|
|
13
13
|
import { toolKeysOverStore } from "./tool-keys-store.js";
|
|
@@ -27,7 +27,7 @@ const answer = async () => {
|
|
|
27
27
|
if (task === "wrapped") {
|
|
28
28
|
const failures = [];
|
|
29
29
|
const { wrappedHome } = await import("@parcha/agentrun-import");
|
|
30
|
-
return { wrapped: await wrappedHome(home, year, { failures, catalog: await catalogPrices() }), unread: failures.length };
|
|
30
|
+
return { wrapped: await wrappedHome(home, year, { failures, catalog: await catalogPrices(), ...wrappedReading() }), unread: failures.length };
|
|
31
31
|
}
|
|
32
32
|
if (task === "plan") {
|
|
33
33
|
// A count keeps no transcript: no key scan (a whole history read through secretlint at every start).
|
package/dist/import.d.ts
CHANGED
|
@@ -44,6 +44,15 @@ export declare const MAX_SESSION_BYTES: number;
|
|
|
44
44
|
export declare const MAX_RUN_BYTES: number;
|
|
45
45
|
/** The most projects a count names for the owner to choose from: the latest active. */
|
|
46
46
|
export declare const MAX_CANDIDATES = 500;
|
|
47
|
+
/** The heap of the worker that counts or imports this machine's sessions, or reads a year of them for Wrapped. A run is
|
|
48
|
+
* read whole, at most MAX_RUN_BYTES of files, which this holds several times over. */
|
|
49
|
+
export declare const IMPORT_HEAP_MB = 2048;
|
|
50
|
+
/** How the import worker reads a year of the home for Wrapped (wrappedHome): on the cores less one, at most
|
|
51
|
+
* WRAPPED_THREADS, and with a quarter of the worker's heap for the reads waiting, which it holds. */
|
|
52
|
+
export declare function wrappedReading(cores?: number): {
|
|
53
|
+
threads: number;
|
|
54
|
+
readAhead: number;
|
|
55
|
+
};
|
|
47
56
|
/** The most of one instructions or skill file read, and of one agent's skill files together. */
|
|
48
57
|
export declare const MAX_FILE_BYTES: number;
|
|
49
58
|
export declare const MAX_SKILL_BYTES: number;
|
package/dist/import.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { createHash, randomUUID } from "node:crypto";
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
9
|
import { lstat, open, realpath, stat } from "node:fs/promises";
|
|
10
|
-
import { homedir, tmpdir } from "node:os";
|
|
10
|
+
import { availableParallelism, homedir, tmpdir } from "node:os";
|
|
11
11
|
import { basename, join, sep } from "node:path";
|
|
12
12
|
import { parseArgs } from "node:util";
|
|
13
13
|
import { BACKGROUND_CONTEXT as ctx } from "@earendil-works/chord/context";
|
|
@@ -246,6 +246,16 @@ export const MAX_SESSION_BYTES = 256 * 1024 * 1024;
|
|
|
246
246
|
export const MAX_RUN_BYTES = MAX_SESSION_BYTES;
|
|
247
247
|
/** The most projects a count names for the owner to choose from: the latest active. */
|
|
248
248
|
export const MAX_CANDIDATES = 500;
|
|
249
|
+
/** The heap of the worker that counts or imports this machine's sessions, or reads a year of them for Wrapped. A run is
|
|
250
|
+
* read whole, at most MAX_RUN_BYTES of files, which this holds several times over. */
|
|
251
|
+
export const IMPORT_HEAP_MB = 2048;
|
|
252
|
+
/** The most threads Wrapped's read of the home starts. */
|
|
253
|
+
const WRAPPED_THREADS = 8;
|
|
254
|
+
/** How the import worker reads a year of the home for Wrapped (wrappedHome): on the cores less one, at most
|
|
255
|
+
* WRAPPED_THREADS, and with a quarter of the worker's heap for the reads waiting, which it holds. */
|
|
256
|
+
export function wrappedReading(cores = availableParallelism()) {
|
|
257
|
+
return { threads: Math.max(1, Math.min(cores - 1, WRAPPED_THREADS)), readAhead: (IMPORT_HEAP_MB / 4) * 2 ** 20 };
|
|
258
|
+
}
|
|
249
259
|
/** The most of one instructions or skill file read, and of one agent's skill files together. */
|
|
250
260
|
export const MAX_FILE_BYTES = 256 * 1024;
|
|
251
261
|
export const MAX_SKILL_BYTES = 1024 * 1024;
|
package/dist/key-refusal.d.ts
CHANGED
|
@@ -9,6 +9,11 @@ export type RunKey = {
|
|
|
9
9
|
/** The key `harness`'s run of model `ref` (the revision's; none, this host's default for the harness) sends, by the route
|
|
10
10
|
* its wire takes (provider.ts; pi's, model.ts); undefined where it is not a model key this server names. */
|
|
11
11
|
export declare function runKeyOf(env: NodeJS.ProcessEnv, harness?: string, ref?: string): RunKey | undefined;
|
|
12
|
+
/** How many texts redacted and withheldWhole have read in this process: a test reads it to see a read of a run's rows
|
|
13
|
+
* cut only the texts an earlier read had not (store-reads/journal.ts rowCutsOnce). */
|
|
14
|
+
export declare const cutPasses: {
|
|
15
|
+
count: number;
|
|
16
|
+
};
|
|
12
17
|
/** `text`, a run's error as serve shows it, with no held secret in it: the one rule learning's checker uses
|
|
13
18
|
* (learn/secrets.ts redactSecrets: each value as written, JSON-escaped, base64 at each offset, hex and percent-encoded,
|
|
14
19
|
* and secret-shaped text), over `secrets`, the values the server holds and handed its run.
|
package/dist/key-refusal.js
CHANGED
|
@@ -7,7 +7,7 @@ import { harnessOf } from "./harness-table.js";
|
|
|
7
7
|
import { cutSecrets, endsInScheme, foldsHeld, redactSecrets, secretShapes, valueLeft, valueMatcher } from "./learn/secrets.js";
|
|
8
8
|
import { hostModel, MODEL_KEYS } from "./model.js";
|
|
9
9
|
import { modelWire, openRouterOnly, WIRES } from "./provider.js";
|
|
10
|
-
import { entityAt, jsonEscapeAt, privateKeyEnd, scanned, squeeze } from "./redact/match.js";
|
|
10
|
+
import { entityAt, jsonEscapeAt, privateKeyEnd, pythonEscapeAt, scanned, squeeze } from "./redact/match.js";
|
|
11
11
|
import { savedGatewayIn } from "./model-gateway.js";
|
|
12
12
|
const row = (id) => {
|
|
13
13
|
const found = MODEL_KEYS.find((r) => r.id === id);
|
|
@@ -49,6 +49,9 @@ function detailOf(rest) {
|
|
|
49
49
|
const text = rest.replace(/^[\s:.-]*(unauthorized\b)?[\s:.-]*/i, "").replace(/,?\s*url:.*$/is, "").trim();
|
|
50
50
|
return (text.split(/(?<=[.!?])\s/)[0] ?? "").slice(0, 200).replace(/[.\s]+$/, "");
|
|
51
51
|
}
|
|
52
|
+
/** How many texts redacted and withheldWhole have read in this process: a test reads it to see a read of a run's rows
|
|
53
|
+
* cut only the texts an earlier read had not (store-reads/journal.ts rowCutsOnce). */
|
|
54
|
+
export const cutPasses = { count: 0 };
|
|
52
55
|
/** The most of a run's error or a tool's output serve ever shows: a Timeline row's text, cut at 2000 characters
|
|
53
56
|
* (`CAPS.text` in timeline/; a summary and a tool result's preview at 500), which the error box reads too. */
|
|
54
57
|
const SHOWN = 2000;
|
|
@@ -62,6 +65,7 @@ const SHOWN = 2000;
|
|
|
62
65
|
* error costs no more to redact than a short one, whatever it holds. `shown`: a head of another length, for a reader
|
|
63
66
|
* that is shown more. */
|
|
64
67
|
export function redacted(text, secrets, shown = SHOWN) {
|
|
68
|
+
cutPasses.count++;
|
|
65
69
|
const longest = secrets.reduce((most, value) => Math.max(most, value.length), 0);
|
|
66
70
|
const window = shown + 6 * longest + 16;
|
|
67
71
|
if (text.length <= window)
|
|
@@ -126,6 +130,7 @@ export function redactedCall(text, secrets, shown, show = (piece) => piece) {
|
|
|
126
130
|
* own finds, so a value read wholly inside one of them is taken there (sdk/runs.ts withheldParts: a part withheld by
|
|
127
131
|
* itself). */
|
|
128
132
|
export function withheldWhole(text, secrets, held = []) {
|
|
133
|
+
cutPasses.count++;
|
|
129
134
|
return redactSecrets(text, secrets, Number.POSITIVE_INFINITY, held) === "[redacted]";
|
|
130
135
|
}
|
|
131
136
|
/** Whether the text a reader is about to be shown (`shown`, what the caller returns) holds a held value, or the joined
|
|
@@ -240,15 +245,17 @@ function inPieces(text, secrets, enough = Number.POSITIVE_INFINITY, show = (piec
|
|
|
240
245
|
}
|
|
241
246
|
/** text from `from` on, as far as `count` characters the matcher sees (all of it, if it holds fewer), each run of
|
|
242
247
|
* whitespace in it one space. The matcher reads "+" as a space and decodes percent-encoded bytes, JSON's escapes (one
|
|
243
|
-
* level and two, as the JSON view reads them)
|
|
244
|
-
*
|
|
245
|
-
* count no more than whitespace does, and any other escape
|
|
246
|
-
* to. A character that renders as nothing (a zero-width
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
* "
|
|
250
|
-
*
|
|
251
|
-
*
|
|
248
|
+
* level and two, as the JSON view reads them), Python's ("\'", "\x" and two hex digits, as the view that reads a
|
|
249
|
+
* single-quoted dict through them does) and HTML's character references (named and numeric), so a "+", an encoded
|
|
250
|
+
* byte, an escape and a reference that decode to whitespace count no more than whitespace does, and any other escape
|
|
251
|
+
* counts as what the view keeps of the character it decodes to. A character that renders as nothing (a zero-width
|
|
252
|
+
* space, a soft hyphen, a control character that is no whitespace: a NUL, an escape, a delete; U+FFFF; as it stands or as
|
|
253
|
+
* "\u0001", "\x01", "%01" or "" decodes) or a combining mark counts as nothing too: the views drop it (kept). So does a quote, an apostrophe
|
|
254
|
+
* or JSON's punctuation ("{", "}", "[", "]", ",", ":"), which the join views drop between a text's strings, and, with
|
|
255
|
+
* `fold` (a held value folds: learn/secrets.ts foldsHeld), a separator ("-", "_", ":", "."), which the fold view
|
|
256
|
+
* drops. Padding of any of them never hides the rest of a value split before it. Undefined, so the caller withholds
|
|
257
|
+
* the text, when that takes more than a piece of text (a run of whitespace counted as one): no redaction pass reads
|
|
258
|
+
* more than a piece. */
|
|
252
259
|
function peek(text, from, count, fold) {
|
|
253
260
|
const read = visible(text, from, count, text.length, fold);
|
|
254
261
|
return read.span > ANSWER_PIECE ? undefined : read.parts.join("");
|
|
@@ -256,7 +263,7 @@ function peek(text, from, count, fold) {
|
|
|
256
263
|
/** The end of the run text[start, to) the pass reads for the head of a value whose rest comes after the run: as few of
|
|
257
264
|
* its last characters as hold `count` characters the matcher sees (at most a piece's worth), counted as peek counts
|
|
258
265
|
* them (with `fold` as peek's), so padding the views read as nothing (whitespace, a zero-width space, a soft hyphen, a
|
|
259
|
-
* quote or JSON's punctuation, a separator a folded value drops, an escape, a character reference or encoded bytes
|
|
266
|
+
* control character, U+FFFF, a quote or JSON's punctuation, a separator a folded value drops, an escape, a character reference or encoded bytes
|
|
260
267
|
* that decode to any of them) between that head and the run's end never pushes the head out of it. Read forward from
|
|
261
268
|
* a start moved back from `to`, twice as far each time, so it reads at most two pieces in all. Undefined, so the
|
|
262
269
|
* caller withholds the text, when that takes more than a piece of text. */
|
|
@@ -313,11 +320,14 @@ function visible(text, from, count, to, fold) {
|
|
|
313
320
|
}
|
|
314
321
|
return { parts, found, span };
|
|
315
322
|
}
|
|
316
|
-
/** The character text[at] starts, as the views read it:
|
|
317
|
-
*
|
|
323
|
+
/** The character text[at] starts, as the views read it: one of Python's escapes (pythonEscapeAt, at either level:
|
|
324
|
+
* "\x20" and "\\x20" are a space), else a JSON escape's (jsonEscapeAt), or a character reference's (entityAt), else
|
|
325
|
+
* the UTF-16 unit itself (`raw`), and where it ends. Python's first: where JSON's escapes read "\\x20" as a backslash
|
|
326
|
+
* and three characters, the view that reads Python's twice reads a space; counting less only reads further. */
|
|
318
327
|
function charAt(text, at) {
|
|
319
328
|
let escape;
|
|
320
|
-
if ((text[at] === "\\" && (escape =
|
|
329
|
+
if ((text[at] === "\\" && ((escape = pythonEscapeAt(text, at)) !== undefined || (escape = jsonEscapeAt(text, at)) !== undefined)) ||
|
|
330
|
+
(text[at] === "&" && (escape = entityAt(text, at)) !== undefined))
|
|
321
331
|
return { ...escape, raw: false };
|
|
322
332
|
return { char: text[at], end: at + 1, raw: true };
|
|
323
333
|
}
|
|
@@ -325,12 +335,14 @@ const HIGH = (char) => char.length === 1 && char.charCodeAt(0) >= 0xd800 && char
|
|
|
325
335
|
const LOW = (char) => char.length === 1 && char.charCodeAt(0) >= 0xdc00 && char.charCodeAt(0) <= 0xdfff;
|
|
326
336
|
const SPACES = /\s+/y;
|
|
327
337
|
const HEX_PAIR = /^[0-9A-Fa-f]{2}$/;
|
|
328
|
-
/** What every view drops between a text's strings: a quote
|
|
329
|
-
|
|
338
|
+
/** What every view drops between a text's strings: a quote, an apostrophe (the join of single-quoted strings) and JSON's
|
|
339
|
+
* punctuation (the join view). */
|
|
340
|
+
const JOIN_DROPS = new Set(['"', "'", "{", "}", "[", "]", ",", ":"]);
|
|
330
341
|
/** What the fold view drops: the separators of a hex identifier. */
|
|
331
342
|
const FOLD_DROPS = new Set(["-", "_", ":", "."]);
|
|
332
|
-
/** How many characters the views keep of `chars` at the least (peek): squeezed
|
|
333
|
-
*
|
|
343
|
+
/** How many characters the views keep of `chars` at the least (peek): squeezed (a control character that is no
|
|
344
|
+
* whitespace, and U+FFFF, as the views drop them, count 0), less each the join view drops, and, with `fold`, each the
|
|
345
|
+
* fold view drops. */
|
|
334
346
|
function kept(chars, fold) {
|
|
335
347
|
let count = 0;
|
|
336
348
|
for (const char of squeeze(chars))
|