@parcha/agentrun-serve 0.1.0-beta.45 → 0.1.0-beta.46

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.
@@ -85,6 +85,8 @@ export declare const promotionGate: (deps: PromotionDeps) => Promoted;
85
85
  export declare const DSL_REFUSES = "this release's workflow DSL refuses it";
86
86
  /** The words a stopped check's record starts with when it had nothing to check its draft on. */
87
87
  export declare const NOTHING_TO_CHECK = "nothing to check it on";
88
+ /** What a held check compared on the whole answer says when it answered some inputs alone and agreed on none. */
89
+ export declare const NEVER_WORD_FOR_WORD = "its answers never matched the agent's word for word; name the fields that carry the decision (learning.agree_on)";
88
90
  /** One input a check ran its draft on: the agent's run (`of`) and its input, the agent's recorded answer, and what the
89
91
  * draft did: its answer when it answered alone, why it handed the input back, or failed (or skipped a write). A
90
92
  * reserved input whose replay run was never created, or never ended, by the check's deadline failed (`unstarted` for
@@ -100,8 +102,8 @@ type CheckRow = {
100
102
  readonly unstarted?: true;
101
103
  };
102
104
  /** Decides a check on its rows: each input it ran on (a skipped write is none) agreed when the draft answered it alone
103
- * with the agent's recorded answer (learn/promote.ts sameAnswer), alone when it answered it with no escalate and no
104
- * failed step. Promoted when it clears the bar (checkPasses); else held with the inputs it did not agree on, which the
105
+ * with the agent's recorded answer (learn/promote.ts sameAnswer, on the bar's agree_on when it names fields), alone
106
+ * when it answered it with no escalate and no failed step. Promoted when it clears the bar (checkPasses); else held with the inputs it did not agree on, which the
105
107
  * agent's next run's compile turn reads as data (its one recompile); a recompile's check that holds it too stops:
106
108
  * nothing compiles again. No grade, refit, queue or second replay. Kept only while `still` holds of the digest's record
107
109
  * (the one write: of two claims at once, one decides). */
@@ -9,7 +9,7 @@ import { isCliRecord, piShaped, runEntries, runTimeline } from "../store-reads/j
9
9
  import { pinAnnotations, recordedCalls, replayCalls, SKIPPED_WRITE, toolClassOf, toolWord, unmarkedWords } from "../learn/replay-calls.js";
10
10
  import { isObject } from "../validate.js";
11
11
  import { agentRun, lastOwnRuns, newCompileAttempt } from "../learn/compile.js";
12
- import { checkPasses, checkShares, CHECK_TEXT_MAX, championOf, promotionOf, promotionsOf, recordPromotion, replayingOf, sameAnswer, skippedToolsOf } from "../learn/promote.js";
12
+ import { checkPasses, checkShares, CHECK_TEXT_MAX, championOf, fieldsWords, promotionOf, promotionsOf, recordPromotion, replayingOf, sameAnswer, skippedToolsOf } from "../learn/promote.js";
13
13
  import { sendCommand } from "./commands.js";
14
14
  import { ClaimRefused } from "./loop-contract.js";
15
15
  import { readSnapshot } from "../learn/folder.js";
@@ -250,15 +250,12 @@ async function decide(deps, workflow, digest) {
250
250
  return startCheck(deps, workflow, digest);
251
251
  }
