@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
package/dist/tools.js
CHANGED
|
@@ -15,7 +15,7 @@ import { mcpNameOf } from "./tool-names.js";
|
|
|
15
15
|
import { appendFileSync } from "node:fs";
|
|
16
16
|
import { pathToFileURL } from "node:url";
|
|
17
17
|
import { defineExtension, defineTool, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
18
|
-
import { registerTurnEnding } from "./timeline/index.js";
|
|
18
|
+
import { registerTurnEnding, webCut } from "./timeline/index.js";
|
|
19
19
|
import { BACKGROUND_LOG_BYTES, BACKGROUND_MAX, BACKGROUND_PAGE_BYTES } from "./background.js";
|
|
20
20
|
import { isWorkspaceError, localWorkspace } from "./workspace/index.js";
|
|
21
21
|
import { HTML_READ_CHARS, TEXT_CAP } from "@parcha/agentrun-web";
|
|
@@ -41,7 +41,7 @@ import { fauxFetch, PARALLEL_KEY_ENV } from "./decisions.js";
|
|
|
41
41
|
import { keyNeeded } from "./key-words.js";
|
|
42
42
|
import { unattachable } from "./attach-images.js";
|
|
43
43
|
import { handedSignIn } from "./secrets.js";
|
|
44
|
-
import { redactedAnswer } from "./key-refusal.js";
|
|
44
|
+
import { redactedAnswer, withheldWhole } from "./key-refusal.js";
|
|
45
45
|
import { SIGN_IN_KEY, vendorsOver } from "./sign-ins.js";
|
|
46
46
|
import { answerIn, answerOnce } from "./runner/hand-back.js";
|
|
47
47
|
import { waitingAsk } from "./browser-commands.js";
|
|
@@ -229,14 +229,49 @@ export function cutAnswer(value, cut) {
|
|
|
229
229
|
}
|
|
230
230
|
return value;
|
|
231
231
|
}
|
|
232
|
+
/** One call's web answer cut by `cut` (timeline/web-calls.ts webCut): each of its JSON's strings cut once, and the whole
|
|
233
|
+
* "[redacted]" when its strings, read joined, hold a held value no cut in place takes (a value split across two of
|
|
234
|
+
* them). The join is read against the values `cut` holds (key-refusal.ts withheldWhole), or through `cut` itself when
|
|
235
|
+
* it does not know them (joinCut). Undefined for an answer that is not a web call's JSON. Make one per call. */
|
|
236
|
+
export function webAnswerCut(cut) {
|
|
237
|
+
const seen = new Map();
|
|
238
|
+
const once = (text) => {
|
|
239
|
+
let out = seen.get(text);
|
|
240
|
+
if (out === undefined)
|
|
241
|
+
seen.set(text, (out = cut(text)));
|
|
242
|
+
return out;
|
|
243
|
+
};
|
|
244
|
+
const holds = (joined, parts) => {
|
|
245
|
+
const values = cut.heldValues?.();
|
|
246
|
+
return values ? withheldWhole(joined, values) : joinCut(joined, parts, once);
|
|
247
|
+
};
|
|
248
|
+
return (tool, text) => webCut(tool, text, once, holds);
|
|
249
|
+
}
|
|
250
|
+
/** Whether `cut`, a redactor that does not know its values, takes from `joined` (`parts` joined by line breaks) what it
|
|
251
|
+
* does not take from the parts each read alone: a held value split across two parts. Its cut of the join whole being
|
|
252
|
+
* "[redacted]" is not enough: it reads a text longer than a piece in pieces of 8,192 characters (key-refusal.ts
|
|
253
|
+
* redactedAnswer), and a value split inside one piece withholds only that piece, the rest of the join served. It misses
|
|
254
|
+
* nothing: no value split across parts is in a part to cut, so the join's cut and the parts' differ wherever the join
|
|
255
|
+
* holds one; where nothing spans two parts they are the same, as every piece ends at whitespace or inside a run longer
|
|
256
|
+
* than a piece, and a line break ends each part. */
|
|
257
|
+
function joinCut(joined, parts, cut) {
|
|
258
|
+
const whole = cut(joined);
|
|
259
|
+
return whole === "[redacted]" || whole !== parts.map(cut).join("\n");
|
|
260
|
+
}
|
|
232
261
|
/** `tool` whose answer, and a throw's message, pass `cut` inside its execute: before pi stores the result or the model
|
|
233
|
-
* reads it.
|
|
234
|
-
|
|
262
|
+
* reads it. A web call's JSON is cut as the agentic specs' answersCut cuts it (webAnswerCut), so it still parses and
|
|
263
|
+
* keeps its links, and a held value split across its strings withholds it whole. */
|
|
264
|
+
export function answersCutInside(tool, cut) {
|
|
265
|
+
// Fail closed and loud: a host with no redactor would only throw inside each call, an error a model may read past.
|
|
266
|
+
if (typeof cut !== "function")
|
|
267
|
+
throw new TypeError(`${tool.name}: the run's redactor (host.redact) is required to cut its answers`);
|
|
235
268
|
return {
|
|
236
269
|
...tool,
|
|
237
270
|
execute: (async (...args) => {
|
|
238
271
|
try {
|
|
239
|
-
|
|
272
|
+
const web = webAnswerCut(cut);
|
|
273
|
+
const textCut = (text) => web(tool.name, text) ?? cut(text);
|
|
274
|
+
return cutAnswer(await tool.execute(...args), textCut);
|
|
240
275
|
}
|
|
241
276
|
catch (error) {
|
|
242
277
|
if (error instanceof Error) {
|
|
@@ -383,7 +418,7 @@ const browserTool = {
|
|
|
383
418
|
// The model's words for the person, with every value this run holds cut, whole, before they are cut to their bound:
|
|
384
419
|
// the run's own cut on the runner (host.redact: the claim's keys too, every tool's, in every form), and the secrets
|
|
385
420
|
// its env holds (runnerSecrets: hostSecrets and every launcher name's value) with its sign-in's pointer.
|
|
386
|
-
redact: (text) => redactedAnswer(host.redact
|
|
421
|
+
redact: (text) => redactedAnswer(host.redact(text), [...runnerSecrets(host.env), ...(kept ? [kept.ref] : [])]),
|
|
387
422
|
// The Screen tab's ended state, one settings row the server reads per poll (browser-wait-ended.ts); cleared as a
|
|
388
423
|
// session opens (onSessions, below).
|
|
389
424
|
waitEnded: (at, why) => {
|
|
@@ -493,7 +528,7 @@ const browserTool = {
|
|
|
493
528
|
const browser = createBrowserExtension({ provider, driver: parts.driver, evidence: evidenceIn(work), ...files, gates, handoff: hands.handoff, onSession: onSessions, signIns: kept !== undefined, beforeCreate: spend.opening, redact: { values: () => [...runnerSecrets(host.env), ...(kept ? [kept.ref] : [])] }, prices: { sessionUsdPerHour: price.usdPerHour, sessionMinimumS: price.minimumS }, onCharge: spend.onCharge });
|
|
494
529
|
// On the runner, every answer the browser's tools give passes the run's one redactor inside the call, so what pi stores
|
|
495
530
|
// (its result record) and what the model reads hold no value the runner or the claim holds.
|
|
496
|
-
const tools = browser.tools.map(spend.capped).map((tool) =>
|
|
531
|
+
const tools = browser.tools.map(spend.capped).map((tool) => answersCutInside(tool, host.redact));
|
|
497
532
|
const extension = { ...browser.extension, tools };
|
|
498
533
|
host.install(extension);
|
|
499
534
|
host.onConversation(async (tx, conversationId) => {
|
|
@@ -8,8 +8,8 @@ export declare const LAUNCH_HOOK_TIMEOUT_MS = 10000;
|
|
|
8
8
|
* trigger's max_active_runs, or one a stop cut short and the next start handed again reaches the host late, and its
|
|
9
9
|
* host gets the same 10 minutes as any. */
|
|
10
10
|
export declare const LAUNCH_HOOK_LATE_START_MS: number;
|
|
11
|
-
/** The hook a server hands its firings to: where, and the secret it signs with. `bound`: a test's seam,
|
|
12
|
-
* POST
|
|
11
|
+
/** The hook a server hands its firings to: where, and the secret it signs with. `bound`: a test's seam, a signal that can
|
|
12
|
+
* cut a POST before LAUNCH_HOOK_TIMEOUT_MS, never after: the 10 s bound is always set as well. */
|
|
13
13
|
export type LaunchHook = {
|
|
14
14
|
readonly url: string;
|
|
15
15
|
readonly secret: string;
|
|
@@ -79,7 +79,7 @@ export async function handToHost(hook, firing, stop, now = Date.now) {
|
|
|
79
79
|
const body = JSON.stringify(firing);
|
|
80
80
|
const timestamp = String(Math.floor(now() / 1000));
|
|
81
81
|
const headers = signedRequest(hook.secret, firing.firing_id, timestamp, body, "agentrun-serve-launch-hook/1");
|
|
82
|
-
const signal = AbortSignal.any([hook.bound ? hook.bound(LAUNCH_HOOK_TIMEOUT_MS) :
|
|
82
|
+
const signal = AbortSignal.any([AbortSignal.timeout(LAUNCH_HOOK_TIMEOUT_MS), ...(hook.bound ? [hook.bound(LAUNCH_HOOK_TIMEOUT_MS)] : []), stop]);
|
|
83
83
|
let res;
|
|
84
84
|
try {
|
|
85
85
|
res = await undiciFetch(hook.url, { method: "POST", redirect: "manual", signal, headers, body });
|
package/dist/triggers.d.ts
CHANGED
|
@@ -434,13 +434,16 @@ export declare class Triggers {
|
|
|
434
434
|
id: string;
|
|
435
435
|
name: string;
|
|
436
436
|
}[]>;
|
|
437
|
-
/** Agent `agentId` unarchived: none of its triggers turns on again, but those its archive turned off
|
|
438
|
-
*
|
|
439
|
-
*
|
|
437
|
+
/** Agent `agentId` unarchived: none of its triggers turns on again, but those its archive turned off that `turnOn`
|
|
438
|
+
* takes (by source and target), each turned on as a PATCH with enabled true does (an API-only server's with the launch
|
|
439
|
+
* hook: api-only.ts apiOnlyTurnsOn). The triggers its archive turned off that are off still, by name: each is
|
|
440
440
|
* turned on by a PATCH. One `turnOn` takes that can't be on (a schedule with no time left), or that its first check
|
|
441
441
|
* turns off again, is named: what is off is read from the store after the turn-ons, never taken from whether one
|
|
442
442
|
* resolved. */
|
|
443
|
-
agentUnarchived(agentId: string, turnOn?: (
|
|
443
|
+
agentUnarchived(agentId: string, turnOn?: (trigger: {
|
|
444
|
+
source: Source;
|
|
445
|
+
target: Target;
|
|
446
|
+
}) => boolean): Promise<{
|
|
444
447
|
id: string;
|
|
445
448
|
name: string;
|
|
446
449
|
}[]>;
|
package/dist/triggers.js
CHANGED
|
@@ -458,9 +458,9 @@ export class Triggers {
|
|
|
458
458
|
await this.offThere((await Promise.all(off.map((t) => this.find(t.id)))).filter((t) => t !== undefined));
|
|
459
459
|
return off;
|
|
460
460
|
}
|
|
461
|
-
/** Agent `agentId` unarchived: none of its triggers turns on again, but those its archive turned off
|
|
462
|
-
*
|
|
463
|
-
*
|
|
461
|
+
/** Agent `agentId` unarchived: none of its triggers turns on again, but those its archive turned off that `turnOn`
|
|
462
|
+
* takes (by source and target), each turned on as a PATCH with enabled true does (an API-only server's with the launch
|
|
463
|
+
* hook: api-only.ts apiOnlyTurnsOn). The triggers its archive turned off that are off still, by name: each is
|
|
464
464
|
* turned on by a PATCH. One `turnOn` takes that can't be on (a schedule with no time left), or that its first check
|
|
465
465
|
* turns off again, is named: what is off is read from the store after the turn-ons, never taken from whether one
|
|
466
466
|
* resolved. */
|
|
@@ -468,7 +468,7 @@ export class Triggers {
|
|
|
468
468
|
await this.store.agents.archive(agentId, false);
|
|
469
469
|
const off = (await this.store.triggers.list(agentId)).map(asTrigger).filter((t) => !t.enabled && reasonOf(t.disabled) === "agent_archived");
|
|
470
470
|
for (const t of off)
|
|
471
|
-
if (turnOn(t
|
|
471
|
+
if (turnOn(t))
|
|
472
472
|
await this.update(t.id, { enabled: true }, { onAgent: agentId }).catch(() => undefined);
|
|
473
473
|
const ids = new Set(off.map((t) => t.id));
|
|
474
474
|
return (await this.store.triggers.list(agentId)).filter((t) => ids.has(t.id) && !t.enabled).map((t) => ({ id: t.id, name: t.name }));
|
package/dist/web-holds.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export type WebHold = Hold;
|
|
|
4
4
|
/** How long the server holds a keyless provider whose limit named no end (out of quota for the rest of a run): the
|
|
5
5
|
* first run after it pays at most one more refusal to learn it again. */
|
|
6
6
|
export declare const ENDLESS_HOLD_MS: number;
|
|
7
|
+
/** The furthest a hold's end may be from `now`: a Retry-After or a reset weeks away holds the host 25 h at most. */
|
|
8
|
+
export declare const MAX_HOLD_MS: number;
|
|
7
9
|
/** The variable a run's own process gets the server's holds in: JSON, an array of WebHold. */
|
|
8
10
|
export declare const WEB_HOLDS_ENV = "AGENTRUN_SERVE_WEB_HOLDS";
|
|
9
11
|
/** Keeps `value` (holdOf) as the host's hold on its provider's tool, unless one held already ends no earlier: the hold
|
package/dist/web-holds.js
CHANGED
|
@@ -7,6 +7,8 @@ import { holdingWords, isProviderId, providerOf } from "@parcha/agentrun-web";
|
|
|
7
7
|
/** How long the server holds a keyless provider whose limit named no end (out of quota for the rest of a run): the
|
|
8
8
|
* first run after it pays at most one more refusal to learn it again. */
|
|
9
9
|
export const ENDLESS_HOLD_MS = 60 * 60_000;
|
|
10
|
+
/** The furthest a hold's end may be from `now`: a Retry-After or a reset weeks away holds the host 25 h at most. */
|
|
11
|
+
export const MAX_HOLD_MS = 25 * 60 * 60_000;
|
|
10
12
|
/** The variable a run's own process gets the server's holds in: JSON, an array of WebHold. */
|
|
11
13
|
export const WEB_HOLDS_ENV = "AGENTRUN_SERVE_WEB_HOLDS";
|
|
12
14
|
const TOOLS = new Set(["search", "fetch", "key"]);
|
|
@@ -17,7 +19,7 @@ const FIELDS = ["provider", "tool", "kind", "until"];
|
|
|
17
19
|
// them.
|
|
18
20
|
const holds = new Map();
|
|
19
21
|
/** `value` as a keyless provider's hold, its end `until` (epoch ms; null or Infinity: none named, read as ENDLESS_HOLD_MS
|
|
20
|
-
* from `now`), or undefined: a keyed or unknown provider, another field, or an end not after `now`. */
|
|
22
|
+
* from `now`; at most MAX_HOLD_MS from `now`), or undefined: a keyed or unknown provider, another field, or an end not after `now`. */
|
|
21
23
|
function holdOf(value, now) {
|
|
22
24
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
23
25
|
return undefined;
|
|
@@ -28,7 +30,8 @@ function holdOf(value, now) {
|
|
|
28
30
|
return undefined;
|
|
29
31
|
if (typeof tool !== "string" || !TOOLS.has(tool) || typeof kind !== "string" || !KINDS.has(kind))
|
|
30
32
|
return undefined;
|
|
31
|
-
const
|
|
33
|
+
const named = until === null || until === Number.POSITIVE_INFINITY ? now + ENDLESS_HOLD_MS : typeof until === "number" && Number.isFinite(until) ? until : Number.NaN;
|
|
34
|
+
const end = Math.min(named, now + MAX_HOLD_MS);
|
|
32
35
|
return end > now ? { provider, tool: tool, kind: kind, until: end } : undefined;
|
|
33
36
|
}
|
|
34
37
|
/** Keeps `value` (holdOf) as the host's hold on its provider's tool, unless one held already ends no earlier: the hold
|
package/dist/web-run.js
CHANGED
|
@@ -85,7 +85,8 @@ export function jevWebOf(env) {
|
|
|
85
85
|
const key = planeOf(env).jev === "off" || webJevOff(env) ? undefined : handedKeyOf(env, JEV_KEY_ENV);
|
|
86
86
|
if (key === undefined)
|
|
87
87
|
return jevWebDecider(null);
|
|
88
|
-
|
|
88
|
+
// Each request carries the key, so a redirect is an error and is never followed. The faux Jev gets the same init.
|
|
89
|
+
return jevWebDecider({ key, jevProvider, price: JEV_PUBLISHED_PRICING, fetch: async (input, init) => ((await fauxFetch(env, FAUX_JEV_ENV)) ?? fetch)(input, { ...init, redirect: "error" }) });
|
|
89
90
|
}
|
|
90
91
|
/** One Web for each environment a run's calls are given (main's run process hands process.env; the runner hands each
|
|
91
92
|
* claim its own), so one run's key, client, pages and breakers never serve another. */
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// - /mnt/archil/work: the workspace's folder, where the program runs;
|
|
8
8
|
// - /mnt/archil/out: its spill folder, BESIDE it and never inside it (archil.ts spillFolderOf), which holds this call's
|
|
9
9
|
// stdin and output files. The workspace's file calls are rooted at the folder, so they never meet them.
|
|
10
|
-
// The rest of the owner's disk (other runs
|
|
10
|
+
// The rest of the owner's disk (other runs) is not in the container at all. Archil answers once
|
|
11
11
|
// the line ended, stdout and stderr as text, and cuts that answer somewhere below 14 MB (measured live), so the
|
|
12
12
|
// program's output never rides in it: the line spills it to files that are read back through the file API.
|
|
13
13
|
// The Workspace port wants argv, the whole environment, binary stdin and stdout, a deadline that kills everything the
|
|
@@ -8,7 +8,7 @@ export declare const APPEND_MAX: number;
|
|
|
8
8
|
export type ArchilWorkspaceOptions = {
|
|
9
9
|
/** How long a call waits for another client's hold on the folder (default 60 s). */
|
|
10
10
|
readonly queueMs?: number;
|
|
11
|
-
/** The image every exec runs in, the same for every workspace serve makes (a run's
|
|
11
|
+
/** The image every exec runs in, the same for every workspace serve makes (a run's), pinned by
|
|
12
12
|
* digest (an image given without one is refused): a public image `<name>@sha256:…`, or one built through Archil's
|
|
13
13
|
* images API with its digest. With none, Archil's default exec image, whose git (2.34.1, measured) is older than a
|
|
14
14
|
* bash policy's floor; serve's claim always names one (archil-settings.ts DEFAULT_ARCHIL_EXEC_IMAGE). */
|
package/dist/workspace/archil.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// ArchilWorkspace: a Workspace on a folder of the owner's Archil disk, through the disk's file API and its serverless
|
|
2
2
|
// exec (archil-disk.ts, archil-exec.ts). Nothing is mounted on the server or a runner, and no program runs here.
|
|
3
3
|
//
|
|
4
|
-
// Keys. The workspace's root is a folder of the disk (paths.ts runKey
|
|
4
|
+
// Keys. The workspace's root is a folder of the disk (paths.ts runKey); every key, prefix, directory
|
|
5
5
|
// and exec mount it sends is the root or under it, or its exec spill folder beside it (spillFolderOf: a run's
|
|
6
6
|
// "exec-out"), built from paths paths.ts has checked. An exec mounts those two folders alone (each a mount's
|
|
7
7
|
// subdirectory): the rest of the owner's disk is not in its container. The spill folder holds an exec's stdin and its
|
|
@@ -31,7 +31,7 @@ import { SERVER_NOTE_LABEL } from "@parcha/agentrun-kernel/kernel/cap";
|
|
|
31
31
|
import { computerForClaim } from "./computer-for-claim.js";
|
|
32
32
|
import { computerHeldWords, computerLapsedWords, computerLostWords, KEEP_WORDS } from "./computer-kept.js";
|
|
33
33
|
import { storeLedger } from "./computer-ledger.js";
|
|
34
|
-
import { computerProviderFactories, computerProviderMakers } from "./computer-providers.js";
|
|
34
|
+
import { computerProviderFactories, computerProviderMakers, providerSecretsOf } from "./computer-providers.js";
|
|
35
35
|
import { aLabel, needsNetwork, noNetworkRefusal, vendorNetworkOnly } from "./resolve-computer.js";
|
|
36
36
|
/** How long a run's computer lives whatever happens to the server: a bound on a leaked one, never its clean end (the old
|
|
37
37
|
* box's lifetime). The clean end is the run's release. */
|
|
@@ -316,12 +316,14 @@ export function computerDepsFrom(options) {
|
|
|
316
316
|
return { ...(volume ?? {}), ...(addresses.length > 0 ? { egress: { hostAddresses: addresses } } : {}) };
|
|
317
317
|
};
|
|
318
318
|
/** The options a provider takes beside its keys, by what its descriptor declares, never by its id: for a local one,
|
|
319
|
-
* its image source and its host options; for a remote one, the server's dial
|
|
320
|
-
*
|
|
319
|
+
* its image source and its host options; for a remote one, the server's dial; for one that makes secrets of its own
|
|
320
|
+
* (its `secrets`), the server's sealed store of them, with a seal key (without one, it keeps them for its process).
|
|
321
|
+
* The host environment it reads is the makers' (computerProviderMakers' `env`). */
|
|
321
322
|
const declaredOptions = async (id, boxAllow) => {
|
|
322
323
|
const entry = kinds.PROVIDERS.find((one) => one.id === id);
|
|
323
324
|
return {
|
|
324
325
|
...(entry?.local ? { image: preparedImage, ...(await localHostOptions(boxAllow)) } : options.dial ? { dial: options.dial } : {}),
|
|
326
|
+
...(entry?.secrets && sealKey ? { [entry.secrets.option]: providerSecretsOf(store, sealKey, id) } : {}),
|
|
325
327
|
};
|
|
326
328
|
};
|
|
327
329
|
const load = options.load ?? providerFor;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type ComputerProvider, type ProviderEntry } from "@parcha/agentrun-computer";
|
|
1
|
+
import { type ComputerProvider, type ProviderEntry, type ProviderSecrets } from "@parcha/agentrun-computer";
|
|
2
2
|
import type { ProviderFactories } from "../computer-keys.js";
|
|
3
|
+
import type { SealedKeys } from "../store/index.js";
|
|
3
4
|
import type { ProviderMakers } from "./computer-for-claim.js";
|
|
4
5
|
/** How a provider is built from its id and options: the computer package's providerFor, or a test's stand-in. `claim`:
|
|
5
6
|
* what the claim that makes it lets its run's computer reach (the launch's box_allow), absent outside a claim; never a
|
|
@@ -10,6 +11,14 @@ export type ProviderLoad = (id: string, options: Record<string, unknown>, claim?
|
|
|
10
11
|
/** Settings → Computers' factories (createComputerRoutes' `factories`, its account test) from the same makers, so serve
|
|
11
12
|
* builds a provider in one place: each made with its options and `ledgerOf` its id's ledger. */
|
|
12
13
|
export declare function computerProviderFactories(makers: ProviderMakers, ledgerOf: (id: string) => unknown): ProviderFactories;
|
|
14
|
+
type SecretsStore = {
|
|
15
|
+
readonly sealedKeys: Pick<SealedKeys, "get" | "putIfAbsent" | "replaceIf">;
|
|
16
|
+
};
|
|
17
|
+
/** The server's store of the secrets provider `id` makes for itself (its descriptor's `secrets`: Agent37's SSH key),
|
|
18
|
+
* each sealed under `sealKey` in store.sealedKeys at its own row, computer.<id>.<name>, so it outlives a restart of the
|
|
19
|
+
* same store and is in no row in the clear. A value that does not open under this seal key reads as none; putIfAbsent
|
|
20
|
+
* keeps one writer's value of those racing (keepSealedKey). The same object for the same store, seal key and id. */
|
|
21
|
+
export declare function providerSecretsOf(store: SecretsStore, sealKey: Buffer, id: string): ProviderSecrets;
|
|
13
22
|
/** `env`'s values of `names` (a descriptor's hostEnv), and no other variable of it. */
|
|
14
23
|
export declare function hostEnvOf(env: NodeJS.ProcessEnv, names: readonly string[]): Record<string, string>;
|
|
15
24
|
/** Every provider in `entries` (the computer package's PROVIDERS, each from its descriptor), made through `load`
|
|
@@ -21,3 +30,4 @@ export declare function computerProviderMakers({ load, entries, env }?: {
|
|
|
21
30
|
readonly entries?: readonly Pick<ProviderEntry, "id" | "ledger" | "hostEnv">[];
|
|
22
31
|
readonly env?: NodeJS.ProcessEnv;
|
|
23
32
|
}): ProviderMakers;
|
|
33
|
+
export {};
|
|
@@ -1,15 +1,42 @@
|
|
|
1
1
|
// The provider makers computerForClaim is handed at the claim (its `providers`): each provider the computer package
|
|
2
2
|
// declares, built by its providerFor from the options its saved keys fill (computer-keys.ts providerOptions, by its
|
|
3
3
|
// descriptor's key names), and nothing else. A provider whose descriptor declares a ledger (its sessions carry no labels
|
|
4
|
-
// of their own) is given the store's computer ledger, as the option its descriptor names
|
|
5
|
-
//
|
|
4
|
+
// of their own) is given the store's computer ledger, as the option its descriptor names; one that declares secrets
|
|
5
|
+
// (a key it makes for itself) is given the server's sealed store of them (providerSecretsOf, by computerDepsFrom). No
|
|
6
|
+
// key reaches a provider any other way, and nothing here reads the environment or names a vendor: a provider whose descriptor names the host
|
|
6
7
|
// variables it reads (hostEnv) is given the caller's values of those names alone.
|
|
7
8
|
import { PROVIDERS, providerFor } from "@parcha/agentrun-computer";
|
|
9
|
+
import { getSealedKey, keepSealedKey } from "../server-keys.js";
|
|
8
10
|
/** Settings → Computers' factories (createComputerRoutes' `factories`, its account test) from the same makers, so serve
|
|
9
11
|
* builds a provider in one place: each made with its options and `ledgerOf` its id's ledger. */
|
|
10
12
|
export function computerProviderFactories(makers, ledgerOf) {
|
|
11
13
|
return Object.fromEntries(Object.entries(makers).map(([id, make]) => [id, (options) => make(options, { ledger: ledgerOf(id) })]));
|
|
12
14
|
}
|
|
15
|
+
/** Each store's ProviderSecrets, by seal key and provider id: one object for them all in this process, so a provider
|
|
16
|
+
* sharing its first use's work by its store (Agent37's key, made once) shares it with every other on the same one. */
|
|
17
|
+
const secretsByStore = new WeakMap();
|
|
18
|
+
/** The server's store of the secrets provider `id` makes for itself (its descriptor's `secrets`: Agent37's SSH key),
|
|
19
|
+
* each sealed under `sealKey` in store.sealedKeys at its own row, computer.<id>.<name>, so it outlives a restart of the
|
|
20
|
+
* same store and is in no row in the clear. A value that does not open under this seal key reads as none; putIfAbsent
|
|
21
|
+
* keeps one writer's value of those racing (keepSealedKey). The same object for the same store, seal key and id. */
|
|
22
|
+
export function providerSecretsOf(store, sealKey, id) {
|
|
23
|
+
let bySeal = secretsByStore.get(store);
|
|
24
|
+
if (bySeal === undefined)
|
|
25
|
+
secretsByStore.set(store, (bySeal = new WeakMap()));
|
|
26
|
+
let byId = bySeal.get(sealKey);
|
|
27
|
+
if (byId === undefined)
|
|
28
|
+
bySeal.set(sealKey, (byId = new Map()));
|
|
29
|
+
const known = byId.get(id);
|
|
30
|
+
if (known !== undefined)
|
|
31
|
+
return known;
|
|
32
|
+
const row = (name) => `computer.${id}.${name}`;
|
|
33
|
+
const made = {
|
|
34
|
+
get: (name) => getSealedKey(store, sealKey, row(name)),
|
|
35
|
+
putIfAbsent: (name, value) => keepSealedKey(store, sealKey, row(name), value),
|
|
36
|
+
};
|
|
37
|
+
byId.set(id, made);
|
|
38
|
+
return made;
|
|
39
|
+
}
|
|
13
40
|
/** `env`'s values of `names` (a descriptor's hostEnv), and no other variable of it. */
|
|
14
41
|
export function hostEnvOf(env, names) {
|
|
15
42
|
return Object.fromEntries(names.flatMap((name) => (env[name] === undefined ? [] : [[name, String(env[name])]])));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./workspace.js";
|
|
2
2
|
export { type AttachableComputer, attachedWorkspace, checkReadBack, COMPUTER_CHUNK, type MountCheck, NO_COMPUTER, noProcesses, type Processes, } from "./attach.js";
|
|
3
|
-
export { agentDirName, agentFolder, agentHomeFolder,
|
|
3
|
+
export { agentDirName, agentFolder, agentHomeFolder, COMPUTER_ROOT, DISK_DIR, homeKey, portPath, relativePath, relativeSegments, runFolder, runKey, scratchFolder, } from "./paths.js";
|
|
4
4
|
export type { Place } from "./place.js";
|
|
5
5
|
export { localWorkspace, workspaceAt } from "./local.js";
|
|
6
6
|
export { archilWorkspace, type ArchilWorkspaceOptions } from "./archil.js";
|
|
@@ -11,7 +11,6 @@ export { ARCHIL_API_KEY_ENV, archilApiKey, type ArchilKeyOptions } from "./archi
|
|
|
11
11
|
export { openRunWorkspace, type RunWorkspace, type RunWorkspaceOptions } from "./run-workspace.js";
|
|
12
12
|
export { readOnlyWorkspace, SERVER_READS_ONLY, serverRunWorkspace, type ServerRunWorkspaceOptions } from "./server-run-workspace.js";
|
|
13
13
|
export { type LedgerEntry, type ProviderLedger, storeLedger } from "./computer-ledger.js";
|
|
14
|
-
export { type LearningPlace, type LearningWorkspace, learningWorkspace, type LearningWorkspaceOptions } from "./learning-workspace.js";
|
|
15
14
|
export { ARCHIL_MAX_EXEC_S, handsOf, MAX_EXEC_S, processesOf, shellEnv } from "./hands.js";
|
|
16
15
|
export { type AgentComputer, type RunComputer, type RunHold, runTools, type RunTools, type ScriptComputer, withKindTools } from "./run-tools.js";
|
|
17
16
|
export { NO_PROGRAMS_WORDS, portOf } from "./computer-ports.js";
|
package/dist/workspace/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// tools run (place.ts), the local backend and the Archil one.
|
|
3
3
|
export * from "./workspace.js";
|
|
4
4
|
export { attachedWorkspace, checkReadBack, COMPUTER_CHUNK, NO_COMPUTER, noProcesses, } from "./attach.js";
|
|
5
|
-
export { agentDirName, agentFolder, agentHomeFolder,
|
|
5
|
+
export { agentDirName, agentFolder, agentHomeFolder, COMPUTER_ROOT, DISK_DIR, homeKey, portPath, relativePath, relativeSegments, runFolder, runKey, scratchFolder, } from "./paths.js";
|
|
6
6
|
export { localWorkspace, workspaceAt } from "./local.js";
|
|
7
7
|
export { archilWorkspace } from "./archil.js";
|
|
8
8
|
export { archilDisk } from "./archil-disk.js";
|
|
@@ -12,7 +12,6 @@ export { ARCHIL_API_KEY_ENV, archilApiKey } from "./archil-key.js";
|
|
|
12
12
|
export { openRunWorkspace } from "./run-workspace.js";
|
|
13
13
|
export { readOnlyWorkspace, SERVER_READS_ONLY, serverRunWorkspace } from "./server-run-workspace.js";
|
|
14
14
|
export { storeLedger } from "./computer-ledger.js";
|
|
15
|
-
export { learningWorkspace } from "./learning-workspace.js";
|
|
16
15
|
export { ARCHIL_MAX_EXEC_S, handsOf, MAX_EXEC_S, processesOf, shellEnv } from "./hands.js";
|
|
17
16
|
export { runTools, withKindTools } from "./run-tools.js";
|
|
18
17
|
export { NO_PROGRAMS_WORDS, portOf } from "./computer-ports.js";
|
|
@@ -6,16 +6,12 @@ export declare const agentDirName: (agentId: string) => string;
|
|
|
6
6
|
export declare const agentFolder: (dataDir: string, agentId: string) => string;
|
|
7
7
|
/** Run `runId`'s folder as a key from a disk's root: `agents/<agent>/runs/<run>/work` (an Archil workspace's root). */
|
|
8
8
|
export declare const runKey: (agentId: string, runId: string) => string;
|
|
9
|
-
/** Agent `agentId`'s learning folder as a key from a disk's root: `agents/<agent>/learning`. */
|
|
10
|
-
export declare const learningKey: (agentId: string) => string;
|
|
11
9
|
/** Run `runId`'s folder, the root of its Workspace: `<data>/disk/agents/<agent>/runs/<run>/work`. */
|
|
12
10
|
export declare const runFolder: (dataDir: string, agentId: string, runId: string) => string;
|
|
13
11
|
/** The recordings folder's name: beside a run's folder on this machine, and the run files route's path to it. */
|
|
14
12
|
export declare const RECORDINGS = "recordings";
|
|
15
13
|
/** Run `runId`'s recordings on this machine, beside its folder: `<data>/disk/agents/<agent>/runs/<run>/recordings`. */
|
|
16
14
|
export declare const recordingsFolder: (dataDir: string, agentId: string, runId: string) => string;
|
|
17
|
-
/** Agent `agentId`'s learning folder, the root of its learning Workspace: `<data>/disk/agents/<agent>/learning`. */
|
|
18
|
-
export declare const agentLearningFolder: (dataDir: string, agentId: string) => string;
|
|
19
15
|
/** Agent `agentId`'s home as a key from a disk's root: `agents/<agent>/home`. */
|
|
20
16
|
export declare const homeKey: (agentId: string) => string;
|
|
21
17
|
/** Agent `agentId`'s home, the root of its home Workspace: `<data>/disk/agents/<agent>/home`. */
|
package/dist/workspace/paths.js
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
//
|
|
3
3
|
// Layout, under a server's data directory, or from the root of an Archil disk (the same keys, without <data>/disk):
|
|
4
4
|
// <data>/disk/agents/<agent>/runs/<run>/work a run's folder (runFolder; runKey on a disk): its Workspace's root
|
|
5
|
-
// <data>/disk/agents/<agent>/learning an agent's learning folder (agentLearningFolder; learningKey): its git
|
|
6
|
-
// folder
|
|
7
5
|
// <data>/disk/agents/<agent>/home an agent's home (agentHomeFolder; homeKey): the files its owner keeps
|
|
8
6
|
// for it
|
|
9
7
|
// and on this machine alone:
|
|
@@ -41,16 +39,12 @@ export const agentDirName = (agentId) => `${checkId(agentId, "agent").toLowerCas
|
|
|
41
39
|
export const agentFolder = (dataDir, agentId) => join(dataDir, DISK_DIR, "agents", agentDirName(agentId));
|
|
42
40
|
/** Run `runId`'s folder as a key from a disk's root: `agents/<agent>/runs/<run>/work` (an Archil workspace's root). */
|
|
43
41
|
export const runKey = (agentId, runId) => `agents/${agentDirName(agentId)}/runs/${checkId(runId, "run")}/work`;
|
|
44
|
-
/** Agent `agentId`'s learning folder as a key from a disk's root: `agents/<agent>/learning`. */
|
|
45
|
-
export const learningKey = (agentId) => `agents/${agentDirName(agentId)}/learning`;
|
|
46
42
|
/** Run `runId`'s folder, the root of its Workspace: `<data>/disk/agents/<agent>/runs/<run>/work`. */
|
|
47
43
|
export const runFolder = (dataDir, agentId, runId) => join(dataDir, DISK_DIR, runKey(agentId, runId));
|
|
48
44
|
/** The recordings folder's name: beside a run's folder on this machine, and the run files route's path to it. */
|
|
49
45
|
export const RECORDINGS = "recordings";
|
|
50
46
|
/** Run `runId`'s recordings on this machine, beside its folder: `<data>/disk/agents/<agent>/runs/<run>/recordings`. */
|
|
51
47
|
export const recordingsFolder = (dataDir, agentId, runId) => join(dirname(runFolder(dataDir, agentId, runId)), RECORDINGS);
|
|
52
|
-
/** Agent `agentId`'s learning folder, the root of its learning Workspace: `<data>/disk/agents/<agent>/learning`. */
|
|
53
|
-
export const agentLearningFolder = (dataDir, agentId) => join(dataDir, DISK_DIR, learningKey(agentId));
|
|
54
48
|
/** Agent `agentId`'s home as a key from a disk's root: `agents/<agent>/home`. */
|
|
55
49
|
export const homeKey = (agentId) => `agents/${agentDirName(agentId)}/home`;
|
|
56
50
|
/** Agent `agentId`'s home, the root of its home Workspace: `<data>/disk/agents/<agent>/home`. */
|
|
@@ -130,7 +130,7 @@ export declare const GREP_FILE_MAX: number;
|
|
|
130
130
|
export declare const GREP_LINE_MAX = 500;
|
|
131
131
|
/** exec's default cap on stdout, and on stderr, each. */
|
|
132
132
|
export declare const EXEC_OUTPUT_MAX: number;
|
|
133
|
-
/** A run's folder
|
|
133
|
+
/** A run's folder: every path is relative to its root. */
|
|
134
134
|
export interface Workspace {
|
|
135
135
|
/** The bytes of file `path`, or `length` of them from `offset` (a range past the end gives what is there). */
|
|
136
136
|
read(path: string, range?: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The Workspace: the one way serve touches a run's files
|
|
1
|
+
// The Workspace: the one way serve touches a run's files. One Workspace is scoped to ONE
|
|
2
2
|
// root folder and takes paths relative to it only (paths.ts). Two backends answer it: Local (a folder on this machine,
|
|
3
3
|
// local.ts) and, next, Archil (the owner's disk through its file API and serverless exec). Nothing on main uses it yet:
|
|
4
4
|
// the writers move onto it in one cutover.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-serve",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.61",
|
|
4
4
|
"description": "The AgentRun server: the /v2 API and console over one store, with runners that run your agents; the deployable process of the AgentRun platform.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentrun",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"build": "rm -rf dist && tsc -p tsconfig.json && node scripts/copy-page.mjs",
|
|
56
56
|
"prepack": "npm run build",
|
|
57
57
|
"typecheck": "tsc -p tsconfig.test.json",
|
|
58
|
-
"test": "node --test --test-concurrency=8 'test/*.test.mjs'",
|
|
58
|
+
"test": "node --test --test-concurrency=8 --import=./test/fixtures/sqlite-guard-register.mjs 'test/*.test.mjs'",
|
|
59
59
|
"test:pg:up": "docker compose -f test/pg/compose.yaml up -d --wait",
|
|
60
60
|
"test:pg:down": "docker compose -f test/pg/compose.yaml down",
|
|
61
61
|
"test:pg": "node scripts/test-pg.mjs"
|
|
@@ -70,17 +70,17 @@
|
|
|
70
70
|
"@opentelemetry/exporter-trace-otlp-http": "0.301.2",
|
|
71
71
|
"@opentelemetry/resources": "3.1.1",
|
|
72
72
|
"@opentelemetry/sdk-trace": "3.1.1",
|
|
73
|
-
"@parcha/agentrun-computer": "0.1.0-beta.
|
|
74
|
-
"@parcha/agentrun-decisions": "0.1.0-beta.
|
|
75
|
-
"@parcha/agentrun-dsl": "0.1.0-beta.
|
|
76
|
-
"@parcha/agentrun-harness-acp": "0.1.0-beta.
|
|
77
|
-
"@parcha/agentrun-harness-claude": "0.1.0-beta.
|
|
78
|
-
"@parcha/agentrun-harness-codex": "0.1.0-beta.
|
|
79
|
-
"@parcha/agentrun-import": "0.1.0-beta.
|
|
80
|
-
"@parcha/agentrun-jev": "0.1.0-beta.
|
|
81
|
-
"@parcha/agentrun-kernel": "0.1.0-beta.
|
|
82
|
-
"@parcha/agentrun-web": "0.1.0-beta.
|
|
83
|
-
"@parcha/pi-browser": "0.1.0-beta.
|
|
73
|
+
"@parcha/agentrun-computer": "0.1.0-beta.61",
|
|
74
|
+
"@parcha/agentrun-decisions": "0.1.0-beta.61",
|
|
75
|
+
"@parcha/agentrun-dsl": "0.1.0-beta.61",
|
|
76
|
+
"@parcha/agentrun-harness-acp": "0.1.0-beta.61",
|
|
77
|
+
"@parcha/agentrun-harness-claude": "0.1.0-beta.61",
|
|
78
|
+
"@parcha/agentrun-harness-codex": "0.1.0-beta.61",
|
|
79
|
+
"@parcha/agentrun-import": "0.1.0-beta.61",
|
|
80
|
+
"@parcha/agentrun-jev": "0.1.0-beta.61",
|
|
81
|
+
"@parcha/agentrun-kernel": "0.1.0-beta.61",
|
|
82
|
+
"@parcha/agentrun-web": "0.1.0-beta.61",
|
|
83
|
+
"@parcha/pi-browser": "0.1.0-beta.61",
|
|
84
84
|
"@secretlint/core": "14.1.0",
|
|
85
85
|
"@secretlint/profiler": "14.1.0",
|
|
86
86
|
"croner": "11.0.0",
|
package/templates/TOOLS.md
CHANGED
|
@@ -126,6 +126,52 @@ both every call is refused. A keys pin bounds one argument: pin `null` any other
|
|
|
126
126
|
same fields (HubSpot's `custom_properties` beside `properties`). Fence every other argument that reaches the same place
|
|
127
127
|
the same way: Gmail's `user_id` also picks the sender, so pin it to `[null, "me"]` beside `from_email: null`.
|
|
128
128
|
|
|
129
|
+
## File
|
|
130
|
+
|
|
131
|
+
Some answers hold text the model shouldn't read: a payments list carries each customer's description, and a page of
|
|
132
|
+
it can carry an instruction someone typed there. `file` sends a tool's answers to the run's files instead of back as the
|
|
133
|
+
tool's result. Your skill's code reads the files; the tool's result is a summary.
|
|
134
|
+
|
|
135
|
+
`file: {<tool>: {folder: <folder>, show: [<path>, ...]}}`, beside `pin`, for tools of the same entry:
|
|
136
|
+
|
|
137
|
+
- `folder`: where each answer goes in the run's files, 1 to 3 segments (`stripe`, `data/pages`). A segment never
|
|
138
|
+
starts with a dot, so `..` and hidden folders are refused.
|
|
139
|
+
- `show`: at most 8 paths into the answer's JSON, each 1 to 6 segments joined by `.`: a key, an index, or `-1` for
|
|
140
|
+
the last item (`data.data.-1.id`).
|
|
141
|
+
|
|
142
|
+
Each answer is written whole, as the server sent it (credentials scrubbed), at `<folder>/<tool>-<time>-<id>.json`
|
|
143
|
+
before the model gets its turn back. The names sort by time. The answer goes through neither the clip nor
|
|
144
|
+
`evidence/mcp/`. The tool's result is three lines: the size and path, the value at each `show` path, and the answer's
|
|
145
|
+
shape (its keys and types to depth 2, each array's length, never a value). The shape names a key only when it reads as
|
|
146
|
+
a short name (a letter or `_` first, at most 32 letters, digits or `_`) and counts the rest, so keys that are data, such
|
|
147
|
+
as emails, aren't shown:
|
|
148
|
+
|
|
149
|
+
```text
|
|
150
|
+
STRIPE_LIST_BALANCE_TRANSACTIONS answered 61,204 bytes, filed whole at stripe/STRIPE_LIST_BALANCE_TRANSACTIONS-2026-11-30T07-02-11-512Z-1a2b3c4d.json for the skill's code; its values are not shown here (the agent's setting files this tool's answers); only these are:
|
|
151
|
+
{"successful": true, "error": null, "data.has_more": true, "data.data.-1.id": "txn_1Q...", "data.data.-1.created": 1763337600}
|
|
152
|
+
Shape: {"data": {"object": string, "data": [100 objects], "has_more": boolean, "url": string}, "successful": boolean, "error": null}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
A `show` path that reaches no scalar shows `null`, and a string is cut at 200 characters. Show only what the model
|
|
156
|
+
needs to go on: the next page's cursor, a done flag, a status. A path that names a free-text field (a description, a
|
|
157
|
+
name, a message body) shows that text to the model and defeats the option. An answer that is an error is filed the
|
|
158
|
+
same way, and the tool's result is its summary marked as an error, so the model can react through a shown field such as
|
|
159
|
+
`error.code`. If the file can't be written, the model gets an error and none of the answer, never the answer as a
|
|
160
|
+
fallback. An answer that is not JSON is filed the same way, every path showing `null`.
|
|
161
|
+
|
|
162
|
+
The setting keeps the answer out of the tool's result, not out of the model's reach. The model's own file tools
|
|
163
|
+
(`read`, `grep`, `ls`, and `bash` on a computer) can still open the folder, and the summary names the file. If the model
|
|
164
|
+
must not read the answer, don't grant those tools, or run your skill's code where the model can't read its output.
|
|
165
|
+
|
|
166
|
+
The setting is per tool. File every tool that returns the same data: a retrieve tool beside a filed list tool returns
|
|
167
|
+
the same objects, unfiled.
|
|
168
|
+
|
|
169
|
+
Apply writes the setting into the agent's own tool settings (`definition.tool_settings["mcp:<server>/<tool>"].file`),
|
|
170
|
+
ticked or not, as it writes a pin. It's the owner's setting: they can change it or remove it. With it removed, the
|
|
171
|
+
tool's answers go to the model whole again, as they do for any tool without it, so a skill that reads the filed pages
|
|
172
|
+
should say what it does when there are none. A stored setting that no longer reads refuses every call of its tool, with
|
|
173
|
+
an error naming the setting and nothing sent, until the owner sets it again or removes it.
|
|
174
|
+
|
|
129
175
|
## Ask
|
|
130
176
|
|
|
131
177
|
- Ticking grants a tool; it doesn't allow it. Apply writes no permission, so a ticked tool follows the server's own
|