@parcha/agentrun-serve 0.0.0-stage → 0.1.0-beta.30
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 +748 -0
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +2190 -2
- package/dist/adapters.d.ts +234 -0
- package/dist/adapters.js +585 -0
- package/dist/agents.d.ts +130 -0
- package/dist/agents.js +308 -0
- package/dist/app.d.ts +7 -0
- package/dist/app.js +384 -0
- package/dist/background.d.ts +28 -0
- package/dist/background.js +376 -0
- package/dist/bound-files.d.ts +4 -0
- package/dist/bound-files.js +164 -0
- package/dist/box/record.d.ts +6 -0
- package/dist/box/record.js +41 -0
- package/dist/box/sweep.d.ts +53 -0
- package/dist/box/sweep.js +193 -0
- package/dist/box-egress.d.ts +98 -0
- package/dist/box-egress.js +259 -0
- package/dist/box-image.d.ts +98 -0
- package/dist/box-image.js +285 -0
- package/dist/box-relay-vm.d.ts +80 -0
- package/dist/box-relay-vm.js +389 -0
- package/dist/box-relay.d.ts +45 -0
- package/dist/box-relay.js +227 -0
- package/dist/boxes.d.ts +72 -0
- package/dist/boxes.js +189 -0
- package/dist/browser-cost.d.ts +41 -0
- package/dist/browser-cost.js +158 -0
- package/dist/cap.d.ts +332 -0
- package/dist/cap.js +992 -0
- package/dist/catalog.d.ts +20 -0
- package/dist/catalog.js +53 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +167 -0
- package/dist/coding-tools.d.ts +35 -0
- package/dist/coding-tools.js +87 -0
- package/dist/console/THIRD-PARTY-NOTICES.txt +1721 -0
- package/dist/console/assets/index-34jfpIbQ.js +481 -0
- package/dist/console/assets/index-DUHbWcIP.css +1 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-400-normal-CIEtRijs.woff +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-600-normal-BB5xRk30.woff +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-600-normal-EVf6-Yzo.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-400-normal-BHyURHCj.woff +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-400-normal-C_uLvvQ5.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-600-normal-Dj6eZy5f.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-600-normal-DpeVePZf.woff +0 -0
- package/dist/console/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-greek-400-normal-CNojz0t3.woff +0 -0
- package/dist/console/assets/jetbrains-mono-greek-600-normal-3KAm9r92.woff +0 -0
- package/dist/console/assets/jetbrains-mono-greek-600-normal-H7WoG9Et.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-400-normal-B11XCQ5g.woff +0 -0
- package/dist/console/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-600-normal-DXv3JcnD.woff +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-400-normal-DHMOLxAi.woff +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-600-normal-BfB_LPfz.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-600-normal-DiQlUoE6.woff +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-400-normal-BeU3T8wf.woff +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-400-normal-ByoDsISC.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-600-normal-CSpzN4cI.woff +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-600-normal-Dtizs43-.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-400-normal-Cph9ettZ.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-400-normal-DfGZKnlb.woff +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-600-normal-BGBUNdzT.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-600-normal-COje25QW.woff +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-400-normal-4l4lq8zr.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-400-normal-BGzXWJeR.woff +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-600-normal-8_E36CQj.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-600-normal-C27an7Zc.woff +0 -0
- package/dist/console/index.html +15 -0
- package/dist/content-filter.d.ts +7 -0
- package/dist/content-filter.js +23 -0
- package/dist/daytona-api.d.ts +21 -0
- package/dist/daytona-api.js +101 -0
- package/dist/decision-rows.d.ts +19 -0
- package/dist/decision-rows.js +123 -0
- package/dist/decisions.d.ts +94 -0
- package/dist/decisions.js +184 -0
- package/dist/effort-guidance.d.ts +5 -0
- package/dist/effort-guidance.js +14 -0
- package/dist/environment.d.ts +5 -0
- package/dist/environment.js +11 -0
- package/dist/errors.d.ts +74 -0
- package/dist/errors.js +69 -0
- package/dist/exa-keyless.d.ts +35 -0
- package/dist/exa-keyless.js +202 -0
- package/dist/fetch-page.d.ts +114 -0
- package/dist/fetch-page.js +182 -0
- package/dist/files.d.ts +65 -0
- package/dist/files.js +158 -0
- package/dist/grade.d.ts +93 -0
- package/dist/grade.js +328 -0
- package/dist/graph-served.d.ts +23 -0
- package/dist/graph-served.js +75 -0
- package/dist/graph-view.d.ts +102 -0
- package/dist/graph-view.js +219 -0
- package/dist/harness-app.d.ts +40 -0
- package/dist/harness-app.js +708 -0
- package/dist/harness-opencode/adapter.d.ts +45 -0
- package/dist/harness-opencode/adapter.js +272 -0
- package/dist/harness-opencode/binary.d.ts +18 -0
- package/dist/harness-opencode/binary.js +87 -0
- package/dist/harness-opencode/config.d.ts +24 -0
- package/dist/harness-opencode/config.js +61 -0
- package/dist/harness-opencode/harness.d.ts +77 -0
- package/dist/harness-opencode/harness.js +620 -0
- package/dist/harness-opencode/host/mcp.d.ts +40 -0
- package/dist/harness-opencode/host/mcp.js +208 -0
- package/dist/harness-opencode/host/policy.d.ts +71 -0
- package/dist/harness-opencode/host/policy.js +419 -0
- package/dist/harness-opencode/host/server.d.ts +55 -0
- package/dist/harness-opencode/host/server.js +165 -0
- package/dist/harness-opencode/index.d.ts +9 -0
- package/dist/harness-opencode/index.js +6 -0
- package/dist/harness-opencode/verify.d.ts +32 -0
- package/dist/harness-opencode/verify.js +75 -0
- package/dist/harness-opencode/versions.d.ts +33 -0
- package/dist/harness-opencode/versions.js +64 -0
- package/dist/harness.d.ts +56 -0
- package/dist/harness.js +77 -0
- package/dist/home-path.d.ts +27 -0
- package/dist/home-path.js +78 -0
- package/dist/host-tools.d.ts +30 -0
- package/dist/host-tools.js +154 -0
- package/dist/host.d.ts +39 -0
- package/dist/host.js +85 -0
- package/dist/hosted-search.d.ts +27 -0
- package/dist/hosted-search.js +133 -0
- package/dist/import-sources.d.ts +104 -0
- package/dist/import-sources.js +629 -0
- package/dist/import-summary.d.ts +25 -0
- package/dist/import-summary.js +75 -0
- package/dist/import-worker.d.ts +26 -0
- package/dist/import-worker.js +41 -0
- package/dist/import.d.ts +145 -0
- package/dist/import.js +1222 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -0
- package/dist/key-check.d.ts +37 -0
- package/dist/key-check.js +112 -0
- package/dist/key-refusal.d.ts +51 -0
- package/dist/key-refusal.js +191 -0
- package/dist/learn/check.d.ts +108 -0
- package/dist/learn/check.js +277 -0
- package/dist/learn/grade.d.ts +80 -0
- package/dist/learn/grade.js +445 -0
- package/dist/learn/index.d.ts +7 -0
- package/dist/learn/index.js +11 -0
- package/dist/learn/invisible.d.ts +5 -0
- package/dist/learn/invisible.js +42 -0
- package/dist/learn/notes.d.ts +59 -0
- package/dist/learn/notes.js +147 -0
- package/dist/learn/reflect.d.ts +49 -0
- package/dist/learn/reflect.js +213 -0
- package/dist/learn/secrets.d.ts +18 -0
- package/dist/learn/secrets.js +131 -0
- package/dist/learn/skills.d.ts +97 -0
- package/dist/learn/skills.js +271 -0
- package/dist/learned-workflow.d.ts +59 -0
- package/dist/learned-workflow.js +191 -0
- package/dist/learning-routes.d.ts +196 -0
- package/dist/learning-routes.js +609 -0
- package/dist/learning-run.d.ts +306 -0
- package/dist/learning-run.js +819 -0
- package/dist/learning-words.d.ts +76 -0
- package/dist/learning-words.js +174 -0
- package/dist/learning.d.ts +418 -0
- package/dist/learning.js +946 -0
- package/dist/llm.d.ts +40 -0
- package/dist/llm.js +37 -0
- package/dist/llms.txt +37 -0
- package/dist/mcp-servers.d.ts +118 -0
- package/dist/mcp-servers.js +450 -0
- package/dist/mcp.d.ts +51 -0
- package/dist/mcp.js +392 -0
- package/dist/model.d.ts +186 -0
- package/dist/model.js +485 -0
- package/dist/monid.d.ts +74 -0
- package/dist/monid.js +277 -0
- package/dist/openapi/agentrun-v2.openapi.json +4806 -0
- package/dist/openapi.d.ts +10 -0
- package/dist/openapi.js +1727 -0
- package/dist/owner.d.ts +55 -0
- package/dist/owner.js +222 -0
- package/dist/packs.d.ts +71 -0
- package/dist/packs.js +180 -0
- package/dist/page.d.ts +32 -0
- package/dist/page.js +133 -0
- package/dist/paid-calls.d.ts +50 -0
- package/dist/paid-calls.js +110 -0
- package/dist/pause.d.ts +70 -0
- package/dist/pause.js +97 -0
- package/dist/pdf-pages.d.ts +44 -0
- package/dist/pdf-pages.js +147 -0
- package/dist/place.d.ts +69 -0
- package/dist/place.js +137 -0
- package/dist/print.d.ts +20 -0
- package/dist/print.js +29 -0
- package/dist/propose.d.ts +40 -0
- package/dist/propose.js +112 -0
- package/dist/quiet-sqlite-warning.d.ts +1 -0
- package/dist/quiet-sqlite-warning.js +14 -0
- package/dist/request-start.d.ts +22 -0
- package/dist/request-start.js +350 -0
- package/dist/result.d.ts +3 -0
- package/dist/result.js +5 -0
- package/dist/rows.d.ts +46 -0
- package/dist/rows.js +121 -0
- package/dist/run-box.d.ts +186 -0
- package/dist/run-box.js +590 -0
- package/dist/run-manifest.d.ts +27 -0
- package/dist/run-manifest.js +60 -0
- package/dist/runnable.d.ts +83 -0
- package/dist/runnable.js +170 -0
- package/dist/runs.d.ts +1062 -0
- package/dist/runs.js +3020 -0
- package/dist/secret-cut.d.ts +27 -0
- package/dist/secret-cut.js +109 -0
- package/dist/secrets.d.ts +62 -0
- package/dist/secrets.js +158 -0
- package/dist/server-lock.d.ts +44 -0
- package/dist/server-lock.js +140 -0
- package/dist/server.d.ts +722 -0
- package/dist/server.js +2118 -0
- package/dist/sessions.d.ts +4 -0
- package/dist/sessions.js +105 -0
- package/dist/sign-ins.d.ts +99 -0
- package/dist/sign-ins.js +288 -0
- package/dist/skills.d.ts +43 -0
- package/dist/skills.js +96 -0
- package/dist/stats.d.ts +106 -0
- package/dist/stats.js +103 -0
- package/dist/tool-gate.d.ts +266 -0
- package/dist/tool-gate.js +554 -0
- package/dist/tool-keys.d.ts +187 -0
- package/dist/tool-keys.js +315 -0
- package/dist/tool-plane.d.ts +228 -0
- package/dist/tool-plane.js +400 -0
- package/dist/tools.d.ts +202 -0
- package/dist/tools.js +372 -0
- package/dist/trigger-secrets.d.ts +32 -0
- package/dist/trigger-secrets.js +143 -0
- package/dist/triggers.d.ts +439 -0
- package/dist/triggers.js +863 -0
- package/dist/turn-end.d.ts +24 -0
- package/dist/turn-end.js +15 -0
- package/dist/turns.d.ts +34 -0
- package/dist/turns.js +202 -0
- package/dist/uploads.d.ts +104 -0
- package/dist/uploads.js +474 -0
- package/dist/usage-lines.d.ts +26 -0
- package/dist/usage-lines.js +28 -0
- package/dist/usage.d.ts +29 -0
- package/dist/usage.js +58 -0
- package/dist/validate.d.ts +57 -0
- package/dist/validate.js +184 -0
- package/dist/web-fetch.d.ts +64 -0
- package/dist/web-fetch.js +262 -0
- package/dist/web-search.d.ts +54 -0
- package/dist/web-search.js +136 -0
- package/dist/webhooks.d.ts +189 -0
- package/dist/webhooks.js +503 -0
- package/dist/workspace-paths.d.ts +33 -0
- package/dist/workspace-paths.js +104 -0
- package/dist/workspace.d.ts +88 -0
- package/dist/workspace.js +369 -0
- package/launcher/agentrun-serve +109 -0
- package/package.json +100 -4
- package/skills/agentrun-serve/SKILL.md +128 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// Each webhook trigger's signing secret (triggers.ts): `whsec_` and 32 random bytes in base64, as the Standard Webhooks
|
|
2
|
+
// spec gives one, made at the trigger's create or a rotation, shown that once, and kept in DIR/trigger-secrets.json only
|
|
3
|
+
// sealed under the seal key (tool-keys.ts), each bound to its trigger by its AAD. With no seal key none is kept, never in
|
|
4
|
+
// the clear, so no webhook trigger is made.
|
|
5
|
+
import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { seal, unseal } from "@parcha/pi-durable-agent";
|
|
9
|
+
import { ApiError } from "./errors.js";
|
|
10
|
+
import { writeDurableSync } from "./files.js";
|
|
11
|
+
import { SEAL_KEY_ENV, sealKeyOf } from "./tool-keys.js";
|
|
12
|
+
import { isObject } from "./validate.js";
|
|
13
|
+
export const TRIGGER_SECRETS_FILE = "trigger-secrets.json";
|
|
14
|
+
const aad = (triggerId) => `trigger-secret|${triggerId}`;
|
|
15
|
+
/** The sealed secrets `file` keeps, by trigger id: none when there is no file, and why not when it does not read. */
|
|
16
|
+
function sealedIn(file) {
|
|
17
|
+
let text;
|
|
18
|
+
try {
|
|
19
|
+
text = readFileSync(file, "utf8");
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
return error.code === "ENOENT" ? { sealed: {} } : { unreadable: error.message };
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const doc = JSON.parse(text);
|
|
26
|
+
if (!isObject(doc) || doc.v !== 1 || !isObject(doc.secrets) || !Object.values(doc.secrets).every((v) => typeof v === "string"))
|
|
27
|
+
return { unreadable: "not a trigger secrets file of version 1" };
|
|
28
|
+
return { sealed: doc.secrets };
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
return { unreadable: error.message };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const opened = (key, sealed) => Object.fromEntries(Object.entries(sealed).flatMap(([id, value]) => {
|
|
35
|
+
try {
|
|
36
|
+
return [[id, unseal(key, Buffer.from(value, "base64"), aad(id)).toString("utf8")]];
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
}));
|
|
42
|
+
/** The trigger secrets data directory `data` keeps, opened with the seal key of `env` (those that open): what an import
|
|
43
|
+
* cuts out of everything it writes. */
|
|
44
|
+
export function triggerSecretsIn(data, env) {
|
|
45
|
+
const key = sealKeyOf(env[SEAL_KEY_ENV]);
|
|
46
|
+
const read = sealedIn(join(data, TRIGGER_SECRETS_FILE));
|
|
47
|
+
return key && "sealed" in read ? Object.values(opened(key, read.sealed)) : [];
|
|
48
|
+
}
|
|
49
|
+
export class TriggerSecrets {
|
|
50
|
+
file;
|
|
51
|
+
key;
|
|
52
|
+
/** Opened, by trigger id: read once at start, then kept with every write. */
|
|
53
|
+
secrets;
|
|
54
|
+
sealed = {};
|
|
55
|
+
/** Why the file does not read: no secret is made or rotated, none signs, and the file is never written over. */
|
|
56
|
+
unreadable;
|
|
57
|
+
constructor(data, env, say = () => { }) {
|
|
58
|
+
this.file = join(data, TRIGGER_SECRETS_FILE);
|
|
59
|
+
this.key = sealKeyOf(env[SEAL_KEY_ENV]);
|
|
60
|
+
const read = sealedIn(this.file);
|
|
61
|
+
if ("sealed" in read)
|
|
62
|
+
this.sealed = read.sealed;
|
|
63
|
+
else {
|
|
64
|
+
this.unreadable = read.unreadable;
|
|
65
|
+
say({ condition: "trigger_secrets_unreadable", file: this.file, error: read.unreadable });
|
|
66
|
+
}
|
|
67
|
+
this.secrets = this.key ? opened(this.key, this.sealed) : {};
|
|
68
|
+
}
|
|
69
|
+
get sealing() {
|
|
70
|
+
return this.key ? "sealed" : "unavailable";
|
|
71
|
+
}
|
|
72
|
+
/** A new secret for `triggerId`, written sealed before it is answered: its only showing. */
|
|
73
|
+
mint(triggerId) {
|
|
74
|
+
if (this.unreadable)
|
|
75
|
+
throw new ApiError("store_unreadable", `${TRIGGER_SECRETS_FILE} in the data directory does not read (${this.unreadable}); it is never written over, so no webhook trigger's secret is made or rotated. Fix it or move it away, then restart.`);
|
|
76
|
+
if (!this.key)
|
|
77
|
+
throw new ApiError("no_sealing_key", `This server was handed no seal key (${SEAL_KEY_ENV}), so it keeps no webhook trigger's secret: it never keeps one in the clear.`);
|
|
78
|
+
const secret = `whsec_${randomBytes(32).toString("base64")}`;
|
|
79
|
+
this.write({ ...this.sealed, [triggerId]: seal(this.key, Buffer.from(secret, "utf8"), aad(triggerId)).toString("base64") });
|
|
80
|
+
this.secrets[triggerId] = secret;
|
|
81
|
+
return secret;
|
|
82
|
+
}
|
|
83
|
+
value(triggerId) {
|
|
84
|
+
return this.secrets[triggerId];
|
|
85
|
+
}
|
|
86
|
+
/** A deleted trigger's secret goes; with the file unreadable it stays in it, unread, as the file is never written over. */
|
|
87
|
+
remove(triggerId) {
|
|
88
|
+
if (this.unreadable || !(triggerId in this.sealed))
|
|
89
|
+
return;
|
|
90
|
+
const { [triggerId]: _, ...rest } = this.sealed;
|
|
91
|
+
this.write(rest);
|
|
92
|
+
delete this.secrets[triggerId];
|
|
93
|
+
}
|
|
94
|
+
/** Every secret held, for the redaction of what is shown. */
|
|
95
|
+
values() {
|
|
96
|
+
return Object.values(this.secrets);
|
|
97
|
+
}
|
|
98
|
+
write(sealed) {
|
|
99
|
+
writeDurableSync(this.file, `${JSON.stringify({ v: 1, secrets: sealed }, null, 2)}\n`);
|
|
100
|
+
this.sealed = sealed;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** How far a request's `webhook-timestamp` may be from this server's clock, either way. */
|
|
104
|
+
export const HOOK_TOLERANCE_S = 300;
|
|
105
|
+
/** A webhook-id: printable ASCII with no space, as the spec's `msg_...` ids are; it goes into a firing's key and history. */
|
|
106
|
+
const HOOK_ID = /^[\x21-\x7e]{1,255}$/;
|
|
107
|
+
/** The longest `webhook-signature` list read: room for many keys during a rotation, never an unbounded loop. */
|
|
108
|
+
const MAX_SIGNATURES_CHARS = 2048;
|
|
109
|
+
/** The fewest bytes a signing key may have (the spec's secrets are 24 to 64; this server makes 32): a shorter one,
|
|
110
|
+
* an empty one above all, signs nothing. */
|
|
111
|
+
const MIN_KEY_BYTES = 24;
|
|
112
|
+
/** Why a request's webhook headers are refused before its body is read, or undefined when they may be checked:
|
|
113
|
+
* present, a webhook-id of printable ASCII, a bounded signature list, a timestamp within HOOK_TOLERANCE_S. */
|
|
114
|
+
export function hookHeadersRefusal(headers, nowMs) {
|
|
115
|
+
const [id, timestamp, signatures] = ["webhook-id", "webhook-timestamp", "webhook-signature"].map((name) => headers[name]);
|
|
116
|
+
if (typeof id !== "string" || typeof timestamp !== "string" || typeof signatures !== "string")
|
|
117
|
+
return "missing_headers";
|
|
118
|
+
if (!HOOK_ID.test(id) || signatures.length > MAX_SIGNATURES_CHARS)
|
|
119
|
+
return "malformed_headers";
|
|
120
|
+
if (!/^\d{1,12}$/.test(timestamp) || Math.abs(nowMs / 1000 - Number(timestamp)) > HOOK_TOLERANCE_S)
|
|
121
|
+
return "stale_timestamp";
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
/** Why a request to /v2/hooks/{id} is not signed by `secret` under the Standard Webhooks spec, or undefined when it is:
|
|
125
|
+
* `webhook-signature` lists `v1,<base64 HMAC-SHA256 of "{webhook-id}.{webhook-timestamp}.{body}">` signatures, space
|
|
126
|
+
* separated, under the secret's bytes, and any one that matches passes; the timestamp is within HOOK_TOLERANCE_S. */
|
|
127
|
+
export function hookRefusal(secret, headers, body, nowMs) {
|
|
128
|
+
const early = hookHeadersRefusal(headers, nowMs);
|
|
129
|
+
if (early)
|
|
130
|
+
return early;
|
|
131
|
+
const [id, timestamp, signatures] = ["webhook-id", "webhook-timestamp", "webhook-signature"].map((name) => headers[name]);
|
|
132
|
+
const key = Buffer.from(secret.slice("whsec_".length), "base64");
|
|
133
|
+
const expected = createHmac("sha256", key).update(`${id}.${timestamp}.`).update(body).digest();
|
|
134
|
+
// Compared all the same, so a short key costs what a good one does; it fails after.
|
|
135
|
+
const matched = signatures.split(" ").some((part) => {
|
|
136
|
+
const [version, signature] = part.split(",");
|
|
137
|
+
const given = Buffer.from(signature ?? "", "base64");
|
|
138
|
+
return version === "v1" && given.length === expected.length && timingSafeEqual(given, expected);
|
|
139
|
+
});
|
|
140
|
+
if (key.length < MIN_KEY_BYTES)
|
|
141
|
+
return "short_key";
|
|
142
|
+
return matched ? undefined : "bad_signature";
|
|
143
|
+
}
|
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { type InputIssue } from "./errors.js";
|
|
2
|
+
import { type Json } from "./validate.js";
|
|
3
|
+
export declare const TRIGGERS_FILE = "triggers.json";
|
|
4
|
+
/** The firings each trigger keeps, newest last; a firing still due is never dropped, nor a failure whose trigger.failed is
|
|
5
|
+
* not queued yet (up to UNTOLD_KEPT). */
|
|
6
|
+
export declare const HISTORY_KEPT = 200;
|
|
7
|
+
/** The most firings a trigger holds due. A message_run firing to a working run stays due, tried every 5 s, until the
|
|
8
|
+
* run takes it: one per idle point, so twenty is far past a sender's burst while the run works, and with up to 16 KiB of
|
|
9
|
+
* payload each they add at most 320 KiB to the file every write rewrites. Past it a webhook event and a run now are
|
|
10
|
+
* refused (429, retryable) before anything is written, and a schedule's time is skipped. */
|
|
11
|
+
export declare const DUE_KEPT = 20;
|
|
12
|
+
/** The shortest every_s, and so the most often a schedule fires: a cron line has no seconds field. */
|
|
13
|
+
export declare const MIN_EVERY_S = 60;
|
|
14
|
+
/** The longest every_s: a year and a day. */
|
|
15
|
+
export declare const MAX_EVERY_S: number;
|
|
16
|
+
export declare const SOURCE_KINDS: readonly ["schedule", "webhook"];
|
|
17
|
+
export declare const TARGET_KINDS: readonly ["start_run", "message_run"];
|
|
18
|
+
export declare const OVERLAP: readonly ["skip"];
|
|
19
|
+
export declare const FIRING_STATUSES: readonly ["due", "started", "sent", "skipped", "failed", "missed"];
|
|
20
|
+
/** The most of a webhook's payload a firing passes on: the rest is cut, at a character's start. */
|
|
21
|
+
export declare const PAYLOAD_KEPT_BYTES: number;
|
|
22
|
+
/** How late a missed time may be and still fire once, by default: an hour. */
|
|
23
|
+
export declare const CATCHUP_WINDOW_S = 3600;
|
|
24
|
+
/** The failed firings in a row that turn a trigger off. */
|
|
25
|
+
export declare const FAILURES_TO_PAUSE = 5;
|
|
26
|
+
type Schedule = {
|
|
27
|
+
kind: "schedule";
|
|
28
|
+
cron: string;
|
|
29
|
+
timezone: string;
|
|
30
|
+
} | {
|
|
31
|
+
kind: "schedule";
|
|
32
|
+
at: string;
|
|
33
|
+
} | {
|
|
34
|
+
kind: "schedule";
|
|
35
|
+
every_s: number;
|
|
36
|
+
start_at: string;
|
|
37
|
+
};
|
|
38
|
+
/** A signed POST to /v2/hooks/{trigger_id} (server.ts): the request is the firing. */
|
|
39
|
+
type Source = Schedule | {
|
|
40
|
+
kind: "webhook";
|
|
41
|
+
};
|
|
42
|
+
/** `max_cost_usd`: each run's cap; absent, the agent's default as it stands when the firing starts (one of the two is
|
|
43
|
+
* required: server.ts targetIssues and start). */
|
|
44
|
+
export type Target = {
|
|
45
|
+
kind: "start_run";
|
|
46
|
+
agent_id: string;
|
|
47
|
+
input: Json;
|
|
48
|
+
max_cost_usd?: number;
|
|
49
|
+
effort?: string;
|
|
50
|
+
} | {
|
|
51
|
+
kind: "message_run";
|
|
52
|
+
run_id: string;
|
|
53
|
+
input: Json;
|
|
54
|
+
};
|
|
55
|
+
type FiringStatus = (typeof FIRING_STATUSES)[number];
|
|
56
|
+
type Firing = {
|
|
57
|
+
key: string;
|
|
58
|
+
by: "schedule" | "manual" | "webhook";
|
|
59
|
+
nominal_at: string;
|
|
60
|
+
status: FiringStatus;
|
|
61
|
+
/** When it was recorded. */
|
|
62
|
+
at: string;
|
|
63
|
+
run_id?: string;
|
|
64
|
+
reason?: string;
|
|
65
|
+
error?: {
|
|
66
|
+
code: string;
|
|
67
|
+
message: string;
|
|
68
|
+
};
|
|
69
|
+
/** A `missed` row: how many times it stands for, from its nominal_at on. */
|
|
70
|
+
count?: number;
|
|
71
|
+
/** A firing kept due by a full server: how many tries so far, and when the next is. */
|
|
72
|
+
attempts?: number;
|
|
73
|
+
retry_at?: string;
|
|
74
|
+
/** A failed firing whose trigger.failed is in the webhook's outbox, or had no webhook to go to. */
|
|
75
|
+
notified?: boolean;
|
|
76
|
+
/** A time that fired late, within the catch-up window: the server was down, or its timer late. */
|
|
77
|
+
catch_up?: boolean;
|
|
78
|
+
/** A failed firing that turned its trigger off (FAILURES_TO_PAUSE in a row). */
|
|
79
|
+
paused?: boolean;
|
|
80
|
+
/** A webhook firing's payload, cut to PAYLOAD_KEPT_BYTES, kept while it is due: what its run is given. */
|
|
81
|
+
payload?: string;
|
|
82
|
+
};
|
|
83
|
+
/** What a trigger.failed webhook message says (webhooks.ts). */
|
|
84
|
+
export type TriggerFailed = {
|
|
85
|
+
trigger_id: string;
|
|
86
|
+
name: string;
|
|
87
|
+
firing_key: string;
|
|
88
|
+
nominal_at: string;
|
|
89
|
+
error: {
|
|
90
|
+
code: string;
|
|
91
|
+
message: string;
|
|
92
|
+
};
|
|
93
|
+
auto_paused: boolean;
|
|
94
|
+
};
|
|
95
|
+
/** A run's provenance, kept in its serve.json: the trigger that started it, and the firing. */
|
|
96
|
+
export type RunTrigger = {
|
|
97
|
+
id: string;
|
|
98
|
+
firing_key: string;
|
|
99
|
+
};
|
|
100
|
+
/** The engine's clock and its one timer: Date.now and setTimeout, or a test's. */
|
|
101
|
+
export type TriggerClock = {
|
|
102
|
+
now(): number;
|
|
103
|
+
arm(fire: () => void, ms: number): {
|
|
104
|
+
clear(): void;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
export type TriggerDeps = {
|
|
108
|
+
/** What keeps a target from starting runs here, by field (its agent, its kind, its input). */
|
|
109
|
+
targetIssues(target: Target): Promise<InputIssue[]>;
|
|
110
|
+
/** Starts the target's run with `input`, as POST /agents/{id}/runs would, under `origin`; ApiError when refused. */
|
|
111
|
+
start(target: Extract<Target, {
|
|
112
|
+
kind: "start_run";
|
|
113
|
+
}>, input: Json, origin: RunTrigger): Promise<{
|
|
114
|
+
run_id: string;
|
|
115
|
+
}>;
|
|
116
|
+
/** Sends `input` to the target's run, as POST /runs/{id}/messages would, under `key` (the run's store takes a message
|
|
117
|
+
* once per key); ApiError when refused. */
|
|
118
|
+
message(target: Extract<Target, {
|
|
119
|
+
kind: "message_run";
|
|
120
|
+
}>, input: Json, key: string): Promise<void | {
|
|
121
|
+
skipped: string;
|
|
122
|
+
}>;
|
|
123
|
+
/** A webhook trigger's signing secret, made now (at its create or a rotation) and shown once; its removal. */
|
|
124
|
+
secrets: {
|
|
125
|
+
mint(triggerId: string): string;
|
|
126
|
+
remove(triggerId: string): void;
|
|
127
|
+
};
|
|
128
|
+
/** A run's status, or null when there is no such run. */
|
|
129
|
+
statusOf(runId: string): Promise<string | null>;
|
|
130
|
+
/** The run the agent store started under origin `key`, if one: a firing left due by a server that went down mid-start.
|
|
131
|
+
* `setup_lost`: that server went down before it set the run up, so the run never started (files.ts SETUP_LOST). */
|
|
132
|
+
runOf(key: string): Promise<{
|
|
133
|
+
run_id: string;
|
|
134
|
+
setup_lost: boolean;
|
|
135
|
+
} | null>;
|
|
136
|
+
/** Queues a trigger.failed webhook message under `key`, the firing's (webhooks.ts emitTrigger): `off` when there is no
|
|
137
|
+
* webhook to send it to; `unsaved` or `closed` when it is not in the outbox on disk. */
|
|
138
|
+
notify(failed: TriggerFailed, key: string): "queued" | "unsaved" | "off" | "closed";
|
|
139
|
+
say(fields: Record<string, string | number>): void;
|
|
140
|
+
clock?: TriggerClock;
|
|
141
|
+
};
|
|
142
|
+
export declare const firingKey: (kind: "schedule" | "manual" | "webhook", triggerId: string, what: string) => string;
|
|
143
|
+
export declare class Triggers {
|
|
144
|
+
private readonly deps;
|
|
145
|
+
private readonly file;
|
|
146
|
+
private readonly clock;
|
|
147
|
+
private triggers;
|
|
148
|
+
/** Why triggers.json does not read: nothing fires and nothing is written over it until it does. */
|
|
149
|
+
private readonly unreadable?;
|
|
150
|
+
private timer?;
|
|
151
|
+
/** The firings in their turn, queued or being driven, by key, with that turn: a firing is asked for once at a time,
|
|
152
|
+
* and the timer arms for none of them until its turn ends. */
|
|
153
|
+
private readonly driving;
|
|
154
|
+
/** Due firings whose last write failed, by key, and when to drive them again: on disk they may hold no retry time. */
|
|
155
|
+
private readonly rewrite;
|
|
156
|
+
/** Each trigger's firings, driven one after another in the order asked: a firing's overlap check reads what the one
|
|
157
|
+
* before it settled to (a firing a crash left due settles to its run before the next start's own is checked). */
|
|
158
|
+
private readonly turns;
|
|
159
|
+
private closed;
|
|
160
|
+
constructor(data: string, deps: TriggerDeps);
|
|
161
|
+
/** At the server's start: every firing an earlier server left due driven again (its origin key makes a run
|
|
162
|
+
* it already started the same run), the times missed while it was down recorded, the timer armed, and each failure's
|
|
163
|
+
* trigger.failed queued that is not yet. */
|
|
164
|
+
start(): void;
|
|
165
|
+
close(): void;
|
|
166
|
+
list(): {
|
|
167
|
+
triggers: {
|
|
168
|
+
last_firing: {
|
|
169
|
+
attempts?: number | undefined;
|
|
170
|
+
retry_at?: string | undefined;
|
|
171
|
+
catch_up?: boolean | undefined;
|
|
172
|
+
count?: number | undefined;
|
|
173
|
+
key: string;
|
|
174
|
+
by: "manual" | "schedule" | "webhook";
|
|
175
|
+
nominal_at: string;
|
|
176
|
+
status: "failed" | "started" | "skipped" | "due" | "sent" | "missed";
|
|
177
|
+
at: string;
|
|
178
|
+
run_id: string | null;
|
|
179
|
+
reason: string | null;
|
|
180
|
+
error: {
|
|
181
|
+
code: string;
|
|
182
|
+
message: string;
|
|
183
|
+
} | null;
|
|
184
|
+
} | null;
|
|
185
|
+
overlap: "skip";
|
|
186
|
+
catchup_window_s: number;
|
|
187
|
+
failures_in_a_row: number;
|
|
188
|
+
disabled: {
|
|
189
|
+
at: string;
|
|
190
|
+
reason: "auto_paused";
|
|
191
|
+
} | {
|
|
192
|
+
at: string;
|
|
193
|
+
reason: "source_unreadable";
|
|
194
|
+
detail: string;
|
|
195
|
+
} | null;
|
|
196
|
+
last_run_id: string | null;
|
|
197
|
+
id: string;
|
|
198
|
+
name: string;
|
|
199
|
+
enabled: boolean;
|
|
200
|
+
source: Source;
|
|
201
|
+
target: Target;
|
|
202
|
+
created_at: string;
|
|
203
|
+
updated_at: string;
|
|
204
|
+
next_at: string | null;
|
|
205
|
+
run_now_kept?: Firing[];
|
|
206
|
+
}[];
|
|
207
|
+
};
|
|
208
|
+
get(id: string): {
|
|
209
|
+
last_firing: {
|
|
210
|
+
attempts?: number | undefined;
|
|
211
|
+
retry_at?: string | undefined;
|
|
212
|
+
catch_up?: boolean | undefined;
|
|
213
|
+
count?: number | undefined;
|
|
214
|
+
key: string;
|
|
215
|
+
by: "manual" | "schedule" | "webhook";
|
|
216
|
+
nominal_at: string;
|
|
217
|
+
status: "failed" | "started" | "skipped" | "due" | "sent" | "missed";
|
|
218
|
+
at: string;
|
|
219
|
+
run_id: string | null;
|
|
220
|
+
reason: string | null;
|
|
221
|
+
error: {
|
|
222
|
+
code: string;
|
|
223
|
+
message: string;
|
|
224
|
+
} | null;
|
|
225
|
+
} | null;
|
|
226
|
+
overlap: "skip";
|
|
227
|
+
catchup_window_s: number;
|
|
228
|
+
failures_in_a_row: number;
|
|
229
|
+
disabled: {
|
|
230
|
+
at: string;
|
|
231
|
+
reason: "auto_paused";
|
|
232
|
+
} | {
|
|
233
|
+
at: string;
|
|
234
|
+
reason: "source_unreadable";
|
|
235
|
+
detail: string;
|
|
236
|
+
} | null;
|
|
237
|
+
last_run_id: string | null;
|
|
238
|
+
id: string;
|
|
239
|
+
name: string;
|
|
240
|
+
enabled: boolean;
|
|
241
|
+
source: Source;
|
|
242
|
+
target: Target;
|
|
243
|
+
created_at: string;
|
|
244
|
+
updated_at: string;
|
|
245
|
+
next_at: string | null;
|
|
246
|
+
run_now_kept?: Firing[];
|
|
247
|
+
};
|
|
248
|
+
firings(id: string): {
|
|
249
|
+
firings: {
|
|
250
|
+
attempts?: number | undefined;
|
|
251
|
+
retry_at?: string | undefined;
|
|
252
|
+
catch_up?: boolean | undefined;
|
|
253
|
+
count?: number | undefined;
|
|
254
|
+
key: string;
|
|
255
|
+
by: "manual" | "schedule" | "webhook";
|
|
256
|
+
nominal_at: string;
|
|
257
|
+
status: "failed" | "started" | "skipped" | "due" | "sent" | "missed";
|
|
258
|
+
at: string;
|
|
259
|
+
run_id: string | null;
|
|
260
|
+
reason: string | null;
|
|
261
|
+
error: {
|
|
262
|
+
code: string;
|
|
263
|
+
message: string;
|
|
264
|
+
} | null;
|
|
265
|
+
}[];
|
|
266
|
+
};
|
|
267
|
+
create(body: Json): Promise<{
|
|
268
|
+
secret?: string | undefined;
|
|
269
|
+
last_firing: {
|
|
270
|
+
attempts?: number | undefined;
|
|
271
|
+
retry_at?: string | undefined;
|
|
272
|
+
catch_up?: boolean | undefined;
|
|
273
|
+
count?: number | undefined;
|
|
274
|
+
key: string;
|
|
275
|
+
by: "manual" | "schedule" | "webhook";
|
|
276
|
+
nominal_at: string;
|
|
277
|
+
status: "failed" | "started" | "skipped" | "due" | "sent" | "missed";
|
|
278
|
+
at: string;
|
|
279
|
+
run_id: string | null;
|
|
280
|
+
reason: string | null;
|
|
281
|
+
error: {
|
|
282
|
+
code: string;
|
|
283
|
+
message: string;
|
|
284
|
+
} | null;
|
|
285
|
+
} | null;
|
|
286
|
+
overlap: "skip";
|
|
287
|
+
catchup_window_s: number;
|
|
288
|
+
failures_in_a_row: number;
|
|
289
|
+
disabled: {
|
|
290
|
+
at: string;
|
|
291
|
+
reason: "auto_paused";
|
|
292
|
+
} | {
|
|
293
|
+
at: string;
|
|
294
|
+
reason: "source_unreadable";
|
|
295
|
+
detail: string;
|
|
296
|
+
} | null;
|
|
297
|
+
last_run_id: string | null;
|
|
298
|
+
id: string;
|
|
299
|
+
name: string;
|
|
300
|
+
enabled: boolean;
|
|
301
|
+
source: Source;
|
|
302
|
+
target: Target;
|
|
303
|
+
created_at: string;
|
|
304
|
+
updated_at: string;
|
|
305
|
+
next_at: string | null;
|
|
306
|
+
run_now_kept?: Firing[];
|
|
307
|
+
}>;
|
|
308
|
+
/** A webhook trigger's new secret, shown this once; the old one signs nothing from now on. */
|
|
309
|
+
rotate(id: string): {
|
|
310
|
+
secret: string;
|
|
311
|
+
};
|
|
312
|
+
/** Whether `id` is a webhook trigger that is on: the one a signed request to /v2/hooks/{id} may fire. */
|
|
313
|
+
hookable(id: string): boolean;
|
|
314
|
+
/** A signed request to /v2/hooks/{id} (server.ts checked it): its firing, keyed by its `webhook-id`, recorded due in
|
|
315
|
+
* one write and driven after the answer. `created` false: that webhook-id's firing, as it stands. */
|
|
316
|
+
receive(id: string, webhookId: string, payload: string): {
|
|
317
|
+
created: boolean;
|
|
318
|
+
firing: ReturnType<typeof firingView>;
|
|
319
|
+
};
|
|
320
|
+
/** PATCH: any of name, enabled, source, target and catchup_window_s. Enabled again, or its source changed, a trigger goes on from now: a
|
|
321
|
+
* paused range is skipped, never caught up. Only the fields named change, applied to the trigger as it stands once
|
|
322
|
+
* the target's check is done: an edit made meanwhile keeps its own. */
|
|
323
|
+
update(id: string, body: Json): Promise<{
|
|
324
|
+
last_firing: {
|
|
325
|
+
attempts?: number | undefined;
|
|
326
|
+
retry_at?: string | undefined;
|
|
327
|
+
catch_up?: boolean | undefined;
|
|
328
|
+
count?: number | undefined;
|
|
329
|
+
key: string;
|
|
330
|
+
by: "manual" | "schedule" | "webhook";
|
|
331
|
+
nominal_at: string;
|
|
332
|
+
status: "failed" | "started" | "skipped" | "due" | "sent" | "missed";
|
|
333
|
+
at: string;
|
|
334
|
+
run_id: string | null;
|
|
335
|
+
reason: string | null;
|
|
336
|
+
error: {
|
|
337
|
+
code: string;
|
|
338
|
+
message: string;
|
|
339
|
+
} | null;
|
|
340
|
+
} | null;
|
|
341
|
+
overlap: "skip";
|
|
342
|
+
catchup_window_s: number;
|
|
343
|
+
failures_in_a_row: number;
|
|
344
|
+
disabled: {
|
|
345
|
+
at: string;
|
|
346
|
+
reason: "auto_paused";
|
|
347
|
+
} | {
|
|
348
|
+
at: string;
|
|
349
|
+
reason: "source_unreadable";
|
|
350
|
+
detail: string;
|
|
351
|
+
} | null;
|
|
352
|
+
last_run_id: string | null;
|
|
353
|
+
id: string;
|
|
354
|
+
name: string;
|
|
355
|
+
enabled: boolean;
|
|
356
|
+
source: Source;
|
|
357
|
+
target: Target;
|
|
358
|
+
created_at: string;
|
|
359
|
+
updated_at: string;
|
|
360
|
+
next_at: string | null;
|
|
361
|
+
run_now_kept?: Firing[];
|
|
362
|
+
}>;
|
|
363
|
+
remove(id: string): void;
|
|
364
|
+
/** Run now: one firing per Idempotency-Key, driven before the answer. `created` false: the key's firing, as it stands. */
|
|
365
|
+
fire(id: string, idempotencyKey: string): Promise<{
|
|
366
|
+
created: boolean;
|
|
367
|
+
firing: ReturnType<typeof firingView>;
|
|
368
|
+
}>;
|
|
369
|
+
/** Every enabled trigger whose next time has come: its firing recorded and its next time moved on, in one write; then
|
|
370
|
+
* each due firing whose time has come driven, and the timer armed again. */
|
|
371
|
+
private tick;
|
|
372
|
+
/** `key`'s firing driven after every firing of its trigger asked before it. */
|
|
373
|
+
private inTurn;
|
|
374
|
+
/** Each of `triggers` turned off, with why its source no longer reads, in one write, and said. False when the write
|
|
375
|
+
* failed, which is said too: the caller tries again after WRITE_RETRY_MS. */
|
|
376
|
+
private offUnreadable;
|
|
377
|
+
/** Records `trigger`'s firings up to now and moves its next time on from the last nominal one. Of the times that have
|
|
378
|
+
* come, the latest fires (on time, or late within catchup_window_s: a catch-up, under its own nominal key), and every
|
|
379
|
+
* other is one `missed` row with their count. A one-time schedule, or one that never fires again, is turned off. */
|
|
380
|
+
private advance;
|
|
381
|
+
/** A firing taken from due to its end: skipped when its trigger's last run is active, else its run started. A full
|
|
382
|
+
* server (429), or a last run that could not be read, keeps it due and tries again later. Nothing it holds across a wait is an object: the trigger may be edited or
|
|
383
|
+
* deleted meanwhile, so each step finds it again by id and key. */
|
|
384
|
+
private drive;
|
|
385
|
+
/** A message_run firing: its message to the target's run, under its key. No overlap: the run's own state picks how the
|
|
386
|
+
* message lands (steer, answer or follow-up). */
|
|
387
|
+
private send;
|
|
388
|
+
private find;
|
|
389
|
+
/** Why `firing` is skipped (overlap: skip), if it is: an earlier firing still due, or the last run still active. */
|
|
390
|
+
private busy;
|
|
391
|
+
private retry;
|
|
392
|
+
private started;
|
|
393
|
+
/** A failed firing: one more in its trigger's streak, the trigger turned off at FAILURES_TO_PAUSE, and trigger.failed
|
|
394
|
+
* queued (after the firing is written: a start finds one not yet queued and queues it, under the same webhook-id). */
|
|
395
|
+
private failed;
|
|
396
|
+
private notifyFailed;
|
|
397
|
+
/** The firing's new state, written with `also` done to its trigger; one whose trigger was deleted meanwhile is gone with it. */
|
|
398
|
+
private settle;
|
|
399
|
+
private record;
|
|
400
|
+
/** A new firing's room: refused (429, retryable, nothing written) while the trigger holds DUE_KEPT firings due. */
|
|
401
|
+
private roomFor;
|
|
402
|
+
/** The firing `key` names, in the history or kept for its key's day after it left. */
|
|
403
|
+
private known;
|
|
404
|
+
/** Whether a firing is within its key's day, as an Idempotency-Key answers. */
|
|
405
|
+
private inDay;
|
|
406
|
+
/** The timer, at the soonest next time of an enabled trigger or retry of a due firing. */
|
|
407
|
+
private arm;
|
|
408
|
+
/** When a due firing is driven next: after the write retry's wait when its write or its drive failed (that wait wins
|
|
409
|
+
* over a retry time that may have passed), else at its retry; one with neither is driven by whatever recorded it. */
|
|
410
|
+
private dueAt;
|
|
411
|
+
/** `change` applied and written whole, or, when the write fails, undone and thrown. Each change, a signed request's
|
|
412
|
+
* firing included, copies and rewrites the whole file and syncs it: one writer (server.lock), and a bounded file. A
|
|
413
|
+
* firing is about 170 bytes of JSON, a due webhook firing's payload at most 16 KiB more, and a trigger keeps at most
|
|
414
|
+
* HISTORY_KEPT (200) in its history and KEPT_FIRINGS (1,000) past it: about 230 KiB a trigger at its fullest, which
|
|
415
|
+
* measured about 3 ms a write (copy, JSON and fsync) on an SSD. Its history runs past HISTORY_KEPT by at most
|
|
416
|
+
* UNTOLD_KEPT (50) failures not yet told and DUE_KEPT (20) due firings, whose payloads add at most 320 KiB. */
|
|
417
|
+
private commit;
|
|
418
|
+
private readable;
|
|
419
|
+
private need;
|
|
420
|
+
private view;
|
|
421
|
+
}
|
|
422
|
+
declare function firingView(firing: Firing): {
|
|
423
|
+
attempts?: number | undefined;
|
|
424
|
+
retry_at?: string | undefined;
|
|
425
|
+
catch_up?: boolean | undefined;
|
|
426
|
+
count?: number | undefined;
|
|
427
|
+
key: string;
|
|
428
|
+
by: "manual" | "schedule" | "webhook";
|
|
429
|
+
nominal_at: string;
|
|
430
|
+
status: "failed" | "started" | "skipped" | "due" | "sent" | "missed";
|
|
431
|
+
at: string;
|
|
432
|
+
run_id: string | null;
|
|
433
|
+
reason: string | null;
|
|
434
|
+
error: {
|
|
435
|
+
code: string;
|
|
436
|
+
message: string;
|
|
437
|
+
} | null;
|
|
438
|
+
};
|
|
439
|
+
export {};
|