@parcha/agentrun-serve 0.1.0-beta.43 → 0.1.0-beta.44

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.
Files changed (141) hide show
  1. package/CHANGELOG.md +105 -0
  2. package/README.md +213 -24
  3. package/dist/cli.js +42 -8
  4. package/dist/composio-preset.d.ts +4 -3
  5. package/dist/composio-preset.js +12 -4
  6. package/dist/composio-triggers.d.ts +20 -2
  7. package/dist/composio-triggers.js +183 -17
  8. package/dist/computer-lost.d.ts +11 -0
  9. package/dist/computer-lost.js +19 -0
  10. package/dist/computer-record.d.ts +10 -2
  11. package/dist/computer-record.js +50 -18
  12. package/dist/computer-setting.d.ts +1 -0
  13. package/dist/computer-setting.js +2 -2
  14. package/dist/console/assets/index-BUktRvS-.css +1 -0
  15. package/dist/console/assets/index-nB9kTfIN.js +711 -0
  16. package/dist/console/index.html +2 -2
  17. package/dist/errors.d.ts +1 -0
  18. package/dist/errors.js +3 -0
  19. package/dist/harness-table.d.ts +51 -3
  20. package/dist/harness-table.js +101 -13
  21. package/dist/harness.d.ts +18 -1
  22. package/dist/harness.js +21 -9
  23. package/dist/host.d.ts +12 -10
  24. package/dist/host.js +18 -16
  25. package/dist/import-worker.d.ts +3 -0
  26. package/dist/import-worker.js +7 -5
  27. package/dist/import.d.ts +22 -1
  28. package/dist/import.js +141 -28
  29. package/dist/learn/check.d.ts +3 -0
  30. package/dist/learn/check.js +1 -1
  31. package/dist/learn/compile.js +1 -1
  32. package/dist/learn/delete.d.ts +17 -0
  33. package/dist/learn/delete.js +44 -0
  34. package/dist/learn/promote.d.ts +7 -1
  35. package/dist/learn/promote.js +8 -4
  36. package/dist/learn/skills.d.ts +4 -0
  37. package/dist/learn/skills.js +17 -1
  38. package/dist/learn/workflow-nodes.d.ts +22 -1
  39. package/dist/learn/workflow-nodes.js +28 -9
  40. package/dist/learning-cost.d.ts +100 -0
  41. package/dist/learning-cost.js +116 -1
  42. package/dist/learning-evals.d.ts +2 -0
  43. package/dist/learning-evals.js +4 -3
  44. package/dist/learning-routes.d.ts +8 -0
  45. package/dist/learning-routes.js +17 -0
  46. package/dist/learning.d.ts +1 -1
  47. package/dist/listen-first.d.ts +30 -0
  48. package/dist/listen-first.js +115 -0
  49. package/dist/llms.txt +2 -1
  50. package/dist/mcp-servers-store.d.ts +12 -12
  51. package/dist/model.d.ts +8 -4
  52. package/dist/model.js +16 -8
  53. package/dist/openapi.js +115 -39
  54. package/dist/owner.d.ts +8 -0
  55. package/dist/owner.js +11 -0
  56. package/dist/paid-calls.d.ts +6 -0
  57. package/dist/paid-calls.js +11 -1
  58. package/dist/place.d.ts +8 -3
  59. package/dist/place.js +13 -9
  60. package/dist/provider.js +15 -1
  61. package/dist/run-learning-served.d.ts +1 -1
  62. package/dist/run-model-key.d.ts +64 -0
  63. package/dist/run-model-key.js +147 -0
  64. package/dist/runner/adapter-loop.d.ts +6 -0
  65. package/dist/runner/adapter-loop.js +9 -2
  66. package/dist/runner/adapter-run-spec.d.ts +6 -3
  67. package/dist/runner/adapter-run-spec.js +70 -23
  68. package/dist/runner/adapters/index.d.ts +4 -2
  69. package/dist/runner/adapters/index.js +13 -4
  70. package/dist/runner/audit.d.ts +4 -0
  71. package/dist/runner/audit.js +15 -4
  72. package/dist/runner/beside.d.ts +2 -1
  73. package/dist/runner/beside.js +5 -2
  74. package/dist/runner/claim-secrets.d.ts +49 -0
  75. package/dist/runner/claim-secrets.js +110 -1
  76. package/dist/runner/cli-run-spec.d.ts +2 -1
  77. package/dist/runner/cli-run-spec.js +32 -13
  78. package/dist/runner/commands.d.ts +3 -6
  79. package/dist/runner/feedback-round.d.ts +3 -2
  80. package/dist/runner/feedback-round.js +7 -3
  81. package/dist/runner/harness-loops.js +30 -8
  82. package/dist/runner/journal-kinds.d.ts +5 -0
  83. package/dist/runner/learning-end.d.ts +3 -0
  84. package/dist/runner/learning-end.js +4 -0
  85. package/dist/runner/loop-contract.d.ts +6 -0
  86. package/dist/runner/loop-contract.js +4 -0
  87. package/dist/runner/loop.js +6 -2
  88. package/dist/runner/main.d.ts +1 -0
  89. package/dist/runner/main.js +24 -7
  90. package/dist/runner/memory-claim.d.ts +9 -6
  91. package/dist/runner/memory-claim.js +12 -9
  92. package/dist/runner/promotion.d.ts +5 -0
  93. package/dist/runner/promotion.js +46 -7
  94. package/dist/runner/reflect-hook.d.ts +4 -0
  95. package/dist/runner/reflect-hook.js +22 -3
  96. package/dist/runner/runner.js +57 -4
  97. package/dist/runner/store-secrets.js +9 -5
  98. package/dist/runner/workflow-spec.js +10 -2
  99. package/dist/runs-over-store.d.ts +5 -4
  100. package/dist/runs-over-store.js +13 -3
  101. package/dist/sdk/workflows.d.ts +1 -1
  102. package/dist/server.d.ts +64 -50
  103. package/dist/server.js +457 -120
  104. package/dist/store/index.d.ts +2 -2
  105. package/dist/store/index.js +1 -1
  106. package/dist/store/seal.d.ts +20 -2
  107. package/dist/store/seal.js +24 -8
  108. package/dist/store/sqlite/run-launch.d.ts +4 -1
  109. package/dist/store/sqlite/run-launch.js +12 -0
  110. package/dist/store/sqlite/store.d.ts +3 -2
  111. package/dist/store/sqlite/store.js +118 -16
  112. package/dist/store/store.d.ts +38 -3
  113. package/dist/store-reads/analytics.js +11 -1
  114. package/dist/store-reads/learning.d.ts +41 -2
  115. package/dist/store-reads/learning.js +158 -5
  116. package/dist/store-reads/stats.js +13 -3
  117. package/dist/store-view.d.ts +5 -1
  118. package/dist/store-view.js +12 -11
  119. package/dist/telemetry.d.ts +59 -0
  120. package/dist/telemetry.js +153 -0
  121. package/dist/tool-keys-store.d.ts +1 -1
  122. package/dist/tool-keys.d.ts +2 -2
  123. package/dist/tool-plane.d.ts +12 -12
  124. package/dist/tools.d.ts +11 -11
  125. package/dist/tools.js +18 -5
  126. package/dist/trigger-adapter.d.ts +3 -0
  127. package/dist/trigger-adapters.d.ts +4 -0
  128. package/dist/trigger-adapters.js +13 -0
  129. package/dist/trigger-composio.d.ts +58 -1
  130. package/dist/trigger-composio.js +160 -6
  131. package/dist/triggers.d.ts +4 -0
  132. package/dist/triggers.js +22 -3
  133. package/dist/validate.d.ts +11 -7
  134. package/dist/validate.js +8 -7
  135. package/dist/workspace/computer-for-claim.d.ts +15 -5
  136. package/dist/workspace/computer-for-claim.js +228 -32
  137. package/dist/workspace/resolve-computer.d.ts +8 -2
  138. package/dist/workspace/resolve-computer.js +1 -1
  139. package/package.json +10 -9
  140. package/dist/console/assets/index-BrcDSBD8.css +0 -1
  141. package/dist/console/assets/index-Bz6IWncl.js +0 -711
