@parcha/agentrun-serve 0.1.0-beta.40 → 0.1.0-beta.41

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 (126) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +78 -15
  3. package/dist/api-only.d.ts +3 -1
  4. package/dist/api-only.js +4 -2
  5. package/dist/api-token.d.ts +30 -0
  6. package/dist/api-token.js +89 -0
  7. package/dist/cli.js +19 -5
  8. package/dist/composio-made.d.ts +54 -0
  9. package/dist/composio-made.js +83 -0
  10. package/dist/composio-preset.d.ts +16 -8
  11. package/dist/composio-preset.js +106 -43
  12. package/dist/composio-triggers.d.ts +7 -2
  13. package/dist/composio-triggers.js +13 -7
  14. package/dist/computer-attach.d.ts +29 -11
  15. package/dist/computer-attach.js +141 -47
  16. package/dist/computer-keys.d.ts +4 -0
  17. package/dist/computer-keys.js +5 -0
  18. package/dist/computers.d.ts +11 -1
  19. package/dist/computers.js +21 -12
  20. package/dist/console/assets/{index-B8Zn1Iqn.css → index-C3gNPz58.css} +1 -1
  21. package/dist/console/assets/index-COGhx_2Z.js +711 -0
  22. package/dist/console/index.html +2 -2
  23. package/dist/decisions.js +9 -2
  24. package/dist/eval-feed.d.ts +26 -0
  25. package/dist/eval-feed.js +68 -0
  26. package/dist/eval-mailbox.d.ts +4 -1
  27. package/dist/eval-mailbox.js +11 -3
  28. package/dist/exa-keyless.d.ts +1 -1
  29. package/dist/exa-keyless.js +1 -1
  30. package/dist/feed/feed-faux.d.ts +62 -0
  31. package/dist/feed/feed-faux.js +123 -0
  32. package/dist/feed/fetch.d.ts +41 -0
  33. package/dist/feed/fetch.js +128 -0
  34. package/dist/feed/parse.d.ts +41 -0
  35. package/dist/feed/parse.js +300 -0
  36. package/dist/learn/check.d.ts +3 -1
  37. package/dist/learn/check.js +57 -2
  38. package/dist/learn/compile.js +1 -1
  39. package/dist/learned-nodes.d.ts +21 -4
  40. package/dist/learned-nodes.js +21 -8
  41. package/dist/learned-workflow.d.ts +3 -3
  42. package/dist/learned-workflow.js +14 -5
  43. package/dist/mcp-oauth.d.ts +15 -1
  44. package/dist/mcp-oauth.js +39 -5
  45. package/dist/mcp-pin-first.d.ts +4 -2
  46. package/dist/mcp-pin-first.js +4 -3
  47. package/dist/mcp-servers-store.d.ts +58 -5
  48. package/dist/mcp-servers-store.js +136 -17
  49. package/dist/mcp.d.ts +2 -2
  50. package/dist/mcp.js +2 -2
  51. package/dist/observation/http.d.ts +4 -1
  52. package/dist/observation/http.js +5 -4
  53. package/dist/openapi.js +46 -12
  54. package/dist/print.d.ts +6 -3
  55. package/dist/print.js +4 -2
  56. package/dist/run-labels.d.ts +23 -0
  57. package/dist/run-labels.js +79 -0
  58. package/dist/run-secrets.js +12 -4
  59. package/dist/runner/adapter-loop.js +91 -10
  60. package/dist/runner/adapter-run-spec.d.ts +4 -0
  61. package/dist/runner/adapter-run-spec.js +38 -31
  62. package/dist/runner/beside.d.ts +6 -3
  63. package/dist/runner/beside.js +9 -7
  64. package/dist/runner/cli-run-spec.js +32 -26
  65. package/dist/runner/conformance/harness.js +69 -14
  66. package/dist/runner/conformance/subject.d.ts +4 -1
  67. package/dist/runner/main.d.ts +1 -1
  68. package/dist/runner/main.js +2 -2
  69. package/dist/runner/mcp-claim.d.ts +3 -0
  70. package/dist/runner/mcp-claim.js +1 -1
  71. package/dist/runner/mcp-run.d.ts +4 -0
  72. package/dist/runner/mcp-run.js +5 -3
  73. package/dist/runner/model-route.d.ts +4 -2
  74. package/dist/runner/model-route.js +8 -8
  75. package/dist/runner/promotion.d.ts +8 -0
  76. package/dist/runner/promotion.js +43 -1
  77. package/dist/runner/workflow-first.d.ts +6 -5
  78. package/dist/runner/workflow-first.js +9 -7
  79. package/dist/runs-over-store.js +5 -2
  80. package/dist/sdk/runs.d.ts +7 -1
  81. package/dist/sdk/runs.js +19 -6
  82. package/dist/secret-cut.js +3 -1
  83. package/dist/secrets.js +3 -1
  84. package/dist/server.d.ts +27 -2
  85. package/dist/server.js +168 -50
  86. package/dist/store/dialect.d.ts +3 -0
  87. package/dist/store/dialect.js +1 -0
  88. package/dist/store/index.d.ts +1 -1
  89. package/dist/store/postgres/dialect.js +1 -0
  90. package/dist/store/postgres/migrations/0015_run_labels.sql +5 -0
  91. package/dist/store/postgres/migrations/0016_minted_tokens.sql +21 -0
  92. package/dist/store/schema.d.ts +9 -0
  93. package/dist/store/schema.js +26 -2
  94. package/dist/store/sqlite/connection.js +11 -3
  95. package/dist/store/sqlite/run-patch.d.ts +2 -1
  96. package/dist/store/sqlite/run-patch.js +3 -2
  97. package/dist/store/sqlite/store.js +64 -10
  98. package/dist/store/store.d.ts +38 -1
  99. package/dist/store-reads/journal.js +2 -1
  100. package/dist/store-reads/learning.js +6 -1
  101. package/dist/store-reads/runs.d.ts +4 -3
  102. package/dist/store-reads/runs.js +3 -2
  103. package/dist/store-view.js +4 -2
  104. package/dist/template-eval.d.ts +4 -0
  105. package/dist/template-eval.js +127 -50
  106. package/dist/templates.d.ts +10 -0
  107. package/dist/templates.js +75 -17
  108. package/dist/timeline/origin.d.ts +1 -1
  109. package/dist/timeline/origin.js +2 -2
  110. package/dist/trigger-adapter.d.ts +9 -4
  111. package/dist/trigger-adapters.js +2 -1
  112. package/dist/trigger-feed.d.ts +12 -0
  113. package/dist/trigger-feed.js +371 -0
  114. package/dist/triggers.d.ts +2 -1
  115. package/dist/triggers.js +23 -5
  116. package/dist/webhooks.js +9 -5
  117. package/dist/workspace/computer-deps.d.ts +5 -1
  118. package/dist/workspace/computer-deps.js +2 -2
  119. package/dist/workspace/index.d.ts +1 -0
  120. package/dist/workspace/index.js +2 -0
  121. package/dist/workspace/resolve-computer.d.ts +32 -3
  122. package/dist/workspace/resolve-computer.js +47 -9
  123. package/launcher/agentrun-serve +6 -1
  124. package/package.json +10 -9
  125. package/templates/README.md +27 -2
  126. package/dist/console/assets/index-Jbxjcmdp.js +0 -705
