@parcha/agentrun-serve 0.1.0-beta.43 → 0.1.0-beta.45
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 +231 -0
- package/README.md +580 -320
- 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 +92 -22
- package/dist/composio-preset.d.ts +4 -3
- package/dist/composio-preset.js +81 -11
- package/dist/composio-triggers.d.ts +34 -2
- package/dist/composio-triggers.js +261 -31
- 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/computer-lost.d.ts +11 -0
- package/dist/computer-lost.js +19 -0
- package/dist/computer-record.d.ts +10 -2
- package/dist/computer-record.js +50 -18
- package/dist/computer-setting.d.ts +1 -0
- package/dist/computer-setting.js +2 -2
- package/dist/computers.d.ts +21 -10
- package/dist/computers.js +39 -28
- package/dist/console/assets/index-3O2Yl6hZ.js +701 -0
- package/dist/console/assets/index-DaFsZuzQ.css +1 -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 +4 -1
- package/dist/errors.js +10 -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 +59 -3
- package/dist/harness-table.js +119 -14
- package/dist/harness.d.ts +17 -1
- package/dist/harness.js +22 -11
- package/dist/host.d.ts +12 -10
- package/dist/host.js +19 -16
- package/dist/import-worker.d.ts +3 -0
- package/dist/import-worker.js +7 -5
- package/dist/import.d.ts +22 -1
- package/dist/import.js +141 -28
- 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 +26 -89
- package/dist/learn/check.js +58 -336
- 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 +88 -103
- package/dist/learn/corrections.d.ts +13 -0
- package/dist/learn/corrections.js +23 -0
- package/dist/learn/delete.d.ts +17 -0
- package/dist/learn/delete.js +42 -0
- 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 +20 -2
- package/dist/learn/promote.js +17 -4
- package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +34 -38
- package/dist/learn/{skills.js → workflow-draft.js} +65 -59
- package/dist/learn/workflow-nodes.d.ts +22 -1
- package/dist/learn/workflow-nodes.js +29 -10
- package/dist/learned-workflow.js +2 -2
- package/dist/learning-cost.d.ts +127 -13
- package/dist/learning-cost.js +142 -10
- package/dist/learning-routes.d.ts +99 -170
- package/dist/learning-routes.js +199 -420
- package/dist/learning-run.d.ts +19 -40
- package/dist/learning-run.js +23 -93
- package/dist/learning-setting.d.ts +4 -4
- package/dist/learning-setting.js +6 -6
- package/dist/learning-words.d.ts +28 -74
- package/dist/learning-words.js +64 -162
- package/dist/learning.d.ts +62 -393
- package/dist/learning.js +101 -651
- package/dist/listen-first.d.ts +30 -0
- package/dist/listen-first.js +115 -0
- package/dist/live-reach.d.ts +25 -2
- package/dist/live-reach.js +46 -4
- package/dist/llms.txt +2 -1
- package/dist/local-models.d.ts +3 -11
- package/dist/local-models.js +5 -6
- package/dist/mcp-servers-store.d.ts +16 -16
- package/dist/model-form.js +6 -5
- package/dist/model.d.ts +12 -4
- package/dist/model.js +41 -16
- 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 +375 -347
- package/dist/owner.d.ts +8 -0
- package/dist/owner.js +11 -0
- package/dist/paid-calls.d.ts +14 -0
- package/dist/paid-calls.js +31 -1
- package/dist/particle-provider.d.ts +11 -0
- package/dist/particle-provider.js +135 -0
- package/dist/place.d.ts +8 -3
- package/dist/place.js +13 -9
- 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 +30 -2
- 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 +16 -90
- package/dist/run-listing.d.ts +34 -0
- package/dist/run-listing.js +128 -0
- package/dist/run-model-key.d.ts +64 -0
- package/dist/run-model-key.js +147 -0
- 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 +14 -6
- package/dist/runner/adapter-loop.js +25 -14
- package/dist/runner/adapter-run-spec.d.ts +22 -7
- package/dist/runner/adapter-run-spec.js +130 -77
- package/dist/runner/adapters/index.d.ts +4 -2
- package/dist/runner/adapters/index.js +35 -4
- package/dist/runner/adapters/pi.d.ts +4 -12
- package/dist/runner/adapters/pi.js +2 -2
- package/dist/runner/audit.d.ts +5 -1
- package/dist/runner/audit.js +31 -12
- package/dist/runner/beside.d.ts +7 -2
- package/dist/runner/beside.js +41 -9
- package/dist/runner/claim-secrets.d.ts +66 -1
- package/dist/runner/claim-secrets.js +136 -3
- package/dist/runner/cli-run-spec.d.ts +2 -1
- package/dist/runner/cli-run-spec.js +82 -59
- package/dist/runner/commands.d.ts +3 -6
- package/dist/runner/conformance/harness.d.ts +6 -0
- package/dist/runner/conformance/harness.js +16 -5
- 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 +5 -4
- package/dist/runner/feedback-round.js +14 -10
- package/dist/runner/github-app.js +3 -1
- package/dist/runner/harness-loops.d.ts +0 -8
- package/dist/runner/harness-loops.js +30 -56
- package/dist/runner/held.d.ts +170 -0
- package/dist/runner/held.js +57 -0
- package/dist/runner/journal-kinds.d.ts +7 -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 -66
- package/dist/runner/learning-end.js +250 -299
- package/dist/runner/learning-seed.d.ts +15 -33
- package/dist/runner/learning-seed.js +24 -45
- package/dist/runner/loop-contract.d.ts +8 -3
- package/dist/runner/loop-contract.js +4 -0
- package/dist/runner/loop.js +6 -2
- package/dist/runner/main.d.ts +18 -9
- package/dist/runner/main.js +82 -22
- package/dist/runner/mcp-run.d.ts +11 -0
- package/dist/runner/mcp-run.js +67 -0
- package/dist/runner/memory-claim.d.ts +14 -6
- package/dist/runner/memory-claim.js +18 -9
- 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 +13 -6
- package/dist/runner/promotion.js +63 -17
- package/dist/runner/reflect-hook.d.ts +64 -91
- package/dist/runner/reflect-hook.js +112 -206
- 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 +1222 -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 +58 -9
- 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 +14 -6
- package/dist/runner/workflow-first.d.ts +5 -0
- package/dist/runner/workflow-first.js +4 -0
- package/dist/runner/workflow-spec.js +17 -4
- package/dist/runs-over-store.d.ts +21 -32
- package/dist/runs-over-store.js +44 -41
- package/dist/sdk/runs.d.ts +6 -11
- package/dist/sdk/runs.js +20 -41
- package/dist/sdk/schema.js +3 -4
- package/dist/sdk/workflows.d.ts +1 -1
- 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 +119 -83
- package/dist/server.js +1121 -419
- 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 +3 -3
- package/dist/store/index.js +2 -2
- 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/seal.d.ts +20 -2
- package/dist/store/seal.js +24 -8
- package/dist/store/sqlite/connection.d.ts +2 -0
- package/dist/store/sqlite/connection.js +3 -1
- package/dist/store/sqlite/run-launch.d.ts +4 -1
- package/dist/store/sqlite/run-launch.js +12 -0
- package/dist/store/sqlite/run-patch.d.ts +0 -17
- package/dist/store/sqlite/run-patch.js +4 -33
- package/dist/store/sqlite/store.d.ts +3 -2
- package/dist/store/sqlite/store.js +360 -75
- package/dist/store/sqlite/worker.js +25 -0
- package/dist/store/store.d.ts +231 -39
- package/dist/store/store.js +25 -3
- package/dist/store-reads/analytics.js +11 -1
- package/dist/store-reads/learning.d.ts +131 -194
- package/dist/store-reads/learning.js +292 -301
- package/dist/store-reads/loop.d.ts +0 -1
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-reads/stats.js +13 -3
- package/dist/store-view.d.ts +34 -2
- package/dist/store-view.js +108 -41
- package/dist/telemetry.d.ts +59 -0
- package/dist/telemetry.js +153 -0
- package/dist/template-eval.d.ts +3 -6
- package/dist/template-eval.js +22 -36
- package/dist/templates.d.ts +2 -1
- package/dist/templates.js +6 -3
- 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/tool-plane.d.ts +12 -12
- package/dist/tools.d.ts +13 -13
- package/dist/tools.js +29 -9
- package/dist/trigger-adapter.d.ts +3 -0
- package/dist/trigger-adapters.d.ts +4 -0
- package/dist/trigger-adapters.js +13 -0
- package/dist/trigger-composio.d.ts +58 -1
- package/dist/trigger-composio.js +160 -6
- package/dist/triggers.d.ts +64 -5
- package/dist/triggers.js +141 -17
- package/dist/validate.d.ts +11 -7
- package/dist/validate.js +9 -8
- package/dist/webhooks.d.ts +4 -1
- package/dist/webhooks.js +11 -4
- 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 +22 -8
- package/dist/workspace/computer-for-claim.js +339 -46
- 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 +41 -21
- 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 -9
- package/templates/README.md +7 -7
- package/templates/inbound-lead/agent.md +3 -3
- 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/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-BrcDSBD8.css +0 -1
- package/dist/console/assets/index-Bz6IWncl.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 -33
- package/dist/learning-evals.js +0 -98
- 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/sdk/runs.d.ts
CHANGED
|
@@ -42,18 +42,14 @@ export type SdkInbox = {
|
|
|
42
42
|
sequence: number;
|
|
43
43
|
events: SdkEvent[];
|
|
44
44
|
}[];
|
|
45
|
-
/** Exact approved skill files delivered by the start receipt; absent on older SDK runs. */
|
|
46
|
-
learning_skills?: SdkSeedSkill[];
|
|
47
45
|
/** Exact approved executable workflows delivered by the start receipt. */
|
|
48
46
|
learning_workflows?: LearnedWorkflow[];
|
|
49
47
|
completion?: SdkCompletion;
|
|
50
48
|
/** Internal terminal admission fence. No later evidence can be newly acknowledged after this CAS wins. */
|
|
51
49
|
closed?: "expired" | "failed" | "cancelled";
|
|
52
50
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
files: Record<string, string>;
|
|
56
|
-
};
|
|
51
|
+
/** The settings key an SDK run's record is kept under (the run's delete with its agent's: agent-delete.ts). */
|
|
52
|
+
export declare const sdkRunKey: (id: string) => string;
|
|
57
53
|
export declare const sdkOf: (body: unknown) => {
|
|
58
54
|
runtime: SdkRuntime;
|
|
59
55
|
} | undefined;
|
|
@@ -76,7 +72,10 @@ export declare class SdkRuns {
|
|
|
76
72
|
token(runId: string): string;
|
|
77
73
|
authenticate(runId: string, token: string): Promise<void>;
|
|
78
74
|
private clean;
|
|
79
|
-
start(entry: AgentEntry, body: Record<string, unknown>, deps: StartDeps, origin: RunOrigin | undefined,
|
|
75
|
+
start(entry: AgentEntry, body: Record<string, unknown>, deps: StartDeps, origin: RunOrigin | undefined, compile: {
|
|
76
|
+
readonly model?: string;
|
|
77
|
+
check(model: string): Promise<void>;
|
|
78
|
+
}, consoleOrigin: string): Promise<{
|
|
80
79
|
run_id: string;
|
|
81
80
|
agent_id: string;
|
|
82
81
|
console_url: string;
|
|
@@ -85,7 +84,6 @@ export declare class SdkRuns {
|
|
|
85
84
|
enabled: boolean;
|
|
86
85
|
revision: string | null;
|
|
87
86
|
context: string;
|
|
88
|
-
skills: SdkSeedSkill[];
|
|
89
87
|
workflows: LearnedWorkflow[];
|
|
90
88
|
};
|
|
91
89
|
}>;
|
|
@@ -98,12 +96,10 @@ export declare class SdkRuns {
|
|
|
98
96
|
enabled: boolean;
|
|
99
97
|
revision: string | null;
|
|
100
98
|
context: string;
|
|
101
|
-
skills: SdkSeedSkill[];
|
|
102
99
|
workflows: LearnedWorkflow[];
|
|
103
100
|
};
|
|
104
101
|
}>;
|
|
105
102
|
private selectedWorkflows;
|
|
106
|
-
private selectedSkills;
|
|
107
103
|
private modify;
|
|
108
104
|
private writable;
|
|
109
105
|
events(runId: string, body: Record<string, unknown>): Promise<{
|
|
@@ -118,4 +114,3 @@ export declare class SdkRuns {
|
|
|
118
114
|
state: string;
|
|
119
115
|
}>;
|
|
120
116
|
}
|
|
121
|
-
export {};
|
package/dist/sdk/runs.js
CHANGED
|
@@ -7,14 +7,15 @@ import { canonical, isObject } from "../store/agent-body.js";
|
|
|
7
7
|
import { uuidv7 } from "../agents-store.js";
|
|
8
8
|
import { launchBody } from "../run-launch.js";
|
|
9
9
|
import { learningStartFor } from "../runs-over-store.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { NATIVE_GRADE_INSTRUCTION_BYTES } from "../learn/grade.js";
|
|
10
|
+
import { chooseWorkflows, learningFolderOf, seedAt, secretsShown } from "../learning.js";
|
|
11
|
+
import { INSTRUCTION_EVIDENCE_BYTES } from "../native/instructions.js";
|
|
13
12
|
import { secretRedactor } from "../runner/redact.js";
|
|
14
13
|
import { redactedOutput } from "../key-refusal.js";
|
|
15
|
-
import { decodedStrings, draftProblems
|
|
14
|
+
import { decodedStrings, draftProblems } from "../learn/workflow-draft.js";
|
|
16
15
|
import { sdkWorkflowManifest, sdkDraftTools } from "./workflows.js";
|
|
17
16
|
const keyOf = (id) => `sdk-run:${id}`;
|
|
17
|
+
/** The settings key an SDK run's record is kept under (the run's delete with its agent's: agent-delete.ts). */
|
|
18
|
+
export const sdkRunKey = keyOf;
|
|
18
19
|
const TEXT_LIMIT = 128_000, BATCH_LIMIT = 256_000, TOTAL_LIMIT = 4_000_000;
|
|
19
20
|
// Always leave enough room for bounded completion after an evidence upload reaches its limit.
|
|
20
21
|
const EVIDENCE_LIMIT = TOTAL_LIMIT - 600_000;
|
|
@@ -157,7 +158,7 @@ export class SdkRuns {
|
|
|
157
158
|
// so treating serialized JSON as prose could remove its delimiters and corrupt the envelope.
|
|
158
159
|
return redactedOutput(body, redact.heldValues?.() ?? []);
|
|
159
160
|
}
|
|
160
|
-
async start(entry, body, deps, origin,
|
|
161
|
+
async start(entry, body, deps, origin, compile, consoleOrigin) {
|
|
161
162
|
only(body, ["runtime", "input", "instructions", "model", "workflow_tools", "workflow_adapters"]);
|
|
162
163
|
const workflow = sdkWorkflowManifest(body.workflow_tools, body.workflow_adapters);
|
|
163
164
|
if (workflow && canonical(this.clean(workflow)) !== canonical(workflow))
|
|
@@ -186,18 +187,20 @@ export class SdkRuns {
|
|
|
186
187
|
const revisionBody = entry.revision.body;
|
|
187
188
|
if (revisionBody.maxCostUsd !== undefined)
|
|
188
189
|
throw new ApiError("agent_not_runnable", "AgentRun cannot enforce a spend cap on an external SDK. Configure the budget in the backend SDK and remove this managed run cap.");
|
|
189
|
-
const learning = await learningStartFor(deps, entry, pinned.revision,
|
|
190
|
+
const learning = await learningStartFor(deps, entry, pinned.revision, revisionBody, {
|
|
191
|
+
noWorkflows: !workflow,
|
|
192
|
+
...(compile.model ? { model: compile.model } : {}),
|
|
193
|
+
});
|
|
190
194
|
if (learning) {
|
|
191
|
-
if (Buffer.byteLength(instructions) >
|
|
192
|
-
refuse("Original SDK instructions exceed the 64 KiB
|
|
193
|
-
if (!learning.
|
|
194
|
-
throw new ApiError("agent_not_runnable", "Self-improving SDK runs need a server
|
|
195
|
-
await
|
|
195
|
+
if (Buffer.byteLength(instructions) > INSTRUCTION_EVIDENCE_BYTES)
|
|
196
|
+
refuse("Original SDK instructions exceed the 64 KiB learning evidence limit. Keep learning off or provide a complete policy within that limit.");
|
|
197
|
+
if (!learning.model)
|
|
198
|
+
throw new ApiError("agent_not_runnable", "Self-improving SDK runs need a server model and its model key to compile workflows. Configure the model or turn self-improving off.");
|
|
199
|
+
await compile.check(learning.model);
|
|
196
200
|
if (learning.seedFailed)
|
|
197
201
|
throw new ApiError("unavailable", "The learning seed could not be read. Retry after restoring the agent learning folder.");
|
|
198
202
|
}
|
|
199
|
-
const
|
|
200
|
-
const workflows = learning && !learning.notesOnly && workflow ? await this.selectedWorkflows(entry.agent.id, learning.seed, workflow) : [];
|
|
203
|
+
const workflows = learning && !learning.noWorkflows && workflow ? await this.selectedWorkflows(entry.agent.id, learning.seed, workflow) : [];
|
|
201
204
|
const cleaned = this.clean({ instructions, ...(model ? { model } : {}) });
|
|
202
205
|
const runId = uuidv7();
|
|
203
206
|
const launch = {
|
|
@@ -211,7 +214,7 @@ export class SdkRuns {
|
|
|
211
214
|
instructions: cleaned.instructions,
|
|
212
215
|
...(cleaned.model ? { model: cleaned.model } : {}),
|
|
213
216
|
},
|
|
214
|
-
...(learning ? { learning: { ...learning,
|
|
217
|
+
...(learning ? { learning: { ...learning, workflows: workflows.map((flow) => flow.name) } } : {}),
|
|
215
218
|
};
|
|
216
219
|
const now = Date.now();
|
|
217
220
|
await this.store.settings.put(keyOf(runId), {
|
|
@@ -219,7 +222,6 @@ export class SdkRuns {
|
|
|
219
222
|
created_at: now,
|
|
220
223
|
expires_at: now + 3_600_000,
|
|
221
224
|
batches: [],
|
|
222
|
-
learning_skills: skills,
|
|
223
225
|
learning_workflows: workflows,
|
|
224
226
|
});
|
|
225
227
|
try {
|
|
@@ -236,25 +238,14 @@ export class SdkRuns {
|
|
|
236
238
|
if (!run)
|
|
237
239
|
throw new ApiError("not_found", "SDK run not found.");
|
|
238
240
|
const launch = (await this.store.runs.launch(runId)).body;
|
|
239
|
-
|
|
240
|
-
if (inbox.learning_skills === undefined) {
|
|
241
|
-
// Older runs did not persist their delivered files. Pin a receipt from their original
|
|
242
|
-
// commit now; do not claim these reconstructed files were supplied on an earlier attempt.
|
|
243
|
-
const skills = launch.learning ? await this.selectedSkills(run.agentId, launch.learning.seed) : [];
|
|
244
|
-
await this.modify(runId, (row) => row.learning_skills === undefined ? { ...row, learning_skills: skills } : row);
|
|
245
|
-
inbox = await sdkInbox(this.store, runId);
|
|
246
|
-
}
|
|
247
|
-
const skills = inbox.learning_skills ?? [];
|
|
248
|
-
// Older SDK receipts never included executable workflows. Do not retroactively deliver one.
|
|
241
|
+
const inbox = await sdkInbox(this.store, runId);
|
|
249
242
|
const workflows = inbox.learning_workflows ?? [];
|
|
250
243
|
const shown = secretsShown(this.secrets(), { local: true });
|
|
251
244
|
if (shown.holds(launch.learning?.section ?? "") ||
|
|
252
245
|
workflows.some((flow) => {
|
|
253
246
|
const decoded = decodedStrings(flow.workflow);
|
|
254
247
|
return shown.holds(flow.name) || shown.holds(flow.description) || shown.holds(flow.workflow) || decoded === "too_deep" || decoded.some(shown.holds);
|
|
255
|
-
})
|
|
256
|
-
skills.some((skill) => shown.holds(skill.name) ||
|
|
257
|
-
Object.entries(skill.files).some(([path, text]) => shown.holds(path) || shown.holds(text) || (path === "SKILL.md" && shown.holds(servedSkill(text))))))
|
|
248
|
+
}))
|
|
258
249
|
throw new ApiError("unavailable", "The pinned SDK learning contains a protected value. Start a new run to receive a fresh safe seed.");
|
|
259
250
|
return {
|
|
260
251
|
run_id: runId,
|
|
@@ -265,7 +256,6 @@ export class SdkRuns {
|
|
|
265
256
|
enabled: !!launch.learning,
|
|
266
257
|
revision: launch.learning?.seed ?? null,
|
|
267
258
|
context: launch.learning?.section ?? "",
|
|
268
|
-
skills,
|
|
269
259
|
workflows,
|
|
270
260
|
},
|
|
271
261
|
};
|
|
@@ -273,7 +263,7 @@ export class SdkRuns {
|
|
|
273
263
|
async selectedWorkflows(agentId, revision, binding) {
|
|
274
264
|
const folder = learningFolderOf(this.data, agentId);
|
|
275
265
|
try {
|
|
276
|
-
const seed = await
|
|
266
|
+
const seed = await seedAt(folder.workspace, revision);
|
|
277
267
|
const { flows } = chooseWorkflows(seed, secretsShown(this.secrets(), { local: true }));
|
|
278
268
|
const dsl = await import("@parcha/agentrun-dsl");
|
|
279
269
|
const { tools, gated, deniedBy } = sdkDraftTools(binding.workflow_tools);
|
|
@@ -290,17 +280,6 @@ export class SdkRuns {
|
|
|
290
280
|
await folder.end();
|
|
291
281
|
}
|
|
292
282
|
}
|
|
293
|
-
async selectedSkills(agentId, revision) {
|
|
294
|
-
const folder = learningFolderOf(this.data, agentId);
|
|
295
|
-
try {
|
|
296
|
-
const seed = await seedFrom(revision, readerOf(folder.workspace));
|
|
297
|
-
const { taken } = await chooseSkills(folder.workspace, seed, [], secretsShown(this.secrets(), { local: true }));
|
|
298
|
-
return taken.map((skill) => ({ name: skill.name, files: { ...skill.files } }));
|
|
299
|
-
}
|
|
300
|
-
finally {
|
|
301
|
-
await folder.end();
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
283
|
async modify(runId, change, limit = TOTAL_LIMIT) {
|
|
305
284
|
for (let retry = 0; retry < 20; retry++) {
|
|
306
285
|
const old = await sdkInbox(this.store, runId), next = change(old);
|
package/dist/sdk/schema.js
CHANGED
|
@@ -48,9 +48,8 @@ const errors = Object.fromEntries([400, 401, 404, 409, 413, 422, 503].map((statu
|
|
|
48
48
|
const learning = object({
|
|
49
49
|
enabled: { type: "boolean" },
|
|
50
50
|
revision: { type: ["string", "null"] },
|
|
51
|
-
context: text,
|
|
52
|
-
|
|
53
|
-
workflows: { type: "array", items: object({ name: text, workflow: text, description: text }), description: "Approved, capability-compatible workflows pinned to this run; empty without a backend workflow bridge or when learning is notes-only or Off." },
|
|
51
|
+
context: { ...text, description: "The agent's corrections.md as the run reads it under # Learned; empty when Off or nothing is learned yet." },
|
|
52
|
+
workflows: { type: "array", items: object({ name: text, workflow: text, description: text }), description: "Active, capability-compatible learned workflows pinned to this run; empty without a backend workflow bridge or when learning is Off." },
|
|
54
53
|
});
|
|
55
54
|
export const SDK_PATHS = {
|
|
56
55
|
"/agents/{agent_id}/sdk-runs": {
|
|
@@ -92,7 +91,7 @@ export const SDK_PATHS = {
|
|
|
92
91
|
...mark,
|
|
93
92
|
operationId: "getSdkRun",
|
|
94
93
|
summary: "Read SDK run and learning state",
|
|
95
|
-
description: "Use the scoped token returned by startSdkRun. A completed task can still
|
|
94
|
+
description: "Use the scoped token returned by startSdkRun. A completed task can still be reflecting while its compile turn runs. The learning field is the ordinary run learning view.",
|
|
96
95
|
parameters: [id("run_id")],
|
|
97
96
|
responses: {
|
|
98
97
|
200: response(object({
|
package/dist/sdk/workflows.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare function sdkWorkflowManifest(tools: unknown, adapters: unknown):
|
|
|
14
14
|
export declare function sdkDraftTools(manifest: readonly SdkWorkflowTool[]): {
|
|
15
15
|
tools: string[];
|
|
16
16
|
gated: {
|
|
17
|
-
[k: string]: "
|
|
17
|
+
[k: string]: "ask" | "allow" | "deny";
|
|
18
18
|
};
|
|
19
19
|
deniedBy: {
|
|
20
20
|
[k: string]: "agent";
|
package/dist/seal-key.d.ts
CHANGED
|
@@ -32,6 +32,11 @@ export type BootedSealKey = SealKey & {
|
|
|
32
32
|
export declare function ensureSealKey(given: string | undefined, { dataDir }: {
|
|
33
33
|
dataDir: string;
|
|
34
34
|
}): SealKey;
|
|
35
|
+
/** The digest a template apply keeps of its parameters (`text`: their stable JSON), in place of the parameters: an
|
|
36
|
+
* HMAC-SHA256 of it under a key drawn from the seal key `key` by a label of its own, so the store holds neither a
|
|
37
|
+
* parameter (one may be a credential) nor a hash a guess could be checked against without the seal key. The same
|
|
38
|
+
* parameters under the same seal key give the same digest. */
|
|
39
|
+
export declare const parametersDigest: (key: Buffer, text: string) => string;
|
|
35
40
|
/** The fingerprint the store records of `key`: an HMAC of a fixed label under it. Neither the key nor a hash of it alone. */
|
|
36
41
|
export declare const sealKeyFingerprint: (key: Buffer) => string;
|
|
37
42
|
/** The store slice the check reads and writes. */
|
package/dist/seal-key.js
CHANGED
|
@@ -151,6 +151,13 @@ export function ensureSealKey(given, { dataDir }) {
|
|
|
151
151
|
throw refused(`${join(dir, SEAL_KEY_FILE)} could not be read back`);
|
|
152
152
|
return { ...made, generated };
|
|
153
153
|
}
|
|
154
|
+
/** The label the key of a template apply's parameters digest is drawn from the seal key by: that key is no other's. */
|
|
155
|
+
const PARAMETERS_DIGEST_LABEL = "agentrun template parameters digest v1";
|
|
156
|
+
/** The digest a template apply keeps of its parameters (`text`: their stable JSON), in place of the parameters: an
|
|
157
|
+
* HMAC-SHA256 of it under a key drawn from the seal key `key` by a label of its own, so the store holds neither a
|
|
158
|
+
* parameter (one may be a credential) nor a hash a guess could be checked against without the seal key. The same
|
|
159
|
+
* parameters under the same seal key give the same digest. */
|
|
160
|
+
export const parametersDigest = (key, text) => createHmac("sha256", createHmac("sha256", key).update(PARAMETERS_DIGEST_LABEL).digest()).update(text).digest("base64url");
|
|
154
161
|
/** The fingerprint the store records of `key`: an HMAC of a fixed label under it. Neither the key nor a hash of it alone. */
|
|
155
162
|
export const sealKeyFingerprint = (key) => createHmac("sha256", key).update(FINGERPRINT_LABEL).digest("base64url");
|
|
156
163
|
/** The fingerprint a store setting's value records: undefined with none, null for one that does not read. */
|
package/dist/secrets.d.ts
CHANGED
|
@@ -12,6 +12,9 @@ export declare const MCP_AUTH = "AGENTRUN_MCP_AUTH";
|
|
|
12
12
|
/** The decision keys among them: a run's process gets them only on its decision descriptor (decisions.ts), never with
|
|
13
13
|
* the secrets on its pipe, which are its tools' environment. */
|
|
14
14
|
export declare const DECISION_KEYS: readonly string[];
|
|
15
|
+
/** NAME=VALUE pairs, each ended by a NUL: what a pipe of secrets carries. A runner writes a run's own process its pairs
|
|
16
|
+
* with it (run-child-host.ts), as a launcher writes its server's. */
|
|
17
|
+
export declare const encode: (pairs: Iterable<readonly [string, string]>) => Buffer;
|
|
15
18
|
/** Reads a tool key a person saved through a server's settings API (tool-keys.ts), by name, opened when asked for. Each
|
|
16
19
|
* server hands its own to what reads for it (its reading, its runs' handover), never through this module, so two
|
|
17
20
|
* servers in one process never read each other's saved keys. A run's process has none: it gets what it needs over its
|
package/dist/secrets.js
CHANGED
|
@@ -39,8 +39,9 @@ let handed;
|
|
|
39
39
|
* the secrets, so it is no tool's environment and no key a scan looks for by name. */
|
|
40
40
|
const SIGN_IN_PAIR = "AGENTRUN_SIGN_IN";
|
|
41
41
|
let signIn;
|
|
42
|
-
/** NAME=VALUE pairs, each ended by a NUL.
|
|
43
|
-
|
|
42
|
+
/** NAME=VALUE pairs, each ended by a NUL: what a pipe of secrets carries. A runner writes a run's own process its pairs
|
|
43
|
+
* with it (run-child-host.ts), as a launcher writes its server's. */
|
|
44
|
+
export const encode = (pairs) => Buffer.concat([...pairs].map(([name, value]) => Buffer.from(`${name}=${value}\0`)));
|
|
44
45
|
function decode(bytes) {
|
|
45
46
|
for (const pair of bytes.toString("utf8").split("\0")) {
|
|
46
47
|
const at = pair.indexOf("=");
|
|
@@ -54,8 +55,20 @@ function decode(bytes) {
|
|
|
54
55
|
* gone short, and refused. */
|
|
55
56
|
function readExactly(fd, length) {
|
|
56
57
|
const bytes = Buffer.alloc(length);
|
|
58
|
+
// A run's process gets its pipe from Node's spawn as a socket that does not block: a read before the runner's write
|
|
59
|
+
// lands is EAGAIN, waited out here for as long as a slow start may take, never past it.
|
|
60
|
+
const until = Date.now() + 60_000;
|
|
57
61
|
for (let read = 0; read < length;) {
|
|
58
|
-
|
|
62
|
+
let got;
|
|
63
|
+
try {
|
|
64
|
+
got = readSync(fd, bytes, read, length - read, null);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error.code !== "EAGAIN" || Date.now() > until)
|
|
68
|
+
throw error;
|
|
69
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 5);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
59
72
|
if (got === 0)
|
|
60
73
|
throw new Error(`the secrets' pipe ended after ${read} of ${length} bytes`);
|
|
61
74
|
read += got;
|