@@ -12,7 +12,8 @@ import { runLearningBody } from "../learning-routes.js";
12
12
  import { learningStartOf, learningStartOfStored, readLaunchBody, seedFailed } from "../run-launch.js";
13
13
  import { said, STOPPED } from "../learning-words.js";
14
14
  import { learningImpact, noteRuns, notesRead } from "../learning-run.js";
15
- import { costSummary, RUN_PATHS, runCostOf } from "../learning-cost.js";
15
+ import { amortize, billOf, costSummary, JOB_PATHS, noiseOff, RUN_PATHS, runCostOf, SERVED_PATHS } from "../learning-cost.js";
16
+ import { COMPILE_AFTER_DEFAULT } from "../learning-setting.js";
16
17
  import { modelsOwn, runPathOf, workflowNameOf } from "../runner/learning-end.js";
17
18
  import { feedbackStatus } from "../runner/feedback-round.js";
18
19
  import { PAST_RUNS, servedAnswerOf, servedAnswerStands, servedOf, workflowCostsOf } from "../runner/workflow-first.js";
@@ -282,8 +283,147 @@ export async function agentCostOverStore(store, agentId, limit = Infinity) {
282
283
  // the runs the run's launch reads (pastRunsOverStore) at the all-in cost this series shows: a workflow over the line
283
284
  // shows `needs_revision` with its two numbers, so the page and the launch's decision agree.
284
285
  const workflows = workflowCostsOf(await pastRunsOverStore(store, agentId, new Map(runs.map((run) => [run.run_id, run.total_usd])), records));
285
- const replay = servingReplayOf(await promotionsOf(store.settings, agentId), runs);
286
- return { runs: runs.slice(Math.max(0, runs.length - limit)), summary: costSummary(runs, replay), total_runs: runs.length, unknown_cost_runs: runs.filter((run) => run.total_usd === null).length, unknown_path_runs: unknownPath, workflows };
286
+ const promotions = await promotionsOf(store.settings, agentId);
287
+ const replay = servingReplayOf(promotions, runs);
288
+ // The owner's bill: booked $, every run of the series (billOf), from the first run on a served path (read from the
289
+ // run rows: the promotion feed is trimmed, so its oldest record need not be the first promotion), and each revision's
290
+ // compile and check over the served runs that carry it.
291
+ const ledger = await agentLedgerOf(records, promotions, listed);
292
+ const servedFrom = listed.filter((run) => !run.importedFrom && FROM_PATHS.includes(metricOf(run).path)).map((run) => run.startedAt).sort((a, b) => a - b)[0];
293
+ const booked = billOf(runs, servedFrom === undefined ? null : new Date(servedFrom).toISOString());
294
+ // What no run carries is the booked total less every run's all-in (A8), so a revision whose records aged out of the
295
+ // feed lands here, never nowhere: unknown while any run's figures are.
296
+ let carried = 0;
297
+ for (const run of runs) {
298
+ const all = run.path === "replay" ? 0 : run.cost_upper_bound ? null : allInV2Of(run, ledger.compiles.get(run.run_id) ?? [], ledger.shares);
299
+ carried = carried === null || all === null ? null : noiseOff(carried + all);
300
+ }
301
+ const unattributed = booked.withheld > 0 || carried === null ? null : noiseOff(booked.booked_usd - carried);
302
+ const bill = { ...booked, revisions: ledger.revisions, unattributed_usd: unattributed, holds: holdsOf(promotions, runs) };
303
+ return { runs: runs.slice(Math.max(0, runs.length - limit)), summary: costSummary(runs, replay), total_runs: runs.length, unknown_cost_runs: runs.filter((run) => run.total_usd === null).length, unknown_path_runs: unknownPath, workflows, bill };
304
+ }
305
+ /** The paths the bill's baseline ends at: the first run a learned workflow served, or an audit audited. */
306
+ const FROM_PATHS = ["workflow", "handed_back", "audit"];
307
+ /** Each hold of the agent's learned workflows (its promotion records that say hold), placed on the series: at the first
308
+ * run that does a job from it on, by its number among them (the points' `n`), null when none has run since. */
309
+ function holdsOf(records, runs) {
310
+ const jobs = runs.filter((run) => JOB_PATHS.includes(run.path));
311
+ return records.filter((one) => one.decided === "hold").map((one) => {
312
+ const at = jobs.findIndex((run) => run.started_at >= one.at);
313
+ return { n: at < 0 ? null : at + 1, at: one.at, workflow: one.workflow, by: one.audit ? "audit" : one.check ? "check" : "dsl", reason: one.reason };
314
+ });
315
+ }
316
+ const metricOf = (row) => (row.metrics ?? {});
317
+ /** The revision a run ran (metrics.workflow and metrics.workflow_digest, workflow-first.ts pathMetrics), undefined when it
318
+ * names none: two workflows of the same text share a digest, so a revision is never its digest alone. */
319
+ const revisionOfRow = (row) => {
320
+ const { workflow, workflow_digest: digest } = metricOf(row);
321
+ return typeof workflow === "string" && typeof digest === "string" ? { workflow, digest } : undefined;
322
+ };
323
+ /** The compile turns run `runId`'s rounds asked, oldest first: none for a run that compiled nothing. */
324
+ async function compilesOf(store, runId) {
325
+ return (await roundsOf(store, runId)).flatMap((kept) => {
326
+ const row = (kept.proposal ?? {});
327
+ const { compiled, draft_errors } = compiledOf(row);
328
+ // A compile the cap stopped (runner/reflect-hook.ts `capped`) closed its round with its turn's spend and no draft: no
329
+ // revision to serve, so its spend is unattributed, never its run's look-back.
330
+ if (!compiled)
331
+ return "compile_usd" in row ? [{ workflow: null, digest: null, usd: usdOrNull(row.compile_usd) }] : [];
332
+ const usd = "compile_usd" in row ? usdOrNull(row.compile_usd) : 0;
333
+ return [{ workflow: compiled.workflow, digest: compiled.digest && !draft_errors?.length ? compiled.digest : null, usd }];
334
+ });
335
+ }
336
+ /** A run's v2 learning (A8): what learning cost for it as the cost series counts it (its look-back, grades and audit
337
+ * shadow: `run.learning_usd`) less its compile turns (each its revision's), with its share of its revision's compile
338
+ * and check (`shares`: a missing entry is none, an unknown share stays unknown). Null while any part is unknown. */
339
+ function learningV2Of(run, compiles, shares) {
340
+ const compiled = compiles.reduce((sum, one) => (sum === null || one.usd === null ? null : sum + one.usd), 0);
341
+ const share = shares.has(run.run_id) ? shares.get(run.run_id) : 0;
342
+ if (run.learning_usd === null || compiled === null || share === null)
343
+ return null;
344
+ return noiseOff(Math.max(0, run.learning_usd - compiled) + share);
345
+ }
346
+ /** A run's v2 all-in: its own $ (the job's) and its v2 learning (learningV2Of); null when either is. */
347
+ function allInV2Of(run, compiles, shares) {
348
+ const learning = learningV2Of(run, compiles, shares);
349
+ return learning === null || run.cost_usd === null ? null : noiseOff(run.cost_usd + learning);
350
+ }
351
+ /** The agent's revision ledger (revisionLedgerOf) over `listed` (its runs, as runs.list read them): its ended runs that do
352
+ * a job or check one (no shadow, no imported or archived run), and the compile turns their rounds asked, by run. */
353
+ async function agentLedgerOf(records, promotions, listed) {
354
+ const rows = listed.filter((one) => FINAL_STATES.includes(one.state) && !one.importedFrom && one.archivedAt === null && !isShadowRun(one.id));
355
+ const compiles = new Map();
356
+ for (const row of rows) {
357
+ const asked = await compilesOf(records, row.id);
358
+ if (asked.length)
359
+ compiles.set(row.id, asked);
360
+ }
361
+ return { ...revisionLedgerOf(promotions, rows, [...compiles.values()].flat()), compiles };
362
+ }
363
+ /** Each revision of the agent's learned workflows (one per workflow and digest its promotion records name, in the order
364
+ * they were first recorded) with its learning spend, and what its served runs carry of it (amortize), over `rows`: the
365
+ * agent's ended runs that do a job or check one (no shadow, no imported or archived run). A revision is its workflow and
366
+ * its digest, never the digest alone: two workflows of the same text share a digest, and each pays its own way. Its
367
+ * spend is the compile turns that drafted it (`compiles` of its workflow at its digest: a recompile drafts a revision of
368
+ * its own) and its check (the replay runs that ran it: metrics.path `replay` of its workflow at its digest); unknown
369
+ * once a part's cost is (null, or only a bound). A compile whose drafts all failed drafted none: no revision carries it
370
+ * (the bill's unattributed does). It is spread over its first K served runs (`workflow` or `handed_back` of its workflow
371
+ * at its digest), K its check's compile_after; `state` from its newest record. */
372
+ export function revisionLedgerOf(records, rows, compiles = []) {
373
+ const ordered = [...rows].sort((a, b) => a.startedAt - b.startedAt || (a.id < b.id ? -1 : 1));
374
+ const newest = new Map();
375
+ for (const record of records)
376
+ newest.set(`${record.workflow}\0${record.digest}`, record);
377
+ const sum = (parts) => (parts.some((one) => one === null) ? null : noiseOff(parts.reduce((total, one) => total + one, 0)));
378
+ const ran = (row, record) => { const at = revisionOfRow(row); return at?.workflow === record.workflow && at.digest === record.digest; };
379
+ const revisions = [...newest.values()].map((record) => {
380
+ const replays = ordered.filter((row) => metricOf(row).path === "replay" && ran(row, record));
381
+ const check = sum(replays.map((row) => (typeof row.costAtMostUsd === "number" ? null : row.costUsd)));
382
+ const compile = sum(compiles.filter((one) => one.workflow === record.workflow && one.digest === record.digest).map((one) => one.usd));
383
+ const state = record.decided === "replaying" ? "checking" : championOf(records, record.workflow)?.digest === record.digest ? "serving" : "stopped";
384
+ return { workflow: record.workflow, digest: record.digest, compile_usd: compile, check_usd: check, spend_usd: sum([compile, check]), k: record.check?.compile_after ?? COMPILE_AFTER_DEFAULT, state };
385
+ });
386
+ const served = ordered.flatMap((row) => {
387
+ const at = revisionOfRow(row);
388
+ return SERVED_PATHS.includes(metricOf(row).path) && at ? [{ run_id: row.id, ...at }] : [];
389
+ });
390
+ return amortize(revisions, served);
391
+ }
392
+ /** Run `runId`'s path and its costs as GET /runs/{id} shows them (A8): `path` its record's (metrics.path, RUN_PATHS:
393
+ * `agent` for a run that does not learn; null while it has not ended, for a workflow revision's run, and for a run that
394
+ * learns whose end named none); `usd` its own spend, the job's (runCostOf's `cost_usd`: its row's cost, `rowUsd` when
395
+ * given, less its look-back and compile turns; null while unknown); `learning_usd` what learning spent for it: its
396
+ * look-back less its compile turns, its grades, its audit shadow's cost, and its share of its revision's compile and
397
+ * check (revisionLedgerOf); `all_in_usd` the two. A replay or a shadow run carries none: its spend is on the runs it
398
+ * serves, so its `learning_usd` and `all_in_usd` are 0, and the sum of every run's `all_in_usd` and the bill's
399
+ * `unattributed_usd` is the booked total. While the run is at work `usd` is `rowUsd` and the rest null; null while
400
+ * unknown (its shadow still at work, a grade's, a compile's or a check's cost unknown), never $0. Undefined for an
401
+ * unknown run. */
402
+ export async function runAllInOverStore(store, runId, rowUsd) {
403
+ const run = await store.runs.get(runId);
404
+ if (!run)
405
+ return undefined;
406
+ const row = rowUsd === undefined ? (typeof run.costAtMostUsd === "number" ? null : run.costUsd) : rowUsd;
407
+ const ended = FINAL_STATES.includes(run.state);
408
+ const kind = (await store.agents.revision(run.revisionId))?.kind;
409
+ const started = kind === "workflow" ? undefined : await learningStartOfRun(store, run.id).catch(() => undefined);
410
+ const path = !ended || kind === "workflow" ? null : (pathOfRow(run.metrics, started)?.path ?? null);
411
+ if (!ended)
412
+ return { path, usd: row, learning_usd: null, all_in_usd: null };
413
+ const { looked, grade } = await learningSpendOf(store, run.id, row);
414
+ const shadow = (await shadowSpendOf(store, run.id)).usd;
415
+ const cost = runCostOf(row, looked, grade === null || shadow === null ? null : grade + shadow);
416
+ if (path === "replay" || path === "audit" || isShadowRun(run.id))
417
+ return { path, usd: cost.cost_usd, learning_usd: 0, all_in_usd: 0 };
418
+ // Its share of its revision's compile and check: a served run's, over the agent's ledger.
419
+ let shares = new Map();
420
+ if (path !== null && SERVED_PATHS.includes(path) && revisionOfRow(run)) {
421
+ const listed = (await store.runs.list({ agentId: run.agentId })).filter((one) => one.agentId === run.agentId);
422
+ shares = (await agentLedgerOf(await agentRecordsOf(store, run.agentId, listed), await promotionsOf(store.settings, run.agentId), listed)).shares;
423
+ }
424
+ const figures = { run_id: run.id, ...cost };
425
+ const compiles = await compilesOf(store, run.id);
426
+ return { path, usd: cost.cost_usd, learning_usd: learningV2Of(figures, compiles, shares), all_in_usd: allInV2Of(figures, compiles, shares) };
287
427
  }
