@parcha/agentrun-serve 0.1.0-beta.33 → 0.1.0-beta.34
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 +233 -0
- package/README.md +266 -201
- package/dist/adapters.d.ts +0 -4
- package/dist/adapters.js +11 -15
- package/dist/agent-rows.d.ts +98 -0
- package/dist/agent-rows.js +1 -0
- package/dist/agents-store.d.ts +6 -2
- package/dist/agents-store.js +60 -25
- package/dist/agents.d.ts +9 -125
- package/dist/agents.js +15 -305
- package/dist/answer-json.d.ts +23 -0
- package/dist/answer-json.js +58 -0
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/bash-read-only.d.ts +22 -0
- package/dist/bash-read-only.js +701 -0
- package/dist/box-settings.d.ts +3 -23
- package/dist/box-settings.js +7 -51
- package/dist/boxes.d.ts +17 -0
- package/dist/boxes.js +27 -20
- package/dist/browser-commands.d.ts +5 -2
- package/dist/browser-commands.js +4 -4
- package/dist/browser-computer.d.ts +5 -0
- package/dist/browser-computer.js +21 -0
- package/dist/browser-cost.d.ts +9 -6
- package/dist/browser-cost.js +92 -50
- package/dist/browser-live.d.ts +7 -20
- package/dist/browser-live.js +15 -93
- package/dist/browser-person.d.ts +18 -51
- package/dist/browser-person.js +94 -277
- package/dist/cap.d.ts +8 -5
- package/dist/cap.js +12 -5
- package/dist/cli.js +39 -13
- package/dist/closed-pipes.d.ts +2 -0
- package/dist/closed-pipes.js +13 -0
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +2 -0
- package/dist/computer-keys.js +5 -2
- package/dist/computer-setting.d.ts +20 -4
- package/dist/computer-setting.js +25 -5
- package/dist/computers.d.ts +30 -2
- package/dist/computers.js +70 -11
- package/dist/confine.d.ts +120 -0
- package/dist/confine.js +436 -0
- package/dist/console/assets/index-RPHGlXmM.js +540 -0
- package/dist/console/assets/index-opTN5Naq.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/decision-rows.d.ts +1 -1
- package/dist/decision-rows.js +1 -1
- package/dist/docker-daemon.d.ts +31 -0
- package/dist/docker-daemon.js +56 -0
- package/dist/effort-guidance.js +4 -3
- package/dist/environment.d.ts +0 -3
- package/dist/environment.js +3 -5
- package/dist/errors.d.ts +0 -2
- package/dist/errors.js +6 -9
- package/dist/filed-answer.d.ts +32 -0
- package/dist/filed-answer.js +160 -0
- package/dist/files.d.ts +1 -3
- package/dist/files.js +2 -4
- package/dist/github-connection.d.ts +1 -1
- package/dist/graph-view.d.ts +3 -5
- package/dist/graph-view.js +4 -14
- package/dist/handed-values.d.ts +9 -0
- package/dist/handed-values.js +26 -0
- package/dist/harness-install.d.ts +1 -7
- package/dist/harness-install.js +1 -18
- package/dist/harness-opencode/adapter.d.ts +7 -0
- package/dist/harness-opencode/adapter.js +23 -6
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/verify.d.ts +17 -0
- package/dist/harness-opencode/verify.js +30 -10
- package/dist/harness-table.js +6 -1
- package/dist/heard.js +1 -1
- package/dist/held-fd.d.ts +5 -0
- package/dist/held-fd.js +14 -0
- package/dist/host-calls.d.ts +20 -0
- package/dist/host-calls.js +12 -0
- package/dist/host-tools.d.ts +4 -21
- package/dist/host-tools.js +4 -61
- package/dist/host.d.ts +2 -4
- package/dist/host.js +2 -7
- package/dist/import-summary.d.ts +1 -5
- package/dist/import-summary.js +0 -21
- package/dist/import.d.ts +6 -6
- package/dist/import.js +14 -15
- package/dist/key-refusal.d.ts +5 -1
- package/dist/key-refusal.js +19 -4
- package/dist/learn/check.d.ts +6 -2
- package/dist/learn/check.js +83 -29
- package/dist/learn/folder.d.ts +5 -1
- package/dist/learn/folder.js +10 -3
- package/dist/learn/grade.d.ts +14 -0
- package/dist/learn/grade.js +68 -12
- package/dist/learn/index.d.ts +4 -4
- package/dist/learn/index.js +4 -4
- package/dist/learn/reflect.d.ts +31 -2
- package/dist/learn/reflect.js +79 -4
- package/dist/learn/relevance.d.ts +24 -0
- package/dist/learn/relevance.js +91 -0
- package/dist/learn/secrets.d.ts +7 -1
- package/dist/learn/secrets.js +86 -19
- package/dist/learn/skills.d.ts +112 -14
- package/dist/learn/skills.js +556 -52
- package/dist/learned-workflow.d.ts +32 -1
- package/dist/learned-workflow.js +100 -9
- package/dist/learning-routes.d.ts +8 -4
- package/dist/learning-routes.js +23 -9
- package/dist/learning-run.d.ts +9 -26
- package/dist/learning-run.js +22 -32
- package/dist/learning-words.d.ts +12 -5
- package/dist/learning-words.js +18 -9
- package/dist/learning.d.ts +93 -77
- package/dist/learning.js +176 -304
- package/dist/live/stream.js +1 -1
- package/dist/live/translate.js +12 -2
- package/dist/local-models.d.ts +11 -5
- package/dist/local-models.js +13 -8
- package/dist/mcp-gateway.d.ts +11 -49
- package/dist/mcp-gateway.js +44 -135
- package/dist/mcp-oauth.d.ts +10 -14
- package/dist/mcp-oauth.js +14 -32
- package/dist/mcp-probe.d.ts +0 -7
- package/dist/mcp-probe.js +4 -10
- package/dist/mcp-servers-store.d.ts +6 -6
- package/dist/mcp-servers-store.js +12 -14
- package/dist/mcp-store.js +3 -4
- package/dist/mcp.js +4 -3
- package/dist/model.d.ts +6 -7
- package/dist/model.js +43 -27
- package/dist/monid.d.ts +0 -2
- package/dist/monid.js +3 -6
- package/dist/openapi.d.ts +8 -1
- package/dist/openapi.js +121 -47
- package/dist/page.d.ts +1 -3
- package/dist/page.js +6 -18
- package/dist/paid-calls.d.ts +21 -27
- package/dist/paid-calls.js +25 -60
- package/dist/propose.js +83 -39
- package/dist/push-handler.d.ts +1 -1
- package/dist/reflect-range.d.ts +25 -0
- package/dist/reflect-range.js +30 -0
- package/dist/refusal-words.d.ts +5 -1
- package/dist/refusal-words.js +5 -1
- package/dist/rows.d.ts +1 -1
- package/dist/run-cut.d.ts +0 -6
- package/dist/run-cut.js +0 -6
- package/dist/run-db.d.ts +2 -11
- package/dist/run-db.js +2 -37
- package/dist/run-launch.d.ts +19 -2
- package/dist/run-launch.js +13 -5
- package/dist/run-learning-served.d.ts +10 -4
- package/dist/run-learning-served.js +23 -13
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-reads-over-store.js +15 -6
- package/dist/run-secrets.d.ts +1 -1
- package/dist/run-timeline-served.d.ts +5 -1
- package/dist/run-timeline-served.js +15 -4
- package/dist/run-view.d.ts +7 -8
- package/dist/run-view.js +26 -7
- package/dist/runnable.d.ts +18 -10
- package/dist/runnable.js +21 -10
- package/dist/runner/adapter-loop.d.ts +6 -1
- package/dist/runner/adapter-loop.js +423 -53
- package/dist/runner/adapter-run-spec.d.ts +21 -8
- package/dist/runner/adapter-run-spec.js +90 -32
- package/dist/runner/adapters/index.js +11 -1
- package/dist/runner/adapters/pi.d.ts +12 -2
- package/dist/runner/adapters/pi.js +16 -5
- package/dist/runner/beside.d.ts +30 -3
- package/dist/runner/beside.js +36 -5
- package/dist/runner/claim-secrets.d.ts +10 -1
- package/dist/runner/claim-secrets.js +48 -14
- package/dist/runner/cli-run-spec.d.ts +2 -0
- package/dist/runner/cli-run-spec.js +45 -16
- package/dist/runner/commands.js +1 -1
- package/dist/runner/computer-journal.d.ts +15 -2
- package/dist/runner/computer-journal.js +41 -5
- package/dist/runner/conformance/harness.js +118 -8
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/dispatch.d.ts +8 -1
- package/dist/runner/dispatch.js +81 -7
- package/dist/runner/end-of-run.d.ts +8 -2
- package/dist/runner/end-of-run.js +10 -4
- package/dist/runner/github-app.js +1 -1
- package/dist/runner/harness-loops.d.ts +9 -1
- package/dist/runner/harness-loops.js +15 -2
- package/dist/runner/journal-kinds.d.ts +24 -6
- package/dist/runner/journal-kinds.js +20 -5
- package/dist/runner/journal-reader.d.ts +1 -1
- package/dist/runner/journal-reader.js +2 -2
- package/dist/runner/learning-ask.d.ts +4 -0
- package/dist/runner/learning-ask.js +15 -1
- package/dist/runner/learning-end.d.ts +18 -3
- package/dist/runner/learning-end.js +113 -11
- package/dist/runner/learning-loop.d.ts +5 -0
- package/dist/runner/learning-loop.js +26 -6
- package/dist/runner/main.d.ts +56 -9
- package/dist/runner/main.js +127 -18
- package/dist/runner/mcp-claim.js +1 -2
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +15 -5
- package/dist/runner/memory-claim.d.ts +9 -0
- package/dist/runner/memory-claim.js +25 -0
- package/dist/runner/metrics.d.ts +33 -1
- package/dist/runner/metrics.js +85 -1
- package/dist/runner/model-route.d.ts +13 -0
- package/dist/runner/model-route.js +133 -9
- package/dist/runner/reflect-hook.d.ts +12 -1
- package/dist/runner/reflect-hook.js +33 -3
- package/dist/runner/runner.d.ts +20 -0
- package/dist/runner/runner.js +56 -10
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +3 -3
- package/dist/runner/store-secrets.js +8 -12
- package/dist/runner/text-tools.d.ts +44 -0
- package/dist/runner/text-tools.js +237 -0
- package/dist/runner/workflow-loop.d.ts +6 -0
- package/dist/runner/workflow-loop.js +6 -4
- package/dist/runner/workflow-spec.d.ts +18 -0
- package/dist/runner/workflow-spec.js +63 -17
- package/dist/runs-over-store.d.ts +7 -2
- package/dist/runs-over-store.js +60 -14
- package/dist/seal-key.js +5 -43
- package/dist/sealed-settings-store.d.ts +19 -4
- package/dist/sealed-settings-store.js +9 -9
- package/dist/sealing.d.ts +4 -0
- package/dist/sealing.js +20 -0
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-name.d.ts +9 -0
- package/dist/secret-name.js +15 -0
- package/dist/secret-writes.d.ts +0 -1
- package/dist/secret-writes.js +0 -1
- package/dist/server-fs.d.ts +4 -0
- package/dist/server-fs.js +8 -2
- package/dist/server-lock.d.ts +0 -24
- package/dist/server-lock.js +1 -80
- package/dist/server-secrets-store.d.ts +4 -4
- package/dist/server-secrets-store.js +9 -31
- package/dist/server-secrets.d.ts +4 -9
- package/dist/server-secrets.js +12 -36
- package/dist/server.d.ts +16 -38
- package/dist/server.js +145 -106
- package/dist/sign-ins-store.d.ts +34 -36
- package/dist/sign-ins-store.js +27 -38
- package/dist/sign-ins.d.ts +2 -119
- package/dist/sign-ins.js +5 -311
- package/dist/standard-webhooks.d.ts +1 -1
- package/dist/standard-webhooks.js +1 -1
- package/dist/stats.d.ts +3 -2
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.d.ts +8 -2
- package/dist/store/agent-body.js +16 -4
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +2 -2
- package/dist/store/open.d.ts +6 -3
- package/dist/store/open.js +2 -2
- package/dist/store/postgres/connection.d.ts +18 -2
- package/dist/store/postgres/connection.js +156 -32
- package/dist/store/postgres/migrate.d.ts +4 -0
- package/dist/store/postgres/migrate.js +9 -2
- package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
- package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
- package/dist/store/postgres/store.d.ts +9 -2
- package/dist/store/postgres/store.js +9 -0
- package/dist/store/schema.js +1 -1
- package/dist/store/seal.js +2 -2
- package/dist/store/sqlite/connection.js +49 -5
- package/dist/store/sqlite/run-patch.d.ts +3 -0
- package/dist/store/sqlite/run-patch.js +3 -0
- package/dist/store/sqlite/store.js +41 -12
- package/dist/store/store.d.ts +35 -6
- package/dist/store/store.js +12 -2
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +22 -4
- package/dist/store-reads/journal.d.ts +9 -6
- package/dist/store-reads/journal.js +93 -17
- package/dist/store-reads/learning.d.ts +26 -8
- package/dist/store-reads/learning.js +12 -4
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-reads/workflow.js +1 -1
- package/dist/store-view.d.ts +5 -1
- package/dist/store-view.js +53 -18
- package/dist/template-eval.d.ts +60 -4
- package/dist/template-eval.js +120 -54
- package/dist/templates.d.ts +24 -10
- package/dist/templates.js +69 -38
- package/dist/timeline/group.d.ts +33 -0
- package/dist/timeline/group.js +77 -0
- package/dist/timeline/index.d.ts +7 -0
- package/dist/timeline/index.js +7 -0
- package/dist/timeline/labels.d.ts +79 -0
- package/dist/timeline/labels.js +150 -0
- package/dist/timeline/origin.d.ts +56 -0
- package/dist/timeline/origin.js +92 -0
- package/dist/timeline/render-text.d.ts +11 -0
- package/dist/timeline/render-text.js +62 -0
- package/dist/timeline/timeline.d.ts +274 -0
- package/dist/timeline/timeline.js +1308 -0
- package/dist/timeline/util.d.ts +17 -0
- package/dist/timeline/util.js +49 -0
- package/dist/tool-gate.d.ts +41 -216
- package/dist/tool-gate.js +79 -540
- package/dist/tool-keys-store.d.ts +11 -12
- package/dist/tool-keys-store.js +24 -31
- package/dist/tool-keys.d.ts +5 -101
- package/dist/tool-keys.js +8 -267
- package/dist/tool-plane.d.ts +14 -42
- package/dist/tool-plane.js +23 -81
- package/dist/tool-settings-store.d.ts +1 -2
- package/dist/tool-settings-store.js +5 -8
- package/dist/tools.d.ts +30 -18
- package/dist/tools.js +97 -107
- package/dist/trigger-adapter.d.ts +2 -2
- package/dist/trigger-targets.d.ts +13 -1
- package/dist/trigger-targets.js +31 -1
- package/dist/triggers.d.ts +2 -2
- package/dist/triggers.js +3 -3
- package/dist/turn-end.d.ts +1 -1
- package/dist/turn-end.js +1 -1
- package/dist/turns.d.ts +0 -6
- package/dist/turns.js +0 -19
- package/dist/uploads.js +1 -1
- package/dist/usage.d.ts +0 -2
- package/dist/usage.js +0 -2
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +23 -14
- package/dist/webhooks.d.ts +102 -76
- package/dist/webhooks.js +266 -233
- package/dist/workflow-run.d.ts +114 -0
- package/dist/workflow-run.js +144 -0
- package/dist/workspace/beneath.d.ts +19 -0
- package/dist/workspace/beneath.js +106 -0
- package/dist/workspace/computer-deps.d.ts +24 -6
- package/dist/workspace/computer-deps.js +108 -20
- package/dist/workspace/computer-for-claim.d.ts +12 -11
- package/dist/workspace/computer-for-claim.js +76 -15
- package/dist/workspace/computer-hold.d.ts +6 -1
- package/dist/workspace/computer-hold.js +6 -1
- package/dist/workspace/computer-janitor.d.ts +47 -0
- package/dist/workspace/computer-janitor.js +182 -0
- package/dist/workspace/grep-worker.d.ts +5 -0
- package/dist/workspace/grep-worker.js +9 -6
- package/dist/workspace/index.d.ts +3 -2
- package/dist/workspace/index.js +3 -3
- package/dist/workspace/local.d.ts +11 -2
- package/dist/workspace/local.js +161 -43
- package/dist/workspace/resolve-computer.d.ts +50 -10
- package/dist/workspace/resolve-computer.js +46 -11
- package/dist/workspace/run-tools.d.ts +13 -31
- package/dist/workspace/run-tools.js +10 -27
- package/dist/workspace-paths.d.ts +0 -17
- package/dist/workspace-paths.js +1 -41
- package/dist/workspace.d.ts +0 -14
- package/dist/workspace.js +3 -96
- package/package.json +13 -13
- package/templates/README.md +9 -3
- package/templates/market-monitor/agent.md +2 -2
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/dist/bound-files.d.ts +0 -4
- package/dist/bound-files.js +0 -164
- package/dist/coding-tools.d.ts +0 -47
- package/dist/coding-tools.js +0 -189
- package/dist/computer-adb.d.ts +0 -12
- package/dist/computer-adb.js +0 -14
- package/dist/console/assets/index-Dn0ngwG9.js +0 -535
- package/dist/console/assets/index-DvW6Aled.css +0 -1
- package/dist/grade.d.ts +0 -63
- package/dist/grade.js +0 -150
- package/dist/mcp-servers.d.ts +0 -269
- package/dist/mcp-servers.js +0 -456
- package/dist/packs.d.ts +0 -71
- package/dist/packs.js +0 -180
- package/dist/sealed-settings.d.ts +0 -60
- package/dist/sealed-settings.js +0 -171
- package/dist/sessions.d.ts +0 -6
- package/dist/sessions.js +0 -109
- package/dist/workspace/computer-serves.d.ts +0 -12
- package/dist/workspace/computer-serves.js +0 -15
package/dist/validate.js
CHANGED
|
@@ -4,9 +4,10 @@ import { HARNESSES } from "./harness.js";
|
|
|
4
4
|
import { THINKING_LEVELS } from "./model.js";
|
|
5
5
|
import { placeIssues } from "./place.js";
|
|
6
6
|
import { computerIssues, settingConflict } from "./computer-setting.js";
|
|
7
|
-
import {
|
|
7
|
+
import { settingsIssues } from "./tool-plane.js";
|
|
8
8
|
import { CAP_MODES } from "./cap.js";
|
|
9
9
|
import { APPROVALS } from "./approvals.js";
|
|
10
|
+
import { schemaCheck } from "./answer-json.js";
|
|
10
11
|
export const ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
11
12
|
/** An inline agent's source or kind in its external reference (POST /runs): no colon, which the reference's key splits on. */
|
|
12
13
|
export const EXTERNAL_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
@@ -16,12 +17,13 @@ export const isObject = (value) => typeof value === "object" && value !== null &
|
|
|
16
17
|
/** How long an Idempotency-Key answers with its first answer (capabilities' limits.idempotency_ttl_s). */
|
|
17
18
|
export const IDEMPOTENCY_TTL_S = 86_400;
|
|
18
19
|
export const stable = (value) => Array.isArray(value) ? `[${value.map(stable).join(",")}]` : isObject(value) ? `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${stable(value[k])}`).join(",")}}` : JSON.stringify(value);
|
|
19
|
-
export const DEFINITION_FIELDS = ["id", "version", "name", "description", "instructions", "workflow", "model", "thinking", "harness", "place", "computer", "learning", "skills", "tools", "tool_settings", "approvals", "max_cost_usd", "cap_mode"];
|
|
20
|
+
export const DEFINITION_FIELDS = ["id", "version", "name", "description", "instructions", "workflow", "model", "thinking", "harness", "place", "computer", "learning", "skills", "tools", "tool_settings", "approvals", "max_cost_usd", "cap_mode", "output_schema"];
|
|
20
21
|
/** Why a field a definition may have elsewhere has no place in an agent store's revision. */
|
|
21
22
|
export const NOT_KEPT = {
|
|
22
23
|
input_schema: "The agent store keeps no input_schema: an agentic run takes {content}, and a workflow checks its input against its own schema.",
|
|
23
|
-
output_schema: "The agent store keeps no output_schema: a workflow run's output is its workflow's.",
|
|
24
24
|
};
|
|
25
|
+
/** The most bytes an agent's output_schema takes, as JSON. */
|
|
26
|
+
export const MAX_OUTPUT_SCHEMA_BYTES = 64 * 1024;
|
|
25
27
|
/** `provider/model-id`. */
|
|
26
28
|
export const MODEL_REF = /^[^/\s]+\/\S+$/;
|
|
27
29
|
const SKILL_FILE = "/SKILL.md";
|
|
@@ -93,22 +95,29 @@ export function definitionIssues(definition, { at = "definition", creating = tru
|
|
|
93
95
|
else if (typeof d.learning !== "boolean")
|
|
94
96
|
out.push(issue(`${at}.learning`, "wrong_type", `${at}.learning is true or false`));
|
|
95
97
|
}
|
|
98
|
+
// An agentic revision's structured answer: the JSON Schema its final answer's last fenced json block meets, read into a
|
|
99
|
+
// completed run's result.output (answer-json.ts structuredAnswer). A workflow's output is its workflow's own.
|
|
100
|
+
if (d.output_schema !== undefined) {
|
|
101
|
+
if (d.workflow !== undefined)
|
|
102
|
+
out.push(issue(`${at}.output_schema`, "not_allowed", "A workflow revision keeps no output_schema: its run's output is its workflow's.", `Remove ${at}.output_schema.`));
|
|
103
|
+
else if (!isObject(d.output_schema))
|
|
104
|
+
out.push(issue(`${at}.output_schema`, "wrong_type", `${at}.output_schema is a JSON Schema object`));
|
|
105
|
+
else if (Buffer.byteLength(JSON.stringify(d.output_schema)) > MAX_OUTPUT_SCHEMA_BYTES)
|
|
106
|
+
out.push(issue(`${at}.output_schema`, "too_long", `${at}.output_schema is over ${MAX_OUTPUT_SCHEMA_BYTES} bytes as JSON`));
|
|
107
|
+
else {
|
|
108
|
+
const compiled = schemaCheck(d.output_schema);
|
|
109
|
+
if ("why" in compiled)
|
|
110
|
+
out.push(issue(`${at}.output_schema`, "bad_format", `${at}.output_schema ${compiled.why}`));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
96
113
|
if (d.skills !== undefined)
|
|
97
114
|
names(d.skills, `${at}.skills`, out);
|
|
98
115
|
if (d.tools !== undefined)
|
|
99
116
|
names(d.tools, `${at}.tools`, out);
|
|
100
117
|
// The agent's own tool settings, over the server's (tool-plane.ts); an edit that leaves them out keeps none.
|
|
101
118
|
if (d.tool_settings !== undefined) {
|
|
102
|
-
|
|
103
|
-
out.push(...
|
|
104
|
-
// An agent's own pin, once its store keeps one (AGENT_LAYER_PINS); until then a pin that is one is the server's to set.
|
|
105
|
-
if (!AGENT_LAYER_PINS && isObject(d.tool_settings)) {
|
|
106
|
-
for (const [name, setting] of Object.entries(d.tool_settings)) {
|
|
107
|
-
const field = `${at}.tool_settings.${name}.pin`;
|
|
108
|
-
if (isObject(setting) && setting.pin !== undefined && !settings.some((one) => one.field === field || one.field.startsWith(`${field}.`)))
|
|
109
|
-
out.push(issue(field, "not_set_up_here", AGENT_PIN_LATER));
|
|
110
|
-
}
|
|
111
|
-
}
|
|
119
|
+
// An agent's own pin among them, kept as given (the gate holds its runs to it).
|
|
120
|
+
out.push(...settingsIssues(d.tool_settings, `${at}.tool_settings`, "agent"));
|
|
112
121
|
}
|
|
113
122
|
// Whether the agent's runs ask a person (the gate as its settings say) or run unattended, an ask allowed: never over a
|
|
114
123
|
// deny. An edit that leaves it out asks, as one that leaves out tool_settings keeps none: no edit makes an agent
|
|
@@ -116,7 +125,7 @@ export function definitionIssues(definition, { at = "definition", creating = tru
|
|
|
116
125
|
if (d.approvals !== undefined && !APPROVALS.includes(d.approvals))
|
|
117
126
|
out.push(issue(`${at}.approvals`, "not_an_option", `${at}.approvals is one of ${APPROVALS.join(", ")}: ask, the default, waits for a person where a tool is set to ask; never runs the agent unattended, each such tool allowed, while a deny still refuses`));
|
|
118
127
|
// The agent's default cap of each run started without one of its own: above 0 sets it, 0 clears it (no default), and
|
|
119
|
-
// an edit that leaves it out keeps the agent's (agents.ts), so leaving a field out never removes a spend limit.
|
|
128
|
+
// an edit that leaves it out keeps the agent's (agents-store.ts), so leaving a field out never removes a spend limit.
|
|
120
129
|
if (d.max_cost_usd !== undefined) {
|
|
121
130
|
if (!(typeof d.max_cost_usd === "number" && Number.isFinite(d.max_cost_usd) && d.max_cost_usd >= 0))
|
|
122
131
|
out.push(issue(`${at}.max_cost_usd`, "wrong_type", `${at}.max_cost_usd is a number of at least 0, in US dollars: above 0 sets the agent's default cap, 0 clears it`));
|
package/dist/webhooks.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type SealedSettingsOverStore, type SettingsSpec } from "./sealed-settings-store.js";
|
|
2
|
+
import type { Settings } from "./store/index.js";
|
|
1
3
|
import type { TriggerFailed } from "./triggers.js";
|
|
2
4
|
/** A run's two notices, which runs.ts tells. */
|
|
3
5
|
export declare const RUN_EVENTS: readonly ["run.needs_input", "run.ended"];
|
|
@@ -6,14 +8,22 @@ export declare const WEBHOOK_EVENTS: readonly ["run.needs_input", "run.ended", "
|
|
|
6
8
|
/** The message types: a run's two notices, and the test send's. */
|
|
7
9
|
export declare const MESSAGE_TYPES: readonly ["run.needs_input", "run.ended", "trigger.failed", "webhook.test"];
|
|
8
10
|
type MessageType = (typeof MESSAGE_TYPES)[number];
|
|
9
|
-
|
|
10
|
-
export declare const
|
|
11
|
+
/** The store setting the webhook is kept in: its URL, when its secret was made, and why it is off, if it is. */
|
|
12
|
+
export declare const WEBHOOK_SETTING = "webhook";
|
|
13
|
+
/** The store setting the outbox is kept in: the messages, the last attempts and the ledger, written whole. */
|
|
14
|
+
export declare const OUTBOX_SETTING = "webhook_outbox";
|
|
15
|
+
/** The webhook's signing secret among the server's sealed settings (sealed-settings-store.ts): minted at the first PUT,
|
|
16
|
+
* kept sealed in the store, retired (still cut from what runs say) when it goes. Not a trigger source: its own adapter id. */
|
|
17
|
+
export declare const OUTBOUND_WEBHOOK: {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly settings: SettingsSpec;
|
|
20
|
+
};
|
|
11
21
|
/** The waits before each try again, after the first at once: the Standard Webhooks schedule, cut at about a day. */
|
|
12
22
|
export declare const RETRY_MS: readonly number[];
|
|
13
23
|
/** How many attempts the log keeps, and with them the messages they tried, for a redelivery. */
|
|
14
24
|
export declare const ATTEMPTS_KEPT = 50;
|
|
15
25
|
/** What a notice says of its run: never its tools' arguments, its output or its input, which a receiver reads through the API. */
|
|
16
|
-
/** What `emit` did with a notice: `queued`, in the outbox
|
|
26
|
+
/** What `emit` did with a notice: `queued`, in the outbox in the store (or already there, or counted as sent); `unsaved`,
|
|
17
27
|
* held here only, its outbox write failed; `off`, no webhook set, or one a 410 turned off, so nothing is to be sent;
|
|
18
28
|
* `closed`, the server is stopping. */
|
|
19
29
|
export type Emitted = "queued" | "unsaved" | "off" | "closed";
|
|
@@ -26,17 +36,6 @@ export type RunNotice = {
|
|
|
26
36
|
kind: "question" | "approval" | "stopped" | "budget" | "browser";
|
|
27
37
|
};
|
|
28
38
|
};
|
|
29
|
-
/** `secret_at`: when the secret was made, its own time (a URL change keeps it); absent in a file from before it was kept. */
|
|
30
|
-
type Config = {
|
|
31
|
-
url: string;
|
|
32
|
-
secret: string;
|
|
33
|
-
secret_at?: string;
|
|
34
|
-
updated_at: string;
|
|
35
|
-
disabled?: {
|
|
36
|
-
at: string;
|
|
37
|
-
reason: string;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
39
|
export type Attempt = {
|
|
41
40
|
webhook_id: string;
|
|
42
41
|
type: MessageType;
|
|
@@ -47,29 +46,45 @@ export type Attempt = {
|
|
|
47
46
|
retry_at: string | null;
|
|
48
47
|
redelivery: boolean;
|
|
49
48
|
};
|
|
50
|
-
/** Whether the secret signs here: sealed, or not, for
|
|
51
|
-
type Signing = "sealed" | "
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
} | {
|
|
57
|
-
signing: Exclude<Signing, "sealed">;
|
|
49
|
+
/** Whether the secret signs here: sealed, or not, for a seal key it does not open under (or damaged). */
|
|
50
|
+
type Signing = "sealed" | "unreadable";
|
|
51
|
+
/** The store slice the webhook reads and writes: its two settings, and the durable commit after each write. */
|
|
52
|
+
export type WebhookStore = {
|
|
53
|
+
readonly settings: Pick<Settings, "get" | "put" | "remove">;
|
|
54
|
+
flush(): Promise<void>;
|
|
58
55
|
};
|
|
59
|
-
/** The
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
/** The webhook's secret, among the server's sealed settings (OUTBOUND_WEBHOOK), loaded before the webhook is. */
|
|
57
|
+
export type WebhookSecret = Pick<SealedSettingsOverStore, "get" | "mint" | "remove">;
|
|
58
|
+
export { signatureOf } from "./standard-webhooks.js";
|
|
59
|
+
/** The mark of the wait a run stands at, its webhook-id's marker: one per ask, however often or whenever the run is read,
|
|
60
|
+
* so every read of the same ask makes the same webhook-id. A question's is its waiting row (run-view.ts withAsks: the
|
|
61
|
+
* asked call's result, `:waiting`); an approval's, the call it holds; a budget pause's, its time; a hand-over's, when it
|
|
62
|
+
* was asked; a stop, which waits on no ask, the last row that shows (not usage, a phase or learning's). Never the last
|
|
63
|
+
* row for an ask: a run read between the person's answer and its runner's take of it shows the answer last, and a
|
|
64
|
+
* marker from that row would tell the same ask twice, under two ids. Undefined when there is none. */
|
|
65
|
+
export declare function waitMarkerOf(rows: readonly {
|
|
66
|
+
id: string;
|
|
67
|
+
kind: string;
|
|
68
|
+
agent_label?: string | null;
|
|
69
|
+
}[], pending: {
|
|
70
|
+
kind?: unknown;
|
|
71
|
+
id?: unknown;
|
|
72
|
+
at?: unknown;
|
|
73
|
+
asked_at?: unknown;
|
|
74
|
+
} | null | undefined, waiting: boolean, learningLabel: string): string | undefined;
|
|
63
75
|
export declare class Webhooks {
|
|
76
|
+
private readonly store;
|
|
77
|
+
private readonly secret;
|
|
64
78
|
private readonly say;
|
|
65
79
|
private readonly retryMs;
|
|
66
|
-
private readonly file;
|
|
67
|
-
private readonly outbox;
|
|
68
|
-
private readonly key;
|
|
69
80
|
private messages;
|
|
70
81
|
private attempts;
|
|
71
82
|
/** The ledger, by run: written with the messages, in the same write. */
|
|
72
83
|
private notices;
|
|
84
|
+
/** The webhook as the store holds it: read at load, then kept with every write (this server is the store's one writer).
|
|
85
|
+
* A write that failed (a 410 that turned it off, on a store that refused the write) leaves it held here as it now is, and
|
|
86
|
+
* the next PUT writes it whole. */
|
|
87
|
+
private current?;
|
|
73
88
|
/** The runs told of since this server started: their ledger entries are this server's news, which a start's catch-up
|
|
74
89
|
* never drops. */
|
|
75
90
|
private readonly told;
|
|
@@ -79,29 +94,27 @@ export declare class Webhooks {
|
|
|
79
94
|
private readonly trying;
|
|
80
95
|
private readonly stop;
|
|
81
96
|
private closed;
|
|
82
|
-
/** The outbox as held here is not
|
|
97
|
+
/** The outbox as held here is not in the store: its last write failed. Written again soon, and at the close. */
|
|
83
98
|
private unsaved;
|
|
84
99
|
private saving?;
|
|
85
|
-
/** The
|
|
86
|
-
|
|
87
|
-
|
|
100
|
+
/** The outbox's writes, one after another: each writes the outbox as it stands when its turn comes. */
|
|
101
|
+
private writing;
|
|
102
|
+
/** What reads the webhook and then writes it (a PUT, a DELETE, a try's 410 that turns it off), one after another: each
|
|
103
|
+
* reads it as the last one left it, so a 410 never turns off a webhook a PUT set again meanwhile. */
|
|
104
|
+
private changing;
|
|
105
|
+
/** A DELETE under way: no notice is queued meanwhile, so none slips past its drop of the pending messages. */
|
|
106
|
+
private removing;
|
|
88
107
|
/** The messages with a try in flight, by id, and how many: kept in the outbox until each lands, so one whose earlier
|
|
89
108
|
* attempts left the log meanwhile can still be redelivered. */
|
|
90
109
|
private readonly sending;
|
|
91
|
-
/** `
|
|
92
|
-
|
|
110
|
+
/** `store` keeps the webhook and its outbox, `secret` its signing secret (the server's sealed settings for
|
|
111
|
+
* OUTBOUND_WEBHOOK, loaded); `say` takes a log line's fields; `retryMs` the waits between tries. load() before use. */
|
|
112
|
+
constructor(store: WebhookStore, secret: WebhookSecret, say: (fields: Record<string, string | number>) => void, retryMs?: readonly number[]);
|
|
113
|
+
/** Reads the webhook and the outbox as the last server left them, and goes on with the messages it left pending, each at
|
|
114
|
+
* its next try's time; a test send is tried once, so one left in flight failed. Awaited once, before anything else. */
|
|
115
|
+
load(): Promise<void>;
|
|
93
116
|
/** Where the page is, for each notice's link to its run. */
|
|
94
117
|
attach(base: string): void;
|
|
95
|
-
/** The secret, opened here, and each one this server held before it since it started (removed by a DELETE, or
|
|
96
|
-
* replaced), for the server's list of its own secrets (server-secrets.ts): a run that echoes an old one is cut all the
|
|
97
|
-
* same. None that is not there, or does not open. */
|
|
98
|
-
signingSecrets(): string[];
|
|
99
|
-
/** The secrets this webhook signed with before, in memory alone, for this process's life. */
|
|
100
|
-
private readonly retired;
|
|
101
|
-
/** The secret, opened here; undefined when there is none, or it does not open. */
|
|
102
|
-
private signingSecret;
|
|
103
|
-
/** signingSecret's last reading: read again after any write of the webhook's file, which only this server makes. */
|
|
104
|
-
private signing?;
|
|
105
118
|
/** GET: the URL, whether the secret signs here, and why the webhook is off, if it is; its secret's metadata (secret-writes.ts
|
|
106
119
|
* SecretMeta), never the secret. */
|
|
107
120
|
view(): {
|
|
@@ -122,34 +135,36 @@ export declare class Webhooks {
|
|
|
122
135
|
} | null;
|
|
123
136
|
updated_at: string;
|
|
124
137
|
};
|
|
125
|
-
/** PUT: the URL, and the webhook on again. The first makes the secret and answers it, once; a later one keeps it
|
|
126
|
-
|
|
138
|
+
/** PUT: the URL, and the webhook on again. The first makes the secret and answers it, once; a later one keeps it, or
|
|
139
|
+
* makes a new one (answered once) when the one kept does not open under this server's seal key. */
|
|
140
|
+
save(body: Record<string, unknown>): Promise<{
|
|
127
141
|
created: boolean;
|
|
128
142
|
view: ReturnType<Webhooks["view"]>;
|
|
129
143
|
secret?: string;
|
|
130
|
-
}
|
|
131
|
-
/** DELETE: the webhook gone,
|
|
132
|
-
|
|
144
|
+
}>;
|
|
145
|
+
/** DELETE: the webhook gone, its secret with it (retired: still cut from what a run says), and its pending messages; the
|
|
146
|
+
* log of attempts stays. */
|
|
147
|
+
remove(): Promise<void>;
|
|
133
148
|
/** GET .../deliveries: the last attempts, newest first. */
|
|
134
149
|
attemptsView(): {
|
|
135
150
|
attempts: Attempt[];
|
|
136
151
|
};
|
|
137
|
-
/** A run's moment, told by
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
emit(type: (typeof RUN_EVENTS)[number], run: RunNotice, marker: string): Emitted
|
|
152
|
+
/** A run's moment, told by the server each time it sees it (a wait reached, an end the store has): queued once, when a
|
|
153
|
+
* webhook is set and on, and kept in the ledger in the same write. `marker` makes its webhook-id: the same moment, seen
|
|
154
|
+
* again after a restart, has the same id, which is a receiver's idempotency key. An end before the webhook was set, or
|
|
155
|
+
* past the outbox's day, counts as sent. */
|
|
156
|
+
emit(type: (typeof RUN_EVENTS)[number], run: RunNotice, marker: string): Promise<Emitted>;
|
|
142
157
|
/** A trigger's failed firing (triggers.ts), queued once: its webhook-id is made from the firing's key, so the same
|
|
143
158
|
* failure told again, by a later server too, is the same message. Its trigger keeps whether it was queued. */
|
|
144
|
-
emitTrigger(failed: TriggerFailed, firingKey: string): Emitted
|
|
145
|
-
/** A start's catch-up, once its runs are read (`rows`, the
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* server was killed between the
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
159
|
+
emitTrigger(failed: TriggerFailed, firingKey: string): Promise<Emitted>;
|
|
160
|
+
/** A start's catch-up, once its runs are read (`rows`, the store's: a row with no state is an ended one). First, before
|
|
161
|
+
* anything is awaited, the ledger as the store now stands: a run the store no longer has goes, and a wait of a run it
|
|
162
|
+
* holds as ended goes (an end the webhook was off for never moved it past). Then each end the store holds that the
|
|
163
|
+
* ledger does not, and that is still due, is queued under the store's end time, so under the same webhook-id: its
|
|
164
|
+
* server was killed between the run's end and the outbox write, or that write never landed. `current` reads the run as
|
|
165
|
+
* the store holds it right before its end is queued, with its notice (null: no such run now). The server takes
|
|
166
|
+
* requests meanwhile, so a run continued since the rows were read has moved past that end, which was queued before it
|
|
167
|
+
* could be continued: its end is not queued again. */
|
|
153
168
|
catchUp(rows: Iterable<{
|
|
154
169
|
id: string;
|
|
155
170
|
state?: string;
|
|
@@ -163,28 +178,39 @@ export declare class Webhooks {
|
|
|
163
178
|
test(): Promise<Attempt>;
|
|
164
179
|
/** POST .../deliveries/{webhook_id}/redeliver: the message sent again once now, under its own webhook-id and body. */
|
|
165
180
|
redeliver(id: string): Promise<Attempt>;
|
|
166
|
-
/** Stops: no try starts, those in flight are cut and waited for, and nothing more is written
|
|
167
|
-
* still pending
|
|
181
|
+
/** Stops: no try starts, those in flight are cut and waited for, and nothing more is written but what a failed write left
|
|
182
|
+
* only here. A message cut here is still pending in the store, for the next server (its receiver may get it twice,
|
|
183
|
+
* under the same webhook-id). Before the store closes. */
|
|
168
184
|
close(): Promise<void>;
|
|
169
185
|
private config;
|
|
170
|
-
/**
|
|
186
|
+
/** Whether what is held here is in the store: once every outbox write asked for so far has settled (each writes it
|
|
187
|
+
* whole), `queued` when the last one landed, else `unsaved`. A moment told again while its first write is still in
|
|
188
|
+
* flight waits for it, never answering `queued` before it lands. */
|
|
189
|
+
private landed;
|
|
190
|
+
/** `work`, once every change of the webhook asked for before it has settled, failed or not. */
|
|
191
|
+
private change;
|
|
192
|
+
/** The signing secret, opened here; undefined when there is none, or it does not open under this server's seal key. */
|
|
193
|
+
private signingSecret;
|
|
194
|
+
/** Throws when the write fails: the webhook as held here stays as it was. */
|
|
171
195
|
private write;
|
|
172
|
-
/** The outbox as the last server left it.
|
|
173
|
-
private
|
|
196
|
+
/** The outbox as the last server left it. One of another version is not read, and the log says which it was. */
|
|
197
|
+
private outboxOf;
|
|
174
198
|
/** Whether an end's run.ended is still to be queued: at or after the webhook was set and the outbox's day began (a
|
|
175
199
|
* marker that names no time is not judged by one). The catch-up and the ledger's pruning read the same line, so the
|
|
176
200
|
* ledger never forgets an end a start would look for. */
|
|
177
201
|
private due;
|
|
178
|
-
/** The ledger without what no start looks for: a run whose end is no longer due goes, with the
|
|
179
|
-
*
|
|
202
|
+
/** The ledger without what no start looks for: a run whose end is no longer due goes, with the waits it ended past.
|
|
203
|
+
* Waits with no end after them stay while the run stands at it, however long: never pruned by age, so the same question
|
|
180
204
|
* is never asked again. */
|
|
181
205
|
private prune;
|
|
206
|
+
/** The outbox written, after every write asked for before it; whether it landed. One that failed is kept here and
|
|
207
|
+
* written again until a write lands (or the close writes it). Closed, nothing is written: the store may be the next
|
|
208
|
+
* server's already. */
|
|
182
209
|
private writeOutbox;
|
|
183
|
-
/** The outbox written whole: the last attempts, and the messages pending or tried by one of
|
|
184
|
-
* one again). False when the write failed, which the log says once until one lands. */
|
|
185
|
-
private
|
|
186
|
-
/**
|
|
187
|
-
private secret;
|
|
210
|
+
/** The outbox written whole, in one durable commit: the last attempts, and the messages pending or tried by one of
|
|
211
|
+
* those (a redelivery sends one again). False when the write failed, which the log says once until one lands. */
|
|
212
|
+
private persist;
|
|
213
|
+
/** A new pending message, and its outbox write (whether it landed). */
|
|
188
214
|
private enqueue;
|
|
189
215
|
private schedule;
|
|
190
216
|
private attempt;
|