@@ -0,0 +1,21 @@
1
+ -- The store's schema on Postgres, version 16: a hosted machine's minted token (a dial provider's create,
2
+ -- spec/computer/attach.md), as store/schema.ts keeps it on SQLite (MINTED_TOKENS). Applied once, after 0015, inside the
3
+ -- transaction migrate.ts opens. Never edit this file once applied: a change is a new file.
4
+ --
5
+ -- minted_tokens: one row per machine (its name, from its create's request id); the token's SHA-256 alone is kept (hex),
6
+ -- with what the machine must say it is at hello (kind, os, arch), when the token ends (expires_at, the machine's backstop)
7
+ -- and when it was revoked (its delete). The table is made only where it is missing, so a store whose record of this file
8
+ -- was lost applies it again unharmed.
9
+
10
+ CREATE TABLE IF NOT EXISTS minted_tokens (
11
+ machine TEXT COLLATE "C" PRIMARY KEY,
12
+ token_sha256 TEXT COLLATE "C" NOT NULL UNIQUE,
13
+ kind TEXT COLLATE "C" NOT NULL,
14
+ os TEXT COLLATE "C" NOT NULL,
15
+ arch TEXT COLLATE "C" NOT NULL,
16
+ expires_at BIGINT NOT NULL,
17
+ revoked_at BIGINT,
18
+ created_at BIGINT NOT NULL
19
+ );
20
+
21
+ UPDATE store_meta SET schema_version = 16 WHERE singleton = 1;
@@ -16,12 +16,21 @@ export declare const REVISIONS_MONID_PIN: string;
16
16
  /** The bound beside a run's cost: in STORE_DDL, and added at a server open to a store an earlier build of this version made,
17
17
  * as REVISIONS_MCP_PIN is (a run it ended reads 0: an exact cost or an unknown one, as it was read then). */
18
18
  export declare const RUNS_COST_UPPER_BOUND = "ALTER TABLE runs ADD COLUMN cost_upper_bound INTEGER NOT NULL DEFAULT 0 CHECK (cost_upper_bound IN (0, 1))";
19
+ /** A run's labels (JSON, null for none): in STORE_DDL, and added at a server open to a store an earlier build of this version
20
+ * made, as RUNS_COST_UPPER_BOUND is (a run started before reads as given none). */
21
+ export declare const RUNS_LABELS: string;
19
22
  /** A template package imported from GitHub (POST /v2/templates/import), by its id (`github:<owner>/<repo>[/<path>]`): its
20
23
  * source as given (ref and all), the full commit SHA read, the GitHub account that publishes it, and its files as read
21
24
  * (`files`, a JSON object of path to base64). A re-import of the id replaces the row. The server checks the files again
22
25
  * as it loads them at its start (templates.ts readPackage); nothing in them runs. In STORE_DDL, and added at a server
23
26
  * open to a store an earlier build of this version made. */
24
27
  export declare const IMPORTED_TEMPLATES: string;
28
+ /** A hosted machine's minted token (a dial provider's create, spec/computer/attach.md): its computerd dials the attach
29
+ * socket and fetches the daemon with it. By the machine (its name, from its create's request id): the token's SHA-256
30
+ * alone (hex), what the machine must say it is at hello (kind, os, arch), and when the token ends (`expires_at`, the
31
+ * machine's backstop) or was revoked (its delete). A row past its end goes at the next mint. In STORE_DDL, and added at
32
+ * a server open to a store an earlier build of this version made. */
33
+ export declare const MINTED_TOKENS = "CREATE TABLE IF NOT EXISTS minted_tokens (\n machine TEXT PRIMARY KEY,\n token_sha256 TEXT NOT NULL UNIQUE,\n kind TEXT NOT NULL,\n os TEXT NOT NULL,\n arch TEXT NOT NULL,\n expires_at INTEGER NOT NULL,\n revoked_at INTEGER,\n created_at INTEGER NOT NULL\n ) STRICT";
25
34
  export declare const STORE_DDL: readonly string[];
26
35
  /** pi-durable's journal tables (its SqliteStorage schema, version 2, the `sleeping` task status included; MIT, see NOTICE),
27
36
  * every one keyed by (run_id, …) with run_id leading its indexes, so one run's scans read only its rows and two runs never
@@ -13,10 +13,11 @@
13
13
  // build of this version made and drops the table, so a revision saved before has no pin until its first run pins it.
14
14
  // Its monid endpoints are pinned beside them (revisions.monid_pin, REVISIONS_MONID_PIN), added at a server open the same way.
15
15
  // A run's cost says whether it is the most the run can have cost (runs.cost_upper_bound, RUNS_COST_UPPER_BOUND), added at a
16
- // server open the same way.
16
+ // server open the same way. A run's labels (runs.labels, RUNS_LABELS) are added at a server open the same way.
17
17
  // The template packages imported from GitHub (imported_templates) are a table of their own that nothing
18
18
  // else reads, so it needs no version: the server adds it at its open to a store an earlier build of this version made
19
- // (IMPORTED_TEMPLATES), as it does the one-answer index.
19
+ // (IMPORTED_TEMPLATES), as it does the one-answer index. A hosted machine's minted token (minted_tokens, MINTED_TOKENS) is
20
+ // added the same way.
20
21
  // Conventions: every time is INTEGER epoch milliseconds; JSON is TEXT checked by json_valid; money is REAL US dollars;
21
22
  // sealed columns hold ciphertext only (sealed with the server's key outside the store), so the store never sees a secret
22
23
  // in the clear. Foreign keys are on (the connection's pragma).
@@ -50,6 +51,9 @@ const COST_UPPER_BOUND = "cost_upper_bound INTEGER NOT NULL DEFAULT 0 CHECK (cos
50
51
  /** The bound beside a run's cost: in STORE_DDL, and added at a server open to a store an earlier build of this version made,
51
52
  * as REVISIONS_MCP_PIN is (a run it ended reads 0: an exact cost or an unknown one, as it was read then). */
52
53
  export const RUNS_COST_UPPER_BOUND = `ALTER TABLE runs ADD COLUMN ${COST_UPPER_BOUND}`;
54
+ /** A run's labels (JSON, null for none): in STORE_DDL, and added at a server open to a store an earlier build of this version
55
+ * made, as RUNS_COST_UPPER_BOUND is (a run started before reads as given none). */
56
+ export const RUNS_LABELS = `ALTER TABLE runs ADD COLUMN ${json("labels", true)}`;
53
57
  /** A template package imported from GitHub (POST /v2/templates/import), by its id (`github:<owner>/<repo>[/<path>]`): its
54
58
  * source as given (ref and all), the full commit SHA read, the GitHub account that publishes it, and its files as read
55
59
  * (`files`, a JSON object of path to base64). A re-import of the id replaces the row. The server checks the files again
@@ -63,6 +67,21 @@ export const IMPORTED_TEMPLATES = `CREATE TABLE IF NOT EXISTS imported_templates
63
67
  ${json("files")},
64
68
  imported_at INTEGER NOT NULL
65
69
  ) STRICT`;
70
+ /** A hosted machine's minted token (a dial provider's create, spec/computer/attach.md): its computerd dials the attach
71
+ * socket and fetches the daemon with it. By the machine (its name, from its create's request id): the token's SHA-256
72
+ * alone (hex), what the machine must say it is at hello (kind, os, arch), and when the token ends (`expires_at`, the
73
+ * machine's backstop) or was revoked (its delete). A row past its end goes at the next mint. In STORE_DDL, and added at
74
+ * a server open to a store an earlier build of this version made. */
75
+ export const MINTED_TOKENS = `CREATE TABLE IF NOT EXISTS minted_tokens (
76
+ machine TEXT PRIMARY KEY,
77
+ token_sha256 TEXT NOT NULL UNIQUE,
78
+ kind TEXT NOT NULL,
79
+ os TEXT NOT NULL,
80
+ arch TEXT NOT NULL,
81
+ expires_at INTEGER NOT NULL,
82
+ revoked_at INTEGER,
83
+ created_at INTEGER NOT NULL
84
+ ) STRICT`;
66
85
  export const STORE_DDL = [
67
86
  `CREATE TABLE IF NOT EXISTS store_meta (
68
87
  singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
@@ -147,6 +166,10 @@ export const STORE_DDL = [
147
166
  -- the write-back (sign-ins-store.ts / runs.update's save decision). Null until it first leaves running. Other vendors
148
167
  -- free the lease the instant it leaves running (no settle window), so this is read only with one.
149
168
  left_running_at INTEGER,
169
+ -- The caller's labels (RunLabels): a JSON object of strings, set once with the queued run (runs.create), opaque to the
170
+ -- server and only filtered on (runs.list). Null when it was given none. Added at a server open to a store an earlier
171
+ -- build of this version made (RUNS_LABELS), its runs reading as given none.
172
+ ${json("labels", true)},
150
173
  started_at INTEGER NOT NULL,
151
174
  ended_at INTEGER
152
175
  ) STRICT`,
@@ -385,6 +408,7 @@ export const STORE_DDL = [
385
408
  PRIMARY KEY (agent_id, key)
386
409
  ) STRICT`,
387
410
  IMPORTED_TEMPLATES,
411
+ MINTED_TOKENS,
388
412
  // An agent's saved browser sign-ins (design 2.1, the browser sign-in rules): one live row per agent and browser provider, its
389
413
  // pointer (the vendor's context or profile id) sealed with the store's one rule (store/seal.ts, AAD
390
414
  // sign_ins|<agent>:<provider>|pointer), which the store never opens. The owner sees its name ("default") and saved_at,
@@ -23,6 +23,11 @@ const OPEN = new Set();
23
23
  * the answers of two workers come back in no set order, so a wait that ran out then can be read before that begin's
24
24
  * answer adds it to OPEN (lockWait). */
25
25
  const BEGINNING = new Set();
26
+ /** How many interactive transactions of this process have ended on each database (`where`), counted once the worker has
27
+ * answered their commit or rollback. A wait whose busy answer is read after a holder of this process let go (its
28
+ * commit's answer read first: two workers' answers come back in no set order) finds it in neither set, yet that holder
29
+ * held the lock through the wait: the count moved since the wait was sent says so (lockWait). */
30
+ const ENDED = new Map();
26
31
  /** `opened`'s frames: where a transaction was asked for, without the Error line itself. */
27
32
  const framesOf = (opened) => (opened.stack ?? "").split("\n").slice(1).join("\n");
28
33
  /** `error` with its stack naming who held the store: `opened` (its own transaction's opener, when it has one), and every
@@ -216,13 +221,15 @@ export class Connection {
216
221
  * way, and the holder, once it runs again, commits or meets its deadline. A wait on another process's write, or one
217
222
  * this process could run through, ends StoreBusy as ever.
218
223
  * Every wait is measured, and the holder looked for when it runs out, never when it is sent: a holder's begin posted
219
- * in the same turn may take the lock before its answer makes it known. `self`: this request's own begin (BEGINNING),
220
- * never its own holder. */
224
+ * in the same turn may take the lock before its answer makes it known. A holder that ended while the wait was out
225
+ * counts too: its commit's answer may be read before the wait's busy answer. `self`: this request's own begin
226
+ * (BEGINNING), never its own holder. */
221
227
  async #lockWait(send, self) {
222
228
  let left = this.#busyTimeoutMs;
223
229
  for (;;) {
224
230
  const clock = runnableDeadline(left, () => { });
225
231
  const sent = performance.now();
232
+ const ended = ENDED.get(this.#where) ?? 0;
226
233
  try {
227
234
  return await send(left < this.#busyTimeoutMs ? left : undefined);
228
235
  }
@@ -230,7 +237,7 @@ export class Connection {
230
237
  if (!(error instanceof StoreBusy))
231
238
  throw error;
232
239
  const held = clock.held();
233
- if (held === 0 || !this.#heldHere(self))
240
+ if (held === 0 || !(this.#heldHere(self) || (ENDED.get(this.#where) ?? 0) !== ended))
234
241
  throw error;
235
242
  left -= performance.now() - sent - held;
236
243
  if (left <= 0)
@@ -384,6 +391,7 @@ export class Connection {
384
391
  finally {
385
392
  // Kept until the worker has answered the commit or rollback: until then this transaction still holds the lock.
386
393
  OPEN.delete(open);
394
+ ENDED.set(open.where, (ENDED.get(open.where) ?? 0) + 1);
387
395
  }
388
396
  });
389
397
  if (until === undefined)
@@ -43,10 +43,11 @@ export type RunRecord = {
43
43
  archived_at: number | null;
44
44
  imported_from: string | null;
45
45
  sign_in_handed: string | null;
46
+ labels: string | null;
46
47
  started_at: number;
47
48
  ended_at: number | null;
48
49
  };
49
- export declare const RUN_COLUMNS = "id, agent_id, revision_id, state, epoch, runner, claimed_until, wake_at, backoff_until, cost_usd, cost_upper_bound, metrics, summary, outcome, archived_at, imported_from, sign_in_handed, started_at, ended_at";
50
+ export declare const RUN_COLUMNS = "id, agent_id, revision_id, state, epoch, runner, claimed_until, wake_at, backoff_until, cost_usd, cost_upper_bound, metrics, summary, outcome, archived_at, imported_from, sign_in_handed, labels, started_at, ended_at";
50
51
  /** A run's exact cost in SQL, for a query that reads runs.cost_usd itself (`alias`: its runs table's): NULL when the
51
52
  * stored figure is only the most the run can have cost, as runOf reads it. Every raw read of the column goes through it. */
52
53
  export declare const EXACT_COST_USD: (alias: string) => string;
@@ -18,7 +18,7 @@ export const learningLaunchOf = (runId, model, round = 1, capUsd) => ({ harness:
18
18
  /** The lock a write of a run's sign_in_handed and a sign-in's forget both take (Dialect.lockKey): the forget's check of
19
19
  * the running runs' hashes and a launch's write of them are serialized, as SQLite's one writer serializes them. */
20
20
  export const SIGN_IN_HANDED_LOCK = "sign_in_handed";
21
- export const RUN_COLUMNS = "id, agent_id, revision_id, state, epoch, runner, claimed_until, wake_at, backoff_until, cost_usd, cost_upper_bound, metrics, summary, outcome, archived_at, imported_from, sign_in_handed, started_at, ended_at";
21
+ export const RUN_COLUMNS = "id, agent_id, revision_id, state, epoch, runner, claimed_until, wake_at, backoff_until, cost_usd, cost_upper_bound, metrics, summary, outcome, archived_at, imported_from, sign_in_handed, labels, started_at, ended_at";
22
22
  /** A run's exact cost in SQL, for a query that reads runs.cost_usd itself (`alias`: its runs table's): NULL when the
23
23
  * stored figure is only the most the run can have cost, as runOf reads it. Every raw read of the column goes through it. */
24
24
  export const EXACT_COST_USD = (alias) => `CASE WHEN ${alias}.cost_upper_bound = 1 THEN NULL ELSE ${alias}.cost_usd END`;
@@ -30,7 +30,8 @@ export const runOf = (r) => ({
30
30
  id: r.id, agentId: r.agent_id, revisionId: r.revision_id, state: r.state, epoch: r.epoch, runner: r.runner, claimedUntil: r.claimed_until,
31
31
  wakeAt: r.wake_at, backoffUntil: r.backoff_until, ...costOf(r.cost_usd, r.cost_upper_bound), metrics: r.metrics === null ? null : JSON.parse(r.metrics), summary: r.summary,
32
32
  outcome: r.outcome ?? null, archivedAt: r.archived_at, importedFrom: r.imported_from === null ? null : JSON.parse(r.imported_from),
33
- signInHanded: r.sign_in_handed === null ? null : JSON.parse(r.sign_in_handed), startedAt: r.started_at, endedAt: r.ended_at,
33
+ signInHanded: r.sign_in_handed === null ? null : JSON.parse(r.sign_in_handed), labels: r.labels === null ? {} : JSON.parse(r.labels),
34
+ startedAt: r.started_at, endedAt: r.ended_at,
34
35
  });
35
36
  /** Applies `patch` to the claim's run, then writes `also`, through `tx` (an open transaction's handle). Fenced, with nothing
36
37
  * of it written once the caller rolls back, when the run's epoch is not the claim's or the claim's lease ran out before
@@ -11,7 +11,7 @@ import { backfillNativeCommandOwners, nativeCommandOwner, validConnectorId } fro
11
11
  import { watchCommandsAt, wakeCommands } from "../command-wake.js";
12
12
  import { claimFence, storeNow } from "../fence.js";
13
13
  import { RunStorage } from "../journal/storage.js";
14
- import { COMMANDS_ONE_ANSWER, DDL, IMPORTED_TEMPLATES, NATIVE_COMMANDS_INDEX, REVISIONS_MCP_PIN, REVISIONS_MONID_PIN, RUNS_COST_UPPER_BOUND, SCHEMA_VERSION } from "../schema.js";
14
+ import { COMMANDS_ONE_ANSWER, DDL, IMPORTED_TEMPLATES, MINTED_TOKENS, NATIVE_COMMANDS_INDEX, REVISIONS_MCP_PIN, REVISIONS_MONID_PIN, RUNS_COST_UPPER_BOUND, RUNS_LABELS, SCHEMA_VERSION } from "../schema.js";
15
15
  import { AgentArchived, CommandTaken, ExternalBodyConflict, Fenced, RunFinal, SchemaVersionUnknown, STORE_WRITE_DEADLINE_MS, StoreConstraint, StoreFromEarlierVersion, TriggerFull, FINAL_STATES, MCP_REFRESH_CALL_MS, MCP_REFRESH_LEASE_MS, RevisionMoved, SignInHandedTo, SignInMissing, RUN_CHANGES_PAGE, } from "../store.js";
16
16
  /** The seq a run-change cursor names (Runs.changedSince): only a cursor this store handed back, a whole number. */
17
17
  const seqOf = (cursor) => {
@@ -107,6 +107,19 @@ const triggerOf = (r) => ({
107
107
  createdAt: r.created_at, updatedAt: r.updated_at,
108
108
  });
109
109
  const json = (value) => JSON.stringify(value ?? null);
110
+ /** A UTF-16 surrogate standing alone (in `u` mode a whole pair is one code point, so only a lone half matches). */
111
+ const LONE_SURROGATE = /[\ud800-\udfff]/u;
112
+ /** A run's labels as its column holds them: keys sorted, so the same labels are the same text; null for none. A key or value
113
+ * holding a lone surrogate is refused (TypeError), nothing written: JSON.stringify keeps it as a `\ud800` escape that
114
+ * Postgres' json check takes but json_each_text cannot decode, so every later label search scanning the run would fail. */
115
+ const labelsColumn = (labels) => {
116
+ for (const [key, value] of Object.entries(labels ?? {})) {
117
+ if (LONE_SURROGATE.test(key) || LONE_SURROGATE.test(value))
118
+ throw new TypeError(`a run's label ${JSON.stringify(key)} holds a lone UTF-16 surrogate: a label is whole Unicode characters`);
119
+ }
120
+ const keys = Object.keys(labels ?? {}).sort();
121
+ return keys.length === 0 ? null : JSON.stringify(Object.fromEntries(keys.map((key) => [key, labels[key]])));
122
+ };
110
123
  /** A revision's MCP pin as its column keeps it: JSON, or null for none. */
111
124
  const pinText = (pin) => (pin === undefined || pin === null ? null : JSON.stringify(pin));
112
125
  const removedOf = (r) => r && { url: r.url, sealed: r.sealed === null ? null : Uint8Array.from(r.sealed) };
@@ -131,6 +144,7 @@ const settingOf = (r) => ({ key: r.key, value: JSON.parse(r.value), updatedAt: r
131
144
  const sealedKeyOf = (r) => ({ name: r.name, sealed: Uint8Array.from(r.sealed), updatedAt: r.updated_at });
132
145
  const ledgerRowOf = (r) => ({ provider: r.provider, sessionId: r.session_id, labels: JSON.parse(r.labels), detail: JSON.parse(r.detail), updatedAt: r.updated_at });
133
146
  const pairedOf = (r) => ({ id: r.id, name: r.name, hello: JSON.parse(r.hello), driver: r.driver, labels: JSON.parse(r.labels), pairingId: r.pairing_id, createdAt: r.created_at, seenAt: r.seen_at, revokedAt: r.revoked_at });
147
+ const mintedOf = (r) => ({ machine: r.machine, kind: r.kind, os: r.os, arch: r.arch, expiresAt: r.expires_at, revokedAt: r.revoked_at, createdAt: r.created_at });
134
148
  const triggerSettingOf = (r) => ({ adapter: r.adapter, scope: r.scope, field: r.field, sealed: r.sealed, updatedAt: r.updated_at });
135
149
  const mcpOauthOf = (r) => ({ state: r.state, server: r.server, sealed: Uint8Array.from(r.sealed), working: r.working === null ? null : JSON.parse(r.working), expiresAt: r.expires_at });
136
150
  const SIGN_IN_COLUMNS = "agent_id, provider, name, pointer_sealed, saved_at, save, verified_at";
@@ -258,12 +272,19 @@ export async function openSqliteStore(options) {
258
272
  }
259
273
  // An earlier build of this version kept no bound beside a run's cost (schema.ts RUNS_COST_UPPER_BOUND): the server adds
260
274
  // it, every run it ended reading 0, and a runner, which writes it at each end, waits for that server.
261
- const costBound = (await connection.all("SELECT name FROM pragma_table_info('runs')")).some((column) => column.name === "cost_upper_bound");
262
- if (!costBound) {
275
+ const runColumns = new Set((await connection.all("SELECT name FROM pragma_table_info('runs')")).map((column) => column.name));
276
+ if (!runColumns.has("cost_upper_bound")) {
263
277
  if (role === "runner")
264
278
  throw new Error("Start the AgentRun server to add the bound beside each run's cost before opening a runner. The runner does not upgrade this store.");
265
279
  await connection.write([{ sql: RUNS_COST_UPPER_BOUND }], { full: true });
266
280
  }
281
+ // An earlier build of this version kept no labels on a run (schema.ts RUNS_LABELS): the server adds the column, nullable,
282
+ // every run it started reading as given none. A runner reads each run through it, so it waits for that server.
283
+ if (!runColumns.has("labels")) {
284
+ if (role === "runner")
285
+ throw new Error("Start the AgentRun server to add each run's labels before opening a runner. The runner does not upgrade this store.");
286
+ await connection.write([{ sql: RUNS_LABELS }], { full: true });
287
+ }
267
288
  // The per-run viewer table was renamed browser_viewers → computer_viewers (schema.ts). Its rows are ephemeral, so none
268
289
  // migrate; the server drops a stale browser_viewers an earlier build of this version left, so none lingers beside it.
269
290
  // An earlier build of this version made no one-answer index on commands (schema.ts COMMANDS_ONE_ANSWER), or one that
@@ -285,6 +306,8 @@ export async function openSqliteStore(options) {
285
306
  { sql: COMMANDS_ONE_ANSWER },
286
307
  // An earlier build of this version kept no imported template packages (schema.ts IMPORTED_TEMPLATES).
287
308
  { sql: IMPORTED_TEMPLATES },
309
+ // Nor any hosted machine's minted token (schema.ts MINTED_TOKENS).
310
+ { sql: MINTED_TOKENS },
288
311
  { sql: NATIVE_COMMANDS_INDEX },
289
312
  ], { full: true });
290
313
  await backfillNativeCommandOwners(connection);
@@ -372,6 +395,7 @@ class SqliteStore {
372
395
  sealedKeys;
373
396
  computerLedger;
374
397
  pairedComputers;
398
+ mintedTokens;
375
399
  importedTemplates;
376
400
  triggerSettings;
377
401
  channels;
@@ -773,15 +797,16 @@ class SqliteStore {
773
797
  })),
774
798
  };
775
799
  this.runs = {
776
- create: async ({ id, agentId, revisionId, origin }, launch) => {
800
+ create: async ({ id, agentId, revisionId, origin, labels }, launch) => {
777
801
  // sign_in_handed is not written here: the runner writes it at its claim (runs.update under the epoch fence).
778
- const insert = `INSERT INTO runs (id, agent_id, revision_id, state, epoch, started_at) VALUES (?, ?, ?, 'queued', 0, ?) RETURNING ${RUN_COLUMNS}`;
802
+ const insert = `INSERT INTO runs (id, agent_id, revision_id, state, epoch, labels, started_at) VALUES (?, ?, ?, 'queued', 0, ?, ?) RETURNING ${RUN_COLUMNS}`;
803
+ const labelled = labelsColumn(labels);
779
804
  if (origin || launch) {
780
805
  // The run, its origin and its launch row in one transaction: the key -> run link holds even if the kept response
781
806
  // never lands, and a run never exists without the launch it was started with.
782
807
  return this.#queued(await db.transaction(async (tx) => {
783
808
  const at = now();
784
- const row = await tx.get(insert, id, agentId, revisionId, at);
809
+ const row = await tx.get(insert, id, agentId, revisionId, labelled, at);
785
810
  if (origin)
786
811
  await tx.run("INSERT INTO run_origins (key, run_id, fingerprint, created_at) VALUES (?, ?, ?, ?)", origin.key, id, origin.fingerprint ?? null, at);
787
812
  if (launch)
@@ -789,11 +814,11 @@ class SqliteStore {
789
814
  return runOf(row);
790
815
  }));
791
816
  }
792
- const [result] = await db.write([{ sql: insert, params: [id, agentId, revisionId, now()] }]);
817
+ const [result] = await db.write([{ sql: insert, params: [id, agentId, revisionId, labelled, now()] }]);
793
818
  return this.#queued(runOf(result.rows[0]));
794
819
  },
795
820
  createInline: async ({ agent, revision, run, launch }) => {
796
- const insert = `INSERT INTO runs (id, agent_id, revision_id, state, epoch, started_at) VALUES (?, ?, ?, 'queued', 0, ?) RETURNING ${RUN_COLUMNS}`;
821
+ const insert = `INSERT INTO runs (id, agent_id, revision_id, state, epoch, labels, started_at) VALUES (?, ?, ?, 'queued', 0, ?, ?) RETURNING ${RUN_COLUMNS}`;
797
822
  const made = await db.transaction(async (tx) => {
798
823
  const at = now();
799
824
  // Hold the external reference, so two first uses of the same expert serialize (SQLite's one writer already does).
@@ -816,7 +841,7 @@ class SqliteStore {
816
841
  await tx.run("UPDATE agents SET current_revision = ?, name = ?, description = ? WHERE id = ?", revisionId, agent.name, agent.description ?? null, mapped.id);
817
842
  }
818
843
  // The run, its origin and its launch, in the same transaction as the agent and the revision.
819
- const row = await tx.get(insert, run.id, mapped.id, revisionId, at);
844
+ const row = await tx.get(insert, run.id, mapped.id, revisionId, labelsColumn(run.labels), at);
820
845
  if (run.origin)
821
846
  await tx.run("INSERT INTO run_origins (key, run_id, fingerprint, created_at) VALUES (?, ?, ?, ?)", run.origin.key, run.id, run.origin.fingerprint ?? null, at);
822
847
  await writeLaunch(tx, run.id, launch, at);
@@ -830,7 +855,7 @@ class SqliteStore {
830
855
  },
831
856
  launch: (runId) => readLaunch(db, runId),
832
857
  learningStarts: (agentId) => readLearningStarts(db, agentId, NOT_A_LEARNING_RUN),
833
- list: async ({ agentId, revisionId, state, archived, limit }) => {
858
+ list: async ({ agentId, revisionId, state, archived, labels, limit }) => {
834
859
  // A built-in learning run (a run's grade and merge, queued with its kept learning) is no run of a person's: no list,
835
860
  // count, stat or notice names it.
836
861
  const where = [NOT_A_LEARNING_RUN];
@@ -843,6 +868,9 @@ class SqliteStore {
843
868
  (where.push("state = ?"), params.push(state));
844
869
  if (archived !== undefined)
845
870
  where.push(`archived_at IS ${archived ? "NOT NULL" : "NULL"}`);
871
+ // Each label, key and value bound as parameters (never spliced into a JSON path), all of them held.
872
+ for (const [key, value] of Object.entries(labels ?? {}))
873
+ (where.push(d.jsonObjectHas("labels")), params.push(key, value));
846
874
  const bounded = typeof limit === "number" && Number.isSafeInteger(limit) && limit >= 0;
847
875
  if (bounded)
848
876
  params.push(limit);
@@ -1362,6 +1390,32 @@ class SqliteStore {
1362
1390
  return (result?.changes ?? 0) === 1;
1363
1391
  },
1364
1392
  };
1393
+ const MINTED = "SELECT machine, kind, os, arch, expires_at, revoked_at, created_at FROM minted_tokens";
1394
+ this.mintedTokens = {
1395
+ // A mint for a machine that has one replaces it: its older token dials no more.
1396
+ mint: async ({ machine, tokenSha256, kind, os, arch, expiresAt }) => {
1397
+ const at = now();
1398
+ await db.write([
1399
+ { sql: "DELETE FROM minted_tokens WHERE expires_at <= ?", params: [at] },
1400
+ {
1401
+ sql: "INSERT INTO minted_tokens (machine, token_sha256, kind, os, arch, expires_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT (machine) DO UPDATE SET token_sha256 = excluded.token_sha256, kind = excluded.kind, os = excluded.os, arch = excluded.arch, expires_at = excluded.expires_at, revoked_at = NULL, created_at = excluded.created_at",
1402
+ params: [machine, tokenSha256, kind, os, arch, expiresAt, at],
1403
+ },
1404
+ ]);
1405
+ },
1406
+ byToken: async (tokenSha256) => {
1407
+ const row = await db.get(`${MINTED} WHERE token_sha256 = ? AND revoked_at IS NULL AND expires_at > ?`, tokenSha256, now());
1408
+ return row === undefined ? undefined : mintedOf(row);
1409
+ },
1410
+ get: async (machine) => {
1411
+ const row = await db.get(`${MINTED} WHERE machine = ?`, machine);
1412
+ return row === undefined ? undefined : mintedOf(row);
1413
+ },
1414
+ revoke: async (machine) => {
1415
+ const [result] = await db.write([{ sql: "UPDATE minted_tokens SET revoked_at = ? WHERE machine = ? AND revoked_at IS NULL", params: [now(), machine] }]);
1416
+ return (result?.changes ?? 0) === 1;
1417
+ },
1418
+ };
1365
1419
  this.importedTemplates = {
1366
1420
  list: async () => (await db.all("SELECT id, source, sha, publisher, files, imported_at FROM imported_templates ORDER BY id")).map((row) => ({
1367
1421
  id: row.id, source: row.source, sha: row.sha, publisher: row.publisher, files: JSON.parse(row.files), importedAt: row.imported_at,
@@ -129,6 +129,9 @@ export interface RunOrigin {
129
129
  readonly key: string;
130
130
  readonly fingerprint?: string | null;
131
131
  }
132
+ /** A run's labels: a small map of the caller's own strings, set once at its start, never read by the server (only
133
+ * filtered on). Bounds: run-labels.ts. */
134
+ export type RunLabels = Readonly<Record<string, string>>;
132
135
  export interface RunRow {
133
136
  readonly id: string;
134
137
  readonly agentId: string;
@@ -158,6 +161,8 @@ export interface RunRow {
158
161
  /** The SHA-256 hashes of the browser sign-in pointers handed to the run at its launch (never the pointers), or null when
159
162
  * it was handed none. A sign-in whose pointer hashes to one of these cannot be forgotten while the run runs. */
160
163
  readonly signInHanded: readonly string[] | null;
164
+ /** The caller's labels, given at its start (RunLabels): opaque to the server, kept as given, {} when none. */
165
+ readonly labels: RunLabels;
161
166
  readonly startedAt: number;
162
167
  readonly endedAt: number | null;
163
168
  }
@@ -774,6 +779,7 @@ export interface Runs {
774
779
  agentId: string;
775
780
  revisionId: string;
776
781
  origin?: RunOrigin;
782
+ labels?: RunLabels;
777
783
  }, launch?: RunLaunchInput): Promise<RunRow>;
778
784
  /** A run whose agent is given inline and mapped to a source system by `agent.ref` and `revision.version`. In one
779
785
  * transaction: the agent (one per `ref`, written on its first run, its name and description brought up to the version
@@ -801,6 +807,7 @@ export interface Runs {
801
807
  run: {
802
808
  id: string;
803
809
  origin?: RunOrigin;
810
+ labels?: RunLabels;
804
811
  };
805
812
  launch: RunLaunchInput;
806
813
  }): Promise<RunRow>;
@@ -817,12 +824,13 @@ export interface Runs {
817
824
  learning: unknown;
818
825
  }[]>;
819
826
  /** Newest first, at most `limit` (no limit: all). `archived` filters on the run's own archive time (true: archived,
820
- * false: not); its agent's archive is read apart. A built-in learning run (one a kept learning names) is never listed. */
827
+ * false: not); its agent's archive is read apart. A built-in learning run (one a kept learning names) is never listed. `labels`: only runs holding every one of these labels, key and value. */
821
828
  list(filter: {
822
829
  agentId?: string;
823
830
  revisionId?: string;
824
831
  state?: RunState;
825
832
  archived?: boolean;
833
+ labels?: RunLabels;
826
834
  limit?: number;
827
835
  }): Promise<RunRow[]>;
828
836
  /** Archives the run (its own archive time), or unarchives it: idempotent. */
@@ -1239,6 +1247,33 @@ export interface PairedComputers {
1239
1247
  /** Removes the computer: its token dials no more. False when it was not paired (unknown, or removed already). */
1240
1248
  revoke(id: string): Promise<boolean>;
1241
1249
  }
1250
+ /** A hosted machine's minted token (store schema `minted_tokens`): what the machine must say it is at hello, and the
1251
+ * token's life. The token is not here: the store keeps its SHA-256 alone. */
1252
+ export interface MintedTokenRow {
1253
+ /** The machine's name (from its create's request id): its id in the attach hub. */
1254
+ readonly machine: string;
1255
+ readonly kind: string;
1256
+ readonly os: string;
1257
+ readonly arch: string;
1258
+ /** When the token ends: the machine's backstop. */
1259
+ readonly expiresAt: number;
1260
+ /** When it was revoked (the machine's delete); null while it is good. */
1261
+ readonly revokedAt: number | null;
1262
+ readonly createdAt: number;
1263
+ }
1264
+ /** The tokens minted for hosted machines that dial this server (a dial provider's create, spec/computer/attach.md). */
1265
+ export interface MintedTokens {
1266
+ /** Keeps the token's SHA-256 for `machine`, replacing one minted for it before. Rows past their end go in the same write. */
1267
+ mint(token: Pick<MintedTokenRow, "machine" | "kind" | "os" | "arch" | "expiresAt"> & {
1268
+ readonly tokenSha256: string;
1269
+ }): Promise<void>;
1270
+ /** The row whose token has this SHA-256, while it is good: neither revoked nor past its end. */
1271
+ byToken(tokenSha256: string): Promise<MintedTokenRow | undefined>;
1272
+ /** The machine's row, good or not; undefined when it has none (never minted, or gone past its end). */
1273
+ get(machine: string): Promise<MintedTokenRow | undefined>;
1274
+ /** Revokes the machine's token. False when it had none good. */
1275
+ revoke(machine: string): Promise<boolean>;
1276
+ }
1242
1277
  /** A template package imported from GitHub (store schema `imported_templates`, POST /v2/templates/import): its id
1243
1278
  * (`github:<owner>/<repo>[/<path>]`), its source as given, the commit SHA read, its publisher (the GitHub account), and
1244
1279
  * its files as they were read, by path, base64. The server checks them again (templates.ts readPackage) as it loads them
@@ -1475,6 +1510,8 @@ export interface Store {
1475
1510
  readonly computerLedger: ComputerLedger;
1476
1511
  /** The people's own machines paired with this server, and the codes that pair them (spec/computer/attach.md). */
1477
1512
  readonly pairedComputers: PairedComputers;
1513
+ /** The tokens minted for hosted machines that dial this server, each kept as its SHA-256. */
1514
+ readonly mintedTokens: MintedTokens;
1478
1515
  /** The template packages imported from GitHub, their files kept as read. */
1479
1516
  readonly importedTemplates: ImportedTemplates;
1480
1517
  /** Each trigger source's sealed settings (design 2.1): a value per adapter, scope and field. */
@@ -51,7 +51,8 @@ export function piShaped(entries) {
51
51
  const timestamp = typeof data.at === "number" ? { timestamp: data.at } : {};
52
52
  if (entry.kind === KINDS.message) {
53
53
  const text = typeof data.text === "string" ? data.text : "";
54
- if (data.role === "person")
54
+ // The person's message, and one they steered into a turn in flight (claude-agent's), as pi writes both: a user turn.
55
+ if (data.role === "person" || data.role === "steer")
55
56
  return { ...entry, kind: "pi.user", model: [{ role: "user", content: text, ...timestamp }] };
56
57
  // A model turn's text; its stop reason is the answer's (a cut at the output limit reads "length", as pi's does).
57
58
  const stopReason = data.stopReason === "length" ? "length" : "stop";
@@ -105,10 +105,15 @@ async function endOfKept(store, kept, row, records = store) {
105
105
  const proposed = { state: "proposed", reason: null, detail: row.detail ?? null, at, ...left };
106
106
  if (!kept.learningRunId)
107
107
  return proposed;
108
- const learningRun = await records.runs.get(kept.learningRunId);
108
+ let learningRun = await records.runs.get(kept.learningRunId);
109
109
  const { merged, dropped, graded } = await learningEndEntries(store, kept.learningRunId, learningRun);
110
110
  if (!merged && !dropped)
111
111
  return proposed;
112
+ // The loop saves its end entry and the learning run's end (state, ended_at) in one transaction, and the row was read
113
+ // before the journal: an end the row had not seen landed between the two reads. The row read again from the store (past
114
+ // any list read before) is the ended one, so the end is at its ended_at, never once at the proposal's time.
115
+ if (!(learningRun && FINAL_STATES.includes(learningRun.state)))
116
+ learningRun = await store.runs.get(kept.learningRunId);
112
117
  const endedAt = learningRun?.endedAt ? timeOf(learningRun.endedAt) : at;
113
118
  // What the grade spent: the graded entry's, or what a grade that failed spent before it did.
114
119
  const spent = graded ?? (dropped && "usd" in dropped ? { usd: dropped.usd ?? null, tokens: dropped.tokens ?? null } : undefined);
@@ -1,5 +1,5 @@
1
1
  import type { Context } from "@earendil-works/chord/context";
2
- import { type ImportedFrom, type RunRow, type Store } from "../store/store.js";
2
+ import { type ImportedFrom, type RunLabels, type RunRow, type Store } from "../store/store.js";
3
3
  /** A revision's kind, as the row names it. */
4
4
  export type RevisionKind = "agentic" | "workflow";
5
5
  /** The run state the v2 API serves, as the old store kept it: a non-terminal run is 'running' (the live view refines its
@@ -29,11 +29,12 @@ export interface RunRowView {
29
29
  * stopped (`kind`: its revision's), whose turn ended and never the run, as main's stop leaves one (runs.ts statusOf: a
30
30
  * stopped run is input_required and idle). A cancel, a workflow's stop and an imported run's read 'stopped'. */
31
31
  export declare function runReadState(run: RunRow, kind: RevisionKind): RunReadState;
32
- /** The runs, newest first; `agent` and `revision` narrow it. Archived runs are listed too (the server filters them), with
33
- * the archive time coalesced onto each row, and a not-ended run's cost its booked-so-far spend. */
32
+ /** The runs, newest first; `agent`, `revision` and `labels` (every one held) narrow it. Archived runs are listed too (the
33
+ * server filters them), with the archive time coalesced onto each row, and a not-ended run's cost its booked-so-far spend. */
34
34
  export declare function listRuns(store: Store, filter: {
35
35
  agent?: string;
36
36
  revision?: string;
37
+ labels?: RunLabels;
37
38
  }, context: Context): Promise<RunRowView[]>;
38
39
  /** One run with its agent's name; undefined for an unknown run. */
39
40
  export declare function readRun(store: Store, runId: string, context: Context): Promise<(RunRowView & {
@@ -60,12 +60,13 @@ function joins(store, context) {
60
60
  },
61
61
  };
62
62
  }
63
- /** The runs, newest first; `agent` and `revision` narrow it. Archived runs are listed too (the server filters them), with
64
- * the archive time coalesced onto each row, and a not-ended run's cost its booked-so-far spend. */
63
+ /** The runs, newest first; `agent`, `revision` and `labels` (every one held) narrow it. Archived runs are listed too (the
64
+ * server filters them), with the archive time coalesced onto each row, and a not-ended run's cost its booked-so-far spend. */
65
65
  export async function listRuns(store, filter, context) {
66
66
  const runs = await store.runs.list({
67
67
  ...(filter.agent !== undefined ? { agentId: filter.agent } : {}),
68
68
  ...(filter.revision !== undefined ? { revisionId: filter.revision } : {}),
69
+ ...(filter.labels !== undefined ? { labels: filter.labels } : {}),
69
70
  });
70
71
  const join = joins(store, context);
71
72
  const views = [];
@@ -459,6 +459,8 @@ export async function viewOverStore(store, runId, deps) {
459
459
  // Only what an imported run shows: never the server's internal file stamp (importedFrom.file).
460
460
  imported_from: runRow.importedFrom ? { source: runRow.importedFrom.source, session: runRow.importedFrom.session } : null,
461
461
  trigger: launch?.trigger ? { id: launch.trigger.id, firing_key: launch.trigger.firing_key } : null,
462
+ // The caller's labels, as given at the start ({} when none): its own strings, never cut.
463
+ labels: runRow.labels,
462
464
  // Cut by the run's one cut (the pointers it was handed among them), and none for a withheld run, as its words.
463
465
  learning: unshown ? null : learningViewOf(run.learningEnd, secretsShown(values), settled),
464
466
  poll_after_ms: settled ? 0 : 1000,
@@ -470,13 +472,13 @@ export async function summaryOverStore(store, runId, deps) {
470
472
  const view = await viewOverStore(store, runId, deps);
471
473
  if (!view)
472
474
  return undefined;
473
- 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, learning } = view;
475
+ 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;
474
476
  return {
475
477
  run_id, agent_id, agent_version, console_url, revision, kind, sha, status, state, title,
476
478
  ...(view.sdk ? { sdk: view.sdk } : {}),
477
479
  ...(view.native ? { native: view.native } : {}),
478
480
  ...(effort ? { effort } : {}),
479
- created_at, ended_at, error, review, pending, cost, archived_at, imported_from, trigger,
481
+ created_at, ended_at, error, review, pending, cost, archived_at, imported_from, trigger, labels,
480
482
  learning: learning ? shortOf(learning) : null,
481
483
  };
482
484
  }
@@ -1,4 +1,5 @@
1
1
  import { type Layout, type MailboxAfter, type MailboxFixture, type MailboxRecord } from "./eval-mailbox.js";
2
+ import { type FeedFixture } from "./eval-feed.js";
2
3
  import type { MonidFake } from "./runner/monid-run.js";
3
4
  import { type WebFake } from "./web-fake.js";
4
5
  import { type Package } from "./templates.js";
@@ -121,6 +122,9 @@ export type EvalCase = {
121
122
  /** The case's fake mailbox (eval-mailbox.ts): each run on each of its layouts gets a fake account seeded from it, and is
122
123
  * started by the package's trigger as it would be. Absent: the server's account, if any. */
123
124
  email?: MailboxFixture;
125
+ /** The case's fake feed (eval-feed.ts): each run gets fake feeds served from it, read in place of the URLs the
126
+ * package's feed trigger names, and is started by that trigger as it would be. */
127
+ feed?: FeedFixture;
124
128
  };
125
129
  /** Cases that do not check: every problem, each naming its file. */
126
130
  export declare class CaseError extends Error {