driverkit 0.0.0-stage → 0.0.1

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 (160) hide show
  1. package/CONTROLS.md +578 -0
  2. package/REACT.md +477 -0
  3. package/README.md +104 -2
  4. package/dist/agent/backend.d.ts +69 -0
  5. package/dist/agent/backend.d.ts.map +1 -0
  6. package/dist/agent/backend.js +130 -0
  7. package/dist/agent/backend.js.map +1 -0
  8. package/dist/agent/control.d.ts +148 -0
  9. package/dist/agent/control.d.ts.map +1 -0
  10. package/dist/agent/control.js +342 -0
  11. package/dist/agent/control.js.map +1 -0
  12. package/dist/agent/index.d.ts +9 -0
  13. package/dist/agent/index.d.ts.map +1 -0
  14. package/dist/agent/index.js +6 -0
  15. package/dist/agent/index.js.map +1 -0
  16. package/dist/agent/loop.d.ts +136 -0
  17. package/dist/agent/loop.d.ts.map +1 -0
  18. package/dist/agent/loop.js +824 -0
  19. package/dist/agent/loop.js.map +1 -0
  20. package/dist/agent/render.d.ts +173 -0
  21. package/dist/agent/render.d.ts.map +1 -0
  22. package/dist/agent/render.js +425 -0
  23. package/dist/agent/render.js.map +1 -0
  24. package/dist/agent/tools.d.ts +138 -0
  25. package/dist/agent/tools.d.ts.map +1 -0
  26. package/dist/agent/tools.js +622 -0
  27. package/dist/agent/tools.js.map +1 -0
  28. package/dist/agent/types.d.ts +566 -0
  29. package/dist/agent/types.d.ts.map +1 -0
  30. package/dist/agent/types.js +32 -0
  31. package/dist/agent/types.js.map +1 -0
  32. package/dist/browser/budget.d.ts +92 -0
  33. package/dist/browser/budget.d.ts.map +1 -0
  34. package/dist/browser/budget.js +151 -0
  35. package/dist/browser/budget.js.map +1 -0
  36. package/dist/browser/connect.d.ts +368 -0
  37. package/dist/browser/connect.d.ts.map +1 -0
  38. package/dist/browser/connect.js +1038 -0
  39. package/dist/browser/connect.js.map +1 -0
  40. package/dist/browser/elsewhere.d.ts +89 -0
  41. package/dist/browser/elsewhere.d.ts.map +1 -0
  42. package/dist/browser/elsewhere.js +91 -0
  43. package/dist/browser/elsewhere.js.map +1 -0
  44. package/dist/browser/frames.d.ts +85 -0
  45. package/dist/browser/frames.d.ts.map +1 -0
  46. package/dist/browser/frames.js +11 -0
  47. package/dist/browser/frames.js.map +1 -0
  48. package/dist/browser/index.d.ts +8 -0
  49. package/dist/browser/index.d.ts.map +1 -0
  50. package/dist/browser/index.js +9 -0
  51. package/dist/browser/index.js.map +1 -0
  52. package/dist/check/check.d.ts +171 -0
  53. package/dist/check/check.d.ts.map +1 -0
  54. package/dist/check/check.js +666 -0
  55. package/dist/check/check.js.map +1 -0
  56. package/dist/check/index.d.ts +3 -0
  57. package/dist/check/index.d.ts.map +1 -0
  58. package/dist/check/index.js +2 -0
  59. package/dist/check/index.js.map +1 -0
  60. package/dist/check/types.d.ts +149 -0
  61. package/dist/check/types.d.ts.map +1 -0
  62. package/dist/check/types.js +29 -0
  63. package/dist/check/types.js.map +1 -0
  64. package/dist/controls/controls.d.ts +198 -0
  65. package/dist/controls/controls.d.ts.map +1 -0
  66. package/dist/controls/controls.js +742 -0
  67. package/dist/controls/controls.js.map +1 -0
  68. package/dist/controls/dom.d.ts +108 -0
  69. package/dist/controls/dom.d.ts.map +1 -0
  70. package/dist/controls/dom.js +56 -0
  71. package/dist/controls/dom.js.map +1 -0
  72. package/dist/controls/index.d.ts +26 -0
  73. package/dist/controls/index.d.ts.map +1 -0
  74. package/dist/controls/index.js +23 -0
  75. package/dist/controls/index.js.map +1 -0
  76. package/dist/controls/rows.d.ts +66 -0
  77. package/dist/controls/rows.d.ts.map +1 -0
  78. package/dist/controls/rows.js +127 -0
  79. package/dist/controls/rows.js.map +1 -0
  80. package/dist/core/index.d.ts +3 -0
  81. package/dist/core/index.d.ts.map +1 -0
  82. package/dist/core/index.js +15 -0
  83. package/dist/core/index.js.map +1 -0
  84. package/dist/core/registry.d.ts +192 -0
  85. package/dist/core/registry.d.ts.map +1 -0
  86. package/dist/core/registry.js +2799 -0
  87. package/dist/core/registry.js.map +1 -0
  88. package/dist/core/types.d.ts +2468 -0
  89. package/dist/core/types.d.ts.map +1 -0
  90. package/dist/core/types.js +19 -0
  91. package/dist/core/types.js.map +1 -0
  92. package/dist/otel/index.d.ts +122 -0
  93. package/dist/otel/index.d.ts.map +1 -0
  94. package/dist/otel/index.js +157 -0
  95. package/dist/otel/index.js.map +1 -0
  96. package/dist/react/index.d.ts +191 -0
  97. package/dist/react/index.d.ts.map +1 -0
  98. package/dist/react/index.js +547 -0
  99. package/dist/react/index.js.map +1 -0
  100. package/dist/react/runtime.d.ts +95 -0
  101. package/dist/react/runtime.d.ts.map +1 -0
  102. package/dist/react/runtime.js +54 -0
  103. package/dist/react/runtime.js.map +1 -0
  104. package/dist/react/store.d.ts +333 -0
  105. package/dist/react/store.d.ts.map +1 -0
  106. package/dist/react/store.js +695 -0
  107. package/dist/react/store.js.map +1 -0
  108. package/dist/relay/auth.d.ts +244 -0
  109. package/dist/relay/auth.d.ts.map +1 -0
  110. package/dist/relay/auth.js +391 -0
  111. package/dist/relay/auth.js.map +1 -0
  112. package/dist/relay/frames.d.ts +141 -0
  113. package/dist/relay/frames.d.ts.map +1 -0
  114. package/dist/relay/frames.js +20 -0
  115. package/dist/relay/frames.js.map +1 -0
  116. package/dist/relay/index.d.ts +8 -0
  117. package/dist/relay/index.d.ts.map +1 -0
  118. package/dist/relay/index.js +4 -0
  119. package/dist/relay/index.js.map +1 -0
  120. package/dist/relay/relay.d.ts +277 -0
  121. package/dist/relay/relay.d.ts.map +1 -0
  122. package/dist/relay/relay.js +1026 -0
  123. package/dist/relay/relay.js.map +1 -0
  124. package/dist/relay/serve.d.ts +33 -0
  125. package/dist/relay/serve.d.ts.map +1 -0
  126. package/dist/relay/serve.js +86 -0
  127. package/dist/relay/serve.js.map +1 -0
  128. package/dist/widget/chat.d.ts +290 -0
  129. package/dist/widget/chat.d.ts.map +1 -0
  130. package/dist/widget/chat.js +486 -0
  131. package/dist/widget/chat.js.map +1 -0
  132. package/dist/widget/css.d.ts +49 -0
  133. package/dist/widget/css.d.ts.map +1 -0
  134. package/dist/widget/css.js +532 -0
  135. package/dist/widget/css.js.map +1 -0
  136. package/dist/widget/dom.d.ts +143 -0
  137. package/dist/widget/dom.d.ts.map +1 -0
  138. package/dist/widget/dom.js +27 -0
  139. package/dist/widget/dom.js.map +1 -0
  140. package/dist/widget/highlight.d.ts +64 -0
  141. package/dist/widget/highlight.d.ts.map +1 -0
  142. package/dist/widget/highlight.js +136 -0
  143. package/dist/widget/highlight.js.map +1 -0
  144. package/dist/widget/index.d.ts +9 -0
  145. package/dist/widget/index.d.ts.map +1 -0
  146. package/dist/widget/index.js +20 -0
  147. package/dist/widget/index.js.map +1 -0
  148. package/dist/widget/position.d.ts +166 -0
  149. package/dist/widget/position.d.ts.map +1 -0
  150. package/dist/widget/position.js +497 -0
  151. package/dist/widget/position.js.map +1 -0
  152. package/dist/widget/settings.d.ts +116 -0
  153. package/dist/widget/settings.d.ts.map +1 -0
  154. package/dist/widget/settings.js +117 -0
  155. package/dist/widget/settings.js.map +1 -0
  156. package/dist/widget/widget.d.ts +442 -0
  157. package/dist/widget/widget.d.ts.map +1 -0
  158. package/dist/widget/widget.js +2005 -0
  159. package/dist/widget/widget.js.map +1 -0
  160. package/package.json +144 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;6EAE6E;AAC7E,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAEtD;8DAC8D;AAC9D,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtC,yEAAyE;IACzE,QAAQ,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,6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;;;;;OAyDG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB;;;;;;;;;;;;;;;;OAgBG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED,MAAM,WAAW,MAAM;IACrB,oEAAoE;IACpE,QAAQ,EAAE,MAAM,QAAQ,CAAC;IACzB,wCAAwC;IACxC,QAAQ,EAAE,MAAM,QAAQ,CAAC;IACzB,sEAAsE;IACtE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3F;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,MAAM,WAAW,CAAC;IAC3B,gCAAgC;IAChC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B;;wDAEoD;IACpD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * driverkit — the types.
