@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/templates.js
CHANGED
|
@@ -29,6 +29,7 @@ import { definitionBodyIssues, inputIssues, inputSchemaOf, isObject, MODEL_REF,
|
|
|
29
29
|
import { schemaCheck } from "./answer-json.js";
|
|
30
30
|
import { webFixtureOf } from "./web-fake.js";
|
|
31
31
|
import { APPROVALS } from "./approvals.js";
|
|
32
|
+
import { agreeOnOf, learningSettingIssue, learningSettingOf, pathSegments } from "./learning-setting.js";
|
|
32
33
|
export const TEMPLATES_DIR = fileURLToPath(new URL("../templates/", import.meta.url));
|
|
33
34
|
export const MANIFEST = "agent.md";
|
|
34
35
|
/** A package's model tier, mapped to the server's own (model.ts Tier: AGENT_MODEL_FAST, AGENT_MODEL, AGENT_MODEL_STRONG). */
|
|
@@ -152,6 +153,26 @@ export class PackageError extends Error {
|
|
|
152
153
|
this.problems = problems;
|
|
153
154
|
}
|
|
154
155
|
}
|
|
156
|
+
/** Why an agree_on path is not a required field of the answer's JSON Schema at every level, in words; undefined when it
|
|
157
|
+
* is (each segment a property of an object schema's `properties`, named in its `required`, and each parent typed
|
|
158
|
+
* `object` alone: one that may be null or another type holds no path, even on two identical answers). */
|
|
159
|
+
function undeclaredPath(schema, path) {
|
|
160
|
+
let node = schema;
|
|
161
|
+
const segments = pathSegments(path);
|
|
162
|
+
for (const [i, segment] of segments.entries()) {
|
|
163
|
+
const of = i ? segments.slice(0, i).join(".") : "the answer";
|
|
164
|
+
if (!(isObject(node) && node.type === "object"))
|
|
165
|
+
return `does not make ${of} an object only: an answer may give it as null or another type, and a path through it never resolves`;
|
|
166
|
+
const properties = isObject(node) && isObject(node.properties) ? node.properties : undefined;
|
|
167
|
+
if (!properties || !Object.hasOwn(properties, segment))
|
|
168
|
+
return `does not declare: ${segment} is no property of ${of}`;
|
|
169
|
+
const required = node.required;
|
|
170
|
+
if (!(Array.isArray(required) && required.includes(segment)))
|
|
171
|
+
return `does not require: an answer may leave ${segment} out of ${of}, and a path missing on both sides never agrees`;
|
|
172
|
+
node = properties[segment];
|
|
173
|
+
}
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
155
176
|
/** The source kinds whose accept rules a parameter may fill: a github trigger's, a webhook trigger's (a provider that
|
|
156
177
|
* sends every trigger of a project to one URL is filtered to the owner's own repository by them), a composio
|
|
157
178
|
* trigger's, and a feed trigger's (the pull requests of one author, say). */
|
|
@@ -674,8 +695,9 @@ export function readPackage(from, { evalFixtures = true } = {}) {
|
|
|
674
695
|
const perRun = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
675
696
|
if (f.budget !== undefined && !(isObject(f.budget) && !unknownFields(f.budget, ["per_run_usd"]).length && perRun(f.budget.per_run_usd)))
|
|
676
697
|
bad(MANIFEST, "budget is {per_run_usd: a number above 0}");
|
|
677
|
-
|
|
678
|
-
|
|
698
|
+
const learningIssue = f.learning === undefined ? undefined : learningSettingIssue(f.learning, "learning");
|
|
699
|
+
if (learningIssue)
|
|
700
|
+
bad(MANIFEST, learningIssue);
|
|
679
701
|
if (f.approvals !== undefined && f.approvals !== "ask" && f.approvals !== "never")
|
|
680
702
|
bad(MANIFEST, "approvals is ask (the agent asks its person before a tool runs) or never (it runs unattended; deny and pins still hold)");
|
|
681
703
|
const triggers = f.triggers === undefined ? [] : Array.isArray(f.triggers) ? f.triggers : (bad(MANIFEST, "triggers is a list of POST /v2/triggers bodies"), []);
|
|
@@ -731,6 +753,19 @@ export function readPackage(from, { evalFixtures = true } = {}) {
|
|
|
731
753
|
}
|
|
732
754
|
}
|
|
733
755
|
}
|
|
756
|
+
// Each agree_on path is a required field of the answer's schema at every level: one an answer may leave out is
|
|
757
|
+
// missing on both sides, and a missing path never agrees, so the check could never promote on it.
|
|
758
|
+
// With no output schema there is nothing to check the paths against, and nothing makes an answer hold them: refused.
|
|
759
|
+
if (!learningIssue && f.output === undefined && (agreeOnOf(f.learning) ?? []).length) {
|
|
760
|
+
bad(MANIFEST, "learning.agree_on names fields of the answer, so the package declares the answer's schema (output: {schema}) that holds them");
|
|
761
|
+
}
|
|
762
|
+
if (!learningIssue && isObject(outputSchema)) {
|
|
763
|
+
for (const [i, path] of (agreeOnOf(f.learning) ?? []).entries()) {
|
|
764
|
+
const why = undeclaredPath(outputSchema, path);
|
|
765
|
+
if (why)
|
|
766
|
+
bad(MANIFEST, `learning.agree_on[${i}] is ${path}, which ${f.output.schema} ${why}`);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
734
769
|
const instructions = manifest?.body.trim() ?? "";
|
|
735
770
|
if (manifest && !instructions)
|
|
736
771
|
bad(MANIFEST, "its body is empty: the body is the agent's instructions");
|
|
@@ -904,7 +939,7 @@ export function readPackage(from, { evalFixtures = true } = {}) {
|
|
|
904
939
|
...(typeof f.license === "string" ? { license: f.license } : {}), ...(isObject(f.author) ? { author: f.author } : {}), ...(typeof f.repository === "string" ? { repository: f.repository } : {}),
|
|
905
940
|
...(typeof f.category === "string" ? { category: f.category } : {}), tags,
|
|
906
941
|
...(harness ? { harness } : {}), ...(isObject(f.model) ? { model: { ...f.model, ...(choices ? { choices } : {}) } } : {}), ...(typeof f.effort === "string" ? { effort: f.effort } : {}),
|
|
907
|
-
...(tools ? { tools } : {}), mcp, ...(computer ? { computer } : {}), ...(toolPolicy ? { toolPolicy } : {}), ...(f.checkout === "pull_request" ? { checkout: "pull_request" } : {}), parameters, ...(inputSchema ? { inputSchema } : {}), secrets, ...(isObject(f.budget) ? { budget: { per_run_usd: f.budget.per_run_usd } } : {}), ...(
|
|
942
|
+
...(tools ? { tools } : {}), mcp, ...(computer ? { computer } : {}), ...(toolPolicy ? { toolPolicy } : {}), ...(f.checkout === "pull_request" ? { checkout: "pull_request" } : {}), parameters, ...(inputSchema ? { inputSchema } : {}), secrets, ...(isObject(f.budget) ? { budget: { per_run_usd: f.budget.per_run_usd } } : {}), ...(f.learning !== undefined ? { learning: learningSettingOf(f.learning) } : {}), ...(f.approvals === "ask" || f.approvals === "never" ? { approvals: f.approvals } : {}),
|
|
908
943
|
triggers: triggers, ...(isObject(f.output) ? { output: { schema: f.output.schema } } : {}), ...(isObject(outputSchema) ? { outputSchema } : {}), instructions, skills, evals,
|
|
909
944
|
};
|
|
910
945
|
// What an apply makes, made here with each parameter's default, else a sample of its type, and checked as POST
|
|
@@ -1027,12 +1062,15 @@ export class TemplateRegistry {
|
|
|
1027
1062
|
return this.imported.delete(id);
|
|
1028
1063
|
}
|
|
1029
1064
|
}
|
|
1030
|
-
/** POST /v2/templates/{name}/apply's body (`{parameters, grants?, overrides?: {model?, choice?, approvals?}}`), checked
|
|
1065
|
+
/** POST /v2/templates/{name}/apply's body (`{parameters, grants?, servers?, overrides?: {model?, choice?, approvals?}, agent_id?}`), checked
|
|
1031
1066
|
* against the package: the parameters as given (a blank one at its default), the MCP tools the owner allows (each one the
|
|
1032
1067
|
* package lists, by its gate name), and the model asked for in place of the package's: one of its own (`model`), or one
|
|
1033
1068
|
* of the package's model choices by id (`choice`), never both. 422 naming every field that is wrong. */
|
|
1034
1069
|
export function applyBodyOf(p, body) {
|
|
1035
|
-
const issues = unknownFields(body, ["parameters", "grants", "servers", "overrides"]);
|
|
1070
|
+
const issues = unknownFields(body, ["parameters", "grants", "servers", "overrides", "agent_id"]);
|
|
1071
|
+
// The agent an update writes onto (the server checks it was made from this package): text, else a 422 with the rest.
|
|
1072
|
+
if (body.agent_id !== undefined && !(typeof body.agent_id === "string" && body.agent_id.trim()))
|
|
1073
|
+
issues.push({ field: "agent_id", reason: "wrong_type", message: `agent_id is the id of an agent the ${p.name} template made: the apply writes a new revision of it in place of making another` });
|
|
1036
1074
|
const listed = p.mcp.flatMap(({ toolkit, tools }) => tools.map((tool) => mcpToolName(toolkit, tool)));
|
|
1037
1075
|
const grants = [];
|
|
1038
1076
|
if (body.grants !== undefined && !Array.isArray(body.grants))
|
|
@@ -1088,7 +1126,7 @@ export function applyBodyOf(p, body) {
|
|
|
1088
1126
|
}
|
|
1089
1127
|
if (issues.length)
|
|
1090
1128
|
throw invalid(issues);
|
|
1091
|
-
return { parameters, grants, servers, ...(isObject(overrides) && typeof overrides.model === "string" ? { model: overrides.model } : {}), ...(choice ? { choice } : {}), ...(isObject(overrides) && (overrides.approvals === "ask" || overrides.approvals === "never") ? { approvals: overrides.approvals } : {}) };
|
|
1129
|
+
return { parameters, grants, servers, ...(typeof body.agent_id === "string" ? { agentId: body.agent_id.trim() } : {}), ...(isObject(overrides) && typeof overrides.model === "string" ? { model: overrides.model } : {}), ...(choice ? { choice } : {}), ...(isObject(overrides) && (overrides.approvals === "ask" || overrides.approvals === "never") ? { approvals: overrides.approvals } : {}) };
|
|
1092
1130
|
}
|
|
1093
1131
|
/** The model a package's agent gets here, as `{model?, warning?}`: its `prefer` when this server runs it on `harness`
|
|
1094
1132
|
* with a key for its provider, else `refused` (preferUnrunnable): apply makes nothing, never the tier's model in its
|
package/dist/timeline/index.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export { costLabel, endedUsage, PAGE_CHANGED_ROW, RUN_RESUMED, toolCallWords, TU
|
|
|
6
6
|
export { FEEDBACK_SUFFIX, isFeedbackRow, isMessageRow, isUserEntry, MESSAGE_ORIGIN, messageOrigins, NOTE_SUFFIX, originMatcher, originOf, TRIGGER_LABELS, TRIGGER_SOURCES, type MessageOrigin, type TriggerSource } from "./origin.js";
|
|
7
7
|
export { cut, scrubUrl, scrubUrls } from "./util.js";
|
|
8
8
|
export { webCut, webShownOf, webWithin, type WebShown } from "./web-calls.js";
|
|
9
|
-
export { BROWSER_CHARGE, CALL_ENDED_WITH_RUN, CALL_REFUSED, CALL_RESULT_CHARS, CAP_WRAPUP, CAPS, chargedTool, COMPUTER_NOTE, endedOnTurnEndingTool, HOST_PHASE, METRIC_NAMES, REQUEST_CONTINUED, REQUEST_COST, REQUEST_COST_LATE, REQUEST_COST_PENDING, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, runMetricsOf, runMetricsWithDecisions, timelineOf, timelineReducer, TOOL_COST, TOOL_STARTED, TOOL_UNMETERED, type AgentEventLike, type DecisionLike, type EntryLike, type RunMetrics, type SideSpend, type TimelineEvent, type TimelineKind, type TimelineOptions, type ToolMetrics, } from "./timeline.js";
|
|
9
|
+
export { answeredRequests, BROWSER_CHARGE, CALL_ENDED_WITH_RUN, CALL_REFUSED, CALL_RESULT_CHARS, CAP_WRAPUP, CAPS, chargedTool, COMPUTER_NOTE, endedOnTurnEndingTool, HOST_PHASE, METRIC_NAMES, REQUEST_CONTINUED, REQUEST_COST, REQUEST_COST_LATE, REQUEST_COST_PENDING, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, runMetricsOf, runMetricsWithDecisions, timelineOf, timelineReducer, TOOL_COST, TOOL_STARTED, TOOL_UNMETERED, type AgentEventLike, type DecisionLike, type EntryLike, type RunMetrics, type SideSpend, type TimelineEvent, type TimelineKind, type TimelineOptions, type ToolMetrics, } from "./timeline.js";
|
package/dist/timeline/index.js
CHANGED
|
@@ -6,4 +6,4 @@ export { costLabel, endedUsage, PAGE_CHANGED_ROW, RUN_RESUMED, toolCallWords, TU
|
|
|
6
6
|
export { FEEDBACK_SUFFIX, isFeedbackRow, isMessageRow, isUserEntry, MESSAGE_ORIGIN, messageOrigins, NOTE_SUFFIX, originMatcher, originOf, TRIGGER_LABELS, TRIGGER_SOURCES } from "./origin.js";
|
|
7
7
|
export { cut, scrubUrl, scrubUrls } from "./util.js";
|
|
8
8
|
export { webCut, webShownOf, webWithin } from "./web-calls.js";
|
|
9
|
-
export { BROWSER_CHARGE, CALL_ENDED_WITH_RUN, CALL_REFUSED, CALL_RESULT_CHARS, CAP_WRAPUP, CAPS, chargedTool, COMPUTER_NOTE, endedOnTurnEndingTool, HOST_PHASE, METRIC_NAMES, REQUEST_CONTINUED, REQUEST_COST, REQUEST_COST_LATE, REQUEST_COST_PENDING, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, runMetricsOf, runMetricsWithDecisions, timelineOf, timelineReducer, TOOL_COST, TOOL_STARTED, TOOL_UNMETERED, } from "./timeline.js";
|
|
9
|
+
export { answeredRequests, BROWSER_CHARGE, CALL_ENDED_WITH_RUN, CALL_REFUSED, CALL_RESULT_CHARS, CAP_WRAPUP, CAPS, chargedTool, COMPUTER_NOTE, endedOnTurnEndingTool, HOST_PHASE, METRIC_NAMES, REQUEST_CONTINUED, REQUEST_COST, REQUEST_COST_LATE, REQUEST_COST_PENDING, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, runMetricsOf, runMetricsWithDecisions, timelineOf, timelineReducer, TOOL_COST, TOOL_STARTED, TOOL_UNMETERED, } from "./timeline.js";
|
|
@@ -5,7 +5,7 @@ import type { ComputerCallRow } from "./computer.js";
|
|
|
5
5
|
export type TimelineKind = "thinking" | "text_block" | "tool_use" | "tool_result" | "phase" | "subagent_started" | "subagent_progress" | "subagent_completed" | "final_answer" | "error" | "user_message" | "waiting" | "usage"
|
|
6
6
|
/** A workflow decision: a judge's answers or a route's branch (serve's decision rows). */
|
|
7
7
|
| "decision"
|
|
8
|
-
/** Where a run's learning ended:
|
|
8
|
+
/** Where a run's learning ended: merged or dropped (serve's learning row). */
|
|
9
9
|
| "learning"
|
|
10
10
|
/** A tool call that waited for a person's approval, after its result's row (serve's tool gate). */
|
|
11
11
|
| "tool_approval_requested";
|
|
@@ -365,3 +365,7 @@ export declare function timelineReducer(options?: TimelineOptions): {
|
|
|
365
365
|
* conversation no longer holds it. */
|
|
366
366
|
isLive: (id: string) => boolean;
|
|
367
367
|
};
|
|
368
|
+
/** The run's model requests that an answer of pi's carries, in log order: each `pi.assistant` entry the usage row counts
|
|
369
|
+
* as a request (createMeter's "answer"). A request the cap or the proxy refused before it left, a continuation of the
|
|
370
|
+
* answer before it and a call the loop's record kept (`recordedCall`) are none. An entry seen twice counts once. */
|
|
371
|
+
export declare function answeredRequests(entries: readonly EntryLike[]): EntryLike[];
|
|
@@ -1467,3 +1467,19 @@ export function timelineReducer(options = {}) {
|
|
|
1467
1467
|
isLive: (id) => liveIds.has(id),
|
|
1468
1468
|
};
|
|
1469
1469
|
}
|
|
1470
|
+
/** The run's model requests that an answer of pi's carries, in log order: each `pi.assistant` entry the usage row counts
|
|
1471
|
+
* as a request (createMeter's "answer"). A request the cap or the proxy refused before it left, a continuation of the
|
|
1472
|
+
* answer before it and a call the loop's record kept (`recordedCall`) are none. An entry seen twice counts once. */
|
|
1473
|
+
export function answeredRequests(entries) {
|
|
1474
|
+
const meter = createMeter();
|
|
1475
|
+
const seen = new Set();
|
|
1476
|
+
return entries.filter((entry) => {
|
|
1477
|
+
if (entry.id !== undefined) {
|
|
1478
|
+
const key = `${entry.conversationId ?? 0}:${entry.id}`;
|
|
1479
|
+
if (seen.has(key))
|
|
1480
|
+
return false;
|
|
1481
|
+
seen.add(key);
|
|
1482
|
+
}
|
|
1483
|
+
return meter.push(entry) === "answer";
|
|
1484
|
+
});
|
|
1485
|
+
}
|
package/dist/tool-gate.d.ts
CHANGED
|
@@ -157,13 +157,6 @@ export declare const noApproverText: (tool: string, ran?: "no" | "unknown", beca
|
|
|
157
157
|
export declare const APPROVAL_ROW: "tool_approval_requested";
|
|
158
158
|
/** A call's arguments shown on its approval, at most this many bytes. */
|
|
159
159
|
export declare const ARGS_PREVIEW_BYTES = 2048;
|
|
160
|
-
/** The refusal of the end-of-run turn's write or edit under work/.learning/: its notes are kept only from its answer's
|
|
161
|
-
* note blocks (learn/reflect.ts parseReflection), which the host merges in its own store; a file there is never kept. */
|
|
162
|
-
export declare const NOTE_ONLY_TEXT = "A note is kept only from your answer: write it in a ```note block, not to a file.";
|
|
163
|
-
/** Whether `args.path`, as a file tool resolves it (a leading `@` dropped, Unicode spaces made plain, then the port's
|
|
164
|
-
* path of it, portPath), names .learning/ in the run's folder or a path under it: by the folder's path here (`work`)
|
|
165
|
-
* or a computer's name for it (COMPUTER_ROOT). */
|
|
166
|
-
export declare function underLearning(work: string, args: unknown): boolean;
|
|
167
160
|
/** One call that waits for approval, as the run's store keeps it. */
|
|
168
161
|
export type ApprovalRequest = {
|
|
169
162
|
id: string;
|
package/dist/tool-gate.js
CHANGED
|
@@ -26,8 +26,7 @@
|
|
|
26
26
|
// in words, never parked.
|
|
27
27
|
import { COMPUTER_OP_TOOL, computerToolDefs, defaultPermissionOf, SHELL_FAMILY, SHELL_WATCHERS, shellPermission, shellToolOf } from "@parcha/agentrun-kernel/kernel";
|
|
28
28
|
import { READ_SKILL_FILE } from "@parcha/agentrun-kernel";
|
|
29
|
-
import {
|
|
30
|
-
import { COMPUTER_ROOT, portPath } from "./workspace/paths.js";
|
|
29
|
+
import { COMPUTER_ROOT } from "./workspace/paths.js";
|
|
31
30
|
import { builtinHarness } from "./harness-table.js";
|
|
32
31
|
import { META_TOOLS } from "./meta-tool-names.js";
|
|
33
32
|
import { DEFAULT_HARNESS } from "./harness.js";
|
|
@@ -338,19 +337,6 @@ export const noApproverText = (tool, ran = "no", because) => because === undefin
|
|
|
338
337
|
export const APPROVAL_ROW = "tool_approval_requested";
|
|
339
338
|
/** A call's arguments shown on its approval, at most this many bytes. */
|
|
340
339
|
export const ARGS_PREVIEW_BYTES = 2048;
|
|
341
|
-
/** The refusal of the end-of-run turn's write or edit under work/.learning/: its notes are kept only from its answer's
|
|
342
|
-
* note blocks (learn/reflect.ts parseReflection), which the host merges in its own store; a file there is never kept. */
|
|
343
|
-
export const NOTE_ONLY_TEXT = "A note is kept only from your answer: write it in a ```note block, not to a file.";
|
|
344
|
-
/** Whether `args.path`, as a file tool resolves it (a leading `@` dropped, Unicode spaces made plain, then the port's
|
|
345
|
-
* path of it, portPath), names .learning/ in the run's folder or a path under it: by the folder's path here (`work`)
|
|
346
|
-
* or a computer's name for it (COMPUTER_ROOT). */
|
|
347
|
-
export function underLearning(work, args) {
|
|
348
|
-
const path = args?.path;
|
|
349
|
-
if (typeof path !== "string")
|
|
350
|
-
return false;
|
|
351
|
-
const plain = path.replace(/[\u00A0\u2002-\u200A\u202F\u205F\u3000]/g, " ").replace(/^@/, "");
|
|
352
|
-
return portPath(plain, [work, COMPUTER_ROOT])?.split("/")[0] === LEARNED_DIR;
|
|
353
|
-
}
|
|
354
340
|
/** `text` cut to at most ARGS_PREVIEW_BYTES. What is shown of a call's arguments is the whole of them redacted first, then
|
|
355
341
|
* cut (runs.ts), so a cut never leaves the head of a key no redaction recognizes. */
|
|
356
342
|
export function previewOf(text) {
|
package/dist/tool-keys.d.ts
CHANGED
|
@@ -50,7 +50,8 @@ export declare const TOOL_KEYS: readonly [{
|
|
|
50
50
|
export declare const TOOL_FIELDS: readonly string[];
|
|
51
51
|
/** What `candidates` unlock here, as capabilities show it: the tools of `tools` (capabilities' `tools`, available or
|
|
52
52
|
* not) and the providers of `providers` (its `workflows.decisions.providers`) named among them, and the harnesses
|
|
53
|
-
* that run those tools
|
|
53
|
+
* that run those tools: the built-in ones first, then any other the tools run on (Goose once its owner installs it). A
|
|
54
|
+
* name neither holds is left out; a key that unlocks none of its names lists nothing. */
|
|
54
55
|
export declare function unlockedBy(candidates: readonly string[], tools: readonly {
|
|
55
56
|
name: string;
|
|
56
57
|
harnesses: readonly string[];
|
|
@@ -58,14 +59,15 @@ export declare function unlockedBy(candidates: readonly string[], tools: readonl
|
|
|
58
59
|
id: string;
|
|
59
60
|
}[]): {
|
|
60
61
|
unlocks: string[];
|
|
61
|
-
harnesses:
|
|
62
|
+
harnesses: string[];
|
|
62
63
|
};
|
|
63
64
|
/** What a row unlocks here: a `tool` row's, its tools and providers as capabilities bind them (unlockedBy); any other
|
|
64
65
|
* kind's (a model's), no tool, on those that run on it (its `harnesses`, when it names them) that this server runs
|
|
65
66
|
* (`offers`, harness.ts' harnessOffers) on the row's key: one whose `keys` (the model keys that run it here, available
|
|
66
67
|
* now or once one is saved) include the row's (its first field). So OpenRouter's row names all three before any key
|
|
67
68
|
* is saved, and no row changes when another provider's key is saved; a harness not installed, off its pins or too big
|
|
68
|
-
* for this host is left out.
|
|
69
|
+
* for this host is left out. A harness the server lists beyond the built-in ones (Goose once its owner installs it: it
|
|
70
|
+
* has no offer before) is named, after them, where its own offer's `keys` name the row's. */
|
|
69
71
|
export declare function rowUnlocks(row: {
|
|
70
72
|
kind: string;
|
|
71
73
|
unlocks: readonly string[];
|
|
@@ -77,7 +79,7 @@ export declare function rowUnlocks(row: {
|
|
|
77
79
|
keys?: readonly string[];
|
|
78
80
|
}[]): {
|
|
79
81
|
unlocks: string[];
|
|
80
|
-
harnesses:
|
|
82
|
+
harnesses: string[];
|
|
81
83
|
};
|
|
82
84
|
/** Whether a key row's `unlock` unlocks the tool `name`: by its name, or `<source>:*` for every tool of a catalog source
|
|
83
85
|
* (`monid:*`: `monid:apollo/people/match`, `monid:apollo/*`). */
|
package/dist/tool-keys.js
CHANGED
|
@@ -29,21 +29,25 @@ export const TOOL_KEYS = [
|
|
|
29
29
|
export const TOOL_FIELDS = TOOL_KEYS.filter((row) => row.kind === "tool").flatMap((row) => row.fields);
|
|
30
30
|
/** What `candidates` unlock here, as capabilities show it: the tools of `tools` (capabilities' `tools`, available or
|
|
31
31
|
* not) and the providers of `providers` (its `workflows.decisions.providers`) named among them, and the harnesses
|
|
32
|
-
* that run those tools
|
|
32
|
+
* that run those tools: the built-in ones first, then any other the tools run on (Goose once its owner installs it). A
|
|
33
|
+
* name neither holds is left out; a key that unlocks none of its names lists nothing. */
|
|
33
34
|
export function unlockedBy(candidates, tools, providers) {
|
|
34
35
|
const bound = new Set([...tools.map((tool) => tool.name), ...providers.map((provider) => `decisions.${provider.id}`)]);
|
|
35
36
|
// A catalog source's tools (`monid:*`) are granted by name, never listed: the source is shown as it is, and its tools are
|
|
36
|
-
// host tools, run on every harness.
|
|
37
|
+
// host tools, run on every harness: the built-in ones and any other a tool here runs on.
|
|
37
38
|
const unlocks = candidates.filter((name) => bound.has(name) || name.endsWith(":*"));
|
|
38
|
-
const
|
|
39
|
-
|
|
39
|
+
const every = unlocks.some((name) => name.endsWith(":*"));
|
|
40
|
+
const run = new Set(tools.filter((tool) => every || unlocks.includes(tool.name)).flatMap((tool) => tool.harnesses));
|
|
41
|
+
const listed = [...run].filter((harness) => !HARNESSES.includes(harness));
|
|
42
|
+
return { unlocks, harnesses: [...HARNESSES.filter((harness) => every || run.has(harness)), ...listed] };
|
|
40
43
|
}
|
|
41
44
|
/** What a row unlocks here: a `tool` row's, its tools and providers as capabilities bind them (unlockedBy); any other
|
|
42
45
|
* kind's (a model's), no tool, on those that run on it (its `harnesses`, when it names them) that this server runs
|
|
43
46
|
* (`offers`, harness.ts' harnessOffers) on the row's key: one whose `keys` (the model keys that run it here, available
|
|
44
47
|
* now or once one is saved) include the row's (its first field). So OpenRouter's row names all three before any key
|
|
45
48
|
* is saved, and no row changes when another provider's key is saved; a harness not installed, off its pins or too big
|
|
46
|
-
* for this host is left out.
|
|
49
|
+
* for this host is left out. A harness the server lists beyond the built-in ones (Goose once its owner installs it: it
|
|
50
|
+
* has no offer before) is named, after them, where its own offer's `keys` name the row's. */
|
|
47
51
|
export function rowUnlocks(row, tools, providers, offers) {
|
|
48
52
|
if (row.kind === "tool")
|
|
49
53
|
return unlockedBy(row.unlocks, tools, providers);
|
|
@@ -51,7 +55,9 @@ export function rowUnlocks(row, tools, providers, offers) {
|
|
|
51
55
|
// Where an offer knows which model keys run it (its `keys`), the row's key must be one of them, available now or not;
|
|
52
56
|
// else (no key runs it: pi on any, or one unavailable for another reason) whether it runs here now.
|
|
53
57
|
const runs = (harness) => offers.some((offer) => offer.id === harness && (offer.keys ? key !== undefined && offer.keys.includes(key) : offer.available));
|
|
54
|
-
|
|
58
|
+
const builtin = HARNESSES.filter((harness) => (row.harnesses ?? HARNESSES).includes(harness) && runs(harness));
|
|
59
|
+
const listed = offers.filter((offer) => !HARNESSES.includes(offer.id) && key !== undefined && offer.keys?.includes(key)).map((offer) => offer.id);
|
|
60
|
+
return { unlocks: [], harnesses: [...builtin, ...listed] };
|
|
55
61
|
}
|
|
56
62
|
/** Whether a key row's `unlock` unlocks the tool `name`: by its name, or `<source>:*` for every tool of a catalog source
|
|
57
63
|
* (`monid:*`: `monid:apollo/people/match`, `monid:apollo/*`). */
|
package/dist/tools.d.ts
CHANGED
|
@@ -261,7 +261,7 @@ export declare const savedOnRelease: (row: {
|
|
|
261
261
|
/** On the runner, the per-session hook that verifies the run's saved sign-in: a session that saved to it (savedOnRelease,
|
|
262
262
|
* in a run handed it to save) verifies it under the run's claim, at the session's own end (its time, else now), as the
|
|
263
263
|
* saved mark main reads at the lease's end. Answers whether it verified (sign-ins-store.ts verifyRunSignIn). */
|
|
264
|
-
export declare const runSignInSaved: (store: Pick<Store, "runs" | "signIns">, sealKey: Buffer, claim: Claim, kept: RunSignIn) => (row: {
|
|
264
|
+
export declare const runSignInSaved: (store: Pick<Store, "runs" | "signIns">, sealKey: Buffer | undefined, claim: Claim, kept: RunSignIn) => (row: {
|
|
265
265
|
session: {
|
|
266
266
|
resourceId: string | null;
|
|
267
267
|
releaseReason: string | null;
|
|
@@ -279,7 +279,7 @@ export declare const allows: (allowed: readonly string[], name: string) => boole
|
|
|
279
279
|
* agent's `granted` tools a workflow's call node runs here (CALL_TOOLS, and each MCP tool granted by its own name,
|
|
280
280
|
* tool-names.ts mcpNameOf), and with the run's `plane`, none it resolves unavailable (its agent's own tool of the name
|
|
281
281
|
* does not run either). A
|
|
282
|
-
* learned model node runs without tools (learn/
|
|
282
|
+
* learned model node runs without tools (learn/workflow-draft.ts MODEL_NODE_TOOLS), and a harness's own tool (Bash,
|
|
283
283
|
* exec_command, apply_patch) is never one, so the DSL refuses a draft that names it. */
|
|
284
284
|
export declare const learnedWorkflowTools: (granted: readonly string[], plane?: Plane, options?: LearnedMcp) => string[];
|
|
285
285
|
/** `mcp: true` at learn time (the end-of-run step's draft tools, a person's write): an MCP tool the revision grants by its
|
package/dist/tools.js
CHANGED
|
@@ -47,6 +47,7 @@ import { HANDOVER_WAITING } from "./runner/journal-kinds.js";
|
|
|
47
47
|
import { provenFor } from "./live-reach.js";
|
|
48
48
|
import { clearWaitEnded, markWaitEnded } from "./browser-wait-ended.js";
|
|
49
49
|
import { runSignIn, verifyRunSignIn } from "./sign-ins-store.js";
|
|
50
|
+
import { held } from "./runner/held.js";
|
|
50
51
|
export const ASK_TOOL = "ask_person";
|
|
51
52
|
/** Under `--faux` only: a module whose default export gives the browser's `{ computer, driver }` for the run's
|
|
52
53
|
* environment, the vendor its plane names and the saved sign-in it was handed for that vendor (`{ provider, ref, save }`,
|
|
@@ -262,7 +263,11 @@ export const runSignInSaved = (store, sealKey, claim, kept) => async (row, chang
|
|
|
262
263
|
if (!kept.save || !savedOnRelease(row, change))
|
|
263
264
|
return false;
|
|
264
265
|
const ended = row.session.endedAt ? Date.parse(row.session.endedAt) : Number.NaN;
|
|
265
|
-
|
|
266
|
+
const at = Number.isFinite(ended) ? ended : Date.now();
|
|
267
|
+
// A run's own process holds no seal key: its runner marks it under the claim (held.ts verifySignIn).
|
|
268
|
+
if (!sealKey)
|
|
269
|
+
return (await held()?.verifySignIn(kept, at)) ?? false;
|
|
270
|
+
return verifyRunSignIn(store, sealKey, claim, kept, at);
|
|
266
271
|
};
|
|
267
272
|
/** A browser on pi-browser's durable adapter, its sessions a browser computer provider's of the computer registry
|
|
268
273
|
* (browser-computer.ts), each driven over its CDP URL by pi-browser's raw-CDP driver: the agent's computer, where it is
|
|
@@ -309,7 +314,9 @@ const browserTool = {
|
|
|
309
314
|
// launch makes it: never the process's environment, so one run's keys never make another's.
|
|
310
315
|
const runLog = (line) => void process.stderr.write(`agentrun-serve: run ${host.where.ref.id}: ${line}\n`);
|
|
311
316
|
const vendorFetch = async () => (host.env[FAUX_ENV] ? fauxFetch(host.env, FAUX_VENDOR_API_ENV) : fetch);
|
|
312
|
-
|
|
317
|
+
// A run's own process holds no seal key: its runner opens the run's sign-in under the claim (held.ts runSignIn).
|
|
318
|
+
const atRunner = held();
|
|
319
|
+
const handed = computer ? undefined : host.claim ? (planeRefused || !host.store ? undefined : host.sealKey ? await runSignIn(host.store, host.sealKey, host.claim, vendor, { vendors: vendorsOver(() => host.env, vendorFetch), log: runLog }) : await atRunner?.runSignIn(vendor)) : handedSignIn();
|
|
313
320
|
const kept = !planeRefused && handed?.provider === vendor ? handed : undefined;
|
|
314
321
|
// Tests only (--faux): the faux browser's computer provider and driver stand in for the plane vendor's and the raw-CDP
|
|
315
322
|
// driver. The agent's browser computer is still the claim's, so a test hands the claim a faux provider of its own.
|
|
@@ -445,7 +452,7 @@ const browserTool = {
|
|
|
445
452
|
const files = { files: uploadsFrom(work, MAX_UPLOAD_BYTES, uploadMime), ...(folder !== undefined && keepsDownloads ? { workspace: () => folder } : {}) };
|
|
446
453
|
// A session that saved to the sign-in, let go: its time, for the sign-in's verified_at when the run's lease ends.
|
|
447
454
|
// On the runner, the store's verified_at under the run's claim (runSignInSaved), never a mark in the run's directory.
|
|
448
|
-
const verify = kept?.save && host.claim && host.store && host.sealKey ? runSignInSaved(host.store, host.sealKey, host.claim, kept) : undefined;
|
|
455
|
+
const verify = kept?.save && host.claim && host.store && (host.sealKey || held()) ? runSignInSaved(host.store, host.sealKey, host.claim, kept) : undefined;
|
|
449
456
|
// Awaited by the session's change, so the release that lets a run's sessions go (beforeRelease) returns only once its
|
|
450
457
|
// last save is verified: the run's end commit, which ends the claim, never fences it.
|
|
451
458
|
const saved = verify
|
|
@@ -649,7 +656,7 @@ export const allows = (allowed, name) => allowed.includes(name);
|
|
|
649
656
|
* agent's `granted` tools a workflow's call node runs here (CALL_TOOLS, and each MCP tool granted by its own name,
|
|
650
657
|
* tool-names.ts mcpNameOf), and with the run's `plane`, none it resolves unavailable (its agent's own tool of the name
|
|
651
658
|
* does not run either). A
|
|
652
|
-
* learned model node runs without tools (learn/
|
|
659
|
+
* learned model node runs without tools (learn/workflow-draft.ts MODEL_NODE_TOOLS), and a harness's own tool (Bash,
|
|
653
660
|
* exec_command, apply_patch) is never one, so the DSL refuses a draft that names it. */
|
|
654
661
|
export const learnedWorkflowTools = (granted, plane, options = {}) => [...new Set(granted.filter((name) => (options.mcp === true && mcpNameOf(name) !== undefined) || (allows(CALL_TOOLS, name) && !isUnavailable(plane?.[name]))))];
|
|
655
662
|
/** The tools a learned draft may name (learnedWorkflowTools) that the gate allows: `permission` is what the gate holds a
|
package/dist/triggers.d.ts
CHANGED
|
@@ -50,8 +50,15 @@ export type TriggerUpstream = {
|
|
|
50
50
|
patched(was: Source, given: Source): Source;
|
|
51
51
|
/** The trigger `id` of `source`, turned on or off here: the same there. */
|
|
52
52
|
turned(source: Source, id: string, on: boolean): Promise<Json | undefined>;
|
|
53
|
-
/** The trigger `id` of `source`, deleted here: removed there. */
|
|
53
|
+
/** The trigger `id` of `source`, deleted here: removed there, with what it keeps here for it (a sealed config). */
|
|
54
54
|
removed(source: Source, id: string): Promise<Json | undefined>;
|
|
55
|
+
/** The trigger `id` of `source`, still here: removed there, then `here` (its delete here) in the same step, so no other
|
|
56
|
+
* trigger's removal there reads it as still holding what they share; what it keeps here for it is left (`forgotten`
|
|
57
|
+
* drops that once the trigger is gone). Undefined when it is gone there and `here` is done; what could not be done
|
|
58
|
+
* there, said, with `here` not run. A refusal of `here`'s is thrown. */
|
|
59
|
+
removedThere(source: Source, id: string, here: () => Promise<void>): Promise<Json | undefined>;
|
|
60
|
+
/** What it keeps here for the trigger `id` of `source` (a sealed config), dropped once the trigger is gone here. */
|
|
61
|
+
forgotten(source: Source, id: string): Promise<void>;
|
|
55
62
|
};
|
|
56
63
|
/** `max_cost_usd`: each run's cap; absent, the agent's default as it stands when the firing starts (one of the two is
|
|
57
64
|
* required: server.ts targetIssues and start). */
|
|
@@ -68,10 +75,14 @@ export type Target = {
|
|
|
68
75
|
};
|
|
69
76
|
/** What the webhook did with a trigger.failed message (webhooks.ts emitTrigger). */
|
|
70
77
|
type Told = "queued" | "unsaved" | "off" | "closed";
|
|
71
|
-
/** What a trigger.failed webhook message says (webhooks.ts).
|
|
78
|
+
/** What a trigger.failed webhook message says (webhooks.ts). `agent_id`: the agent the trigger runs as (its row's: a
|
|
79
|
+
* start_run's agent, or the agent of the run a message_run names), so every trigger has one; `agent_name`, that agent's
|
|
80
|
+
* name as the message is built, its id when it has none (an agent no longer in the store). */
|
|
72
81
|
export type TriggerFailed = {
|
|
73
82
|
trigger_id: string;
|
|
74
83
|
name: string;
|
|
84
|
+
agent_id: string;
|
|
85
|
+
agent_name: string;
|
|
75
86
|
firing_key: string;
|
|
76
87
|
nominal_at: string;
|
|
77
88
|
error: {
|
|
@@ -176,6 +187,11 @@ export declare class Triggers {
|
|
|
176
187
|
/** Each trigger's firings, driven one after another in the order asked: a firing's overlap check reads what the one
|
|
177
188
|
* before it settled to. */
|
|
178
189
|
private readonly turns;
|
|
190
|
+
/** Each trigger's removals and the edits that name a target (the one way it moves to another agent), one after another
|
|
191
|
+
* on this server: a move never lands between a template update's delete of its Composio instance and its conditional
|
|
192
|
+
* delete of the row (remove), so a moved trigger never stands on an instance that delete took. Across servers the
|
|
193
|
+
* store's conditional write holds the row. Removed from the map once idle. */
|
|
194
|
+
private readonly edits;
|
|
179
195
|
/** Whether a firing waits for its trigger's room (max_active_runs): the timer then reads the store every WAIT_POLL_MS. */
|
|
180
196
|
private waiting;
|
|
181
197
|
/** The triggers whose day-kept keys are at their cap, said once until they are under it again. */
|
|
@@ -295,7 +311,7 @@ export declare class Triggers {
|
|
|
295
311
|
} | null;
|
|
296
312
|
}[];
|
|
297
313
|
}>;
|
|
298
|
-
create(body: Json): Promise<{
|
|
314
|
+
create(body: Json, own?: TriggerOwn): Promise<{
|
|
299
315
|
secret?: string;
|
|
300
316
|
id: string;
|
|
301
317
|
name: string;
|
|
@@ -378,6 +394,9 @@ export declare class Triggers {
|
|
|
378
394
|
}[]>;
|
|
379
395
|
/** Refused (409 agent_archived) when agent `agentId` is archived: a trigger made on, turned on or aimed at it. */
|
|
380
396
|
private needAgentOn;
|
|
397
|
+
/** Refused (409 agent_not_runnable, agents.ts agentDeleting) when agent `agentId` is being deleted: another system's
|
|
398
|
+
* agent with an archive time, which only its delete writes (agent-delete.ts). */
|
|
399
|
+
private needNotDeleting;
|
|
381
400
|
/** The store's refusal of a trigger left on for an archived agent (an archive that committed past needAgentOn) as the
|
|
382
401
|
* same 409; undefined for any other error. */
|
|
383
402
|
private archivedRefusal;
|
|
@@ -402,7 +421,7 @@ export declare class Triggers {
|
|
|
402
421
|
/** PATCH: any of name, enabled, source, target, catchup_window_s and max_active_runs. Enabled again, or its source changed, a trigger goes on from now: a
|
|
403
422
|
* paused range is skipped, never caught up. Only the fields named change, applied to the trigger as it stands once
|
|
404
423
|
* the target's check is done: an edit made meanwhile keeps its own. */
|
|
405
|
-
update(id: string, body: Json): Promise<{
|
|
424
|
+
update(id: string, body: Json, own?: TriggerOwn): Promise<{
|
|
406
425
|
id: string;
|
|
407
426
|
name: string;
|
|
408
427
|
enabled: boolean;
|
|
@@ -440,11 +459,37 @@ export declare class Triggers {
|
|
|
440
459
|
} | null | undefined;
|
|
441
460
|
hook_url?: string | undefined;
|
|
442
461
|
}>;
|
|
462
|
+
private updating;
|
|
443
463
|
/** One try of `update`: undefined when its source write was refused because the trigger changed since it was read and
|
|
444
464
|
* `retry` (try again); refused on the last try, precondition_failed. */
|
|
445
465
|
private updateOnce;
|
|
446
|
-
/** The trigger deleted, and what its sender keeps of it removed after (said, when it could not be: the delete holds).
|
|
447
|
-
|
|
466
|
+
/** The trigger deleted, and what its sender keeps of it removed after (said, when it could not be: the delete holds).
|
|
467
|
+
* On its agent's condition (`onAgent`: a template update's removal), what its sender keeps goes first: one its sender
|
|
468
|
+
* did not remove is said, and the trigger is kept here as it was (its row, its package mark, its sealed config and
|
|
469
|
+
* whether it is on), for the next update to remove; once it is gone there, the trigger goes here while it is still that
|
|
470
|
+
* agent's, then what its sender kept here for it. */
|
|
471
|
+
remove(id: string, own?: Pick<TriggerOwn, "onAgent">): Promise<Json | undefined>;
|
|
472
|
+
private removing;
|
|
473
|
+
/** `value` as a create keeps a source (its adapter's defaults filled in: a feed's every_s), or undefined when a create
|
|
474
|
+
* would refuse it. */
|
|
475
|
+
sourceAsKept(value: unknown): Source | undefined;
|
|
476
|
+
/** A deleted agent's trigger (agent-delete.ts), its first half: what its sender keeps of it removed there, the trigger
|
|
477
|
+
* kept here, so a failure, or a stop before the second half (removeHere), leaves the row that names what is left to
|
|
478
|
+
* remove for the next delete to find. Throws `unavailable` with what could not be done there. */
|
|
479
|
+
removeThere(id: string): Promise<void>;
|
|
480
|
+
/** The second half's first part, once removeThere is done: the trigger's adapter settings removed, its row kept. */
|
|
481
|
+
removeSettings(id: string): Promise<void>;
|
|
482
|
+
/** The second half, once removeThere is done: the trigger deleted here, its adapter settings and then its row. */
|
|
483
|
+
removeHere(id: string): Promise<void>;
|
|
484
|
+
/** A trigger's adapter settings (a webhook's secret, a poll's cursor) removed; nothing else of it. */
|
|
485
|
+
private dropSettings;
|
|
486
|
+
/** The trigger's settings and row removed. Without `onAgent`, its settings first, then its row: the settings have no
|
|
487
|
+
* link to the row, so a failure or a stop between the two leaves the row, which the next remove finds, never settings
|
|
488
|
+
* with no trigger left to name them. With `onAgent` (a template update's removal), the row first, on its agent's
|
|
489
|
+
* condition compared in the delete, then its settings: a trigger moved to another agent meanwhile keeps both. A stop
|
|
490
|
+
* between the two there leaves settings no row names (keyed by an id never used again), never a moved trigger
|
|
491
|
+
* without its own. */
|
|
492
|
+
private dropHere;
|
|
448
493
|
/** Run now: one firing per Idempotency-Key, driven before the answer. `created` false: the key's firing, as it stands. */
|
|
449
494
|
fire(id: string, idempotencyKey: string): Promise<{
|
|
450
495
|
created: boolean;
|
|
@@ -454,6 +499,12 @@ export declare class Triggers {
|
|
|
454
499
|
* then each failure's trigger.failed queued that is not yet, each due firing whose time has come driven, each waiting
|
|
455
500
|
* firing whose trigger has room again driven (one read for all of them), and the timer armed again. */
|
|
456
501
|
private tick;
|
|
502
|
+
/** `work` on trigger `id` once every edit or removal of it asked before has settled (edits). Neither update nor remove
|
|
503
|
+
* calls the other, so a turn never waits on itself. Only a target edit takes a turn: any other edit runs beside one, as
|
|
504
|
+
* concurrent edits each keep their change (trigger-engine.test.mjs, two edits at once, one a target whose check is
|
|
505
|
+
* slow: the source edit lands while the target's check waits). One racing a removal writes its row while the row is
|
|
506
|
+
* there, or finds it gone (not_found): the store's update changes no row a delete took. */
|
|
507
|
+
private one;
|
|
457
508
|
/** `key`'s firing driven after every firing of its trigger asked before it. */
|
|
458
509
|
private inTurn;
|
|
459
510
|
/** Each of `triggers` turned off, with why its source no longer reads, and said. */
|
|
@@ -571,6 +622,14 @@ export declare class Triggers {
|
|
|
571
622
|
* source says of it), then a line saying what fired it and when, in the trigger's zone. */
|
|
572
623
|
private inputOf;
|
|
573
624
|
}
|
|
625
|
+
/** What a template apply alone gives a trigger write, never an API body: `templateId`, the package mark it makes the
|
|
626
|
+
* trigger with or sets on one it keeps in place (TriggerRow.templateId); `onAgent`, the agent it read the trigger on, so
|
|
627
|
+
* the write (an update, a removal) is made only while the trigger is still that agent's, compared in the store's
|
|
628
|
+
* statement: one moved to another agent meanwhile is not_found, and nothing is written. */
|
|
629
|
+
export interface TriggerOwn {
|
|
630
|
+
readonly templateId?: string;
|
|
631
|
+
readonly onAgent?: string;
|
|
632
|
+
}
|
|
574
633
|
declare function firingView(firing: FiringRow): {
|
|
575
634
|
attempts?: number | undefined;
|
|
576
635
|
retry_at?: string | undefined;
|