@wirecat/cli-core 3.1.0 → 3.2.0

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 (105) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/dist/bundle/{agent-RMLBQXJF-CuqJBQqf.js → agent-J75WGZEV-K_l-bQ-h.js} +5 -5
  3. package/dist/bundle/{all-profiles-3GEKS7PR-Bi_zb5_-.js → all-profiles-3GEKS7PR-BohqgNvP.js} +6 -6
  4. package/dist/bundle/{anthropic-EVM6I7MZ-BWI01JgC.js → anthropic-EVM6I7MZ-CqB3j7dB.js} +2 -2
  5. package/dist/bundle/{app-server-76XGUZHU-__6SrMhc.js → app-server-5BL62GAL-Osw_tMej.js} +20 -15
  6. package/dist/bundle/{bun-AWMVU72K-COHrAYHA.js → bun-AWMVU72K-Bk0oN5Sm.js} +2 -2
  7. package/dist/bundle/{bun-sqlite-CYFVVXXR-r_kJOwku.js → bun-sqlite-CYFVVXXR-4iGlaI9X.js} +3 -3
  8. package/dist/bundle/{chunk-4ZM6SE7G-DNDxhi8l.js → chunk-4HGRFFTO-fNvELOjI.js} +330 -56
  9. package/dist/bundle/{chunk-6G6TIMKP-CoVYG_I3.js → chunk-6G6TIMKP-Byea1UGV.js} +4 -4
  10. package/dist/bundle/{chunk-M5CHOMME-BIcASmVb.js → chunk-6OLVBOBX-Ch2rblZk.js} +17 -11
  11. package/dist/bundle/{chunk-CCFBHR4O-DAuKd8rI.js → chunk-CCFBHR4O-Bhxq5eaI.js} +1 -1
  12. package/dist/bundle/{chunk-DDXCCEI4-CHLrblc1.js → chunk-DDXCCEI4-CBg_l4Ro.js} +2 -2
  13. package/dist/bundle/{chunk-DZPIGAKP-nrRAPNTz.js → chunk-DZPIGAKP-BZy6DShN.js} +1 -1
  14. package/dist/bundle/{chunk-ERNCGLKE-4JdU74o6.js → chunk-ERNCGLKE-D3HStkJC.js} +1 -1
  15. package/dist/bundle/{chunk-GBNNGOIB-DVUFOYzA.js → chunk-GBNNGOIB-DS3rusdH.js} +5 -5
  16. package/dist/bundle/{chunk-GJTANPFI-5L6Owk-H.js → chunk-GJTANPFI-DlUMnFUQ.js} +3 -3
  17. package/dist/bundle/{chunk-6ZUQA7OL-ofpF0AvH.js → chunk-GRGGW52W-Fkw6omOx.js} +5 -5
  18. package/dist/bundle/{chunk-KSUALCA7-DB6cYuSU.js → chunk-KSUALCA7-SMNQ85c6.js} +1 -1
  19. package/dist/bundle/{chunk-LBVI4Z2X-COUoJmWU.js → chunk-LBVI4Z2X-D9_8iC1S.js} +1 -1
  20. package/dist/bundle/{chunk-M23BPYSL-ChiHsEsy.js → chunk-M23BPYSL-ByTcRixP.js} +3 -3
  21. package/dist/bundle/{chunk-Z3ZVBBWR-whNBW-iH.js → chunk-M4KMNZN6-CBeUwDlF.js} +2 -2
  22. package/dist/bundle/{chunk-NG7F5L7N-BKCEXGxy.js → chunk-NG7F5L7N-Ch_ERSNz.js} +1 -1
  23. package/dist/bundle/{chunk-NX2VS2ER-DS6Urg3e.js → chunk-NX2VS2ER-CWN0zXqZ.js} +1 -1
  24. package/dist/bundle/{chunk-O2HOOK7X-Dboq6vxP.js → chunk-O2HOOK7X-Dyw_Dcql.js} +4 -4
  25. package/dist/bundle/{chunk-PSD6373C-wlicX185.js → chunk-PSD6373C-DgL0rhKe.js} +1 -1
  26. package/dist/bundle/{chunk-RTCT4N7Y-Dn-lP1zF.js → chunk-RTCT4N7Y-BEZ3cJ5d.js} +1 -1
  27. package/dist/bundle/{chunk-S34BE7ZC-p6NeYmqQ.js → chunk-S34BE7ZC-BO0yaVoX.js} +1 -1
  28. package/dist/bundle/{chunk-E6KETVFF-wOOXf4op.js → chunk-SRAGL5LI-CKhhwRrx.js} +5 -5
  29. package/dist/bundle/{chunk-T6V6LFHT-Dwv7XUuC.js → chunk-T6V6LFHT-BazTZ25Y.js} +1 -1
  30. package/dist/bundle/{chunk-ACWFPMZF-DkR70AOW.js → chunk-TFRAD7RO-BVAK9frq.js} +50 -4
  31. package/dist/bundle/{chunk-UH2H3OLE-R_6H5D7o.js → chunk-UH2H3OLE-QNxQo07O.js} +1 -1
  32. package/dist/bundle/{chunk-UQJGYQ56-CANeLx5l.js → chunk-UQJGYQ56-PoYTv6WX.js} +1 -1
  33. package/dist/bundle/{chunk-VKZDPPVI-d7RS_QOW.js → chunk-VKZDPPVI-BOmnhxVJ.js} +2 -2
  34. package/dist/bundle/{chunk-UNGNJ255-CtLEiDap.js → chunk-W3AAOYWE-Cyx1kZsd.js} +7 -7
  35. package/dist/bundle/{chunk-WXEJSLMO-DbSxVCq9.js → chunk-WXEJSLMO-DCjDRcYe.js} +8 -8
  36. package/dist/bundle/{chunk-XW3IHFDH-CjmXc8aI.js → chunk-XW3IHFDH-CA9Bby7o.js} +1 -1
  37. package/dist/bundle/{chunk-YHBBPJW6-jAof9asy.js → chunk-YHBBPJW6-DKIU2gC4.js} +2 -2
  38. package/dist/bundle/{chunk-YITG2CE5-Bg4SA8X1.js → chunk-YITG2CE5-o18mzaka.js} +1 -1
  39. package/dist/bundle/{chunk-ZMRSCVFX-Dwxb-Yg1.js → chunk-ZMRSCVFX-uhwzmZUP.js} +1 -1
  40. package/dist/bundle/chunks.json +83 -83
  41. package/dist/bundle/{command-contract-4X4JDKH7-BsU8tW9N.js → command-contract-DHFUF6RM-Bnc6nJSk.js} +2 -2
  42. package/dist/bundle/{command-server-entry-3JEJBUK5-CF-VyCRd.js → command-server-entry-UQSMAHYK-DzjTaTCZ.js} +2 -2
  43. package/dist/bundle/{decode-KVUA3TLF-Ds0C1R9U.js → decode-KVUA3TLF-BoJfgCpS.js} +2 -2
  44. package/dist/bundle/{dist-TPSNLFVO-D1tJd0aB.js → dist-TPSNLFVO-55jBf4N-.js} +2 -2
  45. package/dist/bundle/documents.js +5 -5
  46. package/dist/bundle/{echarts-6Q4CQ2DC-BvZMDYNl.js → echarts-6Q4CQ2DC-w9WhKUJu.js} +1 -1
  47. package/dist/bundle/{embed-JGGK2WKR-h5ppwooq.js → embed-JGGK2WKR-Cl3meWl4.js} +2 -2
  48. package/dist/bundle/{embedder-5SIVKVWO-D4yt4YCy.js → embedder-5SIVKVWO-DJEa9hBn.js} +2 -2
  49. package/dist/bundle/{first-run-FFHXPGFC-CyHZ4KM3.js → first-run-BT3X33BP-JikrW5_w.js} +2 -2
  50. package/dist/bundle/{first-screen-2NGQNWIN-BkvwnUdE.js → first-screen-KGQQK446-D2MchUuo.js} +2 -2
  51. package/dist/bundle/{hast-util-from-html-WLAUHN53-BfAYjYKc.js → hast-util-from-html-WLAUHN53-BOWgHBLv.js} +4 -4
  52. package/dist/bundle/{hast-util-to-html-PJC36XDP-C8DGIyzU.js → hast-util-to-html-PJC36XDP-QwbM5c4F.js} +5 -5
  53. package/dist/bundle/{hast-util-to-mdast-ZQ5OFYUM-9p6MJEBi.js → hast-util-to-mdast-ZQ5OFYUM-BidjUANu.js} +6 -6
  54. package/dist/bundle/{index-BOgkxLir.js → index-CTvUjqLX.js} +331 -345
  55. package/dist/bundle/index.js +66 -66
  56. package/dist/bundle/install-IPXFNLYZ-BGKW94IA.js +5 -0
  57. package/dist/bundle/{instructions-NHSD6EUE-BfefgySD.js → instructions-34FSWDC6-BR7mbjJH.js} +2 -2
  58. package/dist/bundle/mail.js +3 -3
  59. package/dist/bundle/{mcp-server-5FM4GA2C-CNWjKPAi.js → mcp-server-5FM4GA2C-B4Sqou0Z.js} +2 -2
  60. package/dist/bundle/mcp.js +12 -12
  61. package/dist/bundle/{mdast-util-from-markdown-Y7N3XA5A-ZkhTz5VO.js → mdast-util-from-markdown-Y7N3XA5A-CBCtetYX.js} +8 -8
  62. package/dist/bundle/{mdast-util-gfm-52PMOHWQ-gfhFQVZ5.js → mdast-util-gfm-52PMOHWQ-Bv-Hkixb.js} +12 -12
  63. package/dist/bundle/{mdast-util-to-hast-4MTEM3TB-Bomsq1EU.js → mdast-util-to-hast-4MTEM3TB-40gSN0gV.js} +6 -6
  64. package/dist/bundle/mdast-util-to-markdown-UGCOLDXA-DnYraMQX.js +12 -0
  65. package/dist/bundle/{meeting-combined-G3OVTNM6-CFHWFlT-.js → meeting-combined-G3OVTNM6-C4Jdctiy.js} +2 -2
  66. package/dist/bundle/{meeting-model-RINL42I5-Bab4crMQ.js → meeting-model-RINL42I5-BLAAT6mv.js} +2 -2
  67. package/dist/bundle/meeting-semantic-I7AZQTEI-DQ19wjn5.js +5 -0
  68. package/dist/bundle/{micromark-extension-gfm-FRHRNOIW-81l4O6kr.js → micromark-extension-gfm-FRHRNOIW-BvJCT_wq.js} +6 -6
  69. package/dist/bundle/{node-ZIYT5JOL-WfCpdwZ2.js → node-ZIYT5JOL-DoWqiI0I.js} +2 -2
  70. package/dist/bundle/{node-sqlite-VFGFD4MA-CrKdzJgw.js → node-sqlite-VFGFD4MA-QH9swjUN.js} +3 -3
  71. package/dist/bundle/notes-search-2Q3C65PA-D2HqYyaY.js +5 -0
  72. package/dist/bundle/oauth-TVUNW3GM-uN6u_RWy.js +7 -0
  73. package/dist/bundle/{open-36SZHLGF-kGan0BjP.js → open-36SZHLGF-CPBs6fdy.js} +1 -1
  74. package/dist/bundle/{openai-Z2WIZ6AC-D-aH-As-.js → openai-Z2WIZ6AC-CcEngcFj.js} +2 -2
  75. package/dist/bundle/preload.js +1 -1
  76. package/dist/bundle/{process-KJQOPRSP-C6W_P1_I.js → process-KJQOPRSP-BNqvUqBZ.js} +2 -2
  77. package/dist/bundle/{prompt-S2W33X57-BEDbCA8B.js → prompt-S2W33X57-BiF1939t.js} +2 -2
  78. package/dist/bundle/{recognize-NBWDLXLD-B2LTlDUy.js → recognize-NBWDLXLD-BCqQ8iG1.js} +2 -2
  79. package/dist/bundle/{remote-O54ANXYL-DOEubnhV.js → remote-O54ANXYL-BixLG9XM.js} +2 -2
  80. package/dist/bundle/{rerank-HTCSXPM6-CVIU4cUa.js → rerank-HTCSXPM6-FGYUs2VW.js} +2 -2
  81. package/dist/bundle/serve-7KRXCBBZ-EVSG16Mc.js +8 -0
  82. package/dist/bundle/server-BFD6QUV7-OmgCCeuX.js +11 -0
  83. package/dist/bundle/server-G7VWUBA2-C3Gq_HlM.js +12 -0
  84. package/dist/bundle/{sqlite-runtime-KC3NKKRB-DYslMC-g.js → sqlite-runtime-KC3NKKRB-y_O8PNsQ.js} +1 -1
  85. package/dist/bundle/{start-Dtq56YXe.js → start-CqQGB7xI.js} +5 -5
  86. package/dist/bundle/start.js +1 -1
  87. package/dist/bundle/state-3CFS2SAC-CYYQ103I.js +5 -0
  88. package/dist/bundle/store-BSVRVKTV-Uot4OGm0.js +5 -0
  89. package/dist/bundle/{store-6CM2A3HP-CtnMVUVK.js → store-LGAEGNFF-BzNIKnoK.js} +2 -2
  90. package/dist/bundle/{store-maintenance-command-WYO5PN4V-B0wefBHZ.js → store-maintenance-command-Z27R7URJ-CoJCYGVq.js} +2 -2
  91. package/dist/bundle/surface-ZEEHYD5Q-DRIV3XG3.js +8 -0
  92. package/dist/bundle/testing.js +8 -8
  93. package/package.json +1 -1
  94. package/skills/link-conversations/SKILL.md +1 -1
  95. package/dist/bundle/install-IPXFNLYZ-BSWiztYR.js +0 -5
  96. package/dist/bundle/mdast-util-to-markdown-UGCOLDXA-7D6EJn9r.js +0 -12
  97. package/dist/bundle/meeting-semantic-I7AZQTEI-BgZ3ZzQB.js +0 -5
  98. package/dist/bundle/notes-search-2Q3C65PA-CWKHboCy.js +0 -5
  99. package/dist/bundle/oauth-TVUNW3GM-BqlyhUfp.js +0 -7
  100. package/dist/bundle/serve-7KRXCBBZ-BO9BKhWL.js +0 -8
  101. package/dist/bundle/server-PIT6UZRZ-C6I-VrDd.js +0 -11
  102. package/dist/bundle/server-ZL4FMEHH-DP1oYgCn.js +0 -12
  103. package/dist/bundle/state-3CFS2SAC-xptBCfut.js +0 -5
  104. package/dist/bundle/store-ASWYHJ4Q-C7EFfvzB.js +0 -5
  105. package/dist/bundle/surface-DDH4HGT3-CBZnEqH_.js +0 -8
