@parcha/agentrun-serve 0.1.0-beta.54 → 0.1.0-beta.56
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 +142 -2
- package/README.md +310 -98
- package/dist/adapters.d.ts +11 -0
- package/dist/adapters.js +49 -0
- package/dist/agent-package.d.ts +3 -3
- package/dist/agent-package.js +6 -13
- package/dist/agents-store.js +6 -5
- package/dist/answer-json.d.ts +6 -2
- package/dist/answer-json.js +22 -4
- package/dist/api-only.d.ts +16 -4
- package/dist/api-only.js +23 -7
- package/dist/calendar/tools.js +3 -2
- package/dist/chatgpt-plan.d.ts +16 -1
- package/dist/chatgpt-plan.js +116 -12
- package/dist/claude-login.d.ts +34 -5
- package/dist/claude-login.js +31 -7
- package/dist/claude-sign-in.d.ts +35 -0
- package/dist/claude-sign-in.js +90 -0
- package/dist/cli.js +5 -3
- package/dist/composio-made.d.ts +26 -1
- package/dist/composio-made.js +39 -2
- package/dist/composio-preset.d.ts +3 -2
- package/dist/composio-preset.js +46 -14
- package/dist/computer-held-routes.js +2 -3
- package/dist/computer-setting.d.ts +4 -2
- package/dist/computer-setting.js +0 -2
- package/dist/computers-running.d.ts +8 -0
- package/dist/computers-running.js +27 -0
- package/dist/console/assets/backend-Boh7tC4i.js +166 -0
- package/dist/console/assets/index-CQ3cJRzI.js +746 -0
- package/dist/console/assets/index-DKkaS3a0.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/docker-host-addresses.d.ts +23 -3
- package/dist/docker-host-addresses.js +90 -18
- package/dist/exa-keyless.d.ts +2 -3
- package/dist/exa-keyless.js +43 -127
- package/dist/firecrawl-keyless.d.ts +41 -0
- package/dist/firecrawl-keyless.js +152 -0
- package/dist/handed-secret.d.ts +3 -1
- package/dist/handed-secret.js +4 -2
- package/dist/harness-keys.d.ts +98 -0
- package/dist/harness-keys.js +247 -0
- package/dist/harness-recipe-entry.d.ts +14 -9
- package/dist/harness-recipe-entry.js +25 -14
- package/dist/harness-table.d.ts +16 -1
- package/dist/harness-table.js +19 -7
- package/dist/harness.d.ts +4 -0
- package/dist/harness.js +12 -1
- package/dist/host-check.d.ts +6 -0
- package/dist/host-check.js +10 -0
- package/dist/import-summary.d.ts +1 -1
- package/dist/import-summary.js +1 -1
- package/dist/import.d.ts +5 -5
- package/dist/import.js +54 -67
- package/dist/key-refusal.d.ts +21 -5
- package/dist/key-refusal.js +231 -37
- package/dist/keyless-mcp.d.ts +36 -0
- package/dist/keyless-mcp.js +127 -0
- package/dist/learn/audit.d.ts +3 -3
- package/dist/learn/audit.js +3 -3
- package/dist/learn/commit.d.ts +8 -7
- package/dist/learn/commit.js +60 -20
- package/dist/learn/compile.d.ts +4 -3
- package/dist/learn/compile.js +7 -5
- package/dist/learn/folder.d.ts +16 -3
- package/dist/learn/folder.js +46 -13
- package/dist/learn/promote.d.ts +37 -13
- package/dist/learn/promote.js +112 -40
- package/dist/learn/secrets.d.ts +20 -10
- package/dist/learn/secrets.js +44 -176
- package/dist/learning-routes.d.ts +22 -17
- package/dist/learning-routes.js +40 -39
- package/dist/learning.js +2 -2
- package/dist/llms.txt +1 -1
- package/dist/manifest.d.ts +10 -0
- package/dist/manifest.js +30 -0
- package/dist/mcp-pin-first.d.ts +4 -2
- package/dist/mcp-pin-first.js +5 -2
- package/dist/mcp-secret-writes.d.ts +16 -7
- package/dist/mcp-secret-writes.js +35 -27
- package/dist/mcp-servers-store.d.ts +30 -6
- package/dist/mcp-servers-store.js +112 -28
- package/dist/mcp-sources.d.ts +10 -2
- package/dist/mcp-sources.js +9 -2
- package/dist/mcp-store.d.ts +13 -7
- package/dist/mcp-store.js +12 -9
- package/dist/model-form.d.ts +3 -2
- package/dist/model-form.js +11 -7
- package/dist/model.d.ts +20 -4
- package/dist/model.js +68 -9
- package/dist/native/history.d.ts +1 -1
- package/dist/native/history.js +2 -2
- package/dist/ollama-provider.d.ts +92 -0
- package/dist/ollama-provider.js +495 -0
- package/dist/openapi/agentrun-v2.openapi.json +2 -2
- package/dist/openapi.d.ts +3 -3
- package/dist/openapi.js +197 -55
- package/dist/page.d.ts +11 -3
- package/dist/page.js +22 -7
- package/dist/place-offers.d.ts +25 -1
- package/dist/place-offers.js +62 -8
- package/dist/print.js +1 -1
- package/dist/purged-workflow.d.ts +35 -7
- package/dist/purged-workflow.js +73 -26
- package/dist/redact/match.d.ts +74 -0
- package/dist/redact/match.js +771 -0
- package/dist/run-computer.d.ts +2 -0
- package/dist/run-computer.js +2 -0
- package/dist/run-files.d.ts +4 -0
- package/dist/run-files.js +4 -0
- package/dist/run-keys.d.ts +2 -4
- package/dist/run-keys.js +6 -7
- package/dist/run-launch.d.ts +4 -0
- package/dist/run-launch.js +4 -0
- package/dist/run-reads-over-store.d.ts +3 -2
- package/dist/run-reads-over-store.js +66 -2
- package/dist/run-secrets.js +5 -2
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +4 -4
- package/dist/runner/adapter-loop.d.ts +9 -3
- package/dist/runner/adapter-loop.js +34 -15
- package/dist/runner/adapter-run-spec.d.ts +3 -0
- package/dist/runner/adapter-run-spec.js +9 -4
- package/dist/runner/audit.js +8 -4
- package/dist/runner/beside.d.ts +2 -1
- package/dist/runner/beside.js +13 -5
- package/dist/runner/claim-secrets.d.ts +5 -8
- package/dist/runner/claim-secrets.js +6 -0
- package/dist/runner/cli-run-spec.d.ts +1 -1
- package/dist/runner/cli-run-spec.js +41 -7
- package/dist/runner/harness-loops.d.ts +22 -9
- package/dist/runner/harness-loops.js +21 -11
- package/dist/runner/held.d.ts +3 -0
- package/dist/runner/learning-end.d.ts +1 -1
- package/dist/runner/learning-end.js +8 -3
- package/dist/runner/loop-contract.d.ts +9 -4
- package/dist/runner/main.js +12 -6
- package/dist/runner/mcp-claim.d.ts +3 -0
- package/dist/runner/mcp-claim.js +26 -2
- package/dist/runner/mcp-run.d.ts +3 -0
- package/dist/runner/mcp-run.js +2 -1
- package/dist/runner/metrics.d.ts +10 -10
- package/dist/runner/metrics.js +19 -38
- package/dist/runner/model-route.d.ts +3 -0
- package/dist/runner/model-route.js +6 -2
- package/dist/runner/presence.d.ts +4 -3
- package/dist/runner/presence.js +4 -2
- package/dist/runner/promotion.d.ts +15 -9
- package/dist/runner/promotion.js +25 -15
- package/dist/runner/run-child-host.d.ts +2 -0
- package/dist/runner/run-child-host.js +19 -9
- package/dist/runner/run-child.js +3 -1
- package/dist/runner/runner.d.ts +4 -0
- package/dist/runner/runner.js +33 -3
- package/dist/runner/sdk-loop.js +2 -0
- package/dist/runner/workflow-loop.d.ts +2 -2
- package/dist/runner/workflow-loop.js +1 -2
- package/dist/runner/workflow-spec.d.ts +1 -1
- package/dist/runner/workflow-spec.js +6 -6
- package/dist/sdk/check.d.ts +4 -1
- package/dist/sdk/check.js +2 -1
- package/dist/sdk/runs.d.ts +2 -2
- package/dist/sdk/runs.js +8 -6
- package/dist/secret-cut.js +2 -1
- package/dist/secret-writes.d.ts +3 -2
- package/dist/secret-writes.js +1 -1
- package/dist/server.d.ts +49 -10
- package/dist/server.js +324 -118
- package/dist/standard-webhooks.d.ts +11 -0
- package/dist/standard-webhooks.js +20 -2
- package/dist/store/dialect.d.ts +3 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/postgres/dialect.js +3 -0
- package/dist/store/schema.js +5 -2
- package/dist/store/sqlite/store.js +133 -47
- package/dist/store/store.d.ts +64 -15
- package/dist/store/store.js +7 -0
- package/dist/store-reads/journal.d.ts +7 -2
- package/dist/store-reads/journal.js +9 -6
- package/dist/store-reads/learning.d.ts +12 -9
- package/dist/store-reads/learning.js +18 -24
- package/dist/store-view.d.ts +0 -5
- package/dist/store-view.js +10 -9
- package/dist/template-eval.d.ts +51 -6
- package/dist/template-eval.js +177 -53
- package/dist/template-import.js +4 -2
- package/dist/templates.d.ts +5 -3
- package/dist/templates.js +19 -40
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/labels.d.ts +2 -2
- package/dist/timeline/labels.js +2 -2
- package/dist/timeline/timeline.d.ts +14 -9
- package/dist/timeline/timeline.js +15 -7
- package/dist/tool-gate.js +3 -1
- package/dist/tool-plane.d.ts +17 -9
- package/dist/tool-plane.js +38 -17
- package/dist/tools.js +2 -2
- package/dist/trigger-launch-hook.d.ts +16 -8
- package/dist/trigger-launch-hook.js +32 -23
- package/dist/trigger-targets.d.ts +18 -8
- package/dist/trigger-targets.js +42 -19
- package/dist/triggers.d.ts +85 -23
- package/dist/triggers.js +303 -96
- package/dist/validate.js +1 -1
- package/dist/web-fake.js +3 -3
- package/dist/web-fetch-direct.d.ts +4 -0
- package/dist/web-fetch-direct.js +8 -1
- package/dist/web-fetch.d.ts +12 -3
- package/dist/web-fetch.js +47 -14
- package/dist/web-search.d.ts +33 -4
- package/dist/web-search.js +100 -41
- package/dist/webhooks.js +4 -5
- package/dist/workspace/computer-deps.d.ts +2 -1
- package/dist/workspace/computer-deps.js +5 -4
- package/dist/workspace/computer-for-claim.d.ts +8 -2
- package/dist/workspace/computer-for-claim.js +28 -9
- package/dist/workspace/computer-janitor.d.ts +15 -7
- package/dist/workspace/computer-janitor.js +33 -8
- package/dist/workspace/computer-kept.d.ts +52 -4
- package/dist/workspace/computer-kept.js +118 -6
- package/dist/workspace/run-end-computers.d.ts +5 -1
- package/dist/workspace/run-end-computers.js +27 -1
- package/dist/wrapped.d.ts +57 -0
- package/dist/wrapped.js +51 -0
- package/launcher/agentrun-serve +5 -1
- package/package.json +17 -13
- package/templates/README.md +10 -9
- package/dist/console/assets/index-B_85An2t.js +0 -745
- package/dist/console/assets/index-n1YsbnYh.css +0 -1
- package/dist/import-sources.d.ts +0 -116
- package/dist/import-sources.js +0 -693
package/dist/trigger-targets.js
CHANGED
|
@@ -9,12 +9,14 @@ import { message, startRun, WAITS_ON_A_PERSON } from "./runs-over-store.js";
|
|
|
9
9
|
import { runOfOrigin } from "./store-reads/runs.js";
|
|
10
10
|
import { NATIVE_CAP_UNSUPPORTED, NATIVE_RUN_OVERRIDES_UNSUPPORTED, nativeOf, nativeRunOverrides } from "./native/binding.js";
|
|
11
11
|
import { firingsOwe, keysOwedRefusal } from "./run-keys.js";
|
|
12
|
+
import { isObject } from "./validate.js";
|
|
12
13
|
/** Why a trigger may not message a run with no cap (server.ts NO_CAP). */
|
|
13
14
|
const NO_CAP = "The run has no spend cap: a trigger only messages a run with one, as every turn it drives is capped.";
|
|
14
|
-
/** Why a trigger may not message a run on a harness recipe billed to its vendor's plan
|
|
15
|
-
* does, on its owner's own sign-in, which runs
|
|
16
|
-
*
|
|
17
|
-
|
|
15
|
+
/** Why a trigger may not message a run on a harness recipe billed to its vendor's plan while not every key it runs on is
|
|
16
|
+
* saved for that harness (harness-keys.ts): the turn would run as that run does, on its owner's own sign-in, which runs
|
|
17
|
+
* only what a person starts (HARNESS.md#run-it); a trigger's turn runs on the saved keys alone (the claim's
|
|
18
|
+
* RECIPE_SIGN_IN_PERSON_ONLY, for a new run). */
|
|
19
|
+
export const RECIPE_MESSAGE_PERSON_ONLY = "The run is on a harness recipe billed to its vendor's plan, which runs on its owner's own sign-in only for what a person starts: a trigger's turn runs on keys saved for that harness, and not every one is saved. Save them in Settings → Harness keys, message the run yourself, or target a run on a harness billed through this server's model proxy.";
|
|
18
20
|
/** The most of a trigger's firings, newest first, read for its last completed run. */
|
|
19
21
|
const PREVIOUS_FIRINGS_READ = 20;
|
|
20
22
|
/** The most bytes of a previous run's result a triggered run is handed, as JSON: past it, it is handed none, said so. */
|
|
@@ -112,18 +114,30 @@ function carriedEntryBytes(entry) {
|
|
|
112
114
|
lines += 1;
|
|
113
115
|
return 4 + Buffer.byteLength(json) + 4 * lines;
|
|
114
116
|
}
|
|
117
|
+
/** A handed run's cap: its bound (the target's cap, else the agent's default on the revision the run starts on), which a
|
|
118
|
+
* host's own may lower and never raise; with no bound, the host's. A host's value that is no number is passed on, for
|
|
119
|
+
* the run's checks to refuse. */
|
|
120
|
+
function handedCap(bound, host) {
|
|
121
|
+
if (bound === undefined || host === undefined)
|
|
122
|
+
return bound ?? host;
|
|
123
|
+
return typeof host === "number" ? Math.min(bound, host) : host;
|
|
124
|
+
}
|
|
115
125
|
/** The trigger target policy over `store`, with its reads and the run-start leaves injected. */
|
|
116
126
|
export function triggerTargets(store, deps) {
|
|
127
|
+
/** Under the run-keys setting, the 409 for a trigger whose firings could never bring the keys its runs owe (firingsOwe):
|
|
128
|
+
* at its create or move, and again at each message_run firing, since one made before the setting was on, or while this
|
|
129
|
+
* server held the key, would open a turn with none. */
|
|
130
|
+
async function targetRefusal(target) {
|
|
131
|
+
if (!deps.keysOwed)
|
|
132
|
+
return undefined;
|
|
133
|
+
// The revision a firing would open a turn of: the run's own for a message_run, the agent's current for a start_run.
|
|
134
|
+
const row = target.kind === "message_run" ? await store.runs.get(target.run_id) : undefined;
|
|
135
|
+
const revision = target.kind === "message_run" ? (row ? await store.agents.revision(row.revisionId) : undefined) : (await deps.getAgent(target.agent_id))?.revision;
|
|
136
|
+
const owed = revision ? deps.keysOwed(revision) : [];
|
|
137
|
+
return firingsOwe(owed, target.kind, deps.hooked === true) ? keysOwedRefusal(owed) : undefined;
|
|
138
|
+
}
|
|
117
139
|
return {
|
|
118
|
-
|
|
119
|
-
if (!deps.keysOwed)
|
|
120
|
-
return undefined;
|
|
121
|
-
// The revision a firing would open a turn of: the run's own for a message_run, the agent's current for a start_run.
|
|
122
|
-
const row = target.kind === "message_run" ? await store.runs.get(target.run_id) : undefined;
|
|
123
|
-
const revision = target.kind === "message_run" ? (row ? await store.agents.revision(row.revisionId) : undefined) : (await deps.getAgent(target.agent_id))?.revision;
|
|
124
|
-
const owed = revision ? deps.keysOwed(revision) : [];
|
|
125
|
-
return firingsOwe(owed, target.kind, deps.hooked === true) ? keysOwedRefusal(owed) : undefined;
|
|
126
|
-
},
|
|
140
|
+
targetRefusal,
|
|
127
141
|
async targetIssues(target) {
|
|
128
142
|
if (target.kind === "message_run") {
|
|
129
143
|
const run = await deps.momentOf(target.run_id);
|
|
@@ -158,20 +172,26 @@ export function triggerTargets(store, deps) {
|
|
|
158
172
|
const wrong = revision ? await deps.start.explainRun(await deps.start.inputIssuesOf(revision, target.input), { input: target.input }, revision) : [];
|
|
159
173
|
return [...start, ...wrong.map((issue) => ({ ...issue, field: `target.${issue.field}` }))];
|
|
160
174
|
},
|
|
161
|
-
async start(target, given, trigger, from, title, previous) {
|
|
175
|
+
async start(target, given, trigger, from, title, previous, host) {
|
|
162
176
|
const entry = await deps.needAgent(target.agent_id);
|
|
163
177
|
// An agentic run is handed its trigger's previous result after its message (previousResultOf), so a repeat run
|
|
164
178
|
// (a weekly digest) leaves out what the last one reported. A workflow's input is its own schema's: nothing is added.
|
|
165
179
|
// `previous` is its adapter's previousResult (carriesPrevious).
|
|
166
|
-
const content = given.content;
|
|
180
|
+
const content = isObject(given) ? given.content : undefined;
|
|
167
181
|
const handed = previous && entry.revision?.kind === "agentic" && typeof content === "string" ? await previousResultOf(store, deps, trigger) : "";
|
|
168
182
|
const input = handed ? { ...given, content: `${content}${handed}` } : given;
|
|
169
|
-
// The target's cap, else the agent's default as it stands now
|
|
170
|
-
//
|
|
183
|
+
// The target's cap, else the agent's default as it stands now on the revision the run starts on, either of which a
|
|
184
|
+
// host's may lower and never raise: a run a trigger starts is never uncapped (capped), but a connected agent's,
|
|
185
|
+
// which its own CLI's limits keep and AgentRun can't cap (NATIVE_CAP_UNSUPPORTED). The effort is the target's when
|
|
186
|
+
// it sets one, else the host's, else the agent's.
|
|
171
187
|
const native = Boolean(nativeOf(entry.revision?.body));
|
|
172
|
-
const
|
|
188
|
+
const { max_cost_usd: hostCap, ...overlay } = host?.body ?? {};
|
|
189
|
+
const body = { ...overlay, ...(input !== undefined ? { input } : {}) };
|
|
190
|
+
const agentCap = target.max_cost_usd === undefined && typeof hostCap === "number" ? (await deps.start.pinnedOf(entry, body))?.revision.body?.maxCostUsd : undefined;
|
|
191
|
+
const cap = handedCap(target.max_cost_usd ?? agentCap, hostCap);
|
|
192
|
+
const run = await startRun(store, deps.start, entry, { ...body, ...(cap !== undefined ? { max_cost_usd: cap } : {}), ...(target.effort ? { effort: target.effort } : {}) },
|
|
173
193
|
// Titled from the trigger (the engine's titleOf: "<Source> <name>"), never from its input, a sender's markup.
|
|
174
|
-
{ trigger, origin: { key: trigger.firing_key }, capped: !native, from, ...(title ? { title } : {}) });
|
|
194
|
+
{ trigger, origin: { key: trigger.firing_key }, capped: !native, from, ...(title ? { title } : {}), ...(host?.sealed ? { sealed: host.sealed } : {}), ...(host?.keys ? { keys: host.keys } : {}) });
|
|
175
195
|
return { run_id: run.id };
|
|
176
196
|
},
|
|
177
197
|
async message(target, input, key, from, bound) {
|
|
@@ -190,6 +210,9 @@ export function triggerTargets(store, deps) {
|
|
|
190
210
|
throw new ApiError("not_continuable", NO_CAP);
|
|
191
211
|
if (run.waitsOnPerson)
|
|
192
212
|
return { skipped: WAITS_ON_A_PERSON };
|
|
213
|
+
const owes = await targetRefusal(target);
|
|
214
|
+
if (owes)
|
|
215
|
+
throw owes;
|
|
193
216
|
try {
|
|
194
217
|
// The firing's key is the message's id; the message answers no person (answers false), its origin the trigger's.
|
|
195
218
|
// Its command row is written with its firing marked sent, in one transaction, within the trigger's bound per run
|
package/dist/triggers.d.ts
CHANGED
|
@@ -15,7 +15,8 @@ export declare const DUE_KEPT = 20;
|
|
|
15
15
|
export declare const SOURCE_KINDS: readonly string[];
|
|
16
16
|
export declare const TARGET_KINDS: readonly ["start_run", "message_run"];
|
|
17
17
|
export declare const FIRING_STATUSES: readonly ["due", "started", "sent", "skipped", "failed", "missed"];
|
|
18
|
-
/**
|
|
18
|
+
/** The reason of a firing the launch hook's host took (a 2xx) without starting its run here under the firing (RunCreate
|
|
19
|
+
* trigger_firing). */
|
|
19
20
|
export declare const HANDED_NO_RUN = "Handed to the host by the launch hook, which started no run here for it.";
|
|
20
21
|
/** The most of a webhook's payload a firing passes on: the rest is cut, at a character's start (trigger-adapter.ts). */
|
|
21
22
|
/** How late a missed time may be and still fire once, by default: an hour. */
|
|
@@ -105,6 +106,20 @@ export type RunTrigger = {
|
|
|
105
106
|
name?: string;
|
|
106
107
|
attrs?: Record<string, string>;
|
|
107
108
|
};
|
|
109
|
+
/** A host's start of a firing the launch hook handed it (Triggers.handedStart): the firing's key, the trigger, input
|
|
110
|
+
* origin and title a start here would give the run, and the target and previous-result flag it starts on
|
|
111
|
+
* (TriggerDeps.start's, so a handed run gets its target's cap, effort and previous result as one started here does; the
|
|
112
|
+
* host may lower the cap, and its effort holds when the target sets none). */
|
|
113
|
+
export type HandedStart = {
|
|
114
|
+
key: string;
|
|
115
|
+
trigger: RunTrigger;
|
|
116
|
+
from: MessageOrigin;
|
|
117
|
+
title: string;
|
|
118
|
+
target: Extract<Target, {
|
|
119
|
+
kind: "start_run";
|
|
120
|
+
}>;
|
|
121
|
+
previous: boolean;
|
|
122
|
+
};
|
|
108
123
|
/** The engine's clock and its one timer: Date.now and setTimeout, or a test's. */
|
|
109
124
|
export type TriggerClock = {
|
|
110
125
|
now(): number;
|
|
@@ -196,6 +211,19 @@ export declare class Triggers {
|
|
|
196
211
|
/** Each trigger's firings, driven one after another in the order asked: a firing's overlap check reads what the one
|
|
197
212
|
* before it settled to. */
|
|
198
213
|
private readonly turns;
|
|
214
|
+
/** Each trigger's firings mid-hand on this server, by key, with how many hold each: drive found room for it (busy) and
|
|
215
|
+
* has not yet written what came of it (sent, started, a failed try), or a host start is writing its run and has not
|
|
216
|
+
* yet started the firing with it. Either may hold a firing the other holds (its host starts it before its hook
|
|
217
|
+
* answers), so a firing leaves only once both let go. busy counts each here, but the one it checks, once with the
|
|
218
|
+
* store's firings in progress. */
|
|
219
|
+
private readonly handing;
|
|
220
|
+
/** Each trigger's room checks on this server (drive's, a host start's), one after another: a check's hold (handing, a
|
|
221
|
+
* start_by pushed out) is in place before the next one reads, so two never both take the one place. Removed once idle. */
|
|
222
|
+
private readonly checks;
|
|
223
|
+
/** Each firing a host start on this server is writing the run of, by key: that start's run once written, or undefined
|
|
224
|
+
* when it wrote none. Another start of the firing meanwhile answers that run (handedStart), and its drive waits for it
|
|
225
|
+
* rather than handing it again. */
|
|
226
|
+
private readonly starting;
|
|
199
227
|
/** Each trigger's removals and the edits that name a target (the one way it moves to another agent), one after another
|
|
200
228
|
* on this server: a move never lands between a template update's delete of its Composio instance and its conditional
|
|
201
229
|
* delete of the row (remove), so a moved trigger never stands on an instance that delete took. Across servers the
|
|
@@ -527,6 +555,12 @@ export declare class Triggers {
|
|
|
527
555
|
* slow: the source edit lands while the target's check waits). One racing a removal writes its row while the row is
|
|
528
556
|
* there, or finds it gone (not_found): the store's update changes no row a delete took. */
|
|
529
557
|
private one;
|
|
558
|
+
/** `check` on trigger `triggerId` once every room check of it asked before has settled (checks). A check reads the store
|
|
559
|
+
* and holds what it found (hold, a start_by pushed out); it never waits on a hook or a start. */
|
|
560
|
+
private checked;
|
|
561
|
+
/** Firing `key` of `triggerId` held mid-hand (handing) until the returned release, counted: held while any of its
|
|
562
|
+
* holders has not released. A release lets go once, however often it is called. */
|
|
563
|
+
private hold;
|
|
530
564
|
/** `key`'s firing driven after every firing of its trigger asked before it. */
|
|
531
565
|
private inTurn;
|
|
532
566
|
/** Each of `triggers` turned off, with why its source no longer reads, and said. */
|
|
@@ -560,6 +594,9 @@ export declare class Triggers {
|
|
|
560
594
|
* message sent). A failed try keeps it due under the backoff table, or ends it failed. Each step reads the trigger and
|
|
561
595
|
* the firing again: either may be edited or deleted meanwhile. */
|
|
562
596
|
private drive;
|
|
597
|
+
/** A start_run firing drive found room for: its run started, or it handed to the launch hook's host, on the target as it
|
|
598
|
+
* is now (an edit during the overlap check may have made it a message, sent instead). */
|
|
599
|
+
private roomFound;
|
|
563
600
|
/** A message_run firing: its message to the target's run, under its key, queued as a command row the run takes at its
|
|
564
601
|
* next safe point, within the bound per (trigger, run): a clock's firings coalesce to one waiting message, a pushed
|
|
565
602
|
* source's or a run now's keep each, up to DUE_KEPT; past it the firing is skipped in words. A target run that is gone
|
|
@@ -573,37 +610,61 @@ export declare class Triggers {
|
|
|
573
610
|
* active), or, with max_active_runs (a pushed trigger's, with or without accept), waiting on the last run while that
|
|
574
611
|
* many of the trigger's runs have not ended: a capped trigger starts a run per firing and never skips. A trigger whose
|
|
575
612
|
* source starts a run per firing (its adapter's concurrent) is never skipped either: with no cap it starts, the server's
|
|
576
|
-
* run limit still holding through retry.
|
|
613
|
+
* run limit still holding through retry. A firing its launch hook's host took with no run yet holds the room as a run in
|
|
614
|
+
* progress until it starts or its startBy passes (the store's activeKeys and held): with a cap, a firing waits on it (on
|
|
615
|
+
* its key while the trigger has no run), and the overlap check skips for it. So does a firing mid-hand on this server
|
|
616
|
+
* (handing), other than `firing`: one whose hook has not answered yet, or whose host's start is being written. */
|
|
577
617
|
private busy;
|
|
578
618
|
/** A failed try: kept due with its next try after the backoff table's wait (an answer's own Retry-After when longer), or,
|
|
579
|
-
* past the table, failed.
|
|
580
|
-
* or a run's status that did not read, a programming
|
|
619
|
+
* past the table, failed. A try is no failure in the trigger's streak: its firing is one, once it fails, however many
|
|
620
|
+
* tries it took. A throw that is not a target's answer (a store or a run's status that did not read, a programming
|
|
621
|
+
* error) is a failed try like a busy server's. */
|
|
581
622
|
private failedTry;
|
|
582
|
-
/** A target refused the firing: a busy server's answer
|
|
583
|
-
*
|
|
623
|
+
/** A target refused the firing: a busy server's answer, or a launch hook that did not answer (a retryable HookFailed),
|
|
624
|
+
* is a failed try under the table; any other (a refusal, a hook's other answer, a thrown error) fails the firing at
|
|
625
|
+
* once. The firing counts toward the streak once it fails. */
|
|
584
626
|
private answered;
|
|
585
627
|
/** A start_run firing handed to the host by the launch hook, never started here. The run the host started for it
|
|
586
628
|
* (handedStart: under the firing's key) makes it started, as a run started here would, whatever the hook answered;
|
|
587
629
|
* else a 2xx makes it sent, with no run (its attrs kept for a run the host starts late: handedRan) and its startBy
|
|
588
|
-
* LAUNCH_HOOK_LATE_START_MS after that answer, and any other answer or none
|
|
589
|
-
* it due, so the next start hands it again under the same webhook-id (or finds the run the host started). */
|
|
630
|
+
* LAUNCH_HOOK_LATE_START_MS after that answer, and any other answer or none is a failed try (answered). The server's
|
|
631
|
+
* stop leaves it due, so the next start hands it again under the same webhook-id (or finds the run the host started). */
|
|
590
632
|
private handed;
|
|
591
|
-
/** The run the host starts through the API for a firing the launch hook handed it (RunCreate `trigger_firing`)
|
|
592
|
-
* firing's key (the run's origin key, so the firing finds it),
|
|
593
|
-
* would give the run
|
|
594
|
-
*
|
|
595
|
-
*
|
|
596
|
-
|
|
633
|
+
/** The run the host starts through the API for a firing the launch hook handed it (RunCreate `trigger_firing`),
|
|
634
|
+
* written by `start` from the firing's key (the run's origin key, so the firing finds it), the trigger, input origin
|
|
635
|
+
* and title its own start would give the run, and the target and previous-result flag it starts on (the policy's
|
|
636
|
+
* start, as drive's); then the firing started with it (handedRan). Or the run already started under that key,
|
|
637
|
+
* `replayed`. Refused, in words, unless this server has the hook and the firing, of a start_run trigger on `agentId`,
|
|
638
|
+
* may start now (startRoom). */
|
|
639
|
+
handedStart(given: unknown, agentId: string, start: (firing: HandedStart) => Promise<{
|
|
640
|
+
run_id: string;
|
|
641
|
+
}>): Promise<{
|
|
597
642
|
run_id: string;
|
|
598
|
-
|
|
599
|
-
key: string;
|
|
600
|
-
trigger: RunTrigger;
|
|
601
|
-
from: MessageOrigin;
|
|
602
|
-
title: string;
|
|
643
|
+
replayed: boolean;
|
|
603
644
|
}>;
|
|
604
|
-
/**
|
|
605
|
-
*
|
|
606
|
-
*
|
|
645
|
+
/** Firing `key`'s startBy, which a host start pushed out from `pushed.from` to `pushed.to` and then wrote no run, put
|
|
646
|
+
* back: only while it is still sent with no run at `pushed.to`. A store that does not answer leaves it pushed, a minute
|
|
647
|
+
* past that start's beginning at most. */
|
|
648
|
+
private unpush;
|
|
649
|
+
/** Firing `key` of `triggerId` held mid-hand (hold) by a host start writing its run, and in starting until `release`:
|
|
650
|
+
* `ran` gives another start of the firing meanwhile the run written. A start that wrote none arms the timer again on
|
|
651
|
+
* release, so a retry that came due while it wrote (left to it by drive and arm) is driven at once, and a later one at
|
|
652
|
+
* its time. */
|
|
653
|
+
private startHold;
|
|
654
|
+
/** Whether the host may start firing `key` of `trigger` now, read again within its trigger's room checks (checked), and
|
|
655
|
+
* what holds its room until `release`. Refused, in words, unless the firing is due (being handed over, or waiting on
|
|
656
|
+
* its retry) with room by drive's own check (busy: max_active_runs, the overlap, firings mid-hand), then held mid-hand
|
|
657
|
+
* until its run starts; or is one its host took with no run, up to its startBy (the host may answer first and start
|
|
658
|
+
* the run after), then held mid-hand the same way, however long its run takes to write. Its startBy is pushed out to
|
|
659
|
+
* at least START_WINDOW_MS from now if it is sooner, so the store holds its room too, for another server's checks.
|
|
660
|
+
* Undefined when the push was not written: the firing moved meanwhile. A start that would be refused once its run is
|
|
661
|
+
* under its key (`replay`) answers that run: another start of the firing (the host's repeat) wrote it since handedStart
|
|
662
|
+
* read none. One while another start of the firing on this server is writing its run (starting) follows that start. */
|
|
663
|
+
private startRoom;
|
|
664
|
+
/** Run `runId`, which the host started for firing `key` (handedStart), started: a firing with no run yet, still due
|
|
665
|
+
* (being handed, or waiting on its retry after the hook failed) or one its host took first, is made started here, as
|
|
666
|
+
* handed() makes it when the run came first, so the overlap check, max_active_runs and last_run_id count it. A failed
|
|
667
|
+
* or settled firing is left as it is. */
|
|
607
668
|
handedRan(triggerId: string, key: string, runId: string): Promise<void>;
|
|
608
669
|
/** Each sent firing whose host's run is in the store under its key, though the server stopped before the firing was
|
|
609
670
|
* started with it (a late start writes the run, then handedRan): started with that run, so the overlap check and
|
|
@@ -611,7 +672,8 @@ export declare class Triggers {
|
|
|
611
672
|
private relink;
|
|
612
673
|
private started;
|
|
613
674
|
/** A failed firing: one more in its trigger's streak, the trigger turned off at FAILURES_TO_PAUSE, and trigger.failed
|
|
614
|
-
* queued (after the firing is written: a start finds one not yet queued and queues it, under the same webhook-id).
|
|
675
|
+
* queued (after the firing is written: a start finds one not yet queued and queues it, under the same webhook-id).
|
|
676
|
+
* Failed only while it is due: one its host's run started meanwhile is left started, with no failure and no message. */
|
|
615
677
|
private failed;
|
|
616
678
|
/** Trigger `triggerId`, turned off by its failure streak: off at its sender too (offThere). */
|
|
617
679
|
private pausedThere;
|