288
428
  /** The check the serving promotion was decided on, as the cost summary says it: the champion (championOf) of the learned
289
429
  * workflow the newest run a learned workflow ran first on ran (`workflow` or `handed_back`), its record's check numbers
@@ -388,7 +528,20 @@ export async function costRunOf(store, run, n) {
388
528
  export async function pastRunsOverStore(store, agentId, known, records = store) {
389
529
  const kinds = new Map();
390
530
  const kept = [];
391
- for (const run of await store.runs.list({ agentId, limit: PAST_RUNS })) {
531
+ const page = await store.runs.list({ agentId, limit: PAST_RUNS });
532
+ // Each run's audit shadow is read off the page (allInOf's shadowSpendOf): a shadow starts after the run it audits ends,
533
+ // so it is newer than that run and on the same page of the newest runs; one not on it was never started.
534
+ const shadows = new Map(page.filter((run) => isShadowRun(run.id)).map((run) => [run.id, run]));
535
+ const learningStart = records.runs.learningStart;
536
+ const paged = {
537
+ learning: records.learning,
538
+ runs: {
539
+ launch: (id) => records.runs.launch(id),
540
+ get: (id) => (isShadowRun(id) ? Promise.resolve(shadows.get(id)) : records.runs.get(id)),
541
+ ...(learningStart ? { learningStart: (id) => learningStart.call(records.runs, id) } : {}),
542
+ },
543
+ };
544
+ for (const run of page) {
392
545
  if (run.agentId !== agentId || !FINAL_STATES.includes(run.state) || run.importedFrom || run.archivedAt !== null || isShadowRun(run.id))
393
546
  continue;
394
547
  if (!kinds.has(run.revisionId))
@@ -399,7 +552,7 @@ export async function pastRunsOverStore(store, agentId, known, records = store)
399
552
  // A few reads a run, a batch at a time: a launch reads up to PAST_RUNS of them.
400
553
  const past = [];
401
554
  for (let at = 0; at < kept.length; at += 16) {
402
- past.push(...(await Promise.all(kept.slice(at, at + 16).map(async (run) => ({ metrics: run.metrics, startedAt: run.startedAt, allInUsd: known?.has(run.id) ? known.get(run.id) : (await allInOf(records, run)).total_usd })))));
555
+ past.push(...(await Promise.all(kept.slice(at, at + 16).map(async (run) => ({ metrics: run.metrics, startedAt: run.startedAt, allInUsd: known?.has(run.id) ? known.get(run.id) : (await allInOf(paged, run)).total_usd })))));
403
556
  }
404
557
  return past;
405
558
  }
@@ -1,4 +1,5 @@
1
1
  import { runReadState } from "./runs.js";
2
+ import { isShadowRun, shadowRunId } from "../learn/audit.js";
2
3
  const RUN_STATES = ["running", "completed", "failed", "stopped", "escalated"];
3
4
  const emptyCounts = () => ({ total: 0, running: 0, completed: 0, failed: 0, stopped: 0, escalated: 0 });
4
5
  /** Every agent, by name then id (the old order), with its archive and name. */
