@buoy-gg/agent-core 7.0.41 → 7.0.42

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 (201) hide show
  1. package/lib/commonjs/blocks/receipts.js +1 -761
  2. package/lib/commonjs/blocks/runId.js +1 -31
  3. package/lib/commonjs/blocks/types.js +1 -140
  4. package/lib/commonjs/blocks/uiTool.js +6 -1405
  5. package/lib/commonjs/catalog/catalog.g.js +5 -4556
  6. package/lib/commonjs/catalog/catalog.source.json +249 -0
  7. package/lib/commonjs/catalog/catalog.types.g.js +1 -46
  8. package/lib/commonjs/catalog/normalizeParams.js +2 -332
  9. package/lib/commonjs/catalog/signature.js +1 -68
  10. package/lib/commonjs/catalog/snapshotReads.js +1 -263
  11. package/lib/commonjs/catalog/toProviderTools.js +2 -145
  12. package/lib/commonjs/catalog/validateParams.js +1 -129
  13. package/lib/commonjs/context/buildContextPack.js +1 -489
  14. package/lib/commonjs/effects/digest.js +1 -34
  15. package/lib/commonjs/effects/ledger.js +1 -345
  16. package/lib/commonjs/engine/askGate.js +1 -287
  17. package/lib/commonjs/engine/effectFor.js +1 -223
  18. package/lib/commonjs/engine/evidence.js +3 -111
  19. package/lib/commonjs/engine/historyBudget.js +1 -363
  20. package/lib/commonjs/engine/retrieve.js +1 -214
  21. package/lib/commonjs/engine/runAgentTurn.js +8 -1836
  22. package/lib/commonjs/engine/systemPrompt.js +54 -163
  23. package/lib/commonjs/engine/textToolCalls.js +1 -276
  24. package/lib/commonjs/engine/tokenCalibration.js +1 -81
  25. package/lib/commonjs/engine/verify.js +4 -297
  26. package/lib/commonjs/index.js +1 -384
  27. package/lib/commonjs/policy/labels.js +1 -319
  28. package/lib/commonjs/policy/policy.js +1 -148
  29. package/lib/commonjs/policy/redact.js +1 -172
  30. package/lib/commonjs/providers/anthropic.js +3 -445
  31. package/lib/commonjs/providers/openai.js +4 -324
  32. package/lib/commonjs/providers/problem.js +1 -98
  33. package/lib/commonjs/providers/sse.js +1 -240
  34. package/lib/commonjs/providers/streamTimer.js +1 -123
  35. package/lib/commonjs/providers/transport.js +1 -123
  36. package/lib/commonjs/providers/types.js +1 -6
  37. package/lib/commonjs/providers/xhrStream.js +1 -212
  38. package/lib/commonjs/realNow.js +1 -0
  39. package/lib/commonjs/session.js +1 -393
  40. package/lib/commonjs/types.js +0 -1
  41. package/lib/module/blocks/receipts.js +1 -755
  42. package/lib/module/blocks/runId.js +1 -26
  43. package/lib/module/blocks/types.js +1 -134
  44. package/lib/module/blocks/uiTool.js +6 -1396
  45. package/lib/module/catalog/catalog.g.js +5 -4552
  46. package/lib/module/catalog/catalog.source.json +249 -0
  47. package/lib/module/catalog/catalog.types.g.js +1 -42
  48. package/lib/module/catalog/normalizeParams.js +2 -326
  49. package/lib/module/catalog/signature.js +1 -63
  50. package/lib/module/catalog/snapshotReads.js +1 -259
  51. package/lib/module/catalog/toProviderTools.js +2 -139
  52. package/lib/module/catalog/validateParams.js +1 -124
  53. package/lib/module/context/buildContextPack.js +1 -485
  54. package/lib/module/effects/digest.js +1 -29
  55. package/lib/module/effects/ledger.js +1 -339
  56. package/lib/module/engine/askGate.js +1 -280
  57. package/lib/module/engine/effectFor.js +1 -220
  58. package/lib/module/engine/evidence.js +3 -105
  59. package/lib/module/engine/historyBudget.js +1 -355
  60. package/lib/module/engine/retrieve.js +1 -210
  61. package/lib/module/engine/runAgentTurn.js +8 -1827
  62. package/lib/module/engine/systemPrompt.js +54 -157
  63. package/lib/module/engine/textToolCalls.js +1 -270
  64. package/lib/module/engine/tokenCalibration.js +1 -75
  65. package/lib/module/engine/verify.js +4 -289
  66. package/lib/module/index.js +1 -35
  67. package/lib/module/policy/labels.js +1 -312
  68. package/lib/module/policy/policy.js +1 -142
  69. package/lib/module/policy/redact.js +1 -165
  70. package/lib/module/providers/anthropic.js +3 -441
  71. package/lib/module/providers/openai.js +4 -320
  72. package/lib/module/providers/problem.js +1 -92
  73. package/lib/module/providers/sse.js +1 -231
  74. package/lib/module/providers/streamTimer.js +1 -118
  75. package/lib/module/providers/transport.js +1 -119
  76. package/lib/module/providers/types.js +1 -4
  77. package/lib/module/providers/xhrStream.js +1 -207
  78. package/lib/module/realNow.js +1 -0
  79. package/lib/module/session.js +1 -369
  80. package/lib/module/types.js +0 -1
  81. package/lib/typescript/catalog/catalog.g.d.ts +3 -3
  82. package/lib/typescript/catalog/catalog.types.g.d.ts +3 -2
  83. package/lib/typescript/providers/problem.d.ts +0 -20
  84. package/lib/typescript/providers/streamTimer.d.ts +0 -24
  85. package/lib/typescript/realNow.d.ts +18 -0
  86. package/lib/web/index.mjs +52 -53
  87. package/package.json +1 -1
  88. package/lib/commonjs/blocks/receipts.js.map +0 -1
  89. package/lib/commonjs/blocks/runId.js.map +0 -1
  90. package/lib/commonjs/blocks/types.js.map +0 -1
  91. package/lib/commonjs/blocks/uiTool.js.map +0 -1
  92. package/lib/commonjs/catalog/catalog.g.js.map +0 -1
  93. package/lib/commonjs/catalog/catalog.types.g.js.map +0 -1
  94. package/lib/commonjs/catalog/normalizeParams.js.map +0 -1
  95. package/lib/commonjs/catalog/signature.js.map +0 -1
  96. package/lib/commonjs/catalog/snapshotReads.js.map +0 -1
  97. package/lib/commonjs/catalog/toProviderTools.js.map +0 -1
  98. package/lib/commonjs/catalog/validateParams.js.map +0 -1
  99. package/lib/commonjs/context/buildContextPack.js.map +0 -1
  100. package/lib/commonjs/effects/digest.js.map +0 -1
  101. package/lib/commonjs/effects/ledger.js.map +0 -1
  102. package/lib/commonjs/engine/askGate.js.map +0 -1
  103. package/lib/commonjs/engine/effectFor.js.map +0 -1
  104. package/lib/commonjs/engine/evidence.js.map +0 -1
  105. package/lib/commonjs/engine/historyBudget.js.map +0 -1
  106. package/lib/commonjs/engine/retrieve.js.map +0 -1
  107. package/lib/commonjs/engine/runAgentTurn.js.map +0 -1
  108. package/lib/commonjs/engine/systemPrompt.js.map +0 -1
  109. package/lib/commonjs/engine/textToolCalls.js.map +0 -1
  110. package/lib/commonjs/engine/tokenCalibration.js.map +0 -1
  111. package/lib/commonjs/engine/verify.js.map +0 -1
  112. package/lib/commonjs/index.js.map +0 -1
  113. package/lib/commonjs/policy/labels.js.map +0 -1
  114. package/lib/commonjs/policy/policy.js.map +0 -1
  115. package/lib/commonjs/policy/redact.js.map +0 -1
  116. package/lib/commonjs/providers/anthropic.js.map +0 -1
  117. package/lib/commonjs/providers/openai.js.map +0 -1
  118. package/lib/commonjs/providers/problem.js.map +0 -1
  119. package/lib/commonjs/providers/sse.js.map +0 -1
  120. package/lib/commonjs/providers/streamTimer.js.map +0 -1
  121. package/lib/commonjs/providers/transport.js.map +0 -1
  122. package/lib/commonjs/providers/types.js.map +0 -1
  123. package/lib/commonjs/providers/xhrStream.js.map +0 -1
  124. package/lib/commonjs/session.js.map +0 -1
  125. package/lib/commonjs/types.js.map +0 -1
  126. package/lib/module/blocks/receipts.js.map +0 -1
  127. package/lib/module/blocks/runId.js.map +0 -1
  128. package/lib/module/blocks/types.js.map +0 -1
  129. package/lib/module/blocks/uiTool.js.map +0 -1
  130. package/lib/module/catalog/catalog.g.js.map +0 -1
  131. package/lib/module/catalog/catalog.types.g.js.map +0 -1
  132. package/lib/module/catalog/normalizeParams.js.map +0 -1
  133. package/lib/module/catalog/signature.js.map +0 -1
  134. package/lib/module/catalog/snapshotReads.js.map +0 -1
  135. package/lib/module/catalog/toProviderTools.js.map +0 -1
  136. package/lib/module/catalog/validateParams.js.map +0 -1
  137. package/lib/module/context/buildContextPack.js.map +0 -1
  138. package/lib/module/effects/digest.js.map +0 -1
  139. package/lib/module/effects/ledger.js.map +0 -1
  140. package/lib/module/engine/askGate.js.map +0 -1
  141. package/lib/module/engine/effectFor.js.map +0 -1
  142. package/lib/module/engine/evidence.js.map +0 -1
  143. package/lib/module/engine/historyBudget.js.map +0 -1
  144. package/lib/module/engine/retrieve.js.map +0 -1
  145. package/lib/module/engine/runAgentTurn.js.map +0 -1
  146. package/lib/module/engine/systemPrompt.js.map +0 -1
  147. package/lib/module/engine/textToolCalls.js.map +0 -1
  148. package/lib/module/engine/tokenCalibration.js.map +0 -1
  149. package/lib/module/engine/verify.js.map +0 -1
  150. package/lib/module/index.js.map +0 -1
  151. package/lib/module/policy/labels.js.map +0 -1
  152. package/lib/module/policy/policy.js.map +0 -1
  153. package/lib/module/policy/redact.js.map +0 -1
  154. package/lib/module/providers/anthropic.js.map +0 -1
  155. package/lib/module/providers/openai.js.map +0 -1
  156. package/lib/module/providers/problem.js.map +0 -1
  157. package/lib/module/providers/sse.js.map +0 -1
  158. package/lib/module/providers/streamTimer.js.map +0 -1
  159. package/lib/module/providers/transport.js.map +0 -1
  160. package/lib/module/providers/types.js.map +0 -1
  161. package/lib/module/providers/xhrStream.js.map +0 -1
  162. package/lib/module/session.js.map +0 -1
  163. package/lib/module/types.js.map +0 -1
  164. package/lib/typescript/blocks/receipts.d.ts.map +0 -1
  165. package/lib/typescript/blocks/runId.d.ts.map +0 -1
  166. package/lib/typescript/blocks/types.d.ts.map +0 -1
  167. package/lib/typescript/blocks/uiTool.d.ts.map +0 -1
  168. package/lib/typescript/catalog/catalog.g.d.ts.map +0 -1
  169. package/lib/typescript/catalog/catalog.types.g.d.ts.map +0 -1
  170. package/lib/typescript/catalog/normalizeParams.d.ts.map +0 -1
  171. package/lib/typescript/catalog/signature.d.ts.map +0 -1
  172. package/lib/typescript/catalog/snapshotReads.d.ts.map +0 -1
  173. package/lib/typescript/catalog/toProviderTools.d.ts.map +0 -1
  174. package/lib/typescript/catalog/validateParams.d.ts.map +0 -1
  175. package/lib/typescript/context/buildContextPack.d.ts.map +0 -1
  176. package/lib/typescript/effects/digest.d.ts.map +0 -1
  177. package/lib/typescript/effects/ledger.d.ts.map +0 -1
  178. package/lib/typescript/engine/askGate.d.ts.map +0 -1
  179. package/lib/typescript/engine/effectFor.d.ts.map +0 -1
  180. package/lib/typescript/engine/evidence.d.ts.map +0 -1
  181. package/lib/typescript/engine/historyBudget.d.ts.map +0 -1
  182. package/lib/typescript/engine/retrieve.d.ts.map +0 -1
  183. package/lib/typescript/engine/runAgentTurn.d.ts.map +0 -1
  184. package/lib/typescript/engine/systemPrompt.d.ts.map +0 -1
  185. package/lib/typescript/engine/textToolCalls.d.ts.map +0 -1
  186. package/lib/typescript/engine/tokenCalibration.d.ts.map +0 -1
  187. package/lib/typescript/engine/verify.d.ts.map +0 -1
  188. package/lib/typescript/index.d.ts.map +0 -1
  189. package/lib/typescript/policy/labels.d.ts.map +0 -1
  190. package/lib/typescript/policy/policy.d.ts.map +0 -1
  191. package/lib/typescript/policy/redact.d.ts.map +0 -1
  192. package/lib/typescript/providers/anthropic.d.ts.map +0 -1
  193. package/lib/typescript/providers/openai.d.ts.map +0 -1
  194. package/lib/typescript/providers/problem.d.ts.map +0 -1
  195. package/lib/typescript/providers/sse.d.ts.map +0 -1
  196. package/lib/typescript/providers/streamTimer.d.ts.map +0 -1
  197. package/lib/typescript/providers/transport.d.ts.map +0 -1
  198. package/lib/typescript/providers/types.d.ts.map +0 -1
  199. package/lib/typescript/providers/xhrStream.d.ts.map +0 -1
  200. package/lib/typescript/session.d.ts.map +0 -1
  201. package/lib/typescript/types.d.ts.map +0 -1
