@parcha/agentrun-serve 0.1.0-beta.55 → 0.1.0-beta.57
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 +261 -0
- package/README.md +228 -45
- package/dist/acp-package.d.ts +2 -0
- package/dist/adapters.d.ts +18 -5
- package/dist/adapters.js +23 -9
- package/dist/agent-package.d.ts +3 -3
- package/dist/agent-package.js +17 -8
- package/dist/answer-json.d.ts +6 -2
- package/dist/answer-json.js +22 -4
- package/dist/api-keys.d.ts +76 -0
- package/dist/api-keys.js +217 -0
- package/dist/api-only.d.ts +17 -5
- package/dist/api-only.js +36 -8
- package/dist/browser-hold.d.ts +23 -0
- package/dist/browser-hold.js +48 -0
- package/dist/browser-person.d.ts +3 -0
- package/dist/browser-person.js +4 -1
- package/dist/calendar/tools.js +3 -2
- package/dist/chatgpt-plan.d.ts +28 -3
- package/dist/chatgpt-plan.js +182 -21
- package/dist/claude-login.d.ts +101 -14
- package/dist/claude-login.js +232 -49
- package/dist/claude-sign-in.d.ts +46 -0
- package/dist/claude-sign-in.js +93 -0
- package/dist/cli.js +63 -6
- package/dist/composio-made.d.ts +4 -0
- package/dist/composio-made.js +4 -0
- package/dist/composio-preset.d.ts +43 -2
- package/dist/composio-preset.js +92 -4
- package/dist/computer-held-routes.d.ts +5 -4
- package/dist/computer-held-routes.js +29 -8
- package/dist/computer-held.d.ts +6 -1
- package/dist/computer-held.js +14 -0
- package/dist/computer-record.js +4 -2
- package/dist/computer-viewer.js +4 -1
- package/dist/console/assets/{backend-D5EmB4N3.js → backend-DVhHzJX2.js} +19 -19
- package/dist/console/assets/index-Bwn1oTem.css +1 -0
- package/dist/console/assets/index-okP-y8PK.js +747 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/decisions.js +1 -1
- package/dist/docker-host-addresses.d.ts +22 -11
- package/dist/docker-host-addresses.js +38 -26
- package/dist/env-switch.d.ts +10 -0
- package/dist/env-switch.js +33 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fal-price.d.ts +58 -20
- package/dist/fal-price.js +341 -82
- package/dist/handed-values.d.ts +43 -1
- package/dist/handed-values.js +119 -2
- package/dist/harness-archive.d.ts +13 -10
- package/dist/harness-archive.js +60 -34
- package/dist/harness-check.d.ts +3 -1
- package/dist/harness-check.js +25 -46
- package/dist/harness-keys.d.ts +73 -27
- package/dist/harness-keys.js +194 -61
- package/dist/harness-recipe-entry.d.ts +8 -7
- package/dist/harness-recipe-entry.js +21 -32
- package/dist/harness-recipe.d.ts +38 -25
- package/dist/harness-recipe.js +49 -36
- package/dist/harness-sign-in.js +12 -23
- package/dist/harness-table.d.ts +10 -3
- package/dist/harness-table.js +26 -21
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +17 -5
- package/dist/host-check.d.ts +4 -0
- package/dist/host-check.js +4 -0
- package/dist/hosted-search.d.ts +1 -1
- package/dist/hosted-search.js +1 -2
- package/dist/import-worker.d.ts +4 -2
- package/dist/import-worker.js +9 -2
- package/dist/in-flight.d.ts +26 -0
- package/dist/in-flight.js +52 -0
- package/dist/key-refusal.d.ts +26 -5
- package/dist/key-refusal.js +313 -37
- package/dist/learn/secrets.d.ts +31 -11
- package/dist/learn/secrets.js +152 -191
- package/dist/learning-cost.d.ts +6 -3
- package/dist/learning-cost.js +4 -2
- package/dist/link-check.js +1 -1
- package/dist/llms.txt +2 -2
- package/dist/marketplace.d.ts +77 -0
- package/dist/marketplace.js +224 -0
- package/dist/mcp-api-only-origins.d.ts +30 -0
- package/dist/mcp-api-only-origins.js +57 -0
- package/dist/mcp-gateway.d.ts +7 -5
- package/dist/mcp-gateway.js +9 -12
- package/dist/mcp-secret-writes.js +5 -3
- package/dist/mcp-servers-store.d.ts +28 -6
- package/dist/mcp-servers-store.js +53 -4
- package/dist/media-duration.d.ts +3 -0
- package/dist/media-duration.js +90 -9
- package/dist/model-form.d.ts +5 -4
- package/dist/model-form.js +11 -7
- package/dist/model.d.ts +5 -2
- package/dist/model.js +9 -5
- package/dist/ollama-provider.d.ts +7 -1
- package/dist/ollama-provider.js +14 -2
- package/dist/openapi.d.ts +3 -3
- package/dist/openapi.js +245 -42
- package/dist/otel/genai.d.ts +65 -0
- package/dist/otel/genai.js +116 -0
- package/dist/otel/tracer.d.ts +55 -0
- package/dist/otel/tracer.js +308 -0
- package/dist/page.d.ts +2 -0
- package/dist/page.js +3 -1
- package/dist/paid-calls.d.ts +1 -32
- package/dist/paid-calls.js +4 -39
- package/dist/place-offers.d.ts +14 -6
- package/dist/place-offers.js +26 -13
- package/dist/provider.d.ts +9 -0
- package/dist/provider.js +50 -3
- package/dist/redact/match.d.ts +101 -0
- package/dist/redact/match.js +1152 -0
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +11 -0
- package/dist/run-census.d.ts +67 -0
- package/dist/run-census.js +240 -0
- package/dist/run-computer.d.ts +6 -3
- package/dist/run-computer.js +4 -1
- package/dist/run-cut.d.ts +15 -6
- package/dist/run-cut.js +30 -9
- package/dist/run-files.d.ts +3 -0
- package/dist/run-files.js +3 -0
- package/dist/run-launch.d.ts +12 -1
- package/dist/run-launch.js +9 -10
- package/dist/run-learning-served.d.ts +2 -0
- package/dist/run-model-key.d.ts +8 -0
- package/dist/run-model-key.js +31 -1
- package/dist/run-reads-over-store.d.ts +24 -6
- package/dist/run-reads-over-store.js +67 -23
- package/dist/run-recordings.d.ts +5 -1
- package/dist/run-recordings.js +39 -14
- package/dist/run-timeline-served.d.ts +3 -1
- package/dist/run-timeline-served.js +4 -4
- package/dist/run-usage.d.ts +1 -0
- package/dist/runnable.d.ts +10 -1
- package/dist/runnable.js +20 -8
- package/dist/runner/adapter-loop.d.ts +14 -0
- package/dist/runner/adapter-loop.js +56 -11
- package/dist/runner/adapter-run-spec.d.ts +45 -8
- package/dist/runner/adapter-run-spec.js +154 -29
- package/dist/runner/adapters/pi.js +25 -3
- package/dist/runner/beside.js +11 -6
- package/dist/runner/big-writes.js +1 -10
- package/dist/runner/claim-secrets.d.ts +18 -3
- package/dist/runner/claim-secrets.js +35 -6
- package/dist/runner/cli-run-spec.d.ts +6 -0
- package/dist/runner/cli-run-spec.js +85 -36
- package/dist/runner/computer-journal.d.ts +9 -1
- package/dist/runner/computer-journal.js +26 -0
- package/dist/runner/conformance/harness.js +1 -1
- package/dist/runner/feedback-round.js +3 -0
- package/dist/runner/harness-loops.d.ts +6 -5
- package/dist/runner/harness-loops.js +7 -7
- package/dist/runner/held.d.ts +11 -5
- package/dist/runner/journal-kinds.d.ts +5 -0
- package/dist/runner/journal-kinds.js +5 -0
- package/dist/runner/loop-contract.d.ts +4 -0
- package/dist/runner/main.js +15 -6
- package/dist/runner/mcp-claim.js +30 -3
- package/dist/runner/mcp-run.d.ts +12 -0
- package/dist/runner/mcp-run.js +12 -5
- package/dist/runner/model-route.d.ts +17 -0
- package/dist/runner/model-route.js +120 -2
- package/dist/runner/presence.d.ts +4 -3
- package/dist/runner/presence.js +4 -2
- package/dist/runner/run-child-host.d.ts +5 -0
- package/dist/runner/run-child-host.js +71 -30
- package/dist/runner/run-child.js +5 -2
- package/dist/runner/runner.d.ts +18 -3
- package/dist/runner/runner.js +162 -36
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +6 -0
- package/dist/runner/store-secrets.js +49 -7
- package/dist/runner/subagent.js +4 -40
- package/dist/runner/workflow-first.d.ts +11 -4
- package/dist/runner/workflow-first.js +14 -8
- package/dist/runner/workflow-spec.js +3 -2
- package/dist/runs-over-store.d.ts +15 -6
- package/dist/runs-over-store.js +33 -21
- package/dist/scrub-command.d.ts +73 -0
- package/dist/scrub-command.js +307 -0
- package/dist/secret-cut.d.ts +73 -0
- package/dist/secret-cut.js +291 -4
- package/dist/secret-rules.d.ts +143 -0
- package/dist/secret-rules.js +2564 -0
- package/dist/secrets.d.ts +7 -0
- package/dist/secrets.js +20 -0
- package/dist/server-keys.d.ts +20 -0
- package/dist/server-keys.js +25 -6
- package/dist/server.d.ts +57 -13
- package/dist/server.js +371 -113
- package/dist/skills/agentrun-serve/SKILL.md +4 -0
- package/dist/store/dialect.d.ts +3 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.js +1 -1
- package/dist/store/postgres/dialect.js +3 -0
- package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
- package/dist/store/schema.d.ts +6 -0
- package/dist/store/schema.js +11 -1
- package/dist/store/seal.d.ts +6 -1
- package/dist/store/seal.js +5 -3
- package/dist/store/sqlite/run-launch.d.ts +9 -1
- package/dist/store/sqlite/run-launch.js +24 -13
- package/dist/store/sqlite/run-patch.d.ts +1 -1
- package/dist/store/sqlite/run-patch.js +13 -4
- package/dist/store/sqlite/store.js +76 -16
- package/dist/store/store.d.ts +53 -3
- package/dist/store/store.js +27 -0
- package/dist/store-reads/learning.d.ts +6 -3
- package/dist/store-reads/learning.js +22 -7
- package/dist/store-view.d.ts +3 -0
- package/dist/store-view.js +4 -4
- package/dist/suggestions.js +3 -2
- package/dist/template-eval.d.ts +22 -11
- package/dist/template-eval.js +124 -41
- package/dist/template-import.d.ts +10 -0
- package/dist/template-import.js +16 -7
- package/dist/templates.d.ts +10 -2
- package/dist/templates.js +28 -8
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/labels.d.ts +6 -4
- package/dist/timeline/labels.js +18 -6
- package/dist/timeline/timeline.d.ts +17 -7
- package/dist/timeline/timeline.js +28 -14
- package/dist/timeline/util.js +1 -1
- package/dist/timeline/web-calls.d.ts +26 -9
- package/dist/timeline/web-calls.js +124 -37
- package/dist/tool-gate.d.ts +42 -3
- package/dist/tool-gate.js +69 -6
- package/dist/tool-keys-store.d.ts +2 -4
- package/dist/tool-keys-store.js +5 -21
- package/dist/tool-keys.d.ts +2 -2
- package/dist/tool-keys.js +2 -2
- package/dist/tool-list.js +1 -1
- package/dist/tool-plane.d.ts +2 -2
- package/dist/tool-plane.js +35 -33
- package/dist/tools.js +13 -7
- package/dist/trigger-targets.d.ts +4 -0
- package/dist/trigger-targets.js +9 -2
- package/dist/triggers.d.ts +67 -4
- package/dist/triggers.js +171 -22
- package/dist/until.d.ts +3 -0
- package/dist/until.js +11 -0
- package/dist/validate.js +1 -1
- package/dist/web-fake.d.ts +1 -3
- package/dist/web-fake.js +7 -18
- package/dist/web-fetch.d.ts +6 -72
- package/dist/web-fetch.js +11 -265
- package/dist/web-run.d.ts +31 -0
- package/dist/web-run.js +90 -0
- package/dist/web-save.d.ts +6 -4
- package/dist/web-save.js +9 -12
- package/dist/web-search.d.ts +9 -127
- package/dist/web-search.js +23 -259
- package/dist/wires.d.ts +13 -0
- package/dist/wires.js +11 -0
- package/dist/workflow-run.d.ts +5 -4
- package/dist/workflow-run.js +5 -4
- package/dist/workspace/computer-deps.d.ts +3 -1
- package/dist/workspace/computer-deps.js +12 -4
- package/dist/workspace/computer-for-claim.d.ts +19 -2
- package/dist/workspace/computer-for-claim.js +101 -13
- package/dist/workspace/computer-janitor.d.ts +15 -7
- package/dist/workspace/computer-janitor.js +33 -8
- package/dist/workspace/computer-kept.d.ts +55 -4
- package/dist/workspace/computer-kept.js +129 -8
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/kind-skills.d.ts +4 -0
- package/dist/workspace/kind-skills.js +9 -0
- package/dist/workspace/run-end-computers.d.ts +5 -1
- package/dist/workspace/run-end-computers.js +27 -1
- package/dist/workspace/synced-folder.js +3 -4
- package/dist/wrapped.d.ts +65 -0
- package/dist/wrapped.js +77 -0
- package/package.json +17 -11
- package/skills/agentrun-serve/SKILL.md +4 -0
- package/templates/README.md +38 -15
- package/dist/console/assets/index-DUYLaqiR.js +0 -746
- package/dist/console/assets/index-DYhU4adm.css +0 -1
- package/dist/exa-keyless.d.ts +0 -34
- package/dist/exa-keyless.js +0 -118
- package/dist/firecrawl-keyless.d.ts +0 -41
- package/dist/firecrawl-keyless.js +0 -152
- package/dist/keyless-mcp.d.ts +0 -36
- package/dist/keyless-mcp.js +0 -127
- package/dist/text-urls.d.ts +0 -38
- package/dist/text-urls.js +0 -170
- package/dist/web-fetch-direct.d.ts +0 -119
- package/dist/web-fetch-direct.js +0 -190
|
@@ -4,6 +4,8 @@ import { type AdapterFacts, type AgentAdapter, type Refusal, type SessionRecord,
|
|
|
4
4
|
import type { KernelHooks, ToolCall } from "./conformance/subject.js";
|
|
5
5
|
import { type BudgetData, type EndData, type ToolCalls } from "./journal-kinds.js";
|
|
6
6
|
import { type MessageOrigin } from "../timeline/index.js";
|
|
7
|
+
import { type GenAiTracing } from "../otel/tracer.js";
|
|
8
|
+
import type { RouteTrace } from "../otel/genai.js";
|
|
7
9
|
type EndCost = Required<Pick<EndData, "costUsd" | "costUpperBound">>;
|
|
8
10
|
import { type Claim, type EndOfRunTurn, type LoopFactory } from "./loop-contract.js";
|
|
9
11
|
import type { HeldRedact } from "./redact.js";
|
|
@@ -248,6 +250,12 @@ export interface AdapterRunSpec {
|
|
|
248
250
|
* that misses it is asked again once, in the same session under the same cap (the output contract's retry); absent:
|
|
249
251
|
* the run's answer is never checked here. */
|
|
250
252
|
readonly outputSchema?: unknown;
|
|
253
|
+
/** The model route its requests take, as the run's GenAI trace names it (otel/genai.ts TracedRun): the provider id its
|
|
254
|
+
* model is named by, the host its requests go to, its model. Each where the spec knows it; absent, its spans name none.
|
|
255
|
+
* `routes`: the session's other routes (a subagent's tier), by the name its requests carry (ModelRequest.route). */
|
|
256
|
+
readonly trace?: RouteTrace & {
|
|
257
|
+
readonly routes?: ReadonlyMap<string, RouteTrace>;
|
|
258
|
+
};
|
|
251
259
|
}
|
|
252
260
|
/** A tool host's lifecycle, as its bindings registered it: run by the adapter loop (AdapterRunSpec.lifecycle). */
|
|
253
261
|
export interface HostLifecycle {
|
|
@@ -307,6 +315,9 @@ export type AdapterRun = PiRun & {
|
|
|
307
315
|
* while it is built (a CLI harness's first-use install), so a stop ends that wait at once and never the work it waits
|
|
308
316
|
* for. Absent where no loop gave one. */
|
|
309
317
|
readonly stopped?: AbortSignal;
|
|
318
|
+
/** The runner's presence incarnation (LoopDeps.incarnation): with the claim's runner, who keeps a computer a park pins
|
|
319
|
+
* to its runner (computer-for-claim.ts ClaimLaunch.holder). Absent where no loop gave one. */
|
|
320
|
+
readonly incarnation?: string;
|
|
310
321
|
/** Stages the run row's `summary` on the next commit of this pass that writes a root entry of `kind` whose data `test`
|
|
311
322
|
* takes, in that commit (a tool host's wait on the person, its claim held: the server tells run.needs_input by the
|
|
312
323
|
* summary). Absent where no loop gave one. */
|
|
@@ -360,6 +371,9 @@ export interface AdapterLoopOptions {
|
|
|
360
371
|
/** For tests: awaited once a turn ended on its question to the person, before the wait in the claim (or the park, with
|
|
361
372
|
* nothing to hold open) takes their messages. */
|
|
362
373
|
readonly beforePersonWait?: () => Promise<void>;
|
|
374
|
+
/** The runs' GenAI tracing (otel/tracer.ts). Default the process's, from its OTEL_* env: none unless an OTLP endpoint is
|
|
375
|
+
* set. A test gives its own, over an in-memory exporter. */
|
|
376
|
+
readonly tracing?: Promise<GenAiTracing | undefined>;
|
|
363
377
|
}
|
|
364
378
|
/** A paid call's refusal an earlier claim kept (KINDS.pausePending) whose pause never landed: the newest one with no
|
|
365
379
|
* pause (KINDS.budget), no end and no park on a person's question (KINDS.personAsked: the turn ended on the ask with no
|
|
@@ -21,6 +21,7 @@ import { turnEndedOnAsk } from "../store-reads/journal.js";
|
|
|
21
21
|
import { CAP_REFUSED, CAP_WRAPUP, COMPUTER_NOTE, endsTurn, HOST_PHASE, MESSAGE_ORIGIN, originOf, REQUEST_ENDED, REQUEST_STARTED, RUN_RESUMED } from "../timeline/index.js";
|
|
22
22
|
import { raiseFollowUpId } from "../run-view.js";
|
|
23
23
|
import { durableWait } from "../workflow/pi-versions.js";
|
|
24
|
+
import { genAiTracing } from "../otel/tracer.js";
|
|
24
25
|
/** The root entries a claim writes before its turn, whatever the run's turns are (its session's key, a phase row, a
|
|
25
26
|
* takeover's note, its computer's hold, the learning seed it laid, the computer it made): read past when a claim asks
|
|
26
27
|
* whether the run's root ends on its end (a fresh reopen). */
|
|
@@ -594,6 +595,12 @@ function adapterLoop(specOf, options, deps) {
|
|
|
594
595
|
const retry = options.retry ?? MODEL_RETRY;
|
|
595
596
|
const stream = options.stream ?? MODEL_STREAM;
|
|
596
597
|
const now = options.now ?? Date.now;
|
|
598
|
+
/** The runs' GenAI tracing (none unless the env turns it on), and this claim's trace of its run, open once its spec is
|
|
599
|
+
* known: its chat spans from the session's model port (counted), its tool spans from the session's events (io.onEvent),
|
|
600
|
+
* ended with the claim (traced). */
|
|
601
|
+
let tracing;
|
|
602
|
+
const tracingMade = (options.tracing ?? genAiTracing()).then((now) => (tracing = { now }), () => (tracing = { now: undefined }));
|
|
603
|
+
let trace;
|
|
597
604
|
/** The gate's clock as main's card says a time: ISO. */
|
|
598
605
|
const isoNow = () => new Date(now()).toISOString();
|
|
599
606
|
const inbox = [];
|
|
@@ -1350,7 +1357,25 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1350
1357
|
await specNow?.hooks?.afterMessageSent?.();
|
|
1351
1358
|
return session.turnEnd();
|
|
1352
1359
|
};
|
|
1360
|
+
/** run(claim), its trace ended with it: every span still open ends, with the claim's failure where it failed, handed to
|
|
1361
|
+
* the exporter, which sends it in the background (tracer.ts: the claim's end never waits on a collector, and never
|
|
1362
|
+
* throws). */
|
|
1363
|
+
async function traced(claim) {
|
|
1364
|
+
try {
|
|
1365
|
+
const end = await run(claim);
|
|
1366
|
+
await trace?.end(end.state === "failed" ? end.error.code : undefined);
|
|
1367
|
+
return end;
|
|
1368
|
+
}
|
|
1369
|
+
catch (error) {
|
|
1370
|
+
await trace?.end("run-error");
|
|
1371
|
+
throw error;
|
|
1372
|
+
}
|
|
1373
|
+
finally {
|
|
1374
|
+
trace = undefined;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1353
1377
|
async function run(claim) {
|
|
1378
|
+
const claimedAt = Date.now();
|
|
1354
1379
|
context = withAbortSignal(deps.signal, BACKGROUND_CONTEXT);
|
|
1355
1380
|
// Every row the runner read for this claim is with the loop once delivered resolves (at once without a runner's).
|
|
1356
1381
|
void (deps.delivered ?? Promise.resolve()).then(() => {
|
|
@@ -1510,7 +1535,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1510
1535
|
return;
|
|
1511
1536
|
passGate.expect(writesEntry(kind, test), { run: { summary } }).catch(() => undefined);
|
|
1512
1537
|
};
|
|
1513
|
-
const runOf = { harness, registry, setModels: (given) => (models = given), ledger, redact: deps.redact, signal: deps.signal, stopped: AbortSignal.any([deps.signal, stopAbort.signal]), phase, rowSummaryOn };
|
|
1538
|
+
const runOf = { harness, registry, setModels: (given) => (models = given), ledger, redact: deps.redact, signal: deps.signal, stopped: AbortSignal.any([deps.signal, stopAbort.signal]), phase, rowSummaryOn, ...(deps.incarnation ? { incarnation: deps.incarnation } : {}) };
|
|
1514
1539
|
// The spec, its MCP claim step among it (mcpForClaim, before the session opens). A refusal there ends the run in its
|
|
1515
1540
|
// words with nothing sent; a claim lost during its refresh ends the loop with nothing more written. A claim the spec
|
|
1516
1541
|
// refuses (ClaimRefused: a handed sign-in that won't read back) ends the run in its words too.
|
|
@@ -1542,6 +1567,10 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1542
1567
|
}
|
|
1543
1568
|
throw error;
|
|
1544
1569
|
}
|
|
1570
|
+
// The run's trace, from its claim's start, once its spec says what runs (a restart's spec changes nothing of it).
|
|
1571
|
+
// The tracing is made long before (as the loop is): waited for only on the rare claim whose spec beat it.
|
|
1572
|
+
trace ??= (tracing ?? (await tracingMade)).now?.open({ startedAt: claimedAt, mcp: (name) => mcp?.catalogOf(specNow?.facts?.hostName?.(name) ?? name) !== undefined });
|
|
1573
|
+
trace?.known({ runId: claim.runId, harness: spec.adapter.id, ...(spec.facts?.wire === "plan" ? { plan: true } : {}), ...spec.trace });
|
|
1545
1574
|
mcp = spec.mcp;
|
|
1546
1575
|
specNow = spec;
|
|
1547
1576
|
specKnown = true;
|
|
@@ -1582,18 +1611,18 @@ function adapterLoop(specOf, options, deps) {
|
|
|
1582
1611
|
// in flight may be the one that asked for the call (Claude Code books its cost after its calls; Codex starts a call
|
|
1583
1612
|
// with its response open), so the call is judged beside it and never waits on it. pi's request has answered by then.
|
|
1584
1613
|
// A call settled above its hold (a fal job whose output states more than its input asked, a monid call charged above
|
|
1585
|
-
// its maxCost) can take
|
|
1586
|
-
//
|
|
1587
|
-
//
|
|
1588
|
-
//
|
|
1589
|
-
//
|
|
1590
|
-
// admission, tells an overrun.
|
|
1614
|
+
// its maxCost) can take the run's charges past its cap: from then on, a settle that leaves them over it stops the run
|
|
1615
|
+
// in the cap's words (overCap, settled charges only; paid-calls.ts stopRun). A call still in flight counts only
|
|
1616
|
+
// toward admissions. Its hold, kept from its admission until it settles, tells an overrun (a host tool call's paid
|
|
1617
|
+
// steps, bookedIn below). An admit its ref had booked already opens no step and is never settled, so it keeps
|
|
1618
|
+
// nothing.
|
|
1591
1619
|
const holds = new Map();
|
|
1592
1620
|
let overran = false;
|
|
1593
1621
|
const paidUnder = {
|
|
1594
1622
|
admit: async (request) => {
|
|
1595
1623
|
const admitted = await paid.admit({ ...request, under: spec.session.key });
|
|
1596
|
-
|
|
1624
|
+
if (admitted?.booked !== true)
|
|
1625
|
+
holds.set(request.id, request.holdUsd);
|
|
1597
1626
|
return admitted;
|
|
1598
1627
|
},
|
|
1599
1628
|
settle: async (id, usd, options) => {
|
|
@@ -2234,6 +2263,8 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2234
2263
|
bookingsWriting = 0;
|
|
2235
2264
|
// The conversation each request of this claim was asked in, by its turn, where its client named one.
|
|
2236
2265
|
const askedIn = new Map();
|
|
2266
|
+
// Each admitted model request's chat span, by its turn, until its afterRequest ends it (a paid tool's step is none).
|
|
2267
|
+
const chats = new Map();
|
|
2237
2268
|
const counted = {
|
|
2238
2269
|
beforeRequest: async (request) => {
|
|
2239
2270
|
// The CLI's next request of its main model after its question to the person: never admitted, it asks for the
|
|
@@ -2265,6 +2296,8 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2265
2296
|
carried = undefined;
|
|
2266
2297
|
}
|
|
2267
2298
|
unbooked += 1;
|
|
2299
|
+
if (ticket && trace && request.paid === undefined)
|
|
2300
|
+
chats.set(ticket.turn, trace.request(request.model, request.route));
|
|
2268
2301
|
// The conversation that asked, as its client named it (pi's, one of several asking at once): whose answer reads
|
|
2269
2302
|
// this request's booking (bookedCost).
|
|
2270
2303
|
const conversation = request.conversation;
|
|
@@ -2296,6 +2329,11 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2296
2329
|
const held = carried?.turn !== undefined && carried.turn === ticket?.turn ? carried : undefined;
|
|
2297
2330
|
if (held)
|
|
2298
2331
|
carried = undefined;
|
|
2332
|
+
const chat = ticket ? chats.get(ticket.turn) : undefined;
|
|
2333
|
+
if (chat) {
|
|
2334
|
+
chats.delete(ticket.turn);
|
|
2335
|
+
chat(usage, ended);
|
|
2336
|
+
}
|
|
2299
2337
|
// An answer the model gave, not the provider's error inside one (a stream ended in an error event, a translated
|
|
2300
2338
|
// route's failure in words included: the client drops it and asks again).
|
|
2301
2339
|
const row = held && ended?.end === "answered" && ended.label !== "error" ? tell(held) : undefined;
|
|
@@ -2430,7 +2468,13 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2430
2468
|
ended: (callId, output, failed) => ownWrite(record.end(callId, failed ? "failed" : "done", output).catch(unlessSealed)),
|
|
2431
2469
|
}
|
|
2432
2470
|
: undefined;
|
|
2433
|
-
|
|
2471
|
+
// Every harness's events reach its trace first (its tool calls, a plan harness's turns), with a record or without.
|
|
2472
|
+
const recorded = record ? onEvent(record) : undefined;
|
|
2473
|
+
const traceAnd = (event) => {
|
|
2474
|
+
trace?.event(event);
|
|
2475
|
+
recorded?.(event);
|
|
2476
|
+
};
|
|
2477
|
+
const io = { writer, models: counted, signal: deps.signal, onEvent: traceAnd, gate: bridgeGate, ...(permission ? { permission } : {}), hostTool: hosted, ...(ownCalls ? { ownCalls } : {}), bookedCost, keepCalls, ...(record ? {} : { nestedEnded }) };
|
|
2434
2478
|
// The end-of-run turn an earlier claim asked and never saw end (its runner lost mid look-back or mid compile): the
|
|
2435
2479
|
// root's newest input still in flight is that turn's (end-of-run.ts REFLECT_PREFIX), which pi picks up again as its
|
|
2436
2480
|
// session opens. The job's turn ended before it, answered: this pass runs no job turn (no recovery as the job's, no
|
|
@@ -2448,7 +2492,8 @@ function adapterLoop(specOf, options, deps) {
|
|
|
2448
2492
|
reflecting = lookingBackOpen || jobKept;
|
|
2449
2493
|
// The MCP tools are host tools like any other (mcp.tools, wrapped above): every harness gets them on its own channel
|
|
2450
2494
|
// for host tools, each call through the gate before its intent.
|
|
2451
|
-
|
|
2495
|
+
// A harness's own search defers only where the host offers none (its facts' ownToolSearch).
|
|
2496
|
+
session = await spec.adapter.open({ ...spec.session, tools, deferCatalog: deferred && !offered }, io);
|
|
2452
2497
|
root = await harness.root(context);
|
|
2453
2498
|
// The root as the claim found it, before this pass writes anything of its own there (the computer's show-up, a
|
|
2454
2499
|
// takeover's note): what the reopen check below reads, so a fresh reopen is told by the run's own last entry.
|
|
@@ -4166,7 +4211,7 @@ function adapterLoop(specOf, options, deps) {
|
|
|
4166
4211
|
}
|
|
4167
4212
|
return {
|
|
4168
4213
|
start(claim) {
|
|
4169
|
-
finished =
|
|
4214
|
+
finished = traced(claim);
|
|
4170
4215
|
return finished;
|
|
4171
4216
|
},
|
|
4172
4217
|
async command(command) {
|
|
@@ -5,7 +5,7 @@ import type { Approvals } from "../approvals.js";
|
|
|
5
5
|
import type { installForClaim, installSettled } from "../harness-install.js";
|
|
6
6
|
import type { LiveHandover, LiveViewerStore } from "../browser-live.js";
|
|
7
7
|
import { type RunnerLive } from "../live-reach.js";
|
|
8
|
-
import { type PinnedModel, type Tier } from "../model.js";
|
|
8
|
+
import { type ModelRef, type PinnedModel, type Tier } from "../model.js";
|
|
9
9
|
import { type RunLaunch } from "../run-launch.js";
|
|
10
10
|
import type { Store } from "../store/store.js";
|
|
11
11
|
import { type ArgumentsOf, type Permission, type RunFiles, type SettingFrom, type ToolEffect } from "../tool-gate.js";
|
|
@@ -31,7 +31,7 @@ import { type RunComputerHold } from "./computer-journal.js";
|
|
|
31
31
|
import type { KeptKind, MadeKind, Replaced } from "../workspace/computer-for-claim.js";
|
|
32
32
|
import type { ShellPlace } from "../workspace/resolve-computer.js";
|
|
33
33
|
import type { Workspace } from "../workspace/workspace.js";
|
|
34
|
-
import { type HeldRedact } from "./redact.js";
|
|
34
|
+
import { type HeldRedact, type Redact } from "./redact.js";
|
|
35
35
|
import { type MonidFake } from "./monid-run.js";
|
|
36
36
|
/** What a claim gives the shared computerForClaim: the run, its epoch, the claim itself (a live view's row is fenced on it
|
|
37
37
|
* and names its runner), its revision, its place and any computer choice. */
|
|
@@ -166,26 +166,53 @@ export interface AdapterSpecDeps {
|
|
|
166
166
|
* case, and its harness's own search is never offered (web-fake.ts, fakedPlane). `now`: its clock, the date and time it
|
|
167
167
|
* is told wherever it reads "now" (environment.ts environmentLine, claude-agent's turn date); absent, the real clock.
|
|
168
168
|
* `monid`: its monid endpoints answer as monid unreachable does, never sent (monid-run.ts monidForClaim). `email`: the
|
|
169
|
-
* case's fake mail account's servers (eval-mailbox.ts), the only account its email tools open (email/tools.ts).
|
|
169
|
+
* case's fake mail account's servers (eval-mailbox.ts), the only account its email tools open (email/tools.ts). `files`:
|
|
170
|
+
* the case's files, by their path in the run's work folder, written there at its claim (seedEvalFiles). */
|
|
170
171
|
export type EvalFakes = {
|
|
171
172
|
readonly web?: WebFake;
|
|
172
173
|
readonly now?: Date;
|
|
173
174
|
readonly monid?: MonidFake;
|
|
174
175
|
readonly email?: EmailFake;
|
|
176
|
+
readonly files?: Readonly<Record<string, string>>;
|
|
175
177
|
};
|
|
178
|
+
/** A template eval case's files (EvalFakes.files) written into the run's work folder at its claim, after its inputs and
|
|
179
|
+
* before its computer and its first turn, so they reach a computer's /workspace as its uploads do. Each one the folder
|
|
180
|
+
* does not hold yet: a claim that resumes the run keeps what the run made of it. A write that fails ends the run failed,
|
|
181
|
+
* saying which file. */
|
|
182
|
+
export declare function seedEvalFiles(workspace: Workspace, files: Readonly<Record<string, string>> | undefined): Promise<void>;
|
|
176
183
|
/** A model as the cap prices it, from the route's catalog cost: its price WITH TIERS (the money rule — a request past a
|
|
177
184
|
* model's tier is held and booked at the tier, as main's calculateCost does). `api` is the proxy's shape, for the
|
|
178
185
|
* overhead its provider adds; the output ceiling is the route's when it carries one, else none. */
|
|
179
186
|
export declare function capModelOf(route: ModelRoute): CapModel;
|
|
187
|
+
/** The model of a held run its model kept from running at its create (run-launch.ts hold.refused): as its revision names
|
|
188
|
+
* it (`provider/model-id`). Its launch pins none (runs-over-store.ts skips modelOf for it). Nothing chooses it and
|
|
189
|
+
* nothing prices it. */
|
|
190
|
+
export declare function heldModelOf(ref: string | undefined): ModelRef;
|
|
191
|
+
/** The route of a held run its model kept from running at its create (run-launch.ts hold.refused): its provider is the
|
|
192
|
+
* stand-in (provider.ts heldRefusedProvider), so a host with no key for its model still opens its claim and holds its
|
|
193
|
+
* computer. Its agent never starts (its start and every message are refused in `why`, its create's words:
|
|
194
|
+
* computer-held.ts), and a request that reached its proxy anyway is refused in them too, and never sent. */
|
|
195
|
+
export declare function heldRefusedRoute(model: ModelRef, why: string): ModelRoute;
|
|
180
196
|
/** Particle requests are never automatically replayed after an uncertain failure. Retry is a harness-wide setting,
|
|
181
197
|
* so a claim with any Particle route disables it for all its conversations, including subagents on other tiers. */
|
|
182
198
|
export declare function modelRetryOf(routes: Iterable<Pick<ModelRoute, "like">>): Pick<AdapterRunSpec, "retry">;
|
|
199
|
+
/** A model route as the run's GenAI trace names it: its provider, the host its requests go to, its model. A route that
|
|
200
|
+
* translates its model's requests (its own `fetch`) is named by its upstream's host (ModelRoute.upstreamOrigin), never
|
|
201
|
+
* its proxy's placeholder origin; one whose upstream is unknown names no host. */
|
|
202
|
+
export declare const traceOfRoute: (route: ModelRoute) => import("../otel/genai.js").RouteTrace;
|
|
203
|
+
/** The model a replay run's or an audit shadow's grader runs on (graderRouteOf): the revision's modelTiers.fast, else
|
|
204
|
+
* `env`'s fast tier (AGENT_MODEL_FAST); undefined when there is neither, or the revision names agree_on (no grader). */
|
|
205
|
+
export declare function graderModelOf(body: {
|
|
206
|
+
readonly modelTiers?: Readonly<Partial<Record<SubagentTier, string>>>;
|
|
207
|
+
readonly learning?: unknown;
|
|
208
|
+
}, env: NodeJS.ProcessEnv): string | undefined;
|
|
183
209
|
/** A replay run's or an audit shadow's grader route (runner/compare-end.ts): its fast model (the revision's
|
|
184
210
|
* modelTiers.fast, else AGENT_MODEL_FAST) when its revision names no agree_on, on pi's wires. A fast model may be another
|
|
185
211
|
* provider's than the run's own, whose key claimSecrets never opened: so its route reads every model key the server
|
|
186
|
-
* holds (savedModelKeys) as a subagent's tier does, held by the run's redactor, on the route's env alone
|
|
187
|
-
*
|
|
188
|
-
*
|
|
212
|
+
* holds (savedModelKeys) as a subagent's tier does, held by the run's redactor, on the route's env alone; in a run's own
|
|
213
|
+
* process its runner hands it the fast model's provider's keys alone (run-child-host.ts savedModelKeys, graderModelOf). A
|
|
214
|
+
* run with its own model key carries that key, and no saved key is read. Undefined when there is no fast model, the
|
|
215
|
+
* revision names agree_on, or no route can be made (logged: the pair is then compared whole). */
|
|
189
216
|
export declare function graderRouteOf(body: {
|
|
190
217
|
readonly modelTiers?: Readonly<Partial<Record<SubagentTier, string>>>;
|
|
191
218
|
readonly learning?: unknown;
|
|
@@ -219,6 +246,11 @@ export declare function modelAskOf(pinned: {
|
|
|
219
246
|
*
|
|
220
247
|
* Whether anyone can answer an ask is the store's too (server-approvers.ts), read once at the claim: no one (the
|
|
221
248
|
* server's accounts off), an asked call is refused at once in words, never parked.
|
|
249
|
+
*
|
|
250
|
+
* The run's computer once off for the run (RunGate.computerOff): a call of its tools is refused before any settings read.
|
|
251
|
+
* `turnedOff`: an earlier claim turned it off (computer-journal.ts computerTurnedOff), so this claim's gate starts off.
|
|
252
|
+
* `onComputerOff`: told the computer's kind, and awaited, when this claim's first deny of a call of its tools turns it off,
|
|
253
|
+
* for the run's journal (computer-journal.ts recordComputerOff), so a later claim starts it off too.
|
|
222
254
|
*/
|
|
223
255
|
/** The run's tool permissions as a learned workflow's call nodes are held to them (learned-workflow.ts policy, denyFrom,
|
|
224
256
|
* refresh): the same gate as the run's own calls, its settings read again from the store before each call node. */
|
|
@@ -238,6 +270,8 @@ export declare function adapterRunGate(store: Pick<Store, "settings">, claim: Pi
|
|
|
238
270
|
readonly effectOf?: (name: string) => ToolEffect | undefined;
|
|
239
271
|
readonly argumentsOf?: ArgumentsOf;
|
|
240
272
|
readonly facts: AdapterFacts | undefined;
|
|
273
|
+
readonly turnedOff?: boolean;
|
|
274
|
+
readonly onComputerOff?: (kind: string) => Promise<void>;
|
|
241
275
|
}): Promise<NonNullable<AdapterRunSpec["gate"]> & {
|
|
242
276
|
readonly permissions: RunPermissions;
|
|
243
277
|
readonly learn: (flows: readonly LearnedWorkflow[]) => void;
|
|
@@ -323,8 +357,11 @@ export declare function liveViewersOf(store: LiveViewerStore, sealKey: Buffer |
|
|
|
323
357
|
};
|
|
324
358
|
/** `tool` with its answer's text, and a throw's message, cut by `cut` (the run's one redactor). A web call's answer is cut
|
|
325
359
|
* string by string inside its JSON (timeline/web-calls.ts webCut), so what the harness stores still parses and keeps
|
|
326
|
-
* its links whole for a grader's link check
|
|
327
|
-
|
|
360
|
+
* its links whole for a grader's link check; one whose strings, read joined, hold a held value no cut in place takes (a
|
|
361
|
+
* value split across two of them) is "[redacted]" (webHeld). The join is read against the values `cut` holds
|
|
362
|
+
* (key-refusal.ts withheldWhole), or through `cut` itself when it does not know them (joinCut). Each string is cut once
|
|
363
|
+
* in a call, for the join's read and the answer both. */
|
|
364
|
+
export declare function answersCut(tool: HostTool, cut: Redact): HostTool;
|
|
328
365
|
/** The ToolHost a run's non-hand tools bind through, the one both the pi spec and the CLI spec build: the run's folder and
|
|
329
366
|
* the claim's environment (claim-secrets.ts: the run's keys from the store, its plane set), the run's registry for an
|
|
330
367
|
* extension a binding installs, the install lifecycle (`life`, run by the adapter loop from the spec's `lifecycle`), the
|