@parcha/agentrun-serve 0.1.0-beta.50 → 0.1.0-beta.52
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 +185 -0
- package/README.md +236 -30
- package/dist/adapters.js +1 -1
- package/dist/agent-delete.d.ts +13 -2
- package/dist/agent-delete.js +14 -5
- package/dist/agents-store.d.ts +5 -1
- package/dist/agents-store.js +17 -7
- package/dist/api-only.d.ts +6 -3
- package/dist/api-only.js +8 -5
- package/dist/archil-routes.d.ts +1 -0
- package/dist/archil-routes.js +28 -2
- package/dist/capacity.d.ts +50 -0
- package/dist/capacity.js +49 -0
- package/dist/cli-learning/claude-wire.d.ts +41 -0
- package/dist/cli-learning/claude-wire.js +258 -0
- package/dist/cli-learning/cli.d.ts +11 -0
- package/dist/cli-learning/cli.js +241 -0
- package/dist/cli-learning/codex-worktree.d.ts +10 -0
- package/dist/cli-learning/codex-worktree.js +119 -0
- package/dist/cli-learning/connections.d.ts +62 -0
- package/dist/cli-learning/connections.js +87 -0
- package/dist/cli-learning/entry.d.ts +1 -0
- package/dist/cli-learning/entry.js +4 -0
- package/dist/cli-learning/evidence.d.ts +78 -0
- package/dist/cli-learning/evidence.js +492 -0
- package/dist/cli-learning/hook.d.ts +33 -0
- package/dist/cli-learning/hook.js +544 -0
- package/dist/cli-learning/install.d.ts +33 -0
- package/dist/cli-learning/install.js +335 -0
- package/dist/cli-learning/observation-proof.d.ts +14 -0
- package/dist/cli-learning/observation-proof.js +10 -0
- package/dist/cli-learning/policy.d.ts +48 -0
- package/dist/cli-learning/policy.js +363 -0
- package/dist/cli-learning/schema.d.ts +16 -0
- package/dist/cli-learning/schema.js +27 -0
- package/dist/cli-learning/state.d.ts +23 -0
- package/dist/cli-learning/state.js +61 -0
- package/dist/cli.js +24 -2
- package/dist/computer-setting.d.ts +8 -0
- package/dist/computer-setting.js +11 -0
- package/dist/computers.d.ts +6 -2
- package/dist/computers.js +2 -2
- package/dist/console/assets/index-B-D0EM3j.js +733 -0
- package/dist/console/assets/{index-D0mr9wfZ.css → index-DlQepP2J.css} +1 -1
- package/dist/console/index.html +2 -2
- package/dist/email/email-faux.d.ts +3 -1
- package/dist/email/email-faux.js +3 -2
- package/dist/email/routes.js +22 -12
- package/dist/fal-price.d.ts +76 -0
- package/dist/fal-price.js +368 -0
- package/dist/harness-install.d.ts +6 -2
- package/dist/harness-install.js +40 -8
- package/dist/harness.d.ts +1 -1
- package/dist/harness.js +2 -2
- package/dist/learn/commit.d.ts +5 -0
- package/dist/learn/commit.js +4 -1
- package/dist/learn/compile.d.ts +13 -5
- package/dist/learn/compile.js +24 -7
- package/dist/learn/delete.d.ts +12 -6
- package/dist/learn/delete.js +17 -11
- package/dist/learn/folder.d.ts +11 -0
- package/dist/learn/folder.js +20 -3
- package/dist/learn/learning-of.d.ts +8 -0
- package/dist/learn/learning-of.js +8 -0
- package/dist/learn/learning.sh +14 -1
- package/dist/learn/promote.d.ts +51 -7
- package/dist/learn/promote.js +51 -8
- package/dist/learn/secrets.js +14 -3
- package/dist/learning-reset.d.ts +18 -0
- package/dist/learning-reset.js +115 -0
- package/dist/learning-routes.d.ts +1 -1
- package/dist/learning-words.d.ts +6 -1
- package/dist/learning-words.js +6 -1
- package/dist/learning.d.ts +8 -6
- package/dist/learning.js +5 -4
- package/dist/llms.txt +1 -0
- package/dist/mcp-gateway.d.ts +39 -2
- package/dist/mcp-gateway.js +41 -10
- package/dist/mcp-pin-first.js +3 -2
- package/dist/mcp-private-hosts.d.ts +24 -3
- package/dist/mcp-private-hosts.js +53 -3
- package/dist/mcp-servers-store.d.ts +1 -0
- package/dist/mcp-servers-store.js +2 -1
- package/dist/media-duration.d.ts +2 -0
- package/dist/media-duration.js +136 -0
- package/dist/model-gateway.d.ts +2 -0
- package/dist/model-gateway.js +3 -1
- package/dist/native/runtimes.d.ts +2 -0
- package/dist/native/runtimes.js +2 -0
- package/dist/observation/learning.d.ts +32 -0
- package/dist/observation/learning.js +66 -0
- package/dist/observation/observer.d.ts +8 -1
- package/dist/observation/observer.js +89 -9
- package/dist/observation/schema.js +12 -4
- package/dist/observation/usage-identity.d.ts +9 -0
- package/dist/observation/usage-identity.js +11 -0
- package/dist/openapi.js +133 -24
- package/dist/provider.d.ts +8 -0
- package/dist/provider.js +14 -2
- package/dist/refusal-words.d.ts +0 -3
- package/dist/refusal-words.js +0 -3
- package/dist/request-metadata.d.ts +20 -0
- package/dist/request-metadata.js +24 -0
- package/dist/run-launch.d.ts +27 -4
- package/dist/run-launch.js +18 -3
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-usage.d.ts +48 -4
- package/dist/run-usage.js +156 -39
- package/dist/run-view.d.ts +2 -0
- package/dist/run-view.js +8 -7
- package/dist/runner/adapter-loop.d.ts +3 -1
- package/dist/runner/adapter-loop.js +41 -35
- package/dist/runner/adapter-run-spec.d.ts +1 -1
- package/dist/runner/adapter-run-spec.js +15 -15
- package/dist/runner/audit.d.ts +8 -3
- package/dist/runner/audit.js +21 -6
- package/dist/runner/beside.d.ts +13 -0
- package/dist/runner/beside.js +27 -8
- package/dist/runner/claim-secrets.d.ts +2 -1
- package/dist/runner/claim-secrets.js +5 -3
- package/dist/runner/cli-run-spec.d.ts +1 -1
- package/dist/runner/cli-run-spec.js +14 -13
- package/dist/runner/conformance/harness.js +4 -2
- package/dist/runner/disk-free.d.ts +44 -0
- package/dist/runner/disk-free.js +96 -0
- package/dist/runner/dispatch.js +4 -2
- package/dist/runner/feedback-round.d.ts +12 -8
- package/dist/runner/feedback-round.js +16 -30
- package/dist/runner/harness-loops.js +8 -3
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/learning-end.d.ts +2 -1
- package/dist/runner/learning-end.js +51 -22
- package/dist/runner/main.d.ts +17 -6
- package/dist/runner/main.js +187 -45
- package/dist/runner/mcp-claim.js +1 -1
- package/dist/runner/mcp-run.d.ts +9 -0
- package/dist/runner/mcp-run.js +16 -1
- package/dist/runner/model-route.js +7 -4
- package/dist/runner/presence.d.ts +11 -2
- package/dist/runner/presence.js +31 -3
- package/dist/runner/promotion.d.ts +40 -21
- package/dist/runner/promotion.js +130 -59
- package/dist/runner/run-child-host.d.ts +12 -15
- package/dist/runner/run-child-host.js +52 -112
- package/dist/runner/run-errors.js +2 -0
- package/dist/runner/runner-check.d.ts +51 -0
- package/dist/runner/runner-check.js +206 -0
- package/dist/runner/runner-metrics.d.ts +19 -0
- package/dist/runner/runner-metrics.js +49 -0
- package/dist/runner/runner.d.ts +37 -0
- package/dist/runner/runner.js +58 -6
- package/dist/runner/sdk-loop.d.ts +2 -2
- package/dist/runner/sdk-loop.js +37 -25
- package/dist/runner/store-port.d.ts +3 -0
- package/dist/runner/workflow-spec.js +3 -3
- package/dist/runs-over-store.d.ts +13 -3
- package/dist/runs-over-store.js +71 -16
- package/dist/sdk/check.d.ts +6 -5
- package/dist/sdk/check.js +17 -16
- package/dist/sdk/runs.d.ts +22 -2
- package/dist/sdk/runs.js +167 -82
- package/dist/server.d.ts +3 -0
- package/dist/server.js +230 -43
- package/dist/skills/agentrun-serve/SKILL.md +52 -7
- package/dist/start-switches.js +2 -0
- package/dist/stats.d.ts +4 -0
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.d.ts +16 -0
- package/dist/store/agent-body.js +20 -3
- package/dist/store/dialect.d.ts +2 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.d.ts +2 -0
- package/dist/store/journal/storage.js +2 -1
- package/dist/store/postgres/connection.d.ts +5 -2
- package/dist/store/postgres/connection.js +19 -7
- package/dist/store/postgres/dialect.js +1 -0
- package/dist/store/postgres/migrate.d.ts +30 -0
- package/dist/store/postgres/migrate.js +72 -5
- package/dist/store/postgres/migration-lint.d.ts +8 -0
- package/dist/store/postgres/migration-lint.js +119 -0
- package/dist/store/postgres/migrations/0024_runner_capacity.sql +28 -0
- package/dist/store/postgres/migrations/0025_run_attempts.sql +27 -0
- package/dist/store/postgres/migrations/0026_run_disk.sql +23 -0
- package/dist/store/postgres/store.d.ts +8 -3
- package/dist/store/postgres/store.js +31 -11
- package/dist/store/schema.d.ts +32 -2
- package/dist/store/schema.js +74 -5
- package/dist/store/sqlite/run-launch.d.ts +31 -1
- package/dist/store/sqlite/run-launch.js +111 -2
- package/dist/store/sqlite/run-patch.d.ts +2 -1
- package/dist/store/sqlite/run-patch.js +4 -3
- package/dist/store/sqlite/store.d.ts +17 -0
- package/dist/store/sqlite/store.js +226 -37
- package/dist/store/store-schema.d.ts +34 -0
- package/dist/store/store-schema.js +125 -0
- package/dist/store/store.d.ts +120 -5
- package/dist/store/store.js +13 -0
- package/dist/store-reads/analytics.d.ts +3 -2
- package/dist/store-reads/analytics.js +20 -8
- package/dist/store-reads/learning.d.ts +12 -8
- package/dist/store-reads/learning.js +33 -24
- package/dist/store-reads/loop.d.ts +4 -3
- package/dist/store-reads/loop.js +7 -5
- package/dist/store-view.d.ts +4 -3
- package/dist/store-view.js +11 -7
- package/dist/template-eval.js +4 -4
- package/dist/templates.d.ts +6 -2
- package/dist/templates.js +7 -5
- package/dist/timeline/labels.js +1 -1
- package/dist/tool-gate.d.ts +4 -2
- package/dist/tools.js +1 -1
- package/dist/unified-usage.d.ts +24 -0
- package/dist/unified-usage.js +400 -0
- package/dist/uploads-archil.d.ts +100 -0
- package/dist/uploads-archil.js +431 -0
- package/dist/uploads.d.ts +52 -1
- package/dist/uploads.js +186 -108
- package/dist/validate.js +5 -1
- package/dist/web-save.d.ts +3 -0
- package/dist/web-save.js +17 -2
- package/dist/workspace/archil-disk.d.ts +6 -5
- package/dist/workspace/archil-disk.js +27 -12
- package/dist/workspace/archil-exec.js +1 -1
- package/dist/workspace/archil.js +4 -3
- package/dist/workspace/revision-skills.js +24 -11
- package/dist/workspace/synced-folder.d.ts +3 -3
- package/dist/workspace/synced-folder.js +7 -6
- package/package.json +10 -10
- package/skills/agentrun-serve/SKILL.md +52 -7
- package/dist/console/assets/index-D7G6o-1E.js +0 -720
|
@@ -8,7 +8,7 @@ import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
|
8
8
|
import { currentLearning, holdsForOk, LEARNING_REASONS } from "../learning.js";
|
|
9
9
|
import { runLearningBody } from "../learning-routes.js";
|
|
10
10
|
import { learningStartOf, learningStartOfStored, readLaunchBody, seedFailed } from "../run-launch.js";
|
|
11
|
-
import { said,
|
|
11
|
+
import { said, seedStopped } from "../learning-words.js";
|
|
12
12
|
import { learningImpact } from "../learning-run.js";
|
|
13
13
|
import { amortize, billOf, costSummary, JOB_PATHS, noiseOff, RUN_PATHS, runCostOf, SERVED_PATHS, tookOverOf } from "../learning-cost.js";
|
|
14
14
|
import { COMPILE_AFTER_DEFAULT } from "../learning-setting.js";
|
|
@@ -20,9 +20,9 @@ import { correctionCount } from "../learn/corrections.js";
|
|
|
20
20
|
import { runEntries, runReflect, runTimeline, withoutFeedbackRounds } from "./journal.js";
|
|
21
21
|
import { FINAL_STATES, StoreLaunchMissing } from "../store/store.js";
|
|
22
22
|
import { KINDS } from "../runner/journal-kinds.js";
|
|
23
|
-
import { promotedOf } from "../learn/compile.js";
|
|
23
|
+
import { promotedOf, sinceReset } from "../learn/compile.js";
|
|
24
24
|
import { isShadowRun, shadowRunId } from "../learn/audit.js";
|
|
25
|
-
import { championOf, checkShares, gradesOf, gradeView, promotionsOf } from "../learn/promote.js";
|
|
25
|
+
import { championOf, checkShares, gradesOf, gradeView, promotionsOf, resetLedgerOf } from "../learn/promote.js";
|
|
26
26
|
const timeOf = (ms) => new Date(ms).toISOString();
|
|
27
27
|
const usdOrNull = (value) => (typeof value === "number" && Number.isFinite(value) ? value : null);
|
|
28
28
|
const textOrNull = (value) => (typeof value === "string" ? value : null);
|
|
@@ -251,8 +251,9 @@ export async function agentCostOverStore(store, agentId, limit = Infinity) {
|
|
|
251
251
|
const replay = servingReplayOf(promotions, runs);
|
|
252
252
|
// The owner's bill: booked $, every run of the series (billOf), from the series' first run on a served path (the
|
|
253
253
|
// summary's takeover: read from the run rows by their place, as the promotion feed is trimmed and its oldest record need
|
|
254
|
-
// not be the first promotion), and each revision's compile and check over the served runs that carry it
|
|
255
|
-
|
|
254
|
+
// not be the first promotion), and each revision's compile and check over the served runs that carry it: runs on no
|
|
255
|
+
// named disk alone, as a run on one learns nothing and serves nothing (learn/learning-of.ts).
|
|
256
|
+
const ledger = await agentLedgerOf(records, promotions, listed.filter((run) => run.disk === null), await resetLedgerOf(store.settings, agentId));
|
|
256
257
|
const summary = costSummary(runs, replay);
|
|
257
258
|
const booked = billOf(runs, summary);
|
|
258
259
|
// What no run carries is the booked total less every run's all-in (A8), so a revision whose records aged out of the
|
|
@@ -315,7 +316,7 @@ function allInV2Of(run, compiles, shares) {
|
|
|
315
316
|
}
|
|
316
317
|
/** The agent's revision ledger (revisionLedgerOf) over `listed` (its runs, as runs.list read them): its ended runs that do
|
|
317
318
|
* a job or check one (no shadow, no imported or archived run), and the compile turns their rounds asked, by run. */
|
|
318
|
-
async function agentLedgerOf(records, promotions, listed) {
|
|
319
|
+
async function agentLedgerOf(records, promotions, listed, reset) {
|
|
319
320
|
const rows = listed.filter((one) => FINAL_STATES.includes(one.state) && !one.importedFrom && one.archivedAt === null && !isShadowRun(one.id));
|
|
320
321
|
const compiles = new Map();
|
|
321
322
|
for (const row of rows) {
|
|
@@ -323,7 +324,7 @@ async function agentLedgerOf(records, promotions, listed) {
|
|
|
323
324
|
if (asked.length)
|
|
324
325
|
compiles.set(row.id, asked);
|
|
325
326
|
}
|
|
326
|
-
return { ...revisionLedgerOf(promotions, rows, [...compiles.values()].flat()), compiles };
|
|
327
|
+
return { ...revisionLedgerOf(promotions, rows, [...compiles.values()].flat(), reset), compiles };
|
|
327
328
|
}
|
|
328
329
|
/** Each revision of the agent's learned workflows (one per workflow and digest its promotion records name, in the order
|
|
329
330
|
* they were first recorded) with its learning spend, and what its served runs carry of it (amortize), over `rows`: the
|
|
@@ -333,21 +334,26 @@ async function agentLedgerOf(records, promotions, listed) {
|
|
|
333
334
|
* its own) and its check (the replay runs that ran it: metrics.path `replay` of its workflow at its digest); unknown
|
|
334
335
|
* once a part's cost is (null, or only a bound). A compile whose drafts all failed drafted none: no revision carries it
|
|
335
336
|
* (the bill's unattributed does). It is spread over its first K served runs (`workflow` or `handed_back` of its workflow
|
|
336
|
-
* at its digest), K its check's compile_after; `state` from its newest record.
|
|
337
|
-
|
|
337
|
+
* at its digest), K its check's compile_after; `state` from its newest record. A revision an earlier reset of the agent's
|
|
338
|
+
* learning deleted (`reset`, learn/promote.ts keepResetLedger) is one too, first, stopped, at the K it was kept with,
|
|
339
|
+
* unless the records name it again. */
|
|
340
|
+
export function revisionLedgerOf(records, rows, compiles = [], reset = []) {
|
|
338
341
|
const ordered = [...rows].sort((a, b) => a.startedAt - b.startedAt || (a.id < b.id ? -1 : 1));
|
|
339
342
|
const newest = new Map();
|
|
340
343
|
for (const record of records)
|
|
341
344
|
newest.set(`${record.workflow}\0${record.digest}`, record);
|
|
342
345
|
const sum = (parts) => (parts.some((one) => one === null) ? null : noiseOff(parts.reduce((total, one) => total + one, 0)));
|
|
343
|
-
const ran = (row,
|
|
344
|
-
const
|
|
345
|
-
const replays = ordered.filter((row) => metricOf(row).path === "replay" && ran(row,
|
|
346
|
+
const ran = (row, workflow, digest) => { const at = revisionOfRow(row); return at?.workflow === workflow && at.digest === digest; };
|
|
347
|
+
const spendOf = (workflow, digest, k, state) => {
|
|
348
|
+
const replays = ordered.filter((row) => metricOf(row).path === "replay" && ran(row, workflow, digest));
|
|
346
349
|
const check = sum(replays.map((row) => (typeof row.costAtMostUsd === "number" ? null : row.costUsd)));
|
|
347
|
-
const compile = sum(compiles.filter((one) => one.workflow ===
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
350
|
+
const compile = sum(compiles.filter((one) => one.workflow === workflow && one.digest === digest).map((one) => one.usd));
|
|
351
|
+
return { workflow, digest, compile_usd: compile, check_usd: check, spend_usd: sum([compile, check]), k, state };
|
|
352
|
+
};
|
|
353
|
+
const revisions = [
|
|
354
|
+
...reset.filter((one) => !newest.has(`${one.workflow}\0${one.digest}`)).map((one) => spendOf(one.workflow, one.digest, one.k ?? COMPILE_AFTER_DEFAULT, "stopped")),
|
|
355
|
+
...[...newest.values()].map((record) => spendOf(record.workflow, record.digest, record.check?.compile_after ?? COMPILE_AFTER_DEFAULT, record.decided === "replaying" ? "checking" : championOf(records, record.workflow)?.digest === record.digest ? "serving" : "stopped")),
|
|
356
|
+
];
|
|
351
357
|
const served = ordered.flatMap((row) => {
|
|
352
358
|
const at = revisionOfRow(row);
|
|
353
359
|
return SERVED_PATHS.includes(metricOf(row).path) && at ? [{ run_id: row.id, ...at }] : [];
|
|
@@ -381,8 +387,9 @@ export async function runAllInOverStore(store, runId, rowUsd) {
|
|
|
381
387
|
// Its share of its revision's compile and check: a served run's, over the agent's ledger.
|
|
382
388
|
let shares = new Map();
|
|
383
389
|
if (path !== null && SERVED_PATHS.includes(path) && revisionOfRow(run)) {
|
|
384
|
-
|
|
385
|
-
|
|
390
|
+
// Over the agent's runs on no named disk, as the cost page's ledger reads (learn/learning-of.ts).
|
|
391
|
+
const listed = (await store.runs.list({ agentId: run.agentId, disk: null })).filter((one) => one.agentId === run.agentId);
|
|
392
|
+
shares = (await agentLedgerOf(await agentRecordsOf(store, run.agentId, listed), await promotionsOf(store.settings, run.agentId), listed, await resetLedgerOf(store.settings, run.agentId))).shares;
|
|
386
393
|
}
|
|
387
394
|
const figures = { run_id: run.id, ...cost };
|
|
388
395
|
const compiles = await compilesOf(store, run.id);
|
|
@@ -476,13 +483,16 @@ export async function costRunOf(store, run, n, { path, workflow }) {
|
|
|
476
483
|
return { n, run_id: run.id, started_at: new Date(run.startedAt).toISOString(), path, workflow, digest, audited, cost_usd, cost_upper_bound, learning_usd, total_usd };
|
|
477
484
|
}
|
|
478
485
|
/** The runs the money rule reads for agent `agentId` (runner/workflow-first.ts costLineOf), one set for the run's launch
|
|
479
|
-
* and the cost page: of its newest PAST_RUNS runs
|
|
480
|
-
*
|
|
481
|
-
*
|
|
486
|
+
* and the cost page: of its newest PAST_RUNS runs on no named disk (learn/learning-of.ts: one on a named disk learns
|
|
487
|
+
* nothing), each that ended (ended, stopped or failed) since its learning's reset (learn/compile.ts sinceReset: a
|
|
488
|
+
* workflow before it is not the one it learned after, whatever its name), is neither imported nor archived nor a
|
|
489
|
+
* workflow revision's run, with its all-in cost (allInOf). `known`: all-in costs already read, by run id (the cost
|
|
490
|
+
* page's series), read again for no run; `records`, where any other's rows are read (the store's by default). */
|
|
482
491
|
export async function pastRunsOverStore(store, agentId, known, records = store) {
|
|
483
492
|
const kinds = new Map();
|
|
484
493
|
const kept = [];
|
|
485
|
-
const
|
|
494
|
+
const since = await sinceReset(store, agentId);
|
|
495
|
+
const page = (await store.runs.list({ agentId, disk: null, limit: PAST_RUNS })).filter(since);
|
|
486
496
|
// Each run's audit shadow is read off the page (allInOf's shadowSpendOf): a shadow starts after the run it audits ends,
|
|
487
497
|
// so it is newer than that run and on the same page of the newest runs; one not on it was never started.
|
|
488
498
|
const shadows = new Map(page.filter((run) => isShadowRun(run.id)).map((run) => [run.id, run]));
|
|
@@ -713,8 +723,7 @@ export function usedOnly(started, terminal, at) {
|
|
|
713
723
|
// A start that could not be made (a folder unreadable) handed the run nothing: said so from its start, as the end hook
|
|
714
724
|
// says it for a run that learns, never "seeded" and then `use`. No proposal is written for it.
|
|
715
725
|
if (seedFailed(started)) {
|
|
716
|
-
|
|
717
|
-
return { state: "dropped", reason: "seed_failed", detail: said.stopped(why), at };
|
|
726
|
+
return { state: "dropped", reason: "seed_failed", detail: said.stopped(seedStopped(started.seedFailed)), at };
|
|
718
727
|
}
|
|
719
728
|
return terminal ? { state: "dropped", reason: "use", detail: said.use, at } : { state: "seeded", reason: null, detail: said.seeded(correctionCount(started.section), started.workflows?.length ?? 0), at };
|
|
720
729
|
}
|
|
@@ -17,9 +17,10 @@ export type LoopCompile = {
|
|
|
17
17
|
draft_errors: string[];
|
|
18
18
|
};
|
|
19
19
|
/** The agent's compile turns (every round of each run, roundsOf: newest first, LOOP_COMPILES_MAX), over its ended runs
|
|
20
|
-
* (not imported, not archived)
|
|
21
|
-
*
|
|
22
|
-
* read's `serving`.
|
|
20
|
+
* (not imported, not archived) since its learning's reset (sinceReset: a compile before it wrote what the reset
|
|
21
|
+
* deleted), and how many completed runs of its own count toward its compile. A compile's `promoted` is its revision's
|
|
22
|
+
* promotion as the records say now (null while undecided): whether it serves now is the promotions read's `serving`.
|
|
23
|
+
* Runs on no named disk alone: one on a named disk learns nothing (learn/learning-of.ts). */
|
|
23
24
|
export declare function agentLoopOverStore(store: Store, agentId: string): Promise<{
|
|
24
25
|
compiles: LoopCompile[];
|
|
25
26
|
completed_runs: number;
|
package/dist/store-reads/loop.js
CHANGED
|
@@ -4,18 +4,20 @@
|
|
|
4
4
|
// own words only: no input, no answer.
|
|
5
5
|
import { FINAL_STATES } from "../store/store.js";
|
|
6
6
|
import { promotionOf, promotionsOf } from "../learn/promote.js";
|
|
7
|
-
import { lastOwnRuns, promotedOf } from "../learn/compile.js";
|
|
7
|
+
import { lastOwnRuns, promotedOf, sinceReset } from "../learn/compile.js";
|
|
8
8
|
import { loopOf } from "../learning-setting.js";
|
|
9
9
|
import { roundsOf } from "./learning.js";
|
|
10
10
|
/** How many compile turns the read gives, the newest. */
|
|
11
11
|
export const LOOP_COMPILES_MAX = 50;
|
|
12
12
|
const texts = (list) => (Array.isArray(list) ? list.filter((one) => typeof one === "string") : []);
|
|
13
13
|
/** The agent's compile turns (every round of each run, roundsOf: newest first, LOOP_COMPILES_MAX), over its ended runs
|
|
14
|
-
* (not imported, not archived)
|
|
15
|
-
*
|
|
16
|
-
* read's `serving`.
|
|
14
|
+
* (not imported, not archived) since its learning's reset (sinceReset: a compile before it wrote what the reset
|
|
15
|
+
* deleted), and how many completed runs of its own count toward its compile. A compile's `promoted` is its revision's
|
|
16
|
+
* promotion as the records say now (null while undecided): whether it serves now is the promotions read's `serving`.
|
|
17
|
+
* Runs on no named disk alone: one on a named disk learns nothing (learn/learning-of.ts). */
|
|
17
18
|
export async function agentLoopOverStore(store, agentId) {
|
|
18
|
-
const
|
|
19
|
+
const since = await sinceReset(store, agentId);
|
|
20
|
+
const ended = (await store.runs.list({ agentId, disk: null })).filter((run) => run.agentId === agentId && FINAL_STATES.includes(run.state) && !run.importedFrom && run.archivedAt === null && since(run)).sort((a, b) => a.startedAt - b.startedAt || (a.id < b.id ? -1 : 1));
|
|
19
21
|
// The completed runs of the agent's own toward its compile (what compileDue counts), at most compile_after: the tab
|
|
20
22
|
// says "N of compile_after" from this, never from the one page of runs it reads.
|
|
21
23
|
const current = (await store.agents.get(agentId))?.currentRevision;
|
package/dist/store-view.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ export declare const answerOf: (timeline: readonly TimelineEvent[]) => string |
|
|
|
54
54
|
interface StoreRun {
|
|
55
55
|
readonly native?: Record<string, unknown>;
|
|
56
56
|
readonly sdk?: Record<string, unknown>;
|
|
57
|
+
readonly cli_learning?: Record<string, unknown>;
|
|
57
58
|
readonly row: NonNullable<Awaited<ReturnType<typeof readRun>>>;
|
|
58
59
|
readonly runRow: RunRow;
|
|
59
60
|
readonly launch: RunLaunch | undefined;
|
|
@@ -147,9 +148,9 @@ export declare function standsOnPerson(approvals: ReadonlyMap<string, {
|
|
|
147
148
|
* True when written; false when another write got there first, or when the write failed (said, never thrown: a read
|
|
148
149
|
* never fails on its heal, and the next read or start sweep writes it again). */
|
|
149
150
|
export declare function healStoredCost(store: Store, runId: string, heal: NonNullable<StoreRun["heal"]>): Promise<boolean>;
|
|
150
|
-
/** The end run `
|
|
151
|
-
* undefined: a run that reads ended while it is still learning from that end. */
|
|
152
|
-
export declare function lookingBackEnd(store: Store,
|
|
151
|
+
/** The end run `stored` (its row as the caller read it) keeps while it looks back after its job ended, as every reader
|
|
152
|
+
* serves it (lookingBackOf), else undefined: a run that reads ended while it is still learning from that end. */
|
|
153
|
+
export declare function lookingBackEnd(store: Store, stored: RunRow): Promise<KeptEnd | undefined>;
|
|
153
154
|
/** What run `runId`'s paid tool calls cost, the run read's `cost.tools_usd` (server.ts allInViewOf): the charges its
|
|
154
155
|
* paid-tools session booked (a monid endpoint's, a priced MCP tool's, Parallel's behind the web tools, the browser's
|
|
155
156
|
* time) and the decisions Parallel charged on its own API (store-reads/decisions.ts chargedByParallel), joined and rounded by the one rule its `usd` is (costWordsOf), less those in its end-of-run turn, which are
|
package/dist/store-view.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cliPolicyOf } from "./sdk/runs.js";
|
|
1
2
|
// A run's served view, built from the one store (design 2.1): the same object GET /runs/{id} answered from the per-run
|
|
2
3
|
// files, now composed from the store's row (store-reads/runs.ts), its journal (store-reads/journal.ts) and its learning end
|
|
3
4
|
// (store-reads/learning.ts), fed through the run view's pure functions (run-view.ts) so the figures and words a person or a
|
|
@@ -221,13 +222,12 @@ async function lookingBackOf(stored, entries, commands) {
|
|
|
221
222
|
const kept = keptEndOf(entries, rows);
|
|
222
223
|
return kept !== undefined && !rows.some(waitingMessage) ? kept : undefined;
|
|
223
224
|
}
|
|
224
|
-
/** The end run `
|
|
225
|
-
* undefined: a run that reads ended while it is still learning from that end. */
|
|
226
|
-
export async function lookingBackEnd(store,
|
|
227
|
-
|
|
228
|
-
if (stored?.state !== "running")
|
|
225
|
+
/** The end run `stored` (its row as the caller read it) keeps while it looks back after its job ended, as every reader
|
|
226
|
+
* serves it (lookingBackOf), else undefined: a run that reads ended while it is still learning from that end. */
|
|
227
|
+
export async function lookingBackEnd(store, stored) {
|
|
228
|
+
if (stored.state !== "running")
|
|
229
229
|
return undefined;
|
|
230
|
-
return lookingBackOf(stored, (await journalRecords(store.readJournal(
|
|
230
|
+
return lookingBackOf(stored, (await journalRecords(store.readJournal(stored.id), BACKGROUND_CONTEXT)).entries, () => store.commands(stored.id, 0));
|
|
231
231
|
}
|
|
232
232
|
/** `storeRunOf`'s reads, over `store` (a snapshot) and the run's cut, begun at `since` (servedSince). */
|
|
233
233
|
async function storeRunIn(store, runId, deps, cut, since) {
|
|
@@ -283,6 +283,8 @@ async function storeRunIn(store, runId, deps, cut, since) {
|
|
|
283
283
|
const sdkCompletion = records.entries.findLast(entry => entry.kind === "agentrun.sdk.completion")?.data;
|
|
284
284
|
const sdkSession = records.entries.findLast(entry => entry.kind === "agentrun.sdk.session")?.data;
|
|
285
285
|
const sdk = launch?.sdk ? { runtime: launch.sdk.runtime, ...(launch.sdk.runtime === "external" ? { platform: launch.sdk.platform } : {}), model: sdkCompletion?.model ?? launch.sdk.model ?? null, session_id: sdkCompletion?.session_id ?? sdkSession?.session_id ?? null, learning_revision: launch.learning?.seed ?? null, usage: sdkCompletion?.usage ?? null } : undefined;
|
|
286
|
+
const cliCompletion = records.entries.findLast(entry => entry.kind === "agentrun.cli.completion")?.data;
|
|
287
|
+
const cli_learning = launch?.cli_learning ? { runtime: launch.cli_learning.runtime, session_id: launch.cli_learning.session_id, turn_id: launch.cli_learning.turn_id, model: cliCompletion?.model ?? launch.cli_learning.model ?? null, learning_revision: launch.learning?.seed ?? null, seed_observed: cliCompletion?.seed_observed ?? false, policy_complete: cliPolicyOf(launch, cliCompletion)?.complete ?? false, evidence_complete: cliCompletion?.evidence_complete ?? false, usage: cliCompletion?.usage ?? null } : undefined;
|
|
286
288
|
const nativeConfiguration = records.entries.findLast(e => e.kind === "agentrun.native.configuration")?.data;
|
|
287
289
|
const nativeEvents = records.entries.filter(e => e.kind === "agentrun.native.usage").map(e => e.data);
|
|
288
290
|
const reflectRange = (await runReflect(store, runId, context));
|
|
@@ -416,7 +418,7 @@ async function storeRunIn(store, runId, deps, cut, since) {
|
|
|
416
418
|
const endSaidCost = endCost && !lookingBack ? endSaid !== undefined : false;
|
|
417
419
|
const endUnread = !lookingBack && bookedCost !== undefined && !endCost && endSaid === null;
|
|
418
420
|
const heal = lookingBack ? undefined : healOf(endCost, runRow);
|
|
419
|
-
return { ...(sdk ? { sdk } : {}), ...(native ? { native } : {}), row, runRow, launch, rows, version, harness, learningEnd: shownEnd, shownEnd, view, unshown, values, live, updatedAtMs, lastProgressAt, budget, paused, browserAsk, computerAsk, approvalsMode, output, ...(review ? { review } : {}), structured, decisions, plan, model, ...(endCost ? { endCost, endSaidCost } : {}), ...(endUnread ? { endUnread } : {}), ...(heal ? { heal } : {}), ...(lookingBack ? { lookingBack: true } : {}) };
|
|
421
|
+
return { ...(cli_learning ? { cli_learning } : {}), ...(sdk ? { sdk } : {}), ...(native ? { native } : {}), row, runRow, launch, rows, version, harness, learningEnd: shownEnd, shownEnd, view, unshown, values, live, updatedAtMs, lastProgressAt, budget, paused, browserAsk, computerAsk, approvalsMode, output, ...(review ? { review } : {}), structured, decisions, plan, model, ...(endCost ? { endCost, endSaidCost } : {}), ...(endUnread ? { endUnread } : {}), ...(heal ? { heal } : {}), ...(lookingBack ? { lookingBack: true } : {}) };
|
|
420
422
|
}
|
|
421
423
|
/** Run read `read` (a run still going, as the store holds it) as the end `ended` keeps (its state, summary and end time:
|
|
422
424
|
* the end a run looking back keeps), its cost as read. */
|
|
@@ -638,6 +640,7 @@ async function viewOfRun(store, runId, deps, run, read) {
|
|
|
638
640
|
// A run looking back reads its job's end, and is settled only once its look-back's end is in.
|
|
639
641
|
const settled = terminal && ended && !run.lookingBack;
|
|
640
642
|
return {
|
|
643
|
+
...(run.cli_learning && !unshown ? { cli_learning: redactedOutput(run.cli_learning, values) } : {}),
|
|
641
644
|
...(run.sdk && !unshown ? { sdk: redactedOutput(run.sdk, values) } : {}),
|
|
642
645
|
...(run.native && !unshown ? { native: redactedOutput(run.native, values) } : {}),
|
|
643
646
|
run_id: row.id,
|
|
@@ -705,6 +708,7 @@ export function summaryOfView(view) {
|
|
|
705
708
|
const { run_id, agent_id, agent_version, console_url, revision, kind, sha, status, state, title, effort, created_at, ended_at, error, review, pending, cost, archived_at, imported_from, trigger, labels, learning } = view;
|
|
706
709
|
return {
|
|
707
710
|
run_id, agent_id, agent_version, console_url, revision, kind, sha, status, state, title,
|
|
711
|
+
...(view.cli_learning ? { cli_learning: view.cli_learning } : {}),
|
|
708
712
|
...(view.sdk ? { sdk: view.sdk } : {}),
|
|
709
713
|
...(view.native ? { native: view.native } : {}),
|
|
710
714
|
...(effort ? { effort } : {}),
|
package/dist/template-eval.js
CHANGED
|
@@ -1429,11 +1429,11 @@ async function runOnce(ctx, one, n, fakes, mail, feeds) {
|
|
|
1429
1429
|
// their own, into the fakes' logs, and outlive the eval. Each one the apply made is deleted at once.
|
|
1430
1430
|
// An email or feed case's run is its one trigger's: that one stays, until the run is read.
|
|
1431
1431
|
let kept;
|
|
1432
|
-
for (const
|
|
1433
|
-
if (via !== undefined && !kept &&
|
|
1434
|
-
kept =
|
|
1432
|
+
for (const one of Array.isArray(applied.triggers) ? applied.triggers : []) {
|
|
1433
|
+
if (via !== undefined && !kept && one.name === via)
|
|
1434
|
+
kept = one.trigger_id;
|
|
1435
1435
|
else
|
|
1436
|
-
made.triggers.add(
|
|
1436
|
+
made.triggers.add(one.trigger_id);
|
|
1437
1437
|
}
|
|
1438
1438
|
await deleteTriggers(api, made, true);
|
|
1439
1439
|
if (via !== undefined && !kept)
|
package/dist/templates.d.ts
CHANGED
|
@@ -42,8 +42,9 @@ export declare const MAX_PACKAGE_FILES = 256;
|
|
|
42
42
|
* from the agent's files' limits above. The answer's schema is given to the agent, so under evals/ too it keeps those. */
|
|
43
43
|
export declare const MAX_EVAL_FILE_BYTES: number;
|
|
44
44
|
/** An MCP server a package uses, by where it comes from (`source`, `toolkit`), never by the name an owner saves it under:
|
|
45
|
-
* inside the package its tools are `mcp:<toolkit>/<tool>`. `tools`, those the agent
|
|
46
|
-
*
|
|
45
|
+
* inside the package its tools are `mcp:<toolkit>/<tool>`. `tools`, those the agent uses and the package asks the owner to
|
|
46
|
+
* grant (a consent screen shows each, with `reason`), and `allow`, those of them expected to run without asking (reads);
|
|
47
|
+
* the rest (writes) wait for the owner's OK on each call (packageView's `asks`). Neither the package nor an apply
|
|
47
48
|
* sets a permission: an apply's `grants`, the owner's ticks, grant the tools, and each call follows this server's tool settings
|
|
48
49
|
* (a write asks unless the owner allowed it there, a read follows the server's Allow reads, approvals never lifts an ask). `pin`, by tool: the arguments each of its calls must carry (a value, or
|
|
49
50
|
* `${parameters.<name>}`), which apply writes as the tool's pin in the agent's tool settings, so a send goes only to the
|
|
@@ -139,6 +140,7 @@ export type Package = {
|
|
|
139
140
|
/** Each run's limit: its spend cap (the agent's max_cost_usd). */
|
|
140
141
|
budget?: {
|
|
141
142
|
per_run_usd: number;
|
|
143
|
+
max_requests?: number;
|
|
142
144
|
};
|
|
143
145
|
/** The agent's `learning`, as a definition takes it: true, false, or the loop's settings (agree_on, each path a required
|
|
144
146
|
* field of the output schema). */
|
|
@@ -291,6 +293,7 @@ export declare function packageView(p: Package): {
|
|
|
291
293
|
secrets: string[];
|
|
292
294
|
budget: {
|
|
293
295
|
per_run_usd: number;
|
|
296
|
+
max_requests?: number;
|
|
294
297
|
} | null;
|
|
295
298
|
learning: LearningSetting;
|
|
296
299
|
approvals_default: "ask" | "never";
|
|
@@ -364,6 +367,7 @@ export declare function packageDetail(p: Package): {
|
|
|
364
367
|
secrets: string[];
|
|
365
368
|
budget: {
|
|
366
369
|
per_run_usd: number;
|
|
370
|
+
max_requests?: number;
|
|
367
371
|
} | null;
|
|
368
372
|
learning: LearningSetting;
|
|
369
373
|
approvals_default: "ask" | "never";
|
package/dist/templates.js
CHANGED
|
@@ -691,10 +691,12 @@ export function readPackage(from, { evalFixtures = true } = {}) {
|
|
|
691
691
|
const secrets = list(f.secrets, "secrets", (secret) => /^[A-Z][A-Z0-9_]{0,127}$/.test(secret));
|
|
692
692
|
for (const secret of secrets.filter((name) => !PACKAGE_SECRETS.includes(name)))
|
|
693
693
|
bad(MANIFEST, `secrets names ${secret}, a key this server cannot hold: a package needs the keys Settings saves and a run is handed (${PACKAGE_SECRETS.join(", ")})`);
|
|
694
|
-
// Each run's
|
|
694
|
+
// Each run's limits: its spend cap (per_run_usd, the agent's max_cost_usd), required once a budget is given, and the most
|
|
695
|
+
// requests on free models it makes (max_requests, the agent's max_requests), which a dollar cap cannot bound.
|
|
695
696
|
const perRun = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
696
|
-
|
|
697
|
-
|
|
697
|
+
const requests = (value) => value === undefined || (typeof value === "number" && Number.isSafeInteger(value) && value >= 1);
|
|
698
|
+
if (f.budget !== undefined && !(isObject(f.budget) && !unknownFields(f.budget, ["per_run_usd", "max_requests"]).length && perRun(f.budget.per_run_usd) && requests(f.budget.max_requests)))
|
|
699
|
+
bad(MANIFEST, "budget is {per_run_usd: a number above 0, max_requests: a whole number of free-model requests above 0, when given}");
|
|
698
700
|
const learningIssue = f.learning === undefined ? undefined : learningSettingIssue(f.learning, "learning");
|
|
699
701
|
if (learningIssue)
|
|
700
702
|
bad(MANIFEST, learningIssue);
|
|
@@ -940,7 +942,7 @@ export function readPackage(from, { evalFixtures = true } = {}) {
|
|
|
940
942
|
...(typeof f.license === "string" ? { license: f.license } : {}), ...(isObject(f.author) ? { author: f.author } : {}), ...(typeof f.repository === "string" ? { repository: f.repository } : {}),
|
|
941
943
|
...(typeof f.category === "string" ? { category: f.category } : {}), tags,
|
|
942
944
|
...(harness ? { harness } : {}), ...(isObject(f.model) ? { model: { ...f.model, ...(choices ? { choices } : {}) } } : {}), ...(typeof f.effort === "string" ? { effort: f.effort } : {}),
|
|
943
|
-
...(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 } : {}),
|
|
945
|
+
...(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.budget.max_requests !== undefined ? { max_requests: f.budget.max_requests } : {}) } } : {}), ...(f.learning !== undefined ? { learning: learningSettingOf(f.learning) } : {}), ...(f.approvals === "ask" || f.approvals === "never" ? { approvals: f.approvals } : {}),
|
|
944
946
|
triggers: triggers, ...(isObject(f.output) ? { output: { schema: f.output.schema } } : {}), ...(isObject(outputSchema) ? { outputSchema } : {}), instructions, skills, evals,
|
|
945
947
|
};
|
|
946
948
|
// What an apply makes, made here with each parameter's default, else a sample of its type, and checked as POST
|
|
@@ -1302,7 +1304,7 @@ export function compiled(p, parameters, chosen, _deps) {
|
|
|
1302
1304
|
name: p.displayName ? filled(p.displayName, parameters) : p.name, description: p.description, instructions: filled(p.instructions, parameters),
|
|
1303
1305
|
...(chosen.harness ? { harness: chosen.harness } : {}), ...(chosen.model ? { model: chosen.model } : {}), ...(chosen.modelTiers && Object.keys(chosen.modelTiers).length ? { model_tiers: chosen.modelTiers } : {}), ...(p.effort ? { thinking: p.effort } : {}),
|
|
1304
1306
|
...(pick ? { computer: pick.computer } : {}), ...(tools ? { tools } : {}), ...(Object.keys(settings).length ? { tool_settings: settings } : {}),
|
|
1305
|
-
...(p.learning !== undefined ? { learning: p.learning } : {}), ...(p.budget?.per_run_usd ? { max_cost_usd: p.budget.per_run_usd } : {}), skills,
|
|
1307
|
+
...(p.learning !== undefined ? { learning: p.learning } : {}), ...(p.budget?.per_run_usd ? { max_cost_usd: p.budget.per_run_usd } : {}), ...(p.budget?.max_requests ? { max_requests: p.budget.max_requests } : {}), skills,
|
|
1306
1308
|
// The apply's choice: unattended only when it says never (none given: the agent asks).
|
|
1307
1309
|
...(chosen.approvals === "never" ? { approvals: "never" } : {}),
|
|
1308
1310
|
// The package's typed input (manifest `inputs`): what each run's input is checked against, and how the model reads it.
|
package/dist/timeline/labels.js
CHANGED
|
@@ -134,7 +134,7 @@ const fetchOutcome = (result) => {
|
|
|
134
134
|
// web_fetch answers a page, `{ok, url, status, title, text, links, refused?, error?}`.
|
|
135
135
|
registerLabel("web_fetch", fetchLabel, fetchFold, { name: "Fetch web pages" });
|
|
136
136
|
registerOutcome("web_fetch", fetchOutcome);
|
|
137
|
-
// web_save answers `{ok: true, path, bytes, content_type, url}` or `{ok: false, url, path?, refused | error}` (web-save.ts):
|
|
137
|
+
// web_save answers `{ok: true, path, bytes, content_type, duration_s?, url}` or `{ok: false, url, path?, refused | error}` (web-save.ts):
|
|
138
138
|
// the path it answered, else the one asked (a bare name under media/, as it saves one), and the host it was asked for.
|
|
139
139
|
const savedAt = (a, result) => {
|
|
140
140
|
const answered = result && str(obj(json(result.text))?.path);
|
package/dist/tool-gate.d.ts
CHANGED
|
@@ -143,9 +143,11 @@ export type PendingApproval = {
|
|
|
143
143
|
/** The call's arguments as text, at most ARGS_PREVIEW_BYTES. */
|
|
144
144
|
args_preview: string;
|
|
145
145
|
/** What the call does in words, where its tool says (email_send: "Send email to <to>, cc <cc>: <subject>" and the
|
|
146
|
-
* text's first 300 characters),
|
|
147
|
-
* arguments are. */
|
|
146
|
+
* text's first 300 characters), redacted as its arguments are. */
|
|
148
147
|
summary?: string;
|
|
148
|
+
/** Why the call asks though its setting allows it (its tool's own ask, ToolEntry.asks), redacted as its arguments are;
|
|
149
|
+
* absent for a call that asks by its setting. Never among its arguments. */
|
|
150
|
+
asks_because?: string;
|
|
149
151
|
requested_at: string;
|
|
150
152
|
price?: ApprovalPrice;
|
|
151
153
|
/** Present, true, when the run's pin marks the tool destructive (toolEffect): an allow of it needs confirm_destructive. */
|
package/dist/tools.js
CHANGED
|
@@ -628,7 +628,7 @@ export const TOOLS = Object.freeze({
|
|
|
628
628
|
// web_save (web-save.ts). It makes no paid request, so nothing books it. No node or call node names it: a workflow's
|
|
629
629
|
// effect has only a local work path, not the run's Workspace.
|
|
630
630
|
[WEB_SAVE_TOOL]: {
|
|
631
|
-
summary: `Download one public file into the run's work/ (a bare name under media/), never overwriting: { url, path } -> { ok: true, path, bytes, content_type, url } or { ok: false, url, refused | error }; at most ${SAVE_MAX_BYTES / (1024 * 1024)} MiB, a media type only when its bytes agree.`,
|
|
631
|
+
summary: `Download one public file into the run's work/ (a bare name under media/), never overwriting: { url, path } -> { ok: true, path, bytes, content_type, duration_s?, url } (duration_s an mp3, wav, mp4 or m4a's length in seconds) or { ok: false, url, refused | error }; at most ${SAVE_MAX_BYTES / (1024 * 1024)} MiB, a media type only when its bytes agree.`,
|
|
632
632
|
needs: [],
|
|
633
633
|
nodes: false,
|
|
634
634
|
bind: async (host) => {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Store } from './store/store.js';
|
|
2
|
+
import type { AnalyticsFilter } from './store-reads/analytics.js';
|
|
3
|
+
declare const fields: readonly ["input", "output", "cache_read", "cache_write"];
|
|
4
|
+
type Counts = Record<typeof fields[number], number | null> & {
|
|
5
|
+
tokens: number | null;
|
|
6
|
+
};
|
|
7
|
+
export type UnifiedUsage = Counts & {
|
|
8
|
+
known_runs: number;
|
|
9
|
+
unknown_runs: number;
|
|
10
|
+
observed_sessions: number;
|
|
11
|
+
unknown_sessions: number;
|
|
12
|
+
partial_days: number;
|
|
13
|
+
retention_limited: boolean;
|
|
14
|
+
by_day: {
|
|
15
|
+
day: string;
|
|
16
|
+
tokens: number | null;
|
|
17
|
+
}[];
|
|
18
|
+
by_harness: {
|
|
19
|
+
harness: string;
|
|
20
|
+
tokens: number | null;
|
|
21
|
+
}[];
|
|
22
|
+
};
|
|
23
|
+
export declare function unifiedUsage(store: Store, filter?: AnalyticsFilter, now?: number): Promise<UnifiedUsage>;
|
|
24
|
+
export {};
|