@@ -1,1399 +1,9 @@
1
- "use strict";
1
+ "use strict";import{validateParams as j}from"../catalog/validateParams";import{signature as x}from"../catalog/signature";import{idFactory as k}from"./runId";import{CAPS as c,MODEL_KINDS as u}from"./types";export const UI_TOOL_NAME="buoy_ui";const f={type:"string",enum:["muted","accent","warning","danger","info"]};const d={type:"object",properties:{label:{type:"string",description:"Button text, 1\u20134 words."},primary:{type:"boolean"},send:{type:"string",description:"Text sent as the user's next message when tapped."},dispatch:{type:"object",description:"A Buoy action to run when tapped \u2014 same policy and undo as if you called it.",properties:{toolId:{type:"string"},action:{type:"string"},params:{type:"object"}},required:["toolId","action"]},openTool:{type:"object",properties:{toolId:{type:"string"},select:{type:"string"}},required:["toolId"]},minimize:{type:"boolean",description:"Collapse the chat so the user can look at the app."}},required:["label"],additionalProperties:false};const v={anyOf:[{type:"string"},{type:"object",properties:{text:{type:"string"},tone:f},required:["text"]}]};export const UI_PARAMS={choice:{type:"object",properties:{question:{type:"string",description:"`title` is accepted as a synonym."},title:{type:"string",description:"Synonym for `question`."},options:{type:"array",maxItems:c.choiceOptions,items:{type:"object",properties:{id:{type:"string"},label:{type:"string"},detail:{type:"string"}},required:["id","label"]}},allowFreeText:{type:"boolean"}},required:["options"],additionalProperties:false},confirm:{type:"object",properties:{title:{type:"string",description:'Optional heading. Defaults to "Confirm".'},change:{type:"string",description:"What will change, in the user's words. `message` is accepted as a synonym."},message:{type:"string",description:"Synonym for `change`."},consequence:{type:"string"},approveLabel:{type:"string"},declineLabel:{type:"string"}},required:[],additionalProperties:false},input:{type:"object",properties:{label:{type:"string"},type:{type:"string",enum:["text","number","secret"]},placeholder:{type:"string"},submitLabel:{type:"string"}},required:["label"],additionalProperties:false},table:{type:"object",properties:{title:{type:"string"},columns:{type:"array",maxItems:4,items:{type:"string"}},rows:{type:"array",items:{type:"array",items:v}},total:{type:"number"}},required:["columns","rows"],additionalProperties:false},keyValue:{type:"object",properties:{title:{type:"string"},pairs:{type:"array",items:{type:"object",properties:{key:{type:"string"},value:{}},required:["key"]}}},required:["pairs"],additionalProperties:false},list:{type:"object",properties:{title:{type:"string"},items:{type:"array",items:{type:"object",properties:{id:{type:"string"},title:{type:"string"},subtitle:{type:"string"},trailing:{type:"string"},image:{type:"string",description:"Only a URL you read from the app in this conversation."},tone:f,action:d},required:["title"]}},total:{type:"number"}},required:["items"],additionalProperties:false},imageGrid:{type:"object",properties:{title:{type:"string"},images:{type:"array",maxItems:c.gridMax,items:{type:"object",properties:{url:{type:"string",description:"Only a URL you read from the app in this conversation."},alt:{type:"string",description:"What the picture IS \u2014 the name. Shown as the tile's heading and read by VoiceOver. `title` is accepted as a synonym; when neither is given it is filled from the caption or the file name."},caption:{type:"string",description:"The line under the name \u2014 stats, price, status."}},required:["url"]}},total:{type:"number"}},required:["images"],additionalProperties:false},diff:{type:"object",properties:{title:{type:"string"},changes:{type:"array",items:{type:"object",properties:{path:{type:"string"},before:{},after:{}},required:["path"]}}},required:["changes"],additionalProperties:false},chart:{type:"object",properties:{title:{type:"string"},bars:{type:"array",maxItems:c.chartBars,items:{type:"object",properties:{label:{type:"string"},value:{type:"number"},unit:{type:"string"},tone:f},required:["label","value"]}},max:{type:"number"}},required:["bars"],additionalProperties:false},steps:{type:"object",properties:{title:{type:"string"},steps:{type:"array",items:{type:"object",properties:{text:{type:"string"},state:{type:"string",enum:["todo","done","failed"]}},required:["text"]}}},required:["steps"],additionalProperties:false},code:{type:"object",properties:{title:{type:"string"},language:{type:"string",enum:["json","text"]},text:{type:"string"}},required:["text"],additionalProperties:false},actions:{type:"object",properties:{actions:{type:"array",maxItems:c.actions,items:d}},required:["actions"],additionalProperties:false},suggestions:{type:"object",properties:{chips:{type:"array",maxItems:4,items:{type:"object",properties:{label:{type:"string"},send:{type:"string"}},required:["label"]}}},required:["chips"],additionalProperties:false},multiSelect:{type:"object",properties:{question:{type:"string"},options:{type:"array",maxItems:12,items:{type:"object",properties:{id:{type:"string"},label:{type:"string"},detail:{type:"string"}},required:["id","label"]}},min:{type:"number"},max:{type:"number"},submitLabel:{type:"string"}},required:["question","options"],additionalProperties:false},select:{type:"object",properties:{label:{type:"string"},options:{type:"array",maxItems:100,items:{type:"object",properties:{id:{type:"string"},label:{type:"string"},detail:{type:"string"}},required:["id","label"]}},searchable:{type:"boolean"}},required:["label","options"],additionalProperties:false},slider:{type:"object",properties:{label:{type:"string"},min:{type:"number"},max:{type:"number"},step:{type:"number"},value:{type:"number"},unit:{type:"string"}},required:["label","min","max"],additionalProperties:false},dateTime:{type:"object",properties:{label:{type:"string"},mode:{type:"string",enum:["date","time","datetime"]},presets:{type:"array",items:{type:"object",properties:{label:{type:"string"},value:{type:"string"}},required:["label","value"]}}},required:["label"],additionalProperties:false},form:{type:"object",properties:{title:{type:"string"},fields:{type:"array",maxItems:6,items:{type:"object"}},submitLabel:{type:"string"}},required:["fields"],additionalProperties:false},proposal:{type:"object",properties:{title:{type:"string"},change:{type:"string"},fields:{type:"array",maxItems:6,items:{type:"object"}},consequence:{type:"string"},approveLabel:{type:"string"}},required:["title","change","fields"],additionalProperties:false},claim:{type:"object",properties:{text:{type:"string"},sources:{type:"array",maxItems:4,items:{type:"object",properties:{label:{type:"string"},detail:{type:"string"}},required:["label"]}},verify:d},required:["text","sources"],additionalProperties:false},details:{type:"object",properties:{summary:{type:"string"},body:{type:"string"},open:{type:"boolean"}},required:["summary","body"],additionalProperties:false},compare:{type:"object",properties:{title:{type:"string"},left:{type:"object",properties:{title:{type:"string"},pairs:{type:"array",items:{type:"object"}}},required:["title","pairs"]},right:{type:"object",properties:{title:{type:"string"},pairs:{type:"array",items:{type:"object"}}},required:["title","pairs"]}},required:["left","right"],additionalProperties:false},card:{type:"object",properties:{title:{type:"string"},subtitle:{type:"string"},image:{type:"string"},facts:{type:"array",maxItems:6,items:{type:"object",properties:{label:{type:"string"},value:{type:"string"},tone:f},required:["label","value"]}},actions:{type:"array",maxItems:c.actions,items:d}},required:["title"],additionalProperties:false},cardCarousel:{type:"object",properties:{title:{type:"string"},cards:{type:"array",maxItems:8,items:{type:"object"}},total:{type:"number"}},required:["cards"],additionalProperties:false},sparkline:{type:"object",properties:{title:{type:"string"},series:{type:"array",maxItems:120,items:{type:"number"}},unit:{type:"string"},label:{type:"string"},current:{type:"number"}},required:["series"],additionalProperties:false},plan:{type:"object",properties:{title:{type:"string"},steps:{type:"array",maxItems:10,items:{type:"object",properties:{text:{type:"string"},state:{type:"string",enum:["todo","running","done","failed"]}},required:["text"]}},pending:{type:"boolean"},actions:{type:"array",maxItems:c.actions,items:d}},required:["title","steps"],additionalProperties:false},finding:{type:"object",properties:{title:{type:"string"},evidence:{type:"array",items:{type:"object",properties:{label:{type:"string"},value:{type:"string"},tone:f},required:["label","value"]}},actions:{type:"array",maxItems:c.actions,items:d}},required:["title","evidence"],additionalProperties:false}};const a=e=>!!e&&typeof e==="object"&&!Array.isArray(e);const y=e=>typeof e==="string"&&e.trim()?e.trim():void 0;const b=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40)||"option";const P={choice:{options:["choices","items"]},multiSelect:{options:["choices","items"],question:["title","label"]},select:{options:["choices","items"],label:["title","question"]},input:{label:["title","question","prompt"]},slider:{label:["title"]},dateTime:{label:["title"]},table:{rows:["data","items"],columns:["headers","header"]},keyValue:{pairs:["items","fields","rows","entries"]},list:{items:["rows","entries","data"]},imageGrid:{images:["items","urls","data","pictures"]},diff:{changes:["items","rows","diffs"]},chart:{bars:["items","data","values"]},steps:{steps:["items"]},code:{text:["code","content"]},actions:{actions:["items","buttons"]},suggestions:{chips:["items","suggestions","options","questions"]},finding:{evidence:["items","rows"]},claim:{text:["claim","statement"],sources:["items","evidence"]},details:{summary:["title","label"],body:["text","detail"]},card:{title:["name"]},cardCarousel:{cards:["items"]},sparkline:{series:["data","values","points"]},plan:{steps:["items"]},form:{fields:["items","inputs"]},proposal:{fields:["items","inputs"]}};function S(e,t){if(!t)return;for(const[i,r]of Object.entries(t)){if(e[i]!==void 0)continue;for(const o of r){if(e[o]===void 0)continue;e[i]=e[o];delete e[o];break}}}function n(e,t,i){const r=e[t];if(Array.isArray(r))e[t]=r.map(i)}function s(e,t,i){if(e[t]!==void 0)return;for(const r of i){if(e[r]===void 0)continue;e[t]=e[r];delete e[r];return}}const g=e=>{if(typeof e==="string")return{id:b(e),label:e};if(!a(e))return e;const t={...e};s(t,"label",["name","text","title"]);s(t,"id",["value","key"]);s(t,"detail",["description","subtitle"]);const i=y(t.label);if(i&&y(t.id)===void 0)t.id=b(i);return t};const m=e=>{if(typeof e==="string")return{label:e};if(!a(e))return e;const t={...e};s(t,"label",["name","text","title","question"]);return t};const h=e=>{if(typeof e==="string")return{text:e};if(!a(e))return e;const t={...e};s(t,"text",["label","title","step","description"]);return t};const I=e=>{if(typeof e==="string")return{url:e,alt:q(e)};if(!a(e))return e;const t={...e};s(t,"url",["image","src","uri","href"]);s(t,"alt",["title","name","label"]);s(t,"caption",["subtitle","description","detail"]);if(y(t.alt)===void 0){const i=y(t.url);t.alt=y(t.caption)??(i?q(i):"Image")}return t};function q(e){const t=e.split(/[?#]/)[0]??e;const i=t.split("/").filter(Boolean).pop()??"Image";return i.replace(/\.[a-z0-9]{1,5}$/i,"")||"Image"}const w=e=>{if(typeof e==="string")return{title:e};if(!a(e))return e;const t={...e};s(t,"title",["name","label"]);s(t,"subtitle",["description","detail","caption"]);s(t,"image",["url","thumbnail","img","src"]);s(t,"trailing",["value","right"]);return t};const A=e=>{if(!a(e))return e;const t={...e};s(t,"label",["name","title","key"]);s(t,"value",["count","amount","n"]);return t};const L=e=>{if(!a(e))return e;const t={...e};s(t,"key",["label","name","field"]);return t};const E=e=>{if(!a(e))return e;const t={...e};s(t,"label",["name","key","title"]);s(t,"value",["text","detail","description"]);return t};const O=e=>{if(!a(e))return e;const t={...e};s(t,"path",["field","key","name","label"]);s(t,"before",["from","old","previous"]);s(t,"after",["to","new","current"]);return t};const $={choice:e=>n(e,"options",g),multiSelect:e=>n(e,"options",g),select:e=>n(e,"options",g),suggestions:e=>n(e,"chips",m),actions:e=>n(e,"actions",m),steps:e=>n(e,"steps",h),plan:e=>{n(e,"steps",h);n(e,"actions",m)},imageGrid:e=>n(e,"images",I),list:e=>n(e,"items",w),chart:e=>n(e,"bars",A),diff:e=>n(e,"changes",O),claim:e=>n(e,"sources",m),finding:e=>{n(e,"evidence",E);n(e,"actions",m)},card:e=>n(e,"actions",m),keyValue:e=>{if(a(e.pairs)){e.pairs=Object.entries(e.pairs).map(([t,i])=>({key:t,value:i}))}n(e,"pairs",L)},table:e=>{const t=Array.isArray(e.columns)?e.columns.map(i=>String(i)):void 0;if(!t?.length)return;n(e,"rows",i=>{if(!a(i))return i;const r=Object.keys(i);return t.map(o=>i[o]??i[r.find(p=>p.toLowerCase()===o.toLowerCase())??""]??"")})},sparkline:e=>{n(e,"series",t=>{if(typeof t==="number")return t;if(typeof t==="string"&&t.trim()!==""&&Number.isFinite(Number(t))){return Number(t)}if(a(t)){const i=t.value??t.y??t.n;if(typeof i==="number")return i}return t})},code:e=>{const t=y(e.language)?.toLowerCase();if(t&&t!=="json"&&t!=="text")e.language="text"}};export function normaliseUiParams(e,t){const i=a(t)?{...t}:{};S(i,P[e]);$[e]?.(i);return i}export function uiParamsHelp(){const e=u.map(t=>`- ${t}: ${x(UI_PARAMS[t])}`).join("\n");return`The block's fields. \`*\` marks a required one; everything else is optional. Send EXACTLY these names \u2014 a field that is not listed is rejected.
2
2
 
3
- /**
4
- * `buoy_ui` — the one tool the model uses to SHOW or ASK instead of writing
5
- * prose. One tool with `action` as the block kind, like every other Buoy
6
- * tool, so tool selection stays good; the params are the block itself.
7
- *
8
- * Validation is the same `validateParams` every other action gets, and an
9
- * invalid block goes back as a schema error for self-correction. A valid
10
- * block is stamped with an id and yielded as a `block` event; an Ask block
11
- * also ends the turn (see runAgentTurn).
12
- */
13
- import { validateParams } from "../catalog/validateParams";
14
- import { signature } from "../catalog/signature";
15
- import { idFactory } from "./runId";
16
- import { CAPS, MODEL_KINDS } from "./types";
17
- export const UI_TOOL_NAME = "buoy_ui";
18
- const tone = {
19
- type: "string",
20
- enum: ["muted", "accent", "warning", "danger", "info"]
21
- };
22
- const action = {
23
- type: "object",
24
- properties: {
25
- label: {
26
- type: "string",
27
- description: "Button text, 1–4 words."
28
- },
29
- primary: {
30
- type: "boolean"
31
- },
32
- send: {
33
- type: "string",
34
- description: "Text sent as the user's next message when tapped."
35
- },
36
- dispatch: {
37
- type: "object",
38
- description: "A Buoy action to run when tapped — same policy and undo as if you called it.",
39
- properties: {
40
- toolId: {
41
- type: "string"
42
- },
43
- action: {
44
- type: "string"
45
- },
46
- params: {
47
- type: "object"
48
- }
49
- },
50
- required: ["toolId", "action"]
51
- },
52
- openTool: {
53
- type: "object",
54
- properties: {
55
- toolId: {
56
- type: "string"
57
- },
58
- select: {
59
- type: "string"
60
- }
61
- },
62
- required: ["toolId"]
63
- },
64
- minimize: {
65
- type: "boolean",
66
- description: "Collapse the chat so the user can look at the app."
67
- }
68
- },
69
- required: ["label"],
70
- additionalProperties: false
71
- };
72
- const cell = {
73
- anyOf: [{
74
- type: "string"
75
- }, {
76
- type: "object",
77
- properties: {
78
- text: {
79
- type: "string"
80
- },
81
- tone
82
- },
83
- required: ["text"]
84
- }]
85
- };
3
+ ${e}`}const C={choice:"ASK the user to pick one of 2\u20135 options when a request could mean different things. Ends your turn; their pick comes back as their next message.",confirm:"ASK before a change you are guessing at (a shape you haven't read, a user you invented, anything destructive). Ends your turn.",input:"ASK for one value you need (an order id, a quantity). Ends your turn.",table:"Show rows of comparable facts \u2014 prices before/after, requests, counts. \u22644 columns, \u22648 rows; put the rest in total.",keyValue:"Show one record's fields \u2014 a profile, a store's state, a stored value.",list:"Show several things with a title each \u2014 items, orders, users. Add image only from URLs you read. Each item may carry one action.",imageGrid:"Show pictures \u2014 menu items, loaded images. Only URLs you read from the app in this conversation; a URL you did not read is dropped. \u226424; grid up to 6, carousel after.",diff:"Show what changed: path, before, after. Use for compare questions and after any write.",chart:"Show numbers side by side as bars \u2014 render counts, timings, sizes. \u22648 bars.",steps:"Show a procedure or a plan as a checklist (to reproduce, to test).",code:"Show a raw value only when the user asked for the raw thing.",actions:"Offer up to two buttons for what to do next instead of writing 'say X and I'll\u2026'. Use send for a chat reply, dispatch to run an action directly, minimize to let them look at the app.",finding:"Report something worth filing: a title plus evidence rows (request \u2192 status, screen \u2192 what it showed). Add a button to reproduce or open the tool.",suggestions:"Offer 2\u20134 follow-up questions the user might ask next. Put it last.",multiSelect:"ASK the user to pick several (which stores, which keys). Ends your turn.",select:"ASK the user to pick one from a long list (routes, stores) \u2014 searchable. Ends your turn.",slider:"ASK for a number in a range (a delay, a quantity). Ends your turn.",dateTime:"ASK for a date or time. Ends your turn.",form:"ASK for several coupled values at once. Ends your turn.",proposal:"ASK to approve a change whose values the user may edit first. Ends your turn.",claim:"State one fact with the evidence chips it rests on and a Verify button that re-reads it.",details:"A collapsed detail the user can open \u2014 long explanations, raw values.",compare:"Two things side by side with differences highlighted.",card:"One entity: title, image, facts, up to two actions.",cardCarousel:"3\u20138 cards to scan and pick from (scenarios, snapshots, items).",sparkline:"A series over time \u2014 FPS, memory, request timing.",plan:"Before multi-step work: the steps you intend, with Go/Stop. Update states as you go."};export function uiProviderTool(){const e=u.join(" | ");const t=u.map(o=>`- ${o}: ${C[o]}`).join("\n");const i=`Show the user something richer than text, or ask them something. Blocks render inline in the chat BELOW your text, as the last thing in your answer \u2014 so say what is coming and what it means first, then let the block land. Never repeat its contents in the text. Kinds: ${e}.`;const r=`Rules: choice/confirm/input END your turn \u2014 send them last, alone, with no other tool calls, and the answer arrives as the user's next message. Never put URLs, ids or numbers in a block that you did not read from a tool result in this conversation. Prefer the smallest block that answers.`;return{name:UI_TOOL_NAME,description:`${i}
4
+ ${t}
86
5
 
87
- /** Per-kind param schemas. Keys are block kinds; `kind` itself is the `action`. */
88
- // Keyed by BlockKind, not ModelKind: the definitions for kinds that are no
89
- // longer offered to the model are kept so restoring one is adding its name
90
- // back to MODEL_KINDS. Only MODEL_KINDS decides what is offered.
91
- export const UI_PARAMS = {
92
- choice: {
93
- type: "object",
94
- properties: {
95
- question: {
96
- type: "string",
97
- description: "`title` is accepted as a synonym."
98
- },
99
- title: {
100
- type: "string",
101
- description: "Synonym for `question`."
102
- },
103
- options: {
104
- type: "array",
105
- maxItems: CAPS.choiceOptions,
106
- items: {
107
- type: "object",
108
- properties: {
109
- id: {
110
- type: "string"
111
- },
112
- label: {
113
- type: "string"
114
- },
115
- detail: {
116
- type: "string"
117
- }
118
- },
119
- required: ["id", "label"]
120
- }
121
- },
122
- allowFreeText: {
123
- type: "boolean"
124
- }
125
- },
126
- // `question` is satisfied by `title` too — see normaliseChoice. Same
127
- // lesson the confirm block cost us: a schema that rejects the obvious
128
- // synonym sends a model into a retry loop and the user is never asked.
129
- required: ["options"],
130
- additionalProperties: false
131
- },
132
- confirm: {
133
- type: "object",
134
- properties: {
135
- title: {
136
- type: "string",
137
- description: "Optional heading. Defaults to \"Confirm\"."
138
- },
139
- change: {
140
- type: "string",
141
- description: "What will change, in the user's words. `message` is accepted as a synonym."
142
- },
143
- message: {
144
- type: "string",
145
- description: "Synonym for `change`."
146
- },
147
- consequence: {
148
- type: "string"
149
- },
150
- approveLabel: {
151
- type: "string"
152
- },
153
- declineLabel: {
154
- type: "string"
155
- }
156
- },
157
- // ONLY `change` is required, and `message` satisfies it (see
158
- // normaliseConfirm). Requiring both `title` AND `change` while rejecting
159
- // `message` sent a live model into a four-attempt failure loop — it kept
160
- // sending the universal {title, message} shape, and the validator
161
- // answered "change: required" then "title: required", which reads as
162
- // contradictory. It gave up and the user never got asked.
163
- required: [],
164
- additionalProperties: false
165
- },
166
- input: {
167
- type: "object",
168
- properties: {
169
- label: {
170
- type: "string"
171
- },
172
- type: {
173
- type: "string",
174
- enum: ["text", "number", "secret"]
175
- },
176
- placeholder: {
177
- type: "string"
178
- },
179
- submitLabel: {
180
- type: "string"
181
- }
182
- },
183
- required: ["label"],
184
- additionalProperties: false
185
- },
186
- table: {
187
- type: "object",
188
- properties: {
189
- title: {
190
- type: "string"
191
- },
192
- columns: {
193
- type: "array",
194
- maxItems: 4,
195
- items: {
196
- type: "string"
197
- }
198
- },
199
- rows: {
200
- type: "array",
201
- items: {
202
- type: "array",
203
- items: cell
204
- }
205
- },
206
- total: {
207
- type: "number"
208
- }
209
- },
210
- required: ["columns", "rows"],
211
- additionalProperties: false
212
- },
213
- keyValue: {
214
- type: "object",
215
- properties: {
216
- title: {
217
- type: "string"
218
- },
219
- pairs: {
220
- type: "array",
221
- items: {
222
- type: "object",
223
- properties: {
224
- key: {
225
- type: "string"
226
- },
227
- value: {}
228
- },
229
- required: ["key"]
230
- }
231
- }
232
- },
233
- required: ["pairs"],
234
- additionalProperties: false
235
- },
236
- list: {
237
- type: "object",
238
- properties: {
239
- title: {
240
- type: "string"
241
- },
242
- items: {
243
- type: "array",
244
- items: {
245
- type: "object",
246
- properties: {
247
- id: {
248
- type: "string"
249
- },
250
- title: {
251
- type: "string"
252
- },
253
- subtitle: {
254
- type: "string"
255
- },
256
- trailing: {
257
- type: "string"
258
- },
259
- image: {
260
- type: "string",
261
- description: "Only a URL you read from the app in this conversation."
262
- },
263
- tone,
264
- action
265
- },
266
- required: ["title"]
267
- }
268
- },
269
- total: {
270
- type: "number"
271
- }
272
- },
273
- required: ["items"],
274
- additionalProperties: false
275
- },
276
- imageGrid: {
277
- type: "object",
278
- properties: {
279
- title: {
280
- type: "string"
281
- },
282
- images: {
283
- type: "array",
284
- maxItems: CAPS.gridMax,
285
- items: {
286
- type: "object",
287
- properties: {
288
- url: {
289
- type: "string",
290
- description: "Only a URL you read from the app in this conversation."
291
- },
292
- alt: {
293
- type: "string",
294
- description: "What the picture IS — the name. Shown as the tile's heading and read by VoiceOver. `title` is accepted as a synonym; when neither is given it is filled from the caption or the file name."
295
- },
296
- caption: {
297
- type: "string",
298
- description: "The line under the name — stats, price, status."
299
- }
300
- },
301
- // `alt` used to be required and models kept omitting it while
302
- // sending `title` instead, which cost a whole round to a field the
303
- // block can derive. See normaliseImages.
304
- required: ["url"]
305
- }
306
- },
307
- total: {
308
- type: "number"
309
- }
310
- },
311
- required: ["images"],
312
- additionalProperties: false
313
- },
314
- diff: {
315
- type: "object",
316
- properties: {
317
- title: {
318
- type: "string"
319
- },
320
- changes: {
321
- type: "array",
322
- items: {
323
- type: "object",
324
- properties: {
325
- path: {
326
- type: "string"
327
- },
328
- before: {},
329
- after: {}
330
- },
331
- required: ["path"]
332
- }
333
- }
334
- },
335
- required: ["changes"],
336
- additionalProperties: false
337
- },
338
- chart: {
339
- type: "object",
340
- properties: {
341
- title: {
342
- type: "string"
343
- },
344
- bars: {
345
- type: "array",
346
- maxItems: CAPS.chartBars,
347
- items: {
348
- type: "object",
349
- properties: {
350
- label: {
351
- type: "string"
352
- },
353
- value: {
354
- type: "number"
355
- },
356
- unit: {
357
- type: "string"
358
- },
359
- tone
360
- },
361
- required: ["label", "value"]
362
- }
363
- },
364
- max: {
365
- type: "number"
366
- }
367
- },
368
- required: ["bars"],
369
- additionalProperties: false
370
- },
371
- steps: {
372
- type: "object",
373
- properties: {
374
- title: {
375
- type: "string"
376
- },
377
- steps: {
378
- type: "array",
379
- items: {
380
- type: "object",
381
- properties: {
382
- text: {
383
- type: "string"
384
- },
385
- state: {
386
- type: "string",
387
- enum: ["todo", "done", "failed"]
388
- }
389
- },
390
- required: ["text"]
391
- }
392
- }
393
- },
394
- required: ["steps"],
395
- additionalProperties: false
396
- },
397
- code: {
398
- type: "object",
399
- properties: {
400
- title: {
401
- type: "string"
402
- },
403
- language: {
404
- type: "string",
405
- enum: ["json", "text"]
406
- },
407
- text: {
408
- type: "string"
409
- }
410
- },
411
- required: ["text"],
412
- additionalProperties: false
413
- },
414
- actions: {
415
- type: "object",
416
- properties: {
417
- actions: {
418
- type: "array",
419
- maxItems: CAPS.actions,
420
- items: action
421
- }
422
- },
423
- required: ["actions"],
424
- additionalProperties: false
425
- },
426
- suggestions: {
427
- type: "object",
428
- properties: {
429
- chips: {
430
- type: "array",
431
- maxItems: 4,
432
- items: {
433
- type: "object",
434
- properties: {
435
- label: {
436
- type: "string"
437
- },
438
- send: {
439
- type: "string"
440
- }
441
- },
442
- required: ["label"]
443
- }
444
- }
445
- },
446
- required: ["chips"],
447
- additionalProperties: false
448
- },
449
- multiSelect: {
450
- type: "object",
451
- properties: {
452
- question: {
453
- type: "string"
454
- },
455
- options: {
456
- type: "array",
457
- maxItems: 12,
458
- items: {
459
- type: "object",
460
- properties: {
461
- id: {
462
- type: "string"
463
- },
464
- label: {
465
- type: "string"
466
- },
467
- detail: {
468
- type: "string"
469
- }
470
- },
471
- required: ["id", "label"]
472
- }
473
- },
474
- min: {
475
- type: "number"
476
- },
477
- max: {
478
- type: "number"
479
- },
480
- submitLabel: {
481
- type: "string"
482
- }
483
- },
484
- required: ["question", "options"],
485
- additionalProperties: false
486
- },
487
- select: {
488
- type: "object",
489
- properties: {
490
- label: {
491
- type: "string"
492
- },
493
- options: {
494
- type: "array",
495
- maxItems: 100,
496
- items: {
497
- type: "object",
498
- properties: {
499
- id: {
500
- type: "string"
501
- },
502
- label: {
503
- type: "string"
504
- },
505
- detail: {
506
- type: "string"
507
- }
508
- },
509
- required: ["id", "label"]
510
- }
511
- },
512
- searchable: {
513
- type: "boolean"
514
- }
515
- },
516
- required: ["label", "options"],
517
- additionalProperties: false
518
- },
519
- slider: {
520
- type: "object",
521
- properties: {
522
- label: {
523
- type: "string"
524
- },
525
- min: {
526
- type: "number"
527
- },
528
- max: {
529
- type: "number"
530
- },
531
- step: {
532
- type: "number"
533
- },
534
- value: {
535
- type: "number"
536
- },
537
- unit: {
538
- type: "string"
539
- }
540
- },
541
- required: ["label", "min", "max"],
542
- additionalProperties: false
543
- },
544
- dateTime: {
545
- type: "object",
546
- properties: {
547
- label: {
548
- type: "string"
549
- },
550
- mode: {
551
- type: "string",
552
- enum: ["date", "time", "datetime"]
553
- },
554
- presets: {
555
- type: "array",
556
- items: {
557
- type: "object",
558
- properties: {
559
- label: {
560
- type: "string"
561
- },
562
- value: {
563
- type: "string"
564
- }
565
- },
566
- required: ["label", "value"]
567
- }
568
- }
569
- },
570
- required: ["label"],
571
- additionalProperties: false
572
- },
573
- form: {
574
- type: "object",
575
- properties: {
576
- title: {
577
- type: "string"
578
- },
579
- fields: {
580
- type: "array",
581
- maxItems: 6,
582
- items: {
583
- type: "object"
584
- }
585
- },
586
- submitLabel: {
587
- type: "string"
588
- }
589
- },
590
- required: ["fields"],
591
- additionalProperties: false
592
- },
593
- proposal: {
594
- type: "object",
595
- properties: {
596
- title: {
597
- type: "string"
598
- },
599
- change: {
600
- type: "string"
601
- },
602
- fields: {
603
- type: "array",
604
- maxItems: 6,
605
- items: {
606
- type: "object"
607
- }
608
- },
609
- consequence: {
610
- type: "string"
611
- },
612
- approveLabel: {
613
- type: "string"
614
- }
615
- },
616
- required: ["title", "change", "fields"],
617
- additionalProperties: false
618
- },
619
- claim: {
620
- type: "object",
621
- properties: {
622
- text: {
623
- type: "string"
624
- },
625
- sources: {
626
- type: "array",
627
- maxItems: 4,
628
- items: {
629
- type: "object",
630
- properties: {
631
- label: {
632
- type: "string"
633
- },
634
- detail: {
635
- type: "string"
636
- }
637
- },
638
- required: ["label"]
639
- }
640
- },
641
- verify: action
642
- },
643
- required: ["text", "sources"],
644
- additionalProperties: false
645
- },
646
- details: {
647
- type: "object",
648
- properties: {
649
- summary: {
650
- type: "string"
651
- },
652
- body: {
653
- type: "string"
654
- },
655
- open: {
656
- type: "boolean"
657
- }
658
- },
659
- required: ["summary", "body"],
660
- additionalProperties: false
661
- },
662
- compare: {
663
- type: "object",
664
- properties: {
665
- title: {
666
- type: "string"
667
- },
668
- left: {
669
- type: "object",
670
- properties: {
671
- title: {
672
- type: "string"
673
- },
674
- pairs: {
675
- type: "array",
676
- items: {
677
- type: "object"
678
- }
679
- }
680
- },
681
- required: ["title", "pairs"]
682
- },
683
- right: {
684
- type: "object",
685
- properties: {
686
- title: {
687
- type: "string"
688
- },
689
- pairs: {
690
- type: "array",
691
- items: {
692
- type: "object"
693
- }
694
- }
695
- },
696
- required: ["title", "pairs"]
697
- }
698
- },
699
- required: ["left", "right"],
700
- additionalProperties: false
701
- },
702
- card: {
703
- type: "object",
704
- properties: {
705
- title: {
706
- type: "string"
707
- },
708
- subtitle: {
709
- type: "string"
710
- },
711
- image: {
712
- type: "string"
713
- },
714
- facts: {
715
- type: "array",
716
- maxItems: 6,
717
- items: {
718
- type: "object",
719
- properties: {
720
- label: {
721
- type: "string"
722
- },
723
- value: {
724
- type: "string"
725
- },
726
- tone
727
- },
728
- required: ["label", "value"]
729
- }
730
- },
731
- actions: {
732
- type: "array",
733
- maxItems: CAPS.actions,
734
- items: action
735
- }
736
- },
737
- required: ["title"],
738
- additionalProperties: false
739
- },
740
- cardCarousel: {
741
- type: "object",
742
- properties: {
743
- title: {
744
- type: "string"
745
- },
746
- cards: {
747
- type: "array",
748
- maxItems: 8,
749
- items: {
750
- type: "object"
751
- }
752
- },
753
- total: {
754
- type: "number"
755
- }
756
- },
757
- required: ["cards"],
758
- additionalProperties: false
759
- },
760
- sparkline: {
761
- type: "object",
762
- properties: {
763
- title: {
764
- type: "string"
765
- },
766
- series: {
767
- type: "array",
768
- maxItems: 120,
769
- items: {
770
- type: "number"
771
- }
772
- },
773
- unit: {
774
- type: "string"
775
- },
776
- label: {
777
- type: "string"
778
- },
779
- current: {
780
- type: "number"
781
- }
782
- },
783
- required: ["series"],
784
- additionalProperties: false
785
- },
786
- plan: {
787
- type: "object",
788
- properties: {
789
- title: {
790
- type: "string"
791
- },
792
- steps: {
793
- type: "array",
794
- maxItems: 10,
795
- items: {
796
- type: "object",
797
- properties: {
798
- text: {
799
- type: "string"
800
- },
801
- state: {
802
- type: "string",
803
- enum: ["todo", "running", "done", "failed"]
804
- }
805
- },
806
- required: ["text"]
807
- }
808
- },
809
- pending: {
810
- type: "boolean"
811
- },
812
- actions: {
813
- type: "array",
814
- maxItems: CAPS.actions,
815
- items: action
816
- }
817
- },
818
- required: ["title", "steps"],
819
- additionalProperties: false
820
- },
821
- finding: {
822
- type: "object",
823
- properties: {
824
- title: {
825
- type: "string"
826
- },
827
- evidence: {
828
- type: "array",
829
- items: {
830
- type: "object",
831
- properties: {
832
- label: {
833
- type: "string"
834
- },
835
- value: {
836
- type: "string"
837
- },
838
- tone
839
- },
840
- required: ["label", "value"]
841
- }
842
- },
843
- actions: {
844
- type: "array",
845
- maxItems: CAPS.actions,
846
- items: action
847
- }
848
- },
849
- required: ["title", "evidence"],
850
- additionalProperties: false
851
- }
852
- };
6
+ ${r}`,summaryDescription:`${i}
853
7
 
854
- /* ------------------------------------------------------------------------ *
855
- * Accepting the shape models actually send.
856
- *
857
- * The same lesson as `catalog/normalizeParams.ts`, learned again on the block
858
- * tool: A MECHANICAL ALIAS MUST NEVER COST A TURN. Measured on a live device
859
- * (gateway #182-#184, gpt-4.1), one `imageGrid` + `suggestions` pair took
860
- * THREE rounds to land — `items` for `images`, `items` for `chips`, a missing
861
- * `alt`, then chips as bare strings. Half the turn, and because the model
862
- * rewrites its prose on every round the user read the same closing paragraph
863
- * four times.
864
- *
865
- * None of those were disagreements about meaning. They were field names, and
866
- * the model had never been shown them (see `uiProviderTool`, which now sends
867
- * the signatures). This layer covers the rest: the container the model reached
868
- * for, the item shape it flattened, the synonym it preferred.
869
- *
870
- * The rule for what belongs here: the correction has to be MECHANICAL — one
871
- * unambiguous reading, no guess about intent. Renaming `items` to `images` on
872
- * an imageGrid is mechanical. Inventing a caption is not.
873
- *
874
- * Runs BEFORE `validateParams`, unlike `normaliseChoice`/`normaliseConfirm`
875
- * below it, which predate this and work by listing their synonyms in the
876
- * schema instead. Pre-validation is the better seam: an alias renamed here
877
- * never has to appear in the schema at all, and `additionalProperties: false`
878
- * keeps its meaning.
879
- * ------------------------------------------------------------------------ */
880
-
881
- const isRec = v => !!v && typeof v === "object" && !Array.isArray(v);
882
- const text = v => typeof v === "string" && v.trim() ? v.trim() : undefined;
883
-
884
- /** `Ship it now` -> `ship-it-now`, for an option that arrived without an id. */
885
- const slug = label => label.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "option";
886
-
887
- /**
888
- * Canonical field name -> the names models send instead. Applied only when
889
- * the canonical field is absent, so a model that sent both keeps its own.
890
- */
891
- const FIELD_ALIASES = {
892
- choice: {
893
- options: ["choices", "items"]
894
- },
895
- multiSelect: {
896
- options: ["choices", "items"],
897
- question: ["title", "label"]
898
- },
899
- select: {
900
- options: ["choices", "items"],
901
- label: ["title", "question"]
902
- },
903
- input: {
904
- label: ["title", "question", "prompt"]
905
- },
906
- slider: {
907
- label: ["title"]
908
- },
909
- dateTime: {
910
- label: ["title"]
911
- },
912
- table: {
913
- rows: ["data", "items"],
914
- columns: ["headers", "header"]
915
- },
916
- keyValue: {
917
- pairs: ["items", "fields", "rows", "entries"]
918
- },
919
- list: {
920
- items: ["rows", "entries", "data"]
921
- },
922
- imageGrid: {
923
- images: ["items", "urls", "data", "pictures"]
924
- },
925
- diff: {
926
- changes: ["items", "rows", "diffs"]
927
- },
928
- chart: {
929
- bars: ["items", "data", "values"]
930
- },
931
- steps: {
932
- steps: ["items"]
933
- },
934
- code: {
935
- text: ["code", "content"]
936
- },
937
- actions: {
938
- actions: ["items", "buttons"]
939
- },
940
- suggestions: {
941
- chips: ["items", "suggestions", "options", "questions"]
942
- },
943
- finding: {
944
- evidence: ["items", "rows"]
945
- },
946
- claim: {
947
- text: ["claim", "statement"],
948
- sources: ["items", "evidence"]
949
- },
950
- details: {
951
- summary: ["title", "label"],
952
- body: ["text", "detail"]
953
- },
954
- card: {
955
- title: ["name"]
956
- },
957
- cardCarousel: {
958
- cards: ["items"]
959
- },
960
- sparkline: {
961
- series: ["data", "values", "points"]
962
- },
963
- plan: {
964
- steps: ["items"]
965
- },
966
- form: {
967
- fields: ["items", "inputs"]
968
- },
969
- proposal: {
970
- fields: ["items", "inputs"]
971
- }
972
- };
973
-
974
- /** Rename in place: `canonical <- first alias present`, canonical wins. */
975
- function applyAliases(params, aliases) {
976
- if (!aliases) return;
977
- for (const [canonical, alts] of Object.entries(aliases)) {
978
- if (params[canonical] !== undefined) continue;
979
- for (const alt of alts) {
980
- if (params[alt] === undefined) continue;
981
- params[canonical] = params[alt];
982
- delete params[alt];
983
- break;
984
- }
985
- }
986
- }
987
-
988
- /** Map one array field through a coercion, leaving a non-array untouched. */
989
- function eachItem(params, field, fn) {
990
- const arr = params[field];
991
- if (Array.isArray(arr)) params[field] = arr.map(fn);
992
- }
993
-
994
- /** Rename inside an item object, canonical wins — the per-item `applyAliases`. */
995
- function renameIn(item, canonical, alts) {
996
- if (item[canonical] !== undefined) return;
997
- for (const alt of alts) {
998
- if (item[alt] === undefined) continue;
999
- item[canonical] = item[alt];
1000
- delete item[alt];
1001
- return;
1002
- }
1003
- }
1004
-
1005
- /** `"Ship it"` or `{value,name}` -> `{id, label}`. Options carry a required id. */
1006
- const normaliseOption = raw => {
1007
- if (typeof raw === "string") return {
1008
- id: slug(raw),
1009
- label: raw
1010
- };
1011
- if (!isRec(raw)) return raw;
1012
- const item = {
1013
- ...raw
1014
- };
1015
- renameIn(item, "label", ["name", "text", "title"]);
1016
- renameIn(item, "id", ["value", "key"]);
1017
- renameIn(item, "detail", ["description", "subtitle"]);
1018
- const label = text(item.label);
1019
- if (label && text(item.id) === undefined) item.id = slug(label);
1020
- return item;
1021
- };
1022
-
1023
- /** `"Compare their HP"` -> `{label}`. Chips and buttons. */
1024
- const normaliseLabelled = raw => {
1025
- if (typeof raw === "string") return {
1026
- label: raw
1027
- };
1028
- if (!isRec(raw)) return raw;
1029
- const item = {
1030
- ...raw
1031
- };
1032
- renameIn(item, "label", ["name", "text", "title", "question"]);
1033
- return item;
1034
- };
1035
-
1036
- /** `"Open the bag"` -> `{text}`. Steps and plans. */
1037
- const normaliseStep = raw => {
1038
- if (typeof raw === "string") return {
1039
- text: raw
1040
- };
1041
- if (!isRec(raw)) return raw;
1042
- const item = {
1043
- ...raw
1044
- };
1045
- renameIn(item, "text", ["label", "title", "step", "description"]);
1046
- return item;
1047
- };
1048
-
1049
- /**
1050
- * The imageGrid item, and the only coercion here that fills a field rather
1051
- * than renaming one.
1052
- *
1053
- * `alt` is what the tile shows as its heading and what VoiceOver reads, so it
1054
- * cannot be empty — but every model reaches for `title` first, and refusing
1055
- * that cost a whole round on the wire. Derive it, in the order a person would:
1056
- * the name it gave, else the caption, else the file name it came from.
1057
- */
1058
- const normaliseImage = raw => {
1059
- if (typeof raw === "string") return {
1060
- url: raw,
1061
- alt: fileName(raw)
1062
- };
1063
- if (!isRec(raw)) return raw;
1064
- const item = {
1065
- ...raw
1066
- };
1067
- renameIn(item, "url", ["image", "src", "uri", "href"]);
1068
- renameIn(item, "alt", ["title", "name", "label"]);
1069
- renameIn(item, "caption", ["subtitle", "description", "detail"]);
1070
- if (text(item.alt) === undefined) {
1071
- const url = text(item.url);
1072
- item.alt = text(item.caption) ?? (url ? fileName(url) : "Image");
1073
- }
1074
- return item;
1075
- };
1076
-
1077
- /** `…/official-artwork/25.png?x=1` -> `25`. Last resort for a missing alt. */
1078
- function fileName(url) {
1079
- const path = url.split(/[?#]/)[0] ?? url;
1080
- const last = path.split("/").filter(Boolean).pop() ?? "Image";
1081
- return last.replace(/\.[a-z0-9]{1,5}$/i, "") || "Image";
1082
- }
1083
- const normaliseListItem = raw => {
1084
- if (typeof raw === "string") return {
1085
- title: raw
1086
- };
1087
- if (!isRec(raw)) return raw;
1088
- const item = {
1089
- ...raw
1090
- };
1091
- renameIn(item, "title", ["name", "label"]);
1092
- renameIn(item, "subtitle", ["description", "detail", "caption"]);
1093
- renameIn(item, "image", ["url", "thumbnail", "img", "src"]);
1094
- renameIn(item, "trailing", ["value", "right"]);
1095
- return item;
1096
- };
1097
- const normaliseBar = raw => {
1098
- if (!isRec(raw)) return raw;
1099
- const item = {
1100
- ...raw
1101
- };
1102
- renameIn(item, "label", ["name", "title", "key"]);
1103
- renameIn(item, "value", ["count", "amount", "n"]);
1104
- return item;
1105
- };
1106
- const normalisePair = raw => {
1107
- if (!isRec(raw)) return raw;
1108
- const item = {
1109
- ...raw
1110
- };
1111
- renameIn(item, "key", ["label", "name", "field"]);
1112
- return item;
1113
- };
1114
- const normaliseEvidence = raw => {
1115
- if (!isRec(raw)) return raw;
1116
- const item = {
1117
- ...raw
1118
- };
1119
- renameIn(item, "label", ["name", "key", "title"]);
1120
- renameIn(item, "value", ["text", "detail", "description"]);
1121
- return item;
1122
- };
1123
- const normaliseChange = raw => {
1124
- if (!isRec(raw)) return raw;
1125
- const item = {
1126
- ...raw
1127
- };
1128
- renameIn(item, "path", ["field", "key", "name", "label"]);
1129
- renameIn(item, "before", ["from", "old", "previous"]);
1130
- renameIn(item, "after", ["to", "new", "current"]);
1131
- return item;
1132
- };
1133
-
1134
- /**
1135
- * Per-kind fixes that are more than a rename. Each one is still mechanical:
1136
- * one reading, no guess about what the model meant.
1137
- */
1138
- const SHAPE_FIXES = {
1139
- choice: p => eachItem(p, "options", normaliseOption),
1140
- multiSelect: p => eachItem(p, "options", normaliseOption),
1141
- select: p => eachItem(p, "options", normaliseOption),
1142
- suggestions: p => eachItem(p, "chips", normaliseLabelled),
1143
- actions: p => eachItem(p, "actions", normaliseLabelled),
1144
- steps: p => eachItem(p, "steps", normaliseStep),
1145
- plan: p => {
1146
- eachItem(p, "steps", normaliseStep);
1147
- eachItem(p, "actions", normaliseLabelled);
1148
- },
1149
- imageGrid: p => eachItem(p, "images", normaliseImage),
1150
- list: p => eachItem(p, "items", normaliseListItem),
1151
- chart: p => eachItem(p, "bars", normaliseBar),
1152
- diff: p => eachItem(p, "changes", normaliseChange),
1153
- claim: p => eachItem(p, "sources", normaliseLabelled),
1154
- finding: p => {
1155
- eachItem(p, "evidence", normaliseEvidence);
1156
- eachItem(p, "actions", normaliseLabelled);
1157
- },
1158
- card: p => eachItem(p, "actions", normaliseLabelled),
1159
- keyValue: p => {
1160
- // `{pairs: {hp: 35, attack: 55}}` — the object map is what a model reaches
1161
- // for when the block is "one record's fields", and it means exactly one
1162
- // thing.
1163
- if (isRec(p.pairs)) {
1164
- p.pairs = Object.entries(p.pairs).map(([key, value]) => ({
1165
- key,
1166
- value
1167
- }));
1168
- }
1169
- eachItem(p, "pairs", normalisePair);
1170
- },
1171
- table: p => {
1172
- // Rows as OBJECTS keyed by the column names, instead of positional
1173
- // arrays. Only resolvable when `columns` is there to give the order —
1174
- // without it there is no single reading, so it is left to the validator.
1175
- const columns = Array.isArray(p.columns) ? p.columns.map(c => String(c)) : undefined;
1176
- if (!columns?.length) return;
1177
- eachItem(p, "rows", row => {
1178
- if (!isRec(row)) return row;
1179
- const keys = Object.keys(row);
1180
- return columns.map(col => row[col] ?? row[keys.find(k => k.toLowerCase() === col.toLowerCase()) ?? ""] ?? "");
1181
- });
1182
- },
1183
- sparkline: p => {
1184
- // `[{value: 12}]` or `["12"]` -> `[12]`. The block draws numbers.
1185
- eachItem(p, "series", point => {
1186
- if (typeof point === "number") return point;
1187
- if (typeof point === "string" && point.trim() !== "" && Number.isFinite(Number(point))) {
1188
- return Number(point);
1189
- }
1190
- if (isRec(point)) {
1191
- const v = point.value ?? point.y ?? point.n;
1192
- if (typeof v === "number") return v;
1193
- }
1194
- return point;
1195
- });
1196
- },
1197
- code: p => {
1198
- // The enum is json|text. A model naming the real language ("javascript",
1199
- // "tsx") means "not JSON", and bouncing the block over a label nobody
1200
- // renders differently is the definition of a wasted turn.
1201
- const language = text(p.language)?.toLowerCase();
1202
- if (language && language !== "json" && language !== "text") p.language = "text";
1203
- }
1204
- };
1205
-
1206
- /**
1207
- * The whole pre-validation pass. Returns a NEW object — the caller's params
1208
- * come straight off the model's tool call and are echoed back in the trace.
1209
- */
1210
- export function normaliseUiParams(kind, raw) {
1211
- const params = isRec(raw) ? {
1212
- ...raw
1213
- } : {};
1214
- applyAliases(params, FIELD_ALIASES[kind]);
1215
- SHAPE_FIXES[kind]?.(params);
1216
- return params;
1217
- }
1218
-
1219
- /* ------------------------------------------------------------------------ *
1220
- * The signatures the model is shown.
1221
- *
1222
- * `uiProviderTool` used to send `params: { type: "object" }` and 26 lines of
1223
- * prose about what each kind is FOR — and not one field name. The model was
1224
- * being asked to guess `images` vs `items` and `chips` vs `options`, and it
1225
- * guessed wrong three rounds running. Rendered from `UI_PARAMS` rather than
1226
- * written out, so the thing the model reads can never drift from the thing
1227
- * the validator enforces.
1228
- * ------------------------------------------------------------------------ */
1229
-
1230
- /** The `Fields per kind` block sent in the `params` property description. */
1231
- export function uiParamsHelp() {
1232
- const lines = MODEL_KINDS.map(k => `- ${k}: ${signature(UI_PARAMS[k])}`).join("\n");
1233
- return `The block's fields. \`*\` marks a required one; everything else is optional. Send EXACTLY these names — a field that is not listed is rejected.\n\n${lines}`;
1234
- }
1235
- const KIND_HELP = {
1236
- choice: "ASK the user to pick one of 2–5 options when a request could mean different things. Ends your turn; their pick comes back as their next message.",
1237
- confirm: "ASK before a change you are guessing at (a shape you haven't read, a user you invented, anything destructive). Ends your turn.",
1238
- input: "ASK for one value you need (an order id, a quantity). Ends your turn.",
1239
- table: "Show rows of comparable facts — prices before/after, requests, counts. ≤4 columns, ≤8 rows; put the rest in total.",
1240
- keyValue: "Show one record's fields — a profile, a store's state, a stored value.",
1241
- list: "Show several things with a title each — items, orders, users. Add image only from URLs you read. Each item may carry one action.",
1242
- imageGrid: "Show pictures — menu items, loaded images. Only URLs you read from the app in this conversation; a URL you did not read is dropped. ≤24; grid up to 6, carousel after.",
1243
- diff: "Show what changed: path, before, after. Use for compare questions and after any write.",
1244
- chart: "Show numbers side by side as bars — render counts, timings, sizes. ≤8 bars.",
1245
- steps: "Show a procedure or a plan as a checklist (to reproduce, to test).",
1246
- code: "Show a raw value only when the user asked for the raw thing.",
1247
- actions: "Offer up to two buttons for what to do next instead of writing 'say X and I'll…'. Use send for a chat reply, dispatch to run an action directly, minimize to let them look at the app.",
1248
- finding: "Report something worth filing: a title plus evidence rows (request → status, screen → what it showed). Add a button to reproduce or open the tool.",
1249
- suggestions: "Offer 2–4 follow-up questions the user might ask next. Put it last.",
1250
- multiSelect: "ASK the user to pick several (which stores, which keys). Ends your turn.",
1251
- select: "ASK the user to pick one from a long list (routes, stores) — searchable. Ends your turn.",
1252
- slider: "ASK for a number in a range (a delay, a quantity). Ends your turn.",
1253
- dateTime: "ASK for a date or time. Ends your turn.",
1254
- form: "ASK for several coupled values at once. Ends your turn.",
1255
- proposal: "ASK to approve a change whose values the user may edit first. Ends your turn.",
1256
- claim: "State one fact with the evidence chips it rests on and a Verify button that re-reads it.",
1257
- details: "A collapsed detail the user can open — long explanations, raw values.",
1258
- compare: "Two things side by side with differences highlighted.",
1259
- card: "One entity: title, image, facts, up to two actions.",
1260
- cardCarousel: "3–8 cards to scan and pick from (scenarios, snapshots, items).",
1261
- sparkline: "A series over time — FPS, memory, request timing.",
1262
- plan: "Before multi-step work: the steps you intend, with Go/Stop. Update states as you go."
1263
- };
1264
-
1265
- /** The provider-facing tool definition. */
1266
- export function uiProviderTool() {
1267
- const kinds = MODEL_KINDS.join(" | ");
1268
- const help = MODEL_KINDS.map(k => `- ${k}: ${KIND_HELP[k]}`).join("\n");
1269
- const intro = `Show the user something richer than text, or ask them something. Blocks render inline in the chat BELOW your text, as the last thing in your answer — so say what is coming and what it means first, then let the block land. Never repeat its contents in the text. Kinds: ${kinds}.`;
1270
- const rules = `Rules: choice/confirm/input END your turn — send them last, alone, with no other tool calls, and the answer arrives as the user's next message. Never put URLs, ids or numbers in a block that you did not read from a tool result in this conversation. Prefer the smallest block that answers.`;
1271
- return {
1272
- name: UI_TOOL_NAME,
1273
- description: `${intro}\n${help}\n\n${rules}`,
1274
- // The split the OpenAI adapter serializes (see ProviderTool): the prose
1275
- // fits its 1024-char cap, the per-kind help rides on the `action`
1276
- // property, where nothing is capped. Before the split that cap cut this
1277
- // tool off inside the kind list and the Rules never reached the model.
1278
- summaryDescription: `${intro}\n\n${rules}`,
1279
- actionsBlock: `Kinds:\n${help}`,
1280
- inputSchema: {
1281
- type: "object",
1282
- properties: {
1283
- action: {
1284
- type: "string",
1285
- enum: [...MODEL_KINDS],
1286
- description: "The block kind."
1287
- },
1288
- // The per-kind field names, rendered from UI_PARAMS. Nothing caps a
1289
- // property description on either protocol (see ProviderTool), so this
1290
- // reaches the model whole — which the prose alone never did.
1291
- params: {
1292
- type: "object",
1293
- description: uiParamsHelp()
1294
- }
1295
- },
1296
- required: ["action", "params"],
1297
- additionalProperties: false
1298
- }
1299
- };
1300
- }
1301
- const nextUiId = idFactory("ui");
1302
-
1303
- /** Validate a `buoy_ui` call and build the block. */
1304
- /**
1305
- * Accept the shape models actually send for a confirm. `message` is the
1306
- * near-universal field name, and `title` alone is a perfectly clear ask —
1307
- * so fold them into the block's own vocabulary rather than bouncing the
1308
- * call. Returns null only when there is genuinely nothing to agree to.
1309
- */
1310
- function normaliseConfirm(params) {
1311
- const str = v => typeof v === "string" && v.trim() ? v.trim() : undefined;
1312
- const {
1313
- message,
1314
- ...rest
1315
- } = params;
1316
- const change = str(rest.change) ?? str(message) ?? str(rest.title);
1317
- if (!change) return null;
1318
- // When both arrived, the one we didn't use as `change` still carries
1319
- // meaning — keep it as the consequence line rather than dropping it.
1320
- const spare = str(rest.change) ? str(message) : undefined;
1321
- return {
1322
- ...rest,
1323
- title: str(rest.title) ?? "Confirm",
1324
- change,
1325
- consequence: str(rest.consequence) ?? spare
1326
- };
1327
- }
1328
-
1329
- /** Accept `title` where the schema says `question` — see normaliseConfirm. */
1330
- function normaliseChoice(params) {
1331
- const str = v => typeof v === "string" && v.trim() ? v.trim() : undefined;
1332
- const {
1333
- title,
1334
- ...rest
1335
- } = params;
1336
- const question = str(rest.question) ?? str(title);
1337
- if (!question) return null;
1338
- return {
1339
- ...rest,
1340
- question
1341
- };
1342
- }
1343
- export function buildUiBlock(input) {
1344
- const kind = input.action;
1345
- if (!kind || !MODEL_KINDS.includes(kind)) {
1346
- return {
1347
- ok: false,
1348
- errors: [`"action" must be one of: ${MODEL_KINDS.join(", ")}`]
1349
- };
1350
- }
1351
- // `kind` is already known to be in MODEL_KINDS, so a missing schema means a
1352
- // kind was offered without one — a build mistake, not model input.
1353
- const schema = UI_PARAMS[kind];
1354
- if (!schema) {
1355
- return {
1356
- ok: false,
1357
- errors: [`"${kind}" is offered but has no schema — this is a Buoy bug, not your call.`]
1358
- };
1359
- }
1360
- // Aliases and item shapes FIRST, so a field name never costs a round trip.
1361
- let params = normaliseUiParams(kind, input.params);
1362
- const check = validateParams(params, schema);
1363
- if (!check.ok) return {
1364
- ok: false,
1365
- errors: check.errors
1366
- };
1367
- if (kind === "choice") {
1368
- const fixed = normaliseChoice(params);
1369
- if (!fixed) {
1370
- return {
1371
- ok: false,
1372
- errors: ['choice needs the question being asked: pass `question` (or `title`), e.g. { "question": "Which checkout?", "options": [...] }']
1373
- };
1374
- }
1375
- params = fixed;
1376
- }
1377
- if (kind === "confirm") {
1378
- const fixed = normaliseConfirm(params);
1379
- if (!fixed) {
1380
- return {
1381
- ok: false,
1382
- errors: ['confirm needs what the user is agreeing to: pass `change` (or `message`), e.g. { "change": "Wipe all app storage", "consequence": "This cannot be undone." }']
1383
- };
1384
- }
1385
- params = fixed;
1386
- }
1387
- const block = {
1388
- ...params,
1389
- kind,
1390
- id: nextUiId(),
1391
- source: "model"
1392
- };
1393
- return {
1394
- ok: true,
1395
- errors: [],
1396
- block
1397
- };
1398
- }
1399
- //# sourceMappingURL=uiTool.js.map
8
+ ${r}`,actionsBlock:`Kinds:
9
+ ${t}`,inputSchema:{type:"object",properties:{action:{type:"string",enum:[...u],description:"The block kind."},params:{type:"object",description:uiParamsHelp()}},required:["action","params"],additionalProperties:false}}}const T=k("ui");function U(e){const t=l=>typeof l==="string"&&l.trim()?l.trim():void 0;const{message:i,...r}=e;const o=t(r.change)??t(i)??t(r.title);if(!o)return null;const p=t(r.change)?t(i):void 0;return{...r,title:t(r.title)??"Confirm",change:o,consequence:t(r.consequence)??p}}function K(e){const t=p=>typeof p==="string"&&p.trim()?p.trim():void 0;const{title:i,...r}=e;const o=t(r.question)??t(i);if(!o)return null;return{...r,question:o}}export function buildUiBlock(e){const t=e.action;if(!t||!u.includes(t)){return{ok:false,errors:[`"action" must be one of: ${u.join(", ")}`]}}const i=UI_PARAMS[t];if(!i){return{ok:false,errors:[`"${t}" is offered but has no schema \u2014 this is a Buoy bug, not your call.`]}}let r=normaliseUiParams(t,e.params);const o=j(r,i);if(!o.ok)return{ok:false,errors:o.errors};if(t==="choice"){const l=K(r);if(!l){return{ok:false,errors:['choice needs the question being asked: pass `question` (or `title`), e.g. { "question": "Which checkout?", "options": [...] }']}}r=l}if(t==="confirm"){const l=U(r);if(!l){return{ok:false,errors:['confirm needs what the user is agreeing to: pass `change` (or `message`), e.g. { "change": "Wipe all app storage", "consequence": "This cannot be undone." }']}}r=l}const p={...r,kind:t,id:T(),source:"model"};return{ok:true,errors:[],block:p}}