3
+ *
4
+ * The whole library rests on a split that is worth stating before any code:
5
+ *
6
+ * A VERB is static. Its name, its arguments and what it refuses are the same
7
+ * for every user on every day, so they can be sent to a model once, cached in
8
+ * the prompt prefix, and never sent again.
9
+ *
10
+ * A SNAPSHOT is dynamic. It is what a human could see at this moment, and
11
+ * nothing more, so it is small by construction and goes in the tail where it
12
+ * is never cached.
13
+ *
14
+ * Keeping anything per-user or per-screen out of the verb list is not tidiness,
15
+ * it is the entire cost argument. One user-specific string in the static half
16
+ * busts the cache for everybody and the library stops being cheap to drive.
17
+ */
18
+ export {};
19
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG","sourcesContent":["/**\n * driverkit — the types.\n *\n * The whole library rests on a split that is worth stating before any code:\n *\n * A VERB is static. Its name, its arguments and what it refuses are the same\n * for every user on every day, so they can be sent to a model once, cached in\n * the prompt prefix, and never sent again.\n *\n * A SNAPSHOT is dynamic. It is what a human could see at this moment, and\n * nothing more, so it is small by construction and goes in the tail where it\n * is never cached.\n *\n * Keeping anything per-user or per-screen out of the verb list is not tidiness,\n * it is the entire cost argument. One user-specific string in the static half\n * busts the cache for everybody and the library stops being cheap to drive.\n */\n\n/** A value an agent can pass to a verb. Deliberately not `any`: if an argument\n * cannot survive JSON it cannot cross the relay to an agent in another\n * process, and a verb that only works in-page is a verb that works once. */\nexport type Scalar = string | number | boolean | null;\n\n/** What a verb accepts. A tiny subset of JSON Schema, hand-rolled so the core\n * package keeps its promise of zero runtime dependencies. */\nexport interface ArgSpec {\n type: \"string\" | \"number\" | \"boolean\";\n /** Shown to the model. Write it for a reader who cannot see your app. */\n describe: string;\n /** If present, the only accepted values. Cheaper and safer than prose. */\n oneOf?: Scalar[];\n /** Absent means required. */\n optional?: boolean;\n /**\n * `true` when this argument's VALUE must never appear in an audit record.\n *\n * The one half of redaction the library cannot work out for itself. An\n * argument is whatever the app declared — a row id, a filter, a company\n * name, and on some app somewhere an API key or a one-time code — and only\n * the author who typed the `describe` knows which. A library that guessed\n * would guess by name, which is how `token` gets redacted and\n * `otp_material` does not.\n *\n * So the app declares it and the CORE does the replacing, before the hook\n * is called: `AuditEvent.args` carries `\"[redacted]\"` in this field's place\n * and `AuditEvent.redacted` names the field, so a reader cannot mistake the\n * marker for a string the agent actually sent. The alternative — hand the\n * hook everything and let the host strip it — puts the secret on the far\n * side of the one boundary where a record is most likely to leave the box,\n * and makes the DANGEROUS case the one you get by doing the obvious thing.\n * A host that wires `onAudit` straight to its tracer should not thereby\n * ship a key to a vendor.\n *\n * It changes nothing else. The value reaches `run` untouched — this is a\n * statement about the record, not about the call — and nothing renders it\n * to the model.\n *\n * It IS in the manifest, and so in `fingerprint()`, like the rest of an\n * `ArgSpec`. That is consistent rather than a leak: it is static, it is the\n * same bytes for every user forever, and it carries no value — only the\n * claim that this field has one worth hiding. An app that declares none\n * hashes exactly what it hashed before this field existed.\n */\n sensitive?: true;\n}\n\n/**\n * What a verb does to the world, declared in the cached half so an agent knows\n * before it calls.\n *\n * `read` — changes no data and reports no count. Free to call, free to\n * get wrong. It may still move what the person is looking at:\n * navigation is a read.\n * `describe` — changes what is SELECTED, changes no data, and reports a\n * `count`. Also safe: the worst outcome is the wrong rows\n * highlighted.\n * `commit` — changes data. May be irreversible; see `Verb.reversible`.\n *\n * `read` used to promise \"changes nothing\", and that was false of the commonest\n * verb a multi-screen app has. `go`, `open-contact`, `back` and `sort-by` move\n * the person's screen out from under them — the most visible thing an agent can\n * do to somebody who is watching — and the cached half was telling it that was\n * free. The wording was fixed rather than a fourth kind added, because these\n * three are a ladder of WHAT A WRONG CALL COSTS YOU, and a wrong navigation\n * costs exactly what a wrong read costs: the person has to look somewhere else.\n * The two promises worth making are the ones that decide whether the next call\n * is safe — no data moved, and no count is left pending — so those are the two\n * this now makes, and they are true of every navigation verb.\n *\n * `describe` no longer says \"or FILTERED\", and that was not a trim. By that\n * sentence a search box is a `describe`, which is how `search` gets declared\n * one; but the rest of what `describe` means — that it reports a `count`, that\n * the count is what a following `commit` acts on, that the pair is the safety\n * mechanism — is true only of selection. A verb that narrows a list and leaves\n * nothing pending is a `read`.\n *\n * This exists because of one failure mode. Asked to \"select the top 1000 rows\n * and bulk accept\", an agent that cannot tell `select` from `accept` has to\n * discover the difference by doing it, and the discovery costs you a thousand\n * accepted rows. A screenshot cannot tell it apart either, and neither can an\n * OpenAPI spec, which says what a call takes but not what it costs you.\n *\n * The pairing rule that makes bulk work safe: a `describe` verb takes the\n * predicate and returns the count, a `commit` verb takes NO predicate and acts\n * on the current selection. Two calls, so a count is always seen before data\n * moves. A verb that both selects and accepts is how fifty thousand rows get\n * accepted because a filter was wider than anybody thought.\n *\n * TWO CALLS IS NOT ENOUGH ON ITS OWN, and that is what `Verb.consumes` is for.\n * \"Acts on the current selection\" re-reads the selection at call time, so\n * between the `describe` and the `commit` a person can tick a row, page the\n * list, or a websocket can land — and then the count the agent read and the\n * human approved is not provably the set the commit touched. Django has shipped\n * that exact bug class since 2010, where `select_across` was silently lost and\n * a confirmed bulk action ran on page one only (tickets 15742, 33083, and 36706\n * closed wontfix in 2025). Chrome's WebMCP best practices state the requirement\n * in one line: confirmation must recompute the current state and reject stale\n * work. So a `commit` may declare `consumes: \"plan\"`, the `describe` hands back\n * a token the core minted over the selection it left behind, and the commit has\n * to present it. See `Verb.consumes`, `Snapshot.selectionId` and\n * `CallOptions.plan`.\n *\n * `ask` IS THE FOURTH KIND, AND THIS FILE HAS ALREADY REFUSED ONE ONCE, so the\n * difference is worth stating before the type. Navigation was refused a kind of\n * its own on the grounds that the three are a ladder of WHAT A WRONG CALL COSTS\n * YOU and a wrong navigation costs exactly what a wrong read costs. A wrong\n * question is not on that ladder at all: it costs a PERSON'S ATTENTION, which\n * is the one currency the other three never spend. `read` says \"free to call,\n * free to get wrong\", and that sentence is false of a question — asking is\n * budgeted (`Budget.asks`), it blocks every other call while it is open, and\n * the cost of getting it wrong is paid by somebody who then trusts the next\n * question less. `describe` reports a count about the app and `commit` moves the\n * app's data; a question reads and writes nothing in the app. So it is neither\n * `read` in the ladder's own terms nor a lie dressed as one.\n *\n * **ONLY THE CORE MAY MINT IT.** An app verb declaring `kind: \"ask\"` is refused\n * at `mount()`. A question is put through `MountOptions.ask` so that the core\n * owns the lock, the deadline, the allowance and the audit row; an app verb\n * wearing the kind would be a question none of those applied to, and the first\n * thing somebody would build with it is a confirmation dialog that answers for\n * the approval gate. See `AskHook`.\n */\nexport type VerbKind = \"read\" | \"describe\" | \"commit\" | \"ask\";\n\n/**\n * Something the app can do.\n *\n * `refuses` is the field people skip and the one that earns its place. A\n * screenshot cannot tell an agent what a button will do, and neither can a\n * name: `delete` is reachable on screen whether or not this particular row is\n * deletable. Listing the refusals up front, in the half that gets cached, lets\n * an agent avoid the call instead of discovering the answer by making it.\n *\n * On bulk work, note what a verb must NOT be. If the only way to select a\n * thousand rows is a thousand `select(id)` calls, an agent will make a\n * thousand round trips and lose its way somewhere in the middle. So a verb\n * that operates on many rows takes a PREDICATE and resolves it inside the app,\n * where the rows already are — `select(where, limit)`, never `select(id)`\n * repeated. The agent should never learn an id it did not need.\n */\nexport interface Verb<A extends Record<string, Scalar> = Record<string, Scalar>> {\n /** Stable, kebab-case, unique within a mount. This is the agent's handle on\n * it, so renaming one is a breaking change to every stored prompt. */\n name: string;\n /** One line, imperative, in the user's own vocabulary: \"accept the selected\n * contacts\". Not \"calls patchContacts\" — the agent cannot see your code,\n * and a name drawn from your internals makes it guess at your intent. */\n describe: string;\n /** What this does to the world. Optional, and an absent one makes NO safety\n * claim in either direction: treating it as `read` would tell an agent an\n * irreversible verb is free to try, and treating it as `commit` would mark\n * every verb of an app written before this field as dangerous, which is a\n * warning on everything and therefore a warning on nothing. Declare it. */\n kind?: VerbKind;\n /**\n * A CSS selector naming the element this verb affects. Optional, purely\n * presentational, and **never used by driverkit to find anything.**\n *\n * It exists for the human watching. An agent driving the screen a person is\n * looking at has to be legible, and \"about to accept the selection\" reads\n * better with the table it means outlined on the page. `at` is how a verb\n * says which part of the app it is about, so a UI may draw an outline there\n * before the call and clear it after.\n *\n * The library never queries it, never resolves it, never shows it to the\n * model, and nothing about a verb's behaviour depends on it. That restraint\n * is the field's whole design rather than an omission waiting to be filled\n * in: driverkit's claim is that an app is driven through its own verbs and\n * not by poking at its DOM, and an `at` that driverkit itself clicked would\n * be a back door straight back to selector automation — brittle, invisible\n * to the app, and broken by the next CSS refactor. So a wrong or stale `at`\n * must cost nothing but an outline drawn in the wrong place. If a verb stops\n * working when `at` is edited, something has started using it, and that is\n * the bug.\n *\n * It is in `fingerprint()` all the same. Re-pointing a verb at a different\n * element changes what the cached surface claims, and a UI holding the old\n * copy would go on outlining the thing the verb no longer touches.\n */\n at?: string;\n /**\n * The screen this verb belongs to, or the screens it belongs to, matched\n * against `Snapshot.screen`.\n *\n * Absent means the verb applies anywhere, which is the right answer for most\n * of them: `select-contact` and `clear-selection` work from any screen, and\n * an app with one screen never fills this in.\n *\n * **An array is for a verb that genuinely lives on more than one screen**,\n * and it was added because a single string made the library's own worked\n * example lie. `next-page` and `prev-page` page both the contacts list and a\n * company's contact list; declaring either screen would have the demo refuse\n * a paging call on a screen that was still publishing a `page: {index, size,\n * total}` block and whose rendered snapshot still said \"more rows exist off\n * screen; use the app's own paging verb\". Faced with writing that\n * contradiction into the example, the app invented an `no-pages-here`\n * refusal of its own instead — which is the smell this field exists to\n * remove: an app hand-rolling a check and naming it, so that the next app\n * names it something else and no agent recognises both.\n *\n * A single string behaves exactly as it always did. An EMPTY ARRAY is\n * refused at `mount()`, the way a duplicate verb name is: it says the verb\n * works nowhere, which no author means, and a verb that can never be called\n * is permanently dead weight in everybody's cached prefix. Omit the field to\n * mean \"anywhere\".\n *\n * **The tool list does not change with the screen, and must not.** A verb\n * list that varied per screen would bust the prompt prefix on every single\n * navigation, which is the cost argument the whole library is built on — so\n * `next-page` is offered on the dashboard too, and the core refuses it there\n * with the screen named. Declaring the mapping statically is what makes it\n * cacheable: the names of the screens and which verb lives on which are the\n * same for every user forever, and only *which screen is live* is dynamic.\n *\n * What this buys over an app's own guard is that the refusal is structural\n * and says both halves of the answer. Before it, the app wrote the check by\n * hand and invented a slug for it, and an agent had no way to learn which\n * screen a verb wanted except by being refused once — the manifest was a\n * flat list with no screen on any entry. Now the mapping is in the cached\n * half, where a well-briefed agent reads it before calling, which is the\n * same argument `refuses` is in there for.\n *\n * In `fingerprint()`, for the reason `kind` is: moving a verb to another\n * screen changes what the cached surface claims about where it works, and so\n * does giving it a second one.\n */\n screen?: string | string[];\n /**\n * `true` on a `commit` whose effect the app can undo.\n *\n * Read only for `kind: \"commit\"`, and absent makes no claim — exactly like\n * `kind` itself, because the two wrong defaults cost the same two things:\n * assuming reversible tells an agent a bulk accept can be taken back, and\n * assuming irreversible marks every commit of an app written before this\n * field as the dangerous kind, which is a warning on everything and\n * therefore a warning on nothing.\n *\n * It exists because `set-setting(\"dense-rows\", \"true\")` and accepting 3,412\n * contacts were both `commit`, so both got the same shouted banner and both\n * stopped to ask a person. Putting a page-size change behind a confirmation\n * dialog is how people learn to click Yes without reading, which is the exact\n * failure the gate exists to prevent. The ladder's third rung was carrying\n * two different costs and only had words for the worse one.\n *\n * Reversible is not harmless: it still changes data and the person still\n * sees it. It means there is a way back, not that nobody minds.\n */\n reversible?: true;\n /**\n * `\"plan\"` on a `commit` that may only be called with a token from the\n * `describe` that counted what it is about to touch.\n *\n * THE HOLE THIS CLOSES. The pairing rule — a `describe` takes the predicate\n * and reports a `count`, a `commit` takes no predicate and acts on the\n * current selection — was advertised as \"two calls, so a count is always seen\n * before data moves\". It was not that. `commit` re-reads \"the current\n * selection\" at call time, and between the two calls the person can tick a\n * row, page the list, or a websocket can land. So the count that was read,\n * and approved, was not provably the set that moved. Django shipped exactly\n * this for fifteen years: `select_across` silently lost, so a confirmed bulk\n * action ran on page one only. Chrome's WebMCP best-practices page states the\n * fix in one line — confirmation must recompute the current state and reject\n * stale work — and recommends binding the transition to state version and\n * exact scope, which is what a token here is.\n *\n * The model is Terraform's saved plan: applying one performs exactly the\n * steps in that file, and a saved plan is valid only while the state has not\n * changed. So a `describe` that leaves a selection behind gets a `plan` token\n * back beside its `count` (see `Result.plan`), and a `commit` declaring this\n * must be called with that token in `CallOptions.plan`. The core refuses as\n * `stale-plan` when the token is missing, was never minted here, was taken at\n * an older `rev`, or named a selection that is no longer the one on screen —\n * and names both counts in the hint, the way `wrong-screen` names both\n * screens.\n *\n * **A READ-ONLY MOVE IS NOT AN OLDER `rev`.** Navigation bumps `rev` and\n * changes no data, so a plan is carried across a `kind: \"read\"` verb whose\n * call left `Snapshot.selectionId` unchanged. Without that, \"go back and\n * confirm the number before you move 3,412 rows\" cost a refusal and two\n * recovery calls, and committing blind cost nothing — pricing the\n * double-check above the blind commit, which is the opposite of what this\n * field is for. An app publishing no `selectionId` carries nothing and keeps\n * the behaviour it had.\n *\n * **The app does not mint the token and cannot**, which is the point of the\n * field being this small. An app that computed its own would have to get a\n * hash right, and a token an app can forge or accidentally reuse is worse\n * than no token because it still reads as a guarantee. All the app does is\n * publish `Snapshot.selectionId`; the core does the binding.\n *\n * Static, and in `fingerprint()` for the same reason `kind` is: a verb that\n * has started requiring a token has changed what a cached manifest claims\n * about how it may be called, and an agent holding the old copy would go on\n * calling it bare and being refused. An absent one makes NO claim and\n * changes nothing — a commit written before this field behaves exactly as it\n * did, which is why this is not the default. A `read` or a `describe` that\n * declares it is an authoring mistake and is refused at `mount()`: a token\n * is a claim about data that is about to move, and demanding one for a\n * highlight teaches an agent to fetch tokens it does not need.\n *\n * **ALL OR NONE, AND THIS IS THE RULE THE FIELD IS USELESS WITHOUT.** If one\n * `commit` that acts on the selection consumes a plan, every commit that acts\n * on the same selection must, or the gate is advisory. This is not a style\n * note. An eval asked the worked example for a job it cannot do — \"archive\n * everyone who has not replied in six months\" — and the agent improvised:\n * selected a company, then called the one bulk commit that asked for no\n * receipt, and 403 rows changed with no count read and nothing gated. The\n * verb an agent reaches for when it is off its intended path is the\n * least-declared one, which is exactly when the receipt matters most, so a\n * guarantee is only as strong as its weakest sibling. `mount()` warns when it\n * can see this shape; the warning cannot see every case, and the rule is the\n * thing to remember.\n *\n * What does NOT need one: a commit that names what it acts on. A verb that\n * takes an id, or that changes the one record whose screen is open, is acting\n * on something the person can see and count, and the count is 1. A plan is\n * the receipt for a count LARGER THAN THE SCREEN, which is the only case\n * where a number has to be carried between two calls to mean anything.\n */\n consumes?: \"plan\";\n args?: Record<string, ArgSpec>;\n /**\n * The refusals this verb can return, as short stable slugs.\n *\n * Documentation for the model, and the list a `refuse()` is checked against:\n * declaring it opts this verb into the check, and a refusal with a slug that\n * is not on the list warns once (see `RESERVED_REFUSALS` and `mount`).\n * Leaving it absent makes no claim and is not checked, the same way an absent\n * `kind` makes no safety claim.\n *\n * None of these may be a slug from `RESERVED_REFUSALS`. An app that refuses\n * with `timeout` has taken away an agent's only way to tell \"the app said no\"\n * from \"your call never landed\".\n */\n refuses?: string[];\n /**\n * Do the thing.\n *\n * Return nothing for the ordinary case. Return `ctx.refuse(...)` for an\n * expected \"no\". Return a `Report` when the verb has a number or a sentence\n * the snapshot cannot carry — above all a `describe` verb's `count`, which is\n * the number the person would have had to see before pressing a bulk button.\n *\n * Throwing is a bug, not a \"no\".\n */\n run: (\n args: A,\n ctx: VerbContext,\n ) => void | Refusal | Report | Promise<void | Refusal | Report>;\n}\n\n/**\n * What a verb has to say about what it just did, beyond the screen.\n *\n * This exists for `count`. A `describe` verb resolves a predicate inside the\n * app — \"every contact at Acme\" — and the only thing that makes the following\n * `commit` safe is the person or the agent seeing how many rows that matched\n * BEFORE anything irreversible runs. The screen cannot carry it: the whole\n * point is that the match is larger than the window, so `rows` shows twenty of\n * three thousand and `page.total` is about the table, not about the selection.\n *\n * Without this the pairing rule is advice. With it, it is a number.\n */\nexport interface Report {\n /** How many rows the verb matched or selected. `0` is a real answer and is\n * distinct from omitting the field, which means \"I do not count\". */\n count?: number;\n /** One short line for the agent that the snapshot has nowhere to put. */\n note?: string;\n}\n\n/**\n * WHY THERE IS NO `plan` FIELD HERE, since this is the first place anybody\n * looks for one.\n *\n * A plan token has to be checkable at the moment the `commit` runs, and the\n * only thing the core can read then is `visible()`. A verb returns its `Report`\n * once, at the end of the `describe`, and is never asked again — so an identity\n * handed back here could be bound into a token and never re-derived, which\n * makes the check \"is this the token I minted\" and not \"is this still the\n * selection I counted\". That is the difference between a receipt and a\n * guarantee, and a token that only proves its own provenance is the theatre\n * this whole mechanism exists to avoid.\n *\n * So the identity lives in `Snapshot.selectionId`, which the core reads after\n * the `describe` and again before the `commit`, and the app states it in one\n * place instead of two. Two places is the real cost of the alternative: an app\n * that computed the identity once for the report and once for the screen would\n * eventually compute them differently, and the token would be minted over one\n * and checked against the other.\n */\n\nexport interface VerbContext {\n /** Decline, with a reason the agent can act on. See `refuse`. */\n refuse: (reason: string, hint?: string) => Refusal;\n}\n\n/** The marker returned by `ctx.refuse`. Not an Error: a refusal is an ordinary\n * outcome the agent is expected to handle, and making it an exception pushes\n * app authors toward try/catch around their own business rules. */\nexport interface Refusal {\n readonly __driverkit: \"refusal\";\n reason: string;\n hint?: string;\n}\n\n/**\n * One control the screen is offering right now.\n *\n * The dynamic half of the controls layer, and the split is the whole reason\n * this type is so small. *That an app can press a control* is static and lives\n * in the manifest as a verb. *Which controls are on this screen at this\n * moment* is as per-screen as a row is, so it belongs here, in the half that is\n * never cached. Listing the control names in a verb's `ArgSpec.oneOf` is the\n * tempting mistake: it reads as helpful typing, and it moves a per-screen list\n * into the cached prefix — busting it for every user on every navigation.\n *\n * Every field but `name` is omitted when it would state the common case, which\n * is why `field` and `disabled` are `true` rather than `boolean`. A screen with\n * eight controls should cost a line, not a paragraph.\n *\n * A per-row control is listed ONCE, with `per: \"row\"`, and addressed by row id.\n * Twenty rows with six controls each is six entries here, not a hundred and\n * twenty: a snapshot that grew with the row count would undo the cost argument\n * the rest of this file is written to protect.\n *\n * Note what is absent. There is no selector, no path, no coordinates and no\n * handle this library derived by looking at the page. `name` is a word the\n * app's author typed next to their own button, which is the same claim `Verb`\n * makes and the reason neither one rots when the CSS does. `Verb.at` is the\n * one selector in the library and it is presentational — never used to find\n * anything — so it is deliberately not mirrored here.\n */\nexport interface ScreenControl {\n /** The name the author marked on the element. What a control verb takes,\n * matched exactly. */\n name: string;\n /** One short human label — the control's own text, usually. A model matches\n * the user's words against this; `name` is only the handle. */\n label?: string;\n /** What using it does to the world, as the author declared it.\n *\n * **Absent means the author did not say**, which is not `read` and must\n * never be rendered or treated as one. It is an unreviewed button, and the\n * only honest thing to do with it is to assume the strongest claim. See\n * `packages/adapters/CONTROLS.md`. */\n kind?: VerbKind;\n /** `\"row\"` when the control appears on each row in `rows` and is addressed by\n * row id. Omitted for a control that belongs to the screen itself. */\n per?: \"row\";\n /** Present only when the control takes text. */\n field?: true;\n /** Present only when the control is on screen and not actionable. Listed\n * rather than hidden: the person can see the greyed-out button, so an agent\n * shown nothing would conclude the feature does not exist instead of looking\n * for the precondition that enables it. */\n disabled?: true;\n}\n\n/** One row of whatever the screen is showing. `id` is what verbs take. */\nexport interface Row {\n id: string;\n [column: string]: Scalar | undefined;\n}\n\n/**\n * What a human could see right now.\n *\n * The rule this type exists to enforce: an agent is never shown more than the\n * person at the keyboard. Same filters, same sort, same page. That is what\n * keeps the cost flat as the data grows — a hundred rows on screen is a\n * hundred rows in the prompt whether the table holds a hundred or a million —\n * and it is also what makes \"park that one\" resolvable without a query.\n */\nexport interface Snapshot {\n /** Where the user is, in their words: \"contacts, filtered to Acme\". */\n where: string;\n /**\n * Which screen that is, as a stable kebab-case id: `contacts`, `company`.\n *\n * `where` is prose for a human and carries everything else the person can\n * see — the filter, the sort, and on a drill-down a sentence about the record\n * they opened — so it changes constantly for reasons that are not navigation,\n * and \"did I navigate?\" cannot be answered by diffing it. This can be\n * compared with `===`, and that is its whole job.\n *\n * Dynamic, which is why it is here and not in the manifest: the *names* of\n * an app's screens and which verb belongs to which are static and go in\n * `Verb.screen`; which one is live right now is as per-turn as a row is.\n *\n * Absent means the app does not describe its screens, NOT that it has one.\n * An app that leaves it out keeps every behaviour it had: the core cannot\n * check a `Verb.screen` or a `CallOptions.screen` against nothing, and makes\n * no claim rather than inventing one.\n */\n screen?: string;\n /**\n * Monotonic, bumped on every change. An agent echoes it back to prove it is\n * acting on what it saw; see `stale` in PROTOCOL.md.\n *\n * It means \"the snapshot changed\", which is a wider thing than \"the data\n * changed\": a read-only navigation genuinely changes the snapshot, because\n * the person is looking somewhere else. That is right for `stale` -- the\n * question there is \"is what you were looking at still what is on screen?\"\n * -- and it is why a plan token does NOT turn on this number alone. A plan\n * asks a narrower question, \"is the selection you counted still the\n * selection\", and navigation does not touch it. See `selectionId`, and\n * `plansGoodAt` in the registry for what one number answering two questions\n * cost.\n */\n rev: number;\n /** Only the rows actually on screen. */\n rows?: Row[];\n /**\n * Present when `rows` is a window onto something larger.\n *\n * Three states, and the third exists because without it the type forces a\n * lie. **Absence is a claim that the agent is seeing everything** — so an\n * adapter reading a rendered table, which cannot tell a virtualised grid\n * from a short list, had no honest option: omit `page` and assert\n * completeness it cannot know, or invent a total. Either way an agent\n * eventually concludes a record does not exist because it could not see it.\n *\n * page absent these are all the rows there are\n * page, total given a window, and you know how big the whole is\n * page, total absent a window, and you do NOT know how big the whole is\n *\n * The third is the weakest claim and the right default whenever you are\n * reading the DOM rather than a store. An agent that needs certainty from it\n * must widen the window or use a `describe` verb that counts server-side.\n */\n page?: { index: number; size: number; total?: number };\n /**\n * Row ids the user has selected, in selection order. Resolves \"this one\".\n *\n * **Only the ids on screen belong here**, exactly like `rows`, and for the\n * same reason. `select-where` exists to select thousands of rows in one call,\n * so a driver that honestly fills this with every selected id puts tens of\n * kilobytes of ids into the UNCACHED half of every result from then on — paid\n * for on every turn, and on a big table straight through the relay's 1 MiB\n * body limit. An author who fills it with ten thousand ids has silently\n * broken their own token budget, which is the whole cost argument this type\n * exists to protect.\n *\n * So this field answers \"which of the things in front of me is 'this one'\",\n * and `selectedCount` answers \"how big is the selection\". Both are needed:\n * an agent cannot resolve a pronoun from a number, and cannot decide whether\n * a commit is safe from a truncated list.\n */\n selected?: string[];\n /**\n * How many rows are selected in all, including the ones off screen.\n *\n * The honest size of the selection, which `selected` deliberately does not\n * carry. Omitting it means \"I do not count\" — distinct from `0`, which is a\n * real answer — and when it is larger than `selected.length` the renderer\n * says so in words, because a model handed three ids and a bulk commit will\n * otherwise believe three rows are about to change.\n *\n * It is not a substitute for a `describe` verb's `Report.count`. That one is\n * the number a commit decision turns on at the moment it is made; this one is\n * a property of the screen, and is what makes a selection made several turns\n * ago still legible.\n */\n selectedCount?: number;\n /**\n * An opaque fingerprint of the WHOLE current selection, off-screen rows\n * included. The one input the plan token is built from.\n *\n * WHAT IT HAS TO BE. Equal when the selection has not changed, different when\n * it has — including when one row has been swapped for another, which is the\n * case a count cannot see. Nothing else is required of it: the core never\n * parses it, never orders it and never shows it to a model, so an app may use\n * any string that has that one property. `selectionId([...ids])` from this\n * package is the one to use unless you have a reason; it is order-independent\n * and cheap, and the reason it is exported is that an app computing its own\n * is an app that can get it wrong.\n *\n * WHY NOT THE TWO FIELDS ABOVE, which look as though they would do. `selected`\n * is by design only the ids on screen, so it cannot identify the 3,412-row\n * selection that `select-where` exists to make — and filling it honestly with\n * all of them is the token-budget mistake its own comment is about.\n * `selectedCount` is a number, and a number cannot tell a selection from a\n * different selection of the same size. Each would have produced a token that\n * looked like a guarantee and was not.\n *\n * It is one short string whatever the selection's size, which is why it can\n * be in the uncached half at all. An app with a large selection should keep a\n * running value rather than re-hash a large set inside `visible()`, which\n * runs on every call.\n *\n * IT IS ALSO WHAT MAKES LOOKING FREE. A plan token is refused when `rev` has\n * moved, and `rev` moves on a read-only navigation — so an agent that went\n * back to check its premise before an irreversible commit was refused, while\n * one that committed blind was not. The core now carries a plan across a\n * `kind: \"read\"` verb that moved `rev` **when this string is unchanged\n * across the call**, because that is the app saying the selection is the same\n * selection. This field is the whole of that permission.\n *\n * Absent means the app does not identify its selection — NOT that nothing is\n * selected. A `commit` that declares `consumes: \"plan\"` in an app that omits\n * this still gets a token, and the token still binds the `rev` and the count,\n * which catches every change the app bumps its `rev` for. It cannot catch a\n * change the app made without bumping `rev`, and the core says so once at the\n * first such call rather than letting the weaker check pass for the stronger\n * one. It also carries nothing across a navigation: an app that publishes no\n * identity keeps exactly the expiry it has always had, which is the fail-safe\n * direction, and the reason the permission above is hung on a field an app\n * either publishes or does not rather than on a counter an author has to\n * remember to bump.\n */\n selectionId?: string;\n /**\n * The controls the screen is offering right now.\n *\n * The second layer: `rows` is what the person can read, this is what they\n * could press. It is here rather than in the manifest for the same reason\n * `rows` is — which buttons exist changes with every navigation, and a verb\n * list that changed with the screen would be a prompt prefix that is never\n * cached twice. See `ScreenControl` and `packages/adapters/CONTROLS.md`.\n *\n * Absent means this screen does not describe its controls, NOT that it has\n * none. An app driven entirely by hand-written verbs never fills this in and\n * is no less drivable for it.\n */\n controls?: ScreenControl[];\n /** Anything else the agent needs and the rows cannot carry. Keep it short;\n * this is the uncached half. */\n note?: string;\n}\n\n/**\n * What the agent gets back. Carries the snapshot AFTER the call, so acting and\n * observing are one round trip rather than two. With ten steps that is ten\n * saved model turns, each of which would have re-read the whole prefix — the\n * round trips, not the manifest, are what actually cost money.\n *\n * `count` is how a `describe` verb reports what it matched: \"1,000 selected of\n * 3,412 matching\". It is the number a human would have to see before pressing\n * a bulk button, and the reason `describe` and `commit` are separate verbs.\n *\n * A driver mounted in a page ALWAYS fills `snapshot`. That guarantee is worth\n * keeping in the type, so in-page callers never check for it. See `WireResult`\n * for the one case where it can be missing.\n */\nexport type Result =\n | {\n ok: true;\n note?: string;\n count?: number;\n /**\n * The plan token for the selection this call left behind, minted by the\n * core on a `describe` that reported a `count`. Present only there.\n *\n * It travels beside `count` because it means nothing without it: the\n * count is the number a person approves and this is what binds that\n * number to the set the next `commit` will touch. Pass it back as\n * `CallOptions.plan`. Opaque — a client stores it and forwards it, and\n * nothing outside the core that minted it reads anything out of it.\n */\n plan?: string;\n snapshot: Snapshot;\n }\n | { ok: false; refused: string; hint?: string; snapshot: Snapshot };\n\n/**\n * What an agent receives over the relay: a `Result`, or a refusal from the\n * relay itself about a call that never reached a tab.\n *\n * The distinction is not pedantry. A relay can refuse because the tab id is\n * unknown, because the tab closed, or because the tab accepted the call and\n * went silent past the deadline. In none of those cases is there a screen to\n * report, and the alternatives are both worse than a missing field: inventing\n * an empty snapshot tells an agent the app has no rows, and returning a\n * different shape makes every client parse two shapes and handle the rarer one\n * badly.\n *\n * So the shape holds and `snapshot` goes missing, which is the truthful thing\n * to say — nothing ran and nobody looked. A client must read its absence as\n * \"the call did not arrive\", never as \"the screen is empty\".\n */\nexport type WireResult =\n | Result\n | { ok: false; refused: RelayRefusal; hint?: string; snapshot?: undefined };\n\n/** Refusals that come from the relay rather than from an app's verb. Listed as\n * a closed set so a client can tell \"your app said no\" (retry differently)\n * from \"your call never landed\" (reconnect, or pick another tab). */\nexport type RelayRefusal = \"no-such-tab\" | \"tab-went-away\" | \"timeout\";\n\n/**\n * One screen the app has, declared once in the cached half.\n *\n * THE GAP THIS CLOSES. `Snapshot.screen` says which screen is live and\n * `Verb.screen` says which screen a verb lives on, and between them an agent\n * could learn where it is and be refused where it is not — but it could not\n * learn that a screen EXISTS before standing on it. The library's own worked\n * example papered over that by pasting a prose screen-map into\n * `instructions` (\"this is a CRM with six screens: a dashboard, a contacts\n * list, …\"), which is a map written twice: once in the route table the app\n * already has, and once in English for the model, where nothing checks that\n * the two agree. So this is the map, as data, in the half that is cached.\n *\n * It is static for the same reason `Verb.screen` is, and the argument is the\n * one the whole library rests on: **the names of an app's screens are the same\n * for every user forever.** A CRM has a contacts list whether or not you have\n * any contacts, and whether or not you are allowed to see them. Only *which\n * screen is live* is per-user and per-minute, and that is `Snapshot.screen`.\n *\n * **THE CONSTRAINT THAT MATTERS, and the one an author will be tempted to\n * break: publish every screen the app has, not the screens THIS user can\n * reach.** A list filtered by role, by plan, by feature flag or by permission\n * is a per-user list, and a per-user list in the cached half busts the prompt\n * prefix for everybody — exactly as a per-screen tool list would, which is the\n * mistake `Verb.screen` exists to prevent one level down. Two users of the\n * same app must receive the same bytes here. If a screen is one this person\n * may not open, that is a REFUSAL from the navigate hook at the moment they\n * try, with a reason an agent can relay (\"admin only\"), and not an absence\n * from everybody's map: an absence is unfalsifiable, so an agent meeting it\n * concludes the feature does not exist and stops asking — the same failure\n * `ScreenControl.disabled` is listed rather than hidden to avoid.\n */\nexport interface ScreenSpec {\n /**\n * Stable, kebab-case, unique within a mount. **The same string\n * `Verb.screen` and `Snapshot.screen` compare**, which is the whole reason\n * this type has an id rather than only a name: three fields that spell the\n * screen three ways are three fields that disagree after the first rename.\n */\n id: string;\n /** One line for the model, in the user's vocabulary: \"the contacts list:\n * every contact, searchable, twenty rows at a time\". Write it for a reader\n * who cannot see your app and has never been to this screen — which is\n * precisely the reader this field exists for. At most\n * `SIZE_LIMITS.describe` characters; see that constant for why there is a\n * bound at all. */\n describe: string;\n /**\n * An **RFC 6570** URI template for the screen, if it has an address:\n * `\"#/contacts\"`, `\"#/companies/{slug}\"`.\n *\n * RFC 6570 rather than a placeholder syntax of our own, because a route\n * table with holes in it is a solved problem with a registered media type\n * and a dozen implementations, and the alternative is a third dialect of\n * `:id` versus `{id}` versus `<id>` for every author to get wrong. Only\n * simple string expansion — `{var}` — is used by the core, which is the\n * level a route has; the syntax is the spec's so a template can be handed to\n * `uri-templates` or any other RFC 6570 library unchanged, and the core's\n * own expansion is tested against one.\n *\n * OPTIONAL, and absent is not a defect. A modal, a wizard step, a tab inside\n * a screen and the whole of a single-page app with no router are all screens\n * with no address, and a type that demanded one would push those authors\n * into inventing fake URLs. `goto` reaches an address-less screen exactly as\n * it reaches any other: the ID is the handle an agent uses, and the url is\n * what the app can use to get there, plus the one thing a person can paste\n * into a browser.\n */\n url?: string;\n /**\n * What the url template takes, by the template's own variable names.\n *\n * Typed, so the core can check `goto(\"company\", { slug: 7 })` before any\n * navigation happens and refuse it as `bad-argument` the way every other\n * mistyped argument is refused — rather than expanding `7` into a URL and\n * landing the person on a screen with no record on it. `ArgSpec` rather than\n * a list of names for the reason verbs take `ArgSpec`: `oneOf` is cheaper\n * and safer than prose, and the refusal lists the accepted set.\n *\n * A screen whose template has a variable with no entry here still expands —\n * the value is taken as optional and an absent one expands to nothing, which\n * is RFC 6570's own rule — but it is undeclared, so nothing checks it and\n * the model is told nothing about it. Declare them.\n */\n args?: Record<string, ArgSpec>;\n}\n\n/**\n * Where a `goto` is trying to get to, handed to `MountOptions.navigate`.\n *\n * WHY THERE IS A HOOK AT ALL. The core cannot navigate. It has no router, no\n * `history`, no `location` and no DOM — it is the package that promises to\n * import nothing — and a core that pushed a URL would be guessing between\n * `pushState`, a hash, a framework's own router and a native app with no URLs\n * at all. It would also be the one place in driverkit that reached around the\n * app instead of through it, which is the same back door `Verb.at` is\n * deliberately not allowed to be. So the app supplies the one function it\n * alone can write, and the core supplies everything that is the same in every\n * app: the declared list, the uniqueness check, the argument types, the\n * expansion, the refusal when the screen is not one the app has, and the tool\n * description the model reads.\n */\nexport interface NavigateTarget {\n /** The `ScreenSpec.id` that was asked for. Already checked against the\n * declared list, so a hook never sees a screen the app did not declare. */\n screen: string;\n /** The arguments, already checked against the screen's `args`. A hook may\n * read them directly rather than re-parsing the url. */\n args: Record<string, Scalar>;\n /** The screen's `url` with `args` expanded, or absent when the screen\n * declared no template. A hook that has a router usually ignores this and\n * routes on `screen`; a hook on an app whose only addressing is the address\n * bar assigns it to `location.hash` and is done. */\n url?: string;\n}\n\n/**\n * How the app navigates, for the core's reserved `goto` verb.\n *\n * Returns nothing for the ordinary case, `ctx.refuse(...)` for a screen this\n * person may not open or a record that does not exist, or a `Report` with a\n * `note`. It is the same contract as `Verb.run` on purpose: `goto` is an\n * ordinary verb whose body happens to be supplied through a different field,\n * and an author who already knows how to write a verb has nothing new to\n * learn.\n *\n * **A refusal here is how a per-user restriction is expressed**, and it is the\n * other half of `ScreenSpec`'s rule against filtering the declared list. \"You\n * may not open the billing screen\" is a fact about this person at this moment,\n * so it belongs in the dynamic half — said at the moment of the call, with a\n * reason — and never as a screen quietly missing from everybody's map.\n */\nexport type NavigateHook = (\n target: NavigateTarget,\n ctx: VerbContext,\n) => void | Refusal | Report | Promise<void | Refusal | Report>;\n\n/**\n * What the agent wants to know, handed to `MountOptions.ask`.\n *\n * One field today and a shape rather than a bare string all the same, because\n * the hook is implemented by a UI and a UI that took a positional argument\n * would have to be rewritten to be told anything else — `screen`, the verb that\n * prompted it, a suggested set of answers. A `{ question }` is the version of\n * this that can grow without every implementation changing.\n */\nexport interface AskQuestion {\n /**\n * What the agent is asking, in its own words, as it typed it.\n *\n * Never built by the core and never rewritten by it: a question the library\n * paraphrased is a question the person answers and the model did not ask.\n * Bounded at `SIZE_LIMITS.describe` and refused as `bad-argument` above\n * that — an agent that needs a paragraph to state its question has not\n * worked out what it does not know, and a wall of text in front of somebody\n * is a question they will dismiss.\n */\n question: string;\n}\n\n/**\n * What a person said, or the news that nobody did.\n *\n * THREE ANSWERS, AND THE SPLIT IS THE WHOLE DISCIPLINE OF THIS TYPE. The\n * library already keeps `approval-timeout` apart from `declined-by-user`\n * because \"nobody answered\" and \"the person said no\" are different facts an\n * auditor must never confuse. A question has the same hazard one layer over,\n * with a different pair:\n *\n * a string the person's words. They reach the model as the\n * RESULT of the ask, not as a side channel — see\n * `AskHook` — so a model reads an answer where it reads\n * every other outcome.\n * `{ answered: false }` a question was put in front of somebody and no answer\n * came back: they closed the panel, walked away, or the\n * deadline lapsed. The agent is told plainly that the\n * question was seen by nobody who replied, and that\n * nothing in the app changed.\n * `{ nobody: true }` there is no person on this path at all. A cron run, a\n * test harness, a tab with no panel. The question was\n * never put.\n *\n * `{ answered: false }` AND `{ nobody: true }` ARE NOT ONE ANSWER, and the\n * repairs are why. Unanswered says the channel works and this particular\n * question went unanswered, so asking once more later, or more briefly, is a\n * move that can succeed. Nobody-to-ask says the channel does not exist on this\n * run, so every further question is wasted and the only honest ending is to\n * decide from what is already known or to stop and say what is missing. An\n * agent handed one word for both will keep asking into an empty room.\n *\n * There is deliberately NO \"the person refused to answer\". Somebody who says \"I\n * would rather not say\" has answered; their words are the result, and the model\n * is better at reading that sentence than the core is at classifying it.\n *\n * A HOOK THAT THROWS IS `{ answered: false }`, never `{ nobody: true }`. The\n * precedent is `ApprovalHook`, where a failed ask is a no — here a failed ask is\n * an unanswered question, because a broken question UI is not evidence that\n * nobody is sitting there, and claiming it is would tell an agent to stop asking\n * for the rest of a run over one exception.\n *\n * An answer that is none of these three is treated as `{ answered: false }` and\n * said out loud once. The same rule as `Approval`'s unknown shape being a\n * denial: the core must not read a shape it does not recognise as somebody\n * having spoken.\n */\nexport type AskAnswer = string | { answered: false } | { nobody: true };\n\n/**\n * How the app puts a question to the person. The body of the reserved `ask`\n * verb.\n *\n * WHY THERE IS A HOOK AT ALL, which is the same answer `NavigateHook` gives:\n * the core cannot ask. It has no DOM, no panel, no notification channel and no\n * idea whether anybody is looking. What it CAN own — and does — is everything\n * that is the same in every app: the verb's name, its one argument, its\n * description, the lock that stops the agent acting while a question is open,\n * the deadline that keeps \"nobody answered\" a FACT rather than a transport\n * mystery, the allowance that stops an agent asking instead of thinking, and\n * the audit row.\n *\n * **DECLARED AT `mount()` AND NOWHERE ELSE, AND THIS IS NOT A CONVENIENCE.**\n * The approval gate has `DriverApproval.adopt`, so a panel mounted after the\n * driver can install one. A question cannot work that way, and the constraint\n * is the one the whole library is priced on: `system` and `tools` are\n * byte-identical on every turn so the prompt prefix stays cached, and a verb\n * that appeared when a panel mounted would be a tool list that changed\n * underneath a running conversation. So an app that may ever want to ask\n * declares this at mount; an app that declares nothing gets no `ask` verb, the\n * manifest it had before this field existed, and the same fingerprint.\n *\n * **THE ANSWER IS THE TOOL'S RESULT AND NOTHING ELSE KEEPS IT.** The person's\n * words come back as the `note` of the ask's own `Result` — `ok — they said:\n * \"…\"` — and the core stores not one byte of them. That is the structural half\n * of \"a question is not consent\": there is no field a later `commit` could\n * consult, no remembered yes, and `ApprovalRequest` has no way to reach an\n * answer, so the approval gate is asked exactly as it would have been if the\n * question had never happened. See `MountOptions.ask`.\n */\nexport type AskHook = (question: AskQuestion) => AskAnswer | Promise<AskAnswer>;\n\n/**\n * One step of a `FlowSpec`: a verb, and a line about using it here.\n *\n * The shape is webmachinelearning/webmcp#340's `steps[].{section, tool, hint}`,\n * with `tool` spelled `verb` because that is what this library calls the\n * thing — and because a `tool` field whose value must be a verb name is a\n * field somebody will eventually fill with an MCP tool name instead.\n */\nexport interface FlowStep {\n /** The verb to call. Checked at `mount()` against the verbs that exist; see\n * `Manifest.flows`. */\n verb: string;\n /** What to do with it HERE, in this flow: \"sort by pending so the companies\n * with work at the top\", \"read the count it reports before going on\". The\n * verb's own `describe` already says what the verb does; this says why this\n * step exists and what to watch for, which is what a recipe is. */\n hint: string;\n /** An optional grouping label for a flow with phases — \"find the company\",\n * \"check the numbers\". From #340's shape. Several consecutive steps may\n * share one. */\n section?: string;\n /**\n * When this step may be skipped, in one line: \"the person already named the\n * company\". Present means the step is NOT load-bearing; absent means take it.\n *\n * THE GAP THIS CLOSES. A flow was a flat list in which every step read as\n * required, so a recipe with an optional first step had nowhere to say so and\n * the condition went into the `hint` — the worked example's own step one said\n * \"If the person named the company, you can skip straight to `open-company`\"\n * in the middle of a sentence about what `goto` is for. A reader cannot tell\n * from the structure which steps carry the job and which are there for the\n * case where you do not already know the answer, and neither can a model\n * skimming five of them.\n *\n * **IT IS A SENTENCE AND NOT AN EXPRESSION, AND THAT IS THE DESIGN.** The\n * obvious thing to put here is a machine-readable predicate — Arazzo has\n * `successCriteria`, VS Code has `when` clauses, and a `{ fact: \"count\", gt:\n * 500 }` would look like the same move. It is not, because **nothing in this\n * library evaluates a flow.** A flow is read and followed by the model (see\n * `FlowSpec`), so the only evaluator a predicate could ever have is the\n * reader it is written for, and a predicate read by a model is a sentence\n * with brackets round it: all of the precision is in the notation and none of\n * it is in the enforcement. That is worse than prose rather than better,\n * because a condition that LOOKS checkable gets trusted like one. A string\n * admits in its own type that this is a judgement call.\n *\n * WHERE THE CONDITIONS THAT MUST BE ENFORCED ACTUALLY LIVE, because \"if the\n * count is over 500, ask first\" is the example everybody reaches for and it\n * is already expressible in the one place where the core and not the model\n * holds the gate:\n *\n * approve: (req) => (req.snapshot.selectedCount ?? 0) > 500\n * ? askTheHuman(req)\n * : true\n *\n * `ApprovalHook` runs at the moment of the commit, on the snapshot the core\n * read itself, and a model cannot route around it. `Verb.consumes` is the\n * same shape of answer for \"do not commit a count you have not read\". A\n * threshold written HERE instead would be a second, weaker copy of a gate the\n * library already enforces, and the copy is the one the model can misread.\n * So: conditions that decide whether DATA MOVES go in `approve`; conditions\n * that decide WHICH STEPS YOU TAKE go here, in words.\n *\n * One line, at most `SIZE_LIMITS.describe` characters, no newline, and it\n * counts against the flow's `SIZE_LIMITS.body` budget like a `hint` does —\n * it is rendered into the same cached prefix. An empty string is refused at\n * `mount()`: a step that is skippable for no stated reason is a step the\n * author has not decided about, and \"optional\" with no condition tells a\n * model it may drop a step whenever it likes.\n *\n * In `fingerprint()` with the rest of the flow, for the reason the steps are:\n * a step that has become optional is a different recipe, and an agent holding\n * the old cached copy is working from the version where it was required.\n */\n skipWhen?: string;\n}\n\n/**\n * WHY THERE IS NO ITERATION CONSTRUCT, since \"do this for every company\" is\n * the second thing anybody tries to write down here.\n *\n * It was considered and refused, and not on grounds of effort: a `forEach` over\n * a step list is small. It is refused because it is **against the grain of the\n * one safety mechanism this library actually enforces.** \"For every company,\n * accept its pending contacts\" is N commits. The whole `describe` → read the\n * `count` → `commit` apparatus, and the plan token that binds the second to the\n * first, exists to make ONE commit over many rows safe *instead of* many\n * commits over few — one count a person can check, one approval that names a\n * real number, one receipt. A declared loop would be the library's own manifest\n * teaching an agent to do the thing the plan token was built to stop: N\n * approvals that each look small, with nobody ever shown the total.\n *\n * And it is unnecessary in the case it is wanted for, because `Verb` already\n * answers it one level down: a verb that operates on many rows **takes a\n * predicate and resolves it inside the app**, where the rows already are. The\n * app that needs \"every pending contact everywhere\" declares\n * `select-where(status: \"pending\")` and gets one count and one commit; the\n * worked example has exactly that verb beside its per-company one. If an app\n * cannot express the job as a predicate, the loop is a judgement call about\n * data the agent has to look at between iterations — which is the argument in\n * `FlowSpec` for why nothing executes a flow, applied to the one construct that\n * would need to.\n *\n * So the honest form of \"do this for every company\" is a flow whose `describe`\n * says the job is per-company and whose steps are the one company's, plus the\n * agent repeating it and being gated each time. That repetition is not a gap\n * the notation should close. It is N approvals because it is N commits.\n *\n * WHY THERE IS NO `from: \"step2.slug\"` EITHER — no reference from one step to\n * an earlier step's output. It would require a named output to refer to:\n * `Verb.returns` or similar, since a verb's body returns `void | Refusal |\n * Report` and the only named things in a `Report` are a `count` and a `note`.\n * A half-wired reference — a `from` the model has to guess the meaning of\n * because no verb declares what it hands back — is the worst of the available\n * outcomes, so the choice was properly or not at all, and it is not at all:\n *\n * - Carrying a value between steps means the AGENT holds it, and `Verb` is\n * written against exactly that: \"the agent should never learn an id it did\n * not need\". The steps of the worked example's own flow pass nothing —\n * `open-company` moves the screen, `select-pending-here` needs no slug\n * because it means *this* company, `accept-selected` needs no ids because\n * it means *this* selection. The app holds the state between steps. That is\n * not a missing feature of the flow notation; it is where this library\n * decided state lives, and a `from` field would be the first thing to\n * argue the other way.\n *\n * - The ONE value that genuinely has to cross two steps is the plan token,\n * and it is already declared — per verb, in the cached half, as\n * `Verb.consumes` — and already *enforced* by the core rather than\n * interpreted by the reader. A second declaration of it on the step would\n * be a weaker copy of a check that works.\n *\n * What a flow now does about that one dependency is the little that can be done\n * honestly: `mount()` refuses a flow whose plan-consuming step has no earlier\n * `describe` step to mint the token (a recipe that cannot be followed, found at\n * startup instead of at the commit), and the renderer prints which step the\n * token comes from. Both are derived from what the verbs already declare. No\n * new field, nothing for an author to keep in step, and nothing claimed that\n * the core does not check.\n */\n\n/**\n * A declared, static, READABLE recipe: the level above a single verb.\n *\n * WHY THIS EXISTS, in one sentence: an app's verbs say what can be done and\n * nothing says what is usually done with them, so every agent re-derives the\n * same five-step job from scratch, and the four of five that get it slightly\n * wrong get it wrong in a way nobody sees until the commit. Five independent\n * efforts arrived at the same level — webmcp#255 (`registerCollection`),\n * webmcp#161 (`registerSkill`), webmcp#340, OpenAPI Arazzo's `workflows[]`,\n * and Apple's app skills — which is the usual sign that the gap is in the\n * problem and not in one design.\n *\n * **THE AGENT READS THIS AND FOLLOWS IT. IT DOES NOT CALL IT.** That is the\n * whole design and it is a deliberate refusal to ship a workflow engine. A\n * flow that executed internally would run step 3 on an app whose state had\n * moved — the client already exists, the selection is empty, the record was\n * accepted by somebody else a second ago — and the only answers available to\n * it are to carry on or to stop, both blind, with the agent that could have\n * adapted holding nothing but an `ok`. Adapting mid-job is the one thing a\n * model is better at than a state machine, and handing the recipe to the model\n * keeps the adapting where the judgement is. Apple's app skills make the same\n * admission out loud — *\"Skills don't enforce deterministic behavior, and Siri\n * doesn't run the listed intents in sequence\"* — and it reads as a caveat only\n * if you expected an engine.\n *\n * **The `describe` carries the weight.** Microsoft's finding on plugin\n * selection across groups is that the choice *\"is based on the plugin's\n * description, not on any of the individual functions\"*: a model picking\n * between several flows reads these sentences and not the steps. So `describe`\n * is the field to spend the effort on, which is also why it has a documented\n * size budget — see `SIZE_LIMITS`.\n *\n * Static, so it rides in the manifest that was already being cached and costs\n * nothing per turn. That is the cheapest possible version of this feature:\n * nothing is sent per turn, nothing is computed per call, and an app that\n * declares no flows produces the manifest it produced before the field\n * existed, byte for byte.\n */\nexport interface FlowSpec {\n /** Stable, kebab-case, unique within a mount. An agent's handle on the flow\n * when a person says \"do the usual thing\", and the string a transcript\n * names. */\n id: string;\n /**\n * What this flow is for, in one line, in the user's own words: \"accept a\n * company's pending contacts\".\n *\n * The field a model chooses on. At most `SIZE_LIMITS.describe` characters\n * and **no newline**: it is a one-line label, and a paragraph here is a\n * paragraph that is read instead of the steps.\n */\n describe: string;\n /**\n * The steps, in order. At least one.\n *\n * Every `step.verb` must name a verb that exists, and `mount()` throws if\n * one does not — the way it throws on a duplicate verb name. A recipe citing\n * a verb nobody implemented is a dead end whose only symptom is an agent\n * halfway through a job getting `unknown-verb`, after the navigation and\n * before the commit, which is the worst place to find out.\n *\n * The same argument gets a second check: a step whose verb declares\n * `consumes: \"plan\"` must have an earlier step whose verb is a `describe`,\n * because the token can only come from one of those. A flow that commits\n * without counting first is a recipe whose only possible ending is\n * `stale-plan` — the same dead end, found at the same worst moment — and the\n * core can see it statically, from what the verbs already declare, so it says\n * so at `mount()` instead. Nothing new is written down for this: it is the\n * one piece of data flow between steps that exists, and it is declared on the\n * verb. See the note under `FlowStep` for why there is no other.\n */\n steps: FlowStep[];\n}\n\n/** The static half: hand this to a model once and cache it. Contains no data,\n * no ids, no user, nothing that varies between two people or two minutes. */\nexport interface Manifest {\n /** Changes when the verb list changes, so an agent can tell its cached copy\n * went stale without diffing. */\n version: string;\n app: string;\n /**\n * The app's own briefing, in its own words: \"this app has screens —\n * dashboard, contacts, companies, settings — and `go` reaches those\".\n *\n * It is here because it is static by definition and belongs in the half that\n * gets cached once. Before it there was nowhere: a widget could pass\n * `instructions` to `drive()`, an agent arriving through the relay or MCP\n * never saw those, and an app that needed to say something about itself to\n * BOTH paths had to put it in `Snapshot.note` — in the uncached half, paid\n * for on every single turn, for a sentence that never changes. That was the\n * one thing in the library the in-page path and the outside path disagreed\n * about.\n *\n * Static means static. No ids, no counts, no user, nothing that differs\n * between two people or two minutes; one per-screen word in here makes the\n * prefix uncacheable across users, which is where most of the saving lives.\n * It is in `fingerprint()` for that reason — it is part of what a cached\n * copy claims.\n */\n instructions?: string;\n verbs: Array<{\n name: string;\n describe: string;\n kind?: VerbKind;\n /** A CSS selector for the element this verb affects, if the app named one.\n * A hint for a UI that wants to outline what is about to be touched, and\n * nothing else: driverkit never resolves it and never sends it to a\n * model. See `Verb.at`, which this is copied from. */\n at?: string;\n /** The screen, or screens, this verb belongs to; absent for \"anywhere\".\n * Copied from `Verb.screen`, which carries the reasoning — above all why\n * the tool list must NOT vary with the screen.\n *\n * Copied in the SHAPE the app declared it, a string staying a string, so\n * that a client written before verbs could name two screens goes on\n * reading every single-screen app exactly as it did. A reader that wants\n * one rule for both should normalise with an `Array.isArray` of its own\n * rather than hope. */\n screen?: string | string[];\n /** `true` on a `commit` the app can undo. Copied from `Verb.reversible`;\n * absent makes no claim. */\n reversible?: true;\n /** `\"plan\"` on a `commit` that may only be called with the token from the\n * `describe` that counted what it is about to touch. Copied from\n * `Verb.consumes`; absent means it may be called bare, which is what every\n * commit written before this field does.\n *\n * In the cached half because it has to be: a client renders a tool schema\n * and a description from this once and caches both, and \"you must run the\n * `describe` first and pass what it gave you\" is a fact an agent should\n * read there rather than discover by being refused. The same argument as\n * `refuses` and `screen`. */\n consumes?: \"plan\";\n args?: Record<string, ArgSpec>;\n refuses?: string[];\n }>;\n /**\n * The app's map: every screen it has, declared once.\n *\n * Copied from `MountOptions.screens` and in `fingerprint()`, because it is\n * part of what a cached copy claims about the app — a screen that gained a\n * url template, or whose `describe` was rewritten, is a screen a model was\n * briefed about in the app's old words.\n *\n * Absent means the app does not describe its screens, NOT that it has one.\n * Exactly `Snapshot.screen`'s rule, and for the same reason: an app mounted\n * before this field existed must read identically.\n *\n * See `ScreenSpec`, and above all its rule against publishing only the\n * screens the current user can reach.\n */\n screens?: ScreenSpec[];\n /**\n * The app's recipes: the multi-step jobs its verbs are usually combined\n * into. Read and followed by the agent, never called. See `FlowSpec`.\n *\n * In `fingerprint()` for the reason `kind` and `screen` are: a flow is\n * rendered straight into the cached system prompt, so an agent holding the\n * old manifest is working from the app's old recipe — one that may name a\n * verb this version has renamed.\n */\n flows?: FlowSpec[];\n}\n\n/**\n * Where a tab stands in the person's attention, as the page itself reports it.\n *\n * Three states and not a boolean, because the honest answer has three cases\n * and a boolean would have to lie about one of them:\n *\n * `\"focused\"` the active tab of the frontmost window. The person is looking\n * at THIS. `document.visibilityState === \"visible\"` AND\n * `document.hasFocus()`.\n * `\"visible\"` the active tab of its window, but the window is not frontmost\n * — the person is in another application. Visible, not looked\n * at. This is the state a two-state field would have had to\n * call either \"focused\" (and send an agent to a window nobody\n * is in front of) or \"hidden\" (and lose the only honest answer\n * to \"which one was I last in?\").\n * `\"hidden\"` a background tab, or a minimised window.\n *\n * It is reported by the page and never inferred by a relay: the only process\n * that can see `document.hasFocus()` is the document. A relay carries the\n * string and has no opinion about it, exactly as it carries `rev`.\n *\n * ABSENT IS UNKNOWN, NOT HIDDEN. A tab driven by a hand-written `fetch` loop,\n * or a page that passed `focus: false` to `connect()`, reports nothing — and a\n * client that read absence as \"not the one\" would quietly stop being able to\n * drive it at all.\n */\nexport type TabFocus = \"focused\" | \"visible\" | \"hidden\";\n\n/**\n * One row of `GET /dk/tabs`.\n *\n * Declared here rather than left in the protocol document because this is the\n * listing every client hits first, and it carries a subtlety prose loses: the\n * id field is `tab`, not `id`, spelled the same as in the `hello` frame. A\n * client that re-derived this shape from the markdown is exactly how the first\n * version of it ended up mutually incompatible between two implementations.\n *\n * `manifestVersion` is lifted out of the manifest so a client can tell whether\n * its cached copy is current without fetching the whole thing — which is the\n * only reason the version exists.\n */\nexport interface TabInfo {\n tab: string;\n app?: string;\n /** Only so a human can tell two tabs apart when asked \"which one?\". */\n title?: string;\n url?: string;\n manifestVersion?: string;\n rev?: number;\n /**\n * Where the person's attention is, as the page itself last reported it.\n *\n * The field that answers \"the one I am looking at\" — which is what a person\n * means when they say which tab, and the one thing `--tab <id>` could never\n * express. See `TabFocus` for the three states, and PROTOCOL.md for the rule\n * a client applies when more than one tab is a candidate.\n */\n focus?: TabFocus;\n /** ISO 8601. A string on purpose: nothing computes with it, and parsing it\n * would invent a failure mode for a field only ever shown to a person. */\n since?: string;\n}\n\n/**\n * What an approval is being asked about.\n *\n * Structurally identical to `driverkit/agent`'s `CommitRequest`, on purpose\n * and not by coincidence: the widget's dialog was written against that shape\n * and is now an implementation of THIS hook, so the two types have to be the\n * same four fields or the one working confirmation UI in the repository would\n * need a shim to be reusable. A function that satisfies one satisfies the\n * other.\n *\n * `verb` is the manifest entry rather than the `Verb`, so an approval UI reads\n * `kind`, `reversible` and `refuses` — the declared facts a person's question\n * should be worded from — and cannot reach `run`. A gate that could call the\n * body it is gating is a gate with a way round itself.\n */\nexport interface ApprovalRequest {\n name: string;\n args: Record<string, Scalar>;\n verb: Manifest[\"verbs\"][number];\n /** The screen as it is right now, so a question can name the selection the\n * commit is about to act on. Read before the verb runs. */\n snapshot: Snapshot;\n}\n\n/**\n * What an approval hook answers.\n *\n * Three outcomes, because there are three things that can happen when you ask\n * a person: they say yes, they say no, or they are not there.\n *\n * `true` / nothing allow. Nothing is a yes so a hook may fall through\n * its own cases without accidentally denying.\n * `false` deny, with the core's own wording.\n * a string deny, and the string becomes the hint the agent is\n * told. This is the useful one: \"not until finance\n * signs off\" is something a model can act on and\n * \"declined\" is not.\n * `{ timedOut: true }` nobody answered. Distinct from `false`, which is a\n * person deciding; see `approval-timeout` in\n * `RESERVED_REFUSALS`.\n * `{ asked: false }` allow, and say that nobody was asked. See below.\n *\n * Anything else — an object that is none of these — is treated as a DENIAL and\n * never as consent. A hook that returns a shape the core does not recognise\n * has not approved anything, and reading an unknown answer as yes is how a\n * refactor that changes a return type silently removes the gate.\n *\n * WHY THERE IS A FOURTH ANSWER, AND IT IS THE RECORD'S FAULT. A real gate does\n * not ask about every commit: the widget's dialog lets a `reversible` commit\n * under its size threshold through without a question, and lets every commit\n * through when the person has switched confirmations off. Such a hook used to\n * have to answer `true`, which is right about the call and a lie in the\n * record — the core writes `approval: \"allowed\"`, and that claims somebody\n * said yes. `{ asked: false }` allows the call and records `not-asked`, which\n * is what actually happened. A gate that asks every time never needs it, and\n * `true` still means \"asked, and the answer was yes\" for every hook written\n * before this existed.\n */\nexport type Approval =\n | boolean\n | string\n | void\n | { timedOut: true; hint?: string }\n | { asked: false };\n\n/** The hook itself. Async because a human is on the other end of it; a\n * synchronous gate can only ever consult a policy, never a person. */\nexport type ApprovalHook = (req: ApprovalRequest) => Approval | Promise<Approval>;\n\n/**\n * What `MountOptions.approve` accepts: a hook, or the word `\"unattended\"`.\n *\n * `\"unattended\"` is not a hook that returns true. It is the app SAYING OUT\n * LOUD that commits on this driver run with no person in front of them —\n * which is a legitimate configuration (a cron job, a test harness, a backend\n * that has already done its own authorisation) and is also the dangerous one,\n * so it is written down rather than reached by leaving a field out. See\n * `MountOptions.approve` for the argument, and `connect()` for the one place\n * the absence of either becomes an error.\n */\nexport type ApprovalPolicy = ApprovalHook | \"unattended\";\n\n/**\n * The approval state a mounted driver publishes.\n *\n * Three things live here and they are for three different readers. `declared`\n * is for whoever is about to publish this driver to the outside — `connect()`\n * reads it and refuses to publish a driver whose irreversible commits nobody\n * has said who approves. `policy` is for a reader of the RECORD: who is\n * actually asked right now, which is not always what the app declared. `hold`\n * is for an approval UI that is not an approver at all: a host's own modal that\n * gates outside `call()` and needs the core to stop taking calls while its\n * question is open.\n */\nexport interface DriverApproval {\n /**\n * Who is asked about a commit on this driver RIGHT NOW.\n *\n * Four values, and the fourth is the one worth reading about. Three of them\n * are what the app wrote at `mount()` and are also `declared`: `none`,\n * `hook`, `unattended`. The fourth, `adopted`, means an approver was\n * installed after `mount()` by something in the page — see `adopt` — and it\n * is a weaker claim than `hook` on purpose:\n *\n * `hook` is a line in the app's own source. It is there before the first\n * call and it is there for every path, so `connect()` accepts it as the\n * declaration it requires.\n *\n * `adopted` is a gate that exists only while whatever installed it is\n * still mounted. A panel that is unmounted takes its dialog with it and\n * this goes back to `declared`. That is a real gate while it lasts, and\n * it is not a statement the app made, so it does not satisfy `connect()`.\n *\n * Folding the two into one word was the alternative and it is the one thing\n * this field must not do: an auditor reading `hook` on every record would\n * have no way to tell the app's own gate from one that happened to be on the\n * page that afternoon, and a field that cannot be wrong is a field that\n * cannot be checked.\n *\n * It is a live read, not a constant: the same driver answers `none` before\n * a panel mounts and `adopted` after, because that is the truth about which\n * commits had a person in front of them.\n */\n readonly policy: \"none\" | \"hook\" | \"unattended\" | \"adopted\";\n /**\n * Which of the three the app itself declared at `mount()`, for all time.\n *\n * Never moves, and that is what it is for. `policy` answers \"is there a gate\n * on this driver now\"; this answers \"did the app say who approves\", which is\n * the question `connect()` asks before publishing a driver to an outside\n * agent. The two were one field until the widget could install a gate of its\n * own, and merging them would have made mounting a panel quietly satisfy the\n * check that exists to make somebody write a sentence.\n *\n * Optional, so a hand-written `approval` from before this existed still\n * satisfies the interface; a reader falls back to `policy`, which is what it\n * meant then. See `Driver.approval`.\n */\n readonly declared?: \"none\" | \"hook\" | \"unattended\";\n /**\n * Install an approver now, for a dialog that lives in the page.\n *\n * WHAT IT IS FOR. The widget's confirmation is the one working approval UI\n * in this repository and it used to gate OUTSIDE `call()` — `hold` the lock,\n * ask the person, then call the verb. The core never saw the question, so an\n * app that mounted the panel and wired `onAudit` and nothing else recorded\n * `approval: \"not-asked\", policy: \"none\"` for a commit a person had just\n * clicked Approve on. That record reads as complete and says the opposite of\n * what happened, which is the one thing an audit trail cannot do.\n *\n * WHO WINS. The app does, always. This returns `null` and installs nothing\n * when the app declared `approve` of either kind:\n *\n * a declared `hook` is already asked on every path, so there is nothing to\n * fix and nothing to argue about — and replacing it would mean a commit\n * got two dialogs, or the app's own gate silently stopped running.\n *\n * `unattended` is the app saying out loud that commits here run with\n * nobody in front of them. An approver installed over the top of that\n * would make an unattended driver interactive, which is the configuration\n * somebody deliberately chose against.\n *\n * It also returns `null` when another adopter already holds it. First one\n * wins, because two gates for one commit is two dialogs, and the second\n * caller is told out loud rather than left believing it is the gate.\n *\n * RELEASING. The return value is a disposer, and calling it is not optional\n * for anything that can be torn down: an approver whose UI is gone is a\n * driver where every later commit waits forever on a dialog nobody can see.\n * After it runs, `policy` is `declared` again and the next adopter can win.\n * A disposer only ever releases its own hook, so a late one cannot unhook\n * whoever came after it.\n *\n * Optional on the interface, like the rest of `approval`: a hand-written\n * driver need not offer it, and a caller that finds it absent is on the\n * driver this mechanism did not exist on.\n */\n adopt?: (hook: ApprovalHook) => (() => void) | null;\n /**\n * Run `ask` with the driver's no-other-calls lock held.\n *\n * While it is held, every `call()` on this driver is refused\n * `approval-pending`. That is what stops an agent from pressing the Approve\n * button of the dialog that is asking it about something else — see\n * `RESERVED_REFUSALS` and webmachinelearning/webmcp#288 — and it is why the\n * widget's dialog goes through here even when the app declared no core hook.\n *\n * The verb's own call is not blocked by its own approval: the core clears\n * the lock before it runs `run`.\n */\n hold: <T>(verb: string, ask: () => Promise<T>) => Promise<T>;\n}\n\n/**\n * One thing an agent did to this app, as it happened.\n *\n * WHY THIS EXISTS. The library commits data on a person's behalf — the whole\n * design is about making a 3,412-row bulk accept safe — and until this it kept\n * no record that it happened. Who approved it, which plan token, what count,\n * at what `rev`, on which screen: \"what did the agent do yesterday?\" had no\n * answer. RPA tools have had an audit log for twenty years.\n *\n * WHY A HOOK AND NOT A SINK. The host already has somewhere for this to go:\n * one adopter runs OpenTelemetry, the next has Datadog, the next a table in\n * their own database. A library that picks your logging backend is a library\n * you fight, so this one emits a structured record and owns nothing else.\n * `driverkit/otel` is one such sink, kept behind its own entry point that\n * nothing in here imports.\n *\n * AND WHY THE SINK CANNOT BE THE RELAY OR THE PYTHON PACKAGE. The in-page\n * widget — the case most likely to commit data, because somebody is sitting\n * there — has no relay and no Python in it at all. An audit trail that only\n * existed for the relay case would be worse than none, because it would look\n * complete.\n *\n * WHERE IT IS EMITTED FROM, which is the property that makes it worth\n * trusting: the record is built from the `Result` that `call()` is about to\n * return, in the same place that `Result` is decided, and every field it\n * carries beyond the result was written down by the step that decided it — the\n * approval answer by the gate, the plan by the mint and the burn. Nothing here\n * is reconstructed by a second reading of the app, because a log that can\n * disagree with the `Result` is worse than no log.\n *\n * ONE EVENT PER `call()`, whichever path the call came in on — the in-page\n * loop, a relay frame, a test with no transport — including the calls that\n * never reached a verb at all. A refused call is the most interesting line in\n * an audit trail: `declined-by-user` is a person saying no, `stale-plan` is an\n * agent trying to spend a receipt for a count that moved, and a log that only\n * recorded successes would have nothing to say about either.\n *\n * ---\n *\n * **HOW A QUESTION APPEARS IN HERE, AND WHY IT NEEDED NO NEW FIELD.** An `ask`\n * is a human interaction and belongs in the record as much as an approval does,\n * and the fields already here say all of it — which is worth spelling out\n * because the instinct is to add an `asked:` enum beside `approval`, and a\n * second way to say one thing is a second thing to get wrong.\n *\n * `verb: \"ask\"`, `kind: \"ask\"` this row is a question.\n * `args.question` what was asked, as the agent typed it.\n * `waitedMs` how long it was open. **Present exactly when\n * a question reached somebody**, which is the\n * field that tells \"asked\" from \"never put\".\n * `ok: true` asked AND ANSWERED.\n * `refused: \"ask-unanswered\"` asked AND IGNORED. `waitedMs` says for how\n * long.\n * `refused: \"nobody-to-ask\"` never put: no person on this path.\n * `refused: \"asks-spent\"` never put: the allowance was gone.\n *\n * So \"asked and answered\" and \"asked and ignored\" are two values of a field\n * that already exists, and the two kinds of not-asking are told apart by slug\n * and by the absence of `waitedMs`. `approval` stays `not-asked` on every one\n * of these rows, because nobody approved anything: a question is not consent,\n * and a record in which a question could read as an approval would be the\n * bypass this feature was built not to be.\n *\n * **WHAT THE ANSWER'S TEXT IS DOING OUTSIDE THE RECORD, DELIBERATELY.** The\n * person's words are the `Result`'s `note` and the core keeps no copy, so they\n * are not here. That is the same argument `ArgSpec.sensitive` makes about this\n * very hook being \"the one boundary where a record is most likely to leave the\n * box\": an answer is free text a person typed, it may be anything, and a host\n * that wires `onAudit` straight to a vendor's tracer should not thereby ship it\n * there. What an auditor needs is that a question was asked, what it was, and\n * whether somebody answered — all of which is above. If you need the words,\n * they are in the transcript, which is the artefact that is supposed to hold\n * what was said.\n */\nexport interface AuditEvent {\n /** `Date.now()` when the call settled. Milliseconds since the epoch, not an\n * ISO string: a host formats it its own way, and a number cannot be\n * mistaken for a timezone-bearing claim this library is not making. */\n at: number;\n /** How long the call took, in milliseconds, approval included. The gap\n * between a question being asked and a person answering it is the part of a\n * bulk commit a reader most often wants back. */\n ms: number;\n /**\n * How much of `ms` was spent waiting for an approval to be answered.\n *\n * Present only when somebody was actually asked — so its absence means no\n * question was open and `ms` is the app's own work, start to finish.\n *\n * **Why both numbers and not one.** `ms` is deliberately approval-inclusive:\n * \"this bulk accept took 41 seconds from the agent's point of view\" is the\n * fact an auditor wants, and a record that silently excluded the human would\n * make a slow decision look like a fast app. But the two are different\n * quantities and only one of them is about the software — `ms - waitedMs` is\n * how long the verb took, and `waitedMs` is how long a person took — and a\n * record that gave only the sum cannot be used to answer either question.\n * Subtracting is cheap; recovering a figure that was never written down is\n * not.\n *\n * The same separation reaches the MODEL by a different route and for a\n * sharper reason: see `DriveOptions.timing`, where the duration a model is\n * shown is measured so as to EXCLUDE this from the start. An auditor reading\n * \"41 seconds, 38 of them waiting\" draws the right conclusion; a model told\n * \"this call took 40 seconds\" draws the wrong one about the app's speed and\n * routes around a verb that is not slow.\n */\n waitedMs?: number;\n /** `MountOptions.app`. Two drivers can be mounted on one page — a widget and\n * an embedded view — and an unattributed record is one you cannot act on. */\n app: string;\n /** The verb. `goto` is the core's own and appears here like any other. */\n verb: string;\n /** As DECLARED. Absent means the app made no safety claim about this verb,\n * which is a fact worth keeping in the record rather than defaulting away:\n * an auditor asking \"what commits ran\" must be able to see that some verbs\n * never said. */\n kind?: VerbKind;\n /** As declared. Absent makes no claim; see `Verb.reversible`. */\n reversible?: true;\n /**\n * The arguments AS SENT, with one exception, named by `redacted`.\n *\n * As sent, not as validated: an argument of the wrong type, or one the verb\n * never declared, is exactly what an audit reader is looking for when a call\n * went wrong. The core does not strip undeclared arguments from the record\n * for the same reason it does not strip them from the call.\n */\n args: Record<string, Scalar>;\n /** The argument names whose values were replaced with `REDACTED`, because\n * the verb declared them `ArgSpec.sensitive`. Present only when something\n * was replaced, so the absence of this field means the `args` above are\n * the whole truth. */\n redacted?: string[];\n /** `Snapshot.screen` the call ran against, read once, before the verb. */\n screen?: string;\n /** `Snapshot.rev` the call ran against. With `screen`, this is what the\n * record needs to be re-readable later: \"3,412 rows at rev 180 of the\n * contacts screen\" is a claim somebody can go and check. */\n rev: number;\n /** What the agent CLAIMED it was acting on, when it claimed anything. Kept\n * beside the two above rather than folded into them, because the difference\n * between them is the whole of a `stale` or a `wrong-screen`, and a record\n * that kept only one side could not show why the call was refused. */\n claimed?: { rev?: number; screen?: string };\n /** `Result.ok`. */\n ok: boolean;\n /** The refusal slug, present exactly when `ok` is false. The app's own slug\n * or a reserved one; see `RESERVED_REFUSALS`. */\n refused?: string;\n /** `Result.count` — what a `describe` reported it matched. The number a\n * person approves, and the reason this field is in the record. */\n count?: number;\n /** The plan token this call PRESENTED, when the verb consumes one. Recorded\n * whether or not it was accepted: a rejected token is how you find the\n * agent that tried to spend a stale receipt. */\n plan?: string;\n /** The plan token this call MINTED, on a `describe` that counted. The join\n * key for the two halves of a gated bulk commit: the event that carries\n * this one as `minted` reported the count, and the event that carries it as\n * `plan` is the commit that spent it. That pair is the answer to \"who\n * approved 3,412 rows, and was 3,412 the number that moved\". */\n minted?: string;\n /**\n * How the approval question was answered.\n *\n * `allowed` a hook said yes.\n * `declined` a hook said no — a person deciding.\n * `timed-out` nobody answered. The verb did not run.\n * `not-asked` nobody was asked, and `policy` says why.\n *\n * Four values, not three, because \"declined\" and \"never asked\" are the two\n * an auditor must never confuse: one is a person refusing and one is a gate\n * that was not there.\n *\n * `not-asked` has two shapes and `policy` tells them apart. With a `policy`\n * of `none` or `unattended` there was no gate: nothing could have asked.\n * With a `policy` of `hook` or `adopted` there WAS a gate and it let this\n * commit through without a question — a reversible verb under the panel's\n * size threshold, or confirmations switched off — which is a gate's decision\n * and not a person's, so it is not `allowed`. See `Approval`'s\n * `{ asked: false }`.\n */\n approval: \"allowed\" | \"declined\" | \"timed-out\" | \"not-asked\";\n /**\n * Who was in a position to be asked, at the moment of this call.\n *\n * It is what turns a `not-asked` from a silence into a sentence:\n * `unattended` is an app saying out loud that commits here run with nobody\n * in front of them, `none` is an app that never said, and `hook` or\n * `adopted` beside a `not-asked` is a gate that was there and decided this\n * particular commit did not need a question.\n *\n * Read per call rather than once at `mount()`, because a page can acquire a\n * gate after it starts: `adopted` is a panel's dialog installed by\n * `DriverApproval.adopt`, and the same driver's earlier records honestly say\n * `none`. See `DriverApproval.policy` for why that is a different word from\n * `hook` and not a synonym for it.\n */\n policy: DriverApproval[\"policy\"];\n}\n\n/**\n * Where the records go. See `MountOptions.onAudit`.\n *\n * Returns nothing. A promise is tolerated and is NOT awaited; see the hook's\n * own documentation for why this one differs from `ApprovalHook`, which is.\n */\nexport type AuditHook = (event: AuditEvent) => void | Promise<void>;\n\n/**\n * What one driver tells the other drivers of the same app when a commit lands.\n *\n * The whole payload, and it is deliberately two strings of the core's OWN\n * making. `verb` is a name out of this driver's verb table and `from` is the\n * driver's own identity; neither is app data, neither is a row, neither is a\n * count. A notice that carried the new rows would be a cross-tab replication\n * protocol, which is the app's problem and not a library's — and it would be a\n * leak besides, since the two tabs may not be showing the same person's data\n * if the app got that wrong.\n *\n * It says \"something changed, and it was not your copy that changed it\". That\n * is the only fact a sibling tab cannot work out for itself, and it is enough\n * to stop that tab claiming freshness it has not got.\n */\nexport interface ElsewhereNotice {\n /** The `commit` verb that ran. Named so a refusal can say what happened\n * rather than \"something changed somewhere\", which an agent cannot act on. */\n verb: string;\n /** The driver that sent it. A driver ignores its own notices; without this\n * a `BroadcastChannel` that echoed to the sender would make every commit\n * poison the tab that made it. Opaque, and minted per `mount()`. */\n from: string;\n}\n\n/**\n * How the drivers of one app in different tabs hear about each other's commits.\n *\n * THE HOLE THIS EXISTS TO CLOSE. `Snapshot.rev` is the app's claim that its\n * data has not moved, and it is bumped by the app's own mutation path. Two\n * tabs of the same app over one backend: an agent commits in tab A, tab B's\n * data has changed, and B's `rev` has not moved, because B's store never heard.\n * So B's snapshot reports stale rows as current, a `stale` check against B's\n * `rev` PASSES, and a plan token minted in B still verifies — the whole\n * staleness machinery passing in exactly the situation it exists to catch.\n *\n * Nothing inside tab B can see that. Every value a check could be built from —\n * `rev`, `selectionId`, a count, a hash of the rows — comes out of `visible()`,\n * which reads B's own store, and B's own store is the thing that is wrong. The\n * fact has to arrive from outside, and the core's own commit is the only thing\n * that knows it.\n *\n * SO THIS IS A TRANSPORT AND NOT A POLICY. Two functions, no server, no\n * authority. `driverkit/browser` ships `broadcastElsewhere()`, a\n * `BroadcastChannel` implementation that works same-origin with no relay at all\n * — which matters, because an app driven only by its own in-page panel has no\n * relay to route anything through. An app that already has a websocket or a\n * service worker implements the same two functions over it and gets the same\n * check. The relay deliberately does NOT do this: it grants no authority and\n * knows nothing about verbs, and a relay that read `kind` out of a manifest to\n * decide what to announce would be a second place that decides what a commit\n * is.\n *\n * WHAT IT BUYS, STATED HONESTLY. It does not make tab B's data correct — only\n * the app refetching does that, and an app that listens on this channel itself\n * and refetches is the real fix. What it buys is that B stops lying in the\n * window before that happens: a `commit` in B is refused `changed-elsewhere`,\n * and every snapshot B hands back says so in words. See `MountOptions.elsewhere`.\n */\nexport interface ElsewhereChannel {\n /**\n * Broadcast a notice. Called by the core after a `commit` verb's body runs.\n *\n * Must not throw usefully — the core catches and warns, because a failed\n * broadcast is not a reason to turn a commit that already happened into an\n * error.\n */\n post: (notice: ElsewhereNotice) => void;\n /**\n * Subscribe. Called once at `mount()`.\n *\n * The returned function, if there is one, is called at `unmount()`. Returning\n * nothing is allowed so that a three-line channel in a test need not invent\n * one.\n */\n listen: (heard: (notice: ElsewhereNotice) => void) => (() => void) | void;\n}\n\n/**\n * A hard ceiling on what one mounted driver will ever spend.\n *\n * `DriveOptions.maxSteps` bounds ONE run. Nothing bounded runs. An agent in a\n * loop re-enters `drive()` with a fresh `maxSteps` every time, and a widget\n * somebody leaves open in a tab over a long weekend has no bound at all — so\n * the app's API and somebody's token budget were both unprotected by\n * construction, not by oversight.\n *\n * WHY THIS IS IN `mount()` AND NOT IN THE WIDGET'S SETTINGS. The settings view\n * owns what a VIEWER is comfortable with: the pace, step mode, whether the\n * panel explains itself. A spend limit is not a comfort, it is somebody else's\n * money, and a viewer who can raise their own ceiling does not have one. So it\n * is declared where the app is declared, by the person who pays. The settings\n * view may SHOW it — see `Driver.budget`, which exists so it can — and must\n * not offer to change it.\n *\n * WHAT IS BOUNDED, AND WHAT WAS REJECTED.\n *\n * `calls` — every `call()` this driver ever accepts, refused ones\n * included. This is the bound that matters. It is a bound on the\n * app's own API, because every verb body is behind it, and it is\n * a bound on tokens, because an agent spends a model round trip\n * to produce each one. Refused calls count on purpose: an agent\n * spinning on `bad-argument` is precisely the runaway this\n * exists for, and a counter that only counted successes would\n * never fire on it.\n *\n * `commits` — `kind: \"commit\"` verbs that actually ran. A second counter\n * rather than a stricter first one, because the two bound\n * different costs: a thousand reads costs tokens, and a\n * thousand commits costs DATA. An app may happily allow the\n * first and not the second, and one number cannot say that.\n *\n * `asks` — questions actually put to somebody. A third counter by the\n * same argument the second one is made of: a thousand reads\n * costs tokens, a thousand commits costs data, and a thousand\n * questions costs A PERSON'S PATIENCE, which is the one of the\n * three that cannot be topped up. One number cannot bound all\n * three because an app may well want two hundred calls, ten\n * commits and three questions.\n *\n * It is the counter with the sharpest failure mode behind it: an\n * agent that is confused can ask instead of thinking, and each\n * question looks individually reasonable while the sequence is a\n * person being interrogated by something that has stopped\n * working. `drive`'s `refusalLimit` cannot see it, because every\n * one of those questions SUCCEEDS.\n *\n * It refuses `asks-spent` and never `budget-spent`, and that is\n * the one place this field departs from the two above. See the\n * slug in `RESERVED_REFUSALS`: those two end in no repair — stop,\n * and tell the person — and this one ends in a real one, which is\n * to say in the final answer what you would have asked.\n *\n * REJECTED: **runs per minute**, or calls per minute, or any rolling window.\n * It is the one that looks most like a cost control and is the least like one.\n * A rate limit converts an unbounded spend into a slower unbounded spend — the\n * runaway loop still runs forever, just politely — so it bounds instantaneous\n * load and not cost, and it is a ceiling nobody can ever hit and therefore a\n * ceiling that never says anything. An app that genuinely needs load shedding\n * has it at the server, where a client-side limiter is advisory anyway.\n *\n * REJECTED: **model round trips.** It is the thing an author actually wants to\n * cap, and the core cannot see one. `call()` is the only place every path\n * converges; a round-trip count would have to be reported by the loop, and the\n * loop is the consumer being limited. A number the limited thing reports about\n * itself is not a limit. `calls` is the honest proxy, and the relationship is\n * close: one tool call is one round trip in every tool-use API there is.\n *\n * REJECTED: **total steps per session** as a third field. That is `calls`\n * under another name — `drive()`'s steps are verb calls — and two fields for\n * one quantity is two fields that come to disagree.\n *\n * Absent, or a field absent, means no ceiling: an app mounted before this\n * existed behaves byte-identically, and the manifest and its fingerprint do\n * not move, because a spend limit is a runtime arrangement and not part of the\n * surface an agent caches.\n */\nexport interface Budget {\n /** Most calls this driver will ever accept. Omitted means no bound. A\n * non-positive number is refused at `mount()`: it means the app is never\n * drivable, which nobody means, and it would make every call fail with no\n * hint that a budget was the cause. */\n calls?: number;\n /** Most `commit` verbs this driver will ever run. Omitted means no bound. */\n commits?: number;\n /**\n * Most questions this driver will ever put to a person. Omitted means no\n * bound, which is the same default the two above have and is deliberately\n * not a small number: a ceiling the library picked would be a ceiling that\n * fires in somebody's app for a reason they never wrote down.\n *\n * Counted only when a question actually reached the hook — a question\n * refused for a spent allowance, or one the app answered `{ nobody: true }`\n * to, charged nothing, because neither one took anybody's attention.\n */\n asks?: number;\n /**\n * Where the counters are kept, so a page reload does not refill them.\n *\n * **WHY THIS IS NOT OPTIONAL POLISH.** Navigation is one of the agent's own\n * verbs. `goto`, `go`, `open-contact` are `read` verbs an agent calls freely,\n * and a `goto` to a full page load tears the driver down and mounts a fresh\n * one — with `callsUsed` back at zero. So without this field an agent that\n * reaches a ceiling can refresh its way past it, and the `budget-spent` hint\n * says in so many words \"it does not refill, and waiting or retrying will not\n * change it\", which was then false. A ceiling that resets is not a ceiling,\n * and a hint that lies about it is worse than no hint.\n *\n * Absent means in-memory counters and the behaviour this had before the field\n * existed: the ceiling bounds one mounted driver and a reload starts over.\n * That is still the right default for an app with no storage to reach for.\n *\n * **FAIL CLOSED, UNLIKE EVERY OTHER PIECE OF PERSISTENCE IN HERE.** The\n * widget's panel position and its transcript swallow every storage failure,\n * because the worst case is a forgotten pane and a lost conversation. Here\n * the worst case is an uncapped agent, so the asymmetry is reversed on\n * purpose: when `load()` answers `{ ok: false }`, or a `save()` throws, every\n * subsequent call is refused `budget-spent` with a hint that names the cause.\n * An app whose storage is unavailable is still fully usable by the person at\n * the keyboard — it is only the agent that stops. See `BudgetStore`.\n *\n * **THIS IS A COST CONTROL AND NOT A SECURITY BOUNDARY, and the type should\n * say so rather than imply a guarantee the browser cannot give.** Whatever\n * holds the record is readable and writable by the person sitting there, in\n * two keystrokes of devtools, and clearing site data resets it. That is fine:\n * they own the machine and they are the one paying. What this stops is an\n * agent in a loop, which is the thing it was built for. A ceiling that has to\n * hold against the person is a ceiling that belongs on the server, behind the\n * API the verbs call.\n */\n store?: BudgetStore;\n /**\n * The name of the current allowance. Changing it starts a fresh one.\n *\n * A persisted ceiling cannot reset on nothing, because a budget that is\n * permanently spent makes the app permanently undrivable — which nobody will\n * read as a working cost control, they will read it as this library being\n * broken, and the next thing they do is clear site data, which resets it\n * anyway and teaches them to do that every time.\n *\n * So this is the deliberate, host-held reset: a string the app chooses. A\n * record written under a different `epoch` is discarded and the allowance\n * starts again. A deploy can bump it, a billing period can be its name, a\n * support tool can write a new one into the page it serves.\n *\n * **The agent cannot reach it.** It is an argument to `mount()`, so it lives\n * in the page's own source, which an agent driving through verbs has no verb\n * for. That is the test every reset mechanism here has to pass, and it is why\n * there is no reset VERB and never should be.\n */\n epoch?: string;\n /**\n * How long one allowance lasts, in milliseconds. Omitted means forever.\n *\n * `{ calls: 200, window: 86_400_000 }` is two hundred calls a day: the record\n * carries when its allowance started, and a record older than this is\n * discarded for a fresh one.\n *\n * **This is not the rolling window this type rejects further up, and the\n * difference is worth being exact about.** What was rejected was a RATE\n * limit — calls per minute as the bound — on the grounds that it \"converts an\n * unbounded spend into a slower unbounded spend\": the runaway still runs\n * forever, politely. This is a hard ceiling with a renewal period, which is a\n * quota. A runaway still stops dead at `calls` and stays stopped for the rest\n * of the window; what the window buys is that tomorrow the app works again\n * without anybody deploying anything. Tumbling and not sliding, because a\n * sliding window needs the timestamp of every call and this needs one number.\n *\n * Also agent-unreachable: it is declared at `mount()`, and the only thing\n * that advances it is the wall clock. An agent that could set the page's\n * clock forward has bigger powers than this field.\n *\n * A DESIGN NOTE, NOT BUILT, so the argument is not lost: the settings view\n * could let the VIEWER lower this app's ceiling but never raise it. A person\n * tightening their own leash is always safe, and the app's declared number\n * stays the hard stop, so there is no bypass in it. It is not here because a\n * viewer-held floor is a second persisted number with its own scope question,\n * and the ceiling that actually had to stop resetting is this one.\n */\n window?: number;\n}\n\n/**\n * Where a `Budget`'s counters live between page loads.\n *\n * An interface and not a `localStorage` call, for the reason every other\n * environment touch in the core is one: `mount()` runs in a browser, in a test\n * with a fake DOM, in `jsdom`, and in whatever somebody embeds this in next.\n * The core decides what the numbers MEAN — what counts, when an allowance has\n * expired, what a broken store does to the next call — and the store only\n * carries bytes. `localBudgetStore` in `driverkit/browser` is the one this\n * library ships; it is twenty lines over the same `loadJson`/`saveJson` the\n * widget's position and settings go through.\n *\n * **Scoped PER APP PER ORIGIN, which is what `localBudgetStore` does, and the\n * scope is a design decision rather than an implementation detail.** The\n * widget's transcript is scoped per TAB — it goes in `sessionStorage` — and a\n * budget deliberately is not, for one reason: if the ceiling were per tab then\n * \"open a second tab\" would be a budget-doubling move, which is the reload\n * bypass this whole mechanism exists to close, wearing a different hat. Two\n * tabs of one app therefore share one allowance, and yes, that means one tab\n * can exhaust the other's. That is the correct failure and the honest one: it\n * is ONE ceiling, spent by one person's agents, exactly as it would behave if\n * it were counted on the server — and the alternative fails in the direction\n * that costs money.\n */\nexport interface BudgetStore {\n /**\n * The record this store holds, or the news that it cannot be consulted.\n *\n * Three answers and not two, because the third is the whole of fail-closed:\n * \"nothing stored yet\" and \"I could not look\" are indistinguishable in a\n * plain `getItem` and must never be treated alike. A private window, blocked\n * site data and a corrupt record all answer `{ ok: false }`, and a corrupt\n * record is included on purpose — it cannot be told apart from tampering, and\n * guessing in the agent's favour is the one guess with a bill attached.\n *\n * **Called at `mount()` and again before every charged call**, and the\n * re-read is what makes \"one app, one ceiling\" true rather than aspirational.\n * Two tabs open at once each hold their own copy of the counters, so a\n * mount-time read alone gave each of them the whole allowance — two tabs, two\n * ceilings, which is the reload bypass wearing a different hat. It must\n * therefore be cheap and synchronous; `localBudgetStore` is one `getItem` and\n * one `JSON.parse` of a four-field object.\n *\n * The core takes the HIGHER of what this answers and what it already holds,\n * so a store that reads back a smaller figure — a tab that was behind, a\n * record somebody edited — can never hand an allowance back.\n */\n load(): { ok: true; spent: BudgetRecord | null } | { ok: false };\n /**\n * Write the record back. Called after every charged call.\n *\n * **May throw, and a throw is load-bearing here.** Everywhere else in this\n * library a failed storage write is swallowed, because a forgotten panel\n * position is not worth an exception. A budget that cannot be written is a\n * budget that will not be there after the next reload, which is the uncapped\n * agent again — so the core catches this, refuses every later call\n * `budget-spent`, and names the reason in the hint. Throwing is how a store\n * says \"this ceiling is no longer being kept\".\n */\n save(record: BudgetRecord): void;\n}\n\n/**\n * One allowance, as it is stored.\n *\n * Four fields and no more. In particular there is no verb name, no argument, no\n * count and no screen: a spend record that carried any of those would be a\n * transcript in `localStorage` under a field nobody reads as one, and the\n * privacy class of \"this app has made 41 calls\" is nothing like the privacy\n * class of what those calls were about.\n */\nexport interface BudgetRecord {\n /** Calls charged so far, matching `BudgetState.calls.used`. */\n calls: number;\n /** Commits run so far, matching `BudgetState.commits.used`. */\n commits: number;\n /**\n * Questions put so far, matching `BudgetState.asks.used`.\n *\n * Optional, and that is the migration: a record written before this field\n * existed reads back with no `asks`, which the core takes as 0 rather than\n * discarding the record — the two numbers beside it are still true, and\n * throwing an allowance away because a field was added would hand every app\n * with a store a fresh ceiling on upgrade.\n *\n * Still four fields' worth of privacy class and no more: a count of\n * questions, never a question. Nothing a person typed is written here, by\n * the rule the rest of this type is built on.\n */\n asks?: number;\n /** `Date.now()` when this allowance began. Only `Budget.window` reads it; an\n * app with no window never looks, and the field is still written so that\n * adding a window later does not have to treat every existing record as\n * having started at the epoch. */\n since: number;\n /** The `Budget.epoch` in force when this record was written, absent when the\n * app declared none. A mismatch discards the record; see `Budget.epoch`. */\n epoch?: string;\n}\n\n/**\n * What a mounted driver has spent, for a UI to show a person.\n *\n * READ-ONLY and that is the field's whole design. The widget's settings view\n * shows this and offers no control beside it; see `Budget` for why a viewer\n * must not be able to raise their own ceiling.\n *\n * `used` without `limit` is the normal case — an app with no budget still\n * reports what it has spent, which is the number somebody debugging a runaway\n * actually wants. `left` is deliberately absent: it is `limit - used`, and a\n * second way to say one thing is a second thing to get wrong.\n */\nexport interface BudgetState {\n calls: { used: number; limit?: number };\n commits: { used: number; limit?: number };\n /** Questions put to a person, and the ceiling if the app set one. Reported\n * whatever the app declared, like the two above, so a settings view has one\n * shape to render — and so \"it has asked me four things\" is a number\n * somebody can see. */\n asks: { used: number; limit?: number };\n}\n\nexport interface MountOptions {\n /** Shown in the manifest. A name a human would recognise. */\n app: string;\n /** The app's own briefing, copied into `Manifest.instructions` and read by\n * every path that drives it — the in-page prompt and the MCP server alike.\n * Static: see `Manifest.instructions` for what may not go in it. */\n instructions?: string;\n verbs: Verb<never>[] | Verb<Record<string, Scalar>>[] | Verb<any>[];\n /** Called fresh on every read. Must be cheap: it runs on each verb call. */\n visible: () => Snapshot;\n /**\n * Every screen the app has, with an optional RFC 6570 url template each.\n *\n * Declaring this plus `navigate` is what makes the core offer the reserved\n * `goto` verb, which is the point of the field: an app stops hand-rolling a\n * navigation verb under a name of its own — `go`, `navigate`, `open-screen`,\n * `route-to`, one per app, none of which the next agent recognises — and\n * gets one whose name, arguments, refusals and tool description are the\n * same in every app that declares a map.\n *\n * Declared WITHOUT `navigate` the list is still published and still useful:\n * an agent learns what screens exist and what their addresses look like,\n * which is more than it had. But no `goto` appears, because a navigation\n * verb the core cannot carry out would be a dead verb sitting in everybody's\n * cached prefix. `mount()` says so once, out loud, since the likelier of the\n * two readings is that the hook was forgotten.\n *\n * See `ScreenSpec`. Static, and the one rule worth repeating here: publish\n * the screens the APP has, never the screens this user can reach.\n */\n screens?: ScreenSpec[];\n /**\n * How the app gets to a screen. The body of the reserved `goto` verb.\n *\n * Read only when `screens` is declared, and ignored without it: there is\n * nowhere for `goto` to go. See `NavigateHook` for why this is the app's\n * function and not the core's, and `NavigateTarget` for what it is handed.\n *\n * An app that would rather keep its own navigation verb simply declares one\n * named `goto` in `verbs`, and the core leaves it alone — the same rule as\n * the hoisted `rev` and `screen` arguments in `driverkit/agent`, where an\n * app that claims the name keeps it, because the app's meaning wins over\n * ours.\n */\n navigate?: NavigateHook;\n /**\n * How the app puts a question to the person. Declaring it is what makes the\n * core offer the reserved `ask` verb.\n *\n * THE GAP THIS CLOSES. `approve` is a GATE, not a channel. A person could\n * stop the agent and the agent could not ask the person anything, so an\n * agent meeting an ambiguous instruction — \"select the contact called Ada\n * Duarte\", and five people are called that — had two moves: guess, or give\n * up. The argument is the one `declined-by-user` already rests on, one level\n * up: a model that cannot tell \"the person said no\" from \"your arguments\n * were wrong\" will retry with different arguments, and **a model that cannot\n * ask will guess.** Two of this library's own eval cases were written for an\n * outcome it could not express.\n *\n * Absent means absent, which is the whole of the additive promise here: no\n * `ask` verb appears, the manifest is the document it was before this field\n * existed, and `fingerprint()` does not move. An app that cannot ask is an\n * app where the guidance in `systemPrompt` about asking is never rendered\n * either, so a model is not told about a tool it has not got.\n *\n * BOTH WAYS IN, which is the half that makes this a feature rather than a\n * widget. The verb lives in `call()`, like every other, so an agent arriving\n * over the relay or MCP asks the same question through the same hook and the\n * person answers it in the same panel. What the outside path needs that the\n * in-page one does not is `askTimeout`; see it for why the default is a\n * deadline here and \"wait forever\" for an approval.\n *\n * IT IS NOT AN APPROVAL AND MUST NOT BECOME ONE. Nothing the person types\n * here is stored, nothing reaches `ApprovalRequest`, and a `commit` after a\n * question is gated exactly as a commit before one would have been — so an\n * agent that asks \"shall I accept these 3,412?\" and is told yes still meets\n * `approve`, and a `false` from `approve` still refuses the commit. The\n * separation is structural because there is no state for it to be a policy\n * about. See `AskHook`.\n */\n ask?: AskHook;\n /**\n * How long to wait for an answer before giving up, in milliseconds.\n * **Defaults to `DEFAULT_ASK_TIMEOUT_MS`, which is 45 seconds.**\n *\n * **THE OPPOSITE DEFAULT FROM `approvalTimeout`, ON PURPOSE.** That one waits\n * forever, because the person may be reading the rows the question is about\n * and a deadline that DENIES while they are deciding teaches them the dialog\n * is a race. Both halves of that argument invert here.\n *\n * Nothing is denied by a lapsed question: no verb was going to run and no\n * data was going to move, so giving up costs the agent one refusal it can\n * read and act on, and costs the person nothing at all.\n *\n * And waiting past the transport's own deadline is actively dishonest. The\n * relay gives a call 60 seconds and then answers `timeout`, which PROTOCOL.md\n * defines as **outcome unknown** — a commit that came back that way may\n * already have run. A question that outlived it would convert \"nobody\n * answered\", which is a fact the agent can act on, into \"nobody knows\", which\n * is the most expensive answer in the system, over the one call where the\n * truth was plainly knowable. So the default sits comfortably under the\n * relay's: the page answers `ask-unanswered` first, every time, and the\n * outside agent learns the fact rather than the mystery.\n *\n * 45 seconds is also about as long as a question can sit in front of\n * somebody before it is stale: an agent that asked a minute ago is asking\n * about a screen that has moved. Raise it for a gate that is a webhook or a\n * phone, and raise `RelayOptions.timeoutMs` with it or the relay will answer\n * first — which is the one combination that gives back exactly the honesty\n * this default is protecting. A non-positive number means wait forever, which\n * is the right answer for an app that is only ever driven in-page.\n */\n askTimeout?: number;\n /**\n * The app's multi-step recipes, for an agent to read and follow.\n *\n * Validated at `mount()` — a flow naming a verb that does not exist throws,\n * like a duplicate verb name — and then copied into the manifest and\n * rendered into the cached system prompt. Nothing executes them. See\n * `FlowSpec`, which carries the argument for why not.\n */\n flows?: FlowSpec[];\n /**\n * Who approves a `commit`, as a hook or as the word `\"unattended\"`.\n *\n * WHY THIS IS IN THE CORE AND NOT IN A CONSUMER. The confirmation used to\n * live in `driverkit/agent`'s `onBeforeCommit`, which `mountWidget` turns\n * on by default — so a person watching the panel was asked, and an agent\n * arriving over the relay or MCP called `accept-selected` and it simply ran.\n * The reserved slug `declined-by-user` existed and nothing on the outside\n * path could ever emit it. That is the gate being in the wrong layer: a\n * safety property that holds on one of two paths is not a safety property,\n * it is a property of one consumer. `call()` is where every path converges —\n * the in-page loop, a relay frame, a test with no transport — so the gate\n * belongs here, and from here a denial is the same `declined-by-user`\n * refusal whichever way the call arrived.\n *\n * Called before `run`, for `kind: \"commit\"` verbs only. `read` and\n * `describe` are the two kinds that promise no data moves, which is the\n * promise this gate exists to check; asking about them is how people learn\n * to click Yes without reading. A commit that declares `reversible` is still\n * asked about here — the core does not know how large the selection is or\n * how good the app's undo really is, and the widget's dialog, which does,\n * answers that question inside its own implementation of this hook.\n *\n * NOBODY IS THERE TO ASK: the third answer, and the one this field is shaped\n * by. A headless agent over MCP has no human, and the three candidate\n * answers were refuse (safe, and it breaks every automated run), allow (what\n * happened before this existed, and it is the gap) or make the host DECLARE\n * which it is. The third is taken, and the precedent is `allow_remote=True`\n * with no way to identify callers, which raises at construction rather than\n * serving: three deliberate acts to publish a relay, not one. So here —\n * absent means absent, in-page behaviour is exactly what it was, and the\n * declaration is enforced at the moment the driver is published to the\n * outside. `connect()` refuses to open a stream for a driver that has\n * `commit` verbs which have not declared `reversible` and no `approve` of\n * either kind. Three deliberate acts to let an outside agent change data: a\n * commit verb, a relay connection, and a statement of who approves. The\n * unsafe case is still reachable — `approve: \"unattended\"` — but no longer\n * by accident, which is the whole of what this buys.\n *\n * Absent here makes NO claim and changes nothing about the core: an app\n * mounted yesterday with no `approve` behaves identically in-page, which is\n * why this is not a required field and why the default is not a gate.\n *\n * WHAT THE WIDGET DOES WITH AN ABSENT ONE. `mountWidget` installs its own\n * confirmation dialog here, through `DriverApproval.adopt`, so the question\n * a person answers in the panel is asked inside `call()` and lands in the\n * audit record as `approval: \"allowed\"` with `policy: \"adopted\"`. That is\n * additive — the dialog, its wording and its thresholds are what they were,\n * and a commit now gets asked about on paths the panel could not reach — and\n * it does not make the driver publishable: `connect()` reads\n * `DriverApproval.declared`, which this field alone writes.\n *\n * DECLARING ONE HERE OVERRULES THAT, always. A hook of your own is asked and\n * the panel installs nothing, so one commit gets one dialog; `\"unattended\"`\n * is not quietly made interactive by a panel being mounted. The documented\n * way to have both is to declare the panel's own dialog as this hook:\n * `approve: (req) => panel.approve(req)`. See `Widget.approve`.\n */\n approve?: ApprovalPolicy;\n /**\n * How long to wait for an approval before giving up, in milliseconds.\n *\n * Absent means wait, and that is the right default rather than a timid one:\n * the person may be reading the rows the question is about, and a deadline\n * that denies while they are deciding teaches them that the dialog is a race\n * instead of a decision. Nothing is lost by waiting — the agent's own\n * transport deadline fires on its side and tells it the outcome is unknown,\n * which is true.\n *\n * The cost of waiting is that an approval nobody EVER answers leaves the\n * lock held and every later call refused `approval-pending` until the page\n * is reloaded. That is safe and it is also a dead app, so an app whose\n * people are on a phone, or whose gate is a webhook, sets a number here. A\n * lapsed approval is `approval-timeout`, which says the verb DID NOT RUN —\n * unlike the relay's `timeout`, which means nobody knows.\n */\n approvalTimeout?: number;\n /**\n * Where this app's audit records go. One call per `call()`; see `AuditEvent`.\n *\n * WHAT IT COSTS TO LEAVE OUT. Nothing: an app that passes no hook behaves\n * byte-identically to one mounted before this field existed — no record is\n * built, no clock is read, and the manifest and its fingerprint do not move,\n * because an audit trail is a runtime arrangement and not part of the\n * surface an agent caches.\n *\n * A THROWING OR SLOW HOOK MUST NOT TAKE THE APP DOWN, and this hook is\n * shaped by that rather than by politeness. It is called and NOT awaited: a\n * returned promise has a `catch` attached and is otherwise left alone, and a\n * synchronous throw is caught. Either way the failure is reported once\n * through the same `console.warn` channel the rest of the core's authoring\n * mistakes use — because a record that vanished silently is the one failure\n * an audit trail cannot survive — and the call's `Result` is returned\n * unchanged.\n *\n * WHY THIS IS NOT `ApprovalHook`, which is awaited, deadlined and whose\n * failure is a refusal. An approval is asked BEFORE the decision and its\n * answer IS the decision, so there is nothing to do but wait for it, and a\n * failed ask has to be a no. An audit record is emitted AFTER the outcome is\n * decided and, for a commit, after the data has already moved: there is\n * nothing left to refuse, so waiting on the sink can only delay the agent,\n * and failing the call because the logger is down would turn a broken\n * logging backend into a broken application. Hence no deadline here, and\n * hence no timer — which is also why this hook cannot repeat the bug\n * `deadline()` carries a comment about.\n *\n * FAIL-OPEN IS A REAL LIMIT AND NOT A SHRUG. If you need a commit to be\n * impossible unless it has been recorded, the place to put that is the\n * `approve` hook, which runs before the verb and whose no means no. This one\n * cannot give you that guarantee and does not claim to.\n */\n onAudit?: AuditHook;\n /**\n * A hard ceiling on what this driver will ever spend. See `Budget`, which\n * carries the argument for what is bounded and what was rejected.\n *\n * Off by default and costs nothing to leave out: with no `budget` the\n * counters are not kept, nothing is compared, and the call path is the one\n * it was before this field existed.\n *\n * When a ceiling is reached, the call is refused `budget-spent` with the\n * numbers in the hint. That refusal is the point as much as the stopping is:\n * `approvalTimeout` waits forever by default because \"a deadline that denies\n * while somebody is reading teaches them the dialog is a race\", and a ceiling\n * has the same hazard pointing the other way — a job that stops halfway and\n * does not say why is read as a broken app, and the next thing somebody does\n * is run it again. So nothing here is silent: the agent is told which\n * ceiling and that it does not reset, `Driver.budget` lets a panel show the\n * person the same thing, and `drive()` ends the run with `over-budget`\n * rather than grinding through its refusal limit first.\n */\n budget?: Budget;\n /**\n * How this driver hears that another tab of the same app committed.\n *\n * Absent makes NO claim and changes nothing — the default, and deliberately\n * the default: a single-tab app, or an app that already invalidates across\n * tabs so that `rev` moves on its own, gains nothing from this and should pay\n * nothing for it. An app that passes a channel gets two things:\n *\n * - a `commit` is refused `changed-elsewhere` while a notice from another\n * driver is outstanding, which closes the hole described on\n * `ElsewhereChannel`: the one case where `stale` passed, the plan token\n * verified, and the data had moved anyway;\n * - every `Snapshot` this driver hands back says so, in `note`, so a read is\n * no longer silently wrong either.\n *\n * WHEN IT CLEARS: when this app's own `rev` moves. `rev` is the only\n * statement the core is entitled to believe about this app's data, and a\n * second staleness rule beside it would be a second set of rules — the thing\n * `call()` exists not to have. The cost is stated rather than hidden: a `rev`\n * that moves for an unrelated reason (the person typed in a filter) clears\n * the notice without the data having been refetched. That is the SAME\n * weakness `rev` already has — an app that bumps `rev` without refetching has\n * already broken `stale` — so this adds none. The fix for both is the same:\n * listen on the channel yourself and refetch. An app that does is an app\n * where none of this ever fires.\n *\n * ONE THING IS HELD BACK WHILE A NOTICE STANDS: a plan is not carried across\n * a read-only move. A plan surviving a navigation is a `selectionId` saying\n * the selection is the same selection, and while a notice stands the core has\n * been told that this tab's copy of the data is not. Those two would have\n * composed into a bulk commit going through with the notice silently cleared\n * and no fresh count read anywhere, so the carry declines and the agent has\n * to describe again. See `plansGoodAt` in the registry.\n *\n * See `ElsewhereChannel`, and `broadcastElsewhere()` in `driverkit/browser`\n * for the same-origin implementation that needs no server and no relay.\n */\n elsewhere?: ElsewhereChannel;\n}\n\nexport interface Driver {\n /** The static half. Stable across calls unless the verbs change. */\n manifest: () => Manifest;\n /** The dynamic half, read on demand. */\n snapshot: () => Snapshot;\n /** Run a verb. Never throws for an expected refusal; see `Result`. */\n call: (name: string, args?: Record<string, Scalar>, opts?: CallOptions) => Promise<Result>;\n /**\n * The approval policy this driver was mounted with, and its lock.\n *\n * Optional only so that a hand-written driver — which PROTOCOL.md says must\n * remain possible — still satisfies this interface. A reader treats an\n * absent one as `policy: \"none\"`, and `connect()` does. A hand-written\n * driver that has its own gate says so with\n * `approval: { policy: \"unattended\", hold: (_, ask) => ask() }`, and such a\n * driver has no `declared` and no `adopt`: `connect()` reads `declared` and\n * falls back to `policy`, so that one goes on publishing exactly as it did,\n * and a panel mounted on it finds no `adopt` and keeps its own in-page\n * dialog.\n */\n approval?: DriverApproval;\n /**\n * What this driver has spent, and against what ceiling. See `BudgetState`.\n *\n * Offered whatever the app declared, including no budget at all, so a panel\n * has one shape to render instead of two — and so the numbers are there for\n * somebody debugging an app that is making more calls than they thought.\n *\n * Optional on the interface for the reason `approval` is: a hand-written\n * driver must remain possible, and a reader treats an absent one as \"this\n * driver does not account for itself\".\n */\n budget?: () => BudgetState;\n /** Stop serving. Idempotent. */\n unmount: () => void;\n}\n\nexport interface CallOptions {\n /** The `rev` the agent believes it is acting on. If the screen has moved on,\n * the call is refused as `stale` rather than applied to a row the agent\n * never saw. Omitting it opts out of the check. */\n rev?: number;\n /**\n * The `Snapshot.screen` the agent believes it is on. Checked BEFORE `rev`,\n * and refused as `wrong-screen`.\n *\n * Before this, a `next-page` call sent with no `rev` landed on a screen the\n * agent had never seen, paged a different company's contact list, and\n * answered `ok`. \"You are somewhere else\" is a better answer than \"the\n * number moved\", and the two are different mistakes with different fixes —\n * read again, versus navigate back — which is why this is a separate check\n * and a separate slug rather than more prose on `stale`.\n *\n * Before `rev` for the same reason `rev` is before the argument check: if the\n * agent is not even on the screen it thinks it is, then the arguments and the\n * rev both describe something it never saw, and complaining about either\n * answers the wrong question. Omitting it opts out, like `rev`.\n */\n screen?: string;\n /**\n * The plan token from the `describe` whose `count` this call was approved\n * against. Required by a verb declaring `consumes: \"plan\"`, ignored by every\n * other verb, and refused as `stale-plan`.\n *\n * The third of the three claims, and the one that is NOT optional where it\n * applies. `rev` and `screen` may be omitted to opt out of their checks,\n * because an agent that makes no claim about what it was looking at has at\n * least not made a false one. A plan token cannot work that way: a commit\n * that may be called without one is a commit whose count guarantee is\n * advisory, which is the state this field was added to leave. So the verb\n * declares it statically, in the cached half, and the core refuses the bare\n * call — with the pairing spelled out in the hint, rather than a validator\n * at the client rejecting the call before the explanation can reach the\n * model.\n *\n * Checked after `screen` and BEFORE `rev`, which is the order where both\n * apply; `call()` carries the argument for it. They are not nested: a\n * read-only navigation is `stale` and is not `stale-plan`, since the screen\n * moved and the selection did not. Opaque: the core minted it and the core\n * reads it, and every hop\n * in between — both relays, `connect()`, the Python client — forwards the\n * string untouched, exactly as they do `rev` and `screen`.\n */\n plan?: string;\n}\n"]}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * driverkit/otel — one audit sink, for hosts that already run OpenTelemetry.
3
+ *
4
+ * WHY THIS IS A SEPARATE ENTRY POINT AND NOT A FEATURE OF THE CORE. `mount()`
5
+ * emits `AuditEvent`s and owns no sink, because the host already has somewhere
6
+ * for records to go: one adopter runs an OTel collector, the next has Datadog,
7
+ * the next a table in their own database. A library that picked the backend
8
+ * would be one you fight. So the core calls a hook, and this file is one
9
+ * implementation of that hook — nothing in `core`, `agent`, `widget`,
10
+ * `controls`, `browser` or `relay` imports it, and an app that never writes
11
+ * `driverkit/otel` never loads a byte of it.
12
+ *
13
+ * WHY IT IMPORTS `@opentelemetry/api` AND YET DEPENDS ON NOTHING. It does not
14
+ * import it. It takes a `Tracer` as an argument, typed STRUCTURALLY against the
15
+ * slice of the OTel API it uses, so the host passes
16
+ * `trace.getTracer("driverkit")` from its own installed copy and this package
17
+ * keeps its promise of zero runtime dependencies. Three things that buys, in
18
+ * the order they matter:
19
+ *
20
+ * 1. There is one OTel SDK per process, registered by the host at startup,
21
+ * and a library that imported its own `@opentelemetry/api` could get a
22
+ * SECOND copy of the global API — a different version, hoisted elsewhere,
23
+ * or duplicated by a bundler — whose `trace.getTracer` returns a no-op
24
+ * tracer because the registration happened on the other copy. Spans would
25
+ * be built and silently dropped, which is the worst failure an audit
26
+ * trail can have: it looks complete. Taking the tracer as an argument
27
+ * makes that impossible, because the only tracer that can be passed is
28
+ * one the host already got from the copy it registered.
29
+ * 2. `@opentelemetry/api` would be this package's first dependency, and the
30
+ * no-dependency rule is an argument in PROTOCOL.md rather than an
31
+ * accident. An optional peer would have kept `npm install driverkit`
32
+ * clean and would still have put an unresolvable import in the published
33
+ * `.d.ts` of anybody who did not install it.
34
+ * 3. The in-page widget — the case most likely to commit data — can use this
35
+ * too. Nothing in here is Node-specific, so `./otel` is published to a
36
+ * browser-targeted bundler like the rest of the library, and a page
37
+ * running the OTel web SDK passes its tracer in exactly as a server does.
38
+ *
39
+ * The structural types below are written to be satisfied BY `@opentelemetry/
40
+ * api`'s own `Tracer` and `Span`, not to re-describe them. They are
41
+ * deliberately the narrowest shape that works, because every field named here
42
+ * is a field a future version of that package could rename.
43
+ */
44
+ import type { AuditEvent } from "../core/types.ts";
45
+ /** The slice of `Span` this file touches. Satisfied by the real one. */
46
+ export interface AuditSpan {
47
+ setStatus(status: {
48
+ code: number;
49
+ message?: string;
50
+ }): unknown;
51
+ end(endTime?: number): void;
52
+ }
53
+ /** The slice of `Tracer` this file touches. Satisfied by the real one. */
54
+ export interface AuditTracer {
55
+ startSpan(name: string, options?: {
56
+ startTime?: number;
57
+ attributes?: Record<string, string | number | boolean>;
58
+ }): AuditSpan;
59
+ }
60
+ export interface OtelAuditOptions {
61
+ /**
62
+ * Put each argument on the span as `driverkit.arg.<name>`. Default: true.
63
+ *
64
+ * Off is for a host whose tracing backend bills by attribute, or whose verbs
65
+ * take arguments it would rather keep out of a vendor's index even after the
66
+ * core's redaction. It is not a redaction mechanism and must not be used as
67
+ * one: `ArgSpec.sensitive` is, and it works on every sink rather than this
68
+ * one. See `ArgSpec.sensitive`.
69
+ */
70
+ args?: boolean;
71
+ /**
72
+ * The span name prefix. Default: `"driverkit"`, giving `driverkit accept-selected`.
73
+ *
74
+ * Prefix-and-verb rather than one constant name, because a verb list is
75
+ * STATIC — the same handful of names for every user forever, which is the
76
+ * whole premise of the library — so it is exactly the low-cardinality thing
77
+ * a span name is supposed to be, and it means a trace UI's "slowest
78
+ * operations" list is already a list of verbs.
79
+ */
80
+ prefix?: string;
81
+ }
82
+ /**
83
+ * An `AuditHook` that turns each record into one span.
84
+ *
85
+ * ```ts
86
+ * import { trace } from "@opentelemetry/api";
87
+ * import { otelAudit } from "driverkit/otel";
88
+ *
89
+ * mount({ ..., onAudit: otelAudit(trace.getTracer("driverkit")) });
90
+ * ```
91
+ *
92
+ * ONE SPAN PER CALL, with real start and end times taken from the record, so
93
+ * the span's duration is the call's duration — approval included, which is the
94
+ * part of a gated bulk commit a reader most often wants back. The span is
95
+ * created and ended inside this function rather than wrapping the call,
96
+ * because the record arrives after the outcome is decided: there is no live
97
+ * context to parent into, and pretending otherwise would mean holding an open
98
+ * span across a verb and reporting a duration from a clock the core does not
99
+ * own.
100
+ *
101
+ * WHAT IT DOES NOT DO, and each one is a decision rather than an omission:
102
+ *
103
+ * It does not parent the span into the ambient context. A driverkit call
104
+ * arrives from a model turn, a relay frame or a click, and in the page there
105
+ * is no active span to attach to; a span nested under whatever happened to be
106
+ * active would claim a causal link the library cannot verify. An audit record
107
+ * is a standalone fact about an app, which is what a root span says.
108
+ *
109
+ * It does not mark a refusal as an error. A refusal is an ordinary outcome —
110
+ * `declined-by-user` is a person saying no and `stale-plan` is the safety
111
+ * mechanism working — and an exporter that painted those red would light up
112
+ * a dashboard for every correctly refused call, which is a warning on
113
+ * everything and therefore a warning on nothing. The slug is on the span as
114
+ * `driverkit.refused`, so filtering for one is a query. The ONE exception is
115
+ * `threw`, which is the core's word for the app's own code being broken, and
116
+ * which is an error in anybody's reading.
117
+ *
118
+ * It does not batch, retry or flush. The SDK the host registered does all
119
+ * three, and better.
120
+ */
121
+ export declare function otelAudit(tracer: AuditTracer, options?: OtelAuditOptions): (event: AuditEvent) => void;
122
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/otel/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAYnD,wEAAwE;AACxE,MAAM,WAAW,SAAS;IACxB,SAAS,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;IAC/D,GAAG,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,0EAA0E;AAC1E,MAAM,WAAW,WAAW;IAC1B,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;KACxD,GACA,SAAS,CAAC;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,gBAAqB,GAC7B,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAwD7B"}