kennel 0.2.24 → 0.2.26

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 (88) hide show
  1. package/dist/cli/dispatch.js +2 -2
  2. package/dist/cli/usage.js +7 -1
  3. package/dist/core/api-client.js +1 -2
  4. package/dist/core/command.js +1 -1
  5. package/dist/core/core-folders.js +6 -2
  6. package/dist/core/runtime.js +30 -4657
  7. package/dist/mcp/install-page.d.ts +1 -1
  8. package/dist/mcp/install-page.js +419 -4
  9. package/dist/package/preview.d.ts +4 -0
  10. package/dist/package/preview.js +790 -4990
  11. package/dist/site/hot-viewer.js +1 -1
  12. package/dist/site/kinds.d.ts +1 -1
  13. package/dist/site/kinds.js +2 -59
  14. package/dist/site/terminal.d.ts +9 -1
  15. package/dist/site/terminal.js +162 -20
  16. package/package.json +5 -5
  17. package/web/assets/{abnfDiagram-VRR7QNED-aRemVX7f.js → abnfDiagram-VRR7QNED-CIyEzNaJ.js} +1 -1
  18. package/web/assets/{arc-BpDsnNTf.js → arc-Dba3y3eW.js} +1 -1
  19. package/web/assets/{architectureDiagram-ZJ3FMSHR-DNXHQddP.js → architectureDiagram-ZJ3FMSHR-DjFjO3tR.js} +1 -1
  20. package/web/assets/ask-tray-PMT6VVXN-ButKBzsY.js +23 -0
  21. package/web/assets/{blockDiagram-677ZJIJ3-CF4H4upo.js → blockDiagram-677ZJIJ3-C8ZQgtnK.js} +1 -1
  22. package/web/assets/{c4Diagram-LMCZKHZV-BPWUnjtx.js → c4Diagram-LMCZKHZV-DhWn2tZm.js} +1 -1
  23. package/web/assets/channel-BuqSObVl.js +1 -0
  24. package/web/assets/{chunk-2Q5K7J3B-DGsa7uv7.js → chunk-2Q5K7J3B-BEkPxYAB.js} +1 -1
  25. package/web/assets/{chunk-32BRIVSS-BRfic3W2.js → chunk-32BRIVSS-BZ0ofM9m.js} +1 -1
  26. package/web/assets/{chunk-5VM5RSS4-L2h7hliu.js → chunk-5VM5RSS4-CTgBiom0.js} +1 -1
  27. package/web/assets/{chunk-EX3LRPZG-BPgD_fgx.js → chunk-EX3LRPZG-B7lDJEfz.js} +1 -1
  28. package/web/assets/{chunk-JWPE2WC7-CckCaqu_.js → chunk-JWPE2WC7-DotlQGla.js} +1 -1
  29. package/web/assets/{chunk-MOJQB5TN-zyGgx-VW.js → chunk-MOJQB5TN-BSlB5ICN.js} +1 -1
  30. package/web/assets/{chunk-RYQCIY6F-Drzpg5IG.js → chunk-RYQCIY6F-BbDvgRvj.js} +1 -1
  31. package/web/assets/{chunk-V7JOEXUC-Di4ESKz-.js → chunk-V7JOEXUC-CqC2yHBO.js} +1 -1
  32. package/web/assets/{chunk-VR4S4FIN-C5lQtDI1.js → chunk-VR4S4FIN-18aLOCVw.js} +1 -1
  33. package/web/assets/{chunk-XXDRQBXY-Cell0ft2.js → chunk-XXDRQBXY-uulB67ep.js} +1 -1
  34. package/web/assets/classDiagram-OUVF2IWQ-xfk1LZB_.js +1 -0
  35. package/web/assets/classDiagram-v2-EOCWNBFH-xfk1LZB_.js +1 -0
  36. package/web/assets/{cose-bilkent-JH36ORCC-CiKtOFxl.js → cose-bilkent-JH36ORCC-C8yqL7ml.js} +1 -1
  37. package/web/assets/{cynefin-VYW2F7L2-B75MWf5b.js → cynefin-VYW2F7L2-D-wd85t1.js} +1 -1
  38. package/web/assets/{cynefinDiagram-TSTJHNR4-BmNVkSWW.js → cynefinDiagram-TSTJHNR4-rrV6rLov.js} +1 -1
  39. package/web/assets/{dagre-VKFMJZFB-BcM1Wqu5.js → dagre-VKFMJZFB-BxwiLhMr.js} +1 -1
  40. package/web/assets/{diagram-FQU43EPY-BiBWrxa8.js → diagram-FQU43EPY-8sr7lcj4.js} +1 -1
  41. package/web/assets/{diagram-G47NLZAW-Cfxukr7T.js → diagram-G47NLZAW-BQIU_Mie.js} +1 -1
  42. package/web/assets/{diagram-NH7WQ7WH-C83VkBYW.js → diagram-NH7WQ7WH-Bt-xVbVq.js} +1 -1
  43. package/web/assets/{diagram-OA4YK3LP-Oj0uj6CX.js → diagram-OA4YK3LP-p-i-3cps.js} +1 -1
  44. package/web/assets/{diagram-WEI45ONY-DhbL0nvt.js → diagram-WEI45ONY-E6t6-_mU.js} +1 -1
  45. package/web/assets/{ebnfDiagram-CCIWWBDH-D4JYp1UC.js → ebnfDiagram-CCIWWBDH-DCszfyU3.js} +1 -1
  46. package/web/assets/{entity-search-page-G6QEQNXT-UKzUU5id.js → entity-search-page-G6QEQNXT-D6cvoqrF.js} +1 -1
  47. package/web/assets/{erDiagram-Q63AITRT-C-oyRt9s.js → erDiagram-Q63AITRT-C4gBewIM.js} +1 -1
  48. package/web/assets/{flowDiagram-23GEKE2U-0Tplj9FK.js → flowDiagram-23GEKE2U-BEyFAV-g.js} +1 -1
  49. package/web/assets/{ganttDiagram-NO4QXBWP-wgh2e0B_.js → ganttDiagram-NO4QXBWP-Bat5BF2x.js} +1 -1
  50. package/web/assets/{gitGraphDiagram-IHSO6WYX-D6z9qDXa.js → gitGraphDiagram-IHSO6WYX-CGZs8b5E.js} +1 -1
  51. package/web/assets/index-DmJQJIC1.js +451 -0
  52. package/web/assets/{index-BGwTWQMJ.css → index-tpV2etC4.css} +1 -1
  53. package/web/assets/{infoDiagram-FWYZ7A6U-D3o7el5X.js → infoDiagram-FWYZ7A6U-Cglwuazb.js} +1 -1
  54. package/web/assets/{ishikawaDiagram-FXEZZL3T-CM0QyWYH.js → ishikawaDiagram-FXEZZL3T-C95-Gz9z.js} +1 -1
  55. package/web/assets/{journeyDiagram-5HDEW3XC-fmIoh0h6.js → journeyDiagram-5HDEW3XC-C055Trr6.js} +1 -1
  56. package/web/assets/{kanban-definition-HUTT4EX6-aEtqsiWf.js → kanban-definition-HUTT4EX6-CznSv3_t.js} +1 -1
  57. package/web/assets/{linear-aJ-2UZO5.js → linear-CnWGyi6E.js} +1 -1
  58. package/web/assets/{linked-session-header-M7WY6IGF-CltMJZiX.js → linked-session-header-M7WY6IGF-BFioq_q7.js} +1 -1
  59. package/web/assets/{mermaid.core-CL9g6xVu.js → mermaid.core-BIJiZKob.js} +4 -4
  60. package/web/assets/{mindmap-definition-LN4V7U3C-CtQo0XrW.js → mindmap-definition-LN4V7U3C-k97sTi1e.js} +1 -1
  61. package/web/assets/{pegDiagram-2B236MQR-ecu1L_3A.js → pegDiagram-2B236MQR-C-4ETzyd.js} +1 -1
  62. package/web/assets/{pieDiagram-ENE6RG2P-CdCKg3Cn.js → pieDiagram-ENE6RG2P-CH8gYIx3.js} +1 -1
  63. package/web/assets/{plugin-host-modules-Dz_BPJRS.js → plugin-host-modules-BI0aGGBk.js} +2 -2
  64. package/web/assets/{project-search-dialog-HJFGW4DG-CKtXc-UP.js → project-search-dialog-HJFGW4DG-DC6mBFkm.js} +1 -1
  65. package/web/assets/{project-search-page-NKQEBGPF-CMzuYEeM.js → project-search-page-NKQEBGPF-B0OxN-l5.js} +1 -1
  66. package/web/assets/{quadrantDiagram-ABIIQ3AL-Bt8r5TlW.js → quadrantDiagram-ABIIQ3AL-BFV2fyQY.js} +1 -1
  67. package/web/assets/{railroadDiagram-RFXS5EU6-DrWDVEVi.js → railroadDiagram-RFXS5EU6-Dxj8XtW1.js} +1 -1
  68. package/web/assets/{requirementDiagram-TGXJPOKE-Ewjwpo6V.js → requirementDiagram-TGXJPOKE-Drb3A2JL.js} +1 -1
  69. package/web/assets/{sankeyDiagram-HTMAVEWB-CJCMHuzX.js → sankeyDiagram-HTMAVEWB-DP7Lyg91.js} +1 -1
  70. package/web/assets/{selection-popup-532EHNCZ-py5aCy1E.js → selection-popup-532EHNCZ-C8EBNgOw.js} +1 -1
  71. package/web/assets/{sequenceDiagram-DBY2YBRQ-Chj-4L6Q.js → sequenceDiagram-DBY2YBRQ-6qzKd9e_.js} +1 -1
  72. package/web/assets/{sizeCapture-X5ZJPWSS-BguWhDIF.js → sizeCapture-X5ZJPWSS-DhCU_-w6.js} +1 -1
  73. package/web/assets/{stateDiagram-2N3HPSRC-BWisWMpK.js → stateDiagram-2N3HPSRC-C_BN15Uj.js} +1 -1
  74. package/web/assets/{stateDiagram-v2-6OUMAXLB-AiBXToz-.js → stateDiagram-v2-6OUMAXLB-DtNCoZjH.js} +1 -1
  75. package/web/assets/{swimlanes-5IMT3BWC-CxVQ97_C.js → swimlanes-5IMT3BWC-CW-FMmDB.js} +2 -2
  76. package/web/assets/swimlanesDiagram-G3AALYLV-Cak69Ty7.js +8 -0
  77. package/web/assets/{timeline-definition-FHXFAJF6-CCbI0InF.js → timeline-definition-FHXFAJF6-VX8Kq-Hg.js} +1 -1
  78. package/web/assets/{vennDiagram-L72KCM5P-mA5yKpJj.js → vennDiagram-L72KCM5P-DU3qCuRJ.js} +1 -1
  79. package/web/assets/{wardleyDiagram-EHGQE667-1Epw2EsU.js → wardleyDiagram-EHGQE667-CAA7wYyD.js} +1 -1
  80. package/web/assets/{xychartDiagram-FW5EYKEG-DM1CMD-p.js → xychartDiagram-FW5EYKEG-B-GbIjdQ.js} +1 -1
  81. package/web/index.html +2 -2
  82. package/README.md +0 -317
  83. package/web/assets/ask-tray-PMT6VVXN-HMPARq3A.js +0 -23
  84. package/web/assets/channel-CEZ4sDYU.js +0 -1
  85. package/web/assets/classDiagram-OUVF2IWQ-CjxqMQn2.js +0 -1
  86. package/web/assets/classDiagram-v2-EOCWNBFH-CjxqMQn2.js +0 -1
  87. package/web/assets/index-D_Fcgs3V.js +0 -451
  88. package/web/assets/swimlanesDiagram-G3AALYLV-DliPmGmf.js +0 -8
@@ -17078,9 +17078,6 @@ import { createHash as createHash5 } from "node:crypto";
17078
17078
 
17079
17079
  // node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/core.js
17080
17080
  var _a;
