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":"tools.js","sourceRoot":"","sources":["../../src/agent/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAKH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AAEzC,MAAM,WAAW,GACf,mFAAmF,CAAC;AACtF,MAAM,YAAY,GAChB,sFAAsF;IACtF,sCAAsC,CAAC;AAEzC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,SAAS,GAA2B;IACxC,IAAI,EACF,kFAAkF;QAClF,kFAAkF;QAClF,6BAA6B;IAC/B,QAAQ,EACN,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C,CAAC,CAAC;IACxD,CAAC;IAED,oEAAoE;IACpE,4EAA4E;IAC5E,6EAA6E;IAC7E,6EAA6E;IAC7E,oEAAoE;IACpE,uEAAuE;IACvE,EAAE;IACF,4EAA4E;IAC5E,6EAA6E;IAC7E,iBAAiB;IACjB,IAAI,QAAQ,CAAC,YAAY;QAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC7D,IAAI,YAAY;QAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAE3C,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["/**\n * The manifest, rendered as a tool list and a system prompt.\n *\n * **Nothing in this file knows the name of a single verb.** Each verb in the\n * manifest becomes one tool, its `args` become the tool's `inputSchema`, and\n * its `refuses` go into the description so a model can decline to make a call\n * that was always going to be declined. The app's verb table is the only\n * description of the app that exists, and it lives next to the code that\n * implements it.\n *\n * This is the twin of `tools_for`/`verb_tool` in\n * `python/src/driverkit/mcp_server.py`, and the notes below are the same\n * strings. The Python half renders for an MCP client driving the app from\n * outside; this half renders for a chatbot inside the page. A verb that is\n * described one way through MCP and another way in the widget is a bug: the\n * whole promise is that the app declares its capabilities once.\n *\n * Everything here is the STATIC half. It is a pure function of the manifest,\n * which the core guarantees does not vary between two users or two minutes, so\n * the output is byte-identical across every turn of every session of every\n * person using the app — which is what makes it worth caching in the prompt\n * prefix. Reaching into `driver.snapshot()` from this file would quietly undo\n * that for everybody; it is not imported here, which is the cheapest way to\n * make that impossible rather than merely discouraged.\n */\n\nimport type { ArgSpec, Manifest } from \"../core/index.ts\";\nimport type { JsonSchema, ToolSpec } from \"./types.ts\";\n\n/**\n * The one tool that is not a verb.\n *\n * It is the protocol's own read, not an app feature, and no app should have to\n * declare it. Verb names are kebab-case by the core's contract and this is\n * snake_case so they cannot collide; `toolsFor` checks anyway rather than\n * silently shadowing a verb.\n *\n * MCP's other hand-written tool, `list_tabs`, is deliberately absent. In-page\n * there is one app and it is the one the person is looking at; a tool that\n * lists tabs would invite a model to ask which tab it is driving, and the\n * honest answer is \"this one, there is no other\".\n */\nexport const READ_SCREEN = \"read_screen\";\n\nconst RESULT_NOTE =\n \"Returns the screen as it is AFTER this runs, so you do not need to read it again.\";\nconst REFUSAL_NOTE =\n \"A refusal is a normal answer, not an error: read the reason and change what you do, \" +\n \"rather than repeating the same call.\";\n\n/**\n * `kind` folded into the description, because it is the difference between a\n * call that is free to try and one that is irreversible, and nothing else in\n * the tool definition can express that. Asked to \"select the top 1000 and bulk\n * accept\", a model that cannot tell `select` from `accept` finds out by doing\n * it, and the finding out costs a thousand accepted rows.\n *\n * Verbatim from the Python half, including the asterisks around the commit\n * banner. It looks shouty in a source file and it is the one place in this\n * library where shouting is the correct engineering decision.\n *\n * `read` says \"changes no data and reports no count\" and no longer says\n * \"changes nothing\", because `go`, `open-contact` and `back` are reads and they\n * move the person's screen out from under them. The two things the sentence\n * must get right are the ones that decide whether the next call is safe; \"the\n * person will see it\" is said as well, because they will.\n */\nconst KIND_NOTE: Record<string, string> = {\n read:\n \"READ-ONLY: this changes no data and reports no count. Free to call, free to get \" +\n \"wrong. It may still move what the person is looking at — navigating is a read — \" +\n \"so they will see you do it.\",\n describe:\n \"DESCRIBE: this changes what is SELECTED and changes no data. \" +\n \"Safe to call — the worst outcome is the wrong rows highlighted. It reports a \" +\n \"`count` of what it matched; read that count before you commit to anything.\",\n commit:\n \"*** COMMIT: THIS CHANGES DATA AND MAY BE IRREVERSIBLE. ***\\n\" +\n \"Do not call it to find out what it does. If it acts on a selection, use the \" +\n \"app's `describe` verb first, check the `count` it reports is the number you \" +\n \"expect, and only then commit.\",\n // The fourth kind, and the only one whose cost is paid by somebody who is not\n // the app. `read` is \"free to call, free to get wrong\" and that sentence is\n // false here, so this one says what asking actually costs: a person's\n // attention, a capped allowance, and every other call blocked while the\n // question is open. The last sentence is the one the whole mechanism stands\n // on -- an answer is not an approval -- and it is here, in the cached half,\n // because a model that learns it from a refusal has already asked somebody\n // for permission it was never going to get. Verbatim from the Python half.\n ask:\n \"ASK: this puts a question to the person and their answer comes back as the result. \" +\n \"It changes no data and reports no count, and it is NOT free: it costs their \" +\n \"attention, the app may cap how many questions you get, and nothing else runs while \" +\n \"one is open. Ask when you cannot act without guessing, ask once, and ask the \" +\n \"narrowest question that unblocks you.\\n\" +\n \"An answer is not permission: a commit still goes to whoever approves commits here, \" +\n \"whatever they said to you.\",\n};\n\n/**\n * The commit banner for a commit the app says it can undo.\n *\n * A separate string rather than a sentence appended to the shouted one, and the\n * difference is the point. `set-setting(\"dense-rows\", \"true\")` and accepting\n * 3,412 contacts were both getting THIS CHANGES DATA AND MAY BE IRREVERSIBLE,\n * and a banner that appears on a page-size change is a banner a model learns to\n * read past — the same way a person learns to click Yes without reading. So the\n * reversible one is not shouted, and the irreversible one keeps its asterisks\n * and its capitals and goes on meaning something.\n *\n * It still says the data changes, because it does. `reversible` is a claim\n * about there being a way back, not that nobody minds.\n */\n/**\n * `consumes: \"plan\"` folded into the description.\n *\n * In the cached half for exactly the reason `refuses` and `screen` are: the\n * point is that the bare call is never made. A model that learns the pairing\n * here runs the `describe` first and keeps the token; a model that learns it\n * from a refusal has already spent a round trip, and on a commit it has spent\n * it in front of a person waiting for an answer.\n *\n * It says what the token is FOR and not merely that it is required, because\n * \"pass the plan\" reads as ceremony and gets dropped, while \"the number you\n * read is the number that moves\" is the reason it exists. Verbatim from the\n * Python half.\n */\nconst PLAN_NOTE =\n \"REQUIRES A PLAN. This acts on the selection, so it may only be called with the `plan` \" +\n \"token that the app's `describe` verb returned beside its `count`. Run that describe, read \" +\n \"the count, check it is the number the person asked for, and pass the `plan` straight back \" +\n \"here. If anything has moved the selection in between — the person ticked a row, data \" +\n \"arrived — this is refused as `stale-plan` and the refusal names both counts. Reading and \" +\n \"navigating do not move the selection and do not spend the plan, so go and confirm whatever \" +\n \"you are unsure of first. That is the point of the token: the number you read is the number \" +\n \"that moves.\";\n\nconst COMMIT_REVERSIBLE_NOTE =\n \"COMMIT (reversible): this changes data, and the app says the change can be undone. \" +\n \"Still a change the person will see, so do not call it to find out what it does; if it \" +\n \"acts on a selection, read the `count` from the app's `describe` verb first.\";\n\n/**\n * `screen` folded into the description.\n *\n * The tool list is the same on every screen — a verb list that changed with the\n * screen would bust the prompt prefix on every navigation, which is the cost\n * argument — so this sentence is how a model learns, in the cached half, that a\n * verb it can see will not work where it is standing. Exactly the argument for\n * putting `refuses` in here: the point is that the call is never made.\n *\n * A verb on several screens names them all, because naming one of three is\n * worse than naming none: a model told `next-page` is \"ONLY ON THE `contacts`\n * SCREEN\" will navigate away from the company list it was already standing on\n * to do something it could have done where it was. The one-screen wording is\n * byte-for-byte what it was before this could be a list, so no app's cached\n * prefix moved for a feature it does not use.\n */\nfunction screenNote(screen: string | string[]): string {\n const screens = Array.isArray(screen) ? screen : [screen];\n const quoted = screens.map((s) => `\\`${s}\\``);\n const where =\n quoted.length > 1\n ? `ONLY ON THE ${quoted.slice(0, -1).join(\", \")} AND ${quoted[quoted.length - 1]} SCREENS.`\n : `ONLY ON THE ${quoted[0]} SCREEN.`;\n return (\n `${where} The screen you are on is the \\`screen\\` line of ` +\n \"every screen you read. Called from anywhere else this is refused as `wrong-screen`, \" +\n \"and the refusal names where you are and where the verb lives.\"\n );\n}\n\n/**\n * One `ArgSpec` as one JSON Schema property.\n *\n * `oneOf` becomes `enum`. See the note on `JsonSchema`: the two names look\n * alike and the meanings diverge, and emitting JSON Schema's `oneOf` would\n * produce a schema that validates anything.\n */\nexport function argSchema(spec: ArgSpec): JsonSchema {\n if (spec.type !== \"string\" && spec.type !== \"number\" && spec.type !== \"boolean\") {\n // Thrown, not skipped. The core's three types are a closed set, so an\n // unknown one is a bug that should be loud here rather than become a\n // property no client will validate.\n throw new Error(`driverkit: unknown arg type ${JSON.stringify(spec.type)}`);\n }\n return {\n type: spec.type,\n description: spec.describe,\n ...(spec.oneOf ? { enum: spec.oneOf } : {}),\n };\n}\n\n/**\n * One manifest verb as one tool.\n *\n * `optional` is expressed by omission from `required`, which is how JSON\n * Schema says it; an `\"optional\": true` key would be ignored by every\n * validator and the argument would silently become mandatory.\n *\n * `rev` is added as an extra optional property on every verb. It is not an app\n * argument — it is `CallOptions.rev`, the staleness claim, hoisted into the\n * schema because a model has nowhere else to put it. Passing the `rev` it last\n * read is what turns \"act on a row somebody already moved\" into a clean\n * `stale` refusal, and in-page that is not a rare case: the person is sitting\n * right there, clicking, while the model thinks. A verb that declares its own\n * `rev` argument keeps it and does not get the hoisted one, because the app's\n * meaning wins over ours.\n */\nexport function verbTool(verb: Manifest[\"verbs\"][number]): ToolSpec {\n const args = verb.args ?? {};\n const properties: Record<string, JsonSchema> = {};\n const required: string[] = [];\n for (const [name, spec] of Object.entries(args)) {\n properties[name] = argSchema(spec);\n if (!spec.optional) required.push(name);\n }\n\n // NOT on an `ask`, and this is the one exception to hoisting them onto\n // everything.\n //\n // `rev` and `screen` are staleness claims about the screen a call acts on,\n // and a question acts on no screen: it puts text in front of a person and\n // returns what they typed. Offering them would be worse than merely wasteful.\n // The system prompt tells a model to quote the `rev` it is acting on, so a\n // model that has read its instructions WILL pass one here -- and then a\n // question gets refused `stale` because the person clicked a row while it was\n // being composed, which is the likeliest thing in the world when they are\n // sitting right there. A question refused for a reason that has nothing to do\n // with the question is the shape that teaches a model not to ask.\n const asking = verb.kind === \"ask\";\n\n if (!asking && !(\"rev\" in properties)) {\n properties.rev = {\n type: \"integer\",\n description:\n \"Optional. The `rev` from the last screen you read. If the screen has \" +\n \"moved since, the call is refused as `stale` instead of acting on \" +\n \"something you did not see. Omit it to skip that check.\",\n };\n }\n\n // Hoisted exactly as `rev` is, and for a failure `rev` does not catch: a\n // paging call sent with no rev once landed on a screen the agent had never\n // seen, paged a different company's list and answered `ok`. \"You are\n // somewhere else\" and \"the number moved\" are different mistakes with\n // different fixes, so they are different claims and different refusals.\n //\n // A verb with its own `screen` argument keeps it and does not get this one —\n // `go(screen)` is a real verb in a real app — because the app's meaning wins\n // over ours. The same rule as `rev`.\n if (!asking && !(\"screen\" in properties)) {\n properties.screen = {\n type: \"string\",\n description:\n \"Optional. The `screen` from the last screen you read. If the app is on \" +\n \"another screen now, the call is refused as `wrong-screen` instead of acting \" +\n \"on a screen you never saw. Omit it to skip that check.\",\n };\n }\n\n // Hoisted like `rev` and `screen`, with one difference: ONLY onto a verb that\n // declares `consumes`. `rev` and `screen` are claims any verb can make, so\n // they go on everything; a plan token means nothing to a verb that does not\n // consume one, and adding the property to every tool in every app would move\n // every cached prompt prefix in the world for a feature those apps do not\n // use. That prefix is the cost argument the library is built on.\n //\n // NOT in `required`, although the core will refuse the call without it, and\n // that is deliberate. `required` moves the failure into the client's\n // validator, where the refusal's hint — which names both counts and spells\n // out the pairing — never reaches the model. This library's stance throughout\n // is that an agent learns from a refusal it can act on, so the schema stays\n // permissive and the core is strict. The description says it is required.\n if (verb.consumes === \"plan\" && !(\"plan\" in properties)) {\n properties.plan = {\n type: \"string\",\n description:\n \"Required. The `plan` token from the `describe` verb that counted this \" +\n \"selection, passed back exactly as it was given. Without it the call is \" +\n \"refused as `stale-plan`, and so is a token taken before the selection moved.\",\n };\n }\n\n const description = [verb.describe];\n if (verb.kind === \"commit\" && verb.reversible) {\n // Checked before the table, so a reversible commit reads differently from\n // an irreversible one. `reversible` is read only here, on a `commit`: on a\n // `read` or a `describe` it is a claim about nothing, and the app has\n // already said no data moves.\n description.push(COMMIT_REVERSIBLE_NOTE);\n } else if (verb.kind && KIND_NOTE[verb.kind]) {\n // Second, straight after what the verb does and ahead of the mechanical\n // notes, so a model skimming the first two lines of a description cannot\n // miss that a verb commits. An unknown or absent kind adds nothing: this\n // package does not manufacture a safety claim the app did not make, in\n // either direction.\n description.push(KIND_NOTE[verb.kind]!);\n }\n // Third, above `screen`, because HOW a verb may be called outranks WHERE: a\n // model that goes to the right screen and calls the commit bare has still\n // lost the turn, and this is the sentence that stops it. Both still outrank\n // the mechanics.\n if (verb.consumes === \"plan\") description.push(PLAN_NOTE);\n if (verb.screen) description.push(screenNote(verb.screen));\n description.push(RESULT_NOTE);\n if (verb.refuses && verb.refuses.length) {\n // In the description rather than only in the error path, because this is\n // the half that gets cached in the prompt prefix: the point of `refuses`\n // is that a well-briefed agent never makes the call.\n description.push(\"May refuse: \" + verb.refuses.join(\", \") + \". \" + REFUSAL_NOTE);\n }\n\n return {\n name: verb.name,\n description: description.join(\"\\n\\n\"),\n inputSchema: {\n type: \"object\",\n properties,\n required,\n // The app named its own arguments; an extra one is a mistake worth\n // catching at the client rather than sending to a verb that will ignore\n // it.\n additionalProperties: false,\n },\n };\n}\n\n/** The whole tool list: every verb, then the one fixed read. */\nexport function toolsFor(manifest: Manifest): ToolSpec[] {\n const tools = manifest.verbs.map(verbTool);\n if (!tools.some((t) => t.name === READ_SCREEN)) {\n tools.push({\n name: READ_SCREEN,\n description:\n `Read what is on screen in ${manifest.app || \"the app\"} right now: where the ` +\n \"person is, the rows visible to them, what they have selected, and the `rev` to \" +\n \"quote back when you act.\\n\\n\" +\n \"You see exactly what the person at the keyboard sees — same filters, same page — \" +\n \"and nothing more. If a record you expect is missing, it is probably off screen \" +\n \"rather than absent.\\n\\n\" +\n \"You are given the screen at the start and after every verb, so you rarely need \" +\n \"this. Use it when the person may have clicked something while you were thinking, \" +\n \"or after anything unexpected: it is the cheapest tool here and the only way to \" +\n \"settle what actually happened.\",\n inputSchema: { type: \"object\", properties: {}, required: [], additionalProperties: false },\n });\n }\n return tools;\n}\n\n/**\n * The app's map, rendered for the model.\n *\n * `Manifest.screens` is the static list of every screen the app has, so this\n * belongs in the cached prefix beside the tool list rather than in any turn's\n * tail. What an agent could not do before this existed is learn that a screen\n * EXISTS without standing on it: `Snapshot.screen` says where it is and\n * `Verb.screen` says where a verb works, and between them there was still no\n * way to find out that a companies list is in there somewhere. The worked\n * example closed that gap by pasting a prose screen-map into `instructions`,\n * which is the same map the app's own route table already had, written a\n * second time in English with nothing checking that the two agree.\n *\n * The sentence about it being the same for every user is not padding. It is\n * the one thing a model cannot tell by looking: a list that might have been\n * filtered for this person is a list whose absences mean nothing, and an agent\n * that cannot trust the absences has to probe for screens anyway. See\n * `ScreenSpec`, which forbids filtering it, and which puts \"you may not open\n * that\" in the refusal where it can be read.\n *\n * Verbatim from the Python half.\n */\nexport function screensNote(screens: NonNullable<Manifest[\"screens\"]>): string {\n const lines = [\n \"THE SCREENS THIS APP HAS. The same screens for every user, always — a screen listed \" +\n \"here exists whether or not you have been to it. Only which one is LIVE changes, and \" +\n \"that is the `screen` line of every screen you read. If you cannot get to one of \" +\n \"these, the app will tell you why when you try; it is never missing from this list.\",\n ];\n for (const screen of screens) {\n const needs = Object.keys(screen.args ?? {});\n lines.push(\n `- \\`${screen.id}\\`: ${screen.describe}` +\n (screen.url ? ` Address: \\`${screen.url}\\`.` : \"\") +\n (needs.length ? ` Needs: ${needs.map((n) => `\\`${n}\\``).join(\", \")}.` : \"\"),\n );\n }\n return lines.join(\"\\n\");\n}\n\n/**\n * One flow, rendered as the recipe it is.\n *\n * The id first and the `describe` on the same line, because the `describe` is\n * what a model picks a flow on — Microsoft's finding on selection across tool\n * groups is that the choice is made \"based on the plugin's description, not on\n * any of the individual functions\" — and the steps are what it follows once it\n * has picked. A `section` is printed once where it changes rather than on\n * every step, so a flow with phases reads as phases and a flow without one\n * costs nothing.\n *\n * TWO MARKS GO IN PARENTHESES AFTER THE VERB, and both are there so that a\n * model skimming five numbered lines can see the shape of the recipe without\n * reading every hint:\n *\n * OPTIONAL — a step with a `skipWhen`. Which steps carry the job and which\n * are there for the case where you do not already know the answer is\n * structural, and before the field it was a clause buried mid-hint.\n *\n * the plan handoff — a step whose verb consumes a plan, pointing at the\n * numbered step whose `describe` mints it. DERIVED, not declared: it is read\n * off `Verb.kind` and `Verb.consumes`, which the manifest already carries, so\n * there is nothing for an author to keep in step and nothing claimed here\n * that `mount()` has not already refused to let through. It is the one value\n * that crosses two steps in this library — see `FlowStep` for why there is no\n * general way to say \"pass step 2's output into step 3\".\n *\n * Verbatim from the Python half.\n */\nfunction renderFlow(\n flow: NonNullable<Manifest[\"flows\"]>[number],\n verbs: Manifest[\"verbs\"],\n): string {\n const lines = [`\\`${flow.id}\\` — ${flow.describe}`];\n let section: string | undefined;\n // The numbered step whose `describe` verb last minted a plan token, so the\n // mark can name it. Updated AFTER the current step is rendered: a describe\n // does not consume its own plan.\n let minted: number | undefined;\n flow.steps.forEach((step, i) => {\n if (step.section && step.section !== section) lines.push(` (${step.section})`);\n section = step.section;\n const verb = verbs.find((v) => v.name === step.verb);\n const marks: string[] = [];\n if (step.skipWhen) marks.push(`OPTIONAL — skip it when ${step.skipWhen}`);\n if (verb?.consumes === \"plan\" && minted !== undefined) {\n marks.push(`takes the \\`plan\\` token step ${minted} returned`);\n }\n const mark = marks.length ? ` (${marks.join(\"; \")})` : \"\";\n lines.push(` ${i + 1}. \\`${step.verb}\\`${mark} — ${step.hint}`);\n if (verb?.kind === \"describe\") minted = i + 1;\n });\n return lines.join(\"\\n\");\n}\n\n/**\n * The app's flows, rendered for the model.\n *\n * THE SENTENCE THAT MATTERS is the one saying there is no tool that runs a\n * flow. A model handed a list of numbered steps will look for the button, and\n * not finding one it may well decide the flow is unavailable; being told that\n * following the steps IS the mechanism, and why, is what turns a list into an\n * instruction. The why is honest and is the design: a flow that executed\n * internally could not adapt when step three found the record already\n * accepted, and the agent would get back an `ok` that told it nothing. Apple's\n * app skills say the same thing about themselves — \"Skills don't enforce\n * deterministic behavior, and Siri doesn't run the listed intents in sequence.\"\n *\n * Static, so it rides in the prefix that was already being cached and costs\n * nothing per turn. Verbatim from the Python half.\n */\nexport function flowsNote(\n flows: NonNullable<Manifest[\"flows\"]>,\n verbs: Manifest[\"verbs\"] = [],\n): string {\n return (\n \"THE JOBS THIS APP SAYS ITS VERBS ARE USUALLY COMBINED INTO. Each one is a recipe for \" +\n \"YOU to carry out with the verbs you already have. **There is no tool that runs a \" +\n \"flow**, and that is deliberate: following the steps yourself means you see what each \" +\n \"one actually returned and can change course, which something running them for you \" +\n \"could not. Take the steps in order, read what each verb reports before the next, and \" +\n \"depart from the recipe when the screen says something it did not expect — then say so.\" +\n // The sentence about OPTIONAL steps is added only when some step actually\n // is one. Everything in here rides in the cached prefix of every session of\n // every user, and a paragraph about a construct the app does not use is the\n // kind of cost that is real, paid once, and invisible -- which is the exact\n // cost `SIZE_LIMITS` exists to make somebody weigh. An app whose flows mark\n // nothing optional gets the note it got before the field existed.\n (flows.some((f) => f.steps.some((s) => s.skipWhen))\n ? \" A step marked OPTIONAL may be skipped when the condition beside it holds, and \" +\n \"that condition is a sentence for you to judge, not a rule something checks: when \" +\n \"it is not clearly true, take the step.\"\n : \"\") +\n \"\\n\\n\" +\n flows.map((f) => renderFlow(f, verbs)).join(\"\\n\\n\")\n );\n}\n\n/**\n * The system prompt. A pure function of the manifest — including the app's own\n * `Manifest.instructions` — and the host's static `instructions`, and of\n * nothing else.\n *\n * Mirrors the MCP server's `initialize` instructions, with the differences\n * that are actually true in-page: there is no relay, no tab to pick, and the\n * person whose screen this is can see every word of what happens next.\n *\n * The screen is NOT in here, and that is the rule this function exists to\n * enforce. It is the uncached half; putting it in the system prompt would mean\n * re-sending and re-paying for the entire prefix on every single turn, which\n * is the exact cost the static/dynamic split was designed to avoid. It goes in\n * the newest message instead — see `loop.ts`.\n */\nexport function systemPrompt(\n manifest: Manifest,\n instructions?: string,\n /**\n * `DriveOptions.timing`, so the note about what a `took:` line means is paid\n * for ONCE, in the half a provider caches, instead of once per call.\n *\n * Absent and `\"off\"` are the same thing and add nothing: a caller from before\n * timing existed gets the byte-identical prompt it got before, which is what\n * keeps every existing eval's cached prefix valid on upgrade.\n *\n * Still a pure function of its arguments, which is the property that matters\n * here more than any wording: `drive` computes this once, before the loop,\n * and `test/tools.test.ts` asserts it is byte-identical across turns.\n */\n timing: \"off\" | \"slow\" | \"always\" = \"off\",\n): string {\n const app = manifest.app || \"this app\";\n const parts = [\n `You are driving a live ${app} session: the page the person is looking at as you ` +\n \"read this. You act only through the verbs listed as your tools, which are this \" +\n \"app's own. You cannot click, type, scroll or see pixels, and you do not need to.\",\n\n \"Every verb returns the screen as it is AFTER it ran, so acting and looking are one \" +\n \"step. Never follow a verb with a read to find out what it did — you were just \" +\n \"told. Quote the `rev` from the screen you are acting on, so that if the person \" +\n \"clicks something while you are thinking you get a `stale` refusal instead of \" +\n \"changing a row you never saw.\",\n\n \"Every verb says what it does to the world. READ-ONLY changes no data and reports \" +\n \"no count — moving to another screen is a read, and the person watching will see \" +\n \"it. DESCRIBE changes what is selected and reports a `count` of what it matched. \" +\n \"COMMIT changes data; it may be irreversible, and a COMMIT that says it is \" +\n \"reversible can be undone but is still a change they will see.\\n\\n\" +\n \"Never commit on a selection whose count you have not read. The pairing is: run \" +\n \"the app's `describe` verb with the predicate, read the `count` it reports, check \" +\n \"that count is the number the person asked for, and only then run the `commit` \" +\n \"verb — which takes no predicate and acts on the current selection. If the count \" +\n \"is not what you expected, stop and say so in plain words. Asked to accept a \" +\n \"thousand rows, accepting fifty thousand because a filter was wider than anybody \" +\n \"thought is the single worst thing you can do here, and checking the count is how \" +\n \"you avoid it.\\n\\n\" +\n \"Some commit verbs say they REQUIRE A PLAN. Those return a `plan` token beside the \" +\n \"`count` of the describe that counted them, and you pass it straight back. Do not \" +\n \"hold one over for later and do not reuse one: a plan is good for one commit and \" +\n \"only while nothing has moved the selection. Looking is free: reading a screen or \" +\n \"navigating to another one leaves the plan good, so go back and confirm anything you \" +\n \"are unsure of before an irreversible commit. `stale-plan` means the rows changed \" +\n \"under you — it names the count you were shown and the count there is now — so run \" +\n \"the describe again, read the new number, and say it out loud before you commit to \" +\n \"it. That refusal is not an obstacle; it is the one that stops you from accepting a \" +\n \"set the person never agreed to.\",\n\n \"A refusal is a normal answer, not an error. Read the reason and do something \" +\n \"different; repeating the same call unchanged will get the same answer. If you \" +\n \"cannot find a way through, say so — the person is right there and can do it \" +\n \"themselves or tell you what you are missing.\",\n\n \"You can do exactly what that person could do, and nothing more. You also see \" +\n \"exactly what they see — same filters, same sort, same page — so a record you \" +\n \"expect and cannot find is probably off screen rather than absent; use the app's \" +\n \"own paging verb the way a person would.\",\n\n \"When you are finished, answer in prose and say what you did. A message with no \" +\n \"verb call ends your turn. Keep it short: this is rendered in a small panel in \" +\n \"the corner of the person's screen.\",\n ];\n\n // The paragraph about asking, and only for an app that CAN ask.\n //\n // Conditional for the reason the screens note and the flows note are: this\n // text rides in the cached prefix of every session of every user, and a\n // paragraph about a tool the app has not got is a cost that is real, paid\n // once per person, and invisible -- which is what `SIZE_LIMITS` exists to make\n // somebody weigh. It is also worse than merely wasteful: a model told to ask\n // rather than guess, in an app with no way to ask, has been told to do\n // something it cannot do.\n //\n // Read off `kind` and not off the verb's NAME, because the kind is the\n // structural fact -- only the core mints it -- and a name check would also\n // match an app's own verb called `ask`, which has none of the guarantees this\n // paragraph describes. Still a pure function of the static manifest, so the\n // prefix stays byte-identical across every turn of the run.\n //\n // It goes after the safety rules and before the map, the recipes and the\n // app's own words, because it is one of the library's rules rather than\n // something about this app -- the same position, and the same argument, as\n // the paragraph about the plan token.\n if (manifest.verbs.some((v) => v.kind === \"ask\")) {\n parts.push(\n \"WHEN YOU DO NOT KNOW, ASK INSTEAD OF GUESSING. This app gives you a verb that puts \" +\n \"a question to the person and hands you their answer as its result. Use it when an \" +\n \"instruction cannot be carried out without deciding something they did not say: two \" +\n \"records match the name they used, nothing is selected and you do not know which \" +\n \"rows they meant, the company they named is not in the app. Picking the likeliest \" +\n \"one is the expensive mistake even when you pick right, because you did not know \\u2014 \" +\n \"and selecting something so that a commit has rows to act on is the worst version \" +\n \"of it.\\n\\n\" +\n \"Asking is not free. Each question interrupts somebody, the app may cap how many \" +\n \"you get, and nothing else runs while one is open \\u2014 so ask once, ask the narrowest \" +\n \"question that unblocks you, and put what you already know into it. If no answer \" +\n \"comes back, `ask-unanswered` means nobody replied and nothing changed: do not \" +\n \"invent one. `nobody-to-ask` and `asks-spent` both mean no further question will \" +\n \"reach anybody on this run, so stop asking \\u2014 decide what you honestly can, and say \" +\n \"in your final answer what you needed to know and could not settle.\\n\\n\" +\n \"**An answer is never permission.** A question of yours is not the confirmation a \" +\n \"commit needs: that is asked separately, by this app, and a yes to something you \" +\n \"asked authorises nothing. Never use the question verb to ask for approval, and \" +\n \"never report a change as approved because an answer sounded like one.\",\n );\n }\n\n // How to read a `took:` line, said once in the cached half rather than\n // beside every duration. Two wordings because the two modes mean different\n // things BY SILENCE, and silence is the half a model gets wrong: under\n // `\"slow\"` a call with no line was fast, and under `\"always\"` a call with no\n // line is one where the clock said nothing. A model that read the first as\n // the second would refuse to answer \"which is faster\" on a run where every\n // call was quick, which is the commonest version of the question.\n //\n // Both say that the figure is approximate and that a person's deciding time\n // is not in it, because those are the two ways a model misuses a duration:\n // reporting scheduler noise as a difference, and concluding an app is slow\n // when somebody was reading a dialog.\n if (timing === \"slow\") {\n parts.push(\n \"Some results carry a `took:` line, which is roughly how long that verb took in the \" +\n \"app. It is rounded, so treat `~2s` and `~3s` as about the same and do not report \" +\n \"differences smaller than the rounding. It counts only the app's own work: time \" +\n \"somebody spent reading a confirmation is not in it. A result with NO `took:` line \" +\n \"took under a second — that is the only reason the line is missing, so \\\"it was \" +\n \"fast\\\" is a true answer about those calls. If you are asked which of two things is \" +\n \"slower, you may answer from these lines; say they are approximate.\",\n );\n } else if (timing === \"always\") {\n parts.push(\n \"Every result carries a `took:` line: roughly how long that verb took in the app. It \" +\n \"is rounded, so treat `~0.4s` and `~0.5s` as about the same and do not report \" +\n \"differences smaller than the rounding. It counts only the app's own work: time \" +\n \"somebody spent reading a confirmation is not in it. If you are asked which of two \" +\n \"things is slower, answer from these lines and say they are approximate.\",\n );\n }\n\n // The map and the recipes, between the library's rules and the app's own\n // words. Both are pure functions of the static manifest, so the prefix stays\n // byte-identical across every turn of every session of every user -- which\n // is the only reason either of them is affordable at all. They go AFTER the\n // safety rules, because a recipe is a thing to do within those rules and not\n // an exception to them, and BEFORE `instructions`, because whichever text is\n // last is the one a model follows when two of them disagree and the app's\n // own voice should outrank a list the core rendered.\n if (manifest.screens && manifest.screens.length) parts.push(screensNote(manifest.screens));\n if (manifest.flows && manifest.flows.length) {\n parts.push(flowsNote(manifest.flows, manifest.verbs));\n }\n\n // The app's own briefing, then the host's. Both last, not first: an\n // app-specific note is an addition to these rules and not a replacement for\n // them, and a model reading in order should meet the safety rules before the\n // local colour. Both static — see `Manifest.instructions`, which is where an\n // app says the thing it needs BOTH paths to hear, and `DriveOptions\n // .instructions`, which is this host's own and reaches only this path.\n //\n // The app's goes first of the two because the host embedding the app is the\n // more specific voice, and whichever is last is the one a model follows when\n // they disagree.\n if (manifest.instructions) parts.push(manifest.instructions);\n if (instructions) parts.push(instructions);\n\n return parts.join(\"\\n\\n\");\n}\n"]}