@parcha/agentrun-serve 0.1.0-beta.45 → 0.1.0-beta.47
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 +180 -0
- package/NOTICE +4 -0
- package/README.md +283 -47
- package/dist/acp-package.d.ts +35 -6
- package/dist/acp-package.js +3 -3
- package/dist/adapter-facts.d.ts +5 -2
- package/dist/adapter-facts.js +6 -3
- package/dist/adapters.d.ts +7 -0
- package/dist/adapters.js +39 -0
- package/dist/agents-store.d.ts +5 -3
- package/dist/agents-store.js +13 -8
- package/dist/api-only.d.ts +7 -10
- package/dist/api-only.js +7 -10
- package/dist/archil-routes.js +2 -1
- package/dist/cap.js +12 -2
- package/dist/chatgpt-plan.js +2 -1
- package/dist/cli.js +119 -44
- package/dist/composio-made.d.ts +19 -2
- package/dist/composio-made.js +17 -5
- package/dist/composio-preset.d.ts +42 -7
- package/dist/composio-preset.js +106 -70
- package/dist/composio-triggers.d.ts +9 -4
- package/dist/composio-triggers.js +20 -13
- package/dist/computer-attach.d.ts +11 -10
- package/dist/computer-attach.js +13 -14
- package/dist/computer-commands.d.ts +3 -0
- package/dist/computer-commands.js +3 -2
- package/dist/computer-lost.d.ts +4 -0
- package/dist/computer-lost.js +8 -3
- package/dist/computer-setting.d.ts +2 -0
- package/dist/computer-setting.js +2 -0
- package/dist/computers.d.ts +9 -75
- package/dist/computers.js +20 -66
- package/dist/console/assets/index-BBFzAxLB.js +715 -0
- package/dist/console/assets/index-BRi-Rgq6.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/cost-heal.d.ts +13 -0
- package/dist/cost-heal.js +27 -0
- package/dist/dial-relay.d.ts +6 -2
- package/dist/dial-relay.js +9 -12
- package/dist/email/routes.js +2 -1
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +5 -0
- package/dist/exa-keyless.d.ts +1 -1
- package/dist/exa-keyless.js +1 -1
- package/dist/faux-computers.d.ts +2 -3
- package/dist/faux-computers.js +9 -31
- package/dist/github-connection.js +2 -1
- package/dist/harness-archive.d.ts +19 -2
- package/dist/harness-archive.js +49 -15
- package/dist/harness-check.d.ts +73 -0
- package/dist/harness-check.js +489 -0
- package/dist/harness-cursor.d.ts +45 -0
- package/dist/harness-cursor.js +121 -0
- package/dist/harness-recipe.d.ts +127 -0
- package/dist/harness-recipe.js +357 -0
- package/dist/harness-table.d.ts +12 -0
- package/dist/harness-table.js +62 -2
- package/dist/harness.d.ts +2 -0
- package/dist/harness.js +3 -2
- package/dist/host-check.d.ts +6 -0
- package/dist/host-check.js +14 -0
- package/dist/host.d.ts +10 -3
- package/dist/host.js +17 -3
- package/dist/import-sources.d.ts +2 -0
- package/dist/import-sources.js +2 -0
- package/dist/import-summary.d.ts +15 -5
- package/dist/import-summary.js +24 -8
- package/dist/import.d.ts +34 -4
- package/dist/import.js +134 -32
- package/dist/key-refusal.d.ts +1 -0
- package/dist/key-refusal.js +8 -3
- package/dist/key-words.d.ts +1 -1
- package/dist/key-words.js +4 -4
- package/dist/learn/check.d.ts +3 -0
- package/dist/learn/check.js +31 -20
- package/dist/learn/compile.js +11 -4
- package/dist/learn/promote.d.ts +77 -4
- package/dist/learn/promote.js +123 -2
- package/dist/learned-nodes.d.ts +4 -3
- package/dist/learned-workflow.js +4 -1
- package/dist/learning-cost.d.ts +6 -16
- package/dist/learning-cost.js +6 -12
- package/dist/learning-setting.d.ts +17 -6
- package/dist/learning-setting.js +41 -5
- package/dist/learning-words.d.ts +2 -0
- package/dist/learning-words.js +1 -1
- package/dist/listen-first.d.ts +10 -0
- package/dist/listen-first.js +25 -1
- package/dist/llms.txt +1 -1
- package/dist/mcp-gateway.d.ts +2 -1
- package/dist/mcp-gateway.js +31 -15
- package/dist/mcp-probe.d.ts +18 -6
- package/dist/mcp-probe.js +41 -8
- package/dist/mcp-secret-writes.d.ts +8 -0
- package/dist/mcp-secret-writes.js +104 -4
- package/dist/mcp-servers-store.d.ts +11 -5
- package/dist/mcp-servers-store.js +46 -20
- package/dist/model-form.d.ts +2 -1
- package/dist/model-form.js +22 -8
- package/dist/model-gateway.d.ts +113 -0
- package/dist/model-gateway.js +433 -0
- package/dist/model.d.ts +2 -1
- package/dist/model.js +9 -7
- package/dist/monid.js +1 -1
- package/dist/native/binding.d.ts +4 -0
- package/dist/native/binding.js +9 -0
- package/dist/native/cli.d.ts +3 -2
- package/dist/native/cli.js +6 -5
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +326 -41
- package/dist/owner.d.ts +4 -2
- package/dist/owner.js +10 -4
- package/dist/page.d.ts +8 -0
- package/dist/page.js +9 -1
- package/dist/port-models.js +17 -10
- package/dist/provider.d.ts +3 -3
- package/dist/provider.js +12 -3
- package/dist/public-address.d.ts +28 -0
- package/dist/public-address.js +62 -0
- package/dist/run-launch.d.ts +1 -1
- package/dist/run-launch.js +1 -1
- package/dist/run-secrets.d.ts +3 -2
- package/dist/run-secrets.js +6 -4
- package/dist/runner/adapter-loop.d.ts +10 -7
- package/dist/runner/adapter-loop.js +57 -22
- package/dist/runner/adapter-run-spec.d.ts +12 -0
- package/dist/runner/adapter-run-spec.js +40 -6
- package/dist/runner/adapters/index.js +16 -0
- package/dist/runner/adapters/pi.d.ts +5 -2
- package/dist/runner/adapters/pi.js +7 -4
- package/dist/runner/audit.d.ts +7 -0
- package/dist/runner/audit.js +24 -6
- package/dist/runner/claim-secrets.js +5 -1
- package/dist/runner/cli-run-spec.js +15 -7
- package/dist/runner/compare-end.d.ts +43 -0
- package/dist/runner/compare-end.js +95 -0
- package/dist/runner/computer-journal.d.ts +3 -0
- package/dist/runner/computer-journal.js +22 -2
- package/dist/runner/conformance/harness.js +19 -8
- package/dist/runner/conformance/subject.d.ts +6 -0
- package/dist/runner/harness-loops.d.ts +6 -1
- package/dist/runner/harness-loops.js +94 -54
- package/dist/runner/held.d.ts +5 -4
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +3 -0
- package/dist/runner/loop-contract.d.ts +10 -0
- package/dist/runner/main.d.ts +5 -5
- package/dist/runner/main.js +81 -11
- package/dist/runner/mcp-claim.js +40 -12
- package/dist/runner/metrics.d.ts +26 -0
- package/dist/runner/metrics.js +44 -1
- package/dist/runner/presence.d.ts +41 -0
- package/dist/runner/presence.js +89 -0
- package/dist/runner/promotion.d.ts +10 -3
- package/dist/runner/promotion.js +42 -21
- package/dist/runner/run-child-host.js +52 -14
- package/dist/runner/runner.d.ts +5 -0
- package/dist/runner/runner.js +8 -0
- package/dist/runner/store-port.d.ts +3 -0
- package/dist/runner/store-secrets.js +19 -7
- package/dist/runner/workflow-first.d.ts +5 -2
- package/dist/runner/workflow-first.js +6 -3
- package/dist/runs-over-store.d.ts +6 -2
- package/dist/runs-over-store.js +14 -4
- package/dist/sdk/runs.d.ts +1 -1
- package/dist/sdk/runs.js +6 -1
- package/dist/sdk/schema.js +1 -1
- package/dist/secret-writes.d.ts +16 -3
- package/dist/secret-writes.js +28 -3
- package/dist/server-secrets-store.js +5 -0
- package/dist/server.d.ts +31 -2
- package/dist/server.js +326 -53
- package/dist/sign-ins-secrets.js +4 -1
- package/dist/skills/agentrun-serve/SKILL.md +11 -0
- package/dist/slack-url.d.ts +5 -0
- package/dist/slack-url.js +11 -0
- package/dist/slack.d.ts +107 -0
- package/dist/slack.js +292 -0
- package/dist/start-switches.d.ts +28 -0
- package/dist/start-switches.js +37 -0
- package/dist/stats.d.ts +1 -1
- package/dist/stats.js +2 -1
- package/dist/stop-signals.d.ts +11 -0
- package/dist/stop-signals.js +22 -0
- package/dist/store/agent-body.d.ts +1 -1
- package/dist/store/agent-body.js +2 -2
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +1 -1
- package/dist/store/postgres/migrations/0020_runners.sql +18 -0
- package/dist/store/postgres/store.d.ts +1 -1
- package/dist/store/postgres/store.js +4 -2
- package/dist/store/schema.d.ts +13 -5
- package/dist/store/schema.js +20 -11
- package/dist/store/seal.d.ts +16 -4
- package/dist/store/sqlite/store.d.ts +1 -1
- package/dist/store/sqlite/store.js +106 -27
- package/dist/store/store.d.ts +75 -23
- package/dist/store/store.js +11 -0
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +7 -0
- package/dist/store-reads/cap.js +11 -1
- package/dist/store-reads/journal.js +27 -1
- package/dist/store-reads/learning.d.ts +23 -2
- package/dist/store-reads/learning.js +29 -8
- package/dist/store-reads/runs.d.ts +9 -0
- package/dist/store-reads/runs.js +19 -6
- package/dist/store-reads/stats.d.ts +4 -1
- package/dist/store-reads/stats.js +15 -6
- package/dist/store-view.d.ts +123 -14
- package/dist/store-view.js +154 -21
- package/dist/telemetry.d.ts +7 -7
- package/dist/telemetry.js +38 -15
- package/dist/templates.d.ts +6 -3
- package/dist/templates.js +38 -3
- package/dist/timeline/timeline.js +18 -0
- package/dist/tool-keys-store.js +2 -2
- package/dist/tool-keys.js +2 -1
- package/dist/tool-plane.js +2 -2
- package/dist/trigger-adapter.d.ts +3 -4
- package/dist/trigger-adapter.js +2 -2
- package/dist/trigger-composio.js +3 -3
- package/dist/trigger-email.js +0 -2
- package/dist/trigger-feed.js +0 -2
- package/dist/trigger-schedule.js +3 -0
- package/dist/trigger-secrets-shown.d.ts +6 -3
- package/dist/trigger-secrets-shown.js +22 -13
- package/dist/trigger-targets.d.ts +1 -1
- package/dist/trigger-targets.js +19 -8
- package/dist/triggers.d.ts +7 -3
- package/dist/triggers.js +2 -1
- package/dist/webhooks.d.ts +85 -9
- package/dist/webhooks.js +129 -46
- package/dist/wires.d.ts +6 -1
- package/dist/wires.js +5 -0
- package/dist/workspace/attach.d.ts +3 -2
- package/dist/workspace/attach.js +2 -1
- package/dist/workspace/attached-computers.d.ts +6 -8
- package/dist/workspace/attached-computers.js +27 -24
- package/dist/workspace/computer-deps.d.ts +2 -3
- package/dist/workspace/computer-deps.js +3 -6
- package/dist/workspace/computer-for-claim.js +72 -96
- package/dist/workspace/computer-kept.d.ts +0 -7
- package/dist/workspace/computer-kept.js +0 -17
- package/dist/workspace/resolve-computer.d.ts +18 -14
- package/dist/workspace/resolve-computer.js +47 -60
- package/dist/workspace/synced-folder.d.ts +20 -15
- package/dist/workspace/synced-folder.js +33 -43
- package/launcher/agentrun-serve +4 -1
- package/package.json +10 -10
- package/skills/agentrun-serve/SKILL.md +11 -0
- package/templates/README.md +1 -1
- package/templates/inbound-lead/agent.md +2 -1
- package/templates/kyb/agent.md +2 -1
- package/dist/console/assets/index-3O2Yl6hZ.js +0 -701
- package/dist/console/assets/index-DaFsZuzQ.css +0 -1
package/dist/templates.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { type PinValue } from "./tool-gate.js";
|
|
|
6
6
|
import { type BashPolicy } from "./bash-read-only.js";
|
|
7
7
|
import { type Json } from "./validate.js";
|
|
8
8
|
import { type Approvals } from "./approvals.js";
|
|
9
|
+
import { type LearningSetting } from "./learning-setting.js";
|
|
9
10
|
/** The packages this server ships. */
|
|
10
11
|
/** What applying a template reads of the server beyond its package (server.ts wires it): the GitHub connection, the
|
|
11
12
|
* App's id, slug and installations (github-connection.ts), never a secret; undefined when GitHub is not connected. */
|
|
@@ -139,7 +140,9 @@ export type Package = {
|
|
|
139
140
|
budget?: {
|
|
140
141
|
per_run_usd: number;
|
|
141
142
|
};
|
|
142
|
-
learning
|
|
143
|
+
/** The agent's `learning`, as a definition takes it: true, false, or the loop's settings (agree_on, each path a required
|
|
144
|
+
* field of the output schema). */
|
|
145
|
+
learning?: LearningSetting;
|
|
143
146
|
/** Whether the agent asks its person before a tool runs (`ask`) or runs unattended (`never`): the package's default,
|
|
144
147
|
* shown to the owner at apply. A template whose job runs on triggers says never. Deny and pins hold either way. */
|
|
145
148
|
approvals?: "ask" | "never";
|
|
@@ -289,7 +292,7 @@ export declare function packageView(p: Package): {
|
|
|
289
292
|
budget: {
|
|
290
293
|
per_run_usd: number;
|
|
291
294
|
} | null;
|
|
292
|
-
learning:
|
|
295
|
+
learning: LearningSetting;
|
|
293
296
|
approvals_default: "ask" | "never";
|
|
294
297
|
triggers: Json[];
|
|
295
298
|
skills: string[];
|
|
@@ -362,7 +365,7 @@ export declare function packageDetail(p: Package): {
|
|
|
362
365
|
budget: {
|
|
363
366
|
per_run_usd: number;
|
|
364
367
|
} | null;
|
|
365
|
-
learning:
|
|
368
|
+
learning: LearningSetting;
|
|
366
369
|
approvals_default: "ask" | "never";
|
|
367
370
|
triggers: Json[];
|
|
368
371
|
skills: string[];
|
package/dist/templates.js
CHANGED
|
@@ -29,6 +29,7 @@ import { definitionBodyIssues, inputIssues, inputSchemaOf, isObject, MODEL_REF,
|
|
|
29
29
|
import { schemaCheck } from "./answer-json.js";
|
|
30
30
|
import { webFixtureOf } from "./web-fake.js";
|
|
31
31
|
import { APPROVALS } from "./approvals.js";
|
|
32
|
+
import { agreeOnOf, learningSettingIssue, learningSettingOf, pathSegments } from "./learning-setting.js";
|
|
32
33
|
export const TEMPLATES_DIR = fileURLToPath(new URL("../templates/", import.meta.url));
|
|
33
34
|
export const MANIFEST = "agent.md";
|
|
34
35
|
/** A package's model tier, mapped to the server's own (model.ts Tier: AGENT_MODEL_FAST, AGENT_MODEL, AGENT_MODEL_STRONG). */
|
|
@@ -152,6 +153,26 @@ export class PackageError extends Error {
|
|
|
152
153
|
this.problems = problems;
|
|
153
154
|
}
|
|
154
155
|
}
|
|
156
|
+
/** Why an agree_on path is not a required field of the answer's JSON Schema at every level, in words; undefined when it
|
|
157
|
+
* is (each segment a property of an object schema's `properties`, named in its `required`, and each parent typed
|
|
158
|
+
* `object` alone: one that may be null or another type holds no path, even on two identical answers). */
|
|
159
|
+
function undeclaredPath(schema, path) {
|
|
160
|
+
let node = schema;
|
|
161
|
+
const segments = pathSegments(path);
|
|
162
|
+
for (const [i, segment] of segments.entries()) {
|
|
163
|
+
const of = i ? segments.slice(0, i).join(".") : "the answer";
|
|
164
|
+
if (!(isObject(node) && node.type === "object"))
|
|
165
|
+
return `does not make ${of} an object only: an answer may give it as null or another type, and a path through it never resolves`;
|
|
166
|
+
const properties = isObject(node) && isObject(node.properties) ? node.properties : undefined;
|
|
167
|
+
if (!properties || !Object.hasOwn(properties, segment))
|
|
168
|
+
return `does not declare: ${segment} is no property of ${of}`;
|
|
169
|
+
const required = node.required;
|
|
170
|
+
if (!(Array.isArray(required) && required.includes(segment)))
|
|
171
|
+
return `does not require: an answer may leave ${segment} out of ${of}, and a path missing on both sides never agrees`;
|
|
172
|
+
node = properties[segment];
|
|
173
|
+
}
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
155
176
|
/** The source kinds whose accept rules a parameter may fill: a github trigger's, a webhook trigger's (a provider that
|
|
156
177
|
* sends every trigger of a project to one URL is filtered to the owner's own repository by them), a composio
|
|
157
178
|
* trigger's, and a feed trigger's (the pull requests of one author, say). */
|
|
@@ -674,8 +695,9 @@ export function readPackage(from, { evalFixtures = true } = {}) {
|
|
|
674
695
|
const perRun = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
675
696
|
if (f.budget !== undefined && !(isObject(f.budget) && !unknownFields(f.budget, ["per_run_usd"]).length && perRun(f.budget.per_run_usd)))
|
|
676
697
|
bad(MANIFEST, "budget is {per_run_usd: a number above 0}");
|
|
677
|
-
|
|
678
|
-
|
|
698
|
+
const learningIssue = f.learning === undefined ? undefined : learningSettingIssue(f.learning, "learning");
|
|
699
|
+
if (learningIssue)
|
|
700
|
+
bad(MANIFEST, learningIssue);
|
|
679
701
|
if (f.approvals !== undefined && f.approvals !== "ask" && f.approvals !== "never")
|
|
680
702
|
bad(MANIFEST, "approvals is ask (the agent asks its person before a tool runs) or never (it runs unattended; deny and pins still hold)");
|
|
681
703
|
const triggers = f.triggers === undefined ? [] : Array.isArray(f.triggers) ? f.triggers : (bad(MANIFEST, "triggers is a list of POST /v2/triggers bodies"), []);
|
|
@@ -731,6 +753,19 @@ export function readPackage(from, { evalFixtures = true } = {}) {
|
|
|
731
753
|
}
|
|
732
754
|
}
|
|
733
755
|
}
|
|
756
|
+
// Each agree_on path is a required field of the answer's schema at every level: one an answer may leave out is
|
|
757
|
+
// missing on both sides, and a missing path never agrees, so the check could never promote on it.
|
|
758
|
+
// With no output schema there is nothing to check the paths against, and nothing makes an answer hold them: refused.
|
|
759
|
+
if (!learningIssue && f.output === undefined && (agreeOnOf(f.learning) ?? []).length) {
|
|
760
|
+
bad(MANIFEST, "learning.agree_on names fields of the answer, so the package declares the answer's schema (output: {schema}) that holds them");
|
|
761
|
+
}
|
|
762
|
+
if (!learningIssue && isObject(outputSchema)) {
|
|
763
|
+
for (const [i, path] of (agreeOnOf(f.learning) ?? []).entries()) {
|
|
764
|
+
const why = undeclaredPath(outputSchema, path);
|
|
765
|
+
if (why)
|
|
766
|
+
bad(MANIFEST, `learning.agree_on[${i}] is ${path}, which ${f.output.schema} ${why}`);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
734
769
|
const instructions = manifest?.body.trim() ?? "";
|
|
735
770
|
if (manifest && !instructions)
|
|
736
771
|
bad(MANIFEST, "its body is empty: the body is the agent's instructions");
|
|
@@ -904,7 +939,7 @@ export function readPackage(from, { evalFixtures = true } = {}) {
|
|
|
904
939
|
...(typeof f.license === "string" ? { license: f.license } : {}), ...(isObject(f.author) ? { author: f.author } : {}), ...(typeof f.repository === "string" ? { repository: f.repository } : {}),
|
|
905
940
|
...(typeof f.category === "string" ? { category: f.category } : {}), tags,
|
|
906
941
|
...(harness ? { harness } : {}), ...(isObject(f.model) ? { model: { ...f.model, ...(choices ? { choices } : {}) } } : {}), ...(typeof f.effort === "string" ? { effort: f.effort } : {}),
|
|
907
|
-
...(tools ? { tools } : {}), mcp, ...(computer ? { computer } : {}), ...(toolPolicy ? { toolPolicy } : {}), ...(f.checkout === "pull_request" ? { checkout: "pull_request" } : {}), parameters, ...(inputSchema ? { inputSchema } : {}), secrets, ...(isObject(f.budget) ? { budget: { per_run_usd: f.budget.per_run_usd } } : {}), ...(
|
|
942
|
+
...(tools ? { tools } : {}), mcp, ...(computer ? { computer } : {}), ...(toolPolicy ? { toolPolicy } : {}), ...(f.checkout === "pull_request" ? { checkout: "pull_request" } : {}), parameters, ...(inputSchema ? { inputSchema } : {}), secrets, ...(isObject(f.budget) ? { budget: { per_run_usd: f.budget.per_run_usd } } : {}), ...(f.learning !== undefined ? { learning: learningSettingOf(f.learning) } : {}), ...(f.approvals === "ask" || f.approvals === "never" ? { approvals: f.approvals } : {}),
|
|
908
943
|
triggers: triggers, ...(isObject(f.output) ? { output: { schema: f.output.schema } } : {}), ...(isObject(outputSchema) ? { outputSchema } : {}), instructions, skills, evals,
|
|
909
944
|
};
|
|
910
945
|
// What an apply makes, made here with each parameter's default, else a sample of its type, and checked as POST
|
|
@@ -241,6 +241,8 @@ function createMeter() {
|
|
|
241
241
|
// cost, or with an end when aborted.
|
|
242
242
|
let compactions = 0;
|
|
243
243
|
let compacting = 0;
|
|
244
|
+
// Compaction summaries a host marked as side requests since pi's last pi.compaction entry: that entry is theirs.
|
|
245
|
+
let sideSummaries = 0;
|
|
244
246
|
// How many are in flight: two side requests (a turn's parallel searches) may be.
|
|
245
247
|
let sidesOpen = 0;
|
|
246
248
|
const tokens = { input: 0, cacheRead: 0, cacheWrite: 0, output: 0 };
|
|
@@ -276,9 +278,25 @@ function createMeter() {
|
|
|
276
278
|
continued -= 1;
|
|
277
279
|
return "continued";
|
|
278
280
|
}
|
|
281
|
+
else if (entry.kind === "pi.compaction") {
|
|
282
|
+
// pi's summary of the older context. A summary request that left through the run's own model port was marked as a
|
|
283
|
+
// generation is (no `request` label) and booked at its price, and pi stores no answer for it: its cost rides on the
|
|
284
|
+
// answer pi stores beside it (what the session booked since the last one), so this entry is that request's answer,
|
|
285
|
+
// at no cost of its own here, its tokens unknown to pi's entries. One a host marked as a side request is closed by
|
|
286
|
+
// its own cost entry, never here. Shown as its phase row all the same.
|
|
287
|
+
if (sideSummaries > 0)
|
|
288
|
+
sideSummaries = 0;
|
|
289
|
+
else if (marked - answered - freeUnanswered - atMostUnanswered - (freeEnded ? 1 : 0) - (atMostEnded !== undefined ? 1 : 0) > 0) {
|
|
290
|
+
(requests += 1), (answered += 1);
|
|
291
|
+
addTokens(undefined);
|
|
292
|
+
}
|
|
293
|
+
return undefined;
|
|
294
|
+
}
|
|
279
295
|
else if (entry.kind === REQUEST_STARTED && isSide(entry)) {
|
|
280
296
|
compacting += 1;
|
|
281
297
|
sidesOpen += 1;
|
|
298
|
+
if (obj(entry.data)?.request === COMPACTION)
|
|
299
|
+
sideSummaries += 1;
|
|
282
300
|
}
|
|
283
301
|
else if (entry.kind === REQUEST_ENDED && isSide(entry)) {
|
|
284
302
|
if (unsent(entry))
|
package/dist/tool-keys-store.js
CHANGED
|
@@ -35,8 +35,8 @@ const fingerprint = (key) => createHmac("sha256", key).update("agentrun-serve se
|
|
|
35
35
|
/** What the start's log line says to a person when saved keys do not open, by why: where they are kept is the server's
|
|
36
36
|
* store (`kept=store`), and what to do is to save them again in the console's Settings. */
|
|
37
37
|
export const REENTER_SAID = {
|
|
38
|
-
seal_key_changed: "these saved keys were sealed under another seal key, so they do not open: save them again in Settings →
|
|
39
|
-
file_unreadable: "these saved keys do not read: save them again in Settings →
|
|
38
|
+
seal_key_changed: "these saved keys were sealed under another seal key, so they do not open: save them again in Settings → API Keys",
|
|
39
|
+
file_unreadable: "these saved keys do not read: save them again in Settings → API Keys",
|
|
40
40
|
};
|
|
41
41
|
/** The saved tool keys over the store. `toolKeysOverStore` builds it; the server awaits load() once before the first read. */
|
|
42
42
|
class ToolKeysOverStore {
|
package/dist/tool-keys.js
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
import { HARNESSES } from "./harness.js";
|
|
7
7
|
import { MODEL_KEYS } from "./model.js";
|
|
8
8
|
import { TOOL_KEY_ROWS } from "./key-words.js";
|
|
9
|
-
import { registerSecretWrite, secretMeta, secretName } from "./secret-writes.js";
|
|
9
|
+
import { registerSecretPage, registerSecretWrite, secretMeta, secretName } from "./secret-writes.js";
|
|
10
10
|
// Every value a person saves here is a secret (a tool's key, a model provider's key; BROWSERBASE_PROJECT_ID is kept the
|
|
11
11
|
// same way): saving one, replacing it or removing it takes the owner's session (secret-writes.ts), never the token.
|
|
12
12
|
registerSecretWrite("saveToolKey", () => true);
|
|
13
13
|
registerSecretWrite("deleteToolKey", () => true);
|
|
14
|
+
registerSecretPage(["saveToolKey", "deleteToolKey"], "/#/settings/keys");
|
|
14
15
|
export const SEAL_KEY_ENV = "AGENTRUN_SEAL_KEY";
|
|
15
16
|
/** Each key a person may save, fixed here: its kind, the fields it is entered as (BROWSERBASE_PROJECT_ID is no secret,
|
|
16
17
|
* and is kept the same way), and what it may unlock: tools by name, and `decisions.<id>`, a workflow's decision
|
package/dist/tool-plane.js
CHANGED
|
@@ -26,7 +26,7 @@ import { decisionKeysOf, PARALLEL_KEY_ENV } from "./decisions.js";
|
|
|
26
26
|
import { keyNeeded } from "./key-words.js";
|
|
27
27
|
import { DEFAULT_HARNESS, HARNESSES } from "./harness.js";
|
|
28
28
|
import { builtinHarness, harnessOf } from "./harness-table.js";
|
|
29
|
-
import { viaOpenRouter,
|
|
29
|
+
import { viaOpenRouter, wireOf } from "./provider.js";
|
|
30
30
|
import { savedIn } from "./secrets.js";
|
|
31
31
|
import { hostModel } from "./model.js";
|
|
32
32
|
import { NEEDS_A_COMPUTER, NO_SHELL } from "@parcha/agentrun-kernel/kernel";
|
|
@@ -170,7 +170,7 @@ function noNative(input) {
|
|
|
170
170
|
return { id: `${input.harness}, whose model requests carry no provider-hosted tool`, why: `${facts.label}'s model requests carry no provider-hosted tool` };
|
|
171
171
|
if (input.openRouter)
|
|
172
172
|
return { id: `${input.harness} on OpenRouter`, why: `through OpenRouter ${facts.label}'s own search is not run, and its searches are not counted to price` };
|
|
173
|
-
if (input.gateway &&
|
|
173
|
+
if (input.gateway && wireOf(facts.wire)?.gateway)
|
|
174
174
|
return { id: `${input.harness} behind a gateway`, why: `behind a gateway ${facts.label} has no own search` };
|
|
175
175
|
return input.capped ? cappedOwn(input.harness, facts.label, facts.webSearch) : undefined;
|
|
176
176
|
}
|
|
@@ -2,7 +2,7 @@ import type { InputIssue } from "./errors.js";
|
|
|
2
2
|
import type { SettingsSpec } from "./sealed-settings-store.js";
|
|
3
3
|
type Json = Record<string, unknown>;
|
|
4
4
|
/** Whether a run `adapter`'s firing starts is handed its trigger's last completed result: the one place it is decided
|
|
5
|
-
* (its previousResult, by default
|
|
5
|
+
* (its previousResult, by default false: a source opts in). */
|
|
6
6
|
export declare const carriesPrevious: (adapter: Pick<TriggerAdapter, "previousResult">) => boolean;
|
|
7
7
|
/** The most of a firing's payload passed on, in bytes of UTF-8 (triggers.ts cuts past it, at a character's start). A
|
|
8
8
|
* source that answers JSON fits its payload within it first (trigger-email.ts), so its JSON is never cut. */
|
|
@@ -28,9 +28,8 @@ export type TriggerAdapter = {
|
|
|
28
28
|
/** `clock`: it fires on its own times, read by the engine's timer (a source that polls, on each). `push`: a request delivered to the server fires it,
|
|
29
29
|
* keyed by the sender's own id, which a retry repeats. */
|
|
30
30
|
delivery: "clock" | "push";
|
|
31
|
-
/** Whether a run it starts is handed its trigger's last completed result (
|
|
32
|
-
*
|
|
33
|
-
* different person's (an email's sender), so one run's answer is never handed to the next. */
|
|
31
|
+
/** Whether a run it starts is handed its trigger's last completed result (previousResultOf). Default false. true only
|
|
32
|
+
* for a source whose runs repeat one job, never for one whose firings are different events. */
|
|
34
33
|
previousResult?: boolean;
|
|
35
34
|
/** Whether its words are its owner's (a run's message origin `owner`): true only when the owner wrote them as they set
|
|
36
35
|
* it up; never for words that come from outside. */
|
package/dist/trigger-adapter.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { unknownFields } from "./validate.js";
|
|
2
2
|
/** Whether a run `adapter`'s firing starts is handed its trigger's last completed result: the one place it is decided
|
|
3
|
-
* (its previousResult, by default
|
|
4
|
-
export const carriesPrevious = (adapter) => adapter.previousResult ??
|
|
3
|
+
* (its previousResult, by default false: a source opts in). */
|
|
4
|
+
export const carriesPrevious = (adapter) => adapter.previousResult ?? false;
|
|
5
5
|
/** The most of a firing's payload passed on, in bytes of UTF-8 (triggers.ts cuts past it, at a character's start). A
|
|
6
6
|
* source that answers JSON fits its payload within it first (trigger-email.ts), so its JSON is never cut. */
|
|
7
7
|
export const PAYLOAD_KEPT_BYTES = 16 * 1024;
|
package/dist/trigger-composio.js
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
// that scope. Every event of the project comes to that one route, checked once with the secret (trigger-signatures.ts's
|
|
7
7
|
// composio scheme); each trigger whose instance is the delivery's metadata.trigger_id and whose `accept` takes it fires,
|
|
8
8
|
// each its own run. This is the one way Composio's events start runs: a webhook trigger takes no composio signature.
|
|
9
|
-
// A config can hold a credential
|
|
10
|
-
//
|
|
11
|
-
//
|
|
9
|
+
// A config can hold a credential. Composio's trigger schemas mark no field secret (their `config` is a plain JSON
|
|
10
|
+
// schema: type, title, description, required), so a field is sealed by its name (sealedConfigFields), or as an address
|
|
11
|
+
// carrying a credential (credentialUrl): kept in this source's sealed settings, the trigger keeping SEALED_MASK in its
|
|
12
12
|
// place and the field named in `sealed_config`, so no answer, row or log holds it (composio-triggers.ts).
|
|
13
13
|
import { ACCEPT_SCHEMA, acceptOf, acceptRefusal } from "./trigger-accept.js";
|
|
14
14
|
import { closedSchema, unknownSourceFields } from "./trigger-adapter.js";
|
package/dist/trigger-email.js
CHANGED
|
@@ -138,8 +138,6 @@ export const email = {
|
|
|
138
138
|
label: "email trigger",
|
|
139
139
|
delivery: "clock",
|
|
140
140
|
owner: false,
|
|
141
|
-
// Each message is its sender's: one run's answer (to alice) is never handed to the next (bob's).
|
|
142
|
-
previousResult: false,
|
|
143
141
|
settings: { scope: "trigger", fields: { [CURSOR]: { public: true }, [LAST_CHECK]: { public: true } } },
|
|
144
142
|
describe: `{kind: "email", account?: "${DEFAULT_ACCOUNT}", mailbox?: "INBOX", every_s?: ${MIN_EVERY_S}, accept?: [{event: "${EVENT}", where?}]}`,
|
|
145
143
|
fires: "each new message in the server's email account's mailbox (`email`), read every every_s seconds, that its `accept` takes",
|
package/dist/trigger-feed.js
CHANGED
|
@@ -375,8 +375,6 @@ export const feed = {
|
|
|
375
375
|
label: "feed trigger",
|
|
376
376
|
delivery: "clock",
|
|
377
377
|
owner: false,
|
|
378
|
-
// Each item is its own: one run's answer is never handed to the next.
|
|
379
|
-
previousResult: false,
|
|
380
378
|
settings: { scope: "trigger", fields: { [CURSOR]: { public: true }, [LAST_CHECK]: { public: true } } },
|
|
381
379
|
describe: `{kind: "feed", urls: ["https://..."], every_s?: ${DEFAULT_EVERY_S}, items?: "/data/items", id?: "/id", updated?: "/updated_at", fields?: ["/number", "/title"], accept?: [{event: "${EVENT}", where?}]}`,
|
|
382
380
|
fires: "each new or updated item in its feeds (`feed`: RSS, Atom, JSON Feed or a JSON list), read every every_s seconds, that its `accept` takes",
|
package/dist/trigger-schedule.js
CHANGED
|
@@ -40,6 +40,9 @@ export const schedule = {
|
|
|
40
40
|
label: "schedule",
|
|
41
41
|
delivery: "clock",
|
|
42
42
|
owner: true,
|
|
43
|
+
// Its runs repeat one job (a weekly digest): each is handed its trigger's last completed result, to leave out what
|
|
44
|
+
// that one reported.
|
|
45
|
+
previousResult: true,
|
|
43
46
|
describe: '{kind: "schedule", cron, timezone}, {kind: "schedule", at}, {kind: "schedule", every_s, start_at?}',
|
|
44
47
|
fires: `a cron line in a zone, one time, every N seconds (${MIN_EVERY_S} or more)`,
|
|
45
48
|
schemas: SCHEMAS,
|
|
@@ -2,9 +2,9 @@ import { type SecretMeta } from "./secret-writes.js";
|
|
|
2
2
|
import type { TriggerAdapter } from "./trigger-adapter.js";
|
|
3
3
|
/** What the token's answer says of a webhook trigger's secret, made and kept but not shown to it. */
|
|
4
4
|
export declare const TRIGGER_SECRET_WORDS = "Open the console to see this trigger's signing secret once: rotate it there.";
|
|
5
|
-
/** What the token's answer says of the outbound webhook's secret: the console
|
|
6
|
-
*
|
|
7
|
-
export declare const WEBHOOK_SECRET_WORDS = "Open the console to
|
|
5
|
+
/** What the token's answer says of the outbound webhook's secret: the console's Rotate secret makes a new one and shows it
|
|
6
|
+
* once. */
|
|
7
|
+
export declare const WEBHOOK_SECRET_WORDS = "Open Settings \u2192 Webhook in the console to rotate this webhook's signing secret and see the new one once.";
|
|
8
8
|
/** A webhook trigger's minted secret's metadata, named trigger:<id>: made by this server at a console's or a script's
|
|
9
9
|
* request (source console). `changedAt`: when it was made, where known (its create's or rotation's answer); its row
|
|
10
10
|
* keeps no time yet, so a read says null. */
|
|
@@ -31,6 +31,9 @@ export declare const webhookSecretMeta: (set: boolean, changedAt: string | null)
|
|
|
31
31
|
/** PUT /settings/webhook's answer: the minted value (the first save's) as `signing_secret` to a caller that may hold it,
|
|
32
32
|
* else the words. `view` carries the `secret` metadata already. */
|
|
33
33
|
export declare function webhookSaved(view: Record<string, unknown>, minted: string | undefined, mayHold: boolean): Record<string, unknown>;
|
|
34
|
+
/** POST /settings/webhook/secret's answer (the owner's session alone reaches it): the webhook as a read answers it, its
|
|
35
|
+
* `secret` metadata the new secret's, and the new value as `signing_secret`, this once. */
|
|
36
|
+
export declare const webhookRotated: (view: Record<string, unknown>, minted: string) => Record<string, unknown>;
|
|
34
37
|
/** What a trigger's view says of a secret its sealed settings keep but that does not open here (sealed under another seal
|
|
35
38
|
* key): unset, and why. */
|
|
36
39
|
export declare const TRIGGER_SECRET_UNOPENED = "Its signing secret does not open under this server's seal key: rotate it in the console.";
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
// Who sees a signing secret this server mints: a webhook trigger's (POST /triggers, POST /triggers/{id}/secret) and the
|
|
2
|
-
// outbound webhook's (the first PUT /settings/webhook). Each is shown once, as
|
|
3
|
-
// may write secrets (secret-writes.ts, the owner's signed-in session): the
|
|
4
|
-
// screens. The API token, which a run's process, an agent's MCP client or a
|
|
5
|
-
// secret's metadata (`secret`, the one SecretMeta shape) and the words that
|
|
6
|
-
//
|
|
7
|
-
// the
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
//
|
|
2
|
+
// outbound webhook's (the first PUT /settings/webhook, POST /settings/webhook/secret). Each is shown once, as
|
|
3
|
+
// `signing_secret`, and only to a caller that may write secrets (secret-writes.ts, the owner's signed-in session): the
|
|
4
|
+
// console's Triggers and Settings → Webhook screens. The API token, which a run's process, an agent's MCP client or a
|
|
5
|
+
// script may hold, gets what it made with the secret's metadata (`secret`, the one SecretMeta shape) and the words that
|
|
6
|
+
// send the person to the console for it.
|
|
7
|
+
// Rotating a trigger's secret, or the outbound webhook's, is a secret write: the token is refused it in the secret-write
|
|
8
|
+
// words, at the one check in the server's dispatch.
|
|
9
|
+
import { registerSecretPage, registerSecretWrite, secretMeta, secretName } from "./secret-writes.js";
|
|
10
|
+
// Replacing a trigger's secret or the outbound webhook's, and removing the outbound webhook (its secret goes with it), are
|
|
11
|
+
// secret writes. A trigger's create and the outbound webhook's first save mint one and write none the caller gave: the
|
|
12
|
+
// token may make them, and is shown no value.
|
|
12
13
|
registerSecretWrite("rotateTriggerSecret", () => true);
|
|
14
|
+
registerSecretWrite("rotateWebhookSecret", () => true);
|
|
13
15
|
registerSecretWrite("deleteWebhook", () => true);
|
|
16
|
+
// Where the owner finishes each in the console: the trigger's own page (Rotate), and Settings → Webhook (Rotate secret,
|
|
17
|
+
// Remove). The webhook's URL is never in a link: it can be a credential itself (webhooks.ts shownUrl).
|
|
18
|
+
registerSecretPage("rotateTriggerSecret", (_body, { params: [id] }) => (id && /^[A-Za-z0-9_-]{1,128}$/.test(id) ? `/#/triggers/${id}` : "/#/triggers"));
|
|
19
|
+
registerSecretPage(["rotateWebhookSecret", "deleteWebhook"], "/#/settings/webhook");
|
|
14
20
|
/** What the token's answer says of a webhook trigger's secret, made and kept but not shown to it. */
|
|
15
21
|
export const TRIGGER_SECRET_WORDS = "Open the console to see this trigger's signing secret once: rotate it there.";
|
|
16
|
-
/** What the token's answer says of the outbound webhook's secret: the console
|
|
17
|
-
*
|
|
18
|
-
export const WEBHOOK_SECRET_WORDS = "Open the console to
|
|
22
|
+
/** What the token's answer says of the outbound webhook's secret: the console's Rotate secret makes a new one and shows it
|
|
23
|
+
* once. */
|
|
24
|
+
export const WEBHOOK_SECRET_WORDS = "Open Settings → Webhook in the console to rotate this webhook's signing secret and see the new one once.";
|
|
19
25
|
/** A webhook trigger's minted secret's metadata, named trigger:<id>: made by this server at a console's or a script's
|
|
20
26
|
* request (source console). `changedAt`: when it was made, where known (its create's or rotation's answer); its row
|
|
21
27
|
* keeps no time yet, so a read says null. */
|
|
@@ -44,6 +50,9 @@ export function webhookSaved(view, minted, mayHold) {
|
|
|
44
50
|
return view;
|
|
45
51
|
return mayHold ? { ...view, signing_secret: minted } : { ...view, note: WEBHOOK_SECRET_WORDS };
|
|
46
52
|
}
|
|
53
|
+
/** POST /settings/webhook/secret's answer (the owner's session alone reaches it): the webhook as a read answers it, its
|
|
54
|
+
* `secret` metadata the new secret's, and the new value as `signing_secret`, this once. */
|
|
55
|
+
export const webhookRotated = (view, minted) => ({ ...view, signing_secret: minted });
|
|
47
56
|
/** The field an adapter mints for each of its triggers (a webhook's `secret`), if it mints one. */
|
|
48
57
|
const mintedField = (adapter) => adapter?.settings?.scope === "trigger" ? Object.entries(adapter.settings.fields).find(([, field]) => field.mint)?.[0] : undefined;
|
|
49
58
|
/** What a trigger's view says of a secret its sealed settings keep but that does not open here (sealed under another seal
|
|
@@ -40,7 +40,7 @@ export type TriggerTargets = {
|
|
|
40
40
|
targetIssues(target: Target): Promise<InputIssue[]>;
|
|
41
41
|
start(target: Extract<Target, {
|
|
42
42
|
kind: "start_run";
|
|
43
|
-
}>, input: Json, origin: RunTrigger, from: MessageOrigin, title
|
|
43
|
+
}>, input: Json, origin: RunTrigger, from: MessageOrigin, title: string | undefined, previous: boolean): Promise<{
|
|
44
44
|
run_id: string;
|
|
45
45
|
}>;
|
|
46
46
|
message(target: Extract<Target, {
|
package/dist/trigger-targets.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { ApiError, unsupported } from "./errors.js";
|
|
8
8
|
import { message, startRun, WAITS_ON_A_PERSON } from "./runs-over-store.js";
|
|
9
9
|
import { runOfOrigin } from "./store-reads/runs.js";
|
|
10
|
+
import { NATIVE_CAP_UNSUPPORTED, NATIVE_RUN_OVERRIDES_UNSUPPORTED, nativeOf, nativeRunOverrides } from "./native/binding.js";
|
|
10
11
|
/** Why a trigger may not message a run with no cap (server.ts NO_CAP). */
|
|
11
12
|
const NO_CAP = "The run has no spend cap: a trigger only messages a run with one, as every turn it drives is capped.";
|
|
12
13
|
/** The most of a trigger's firings, newest first, read for its last completed run. */
|
|
@@ -55,24 +56,34 @@ export function triggerTargets(store, deps) {
|
|
|
55
56
|
const pinned = await deps.start.pinnedOf(entry, { input: target.input });
|
|
56
57
|
const revision = pinned?.revision;
|
|
57
58
|
const defaultCap = revision?.body?.maxCostUsd;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
// A native run takes no cap and none of nativeRunOverrides, which its start refuses: so does a trigger on one.
|
|
60
|
+
const native = revision !== undefined && nativeOf(revision.body) !== undefined;
|
|
61
|
+
const start = native
|
|
62
|
+
? [
|
|
63
|
+
...(target.max_cost_usd !== undefined ? [{ field: "target.max_cost_usd", reason: "not_allowed", message: NATIVE_CAP_UNSUPPORTED }] : []),
|
|
64
|
+
...(defaultCap !== undefined ? [{ field: "target.agent_id", reason: "not_allowed", message: NATIVE_CAP_UNSUPPORTED }] : []),
|
|
65
|
+
...nativeRunOverrides(target).map((field) => ({ field: `target.${field}`, reason: "not_allowed", message: NATIVE_RUN_OVERRIDES_UNSUPPORTED })),
|
|
66
|
+
]
|
|
67
|
+
: target.max_cost_usd === undefined && defaultCap === undefined
|
|
68
|
+
? [{ field: "target.max_cost_usd", reason: "missing", message: `Every run a trigger starts is capped: give the target a max_cost_usd or set the agent's (the agent ${target.agent_id} has none).` }]
|
|
69
|
+
: [];
|
|
61
70
|
const wrong = revision ? await deps.start.explainRun(await deps.start.inputIssuesOf(revision, target.input), { input: target.input }, revision) : [];
|
|
62
|
-
return [...
|
|
71
|
+
return [...start, ...wrong.map((issue) => ({ ...issue, field: `target.${issue.field}` }))];
|
|
63
72
|
},
|
|
64
|
-
async start(target, given, trigger, from, title, previous
|
|
73
|
+
async start(target, given, trigger, from, title, previous) {
|
|
65
74
|
const entry = await deps.needAgent(target.agent_id);
|
|
66
75
|
// An agentic run is handed its trigger's previous result after its message (previousResultOf), so a repeat run
|
|
67
76
|
// (a weekly digest) leaves out what the last one reported. A workflow's input is its own schema's: nothing is added.
|
|
68
|
-
//
|
|
77
|
+
// `previous` is its adapter's previousResult (carriesPrevious).
|
|
69
78
|
const content = given.content;
|
|
70
79
|
const handed = previous && entry.revision?.kind === "agentic" && typeof content === "string" ? await previousResultOf(store, deps, trigger) : "";
|
|
71
80
|
const input = handed ? { ...given, content: `${content}${handed}` } : given;
|
|
72
|
-
// The target's cap, else the agent's default as it stands now: a run a trigger starts is never uncapped (capped)
|
|
81
|
+
// The target's cap, else the agent's default as it stands now: a run a trigger starts is never uncapped (capped),
|
|
82
|
+
// but a connected agent's, which its own CLI's limits keep and AgentRun can't cap (NATIVE_CAP_UNSUPPORTED).
|
|
83
|
+
const native = Boolean(nativeOf(entry.revision?.body));
|
|
73
84
|
const run = await startRun(store, deps.start, entry, { input, ...(target.max_cost_usd !== undefined ? { max_cost_usd: target.max_cost_usd } : {}), ...(target.effort ? { effort: target.effort } : {}) },
|
|
74
85
|
// Titled from the trigger (the engine's titleOf: "<Source> <name>"), never from its input, a sender's markup.
|
|
75
|
-
{ trigger, origin: { key: trigger.firing_key }, capped:
|
|
86
|
+
{ trigger, origin: { key: trigger.firing_key }, capped: !native, from, ...(title ? { title } : {}) });
|
|
76
87
|
return { run_id: run.id };
|
|
77
88
|
},
|
|
78
89
|
async message(target, input, key, from, bound) {
|
package/dist/triggers.d.ts
CHANGED
|
@@ -75,10 +75,14 @@ export type Target = {
|
|
|
75
75
|
};
|
|
76
76
|
/** What the webhook did with a trigger.failed message (webhooks.ts emitTrigger). */
|
|
77
77
|
type Told = "queued" | "unsaved" | "off" | "closed";
|
|
78
|
-
/** What a trigger.failed webhook message says (webhooks.ts).
|
|
78
|
+
/** What a trigger.failed webhook message says (webhooks.ts). `agent_id`: the agent the trigger runs as (its row's: a
|
|
79
|
+
* start_run's agent, or the agent of the run a message_run names), so every trigger has one; `agent_name`, that agent's
|
|
80
|
+
* name as the message is built, its id when it has none (an agent no longer in the store). */
|
|
79
81
|
export type TriggerFailed = {
|
|
80
82
|
trigger_id: string;
|
|
81
83
|
name: string;
|
|
84
|
+
agent_id: string;
|
|
85
|
+
agent_name: string;
|
|
82
86
|
firing_key: string;
|
|
83
87
|
nominal_at: string;
|
|
84
88
|
error: {
|
|
@@ -118,10 +122,10 @@ export type TriggerDeps = {
|
|
|
118
122
|
/** Starts the target's run with `input`, as POST /agents/{id}/runs would, under `origin`, titled `title` (its
|
|
119
123
|
* trigger's, never its input's); its first message is the trigger's (`from`, never the person's); ApiError when
|
|
120
124
|
* refused. */
|
|
121
|
-
/** `previous`
|
|
125
|
+
/** `previous` true: the run is handed its trigger's previous result (its adapter's previousResult, carriesPrevious). */
|
|
122
126
|
start(target: Extract<Target, {
|
|
123
127
|
kind: "start_run";
|
|
124
|
-
}>, input: Json, origin: RunTrigger, from: MessageOrigin, title: string, previous
|
|
128
|
+
}>, input: Json, origin: RunTrigger, from: MessageOrigin, title: string, previous: boolean): Promise<{
|
|
125
129
|
run_id: string;
|
|
126
130
|
}>;
|
|
127
131
|
/** Queues `input` for the target's run as a command row (answers false) under `key`, as the trigger's (`from`), within
|
package/dist/triggers.js
CHANGED
|
@@ -1145,7 +1145,8 @@ export class Triggers {
|
|
|
1145
1145
|
const trigger = await this.find(triggerId);
|
|
1146
1146
|
if (!firing || !trigger || firing.status !== "failed" || firing.notified)
|
|
1147
1147
|
return;
|
|
1148
|
-
const
|
|
1148
|
+
const agentName = (await this.store.agents.get(trigger.agentId))?.name || trigger.agentId;
|
|
1149
|
+
const told = await this.deps.notify({ trigger_id: trigger.id, name: trigger.name, agent_id: trigger.agentId, agent_name: agentName, firing_key: key, nominal_at: second(firing.nominalAt), error: firing.error ?? { code: "internal", message: "" }, auto_paused: firing.paused }, key);
|
|
1149
1150
|
// A mark that does not land (the outbox's write failed) is tried again at the next tick, under the same key, which
|
|
1150
1151
|
// the outbox holds once: a restart then finds it marked.
|
|
1151
1152
|
if (told === "queued" || told === "off")
|