@parcha/agentrun-serve 0.1.0-beta.36 → 0.1.0-beta.37
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 +170 -0
- package/README.md +158 -52
- package/dist/attach-conformance-cli.d.ts +1 -0
- package/dist/attach-conformance-cli.js +18 -0
- package/dist/attach-conformance.d.ts +25 -0
- package/dist/attach-conformance.js +343 -0
- package/dist/browser-cost.d.ts +1 -1
- package/dist/browser-live.d.ts +20 -8
- package/dist/browser-live.js +50 -27
- package/dist/cap.d.ts +0 -17
- package/dist/cap.js +0 -91
- package/dist/catalog.d.ts +1 -12
- package/dist/catalog.js +3 -33
- package/dist/cli.js +13 -4
- package/dist/composio-preset.d.ts +36 -0
- package/dist/composio-preset.js +179 -0
- package/dist/computer-attach.d.ts +125 -0
- package/dist/computer-attach.js +330 -0
- package/dist/computer-calls.d.ts +48 -0
- package/dist/computer-calls.js +126 -0
- package/dist/computer-channel.d.ts +57 -0
- package/dist/computer-channel.js +115 -0
- package/dist/computer-commands.d.ts +1 -1
- package/dist/computer-held-routes.d.ts +35 -0
- package/dist/computer-held-routes.js +106 -0
- package/dist/computer-held.d.ts +48 -0
- package/dist/computer-held.js +87 -0
- package/dist/computer-keys.d.ts +21 -1
- package/dist/computer-keys.js +53 -11
- package/dist/computer-live.d.ts +160 -0
- package/dist/computer-live.js +643 -0
- package/dist/computer-view.d.ts +13 -0
- package/dist/computer-view.js +50 -3
- package/dist/computer-viewer.d.ts +6 -0
- package/dist/computer-viewer.js +297 -0
- package/dist/computers.d.ts +33 -7
- package/dist/computers.js +50 -8
- package/dist/console/assets/index-Cn6JX1uH.js +563 -0
- package/dist/console/assets/index-DRN62V5v.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/faux-computers.d.ts +9 -20
- package/dist/faux-computers.js +53 -25
- package/dist/github-connection.d.ts +10 -2
- package/dist/github-connection.js +65 -2
- package/dist/github-faux.js +1 -1
- package/dist/graph-view.d.ts +1 -1
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +35 -1
- package/dist/host-tools.d.ts +1 -1
- package/dist/hosted-search.d.ts +5 -4
- package/dist/hosted-search.js +2 -7
- package/dist/import-sources.d.ts +10 -0
- package/dist/import-sources.js +44 -2
- package/dist/import.d.ts +3 -3
- package/dist/import.js +37 -6
- package/dist/learn/check.d.ts +4 -1
- package/dist/learn/check.js +1 -1
- package/dist/learn/commit.d.ts +4 -2
- package/dist/learn/commit.js +5 -5
- package/dist/learn/folder.d.ts +6 -0
- package/dist/learn/folder.js +4 -1
- package/dist/learn/general.d.ts +66 -0
- package/dist/learn/general.js +73 -0
- package/dist/learn/grade.d.ts +4 -0
- package/dist/learn/grade.js +22 -1
- package/dist/learn/reflect.d.ts +10 -1
- package/dist/learn/reflect.js +14 -4
- package/dist/learn/skills.d.ts +33 -5
- package/dist/learn/skills.js +53 -7
- package/dist/learned-workflow.d.ts +24 -0
- package/dist/learned-workflow.js +66 -3
- package/dist/learning-batch.d.ts +283 -0
- package/dist/learning-batch.js +574 -0
- package/dist/learning-evals.d.ts +33 -0
- package/dist/learning-evals.js +98 -0
- package/dist/learning-routes.d.ts +25 -2
- package/dist/learning-routes.js +39 -6
- package/dist/learning-words.d.ts +6 -0
- package/dist/learning-words.js +6 -0
- package/dist/learning.d.ts +28 -15
- package/dist/learning.js +84 -44
- package/dist/live/stream.js +6 -3
- package/dist/live/translate.d.ts +4 -3
- package/dist/live/translate.js +8 -4
- package/dist/live-reach.d.ts +37 -0
- package/dist/live-reach.js +62 -0
- package/dist/mcp-gateway.d.ts +9 -0
- package/dist/mcp-gateway.js +60 -11
- package/dist/mcp-oauth.d.ts +57 -7
- package/dist/mcp-oauth.js +133 -18
- package/dist/mcp-private-hosts.d.ts +4 -4
- package/dist/mcp-private-hosts.js +20 -12
- package/dist/mcp-probe.d.ts +19 -2
- package/dist/mcp-probe.js +44 -9
- package/dist/mcp-secret-writes.js +4 -0
- package/dist/mcp-servers-store.d.ts +38 -15
- package/dist/mcp-servers-store.js +112 -20
- package/dist/mcp-store.d.ts +10 -4
- package/dist/mcp-store.js +17 -6
- package/dist/model-form.d.ts +26 -0
- package/dist/model-form.js +80 -0
- package/dist/model.js +23 -10
- package/dist/openapi.js +386 -21
- package/dist/page.d.ts +18 -0
- package/dist/page.js +48 -20
- package/dist/paid-calls.d.ts +1 -1
- package/dist/place-offers.d.ts +2 -3
- package/dist/place-offers.js +3 -7
- package/dist/place.js +1 -2
- package/dist/print.d.ts +15 -1
- package/dist/print.js +14 -3
- package/dist/propose.d.ts +3 -0
- package/dist/propose.js +13 -5
- package/dist/provider.js +3 -2
- package/dist/reflect-range.d.ts +8 -1
- package/dist/reflect-range.js +1 -1
- package/dist/run-launch.d.ts +14 -2
- package/dist/run-launch.js +9 -4
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-repo.d.ts +20 -0
- package/dist/run-repo.js +63 -0
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-view.d.ts +3 -3
- package/dist/run-view.js +14 -7
- package/dist/runner/adapter-loop.d.ts +23 -7
- package/dist/runner/adapter-loop.js +648 -62
- package/dist/runner/adapter-run-spec.d.ts +11 -3
- package/dist/runner/adapter-run-spec.js +77 -22
- package/dist/runner/adapters/pi-computer.d.ts +7 -0
- package/dist/runner/adapters/pi-computer.js +43 -0
- package/dist/runner/adapters/pi.d.ts +9 -4
- package/dist/runner/adapters/pi.js +76 -14
- package/dist/runner/beside.d.ts +7 -3
- package/dist/runner/beside.js +21 -11
- package/dist/runner/claim-secrets.d.ts +4 -0
- package/dist/runner/claim-secrets.js +6 -1
- package/dist/runner/cli-run-spec.d.ts +20 -3
- package/dist/runner/cli-run-spec.js +113 -43
- package/dist/runner/commands.d.ts +3 -1
- package/dist/runner/commands.js +28 -3
- package/dist/runner/computer-channel.d.ts +34 -0
- package/dist/runner/computer-channel.js +61 -0
- package/dist/runner/conformance/harness.js +80 -14
- package/dist/runner/conformance/subject.d.ts +1 -1
- package/dist/runner/dispatch.js +3 -0
- package/dist/runner/end-of-run.d.ts +22 -12
- package/dist/runner/end-of-run.js +38 -16
- package/dist/runner/github-app.d.ts +2 -1
- package/dist/runner/github-app.js +4 -2
- package/dist/runner/harness-loops.js +15 -1
- package/dist/runner/held-run.d.ts +65 -0
- package/dist/runner/held-run.js +158 -0
- package/dist/runner/journal-kinds.d.ts +20 -1
- package/dist/runner/journal-kinds.js +14 -0
- package/dist/runner/journal-reader.d.ts +5 -4
- package/dist/runner/journal-reader.js +12 -10
- package/dist/runner/learning-ask.d.ts +7 -1
- package/dist/runner/learning-ask.js +21 -6
- package/dist/runner/learning-dispatch.d.ts +22 -0
- package/dist/runner/learning-dispatch.js +77 -10
- package/dist/runner/learning-end.d.ts +22 -1
- package/dist/runner/learning-end.js +92 -12
- package/dist/runner/learning-factory.d.ts +1 -1
- package/dist/runner/learning-factory.js +11 -5
- package/dist/runner/learning-loop.d.ts +67 -7
- package/dist/runner/learning-loop.js +173 -21
- package/dist/runner/learning-seed.d.ts +7 -0
- package/dist/runner/learning-seed.js +13 -0
- package/dist/runner/live-ticker.js +1 -0
- package/dist/runner/loop-contract.d.ts +8 -1
- package/dist/runner/loop.d.ts +5 -1
- package/dist/runner/loop.js +2 -1
- package/dist/runner/main.d.ts +13 -1
- package/dist/runner/main.js +27 -5
- package/dist/runner/mcp-claim.d.ts +10 -7
- package/dist/runner/mcp-claim.js +113 -24
- package/dist/runner/mcp-github.js +1 -1
- package/dist/runner/mcp-run.d.ts +5 -5
- package/dist/runner/mcp-run.js +15 -3
- package/dist/runner/metrics.d.ts +11 -2
- package/dist/runner/metrics.js +12 -2
- package/dist/runner/pr-checkout.d.ts +1 -0
- package/dist/runner/pr-checkout.js +1 -1
- package/dist/runner/reflect-hook.d.ts +18 -0
- package/dist/runner/reflect-hook.js +20 -8
- package/dist/runner/runner.d.ts +26 -0
- package/dist/runner/runner.js +184 -15
- package/dist/runner/scratch-sweep.d.ts +13 -0
- package/dist/runner/scratch-sweep.js +62 -0
- package/dist/runner/sessions.d.ts +1 -1
- package/dist/runner/store-port.d.ts +4 -2
- package/dist/runner/store-secrets.js +4 -3
- package/dist/runner/subagent.js +3 -1
- package/dist/runner/workflow-host.d.ts +6 -1
- package/dist/runner/workflow-host.js +1 -1
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-spec.d.ts +14 -2
- package/dist/runner/workflow-spec.js +56 -20
- package/dist/runs-over-store.d.ts +6 -1
- package/dist/runs-over-store.js +38 -9
- package/dist/seal-key.js +3 -3
- package/dist/sealed-settings-store.d.ts +5 -2
- package/dist/sealed-settings-store.js +10 -4
- package/dist/secret-writes.d.ts +5 -4
- package/dist/secret-writes.js +5 -4
- package/dist/server-secrets-store.d.ts +4 -3
- package/dist/server-secrets-store.js +15 -9
- package/dist/server-secrets.js +3 -2
- package/dist/server.d.ts +43 -14
- package/dist/server.js +472 -126
- package/dist/settings-wake.d.ts +21 -0
- package/dist/settings-wake.js +59 -0
- package/dist/standard-webhooks.d.ts +4 -1
- package/dist/standard-webhooks.js +8 -4
- package/dist/store/command-wake.d.ts +12 -0
- package/dist/store/command-wake.js +37 -0
- package/dist/store/dialect.d.ts +6 -0
- package/dist/store/dialect.js +5 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/journal/storage.d.ts +3 -2
- package/dist/store/journal/storage.js +13 -5
- package/dist/store/postgres/dialect.js +4 -0
- package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
- package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
- package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
- package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
- package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
- package/dist/store/schema.d.ts +1 -1
- package/dist/store/schema.js +77 -8
- package/dist/store/sqlite/run-patch.d.ts +7 -5
- package/dist/store/sqlite/run-patch.js +28 -13
- package/dist/store/sqlite/store.js +272 -54
- package/dist/store/store.d.ts +268 -9
- package/dist/store/store.js +12 -1
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +8 -1
- package/dist/store-reads/decisions.d.ts +2 -2
- package/dist/store-reads/decisions.js +1 -1
- package/dist/store-reads/import-summary.d.ts +1 -1
- package/dist/store-reads/journal.d.ts +5 -4
- package/dist/store-reads/journal.js +73 -15
- package/dist/store-reads/learning.d.ts +20 -4
- package/dist/store-reads/learning.js +74 -18
- package/dist/store-reads/runs.d.ts +1 -1
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-view.d.ts +5 -0
- package/dist/store-view.js +26 -11
- package/dist/template-eval.js +6 -4
- package/dist/template-github-permissions.d.ts +22 -8
- package/dist/template-github-permissions.js +35 -15
- package/dist/timeline/timeline.d.ts +27 -0
- package/dist/timeline/timeline.js +10 -9
- package/dist/timeline/util.d.ts +4 -0
- package/dist/timeline/util.js +14 -0
- package/dist/tool-budget.d.ts +19 -7
- package/dist/tool-budget.js +14 -8
- package/dist/tool-gate.d.ts +16 -9
- package/dist/tool-gate.js +53 -42
- package/dist/tool-plane.d.ts +16 -12
- package/dist/tool-plane.js +9 -4
- package/dist/tools.d.ts +13 -4
- package/dist/tools.js +13 -4
- package/dist/trigger-adapter.d.ts +4 -0
- package/dist/trigger-secrets-shown.d.ts +2 -2
- package/dist/trigger-secrets-shown.js +1 -1
- package/dist/trigger-signatures.d.ts +25 -6
- package/dist/trigger-signatures.js +41 -7
- package/dist/trigger-targets.d.ts +2 -0
- package/dist/trigger-targets.js +1 -0
- package/dist/trigger-webhook.js +5 -2
- package/dist/triggers.d.ts +7 -3
- package/dist/triggers.js +35 -5
- package/dist/turns.js +16 -1
- package/dist/validate.js +11 -1
- package/dist/web-fetch.d.ts +1 -1
- package/dist/web-search.d.ts +10 -5
- package/dist/web-search.js +7 -6
- package/dist/webhooks.d.ts +145 -102
- package/dist/webhooks.js +559 -322
- package/dist/workflow/decisions.d.ts +1 -1
- package/dist/workflow/node-runner.d.ts +2 -1
- package/dist/workflow/node.d.ts +2 -1
- package/dist/workflow/node.js +3 -1
- package/dist/workflow/pi-versions.d.ts +23 -0
- package/dist/workflow/pi-versions.js +57 -0
- package/dist/workflow/record-tool.d.ts +2 -1
- package/dist/workflow/store.d.ts +1 -1
- package/dist/workflow/task.js +3 -2
- package/dist/workflow-run.d.ts +1 -1
- package/dist/workspace/attached-computers.d.ts +41 -0
- package/dist/workspace/attached-computers.js +114 -0
- package/dist/workspace/computer-deps.d.ts +16 -9
- package/dist/workspace/computer-deps.js +19 -7
- package/dist/workspace/computer-for-claim.d.ts +17 -8
- package/dist/workspace/computer-for-claim.js +62 -21
- package/dist/workspace/computer-hold.d.ts +11 -27
- package/dist/workspace/computer-hold.js +36 -56
- package/dist/workspace/computer-ledger.d.ts +3 -1
- package/dist/workspace/computer-ledger.js +4 -0
- package/dist/workspace/computer-mcp.d.ts +25 -0
- package/dist/workspace/computer-mcp.js +41 -0
- package/dist/workspace/computer-ports.d.ts +4 -13
- package/dist/workspace/computer-ports.js +4 -107
- package/dist/workspace/computer-script.d.ts +37 -0
- package/dist/workspace/computer-script.js +138 -0
- package/dist/workspace/executors.d.ts +1 -1
- package/dist/workspace/index.d.ts +4 -2
- package/dist/workspace/index.js +3 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +119 -84
- package/dist/workspace/kind-skills/phone/SKILL.md +100 -85
- package/dist/workspace/resolve-computer.d.ts +3 -0
- package/dist/workspace/resolve-computer.js +8 -2
- package/dist/workspace/run-tools.d.ts +32 -15
- package/dist/workspace/run-tools.js +23 -30
- package/package.json +19 -16
- package/templates/market-monitor/agent.md +1 -1
- package/dist/console/assets/index-BI4Byidu.js +0 -550
- package/dist/console/assets/index-C19gUF2n.css +0 -1
- package/dist/run-db.d.ts +0 -53
- package/dist/run-db.js +0 -116
- package/dist/workflow/readers.d.ts +0 -36
- package/dist/workflow/readers.js +0 -145
- package/dist/workflow/wal.d.ts +0 -11
- package/dist/workflow/wal.js +0 -106
package/dist/tool-plane.js
CHANGED
|
@@ -68,14 +68,19 @@ export const SERVE_OWN_TOOLS = ["learned_workflow"];
|
|
|
68
68
|
* held to `desktop`, every phone tool to `phone` (the kernel registry's definitions name the key; tool-gate.ts
|
|
69
69
|
* settingsKeyOf reads it there). Allowed by default like a table tool; allow or deny. */
|
|
70
70
|
export const KIND_KEYS = ["desktop", "phone"];
|
|
71
|
+
/** A decision provider's settings key, its bare id (decisions.ts' providers: Jev, Parallel, OpenRouter's Decisions
|
|
72
|
+
* models): what an agent's learned workflow's decision nodes may ask (learned-workflow.ts, LS-07), and whose keys the
|
|
73
|
+
* runner hands its claim. Allowed by default; allow or deny. A workflow agent's own decisions read no setting of it. */
|
|
74
|
+
export const DECISION_PROVIDER_KEYS = ["jev", "parallel", "openrouter"];
|
|
71
75
|
/** A settings key: a tool of the table, one of the run's own tools (SERVE_OWN_TOOLS), a computer kind's (KIND_KEYS), a
|
|
76
|
+
* decision provider's (DECISION_PROVIDER_KEYS), a
|
|
72
77
|
* catalog tool (`monid.<tool>`, `mcp:<server>/<tool>`), or an MCP server's wildcard (`mcp:<server>/*`), which sets each
|
|
73
78
|
* of its tools. */
|
|
74
79
|
/** A tool's name in an agent's or the server's tool settings: a plain name, a catalog's tool (`monid.discover`), an MCP
|
|
75
80
|
* server's tool (`mcp:<server>/<tool>`) or its wildcard (`mcp:<server>/*`). */
|
|
76
81
|
const TOOL_KEY = /^(?:[a-z][a-z0-9_-]{0,63}(?:\.[A-Za-z0-9_-]{1,64})?|mcp:[A-Za-z0-9_.-]{1,64}\/(?:\*|[A-Za-z0-9_.-]{1,128}))$/;
|
|
77
82
|
const isToolSettingsKey = (name) => TOOL_KEY.test(name);
|
|
78
|
-
const isSettingsKey = (name) => isToolSettingsKey(name) && (TABLE_TOOLS.includes(name) || SERVE_OWN_TOOLS.includes(name) || KIND_KEYS.includes(name) || isCatalogTool(name) || /^mcp:[^/]+\/\*$/.test(name));
|
|
83
|
+
const isSettingsKey = (name) => isToolSettingsKey(name) && (TABLE_TOOLS.includes(name) || SERVE_OWN_TOOLS.includes(name) || KIND_KEYS.includes(name) || DECISION_PROVIDER_KEYS.includes(name) || isCatalogTool(name) || /^mcp:[^/]+\/\*$/.test(name));
|
|
79
84
|
/** The longest pinned string. */
|
|
80
85
|
export const MAX_PIN_TEXT = 1024;
|
|
81
86
|
/** A pinned argument's name: a top-level argument of the tool, as MCP tools name theirs. */
|
|
@@ -369,7 +374,7 @@ export function settingsIssues(value, at = "", layer = "server") {
|
|
|
369
374
|
return Object.entries(value).flatMap(([name, setting]) => {
|
|
370
375
|
const pickable = Object.hasOwn(PROVIDERS, name);
|
|
371
376
|
if (!isSettingsKey(name))
|
|
372
|
-
return [{ field: field(name), reason: "not_allowed", message: `Tool settings are kept for this server's tools (${[...TABLE_TOOLS, ...SERVE_OWN_TOOLS, ...KIND_KEYS].join(", ")}), catalog tools (monid.<tool>, mcp:<server>/<tool>) and an MCP server's tools (mcp:<server>/*); ${name} is none of them.` }];
|
|
377
|
+
return [{ field: field(name), reason: "not_allowed", message: `Tool settings are kept for this server's tools (${[...TABLE_TOOLS, ...SERVE_OWN_TOOLS, ...KIND_KEYS, ...DECISION_PROVIDER_KEYS].join(", ")}), catalog tools (monid.<tool>, mcp:<server>/<tool>) and an MCP server's tools (mcp:<server>/*); ${name} is none of them.` }];
|
|
373
378
|
if (!isPlain(setting))
|
|
374
379
|
return [{ field: field(name), reason: "wrong_type", message: `${field(name)} is an object, {${pickable ? "provider, " : ""}permission${isMcpTool(name) ? ", pin" : ""}${layer === "agent" && name === "bash" ? ", policy" : ""}}` }];
|
|
375
380
|
return Object.entries(setting).flatMap(([key, given]) => {
|
|
@@ -390,7 +395,7 @@ export function settingsIssues(value, at = "", layer = "server") {
|
|
|
390
395
|
}
|
|
391
396
|
if (key === "permission") {
|
|
392
397
|
// A wildcard sets each tool of its server's: a catalog tool's permissions.
|
|
393
|
-
const offered = permissionsOf(
|
|
398
|
+
const offered = permissionsOf(name);
|
|
394
399
|
return offered.includes(given) ? [] : [{ field: field(name, key), reason: "not_an_option", message: `${field(name, key)} is one of ${offered.join(", ")}` }];
|
|
395
400
|
}
|
|
396
401
|
if (key !== "provider" || !pickable)
|
|
@@ -453,7 +458,7 @@ export function checkToolSettings(read, where) {
|
|
|
453
458
|
kept.pin = setting.pin;
|
|
454
459
|
}
|
|
455
460
|
if (setting.permission !== undefined) {
|
|
456
|
-
const offered = permissionsOf(
|
|
461
|
+
const offered = permissionsOf(name);
|
|
457
462
|
if (offered.includes(setting.permission))
|
|
458
463
|
kept.permission = setting.permission;
|
|
459
464
|
else {
|
package/dist/tools.d.ts
CHANGED
|
@@ -7,9 +7,11 @@ import { type Complete } from "./llm.js";
|
|
|
7
7
|
import { type Ledger, type PaidBooking } from "./paid-calls.js";
|
|
8
8
|
import type { Refusal } from "@parcha/agentrun-kernel";
|
|
9
9
|
import { type ShellPlace } from "@parcha/agentrun-kernel/kernel";
|
|
10
|
+
import { type SearchOn } from "./web-search.js";
|
|
10
11
|
import { type Plane, type Resolution, type Tooling, type ToolSettingsMap } from "./tool-plane.js";
|
|
11
12
|
import type { DenyFrom, SettingFrom } from "./tool-gate.js";
|
|
12
13
|
import type { LiveHandover, LiveViewerStore } from "./browser-live.js";
|
|
14
|
+
import { type RunnerLive } from "./live-reach.js";
|
|
13
15
|
import type { Claim, Store } from "./store/store.js";
|
|
14
16
|
import { type RunSignIn } from "./sign-ins-store.js";
|
|
15
17
|
export declare const ASK_TOOL = "ask_person";
|
|
@@ -23,7 +25,7 @@ export declare const FAUX_BROWSER_ENV = "AGENTRUN_SERVE_FAUX_BROWSER";
|
|
|
23
25
|
export declare const FAUX_VENDOR_API_ENV = "AGENTRUN_SERVE_FAUX_VENDOR_API";
|
|
24
26
|
/** What the result of `ask_person` says; the person's page shows the question as a waiting row. */
|
|
25
27
|
export declare const asked: (question: string) => string;
|
|
26
|
-
export declare const askPerson: ToolRegistration<TSchema, import("@earendil-works/chord").JsonValue>;
|
|
28
|
+
export declare const askPerson: ToolRegistration<TSchema, import("@earendil-works/chord/json").JsonValue>;
|
|
27
29
|
/** Where a run's tools are bound: the run, by its id, its folder and the folder its tools work in. */
|
|
28
30
|
export type RunWhere = {
|
|
29
31
|
readonly ref: {
|
|
@@ -69,6 +71,9 @@ export type ToolHost = {
|
|
|
69
71
|
put(handover: LiveHandover): Promise<boolean>;
|
|
70
72
|
drop(tag?: string): Promise<void>;
|
|
71
73
|
};
|
|
74
|
+
/** On a runner on another host than its server (live-reach.ts runnerLiveOf): where its browser's viewer listens, the host
|
|
75
|
+
* its hand-over names, and the key the server's proof is checked with. Absent: loopback. */
|
|
76
|
+
liveAt?: RunnerLive;
|
|
72
77
|
/** The one store, for the live-viewer seam above, the run's saved sign-in (its runs and sign-ins, read under `claim`),
|
|
73
78
|
* the sign-in verify the runner saves, and the Screen tab's ended state (settings: browser-wait-ended.ts). */
|
|
74
79
|
store?: LiveViewerStore & Pick<Store, "runs" | "signIns" | "settings">;
|
|
@@ -99,6 +104,9 @@ export type ToolHost = {
|
|
|
99
104
|
* claim's provider, whatever the tool plane picked. Absent: the plane's vendor, opened the same way (browser-computer.ts
|
|
100
105
|
* planeBrowser). */
|
|
101
106
|
browserComputer?: ClaimBrowser;
|
|
107
|
+
/** The run's own models a native web_search goes through (hosted-search.ts), asked as a search runs: on the runner, the
|
|
108
|
+
* session's port (its proxy, policy, key, price and cap), this run's alone. Absent: a native search has no model. */
|
|
109
|
+
search?: SearchOn;
|
|
102
110
|
};
|
|
103
111
|
/** What a name stands for in the run: the pi tools it offers, and the extensions a conversation selects for them. */
|
|
104
112
|
export type ToolBinding = {
|
|
@@ -113,6 +121,7 @@ export type EffectRun = {
|
|
|
113
121
|
work: string;
|
|
114
122
|
complete?: Complete;
|
|
115
123
|
ledger?: Ledger;
|
|
124
|
+
search?: SearchOn;
|
|
116
125
|
};
|
|
117
126
|
export type ToolEntry = {
|
|
118
127
|
/** One line, for capabilities. */
|
|
@@ -282,9 +291,9 @@ export declare const toolsView: (env: NodeJS.ProcessEnv, settings?: ToolSettings
|
|
|
282
291
|
default_provider?: string | undefined;
|
|
283
292
|
resolves?: Record<"opencode" | "codex" | "pi" | "claude-agent", Resolution> | undefined;
|
|
284
293
|
why?: Record<"opencode" | "codex" | "pi" | "claude-agent", string> | undefined;
|
|
285
|
-
permission: "deny" | "
|
|
286
|
-
default_permission: "deny" | "
|
|
287
|
-
permissions: ("deny" | "
|
|
294
|
+
permission: "deny" | "ask" | "allow";
|
|
295
|
+
default_permission: "deny" | "ask" | "allow";
|
|
296
|
+
permissions: ("deny" | "ask" | "allow")[];
|
|
288
297
|
harnesses: ("opencode" | "codex" | "pi" | "claude-agent")[];
|
|
289
298
|
missing?: string[] | undefined;
|
|
290
299
|
reason?: string | undefined;
|
package/dist/tools.js
CHANGED
|
@@ -37,6 +37,7 @@ import { answerIn, answerOnce } from "./runner/hand-back.js";
|
|
|
37
37
|
import { waitingAsk } from "./browser-commands.js";
|
|
38
38
|
import { runnerSecrets } from "./runner/redact.js";
|
|
39
39
|
import { HANDOVER_WAITING } from "./runner/journal-kinds.js";
|
|
40
|
+
import { provenFor } from "./live-reach.js";
|
|
40
41
|
import { clearWaitEnded, markWaitEnded } from "./browser-wait-ended.js";
|
|
41
42
|
import { runSignIn, verifyRunSignIn } from "./sign-ins-store.js";
|
|
42
43
|
export const ASK_TOOL = "ask_person";
|
|
@@ -387,7 +388,14 @@ const browserTool = {
|
|
|
387
388
|
return { outcome: stood.state, at: stood.at, ...(stood.reason !== undefined ? { reason: stood.reason } : {}) };
|
|
388
389
|
},
|
|
389
390
|
});
|
|
390
|
-
|
|
391
|
+
// On a runner on another host than its server, the viewer listens on the runner's live address and takes no page or
|
|
392
|
+
// socket without the server's proof for its own path id (live-reach.ts).
|
|
393
|
+
const at = host.liveAt;
|
|
394
|
+
const admit = at ? (req) => {
|
|
395
|
+
const id = /^\/v\/([A-Za-z0-9_-]{22})(?:\/ws)?(?:\?|$)/.exec(req.url ?? "")?.[1];
|
|
396
|
+
return id !== undefined && provenFor(req, at, id);
|
|
397
|
+
} : undefined;
|
|
398
|
+
const view = createLiveView({ hostOrigin: "'self'", gates, takeOver: { take: (tag) => hands.take(tag) }, ...(at ? { listen: { bind: at.bind, host: at.host }, admit: admit } : {}) });
|
|
391
399
|
const watched = handedProvider ? liveViewProvider(handedProvider, view) : undefined;
|
|
392
400
|
const provider = () => {
|
|
393
401
|
if (refused)
|
|
@@ -396,7 +404,7 @@ const browserTool = {
|
|
|
396
404
|
};
|
|
397
405
|
// Each session's viewer reaches the server as it launches, and goes as it ends: through the store, under the run's claim
|
|
398
406
|
// (host.liveViewers); never a file in the run's folder, which is the agent's workspace.
|
|
399
|
-
const viewers = live.sessionHandovers(host.liveViewers);
|
|
407
|
+
const viewers = live.sessionHandovers(host.liveViewers, at?.host);
|
|
400
408
|
const onSession = (row, change) => viewers.changed(row, change);
|
|
401
409
|
// Its session time is the run's spend, at its provider's price, and held under the run's cap (browser-cost.ts).
|
|
402
410
|
const providerName = parts.provider?.name ?? vendor;
|
|
@@ -570,8 +578,9 @@ export const TOOLS = Object.freeze({
|
|
|
570
578
|
summary: "Search the web: codex's own search (claude-agent's where it is picked), on pi the model provider's hosted search (Anthropic, OpenAI), with none of those Parallel's Search API where the server holds its key, else Exa's keyless search; or the provider picked: { query, n? } -> { provider, query, results: [{ url, title, snippet, published? }], text? }, provider naming the one that served it, 1 to 25 results, each snippet at most 3,000 characters; { error } when the search gives no answer.",
|
|
571
579
|
needs: [],
|
|
572
580
|
nodes: true,
|
|
573
|
-
|
|
574
|
-
|
|
581
|
+
// On the runner its hosted search goes through the run's own route (host.search, run.search), labelled web_search.
|
|
582
|
+
bind: async (host) => installTool(host, "web-search", booking(webSearchTool(host.env, host.search))),
|
|
583
|
+
effect: async (args, run) => bookedIn(run.ledger, () => searchFor(run.env, args, run.signal, run.search)),
|
|
575
584
|
},
|
|
576
585
|
browser: browserTool,
|
|
577
586
|
// monid's catalog on one key (monid.ts): every harness calls each by its wire name, `monid_discover` and the rest.
|
|
@@ -28,6 +28,10 @@ export type TriggerAdapter = {
|
|
|
28
28
|
/** What it keeps sealed (sealed-settings-store.ts), for the server or for each trigger: a field it mints (a signing secret)
|
|
29
29
|
* is made at a trigger's create and at a rotation, shown once, and goes with the trigger. */
|
|
30
30
|
settings?: SettingsSpec;
|
|
31
|
+
/** Whether a trigger of this source keeps a secret its sender gave (a create's and a rotation's `secret`, Composio's)
|
|
32
|
+
* instead of one this server mints: then the secret is required there, sealed as a minted one is, and never made
|
|
33
|
+
* here. Default: it mints. */
|
|
34
|
+
givesSecret?(source: Source): boolean;
|
|
31
35
|
/** Its shapes as a create's error names them: `{kind: "..."}` with its fields. */
|
|
32
36
|
describe: string;
|
|
33
37
|
/** When it fires, for the OpenAPI document's source description. */
|
|
@@ -14,9 +14,9 @@ export declare const triggerSecretMeta: (id: string, set: boolean, changedAt?: s
|
|
|
14
14
|
* trigger's view. */
|
|
15
15
|
export declare function triggerMade(made: Record<string, unknown>, minted: string | undefined, mayHold: boolean, at: string): Record<string, unknown>;
|
|
16
16
|
/** POST /triggers/{id}/secret's answer (the owner's session alone reaches it): the new value, and its metadata. */
|
|
17
|
-
export declare const triggerRotated: (id: string, minted: string, at: string) => {
|
|
17
|
+
export declare const triggerRotated: (id: string, minted: string | undefined, at: string) => {
|
|
18
|
+
signing_secret?: string | undefined;
|
|
18
19
|
secret: SecretMeta;
|
|
19
|
-
signing_secret: string;
|
|
20
20
|
};
|
|
21
21
|
/** A template's apply answer's warning for its webhook trigger `i`: its secret is in no apply answer (the Idempotency-Key
|
|
22
22
|
* record would keep it), so the person gets it from the console. */
|
|
@@ -30,7 +30,7 @@ export function triggerMade(made, minted, mayHold, at) {
|
|
|
30
30
|
return mayHold ? { ...made, secret, signing_secret: minted } : { ...made, secret, secret_set: true, note: TRIGGER_SECRET_WORDS };
|
|
31
31
|
}
|
|
32
32
|
/** POST /triggers/{id}/secret's answer (the owner's session alone reaches it): the new value, and its metadata. */
|
|
33
|
-
export const triggerRotated = (id, minted, at) => ({ secret: triggerSecretMeta(id, true, at), signing_secret: minted });
|
|
33
|
+
export const triggerRotated = (id, minted, at) => ({ secret: triggerSecretMeta(id, true, at), ...(minted !== undefined ? { signing_secret: minted } : {}) });
|
|
34
34
|
/** A template's apply answer's warning for its webhook trigger `i`: its secret is in no apply answer (the Idempotency-Key
|
|
35
35
|
* record would keep it), so the person gets it from the console. */
|
|
36
36
|
export const templateTriggerSecret = (i) => ({ field: `triggers.${i}.secret`, reason: "not_allowed", message: `This webhook trigger's signing secret is not in an apply answer. ${TRIGGER_SECRET_WORDS}` });
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { headersRefusal
|
|
1
|
+
import { headersRefusal } from "./standard-webhooks.js";
|
|
2
2
|
type Headers = Record<string, string | string[] | undefined>;
|
|
3
3
|
export type Scheme = {
|
|
4
|
-
/** The header its signature comes in: a request that carries it, and no other
|
|
4
|
+
/** The header its signature comes in: a request that carries it, and no other header's, is checked by a scheme that
|
|
5
|
+
* names it; where several do (`composio` shares `webhook-signature` with `standard`) the trigger's own `signature` picks. */
|
|
5
6
|
signatureHeader: string;
|
|
7
|
+
/** Its secret is the sender's own, given at the trigger's create and rotation, never one this server mints. */
|
|
8
|
+
givenSecret?: true;
|
|
6
9
|
/** How a sender signs under it, for the OpenAPI document. */
|
|
7
10
|
describe: string;
|
|
8
11
|
/** Why the headers alone are refused, before a byte of the body is read. */
|
|
@@ -26,7 +29,7 @@ export declare const SIGNATURE_SCHEMES: {
|
|
|
26
29
|
signatureHeader: string;
|
|
27
30
|
describe: string;
|
|
28
31
|
precheck: typeof headersRefusal;
|
|
29
|
-
verify:
|
|
32
|
+
verify: (secret: string, headers: Record<string, string | string[] | undefined>, body: Buffer, nowMs: number) => string | undefined;
|
|
30
33
|
firingKeyOf: (headers: Headers) => string;
|
|
31
34
|
eventOf: (_headers: Headers, json: unknown) => string | undefined;
|
|
32
35
|
};
|
|
@@ -44,13 +47,29 @@ export declare const SIGNATURE_SCHEMES: {
|
|
|
44
47
|
number?: string | undefined;
|
|
45
48
|
};
|
|
46
49
|
};
|
|
50
|
+
composio: {
|
|
51
|
+
signatureHeader: string;
|
|
52
|
+
givenSecret: true;
|
|
53
|
+
describe: string;
|
|
54
|
+
precheck: typeof headersRefusal;
|
|
55
|
+
verify: (key: string, headers: Headers, body: Buffer<ArrayBufferLike>, nowMs: number) => string | undefined;
|
|
56
|
+
firingKeyOf: (headers: Headers) => string;
|
|
57
|
+
eventOf(_headers: Headers, json: unknown): string | undefined;
|
|
58
|
+
attrsOf(json: unknown): {
|
|
59
|
+
user_id?: string | undefined;
|
|
60
|
+
trigger_id?: string | undefined;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
47
63
|
};
|
|
48
64
|
export type SchemeName = keyof typeof SIGNATURE_SCHEMES;
|
|
49
65
|
export declare const SCHEME_NAMES: SchemeName[];
|
|
50
66
|
export declare const DEFAULT_SCHEME: SchemeName;
|
|
51
|
-
/** The scheme a request asks for: the one whose signature header it carries.
|
|
52
|
-
*
|
|
53
|
-
|
|
67
|
+
/** The scheme a request asks for: the one whose signature header it carries. Schemes that share a header (`standard` and
|
|
68
|
+
* `composio`) are told apart by the trigger's own (`wanted`, its `signature`): a request is verified under the trigger's
|
|
69
|
+
* scheme, so one signed for the other fails its check as any bad signature does. With no `wanted` (before the trigger is
|
|
70
|
+
* read, where the headers' check is the same for both) the first of them stands in. `refusal` when it carries no
|
|
71
|
+
* signature header, or the headers of more than one. */
|
|
72
|
+
export declare function schemeOf(headers: Headers, wanted?: string): {
|
|
54
73
|
name: SchemeName;
|
|
55
74
|
scheme: Scheme;
|
|
56
75
|
} | {
|
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
// scheme whose signature header it carries; a trigger's `signature` names the scheme it takes. A new scheme is one entry
|
|
6
6
|
// here: the source's schema and its check read the table's keys.
|
|
7
7
|
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
8
|
-
import { HOOK_TOLERANCE_S, headersRefusal, HOOK_ID, MIN_KEY_BYTES, verify as verifyStandard } from "./standard-webhooks.js";
|
|
8
|
+
import { HOOK_TOLERANCE_S, headersRefusal, HOOK_ID, MIN_KEY_BYTES, verify as verifyStandard, verifyWithKey } from "./standard-webhooks.js";
|
|
9
9
|
import { isObject } from "./validate.js";
|
|
10
10
|
/** An event's name in a header: printable ASCII with no space (`pull_request`, `ping`). */
|
|
11
11
|
const EVENT = /^[\x21-\x7e]{1,200}$/;
|
|
12
|
+
/** An id a payload's tag may name: short printable ASCII with no space, quote or bracket. */
|
|
13
|
+
const ID_ATTR = /^[A-Za-z0-9_.:@-]{1,100}$/;
|
|
12
14
|
const GITHUB_SIGNATURE = /^sha256=([0-9a-f]{64})$/i;
|
|
13
15
|
const githubHmac = (secret, body) => createHmac("sha256", Buffer.from(secret, "utf8")).update(body).digest();
|
|
14
16
|
function githubPrecheck(headers) {
|
|
@@ -68,14 +70,46 @@ export const SIGNATURE_SCHEMES = {
|
|
|
68
70
|
};
|
|
69
71
|
},
|
|
70
72
|
},
|
|
73
|
+
// Composio's (docs.composio.dev webhooks, @composio/core's verifyWebhook): the Standard Webhooks headers and message
|
|
74
|
+
// ("{id}.{timestamp}.{body}", `v1,<base64 HMAC-SHA256>`), but keyed by the UTF-8 bytes of the whole secret string
|
|
75
|
+
// Composio minted, not by a base64-decoded `whsec_` key. Every trigger of its project comes to the one webhook URL, so
|
|
76
|
+
// the event is the body's metadata.trigger_slug, and `where` reads the trigger's own data under /data.
|
|
77
|
+
composio: {
|
|
78
|
+
signatureHeader: "webhook-signature",
|
|
79
|
+
givenSecret: true,
|
|
80
|
+
describe: `\`composio\` takes a Composio trigger's delivery (the webhook subscription whose URL is the trigger's hook_url): the Standard Webhooks headers and message, \`v1,<base64 HMAC-SHA256 of "{webhook-id}.{webhook-timestamp}.{body}">\`, keyed by the UTF-8 bytes of the whole secret string Composio gave the subscription (make the trigger first, register its hook_url as Composio's webhook subscription, then \`POST /v2/triggers/{id}/secret\` with \`{secret}\`; until then every request is refused, and this server never makes one), with the same ${HOOK_TOLERANCE_S} s window and firing key (\`webhook-id\`). Its event is the body's \`metadata.trigger_slug\` (\`GITHUB_ISSUE_ADDED_EVENT\`), else its top-level \`type\` (the subscription's account events, \`composio.connected_account.expired\`), and \`where\` pointers read the payload under \`/data\`.`,
|
|
81
|
+
precheck: headersRefusal,
|
|
82
|
+
verify: (key, headers, body, nowMs) => verifyWithKey(Buffer.from(key, "utf8"), headers, body, nowMs),
|
|
83
|
+
firingKeyOf: (headers) => headers["webhook-id"],
|
|
84
|
+
// A trigger message names its slug; the subscription's account events (composio.connected_account.expired) have no
|
|
85
|
+
// metadata, so their event is the body's own type.
|
|
86
|
+
eventOf(_headers, json) {
|
|
87
|
+
if (!isObject(json))
|
|
88
|
+
return undefined;
|
|
89
|
+
if (isObject(json.metadata) && typeof json.metadata.trigger_slug === "string")
|
|
90
|
+
return json.metadata.trigger_slug;
|
|
91
|
+
return typeof json.type === "string" ? json.type : undefined;
|
|
92
|
+
},
|
|
93
|
+
attrsOf(json) {
|
|
94
|
+
const meta = isObject(json) && isObject(json.metadata) ? json.metadata : {};
|
|
95
|
+
const short = (value) => (typeof value === "string" && ID_ATTR.test(value) ? value : undefined);
|
|
96
|
+
const [triggerId, userId] = [short(meta.trigger_id), short(meta.user_id)];
|
|
97
|
+
return { ...(triggerId ? { trigger_id: triggerId } : {}), ...(userId ? { user_id: userId } : {}) };
|
|
98
|
+
},
|
|
99
|
+
},
|
|
71
100
|
};
|
|
72
101
|
export const SCHEME_NAMES = Object.keys(SIGNATURE_SCHEMES);
|
|
73
102
|
export const DEFAULT_SCHEME = "standard";
|
|
74
|
-
/** The scheme a request asks for: the one whose signature header it carries.
|
|
75
|
-
*
|
|
76
|
-
|
|
103
|
+
/** The scheme a request asks for: the one whose signature header it carries. Schemes that share a header (`standard` and
|
|
104
|
+
* `composio`) are told apart by the trigger's own (`wanted`, its `signature`): a request is verified under the trigger's
|
|
105
|
+
* scheme, so one signed for the other fails its check as any bad signature does. With no `wanted` (before the trigger is
|
|
106
|
+
* read, where the headers' check is the same for both) the first of them stands in. `refusal` when it carries no
|
|
107
|
+
* signature header, or the headers of more than one. */
|
|
108
|
+
export function schemeOf(headers, wanted) {
|
|
77
109
|
const carried = SCHEME_NAMES.filter((name) => headers[SIGNATURE_SCHEMES[name].signatureHeader] !== undefined);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
110
|
+
const byHeader = new Set(carried.map((name) => SIGNATURE_SCHEMES[name].signatureHeader));
|
|
111
|
+
if (byHeader.size !== 1)
|
|
112
|
+
return { refusal: byHeader.size ? "ambiguous_signature" : "missing_headers" };
|
|
113
|
+
const name = carried.find((one) => one === wanted) ?? carried[0];
|
|
114
|
+
return { name, scheme: SIGNATURE_SCHEMES[name] };
|
|
81
115
|
}
|
|
@@ -8,6 +8,8 @@ import type { RunTrigger, Target } from "./triggers.js";
|
|
|
8
8
|
/** What the trigger target policy needs that lives elsewhere: the run-start leaves (StartDeps, shared with the create
|
|
9
9
|
* route), the agent reads, and the run view that gives a run's live moment and its v2 status. */
|
|
10
10
|
export interface TriggerTargetDeps {
|
|
11
|
+
/** A test's seam (ServeOptions.beforeSubmit): awaited by a firing's message after its checks, before its row is written. */
|
|
12
|
+
readonly beforeSubmit?: (runId: string, content: string) => Promise<void> | void;
|
|
11
13
|
/** The run-start leaves, shared with the create route (runs-over-store.StartDeps). */
|
|
12
14
|
readonly start: StartDeps;
|
|
13
15
|
/** The agent an id names, with its current revision; undefined when unknown (the agent store's getAgent). */
|
package/dist/trigger-targets.js
CHANGED
|
@@ -96,6 +96,7 @@ export function triggerTargets(store, deps) {
|
|
|
96
96
|
answers: false,
|
|
97
97
|
origin: from,
|
|
98
98
|
requestId: key,
|
|
99
|
+
...(deps.beforeSubmit ? { beforeSubmit: deps.beforeSubmit } : {}),
|
|
99
100
|
queue: async (command) => {
|
|
100
101
|
const done = await store.triggers.message({ triggerId, key }, run.id, command, bound);
|
|
101
102
|
return done && "skipped" in done ? { skipped: done.skipped } : undefined;
|
package/dist/trigger-webhook.js
CHANGED
|
@@ -12,6 +12,8 @@ import { isObject } from "./validate.js";
|
|
|
12
12
|
const ATTR_CHARS = 200;
|
|
13
13
|
/** The scheme a trigger's source takes. */
|
|
14
14
|
const schemeName = (source) => (typeof source.signature === "string" ? source.signature : DEFAULT_SCHEME);
|
|
15
|
+
/** Whether a source's secret is the sender's own (Composio's): given, not minted. */
|
|
16
|
+
const givesSecret = (source) => SIGNATURE_SCHEMES[schemeName(source)]?.givenSecret === true;
|
|
15
17
|
/** The source's own fields, checked: each issue through `bad`. Undefined when one does not read. */
|
|
16
18
|
function fieldsOf(value, bad) {
|
|
17
19
|
let failed = false;
|
|
@@ -38,6 +40,7 @@ export const webhook = {
|
|
|
38
40
|
delivery: "push",
|
|
39
41
|
owner: false,
|
|
40
42
|
settings: { scope: "trigger", fields: { secret: { mint: true, minBytes: MIN_KEY_BYTES } } },
|
|
43
|
+
givesSecret,
|
|
41
44
|
describe: `{kind: "webhook", signature?: ${SCHEME_NAMES.map((name) => `"${name}"`).join(" | ")}, accept?: [{event, actions?, where?}]}`,
|
|
42
45
|
fires: "a signed request to /hooks/{trigger_id} (`webhook`) that its `accept` takes",
|
|
43
46
|
firedBy: "`webhook`: a signed request to /hooks/{trigger_id}, its key from the trigger and what the request's signature covers: its `webhook-id` (`standard`), or the SHA-256 of its body (`github`).",
|
|
@@ -61,7 +64,7 @@ export const webhook = {
|
|
|
61
64
|
return "refusal" in asked ? asked.refusal : asked.scheme.precheck(headers, nowMs);
|
|
62
65
|
},
|
|
63
66
|
verify(key, headers, body, nowMs, source) {
|
|
64
|
-
const asked = schemeOf(headers);
|
|
67
|
+
const asked = schemeOf(headers, source && schemeName(source));
|
|
65
68
|
if ("refusal" in asked)
|
|
66
69
|
return asked.refusal;
|
|
67
70
|
const refusal = asked.scheme.verify(key, headers, body, nowMs);
|
|
@@ -71,7 +74,7 @@ export const webhook = {
|
|
|
71
74
|
// The request is the firing: its scheme's firing key keys it, and its body, whatever it holds, is what the run is
|
|
72
75
|
// given, with its scheme, event, action and unsigned delivery id named on the payload's tag. A trigger with `accept` takes only the events it names.
|
|
73
76
|
parse(headers, body, source) {
|
|
74
|
-
const asked = schemeOf(headers);
|
|
77
|
+
const asked = schemeOf(headers, source && schemeName(source));
|
|
75
78
|
if ("refusal" in asked)
|
|
76
79
|
return [];
|
|
77
80
|
const text = body.toString("utf8");
|
package/dist/triggers.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export type Target = {
|
|
|
43
43
|
run_id: string;
|
|
44
44
|
input: Json;
|
|
45
45
|
};
|
|
46
|
+
/** What the webhook did with a trigger.failed message (webhooks.ts emitTrigger). */
|
|
47
|
+
type Told = "queued" | "unsaved" | "off" | "closed";
|
|
46
48
|
/** What a trigger.failed webhook message says (webhooks.ts). */
|
|
47
49
|
export type TriggerFailed = {
|
|
48
50
|
trigger_id: string;
|
|
@@ -101,6 +103,7 @@ export type TriggerDeps = {
|
|
|
101
103
|
* once, durable before it is answered; a trigger's settings removed with it. Undefined for an adapter that keeps none. */
|
|
102
104
|
settings(adapterId: string): {
|
|
103
105
|
mint(scope: string, field: string): Promise<string>;
|
|
106
|
+
set(scope: string, field: string, value: string, as?: "utf8"): Promise<void>;
|
|
104
107
|
remove(scope: string): Promise<void>;
|
|
105
108
|
} | undefined;
|
|
106
109
|
/** A run's status, or null when there is no such run. */
|
|
@@ -112,7 +115,7 @@ export type TriggerDeps = {
|
|
|
112
115
|
} | null>;
|
|
113
116
|
/** Queues a trigger.failed webhook message under `key`, the firing's (webhooks.ts emitTrigger): `off` when there is no
|
|
114
117
|
* webhook to send it to; `unsaved` or `closed` when it is not in the outbox. */
|
|
115
|
-
notify(failed: TriggerFailed, key: string):
|
|
118
|
+
notify(failed: TriggerFailed, key: string): Told | Promise<Told>;
|
|
116
119
|
say(fields: Record<string, string | number>): void;
|
|
117
120
|
clock?: TriggerClock;
|
|
118
121
|
/** The sources this engine reads: the registry's (trigger-adapters.ts), unless a test gives its own. */
|
|
@@ -273,8 +276,9 @@ export declare class Triggers {
|
|
|
273
276
|
} | null;
|
|
274
277
|
hook_url?: string | undefined;
|
|
275
278
|
}>;
|
|
276
|
-
/** A trigger's new signing secret, shown this once; the old one signs nothing from now on.
|
|
277
|
-
|
|
279
|
+
/** A trigger's new signing secret, shown this once; the old one signs nothing from now on. One whose sender gives its
|
|
280
|
+
* secret (Composio's) takes it as `given` and shows nothing: none is made for it. */
|
|
281
|
+
rotate(id: string, given?: unknown): Promise<Record<string, string>>;
|
|
278
282
|
/** Whether `id` is a trigger of the pushed source `kind` that is on: the one a request delivered for `kind` may fire. */
|
|
279
283
|
hookable(id: string, kind: string): Promise<boolean>;
|
|
280
284
|
/** The source of trigger `id` when it is hookable: what its pushed source's check and parse read (its filter). With no
|
package/dist/triggers.js
CHANGED
|
@@ -151,6 +151,20 @@ function capIssues(adapters, source, target) {
|
|
|
151
151
|
return [{ field: "max_active_runs", reason: "not_allowed", message: "max_active_runs bounds the runs a trigger starts, and a message_run target starts none. Set it to null to clear it." }];
|
|
152
152
|
return [];
|
|
153
153
|
}
|
|
154
|
+
/** What is wrong with the secret a rotation gives for a trigger of `source`: a source whose sender gives its secret
|
|
155
|
+
* (Composio's) needs one, a string (the store checks its length and form); any other takes none, it is minted. A create
|
|
156
|
+
* never takes one: Composio makes the secret once the trigger's URL is registered, so a composio trigger starts with none
|
|
157
|
+
* and refuses every request until it is set. */
|
|
158
|
+
function givenSecretIssues(adapter, source, secret) {
|
|
159
|
+
const gives = adapter?.givesSecret?.(source) === true;
|
|
160
|
+
if (gives && secret === undefined)
|
|
161
|
+
return [{ field: "secret", reason: "missing", message: "This trigger's sender gives its secret (Composio's webhook subscription secret): send it as secret." }];
|
|
162
|
+
if (!gives && secret !== undefined)
|
|
163
|
+
return [{ field: "secret", reason: "not_allowed", message: "This trigger's secret is made by this server: send no secret." }];
|
|
164
|
+
if (gives && typeof secret !== "string")
|
|
165
|
+
return [{ field: "secret", reason: "wrong_type", message: "secret is a string" }];
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
154
168
|
/** A POST /triggers body's own fields, read as create reads them with the sources of `adapters`: its source, target,
|
|
155
169
|
* settings, name and enabled, with every issue. What it names (the agent, the run) is create's own check
|
|
156
170
|
* (TriggerDeps.targetIssues). */
|
|
@@ -271,12 +285,17 @@ export class Triggers {
|
|
|
271
285
|
// What it minted, shown this once, by field: a webhook's `secret`.
|
|
272
286
|
return { ...(await this.view(asTrigger(row))), ...minted };
|
|
273
287
|
}
|
|
274
|
-
/** A trigger's new signing secret, shown this once; the old one signs nothing from now on.
|
|
275
|
-
|
|
288
|
+
/** A trigger's new signing secret, shown this once; the old one signs nothing from now on. One whose sender gives its
|
|
289
|
+
* secret (Composio's) takes it as `given` and shows nothing: none is made for it. */
|
|
290
|
+
async rotate(id, given) {
|
|
276
291
|
const trigger = await this.need(id);
|
|
277
|
-
|
|
292
|
+
const adapter = this.adapter(trigger.source);
|
|
293
|
+
if (!mints(adapter))
|
|
278
294
|
throw invalid([{ field: "source.kind", reason: "not_allowed", message: "Only a webhook trigger has a secret." }]);
|
|
279
|
-
|
|
295
|
+
const issues = givenSecretIssues(adapter, trigger.source, given);
|
|
296
|
+
if (issues.length)
|
|
297
|
+
throw invalid(issues);
|
|
298
|
+
return this.mint(trigger.source, id, given);
|
|
280
299
|
}
|
|
281
300
|
/** Whether `id` is a trigger of the pushed source `kind` that is on: the one a request delivered for `kind` may fire. */
|
|
282
301
|
async hookable(id, kind) {
|
|
@@ -412,6 +431,9 @@ export class Triggers {
|
|
|
412
431
|
const trigger = await this.need(id);
|
|
413
432
|
if (source && source.kind !== trigger.source.kind)
|
|
414
433
|
throw invalid([{ field: "source.kind", reason: "not_allowed", message: "A trigger's source kind is fixed: make a new trigger for another." }]);
|
|
434
|
+
// Whose secret it keeps (the sender's, or one this server made) is fixed with its scheme: make a new trigger for the other.
|
|
435
|
+
if (source && (this.adapter(source).givesSecret?.(source) === true) !== (this.adapter(trigger.source).givesSecret?.(trigger.source) === true))
|
|
436
|
+
throw invalid([{ field: "source.signature", reason: "not_allowed", message: "A trigger's signature cannot move between a secret its sender gives (composio) and one this server makes: make a new trigger for the other." }]);
|
|
415
437
|
const now = this.clock.now();
|
|
416
438
|
const enabled = typeof body.enabled === "boolean" ? body.enabled : trigger.enabled;
|
|
417
439
|
const adapter = this.adapter(trigger.source);
|
|
@@ -863,13 +885,21 @@ export class Triggers {
|
|
|
863
885
|
}
|
|
864
886
|
/** Each field `source`'s adapter mints for its triggers, made now for trigger `id`, by field: none for one that keeps
|
|
865
887
|
* no trigger-scoped secret. */
|
|
866
|
-
async mint(source, id) {
|
|
888
|
+
async mint(source, id, given) {
|
|
867
889
|
const adapter = this.adapter(source);
|
|
868
890
|
if (!mints(adapter))
|
|
869
891
|
return {};
|
|
870
892
|
const store = this.deps.settings(adapter.id);
|
|
871
893
|
if (!store)
|
|
872
894
|
throw new Error(`no sealed settings for ${adapter.id}`);
|
|
895
|
+
// The sender's own secret, sealed as a minted one is, and never answered; none yet, none made.
|
|
896
|
+
if (adapter.givesSecret?.(source)) {
|
|
897
|
+
if (given === undefined)
|
|
898
|
+
return {};
|
|
899
|
+
const field = Object.entries(adapter.settings.fields).find(([, f]) => f.mint)[0];
|
|
900
|
+
await store.set(id, field, given, "utf8");
|
|
901
|
+
return {};
|
|
902
|
+
}
|
|
873
903
|
return Object.fromEntries(await Promise.all(Object.entries(adapter.settings.fields).filter(([, f]) => f.mint).map(async ([field]) => [field, await store.mint(id, field)])));
|
|
874
904
|
}
|
|
875
905
|
/** A scope belongs to one trigger: `source`'s (its adapter's scopeOf), for a trigger `id` that is to be on, is refused
|
package/dist/turns.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// codex as it is sent (or dropped by a stop), and TURN_END, in the commit of the turn's last entries.
|
|
7
7
|
// A message is open from the moment the run took it until its turn's end closes it, so a follow-up queued behind a turn
|
|
8
8
|
// keeps the run open whatever the door says meanwhile.
|
|
9
|
+
import { KINDS } from "./runner/journal-kinds.js";
|
|
9
10
|
import { ADAPTER_API, MESSAGE, MESSAGE_END, TURN_END } from "./turn-end.js";
|
|
10
11
|
/** The request id prefix of a run's end-of-run turn (learning-run.ts): the server's message, never the person's. */
|
|
11
12
|
export const REFLECT_REQUEST = "learn-reflect-";
|
|
@@ -41,8 +42,10 @@ export class Turns {
|
|
|
41
42
|
const fresh = id === undefined || id > this.#seen;
|
|
42
43
|
if (id !== undefined && fresh) {
|
|
43
44
|
this.#seen = id;
|
|
45
|
+
// A CLI record's entry says when it was written (`at`): that is the progress, since a CLI run's live tick moves only
|
|
46
|
+
// with the tool it holds, never with each entry. Any other entry's is the read's `now`.
|
|
44
47
|
if (this.open > 0)
|
|
45
|
-
this.#progress = now;
|
|
48
|
+
this.#progress = isObject(value.data) && typeof value.data.at === "number" ? value.data.at : now;
|
|
46
49
|
}
|
|
47
50
|
const data = isObject(value.data) ? value.data : undefined;
|
|
48
51
|
const first = Array.isArray(value.model) && isObject(value.model[0]) ? value.model[0] : undefined;
|
|
@@ -61,6 +64,18 @@ export class Turns {
|
|
|
61
64
|
if (fresh)
|
|
62
65
|
this.#sinceError = first.errorMessage;
|
|
63
66
|
}
|
|
67
|
+
else if (value.kind === KINDS.turnStart && id !== undefined) {
|
|
68
|
+
// A CLI run's turn, open from the commit of the message that starts it until its turn end (adapter-loop.ts CliRecord).
|
|
69
|
+
this.#take(`c:${id}`, typeof data?.at === "number" ? data.at : now, id);
|
|
70
|
+
}
|
|
71
|
+
else if (value.kind === KINDS.turnEnd && data) {
|
|
72
|
+
// Turns are taken one at a time, so the end closes the oldest turn still open.
|
|
73
|
+
const message = [...this.#messages.values()].find((one) => one.key.startsWith("c:") && !one.end);
|
|
74
|
+
if (!message)
|
|
75
|
+
continue;
|
|
76
|
+
const status = data.status === "completed" ? "answered" : data.status === "interrupted" ? "interrupted" : "failed";
|
|
77
|
+
message.end = { status, answer: null, ...(typeof data.error === "string" ? { error: data.error } : {}) };
|
|
78
|
+
}
|
|
64
79
|
else if (value.kind === MESSAGE && typeof data?.id === "string") {
|
|
65
80
|
this.#take(`m:${data.id}`, now, id ?? this.#seen);
|
|
66
81
|
}
|
package/dist/validate.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { invalid } from "./errors.js";
|
|
3
3
|
import { HARNESSES } from "./harness.js";
|
|
4
4
|
import { THINKING_LEVELS } from "./model.js";
|
|
5
|
+
import { likelyModel, modelShape } from "./model-form.js";
|
|
5
6
|
import { placeIssues } from "./place.js";
|
|
6
7
|
import { computerIssues, settingConflict } from "./computer-setting.js";
|
|
7
8
|
import { settingsIssues } from "./tool-plane.js";
|
|
@@ -34,6 +35,15 @@ export const MAX_OUTPUT_SCHEMA_BYTES = 64 * 1024;
|
|
|
34
35
|
export const MODEL_TIER_NAMES = ["fast", "strong"];
|
|
35
36
|
/** `provider/model-id`. */
|
|
36
37
|
export const MODEL_REF = /^[^/\s]+\/\S+$/;
|
|
38
|
+
/** What a model that is no `provider/model-id` is told: the form `harness` takes, with examples, and the likely id when
|
|
39
|
+
* one is obvious. Structural, so it knows no keys here: the likely id is named in both forms (the vendor's own, and
|
|
40
|
+
* OpenRouter's), never one that a server with only the other key could not run. */
|
|
41
|
+
function modelFormIssue(harness, given) {
|
|
42
|
+
const own = typeof given === "string" ? likelyModel({}, harness, given) : undefined;
|
|
43
|
+
const routed = typeof given === "string" ? likelyModel({ OPENROUTER_API_KEY: "-" }, harness, given) : undefined;
|
|
44
|
+
const likely = own && routed && own !== routed ? `${own}, or ${routed} through OpenRouter` : own;
|
|
45
|
+
return `${modelShape({}, harness)}: ${typeof given === "string" ? `"${given}"` : "that"} is not one.${likely ? ` Did you mean ${likely}?` : ""}`;
|
|
46
|
+
}
|
|
37
47
|
const SKILL_FILE = "/SKILL.md";
|
|
38
48
|
const issue = (field, reason, message, fix) => ({ field, reason, message, ...(fix ? { fix } : {}) });
|
|
39
49
|
/** A body's fields that `allowed` does not name, each as the 422's not_allowed issue. */
|
|
@@ -83,7 +93,7 @@ export function definitionIssues(definition, { at = "definition", creating = tru
|
|
|
83
93
|
if (d.workflow !== undefined)
|
|
84
94
|
out.push(issue(`${at}.model`, "not_allowed", "A workflow revision keeps no model: its model nodes run on this host's default.", `Remove ${at}.model.`));
|
|
85
95
|
else if (typeof d.model !== "string" || !MODEL_REF.test(d.model))
|
|
86
|
-
out.push(issue(`${at}.model`, "bad_format",
|
|
96
|
+
out.push(issue(`${at}.model`, "bad_format", modelFormIssue(typeof d.harness === "string" ? d.harness : "pi", d.model)));
|
|
87
97
|
}
|
|
88
98
|
if (d.model_tiers !== undefined) {
|
|
89
99
|
if (d.workflow !== undefined)
|
package/dist/web-fetch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JsonValue } from "@earendil-works/chord";
|
|
1
|
+
import type { JsonValue } from "@earendil-works/chord/json";
|
|
2
2
|
import type { TSchema } from "typebox";
|
|
3
3
|
import { type ToolRegistration } from "@earendil-works/pi-durable";
|
|
4
4
|
import type { PublicFetchOptions } from "@parcha/pi-browser";
|
package/dist/web-search.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TSchema } from "typebox";
|
|
2
|
-
import type { JsonValue } from "@earendil-works/chord";
|
|
2
|
+
import type { JsonValue } from "@earendil-works/chord/json";
|
|
3
3
|
import { type ToolRegistration } from "@earendil-works/pi-durable";
|
|
4
|
+
import { type SearchModels } from "./hosted-search.js";
|
|
4
5
|
import { type Extract } from "./web-fetch.js";
|
|
5
6
|
export declare const WEB_SEARCH_TOOL = "web_search";
|
|
6
7
|
/** The tools that reach the web, each through the provider its run's plane resolves it to. */
|
|
@@ -47,8 +48,12 @@ export declare const searchArgs: (args: Record<string, unknown>) => {
|
|
|
47
48
|
};
|
|
48
49
|
/** `{query, n?}` searched through `parallel` (null: the run holds no key), as a Search. */
|
|
49
50
|
export declare function webSearch(args: Record<string, unknown>, parallel: Extract | null, signal?: AbortSignal): Promise<Search>;
|
|
50
|
-
/**
|
|
51
|
-
|
|
51
|
+
/** The run's models a native search goes through, asked when a search runs (the runner's: the session's port, up once
|
|
52
|
+
* the session is open): ToolHost.search, EffectRun.search. */
|
|
53
|
+
export type SearchOn = () => Promise<SearchModels | undefined>;
|
|
54
|
+
/** `{query, n?}` searched by the provider the run's plane resolves web_search to, as a Search. `models`: the run's own
|
|
55
|
+
* models a native search goes through (none: a native search has no model to search on). */
|
|
56
|
+
export declare function searchFor(env: NodeJS.ProcessEnv, args: Record<string, unknown>, signal?: AbortSignal, models?: SearchOn): Promise<Search>;
|
|
52
57
|
/** The agent's tool: the Search as JSON text. A run whose web_search resolves to Parallel reads its key as the tool is
|
|
53
|
-
* made, when the run opens. */
|
|
54
|
-
export declare function webSearchTool(env: NodeJS.ProcessEnv): ToolRegistration<TSchema, JsonValue>;
|
|
58
|
+
* made, when the run opens; one that resolves native searches through `models`, the run's own (ToolHost.search). */
|
|
59
|
+
export declare function webSearchTool(env: NodeJS.ProcessEnv, models?: SearchOn): ToolRegistration<TSchema, JsonValue>;
|