@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/web-search.js
CHANGED
|
@@ -88,8 +88,9 @@ export async function webSearch(args, parallel, signal) {
|
|
|
88
88
|
return { error: error?.name === "TimeoutError" ? "Parallel's search did not answer within 60 s" : `Parallel's search failed: ${error?.message ?? String(error)}` };
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
/** `{query, n?}` searched by the provider the run's plane resolves web_search to, as a Search.
|
|
92
|
-
|
|
91
|
+
/** `{query, n?}` searched by the provider the run's plane resolves web_search to, as a Search. `models`: the run's own
|
|
92
|
+
* models a native search goes through (none: a native search has no model to search on). */
|
|
93
|
+
export async function searchFor(env, args, signal, models) {
|
|
93
94
|
const plane = planeOf(env);
|
|
94
95
|
if (plane.web_search === "parallel")
|
|
95
96
|
return webSearch(args, parallelOf(env), signal);
|
|
@@ -99,7 +100,7 @@ export async function searchFor(env, args, signal) {
|
|
|
99
100
|
if (!query)
|
|
100
101
|
return { error: "web_search needs a query" };
|
|
101
102
|
if (plane.web_search === "native")
|
|
102
|
-
return hostedSearch(query, n, plane.model, signal);
|
|
103
|
+
return hostedSearch(query, n, plane.model, signal, await models?.());
|
|
103
104
|
// Under --faux, Exa is the faux module's or none: a test never reaches the network.
|
|
104
105
|
const faux = await fauxFetch(env, FAUX_EXA_ENV);
|
|
105
106
|
if (env[FAUX_ENV] && !faux)
|
|
@@ -109,8 +110,8 @@ export async function searchFor(env, args, signal) {
|
|
|
109
110
|
return "limit" in found ? { error: found.error } : found;
|
|
110
111
|
}
|
|
111
112
|
/** The agent's tool: the Search as JSON text. A run whose web_search resolves to Parallel reads its key as the tool is
|
|
112
|
-
* made, when the run opens. */
|
|
113
|
-
export function webSearchTool(env) {
|
|
113
|
+
* made, when the run opens; one that resolves native searches through `models`, the run's own (ToolHost.search). */
|
|
114
|
+
export function webSearchTool(env, models) {
|
|
114
115
|
const provider = planeOf(env).web_search;
|
|
115
116
|
const parallel = provider === "parallel";
|
|
116
117
|
if (parallel)
|
|
@@ -129,7 +130,7 @@ export function webSearchTool(env) {
|
|
|
129
130
|
},
|
|
130
131
|
replay: "safe",
|
|
131
132
|
execute: async (args, _api, context) => {
|
|
132
|
-
const answer = fitSearch(await searchFor(env, args, context?.abortSignal));
|
|
133
|
+
const answer = fitSearch(await searchFor(env, args, context?.abortSignal, models));
|
|
133
134
|
return forModel(searchText(answer), { details: answer });
|
|
134
135
|
},
|
|
135
136
|
});
|
package/dist/webhooks.d.ts
CHANGED
|
@@ -1,32 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { Settings } from "./store/index.js";
|
|
1
|
+
import type { Store } from "./store/index.js";
|
|
3
2
|
import type { TriggerFailed } from "./triggers.js";
|
|
4
|
-
/** A run's two notices, which
|
|
3
|
+
/** A run's two notices, which the server's run-change follower tells. */
|
|
5
4
|
export declare const RUN_EVENTS: readonly ["run.needs_input", "run.ended"];
|
|
6
5
|
/** Every message type a webhook is sent: a run's notices, and a trigger's failed firing (triggers.ts). */
|
|
7
6
|
export declare const WEBHOOK_EVENTS: readonly ["run.needs_input", "run.ended", "trigger.failed"];
|
|
8
7
|
/** The message types: a run's two notices, and the test send's. */
|
|
9
8
|
export declare const MESSAGE_TYPES: readonly ["run.needs_input", "run.ended", "trigger.failed", "webhook.test"];
|
|
10
9
|
type MessageType = (typeof MESSAGE_TYPES)[number];
|
|
11
|
-
/** The
|
|
12
|
-
export declare const
|
|
13
|
-
/** The
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export declare const
|
|
18
|
-
readonly id: string;
|
|
19
|
-
readonly settings: SettingsSpec;
|
|
20
|
-
};
|
|
10
|
+
/** The file an earlier version kept the webhook in, beside its store: never read, only said at a start when it is left. */
|
|
11
|
+
export declare const WEBHOOK_FILE = "webhook.json";
|
|
12
|
+
/** The webhook's channel in the store (channel_posts, channel_attempts, channel_told) and its secret's adapter in
|
|
13
|
+
* trigger_settings. */
|
|
14
|
+
export declare const WEBHOOK_CHANNEL = "webhook-out";
|
|
15
|
+
/** The store setting that holds the webhook's URL, when its secret was made, and why it is off. */
|
|
16
|
+
export declare const WEBHOOK_SETTING = "webhook-out";
|
|
21
17
|
/** The waits before each try again, after the first at once: the Standard Webhooks schedule, cut at about a day. */
|
|
22
18
|
export declare const RETRY_MS: readonly number[];
|
|
23
19
|
/** How many attempts the log keeps, and with them the messages they tried, for a redelivery. */
|
|
24
20
|
export declare const ATTEMPTS_KEPT = 50;
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
/** Where its secret is kept in trigger_settings (adapter WEBHOOK_CHANNEL): the server's one scope, one minted field. */
|
|
22
|
+
export declare const WEBHOOK_SECRET_SPEC: {
|
|
23
|
+
scope: "server";
|
|
24
|
+
fields: {
|
|
25
|
+
secret: {
|
|
26
|
+
mint: true;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/** The webhook's URL as the server shows it (GET, its log): its origin and the last four characters of its path, never
|
|
31
|
+
* the whole URL, which can be a credential itself (a chat service's incoming-hook URL). */
|
|
32
|
+
export declare function shownUrl(url: string): string;
|
|
33
|
+
/** What the webhook takes beside its store: `retryMs`, the waits between tries; `privateTargets`, whether it may send to a
|
|
34
|
+
* private network or this machine (the operator's AGENTRUN_WEBHOOK_PRIVATE_TARGETS, never the API's); `lookup`, every
|
|
35
|
+
* address a name resolves to (the system resolver by default); `storeRetryMs`, the wait before a try the store failed is
|
|
36
|
+
* tried again (STORE_RETRY_MS by default). */
|
|
37
|
+
export type WebhooksOptions = {
|
|
38
|
+
retryMs?: readonly number[];
|
|
39
|
+
privateTargets?: boolean;
|
|
40
|
+
lookup?: (host: string) => Promise<string[]>;
|
|
41
|
+
storeRetryMs?: number;
|
|
42
|
+
};
|
|
43
|
+
/** What `emit` did with a notice: `queued`, in the store (or already there, or counted as sent); `unsaved`, the store
|
|
44
|
+
* refused the write, so the caller tells it again; `off`, no webhook set, or one a 410 turned off, so nothing is to be
|
|
45
|
+
* sent; `closed`, the server is stopping. */
|
|
29
46
|
export type Emitted = "queued" | "unsaved" | "off" | "closed";
|
|
47
|
+
/** What a notice says of its run: never its tools' arguments, its output or its input, which a receiver reads through the API. */
|
|
30
48
|
export type RunNotice = {
|
|
31
49
|
run_id: string;
|
|
32
50
|
agent_id: string;
|
|
@@ -48,13 +66,6 @@ export type Attempt = {
|
|
|
48
66
|
};
|
|
49
67
|
/** Whether the secret signs here: sealed, or not, for a seal key it does not open under (or damaged). */
|
|
50
68
|
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>;
|
|
55
|
-
};
|
|
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
69
|
export { signatureOf } from "./standard-webhooks.js";
|
|
59
70
|
/** 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
71
|
* so every read of the same ask makes the same webhook-id. A question's is its waiting row (run-view.ts withAsks: the
|
|
@@ -73,19 +84,16 @@ export declare function waitMarkerOf(rows: readonly {
|
|
|
73
84
|
asked_at?: unknown;
|
|
74
85
|
cap_usd?: unknown;
|
|
75
86
|
} | null | undefined, waiting: boolean, learningLabel: string): string | undefined;
|
|
87
|
+
/** The store slice the webhook reads and writes. */
|
|
88
|
+
export type WebhooksStore = Pick<Store, "settings" | "triggerSettings" | "channels" | "flush">;
|
|
76
89
|
export declare class Webhooks {
|
|
77
90
|
private readonly store;
|
|
78
|
-
private readonly secret;
|
|
79
91
|
private readonly say;
|
|
80
|
-
private readonly
|
|
81
|
-
private
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
private notices;
|
|
85
|
-
/** The webhook as the store holds it: read at load, then kept with every write (this server is the store's one writer).
|
|
86
|
-
* 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
|
|
87
|
-
* the next PUT writes it whole. */
|
|
88
|
-
private current?;
|
|
92
|
+
private readonly secrets;
|
|
93
|
+
private config?;
|
|
94
|
+
/** The ledger, by run, as channel_told holds it (this server is its one writer), and the waits seen while nothing is
|
|
95
|
+
* sent, held here only. */
|
|
96
|
+
private readonly notices;
|
|
89
97
|
/** The runs told of since this server started: their ledger entries are this server's news, which a start's catch-up
|
|
90
98
|
* never drops. */
|
|
91
99
|
private readonly told;
|
|
@@ -93,31 +101,40 @@ export declare class Webhooks {
|
|
|
93
101
|
private readonly timers;
|
|
94
102
|
/** The tries in flight, which close() stops and waits for: nothing is written once it is closed. */
|
|
95
103
|
private readonly trying;
|
|
104
|
+
/** The messages with a try in flight, and how many: a settle keeps each in the store until it lands, so one whose
|
|
105
|
+
* earlier attempts left the log meanwhile can still be redelivered. */
|
|
106
|
+
private readonly sending;
|
|
96
107
|
private readonly stop;
|
|
97
108
|
private closed;
|
|
98
|
-
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
/** The outbox's writes, one after another: each writes the outbox as it stands when its turn comes. */
|
|
102
|
-
private writing;
|
|
103
|
-
/** What reads the webhook and then writes it (a PUT, a DELETE, a try's 410 that turns it off), one after another: each
|
|
104
|
-
* reads it as the last one left it, so a 410 never turns off a webhook a PUT set again meanwhile. */
|
|
109
|
+
/** What reads the webhook and then writes it (a PUT, a DELETE, a try's outcome and its 410), one after another: each
|
|
110
|
+
* reads it as the last one left it, so a 410 never turns off a webhook a PUT set again meanwhile, and two first PUTs
|
|
111
|
+
* never each show a secret the other replaced. */
|
|
105
112
|
private changing;
|
|
106
|
-
/** A DELETE under way: no notice is queued meanwhile, so none slips past its drop of the
|
|
113
|
+
/** A DELETE under way: no notice is queued meanwhile, so none slips past its drop of the queued messages. */
|
|
107
114
|
private removing;
|
|
108
|
-
/** The
|
|
109
|
-
*
|
|
110
|
-
private readonly
|
|
111
|
-
/**
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
/** The tries' writes the store refused, each waiting to be written again (resettle), by its timer: the close writes each
|
|
116
|
+
* at once instead. */
|
|
117
|
+
private readonly rewriting;
|
|
118
|
+
/** Those writes under way, which the close waits for, so each lands before the store closes. */
|
|
119
|
+
private readonly rewrites;
|
|
120
|
+
/** The message writes in flight (posted), each settled or not: a DELETE, and a 410's turn-off, waits for them before its drop. */
|
|
121
|
+
private readonly posting;
|
|
122
|
+
private readonly retryMs;
|
|
123
|
+
private readonly privateTargets;
|
|
124
|
+
private readonly lookup;
|
|
125
|
+
private readonly storeRetryMs;
|
|
126
|
+
/** `key` is the server's seal key; `say` takes a log line's fields. */
|
|
127
|
+
constructor(store: WebhooksStore, key: Buffer, say: (fields: Record<string, string | number>) => void, options?: WebhooksOptions);
|
|
128
|
+
/** Reads the webhook, its secret and its ledger once, and goes on with the messages an earlier server left queued, each
|
|
129
|
+
* at its next try's time; a test send is tried once, so one left queued failed. Awaited once at start. */
|
|
116
130
|
load(): Promise<void>;
|
|
117
131
|
/** Where the page is, for each notice's link to its run. */
|
|
118
132
|
attach(base: string): void;
|
|
119
|
-
/**
|
|
120
|
-
*
|
|
133
|
+
/** The secret, and each one this webhook held before (removed by a DELETE, or replaced: kept retired in the store), for
|
|
134
|
+
* the server's list of its own secrets (server-secrets.ts): a run that echoes an old one is cut all the same. */
|
|
135
|
+
signingSecrets(): string[];
|
|
136
|
+
/** GET: the URL, whether the secret signs here, and why the webhook is off, if it is; its secret's metadata, never the
|
|
137
|
+
* secret. */
|
|
121
138
|
view(): {
|
|
122
139
|
configured: false;
|
|
123
140
|
secret: import("./secret-writes.js").SecretMeta;
|
|
@@ -136,36 +153,43 @@ export declare class Webhooks {
|
|
|
136
153
|
} | null;
|
|
137
154
|
updated_at: string;
|
|
138
155
|
};
|
|
139
|
-
/** PUT: the URL, and the webhook on again. The first makes the secret and answers it, once
|
|
140
|
-
*
|
|
156
|
+
/** PUT: the URL, and the webhook on again. The first makes the secret and answers it, once, and so does one that changes
|
|
157
|
+
* the URL: a new receiver gets a new secret, so no one who may set the URL can have messages signed for another
|
|
158
|
+
* receiver. One that keeps the URL keeps the secret. A URL on a private network or this machine is refused (unless the
|
|
159
|
+
* operator allows it), by name or by any address its name resolves to; each try checks again (tryOnce). */
|
|
141
160
|
save(body: Record<string, unknown>): Promise<{
|
|
142
161
|
created: boolean;
|
|
143
162
|
view: ReturnType<Webhooks["view"]>;
|
|
144
163
|
secret?: string;
|
|
145
164
|
}>;
|
|
146
|
-
/**
|
|
147
|
-
|
|
165
|
+
/** The PUT's change, once every change before it has landed: the webhook as the last one left it, then the new one. */
|
|
166
|
+
private saveNow;
|
|
167
|
+
/** DELETE: the webhook gone, its queued messages with it, and its secret (retired: still cut from what a run says); the
|
|
168
|
+
* log of attempts stays. In that order: shut to new notices, its queued messages dropped, the setting removed, then
|
|
169
|
+
* every secret of the webhook, on every DELETE (none once gone), so a removal of a secret that failed is finished by
|
|
170
|
+
* the next DELETE, and whatever fails, nothing of the removed webhook is left to send, to it or to a later one. */
|
|
148
171
|
remove(): Promise<void>;
|
|
172
|
+
/** `work`, once every change of the webhook asked for before it has settled, failed or not. */
|
|
173
|
+
private change;
|
|
149
174
|
/** GET .../deliveries: the last attempts, newest first. */
|
|
150
|
-
attemptsView(): {
|
|
175
|
+
attemptsView(): Promise<{
|
|
151
176
|
attempts: Attempt[];
|
|
152
|
-
}
|
|
177
|
+
}>;
|
|
153
178
|
/** 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
|
|
154
|
-
* webhook is set and on,
|
|
155
|
-
* again after a restart, has the same id, which is a receiver's idempotency key. An end before the webhook was
|
|
156
|
-
* past the
|
|
179
|
+
* webhook is set and on, with its ledger row in the same transaction. `marker` makes its webhook-id: the same moment,
|
|
180
|
+
* seen again after a restart, has the same id, which is a receiver's idempotency key. An end before the webhook was
|
|
181
|
+
* set, or past the day, counts as sent. */
|
|
157
182
|
emit(type: (typeof RUN_EVENTS)[number], run: RunNotice, marker: string): Promise<Emitted>;
|
|
158
183
|
/** A trigger's failed firing (triggers.ts), queued once: its webhook-id is made from the firing's key, so the same
|
|
159
184
|
* failure told again, by a later server too, is the same message. Its trigger keeps whether it was queued. */
|
|
160
185
|
emitTrigger(failed: TriggerFailed, firingKey: string): Promise<Emitted>;
|
|
161
|
-
/** A start's catch-up, once its runs are read (`rows`, the store's: a row with no state is an ended one). First
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* could be continued: its end is not queued again. */
|
|
186
|
+
/** A start's catch-up, once its runs are read (`rows`, the store's: a row with no state is an ended one). First the
|
|
187
|
+
* ledger as the store now stands: a run the store no longer has goes, and a wait of a run it holds as ended goes (an
|
|
188
|
+
* end the webhook was off for never moved it past). Then each end the store holds that the ledger does not, and that is
|
|
189
|
+
* still due, is queued under the store's end time, so under the same webhook-id. `current` reads the run as the store
|
|
190
|
+
* holds it right before its end is queued, with its notice (null: no such run now): a run continued since the rows
|
|
191
|
+
* were read has moved past that end, which is not queued again. Answers the runs whose end the store refused to queue
|
|
192
|
+
* (`unsaved`): the caller tells each again until it is saved (server.ts endsLeft), since no feed change will. */
|
|
169
193
|
catchUp(rows: Iterable<{
|
|
170
194
|
id: string;
|
|
171
195
|
state?: string;
|
|
@@ -174,52 +198,71 @@ export declare class Webhooks {
|
|
|
174
198
|
state?: string;
|
|
175
199
|
endedAt?: string;
|
|
176
200
|
notice: RunNotice;
|
|
177
|
-
} | null>): Promise<
|
|
201
|
+
} | null>): Promise<string[]>;
|
|
178
202
|
/** POST .../test: a `webhook.test` message tried once now, never again; its attempt. */
|
|
179
203
|
test(): Promise<Attempt>;
|
|
204
|
+
/** A message (and its ledger row, `told`) queued in one transaction, then made durable (the store's flush, as every write
|
|
205
|
+
* the server confirms is) before it is answered or tried: a crash of the machine never loses a message answered
|
|
206
|
+
* `queued`, nor the row that keeps it from being told twice. Tracked while in flight, so a DELETE waits for it. */
|
|
207
|
+
private posted;
|
|
180
208
|
/** POST .../deliveries/{webhook_id}/redeliver: the message sent again once now, under its own webhook-id and body. */
|
|
181
209
|
redeliver(id: string): Promise<Attempt>;
|
|
182
|
-
/** Stops: no try starts, those in flight are cut and waited for, and nothing more is written but
|
|
183
|
-
*
|
|
184
|
-
*
|
|
210
|
+
/** Stops: no try starts, those in flight are cut and waited for, and nothing more is written but the tries' writes the
|
|
211
|
+
* store refused before (resettle), each written now and waited for, so a try's known outcome (a delivered message, a
|
|
212
|
+
* 410's turn-off) lands before the store closes. A message cut here is still queued in the store, for the next server
|
|
213
|
+
* (its receiver may get it twice, under the same webhook-id). */
|
|
185
214
|
close(): Promise<void>;
|
|
186
|
-
private
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
private
|
|
193
|
-
|
|
215
|
+
/** Why `url` may not be sent to (a private address, by name or by what the name resolves to now), or undefined. A name
|
|
216
|
+
* that does not resolve passes here: the try resolves it again, and refuses then. */
|
|
217
|
+
private privateAt;
|
|
218
|
+
/** The address a try dials for `url`, checked: every address its name resolves to now is public (unless the operator
|
|
219
|
+
* allows private ones), and the connection goes to the one checked, so a name that resolves again between the check
|
|
220
|
+
* and the connect cannot reach another. A refusal in words. */
|
|
221
|
+
private dialled;
|
|
222
|
+
private signing;
|
|
223
|
+
/** The secret the webhook's setting names, opened here; undefined when none is set, or it does not open here. */
|
|
194
224
|
private signingSecret;
|
|
195
|
-
|
|
225
|
+
private body;
|
|
226
|
+
/** The setting written, then held here: a write the store refuses throws, and what was held stays held. */
|
|
196
227
|
private write;
|
|
197
|
-
/**
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
* marker that names no time is not judged by one). The catch-up and the ledger's pruning read the same line, so the
|
|
201
|
-
* ledger never forgets an end a start would look for. */
|
|
228
|
+
/** Whether an end's run.ended is still to be queued: at or after the webhook was set and the day began (a marker that
|
|
229
|
+
* names no time is not judged by one). The catch-up and the ledger's pruning read the same line, so the ledger never
|
|
230
|
+
* forgets an end a start would look for. */
|
|
202
231
|
private due;
|
|
203
|
-
/** The ledger
|
|
204
|
-
*
|
|
205
|
-
* is never asked again. */
|
|
232
|
+
/** The ledger's ends no longer due go (a start would not look for them). Waits with no end after them stay while the run
|
|
233
|
+
* stands at them, however long: never pruned by age, so the same question is never asked again. */
|
|
206
234
|
private prune;
|
|
207
|
-
/** The outbox written, after every write asked for before it; whether it landed. One that failed is kept here and
|
|
208
|
-
* written again until a write lands (or the close writes it). Closed, nothing is written: the store may be the next
|
|
209
|
-
* server's already. */
|
|
210
|
-
private writeOutbox;
|
|
211
|
-
/** The outbox written whole, in one durable commit: the last attempts, and the messages pending or tried by one of
|
|
212
|
-
* those (a redelivery sends one again). False when the write failed, which the log says once until one lands. */
|
|
213
|
-
private persist;
|
|
214
|
-
/** A new pending message, and its outbox write (whether it landed). */
|
|
215
|
-
private enqueue;
|
|
216
235
|
private schedule;
|
|
217
236
|
private attempt;
|
|
218
237
|
/** One try: POSTed, signed, to the URL set now; no redirect followed, at most 15 s. Not 2xx: tried again after the
|
|
219
|
-
* next wait (`retry`), else
|
|
220
|
-
* own: it
|
|
238
|
+
* next wait (`retry`), else dropped, and the log says so. A 410 turns the webhook off. A redelivery is a try of its
|
|
239
|
+
* own: it marks a message sent when it lands, and never drops one. */
|
|
221
240
|
private tryOnce;
|
|
222
|
-
/**
|
|
241
|
+
/** A try's outcome written: the message's new state and the try, in one transaction; its next try armed; a 410 that
|
|
242
|
+
* still names the webhook as it stands turns it off.
|
|
243
|
+
*
|
|
244
|
+
* Every write of a message's state after a try is fenced, never worked out from a read of the message: a message's
|
|
245
|
+
* own try writes under its claim (`claimed`, taken by `tryId`), and the store writes it only while the message still
|
|
246
|
+
* holds that claim (Channels.settle), so a write that lands late, after a redelivery sent the message, a newer try
|
|
247
|
+
* claimed it or a DELETE dropped it, changes nothing and arms nothing. A redelivery claims nothing: a landed one writes
|
|
248
|
+
* sent, which no try's write undoes (sent is final), and a failed one writes no state at all, only its try. */
|
|
249
|
+
private settleTry;
|
|
250
|
+
/** What follows a try's write: its next try armed and its failure said, only when its state was written (`written`: a
|
|
251
|
+
* fenced write that found the message taken by something newer arms nothing), and a 410's turn-off of the webhook as it
|
|
252
|
+
* stands, whatever the message's state, since it is the receiver's answer. The 410 is checked again against the webhook
|
|
253
|
+
* as it stands now: one whose write landed late (resettle), after a PUT set another URL or a DELETE removed it, was the
|
|
254
|
+
* old URL's, and turns nothing off. */
|
|
255
|
+
private afterSettle;
|
|
256
|
+
/** A try's write the store refused (`write`), written again after the store's wait until it lands, then what follows it
|
|
257
|
+
* (`after`, told whether the state was written), among the webhook's changes. Its own timer, beside the message's: the
|
|
258
|
+
* message keeps its schedule meanwhile. The write is the same one, under the same fence (settleTry): it reads nothing
|
|
259
|
+
* first, and a message's own try writes only while the message still holds its claim, so one a DELETE dropped, a
|
|
260
|
+
* redelivery sent or a newer try claimed meanwhile is left as that left it. One under way when the server closes is
|
|
261
|
+
* waited for, and one waiting is written at the close (close); one refused again then is left as the store holds it,
|
|
262
|
+
* for the next server. */
|
|
263
|
+
private resettle;
|
|
264
|
+
/** Every queued message dropped, with `why` in the log. `strict`: a drop the store refuses throws (a DELETE then fails
|
|
265
|
+
* before anything else of it is done); else it is let be, and a queued message's try finds the webhook off. */
|
|
223
266
|
private drop;
|
|
224
267
|
/** The webhook, set and on: a test or a redelivery sends nothing to one a 410 turned off, as no try does. */
|
|
225
268
|
private need;
|