@parcha/agentrun-serve 0.1.0-beta.50 → 0.1.0-beta.52
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 +185 -0
- package/README.md +236 -30
- package/dist/adapters.js +1 -1
- package/dist/agent-delete.d.ts +13 -2
- package/dist/agent-delete.js +14 -5
- package/dist/agents-store.d.ts +5 -1
- package/dist/agents-store.js +17 -7
- package/dist/api-only.d.ts +6 -3
- package/dist/api-only.js +8 -5
- package/dist/archil-routes.d.ts +1 -0
- package/dist/archil-routes.js +28 -2
- package/dist/capacity.d.ts +50 -0
- package/dist/capacity.js +49 -0
- package/dist/cli-learning/claude-wire.d.ts +41 -0
- package/dist/cli-learning/claude-wire.js +258 -0
- package/dist/cli-learning/cli.d.ts +11 -0
- package/dist/cli-learning/cli.js +241 -0
- package/dist/cli-learning/codex-worktree.d.ts +10 -0
- package/dist/cli-learning/codex-worktree.js +119 -0
- package/dist/cli-learning/connections.d.ts +62 -0
- package/dist/cli-learning/connections.js +87 -0
- package/dist/cli-learning/entry.d.ts +1 -0
- package/dist/cli-learning/entry.js +4 -0
- package/dist/cli-learning/evidence.d.ts +78 -0
- package/dist/cli-learning/evidence.js +492 -0
- package/dist/cli-learning/hook.d.ts +33 -0
- package/dist/cli-learning/hook.js +544 -0
- package/dist/cli-learning/install.d.ts +33 -0
- package/dist/cli-learning/install.js +335 -0
- package/dist/cli-learning/observation-proof.d.ts +14 -0
- package/dist/cli-learning/observation-proof.js +10 -0
- package/dist/cli-learning/policy.d.ts +48 -0
- package/dist/cli-learning/policy.js +363 -0
- package/dist/cli-learning/schema.d.ts +16 -0
- package/dist/cli-learning/schema.js +27 -0
- package/dist/cli-learning/state.d.ts +23 -0
- package/dist/cli-learning/state.js +61 -0
- package/dist/cli.js +24 -2
- package/dist/computer-setting.d.ts +8 -0
- package/dist/computer-setting.js +11 -0
- package/dist/computers.d.ts +6 -2
- package/dist/computers.js +2 -2
- package/dist/console/assets/index-B-D0EM3j.js +733 -0
- package/dist/console/assets/{index-D0mr9wfZ.css → index-DlQepP2J.css} +1 -1
- package/dist/console/index.html +2 -2
- package/dist/email/email-faux.d.ts +3 -1
- package/dist/email/email-faux.js +3 -2
- package/dist/email/routes.js +22 -12
- package/dist/fal-price.d.ts +76 -0
- package/dist/fal-price.js +368 -0
- package/dist/harness-install.d.ts +6 -2
- package/dist/harness-install.js +40 -8
- package/dist/harness.d.ts +1 -1
- package/dist/harness.js +2 -2
- package/dist/learn/commit.d.ts +5 -0
- package/dist/learn/commit.js +4 -1
- package/dist/learn/compile.d.ts +13 -5
- package/dist/learn/compile.js +24 -7
- package/dist/learn/delete.d.ts +12 -6
- package/dist/learn/delete.js +17 -11
- package/dist/learn/folder.d.ts +11 -0
- package/dist/learn/folder.js +20 -3
- package/dist/learn/learning-of.d.ts +8 -0
- package/dist/learn/learning-of.js +8 -0
- package/dist/learn/learning.sh +14 -1
- package/dist/learn/promote.d.ts +51 -7
- package/dist/learn/promote.js +51 -8
- package/dist/learn/secrets.js +14 -3
- package/dist/learning-reset.d.ts +18 -0
- package/dist/learning-reset.js +115 -0
- package/dist/learning-routes.d.ts +1 -1
- package/dist/learning-words.d.ts +6 -1
- package/dist/learning-words.js +6 -1
- package/dist/learning.d.ts +8 -6
- package/dist/learning.js +5 -4
- package/dist/llms.txt +1 -0
- package/dist/mcp-gateway.d.ts +39 -2
- package/dist/mcp-gateway.js +41 -10
- package/dist/mcp-pin-first.js +3 -2
- package/dist/mcp-private-hosts.d.ts +24 -3
- package/dist/mcp-private-hosts.js +53 -3
- package/dist/mcp-servers-store.d.ts +1 -0
- package/dist/mcp-servers-store.js +2 -1
- package/dist/media-duration.d.ts +2 -0
- package/dist/media-duration.js +136 -0
- package/dist/model-gateway.d.ts +2 -0
- package/dist/model-gateway.js +3 -1
- package/dist/native/runtimes.d.ts +2 -0
- package/dist/native/runtimes.js +2 -0
- package/dist/observation/learning.d.ts +32 -0
- package/dist/observation/learning.js +66 -0
- package/dist/observation/observer.d.ts +8 -1
- package/dist/observation/observer.js +89 -9
- package/dist/observation/schema.js +12 -4
- package/dist/observation/usage-identity.d.ts +9 -0
- package/dist/observation/usage-identity.js +11 -0
- package/dist/openapi.js +133 -24
- package/dist/provider.d.ts +8 -0
- package/dist/provider.js +14 -2
- package/dist/refusal-words.d.ts +0 -3
- package/dist/refusal-words.js +0 -3
- package/dist/request-metadata.d.ts +20 -0
- package/dist/request-metadata.js +24 -0
- package/dist/run-launch.d.ts +27 -4
- package/dist/run-launch.js +18 -3
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-usage.d.ts +48 -4
- package/dist/run-usage.js +156 -39
- package/dist/run-view.d.ts +2 -0
- package/dist/run-view.js +8 -7
- package/dist/runner/adapter-loop.d.ts +3 -1
- package/dist/runner/adapter-loop.js +41 -35
- package/dist/runner/adapter-run-spec.d.ts +1 -1
- package/dist/runner/adapter-run-spec.js +15 -15
- package/dist/runner/audit.d.ts +8 -3
- package/dist/runner/audit.js +21 -6
- package/dist/runner/beside.d.ts +13 -0
- package/dist/runner/beside.js +27 -8
- package/dist/runner/claim-secrets.d.ts +2 -1
- package/dist/runner/claim-secrets.js +5 -3
- package/dist/runner/cli-run-spec.d.ts +1 -1
- package/dist/runner/cli-run-spec.js +14 -13
- package/dist/runner/conformance/harness.js +4 -2
- package/dist/runner/disk-free.d.ts +44 -0
- package/dist/runner/disk-free.js +96 -0
- package/dist/runner/dispatch.js +4 -2
- package/dist/runner/feedback-round.d.ts +12 -8
- package/dist/runner/feedback-round.js +16 -30
- package/dist/runner/harness-loops.js +8 -3
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/learning-end.d.ts +2 -1
- package/dist/runner/learning-end.js +51 -22
- package/dist/runner/main.d.ts +17 -6
- package/dist/runner/main.js +187 -45
- package/dist/runner/mcp-claim.js +1 -1
- package/dist/runner/mcp-run.d.ts +9 -0
- package/dist/runner/mcp-run.js +16 -1
- package/dist/runner/model-route.js +7 -4
- package/dist/runner/presence.d.ts +11 -2
- package/dist/runner/presence.js +31 -3
- package/dist/runner/promotion.d.ts +40 -21
- package/dist/runner/promotion.js +130 -59
- package/dist/runner/run-child-host.d.ts +12 -15
- package/dist/runner/run-child-host.js +52 -112
- package/dist/runner/run-errors.js +2 -0
- package/dist/runner/runner-check.d.ts +51 -0
- package/dist/runner/runner-check.js +206 -0
- package/dist/runner/runner-metrics.d.ts +19 -0
- package/dist/runner/runner-metrics.js +49 -0
- package/dist/runner/runner.d.ts +37 -0
- package/dist/runner/runner.js +58 -6
- package/dist/runner/sdk-loop.d.ts +2 -2
- package/dist/runner/sdk-loop.js +37 -25
- package/dist/runner/store-port.d.ts +3 -0
- package/dist/runner/workflow-spec.js +3 -3
- package/dist/runs-over-store.d.ts +13 -3
- package/dist/runs-over-store.js +71 -16
- package/dist/sdk/check.d.ts +6 -5
- package/dist/sdk/check.js +17 -16
- package/dist/sdk/runs.d.ts +22 -2
- package/dist/sdk/runs.js +167 -82
- package/dist/server.d.ts +3 -0
- package/dist/server.js +230 -43
- package/dist/skills/agentrun-serve/SKILL.md +52 -7
- package/dist/start-switches.js +2 -0
- package/dist/stats.d.ts +4 -0
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.d.ts +16 -0
- package/dist/store/agent-body.js +20 -3
- package/dist/store/dialect.d.ts +2 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.d.ts +2 -0
- package/dist/store/journal/storage.js +2 -1
- package/dist/store/postgres/connection.d.ts +5 -2
- package/dist/store/postgres/connection.js +19 -7
- package/dist/store/postgres/dialect.js +1 -0
- package/dist/store/postgres/migrate.d.ts +30 -0
- package/dist/store/postgres/migrate.js +72 -5
- package/dist/store/postgres/migration-lint.d.ts +8 -0
- package/dist/store/postgres/migration-lint.js +119 -0
- package/dist/store/postgres/migrations/0024_runner_capacity.sql +28 -0
- package/dist/store/postgres/migrations/0025_run_attempts.sql +27 -0
- package/dist/store/postgres/migrations/0026_run_disk.sql +23 -0
- package/dist/store/postgres/store.d.ts +8 -3
- package/dist/store/postgres/store.js +31 -11
- package/dist/store/schema.d.ts +32 -2
- package/dist/store/schema.js +74 -5
- package/dist/store/sqlite/run-launch.d.ts +31 -1
- package/dist/store/sqlite/run-launch.js +111 -2
- package/dist/store/sqlite/run-patch.d.ts +2 -1
- package/dist/store/sqlite/run-patch.js +4 -3
- package/dist/store/sqlite/store.d.ts +17 -0
- package/dist/store/sqlite/store.js +226 -37
- package/dist/store/store-schema.d.ts +34 -0
- package/dist/store/store-schema.js +125 -0
- package/dist/store/store.d.ts +120 -5
- package/dist/store/store.js +13 -0
- package/dist/store-reads/analytics.d.ts +3 -2
- package/dist/store-reads/analytics.js +20 -8
- package/dist/store-reads/learning.d.ts +12 -8
- package/dist/store-reads/learning.js +33 -24
- package/dist/store-reads/loop.d.ts +4 -3
- package/dist/store-reads/loop.js +7 -5
- package/dist/store-view.d.ts +4 -3
- package/dist/store-view.js +11 -7
- package/dist/template-eval.js +4 -4
- package/dist/templates.d.ts +6 -2
- package/dist/templates.js +7 -5
- package/dist/timeline/labels.js +1 -1
- package/dist/tool-gate.d.ts +4 -2
- package/dist/tools.js +1 -1
- package/dist/unified-usage.d.ts +24 -0
- package/dist/unified-usage.js +400 -0
- package/dist/uploads-archil.d.ts +100 -0
- package/dist/uploads-archil.js +431 -0
- package/dist/uploads.d.ts +52 -1
- package/dist/uploads.js +186 -108
- package/dist/validate.js +5 -1
- package/dist/web-save.d.ts +3 -0
- package/dist/web-save.js +17 -2
- package/dist/workspace/archil-disk.d.ts +6 -5
- package/dist/workspace/archil-disk.js +27 -12
- package/dist/workspace/archil-exec.js +1 -1
- package/dist/workspace/archil.js +4 -3
- package/dist/workspace/revision-skills.js +24 -11
- package/dist/workspace/synced-folder.d.ts +3 -3
- package/dist/workspace/synced-folder.js +7 -6
- package/package.json +10 -10
- package/skills/agentrun-serve/SKILL.md +52 -7
- package/dist/console/assets/index-D7G6o-1E.js +0 -720
package/dist/runs-over-store.js
CHANGED
|
@@ -26,6 +26,7 @@ import { resolvePlace } from "./place.js";
|
|
|
26
26
|
import { githubTargetOf } from "./github.js";
|
|
27
27
|
import { repoOf } from "./run-repo.js";
|
|
28
28
|
import { launchBody } from "./run-launch.js";
|
|
29
|
+
import { learningDiskOf } from "./learn/learning-of.js";
|
|
29
30
|
import { modelKeyRequired, serverKeyMissing } from "./run-model-key.js";
|
|
30
31
|
import { raiseFollowUpId } from "./run-view.js";
|
|
31
32
|
import { sendCommand } from "./runner/commands.js";
|
|
@@ -132,6 +133,8 @@ async function controlLaunchBody(store, runId) {
|
|
|
132
133
|
/** Only the application can abort its SDK and tools. An HTTP acknowledgement must not pretend that it did. */
|
|
133
134
|
async function refuseSdkStop(store, runId) {
|
|
134
135
|
const launch = await controlLaunchBody(store, runId);
|
|
136
|
+
if (isObject(launch) && launch.cli_learning)
|
|
137
|
+
throw new ApiError("not_continuable", "This run belongs to your existing CLI session. Stop it in that session; AgentRun does not control its execution.");
|
|
135
138
|
if (isObject(launch) && launch.sdk)
|
|
136
139
|
throw new ApiError("not_continuable", "This agent runs in your backend SDK. Cancel it using the original application's cancellation signal; its wrapper will report that outcome here.");
|
|
137
140
|
}
|
|
@@ -164,6 +167,8 @@ export async function message(store, moment, content, { requestId, answers = tru
|
|
|
164
167
|
if (moment.importedSource !== undefined)
|
|
165
168
|
throw importedRefusal(moment);
|
|
166
169
|
const launchBody = await controlLaunchBody(store, moment.id);
|
|
170
|
+
if (isObject(launchBody) && launchBody.cli_learning)
|
|
171
|
+
throw new ApiError("not_continuable", "Continue in the original CLI session.");
|
|
167
172
|
if (isObject(launchBody) && launchBody.sdk)
|
|
168
173
|
throw new ApiError("not_continuable", "Backend SDK runs are single-task sessions. Start a new SDK call for another task.");
|
|
169
174
|
if (nativeOf(launchBody))
|
|
@@ -410,8 +415,10 @@ const noShown = { text: (text) => text, name: (name) => name, holds: () => false
|
|
|
410
415
|
* null when its seed cannot be read (a learning fault never refuses a run). `use`: the run's start said `learning:
|
|
411
416
|
* "use"`, so it starts from what its agent learned, its revision's own learning aside, and keeps nothing. `noWorkflows`:
|
|
412
417
|
* a run never answered by a learned workflow nor asked to draft one (a native run's, an SDK run's with no workflow
|
|
413
|
-
* binding). `model`: an SDK run's compile model.
|
|
414
|
-
|
|
418
|
+
* binding). `model`: an SDK run's compile model. `disk`: the disk the run's launch names as its own (learn/learning-of.ts
|
|
419
|
+
* learningDiskOf), null for the default disk: a run on a named disk learns nothing, so it is never started from the
|
|
420
|
+
* folder seedFor reads (seedFailed `other_disk`: it starts with nothing learned). */
|
|
421
|
+
export async function learningStartFor(deps, entry, revision, rbody, { use = false, noWorkflows = false, model, disk }) {
|
|
415
422
|
// A run started with `learning: "use"` starts from what its agent learned whatever its revision says, and keeps
|
|
416
423
|
// nothing; the server's learning off still gives it nothing.
|
|
417
424
|
const learns = deps.learning !== undefined && deps.learning !== "off" && revision.kind === "agentic" && (learnsOf(rbody.learning) || use);
|
|
@@ -419,6 +426,9 @@ export async function learningStartFor(deps, entry, revision, rbody, { use = fal
|
|
|
419
426
|
return undefined;
|
|
420
427
|
const flows = noWorkflows || nativeOf(revision.body) ? { noWorkflows: true } : {};
|
|
421
428
|
const own = { ...flows, ...(use ? { use: true } : {}), ...(model ? { model } : {}) };
|
|
429
|
+
// Another disk's learning is never read for it: not its corrections, not its workflows.
|
|
430
|
+
if (disk !== null)
|
|
431
|
+
return { seed: null, section: "", seedFailed: "other_disk", ...own };
|
|
422
432
|
const seeded = await deps.seedFor(entry.agent.id);
|
|
423
433
|
// The folder could not be read (main's STOPPED.unreadable), or what it read could not be made into the start (main's
|
|
424
434
|
// copy that threw, STOPPED.notCopied): the run starts with nothing learned, and its learning end says which.
|
|
@@ -427,7 +437,7 @@ export async function learningStartFor(deps, entry, revision, rbody, { use = fal
|
|
|
427
437
|
try {
|
|
428
438
|
const shown = deps.shown ? deps.shown() : noShown;
|
|
429
439
|
const workflows = flows.noWorkflows ? [] : chooseWorkflows(seeded.seed, shown).flows.map(({ name }) => name);
|
|
430
|
-
return { seed: seeded.seed.sha, section: learnedSection(seeded.seed, shown), ...(workflows.length ? { workflows } : {}), ...own };
|
|
440
|
+
return { seed: seeded.seed.sha, section: learnedSection(seeded.seed, shown), ...(workflows.length ? { workflows } : {}), ...(seeded.seed.at !== undefined ? { seededAt: seeded.seed.at } : {}), ...own };
|
|
431
441
|
}
|
|
432
442
|
catch {
|
|
433
443
|
return { seed: null, section: "", seedFailed: "not_copied", ...own };
|
|
@@ -439,6 +449,8 @@ export async function learningStartFor(deps, entry, revision, rbody, { use = fal
|
|
|
439
449
|
* runner's. Under `origin`, a key that already started a run gets that run (the store's one-run-per-key), so a retry never
|
|
440
450
|
* starts a second. */
|
|
441
451
|
export async function startRun(store, deps, entry, body, { trigger, origin, capped = false, from, title, sealed } = {}) {
|
|
452
|
+
if (entry.revision?.body?.cli_learning)
|
|
453
|
+
throw new ApiError("agent_not_runnable", "Start the next prompt in your existing CLI session. AgentRun records its learning; it does not launch this connection.");
|
|
442
454
|
if (entry.revision?.body?.sdk)
|
|
443
455
|
throw new ApiError("agent_not_runnable", "This agent runs in your backend SDK. Start it through its SDK learning wrapper; AgentRun does not launch its tools or credentials.");
|
|
444
456
|
const { launch, revision } = await prepareLaunch(deps, entry, body, { ...(trigger ? { trigger } : {}), capped, ...(from ? { from } : {}), ...(title !== undefined ? { title } : {}) });
|
|
@@ -446,7 +458,7 @@ export async function startRun(store, deps, entry, body, { trigger, origin, capp
|
|
|
446
458
|
const runId = (deps.newRunId ?? uuidv7)();
|
|
447
459
|
try {
|
|
448
460
|
const labels = labelsOf(body.labels);
|
|
449
|
-
return await withHeldFiles(deps, runId, launch, () => store.runs.create({ id: runId, agentId: entry.agent.id, revisionId: revision.id, ...(origin ? { origin } : {}), ...(labels ? { labels } : {}) }, { body: launchBody(launch), ...(sealed ? { sealed: sealed(runId, launch, revision.kind) } : {}) }));
|
|
461
|
+
return await withHeldFiles(deps, runId, entry.agent.id, launch, (launch) => store.runs.create({ id: runId, agentId: entry.agent.id, revisionId: revision.id, ...(origin ? { origin } : {}), ...(labels ? { labels } : {}) }, { body: launchBody(launch), ...(sealed ? { sealed: sealed(runId, launch, revision.kind) } : {}) }));
|
|
450
462
|
}
|
|
451
463
|
catch (error) {
|
|
452
464
|
// Only another writer of the store got here first under the same origin key: its run is the one asked for.
|
|
@@ -466,15 +478,30 @@ function keyedOrRefused(deps, launch, kind, sealed) {
|
|
|
466
478
|
if (!sealed && serverKeyMissing(deps.planeEnv(), { kind, model: launch.model, native: Boolean(launch.native) }))
|
|
467
479
|
throw modelKeyRequired(false);
|
|
468
480
|
}
|
|
469
|
-
/** Writes run `runId` with `write`, its files (launch.files) held for it first (StartDeps.files): a
|
|
470
|
-
* way, a write that fails, or one that answers another run (an origin key's run started before),
|
|
471
|
-
|
|
481
|
+
/** Writes run `runId` of agent `agentId` with `write`, its files (launch.files) held for it first (StartDeps.files): a
|
|
482
|
+
* hold that fails part way, a write that fails, or one that answers another run (an origin key's run started before),
|
|
483
|
+
* lets go of the hold. In Mode 2 they are placed in the run's folder instead (StartDeps.files.place), and the run is
|
|
484
|
+
* written with the launch that says so; the same failures undo the placing. */
|
|
485
|
+
async function withHeldFiles(deps, runId, agentId, launch, write) {
|
|
472
486
|
const ids = launch.files ?? [];
|
|
473
487
|
if (!ids.length || !deps.files)
|
|
474
|
-
return await write();
|
|
488
|
+
return await write(launch);
|
|
489
|
+
const placed = await deps.files.place?.(runId, agentId, launch);
|
|
490
|
+
if (placed) {
|
|
491
|
+
try {
|
|
492
|
+
const row = await write(placed.launch);
|
|
493
|
+
if (row.id !== runId)
|
|
494
|
+
await placed.undo();
|
|
495
|
+
return row;
|
|
496
|
+
}
|
|
497
|
+
catch (error) {
|
|
498
|
+
await placed.undo().catch(() => undefined);
|
|
499
|
+
throw error;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
475
502
|
try {
|
|
476
503
|
await deps.files.hold(runId, ids);
|
|
477
|
-
const row = await write();
|
|
504
|
+
const row = await write(launch);
|
|
478
505
|
if (row.id !== runId)
|
|
479
506
|
await deps.files.release(runId);
|
|
480
507
|
return row;
|
|
@@ -492,7 +519,34 @@ const bodyConflict = ({ source, kind, id, version }) => new ApiError("external_b
|
|
|
492
519
|
* agent already mapped to the reference is the run's (its id, its learning), so a run of a later version learns from the
|
|
493
520
|
* earlier ones. A different definition under a version already run is 409 external_body_conflict, nothing written; under
|
|
494
521
|
* `origin`, a key that already started a run gets that run, as startRun's. */
|
|
495
|
-
export async function startInline(store, deps, inline, body,
|
|
522
|
+
export async function startInline(store, deps, inline, body, options = {}) {
|
|
523
|
+
const ref = externalKey(inline.external);
|
|
524
|
+
// A reference's first starts that overlap in this server share one agent id: each prepares its launch, and in Mode 2
|
|
525
|
+
// places its files (uploads-archil.ts place), under the id the agent is written with, whichever start's transaction
|
|
526
|
+
// writes it (createInline writes the agent once per reference and reads it back). They run at once; none waits on
|
|
527
|
+
// another. (One server writes a store: its owner lock.)
|
|
528
|
+
let tentative = tentativeAgents.get(ref);
|
|
529
|
+
if (!tentative)
|
|
530
|
+
tentativeAgents.set(ref, (tentative = { id: uuidv7(), starts: 0 }));
|
|
531
|
+
tentative.starts += 1;
|
|
532
|
+
let written = false;
|
|
533
|
+
try {
|
|
534
|
+
const row = await startInlineOnce(store, deps, inline, body, options, tentative.id);
|
|
535
|
+
written = true;
|
|
536
|
+
return row;
|
|
537
|
+
}
|
|
538
|
+
finally {
|
|
539
|
+
tentative.starts -= 1;
|
|
540
|
+
// A first start that failed keeps the id for its reference: what it made under it (in Mode 2, the agent's disk, made
|
|
541
|
+
// before the agent is written) is found again by the next start, never made anew. Once a start is written, the
|
|
542
|
+
// reference maps to its agent and the id is let go.
|
|
543
|
+
if (tentative.starts === 0 && written && tentativeAgents.get(ref) === tentative)
|
|
544
|
+
tentativeAgents.delete(ref);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
/** The agent id each reference's first starts in progress share, and a failed first start's kept (startInline). */
|
|
548
|
+
const tentativeAgents = new Map();
|
|
549
|
+
async function startInlineOnce(store, deps, inline, body, { origin, sealed }, newAgentId) {
|
|
496
550
|
const { external, revision, stored: storedRevision } = inline;
|
|
497
551
|
const ref = externalKey(external);
|
|
498
552
|
// A version's body never changes here: a different one is refused before anything else is read or written.
|
|
@@ -511,7 +565,7 @@ export async function startInline(store, deps, inline, body, { origin, sealed }
|
|
|
511
565
|
const entry = stored
|
|
512
566
|
? firstOfVersion ? { ...stored, agent: { ...stored.agent, name: inline.name, description: inline.description } } : stored
|
|
513
567
|
: {
|
|
514
|
-
agent: { id:
|
|
568
|
+
agent: { id: newAgentId, name: inline.name, description: inline.description, currentRevision: null, createdAt: Date.now(), archivedAt: null, externalRef: ref, purgedAt: null },
|
|
515
569
|
revision: null, version: 0, revisions: 0, sizes: new Map(),
|
|
516
570
|
};
|
|
517
571
|
// A store revision is the revision the run path reads as a pi Revision (its body is the revision body), as pinnedOf hands
|
|
@@ -521,7 +575,7 @@ export async function startInline(store, deps, inline, body, { origin, sealed }
|
|
|
521
575
|
const runId = (deps.newRunId ?? uuidv7)();
|
|
522
576
|
const labels = labelsOf(body.labels);
|
|
523
577
|
try {
|
|
524
|
-
return await withHeldFiles(deps, runId, launch, () => store.runs.createInline({
|
|
578
|
+
return await withHeldFiles(deps, runId, entry.agent.id, launch, (launch) => store.runs.createInline({
|
|
525
579
|
agent: { id: entry.agent.id, name: inline.name, description: inline.description, ref },
|
|
526
580
|
revision: { id: revision.id, version: external.version, kind: revision.kind, body: revision.body, skills: revision.skills, ...(revision.note !== undefined ? { note: revision.note } : {}), ...(revision.mcpPin !== undefined ? { mcpPin: revision.mcpPin } : {}), ...(revision.monidPin !== undefined ? { monidPin: revision.monidPin } : {}) },
|
|
527
581
|
run: { id: runId, ...(origin ? { origin } : {}), ...(labels ? { labels } : {}) },
|
|
@@ -608,16 +662,17 @@ export async function prepareLaunch(deps, entry, body, { trigger, capped = false
|
|
|
608
662
|
const plane = tooling ? planeFor(deps.planeEnv(), tooling, deps.toolSettings(), { capped: cap !== undefined, run: true }) : {};
|
|
609
663
|
// The run's model, resolved once, at start (the runner reads launch.model only).
|
|
610
664
|
const model = await deps.modelOf(entry, revision);
|
|
611
|
-
// The run's learning start, decided here: a run learns when the server's learning is on and its revision says so; then
|
|
612
|
-
// its seed is read now and its # Learned text pinned in the launch for the runner to put in the prompt. A seed that
|
|
613
|
-
// cannot be read starts it with nothing (seed null); the end state is the runner's.
|
|
614
|
-
const learning = await learningStartFor(deps, entry, revision, rbody, { use: body.learning === RUN_LEARNING_USE });
|
|
615
665
|
// The run's Archil disk, chosen now and kept in its launch (run-launch.ts archilDisk): the one the body names (a disk per
|
|
616
666
|
// customer), else its agent's when it has one; with neither, its claim makes the agent's.
|
|
617
667
|
const named = isObject(body.archil_disk) && typeof body.archil_disk.disk_id === "string" ? body.archil_disk.disk_id : undefined;
|
|
618
668
|
if (named !== undefined && !deps.launchDiskOf)
|
|
619
669
|
throw invalid([{ field: "archil_disk", reason: "not_allowed", message: "This server keeps no run on an Archil disk." }]);
|
|
620
670
|
const archilDisk = deps.launchDiskOf ? await deps.launchDiskOf(entry.agent.id, named) : undefined;
|
|
671
|
+
// The run's learning start, decided here: a run learns when the server's learning is on and its revision says so; then
|
|
672
|
+
// its seed is read now and its # Learned text pinned in the launch for the runner to put in the prompt. A seed that
|
|
673
|
+
// cannot be read starts it with nothing (seed null); the end state is the runner's. Its learning is its disk's: a run on
|
|
674
|
+
// a disk its launch names is never started from the default disk's.
|
|
675
|
+
const learning = await learningStartFor(deps, entry, revision, rbody, { use: body.learning === RUN_LEARNING_USE, disk: archilDisk ? learningDiskOf({ archilDisk }) : null });
|
|
621
676
|
// The run's effort: its own, else its revision's saved thinking, else the host's AGENT_THINKING (each a thinking level,
|
|
622
677
|
// else none). Nothing set: none, so the run gets no effort note and its harness's own default. Kept in its launch, so
|
|
623
678
|
// its harness's thinking, its guidance and its metrics all read the one value.
|
package/dist/sdk/check.d.ts
CHANGED
|
@@ -16,11 +16,12 @@ export type SdkWorkflowCheckEvent = {
|
|
|
16
16
|
/** Fresh read-only calls the shadow made where the native recording had no result (the client's shadowReadFallback). */
|
|
17
17
|
fresh_reads?: number;
|
|
18
18
|
};
|
|
19
|
-
/** Settles a connected agent's
|
|
20
|
-
* immutable completion is the baseline. A shadow that answered or handed back on a valid native turn is one row of
|
|
21
|
-
* check (
|
|
22
|
-
*
|
|
23
|
-
*
|
|
19
|
+
/** Settles a connected agent's reserved turn at its run's end. The client reports execution, never its own verdict, and
|
|
20
|
+
* the immutable completion is the baseline. A shadow that answered or handed back on a valid native turn is one row of
|
|
21
|
+
* the check (sdkCheckTurn: kept until the check holds compile_after rows, the one that makes compile_after deciding on
|
|
22
|
+
* them all); any other turn is given back (releaseSdkCheck) and the check waits for the next turn; a turn the backend
|
|
23
|
+
* never completed before its inbox expired is one failed row (sdkCheckDeadline). Exact retries and reclaims compete on
|
|
24
|
+
* the reservation. */
|
|
24
25
|
export declare function settleSdkCheck(deps: {
|
|
25
26
|
store: Store;
|
|
26
27
|
agentId: string;
|
package/dist/sdk/check.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { releaseSdkCheck, sdkCheckDeadline, sdkCheckTurn, sdkInputText } from "../runner/promotion.js";
|
|
2
2
|
import { promotionOf, promotionsOf } from "../learn/promote.js";
|
|
3
3
|
/** Why a completed inbox's native turn cannot be its check's baseline, or undefined when it can: a completed turn with
|
|
4
4
|
* complete, unredacted evidence and no learned workflow or nested call in it, whose shadow answered or handed back. */
|
|
@@ -20,11 +20,12 @@ function notBaseline(inbox, reported) {
|
|
|
20
20
|
return `its shadow stopped at a write the native turn did not make (${reported.skipped?.tool ?? "a tool"})`;
|
|
21
21
|
return undefined;
|
|
22
22
|
}
|
|
23
|
-
/** Settles a connected agent's
|
|
24
|
-
* immutable completion is the baseline. A shadow that answered or handed back on a valid native turn is one row of
|
|
25
|
-
* check (
|
|
26
|
-
*
|
|
27
|
-
*
|
|
23
|
+
/** Settles a connected agent's reserved turn at its run's end. The client reports execution, never its own verdict, and
|
|
24
|
+
* the immutable completion is the baseline. A shadow that answered or handed back on a valid native turn is one row of
|
|
25
|
+
* the check (sdkCheckTurn: kept until the check holds compile_after rows, the one that makes compile_after deciding on
|
|
26
|
+
* them all); any other turn is given back (releaseSdkCheck) and the check waits for the next turn; a turn the backend
|
|
27
|
+
* never completed before its inbox expired is one failed row (sdkCheckDeadline). Exact retries and reclaims compete on
|
|
28
|
+
* the reservation. */
|
|
28
29
|
export async function settleSdkCheck(deps) {
|
|
29
30
|
const { inbox } = deps;
|
|
30
31
|
const check = inbox.learning_check;
|
|
@@ -37,22 +38,22 @@ export async function settleSdkCheck(deps) {
|
|
|
37
38
|
if (!completion) {
|
|
38
39
|
if (inbox.closed === "expired")
|
|
39
40
|
return sdkCheckDeadline(deps, record);
|
|
41
|
+
// A cancel is a person's choice, not the integration failing to give a baseline: given back uncounted.
|
|
40
42
|
if (inbox.closed)
|
|
41
|
-
return releaseSdkCheck(deps, record, inbox.closed === "cancelled" ? "its native turn was stopped before the backend completed it" : "its native turn ended before the backend completed it");
|
|
43
|
+
return releaseSdkCheck(deps, record, inbox.closed === "cancelled" ? "its native turn was stopped before the backend completed it" : "its native turn ended before the backend completed it", inbox.closed !== "cancelled");
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
44
46
|
const reported = inbox.batches.flatMap((batch) => batch.events)
|
|
45
47
|
.find((event) => event.type === "workflow_check" && event.id === check.id && event.digest === check.digest);
|
|
46
48
|
const cause = notBaseline({ ...inbox, completion }, reported);
|
|
47
49
|
if (cause !== undefined || !reported)
|
|
48
|
-
return releaseSdkCheck(deps, record, cause ?? "the connected agent reported no shadow check");
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}], cost: null, outcomes, unstarted: 0, ...(reported.fresh_reads ? { fresh_reads: reported.fresh_reads } : {}),
|
|
50
|
+
return releaseSdkCheck(deps, record, cause ?? "the connected agent reported no shadow check", completion.status !== "cancelled");
|
|
51
|
+
return sdkCheckTurn(deps, { ...record, check: record.check }, {
|
|
52
|
+
of: inbox.run_id, input: sdkInputText(deps.launch), agent: completion.answer, outcome: reported.outcome,
|
|
53
|
+
answer: reported.outcome === "answered" ? reported.answer ?? null : null,
|
|
54
|
+
...(reported.outcome === "handed_back" ? { escalated: reported.reason ?? "The shadow workflow handed the task back." } : {}),
|
|
55
|
+
}, (was) => was?.decided === "replaying" && was.replay_id === check.id, {
|
|
56
|
+
...(reported.fresh_reads ? { fresh_reads: reported.fresh_reads } : {}),
|
|
56
57
|
exactMismatchReason: "its answer did not match the native answer exactly; connected SDK checks do not use a semantic grader, so name the fields that carry the decision (learning.agree_on) when whole-answer equality is not the intended check",
|
|
57
|
-
}
|
|
58
|
+
});
|
|
58
59
|
}
|
package/dist/sdk/runs.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Claim, RunOrigin, Store } from "../store/store.js";
|
|
2
2
|
import type { AgentEntry } from "../agents-store.js";
|
|
3
|
+
import { type RunLaunch } from "../run-launch.js";
|
|
3
4
|
import { type StartDeps } from "../runs-over-store.js";
|
|
4
5
|
import { type LearnedWorkflow } from "../learning.js";
|
|
5
6
|
import type { SdkWorkflowCheckEvent } from "./check.js";
|
|
@@ -19,6 +20,10 @@ export type SdkEvent = SdkWorkflowCheckEvent | {
|
|
|
19
20
|
} | {
|
|
20
21
|
type: "session";
|
|
21
22
|
session_id: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: "message";
|
|
25
|
+
role: "user" | "assistant";
|
|
26
|
+
text: string;
|
|
22
27
|
} | {
|
|
23
28
|
type: "tool";
|
|
24
29
|
id: string;
|
|
@@ -33,10 +38,22 @@ export type SdkCompletion = {
|
|
|
33
38
|
answer: string;
|
|
34
39
|
error?: string;
|
|
35
40
|
evidence_complete?: boolean;
|
|
41
|
+
seed_observed?: boolean;
|
|
42
|
+
seed_revision?: string;
|
|
43
|
+
/** Claude records the effective same-prompt policy only after UserPromptSubmit. */
|
|
44
|
+
source_policy?: {
|
|
45
|
+
instructions: string;
|
|
46
|
+
complete: boolean;
|
|
47
|
+
};
|
|
36
48
|
model?: string;
|
|
37
49
|
session_id?: string;
|
|
38
50
|
usage?: SdkUsage;
|
|
39
51
|
};
|
|
52
|
+
/** Claude's begin snapshot is provisional; only its immutable same-window completion can establish policy. */
|
|
53
|
+
export declare function cliPolicyOf(launch: RunLaunch, completion?: SdkCompletion): {
|
|
54
|
+
instructions: string;
|
|
55
|
+
complete: boolean;
|
|
56
|
+
} | undefined;
|
|
40
57
|
export type SdkInbox = {
|
|
41
58
|
run_id: string;
|
|
42
59
|
created_at: number;
|
|
@@ -52,6 +69,8 @@ export type SdkInbox = {
|
|
|
52
69
|
/** Server cleaning changed evidence: two different secret-bearing answers must never agree by their placeholder. */
|
|
53
70
|
check_redacted?: true;
|
|
54
71
|
completion?: SdkCompletion;
|
|
72
|
+
/** CLI source evidence was withheld by the redactor; never infer learning from that partial trace. */
|
|
73
|
+
evidence_incomplete?: true;
|
|
55
74
|
/** Internal terminal admission fence. No later evidence can be newly acknowledged after this CAS wins. */
|
|
56
75
|
closed?: "expired" | "failed" | "cancelled";
|
|
57
76
|
};
|
|
@@ -71,16 +90,17 @@ export declare class SdkRuns {
|
|
|
71
90
|
private readonly secret;
|
|
72
91
|
private readonly secrets;
|
|
73
92
|
private readonly earlier;
|
|
93
|
+
private readonly lane;
|
|
74
94
|
/** `earlier` are the keys credentials were once signed with (the server's API tokens, before `secret` was its seal
|
|
75
95
|
* key's): a credential any of them signed is still taken, so a run started before an upgrade keeps its credential. */
|
|
76
|
-
constructor(store: Store, data: string, secret: string, secrets?: () => readonly string[], earlier?: readonly string[]);
|
|
96
|
+
constructor(store: Store, data: string, secret: string, secrets?: () => readonly string[], earlier?: readonly string[], lane?: "sdk" | "cli");
|
|
77
97
|
token(runId: string): string;
|
|
78
98
|
authenticate(runId: string, token: string): Promise<void>;
|
|
79
99
|
private clean;
|
|
80
100
|
start(entry: AgentEntry, body: Record<string, unknown>, deps: StartDeps, origin: RunOrigin | undefined, compile: {
|
|
81
101
|
readonly model?: string;
|
|
82
102
|
check(model: string): Promise<void>;
|
|
83
|
-
}, consoleOrigin: string): Promise<{
|
|
103
|
+
}, consoleOrigin: string, cli?: NonNullable<RunLaunch["cli_learning"]>): Promise<{
|
|
84
104
|
run_id: string;
|
|
85
105
|
agent_id: string;
|
|
86
106
|
console_url: string;
|