@parcha/agentrun-serve 0.1.0-beta.44 → 0.1.0-beta.46
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 +148 -5
- package/README.md +385 -305
- package/dist/acp-package.d.ts +28 -0
- package/dist/acp-package.js +23 -0
- package/dist/adapter-facts.d.ts +8 -1
- package/dist/adapter-facts.js +9 -1
- package/dist/adapters.d.ts +5 -0
- package/dist/adapters.js +36 -3
- package/dist/agent-delete.d.ts +50 -0
- package/dist/agent-delete.js +125 -0
- package/dist/agents-store.d.ts +9 -3
- package/dist/agents-store.js +22 -8
- package/dist/agents.d.ts +5 -1
- package/dist/agents.js +8 -4
- package/dist/api-only.d.ts +8 -3
- package/dist/api-only.js +10 -4
- package/dist/archil-routes.d.ts +5 -1
- package/dist/archil-routes.js +57 -2
- package/dist/browser-wait-ended.d.ts +2 -0
- package/dist/browser-wait-ended.js +2 -0
- package/dist/calendar/ics-faux.d.ts +3 -1
- package/dist/calendar/ics-faux.js +12 -2
- package/dist/calendar/tools.js +5 -2
- package/dist/chatgpt-plan.js +3 -1
- package/dist/claude-login.d.ts +135 -0
- package/dist/claude-login.js +244 -0
- package/dist/cli.js +62 -19
- package/dist/composio-preset.js +69 -7
- package/dist/composio-triggers.d.ts +14 -0
- package/dist/composio-triggers.js +79 -15
- package/dist/computer-attach.d.ts +40 -5
- package/dist/computer-attach.js +130 -15
- package/dist/computer-keys.d.ts +3 -0
- package/dist/computer-keys.js +7 -1
- package/dist/computer-live.js +3 -2
- package/dist/computers.d.ts +21 -10
- package/dist/computers.js +39 -28
- package/dist/console/assets/index-C2MYaUBa.css +1 -0
- package/dist/console/assets/index-CZZeCReB.js +701 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/dial-relay.d.ts +29 -0
- package/dist/dial-relay.js +94 -0
- package/dist/email/tools.js +10 -5
- package/dist/env-proxy.d.ts +2 -0
- package/dist/env-proxy.js +35 -0
- package/dist/errors.d.ts +3 -1
- package/dist/errors.js +7 -4
- package/dist/faux-computers.d.ts +8 -2
- package/dist/faux-computers.js +83 -6
- package/dist/harness-archive.d.ts +67 -0
- package/dist/harness-archive.js +177 -0
- package/dist/harness-goose.d.ts +34 -0
- package/dist/harness-goose.js +87 -0
- package/dist/harness-install.d.ts +21 -0
- package/dist/harness-install.js +24 -11
- package/dist/harness-opencode/adapter.js +1 -1
- package/dist/harness-table.d.ts +9 -1
- package/dist/harness-table.js +20 -3
- package/dist/harness.d.ts +1 -2
- package/dist/harness.js +3 -4
- package/dist/host.js +2 -1
- package/dist/import.d.ts +10 -0
- package/dist/import.js +28 -8
- package/dist/key-check.js +3 -0
- package/dist/learn/audit.d.ts +6 -6
- package/dist/learn/audit.js +3 -7
- package/dist/learn/check.d.ts +23 -89
- package/dist/learn/check.js +57 -335
- package/dist/learn/commit.d.ts +63 -90
- package/dist/learn/commit.js +124 -316
- package/dist/learn/compile.d.ts +53 -50
- package/dist/learn/compile.js +89 -104
- package/dist/learn/corrections.d.ts +13 -0
- package/dist/learn/corrections.js +23 -0
- package/dist/learn/delete.d.ts +5 -5
- package/dist/learn/delete.js +8 -10
- package/dist/learn/folder.d.ts +35 -47
- package/dist/learn/folder.js +118 -134
- package/dist/learn/index.d.ts +3 -5
- package/dist/learn/index.js +6 -9
- package/dist/learn/learning.sh +45 -15
- package/dist/learn/promote.d.ts +23 -5
- package/dist/learn/promote.js +40 -2
- package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +30 -38
- package/dist/learn/{skills.js → workflow-draft.js} +48 -58
- package/dist/learn/workflow-nodes.js +1 -1
- package/dist/learned-workflow.js +2 -2
- package/dist/learning-cost.d.ts +38 -24
- package/dist/learning-cost.js +41 -24
- package/dist/learning-routes.d.ts +91 -170
- package/dist/learning-routes.js +183 -421
- package/dist/learning-run.d.ts +19 -40
- package/dist/learning-run.js +23 -93
- package/dist/learning-setting.d.ts +21 -10
- package/dist/learning-setting.js +47 -11
- package/dist/learning-words.d.ts +28 -74
- package/dist/learning-words.js +64 -162
- package/dist/learning.d.ts +61 -392
- package/dist/learning.js +101 -651
- package/dist/live-reach.d.ts +25 -2
- package/dist/live-reach.js +46 -4
- package/dist/llms.txt +1 -1
- package/dist/local-models.d.ts +3 -11
- package/dist/local-models.js +5 -6
- package/dist/mcp-servers-store.d.ts +4 -4
- package/dist/model-form.js +6 -5
- package/dist/model.d.ts +4 -0
- package/dist/model.js +26 -9
- package/dist/native/binding.js +1 -1
- package/dist/native/connection.js +1 -1
- package/dist/native/discovery.js +1 -1
- package/dist/native/instructions.d.ts +3 -0
- package/dist/native/instructions.js +5 -3
- package/dist/native/remote-worker-bridge.js +9 -43
- package/dist/native/remote.d.ts +8 -15
- package/dist/native/remote.js +3 -3
- package/dist/native/schema.js +1 -1
- package/dist/native/types.d.ts +2 -2
- package/dist/openapi.js +273 -319
- package/dist/paid-calls.d.ts +8 -0
- package/dist/paid-calls.js +20 -0
- package/dist/particle-provider.d.ts +11 -0
- package/dist/particle-provider.js +135 -0
- package/dist/port-models.d.ts +12 -4
- package/dist/port-models.js +28 -11
- package/dist/print.d.ts +27 -0
- package/dist/print.js +21 -0
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +15 -1
- package/dist/reflect-range.js +2 -3
- package/dist/run-launch.d.ts +14 -28
- package/dist/run-launch.js +9 -12
- package/dist/run-learning-served.d.ts +15 -89
- package/dist/run-listing.d.ts +34 -0
- package/dist/run-listing.js +128 -0
- package/dist/run-model-key.js +1 -1
- package/dist/run-timeline-served.js +5 -3
- package/dist/run-trace.d.ts +97 -0
- package/dist/run-trace.js +253 -0
- package/dist/run-view.d.ts +15 -0
- package/dist/run-view.js +9 -0
- package/dist/runnable.js +2 -1
- package/dist/runner/adapter-loop.d.ts +8 -6
- package/dist/runner/adapter-loop.js +16 -12
- package/dist/runner/adapter-run-spec.d.ts +16 -4
- package/dist/runner/adapter-run-spec.js +64 -58
- package/dist/runner/adapters/index.js +22 -0
- package/dist/runner/adapters/pi.d.ts +4 -12
- package/dist/runner/adapters/pi.js +2 -2
- package/dist/runner/audit.d.ts +1 -1
- package/dist/runner/audit.js +30 -13
- package/dist/runner/beside.d.ts +6 -2
- package/dist/runner/beside.js +38 -9
- package/dist/runner/claim-secrets.d.ts +18 -2
- package/dist/runner/claim-secrets.js +42 -18
- package/dist/runner/cli-run-spec.js +55 -51
- package/dist/runner/conformance/harness.d.ts +6 -0
- package/dist/runner/conformance/harness.js +35 -13
- package/dist/runner/conformance/subject.d.ts +6 -0
- package/dist/runner/dispatch.d.ts +2 -2
- package/dist/runner/end-of-run.d.ts +6 -14
- package/dist/runner/end-of-run.js +8 -33
- package/dist/runner/feedback-round.d.ts +2 -2
- package/dist/runner/feedback-round.js +7 -7
- package/dist/runner/github-app.js +3 -1
- package/dist/runner/harness-loops.d.ts +0 -8
- package/dist/runner/harness-loops.js +11 -59
- package/dist/runner/held.d.ts +170 -0
- package/dist/runner/held.js +57 -0
- package/dist/runner/journal-kinds.d.ts +2 -3
- package/dist/runner/journal-kinds.js +2 -3
- package/dist/runner/learned-first.d.ts +40 -0
- package/dist/runner/learned-first.js +32 -0
- package/dist/runner/learning-end.d.ts +77 -69
- package/dist/runner/learning-end.js +250 -303
- package/dist/runner/learning-seed.d.ts +15 -33
- package/dist/runner/learning-seed.js +24 -45
- package/dist/runner/loop-contract.d.ts +2 -3
- package/dist/runner/main.d.ts +17 -9
- package/dist/runner/main.js +82 -20
- package/dist/runner/mcp-run.d.ts +11 -0
- package/dist/runner/mcp-run.js +67 -0
- package/dist/runner/memory-claim.d.ts +10 -5
- package/dist/runner/memory-claim.js +12 -6
- package/dist/runner/model-route.d.ts +7 -4
- package/dist/runner/model-route.js +22 -10
- package/dist/runner/native-loop.d.ts +0 -7
- package/dist/runner/native-loop.js +9 -101
- package/dist/runner/promotion.d.ts +12 -8
- package/dist/runner/promotion.js +37 -28
- package/dist/runner/reflect-hook.d.ts +64 -95
- package/dist/runner/reflect-hook.js +112 -225
- package/dist/runner/run-channel.d.ts +43 -0
- package/dist/runner/run-channel.js +467 -0
- package/dist/runner/run-child-host.d.ts +169 -0
- package/dist/runner/run-child-host.js +1230 -0
- package/dist/runner/run-child.d.ts +1 -0
- package/dist/runner/run-child.js +254 -0
- package/dist/runner/run-errors.d.ts +2 -0
- package/dist/runner/run-errors.js +20 -0
- package/dist/runner/runner.js +1 -5
- package/dist/runner/sdk-ask.d.ts +78 -0
- package/dist/runner/sdk-ask.js +158 -0
- package/dist/runner/sdk-loop.d.ts +2 -4
- package/dist/runner/sdk-loop.js +29 -49
- package/dist/runner/store-secrets.d.ts +5 -3
- package/dist/runner/store-secrets.js +5 -1
- package/dist/runner/workflow-first.d.ts +5 -0
- package/dist/runner/workflow-first.js +4 -0
- package/dist/runner/workflow-spec.js +7 -2
- package/dist/runs-over-store.d.ts +16 -28
- package/dist/runs-over-store.js +31 -38
- package/dist/sdk/runs.d.ts +6 -11
- package/dist/sdk/runs.js +20 -41
- package/dist/sdk/schema.js +3 -4
- package/dist/seal-key.d.ts +5 -0
- package/dist/seal-key.js +7 -0
- package/dist/secrets.d.ts +3 -0
- package/dist/secrets.js +16 -3
- package/dist/server.d.ts +55 -33
- package/dist/server.js +689 -322
- package/dist/sign-ins-store.d.ts +8 -0
- package/dist/sign-ins-store.js +36 -1
- package/dist/skills.js +1 -1
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.js +3 -0
- package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
- package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
- package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
- package/dist/store/schema.d.ts +53 -4
- package/dist/store/schema.js +137 -6
- package/dist/store/sqlite/connection.d.ts +2 -0
- package/dist/store/sqlite/connection.js +3 -1
- package/dist/store/sqlite/run-patch.d.ts +0 -17
- package/dist/store/sqlite/run-patch.js +4 -33
- package/dist/store/sqlite/store.js +246 -63
- package/dist/store/sqlite/worker.js +25 -0
- package/dist/store/store.d.ts +193 -36
- package/dist/store/store.js +25 -3
- package/dist/store-reads/learning.d.ts +102 -204
- package/dist/store-reads/learning.js +159 -321
- package/dist/store-reads/loop.d.ts +0 -1
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-view.d.ts +29 -1
- package/dist/store-view.js +97 -31
- package/dist/template-eval.d.ts +3 -6
- package/dist/template-eval.js +22 -36
- package/dist/templates.d.ts +8 -4
- package/dist/templates.js +44 -6
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -1
- package/dist/timeline/timeline.js +16 -0
- package/dist/tool-gate.d.ts +0 -7
- package/dist/tool-gate.js +1 -15
- package/dist/tool-keys-store.d.ts +1 -1
- package/dist/tool-keys.d.ts +6 -4
- package/dist/tool-keys.js +12 -6
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +11 -4
- package/dist/triggers.d.ts +65 -6
- package/dist/triggers.js +125 -19
- package/dist/validate.js +1 -1
- package/dist/webhooks.d.ts +7 -2
- package/dist/webhooks.js +12 -5
- package/dist/workspace/agent-computer.d.ts +2 -0
- package/dist/workspace/agent-computer.js +2 -0
- package/dist/workspace/archil-claim.d.ts +7 -0
- package/dist/workspace/archil-claim.js +29 -0
- package/dist/workspace/archil.d.ts +9 -1
- package/dist/workspace/archil.js +165 -3
- package/dist/workspace/attach.d.ts +3 -1
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/attached-computers.d.ts +16 -5
- package/dist/workspace/attached-computers.js +25 -9
- package/dist/workspace/computer-deps.js +1 -1
- package/dist/workspace/computer-for-claim.d.ts +7 -3
- package/dist/workspace/computer-for-claim.js +119 -22
- package/dist/workspace/computer-hold.js +2 -1
- package/dist/workspace/computer-kept.d.ts +11 -1
- package/dist/workspace/computer-kept.js +24 -3
- package/dist/workspace/resolve-computer.d.ts +33 -19
- package/dist/workspace/resolve-computer.js +172 -64
- package/dist/workspace/revision-skills.d.ts +1 -2
- package/dist/workspace/revision-skills.js +3 -4
- package/dist/workspace/run-workspace.d.ts +1 -1
- package/dist/workspace/run-workspace.js +5 -0
- package/dist/workspace/synced-folder.d.ts +85 -0
- package/dist/workspace/synced-folder.js +230 -0
- package/dist/workspace/workspace.d.ts +4 -0
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -10
- package/templates/README.md +8 -8
- package/templates/inbound-lead/agent.md +5 -4
- package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
- package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
- package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
- package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
- package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
- package/templates/inbound-lead/lead.schema.json +6 -5
- package/templates/inbound-lead/rules/RUBRIC.md +4 -4
- package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
- package/templates/kyb/agent.md +2 -1
- package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
- package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
- package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
- package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
- package/templates/release-notes/evals/learned-style/case.yaml +4 -4
- package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
- package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
- package/templates/release-notes/evals/learned-style/prompt.md +1 -1
- package/dist/console/assets/index-BUktRvS-.css +0 -1
- package/dist/console/assets/index-nB9kTfIN.js +0 -711
- package/dist/learn/grade.d.ts +0 -138
- package/dist/learn/grade.js +0 -682
- package/dist/learn/notes.d.ts +0 -81
- package/dist/learn/notes.js +0 -178
- package/dist/learn/reflect.d.ts +0 -77
- package/dist/learn/reflect.js +0 -228
- package/dist/learn/relevance.d.ts +0 -24
- package/dist/learn/relevance.js +0 -91
- package/dist/learn/seed-check.d.ts +0 -74
- package/dist/learn/seed-check.js +0 -103
- package/dist/learning-batch.d.ts +0 -291
- package/dist/learning-batch.js +0 -600
- package/dist/learning-evals.d.ts +0 -35
- package/dist/learning-evals.js +0 -99
- package/dist/native/context.d.ts +0 -6
- package/dist/native/context.js +0 -22
- package/dist/propose.d.ts +0 -52
- package/dist/propose.js +0 -224
- package/dist/runner/learning-ask.d.ts +0 -47
- package/dist/runner/learning-ask.js +0 -128
- package/dist/runner/learning-dispatch.d.ts +0 -45
- package/dist/runner/learning-dispatch.js +0 -99
- package/dist/runner/learning-factory.d.ts +0 -16
- package/dist/runner/learning-factory.js +0 -50
- package/dist/runner/learning-loop.d.ts +0 -273
- package/dist/runner/learning-loop.js +0 -521
- package/dist/usage.d.ts +0 -11
- package/dist/usage.js +0 -11
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
- package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
- package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
- package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
package/dist/sign-ins-store.d.ts
CHANGED
|
@@ -187,6 +187,14 @@ export declare function signInsOverStore(store: SignInsStore, sealKey: Buffer, v
|
|
|
187
187
|
message?: string;
|
|
188
188
|
}>;
|
|
189
189
|
}>;
|
|
190
|
+
/** Every saved sign-in of a deleted agent (agent-delete.ts), once no run of it is going, forgotten here and its object
|
|
191
|
+
* deleted at the vendor. Each live sign-in moves to a tombstone first (forgetSignIn's hold check; one forgotten
|
|
192
|
+
* meanwhile is passed by), and then every tombstone of the agent's, which stays until the agent's row goes, is
|
|
193
|
+
* deleted at its vendor (a 404 there is gone already). So a vendor delete that failed, or a stop after the move, is
|
|
194
|
+
* done again by the next call. Throws `unavailable` naming each vendor that did not delete, the tombstones kept. A
|
|
195
|
+
* tombstone whose pointer does not open under this server's seal key is passed by: no call of this server's can
|
|
196
|
+
* delete its object. */
|
|
197
|
+
forgetAll: (agentId: string) => Promise<void>;
|
|
190
198
|
peek: (agentId: string, resolution: string) => Promise<"unreadable" | {
|
|
191
199
|
ref: string;
|
|
192
200
|
} | undefined>;
|
package/dist/sign-ins-store.js
CHANGED
|
@@ -177,7 +177,7 @@ export async function handedSignInReadsBack(store, sealKey, run) {
|
|
|
177
177
|
if (pointer !== undefined)
|
|
178
178
|
known.add(pointerHash(pointer));
|
|
179
179
|
}
|
|
180
|
-
for (const provider of
|
|
180
|
+
for (const provider of VENDORS) {
|
|
181
181
|
for (const tomb of await store.signIns.tombstones(run.agentId, provider)) {
|
|
182
182
|
const pointer = open(sealKey, run.agentId, provider, tomb.pointerSealed);
|
|
183
183
|
if (pointer !== undefined)
|
|
@@ -259,6 +259,8 @@ export { SignInHandedTo, SignInMissing };
|
|
|
259
259
|
export const BROWSERBASE_SETTLE_MS = 10_000;
|
|
260
260
|
/** The settle window a provider's save lease outlives its run leaving 'running' by: Browserbase's, and none for the rest. */
|
|
261
261
|
const settleFor = (provider) => (provider === "browserbase" ? BROWSERBASE_SETTLE_MS : 0);
|
|
262
|
+
/** Every vendor a sign-in is kept at, for a walk over an agent's tombstones. */
|
|
263
|
+
const VENDORS = ["browserbase", "kernel"];
|
|
262
264
|
/** The vendor a run's browser resolves to keeps a sign-in for: Browserbase's and Kernel's; a local Chrome is refused by
|
|
263
265
|
* name; an unavailable browser has none. */
|
|
264
266
|
export function vendorOf(resolution) {
|
|
@@ -358,5 +360,38 @@ export function signInsOverStore(store, sealKey, vendors) {
|
|
|
358
360
|
view: (agentId) => signInViews(store, sealKey, agentId),
|
|
359
361
|
...signInReads(store, sealKey),
|
|
360
362
|
forget: (agentId, key) => forgetSignInView(store, sealKey, vendors, agentId, key),
|
|
363
|
+
/** Every saved sign-in of a deleted agent (agent-delete.ts), once no run of it is going, forgotten here and its object
|
|
364
|
+
* deleted at the vendor. Each live sign-in moves to a tombstone first (forgetSignIn's hold check; one forgotten
|
|
365
|
+
* meanwhile is passed by), and then every tombstone of the agent's, which stays until the agent's row goes, is
|
|
366
|
+
* deleted at its vendor (a 404 there is gone already). So a vendor delete that failed, or a stop after the move, is
|
|
367
|
+
* done again by the next call. Throws `unavailable` naming each vendor that did not delete, the tombstones kept. A
|
|
368
|
+
* tombstone whose pointer does not open under this server's seal key is passed by: no call of this server's can
|
|
369
|
+
* delete its object. */
|
|
370
|
+
forgetAll: async (agentId) => {
|
|
371
|
+
for (const row of await store.signIns.list(agentId)) {
|
|
372
|
+
checkParts(agentId, row.provider);
|
|
373
|
+
const pointer = open(sealKey, agentId, row.provider, row.pointerSealed);
|
|
374
|
+
try {
|
|
375
|
+
await store.signIns.forget(agentId, row.provider, pointer === undefined ? { heldUnreadable: true } : { hash: pointerHash(pointer) });
|
|
376
|
+
}
|
|
377
|
+
catch (error) {
|
|
378
|
+
if (!(error instanceof SignInMissing))
|
|
379
|
+
throw error;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
const failed = [];
|
|
383
|
+
for (const provider of VENDORS) {
|
|
384
|
+
for (const tomb of await store.signIns.tombstones(agentId, provider)) {
|
|
385
|
+
const pointer = open(sealKey, agentId, provider, tomb.pointerSealed);
|
|
386
|
+
if (pointer === undefined)
|
|
387
|
+
continue;
|
|
388
|
+
const error = await vendors.remove(provider, pointer).then(() => undefined, (e) => e);
|
|
389
|
+
if (error)
|
|
390
|
+
failed.push(`${provider} (${error.message})`);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (failed.length)
|
|
394
|
+
throw new ApiError("unavailable", `The agent ${agentId}'s saved sign-in${failed.length === 1 ? " is" : "s are"} not deleted at ${failed.join(", ")} yet.`, { retry_after_ms: 5_000 });
|
|
395
|
+
},
|
|
361
396
|
};
|
|
362
397
|
}
|
package/dist/skills.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// refuse. The adapter's own check (its exported skillProblems) says which: serve takes any <name>/SKILL.md, the adapter
|
|
8
8
|
// only a lowercase name, a SKILL.md whose front matter names the skill and describes it, plain file paths, and 1 MiB in
|
|
9
9
|
// all.
|
|
10
|
-
import { learnedFront } from "./learn/
|
|
10
|
+
import { learnedFront } from "./learn/workflow-draft.js";
|
|
11
11
|
import { skillNames } from "./validate.js";
|
|
12
12
|
import { workspaceAt } from "./workspace/index.js";
|
|
13
13
|
/** The most skill files read at once, so a run with many skill files stays under a low open-file limit. */
|
package/dist/store/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { AgentArchived, AnswerTaken, CommandTaken, endedReason, ExternalBodyConflict, FINAL_STATES, Fenced, MCP_REFRESH_CALL_MS, MCP_REFRESH_LEASE_MS, RevisionMoved, RunFinal, SchemaVersionUnknown, SignInHandedTo, SignInMissing, StoreBusy, StoreClosed, StoreConstraint, StoreDeadline, StoreFromEarlierVersion, StoreLaunchMissing, StoreOwned, StoreWorkerLost, STORE_WRITE_DEADLINE_MS, stoppedByPerson, TriggerFull } from "./store.js";
|
|
2
|
-
export type { ConstraintRule, AgentRow, Agents, AlsoRow, ChannelPost, Claim, Command, ComputerLedger, ComputerLedgerRow, Firing, FiringChange, FiringRow, FiringStatus, FiringStreak, Journal, Live, LiveRow, Mcp, McpCredentialMark, McpRemoved, McpOauth, McpOauthPendingRow, McpPinRow, McpServerRow, McpServerStamp, McpServerWrite, MintedTokenRow, MintedTokens, NewFiring, NewPairedComputer, NewRevision, NewTrigger, PairedComputerRow, PairedComputers, ReleasedState, RevisionRow, RunPatch, RunRow, Runs, RunState, SealedKeyRow, SealedKeys, SealedPlane, SealedSecretRow, SealedSecrets, SettingRow, Settings, Staged, StagedTake, Store, StoreRole, TemplatePackage, Templates, TriggerDef, TriggerPatch, TriggerRow, Triggers, TriggerScope, TriggerSettingRow, TriggerSettings, Channels, ChannelAttemptRow, ChannelPostRow, ChannelToldRow, ImportedFrom, ImportSource, ImportRunInput, JournalReads, RunLabels, RunOrigin, RunOutcome, RunLaunchInput, RunLaunchRow, LaunchSealed, LaunchSealedWrite, Learning, LearningProposal, LiveViewerRow, LiveViewers, SignIns, SignInRow, SignInTombstoneRow, UpdatedRun, ViewerKind, } from "./store.js";
|
|
1
|
+
export { AgentArchived, AgentDeleting, AnswerTaken, CommandTaken, endedReason, ExternalBodyConflict, FINAL_STATES, Fenced, MCP_REFRESH_CALL_MS, MCP_REFRESH_LEASE_MS, RevisionMoved, RunFinal, SchemaVersionUnknown, SignInHandedTo, SignInMissing, StoreBusy, StoreClosed, StoreConstraint, StoreDeadline, StoreFromEarlierVersion, StoreLaunchMissing, StoreOwned, StoreWorkerLost, STORE_WRITE_DEADLINE_MS, stoppedByPerson, TriggerFull, TriggersLeft } from "./store.js";
|
|
2
|
+
export type { ConstraintRule, AgentRow, Agents, AlsoRow, ChannelPost, Claim, Command, ComputerLedger, ComputerLedgerRow, Firing, FiringChange, FiringRow, FiringStatus, FiringStreak, Journal, Live, LiveRow, Mcp, McpCredentialMark, McpRemoved, McpOauth, McpOauthPendingRow, McpPinRow, McpServerRow, McpServerStamp, McpServerWrite, MintedTokenRow, MintedTokens, NewFiring, NewPairedComputer, NewRevision, NewTrigger, PairedComputerRow, PairedComputers, ReleasedState, RevisionRow, RunnerRelayRow, RunnerRelays, RunPatch, RunRow, Runs, RunState, SealedKeyRow, SealedKeys, SealedPlane, SealedSecretRow, SealedSecrets, SettingRow, Settings, Staged, StagedTake, Store, StoreRole, TemplatePackage, Templates, TriggerDef, TriggerPatch, TriggerRow, Triggers, TriggerScope, TriggerSettingRow, TriggerSettings, Channels, ChannelAttemptRow, ChannelPostRow, ChannelToldRow, ImportedFrom, ImportSource, ImportRunInput, JournalReads, RunLabels, RunOrigin, RunOutcome, RunLaunchInput, RunLaunchRow, LaunchSealed, LaunchSealedWrite, Learning, LearningProposal, LiveViewerRow, LiveViewers, SignIns, SignInRow, SignInTombstoneRow, UpdatedRun, ViewerKind, } from "./store.js";
|
|
3
3
|
export { aadOf, type McpCredential, type OpenedMcpCredential, openMcpCredential, openRunLaunch, openRunMcpAuth, type RunLaunchSecrets, type RunMcpAuth, type RunModelKey, sealColumn, type SealedAt, sealedAt, sealMcpCredential, sealRunLaunch, sealRunMcpAuth, unsealColumn } from "./seal.js";
|
|
4
4
|
export { AgentBodyInvalid, type AgenticBody, bodyOf, canonical, isObject, isSkillPath, type PromptVariant, type ModelTiers, type MonidPinBody, type RevisionBodyInput, type RevisionComputer, type RevisionPlace, sha256, type ToolSettings, type WorkflowBody, } from "./agent-body.js";
|
|
5
5
|
export { checkPrompts, OTHER_OPTION, PromptsInvalid } from "./prompts.js";
|
package/dist/store/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// The one store (design 2.1), for the cutover: nothing on main imports it until then.
|
|
2
|
-
export { AgentArchived, AnswerTaken, CommandTaken, endedReason, ExternalBodyConflict, FINAL_STATES, Fenced, MCP_REFRESH_CALL_MS, MCP_REFRESH_LEASE_MS, RevisionMoved, RunFinal, SchemaVersionUnknown, SignInHandedTo, SignInMissing, StoreBusy, StoreClosed, StoreConstraint, StoreDeadline, StoreFromEarlierVersion, StoreLaunchMissing, StoreOwned, StoreWorkerLost, STORE_WRITE_DEADLINE_MS, stoppedByPerson, TriggerFull } from "./store.js";
|
|
2
|
+
export { AgentArchived, AgentDeleting, AnswerTaken, CommandTaken, endedReason, ExternalBodyConflict, FINAL_STATES, Fenced, MCP_REFRESH_CALL_MS, MCP_REFRESH_LEASE_MS, RevisionMoved, RunFinal, SchemaVersionUnknown, SignInHandedTo, SignInMissing, StoreBusy, StoreClosed, StoreConstraint, StoreDeadline, StoreFromEarlierVersion, StoreLaunchMissing, StoreOwned, StoreWorkerLost, STORE_WRITE_DEADLINE_MS, stoppedByPerson, TriggerFull, TriggersLeft } from "./store.js";
|
|
3
3
|
export { aadOf, openMcpCredential, openRunLaunch, openRunMcpAuth, sealColumn, sealedAt, sealMcpCredential, sealRunLaunch, sealRunMcpAuth, unsealColumn } from "./seal.js";
|
|
4
4
|
export { AgentBodyInvalid, bodyOf, canonical, isObject, isSkillPath, sha256, } from "./agent-body.js";
|
|
5
5
|
export { checkPrompts, OTHER_OPTION, PromptsInvalid } from "./prompts.js";
|
|
@@ -307,6 +307,9 @@ export class RunStorage {
|
|
|
307
307
|
}
|
|
308
308
|
if (seqs.length > 0) {
|
|
309
309
|
await tx.run(`INSERT INTO ${T.metadata} (run_id, next_id, next_seq) VALUES (?, ?, ?) ON CONFLICT (run_id) DO UPDATE SET next_id = excluded.next_id, next_seq = excluded.next_seq`, this.#runId, String(Math.max(Number(metadata.next_id), candidateNextId)), next);
|
|
310
|
+
// What the run's list shows may have moved with what this commit stored (a turn, an ask, a request's cost): its
|
|
311
|
+
// listing is behind from this commit on (store/schema.ts RUN_LISTING_COLUMNS), in this commit's transaction.
|
|
312
|
+
await tx.run("UPDATE runs SET list_mark = list_mark + 1 WHERE id = ?", this.#runId);
|
|
310
313
|
// The run patch's fenced UPDATE (0 rows: Fenced), then its rows (store/sqlite/run-patch.ts, as runs.update writes
|
|
311
314
|
// them), then the takes.
|
|
312
315
|
const now = this.#now();
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
-- Version 17: each run's listing on its row (store/schema.ts RUN_LISTING_COLUMNS, as SQLite's schema version 12 keeps it):
|
|
2
|
+
-- what a runs list shows of the run, so a list reads rows alone and never builds a run's view. list_mark moves (+1) in the
|
|
3
|
+
-- transaction of every write that can change the run's view: its journal's commits (store/journal/storage.ts), its row's
|
|
4
|
+
-- state, claim, cost and end (runs_list_moved), its commands (commands_list_moved), its learning's rows
|
|
5
|
+
-- (learning_list_moved), and its learning run's or audit's own moves (runs_list_parent). The server's lister rebuilds a
|
|
6
|
+
-- listing from the run's view and writes it with the mark it read before it built (listing_mark), so a row whose listing is
|
|
7
|
+
-- behind says so. Every run starts behind; a settled run's status is set from its row here (an end that is no person's stop
|
|
8
|
+
-- of an agentic run). Applied once, after 0016, inside the transaction migrate.ts opens. Never edit this file once
|
|
9
|
+
-- applied: a change is a new file.
|
|
10
|
+
ALTER TABLE runs ADD COLUMN IF NOT EXISTS list_mark BIGINT NOT NULL DEFAULT 1;
|
|
11
|
+
ALTER TABLE runs ADD COLUMN IF NOT EXISTS listing TEXT COLLATE "C" CHECK (listing IS NULL OR listing::json IS NOT NULL);
|
|
12
|
+
ALTER TABLE runs ADD COLUMN IF NOT EXISTS list_status TEXT COLLATE "C";
|
|
13
|
+
ALTER TABLE runs ADD COLUMN IF NOT EXISTS listing_mark BIGINT NOT NULL DEFAULT 0;
|
|
14
|
+
ALTER TABLE runs ADD COLUMN IF NOT EXISTS listing_live BIGINT NOT NULL DEFAULT 0 CHECK (listing_live IN (0, 1));
|
|
15
|
+
ALTER TABLE runs ADD COLUMN IF NOT EXISTS listing_until BIGINT;
|
|
16
|
+
ALTER TABLE runs ADD COLUMN IF NOT EXISTS listing_flags BIGINT NOT NULL DEFAULT 0;
|
|
17
|
+
|
|
18
|
+
CREATE INDEX IF NOT EXISTS runs_listing_behind ON runs (started_at) WHERE listing_mark < list_mark;
|
|
19
|
+
CREATE INDEX IF NOT EXISTS runs_listing_live ON runs (started_at) WHERE listing_live = 1;
|
|
20
|
+
CREATE INDEX IF NOT EXISTS runs_listing_until ON runs (listing_until) WHERE listing_until IS NOT NULL;
|
|
21
|
+
CREATE INDEX IF NOT EXISTS runs_by_list_status ON runs (list_status, started_at);
|
|
22
|
+
CREATE INDEX IF NOT EXISTS runs_listing_flagged ON runs (agent_id) WHERE listing_flags <> 0;
|
|
23
|
+
CREATE INDEX IF NOT EXISTS learning_proposals_by_learning_run ON learning_proposals (learning_run_id) WHERE learning_run_id IS NOT NULL;
|
|
24
|
+
|
|
25
|
+
-- The run's own mark, for a change of its row a list may show (a renew, which moves only claimed_until, is none), and its
|
|
26
|
+
-- list_status from the row: a settled run's status, else none until its listing is built.
|
|
27
|
+
CREATE OR REPLACE FUNCTION run_list_moved() RETURNS trigger LANGUAGE plpgsql AS $$
|
|
28
|
+
BEGIN
|
|
29
|
+
EXECUTE format('UPDATE %I.runs SET list_mark = list_mark + 1, list_status = CASE
|
|
30
|
+
WHEN state = ''ended'' THEN ''completed''
|
|
31
|
+
WHEN state = ''failed'' THEN ''failed''
|
|
32
|
+
WHEN state = ''stopped'' AND (outcome IS NULL OR outcome <> ''stopped'' OR imported_from IS NOT NULL
|
|
33
|
+
OR (SELECT kind FROM %I.revisions WHERE revisions.id = runs.revision_id) <> ''agentic'') THEN ''cancelled''
|
|
34
|
+
ELSE NULL END
|
|
35
|
+
WHERE id = $1', TG_TABLE_SCHEMA, TG_TABLE_SCHEMA) USING NEW.id;
|
|
36
|
+
RETURN NULL;
|
|
37
|
+
END
|
|
38
|
+
$$;
|
|
39
|
+
DROP TRIGGER IF EXISTS runs_list_moved ON runs;
|
|
40
|
+
CREATE TRIGGER runs_list_moved AFTER UPDATE OF state, epoch, runner, cost_usd, cost_upper_bound, metrics, summary, outcome, imported_from, sign_in_handed, labels, ended_at ON runs
|
|
41
|
+
FOR EACH ROW EXECUTE FUNCTION run_list_moved();
|
|
42
|
+
|
|
43
|
+
-- A learning run's or an audit shadow run's move is its served run's too: that run's view reads them.
|
|
44
|
+
CREATE OR REPLACE FUNCTION run_list_parent() RETURNS trigger LANGUAGE plpgsql AS $$
|
|
45
|
+
BEGIN
|
|
46
|
+
IF NEW.id LIKE 'audit.%' THEN
|
|
47
|
+
EXECUTE format('UPDATE %I.runs SET list_mark = list_mark + 1 WHERE id = $1', TG_TABLE_SCHEMA) USING substr(NEW.id, 7);
|
|
48
|
+
END IF;
|
|
49
|
+
EXECUTE format('UPDATE %I.runs SET list_mark = list_mark + 1 WHERE id IN (SELECT run_id FROM %I.learning_proposals WHERE learning_run_id = $1)', TG_TABLE_SCHEMA, TG_TABLE_SCHEMA) USING NEW.id;
|
|
50
|
+
RETURN NULL;
|
|
51
|
+
END
|
|
52
|
+
$$;
|
|
53
|
+
DROP TRIGGER IF EXISTS runs_list_parent ON runs;
|
|
54
|
+
CREATE TRIGGER runs_list_parent AFTER UPDATE OF list_mark ON runs
|
|
55
|
+
FOR EACH ROW WHEN (pg_trigger_depth() < 3) EXECUTE FUNCTION run_list_parent();
|
|
56
|
+
|
|
57
|
+
-- A command written, taken or refused, and a learning row written or changed: its run's mark, moved at the commit of the
|
|
58
|
+
-- write's transaction (deferred), still inside it. The run's row is locked only for that moment: a command whose
|
|
59
|
+
-- transaction waits on something else (its launch row) never holds up the run's journal commits, or the run's other
|
|
60
|
+
-- commands, which take their ids in the order they were inserted.
|
|
61
|
+
CREATE OR REPLACE FUNCTION run_list_of_row() RETURNS trigger LANGUAGE plpgsql AS $$
|
|
62
|
+
BEGIN
|
|
63
|
+
EXECUTE format('UPDATE %I.runs SET list_mark = list_mark + 1 WHERE id = $1', TG_TABLE_SCHEMA) USING NEW.run_id;
|
|
64
|
+
RETURN NULL;
|
|
65
|
+
END
|
|
66
|
+
$$;
|
|
67
|
+
DROP TRIGGER IF EXISTS commands_list_moved ON commands;
|
|
68
|
+
CREATE CONSTRAINT TRIGGER commands_list_moved AFTER INSERT ON commands DEFERRABLE INITIALLY DEFERRED
|
|
69
|
+
FOR EACH ROW EXECUTE FUNCTION run_list_of_row();
|
|
70
|
+
DROP TRIGGER IF EXISTS commands_list_settled ON commands;
|
|
71
|
+
CREATE CONSTRAINT TRIGGER commands_list_settled AFTER UPDATE OF taken_at, refused ON commands DEFERRABLE INITIALLY DEFERRED
|
|
72
|
+
FOR EACH ROW EXECUTE FUNCTION run_list_of_row();
|
|
73
|
+
DROP TRIGGER IF EXISTS learning_list_moved ON learning_proposals;
|
|
74
|
+
CREATE CONSTRAINT TRIGGER learning_list_moved AFTER INSERT OR UPDATE ON learning_proposals DEFERRABLE INITIALLY DEFERRED
|
|
75
|
+
FOR EACH ROW EXECUTE FUNCTION run_list_of_row();
|
|
76
|
+
|
|
77
|
+
UPDATE runs SET list_status = CASE
|
|
78
|
+
WHEN state = 'ended' THEN 'completed'
|
|
79
|
+
WHEN state = 'failed' THEN 'failed'
|
|
80
|
+
WHEN state = 'stopped' AND (outcome IS NULL OR outcome <> 'stopped' OR imported_from IS NOT NULL
|
|
81
|
+
OR (SELECT kind FROM revisions WHERE revisions.id = runs.revision_id) <> 'agentic') THEN 'cancelled'
|
|
82
|
+
ELSE NULL END;
|
|
83
|
+
UPDATE store_meta SET schema_version = 17 WHERE singleton = 1;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- A trigger's package mark (triggers.template_id, as store/schema.ts keeps it on SQLite: TRIGGERS_TEMPLATE_ID): the id of
|
|
2
|
+
-- the template package whose apply made or last kept the trigger, null for one a person made, so a trigger made before
|
|
3
|
+
-- reads as no package's. A template update removes only triggers marked with its own package. Applied once, after the
|
|
4
|
+
-- migration before it, inside the transaction migrate.ts opens. Never edit this file once applied: a change is a new file.
|
|
5
|
+
ALTER TABLE triggers ADD COLUMN IF NOT EXISTS template_id TEXT COLLATE "C";
|
|
6
|
+
UPDATE store_meta SET schema_version = 18 WHERE singleton = 1;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
-- The store's schema on Postgres, version 19: a dial relayed to the runner that made its machine (dial-relay.ts), as
|
|
2
|
+
-- store/schema.ts keeps it on SQLite (version 13). Applied once, after 0018, inside the transaction migrate.ts opens.
|
|
3
|
+
-- Never edit this file once applied: a change is a new file.
|
|
4
|
+
--
|
|
5
|
+
-- minted_tokens.runner, .incarnation: the runner in a process of its own that minted the machine's token, and its
|
|
6
|
+
-- incarnation (its process since its start); null for a token the server's own process minted.
|
|
7
|
+
-- minted_tokens.run: the run the machine works for, as its create named it, which the words about its dial say; null for
|
|
8
|
+
-- a machine of no run.
|
|
9
|
+
-- minted_tokens.refused: why the server refused to relay the machine's dial, in its 503's words (never the token), which
|
|
10
|
+
-- the minting runner's create reads to end its wait; null while none was, and again at a mint.
|
|
11
|
+
-- runner_relays: one row per runner in a process of its own, where its attach listener takes the dials the server relays
|
|
12
|
+
-- to it (its host and port), under its incarnation, and when it last said it was there.
|
|
13
|
+
-- IF NOT EXISTS: applied again over a store that has them, it changes nothing.
|
|
14
|
+
|
|
15
|
+
ALTER TABLE minted_tokens ADD COLUMN IF NOT EXISTS runner TEXT COLLATE "C";
|
|
16
|
+
ALTER TABLE minted_tokens ADD COLUMN IF NOT EXISTS incarnation TEXT COLLATE "C";
|
|
17
|
+
ALTER TABLE minted_tokens ADD COLUMN IF NOT EXISTS run TEXT COLLATE "C";
|
|
18
|
+
ALTER TABLE minted_tokens ADD COLUMN IF NOT EXISTS refused TEXT;
|
|
19
|
+
|
|
20
|
+
CREATE TABLE IF NOT EXISTS runner_relays (
|
|
21
|
+
runner TEXT COLLATE "C" PRIMARY KEY,
|
|
22
|
+
incarnation TEXT COLLATE "C" NOT NULL,
|
|
23
|
+
host TEXT COLLATE "C" NOT NULL,
|
|
24
|
+
port INTEGER NOT NULL,
|
|
25
|
+
seen_at BIGINT NOT NULL
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
UPDATE store_meta SET schema_version = 19 WHERE singleton = 1;
|
package/dist/store/schema.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const SCHEMA_VERSION =
|
|
1
|
+
export declare const SCHEMA_VERSION = 13;
|
|
2
2
|
/** One answer per approval of a run: a second approve or deny command naming the same approval is refused
|
|
3
3
|
* (StoreConstraint), so the first answer a person gives wins from the moment it is written, before the runner takes it
|
|
4
4
|
* (runs-over-store.ts approve). In STORE_DDL, and added at a server open to a store an earlier build of this version made. */
|
|
@@ -19,6 +19,10 @@ export declare const RUNS_COST_UPPER_BOUND = "ALTER TABLE runs ADD COLUMN cost_u
|
|
|
19
19
|
/** A run's labels (JSON, null for none): in STORE_DDL, and added at a server open to a store an earlier build of this version
|
|
20
20
|
* made, as RUNS_COST_UPPER_BOUND is (a run started before reads as given none). */
|
|
21
21
|
export declare const RUNS_LABELS: string;
|
|
22
|
+
/** A trigger's package mark (TriggerRow.templateId): the id of the template package whose apply made or last kept it, null
|
|
23
|
+
* for one a person made. In STORE_DDL, and added at a server open to a store an earlier build of this version made, as
|
|
24
|
+
* RUNS_LABELS is (a trigger made before reads as no package's). */
|
|
25
|
+
export declare const TRIGGERS_TEMPLATE_ID = "ALTER TABLE triggers ADD COLUMN template_id TEXT";
|
|
22
26
|
/** A template package imported from GitHub (POST /v2/templates/import), by its id (`github:<owner>/<repo>[/<path>]`): its
|
|
23
27
|
* source as given (ref and all), the full commit SHA read, the GitHub account that publishes it, and its files as read
|
|
24
28
|
* (`files`, a JSON object of path to base64). A re-import of the id replaces the row. The server checks the files again
|
|
@@ -28,9 +32,54 @@ export declare const IMPORTED_TEMPLATES: string;
|
|
|
28
32
|
/** A hosted machine's minted token (a dial provider's create, spec/computer/attach.md): its computerd dials the attach
|
|
29
33
|
* socket and fetches the daemon with it. By the machine (its name, from its create's request id): the token's SHA-256
|
|
30
34
|
* alone (hex), what the machine must say it is at hello (kind, os, arch), and when the token ends (`expires_at`, the
|
|
31
|
-
* machine's backstop) or was revoked (its delete). A row past its end goes at the next mint.
|
|
32
|
-
*
|
|
33
|
-
|
|
35
|
+
* machine's backstop) or was revoked (its delete). A row past its end goes at the next mint. `runner` and `incarnation`
|
|
36
|
+
* (version 13): the runner in a process of its own that minted it, and its incarnation, to which the server relays the
|
|
37
|
+
* machine's socket (dial-relay.ts); null for the server's own process. `run` (version 13): the run the machine works for,
|
|
38
|
+
* as its create named it, which the words about its dial say; null for a machine of no run. `refused` (version 13): why
|
|
39
|
+
* the server refused to relay its dial, in its 503's words (never the token), which the minting runner's create reads to
|
|
40
|
+
* end its wait; null while none was, and again at a mint. In STORE_DDL, and added at a server open to a store an earlier
|
|
41
|
+
* build of this version made. */
|
|
42
|
+
export declare const MINTED_TOKENS = "CREATE TABLE IF NOT EXISTS minted_tokens (\n machine TEXT PRIMARY KEY,\n token_sha256 TEXT NOT NULL UNIQUE,\n kind TEXT NOT NULL,\n os TEXT NOT NULL,\n arch TEXT NOT NULL,\n expires_at INTEGER NOT NULL,\n revoked_at INTEGER,\n created_at INTEGER NOT NULL,\n runner TEXT,\n incarnation TEXT,\n run TEXT,\n refused TEXT\n ) STRICT";
|
|
43
|
+
/** Where each runner in a process of its own takes the dials the server relays to it (version 13, dial-relay.ts): its
|
|
44
|
+
* attach listener's host and port under its name, with its incarnation and when it last said it was there. */
|
|
45
|
+
export declare const RUNNER_RELAYS = "CREATE TABLE IF NOT EXISTS runner_relays (\n runner TEXT PRIMARY KEY,\n incarnation TEXT NOT NULL,\n host TEXT NOT NULL,\n port INTEGER NOT NULL,\n seen_at INTEGER NOT NULL\n ) STRICT";
|
|
46
|
+
/** Version 12 → 13 on SQLite (the server's open, sqlite/store.ts), given minted_tokens' columns now: the minting runner,
|
|
47
|
+
* its incarnation, the machine's run and a refused relay's words on each token's row (none of the rows there has one: the
|
|
48
|
+
* server's own process minted them, naming no run), the runners' relays, and the version, in one durable write. */
|
|
49
|
+
export declare function relayUpgrade(mintedColumns: ReadonlySet<string>): readonly string[];
|
|
50
|
+
/** A run's listing on its row (version 12): what a runs list shows of the run, so a list reads rows alone and never builds
|
|
51
|
+
* a run's view. `list_mark` moves (+1) in the transaction of every write that can change what the run's view shows: its
|
|
52
|
+
* journal's commits (store/journal/storage.ts), its row's state, claim, cost and end (runs_list_moved), its commands
|
|
53
|
+
* (commands_list_moved), its learning's rows (learning_list_moved), and its learning run's or audit's own moves
|
|
54
|
+
* (runs_list_parent). The server rebuilds a listing from the run's view (store-view.ts listingOverStore, run-listing.ts)
|
|
55
|
+
* and writes it with the mark it read before it built (`listing_mark`), only while list_mark is still that mark: a write
|
|
56
|
+
* that lands meanwhile keeps the row as it left it (its list_status too), behind (listing_mark < list_mark), and it is
|
|
57
|
+
* built again: a crash between a write and its listing leaves a row that says
|
|
58
|
+
* it is behind, never one that says it is current. `listing` is the list item without the parts read when it is listed
|
|
59
|
+
* (console_url, archived_at); `list_status` its status, which a status filter reads in SQL; `listing_live` whether a runner
|
|
60
|
+
* held the run when it was built (its status reads otherwise once that claim runs out); `listing_until` when it goes stale
|
|
61
|
+
* by the clock alone (an ask that expires, or the retry of a build that withheld the run for a sign-in it could not read
|
|
62
|
+
* back); `listing_flags` what outside the run it read (LISTING_HELD: learning held for
|
|
63
|
+
* its owner's OK on its agent's folder; LISTING_KEYED: a failed run's error words, which read the server's keys). */
|
|
64
|
+
export declare const RUN_LISTING_COLUMNS: readonly ["list_mark INTEGER NOT NULL DEFAULT 1", string, "list_status TEXT", "listing_mark INTEGER NOT NULL DEFAULT 0", "listing_live INTEGER NOT NULL DEFAULT 0 CHECK (listing_live IN (0, 1))", "listing_until INTEGER", "listing_flags INTEGER NOT NULL DEFAULT 0"];
|
|
65
|
+
/** listing_flags: the run's learning holds items for its owner's OK, read as they stand on its agent's folder now. */
|
|
66
|
+
export declare const LISTING_HELD = 1;
|
|
67
|
+
/** listing_flags: a failed run's error words, which name a refused key by the server's keys and settings. */
|
|
68
|
+
export declare const LISTING_KEYED = 2;
|
|
69
|
+
/** A run's status from its row alone, where its row says it (an end that is no person's stop of an agentic run): the status
|
|
70
|
+
* its view reads (store-view.ts STATUS_OF), in SQL. Null for any other run, whose listing says it once it is built. */
|
|
71
|
+
export declare const SETTLED_LIST_STATUS = "CASE\n WHEN state = 'ended' THEN 'completed'\n WHEN state = 'failed' THEN 'failed'\n WHEN state = 'stopped' AND (outcome IS NULL OR outcome <> 'stopped' OR imported_from IS NOT NULL\n OR (SELECT kind FROM revisions WHERE revisions.id = runs.revision_id) <> 'agentic') THEN 'cancelled'\n ELSE NULL END";
|
|
72
|
+
/** The listing's indexes and triggers (RUN_LISTING_COLUMNS), after every table they name. A write to a run's row moves its
|
|
73
|
+
* mark and sets its list_status from the row (SETTLED_LIST_STATUS: a settled run's status, else none until its listing
|
|
74
|
+
* is built), so a status filter never reads a status the row has left. The parent trigger moves the mark of the run a
|
|
75
|
+
* learning run grades (learning_proposals.learning_run_id) or an audit's shadow run audits (its id after "audit.",
|
|
76
|
+
* learn/audit.ts shadowRunId), since each run's view reads those. */
|
|
77
|
+
export declare const RUN_LISTING_DDL: readonly string[];
|
|
78
|
+
/** Version 11 → 12 on SQLite (the server's open, sqlite/store.ts), given the runs table's columns now: the listing's columns
|
|
79
|
+
* it lacks, its indexes and triggers, every settled run's status from its row (SETTLED_LIST_STATUS), and the version, in
|
|
80
|
+
* one durable write. Every run starts behind (listing_mark 0 < list_mark 1): the server's lister builds each listing in
|
|
81
|
+
* the background, the runs no runner holds first. */
|
|
82
|
+
export declare function listingUpgrade(runColumns: ReadonlySet<string>): readonly string[];
|
|
34
83
|
export declare const STORE_DDL: readonly string[];
|
|
35
84
|
/** pi-durable's journal tables (its SqliteStorage schema, version 2, the `sleeping` task status included; MIT, see NOTICE),
|
|
36
85
|
* every one keyed by (run_id, …) with run_id leading its indexes, so one run's scans read only its rows and two runs never
|
package/dist/store/schema.js
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
// build of this version made and drops the table, so a revision saved before has no pin until its first run pins it.
|
|
14
14
|
// Its monid endpoints are pinned beside them (revisions.monid_pin, REVISIONS_MONID_PIN), added at a server open the same way.
|
|
15
15
|
// A run's cost says whether it is the most the run can have cost (runs.cost_upper_bound, RUNS_COST_UPPER_BOUND), added at a
|
|
16
|
-
// server open the same way. A run's labels (runs.labels, RUNS_LABELS) are added at a server open the same way
|
|
16
|
+
// server open the same way. A run's labels (runs.labels, RUNS_LABELS) are added at a server open the same way, and so is
|
|
17
|
+
// a trigger's package mark (triggers.template_id, TRIGGERS_TEMPLATE_ID).
|
|
17
18
|
// The template packages imported from GitHub (imported_templates) are a table of their own that nothing
|
|
18
19
|
// else reads, so it needs no version: the server adds it at its open to a store an earlier build of this version made
|
|
19
20
|
// (IMPORTED_TEMPLATES), as it does the one-answer index. A hosted machine's minted token (minted_tokens, MINTED_TOKENS) is
|
|
@@ -28,7 +29,11 @@
|
|
|
28
29
|
// learning state, the MCP registry, pending MCP sign-ins, and the computer ledger. PI_DDL is pi-durable's
|
|
29
30
|
// journal tables, keyed by run_id (store/journal): one schema for every run's journal, so a query joins runs and their
|
|
30
31
|
// journals.
|
|
31
|
-
|
|
32
|
+
// Version 12 keeps each run's listing on its row (RUN_LISTING_COLUMNS): what a runs list shows of it, so a list reads rows
|
|
33
|
+
// alone. Version 13 names the runner in a process of its own that minted a hosted machine's token (minted_tokens.runner,
|
|
34
|
+
// .incarnation), the run the machine works for (.run), why the server refused to relay its dial (.refused), and where each
|
|
35
|
+
// such runner takes the dials the server relays to it (runner_relays, dial-relay.ts). The server upgrades these two in place at its open (listingUpgrade from 11, then relayUpgrade from 12); a runner waits for it.
|
|
36
|
+
export const SCHEMA_VERSION = 13;
|
|
32
37
|
/** One answer per approval of a run: a second approve or deny command naming the same approval is refused
|
|
33
38
|
* (StoreConstraint), so the first answer a person gives wins from the moment it is written, before the runner takes it
|
|
34
39
|
* (runs-over-store.ts approve). In STORE_DDL, and added at a server open to a store an earlier build of this version made. */
|
|
@@ -54,6 +59,10 @@ export const RUNS_COST_UPPER_BOUND = `ALTER TABLE runs ADD COLUMN ${COST_UPPER_B
|
|
|
54
59
|
/** A run's labels (JSON, null for none): in STORE_DDL, and added at a server open to a store an earlier build of this version
|
|
55
60
|
* made, as RUNS_COST_UPPER_BOUND is (a run started before reads as given none). */
|
|
56
61
|
export const RUNS_LABELS = `ALTER TABLE runs ADD COLUMN ${json("labels", true)}`;
|
|
62
|
+
/** A trigger's package mark (TriggerRow.templateId): the id of the template package whose apply made or last kept it, null
|
|
63
|
+
* for one a person made. In STORE_DDL, and added at a server open to a store an earlier build of this version made, as
|
|
64
|
+
* RUNS_LABELS is (a trigger made before reads as no package's). */
|
|
65
|
+
export const TRIGGERS_TEMPLATE_ID = "ALTER TABLE triggers ADD COLUMN template_id TEXT";
|
|
57
66
|
/** A template package imported from GitHub (POST /v2/templates/import), by its id (`github:<owner>/<repo>[/<path>]`): its
|
|
58
67
|
* source as given (ref and all), the full commit SHA read, the GitHub account that publishes it, and its files as read
|
|
59
68
|
* (`files`, a JSON object of path to base64). A re-import of the id replaces the row. The server checks the files again
|
|
@@ -70,8 +79,13 @@ export const IMPORTED_TEMPLATES = `CREATE TABLE IF NOT EXISTS imported_templates
|
|
|
70
79
|
/** A hosted machine's minted token (a dial provider's create, spec/computer/attach.md): its computerd dials the attach
|
|
71
80
|
* socket and fetches the daemon with it. By the machine (its name, from its create's request id): the token's SHA-256
|
|
72
81
|
* alone (hex), what the machine must say it is at hello (kind, os, arch), and when the token ends (`expires_at`, the
|
|
73
|
-
* machine's backstop) or was revoked (its delete). A row past its end goes at the next mint.
|
|
74
|
-
*
|
|
82
|
+
* machine's backstop) or was revoked (its delete). A row past its end goes at the next mint. `runner` and `incarnation`
|
|
83
|
+
* (version 13): the runner in a process of its own that minted it, and its incarnation, to which the server relays the
|
|
84
|
+
* machine's socket (dial-relay.ts); null for the server's own process. `run` (version 13): the run the machine works for,
|
|
85
|
+
* as its create named it, which the words about its dial say; null for a machine of no run. `refused` (version 13): why
|
|
86
|
+
* the server refused to relay its dial, in its 503's words (never the token), which the minting runner's create reads to
|
|
87
|
+
* end its wait; null while none was, and again at a mint. In STORE_DDL, and added at a server open to a store an earlier
|
|
88
|
+
* build of this version made. */
|
|
75
89
|
export const MINTED_TOKENS = `CREATE TABLE IF NOT EXISTS minted_tokens (
|
|
76
90
|
machine TEXT PRIMARY KEY,
|
|
77
91
|
token_sha256 TEXT NOT NULL UNIQUE,
|
|
@@ -80,8 +94,117 @@ export const MINTED_TOKENS = `CREATE TABLE IF NOT EXISTS minted_tokens (
|
|
|
80
94
|
arch TEXT NOT NULL,
|
|
81
95
|
expires_at INTEGER NOT NULL,
|
|
82
96
|
revoked_at INTEGER,
|
|
83
|
-
created_at INTEGER NOT NULL
|
|
97
|
+
created_at INTEGER NOT NULL,
|
|
98
|
+
runner TEXT,
|
|
99
|
+
incarnation TEXT,
|
|
100
|
+
run TEXT,
|
|
101
|
+
refused TEXT
|
|
102
|
+
) STRICT`;
|
|
103
|
+
/** Where each runner in a process of its own takes the dials the server relays to it (version 13, dial-relay.ts): its
|
|
104
|
+
* attach listener's host and port under its name, with its incarnation and when it last said it was there. */
|
|
105
|
+
export const RUNNER_RELAYS = `CREATE TABLE IF NOT EXISTS runner_relays (
|
|
106
|
+
runner TEXT PRIMARY KEY,
|
|
107
|
+
incarnation TEXT NOT NULL,
|
|
108
|
+
host TEXT NOT NULL,
|
|
109
|
+
port INTEGER NOT NULL,
|
|
110
|
+
seen_at INTEGER NOT NULL
|
|
84
111
|
) STRICT`;
|
|
112
|
+
/** Version 12 → 13 on SQLite (the server's open, sqlite/store.ts), given minted_tokens' columns now: the minting runner,
|
|
113
|
+
* its incarnation, the machine's run and a refused relay's words on each token's row (none of the rows there has one: the
|
|
114
|
+
* server's own process minted them, naming no run), the runners' relays, and the version, in one durable write. */
|
|
115
|
+
export function relayUpgrade(mintedColumns) {
|
|
116
|
+
return [
|
|
117
|
+
...["runner", "incarnation", "run", "refused"].filter((column) => !mintedColumns.has(column)).map((column) => `ALTER TABLE minted_tokens ADD COLUMN ${column} TEXT`),
|
|
118
|
+
RUNNER_RELAYS,
|
|
119
|
+
"UPDATE store_meta SET schema_version = 13 WHERE singleton = 1",
|
|
120
|
+
];
|
|
121
|
+
}
|
|
122
|
+
/** A run's listing on its row (version 12): what a runs list shows of the run, so a list reads rows alone and never builds
|
|
123
|
+
* a run's view. `list_mark` moves (+1) in the transaction of every write that can change what the run's view shows: its
|
|
124
|
+
* journal's commits (store/journal/storage.ts), its row's state, claim, cost and end (runs_list_moved), its commands
|
|
125
|
+
* (commands_list_moved), its learning's rows (learning_list_moved), and its learning run's or audit's own moves
|
|
126
|
+
* (runs_list_parent). The server rebuilds a listing from the run's view (store-view.ts listingOverStore, run-listing.ts)
|
|
127
|
+
* and writes it with the mark it read before it built (`listing_mark`), only while list_mark is still that mark: a write
|
|
128
|
+
* that lands meanwhile keeps the row as it left it (its list_status too), behind (listing_mark < list_mark), and it is
|
|
129
|
+
* built again: a crash between a write and its listing leaves a row that says
|
|
130
|
+
* it is behind, never one that says it is current. `listing` is the list item without the parts read when it is listed
|
|
131
|
+
* (console_url, archived_at); `list_status` its status, which a status filter reads in SQL; `listing_live` whether a runner
|
|
132
|
+
* held the run when it was built (its status reads otherwise once that claim runs out); `listing_until` when it goes stale
|
|
133
|
+
* by the clock alone (an ask that expires, or the retry of a build that withheld the run for a sign-in it could not read
|
|
134
|
+
* back); `listing_flags` what outside the run it read (LISTING_HELD: learning held for
|
|
135
|
+
* its owner's OK on its agent's folder; LISTING_KEYED: a failed run's error words, which read the server's keys). */
|
|
136
|
+
export const RUN_LISTING_COLUMNS = [
|
|
137
|
+
"list_mark INTEGER NOT NULL DEFAULT 1",
|
|
138
|
+
json("listing", true),
|
|
139
|
+
"list_status TEXT",
|
|
140
|
+
"listing_mark INTEGER NOT NULL DEFAULT 0",
|
|
141
|
+
"listing_live INTEGER NOT NULL DEFAULT 0 CHECK (listing_live IN (0, 1))",
|
|
142
|
+
"listing_until INTEGER",
|
|
143
|
+
"listing_flags INTEGER NOT NULL DEFAULT 0",
|
|
144
|
+
];
|
|
145
|
+
/** listing_flags: the run's learning holds items for its owner's OK, read as they stand on its agent's folder now. */
|
|
146
|
+
export const LISTING_HELD = 1;
|
|
147
|
+
/** listing_flags: a failed run's error words, which name a refused key by the server's keys and settings. */
|
|
148
|
+
export const LISTING_KEYED = 2;
|
|
149
|
+
/** A run's status from its row alone, where its row says it (an end that is no person's stop of an agentic run): the status
|
|
150
|
+
* its view reads (store-view.ts STATUS_OF), in SQL. Null for any other run, whose listing says it once it is built. */
|
|
151
|
+
export const SETTLED_LIST_STATUS = `CASE
|
|
152
|
+
WHEN state = 'ended' THEN 'completed'
|
|
153
|
+
WHEN state = 'failed' THEN 'failed'
|
|
154
|
+
WHEN state = 'stopped' AND (outcome IS NULL OR outcome <> 'stopped' OR imported_from IS NOT NULL
|
|
155
|
+
OR (SELECT kind FROM revisions WHERE revisions.id = runs.revision_id) <> 'agentic') THEN 'cancelled'
|
|
156
|
+
ELSE NULL END`;
|
|
157
|
+
/** The listing's indexes and triggers (RUN_LISTING_COLUMNS), after every table they name. A write to a run's row moves its
|
|
158
|
+
* mark and sets its list_status from the row (SETTLED_LIST_STATUS: a settled run's status, else none until its listing
|
|
159
|
+
* is built), so a status filter never reads a status the row has left. The parent trigger moves the mark of the run a
|
|
160
|
+
* learning run grades (learning_proposals.learning_run_id) or an audit's shadow run audits (its id after "audit.",
|
|
161
|
+
* learn/audit.ts shadowRunId), since each run's view reads those. */
|
|
162
|
+
export const RUN_LISTING_DDL = [
|
|
163
|
+
`CREATE INDEX IF NOT EXISTS runs_listing_behind ON runs (started_at) WHERE listing_mark < list_mark`,
|
|
164
|
+
`CREATE INDEX IF NOT EXISTS runs_listing_live ON runs (started_at) WHERE listing_live = 1`,
|
|
165
|
+
`CREATE INDEX IF NOT EXISTS runs_listing_until ON runs (listing_until) WHERE listing_until IS NOT NULL`,
|
|
166
|
+
`CREATE INDEX IF NOT EXISTS runs_by_list_status ON runs (list_status, started_at)`,
|
|
167
|
+
`CREATE INDEX IF NOT EXISTS runs_listing_flagged ON runs (agent_id) WHERE listing_flags <> 0`,
|
|
168
|
+
`CREATE INDEX IF NOT EXISTS learning_proposals_by_learning_run ON learning_proposals (learning_run_id) WHERE learning_run_id IS NOT NULL`,
|
|
169
|
+
`CREATE TRIGGER IF NOT EXISTS runs_list_moved AFTER UPDATE OF state, epoch, runner, cost_usd, cost_upper_bound, metrics, summary, outcome, imported_from, sign_in_handed, labels, ended_at ON runs
|
|
170
|
+
BEGIN
|
|
171
|
+
UPDATE runs SET list_mark = list_mark + 1, list_status = ${SETTLED_LIST_STATUS} WHERE id = NEW.id;
|
|
172
|
+
END`,
|
|
173
|
+
`CREATE TRIGGER IF NOT EXISTS runs_list_parent AFTER UPDATE OF list_mark ON runs
|
|
174
|
+
WHEN substr(NEW.id, 1, 6) = 'audit.' OR EXISTS (SELECT 1 FROM learning_proposals WHERE learning_run_id = NEW.id)
|
|
175
|
+
BEGIN
|
|
176
|
+
UPDATE runs SET list_mark = list_mark + 1
|
|
177
|
+
WHERE (substr(NEW.id, 1, 6) = 'audit.' AND id = substr(NEW.id, 7)) OR id IN (SELECT run_id FROM learning_proposals WHERE learning_run_id = NEW.id);
|
|
178
|
+
END`,
|
|
179
|
+
`CREATE TRIGGER IF NOT EXISTS commands_list_moved AFTER INSERT ON commands
|
|
180
|
+
BEGIN
|
|
181
|
+
UPDATE runs SET list_mark = list_mark + 1 WHERE id = NEW.run_id;
|
|
182
|
+
END`,
|
|
183
|
+
`CREATE TRIGGER IF NOT EXISTS commands_list_settled AFTER UPDATE OF taken_at, refused ON commands
|
|
184
|
+
BEGIN
|
|
185
|
+
UPDATE runs SET list_mark = list_mark + 1 WHERE id = NEW.run_id;
|
|
186
|
+
END`,
|
|
187
|
+
`CREATE TRIGGER IF NOT EXISTS learning_list_moved AFTER INSERT ON learning_proposals
|
|
188
|
+
BEGIN
|
|
189
|
+
UPDATE runs SET list_mark = list_mark + 1 WHERE id = NEW.run_id;
|
|
190
|
+
END`,
|
|
191
|
+
`CREATE TRIGGER IF NOT EXISTS learning_list_changed AFTER UPDATE ON learning_proposals
|
|
192
|
+
BEGIN
|
|
193
|
+
UPDATE runs SET list_mark = list_mark + 1 WHERE id = NEW.run_id;
|
|
194
|
+
END`,
|
|
195
|
+
];
|
|
196
|
+
/** Version 11 → 12 on SQLite (the server's open, sqlite/store.ts), given the runs table's columns now: the listing's columns
|
|
197
|
+
* it lacks, its indexes and triggers, every settled run's status from its row (SETTLED_LIST_STATUS), and the version, in
|
|
198
|
+
* one durable write. Every run starts behind (listing_mark 0 < list_mark 1): the server's lister builds each listing in
|
|
199
|
+
* the background, the runs no runner holds first. */
|
|
200
|
+
export function listingUpgrade(runColumns) {
|
|
201
|
+
return [
|
|
202
|
+
...RUN_LISTING_COLUMNS.filter((column) => !runColumns.has(column.split(" ")[0])).map((column) => `ALTER TABLE runs ADD COLUMN ${column}`),
|
|
203
|
+
...RUN_LISTING_DDL,
|
|
204
|
+
`UPDATE runs SET list_status = ${SETTLED_LIST_STATUS}`,
|
|
205
|
+
"UPDATE store_meta SET schema_version = 12 WHERE singleton = 1",
|
|
206
|
+
];
|
|
207
|
+
}
|
|
85
208
|
export const STORE_DDL = [
|
|
86
209
|
`CREATE TABLE IF NOT EXISTS store_meta (
|
|
87
210
|
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
@@ -171,7 +294,9 @@ export const STORE_DDL = [
|
|
|
171
294
|
-- build of this version made (RUNS_LABELS), its runs reading as given none.
|
|
172
295
|
${json("labels", true)},
|
|
173
296
|
started_at INTEGER NOT NULL,
|
|
174
|
-
ended_at INTEGER
|
|
297
|
+
ended_at INTEGER,
|
|
298
|
+
-- The run's listing (RUN_LISTING_COLUMNS): what a runs list shows of it, kept on its row so a list reads rows alone.
|
|
299
|
+
${RUN_LISTING_COLUMNS.join(",\n ")}
|
|
175
300
|
) STRICT`,
|
|
176
301
|
`CREATE INDEX IF NOT EXISTS runs_by_agent ON runs (agent_id, started_at)`,
|
|
177
302
|
`CREATE INDEX IF NOT EXISTS runs_by_revision ON runs (revision_id, started_at)`,
|
|
@@ -251,6 +376,10 @@ export const STORE_DDL = [
|
|
|
251
376
|
max_active_runs INTEGER CHECK (max_active_runs IS NULL OR max_active_runs BETWEEN 1 AND 100),
|
|
252
377
|
created_at INTEGER NOT NULL,
|
|
253
378
|
updated_at INTEGER NOT NULL,
|
|
379
|
+
-- The template package whose apply made or last kept the trigger (TriggerRow.templateId), null for one a person made:
|
|
380
|
+
-- a template update removes only triggers marked with its own package. Written by the apply alone; a move to another
|
|
381
|
+
-- agent clears it. Added at a server open to a store an earlier build of this version made (TRIGGERS_TEMPLATE_ID).
|
|
382
|
+
template_id TEXT,
|
|
254
383
|
UNIQUE (agent_id, name)
|
|
255
384
|
) STRICT`,
|
|
256
385
|
`CREATE INDEX IF NOT EXISTS triggers_due ON triggers (enabled, next_at)`,
|
|
@@ -409,6 +538,7 @@ export const STORE_DDL = [
|
|
|
409
538
|
) STRICT`,
|
|
410
539
|
IMPORTED_TEMPLATES,
|
|
411
540
|
MINTED_TOKENS,
|
|
541
|
+
RUNNER_RELAYS,
|
|
412
542
|
// An agent's saved browser sign-ins (design 2.1, the browser sign-in rules): one live row per agent and browser provider, its
|
|
413
543
|
// pointer (the vendor's context or profile id) sealed with the store's one rule (store/seal.ts, AAD
|
|
414
544
|
// sign_ins|<agent>:<provider>|pointer), which the store never opens. The owner sees its name ("default") and saved_at,
|
|
@@ -529,6 +659,7 @@ export const STORE_DDL = [
|
|
|
529
659
|
PRIMARY KEY (run_id, round)
|
|
530
660
|
) STRICT`,
|
|
531
661
|
`CREATE INDEX IF NOT EXISTS learning_proposals_by_agent ON learning_proposals (agent_id, created_at DESC)`,
|
|
662
|
+
...RUN_LISTING_DDL,
|
|
532
663
|
];
|
|
533
664
|
/** pi-durable's journal tables (its SqliteStorage schema, version 2, the `sleeping` task status included; MIT, see NOTICE),
|
|
534
665
|
* every one keyed by (run_id, …) with run_id leading its indexes, so one run's scans read only its rows and two runs never
|
|
@@ -4,6 +4,8 @@ import type { Statement, StatementResult } from "./worker.js";
|
|
|
4
4
|
export type { Params, Statement, StatementResult } from "./worker.js";
|
|
5
5
|
/** How long a transaction may stay open (it holds every other call of the process) before it is rolled back. */
|
|
6
6
|
export declare const DEFAULT_TRANSACTION_DEADLINE_MS = 10000;
|
|
7
|
+
/** How long a connection waits for another process's lock on the store file by default (its open's busyTimeoutMs). */
|
|
8
|
+
export declare const DEFAULT_BUSY_TIMEOUT_MS = 10000;
|
|
7
9
|
/** `error` with its stack naming who held the store: `opened` (its own transaction's opener, when it has one), and every
|
|
8
10
|
* other transaction open in this process with its age. */
|
|
9
11
|
export declare function holderNamed<E extends Error>(error: E, { opened }?: {
|
|
@@ -12,6 +12,8 @@ import { ONE_ANSWER_INDEX } from "../schema.js";
|
|
|
12
12
|
import { AnswerTaken, Fenced, RunFinal, StoreBusy, StoreClosed, StoreConstraint, StoreDeadline, StoreOwned, StoreWorkerLost } from "../store.js";
|
|
13
13
|
/** How long a transaction may stay open (it holds every other call of the process) before it is rolled back. */
|
|
14
14
|
export const DEFAULT_TRANSACTION_DEADLINE_MS = 10_000;
|
|
15
|
+
/** How long a connection waits for another process's lock on the store file by default (its open's busyTimeoutMs). */
|
|
16
|
+
export const DEFAULT_BUSY_TIMEOUT_MS = 10_000;
|
|
15
17
|
/** The interactive transactions open in this process, on any of its connections: each with where it was opened and when
|
|
16
18
|
* it began. A transaction's StoreDeadline, and a begin's StoreBusy, name them in their stack (never their message, which
|
|
17
19
|
* an answer may carry), so a log says who held the store: the deadline's own transaction, or another of this process's
|
|
@@ -172,7 +174,7 @@ export class Connection {
|
|
|
172
174
|
return connection.#worker;
|
|
173
175
|
}
|
|
174
176
|
/** Starts the worker and opens `file` in it; `owner` takes the store's owner lock too (StoreOwned when another holds it). */
|
|
175
|
-
static async open(file, { busyTimeoutMs =
|
|
177
|
+
static async open(file, { busyTimeoutMs = DEFAULT_BUSY_TIMEOUT_MS, owner = false } = {}) {
|
|
176
178
|
const execArgv = workerExecArgv(process.execArgv);
|
|
177
179
|
const worker = new Worker(new URL("./worker.js", import.meta.url), execArgv ? { execArgv } : {});
|
|
178
180
|
const connection = new Connection(worker);
|
|
@@ -5,23 +5,6 @@ import { type StoreNow } from "../fence.js";
|
|
|
5
5
|
/** A WHERE condition on `runs`: the run is no built-in learning run (one a kept learning names, queued with it), which no
|
|
6
6
|
* list of runs names. */
|
|
7
7
|
export declare const NOT_A_LEARNING_RUN = "id NOT IN (SELECT learning_run_id FROM learning_proposals WHERE learning_run_id IS NOT NULL)";
|
|
8
|
-
/** A learning run's launch: harness "learning", its input the run that learned (and the round it grades, past the first),
|
|
9
|
-
* where it runs (on the runner, no box: its only writes are the learning folder's one script), `model`, the grade model
|
|
10
|
-
* when one is named (gradeModelOf; none: the agent's own grades it, as main's), and `max_cost_usd`, what the run's cap
|
|
11
|
-
* left for its grade (`capUsd`: a figure that is not one is no room, $0, never no cap; none for an uncapped run). */
|
|
12
|
-
export declare const learningLaunchOf: (runId: string, model?: string, round?: number, capUsd?: number) => {
|
|
13
|
-
max_cost_usd?: number | undefined;
|
|
14
|
-
model?: string | undefined;
|
|
15
|
-
harness: string;
|
|
16
|
-
input: {
|
|
17
|
-
round?: number | undefined;
|
|
18
|
-
runId: string;
|
|
19
|
-
};
|
|
20
|
-
title: string;
|
|
21
|
-
place: {
|
|
22
|
-
mode: string;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
8
|
/** The lock a write of a run's sign_in_handed and a sign-in's forget both take (Dialect.lockKey): the forget's check of
|
|
26
9
|
* the running runs' hashes and a launch's write of them are serialized, as SQLite's one writer serializes them. */
|
|
27
10
|
export declare const SIGN_IN_HANDED_LOCK = "sign_in_handed";
|