@@ -1,12 +1,13 @@
1
1
  import "./rolldown-runtime-C_t765_o.js";
2
- import { k as __name$1 } from "./start-Dtq56YXe.js";
3
- import { $D as answerSchema, AR as string, Ak as listOf, BD as REMOTE_WRITE, CA as refuseStoreChange, Ck as keyForCommand, DR as regex, ER as record, Ek as levelFor, GO as fetchesAt, Hw as storeModeDeps, Kj as inRun, LR as unknown, Lp as refuseLacking, Ls as MAX_BUFFERED_INPUT, OR as safeParse, SR as optional, TR as pipe, UA as sealed, Xj as newRunId, aR as description, bD as DEFAULT_OUTPUT_BYTES, bc as toJsonSchema, bk as judgedAnswer, bz as storeDamaged, dR as maxLength, da as UNTRUSTED, fR as maxValue, ga as agentJson, gz as withCaller, hA as readKeysForCommand, jD as LOCAL_WRITE, jR as summarize, jw as onlineDeps, kR as strictObject, lz as currentCaller, mR as minValue, ma as agentArguments, mz as runContextOf, nR as array, pR as minLength, pa as UNTRUSTED_NEUTRAL, rR as boolean, sR as integer, tj as startRecording, tm as servicesFor, uR as looseObject, uz as keepsSuccess, wD as ENTITIES, xc as toStandardJsonSchema, xk as judgedEffects, yR as number, yc as failureContext, yz as storeBusy } from "./index-BOgkxLir.js";
4
- import { r as callerOf } from "./chunk-GJTANPFI-5L6Owk-H.js";
2
+ import { k as __name$1 } from "./start-CqQGB7xI.js";
3
+ import { AR as record, Ak as levelFor, CR as number, Cc as toStandardJsonSchema, Cz as storeBusy, DA as refuseStoreChange, Dk as keyForCommand, ED as ENTITIES, ER as optional, FR as summarize, Jk as nextStep, MR as safeParse, ND as LOCAL_WRITE, NR as strictObject, Nw as onlineDeps, PR as string, Pk as listOf, QD as agentView, SD as DEFAULT_OUTPUT_BYTES, Sc as toJsonSchema, Tk as judgedEffects, UD as REMOTE_WRITE, VD as RECORD_ENTITIES, VR as unknown, Ww as storeModeDeps, Xj as inRun, YO as fetchesAt, _R as minLength, aj as startRecording, bz as withCaller, dR as integer, da as UNTRUSTED, eM as newRunId, gR as maxValue, ga as agentJson, hR as maxLength, jR as regex, kR as pipe, lR as description, mR as looseObject, ma as agentArguments, mz as keepsSuccess, oR as array, pa as UNTRUSTED_NEUTRAL, pz as currentCaller, qA as sealed, rO as answerSchema, rm as servicesFor, sR as boolean, vR as minValue, vz as runContextOf, wk as judgedAnswer, wz as storeDamaged, xc as failureContext, yA as readKeysForCommand, zp as refuseLacking, zs as MAX_BUFFERED_INPUT } from "./index-CTvUjqLX.js";
4
+ import { r as callerOf } from "./chunk-GJTANPFI-DlUMnFUQ.js";
5
5
  import { createRequire } from "node:module";