@@ -18,7 +19,12 @@ export async function stats(store) {
18
19
  const running = [];
19
20
  // Each revision's kind, read once: an agentic run a person stopped reads running (runReadState).
20
21
  const kinds = new Map();
22
+ // An audit's shadow run is learning spend on the run it audits, never a run of its own (A8): its cost, once known, is
23
+ // in the dollars with that run, shown or hidden with it; it is in no count, and never running work.
24
+ const shadows = new Map(runs.filter((run) => isShadowRun(run.id)).map((run) => [run.id, run]));
21
25
  for (const run of runs) {
26
+ if (isShadowRun(run.id))
27
+ continue;
22
28
  if (!kinds.has(run.revisionId))
23
29
  kinds.set(run.revisionId, (await store.agents.revision(run.revisionId))?.kind === "workflow" ? "workflow" : "agentic");
24
30
  const state = runReadState(run, kinds.get(run.revisionId));
@@ -31,7 +37,10 @@ export async function stats(store) {
31
37
  }
32
38
  let g = shown.get(run.agentId);
33
39
  if (g === undefined)
34
- shown.set(run.agentId, (g = { counts: emptyCounts(), costUsd: 0, known: 0 }));
40
+ shown.set(run.agentId, (g = { counts: emptyCounts(), costUsd: 0, known: 0, shadowUsd: 0 }));
41
+ const shadow = shadows.get(shadowRunId(run.id));
42
+ if (shadow && runReadState(shadow, "agentic") !== "running" && shadow.costUsd !== null)
43
+ g.shadowUsd += shadow.costUsd;
35
44
  g.counts.total += 1;
36
45
  g.counts[state] += 1;
37
46
  if (state !== "running" && run.costUsd !== null) {
@@ -54,8 +63,9 @@ export async function stats(store) {
54
63
  for (const key of ["total", ...RUN_STATES])
55
64
  stats.runs[key] += counts[key];
56
65
  const known = g?.known ?? 0;
57
- if (known > 0)
58
- stats.cost.usd = (stats.cost.usd ?? 0) + (g?.costUsd ?? 0);
66
+ // A shadow's known $ is spent whether or not the run it audits has a known cost: never a null for its dollars.
67
+ if (known > 0 || (g?.shadowUsd ?? 0) > 0)
68
+ stats.cost.usd = (stats.cost.usd ?? 0) + (g?.costUsd ?? 0) + (g?.shadowUsd ?? 0);
59
69
  stats.cost.known += known;
60
70
  stats.cost.unknown += counts.total - known;
61
71
  }
@@ -1,6 +1,7 @@
1
1
  import { type TimelineEvent } from "./timeline/index.js";
2
2
  import { type ItemStatus } from "./learning.js";
3
- import { type RunMoment, type SignInReader } from "./run-view.js";
3
+ import { type RunMoment, type SignInReader, type Status } from "./run-view.js";
4
+ import { type RunReadState } from "./store-reads/runs.js";
4
5
  import { type Store } from "./store/store.js";
5
6
  import type { RecordingView } from "./run-recordings.js";
6
7
  /** What the store-backed view needs beside the store: where its console lives, every secret it never shows (read now, so
@@ -25,6 +26,9 @@ export interface ViewDeps {
25
26
  * so a list, a poll or a status read opens no file. */
26
27
  readonly recordings?: (agentId: string, runId: string, endedAt: number | null) => Promise<RecordingView[]>;
27
28
  }
29
+ /** A settled run's v2 status from its row alone (STATUS_OF), the status its view reads (statusOf returns the outcome
30
+ * first); undefined for a run still going, whose status only its journal says. */
31
+ export declare const settledStatusOf: (state: RunReadState) => Status | undefined;
28
32
  /** A run's whole answer as answerOfRun read it from the rows: its newest final-answer row, never the learning turn's, and
29
33
  * never an earlier turn's: a final answer row before the person's last message belongs to the turn that message
30
34
  * followed, so a follow-up whose own stop said nothing (no text block: a thinking-only stop) has no answer, null, not
@@ -13,6 +13,7 @@ import { isObject } from "./validate.js";
13
13
  import { currentLearning, holdsForOk, learningView, LEARNING_LABEL, secretsShown, shortOf } from "./learning.js";
14
14
  import { said } from "./learning-words.js";
15
15
  import { CONTENT_FILTER_WORDS, contentFiltered, MODERATED } from "./content-filter.js";
16
+ import { COMPUTER_UNAVAILABLE_CODE, lostEndMessage } from "./computer-lost.js";
16
17
  import { launchOf } from "./handed-values.js";
17
18
  import { learningStartOf, seedFailed } from "./run-launch.js";
18
19
  import { momentOf, pendingOf, stoppedTurn, approvalOf, asksOf, answersOf, activePauseOf, budgetOf, browserPending, computerPending, redactorOf, servedRunErrorWith, servedReviewWith, statusOf, WITHHELD_SIGN_IN, WITHHELD_TITLE, costWordsOfView, freeOf, usersOf, withAsks, withApprovalRows, } from "./run-view.js";
@@ -21,7 +22,7 @@ import { freeCeilingMessage, overCapMessage, SPEND_CAP_REACHED } from "@parcha/a
21
22
  import { bookedSpend, cliModelWorked, costWordsOf, planSpend, runCostOf } from "./runner/metrics.js";
22
23
  import { journalRecords, recordOf } from "./runner/journal-reader.js";
23
24
  import { capNowOf, KINDS } from "./runner/journal-kinds.js";
24
- import { laidOf, notesReadOf, runLearningEnd, shadowSpendOf, usedOnly, withNotes } from "./store-reads/learning.js";
25
+ import { laidOf, notesReadOf, runLearningEnd, usedOnly, withNotes } from "./store-reads/learning.js";
25
26
  import { isCliRecord, runReflect, runTimeline, wholeAnswerFor, wholeAnswers, withoutFeedbackRounds } from "./store-reads/journal.js";
26
27
  import { readRun } from "./store-reads/runs.js";
27
28
  import { runCutValues, runErrorWordsOf, underCut } from "./run-cut.js";
@@ -35,6 +36,9 @@ import { FINAL_STATES, stoppedByPerson } from "./store/store.js";
35
36
  * review; a stopped run is a cancellation), as runs.ts's STATUS_OF mapped them. A running run reads its status from the
36
37
  * journal, and so does an agentic run a person stopped, which reads running (runReadState). */
37
38
  const STATUS_OF = { completed: "completed", failed: "failed", escalated: "completed", stopped: "cancelled" };
39
+ /** A settled run's v2 status from its row alone (STATUS_OF), the status its view reads (statusOf returns the outcome
40
+ * first); undefined for a run still going, whose status only its journal says. */
41
+ export const settledStatusOf = (state) => (state === "running" ? undefined : STATUS_OF[state]);
38
42
  /** A run that has reached a last state (its view is its ended shape). */
39
43
  const TERMINAL = new Set(["completed", "failed", "cancelled"]);
40
44
  const iso = (ms) => new Date(ms).toISOString();
@@ -81,13 +85,17 @@ export const answerOf = (timeline) => {
81
85
  /** A failed run's error from its row (its own words are the summary; the store keeps no code or detail apart). A run
82
86
  * its cap ended once its cost passed it (the kernel's overCapEnd) is code spend_cap_reached, its message the words after
83
87
  * the code, as main served it; a provider's content-filter stop is `moderated`, in words a person can act on
84
- * (content-filter.ts); every other failure is run_failed. */
88
+ * (content-filter.ts); a run whose sandbox was lost more times than its claim starts new ones (computer-lost.ts lostEnd)
89
+ * is computer_unavailable, its message the words after the code; every other failure is run_failed. */
85
90
  const errorOfRow = (summary) => {
86
91
  // A run that reached its limit of requests on free models (the kernel cap's freeCeilingEnd) ends as its cap ends one: code
87
92
  // spend_cap_reached, its message the words after the code.
88
93
  const over = overCapMessage(summary) ?? freeCeilingMessage(summary);
89
94
  if (over !== undefined)
90
95
  return { code: SPEND_CAP_REACHED, message: over, retryable: false };
96
+ const lost = lostEndMessage(summary);
97
+ if (lost !== undefined)
98
+ return { code: COMPUTER_UNAVAILABLE_CODE, message: lost, retryable: false };
91
99
  if (summary !== null && contentFiltered(summary))
92
100
  return { code: MODERATED, message: CONTENT_FILTER_WORDS, retryable: false };
93
101
  return { code: "run_failed", message: summary ?? "The run failed.", retryable: false };
@@ -319,14 +327,6 @@ function learningViewOf(learningEnd, shown, settled) {
319
327
  function underWay(started, laid, reflect, at) {
320
328
  return reflect ? { state: "reflecting", reason: null, detail: said.reflecting, at } : { state: "seeded", reason: null, detail: said.seeded(started.seedNotes ?? 0, laid.skills.length, laid.workflows.length), at };
321
329
  }
322
- /** A view's cost with its audit shadow run's (store-reads/learning.ts shadowSpendOf: unknown while it is queued or
323
- * running, 0 when none was started) added to `usd` (unknown once either is). */
324
- function withShadowCost(cost, shadow) {
325
- if (shadow === 0)
326
- return cost;
327
- const usd = typeof cost.usd === "number" && shadow !== null ? Math.round((cost.usd + shadow) * 1e6) / 1e6 : null;
328
- return { ...cost, usd };
329
- }
330
330
  /** The cost a run's view shows (runs.ts cost): its rows' cost, else what the store kept, and its cap. */
331
331
  function costOfView(run) {
332
332
  const imported = Boolean(run.row.importedFrom);
@@ -460,7 +460,8 @@ export async function viewOverStore(store, runId, deps) {
460
460
  error,
461
461
  review,
462
462
  pending,
463
- cost: withShadowCost(costOfView(run), (await shadowSpendOf(store, runId)).usd),
463
+ // Its own spend: an audit's shadow run of it is learning (GET /runs/{id}'s cost.learning_usd), never its cost.usd.
464
+ cost: costOfView(run),
464
465
  // The run an audit's shadow run audits (launch.audit, runner/audit.ts); null for any other run.
465
466
  audit_of: launch?.audit?.of ?? null,
466
467
  // Whether it ran unattended (its revision's approvals, as it started): never, an ask allowed at its gate; ask, the default.
@@ -0,0 +1,59 @@
1
+ /** Where events go: PostHog's capture route, behind this project's own name. */
2
+ export declare const TELEMETRY_URL = "https://telemetry.agentrun.ai/i/v0/e/";
3
+ /** The project's write-only key, public by design. Empty: this build sends nothing and prints no notice. */
4
+ export declare const TELEMETRY_KEY = "";
5
+ /** The file in the data directory that keeps the id, when the notice was printed and how many runs ended. */
6
+ export declare const TELEMETRY_FILE = ".telemetry.json";
7
+ /** How often a running server says it still runs. */
8
+ export declare const HEARTBEAT_MS: number;
9
+ export declare const TELEMETRY_NOTICE = "AgentRun sends anonymous usage counts (a random id, the version, the platform, how many runs as a range): never prompts, files, keys or names. Nothing was sent at this start. Turn it off with AGENTRUN_TELEMETRY=0 or DO_NOT_TRACK=1. Every field: https://github.com/Parcha-ai/agentrun/blob/main/docs/telemetry.md";
10
+ export type TelemetryEventName = "server_started" | "heartbeat" | "first_run_completed";
11
+ /** One event, as sent. `runs` is a range, never a count. */
12
+ export interface TelemetryEvent {
13
+ event: TelemetryEventName;
14
+ distinct_id: string;
15
+ timestamp: string;
16
+ properties: {
17
+ version: string;
18
+ os: string;
19
+ arch: string;
20
+ node: number;
21
+ runs: RunsRange;
22
+ $process_person_profile: false;
23
+ $geoip_disable: true;
24
+ };
25
+ }
26
+ export type RunsRange = "0" | "1-10" | "11-100" | "101+";
27
+ /** Why nothing is sent, or "on" / "debug" (events printed to stderr, none sent). */
28
+ export type TelemetryMode = "on" | "debug" | "off_setting" | "off_do_not_track" | "off_ci" | "off_faux" | "off_no_key";
29
+ /** What this start does, from its environment: the operator's own setting first, then DO_NOT_TRACK, CI and --faux. */
30
+ export declare function telemetryMode(env: NodeJS.ProcessEnv, o?: {
31
+ faux?: boolean;
32
+ key?: string;
33
+ }): TelemetryMode;
34
+ export declare const runsRange: (runs: number) => RunsRange;
35
+ export interface Telemetry {
36
+ mode: TelemetryMode;
37
+ /** The line to print once, at the start that first could send; undefined at every other. */
38
+ notice?: string;
39
+ /** A run reached its end here. `status` is the runner's (`ended` is a completed run). */
40
+ runEnded(status: string): void;
41
+ /** Stops the heartbeat and waits for the count's last write. Sends nothing. */
42
+ close(): Promise<void>;
43
+ }
44
+ export interface TelemetryOptions {
45
+ data: string;
46
+ /** The server's version (default: this package's). */
47
+ version?: string;
48
+ env?: NodeJS.ProcessEnv;
49
+ faux?: boolean;
50
+ /** For tests: the key, the route, the sender, the clock, the heartbeat's period and where debug lines go. */
51
+ key?: string;
52
+ url?: string;
53
+ fetch?: typeof fetch;
54
+ now?: () => Date;
55
+ heartbeatMs?: number;
56
+ say?: (line: string) => void;
57
+ }
58
+ /** Starts the counts for a server on `data`. Never throws: a data directory it cannot write turns it off. */
59
+ export declare function startTelemetry(o: TelemetryOptions): Telemetry;
@@ -0,0 +1,153 @@
1
+ // Anonymous usage counts (docs/telemetry.md): that a server started, that it is still running a day later, and that its
2
+ // first run completed. Each event holds a random id made for this data directory, the server's version, the platform,
3
+ // and how many runs ended here as a range. It never holds a prompt, a workflow, a key, a name, a path or an address.
4
+ //
5
+ // Off with AGENTRUN_TELEMETRY=0 or DO_NOT_TRACK=1, in CI, and under --faux. The start that first could send prints one
6
+ // notice and sends nothing at its start, so a person reads how to turn it off before anything leaves the machine.
7
+ // AGENTRUN_TELEMETRY=debug prints every event and sends none; it never stands in for that notice.
8
+ // Sending never delays a start, a run or a stop, and a send that fails is dropped without a word. A run's end is counted
9
+ // in memory and written behind it, one write at a time, so no request or run waits on the disk.
10
+ import { randomUUID } from "node:crypto";
11
+ import { readFileSync } from "node:fs";
12
+ import { rename, unlink, writeFile } from "node:fs/promises";
13
+ import { join } from "node:path";
14
+ import { tempOf, writeDurableSync } from "./server-fs.js";
15
+ /** Where events go: PostHog's capture route, behind this project's own name. */
16
+ export const TELEMETRY_URL = "https://telemetry.agentrun.ai/i/v0/e/";
17
+ /** The project's write-only key, public by design. Empty: this build sends nothing and prints no notice. */
18
+ export const TELEMETRY_KEY = "";
19
+ /** The file in the data directory that keeps the id, when the notice was printed and how many runs ended. */
20
+ export const TELEMETRY_FILE = ".telemetry.json";
21
+ /** How often a running server says it still runs. */
22
+ export const HEARTBEAT_MS = 24 * 60 * 60 * 1000;
23
+ /** How long one send may take before it is dropped. */
24
+ const SEND_TIMEOUT_MS = 3_000;
25
+ const ownVersion = () => JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
26
+ export const TELEMETRY_NOTICE = "AgentRun sends anonymous usage counts (a random id, the version, the platform, how many runs as a range): never prompts, files, keys or names. Nothing was sent at this start. Turn it off with AGENTRUN_TELEMETRY=0 or DO_NOT_TRACK=1. Every field: https://github.com/Parcha-ai/agentrun/blob/main/docs/telemetry.md";
27
+ const OFF = new Set(["0", "false", "off", "no"]);
28
+ /** What this start does, from its environment: the operator's own setting first, then DO_NOT_TRACK, CI and --faux. */
29
+ export function telemetryMode(env, o = {}) {
30
+ const setting = (env.AGENTRUN_TELEMETRY ?? "").trim().toLowerCase();
31
+ if (OFF.has(setting))
32
+ return "off_setting";
33
+ const dnt = (env.DO_NOT_TRACK ?? "").trim().toLowerCase();
34
+ if (dnt !== "" && !OFF.has(dnt))
35
+ return "off_do_not_track";
36
+ if (env.CI)
37
+ return "off_ci";
38
+ if (o.faux)
39
+ return "off_faux";
40
+ if (setting === "debug")
41
+ return "debug";
42
+ return (o.key ?? TELEMETRY_KEY) === "" ? "off_no_key" : "on";
43
+ }
44
+ export const runsRange = (runs) => (runs <= 0 ? "0" : runs <= 10 ? "1-10" : runs <= 100 ? "11-100" : "101+");
45
+ /** The kept state, or a new one when the file is missing or not what this wrote. */
46
+ function readState(file) {
47
+ try {
48
+ const kept = JSON.parse(readFileSync(file, "utf8"));
49
+ if (kept && typeof kept.id === "string" && /^[0-9a-f-]{36}$/.test(kept.id)) {
50
+ return {
51
+ id: kept.id,
52
+ runs: typeof kept.runs === "number" && Number.isInteger(kept.runs) && kept.runs >= 0 ? kept.runs : 0,
53
+ ...(typeof kept.noticed_at === "string" ? { noticed_at: kept.noticed_at } : {}),
54
+ ...(kept.first_run_sent === true ? { first_run_sent: true } : {}),
55
+ };
56
+ }
57
+ }
58
+ catch {
59
+ // Missing or unreadable: a new id, and the notice again.
60
+ }
61
+ return { id: randomUUID(), runs: 0 };
62
+ }
63
+ /** Starts the counts for a server on `data`. Never throws: a data directory it cannot write turns it off. */
64
+ export function startTelemetry(o) {
65
+ const env = o.env ?? process.env;
66
+ const key = o.key ?? TELEMETRY_KEY;
67
+ const mode = telemetryMode(env, { ...(o.faux ? { faux: true } : {}), key });
68
+ const idle = { mode, runEnded: () => { }, close: () => Promise.resolve() };
69
+ if (mode !== "on" && mode !== "debug")
70
+ return idle;
71
+ const file = join(o.data, TELEMETRY_FILE);
72
+ const now = o.now ?? (() => new Date());
73
+ const say = o.say ?? ((line) => void process.stderr.write(`${line}\n`));
74
+ const send = o.fetch ?? fetch;
75
+ const state = readState(file);
76
+ const version = o.version ?? ownVersion();
77
+ const text = () => `${JSON.stringify(state)}\n`;
78
+ // The start's one write, durable before anything is sent: the id, and the notice's time when this start prints it.
79
+ const keepNow = () => {
80
+ try {
81
+ writeDurableSync(file, text());
82
+ return true;
83
+ }
84
+ catch {
85
+ return false;
86
+ }
87
+ };
88
+ // Every later write (a run's end) goes behind the caller: one at a time, the latest state each time, so ends that come
89
+ // together make one write and none waits on the disk. A write that fails is dropped; the next end writes again.
90
+ // Each goes through a temporary file of its own: a server that takes this data directory while this one still stops
91
+ // never shares one with it. The two can still each write the file whole, last one kept, so a restart that overlaps a
92
+ // run's end may count a few runs short: the count is sent as a range, and nothing else is kept here.
93
+ const whole = async () => {
94
+ const temp = tempOf(file);
95
+ try {
96
+ await writeFile(temp, text(), { mode: 0o600 });
97
+ await rename(temp, file);
98
+ }
99
+ catch {
100
+ await unlink(temp).catch(() => { });
101
+ }
102
+ };
103
+ let stale = false;
104
+ let writing;
105
+ const keepLater = () => {
106
+ stale = true;
107
+ writing ??= (async () => {
108
+ while (stale) {
109
+ stale = false;
110
+ await whole();
111
+ }
112
+ writing = undefined;
113
+ })();
114
+ };
115
+ // The start that first could send: the notice, kept before anything is sent. If it cannot be kept, the next start would
116
+ // print it again and still send nothing, so this one stays quiet too. Debug sends nothing and prints no notice, so it
117
+ // never marks the notice as read: a start that can send after it still prints the notice and holds its first event.
118
+ const first = mode === "on" && state.noticed_at === undefined;
119
+ if (first)
120
+ state.noticed_at = now().toISOString();
121
+ if (!keepNow())
122
+ return { ...idle, mode: "off_setting" };
123
+ const emit = (event) => {
124
+ const body = {
125
+ event,
126
+ distinct_id: state.id,
127
+ timestamp: now().toISOString(),
128
+ properties: { version, os: process.platform, arch: process.arch, node: Number(process.versions.node.split(".")[0]), runs: runsRange(state.runs), $process_person_profile: false, $geoip_disable: true },
129
+ };
130
+ if (mode === "debug")
131
+ return say(`agentrun-serve telemetry (debug, not sent): ${JSON.stringify(body)}`);
132
+ void send(o.url ?? TELEMETRY_URL, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ api_key: key, ...body }), signal: AbortSignal.timeout(SEND_TIMEOUT_MS) }).then(() => { }, () => { });
133
+ };
134
+ if (!first)
135
+ emit("server_started");
136
+ // A server that stays up is counted by its heartbeat, the first start's too: a day after the notice.
137
+ const beat = setInterval(() => emit("heartbeat"), o.heartbeatMs ?? HEARTBEAT_MS);
138
+ beat.unref();
139
+ return {
140
+ mode,
141
+ ...(first ? { notice: TELEMETRY_NOTICE } : {}),
142
+ runEnded(status) {
143
+ state.runs += 1;
144
+ const completed = status === "ended" && !state.first_run_sent;
145
+ if (completed)
146
+ state.first_run_sent = true;
147
+ keepLater();
148
+ if (completed)
149
+ emit("first_run_completed");
150
+ },
151
+ close: () => (clearInterval(beat), writing ?? Promise.resolve()),
152
+ };
153
+ }
@@ -69,7 +69,7 @@ declare class ToolKeysOverStore {
69
69
  at: string;
70
70
  } | null;
71
71
  unlocks: string[];
72
- harnesses: ("opencode" | "codex" | "pi" | "claude-agent")[];
72
+ harnesses: ("opencode" | "codex" | "claude-agent" | "pi")[];
73
73
  id: string;
74
74
  kind: "model" | "tool";
75
75
  label: string;
@@ -58,7 +58,7 @@ export declare function unlockedBy(candidates: readonly string[], tools: readonl
58
58
  id: string;
59
59
  }[]): {
60
60
  unlocks: string[];
61
- harnesses: ("opencode" | "codex" | "pi" | "claude-agent")[];
61
+ harnesses: ("opencode" | "codex" | "claude-agent" | "pi")[];
62
62
  };
63
63
  /** What a row unlocks here: a `tool` row's, its tools and providers as capabilities bind them (unlockedBy); any other
64
64
  * kind's (a model's), no tool, on those that run on it (its `harnesses`, when it names them) that this server runs
@@ -77,7 +77,7 @@ export declare function rowUnlocks(row: {
77
77
  keys?: readonly string[];
78
78
  }[]): {
79
79
  unlocks: string[];
80
- harnesses: ("opencode" | "codex" | "pi" | "claude-agent")[];
80
+ harnesses: ("opencode" | "codex" | "claude-agent" | "pi")[];
81
81
  };
82
82
  /** Whether a key row's `unlock` unlocks the tool `name`: by its name, or `<source>:*` for every tool of a catalog source
83
83
  * (`monid:*`: `monid:apollo/people/match`, `monid:apollo/*`). */
@@ -39,11 +39,11 @@ export declare const permissionsOf: (name: string) => readonly Permission[];
39
39
  * give it: the one in force under the server's settings (`permission`), the owner's default (`default_permission`) and
40
40
  * those it may be set to. An agent's read gives the same, the agent's own layer over it (agentTools). */
41
41
  export declare const serverGate: (name: string, settings: ToolSettingsMap, effect?: ToolEffect) => {
42
- default_permission: "allow" | "ask" | "deny";
43
- permissions: ("allow" | "ask" | "deny")[];
42
+ default_permission: "ask" | "allow" | "deny";
43
+ permissions: ("ask" | "allow" | "deny")[];
44
44
  fallback_allow_reads?: true | undefined;
45
45
  allow_reads?: true | undefined;
46
- permission: "allow" | "ask" | "deny";
46
+ permission: "ask" | "allow" | "deny";
47
47
  };
48
48
  /** The run's own tools beyond the table, each its own settings key, allowed by default like a table tool: the learned
49
49
  * workflow a run's pin names runs as `learned_workflow` (learned-workflow.ts LEARNED_WORKFLOW_TOOL), and the host's
@@ -285,17 +285,17 @@ export declare function shellUnavailable(name: string, shell: ShellPlace): Resol
285
285
  * computer setting); a tool of bash's family that leaves out resolves unavailable, saying why (shellUnavailable). */
286
286
  export declare function agentTools(env: NodeJS.ProcessEnv, settings: ToolSettingsMap, agent: Tooling, order: readonly string[], shell?: ShellPlace, effectOf?: (name: string) => ToolEffect | undefined): ({
287
287
  resolved: Resolution;
288
- permission: "allow" | "ask" | "deny";
288
+ permission: "ask" | "allow" | "deny";
289
289
  permission_from: import("./refusal-words.js").SettingFrom;
290
- default_permission: "allow" | "ask" | "deny";
291
- permissions: ("allow" | "ask" | "deny")[];
290
+ default_permission: "ask" | "allow" | "deny";
291
+ permissions: ("ask" | "allow" | "deny")[];
292
292
  blurb?: string | undefined;
293
293
  name: string;
294
294
  } | {
295
- permission: "allow" | "ask" | "deny";
295
+ permission: "ask" | "allow" | "deny";
296
296
  permission_from: import("./refusal-words.js").SettingFrom;
297
- default_permission: "allow" | "ask" | "deny";
298
- permissions: ("allow" | "ask" | "deny")[];
297
+ default_permission: "ask" | "allow" | "deny";
298
+ permissions: ("ask" | "allow" | "deny")[];
299
299
  blurb?: string | undefined;
300
300
  name: string;
301
301
  } | {
@@ -303,10 +303,10 @@ export declare function agentTools(env: NodeJS.ProcessEnv, settings: ToolSetting
303
303
  provider_from: string;
304
304
  default_provider: string;
305
305
  resolved: Resolution;
306
- permission: "allow" | "ask" | "deny";
306
+ permission: "ask" | "allow" | "deny";
307
307
  permission_from: import("./refusal-words.js").SettingFrom;
308
- default_permission: "allow" | "ask" | "deny";
309
- permissions: ("allow" | "ask" | "deny")[];
308
+ default_permission: "ask" | "allow" | "deny";
309
+ permissions: ("ask" | "allow" | "deny")[];
310
310
  blurb?: string | undefined;
311
311
  name: string;
312
312
  })[];