252
252
  /** The loop's numbers (learning-setting.ts) of the revision the claim runs: its definition's `learning`, each one it
253
- * leaves out at its default (a revision that cannot be read: every default). */
253
+ * leaves out at its default, and the answer paths its check compares on (its agree_on; none, the whole answer). A read
254
+ * that fails throws: no check is saved on defaults (a bar with no agree_on would compare the whole answer for the
255
+ * check's life); the claim's gate leaves the run to its agent and the next claim reads it again (#3182 review). */
254
256
  async function loopOfRevision(deps) {
255
- try {
256
- const revision = await deps.store.agents.revision(deps.revisionId);
257
- return loopOf(revision?.body?.learning);
258
- }
259
- catch {
260
- return loopOf(undefined);
261
- }
257
+ const revision = await deps.store.agents.revision(deps.revisionId);
258
+ return loopOf(revision?.body?.learning);
262
259
  }
263
260
  /** Which check of a compile a new revision's is: 2 when the workflow's newest record of another revision is a first
264
261
  * check's hold, an audit's hold or a hold by its reason alone (holdRefused: the DSL refuses a serving revision), or a
@@ -346,7 +343,7 @@ async function startCheck(deps, workflow, digest) {
346
343
  return;
347
344
  }
348
345
  const loop = await loopOfRevision(deps);
349
- const bar = { compile_after: loop.compile_after, agree_min: loop.agree_min, alone_min: loop.alone_min, attempt: attemptOf(records, workflow.name, digest) };
346
+ const bar = { ...loop, attempt: attemptOf(records, workflow.name, digest) };
350
347
  const { inputs, looked, unfit, files } = await checkInputs(deps, workflow, { of: [], n: loop.compile_after }, auditInputsOf(records, workflow.name, digest));
351
348
  if (!inputs.length) {
352
349
  // Nothing of the agent's to check it on (a workflow landed before any run it fits): never promoted unchecked. It
@@ -368,6 +365,8 @@ async function startCheck(deps, workflow, digest) {
368
365
  }
369
366
  /** The words a stopped check's record starts with when it had nothing to check its draft on. */
370
367
  export const NOTHING_TO_CHECK = "nothing to check it on";
368
+ /** What a held check compared on the whole answer says when it answered some inputs alone and agreed on none. */
369
+ export const NEVER_WORD_FOR_WORD = "its answers never matched the agent's word for word; name the fields that carry the decision (learning.agree_on)";
371
370
  /** Stops a draft its check had nothing to run on (`why`: no input of the agent's it takes, or every input skipped at a
372
371
  * write): held, never promoted unchecked, its record `stopped` (nothing compiles again until a hold or its owner acts)
373
372
  * and naming the cause, which the compile's draft errors show (store-reads/loop.ts). It asks no recompile: a revision
@@ -460,8 +459,8 @@ async function settleCheck(deps, workflow, digest, record) {
460
459
  return decided.record?.decided === "replaying" ? undefined : decided.record;
461
460
  }
462
461
  /** Decides a check on its rows: each input it ran on (a skipped write is none) agreed when the draft answered it alone
463
- * with the agent's recorded answer (learn/promote.ts sameAnswer), alone when it answered it with no escalate and no
464
- * failed step. Promoted when it clears the bar (checkPasses); else held with the inputs it did not agree on, which the
462
+ * with the agent's recorded answer (learn/promote.ts sameAnswer, on the bar's agree_on when it names fields), alone
463
+ * when it answered it with no escalate and no failed step. Promoted when it clears the bar (checkPasses); else held with the inputs it did not agree on, which the
465
464
  * agent's next run's compile turn reads as data (its one recompile); a recompile's check that holds it too stops:
466
465
  * nothing compiles again. No grade, refit, queue or second replay. Kept only while `still` holds of the digest's record
467
466
  * (the one write: of two claims at once, one decides). */
@@ -469,7 +468,8 @@ export async function decideCheck(deps, name, digest, bar, read, still, extra) {
469
468
  const now = deps.now ?? Date.now;
470
469
  const ran = read.rows.filter((row) => row.outcome !== "skipped_write");
471
470
  const alone = (row) => row.outcome === "answered";
472
- const agrees = (row) => alone(row) && sameAnswer(row.answer, row.agent);
471
+ // Compared on the bar's agree_on when it names paths (the definition's), else the whole answer.
472
+ const agrees = (row) => alone(row) && sameAnswer(row.answer, row.agent, bar.agree_on);
473
473
  const score = { n: ran.length, agreed: ran.filter(agrees).length, alone: ran.filter(alone).length };
474
474
  const ok = checkPasses(score, bar);
475
475
  // Each text is cut of the host's secrets whole, then shortened (learn/secrets.ts excerptShown).
@@ -501,8 +501,10 @@ export async function decideCheck(deps, name, digest, bar, read, still, extra) {
501
501
  // and the words say none ran.
502
502
  const said = read.unstarted === score.n
503
503
  ? `none of its ${plural(score.n, "check run")} started by the check's deadline (its launch was interrupted: the server stopped after reserving it, say): nothing was checked`
504
- : `checked on ${score.n} of the agent's inputs: answered ${score.alone} alone (${pct(shares.alone)}, the bar ${pct(bar.alone_min)}), and ${score.agreed} of those said what the agent said (${pct(shares.agreement)}, the bar ${pct(bar.agree_min)})${aside ? ` (${aside})` : ""}`;
505
- const reason = ok ? `${said}: promoted` : stopped ? `${said}: held, and this was the recompile's check, so it stops: nothing compiles again until a hold or its owner acts` : `${said}: held; the agent's next run recompiles it once with the inputs it did not agree on`;
504
+ : `checked on ${score.n} of the agent's inputs: answered ${score.alone} alone (${pct(shares.alone)}, the bar ${pct(bar.alone_min)}), and ${score.agreed} of those said what the agent said${bar.agree_on?.length ? ` on ${fieldsWords(bar.agree_on)}` : ""} (${pct(shares.agreement)}, the bar ${pct(bar.agree_min)})${aside ? ` (${aside})` : ""}`;
505
+ // Compared whole and never once the same: free text two runs never repeat, most likely, so the owner is told what to set.
506
+ const verbatim = !ok && !bar.agree_on?.length && score.alone > 0 && score.agreed === 0 ? `; ${NEVER_WORD_FOR_WORD}` : "";
507
+ const reason = ok ? `${said}: promoted` : stopped ? `${said}: held${verbatim}, and this was the recompile's check, so it stops: nothing compiles again until a hold or its owner acts` : `${said}: held${verbatim}; the agent's next run recompiles it once with the inputs it did not agree on`;
506
508
  const check = { ...bar, ...score, ...numbers, ...(disagreements.length ? { disagreements } : {}), ...(stopped ? { stopped: true } : {}) };
507
509
  const decided = await recordPromotion(deps.store.settings, deps.agentId, { workflow: name, digest, at: iso(now()), decided: ok ? "promote" : "hold", reason, check, ...seedOf(deps), ...extra }, still);
508
510
  if (decided.won)
@@ -767,7 +769,7 @@ export async function askReplay(ask, name, digest, inputs) {
767
769
  if (!launch.learning || launch.learning.noWorkflows)
768
770
  throw new ReplayRefused("conflict", `A replay runs ${name} as a run of the agent that learns does, and the agent's runs do not take learned workflows here (its learning is off, it takes no workflows, or this server's is off).`);
769
771
  const deps = { store: ask.store, agentId: ask.agentId, revisionId, launch: { ...launch, learning: { ...launch.learning, seed: found.commit } }, context: ask.context, log: ask.log, shown: ask.shown, ...(ask.now ? { now: ask.now } : {}) };
770
- const bar = { compile_after: loop.compile_after, agree_min: loop.agree_min, alone_min: loop.alone_min, attempt: attemptOf(records, name, digest) };
772
+ const bar = { ...loop, attempt: attemptOf(records, name, digest) };
771
773
  const said = `checking it on ${plural(picked.length, "input")} of the agent's own runs, as its owner asked`;
772
774
  // Kept only while the revision's newest record is still the one read here: each record write stamps a new `at`.
773
775
  const reserved = await reserve(deps, found.workflow, digest, picked, said, (was) => was?.at === own?.at && was?.decided === own?.decided, bar);
@@ -84,11 +84,19 @@ export const runIsolationName = (isolation) => isolation.kind;
84
84
  export class RunIsolationRefused extends Error {
85
85
  name = "RunIsolationRefused";
86
86
  }
87
+ /** The helper run once: its exit code and output, never a rejection. A spawn error Node throws from execFile itself
88
+ * (EPERM, say, where a platform forbids the helper's file capabilities; only EACCES, EAGAIN, EMFILE, ENFILE and ENOENT
89
+ * come to the callback) is `code` -1 with the error's words as `stderr`, so every caller reads it as the failure it is. */
87
90
  const execText = (file, args, timeoutMs) => new Promise((resolve) => {
88
- execFile(file, args, { timeout: timeoutMs, encoding: "utf8" }, (error, stdout, stderr) => {
89
- const code = error ? (typeof error.code === "number" ? (error.code) : 1) : 0;
90
- resolve({ code, stdout: String(stdout), stderr: String(stderr || (error && !stderr ? error.message : "")) });
91
- });
91
+ try {
92
+ execFile(file, args, { timeout: timeoutMs, encoding: "utf8" }, (error, stdout, stderr) => {
93
+ const code = error ? (typeof error.code === "number" ? (error.code) : 1) : 0;
94
+ resolve({ code, stdout: String(stdout), stderr: String(stderr || (error && !stderr ? error.message : "")) });
95
+ });
96
+ }
97
+ catch (error) {
98
+ resolve({ code: -1, stdout: "", stderr: error?.message ?? String(error) });
99
+ }
92
100
  });
93
101
  /** This host's isolation for `loops` runs at once, by `env` and the helper: the helper's own check that it can switch
94
102
  * (its effective set holds what it needs) decides `uid`; none installed (a local install), `process`; `same`, `process`
package/dist/server.js CHANGED
@@ -5245,13 +5245,15 @@ async function startHolding(options, data, checked, stops) {
5245
5245
  * status input_required and idle, a message continues it) and not have ended: its view says which. */
5246
5246
  const stopRow = (row) => row.state === "stopped" && row.outcome === "stopped" && row.importedFrom === null;
5247
5247
  const endOf = (row) => ({ id: row.id, state: final(row) ? row.state : "running", ...(final(row) && row.endedAt !== null ? { endedAt: new Date(row.endedAt).toISOString() } : {}), ...(stopRow(row) ? { stop: true } : {}) });
5248
+ /** Agent `agentId`'s name as the store holds it now, for a webhook notice: its id when it has none, or is gone. */
5249
+ const agentNameOf = async (agentId) => (await store.agents.get(agentId))?.name || agentId;
5248
5250
  /** The run as the store holds it now, with its notice (the run list's own view of it); null when there is no such run. */
5249
5251
  const endNotice = async (id) => {
5250
5252
  const row = await store.runs.get(id);
5251
5253
  const summary = row && (await summaryOverStore(store, id, viewDepsFor(ownOriginOf())));
5252
5254
  if (!row || !summary)
5253
5255
  return null;
5254
- return { ...endOf(row), notice: { run_id: id, agent_id: row.agentId, status: String(summary.status), title: typeof summary.title === "string" ? summary.title : "" } };
5256
+ return { ...endOf(row), notice: { run_id: id, agent_id: row.agentId, agent_name: await agentNameOf(row.agentId), status: String(summary.status), title: typeof summary.title === "string" ? summary.title : "" } };
5255
5257
  };
5256
5258
  /** The run-end read's look at a run: its end from its row alone when it has none, or one told already; else its
5257
5259
  * endNotice. The run's view redacts the run's words (its title, its output) on every build, and the newest runs are
@@ -5297,7 +5299,7 @@ async function startHolding(options, data, checked, stops) {
5297
5299
  // whose card is withheld is a question. A run idle on nothing named (its harness ended its turn on its own) names no kind.
5298
5300
  const kind = typeof card === "string" && waitKinds.has(card) ? card : view.state === "waiting" ? "question" : undefined;
5299
5301
  const wait = kind === undefined ? undefined : { kind };
5300
- const notice = { run_id: row.id, agent_id: row.agentId, status: "input_required", title: typeof view.title === "string" ? view.title : "", ...(wait ? { pending: wait } : {}) };
5302
+ const notice = { run_id: row.id, agent_id: row.agentId, agent_name: await agentNameOf(row.agentId), status: "input_required", title: typeof view.title === "string" ? view.title : "", ...(wait ? { pending: wait } : {}) };
5301
5303
  if (!(await toldAll(row.id, waitSubscribers.map((tell) => () => tell(notice, wait, marker)))))
5302
5304
  return false;
5303
5305
  readWaits.set(row.id, seen);
@@ -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?: boolean;
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: boolean;
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: boolean;
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
- if (f.learning !== undefined && typeof f.learning !== "boolean")
678
- bad(MANIFEST, "learning is true or false");
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 } } : {}), ...(typeof f.learning === "boolean" ? { learning: f.learning } : {}), ...(f.approvals === "ask" || f.approvals === "never" ? { approvals: f.approvals } : {}),
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
@@ -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: {
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 told = await this.deps.notify({ trigger_id: trigger.id, name: trigger.name, firing_key: key, nominal_at: second(firing.nominalAt), error: firing.error ?? { code: "internal", message: "" }, auto_paused: firing.paused }, key);
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")
@@ -46,10 +46,12 @@ export type WebhooksOptions = {
46
46
  * refused the write, so the caller tells it again; `off`, no webhook set, or one a 410 turned off, so nothing is to be
47
47
  * sent; `closed`, the server is stopping. */
48
48
  export type Emitted = "queued" | "unsaved" | "off" | "closed";
49
- /** What a notice says of its run: never its tools' arguments, its output or its input, which a receiver reads through the API. */
49
+ /** What a notice says of its run: never its tools' arguments, its output or its input, which a receiver reads through the API.
50
+ * `agent_name`: its agent's name as the notice is built (server.ts agentNameOf), its id when the agent has no name. */
50
51
  export type RunNotice = {
51
52
  run_id: string;
52
53
  agent_id: string;
54
+ agent_name: string;
53
55
  status: string;
54
56
  title: string;
55
57
  pending?: {
package/dist/webhooks.js CHANGED
@@ -318,7 +318,7 @@ export class Webhooks {
318
318
  if (ends && !this.due(marker, config))
319
319
  return "queued";
320
320
  const id = `msg_${createHash("sha256").update(`${run.run_id}\n${type}\n${marker}`).digest("hex").slice(0, 32)}`;
321
- const data = { run_id: run.run_id, agent_id: run.agent_id, status: run.status, title: run.title, url: `${this.base}/#/runs/${encodeURIComponent(run.run_id)}`, ...(run.pending ? { pending: run.pending } : {}) };
321
+ const data = { run_id: run.run_id, agent_id: run.agent_id, agent_name: run.agent_name, status: run.status, title: run.title, url: `${this.base}/#/runs/${encodeURIComponent(run.run_id)}`, ...(run.pending ? { pending: run.pending } : {}) };
322
322
  // A new wait goes beside the run's earlier waits and replaces its end (one after an end is a continued run's, past that
323
323
  // end); an end replaces the run's last end and keeps its waits.
324
324
  const told = ends ? { runId: run.run_id, marker: `${ENDED}${marker}`, replacing: ENDED } : { runId: run.run_id, marker: `${WAIT}${marker}`, replacing: ENDED };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-serve",
3
- "version": "0.1.0-beta.45",
3
+ "version": "0.1.0-beta.46",
4
4
  "description": "The AgentRun server: the /v2 API and console over one store, with runners that run your agents; the deployable process of the AgentRun platform.",
5
5
  "keywords": [
6
6
  "agentrun",
@@ -54,14 +54,14 @@
54
54
  "@earendil-works/pi-coding-agent": "1.5.2",
55
55
  "@modelcontextprotocol/client": "2.4.0",
56
56
  "@modelcontextprotocol/server": "2.4.0",
57
- "@parcha/agentrun-computer": "0.1.0-beta.45",
58
- "@parcha/agentrun-decisions": "0.1.0-beta.45",
59
- "@parcha/agentrun-dsl": "0.1.0-beta.45",
60
- "@parcha/agentrun-harness-claude": "0.1.0-beta.45",
61
- "@parcha/agentrun-harness-codex": "0.1.0-beta.45",
62
- "@parcha/agentrun-jev": "0.1.0-beta.45",
63
- "@parcha/agentrun-kernel": "0.1.0-beta.45",
64
- "@parcha/pi-browser": "0.1.0-beta.45",
57
+ "@parcha/agentrun-computer": "0.1.0-beta.46",
58
+ "@parcha/agentrun-decisions": "0.1.0-beta.46",
59
+ "@parcha/agentrun-dsl": "0.1.0-beta.46",
60
+ "@parcha/agentrun-harness-claude": "0.1.0-beta.46",
61
+ "@parcha/agentrun-harness-codex": "0.1.0-beta.46",
62
+ "@parcha/agentrun-jev": "0.1.0-beta.46",
63
+ "@parcha/agentrun-kernel": "0.1.0-beta.46",
64
+ "@parcha/pi-browser": "0.1.0-beta.46",
65
65
  "@secretlint/core": "13.1.0",
66
66
  "@secretlint/profiler": "13.1.0",
67
67
  "@secretlint/secretlint-rule-preset-recommend": "13.1.0",
@@ -96,7 +96,7 @@
96
96
  "@earendil-works/chord": "1.5.2",
97
97
  "@earendil-works/pi-ai": "1.5.2",
98
98
  "@earendil-works/pi-durable": "1.5.2",
99
- "@parcha/agentrun-harness-acp": "0.1.0-beta.45",
99
+ "@parcha/agentrun-harness-acp": "0.1.0-beta.46",
100
100
  "@types/pg": "8.23.1",
101
101
  "@types/proxy-addr": "2.0.3",
102
102
  "@types/ws": "8.18.2",
@@ -347,7 +347,7 @@ package}`, and a line in the markdown).
347
347
  | `inputs` | By name: each run's typed input, which apply compiles into the agent's `input_schema` (a closed JSON Schema object). Each is `{type: string \| number \| integer \| boolean \| array, required?, title?, description?, examples?, default?, enum?, pattern? and format? (strings), minLength?/maxLength? (strings), minimum?/maximum? (numbers), items? (an array's scalar, with that scalar's keys)}`, nothing else; an input is required unless it says `required: false`, and a `default` is for one that is not. `format` is `uri`, `email`, `hostname`, `date`, `date-time` or `uuid`, which the server checks, or `cron` or `timezone`, which a form reads. A default and each example are checked against their own input. `content` is the run's message: named, it is a string. Every path that starts a run (the API, the CLI, a trigger, the console) checks the input against it and refuses one that does not meet it with `422 input_invalid`, a path per field (`input.country`). The model is sent the input's `content`, then the other fields as one fenced `json` block under the line `Input:`, so the instructions read each field by its name. `GET /v2/templates` shows it as `input_schema`, and the console's run form is drawn from it. A trigger's `target.input` and an eval case's `input` are checked against it too. Absent: a run takes `{content}`, as before. |
348
348
  | `secrets` | Variable names (never values) the server must hold: a model or tool key Settings saves (`OPENROUTER_API_KEY`, `PARALLEL_API_KEY`, ...), set where it starts or saved there. Any other name is refused: the server could neither save it nor hand it to a run. Apply refuses with `409 agent_not_runnable`, making nothing, when one is missing. |
349
349
  | `budget` | `{per_run_usd}`: each run's cap (the agent's `max_cost_usd`), required when the package has triggers. A call count belongs in the instructions ("about 30 calls"); the cap is the hard stop. |
350
- | `learning` | `true` or `false`: whether the agent's runs learn. |
350
+ | `learning` | `true`, `false`, or an object (on, with the loop's settings), as an agent definition's `learning` takes it: whether the agent's runs learn. A package whose answer carries a decision names it in `agree_on`, dotted paths into the answer's JSON object (kyb's `{agree_on: [verdict.decision]}`, inbound-lead's `[next_step.action]`): a learned workflow's check and audit compare two answers on those alone, never on the rationale or prose two runs never repeat. Each path must be a required property at every level of the `output` schema (validate refuses one an answer may leave out: a path missing on both sides never agrees). Without it the whole answer is compared, which suits an answer that is generated text (a digest, release notes). |
351
351
  | `approvals` | `ask` (the default: the agent asks its person before a tool runs) or `never` (it runs unattended). The package's recommendation, shown as `approvals_default` for the apply screen; a template whose job runs on triggers says `never`. `never` only skips asking for the tools the agent was granted: an MCP tool the owner left unticked at apply is not one. Under `ask`, a ticked tool is granted but not allowed: it follows this server's tool settings, so a write asks unless the owner allowed it in Settings → Tools, and a read runs unasked only where the owner turned on Allow reads for its server. Deny settings and pins hold either way. |
352
352
  | `triggers` | `POST /v2/triggers` bodies with no `agent_id` (the target is a `start_run`), each with a `name`, unique in the package: the key an upgrade will match triggers by. `enabled` is `true` (the default), `false`, or `"${parameters.<name>}"`, one placeholder alone naming a boolean parameter that has a default (validate refuses any other text there, a parameter of another type, or one with no default): apply makes the trigger enabled or disabled by the owner's answer, the default when it is left out, so a second schedule can be one the owner opts into (`weekly`, default `false`, turning on a `monday-brief` at `0 8 * * 1`). A trigger made off is off as any trigger is: the owner switches it on or off later with `PATCH /v2/triggers/{id}` or the console. A `composio` trigger's `source.server` is the toolkit of one of the package's `mcp` needs, one with `source: composio` and `required: true` (`server: github` for `{source: composio, toolkit: github}`), never a saved server's name: apply makes the trigger on the saved Composio server that need maps to, the one candidate or the owner's pick under `servers`. Its `config` values and its `accept` where `in` values may hold `${parameters.<name>}`, a parameter that is required or has a default (`config: {owner: "${parameters.owner}", repo: "${parameters.repo}"}`); its `server` and `event` can't. It can't carry `instance_id`, `hook` or `move_subscription`, which this server sets when it makes the trigger on Composio. A composio trigger this server can't set up yet (no public URL, the saved server's user with no connected account or several, the project's subscription at another address) is skipped with a `triggers.<i>` warning in the refusal's words, as a github one is with GitHub not connected: the agent stands, and the owner makes the trigger from Triggers → New app trigger once that's fixed. Any other refusal undoes the apply. A `feed` trigger's `urls` is a list of URLs, each of which may hold `${parameters.<name>}` (pr-alert's `https://api.github.com/repos/${parameters.owner}/${parameters.repo}/pulls?state=open&sort=created&direction=desc`), or one placeholder alone naming an array-of-strings parameter (vendor-outage-watch's `"${parameters.status_feeds}"`), filled whole; each parameter required or with a default, and each filled value an http(s) URL, which apply checks (`422` under `triggers.<i>.source.urls[<j>]`). An array parameter given empty (`[]`) reads no feed: apply skips that trigger with a `triggers.<i>` warning naming the parameter, as it skips a github one with GitHub not connected, and the agent stands. Its `every_s`, `items` and `id` take no placeholder, its `accept` where `in` values may, and it has no `key` in a package. |
353
353
  | `output` | `{schema: <file>}`: the JSON Schema of the agent's answer, a file in the package. It becomes the agent's `output_schema`: the runner puts it in the instructions on every harness and asks once more when an answer misses it. A string property with `contentMediaType: "text/markdown"` is a report the console renders as Markdown. A skill that reads the schema itself keeps the file in its own folder. |
@@ -34,7 +34,8 @@ parameters:
34
34
  slack_channel: { type: string, required: false, pattern: "^[CG][A-Z0-9]{8,12}$", description: "a Slack channel ID like C0123ABCD (the channel's details in Slack show it), never its name: where the brief is posted when post_to is slack" }
35
35
  competitors: { type: string, required: false, description: "your competitors' names or domains, comma-separated; a lead from one is flagged, never scored as a customer" }
36
36
  budget: { per_run_usd: 5.00 }
37
- learning: true
37
+ # Learning on, its check and audit comparing two answers on the next step's action alone (never the brief's prose).
38
+ learning: { agree_on: [next_step.action] }
38
39
  # Runs unattended (its job runs on triggers): no tool asks; deny and the pins above still hold.
39
40
  approvals: never
40
41
  triggers:
@@ -23,7 +23,8 @@ inputs:
23
23
  registration_number: { type: string, required: false, title: "Registration number", description: "Optional. The company number in its registry, as the applicant gave it.", maxLength: 100 }
24
24
  reason: { type: string, required: false, title: "Why it is checked", description: "Optional. vendor, customer or investment. Left out: unspecified.", enum: [vendor, customer, investment] }
25
25
  budget: { per_run_usd: 5.00 }
26
- learning: true
26
+ # Learning on, its check and audit comparing two answers on the verdict's decision alone (never the rationale or report).
27
+ learning: { agree_on: [verdict.decision] }
27
28
  output: { schema: kyb.schema.json }
28
29
  ---
29
30
  You are a business due diligence (KYB) analyst. Someone is about to sign, pay or onboard a company and needs to know who