17081
- var NEVER = /* @__PURE__ */ Object.freeze({
17082
- status: "aborted"
17083
- });
17084
17081
  function $constructor(name, initializer, params) {
17085
17082
  function init(inst, def) {
17086
17083
  if (!inst._zod) {
@@ -17160,9 +17157,6 @@ function getEnumValues(entries) {
17160
17157
  const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
17161
17158
  return values;
17162
17159
  }
17163
- function joinValues(array, separator = "|") {
17164
- return array.map((val) => stringifyPrimitive(val)).join(separator);
17165
- }
17166
17160
  function jsonStringifyReplacer(_, value) {
17167
17161
  if (typeof value === "bigint")
17168
17162
  return value.toString();
@@ -17313,13 +17307,6 @@ function normalizeParams(_params) {
17313
17307
  return { ...params, error: () => params.error };
17314
17308
  return params;
17315
17309
  }
17316
- function stringifyPrimitive(value) {
17317
- if (typeof value === "bigint")
17318
- return value.toString() + "n";
17319
- if (typeof value === "string")
17320
- return `"${value}"`;
17321
- return `${value}`;
17322
- }
17323
17310
  function optionalKeys(shape) {
17324
17311
  return Object.keys(shape).filter((k) => {
17325
17312
  return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
@@ -17552,27 +17539,6 @@ function getLengthableOrigin(input) {
17552
17539
  return "string";
17553
17540
  return "unknown";
17554
17541
  }
17555
- function parsedType(data) {
17556
- const t = typeof data;
17557
- switch (t) {
17558
- case "number": {
17559
- return Number.isNaN(data) ? "nan" : "number";
17560
- }
17561
- case "object": {
17562
- if (data === null) {
17563
- return "null";
17564
- }
17565
- if (Array.isArray(data)) {
17566
- return "array";
17567
- }
17568
- const obj = data;
17569
- if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
17570
- return obj.constructor.name;
17571
- }
17572
- }
17573
- }
17574
- return t;
17575
- }
17576
17542
  function issue(...args) {
17577
17543
  const [iss, input, inst] = args;
17578
17544
  if (typeof iss === "string") {
@@ -19609,116 +19575,6 @@ function handleRefineResult(result, payload, input, inst) {
19609
19575
  payload.issues.push(issue(_iss));
19610
19576
  }
19611
19577
  }
19612
- // node_modules/.bun/zod@4.4.3/node_modules/zod/v4/locales/en.js
19613
- var error = () => {
19614
- const Sizable = {
19615
- string: { unit: "characters", verb: "to have" },
19616
- file: { unit: "bytes", verb: "to have" },
19617
- array: { unit: "items", verb: "to have" },
19618
- set: { unit: "items", verb: "to have" },
19619
- map: { unit: "entries", verb: "to have" }
19620
- };
19621
- function getSizing(origin) {
19622
- return Sizable[origin] ?? null;
19623
- }
19624
- const FormatDictionary = {
19625
- regex: "input",
19626
- email: "email address",
19627
- url: "URL",
19628
- emoji: "emoji",
19629
- uuid: "UUID",
19630
- uuidv4: "UUIDv4",
19631
- uuidv6: "UUIDv6",
19632
- nanoid: "nanoid",
19633
- guid: "GUID",
19634
- cuid: "cuid",
19635
- cuid2: "cuid2",
19636
- ulid: "ULID",
19637
- xid: "XID",
19638
- ksuid: "KSUID",
19639
- datetime: "ISO datetime",
19640
- date: "ISO date",
19641
- time: "ISO time",
19642
- duration: "ISO duration",
19643
- ipv4: "IPv4 address",
19644
- ipv6: "IPv6 address",
19645
- mac: "MAC address",
19646
- cidrv4: "IPv4 range",
19647
- cidrv6: "IPv6 range",
19648
- base64: "base64-encoded string",
19649
- base64url: "base64url-encoded string",
19650
- json_string: "JSON string",
19651
- e164: "E.164 number",
19652
- jwt: "JWT",
19653
- template_literal: "input"
19654
- };
19655
- const TypeDictionary = {
19656
- nan: "NaN"
19657
- };
19658
- return (issue) => {
19659
- switch (issue.code) {
19660
- case "invalid_type": {
19661
- const expected = TypeDictionary[issue.expected] ?? issue.expected;
19662
- const receivedType = parsedType(issue.input);
19663
- const received = TypeDictionary[receivedType] ?? receivedType;
19664
- return `Invalid input: expected ${expected}, received ${received}`;
19665
- }
19666
- case "invalid_value":
19667
- if (issue.values.length === 1)
19668
- return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
19669
- return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
19670
- case "too_big": {
19671
- const adj = issue.inclusive ? "<=" : "<";
19672
- const sizing = getSizing(issue.origin);
19673
- if (sizing)
19674
- return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
19675
- return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
19676
- }
19677
- case "too_small": {
19678
- const adj = issue.inclusive ? ">=" : ">";
19679
- const sizing = getSizing(issue.origin);
19680
- if (sizing) {
19681
- return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
19682
- }
19683
- return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
19684
- }
19685
- case "invalid_format": {
19686
- const _issue = issue;
19687
- if (_issue.format === "starts_with") {
19688
- return `Invalid string: must start with "${_issue.prefix}"`;
19689
- }
19690
- if (_issue.format === "ends_with")
19691
- return `Invalid string: must end with "${_issue.suffix}"`;
19692
- if (_issue.format === "includes")
19693
- return `Invalid string: must include "${_issue.includes}"`;
19694
- if (_issue.format === "regex")
19695
- return `Invalid string: must match pattern ${_issue.pattern}`;
19696
- return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
19697
- }
19698
- case "not_multiple_of":
19699
- return `Invalid number: must be a multiple of ${issue.divisor}`;
19700
- case "unrecognized_keys":
19701
- return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
19702
- case "invalid_key":
19703
- return `Invalid key in ${issue.origin}`;
19704
- case "invalid_union":
19705
- if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
19706
- const opts = issue.options.map((o) => `'${o}'`).join(" | ");
19707
- return `Invalid discriminator value. Expected ${opts}`;
19708
- }
19709
- return "Invalid input";
19710
- case "invalid_element":
19711
- return `Invalid value in ${issue.origin}`;
19712
- default:
19713
- return `Invalid input`;
19714
- }
19715
- };
19716
- };
19717
- function en_default() {
19718
- return {
19719
- localeError: error()
19720
- };
19721
- }
19722
19578
  // node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/registries.js
19723
19579
  var _a2;
19724
19580
  var $output = Symbol("ZodOutput");
@@ -21244,9 +21100,6 @@ var ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
21244
21100
  $ZodURL.init(inst, def);
21245
21101
  ZodStringFormat.init(inst, def);
21246
21102
  });
21247
- function url(params) {
21248
- return _url(ZodURL, params);
21249
- }
21250
21103
  var ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
21251
21104
  $ZodEmoji.init(inst, def);
21252
21105
  ZodStringFormat.init(inst, def);
@@ -21768,8 +21621,6 @@ function refine(fn, _params = {}) {
21768
21621
  function superRefine(fn, params) {
21769
21622
  return _superRefine(fn, params);
21770
21623
  }
21771
- // node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/external.js
21772
- config(en_default());
21773
21624
  // packages/schemas/src/data/contract.ts
21774
21625
  var issueSchema = object({ path: string2(), message: string2() });
21775
21626
  var coreRecordIconSchema = object({
@@ -21791,7 +21642,7 @@ var coreCollectionUiSchema = object({
21791
21642
  primaryField: string2(),
21792
21643
  secondaryField: string2().optional(),
21793
21644
  filters: array(string2()),
21794
- numericFilters: array(string2()),
21645
+ numericFilters: array(string2()).default([]),
21795
21646
  sort: array(coreCollectionSortSchema).optional()
21796
21647
  });
21797
21648
  var collectionSummarySchema = object({
@@ -22009,7 +21860,6 @@ var routes = {
22009
21860
  method: "get",
22010
21861
  query: emptyQuery,
22011
21862
  response: object({
22012
- acp: boolean2(),
22013
21863
  download: boolean2(),
22014
21864
  hostActions: _enum(["local", "none"]),
22015
21865
  local: boolean2(),
@@ -22155,7 +22005,7 @@ import {
22155
22005
  sep as sep7
22156
22006
  } from "node:path";
22157
22007
 
22158
- // node_modules/.bun/@raggle-ai+barkdown@0.6.1+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/react.js
22008
+ // node_modules/.bun/@raggle-ai+barkdown@0.7.0+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/react.js
22159
22009
  var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
22160
22010
  var import_react6 = __toESM(require_react(), 1);
22161
22011
 
@@ -22332,7 +22182,7 @@ var defaultSchema = {
22332
22182
  "var"
22333
22183
  ]
22334
22184
  };
22335
- // node_modules/.bun/@raggle-ai+barkdown@0.6.1+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/react.js
22185
+ // node_modules/.bun/@raggle-ai+barkdown@0.7.0+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/react.js
22336
22186
  var runtime = __toESM(require_jsx_runtime(), 1);
22337
22187
 
22338
22188
  // node_modules/.bun/gemoji@8.1.0/node_modules/gemoji/index.js
@@ -35429,7 +35279,7 @@ var gemoji = [
35429
35279
  }
35430
35280
  ];
35431
35281
 
35432
- // node_modules/.bun/@raggle-ai+barkdown@0.6.1+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/emoji.js
35282
+ // node_modules/.bun/@raggle-ai+barkdown@0.7.0+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/emoji.js
35433
35283
  var shortcodeToEmoji = new Map(gemoji.flatMap((entry) => entry.names.map((name) => [
35434
35284
  name,
35435
35285
  {
@@ -35438,36 +35288,36 @@ var shortcodeToEmoji = new Map(gemoji.flatMap((entry) => entry.names.map((name)
35438
35288
  }
35439
35289
  ])));
35440
35290
 
35441
- // node_modules/.bun/@raggle-ai+barkdown@0.6.1+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/link.js
35291
+ // node_modules/.bun/@raggle-ai+barkdown@0.7.0+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/link.js
35442
35292
  var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
35443
35293
 
35444
- // node_modules/.bun/@raggle-ai+barkdown@0.6.1+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/rehype-collapsible-headings.js
35294
+ // node_modules/.bun/@raggle-ai+barkdown@0.7.0+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/rehype-collapsible-headings.js
35445
35295
  var HEADING_TAGS = new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
35446
35296
 
35447
- // node_modules/.bun/@raggle-ai+barkdown@0.6.1+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/react-collapsible-sections.js
35297
+ // node_modules/.bun/@raggle-ai+barkdown@0.7.0+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/react-collapsible-sections.js
35448
35298
  var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
35449
35299
  var import_react3 = __toESM(require_react(), 1);
35450
35300
 
35451
- // node_modules/.bun/@raggle-ai+barkdown@0.6.1+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/react-heading-copy.js
35301
+ // node_modules/.bun/@raggle-ai+barkdown@0.7.0+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/react-heading-copy.js
35452
35302
  var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
35453
35303
  var import_react = __toESM(require_react(), 1);
35454
35304
 
35455
- // node_modules/.bun/@raggle-ai+barkdown@0.6.1+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/use-copy-to-clipboard.js
35305
+ // node_modules/.bun/@raggle-ai+barkdown@0.7.0+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/use-copy-to-clipboard.js
35456
35306
  var import_react2 = __toESM(require_react(), 1);
35457
35307
 
35458
- // node_modules/.bun/@raggle-ai+barkdown@0.6.1+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/rehype-heading-lines.js
35308
+ // node_modules/.bun/@raggle-ai+barkdown@0.7.0+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/rehype-heading-lines.js
35459
35309
  var HEADING_TAGS2 = new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
35460
35310
 
35461
- // node_modules/.bun/@raggle-ai+barkdown@0.6.1+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/react-mermaid.js
35311
+ // node_modules/.bun/@raggle-ai+barkdown@0.7.0+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/react-mermaid.js
35462
35312
  var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
35463
35313
  var import_react4 = __toESM(require_react(), 1);
35464
35314
  var renderQueue = Promise.resolve();
35465
35315
 
35466
- // node_modules/.bun/@raggle-ai+barkdown@0.6.1+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/react-media.js
35316
+ // node_modules/.bun/@raggle-ai+barkdown@0.7.0+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/react-media.js
35467
35317
  var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
35468
35318
  var import_react5 = __toESM(require_react(), 1);
35469
35319
 
35470
- // node_modules/.bun/@raggle-ai+barkdown@0.6.1+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/react.js
35320
+ // node_modules/.bun/@raggle-ai+barkdown@0.7.0+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/react.js
35471
35321
  var markdownSchema = {
35472
35322
  ...defaultSchema,
35473
35323
  tagNames: [
@@ -35567,7 +35417,7 @@ __exportCjs(exports_dist, {
35567
35417
  var composer = require_composer();
35568
35418
  var Document = require_Document();
35569
35419
  var Schema = require_Schema();
35570
- var errors3 = require_errors();
35420
+ var errors2 = require_errors();
35571
35421
  var Alias = require_Alias();
35572
35422
  var identity = require_identity();
35573
35423
  var Pair = require_Pair();
@@ -35583,9 +35433,9 @@ var visit = require_visit();
35583
35433
  var $Composer = composer.Composer;
35584
35434
  var $Document = Document.Document;
35585
35435
  var $Schema = Schema.Schema;
35586
- var $YAMLError = errors3.YAMLError;
35587
- var $YAMLParseError = errors3.YAMLParseError;
35588
- var $YAMLWarning = errors3.YAMLWarning;
35436
+ var $YAMLError = errors2.YAMLError;
35437
+ var $YAMLParseError = errors2.YAMLParseError;
35438
+ var $YAMLWarning = errors2.YAMLWarning;
35589
35439
  var $Alias = Alias.Alias;
35590
35440
  var $isAlias = identity.isAlias;
35591
35441
  var $isCollection = identity.isCollection;
@@ -35610,7 +35460,7 @@ var $stringify = publicApi.stringify;
35610
35460
  var $visit = visit.visit;
35611
35461
  var $visitAsync = visit.visitAsync;
35612
35462
 
35613
- // packages/markdown/src/metadata.ts
35463
+ // packages/ui/src/markdown/metadata.ts
35614
35464
  function frontmatter(content) {
35615
35465
  const match = /^---\s*\r?\n([\s\S]*?)\r?\n---\s*(?:\r?\n|$)/.exec(content);
35616
35466
  if (!match)
@@ -35655,11 +35505,11 @@ function markdownMetadata(content) {
35655
35505
  title: metadata?.title ?? leadingHeading(body)
35656
35506
  };
35657
35507
  }
35658
- // node_modules/.bun/@raggle-ai+barkdown@0.6.1+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/node.js
35508
+ // node_modules/.bun/@raggle-ai+barkdown@0.7.0+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/node.js
35659
35509
  import { readdir, readFile } from "node:fs/promises";
35660
35510
  import { relative, resolve as resolve2, sep } from "node:path";
35661
35511
 
35662
- // node_modules/.bun/@raggle-ai+barkdown@0.6.1+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/documents.js
35512
+ // node_modules/.bun/@raggle-ai+barkdown@0.7.0+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/documents.js
35663
35513
  var extensions = new Set([
35664
35514
  ".htm",
35665
35515
  ".html",
@@ -35679,7 +35529,7 @@ function documentKind(path) {
35679
35529
  return;
35680
35530
  }
35681
35531
 
35682
- // node_modules/.bun/@raggle-ai+barkdown@0.6.1+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/node.js
35532
+ // node_modules/.bun/@raggle-ai+barkdown@0.7.0+22117d1132b05fb8/node_modules/@raggle-ai/barkdown/dist/node.js
35683
35533
  var skipped = new Set([".git", ".turbo", "dist", "node_modules"]);
35684
35534
  async function readFolder(root) {
35685
35535
  const folder = resolve2(root);
@@ -35709,6 +35559,7 @@ async function readFolder(root) {
35709
35559
  documents: (await read(folder)).sort((left, right) => left.path.localeCompare(right.path))
35710
35560
  };
35711
35561
  }
35562
+
35712
35563
  // packages/api/src/server/folder-metadata-plugin.ts
35713
35564
  import { execFile as execFile4 } from "node:child_process";
35714
35565
 
@@ -35971,8 +35822,11 @@ import { join } from "node:path";
35971
35822
  // packages/schemas/src/data/icon-image.ts
35972
35823
  import { constants } from "node:fs";
35973
35824
  import { open } from "node:fs/promises";
35974
- import sharp from "sharp";
35975
35825
  var maxIconBytes = 512 * 1024;
35826
+ var importRuntime = new Function("specifier", "return import(specifier)");
35827
+ async function loadSharp() {
35828
+ return (await importRuntime("sharp")).default;
35829
+ }
35976
35830
  async function readIconFile(path) {
35977
35831
  const file = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW).catch(() => {
35978
35832
  return;
@@ -36000,6 +35854,7 @@ async function normalizeIcon(data) {
36000
35854
  if (!data.length || data.length > maxIconBytes)
36001
35855
  return;
36002
35856
  try {
35857
+ const sharp = await loadSharp();
36003
35858
  const image = sharp(data, {
36004
35859
  limitInputPixels: 1024 * 1024,
36005
35860
  failOn: "warning"
@@ -37664,7 +37519,7 @@ function createProjectDiscovery(load = discoverProjects) {
37664
37519
  };
37665
37520
  }
37666
37521
 
37667
- // packages/kinds/src/kinds.ts
37522
+ // packages/api/src/shared/document-kinds.ts
37668
37523
  var previewTextKinds = new Set([
37669
37524
  "code",
37670
37525
  "eml",
@@ -37816,6 +37671,7 @@ function mediaRawMime(path) {
37816
37671
  const extension = path.slice(path.lastIndexOf(".")).toLowerCase();
37817
37672
  return mediaMime[extension];
37818
37673
  }
37674
+
37819
37675
  // packages/api/src/server/folder-metadata-plugin.ts
37820
37676
  var {
37821
37677
  applyProjectFavorites,
@@ -38339,7 +38195,6 @@ function createFolderApi({
38339
38195
  return;
38340
38196
  if (url.pathname === "/api/capabilities") {
38341
38197
  sendContract(response, url, {
38342
- acp: !remote,
38343
38198
  download: true,
38344
38199
  hostActions: remote ? "none" : "local",
38345
38200
  local: !remote,
@@ -38877,4485 +38732,6 @@ function createFolderApi({
38877
38732
  };
38878
38733
  }
38879
38734
 
38880
- // packages/api/src/server/acp-live-plugin.ts
38881
- import { randomUUID as randomUUID3 } from "node:crypto";
38882
- import { Readable, Writable } from "node:stream";
38883
- import localSessions from "@raggle-ai/local/sessions";
38884
-
38885
- // packages/api/src/server/acp/process-manager.ts
38886
- import { spawn } from "node:child_process";
38887
-
38888
- class AcpProcessManager {
38889
- slots = new Map;
38890
- start(key, adapter) {
38891
- if (this.slots.has(key)) {
38892
- throw new DuplicateProcessError(key);
38893
- }
38894
- const stderrLimit = 256;
38895
- const stderrRing = [];
38896
- let exitResolver;
38897
- let exitCalled = false;
38898
- const onExit = new Promise((resolve) => {
38899
- exitResolver = resolve;
38900
- });
38901
- const child = spawn(adapter.command, adapter.args, {
38902
- env: process.env,
38903
- cwd: adapter.workingFolder,
38904
- shell: false,
38905
- stdio: ["pipe", "pipe", "pipe"]
38906
- });
38907
- const startedAt = new Date().toISOString();
38908
- const handle = {
38909
- stdin: child.stdin,
38910
- stdout: child.stdout,
38911
- stderr: child.stderr,
38912
- get state() {
38913
- return slot.state;
38914
- },
38915
- onExit
38916
- };
38917
- const slot = {
38918
- process: child,
38919
- handle,
38920
- state: "starting",
38921
- startedAt,
38922
- stderrRing,
38923
- stopResolver: null,
38924
- exitResolver
38925
- };
38926
- child.stderr.on("data", (chunk) => {
38927
- const text = chunk.toString("utf-8");
38928
- const lines = text.split(`
38929
- `);
38930
- for (const line of lines) {
38931
- if (line.length === 0)
38932
- continue;
38933
- stderrRing.push(line);
38934
- if (stderrRing.length > stderrLimit) {
38935
- stderrRing.splice(0, stderrRing.length - stderrLimit);
38936
- }
38937
- }
38938
- });
38939
- child.on("spawn", () => {
38940
- slot.state = "running";
38941
- });
38942
- child.on("error", (err) => {
38943
- stderrRing.push(`[spawn-error] ${err.message}`);
38944
- if (slot.state !== "stopping" && slot.state !== "stopped") {
38945
- slot.state = "errored";
38946
- }
38947
- if (!exitCalled) {
38948
- exitCalled = true;
38949
- exitResolver({ code: 1, signal: null });
38950
- this.slots.delete(key);
38951
- }
38952
- });
38953
- child.on("exit", (code, signal) => {
38954
- if (slot.state === "stopping") {
38955
- slot.state = "stopped";
38956
- } else if (slot.state !== "stopped") {
38957
- slot.state = code === 0 ? "stopped" : "errored";
38958
- }
38959
- slot.stopResolver?.();
38960
- slot.stopResolver = null;
38961
- if (!exitCalled) {
38962
- exitCalled = true;
38963
- exitResolver({ code, signal });
38964
- this.slots.delete(key);
38965
- }
38966
- });
38967
- this.slots.set(key, slot);
38968
- return handle;
38969
- }
38970
- async stop(key, graceMs = 5000, killMs = 2000) {
38971
- const slot = this.slots.get(key);
38972
- if (!slot)
38973
- return;
38974
- if (slot.state === "stopping" || slot.state === "stopped" || slot.state === "errored")
38975
- return;
38976
- slot.state = "stopping";
38977
- return new Promise((resolve, reject) => {
38978
- slot.stopResolver = resolve;
38979
- const killed = slot.process.kill("SIGTERM");
38980
- if (!killed) {
38981
- resolve();
38982
- return;
38983
- }
38984
- const escalate = setTimeout(() => {
38985
- slot.process.kill("SIGKILL");
38986
- const force = setTimeout(() => {
38987
- reject(new Error(`Process ${key} did not exit after SIGKILL (${killMs} ms)`));
38988
- }, killMs);
38989
- slot.process.on("exit", () => clearTimeout(force));
38990
- }, graceMs);
38991
- slot.process.on("exit", () => clearTimeout(escalate));
38992
- });
38993
- }
38994
- status(key) {
38995
- const slot = this.slots.get(key);
38996
- if (!slot)
38997
- return null;
38998
- return {
38999
- key,
39000
- state: slot.state,
39001
- pid: slot.process.pid ?? null,
39002
- startedAt: slot.startedAt,
39003
- exitCode: slot.process.exitCode ?? null,
39004
- signal: slot.process.signalCode,
39005
- stderrLines: [...slot.stderrRing]
39006
- };
39007
- }
39008
- activeKeys() {
39009
- return [...this.slots.keys()];
39010
- }
39011
- async stopAll(graceMs = 5000, killMs = 2000) {
39012
- const keys = this.activeKeys();
39013
- await Promise.all(keys.map((key) => this.stop(key, graceMs, killMs)));
39014
- }
39015
- }
39016
-
39017
- class DuplicateProcessError extends Error {
39018
- constructor(key) {
39019
- super(`Process slot "${key}" is already active. Stop it before starting a new one.`);
39020
- this.name = "DuplicateProcessError";
39021
- }
39022
- }
39023
-
39024
- // packages/api/src/server/acp/registry.ts
39025
- var adapters = new Map;
39026
- adapters.set("pi", {
39027
- id: "pi",
39028
- displayName: "Pi Coding Agent",
39029
- command: "pi-acp",
39030
- args: [],
39031
- workingFolder: "/tmp",
39032
- capabilities: [
39033
- "acp:tool_call",
39034
- "acp:resource_read",
39035
- "acp:prompt",
39036
- "acp:completion",
39037
- "acp:session_resume"
39038
- ],
39039
- enabled: true
39040
- });
39041
- adapters.set("opencode", {
39042
- id: "opencode",
39043
- displayName: "OpenCode",
39044
- command: "opencode",
39045
- args: ["acp"],
39046
- workingFolder: "/tmp",
39047
- capabilities: ["acp:tool_call", "acp:prompt", "acp:session_resume"],
39048
- enabled: true
39049
- });
39050
- function findAdapter(id) {
39051
- return adapters.get(id);
39052
- }
39053
-
39054
- // node_modules/.bun/@agentclientprotocol+sdk@1.3.0+68a1e3a0c4588df3/node_modules/@agentclientprotocol/sdk/dist/schema/index.js
39055
- var AGENT_METHODS = {
39056
- initialize: "initialize",
39057
- authenticate: "authenticate",
39058
- providers_list: "providers/list",
39059
- providers_set: "providers/set",
39060
- providers_disable: "providers/disable",
39061
- session_new: "session/new",
39062
- session_load: "session/load",
39063
- session_set_mode: "session/set_mode",
39064
- session_set_config_option: "session/set_config_option",
39065
- session_prompt: "session/prompt",
39066
- session_cancel: "session/cancel",
39067
- mcp_message: "mcp/message",
39068
- session_list: "session/list",
39069
- session_delete: "session/delete",
39070
- session_fork: "session/fork",
39071
- session_resume: "session/resume",
39072
- session_close: "session/close",
39073
- logout: "logout",
39074
- nes_start: "nes/start",
39075
- nes_suggest: "nes/suggest",
39076
- nes_accept: "nes/accept",
39077
- nes_reject: "nes/reject",
39078
- nes_close: "nes/close",
39079
- document_did_open: "document/didOpen",
39080
- document_did_change: "document/didChange",
39081
- document_did_close: "document/didClose",
39082
- document_did_save: "document/didSave",
39083
- document_did_focus: "document/didFocus"
39084
- };
39085
- var CLIENT_METHODS = {
39086
- session_request_permission: "session/request_permission",
39087
- session_update: "session/update",
39088
- fs_write_text_file: "fs/write_text_file",
39089
- fs_read_text_file: "fs/read_text_file",
39090
- terminal_create: "terminal/create",
39091
- terminal_output: "terminal/output",
39092
- terminal_release: "terminal/release",
39093
- terminal_wait_for_exit: "terminal/wait_for_exit",
39094
- terminal_kill: "terminal/kill",
39095
- mcp_connect: "mcp/connect",
39096
- mcp_message: "mcp/message",
39097
- mcp_disconnect: "mcp/disconnect",
39098
- elicitation_create: "elicitation/create",
39099
- elicitation_complete: "elicitation/complete"
39100
- };
39101
- var PROTOCOL_METHODS = {
39102
- cancel_request: "$/cancel_request"
39103
- };
39104
- // node_modules/.bun/@agentclientprotocol+sdk@1.3.0+68a1e3a0c4588df3/node_modules/@agentclientprotocol/sdk/dist/schema-deserialize.js
39105
- var skippedItem = Symbol("skippedItem");
39106
- function defaultOnError(schema, fallback) {
39107
- return schema.catch(fallback);
39108
- }
39109
- function requiredDefaultOnError(schema, fallback) {
39110
- const schemaWithCatch = schema.catch(fallback);
39111
- return unknown().transform((value, context) => {
39112
- if (value !== undefined)
39113
- return schemaWithCatch.parse(value);
39114
- context.addIssue({
39115
- code: "custom",
39116
- message: "Required value is missing"
39117
- });
39118
- return NEVER;
39119
- });
39120
- }
39121
- function stringTag(value, key) {
39122
- if (value === null || typeof value !== "object" || Array.isArray(value)) {
39123
- return;
39124
- }
39125
- const tag = value[key];
39126
- return typeof tag === "string" ? tag : undefined;
39127
- }
39128
- function excludeKnownTags(schema, key, knownTags) {
39129
- return schema.superRefine((value, context) => {
39130
- const tag = stringTag(value, key);
39131
- if (tag !== undefined && knownTags.includes(tag)) {
39132
- context.addIssue({
39133
- code: "custom",
39134
- path: [key],
39135
- message: `${key} ${JSON.stringify(tag)} is reserved by a known variant, ` + `but the value does not match that variant's schema`
39136
- });
39137
- }
39138
- });
39139
- }
39140
- function preserveCustomPayload(schema, key, knownTags) {
39141
- return unknown().transform((value, context) => {
39142
- const result = schema.safeParse(value);
39143
- if (!result.success) {
39144
- for (const issue of result.error.issues) {
39145
- context.addIssue({ ...issue, input: value });
39146
- }
39147
- return NEVER;
39148
- }
39149
- const output = result.data;
39150
- const tag = stringTag(value, key);
39151
- if (tag !== undefined && !knownTags.includes(tag)) {
39152
- const raw = value;
39153
- for (const [property, rawValue] of Object.entries(raw)) {
39154
- if (property === "__proto__")
39155
- continue;
39156
- if (!Object.hasOwn(output, property))
39157
- output[property] = rawValue;
39158
- }
39159
- }
39160
- return output;
39161
- });
39162
- }
39163
- function vecSkipError(itemSchema) {
39164
- return array(itemSchema.catch(skippedItem)).transform((items) => items.filter((item) => item !== skippedItem));
39165
- }
39166
-
39167
- // node_modules/.bun/@agentclientprotocol+sdk@1.3.0+68a1e3a0c4588df3/node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.js
39168
- var zRequestId = union([number2(), string2()]).nullable();
39169
- var zSessionId = string2();
39170
- var zWriteTextFileRequest = object({
39171
- sessionId: zSessionId,
39172
- path: string2(),
39173
- content: string2(),
39174
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39175
- return;
39176
- })
39177
- });
39178
- var zReadTextFileRequest = object({
39179
- sessionId: zSessionId,
39180
- path: string2(),
39181
- line: defaultOnError(int().gte(0).max(4294967295, {
39182
- error: "Invalid value: Expected uint32 to be <= 4294967295"
39183
- }).nullish(), () => {
39184
- return;
39185
- }),
39186
- limit: defaultOnError(int().gte(0).max(4294967295, {
39187
- error: "Invalid value: Expected uint32 to be <= 4294967295"
39188
- }).nullish(), () => {
39189
- return;
39190
- }),
39191
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39192
- return;
39193
- })
39194
- });
39195
- var zToolCallId = string2();
39196
- var zToolKind = union([
39197
- literal("read"),
39198
- literal("edit"),
39199
- literal("delete"),
39200
- literal("move"),
39201
- literal("search"),
39202
- literal("execute"),
39203
- literal("think"),
39204
- literal("fetch"),
39205
- literal("switch_mode"),
39206
- literal("other")
39207
- ]);
39208
- var zToolCallStatus = union([
39209
- literal("pending"),
39210
- literal("in_progress"),
39211
- literal("completed"),
39212
- literal("failed")
39213
- ]);
39214
- var zRole = union([literal("assistant"), literal("user")]);
39215
- var zAnnotations = object({
39216
- audience: defaultOnError(vecSkipError(zRole).nullish(), () => {
39217
- return;
39218
- }),
39219
- lastModified: defaultOnError(string2().nullish(), () => {
39220
- return;
39221
- }),
39222
- priority: defaultOnError(number2().nullish(), () => {
39223
- return;
39224
- }),
39225
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39226
- return;
39227
- })
39228
- });
39229
- var zTextContent = object({
39230
- annotations: defaultOnError(zAnnotations.nullish(), () => {
39231
- return;
39232
- }),
39233
- text: string2(),
39234
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39235
- return;
39236
- })
39237
- });
39238
- var zImageContent = object({
39239
- annotations: defaultOnError(zAnnotations.nullish(), () => {
39240
- return;
39241
- }),
39242
- data: string2(),
39243
- mimeType: string2(),
39244
- uri: defaultOnError(string2().nullish(), () => {
39245
- return;
39246
- }),
39247
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39248
- return;
39249
- })
39250
- });
39251
- var zAudioContent = object({
39252
- annotations: defaultOnError(zAnnotations.nullish(), () => {
39253
- return;
39254
- }),
39255
- data: string2(),
39256
- mimeType: string2(),
39257
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39258
- return;
39259
- })
39260
- });
39261
- var zResourceLink = object({
39262
- annotations: defaultOnError(zAnnotations.nullish(), () => {
39263
- return;
39264
- }),
39265
- description: defaultOnError(string2().nullish(), () => {
39266
- return;
39267
- }),
39268
- mimeType: defaultOnError(string2().nullish(), () => {
39269
- return;
39270
- }),
39271
- name: string2(),
39272
- size: defaultOnError(number2().nullish(), () => {
39273
- return;
39274
- }),
39275
- title: defaultOnError(string2().nullish(), () => {
39276
- return;
39277
- }),
39278
- uri: string2(),
39279
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39280
- return;
39281
- })
39282
- });
39283
- var zTextResourceContents = object({
39284
- mimeType: defaultOnError(string2().nullish(), () => {
39285
- return;
39286
- }),
39287
- text: string2(),
39288
- uri: string2(),
39289
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39290
- return;
39291
- })
39292
- });
39293
- var zBlobResourceContents = object({
39294
- blob: string2(),
39295
- mimeType: defaultOnError(string2().nullish(), () => {
39296
- return;
39297
- }),
39298
- uri: string2(),
39299
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39300
- return;
39301
- })
39302
- });
39303
- var zEmbeddedResourceResource = union([
39304
- zTextResourceContents,
39305
- zBlobResourceContents
39306
- ]);
39307
- var zEmbeddedResource = object({
39308
- annotations: defaultOnError(zAnnotations.nullish(), () => {
39309
- return;
39310
- }),
39311
- resource: zEmbeddedResourceResource,
39312
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39313
- return;
39314
- })
39315
- });
39316
- var zContentBlock = union([
39317
- zTextContent.and(object({
39318
- type: literal("text")
39319
- })),
39320
- zImageContent.and(object({
39321
- type: literal("image")
39322
- })),
39323
- zAudioContent.and(object({
39324
- type: literal("audio")
39325
- })),
39326
- zResourceLink.and(object({
39327
- type: literal("resource_link")
39328
- })),
39329
- zEmbeddedResource.and(object({
39330
- type: literal("resource")
39331
- }))
39332
- ]);
39333
- var zContent = object({
39334
- content: zContentBlock,
39335
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39336
- return;
39337
- })
39338
- });
39339
- var zDiff = object({
39340
- path: string2(),
39341
- oldText: defaultOnError(string2().nullish(), () => {
39342
- return;
39343
- }),
39344
- newText: string2(),
39345
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39346
- return;
39347
- })
39348
- });
39349
- var zTerminalId = string2();
39350
- var zTerminal = object({
39351
- terminalId: zTerminalId,
39352
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39353
- return;
39354
- })
39355
- });
39356
- var zToolCallContent = union([
39357
- zContent.and(object({
39358
- type: literal("content")
39359
- })),
39360
- zDiff.and(object({
39361
- type: literal("diff")
39362
- })),
39363
- zTerminal.and(object({
39364
- type: literal("terminal")
39365
- }))
39366
- ]);
39367
- var zToolCallLocation = object({
39368
- path: string2(),
39369
- line: defaultOnError(int().gte(0).max(4294967295, {
39370
- error: "Invalid value: Expected uint32 to be <= 4294967295"
39371
- }).nullish(), () => {
39372
- return;
39373
- }),
39374
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39375
- return;
39376
- })
39377
- });
39378
- var zToolCallUpdate = object({
39379
- toolCallId: zToolCallId,
39380
- kind: defaultOnError(zToolKind.nullish(), () => {
39381
- return;
39382
- }),
39383
- status: defaultOnError(zToolCallStatus.nullish(), () => {
39384
- return;
39385
- }),
39386
- title: defaultOnError(string2().nullish(), () => {
39387
- return;
39388
- }),
39389
- name: defaultOnError(string2().nullish(), () => {
39390
- return;
39391
- }),
39392
- content: defaultOnError(vecSkipError(zToolCallContent).nullish(), () => {
39393
- return;
39394
- }),
39395
- locations: defaultOnError(vecSkipError(zToolCallLocation).nullish(), () => {
39396
- return;
39397
- }),
39398
- rawInput: defaultOnError(unknown().optional(), () => {
39399
- return;
39400
- }),
39401
- rawOutput: defaultOnError(unknown().optional(), () => {
39402
- return;
39403
- }),
39404
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39405
- return;
39406
- })
39407
- });
39408
- var zPermissionOptionId = string2();
39409
- var zPermissionOptionKind = union([
39410
- literal("allow_once"),
39411
- literal("allow_always"),
39412
- literal("reject_once"),
39413
- literal("reject_always")
39414
- ]);
39415
- var zPermissionOption = object({
39416
- optionId: zPermissionOptionId,
39417
- name: string2(),
39418
- kind: zPermissionOptionKind,
39419
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39420
- return;
39421
- })
39422
- });
39423
- var zRequestPermissionRequest = object({
39424
- sessionId: zSessionId,
39425
- toolCall: zToolCallUpdate,
39426
- options: array(zPermissionOption),
39427
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39428
- return;
39429
- })
39430
- });
39431
- var zEnvVariable = object({
39432
- name: string2(),
39433
- value: string2(),
39434
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39435
- return;
39436
- })
39437
- });
39438
- var zCreateTerminalRequest = object({
39439
- sessionId: zSessionId,
39440
- command: string2(),
39441
- args: defaultOnError(vecSkipError(string2()).optional(), () => []),
39442
- env: defaultOnError(vecSkipError(zEnvVariable).optional(), () => []),
39443
- cwd: defaultOnError(string2().nullish(), () => {
39444
- return;
39445
- }),
39446
- outputByteLimit: defaultOnError(number2().nullish(), () => {
39447
- return;
39448
- }),
39449
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39450
- return;
39451
- })
39452
- });
39453
- var zTerminalOutputRequest = object({
39454
- sessionId: zSessionId,
39455
- terminalId: zTerminalId,
39456
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39457
- return;
39458
- })
39459
- });
39460
- var zReleaseTerminalRequest = object({
39461
- sessionId: zSessionId,
39462
- terminalId: zTerminalId,
39463
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39464
- return;
39465
- })
39466
- });
39467
- var zWaitForTerminalExitRequest = object({
39468
- sessionId: zSessionId,
39469
- terminalId: zTerminalId,
39470
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39471
- return;
39472
- })
39473
- });
39474
- var zKillTerminalRequest = object({
39475
- sessionId: zSessionId,
39476
- terminalId: zTerminalId,
39477
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39478
- return;
39479
- })
39480
- });
39481
- var zElicitationSessionScope = object({
39482
- sessionId: zSessionId,
39483
- toolCallId: defaultOnError(zToolCallId.nullish(), () => {
39484
- return;
39485
- })
39486
- });
39487
- var zElicitationRequestScope = object({
39488
- requestId: zRequestId
39489
- });
39490
- var zElicitationSchemaType = literal("object");
39491
- var zStringFormat = union([
39492
- literal("email"),
39493
- literal("uri"),
39494
- literal("date"),
39495
- literal("date-time")
39496
- ]);
39497
- var zEnumOption = object({
39498
- const: string2(),
39499
- title: string2(),
39500
- description: defaultOnError(string2().nullish(), () => {
39501
- return;
39502
- }),
39503
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39504
- return;
39505
- })
39506
- });
39507
- var zStringPropertySchema = object({
39508
- title: defaultOnError(string2().nullish(), () => {
39509
- return;
39510
- }),
39511
- description: defaultOnError(string2().nullish(), () => {
39512
- return;
39513
- }),
39514
- minLength: int().gte(0).max(4294967295, {
39515
- error: "Invalid value: Expected uint32 to be <= 4294967295"
39516
- }).nullish(),
39517
- maxLength: int().gte(0).max(4294967295, {
39518
- error: "Invalid value: Expected uint32 to be <= 4294967295"
39519
- }).nullish(),
39520
- pattern: string2().nullish(),
39521
- format: zStringFormat.nullish(),
39522
- default: defaultOnError(string2().nullish(), () => {
39523
- return;
39524
- }),
39525
- enum: array(string2()).nullish(),
39526
- oneOf: array(zEnumOption).nullish(),
39527
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39528
- return;
39529
- })
39530
- });
39531
- var zNumberPropertySchema = object({
39532
- title: defaultOnError(string2().nullish(), () => {
39533
- return;
39534
- }),
39535
- description: defaultOnError(string2().nullish(), () => {
39536
- return;
39537
- }),
39538
- minimum: number2().nullish(),
39539
- maximum: number2().nullish(),
39540
- default: defaultOnError(number2().nullish(), () => {
39541
- return;
39542
- }),
39543
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39544
- return;
39545
- })
39546
- });
39547
- var zIntegerPropertySchema = object({
39548
- title: defaultOnError(string2().nullish(), () => {
39549
- return;
39550
- }),
39551
- description: defaultOnError(string2().nullish(), () => {
39552
- return;
39553
- }),
39554
- minimum: number2().nullish(),
39555
- maximum: number2().nullish(),
39556
- default: defaultOnError(number2().nullish(), () => {
39557
- return;
39558
- }),
39559
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39560
- return;
39561
- })
39562
- });
39563
- var zBooleanPropertySchema = object({
39564
- title: defaultOnError(string2().nullish(), () => {
39565
- return;
39566
- }),
39567
- description: defaultOnError(string2().nullish(), () => {
39568
- return;
39569
- }),
39570
- default: defaultOnError(boolean2().nullish(), () => {
39571
- return;
39572
- }),
39573
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39574
- return;
39575
- })
39576
- });
39577
- var zStringMultiSelectItems = object({
39578
- enum: array(string2()),
39579
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39580
- return;
39581
- })
39582
- });
39583
- var zTitledMultiSelectItems = object({
39584
- anyOf: array(zEnumOption),
39585
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39586
- return;
39587
- })
39588
- });
39589
- var zMultiSelectItems = preserveCustomPayload(union([
39590
- zStringMultiSelectItems.and(object({
39591
- type: literal("string")
39592
- })),
39593
- excludeKnownTags(object({
39594
- type: string2()
39595
- }), "type", ["string"]),
39596
- zTitledMultiSelectItems
39597
- ]), "type", ["string"]);
39598
- var zMultiSelectPropertySchema = object({
39599
- title: defaultOnError(string2().nullish(), () => {
39600
- return;
39601
- }),
39602
- description: defaultOnError(string2().nullish(), () => {
39603
- return;
39604
- }),
39605
- minItems: number2().nullish(),
39606
- maxItems: number2().nullish(),
39607
- items: zMultiSelectItems,
39608
- default: defaultOnError(vecSkipError(string2()).nullish(), () => {
39609
- return;
39610
- }),
39611
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39612
- return;
39613
- })
39614
- });
39615
- var zElicitationPropertySchema = preserveCustomPayload(union([
39616
- zStringPropertySchema.and(object({
39617
- type: literal("string")
39618
- })),
39619
- zNumberPropertySchema.and(object({
39620
- type: literal("number")
39621
- })),
39622
- zIntegerPropertySchema.and(object({
39623
- type: literal("integer")
39624
- })),
39625
- zBooleanPropertySchema.and(object({
39626
- type: literal("boolean")
39627
- })),
39628
- zMultiSelectPropertySchema.and(object({
39629
- type: literal("array")
39630
- })),
39631
- excludeKnownTags(object({
39632
- type: string2()
39633
- }), "type", ["array", "boolean", "integer", "number", "string"])
39634
- ]), "type", ["array", "boolean", "integer", "number", "string"]);
39635
- var zElicitationSchema = object({
39636
- type: defaultOnError(zElicitationSchemaType.optional().default("object"), () => "object"),
39637
- title: defaultOnError(string2().nullish(), () => {
39638
- return;
39639
- }),
39640
- properties: record(string2(), zElicitationPropertySchema).optional().default({}),
39641
- required: array(string2()).nullish(),
39642
- description: defaultOnError(string2().nullish(), () => {
39643
- return;
39644
- }),
39645
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39646
- return;
39647
- })
39648
- });
39649
- var zElicitationFormMode = intersection(union([zElicitationSessionScope, zElicitationRequestScope]), object({
39650
- requestedSchema: zElicitationSchema
39651
- }));
39652
- var zElicitationId = string2();
39653
- var zElicitationUrlMode = intersection(union([zElicitationSessionScope, zElicitationRequestScope]), object({
39654
- elicitationId: zElicitationId,
39655
- url: url()
39656
- }));
39657
- var zCreateElicitationRequest = preserveCustomPayload(intersection(union([
39658
- zElicitationFormMode.and(object({
39659
- mode: literal("form")
39660
- })),
39661
- zElicitationUrlMode.and(object({
39662
- mode: literal("url")
39663
- })),
39664
- excludeKnownTags(intersection(union([zElicitationSessionScope, zElicitationRequestScope]), object({
39665
- mode: string2()
39666
- })), "mode", ["form", "url"])
39667
- ]), object({
39668
- message: string2(),
39669
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39670
- return;
39671
- })
39672
- })), "mode", ["form", "url"]);
39673
- var zMcpServerAcpId = string2();
39674
- var zConnectMcpRequest = object({
39675
- serverId: zMcpServerAcpId,
39676
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39677
- return;
39678
- })
39679
- });
39680
- var zMcpConnectionId = string2();
39681
- var zMessageMcpRequest = object({
39682
- connectionId: zMcpConnectionId,
39683
- method: string2(),
39684
- params: record(string2(), unknown()).nullish(),
39685
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39686
- return;
39687
- })
39688
- });
39689
- var zDisconnectMcpRequest = object({
39690
- connectionId: zMcpConnectionId,
39691
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39692
- return;
39693
- })
39694
- });
39695
- var zExtRequest = unknown();
39696
- var zAgentRequest = object({
39697
- id: zRequestId,
39698
- method: string2(),
39699
- params: union([
39700
- zWriteTextFileRequest,
39701
- zReadTextFileRequest,
39702
- zRequestPermissionRequest,
39703
- zCreateTerminalRequest,
39704
- zTerminalOutputRequest,
39705
- zReleaseTerminalRequest,
39706
- zWaitForTerminalExitRequest,
39707
- zKillTerminalRequest,
39708
- zCreateElicitationRequest,
39709
- zConnectMcpRequest,
39710
- zMessageMcpRequest,
39711
- zDisconnectMcpRequest,
39712
- zExtRequest
39713
- ]).nullish()
39714
- });
39715
- var zProtocolVersion = int().gte(0).lte(65535);
39716
- var zPromptCapabilities = object({
39717
- image: defaultOnError(boolean2().optional().default(false), () => false),
39718
- audio: defaultOnError(boolean2().optional().default(false), () => false),
39719
- embeddedContext: defaultOnError(boolean2().optional().default(false), () => false),
39720
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39721
- return;
39722
- })
39723
- });
39724
- var zMcpCapabilities = object({
39725
- http: defaultOnError(boolean2().optional().default(false), () => false),
39726
- sse: defaultOnError(boolean2().optional().default(false), () => false),
39727
- acp: defaultOnError(boolean2().optional().default(false), () => false),
39728
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39729
- return;
39730
- })
39731
- });
39732
- var zSessionListCapabilities = object({
39733
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39734
- return;
39735
- })
39736
- });
39737
- var zSessionDeleteCapabilities = object({
39738
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39739
- return;
39740
- })
39741
- });
39742
- var zSessionAdditionalDirectoriesCapabilities = object({
39743
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39744
- return;
39745
- })
39746
- });
39747
- var zSessionForkCapabilities = object({
39748
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39749
- return;
39750
- })
39751
- });
39752
- var zSessionResumeCapabilities = object({
39753
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39754
- return;
39755
- })
39756
- });
39757
- var zSessionCloseCapabilities = object({
39758
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39759
- return;
39760
- })
39761
- });
39762
- var zSessionCapabilities = object({
39763
- list: defaultOnError(zSessionListCapabilities.nullish(), () => {
39764
- return;
39765
- }),
39766
- delete: defaultOnError(zSessionDeleteCapabilities.nullish(), () => {
39767
- return;
39768
- }),
39769
- additionalDirectories: defaultOnError(zSessionAdditionalDirectoriesCapabilities.nullish(), () => {
39770
- return;
39771
- }),
39772
- fork: defaultOnError(zSessionForkCapabilities.nullish(), () => {
39773
- return;
39774
- }),
39775
- resume: defaultOnError(zSessionResumeCapabilities.nullish(), () => {
39776
- return;
39777
- }),
39778
- close: defaultOnError(zSessionCloseCapabilities.nullish(), () => {
39779
- return;
39780
- }),
39781
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39782
- return;
39783
- })
39784
- });
39785
- var zLogoutCapabilities = object({
39786
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39787
- return;
39788
- })
39789
- });
39790
- var zAgentAuthCapabilities = object({
39791
- logout: defaultOnError(zLogoutCapabilities.nullish(), () => {
39792
- return;
39793
- }),
39794
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39795
- return;
39796
- })
39797
- });
39798
- var zProvidersCapabilities = object({
39799
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39800
- return;
39801
- })
39802
- });
39803
- var zNesDocumentDidOpenCapabilities = object({
39804
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39805
- return;
39806
- })
39807
- });
39808
- var zTextDocumentSyncKind = union([
39809
- literal("full"),
39810
- literal("incremental")
39811
- ]);
39812
- var zNesDocumentDidChangeCapabilities = object({
39813
- syncKind: zTextDocumentSyncKind,
39814
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39815
- return;
39816
- })
39817
- });
39818
- var zNesDocumentDidCloseCapabilities = object({
39819
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39820
- return;
39821
- })
39822
- });
39823
- var zNesDocumentDidSaveCapabilities = object({
39824
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39825
- return;
39826
- })
39827
- });
39828
- var zNesDocumentDidFocusCapabilities = object({
39829
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39830
- return;
39831
- })
39832
- });
39833
- var zNesDocumentEventCapabilities = object({
39834
- didOpen: defaultOnError(zNesDocumentDidOpenCapabilities.nullish(), () => {
39835
- return;
39836
- }),
39837
- didChange: defaultOnError(zNesDocumentDidChangeCapabilities.nullish(), () => {
39838
- return;
39839
- }),
39840
- didClose: defaultOnError(zNesDocumentDidCloseCapabilities.nullish(), () => {
39841
- return;
39842
- }),
39843
- didSave: defaultOnError(zNesDocumentDidSaveCapabilities.nullish(), () => {
39844
- return;
39845
- }),
39846
- didFocus: defaultOnError(zNesDocumentDidFocusCapabilities.nullish(), () => {
39847
- return;
39848
- }),
39849
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39850
- return;
39851
- })
39852
- });
39853
- var zNesEventCapabilities = object({
39854
- document: defaultOnError(zNesDocumentEventCapabilities.nullish(), () => {
39855
- return;
39856
- }),
39857
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39858
- return;
39859
- })
39860
- });
39861
- var zNesRecentFilesCapabilities = object({
39862
- maxCount: defaultOnError(int().gte(0).max(4294967295, {
39863
- error: "Invalid value: Expected uint32 to be <= 4294967295"
39864
- }).nullish(), () => {
39865
- return;
39866
- }),
39867
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39868
- return;
39869
- })
39870
- });
39871
- var zNesRelatedSnippetsCapabilities = object({
39872
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39873
- return;
39874
- })
39875
- });
39876
- var zNesEditHistoryCapabilities = object({
39877
- maxCount: defaultOnError(int().gte(0).max(4294967295, {
39878
- error: "Invalid value: Expected uint32 to be <= 4294967295"
39879
- }).nullish(), () => {
39880
- return;
39881
- }),
39882
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39883
- return;
39884
- })
39885
- });
39886
- var zNesUserActionsCapabilities = object({
39887
- maxCount: defaultOnError(int().gte(0).max(4294967295, {
39888
- error: "Invalid value: Expected uint32 to be <= 4294967295"
39889
- }).nullish(), () => {
39890
- return;
39891
- }),
39892
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39893
- return;
39894
- })
39895
- });
39896
- var zNesOpenFilesCapabilities = object({
39897
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39898
- return;
39899
- })
39900
- });
39901
- var zNesDiagnosticsCapabilities = object({
39902
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39903
- return;
39904
- })
39905
- });
39906
- var zNesContextCapabilities = object({
39907
- recentFiles: defaultOnError(zNesRecentFilesCapabilities.nullish(), () => {
39908
- return;
39909
- }),
39910
- relatedSnippets: defaultOnError(zNesRelatedSnippetsCapabilities.nullish(), () => {
39911
- return;
39912
- }),
39913
- editHistory: defaultOnError(zNesEditHistoryCapabilities.nullish(), () => {
39914
- return;
39915
- }),
39916
- userActions: defaultOnError(zNesUserActionsCapabilities.nullish(), () => {
39917
- return;
39918
- }),
39919
- openFiles: defaultOnError(zNesOpenFilesCapabilities.nullish(), () => {
39920
- return;
39921
- }),
39922
- diagnostics: defaultOnError(zNesDiagnosticsCapabilities.nullish(), () => {
39923
- return;
39924
- }),
39925
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39926
- return;
39927
- })
39928
- });
39929
- var zNesCapabilities = object({
39930
- events: defaultOnError(zNesEventCapabilities.nullish(), () => {
39931
- return;
39932
- }),
39933
- context: defaultOnError(zNesContextCapabilities.nullish(), () => {
39934
- return;
39935
- }),
39936
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39937
- return;
39938
- })
39939
- });
39940
- var zPositionEncodingKind = union([
39941
- literal("utf-16"),
39942
- literal("utf-32"),
39943
- literal("utf-8")
39944
- ]);
39945
- var zAgentCapabilities = object({
39946
- loadSession: defaultOnError(boolean2().optional().default(false), () => false),
39947
- promptCapabilities: defaultOnError(zPromptCapabilities.optional().default({
39948
- image: false,
39949
- audio: false,
39950
- embeddedContext: false
39951
- }), () => ({
39952
- image: false,
39953
- audio: false,
39954
- embeddedContext: false
39955
- })),
39956
- mcpCapabilities: defaultOnError(zMcpCapabilities.optional().default({
39957
- http: false,
39958
- sse: false,
39959
- acp: false
39960
- }), () => ({
39961
- http: false,
39962
- sse: false,
39963
- acp: false
39964
- })),
39965
- sessionCapabilities: defaultOnError(zSessionCapabilities.optional().default({}), () => ({})),
39966
- auth: defaultOnError(zAgentAuthCapabilities.optional().default({}), () => ({})),
39967
- providers: defaultOnError(zProvidersCapabilities.nullish(), () => {
39968
- return;
39969
- }),
39970
- nes: defaultOnError(zNesCapabilities.nullish(), () => {
39971
- return;
39972
- }),
39973
- positionEncoding: defaultOnError(zPositionEncodingKind.nullish(), () => {
39974
- return;
39975
- }),
39976
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39977
- return;
39978
- })
39979
- });
39980
- var zAuthMethodId = string2();
39981
- var zAuthEnvVar = object({
39982
- name: string2(),
39983
- label: defaultOnError(string2().nullish(), () => {
39984
- return;
39985
- }),
39986
- secret: defaultOnError(boolean2().optional().default(true), () => true),
39987
- optional: defaultOnError(boolean2().optional().default(false), () => false),
39988
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
39989
- return;
39990
- })
39991
- });
39992
- var zAuthMethodEnvVar = object({
39993
- id: zAuthMethodId,
39994
- name: string2(),
39995
- description: defaultOnError(string2().nullish(), () => {
39996
- return;
39997
- }),
39998
- vars: requiredDefaultOnError(vecSkipError(zAuthEnvVar), () => []),
39999
- link: defaultOnError(string2().nullish(), () => {
40000
- return;
40001
- }),
40002
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40003
- return;
40004
- })
40005
- });
40006
- var zAuthMethodTerminal = object({
40007
- id: zAuthMethodId,
40008
- name: string2(),
40009
- description: defaultOnError(string2().nullish(), () => {
40010
- return;
40011
- }),
40012
- args: defaultOnError(vecSkipError(string2()).optional(), () => []),
40013
- env: defaultOnError(record(string2(), string2()).optional(), () => {
40014
- return;
40015
- }),
40016
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40017
- return;
40018
- })
40019
- });
40020
- var zAuthMethodAgent = object({
40021
- id: zAuthMethodId,
40022
- name: string2(),
40023
- description: defaultOnError(string2().nullish(), () => {
40024
- return;
40025
- }),
40026
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40027
- return;
40028
- })
40029
- });
40030
- var zAuthMethod = union([
40031
- zAuthMethodEnvVar.and(object({
40032
- type: literal("env_var")
40033
- })),
40034
- zAuthMethodTerminal.and(object({
40035
- type: literal("terminal")
40036
- })),
40037
- zAuthMethodAgent
40038
- ]);
40039
- var zImplementation = object({
40040
- name: string2(),
40041
- title: defaultOnError(string2().nullish(), () => {
40042
- return;
40043
- }),
40044
- version: string2(),
40045
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40046
- return;
40047
- })
40048
- });
40049
- var zInitializeResponse = object({
40050
- protocolVersion: zProtocolVersion,
40051
- agentCapabilities: defaultOnError(zAgentCapabilities.optional().default({
40052
- loadSession: false,
40053
- promptCapabilities: {
40054
- image: false,
40055
- audio: false,
40056
- embeddedContext: false
40057
- },
40058
- mcpCapabilities: {
40059
- http: false,
40060
- sse: false,
40061
- acp: false
40062
- },
40063
- sessionCapabilities: {},
40064
- auth: {}
40065
- }), () => ({
40066
- loadSession: false,
40067
- promptCapabilities: {
40068
- image: false,
40069
- audio: false,
40070
- embeddedContext: false
40071
- },
40072
- mcpCapabilities: {
40073
- http: false,
40074
- sse: false,
40075
- acp: false
40076
- },
40077
- sessionCapabilities: {},
40078
- auth: {}
40079
- })),
40080
- authMethods: defaultOnError(vecSkipError(zAuthMethod).optional().default([]), () => []),
40081
- agentInfo: defaultOnError(zImplementation.nullish(), () => {
40082
- return;
40083
- }),
40084
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40085
- return;
40086
- })
40087
- });
40088
- var zAuthenticateResponse = object({
40089
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40090
- return;
40091
- })
40092
- });
40093
- var zProviderId = string2();
40094
- var zLlmProtocol = union([
40095
- literal("anthropic"),
40096
- literal("openai"),
40097
- literal("azure"),
40098
- literal("vertex"),
40099
- literal("bedrock"),
40100
- string2()
40101
- ]);
40102
- var zProviderCurrentConfig = object({
40103
- apiType: zLlmProtocol,
40104
- baseUrl: string2(),
40105
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40106
- return;
40107
- })
40108
- });
40109
- var zProviderInfo = object({
40110
- providerId: zProviderId,
40111
- supported: requiredDefaultOnError(vecSkipError(zLlmProtocol), () => []),
40112
- required: boolean2(),
40113
- current: zProviderCurrentConfig.nullish(),
40114
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40115
- return;
40116
- })
40117
- });
40118
- var zListProvidersResponse = object({
40119
- providers: array(zProviderInfo),
40120
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40121
- return;
40122
- })
40123
- });
40124
- var zSetProviderResponse = object({
40125
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40126
- return;
40127
- })
40128
- });
40129
- var zDisableProviderResponse = object({
40130
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40131
- return;
40132
- })
40133
- });
40134
- var zLogoutResponse = object({
40135
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40136
- return;
40137
- })
40138
- });
40139
- var zSessionModeId = string2();
40140
- var zSessionMode = object({
40141
- id: zSessionModeId,
40142
- name: string2(),
40143
- description: defaultOnError(string2().nullish(), () => {
40144
- return;
40145
- }),
40146
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40147
- return;
40148
- })
40149
- });
40150
- var zSessionModeState = object({
40151
- currentModeId: zSessionModeId,
40152
- availableModes: requiredDefaultOnError(vecSkipError(zSessionMode), () => []),
40153
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40154
- return;
40155
- })
40156
- });
40157
- var zSessionConfigId = string2();
40158
- var zSessionConfigOptionCategory = union([
40159
- literal("mode"),
40160
- literal("model"),
40161
- literal("model_config"),
40162
- literal("thought_level"),
40163
- string2()
40164
- ]);
40165
- var zSessionConfigValueId = string2();
40166
- var zSessionConfigSelectOption = object({
40167
- value: zSessionConfigValueId,
40168
- name: string2(),
40169
- description: defaultOnError(string2().nullish(), () => {
40170
- return;
40171
- }),
40172
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40173
- return;
40174
- })
40175
- });
40176
- var zSessionConfigGroupId = string2();
40177
- var zSessionConfigSelectGroup = object({
40178
- group: zSessionConfigGroupId,
40179
- name: string2(),
40180
- options: requiredDefaultOnError(vecSkipError(zSessionConfigSelectOption), () => []),
40181
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40182
- return;
40183
- })
40184
- });
40185
- var zSessionConfigSelectOptions = union([
40186
- array(zSessionConfigSelectOption),
40187
- array(zSessionConfigSelectGroup)
40188
- ]);
40189
- var zSessionConfigSelect = object({
40190
- currentValue: zSessionConfigValueId,
40191
- options: zSessionConfigSelectOptions
40192
- });
40193
- var zSessionConfigBoolean = object({
40194
- currentValue: boolean2()
40195
- });
40196
- var zSessionConfigOption = intersection(union([
40197
- zSessionConfigSelect.and(object({
40198
- type: literal("select")
40199
- })),
40200
- zSessionConfigBoolean.and(object({
40201
- type: literal("boolean")
40202
- }))
40203
- ]), object({
40204
- id: zSessionConfigId,
40205
- name: string2(),
40206
- description: defaultOnError(string2().nullish(), () => {
40207
- return;
40208
- }),
40209
- category: defaultOnError(zSessionConfigOptionCategory.nullish(), () => {
40210
- return;
40211
- }),
40212
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40213
- return;
40214
- })
40215
- }));
40216
- var zNewSessionResponse = object({
40217
- sessionId: zSessionId,
40218
- modes: defaultOnError(zSessionModeState.nullish(), () => {
40219
- return;
40220
- }),
40221
- configOptions: defaultOnError(vecSkipError(zSessionConfigOption).nullish(), () => {
40222
- return;
40223
- }),
40224
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40225
- return;
40226
- })
40227
- });
40228
- var zLoadSessionResponse = object({
40229
- modes: defaultOnError(zSessionModeState.nullish(), () => {
40230
- return;
40231
- }),
40232
- configOptions: defaultOnError(vecSkipError(zSessionConfigOption).nullish(), () => {
40233
- return;
40234
- }),
40235
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40236
- return;
40237
- })
40238
- });
40239
- var zSessionInfo = object({
40240
- sessionId: zSessionId,
40241
- cwd: string2(),
40242
- additionalDirectories: defaultOnError(vecSkipError(string2()).optional(), () => []),
40243
- title: defaultOnError(string2().nullish(), () => {
40244
- return;
40245
- }),
40246
- updatedAt: defaultOnError(string2().nullish(), () => {
40247
- return;
40248
- }),
40249
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40250
- return;
40251
- })
40252
- });
40253
- var zListSessionsResponse = object({
40254
- sessions: requiredDefaultOnError(vecSkipError(zSessionInfo), () => []),
40255
- nextCursor: defaultOnError(string2().nullish(), () => {
40256
- return;
40257
- }),
40258
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40259
- return;
40260
- })
40261
- });
40262
- var zDeleteSessionResponse = object({
40263
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40264
- return;
40265
- })
40266
- });
40267
- var zForkSessionResponse = object({
40268
- sessionId: zSessionId,
40269
- modes: defaultOnError(zSessionModeState.nullish(), () => {
40270
- return;
40271
- }),
40272
- configOptions: defaultOnError(vecSkipError(zSessionConfigOption).nullish(), () => {
40273
- return;
40274
- }),
40275
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40276
- return;
40277
- })
40278
- });
40279
- var zResumeSessionResponse = object({
40280
- modes: defaultOnError(zSessionModeState.nullish(), () => {
40281
- return;
40282
- }),
40283
- configOptions: defaultOnError(vecSkipError(zSessionConfigOption).nullish(), () => {
40284
- return;
40285
- }),
40286
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40287
- return;
40288
- })
40289
- });
40290
- var zCloseSessionResponse = object({
40291
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40292
- return;
40293
- })
40294
- });
40295
- var zSetSessionModeResponse = object({
40296
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40297
- return;
40298
- })
40299
- });
40300
- var zSetSessionConfigOptionResponse = object({
40301
- configOptions: requiredDefaultOnError(vecSkipError(zSessionConfigOption), () => []),
40302
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40303
- return;
40304
- })
40305
- });
40306
- var zStopReason = union([
40307
- literal("end_turn"),
40308
- literal("max_tokens"),
40309
- literal("max_turn_requests"),
40310
- literal("refusal"),
40311
- literal("cancelled")
40312
- ]);
40313
- var zUsage = object({
40314
- totalTokens: number2(),
40315
- inputTokens: number2(),
40316
- outputTokens: number2(),
40317
- thoughtTokens: defaultOnError(number2().nullish(), () => {
40318
- return;
40319
- }),
40320
- cachedReadTokens: defaultOnError(number2().nullish(), () => {
40321
- return;
40322
- }),
40323
- cachedWriteTokens: defaultOnError(number2().nullish(), () => {
40324
- return;
40325
- }),
40326
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40327
- return;
40328
- })
40329
- });
40330
- var zPromptResponse = object({
40331
- stopReason: zStopReason,
40332
- usage: defaultOnError(zUsage.nullish(), () => {
40333
- return;
40334
- }),
40335
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40336
- return;
40337
- })
40338
- });
40339
- var zStartNesResponse = object({
40340
- sessionId: zSessionId,
40341
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40342
- return;
40343
- })
40344
- });
40345
- var zNesSuggestionId = string2();
40346
- var zPosition = object({
40347
- line: int().gte(0).max(4294967295, {
40348
- error: "Invalid value: Expected uint32 to be <= 4294967295"
40349
- }),
40350
- character: int().gte(0).max(4294967295, {
40351
- error: "Invalid value: Expected uint32 to be <= 4294967295"
40352
- }),
40353
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40354
- return;
40355
- })
40356
- });
40357
- var zRange = object({
40358
- start: zPosition,
40359
- end: zPosition,
40360
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40361
- return;
40362
- })
40363
- });
40364
- var zNesTextEdit = object({
40365
- range: zRange,
40366
- newText: string2(),
40367
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40368
- return;
40369
- })
40370
- });
40371
- var zNesEditSuggestion = object({
40372
- id: zNesSuggestionId,
40373
- uri: string2(),
40374
- edits: array(zNesTextEdit),
40375
- cursorPosition: defaultOnError(zPosition.nullish(), () => {
40376
- return;
40377
- }),
40378
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40379
- return;
40380
- })
40381
- });
40382
- var zNesJumpSuggestion = object({
40383
- id: zNesSuggestionId,
40384
- uri: string2(),
40385
- position: zPosition,
40386
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40387
- return;
40388
- })
40389
- });
40390
- var zNesRenameSuggestion = object({
40391
- id: zNesSuggestionId,
40392
- uri: string2(),
40393
- position: zPosition,
40394
- newName: string2(),
40395
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40396
- return;
40397
- })
40398
- });
40399
- var zNesSearchAndReplaceSuggestion = object({
40400
- id: zNesSuggestionId,
40401
- uri: string2(),
40402
- search: string2(),
40403
- replace: string2(),
40404
- isRegex: boolean2().nullish(),
40405
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40406
- return;
40407
- })
40408
- });
40409
- var zNesSuggestion = union([
40410
- zNesEditSuggestion.and(object({
40411
- kind: literal("edit")
40412
- })),
40413
- zNesJumpSuggestion.and(object({
40414
- kind: literal("jump")
40415
- })),
40416
- zNesRenameSuggestion.and(object({
40417
- kind: literal("rename")
40418
- })),
40419
- zNesSearchAndReplaceSuggestion.and(object({
40420
- kind: literal("searchAndReplace")
40421
- }))
40422
- ]);
40423
- var zSuggestNesResponse = object({
40424
- suggestions: array(zNesSuggestion),
40425
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40426
- return;
40427
- })
40428
- });
40429
- var zCloseNesResponse = object({
40430
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40431
- return;
40432
- })
40433
- });
40434
- var zExtResponse = unknown();
40435
- var zMessageMcpResponse = unknown();
40436
- var zErrorCode = union([
40437
- literal(-32700),
40438
- literal(-32600),
40439
- literal(-32601),
40440
- literal(-32602),
40441
- literal(-32603),
40442
- literal(-32800),
40443
- literal(-32000),
40444
- literal(-32002),
40445
- int().min(-2147483648, {
40446
- error: "Invalid value: Expected int32 to be >= -2147483648"
40447
- }).max(2147483647, {
40448
- error: "Invalid value: Expected int32 to be <= 2147483647"
40449
- })
40450
- ]);
40451
- var zError = object({
40452
- code: zErrorCode,
40453
- message: string2(),
40454
- data: defaultOnError(unknown().optional(), () => {
40455
- return;
40456
- })
40457
- });
40458
- var zAgentResponse = union([
40459
- object({
40460
- id: zRequestId,
40461
- result: union([
40462
- zInitializeResponse,
40463
- zAuthenticateResponse,
40464
- zListProvidersResponse,
40465
- zSetProviderResponse,
40466
- zDisableProviderResponse,
40467
- zLogoutResponse,
40468
- zNewSessionResponse,
40469
- zLoadSessionResponse,
40470
- zListSessionsResponse,
40471
- zDeleteSessionResponse,
40472
- zForkSessionResponse,
40473
- zResumeSessionResponse,
40474
- zCloseSessionResponse,
40475
- zSetSessionModeResponse,
40476
- zSetSessionConfigOptionResponse,
40477
- zPromptResponse,
40478
- zStartNesResponse,
40479
- zSuggestNesResponse,
40480
- zCloseNesResponse,
40481
- zExtResponse,
40482
- zMessageMcpResponse
40483
- ])
40484
- }),
40485
- object({
40486
- id: zRequestId,
40487
- error: zError
40488
- })
40489
- ]);
40490
- var zMessageId = string2();
40491
- var zContentChunk = object({
40492
- content: zContentBlock,
40493
- messageId: defaultOnError(zMessageId.nullish(), () => {
40494
- return;
40495
- }),
40496
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40497
- return;
40498
- })
40499
- });
40500
- var zToolCall = object({
40501
- toolCallId: zToolCallId,
40502
- title: string2(),
40503
- name: defaultOnError(string2().nullish(), () => {
40504
- return;
40505
- }),
40506
- kind: defaultOnError(zToolKind.optional(), () => {
40507
- return;
40508
- }),
40509
- status: defaultOnError(zToolCallStatus.optional(), () => {
40510
- return;
40511
- }),
40512
- content: defaultOnError(vecSkipError(zToolCallContent).optional(), () => []),
40513
- locations: defaultOnError(vecSkipError(zToolCallLocation).optional(), () => []),
40514
- rawInput: defaultOnError(unknown().optional(), () => {
40515
- return;
40516
- }),
40517
- rawOutput: defaultOnError(unknown().optional(), () => {
40518
- return;
40519
- }),
40520
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40521
- return;
40522
- })
40523
- });
40524
- var zPlanEntryPriority = union([
40525
- literal("high"),
40526
- literal("medium"),
40527
- literal("low")
40528
- ]);
40529
- var zPlanEntryStatus = union([
40530
- literal("pending"),
40531
- literal("in_progress"),
40532
- literal("completed")
40533
- ]);
40534
- var zPlanEntry = object({
40535
- content: string2(),
40536
- priority: zPlanEntryPriority,
40537
- status: zPlanEntryStatus,
40538
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40539
- return;
40540
- })
40541
- });
40542
- var zPlan = object({
40543
- entries: requiredDefaultOnError(vecSkipError(zPlanEntry), () => []),
40544
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40545
- return;
40546
- })
40547
- });
40548
- var zPlanId = string2();
40549
- var zPlanItems = object({
40550
- planId: zPlanId,
40551
- entries: requiredDefaultOnError(vecSkipError(zPlanEntry), () => []),
40552
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40553
- return;
40554
- })
40555
- });
40556
- var zPlanFile = object({
40557
- planId: zPlanId,
40558
- uri: string2(),
40559
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40560
- return;
40561
- })
40562
- });
40563
- var zPlanMarkdown = object({
40564
- planId: zPlanId,
40565
- content: string2(),
40566
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40567
- return;
40568
- })
40569
- });
40570
- var zPlanUpdateContent = union([
40571
- zPlanItems.and(object({
40572
- type: literal("items")
40573
- })),
40574
- zPlanFile.and(object({
40575
- type: literal("file")
40576
- })),
40577
- zPlanMarkdown.and(object({
40578
- type: literal("markdown")
40579
- }))
40580
- ]);
40581
- var zPlanUpdate = object({
40582
- plan: zPlanUpdateContent,
40583
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40584
- return;
40585
- })
40586
- });
40587
- var zPlanRemoved = object({
40588
- planId: zPlanId,
40589
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40590
- return;
40591
- })
40592
- });
40593
- var zUnstructuredCommandInput = object({
40594
- hint: string2(),
40595
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40596
- return;
40597
- })
40598
- });
40599
- var zAvailableCommandInput = zUnstructuredCommandInput;
40600
- var zAvailableCommand = object({
40601
- name: string2(),
40602
- description: string2(),
40603
- input: defaultOnError(zAvailableCommandInput.nullish(), () => {
40604
- return;
40605
- }),
40606
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40607
- return;
40608
- })
40609
- });
40610
- var zAvailableCommandsUpdate = object({
40611
- availableCommands: requiredDefaultOnError(vecSkipError(zAvailableCommand), () => []),
40612
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40613
- return;
40614
- })
40615
- });
40616
- var zCurrentModeUpdate = object({
40617
- currentModeId: zSessionModeId,
40618
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40619
- return;
40620
- })
40621
- });
40622
- var zConfigOptionUpdate = object({
40623
- configOptions: requiredDefaultOnError(vecSkipError(zSessionConfigOption), () => []),
40624
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40625
- return;
40626
- })
40627
- });
40628
- var zSessionInfoUpdate = object({
40629
- title: defaultOnError(string2().nullish(), () => {
40630
- return;
40631
- }),
40632
- updatedAt: defaultOnError(string2().nullish(), () => {
40633
- return;
40634
- }),
40635
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40636
- return;
40637
- })
40638
- });
40639
- var zCost = object({
40640
- amount: number2(),
40641
- currency: string2(),
40642
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40643
- return;
40644
- })
40645
- });
40646
- var zUsageUpdate = object({
40647
- used: number2(),
40648
- size: number2(),
40649
- cost: defaultOnError(zCost.nullish(), () => {
40650
- return;
40651
- }),
40652
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40653
- return;
40654
- })
40655
- });
40656
- var zSessionUpdate = union([
40657
- zContentChunk.and(object({
40658
- sessionUpdate: literal("user_message_chunk")
40659
- })),
40660
- zContentChunk.and(object({
40661
- sessionUpdate: literal("agent_message_chunk")
40662
- })),
40663
- zContentChunk.and(object({
40664
- sessionUpdate: literal("agent_thought_chunk")
40665
- })),
40666
- zToolCall.and(object({
40667
- sessionUpdate: literal("tool_call")
40668
- })),
40669
- zToolCallUpdate.and(object({
40670
- sessionUpdate: literal("tool_call_update")
40671
- })),
40672
- zPlan.and(object({
40673
- sessionUpdate: literal("plan")
40674
- })),
40675
- zPlanUpdate.and(object({
40676
- sessionUpdate: literal("plan_update")
40677
- })),
40678
- zPlanRemoved.and(object({
40679
- sessionUpdate: literal("plan_removed")
40680
- })),
40681
- zAvailableCommandsUpdate.and(object({
40682
- sessionUpdate: literal("available_commands_update")
40683
- })),
40684
- zCurrentModeUpdate.and(object({
40685
- sessionUpdate: literal("current_mode_update")
40686
- })),
40687
- zConfigOptionUpdate.and(object({
40688
- sessionUpdate: literal("config_option_update")
40689
- })),
40690
- zSessionInfoUpdate.and(object({
40691
- sessionUpdate: literal("session_info_update")
40692
- })),
40693
- zUsageUpdate.and(object({
40694
- sessionUpdate: literal("usage_update")
40695
- }))
40696
- ]);
40697
- var zSessionNotification = object({
40698
- sessionId: zSessionId,
40699
- update: zSessionUpdate,
40700
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40701
- return;
40702
- })
40703
- });
40704
- var zCompleteElicitationNotification = object({
40705
- elicitationId: zElicitationId,
40706
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40707
- return;
40708
- })
40709
- });
40710
- var zMessageMcpNotification = object({
40711
- connectionId: zMcpConnectionId,
40712
- method: string2(),
40713
- params: defaultOnError(record(string2(), unknown()).nullish(), () => {
40714
- return;
40715
- }),
40716
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40717
- return;
40718
- })
40719
- });
40720
- var zExtNotification = unknown();
40721
- var zAgentNotification = object({
40722
- method: string2(),
40723
- params: union([
40724
- zSessionNotification,
40725
- zCompleteElicitationNotification,
40726
- zMessageMcpNotification,
40727
- zExtNotification
40728
- ]).nullish()
40729
- });
40730
- var zFileSystemCapabilities = object({
40731
- readTextFile: defaultOnError(boolean2().optional().default(false), () => false),
40732
- writeTextFile: defaultOnError(boolean2().optional().default(false), () => false),
40733
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40734
- return;
40735
- })
40736
- });
40737
- var zBooleanConfigOptionCapabilities = object({
40738
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40739
- return;
40740
- })
40741
- });
40742
- var zSessionConfigOptionsCapabilities = object({
40743
- boolean: defaultOnError(zBooleanConfigOptionCapabilities.nullish(), () => {
40744
- return;
40745
- }),
40746
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40747
- return;
40748
- })
40749
- });
40750
- var zClientSessionCapabilities = object({
40751
- configOptions: defaultOnError(zSessionConfigOptionsCapabilities.nullish(), () => {
40752
- return;
40753
- }),
40754
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40755
- return;
40756
- })
40757
- });
40758
- var zPlanCapabilities = object({
40759
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40760
- return;
40761
- })
40762
- });
40763
- var zAuthCapabilities = object({
40764
- terminal: defaultOnError(boolean2().optional().default(false), () => false),
40765
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40766
- return;
40767
- })
40768
- });
40769
- var zElicitationFormCapabilities = object({
40770
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40771
- return;
40772
- })
40773
- });
40774
- var zElicitationUrlCapabilities = object({
40775
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40776
- return;
40777
- })
40778
- });
40779
- var zElicitationCapabilities = object({
40780
- form: defaultOnError(zElicitationFormCapabilities.nullish(), () => {
40781
- return;
40782
- }),
40783
- url: defaultOnError(zElicitationUrlCapabilities.nullish(), () => {
40784
- return;
40785
- }),
40786
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40787
- return;
40788
- })
40789
- });
40790
- var zNesJumpCapabilities = object({
40791
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40792
- return;
40793
- })
40794
- });
40795
- var zNesRenameCapabilities = object({
40796
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40797
- return;
40798
- })
40799
- });
40800
- var zNesSearchAndReplaceCapabilities = object({
40801
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40802
- return;
40803
- })
40804
- });
40805
- var zClientNesCapabilities = object({
40806
- jump: defaultOnError(zNesJumpCapabilities.nullish(), () => {
40807
- return;
40808
- }),
40809
- rename: defaultOnError(zNesRenameCapabilities.nullish(), () => {
40810
- return;
40811
- }),
40812
- searchAndReplace: defaultOnError(zNesSearchAndReplaceCapabilities.nullish(), () => {
40813
- return;
40814
- }),
40815
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40816
- return;
40817
- })
40818
- });
40819
- var zClientCapabilities = object({
40820
- fs: defaultOnError(zFileSystemCapabilities.optional().default({ readTextFile: false, writeTextFile: false }), () => ({ readTextFile: false, writeTextFile: false })),
40821
- terminal: defaultOnError(boolean2().optional().default(false), () => false),
40822
- session: defaultOnError(zClientSessionCapabilities.nullish(), () => {
40823
- return;
40824
- }),
40825
- plan: defaultOnError(zPlanCapabilities.nullish(), () => {
40826
- return;
40827
- }),
40828
- auth: defaultOnError(zAuthCapabilities.optional().default({ terminal: false }), () => ({ terminal: false })),
40829
- elicitation: defaultOnError(zElicitationCapabilities.nullish(), () => {
40830
- return;
40831
- }),
40832
- nes: defaultOnError(zClientNesCapabilities.nullish(), () => {
40833
- return;
40834
- }),
40835
- positionEncodings: defaultOnError(vecSkipError(zPositionEncodingKind).optional(), () => []),
40836
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40837
- return;
40838
- })
40839
- });
40840
- var zInitializeRequest = object({
40841
- protocolVersion: zProtocolVersion,
40842
- clientCapabilities: defaultOnError(zClientCapabilities.optional().default({
40843
- fs: { readTextFile: false, writeTextFile: false },
40844
- terminal: false,
40845
- auth: { terminal: false }
40846
- }), () => ({
40847
- fs: { readTextFile: false, writeTextFile: false },
40848
- terminal: false,
40849
- auth: { terminal: false }
40850
- })),
40851
- clientInfo: defaultOnError(zImplementation.nullish(), () => {
40852
- return;
40853
- }),
40854
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40855
- return;
40856
- })
40857
- });
40858
- var zAuthenticateRequest = object({
40859
- methodId: zAuthMethodId,
40860
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40861
- return;
40862
- })
40863
- });
40864
- var zListProvidersRequest = object({
40865
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40866
- return;
40867
- })
40868
- });
40869
- var zSetProviderRequest = object({
40870
- providerId: zProviderId,
40871
- apiType: zLlmProtocol,
40872
- baseUrl: string2(),
40873
- headers: record(string2(), string2()).optional(),
40874
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40875
- return;
40876
- })
40877
- });
40878
- var zDisableProviderRequest = object({
40879
- providerId: zProviderId,
40880
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40881
- return;
40882
- })
40883
- });
40884
- var zLogoutRequest = object({
40885
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40886
- return;
40887
- })
40888
- });
40889
- var zHttpHeader = object({
40890
- name: string2(),
40891
- value: string2(),
40892
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40893
- return;
40894
- })
40895
- });
40896
- var zMcpServerHttp = object({
40897
- name: string2(),
40898
- url: string2(),
40899
- headers: array(zHttpHeader),
40900
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40901
- return;
40902
- })
40903
- });
40904
- var zMcpServerSse = object({
40905
- name: string2(),
40906
- url: string2(),
40907
- headers: array(zHttpHeader),
40908
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40909
- return;
40910
- })
40911
- });
40912
- var zMcpServerAcp = object({
40913
- name: string2(),
40914
- serverId: zMcpServerAcpId,
40915
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40916
- return;
40917
- })
40918
- });
40919
- var zMcpServerStdio = object({
40920
- name: string2(),
40921
- command: string2(),
40922
- args: array(string2()),
40923
- env: array(zEnvVariable),
40924
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40925
- return;
40926
- })
40927
- });
40928
- var zMcpServer = union([
40929
- zMcpServerHttp.and(object({
40930
- type: literal("http")
40931
- })),
40932
- zMcpServerSse.and(object({
40933
- type: literal("sse")
40934
- })),
40935
- zMcpServerAcp.and(object({
40936
- type: literal("acp")
40937
- })),
40938
- zMcpServerStdio
40939
- ]);
40940
- var zNewSessionRequest = object({
40941
- cwd: string2(),
40942
- additionalDirectories: defaultOnError(vecSkipError(string2()).optional(), () => []),
40943
- mcpServers: requiredDefaultOnError(vecSkipError(zMcpServer), () => []),
40944
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40945
- return;
40946
- })
40947
- });
40948
- var zLoadSessionRequest = object({
40949
- mcpServers: requiredDefaultOnError(vecSkipError(zMcpServer), () => []),
40950
- cwd: string2(),
40951
- additionalDirectories: defaultOnError(vecSkipError(string2()).optional(), () => []),
40952
- sessionId: zSessionId,
40953
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40954
- return;
40955
- })
40956
- });
40957
- var zListSessionsRequest = object({
40958
- cwd: string2().nullish(),
40959
- cursor: string2().nullish(),
40960
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40961
- return;
40962
- })
40963
- });
40964
- var zDeleteSessionRequest = object({
40965
- sessionId: zSessionId,
40966
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40967
- return;
40968
- })
40969
- });
40970
- var zForkSessionRequest = object({
40971
- sessionId: zSessionId,
40972
- cwd: string2(),
40973
- additionalDirectories: defaultOnError(vecSkipError(string2()).optional(), () => []),
40974
- mcpServers: defaultOnError(vecSkipError(zMcpServer).optional(), () => []),
40975
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40976
- return;
40977
- })
40978
- });
40979
- var zResumeSessionRequest = object({
40980
- sessionId: zSessionId,
40981
- cwd: string2(),
40982
- additionalDirectories: defaultOnError(vecSkipError(string2()).optional(), () => []),
40983
- mcpServers: defaultOnError(vecSkipError(zMcpServer).optional(), () => []),
40984
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40985
- return;
40986
- })
40987
- });
40988
- var zCloseSessionRequest = object({
40989
- sessionId: zSessionId,
40990
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40991
- return;
40992
- })
40993
- });
40994
- var zSetSessionModeRequest = object({
40995
- sessionId: zSessionId,
40996
- modeId: zSessionModeId,
40997
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
40998
- return;
40999
- })
41000
- });
41001
- var zSetSessionConfigOptionRequest = intersection(union([
41002
- object({
41003
- value: boolean2(),
41004
- type: literal("boolean")
41005
- }),
41006
- object({
41007
- value: zSessionConfigValueId
41008
- })
41009
- ]), object({
41010
- sessionId: zSessionId,
41011
- configId: zSessionConfigId,
41012
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41013
- return;
41014
- })
41015
- }));
41016
- var zPromptRequest = object({
41017
- sessionId: zSessionId,
41018
- prompt: array(zContentBlock),
41019
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41020
- return;
41021
- })
41022
- });
41023
- var zWorkspaceFolder = object({
41024
- uri: string2(),
41025
- name: string2(),
41026
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41027
- return;
41028
- })
41029
- });
41030
- var zNesRepository = object({
41031
- name: string2(),
41032
- owner: string2(),
41033
- remoteUrl: string2(),
41034
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41035
- return;
41036
- })
41037
- });
41038
- var zStartNesRequest = object({
41039
- workspaceUri: defaultOnError(string2().nullish(), () => {
41040
- return;
41041
- }),
41042
- workspaceFolders: array(zWorkspaceFolder).nullish(),
41043
- repository: defaultOnError(zNesRepository.nullish(), () => {
41044
- return;
41045
- }),
41046
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41047
- return;
41048
- })
41049
- });
41050
- var zNesTriggerKind = union([
41051
- literal("automatic"),
41052
- literal("diagnostic"),
41053
- literal("manual")
41054
- ]);
41055
- var zNesRecentFile = object({
41056
- uri: string2(),
41057
- languageId: string2(),
41058
- text: string2(),
41059
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41060
- return;
41061
- })
41062
- });
41063
- var zNesExcerpt = object({
41064
- startLine: int().gte(0).max(4294967295, {
41065
- error: "Invalid value: Expected uint32 to be <= 4294967295"
41066
- }),
41067
- endLine: int().gte(0).max(4294967295, {
41068
- error: "Invalid value: Expected uint32 to be <= 4294967295"
41069
- }),
41070
- text: string2(),
41071
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41072
- return;
41073
- })
41074
- });
41075
- var zNesRelatedSnippet = object({
41076
- uri: string2(),
41077
- excerpts: array(zNesExcerpt),
41078
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41079
- return;
41080
- })
41081
- });
41082
- var zNesEditHistoryEntry = object({
41083
- uri: string2(),
41084
- diff: string2(),
41085
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41086
- return;
41087
- })
41088
- });
41089
- var zNesUserAction = object({
41090
- action: string2(),
41091
- uri: string2(),
41092
- position: zPosition,
41093
- timestampMs: number2(),
41094
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41095
- return;
41096
- })
41097
- });
41098
- var zNesOpenFile = object({
41099
- uri: string2(),
41100
- languageId: string2(),
41101
- visibleRange: defaultOnError(zRange.nullish(), () => {
41102
- return;
41103
- }),
41104
- lastFocusedMs: defaultOnError(number2().nullish(), () => {
41105
- return;
41106
- }),
41107
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41108
- return;
41109
- })
41110
- });
41111
- var zNesDiagnosticSeverity = union([
41112
- literal("error"),
41113
- literal("warning"),
41114
- literal("information"),
41115
- literal("hint")
41116
- ]);
41117
- var zNesDiagnostic = object({
41118
- uri: string2(),
41119
- range: zRange,
41120
- severity: zNesDiagnosticSeverity,
41121
- message: string2(),
41122
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41123
- return;
41124
- })
41125
- });
41126
- var zNesSuggestContext = object({
41127
- recentFiles: array(zNesRecentFile).nullish(),
41128
- relatedSnippets: array(zNesRelatedSnippet).nullish(),
41129
- editHistory: array(zNesEditHistoryEntry).nullish(),
41130
- userActions: array(zNesUserAction).nullish(),
41131
- openFiles: array(zNesOpenFile).nullish(),
41132
- diagnostics: array(zNesDiagnostic).nullish(),
41133
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41134
- return;
41135
- })
41136
- });
41137
- var zSuggestNesRequest = object({
41138
- sessionId: zSessionId,
41139
- uri: string2(),
41140
- version: number2(),
41141
- position: zPosition,
41142
- selection: zRange.nullish(),
41143
- triggerKind: zNesTriggerKind,
41144
- context: zNesSuggestContext.nullish(),
41145
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41146
- return;
41147
- })
41148
- });
41149
- var zCloseNesRequest = object({
41150
- sessionId: zSessionId,
41151
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41152
- return;
41153
- })
41154
- });
41155
- var zClientRequest = object({
41156
- id: zRequestId,
41157
- method: string2(),
41158
- params: union([
41159
- zInitializeRequest,
41160
- zAuthenticateRequest,
41161
- zListProvidersRequest,
41162
- zSetProviderRequest,
41163
- zDisableProviderRequest,
41164
- zLogoutRequest,
41165
- zNewSessionRequest,
41166
- zLoadSessionRequest,
41167
- zListSessionsRequest,
41168
- zDeleteSessionRequest,
41169
- zForkSessionRequest,
41170
- zResumeSessionRequest,
41171
- zCloseSessionRequest,
41172
- zSetSessionModeRequest,
41173
- zSetSessionConfigOptionRequest,
41174
- zPromptRequest,
41175
- zStartNesRequest,
41176
- zSuggestNesRequest,
41177
- zCloseNesRequest,
41178
- zMessageMcpRequest,
41179
- zExtRequest
41180
- ]).nullish()
41181
- });
41182
- var zWriteTextFileResponse = object({
41183
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41184
- return;
41185
- })
41186
- });
41187
- var zReadTextFileResponse = object({
41188
- content: string2(),
41189
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41190
- return;
41191
- })
41192
- });
41193
- var zSelectedPermissionOutcome = object({
41194
- optionId: zPermissionOptionId,
41195
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41196
- return;
41197
- })
41198
- });
41199
- var zRequestPermissionOutcome = union([
41200
- object({
41201
- outcome: literal("cancelled")
41202
- }),
41203
- zSelectedPermissionOutcome.and(object({
41204
- outcome: literal("selected")
41205
- }))
41206
- ]);
41207
- var zRequestPermissionResponse = object({
41208
- outcome: zRequestPermissionOutcome,
41209
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41210
- return;
41211
- })
41212
- });
41213
- var zCreateTerminalResponse = object({
41214
- terminalId: zTerminalId,
41215
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41216
- return;
41217
- })
41218
- });
41219
- var zTerminalExitStatus = object({
41220
- exitCode: defaultOnError(int().gte(0).max(4294967295, {
41221
- error: "Invalid value: Expected uint32 to be <= 4294967295"
41222
- }).nullish(), () => {
41223
- return;
41224
- }),
41225
- signal: defaultOnError(string2().nullish(), () => {
41226
- return;
41227
- }),
41228
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41229
- return;
41230
- })
41231
- });
41232
- var zTerminalOutputResponse = object({
41233
- output: string2(),
41234
- truncated: boolean2(),
41235
- exitStatus: defaultOnError(zTerminalExitStatus.nullish(), () => {
41236
- return;
41237
- }),
41238
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41239
- return;
41240
- })
41241
- });
41242
- var zReleaseTerminalResponse = object({
41243
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41244
- return;
41245
- })
41246
- });
41247
- var zWaitForTerminalExitResponse = object({
41248
- exitCode: defaultOnError(int().gte(0).max(4294967295, {
41249
- error: "Invalid value: Expected uint32 to be <= 4294967295"
41250
- }).nullish(), () => {
41251
- return;
41252
- }),
41253
- signal: defaultOnError(string2().nullish(), () => {
41254
- return;
41255
- }),
41256
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41257
- return;
41258
- })
41259
- });
41260
- var zKillTerminalResponse = object({
41261
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41262
- return;
41263
- })
41264
- });
41265
- var zElicitationContentValue = union([
41266
- string2(),
41267
- number2(),
41268
- number2(),
41269
- boolean2(),
41270
- array(string2())
41271
- ]);
41272
- var zElicitationAcceptAction = object({
41273
- content: record(string2(), zElicitationContentValue).nullish()
41274
- });
41275
- var zCreateElicitationResponse = preserveCustomPayload(intersection(union([
41276
- zElicitationAcceptAction.and(object({
41277
- action: literal("accept")
41278
- })),
41279
- object({
41280
- action: literal("decline")
41281
- }),
41282
- object({
41283
- action: literal("cancel")
41284
- }),
41285
- excludeKnownTags(object({
41286
- action: string2()
41287
- }), "action", ["accept", "cancel", "decline"])
41288
- ]), object({
41289
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41290
- return;
41291
- })
41292
- })), "action", ["accept", "cancel", "decline"]);
41293
- var zConnectMcpResponse = object({
41294
- connectionId: zMcpConnectionId,
41295
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41296
- return;
41297
- })
41298
- });
41299
- var zDisconnectMcpResponse = object({
41300
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41301
- return;
41302
- })
41303
- });
41304
- var zClientResponse = union([
41305
- object({
41306
- id: zRequestId,
41307
- result: union([
41308
- zWriteTextFileResponse,
41309
- zReadTextFileResponse,
41310
- zRequestPermissionResponse,
41311
- zCreateTerminalResponse,
41312
- zTerminalOutputResponse,
41313
- zReleaseTerminalResponse,
41314
- zWaitForTerminalExitResponse,
41315
- zKillTerminalResponse,
41316
- zCreateElicitationResponse,
41317
- zConnectMcpResponse,
41318
- zDisconnectMcpResponse,
41319
- zMessageMcpResponse,
41320
- zExtResponse
41321
- ])
41322
- }),
41323
- object({
41324
- id: zRequestId,
41325
- error: zError
41326
- })
41327
- ]);
41328
- var zCancelNotification = object({
41329
- sessionId: zSessionId,
41330
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41331
- return;
41332
- })
41333
- });
41334
- var zDidOpenDocumentNotification = object({
41335
- sessionId: zSessionId,
41336
- uri: string2(),
41337
- languageId: string2(),
41338
- version: number2(),
41339
- text: string2(),
41340
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41341
- return;
41342
- })
41343
- });
41344
- var zTextDocumentContentChangeEvent = object({
41345
- range: zRange.nullish(),
41346
- text: string2(),
41347
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41348
- return;
41349
- })
41350
- });
41351
- var zDidChangeDocumentNotification = object({
41352
- sessionId: zSessionId,
41353
- uri: string2(),
41354
- version: number2(),
41355
- contentChanges: requiredDefaultOnError(vecSkipError(zTextDocumentContentChangeEvent), () => []),
41356
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41357
- return;
41358
- })
41359
- });
41360
- var zDidCloseDocumentNotification = object({
41361
- sessionId: zSessionId,
41362
- uri: string2(),
41363
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41364
- return;
41365
- })
41366
- });
41367
- var zDidSaveDocumentNotification = object({
41368
- sessionId: zSessionId,
41369
- uri: string2(),
41370
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41371
- return;
41372
- })
41373
- });
41374
- var zDidFocusDocumentNotification = object({
41375
- sessionId: zSessionId,
41376
- uri: string2(),
41377
- version: number2(),
41378
- position: zPosition,
41379
- visibleRange: zRange,
41380
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41381
- return;
41382
- })
41383
- });
41384
- var zAcceptNesNotification = object({
41385
- sessionId: zSessionId,
41386
- id: zNesSuggestionId,
41387
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41388
- return;
41389
- })
41390
- });
41391
- var zNesRejectReason = union([
41392
- literal("rejected"),
41393
- literal("ignored"),
41394
- literal("replaced"),
41395
- literal("cancelled")
41396
- ]);
41397
- var zRejectNesNotification = object({
41398
- sessionId: zSessionId,
41399
- id: zNesSuggestionId,
41400
- reason: defaultOnError(zNesRejectReason.nullish(), () => {
41401
- return;
41402
- }),
41403
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41404
- return;
41405
- })
41406
- });
41407
- var zClientNotification = object({
41408
- method: string2(),
41409
- params: union([
41410
- zCancelNotification,
41411
- zDidOpenDocumentNotification,
41412
- zDidChangeDocumentNotification,
41413
- zDidCloseDocumentNotification,
41414
- zDidSaveDocumentNotification,
41415
- zDidFocusDocumentNotification,
41416
- zAcceptNesNotification,
41417
- zRejectNesNotification,
41418
- zMessageMcpNotification,
41419
- zExtNotification
41420
- ]).nullish()
41421
- });
41422
- var zCancelRequestNotification = object({
41423
- requestId: zRequestId,
41424
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
41425
- return;
41426
- })
41427
- });
41428
-
41429
- // node_modules/.bun/@agentclientprotocol+sdk@1.3.0+68a1e3a0c4588df3/node_modules/@agentclientprotocol/sdk/dist/jsonrpc.js
41430
- var CANCEL_REQUEST_METHOD = "$/cancel_request";
41431
- function isRequestMessage(value) {
41432
- return isJsonRpcEnvelope(value) && "id" in value && typeof value["method"] === "string" && isJsonRpcId(value["id"]);
41433
- }
41434
- function isResponseMessage(value) {
41435
- if (!isJsonRpcEnvelope(value) || "method" in value) {
41436
- return false;
41437
- }
41438
- if (!("id" in value) || !isJsonRpcId(value["id"])) {
41439
- return false;
41440
- }
41441
- const hasResult = Object.hasOwn(value, "result");
41442
- const hasError = Object.hasOwn(value, "error");
41443
- if (hasResult === hasError) {
41444
- return false;
41445
- }
41446
- return !hasError || isErrorResponse(value["error"]);
41447
- }
41448
- function isNotificationMessage(value) {
41449
- return isJsonRpcEnvelope(value) && !("id" in value) && typeof value["method"] === "string";
41450
- }
41451
- function isRecord(value) {
41452
- return typeof value === "object" && value !== null;
41453
- }
41454
- function isJsonRpcEnvelope(value) {
41455
- return isRecord(value) && value["jsonrpc"] === "2.0";
41456
- }
41457
- function isJsonRpcId(value) {
41458
- return value === null || typeof value === "string" || typeof value === "number" && Number.isFinite(value);
41459
- }
41460
- function isResponseShapedMessage(value) {
41461
- return isRecord(value) && !("method" in value) && (("id" in value) || ("result" in value) || ("error" in value));
41462
- }
41463
- function isResponseBatch(batch) {
41464
- let hasValidCall = false;
41465
- let hasValidResponse = false;
41466
- let hasCallShape = false;
41467
- let hasResponseShape = false;
41468
- for (const entry of batch) {
41469
- hasValidCall ||= isRequestMessage(entry) || isNotificationMessage(entry);
41470
- hasValidResponse ||= isResponseMessage(entry);
41471
- if (!isRecord(entry)) {
41472
- continue;
41473
- }
41474
- hasCallShape ||= "method" in entry;
41475
- hasResponseShape ||= "result" in entry || "error" in entry;
41476
- }
41477
- if (hasValidCall) {
41478
- return false;
41479
- }
41480
- if (hasValidResponse) {
41481
- return true;
41482
- }
41483
- return hasResponseShape && !hasCallShape;
41484
- }
41485
- function cancelRequestId(params) {
41486
- if (!isRecord(params) || !isJsonRpcId(params["requestId"])) {
41487
- return;
41488
- }
41489
- return params["requestId"];
41490
- }
41491
- function isErrorResponse(value) {
41492
- return isRecord(value) && typeof value["code"] === "number" && Number.isInteger(value["code"]) && typeof value["message"] === "string";
41493
- }
41494
- var Handled = {
41495
- yes() {
41496
- return { handled: true };
41497
- },
41498
- no(message, retry = false) {
41499
- return { handled: false, message, retry };
41500
- }
41501
- };
41502
- function rejectedPromise(error) {
41503
- const promise = Promise.reject(error);
41504
- promise.catch(() => {});
41505
- return promise;
41506
- }
41507
- function errorDetails(error) {
41508
- if (error instanceof Error) {
41509
- return error.message;
41510
- }
41511
- if (typeof error === "object" && error != null && "message" in error && typeof error.message === "string") {
41512
- return error.message;
41513
- }
41514
- return;
41515
- }
41516
- function isZodError(error) {
41517
- return typeof error === "object" && error !== null && "name" in error && error.name === "ZodError" && "issues" in error && Array.isArray(error.issues) && "format" in error && typeof error.format === "function";
41518
- }
41519
- function errorToResult(error) {
41520
- if (error instanceof RequestError) {
41521
- return error.toResult();
41522
- }
41523
- if (isZodError(error)) {
41524
- return RequestError.invalidParams(error.format()).toResult();
41525
- }
41526
- const details = errorDetails(error);
41527
- try {
41528
- return RequestError.internalError(details ? JSON.parse(details) : {}).toResult();
41529
- } catch {
41530
- return RequestError.internalError({ details }).toResult();
41531
- }
41532
- }
41533
- function requestCancelledError(reason) {
41534
- if (reason instanceof RequestError && reason.code === -32800) {
41535
- return reason;
41536
- }
41537
- return RequestError.requestCancelled(reason);
41538
- }
41539
- function errorToRequestResult(error, signal) {
41540
- const requestCancelled = abortErrorToRequestCancelled(error, signal);
41541
- return requestCancelled ? requestCancelled.toResult() : errorToResult(error);
41542
- }
41543
- function abortErrorToRequestCancelled(error, signal) {
41544
- if (!signal.aborted || !isAbortError(error)) {
41545
- return;
41546
- }
41547
- return requestCancelledError(signal.reason);
41548
- }
41549
- function isAbortError(error) {
41550
- if (typeof error !== "object" || error === null) {
41551
- return false;
41552
- }
41553
- const maybeAbortError = error;
41554
- return maybeAbortError.name === "AbortError" || maybeAbortError.code === "ABORT_ERR";
41555
- }
41556
-
41557
- class RequestResponder {
41558
- id;
41559
- sendResult;
41560
- signal;
41561
- finishRequest;
41562
- didRespond = false;
41563
- constructor(id, sendResult, signal = new AbortController().signal, finishRequest) {
41564
- this.id = id;
41565
- this.sendResult = sendResult;
41566
- this.signal = signal;
41567
- this.finishRequest = finishRequest;
41568
- }
41569
- get responded() {
41570
- return this.didRespond;
41571
- }
41572
- respond(response) {
41573
- return this.respondWithResult({ result: response ?? null });
41574
- }
41575
- respondWithError(error) {
41576
- const errorResponse = error instanceof RequestError ? error.toErrorResponse() : error;
41577
- return this.respondWithResult({ error: errorResponse });
41578
- }
41579
- respondWithResult(result) {
41580
- if (this.didRespond) {
41581
- return rejectedPromise(new Error("JSON-RPC request already responded"));
41582
- }
41583
- this.didRespond = true;
41584
- return this.sendResult(result).finally(() => {
41585
- this.finishRequest?.();
41586
- });
41587
- }
41588
- }
41589
-
41590
- class HandlerRegistration {
41591
- disposeHandler;
41592
- active = true;
41593
- constructor(disposeHandler) {
41594
- this.disposeHandler = disposeHandler;
41595
- }
41596
- dispose() {
41597
- if (!this.active) {
41598
- return;
41599
- }
41600
- this.active = false;
41601
- this.disposeHandler();
41602
- }
41603
- [Symbol.dispose]() {
41604
- this.dispose();
41605
- }
41606
- runIndefinitely() {
41607
- return this;
41608
- }
41609
- }
41610
-
41611
- class ConnectionContext {
41612
- connection;
41613
- constructor(connection) {
41614
- this.connection = connection;
41615
- }
41616
- sendRequest(method, params, mapResponse, options) {
41617
- return this.connection.sendRequest(method, params, mapResponse, options);
41618
- }
41619
- sendNotification(method, params) {
41620
- return this.connection.sendNotification(method, params);
41621
- }
41622
- sendBatch(entries) {
41623
- return this.connection.sendBatch(entries);
41624
- }
41625
- sendCancelRequest(requestId) {
41626
- return this.connection.sendCancelRequest(requestId);
41627
- }
41628
- addDynamicHandler(handler) {
41629
- return this.connection.addDynamicHandler(handler);
41630
- }
41631
- get signal() {
41632
- return this.connection.signal;
41633
- }
41634
- get closed() {
41635
- return this.connection.closed;
41636
- }
41637
- }
41638
-
41639
- class Connection {
41640
- pendingResponses = new Map;
41641
- incomingRequests = new Map;
41642
- nextRequestId = 0;
41643
- staticHandlers = [];
41644
- dynamicHandlers = new Set;
41645
- stream;
41646
- writeQueue = Promise.resolve();
41647
- abortController = new AbortController;
41648
- closedPromise;
41649
- retryQueue = [];
41650
- context = new ConnectionContext(this);
41651
- receiveReader;
41652
- allowBatches = true;
41653
- constructor(requestHandlerOrStream, notificationHandlerOrHandlers, streamOrOptions, options) {
41654
- if (typeof requestHandlerOrStream === "function") {
41655
- const requestHandler = requestHandlerOrStream;
41656
- const notificationHandler = notificationHandlerOrHandlers;
41657
- const stream = streamOrOptions;
41658
- this.initialize(stream, [
41659
- ...options?.handlers ?? [],
41660
- this.legacyHandler(requestHandler, notificationHandler)
41661
- ], options);
41662
- return;
41663
- }
41664
- const stream = requestHandlerOrStream;
41665
- const handlers = notificationHandlerOrHandlers;
41666
- const connectionOptions = streamOrOptions;
41667
- this.initialize(stream, [...connectionOptions?.handlers ?? [], ...handlers], connectionOptions);
41668
- }
41669
- static builder() {
41670
- return new ConnectionBuilder;
41671
- }
41672
- runUntil(op) {
41673
- let opSettled = false;
41674
- const opPromise = Promise.resolve().then(() => op(this.context)).finally(() => {
41675
- opSettled = true;
41676
- });
41677
- const closedPromise = this.closed.then(() => {
41678
- if (opSettled) {
41679
- return new Promise(() => {});
41680
- }
41681
- throw this.closedReason();
41682
- });
41683
- return Promise.race([opPromise, closedPromise]).finally(() => {
41684
- opSettled = true;
41685
- this.close();
41686
- });
41687
- }
41688
- addDynamicHandler(handler) {
41689
- this.dynamicHandlers.add(handler);
41690
- if (this.retryQueue.length > 0) {
41691
- for (const message of this.retryQueue.splice(0)) {
41692
- this.processIncomingMessage(message).catch((error) => this.close(error));
41693
- }
41694
- }
41695
- return new HandlerRegistration(() => {
41696
- this.dynamicHandlers.delete(handler);
41697
- });
41698
- }
41699
- get signal() {
41700
- return this.abortController.signal;
41701
- }
41702
- get closed() {
41703
- return this.closedPromise;
41704
- }
41705
- getContext() {
41706
- return this.context;
41707
- }
41708
- sendRequest(method, params, mapResponse, options = {}) {
41709
- if (this.abortController.signal.aborted) {
41710
- return rejectedPromise(this.closedReason());
41711
- }
41712
- const request = this.prepareRequest(method, params, mapResponse, options);
41713
- const requestSent = this.sendWireMessage(request.message);
41714
- requestSent.catch(() => {});
41715
- if (options.cancellationSignal?.aborted) {
41716
- request.cancel();
41717
- }
41718
- return request.response;
41719
- }
41720
- sendBatch(entries) {
41721
- if (this.abortController.signal.aborted) {
41722
- return rejectedPromise(this.closedReason());
41723
- }
41724
- if (!this.allowBatches) {
41725
- return rejectedPromise(new TypeError("JSON-RPC batches are not supported on this connection"));
41726
- }
41727
- if (entries.length === 0) {
41728
- return rejectedPromise(new TypeError("JSON-RPC batch must contain at least one entry"));
41729
- }
41730
- const messages = [];
41731
- const cancellations = [];
41732
- const outputs = [];
41733
- for (const entry of entries) {
41734
- if (entry.kind === "notification") {
41735
- messages.push({
41736
- jsonrpc: "2.0",
41737
- method: entry.method,
41738
- params: entry.params
41739
- });
41740
- outputs.push(Promise.resolve(undefined));
41741
- continue;
41742
- }
41743
- const request = this.prepareRequest(entry.method, entry.params, entry.mapResponse, entry.options);
41744
- messages.push(request.message);
41745
- outputs.push(request.response);
41746
- cancellations.push({
41747
- signal: entry.options?.cancellationSignal,
41748
- cancel: request.cancel
41749
- });
41750
- }
41751
- const batch = messages;
41752
- const batchSent = this.sendWireMessage(batch);
41753
- for (const cancellation of cancellations) {
41754
- if (cancellation.signal?.aborted) {
41755
- cancellation.cancel();
41756
- }
41757
- }
41758
- const response = Promise.all([batchSent, ...outputs]).then(([, ...resolved]) => resolved);
41759
- response.catch(() => {});
41760
- return response;
41761
- }
41762
- sendCancelRequest(requestId) {
41763
- return this.sendNotification(CANCEL_REQUEST_METHOD, { requestId });
41764
- }
41765
- sendNotification(method, params) {
41766
- if (this.abortController.signal.aborted) {
41767
- return rejectedPromise(this.closedReason());
41768
- }
41769
- return this.sendWireMessage({ jsonrpc: "2.0", method, params });
41770
- }
41771
- prepareRequest(method, params, mapResponse, options = {}) {
41772
- const id = this.nextRequestId++;
41773
- let cancel = () => {};
41774
- const response = new Promise((resolve, reject) => {
41775
- const pendingResponse = {
41776
- resolve: (value) => {
41777
- try {
41778
- resolve(mapResponse ? mapResponse(value) : value);
41779
- } catch (error) {
41780
- reject(error);
41781
- }
41782
- },
41783
- reject
41784
- };
41785
- cancel = () => {
41786
- if (pendingResponse.cancellationSent) {
41787
- return;
41788
- }
41789
- pendingResponse.cancellationSent = true;
41790
- pendingResponse.cleanup?.();
41791
- this.sendCancelRequest(id).catch(() => {});
41792
- };
41793
- options.cancellationSignal?.addEventListener("abort", cancel, {
41794
- once: true
41795
- });
41796
- pendingResponse.cleanup = () => {
41797
- options.cancellationSignal?.removeEventListener("abort", cancel);
41798
- };
41799
- this.pendingResponses.set(id, pendingResponse);
41800
- });
41801
- response.catch(() => {});
41802
- return {
41803
- message: { jsonrpc: "2.0", id, method, params },
41804
- response,
41805
- cancel: () => cancel()
41806
- };
41807
- }
41808
- close(error) {
41809
- if (this.abortController.signal.aborted) {
41810
- return;
41811
- }
41812
- const closeError = error ?? new Error("ACP connection closed");
41813
- this.abortController.abort(closeError);
41814
- for (const pendingResponse of this.pendingResponses.values()) {
41815
- pendingResponse.cleanup?.();
41816
- pendingResponse.reject(closeError);
41817
- }
41818
- this.pendingResponses.clear();
41819
- for (const controller of this.incomingRequests.values()) {
41820
- controller.abort(closeError);
41821
- }
41822
- this.incomingRequests.clear();
41823
- this.receiveReader?.cancel(closeError).catch(() => {});
41824
- }
41825
- initialize(stream, handlers, options) {
41826
- this.stream = stream;
41827
- this.staticHandlers = handlers;
41828
- this.allowBatches = options?.allowBatches ?? true;
41829
- this.closedPromise = new Promise((resolve) => {
41830
- this.abortController.signal.addEventListener("abort", () => resolve());
41831
- });
41832
- this.receive();
41833
- }
41834
- legacyHandler(requestHandler, notificationHandler) {
41835
- return {
41836
- handleMessage: async (message, cx) => {
41837
- if (message.kind === "request") {
41838
- const result = await requestHandler(message.method, message.params, cx);
41839
- await message.responder.respond(result);
41840
- } else {
41841
- await notificationHandler(message.method, message.params, cx);
41842
- }
41843
- return Handled.yes();
41844
- }
41845
- };
41846
- }
41847
- async receive() {
41848
- let closeError = undefined;
41849
- try {
41850
- const reader = this.stream.readable.getReader();
41851
- this.receiveReader = reader;
41852
- try {
41853
- while (!this.abortController.signal.aborted) {
41854
- const { value: message, done } = await reader.read();
41855
- if (this.abortController.signal.aborted) {
41856
- break;
41857
- }
41858
- if (done) {
41859
- break;
41860
- }
41861
- if (!message) {
41862
- continue;
41863
- }
41864
- this.receiveWireMessage(message);
41865
- }
41866
- } finally {
41867
- if (this.receiveReader === reader) {
41868
- this.receiveReader = undefined;
41869
- }
41870
- reader.releaseLock();
41871
- }
41872
- } catch (error) {
41873
- closeError = error;
41874
- } finally {
41875
- this.close(closeError);
41876
- }
41877
- }
41878
- receiveWireMessage(message) {
41879
- if (Array.isArray(message)) {
41880
- if (!this.allowBatches) {
41881
- this.close(new TypeError("JSON-RPC batches are not supported on this connection"));
41882
- return;
41883
- }
41884
- this.receiveBatch(message);
41885
- return;
41886
- }
41887
- if (!isRecord(message)) {
41888
- console.error("Invalid message", { message });
41889
- return;
41890
- }
41891
- this.receiveMessage(message);
41892
- }
41893
- receiveBatch(batch) {
41894
- if (batch.length === 0) {
41895
- this.sendWireMessage({
41896
- jsonrpc: "2.0",
41897
- id: null,
41898
- error: RequestError.invalidRequest(batch).toErrorResponse()
41899
- }).catch(() => {});
41900
- return;
41901
- }
41902
- const responseBatch = isResponseBatch(batch);
41903
- const responseCount = responseBatch ? 0 : batch.reduce((count, message) => count + (isNotificationMessage(message) ? 0 : 1), 0);
41904
- let remaining = responseCount;
41905
- let remainingNotifications = batch.reduce((count, message) => count + (isNotificationMessage(message) ? 1 : 0), 0);
41906
- let responseSent = false;
41907
- const responses = [];
41908
- const sendResponsesIfReady = async () => {
41909
- if (responseSent || remaining !== 0 || remainingNotifications !== 0 || responses.length === 0) {
41910
- return;
41911
- }
41912
- responseSent = true;
41913
- await this.sendWireMessage(responses);
41914
- };
41915
- const collectResponse = async (response) => {
41916
- responses.push(response);
41917
- remaining -= 1;
41918
- await sendResponsesIfReady();
41919
- };
41920
- for (const message of batch) {
41921
- if (responseBatch) {
41922
- if (isResponseShapedMessage(message)) {
41923
- this.receiveMessage(message);
41924
- }
41925
- continue;
41926
- }
41927
- if (!isRequestMessage(message) && !isNotificationMessage(message)) {
41928
- collectResponse({
41929
- jsonrpc: "2.0",
41930
- id: null,
41931
- error: RequestError.invalidRequest(message).toErrorResponse()
41932
- }).catch(() => {});
41933
- continue;
41934
- }
41935
- const processing = this.receiveMessage(message, isRequestMessage(message) ? collectResponse : undefined);
41936
- if (isNotificationMessage(message)) {
41937
- processing.finally(() => {
41938
- remainingNotifications -= 1;
41939
- sendResponsesIfReady().catch((error) => this.close(error));
41940
- });
41941
- }
41942
- }
41943
- }
41944
- receiveMessage(message, sendResponse) {
41945
- if (this.abortController.signal.aborted) {
41946
- return Promise.resolve();
41947
- }
41948
- if (!isRecord(message)) {
41949
- console.error("Invalid message", { message });
41950
- return Promise.resolve();
41951
- }
41952
- if ("method" in message) {
41953
- if (!("id" in message)) {
41954
- this.handleProtocolNotification(message);
41955
- }
41956
- return this.processIncomingMessage(this.toIncomingMessage(message, sendResponse)).catch((error) => this.close(error));
41957
- } else if ("id" in message) {
41958
- this.handleResponse(message);
41959
- } else {
41960
- console.error("Invalid message", { message });
41961
- }
41962
- return Promise.resolve();
41963
- }
41964
- async processIncomingMessage(message) {
41965
- if (this.abortController.signal.aborted) {
41966
- return;
41967
- }
41968
- let current = message;
41969
- let retry = false;
41970
- try {
41971
- for (const handler of [
41972
- ...this.staticHandlers,
41973
- ...this.dynamicHandlers.values()
41974
- ]) {
41975
- if (this.abortController.signal.aborted) {
41976
- return;
41977
- }
41978
- const result = await handler.handleMessage(current, this.context) ?? {
41979
- handled: true
41980
- };
41981
- if (result.handled) {
41982
- return;
41983
- }
41984
- current = result.message ?? current;
41985
- retry = retry || Boolean(result.retry);
41986
- }
41987
- if (retry) {
41988
- this.retryQueue.push(current);
41989
- } else if (current.kind === "request") {
41990
- await current.responder.respondWithError(RequestError.methodNotFound(current.method));
41991
- }
41992
- } catch (error) {
41993
- if (this.abortController.signal.aborted) {
41994
- return;
41995
- }
41996
- if (current.kind === "request" && !current.responder.responded) {
41997
- await current.responder.respondWithResult(errorToRequestResult(error, current.responder.signal));
41998
- } else {
41999
- const response = errorToResult(error);
42000
- if ("error" in response) {
42001
- console.error("Error handling notification", message.raw, response.error);
42002
- }
42003
- }
42004
- }
42005
- }
42006
- toIncomingMessage(message, sendResponse) {
42007
- if ("id" in message) {
42008
- const abortController = new AbortController;
42009
- this.incomingRequests.set(message.id, abortController);
42010
- const finishRequest = () => {
42011
- if (this.incomingRequests.get(message.id) === abortController) {
42012
- this.incomingRequests.delete(message.id);
42013
- }
42014
- };
42015
- return {
42016
- kind: "request",
42017
- method: message.method,
42018
- params: message.params,
42019
- raw: message,
42020
- signal: abortController.signal,
42021
- responder: new RequestResponder(message.id, (result) => {
42022
- const response = {
42023
- jsonrpc: "2.0",
42024
- id: message.id,
42025
- ...result
42026
- };
42027
- return sendResponse ? sendResponse(response) : this.sendWireMessage(response);
42028
- }, abortController.signal, finishRequest)
42029
- };
42030
- }
42031
- return {
42032
- kind: "notification",
42033
- method: message.method,
42034
- params: message.params,
42035
- raw: message
42036
- };
42037
- }
42038
- handleResponse(response) {
42039
- const pendingResponse = this.pendingResponses.get(response.id);
42040
- if (pendingResponse) {
42041
- this.pendingResponses.delete(response.id);
42042
- pendingResponse.cleanup?.();
42043
- if (!isResponseMessage(response)) {
42044
- pendingResponse.reject(RequestError.invalidRequest(response));
42045
- } else if ("result" in response) {
42046
- pendingResponse.resolve(response.result);
42047
- } else {
42048
- const { code, message, data } = response.error;
42049
- pendingResponse.reject(new RequestError(code, message, data));
42050
- }
42051
- } else {
42052
- console.error("Got response to unknown request", response.id);
42053
- }
42054
- }
42055
- handleProtocolNotification(message) {
42056
- if (message.method !== CANCEL_REQUEST_METHOD) {
42057
- return;
42058
- }
42059
- const requestId = cancelRequestId(message.params);
42060
- if (requestId === undefined) {
42061
- return;
42062
- }
42063
- const controller = this.incomingRequests.get(requestId);
42064
- if (!controller || controller.signal.aborted) {
42065
- return;
42066
- }
42067
- controller.abort(RequestError.requestCancelled({ requestId }));
42068
- }
42069
- closedReason() {
42070
- return this.abortController.signal.reason ?? new Error("ACP connection closed");
42071
- }
42072
- async sendWireMessage(message) {
42073
- if (this.abortController.signal.aborted) {
42074
- return rejectedPromise(this.closedReason());
42075
- }
42076
- this.writeQueue = this.writeQueue.then(async () => {
42077
- if (this.abortController.signal.aborted) {
42078
- throw this.closedReason();
42079
- }
42080
- const writer = this.stream.writable.getWriter();
42081
- try {
42082
- await writer.write(message);
42083
- } finally {
42084
- writer.releaseLock();
42085
- }
42086
- }).catch((error) => {
42087
- this.close(error);
42088
- throw error;
42089
- });
42090
- return this.writeQueue;
42091
- }
42092
- }
42093
-
42094
- class ConnectionBuilder {
42095
- handlers = [];
42096
- connectionName;
42097
- name(name) {
42098
- this.connectionName = name;
42099
- return this;
42100
- }
42101
- withHandler(handler) {
42102
- this.handlers.push(handler);
42103
- return this;
42104
- }
42105
- onReceiveMessage(handler) {
42106
- return this.withHandler({
42107
- handleMessage: async (message, cx) => await handler(message, cx) ?? Handled.no(message),
42108
- describe: () => this.connectionName ?? "onReceiveMessage"
42109
- });
42110
- }
42111
- onReceiveRequest(method, parse, handler) {
42112
- return this.withHandler({
42113
- handleMessage: async (message, cx) => {
42114
- if (message.kind !== "request" || message.method !== method) {
42115
- return Handled.no(message);
42116
- }
42117
- const request = parse(message.params);
42118
- return await handler(request, message.responder, cx) ?? Handled.yes();
42119
- },
42120
- describe: () => `${this.connectionName ?? "request"}:${method}`
42121
- });
42122
- }
42123
- onReceiveNotification(method, parse, handler) {
42124
- return this.withHandler({
42125
- handleMessage: async (message, cx) => {
42126
- if (message.kind !== "notification" || message.method !== method) {
42127
- return Handled.no(message);
42128
- }
42129
- const notification = parse(message.params);
42130
- return await handler(notification, cx) ?? Handled.yes();
42131
- },
42132
- describe: () => `${this.connectionName ?? "notification"}:${method}`
42133
- });
42134
- }
42135
- connect(stream, options) {
42136
- return new Connection(stream, this.handlers, options);
42137
- }
42138
- connectWith(stream, op, options) {
42139
- return this.connect(stream, options).runUntil(op);
42140
- }
42141
- }
42142
-
42143
- class RequestError extends Error {
42144
- code;
42145
- data;
42146
- constructor(code, message, data) {
42147
- super(message);
42148
- this.code = code;
42149
- this.name = "RequestError";
42150
- this.data = data;
42151
- }
42152
- static parseError(data, additionalMessage) {
42153
- return new RequestError(-32700, `Parse error${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
42154
- }
42155
- static invalidRequest(data, additionalMessage) {
42156
- return new RequestError(-32600, `Invalid request${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
42157
- }
42158
- static methodNotFound(method) {
42159
- return new RequestError(-32601, `"Method not found": ${method}`, {
42160
- method
42161
- });
42162
- }
42163
- static invalidParams(data, additionalMessage) {
42164
- return new RequestError(-32602, `Invalid params${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
42165
- }
42166
- static internalError(data, additionalMessage) {
42167
- return new RequestError(-32603, `Internal error${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
42168
- }
42169
- static requestCancelled(data, additionalMessage) {
42170
- return new RequestError(-32800, `Request cancelled${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
42171
- }
42172
- static authRequired(data, additionalMessage) {
42173
- return new RequestError(-32000, `Authentication required${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
42174
- }
42175
- static resourceNotFound(uri) {
42176
- return new RequestError(-32002, `Resource not found${uri ? `: ${uri}` : ""}`, uri && { uri });
42177
- }
42178
- toResult() {
42179
- return {
42180
- error: {
42181
- code: this.code,
42182
- message: this.message,
42183
- data: this.data
42184
- }
42185
- };
42186
- }
42187
- toErrorResponse() {
42188
- return {
42189
- code: this.code,
42190
- message: this.message,
42191
- data: this.data
42192
- };
42193
- }
42194
- }
42195
-
42196
- // node_modules/.bun/@agentclientprotocol+sdk@1.3.0+68a1e3a0c4588df3/node_modules/@agentclientprotocol/sdk/dist/line-buffer.js
42197
- var newline = 10;
42198
-
42199
- class LineBuffer {
42200
- #pending = [];
42201
- push(chunk) {
42202
- const lines = [];
42203
- let start = 0;
42204
- let newlineIndex = chunk.indexOf(newline, start);
42205
- while (newlineIndex !== -1) {
42206
- lines.push(this.#takeLine(chunk.subarray(start, newlineIndex)));
42207
- start = newlineIndex + 1;
42208
- newlineIndex = chunk.indexOf(newline, start);
42209
- }
42210
- if (start < chunk.byteLength) {
42211
- this.#pending.push(start === 0 ? chunk : new Uint8Array(chunk.subarray(start)));
42212
- }
42213
- return lines;
42214
- }
42215
- flush() {
42216
- if (this.#pending.length === 0) {
42217
- return;
42218
- }
42219
- return this.#takeLine(new Uint8Array(0));
42220
- }
42221
- #takeLine(tail) {
42222
- if (this.#pending.length === 0) {
42223
- return tail;
42224
- }
42225
- let total = tail.byteLength;
42226
- for (const part of this.#pending) {
42227
- total += part.byteLength;
42228
- }
42229
- const line = new Uint8Array(total);
42230
- let offset = 0;
42231
- for (const part of this.#pending) {
42232
- line.set(part, offset);
42233
- offset += part.byteLength;
42234
- }
42235
- line.set(tail, offset);
42236
- this.#pending = [];
42237
- return line;
42238
- }
42239
- }
42240
-
42241
- // node_modules/.bun/@agentclientprotocol+sdk@1.3.0+68a1e3a0c4588df3/node_modules/@agentclientprotocol/sdk/dist/stream.js
42242
- function ndJsonStream(output, input) {
42243
- const textEncoder = new TextEncoder;
42244
- const textDecoder = new TextDecoder;
42245
- let cancelled = false;
42246
- let inputReader;
42247
- const readable = new ReadableStream({
42248
- async start(controller) {
42249
- const lines = new LineBuffer;
42250
- const enqueueLine = (lineBytes) => {
42251
- const trimmedLine = textDecoder.decode(lineBytes).trim();
42252
- if (trimmedLine) {
42253
- try {
42254
- const message = JSON.parse(trimmedLine);
42255
- if (isRecord(message) || Array.isArray(message)) {
42256
- controller.enqueue(message);
42257
- } else {
42258
- console.warn("Skipping JSON line that is not an object:", trimmedLine);
42259
- }
42260
- } catch (err) {
42261
- console.error("Failed to parse JSON message:", trimmedLine, err);
42262
- }
42263
- }
42264
- };
42265
- const reader = input.getReader();
42266
- inputReader = reader;
42267
- try {
42268
- while (true) {
42269
- const { value, done } = await reader.read();
42270
- if (cancelled) {
42271
- return;
42272
- }
42273
- if (done) {
42274
- break;
42275
- }
42276
- if (!value) {
42277
- continue;
42278
- }
42279
- for (const line of lines.push(value)) {
42280
- enqueueLine(line);
42281
- if (cancelled) {
42282
- return;
42283
- }
42284
- }
42285
- }
42286
- if (cancelled) {
42287
- return;
42288
- }
42289
- const lastLine = lines.flush();
42290
- if (lastLine) {
42291
- enqueueLine(lastLine);
42292
- }
42293
- } catch (err) {
42294
- if (cancelled) {
42295
- return;
42296
- }
42297
- controller.error(err);
42298
- return;
42299
- } finally {
42300
- if (inputReader === reader) {
42301
- inputReader = undefined;
42302
- }
42303
- reader.releaseLock();
42304
- }
42305
- if (cancelled) {
42306
- return;
42307
- }
42308
- controller.close();
42309
- },
42310
- cancel(reason) {
42311
- cancelled = true;
42312
- return inputReader?.cancel(reason);
42313
- }
42314
- });
42315
- const writable = new WritableStream({
42316
- async write(message) {
42317
- const content = JSON.stringify(message) + `
42318
- `;
42319
- const writer = output.getWriter();
42320
- try {
42321
- await writer.write(textEncoder.encode(content));
42322
- } finally {
42323
- writer.releaseLock();
42324
- }
42325
- }
42326
- });
42327
- return { readable, writable };
42328
- }
42329
-
42330
- // node_modules/.bun/@agentclientprotocol+sdk@1.3.0+68a1e3a0c4588df3/node_modules/@agentclientprotocol/sdk/dist/schema/guards.gen.js
42331
- var zGuardCreateElicitationRequestForm = zElicitationFormMode.and(object({ mode: literal("form") })).and(object({ message: string2() }));
42332
- var zGuardCreateElicitationRequestUrl = zElicitationUrlMode.and(object({ mode: literal("url") })).and(object({ message: string2() }));
42333
- var zGuardCreateElicitationRequestCustom = union([zElicitationSessionScope, zElicitationRequestScope]).and(object({ message: string2() }));
42334
- var zGuardElicitationPropertySchemaString = zStringPropertySchema.and(object({ type: literal("string") }));
42335
- var zGuardElicitationPropertySchemaNumber = zNumberPropertySchema.and(object({ type: literal("number") }));
42336
- var zGuardElicitationPropertySchemaInteger = zIntegerPropertySchema.and(object({ type: literal("integer") }));
42337
- var zGuardElicitationPropertySchemaBoolean = zBooleanPropertySchema.and(object({ type: literal("boolean") }));
42338
- var zGuardElicitationPropertySchemaArray = zMultiSelectPropertySchema.and(object({ type: literal("array") }));
42339
- var zGuardMultiSelectItemsString = zStringMultiSelectItems.and(object({ type: literal("string") }));
42340
- var zGuardCreateElicitationResponseAccept = zElicitationAcceptAction.and(object({ action: literal("accept") }));
42341
- var zGuardCreateElicitationResponseDecline = object({
42342
- action: literal("decline")
42343
- });
42344
- var zGuardCreateElicitationResponseCancel = object({
42345
- action: literal("cancel")
42346
- });
42347
- // node_modules/.bun/@agentclientprotocol+sdk@1.3.0+68a1e3a0c4588df3/node_modules/@agentclientprotocol/sdk/dist/acp.js
42348
- function ndJsonStream2(output, input) {
42349
- return ndJsonStream(output, input);
42350
- }
42351
- function emptyObjectResponse(response) {
42352
- return response ?? {};
42353
- }
42354
- function isStream(value) {
42355
- return typeof value === "object" && value !== null && "readable" in value && "writable" in value;
42356
- }
42357
- function memoryStreamPair() {
42358
- const leftToRight = new TransformStream;
42359
- const rightToLeft = new TransformStream;
42360
- return [
42361
- {
42362
- readable: rightToLeft.readable,
42363
- writable: leftToRight.writable
42364
- },
42365
- {
42366
- readable: leftToRight.readable,
42367
- writable: rightToLeft.writable
42368
- }
42369
- ];
42370
- }
42371
- var methods = {
42372
- agent: {
42373
- initialize: AGENT_METHODS.initialize,
42374
- authenticate: AGENT_METHODS.authenticate,
42375
- logout: AGENT_METHODS.logout,
42376
- providers: {
42377
- list: AGENT_METHODS.providers_list,
42378
- set: AGENT_METHODS.providers_set,
42379
- disable: AGENT_METHODS.providers_disable
42380
- },
42381
- session: {
42382
- new: AGENT_METHODS.session_new,
42383
- load: AGENT_METHODS.session_load,
42384
- list: AGENT_METHODS.session_list,
42385
- delete: AGENT_METHODS.session_delete,
42386
- fork: AGENT_METHODS.session_fork,
42387
- resume: AGENT_METHODS.session_resume,
42388
- close: AGENT_METHODS.session_close,
42389
- setMode: AGENT_METHODS.session_set_mode,
42390
- setConfigOption: AGENT_METHODS.session_set_config_option,
42391
- prompt: AGENT_METHODS.session_prompt,
42392
- cancel: AGENT_METHODS.session_cancel
42393
- },
42394
- nes: {
42395
- start: AGENT_METHODS.nes_start,
42396
- suggest: AGENT_METHODS.nes_suggest,
42397
- accept: AGENT_METHODS.nes_accept,
42398
- reject: AGENT_METHODS.nes_reject,
42399
- close: AGENT_METHODS.nes_close
42400
- },
42401
- document: {
42402
- didOpen: AGENT_METHODS.document_did_open,
42403
- didChange: AGENT_METHODS.document_did_change,
42404
- didClose: AGENT_METHODS.document_did_close,
42405
- didSave: AGENT_METHODS.document_did_save,
42406
- didFocus: AGENT_METHODS.document_did_focus
42407
- }
42408
- },
42409
- client: {
42410
- session: {
42411
- requestPermission: CLIENT_METHODS.session_request_permission,
42412
- update: CLIENT_METHODS.session_update
42413
- },
42414
- fs: {
42415
- writeTextFile: CLIENT_METHODS.fs_write_text_file,
42416
- readTextFile: CLIENT_METHODS.fs_read_text_file
42417
- },
42418
- terminal: {
42419
- create: CLIENT_METHODS.terminal_create,
42420
- output: CLIENT_METHODS.terminal_output,
42421
- release: CLIENT_METHODS.terminal_release,
42422
- waitForExit: CLIENT_METHODS.terminal_wait_for_exit,
42423
- kill: CLIENT_METHODS.terminal_kill
42424
- },
42425
- elicitation: {
42426
- create: CLIENT_METHODS.elicitation_create,
42427
- complete: CLIENT_METHODS.elicitation_complete
42428
- }
42429
- },
42430
- protocol: {
42431
- cancelRequest: PROTOCOL_METHODS.cancel_request
42432
- }
42433
- };
42434
- var startActiveSession = Symbol("startActiveSession");
42435
-
42436
- class AcpContext {
42437
- cx;
42438
- currentRequestId;
42439
- constructor(cx, currentRequestId) {
42440
- this.cx = cx;
42441
- this.currentRequestId = currentRequestId;
42442
- }
42443
- get requestId() {
42444
- return this.currentRequestId;
42445
- }
42446
- get connectionContext() {
42447
- return this.cx;
42448
- }
42449
- sendRequest(method, params, mapResponse, options) {
42450
- return this.cx.sendRequest(method, params, mapResponse, options);
42451
- }
42452
- sendNotification(method, params) {
42453
- return this.cx.sendNotification(method, params);
42454
- }
42455
- addDynamicHandler(handler) {
42456
- return this.cx.addDynamicHandler(handler);
42457
- }
42458
- }
42459
-
42460
- class AgentContext extends AcpContext {
42461
- constructor(cx, requestId) {
42462
- super(cx, requestId);
42463
- }
42464
- static create(cx, requestId) {
42465
- return new AgentContext(cx, requestId);
42466
- }
42467
- request(method, params, options) {
42468
- const spec = clientRequestSpecsByMethod[method];
42469
- return this.sendRequest(method, params, spec?.mapResponse, options);
42470
- }
42471
- notify(method, params) {
42472
- return this.sendNotification(method, params);
42473
- }
42474
- }
42475
-
42476
- class ClientContext extends AcpContext {
42477
- constructor(cx, requestId) {
42478
- super(cx, requestId);
42479
- }
42480
- static create(cx, requestId) {
42481
- return new ClientContext(cx, requestId);
42482
- }
42483
- [startActiveSession](params, options) {
42484
- return this.sendRequest(AGENT_METHODS.session_new, params, (response) => this.attachSession(response), options);
42485
- }
42486
- buildSession(cwdOrRequest) {
42487
- if (typeof cwdOrRequest === "string") {
42488
- return SessionBuilder.create(this, {
42489
- cwd: cwdOrRequest,
42490
- mcpServers: []
42491
- });
42492
- }
42493
- return SessionBuilder.create(this, cwdOrRequest);
42494
- }
42495
- attachSession(response) {
42496
- const updates = new AsyncQueue;
42497
- const closeSignal = this.connectionContext.signal;
42498
- const failUpdatesOnClose = () => {
42499
- updates.fail(closeSignal.reason ?? new Error("ACP connection closed"));
42500
- };
42501
- if (closeSignal.aborted) {
42502
- failUpdatesOnClose();
42503
- } else {
42504
- closeSignal.addEventListener("abort", failUpdatesOnClose);
42505
- }
42506
- const sessionRegistration = sessionUpdateRouter(this.connectionContext).attach(response, updates);
42507
- const closeRegistration = new HandlerRegistration(() => {
42508
- closeSignal.removeEventListener("abort", failUpdatesOnClose);
42509
- });
42510
- return ActiveSession.create(this, response, updates, [
42511
- sessionRegistration,
42512
- closeRegistration
42513
- ]);
42514
- }
42515
- request(method, params, options) {
42516
- const spec = agentRequestSpecsByMethod[method];
42517
- return this.sendRequest(method, params, spec?.mapResponse, options);
42518
- }
42519
- notify(method, params) {
42520
- return this.sendNotification(method, params);
42521
- }
42522
- }
42523
-
42524
- class AcpConnectionHandle {
42525
- connection;
42526
- constructor(connection) {
42527
- this.connection = connection;
42528
- }
42529
- get signal() {
42530
- return this.connection.signal;
42531
- }
42532
- get closed() {
42533
- return this.connection.closed;
42534
- }
42535
- close(error) {
42536
- this.connection.close(error);
42537
- }
42538
- }
42539
-
42540
- class AgentConnectionHandle extends AcpConnectionHandle {
42541
- connectHandlers;
42542
- client;
42543
- didStartConnectHandlers = false;
42544
- constructor(connection, connectHandlers = []) {
42545
- super(connection);
42546
- this.connectHandlers = connectHandlers;
42547
- this.client = AgentContext.create(connection.getContext());
42548
- }
42549
- startConnectHandlers() {
42550
- if (this.didStartConnectHandlers) {
42551
- return;
42552
- }
42553
- this.didStartConnectHandlers = true;
42554
- runConnectHandlers(this, this.connectHandlers);
42555
- }
42556
- }
42557
-
42558
- class ClientConnectionHandle extends AcpConnectionHandle {
42559
- connectHandlers;
42560
- agent;
42561
- didStartConnectHandlers = false;
42562
- constructor(connection, connectHandlers = []) {
42563
- super(connection);
42564
- this.connectHandlers = connectHandlers;
42565
- this.agent = ClientContext.create(connection.getContext());
42566
- }
42567
- startConnectHandlers() {
42568
- if (this.didStartConnectHandlers) {
42569
- return;
42570
- }
42571
- this.didStartConnectHandlers = true;
42572
- runConnectHandlers(this, this.connectHandlers);
42573
- }
42574
- }
42575
- function agentConnection(connection, connectHandlers = []) {
42576
- return new AgentConnectionHandle(connection, connectHandlers);
42577
- }
42578
- function clientConnection(connection, connectHandlers = []) {
42579
- return new ClientConnectionHandle(connection, connectHandlers);
42580
- }
42581
-
42582
- class AsyncQueue {
42583
- values = [];
42584
- waiters = [];
42585
- failed = false;
42586
- failure;
42587
- enqueue(value) {
42588
- if (this.failed) {
42589
- return;
42590
- }
42591
- const waiter = this.waiters.shift();
42592
- if (waiter) {
42593
- waiter.resolve(value);
42594
- } else {
42595
- this.values.push({ kind: "value", value });
42596
- }
42597
- }
42598
- reject(error) {
42599
- if (this.failed) {
42600
- return;
42601
- }
42602
- if (this.waiters.length > 0) {
42603
- for (const waiter of this.waiters.splice(0)) {
42604
- waiter.reject(error);
42605
- }
42606
- return;
42607
- }
42608
- this.values.push({ kind: "error", error });
42609
- }
42610
- clearErrors() {
42611
- this.values = this.values.filter((entry) => entry.kind === "value");
42612
- }
42613
- fail(error) {
42614
- if (this.failed) {
42615
- return;
42616
- }
42617
- this.failed = true;
42618
- this.failure = error;
42619
- for (const waiter of this.waiters.splice(0)) {
42620
- waiter.reject(error);
42621
- }
42622
- }
42623
- next() {
42624
- if (this.values.length > 0) {
42625
- const entry = this.values.shift();
42626
- if (entry.kind === "error") {
42627
- return Promise.reject(entry.error);
42628
- }
42629
- return Promise.resolve(entry.value);
42630
- }
42631
- if (this.failed) {
42632
- return Promise.reject(this.failure);
42633
- }
42634
- return new Promise((resolve, reject) => {
42635
- this.waiters.push({ resolve, reject });
42636
- });
42637
- }
42638
- }
42639
- function cloneNewSessionRequest(request) {
42640
- return {
42641
- ...request,
42642
- additionalDirectories: request.additionalDirectories ? [...request.additionalDirectories] : undefined,
42643
- mcpServers: [...request.mcpServers]
42644
- };
42645
- }
42646
-
42647
- class SessionBuilder {
42648
- cx;
42649
- request;
42650
- constructor(cx, request) {
42651
- this.cx = cx;
42652
- this.request = cloneNewSessionRequest(request);
42653
- }
42654
- static create(cx, request) {
42655
- return new SessionBuilder(cx, request);
42656
- }
42657
- toRequest() {
42658
- return cloneNewSessionRequest(this.request);
42659
- }
42660
- withAdditionalDirectories(additionalDirectories) {
42661
- this.request = {
42662
- ...this.request,
42663
- additionalDirectories: [...additionalDirectories]
42664
- };
42665
- return this;
42666
- }
42667
- withMcpServer(mcpServer) {
42668
- this.request = {
42669
- ...this.request,
42670
- mcpServers: [...this.request.mcpServers, mcpServer]
42671
- };
42672
- return this;
42673
- }
42674
- async start(options) {
42675
- return this.cx[startActiveSession](this.toRequest(), options);
42676
- }
42677
- async withSession(op) {
42678
- const session = await this.start();
42679
- try {
42680
- return await op(session);
42681
- } finally {
42682
- session.dispose();
42683
- }
42684
- }
42685
- }
42686
-
42687
- class ActiveSession {
42688
- cx;
42689
- sessionResponse;
42690
- updates;
42691
- registrations;
42692
- constructor(cx, sessionResponse, updates, registrations) {
42693
- this.cx = cx;
42694
- this.sessionResponse = sessionResponse;
42695
- this.updates = updates;
42696
- this.registrations = registrations;
42697
- }
42698
- static create(cx, sessionResponse, updates, registrations) {
42699
- return new ActiveSession(cx, sessionResponse, updates, registrations);
42700
- }
42701
- get sessionId() {
42702
- return this.sessionResponse.sessionId;
42703
- }
42704
- get modes() {
42705
- return this.sessionResponse.modes;
42706
- }
42707
- get meta() {
42708
- return this.sessionResponse._meta;
42709
- }
42710
- get newSessionResponse() {
42711
- return this.sessionResponse;
42712
- }
42713
- prompt(prompt, options) {
42714
- this.updates.clearErrors();
42715
- const response = this.cx.request(AGENT_METHODS.session_prompt, {
42716
- sessionId: this.sessionId,
42717
- prompt: this.promptBlocks(prompt)
42718
- }, options);
42719
- response.then((value) => {
42720
- this.updates.enqueue({
42721
- kind: "stop",
42722
- response: value,
42723
- stopReason: value.stopReason
42724
- });
42725
- }, (error) => {
42726
- this.updates.reject(error);
42727
- });
42728
- return response;
42729
- }
42730
- nextUpdate() {
42731
- return this.updates.next();
42732
- }
42733
- async readText() {
42734
- let output = "";
42735
- for (;; ) {
42736
- const message = await this.nextUpdate();
42737
- if (message.kind === "stop") {
42738
- return output;
42739
- }
42740
- const { update } = message;
42741
- if (update.sessionUpdate === "agent_message_chunk" && update.content.type === "text") {
42742
- output += update.content.text;
42743
- }
42744
- }
42745
- }
42746
- dispose() {
42747
- for (const registration of this.registrations.splice(0)) {
42748
- registration.dispose();
42749
- }
42750
- this.updates.fail(new Error("Active session disposed"));
42751
- }
42752
- [Symbol.dispose]() {
42753
- this.dispose();
42754
- }
42755
- promptBlocks(prompt) {
42756
- if (typeof prompt === "string") {
42757
- return [{ type: "text", text: prompt }];
42758
- }
42759
- if (Array.isArray(prompt)) {
42760
- return prompt;
42761
- }
42762
- return [prompt];
42763
- }
42764
- }
42765
- function parseParams(parser, params) {
42766
- if (!parser) {
42767
- return params;
42768
- }
42769
- if (typeof parser === "function") {
42770
- return parser(params);
42771
- }
42772
- return parser.parse(params);
42773
- }
42774
- function requestSpec(method, params, mapResponse) {
42775
- return { method, params, mapResponse };
42776
- }
42777
- function notificationSpec(method, params) {
42778
- return { method, params };
42779
- }
42780
- function registerAppRequest(builder, spec, context, handler) {
42781
- builder.onReceiveRequest(spec.method, (params) => parseParams(spec.params, params), async (params, responder, cx) => {
42782
- const response = await handler(context(params, cx, responder.signal, responder.id));
42783
- await responder.respond(spec.mapResponse ? spec.mapResponse(response) : response);
42784
- });
42785
- }
42786
- function registerAppNotification(builder, spec, context, handler) {
42787
- builder.onReceiveNotification(spec.method, (params) => parseParams(spec.params, params), (params, cx) => handler(context(params, cx, cx.signal)));
42788
- }
42789
- function specsByMethod(specs) {
42790
- const byMethod = {};
42791
- for (const spec of Object.values(specs)) {
42792
- byMethod[spec.method] = spec;
42793
- }
42794
- return byMethod;
42795
- }
42796
- var agentRequestSpecs = {
42797
- initialize: requestSpec(AGENT_METHODS.initialize, zInitializeRequest),
42798
- newSession: requestSpec(AGENT_METHODS.session_new, zNewSessionRequest),
42799
- loadSession: requestSpec(AGENT_METHODS.session_load, zLoadSessionRequest, emptyObjectResponse),
42800
- unstable_forkSession: requestSpec(AGENT_METHODS.session_fork, zForkSessionRequest),
42801
- listSessions: requestSpec(AGENT_METHODS.session_list, zListSessionsRequest),
42802
- deleteSession: requestSpec(AGENT_METHODS.session_delete, zDeleteSessionRequest, emptyObjectResponse),
42803
- resumeSession: requestSpec(AGENT_METHODS.session_resume, zResumeSessionRequest),
42804
- closeSession: requestSpec(AGENT_METHODS.session_close, zCloseSessionRequest, emptyObjectResponse),
42805
- setSessionMode: requestSpec(AGENT_METHODS.session_set_mode, zSetSessionModeRequest, emptyObjectResponse),
42806
- setSessionConfigOption: requestSpec(AGENT_METHODS.session_set_config_option, zSetSessionConfigOptionRequest),
42807
- authenticate: requestSpec(AGENT_METHODS.authenticate, zAuthenticateRequest, emptyObjectResponse),
42808
- unstable_listProviders: requestSpec(AGENT_METHODS.providers_list, zListProvidersRequest),
42809
- unstable_setProvider: requestSpec(AGENT_METHODS.providers_set, zSetProviderRequest, emptyObjectResponse),
42810
- unstable_disableProvider: requestSpec(AGENT_METHODS.providers_disable, zDisableProviderRequest, emptyObjectResponse),
42811
- logout: requestSpec(AGENT_METHODS.logout, zLogoutRequest, emptyObjectResponse),
42812
- prompt: requestSpec(AGENT_METHODS.session_prompt, zPromptRequest),
42813
- unstable_startNes: requestSpec(AGENT_METHODS.nes_start, zStartNesRequest),
42814
- unstable_suggestNes: requestSpec(AGENT_METHODS.nes_suggest, zSuggestNesRequest),
42815
- unstable_closeNes: requestSpec(AGENT_METHODS.nes_close, zCloseNesRequest, emptyObjectResponse)
42816
- };
42817
- var agentNotificationSpecs = {
42818
- cancel: notificationSpec(AGENT_METHODS.session_cancel, zCancelNotification),
42819
- unstable_didOpenDocument: notificationSpec(AGENT_METHODS.document_did_open, zDidOpenDocumentNotification),
42820
- unstable_didChangeDocument: notificationSpec(AGENT_METHODS.document_did_change, zDidChangeDocumentNotification),
42821
- unstable_didCloseDocument: notificationSpec(AGENT_METHODS.document_did_close, zDidCloseDocumentNotification),
42822
- unstable_didSaveDocument: notificationSpec(AGENT_METHODS.document_did_save, zDidSaveDocumentNotification),
42823
- unstable_didFocusDocument: notificationSpec(AGENT_METHODS.document_did_focus, zDidFocusDocumentNotification),
42824
- unstable_acceptNes: notificationSpec(AGENT_METHODS.nes_accept, zAcceptNesNotification),
42825
- unstable_rejectNes: notificationSpec(AGENT_METHODS.nes_reject, zRejectNesNotification)
42826
- };
42827
- var clientRequestSpecs = {
42828
- requestPermission: requestSpec(CLIENT_METHODS.session_request_permission, zRequestPermissionRequest),
42829
- writeTextFile: requestSpec(CLIENT_METHODS.fs_write_text_file, zWriteTextFileRequest, emptyObjectResponse),
42830
- readTextFile: requestSpec(CLIENT_METHODS.fs_read_text_file, zReadTextFileRequest),
42831
- createTerminal: requestSpec(CLIENT_METHODS.terminal_create, zCreateTerminalRequest),
42832
- terminalOutput: requestSpec(CLIENT_METHODS.terminal_output, zTerminalOutputRequest),
42833
- releaseTerminal: requestSpec(CLIENT_METHODS.terminal_release, zReleaseTerminalRequest, emptyObjectResponse),
42834
- waitForTerminalExit: requestSpec(CLIENT_METHODS.terminal_wait_for_exit, zWaitForTerminalExitRequest),
42835
- killTerminal: requestSpec(CLIENT_METHODS.terminal_kill, zKillTerminalRequest, emptyObjectResponse),
42836
- unstable_createElicitation: requestSpec(CLIENT_METHODS.elicitation_create, zCreateElicitationRequest)
42837
- };
42838
- var clientNotificationSpecs = {
42839
- sessionUpdate: notificationSpec(CLIENT_METHODS.session_update, zSessionNotification),
42840
- unstable_completeElicitation: notificationSpec(CLIENT_METHODS.elicitation_complete, zCompleteElicitationNotification)
42841
- };
42842
- var agentRequestSpecsByMethod = specsByMethod(agentRequestSpecs);
42843
- var agentNotificationSpecsByMethod = specsByMethod(agentNotificationSpecs);
42844
- var clientRequestSpecsByMethod = specsByMethod(clientRequestSpecs);
42845
- var clientNotificationSpecsByMethod = specsByMethod(clientNotificationSpecs);
42846
- function clientRequestContext(params, agent, signal, requestId) {
42847
- return {
42848
- params,
42849
- requestId,
42850
- signal,
42851
- agent
42852
- };
42853
- }
42854
- function clientNotificationContext(params, agent, signal) {
42855
- return {
42856
- params,
42857
- signal,
42858
- agent
42859
- };
42860
- }
42861
-
42862
- class SessionUpdateRouter {
42863
- activeSessions = new Map;
42864
- handleMessage(message) {
42865
- if (message.kind !== "notification" || message.method !== CLIENT_METHODS.session_update) {
42866
- return Handled.no(message);
42867
- }
42868
- const notification = zSessionNotification.parse(message.params);
42869
- const update = {
42870
- kind: "session_update",
42871
- notification,
42872
- update: notification.update
42873
- };
42874
- const activeSessions = this.activeSessions.get(notification.sessionId);
42875
- if (activeSessions && activeSessions.size > 0) {
42876
- for (const session of activeSessions) {
42877
- session.enqueue(update);
42878
- }
42879
- }
42880
- return Handled.no(message);
42881
- }
42882
- attach(response, updates) {
42883
- const sessions = this.activeSessions.get(response.sessionId) ?? new Set;
42884
- sessions.add(updates);
42885
- this.activeSessions.set(response.sessionId, sessions);
42886
- return new HandlerRegistration(() => {
42887
- sessions.delete(updates);
42888
- if (sessions.size === 0) {
42889
- this.activeSessions.delete(response.sessionId);
42890
- }
42891
- });
42892
- }
42893
- }
42894
- var sessionUpdateRouters = new WeakMap;
42895
- function sessionUpdateRouter(cx) {
42896
- let router = sessionUpdateRouters.get(cx);
42897
- if (!router) {
42898
- router = new SessionUpdateRouter;
42899
- sessionUpdateRouters.set(cx, router);
42900
- }
42901
- return router;
42902
- }
42903
- function runConnectHandlers(connection, handlers) {
42904
- for (const handler of handlers) {
42905
- let result;
42906
- try {
42907
- result = handler(connection);
42908
- } catch (error) {
42909
- connection.close(error);
42910
- throw error;
42911
- }
42912
- Promise.resolve(result).catch((error) => {
42913
- connection.close(error);
42914
- });
42915
- }
42916
- }
42917
- var appBuilder = Symbol("appBuilder");
42918
- var runAgentConnectHandlers = Symbol("runAgentConnectHandlers");
42919
- var runClientConnectHandlers = Symbol("runClientConnectHandlers");
42920
- var stableConnectionOptions = { allowBatches: false };
42921
- function client(options) {
42922
- return new ClientApp(options);
42923
- }
42924
-
42925
- class ClientApp {
42926
- builder = Connection.builder();
42927
- connectHandlers = [];
42928
- constructor(options = {}) {
42929
- if (options.name) {
42930
- this.builder.name(options.name);
42931
- }
42932
- this.builder.withHandler({
42933
- handleMessage: (message, cx) => sessionUpdateRouter(cx).handleMessage(message),
42934
- describe: () => "client-session-update-router"
42935
- });
42936
- }
42937
- [appBuilder]() {
42938
- return this.builder;
42939
- }
42940
- [runClientConnectHandlers](connection) {
42941
- runConnectHandlers(connection, this.connectHandlers);
42942
- }
42943
- connect(target) {
42944
- return this.connectConnection(target).connection;
42945
- }
42946
- connectWith(target, op) {
42947
- const { rawConnection, connection } = this.connectConnection(target);
42948
- return rawConnection.runUntil(() => op(connection.agent));
42949
- }
42950
- onConnect(handler) {
42951
- this.connectHandlers.push(handler);
42952
- return this;
42953
- }
42954
- onRequest(method, handlerOrParams, handler) {
42955
- if (handler) {
42956
- return this.request({ method, params: handlerOrParams }, handler);
42957
- }
42958
- const spec = clientRequestSpecsByMethod[method];
42959
- if (!spec) {
42960
- throw new Error(`Unknown ACP request method '${method}'. Pass a params parser for custom methods.`);
42961
- }
42962
- return this.request(spec, handlerOrParams);
42963
- }
42964
- onNotification(method, handlerOrParams, handler) {
42965
- if (handler) {
42966
- return this.notification({ method, params: handlerOrParams }, handler);
42967
- }
42968
- const spec = clientNotificationSpecsByMethod[method];
42969
- if (!spec) {
42970
- throw new Error(`Unknown ACP notification method '${method}'. Pass a params parser for custom methods.`);
42971
- }
42972
- return this.notification(spec, handlerOrParams);
42973
- }
42974
- request(spec, handler) {
42975
- registerAppRequest(this.builder, spec, (params, cx, signal, requestId) => clientRequestContext(params, ClientContext.create(cx, requestId), signal, requestId), handler);
42976
- return this;
42977
- }
42978
- notification(spec, handler) {
42979
- registerAppNotification(this.builder, spec, (params, cx, signal) => clientNotificationContext(params, ClientContext.create(cx), signal), handler);
42980
- return this;
42981
- }
42982
- connectConnection(target) {
42983
- if (isStream(target)) {
42984
- const state = this.openStreamConnection(target);
42985
- this[runClientConnectHandlers](state.connection);
42986
- return state;
42987
- }
42988
- const [thisStream, peerStream] = memoryStreamPair();
42989
- const peerRawConnection = target[appBuilder]().connect(peerStream, stableConnectionOptions);
42990
- const peerConnection = agentConnection(peerRawConnection);
42991
- const state = this.openStreamConnection(thisStream);
42992
- state.rawConnection.closed.then(() => peerConnection.close());
42993
- peerRawConnection.closed.then(() => state.connection.close());
42994
- try {
42995
- target[runAgentConnectHandlers](peerConnection);
42996
- this[runClientConnectHandlers](state.connection);
42997
- } catch (error) {
42998
- peerConnection.close(error);
42999
- state.connection.close(error);
43000
- throw error;
43001
- }
43002
- return state;
43003
- }
43004
- openStreamConnection(stream) {
43005
- const rawConnection = this.builder.connect(stream, stableConnectionOptions);
43006
- return {
43007
- rawConnection,
43008
- connection: clientConnection(rawConnection, this.connectHandlers)
43009
- };
43010
- }
43011
- }
43012
- var legacyAgentRequestMethods = new Set([
43013
- AGENT_METHODS.initialize,
43014
- AGENT_METHODS.authenticate,
43015
- AGENT_METHODS.providers_list,
43016
- AGENT_METHODS.providers_set,
43017
- AGENT_METHODS.providers_disable,
43018
- AGENT_METHODS.session_new,
43019
- AGENT_METHODS.session_load,
43020
- AGENT_METHODS.session_set_mode,
43021
- AGENT_METHODS.session_set_config_option,
43022
- AGENT_METHODS.session_prompt,
43023
- AGENT_METHODS.session_list,
43024
- AGENT_METHODS.session_delete,
43025
- AGENT_METHODS.session_fork,
43026
- AGENT_METHODS.session_resume,
43027
- AGENT_METHODS.session_close,
43028
- AGENT_METHODS.logout,
43029
- AGENT_METHODS.nes_start,
43030
- AGENT_METHODS.nes_suggest,
43031
- AGENT_METHODS.nes_close
43032
- ]);
43033
- var legacyAgentNotificationMethods = new Set([
43034
- AGENT_METHODS.session_cancel,
43035
- AGENT_METHODS.nes_accept,
43036
- AGENT_METHODS.nes_reject,
43037
- AGENT_METHODS.document_did_open,
43038
- AGENT_METHODS.document_did_change,
43039
- AGENT_METHODS.document_did_close,
43040
- AGENT_METHODS.document_did_save,
43041
- AGENT_METHODS.document_did_focus
43042
- ]);
43043
- var legacyClientRequestMethods = new Set([
43044
- CLIENT_METHODS.session_request_permission,
43045
- CLIENT_METHODS.fs_write_text_file,
43046
- CLIENT_METHODS.fs_read_text_file,
43047
- CLIENT_METHODS.terminal_create,
43048
- CLIENT_METHODS.terminal_output,
43049
- CLIENT_METHODS.terminal_release,
43050
- CLIENT_METHODS.terminal_wait_for_exit,
43051
- CLIENT_METHODS.terminal_kill,
43052
- CLIENT_METHODS.elicitation_create
43053
- ]);
43054
- var legacyClientNotificationMethods = new Set([
43055
- CLIENT_METHODS.session_update,
43056
- CLIENT_METHODS.elicitation_complete
43057
- ]);
43058
-
43059
- // packages/api/src/server/acp/transport.ts
43060
- function createAcpTransport(options) {
43061
- const stream = ndJsonStream2(options.output, options.input);
43062
- const app = client({ name: "kennel-acp" });
43063
- if (options.onSessionUpdate) {
43064
- app.onNotification("session/update", (ctx) => {
43065
- Promise.resolve(options.onSessionUpdate(ctx.params, ctx.agent));
43066
- });
43067
- }
43068
- const connection = app.connect(stream);
43069
- connection.closed.then(() => options.onClose?.(), (error) => options.onClose?.(error));
43070
- return {
43071
- agent: connection.agent,
43072
- closed: connection.closed,
43073
- signal: connection.signal,
43074
- close(error) {
43075
- connection.close(error);
43076
- }
43077
- };
43078
- }
43079
-
43080
- // packages/api/src/server/acp-live-plugin.ts
43081
- async function bodyJson(request) {
43082
- const chunks = [];
43083
- for await (const chunk of request)
43084
- chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
43085
- const raw = Buffer.concat(chunks).toString("utf-8").trim();
43086
- return raw ? JSON.parse(raw) : {};
43087
- }
43088
- function reply(response, status, body, ct = "application/json; charset=utf-8") {
43089
- response.writeHead(status, {
43090
- "Content-Type": ct,
43091
- "Cache-Control": "no-store"
43092
- });
43093
- response.end(typeof body === "string" ? body : JSON.stringify(body));
43094
- }
43095
- function guardMutation(request, response) {
43096
- if (sameOrigin(request))
43097
- return false;
43098
- reply(response, 403, "Cross-origin mutations are not allowed", "text/plain");
43099
- return true;
43100
- }
43101
- function loopbackHost(value) {
43102
- if (!value)
43103
- return false;
43104
- try {
43105
- const parsed = new URL(value.includes("://") ? value : `http://${value}`);
43106
- const hostname = parsed.hostname.replace(/^\[|\]$/g, "").toLowerCase();
43107
- return hostname === "127.0.0.1" || hostname === "localhost" || hostname === "::1" || hostname === "::ffff:127.0.0.1" || hostname.startsWith("127.");
43108
- } catch {
43109
- return false;
43110
- }
43111
- }
43112
- function createAcpApi({
43113
- remoteAccess = false
43114
- } = {}) {
43115
- const manager = new AcpProcessManager;
43116
- const sessions = new Map;
43117
- let closed = false;
43118
- function broadcast(s, event) {
43119
- for (const fn of s.subscribers)
43120
- fn(event);
43121
- }
43122
- async function loadSession(transport, adapter, resumeId) {
43123
- const stored = await localSessions.readLocalSession(resumeId).catch(() => {
43124
- return;
43125
- });
43126
- const native = stored ? stored.id.slice(stored.id.indexOf(":") + 1) : resumeId;
43127
- await transport.agent.request("session/load", {
43128
- cwd: stored?.folder ?? adapter.workingFolder,
43129
- mcpServers: [],
43130
- sessionId: native
43131
- });
43132
- return native;
43133
- }
43134
- async function startSession(client, resumeId) {
43135
- if (closed)
43136
- throw new Error("Core is shutting down");
43137
- const adapter = findAdapter(client ?? "pi");
43138
- if (!adapter?.enabled)
43139
- throw new Error(`No ACP adapter available for "${client ?? "pi"}"`);
43140
- const browserId = randomUUID3();
43141
- const processKey = `acp-${browserId.slice(0, 8)}`;
43142
- const handle = manager.start(processKey, adapter);
43143
- const transport = createAcpTransport({
43144
- input: Readable.toWeb(handle.stdout),
43145
- output: Writable.toWeb(handle.stdin),
43146
- onClose: (err) => {
43147
- const s = sessions.get(browserId);
43148
- if (s) {
43149
- s.error = err ? String(err) : null;
43150
- s.transport = null;
43151
- }
43152
- }
43153
- });
43154
- await transport.agent.request("initialize", {
43155
- protocolVersion: 1,
43156
- clientInfo: { name: "kennel", version: "1.0.0" },
43157
- capabilities: {}
43158
- });
43159
- const acpId = resumeId ? await loadSession(transport, adapter, resumeId) : (await transport.agent.request("session/new", {
43160
- cwd: adapter.workingFolder,
43161
- mcpServers: []
43162
- })).sessionId;
43163
- const session = {
43164
- adapter,
43165
- browserId,
43166
- acpId,
43167
- transport,
43168
- processKey,
43169
- subscribers: new Set,
43170
- error: null
43171
- };
43172
- sessions.set(browserId, session);
43173
- return session;
43174
- }
43175
- async function destroySession(s) {
43176
- s.transport?.close();
43177
- s.transport = null;
43178
- await manager.stop(s.processKey, 2000, 1000).catch(() => {});
43179
- s.subscribers.clear();
43180
- sessions.delete(s.browserId);
43181
- }
43182
- return {
43183
- async close() {
43184
- closed = true;
43185
- await Promise.all([...sessions.values()].map(destroySession));
43186
- await manager.stopAll(2000, 1000);
43187
- },
43188
- name: "kennel-acp-live",
43189
- attach(server) {
43190
- server.use(async (request, response, next) => {
43191
- const url = new URL(request.url ?? "/", "http://127.0.0.1");
43192
- const method = request.method ?? "GET";
43193
- if (!url.pathname.startsWith("/api/acp/"))
43194
- return next();
43195
- if (remoteAccess) {
43196
- reply(response, 403, "ACP live sessions are disabled for remote access", "text/plain");
43197
- return;
43198
- }
43199
- if (url.pathname.startsWith("/api/acp/") && !loopbackHost(request.headers.host)) {
43200
- reply(response, 403, "Untrusted Host header", "text/plain");
43201
- return;
43202
- }
43203
- const streamMatch = /^\/api\/acp\/stream\/([a-f0-9-]+)$/.exec(url.pathname);
43204
- if (streamMatch?.[1] && method === "GET") {
43205
- const s = sessions.get(streamMatch[1]);
43206
- if (!s)
43207
- return reply(response, 404, "Session not found", "text/plain");
43208
- response.writeHead(200, {
43209
- "Content-Type": "text/event-stream; charset=utf-8",
43210
- "Cache-Control": "no-store",
43211
- Connection: "keep-alive",
43212
- "X-Accel-Buffering": "no"
43213
- });
43214
- const onEvent = (event) => {
43215
- if (!response.writableEnded)
43216
- response.write(`data: ${JSON.stringify(event)}
43217
-
43218
- `);
43219
- };
43220
- s.subscribers.add(onEvent);
43221
- request.on("close", () => {
43222
- s.subscribers.delete(onEvent);
43223
- if (!response.writableEnded)
43224
- response.end();
43225
- });
43226
- return;
43227
- }
43228
- if (url.pathname === "/api/acp/connect" && method === "POST") {
43229
- if (guardMutation(request, response))
43230
- return;
43231
- try {
43232
- const { client, resumeId } = await bodyJson(request);
43233
- const s = await startSession(client ? String(client) : undefined, resumeId ? String(resumeId) : undefined);
43234
- return reply(response, 200, {
43235
- sessionId: s.browserId,
43236
- connectionState: "connected"
43237
- });
43238
- } catch (err) {
43239
- return reply(response, 500, {
43240
- error: err instanceof Error ? err.message : String(err)
43241
- });
43242
- }
43243
- }
43244
- if (url.pathname === "/api/acp/send" && method === "POST") {
43245
- if (guardMutation(request, response))
43246
- return;
43247
- const { sessionId, text } = await bodyJson(request);
43248
- if (!sessionId || !text)
43249
- return reply(response, 400, "Missing sessionId or text", "text/plain");
43250
- const s = sessions.get(String(sessionId));
43251
- if (!s?.transport || !s.acpId)
43252
- return reply(response, 404, "Session not found", "text/plain");
43253
- s.transport.agent.request("session/prompt", {
43254
- sessionId: s.acpId,
43255
- prompt: [{ type: "text", text }]
43256
- }).then((result) => {
43257
- const data = result;
43258
- if (data?.content) {
43259
- for (const block of data.content) {
43260
- if (block.type === "text" && block.text) {
43261
- broadcast(s, { type: "text-delta", text: block.text });
43262
- } else if (block.type === "tool_call") {
43263
- const callId = randomUUID3();
43264
- broadcast(s, {
43265
- type: "tool-call-start",
43266
- callId,
43267
- name: block.name ?? "unknown",
43268
- input: block.input
43269
- });
43270
- broadcast(s, { type: "tool-call-end", callId });
43271
- }
43272
- }
43273
- }
43274
- if (data?.stopReason) {
43275
- broadcast(s, {
43276
- type: "done",
43277
- stopReason: data.stopReason,
43278
- usage: data.usage
43279
- });
43280
- }
43281
- }).catch((err) => {
43282
- broadcast(s, {
43283
- type: "error",
43284
- message: err instanceof Error ? err.message : String(err)
43285
- });
43286
- });
43287
- return reply(response, 202, { accepted: true });
43288
- }
43289
- if (url.pathname === "/api/acp/cancel" && method === "POST") {
43290
- if (guardMutation(request, response))
43291
- return;
43292
- const { sessionId } = await bodyJson(request);
43293
- const s = sessions.get(String(sessionId ?? ""));
43294
- if (!s?.transport)
43295
- return reply(response, 404, "Session not found", "text/plain");
43296
- try {
43297
- s.transport.agent.notify("$/cancel_request", {});
43298
- } catch {}
43299
- broadcast(s, { type: "cancelled" });
43300
- return reply(response, 200, { cancelled: true });
43301
- }
43302
- if (url.pathname === "/api/acp/disconnect" && method === "POST") {
43303
- if (guardMutation(request, response))
43304
- return;
43305
- const { sessionId } = await bodyJson(request);
43306
- const s = sessions.get(String(sessionId ?? ""));
43307
- if (!s)
43308
- return reply(response, 404, "Session not found", "text/plain");
43309
- await destroySession(s);
43310
- return reply(response, 200, { disconnected: true });
43311
- }
43312
- if (url.pathname === "/api/acp/resume" && method === "POST") {
43313
- if (guardMutation(request, response))
43314
- return;
43315
- const { sessionId, resumeId } = await bodyJson(request);
43316
- if (!resumeId)
43317
- return reply(response, 400, "Missing resumeId", "text/plain");
43318
- const s = sessions.get(String(sessionId ?? ""));
43319
- if (!s?.transport)
43320
- return reply(response, 404, "Session not found", "text/plain");
43321
- try {
43322
- s.acpId = await loadSession(s.transport, s.adapter, String(resumeId));
43323
- return reply(response, 200, {
43324
- sessionId: s.browserId,
43325
- resumed: true
43326
- });
43327
- } catch (err) {
43328
- return reply(response, 500, {
43329
- error: err instanceof Error ? err.message : String(err)
43330
- });
43331
- }
43332
- }
43333
- if (url.pathname === "/api/acp/reconnect" && method === "POST") {
43334
- if (guardMutation(request, response))
43335
- return;
43336
- const { sessionId } = await bodyJson(request);
43337
- const old = sessions.get(String(sessionId ?? ""));
43338
- if (!old)
43339
- return reply(response, 404, "Session not found", "text/plain");
43340
- await destroySession(old);
43341
- try {
43342
- const s = await startSession();
43343
- return reply(response, 200, {
43344
- sessionId: s.browserId,
43345
- connectionState: "connected"
43346
- });
43347
- } catch (err) {
43348
- return reply(response, 500, {
43349
- error: err instanceof Error ? err.message : String(err)
43350
- });
43351
- }
43352
- }
43353
- next();
43354
- });
43355
- }
43356
- };
43357
- }
43358
-
43359
38735
  // packages/api/src/server/index.ts
43360
38736
  var contentTypes = {
43361
38737
  ".html": "text/html",
@@ -43439,9 +38815,7 @@ data: ${JSON.stringify(event.data)}
43439
38815
  ...options,
43440
38816
  remoteAccess: remote
43441
38817
  });
43442
- const acp = createAcpApi({ remoteAccess: remote });
43443
38818
  folder.attach(host);
43444
- acp.attach(host);
43445
38819
  async function handle(request, response, next = () => {
43446
38820
  response.writeHead(404);
43447
38821
  response.end("Not found");
@@ -43550,8 +38924,7 @@ data: ${JSON.stringify(event.data)}
43550
38924
  await Promise.all([
43551
38925
  new Promise((done) => server.close(() => done())),
43552
38926
  watcher.close(),
43553
- folder.close(),
43554
- acp.close()
38927
+ folder.close()
43555
38928
  ]);
43556
38929
  }
43557
38930
  };