6
6
  import { CliError, errorCodes, errorObjectOf, mcpErrorResult } from "@wirecat/cli-base";
7
7
  import { randomUUID } from "node:crypto";
8
- import { itemEnvelopeSchema, listEnvelopeSchema, traceIdOf } from "@wirecat/cli-base/standards";
8
+ import { MAX_NEXT_STEPS, itemEnvelopeSchema, listEnvelopeSchema, traceIdOf } from "@wirecat/cli-base/standards";
9
9
  createRequire(import.meta.url);
10
+ var leansRead = /* @__PURE__ */ __name$1(({ writes, entity }) => !writes && RECORD_ENTITIES.has(entity?.split(".")[0] ?? ""), "leansRead");
10
11
  optional(pipe(number(), integer(), minValue(1), maxValue(100), description("how many")));
11
12
  optional(pipe(number(), integer(), minValue(1), description("which page, from 1")));
12
13
  var message = pipe(string(), maxLength(256), regex(/^[^\s\x00-\x1F\x7F-\x9F]+$/, "a message id has no spaces or control characters"), description("message id"));
@@ -130,7 +131,7 @@ var entryRunner = /* @__PURE__ */ __name$1((registration) => {
130
131
  return result;
131
132
  };
132
133
  }, "entryRunner");
133
- var callRunner = /* @__PURE__ */ __name$1(({ messenger, session, withStore, withServices, defaults, around, targets }) => {
134
+ var callRunner = /* @__PURE__ */ __name$1(({ messenger, session, withStore, withServices, defaults, around, targets, view }) => {
134
135
  const where = {
135
136
  profile: defaults.settings.profile,
136
137
  env: defaults.env,
@@ -140,6 +141,10 @@ var callRunner = /* @__PURE__ */ __name$1(({ messenger, session, withStore, with
140
141
  return async (key, definition, args, ctx) => {
141
142
  const path = commandOf(key, definition).split(" ");
142
143
  const run = `mcp ${path.join(" ")}`;
144
+ const lean = leansRead({
145
+ writes: definition.annotations.readOnlyHint !== true,
146
+ ...definition.output ? { entity: definition.output.entity } : {}
147
+ }) ? view : void 0;
143
148
  try {
144
149
  const execute = /* @__PURE__ */ __name$1(async () => {
145
150
  const syncAllowed = syncAllowedFor(key, defaults);
@@ -156,8 +161,8 @@ var callRunner = /* @__PURE__ */ __name$1(({ messenger, session, withStore, with
156
161
  if (definition.custom) return answered(await definition.custom(args, {
157
162
  ...defaults,
158
163
  signal: ctx.mcpReq.signal
159
- }, ctx), definition.outputLimit?.(args, defaults), targets);
160
- if (definition.local) return answered(await definition.local(args, defaults), definition.outputLimit?.(args, defaults), targets);
164
+ }, ctx), definition.outputLimit?.(args, defaults), targets, lean);
165
+ if (definition.local) return answered(await definition.local(args, defaults), definition.outputLimit?.(args, defaults), targets, lean);
161
166
  const { online, stored: local, served } = definition;
162
167
  const stored = local && (!definition.storedWhen || definition.storedWhen(args)) ? local : void 0;
163
168
  return answered(stored ? await withStore((store, account) => stored(store, account, args, {
@@ -182,7 +187,7 @@ var callRunner = /* @__PURE__ */ __name$1(({ messenger, session, withStore, with
182
187
  })())) : await session.use(run, (adapter, release) => online(adapter, args, {
183
188
  ...defaults,
184
189
  release
185
- })), definition.outputLimit?.(args, defaults), targets);
190
+ })), definition.outputLimit?.(args, defaults), targets, lean);
186
191
  }, "execute");
187
192
  return around ? await around(key, definition, execute) : await execute();
188
193
  } catch (error) {
@@ -223,7 +228,7 @@ var BinaryResource = class {
223
228
  this.about = about;
224
229
  }
225
230
  };
226
- var answered = /* @__PURE__ */ __name$1((answer, maxBytes = DEFAULT_OUTPUT_BYTES, targets) => {
231
+ var answered = /* @__PURE__ */ __name$1((answer, maxBytes = DEFAULT_OUTPUT_BYTES, targets, view) => {
227
232
  const bounded = /* @__PURE__ */ __name$1((result) => {
228
233
  if (maxBytes !== 0 && Buffer.byteLength(JSON.stringify(result.content)) > maxBytes) throw new CliError("invalid_response", "tool output exceeds its byte limit — reduce limit or use a narrower request", {
229
234
  reason: "output.too-large",
@@ -269,7 +274,8 @@ var answered = /* @__PURE__ */ __name$1((answer, maxBytes = DEFAULT_OUTPUT_BYTES
269
274
  }]
270
275
  });
271
276
  }
272
- const body = objectBody(sealed(targets ? judgedAnswer(answer, targets) : answer));
277
+ const judged = sealed(targets ? judgedAnswer(answer, targets) : answer);
278
+ const body = objectBody(view ? agentView(judged) : judged);
273
279
  return bounded({
274
280
  content: [{
275
281
  type: "text",
@@ -286,10 +292,13 @@ var failed = /* @__PURE__ */ __name$1((error, errors, effects) => {
286
292
  };
287
293
  return mcpErrorResult(JSON.parse(agentJson(errorObjectOf(storeBusy(storeDamaged(error)), context))));
288
294
  }, "failed");
289
- var MATCHES = 8;
295
+ var MATCHES = 5;
296
+ var FULL_MATCHES = 2;
297
+ var NEAR = .45;
298
+ var AGENT_ANSWER_CHARS = 4e4;
290
299
  var ANSWER = answerSchema();
291
300
  var agentAnswer = /* @__PURE__ */ __name$1((prefix, writes) => {
292
- const meta = pipe(looseObject({}), description(`run facts; ${prefix}_tools_search shows the full answer`));
301
+ const meta = pipe(looseObject({}), description(`run facts; ${prefix}_tools_search with schema: true shows the full answer`));
293
302
  const next = optional(pipe(array(looseObject({})), description("steps to run next: command and args")));
294
303
  return looseObject(writes ? {
295
304
  item: optional(unknown()),
@@ -321,19 +330,19 @@ var wordsOf = /* @__PURE__ */ __name$1((text) => text.toLowerCase().split(/[^\p{
321
330
  var stem = /* @__PURE__ */ __name$1((word) => {
322
331
  const bare = word.replace(/'s$/u, "");
323
332
  if (bare.length > 4 && bare.endsWith("ies")) return `${bare.slice(0, -3)}y`;
333
+ if (bare.length > 5 && /(?:[sxz]|ch|sh)es$/u.test(bare)) return bare.slice(0, -2);
324
334
  for (const ending of [
325
335
  "ing",
326
336
  "ed",
327
- "es",
328
337
  "s"
329
338
  ]) if (bare.length - ending.length >= 3 && bare.endsWith(ending)) return bare.slice(0, -ending.length);
330
339
  return bare;
331
340
  }, "stem");
332
- var sameWord = /* @__PURE__ */ __name$1((asked, known) => {
333
- if (asked === known) return true;
341
+ var likeness = /* @__PURE__ */ __name$1((asked, known) => {
342
+ if (asked === known) return 1;
334
343
  const [short, long] = asked.length <= known.length ? [asked, known] : [known, asked];
335
- return short.length >= 3 && long.startsWith(short);
336
- }, "sameWord");
344
+ return short.length >= 3 && long.startsWith(short) ? .5 : 0;
345
+ }, "likeness");
337
346
  var fieldsOf$1 = /* @__PURE__ */ __name$1((command, one) => [
338
347
  [4, [...wordsOf(command), ...(one.aliases ?? []).flatMap(wordsOf)]],
339
348
  [2, wordsOf(one.title)],
@@ -343,22 +352,202 @@ var fieldsOf$1 = /* @__PURE__ */ __name$1((command, one) => [
343
352
  ...Object.keys(one.input.entries)
344
353
  ]]
345
354
  ].map(([weight, words]) => [weight, [...new Set(words.map(stem))]]), "fieldsOf");
355
+ var pairsOf = /* @__PURE__ */ __name$1((text) => {
356
+ const words = wordsOf(text);
357
+ return words.slice(1).flatMap((word, at) => {
358
+ const before = words[at] ?? "";
359
+ return STOP_WORDS.has(before) && STOP_WORDS.has(word) ? [] : [`${stem(before)} ${stem(word)}`];
360
+ });
361
+ }, "pairsOf");
362
+ var PAIR = 3;
346
363
  var search = /* @__PURE__ */ __name$1((commands, query) => {
364
+ if (!normal(query)) return Object.entries(commands).sort((a, b) => a[0].localeCompare(b[0]));
365
+ return scored(commands, query).map(({ entry }) => entry);
366
+ }, "search");
367
+ var scored = /* @__PURE__ */ __name$1((commands, query) => {
347
368
  const named = normal(query);
348
369
  const all = Object.entries(commands);
349
- if (!named) return all.map((entry) => entry).sort((a, b) => a[0].localeCompare(b[0]));
350
- const words = [...new Set(wordsOf(query).filter((word) => word.length > 1 && !STOP_WORDS.has(word)).map(stem))];
351
- return all.map((entry) => {
370
+ const asked = [...new Set(wordsOf(query).filter((word) => word.length > 1 && !STOP_WORDS.has(word)).map(stem))];
371
+ const pairs = [...new Set(pairsOf(query))];
372
+ const phrased = all.map(([command, one]) => {
373
+ const names = [command, ...one.aliases ?? []].flatMap((name) => [name, wordsOf(name).reverse().join(" ")]);
374
+ const known = new Set([
375
+ ...names,
376
+ one.title,
377
+ one.description
378
+ ].flatMap(pairsOf));
379
+ return pairs.filter((pair) => known.has(pair)).length;
380
+ });
381
+ const weighed = all.map((entry) => {
352
382
  const fields = fieldsOf$1(entry[0], entry[1]);
353
- const weights = words.map((word) => fields.reduce((best, [weight, known]) => known.some((one) => sameWord(word, one)) ? Math.max(best, weight) : best, 0));
354
- const matched = weights.filter((weight) => weight > 0).length;
383
+ return asked.map((word) => {
384
+ const likes = fields.map(([weight, known]) => ({
385
+ weight: weight * known.reduce((most, one) => Math.max(most, likeness(word, one)), 0),
386
+ same: known.includes(word)
387
+ }));
388
+ return {
389
+ weight: likes.reduce((best, one) => Math.max(best, one.weight), 0),
390
+ fields: likes.filter(({ same }) => same).length
391
+ };
392
+ });
393
+ });
394
+ return all.map((entry, index) => {
395
+ const found = weighed[index] ?? [];
396
+ const matched = found.filter(({ weight }) => weight > 0).length;
355
397
  return {
356
398
  entry,
357
- matched,
358
- rank: (normal(entry[0]) === named || (entry[1].aliases ?? []).some((alias) => normal(alias) === named) ? 1e3 : 0) + matched * 10 + weights.reduce((a, b) => a + b, 0)
399
+ exact: isNamed(entry, named),
400
+ whole: matched === found.length,
401
+ score: matched * 10 + found.reduce((sum, { weight }) => sum + weight, 0) + (matched ? PAIR * (phrased[index] ?? 0) : 0),
402
+ evidence: found.reduce((sum, { fields }) => sum + fields, 0)
359
403
  };
360
- }).filter(({ matched, rank }) => matched > 0 || rank >= 1e3).sort((a, b) => b.rank - a.rank || wordsOf(a.entry[0]).length - wordsOf(b.entry[0]).length || a.entry[0].localeCompare(b.entry[0])).map(({ entry }) => entry);
361
- }, "search");
404
+ }).filter(({ score, exact }) => score > 0 || exact).sort((a, b) => Number(b.exact) - Number(a.exact) || b.score - a.score || b.evidence - a.evidence || wordsOf(a.entry[0]).length - wordsOf(b.entry[0]).length || a.entry[0].localeCompare(b.entry[0]));
405
+ }, "scored");
406
+ var isApi = /* @__PURE__ */ __name$1((command) => command.split(" ")[0] === "api", "isApi");
407
+ var matchesOf = /* @__PURE__ */ __name$1((commands, query) => {
408
+ const ranked = scored(commands, query);
409
+ const groups = new Set(wordsOf(query).map(stem));
410
+ if (normal(query).split(" ")[0] === "api") return near(ranked, groups);
411
+ const own = ranked.filter(({ entry, exact }) => exact || !isApi(entry[0]));
412
+ const api = ranked.filter(({ entry, exact }) => !exact && isApi(entry[0]));
413
+ const best = bestOf(own);
414
+ if (best < NEAR * (api[0]?.score ?? 0)) return near([...own, ...api], groups);
415
+ const shown = near(own, groups);
416
+ const fallback = api[0];
417
+ if (!fallback || own.some(({ whole }) => whole) || fallback.score < NEAR * best) return shown;
418
+ return [
419
+ ...shown.slice(0, MATCHES - 1),
420
+ fallback.entry,
421
+ ...shown.slice(MATCHES - 1)
422
+ ];
423
+ }, "matchesOf");
424
+ var bestOf = /* @__PURE__ */ __name$1((ranked) => ranked.reduce((best, { score }) => Math.max(best, score), 0), "bestOf");
425
+ var SIBLINGS = 2;
426
+ var near = /* @__PURE__ */ __name$1((ranked, groups) => {
427
+ const best = bestOf(ranked);
428
+ const taken = /* @__PURE__ */ new Map();
429
+ return ranked.filter(({ exact, score }) => exact || score >= NEAR * best).filter(({ entry, exact }) => {
430
+ const group = stem(entry[0].split(" ")[0] ?? "");
431
+ const count = (taken.get(group) ?? 0) + 1;
432
+ taken.set(group, count);
433
+ return exact || groups.has(group) || count <= SIBLINGS;
434
+ }).map(({ entry }) => entry);
435
+ }, "near");
436
+ var CHECKS = /* @__PURE__ */ new Set([
437
+ "$schema",
438
+ "pattern",
439
+ "minLength",
440
+ "minItems"
441
+ ]);
442
+ var DATA = /* @__PURE__ */ new Set([
443
+ "default",
444
+ "enum",
445
+ "const",
446
+ "examples"
447
+ ]);
448
+ var argumentsOf = /* @__PURE__ */ __name$1((one) => {
449
+ const bare = /* @__PURE__ */ __name$1((node) => {
450
+ if (Array.isArray(node)) return node.map(bare);
451
+ if (node === null || typeof node !== "object") return node;
452
+ return Object.fromEntries(Object.entries(node).filter(([key, value]) => !CHECKS.has(key) && !(key === "additionalProperties" && value === false) && !(key === "required" && Array.isArray(value) && value.length === 0)).map(([key, value]) => [key, DATA.has(key) ? value : key === "properties" && value !== null && typeof value === "object" ? Object.fromEntries(Object.entries(value).map(([name, inner]) => [name, bare(inner)])) : bare(value)]));
453
+ }, "bare");
454
+ return bare(toJsonSchema(one.input));
455
+ }, "argumentsOf");
456
+ var availabilityOf = /* @__PURE__ */ __name$1((one) => {
457
+ const availability = one.availability?.();
458
+ return availability && (!availability.available || (availability.level ?? "allow") !== "allow") ? { availability } : {};
459
+ }, "availabilityOf");
460
+ var shortMatch = /* @__PURE__ */ __name$1((command, one) => ({
461
+ command,
462
+ does: one.description,
463
+ writes: one.writes,
464
+ ...availabilityOf(one)
465
+ }), "shortMatch");
466
+ var fullMatch = /* @__PURE__ */ __name$1((command, one) => ({
467
+ command,
468
+ ...one.title !== one.description ? { title: one.title } : {},
469
+ does: one.description,
470
+ writes: one.writes,
471
+ ...one.answers ? { answers: one.answers } : {},
472
+ ...availabilityOf(one),
473
+ arguments: argumentsOf(one)
474
+ }), "fullMatch");
475
+ var API_ROOM = 2e3;
476
+ var apiGroup = /* @__PURE__ */ __name$1((api, prefix, room) => {
477
+ const find = `${prefix}_tools_search with "api" and words of the task, for example "${api[0]?.[0]}"`;
478
+ const commands = [];
479
+ let size = find.length + API_ROOM;
480
+ for (const [command] of api) {
481
+ size += command.length + 3;
482
+ if (size > room) break;
483
+ commands.push(command);
484
+ }
485
+ return {
486
+ group: "api",
487
+ count: api.length,
488
+ commands,
489
+ ...commands.length < api.length ? { find } : {}
490
+ };
491
+ }, "apiGroup");
492
+ var isNamed = /* @__PURE__ */ __name$1(([command, one], named) => normal(command) === named || (one.aliases ?? []).some((alias) => normal(alias) === named), "isNamed");
493
+ var asAgentSees = /* @__PURE__ */ __name$1((schema, inRecord = false) => {
494
+ if (Array.isArray(schema)) return schema.map((one) => asAgentSees(one, inRecord));
495
+ if (schema === null || typeof schema !== "object") return schema;
496
+ return Object.fromEntries(Object.entries(schema).filter(([key]) => !(inRecord && key === "required")).map(([key, value]) => [key, key === "properties" && value !== null && typeof value === "object" ? Object.fromEntries(Object.entries(value).map(([name, inner]) => [name, asAgentSees(inner, inRecord || name === "item" || name === "items")])) : asAgentSees(value, inRecord)]));
497
+ }, "asAgentSees");
498
+ var leanSchema = /* @__PURE__ */ __name$1((one, schema) => leansRead({
499
+ writes: one.writes,
500
+ ...one.answers ? { entity: one.answers } : {}
501
+ }) ? asAgentSees(schema) : schema, "leanSchema");
502
+ var listingOf = /* @__PURE__ */ __name$1((commands, prefix) => {
503
+ const all = search(commands, "");
504
+ const api = all.filter(([command]) => isApi(command));
505
+ const service = all.filter(([command, one]) => !isApi(command) && one.upkeep === true && !("availability" in availabilityOf(one)));
506
+ const rows = [...all.filter(([command]) => !isApi(command) && !service.some(([named]) => named === command)).map(([command, one]) => ({
507
+ command,
508
+ does: one.title.length < one.description.length ? one.title : one.description,
509
+ ...one.writes ? { writes: true } : {},
510
+ ...availabilityOf(one)
511
+ })), ...service.length ? [{
512
+ group: "service",
513
+ commands: service.map(([command]) => command)
514
+ }] : []];
515
+ return [...rows, ...api.length ? [apiGroup(api, prefix, AGENT_ANSWER_CHARS - JSON.stringify(rows).length)] : []];
516
+ }, "listingOf");
517
+ var searchAnswer = /* @__PURE__ */ __name$1((commands, prefix, { query = "", schema = false } = {}) => {
518
+ if (schema) {
519
+ const [command, one] = Object.entries(commands).find((entry) => isNamed(entry, normal(query))) ?? [];
520
+ if (command === void 0 || !one) throw new CliError("validation_error", `schema needs a command's exact name; "${query}" is none`);
521
+ const { next: _none, ...list } = listOf(`${prefix}_tools_search`, {
522
+ items: [{
523
+ ...fullMatch(command, one),
524
+ output: leanSchema(one, toJsonSchema(one.output ?? (one.answers ? entityAnswer(one.answers) : ANSWER)))
525
+ }],
526
+ limit: 1,
527
+ has_more: false
528
+ });
529
+ return list;
530
+ }
531
+ if (normal(query) === "api") {
532
+ const api = search(commands, "").filter(([command]) => isApi(command));
533
+ if (api.length) return unpaged(prefix, [apiGroup(api, prefix, AGENT_ANSWER_CHARS)], false);
534
+ }
535
+ const found = query.trim() ? matchesOf(commands, query) : [];
536
+ const items = query.trim() ? found.slice(0, MATCHES).map(([command, one], index) => index < FULL_MATCHES ? fullMatch(command, one) : shortMatch(command, one)) : listingOf(commands, prefix);
537
+ return unpaged(prefix, items, found.length > items.length);
538
+ }, "searchAnswer");
539
+ var unpaged = /* @__PURE__ */ __name$1((prefix, items, more) => {
540
+ const { next: _paging, page: page2, ...list } = listOf(`${prefix}_tools_search`, {
541
+ items,
542
+ limit: Math.max(items.length, 1),
543
+ has_more: more
544
+ });
545
+ const { next_page: _none, ...shown } = page2;
546
+ return {
547
+ ...list,
548
+ page: shown
549
+ };
550
+ }, "unpaged");
362
551
  var nearest = /* @__PURE__ */ __name$1((commands, asked) => {
363
552
  const words = normal(asked).split(" ");
364
553
  return Object.keys(commands).map((one) => ({
@@ -384,6 +573,97 @@ var runnableOnly = /* @__PURE__ */ __name$1((result, offered) => {
384
573
  } : part)
385
574
  };
386
575
  }, "runnableOnly");
576
+ var rewritten = /* @__PURE__ */ __name$1((result, body) => ({
577
+ ...result,
578
+ structuredContent: body,
579
+ content: result.content.map((part) => part.type === "text" ? {
580
+ ...part,
581
+ text: JSON.stringify(body)
582
+ } : part)
583
+ }), "rewritten");
584
+ var cutPage = /* @__PURE__ */ __name$1((body, command, one, args) => {
585
+ const { items, page: page2 } = body;
586
+ if (one.writes || !Array.isArray(items) || page2?.mode !== "page" || typeof page2.limit !== "number") return void 0;
587
+ if (!("page" in one.input.entries && "limit" in one.input.entries)) return void 0;
588
+ const before = (Number(args.page ?? 1) - 1) * page2.limit;
589
+ if (!Number.isSafeInteger(before) || before < 0) return void 0;
590
+ const paged = body.next?.find((step) => step.kind === "command" && step.step === "page.next");
591
+ const { all: _all, ...rest } = paged?.kind === "command" ? paged.args : args;
592
+ const ends = [];
593
+ items.forEach((item, index) => {
594
+ ends.push((ends[index - 1] ?? 0) + JSON.stringify(item).length + (index > 0 ? 1 : 0));
595
+ });
596
+ for (let shown = items.length - 1; shown >= 1; shown--) {
597
+ if (before % shown !== 0) continue;
598
+ const values = {
599
+ page: before / shown + 2,
600
+ limit: shown
601
+ };
602
+ const stepArgs = {
603
+ ...rest,
604
+ ...values
605
+ };
606
+ const fresh = nextStep("page.next", {
607
+ command,
608
+ args: stepArgs,
609
+ values: { shown }
610
+ });
611
+ const step = paged?.kind === "command" ? {
612
+ ...paged,
613
+ args: stepArgs,
614
+ why: fresh.why
615
+ } : fresh;
616
+ const shell = {
617
+ ...body,
618
+ items: [],
619
+ page: {
620
+ ...page2,
621
+ limit: shown,
622
+ has_more: true,
623
+ next_page: values.page
624
+ },
625
+ next: [step, ...(body.next ?? []).filter((other) => other !== paged)].slice(0, MAX_NEXT_STEPS)
626
+ };
627
+ if (JSON.stringify(shell).length + (ends[shown - 1] ?? 0) <= 4e4) return {
628
+ ...shell,
629
+ items: items.slice(0, shown)
630
+ };
631
+ }
632
+ }, "cutPage");
633
+ var flagged = /* @__PURE__ */ __name$1((body, size, command, one, args) => {
634
+ const items = Array.isArray(body.items) ? body.items.length : 0;
635
+ const fits = Math.floor(items * AGENT_ANSWER_CHARS / size * .9);
636
+ if (!("limit" in one.input.entries) || fits < 1 || fits >= items) return body;
637
+ const { all: _all, page: _page, ...rest } = args;
638
+ const step = {
639
+ kind: "command",
640
+ step: "output.limit",
641
+ command,
642
+ args: {
643
+ ...rest,
644
+ limit: fits
645
+ },
646
+ why: `this answer is ${size} characters, more than an agent reads whole; limit ${fits} gives a smaller one`,
647
+ safe_to_auto_execute: false
648
+ };
649
+ return {
650
+ ...body,
651
+ next: [...body.next ?? [], step].slice(0, MAX_NEXT_STEPS)
652
+ };
653
+ }, "flagged");
654
+ var fitted = /* @__PURE__ */ __name$1((result, command, one, args) => {
655
+ const body = result.structuredContent;
656
+ if (one.writes || result.isError || !body) return result;
657
+ const size = JSON.stringify(body).length;
658
+ if (size <= 4e4) return result;
659
+ return rewritten(result, (() => {
660
+ try {
661
+ return cutPage(body, command, one, args);
662
+ } catch {
663
+ return;
664
+ }
665
+ })() ?? flagged(body, size, command, one, args));
666
+ }, "fitted");
387
667
  var takesNothing = /* @__PURE__ */ __name$1((one) => Object.values(one.input.entries).every((entry) => entry.type === "optional"), "takesNothing");
388
668
  var sampleOf = /* @__PURE__ */ __name$1((commands) => {
389
669
  const reading = Object.entries(commands).filter(([, one]) => !one.writes);
@@ -399,35 +679,25 @@ var registerCommands = /* @__PURE__ */ __name$1((server, prefix, commands, error
399
679
  server.registerTool(`${prefix}_tools_search`, {
400
680
  outputSchema: toStandardJsonSchema(looseObject({})),
401
681
  title: "Find a command",
402
- description: `Find the command for a task \u2014 ${tasks} \u2014 before calling ${prefix}_read or ${prefix}_write with it. Each match gives its command, whether it writes, its arguments and the shape of its answer. With no words, lists every command and title, without arguments.`,
403
- inputSchema: toStandardJsonSchema(strictObject({ query: optional(pipe(string(), description("words that describe the task"))) })),
682
+ description: `Find the command for a task \u2014 ${tasks} \u2014 before calling ${prefix}_read or ${prefix}_write with it. Up to ${MATCHES} matches, best first: each gives its command, what it does and whether it writes; the first ${FULL_MATCHES} also give their arguments. A command's exact name ranks it first. With no words, lists every command a line, by group; "api" lists the api commands.`,
683
+ inputSchema: toStandardJsonSchema(strictObject({
684
+ query: optional(pipe(string(), description("words that describe the task"))),
685
+ schema: optional(pipe(boolean(), description("with a command's exact name as query: also its answer's schema, as an agent reads it")))
686
+ })),
404
687
  annotations: {
405
688
  ...READ,
406
689
  openWorldHint: false,
407
690
  idempotentHint: true
408
691
  }
409
- }, async ({ query }) => {
410
- const found = search(commands, query ?? "");
411
- const items = query?.trim() ? found.slice(0, MATCHES).map(([command, one]) => ({
412
- command,
413
- title: one.title,
414
- description: one.description,
415
- writes: one.writes,
416
- availability: one.availability?.() ?? { available: true },
417
- arguments: toJsonSchema(one.input),
418
- output: toJsonSchema(one.output ?? ANSWER)
419
- })) : found.map(([command, one]) => ({
420
- command,
421
- title: one.title,
422
- writes: one.writes,
423
- availability: one.availability?.() ?? { available: true }
424
- }));
425
- const { next: _paging, ...list } = listOf(`${prefix}_tools_search`, {
426
- items,
427
- limit: Math.max(items.length, query?.trim() ? MATCHES : 1),
428
- has_more: found.length > items.length
429
- });
430
- return answered(list);
692
+ }, async ({ query, schema }) => {
693
+ try {
694
+ return answered(searchAnswer(commands, prefix, {
695
+ query: query ?? "",
696
+ schema: schema === true
697
+ }));
698
+ } catch (error) {
699
+ return failed(error, errors);
700
+ }
431
701
  });
432
702
  const callers = {
433
703
  env: process.env,
@@ -440,16 +710,18 @@ var registerCommands = /* @__PURE__ */ __name$1((server, prefix, commands, error
440
710
  const one = command === void 0 ? void 0 : commands[command];
441
711
  if (command === void 0 || !one) {
442
712
  withheld?.(normal(asked));
443
- const near = nearest(commands, asked);
444
- throw new CliError("validation_error", `no command "${asked}" here${near.length ? ` \u2014 did you mean ${near.map((name) => `"${name}"`).join(", ")}?` : ""}; ${prefix}_tools_search finds one`);
713
+ const near2 = nearest(commands, asked);
714
+ throw new CliError("validation_error", `no command "${asked}" here${near2.length ? ` \u2014 did you mean ${near2.map((name) => `"${name}"`).join(", ")}?` : ""}; ${prefix}_tools_search finds one`);
445
715
  }
446
716
  if (one.writes !== writing) throw new CliError("validation_error", `"${command}" ${writing ? "only reads" : "writes"}: call it with ${prefix}_${writing ? "read" : "write"}`);
447
717
  const args = writing ? agentArguments(given ?? {}) : given ?? {};
448
718
  const caller = currentCaller() ?? callerOf(ctx, command.replace(/[ -]/g, "_"), callers);
449
- if (one.checked) return runnableOnly(await withCaller(caller, () => one.run(args, ctx)), (named) => byNormal.has(normal(named)));
719
+ const offered = /* @__PURE__ */ __name$1((named) => byNormal.has(normal(named)), "offered");
720
+ if (one.checked) return fitted(runnableOnly(await withCaller(caller, () => one.run(args, ctx)), offered), command, one, args);
450
721
  const parsed = safeParse(strictObject(one.input.entries), args);
451
722
  if (!parsed.success) throw new CliError("validation_error", `${command}: ${summarize(parsed.issues)}`, { arguments: toJsonSchema(one.input) });
452
- return runnableOnly(await withCaller(caller, () => one.run(parsed.output, ctx)), (named) => byNormal.has(normal(named)));
723
+ const input = parsed.output;
724
+ return fitted(runnableOnly(await withCaller(caller, () => one.run(input, ctx)), offered), command, one, input);
453
725
  } catch (error) {
454
726
  return failed(error, errors);
455
727
  }
@@ -485,5 +757,7 @@ var surfaceCommands = /* @__PURE__ */ __name$1((tools, registration) => {
485
757
  run: /* @__PURE__ */ __name$1((args, ctx) => run(key, definition, args, ctx), "run")
486
758
  }]));
487
759
  }, "surfaceCommands");
488
- var outputOf = /* @__PURE__ */ __name$1(({ entity, view }) => answerSchema(ENTITIES[view ? `${entity}.${view}` : entity] ?? unknown()), "outputOf");
489
- export { tool as _, answered as a, failed as c, outcomeOf as d, outputOf as f, tierOf as g, surfaceCommands as h, WRITE as i, message as l, search as m, Picture as n, chatOf as o, registerCommands as p, READ as r, commandOf as s, BinaryResource as t, normal as u, toolKey as v };
760
+ var answersOf = /* @__PURE__ */ __name$1(({ entity, view }) => view ? `${entity}.${view}` : entity, "answersOf");
761
+ var outputOf = /* @__PURE__ */ __name$1((output) => entityAnswer(answersOf(output)), "outputOf");
762
+ var entityAnswer = /* @__PURE__ */ __name$1((name) => answerSchema(ENTITIES[name] ?? unknown()), "entityAnswer");
763
+ export { tool as C, tierOf as S, outputOf as _, WRITE as a, searchAnswer as b, argumentsOf as c, failed as d, leansRead as f, outcomeOf as g, normal as h, READ as i, chatOf as l, message as m, BinaryResource as n, answered as o, matchesOf as p, Picture as r, answersOf as s, AGENT_ANSWER_CHARS as t, commandOf as u, registerCommands as v, toolKey as w, surfaceCommands as x, search as y };
@@ -1,8 +1,8 @@
1
1
  import "./rolldown-runtime-C_t765_o.js";
2
- import { k as __name$1 } from "./start-Dtq56YXe.js";
3
- import { a as asciiDigit, c as markdownLineEnding, i as asciiControl, l as markdownLineEndingOrSpace, n as asciiAlphanumeric, o as asciiHexDigit, r as asciiAtext, s as asciiPunctuation, t as asciiAlpha, u as markdownSpace } from "./chunk-CCFBHR4O-DAuKd8rI.js";
4
- import { i as htmlRawNames, n as decodeNamedCharacterReference, r as htmlBlockNames, t as classifyCharacter } from "./chunk-DDXCCEI4-CHLrblc1.js";
5
- import { t as normalizeIdentifier } from "./chunk-UH2H3OLE-R_6H5D7o.js";
2
+ import { k as __name$1 } from "./start-CqQGB7xI.js";
3
+ import { a as asciiDigit, c as markdownLineEnding, i as asciiControl, l as markdownLineEndingOrSpace, n as asciiAlphanumeric, o as asciiHexDigit, r as asciiAtext, s as asciiPunctuation, t as asciiAlpha, u as markdownSpace } from "./chunk-CCFBHR4O-Bhxq5eaI.js";
4
+ import { i as htmlRawNames, n as decodeNamedCharacterReference, r as htmlBlockNames, t as classifyCharacter } from "./chunk-DDXCCEI4-CBg_l4Ro.js";
5
+ import { t as normalizeIdentifier } from "./chunk-UH2H3OLE-QNxQo07O.js";
6
6
  import { createRequire } from "node:module";
7
7
  createRequire(import.meta.url);
8
8
  function splice(list2, start, remove, items) {
@@ -1,12 +1,12 @@
1
1
  import "./rolldown-runtime-C_t765_o.js";
2
- import { T as readOnlyLockOf, k as __name$1 } from "./start-Dtq56YXe.js";
3
- import { AR as string, Ac as connectedFor, DR as regex, Da as mcpUrlOf, Dl as wholeList, Ek as levelFor, GO as fetchesAt, Hs as CHART_KINDS, Ks as chartAnswer, Kw as storedDeps, Lv as guardFor, NA as rootOf2, OS as pdfPreviewLimits, QT as warmEmbedders, SR as optional, Sk as judgedTargets, TR as pipe, UA as sealed, UO as environmentOf, Us as CHART_SIZE, Wt as refuseWriteBeforeConnecting, Xs as chartRenderer, Yi as findCommand, Ys as chartPng, ZA as snakeKeys, ZR as sharedConfigPath, Zs as chatChart, _A as readsOverMcpAt, _T as capability, _z as isCliFailure, aR as description, bD as DEFAULT_OUTPUT_BYTES, bR as object, fR as maxValue, fk as itemOf, gO as changesAuthorityAt, ga as agentJson, gf as lackedNeed, gz as withCaller, hA as readKeysForCommand, kR as strictObject, lc as registerPrompts, mR as minValue, mc as syncsFirst, oM as typedCommand, oa as mcpHttpMarker, on as stdinFieldOf, oz as storePath, pR as minLength, qO as fetchesOnlyAt, rc as keepRefreshedRefs, sR as integer, tc as engineIssue, tm as servicesFor, vA as recalledAccount, wR as picklist, yR as number, yS as openStore, z_ as dateWindow, zv as imageSize } from "./index-BOgkxLir.js";
4
- import { h as xr, m as xS, p as vS, r as KR } from "./chunk-PSD6373C-wlicX185.js";
5
- import { t as answeredWire } from "./chunk-NX2VS2ER-DS6Urg3e.js";
6
- import { i as callingAgent, r as callerOf } from "./chunk-GJTANPFI-5L6Owk-H.js";
7
- import { _ as tool, a as answered, c as failed, d as outcomeOf, f as outputOf, g as tierOf, h as surfaceCommands, i as WRITE, l as message, n as Picture, o as chatOf, p as registerCommands, r as READ, s as commandOf, t as BinaryResource, u as normal, v as toolKey } from "./chunk-4ZM6SE7G-DNDxhi8l.js";
8
- import { n as toolsFromCommands, t as runCommandForAgent } from "./chunk-ACWFPMZF-DkR70AOW.js";
9
- import { n as instructions } from "./chunk-6ZUQA7OL-ofpF0AvH.js";
2
+ import { T as readOnlyLockOf, k as __name$1 } from "./start-CqQGB7xI.js";
3
+ import { $s as chatChart, AS as pdfPreviewLimits, Ak as levelFor, CR as number, Da as mcpUrlOf, ER as optional, Ek as judgedTargets, Gs as CHART_SIZE, Js as chartAnswer, Jw as storedDeps, LA as rootOf2, Mc as connectedFor, NR as strictObject, OR as picklist, PR as string, Qs as chartRenderer, SA as recalledAccount, SD as DEFAULT_OUTPUT_BYTES, V_ as dateWindow, Vv as imageSize, Ws as CHART_KINDS, Wt as refuseWriteBeforeConnecting, YO as fetchesAt, Yi as findCommand, ZO as fetchesOnlyAt, Zs as chartPng, _R as minLength, ac as keepRefreshedRefs, bO as changesAuthorityAt, bz as withCaller, dR as integer, dc as registerPrompts, eE as warmEmbedders, gR as maxValue, ga as agentJson, gc as syncsFirst, gk as itemOf, hs as isUpkeep, jR as regex, kR as pipe, kl as wholeList, lR as description, oa as mcpHttpMarker, on as stdinFieldOf, qA as sealed, qO as environmentOf, rc as engineIssue, rm as servicesFor, tj as snakeKeys, tz as sharedConfigPath, uM as typedCommand, uz as storePath, vR as minValue, vf as lackedNeed, wR as object, xA as readsOverMcpAt, xS as openStore, xz as isCliFailure, yA as readKeysForCommand, yT as capability, zv as guardFor } from "./index-CTvUjqLX.js";
4
+ import { h as xr, m as xS, p as vS, r as KR } from "./chunk-PSD6373C-DgL0rhKe.js";
5
+ import { t as answeredWire } from "./chunk-NX2VS2ER-CWN0zXqZ.js";
6
+ import { i as callingAgent, r as callerOf } from "./chunk-GJTANPFI-DlUMnFUQ.js";
7
+ import { C as tool, S as tierOf, _ as outputOf, a as WRITE, d as failed, g as outcomeOf, h as normal, i as READ, l as chatOf, m as message, n as BinaryResource, o as answered, r as Picture, s as answersOf, u as commandOf, v as registerCommands, w as toolKey, x as surfaceCommands } from "./chunk-4HGRFFTO-fNvELOjI.js";
8
+ import { n as toolsFromCommands, t as runCommandForAgent } from "./chunk-TFRAD7RO-BVAK9frq.js";
9
+ import { n as instructions } from "./chunk-GRGGW52W-Fkw6omOx.js";
10
10
  import { createRequire } from "node:module";
11
11
  import { CliError, errorObjectOf, mcpErrorResult, visibleControls } from "@wirecat/cli-base";
12
12
  import { randomUUID } from "node:crypto";
@@ -500,7 +500,8 @@ var createServer = /* @__PURE__ */ __name$1((command, context, messenger, sessio
500
500
  stdin,
501
501
  connection,
502
502
  environment: agentEnvironment,
503
- caller
503
+ caller,
504
+ ...one.writes ? {} : { view: {} }
504
505
  }).then(async (answer) => {
505
506
  finish?.("error" in answer && !harmless(answer.error.error.code));
506
507
  await held?.catch(() => void 0);
@@ -519,7 +520,11 @@ var createServer = /* @__PURE__ */ __name$1((command, context, messenger, sessio
519
520
  writes: one.writes,
520
521
  availability: one.availability,
521
522
  input: one.input,
522
- ...one.output ? { output: outputOf(one.output) } : {},
523
+ ...one.output ? {
524
+ output: outputOf(one.output),
525
+ answers: answersOf(one.output)
526
+ } : {},
527
+ ...isUpkeep(findCommand(root, one.path)) ? { upkeep: true } : {},
523
528
  run: /* @__PURE__ */ __name$1(async (args, ctx) => {
524
529
  const startedAt = Date.now();
525
530
  const traceparent = ctx?.mcpReq?._meta?.traceparent;
@@ -571,6 +576,7 @@ var createServer = /* @__PURE__ */ __name$1((command, context, messenger, sessio
571
576
  session,
572
577
  withStore: context.withStore,
573
578
  targets,
579
+ view: {},
574
580
  log: audit,
575
581
  around: /* @__PURE__ */ __name$1((key, definition, work) => {
576
582
  refreshPermissions();
@@ -665,7 +671,7 @@ var serveOverStdio = /* @__PURE__ */ __name$1(async (command, context, messenger
665
671
  }, "serveOverStdio");
666
672
  var serveOverHttpUntilStopped = /* @__PURE__ */ __name$1(async (command, context, messenger, options, http) => {
667
673
  const { session, embedders, build, log } = createServer(command, context, messenger, options);
668
- const { serveOverHttp } = await import("./serve-7KRXCBBZ-BO9BKhWL.js");
674
+ const { serveOverHttp } = await import("./serve-7KRXCBBZ-EVSG16Mc.js");
669
675
  const appName = messenger.app.command;
670
676
  const appEnvPrefix = messenger.app.envPrefix;
671
677
  const listening = await serveOverHttp(build, {
@@ -1,5 +1,5 @@
1
1
  import "./rolldown-runtime-C_t765_o.js";
2
- import { k as __name$1 } from "./start-Dtq56YXe.js";
2
+ import { k as __name$1 } from "./start-CqQGB7xI.js";
3
3
  import { createRequire } from "node:module";
4
4
  createRequire(import.meta.url);
5
5
  var asciiAlpha = regexCheck(/[A-Za-z]/);
@@ -1,6 +1,6 @@
1
1
  import "./rolldown-runtime-C_t765_o.js";
2
- import { k as __name$1 } from "./start-Dtq56YXe.js";
3
- import { d as unicodePunctuation, f as unicodeWhitespace, l as markdownLineEndingOrSpace } from "./chunk-CCFBHR4O-DAuKd8rI.js";
2
+ import { k as __name$1 } from "./start-CqQGB7xI.js";
3
+ import { d as unicodePunctuation, f as unicodeWhitespace, l as markdownLineEndingOrSpace } from "./chunk-CCFBHR4O-Bhxq5eaI.js";
4
4
  import { createRequire } from "node:module";
5
5
  createRequire(import.meta.url);
6
6
  var characterEntities = {
@@ -1,4 +1,4 @@
1
- import { n as convert } from "./chunk-T6V6LFHT-Dwv7XUuC.js";
1
+ import { n as convert } from "./chunk-T6V6LFHT-BazTZ25Y.js";
2
2
  import { createRequire } from "node:module";
3
3
  createRequire(import.meta.url);
4
4
  var phrasing = convert([
@@ -1,5 +1,5 @@
1
1
  import "./rolldown-runtime-C_t765_o.js";
2
- import { k as __name$1 } from "./start-Dtq56YXe.js";
2
+ import { k as __name$1 } from "./start-CqQGB7xI.js";
3
3
  import { createRequire } from "node:module";
4
4
  createRequire(import.meta.url);
5
5
  var VOID = -1;