@cursor/july 0.1.103 → 0.1.105

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 (264) hide show
  1. package/dist/channels/change-monitors/change-monitors-channel.d.ts +5 -0
  2. package/dist/channels/change-monitors/change-monitors-channel.d.ts.map +1 -0
  3. package/dist/channels/change-monitors/change-monitors-channel.js +41 -0
  4. package/dist/channels/change-monitors/index.d.ts +4 -0
  5. package/dist/channels/change-monitors/index.d.ts.map +1 -0
  6. package/dist/channels/change-monitors/index.js +2 -0
  7. package/dist/channels/change-monitors/types.d.ts +39 -0
  8. package/dist/channels/change-monitors/types.d.ts.map +1 -0
  9. package/dist/channels/change-monitors/types.js +1 -0
  10. package/dist/channels/deployments/deployments-channel.d.ts.map +1 -1
  11. package/dist/channels/deployments/deployments-channel.js +1 -0
  12. package/dist/channels/deployments/types.d.ts +2 -0
  13. package/dist/channels/deployments/types.d.ts.map +1 -1
  14. package/dist/channels/github/defaults.d.ts.map +1 -1
  15. package/dist/channels/github/defaults.js +4 -0
  16. package/dist/channels/github/progress.d.ts +22 -0
  17. package/dist/channels/github/progress.d.ts.map +1 -1
  18. package/dist/channels/github/progress.js +32 -5
  19. package/dist/channels/issues/index.d.ts +4 -0
  20. package/dist/channels/issues/index.d.ts.map +1 -0
  21. package/dist/channels/issues/index.js +2 -0
  22. package/dist/channels/issues/issues-channel.d.ts +5 -0
  23. package/dist/channels/issues/issues-channel.d.ts.map +1 -0
  24. package/dist/channels/issues/issues-channel.js +37 -0
  25. package/dist/channels/issues/types.d.ts +33 -0
  26. package/dist/channels/issues/types.d.ts.map +1 -0
  27. package/dist/channels/issues/types.js +1 -0
  28. package/dist/docs/404.html +2 -2
  29. package/dist/docs/ab.html +4 -4
  30. package/dist/docs/assets/{app.DW9pXkpL.js → app.BVwaffdK.js} +1 -1
  31. package/dist/docs/assets/chunks/@localSearchIndexroot.CJxMklAy.js +1 -0
  32. package/dist/docs/assets/chunks/{VPLocalSearchBox.CdEIUwDg.js → VPLocalSearchBox.WuWTZ1x8.js} +1 -1
  33. package/dist/docs/assets/chunks/{theme.YZMHgPgg.js → theme.BYdI_6sF.js} +2 -2
  34. package/dist/docs/assets/{guides_github.md.DKYiT9do.js → guides_github.md.c0gdGJ-D.js} +1 -1
  35. package/dist/docs/assets/{guides_github.md.DKYiT9do.lean.js → guides_github.md.c0gdGJ-D.lean.js} +1 -1
  36. package/dist/docs/assets/guides_grokbot-agents.md.DVqdhBKb.js +9 -0
  37. package/dist/docs/assets/guides_grokbot-agents.md.DVqdhBKb.lean.js +1 -0
  38. package/dist/docs/assets/index.md.BW_6tOgR.js +5 -0
  39. package/dist/docs/assets/index.md.BW_6tOgR.lean.js +1 -0
  40. package/dist/docs/assets/{reference_channels.md.Dz8Cnudp.js → reference_channels.md.DBGcaB7m.js} +2 -2
  41. package/dist/docs/assets/{reference_channels.md.Dz8Cnudp.lean.js → reference_channels.md.DBGcaB7m.lean.js} +1 -1
  42. package/dist/docs/assets/{reference_cli.md.CJNc_xYK.js → reference_cli.md.C6Lo8SEd.js} +2 -1
  43. package/dist/docs/assets/{reference_extensions.md.DykHW3qL.js → reference_extensions.md.CGmMLblt.js} +1 -1
  44. package/dist/docs/assets/templates_grokbot-agents.md.c1s6Flp9.js +3 -0
  45. package/dist/docs/assets/templates_grokbot-agents.md.c1s6Flp9.lean.js +1 -0
  46. package/dist/docs/building-with-agents.html +4 -4
  47. package/dist/docs/concepts.html +4 -4
  48. package/dist/docs/deployment.html +4 -4
  49. package/dist/docs/design/filesystem.md +376 -0
  50. package/dist/docs/evals.html +4 -4
  51. package/dist/docs/guides/agent-to-agent.html +4 -4
  52. package/dist/docs/guides/cloud-agents.html +5 -5
  53. package/dist/docs/guides/convert-automation.html +4 -4
  54. package/dist/docs/guides/github.html +6 -6
  55. package/dist/docs/guides/github.md +5 -0
  56. package/dist/docs/guides/grokbot-agents.html +35 -0
  57. package/dist/docs/guides/grokbot-agents.md +88 -0
  58. package/dist/docs/guides/human-in-the-loop.html +4 -4
  59. package/dist/docs/guides/mcp-oauth.html +4 -4
  60. package/dist/docs/guides/opentelemetry.html +5 -5
  61. package/dist/docs/guides/slack.html +4 -4
  62. package/dist/docs/guides/webhooks.html +4 -4
  63. package/dist/docs/hashmap.json +1 -1
  64. package/dist/docs/hillclimbing.html +4 -4
  65. package/dist/docs/index.html +6 -6
  66. package/dist/docs/index.md +6 -1
  67. package/dist/docs/llms-full.txt +562 -2
  68. package/dist/docs/llms.txt +3 -0
  69. package/dist/docs/quickstart.html +4 -4
  70. package/dist/docs/reference/agent-config.html +4 -4
  71. package/dist/docs/reference/artifacts.html +4 -4
  72. package/dist/docs/reference/channels.html +6 -6
  73. package/dist/docs/reference/channels.md +20 -0
  74. package/dist/docs/reference/cli.html +7 -6
  75. package/dist/docs/reference/cli.md +2 -1
  76. package/dist/docs/reference/connections.html +4 -4
  77. package/dist/docs/reference/extensions.html +6 -6
  78. package/dist/docs/reference/extensions.md +2 -0
  79. package/dist/docs/reference/hooks.html +4 -4
  80. package/dist/docs/reference/http-api.html +4 -4
  81. package/dist/docs/reference/instructions.html +4 -4
  82. package/dist/docs/reference/playground.html +4 -4
  83. package/dist/docs/reference/project-layout.html +4 -4
  84. package/dist/docs/reference/prompt.html +4 -4
  85. package/dist/docs/reference/result.html +4 -4
  86. package/dist/docs/reference/schedules.html +4 -4
  87. package/dist/docs/reference/sessions.html +4 -4
  88. package/dist/docs/reference/skills.html +4 -4
  89. package/dist/docs/reference/subagents.html +4 -4
  90. package/dist/docs/reference/tools.html +4 -4
  91. package/dist/docs/scaffolding-agents.html +4 -4
  92. package/dist/docs/skills/ab.html +4 -4
  93. package/dist/docs/skills/create-agent.html +4 -4
  94. package/dist/docs/skills/debug.html +4 -4
  95. package/dist/docs/skills/evals.html +4 -4
  96. package/dist/docs/skills/framework-map.html +4 -4
  97. package/dist/docs/skills/github.html +4 -4
  98. package/dist/docs/skills/hillclimb.html +4 -4
  99. package/dist/docs/skills/index.html +4 -4
  100. package/dist/docs/skills/mcp-auth.html +4 -4
  101. package/dist/docs/skills/otel.html +4 -4
  102. package/dist/docs/skills/setup-slack.html +4 -4
  103. package/dist/docs/storage.html +4 -4
  104. package/dist/docs/templates/agentic-owners.html +4 -4
  105. package/dist/docs/templates/agents-md.html +4 -4
  106. package/dist/docs/templates/code-wiki.html +5 -5
  107. package/dist/docs/templates/demo.html +5 -5
  108. package/dist/docs/templates/grokbot-agents.html +29 -0
  109. package/dist/docs/templates/grokbot-agents.md +48 -0
  110. package/dist/docs/templates/pr-autofixer.html +4 -4
  111. package/dist/docs/templates/security-help.html +4 -4
  112. package/dist/docs/templates/security-reviewer.html +4 -4
  113. package/dist/docs/templates/triage.html +4 -4
  114. package/dist/docs/troubleshooting.html +4 -4
  115. package/dist/files.d.ts +7 -2
  116. package/dist/files.d.ts.map +1 -1
  117. package/dist/files.js +7 -2
  118. package/dist/filesystem.d.ts +440 -0
  119. package/dist/filesystem.d.ts.map +1 -0
  120. package/dist/filesystem.js +1694 -0
  121. package/dist/index.d.ts +2 -0
  122. package/dist/index.d.ts.map +1 -1
  123. package/dist/index.js +1 -0
  124. package/dist/internal/continuation-channel.d.ts +4 -2
  125. package/dist/internal/continuation-channel.d.ts.map +1 -1
  126. package/dist/internal/continuation-channel.js +21 -12
  127. package/dist/internal/continuation-identity.d.ts +13 -5
  128. package/dist/internal/continuation-identity.d.ts.map +1 -1
  129. package/dist/internal/continuation-identity.js +74 -35
  130. package/dist/internal/cursor-agent-template.d.ts +1 -1
  131. package/dist/internal/cursor-agent-template.d.ts.map +1 -1
  132. package/dist/internal/cursor-agent-template.js +1 -0
  133. package/dist/internal/discovery/agent.d.ts.map +1 -1
  134. package/dist/internal/discovery/agent.js +80 -8
  135. package/dist/internal/discovery/info.d.ts.map +1 -1
  136. package/dist/internal/discovery/info.js +3 -0
  137. package/dist/internal/factory-resource-channel.d.ts +33 -0
  138. package/dist/internal/factory-resource-channel.d.ts.map +1 -0
  139. package/dist/internal/factory-resource-channel.js +77 -0
  140. package/dist/internal/filesystem/errors.d.ts +64 -0
  141. package/dist/internal/filesystem/errors.d.ts.map +1 -0
  142. package/dist/internal/filesystem/errors.js +175 -0
  143. package/dist/internal/filesystem/format.d.ts +28 -0
  144. package/dist/internal/filesystem/format.d.ts.map +1 -0
  145. package/dist/internal/filesystem/format.js +213 -0
  146. package/dist/internal/filesystem/merge.d.ts +34 -0
  147. package/dist/internal/filesystem/merge.d.ts.map +1 -0
  148. package/dist/internal/filesystem/merge.js +196 -0
  149. package/dist/internal/filesystem/scratch.d.ts +59 -0
  150. package/dist/internal/filesystem/scratch.d.ts.map +1 -0
  151. package/dist/internal/filesystem/scratch.js +212 -0
  152. package/dist/internal/filesystem/sdk-schemas.d.ts +29 -0
  153. package/dist/internal/filesystem/sdk-schemas.d.ts.map +1 -0
  154. package/dist/internal/filesystem/sdk-schemas.js +153 -0
  155. package/dist/internal/filesystem/tools.d.ts +42 -0
  156. package/dist/internal/filesystem/tools.d.ts.map +1 -0
  157. package/dist/internal/filesystem/tools.js +618 -0
  158. package/dist/internal/filesystem/walk.d.ts +74 -0
  159. package/dist/internal/filesystem/walk.d.ts.map +1 -0
  160. package/dist/internal/filesystem/walk.js +339 -0
  161. package/dist/internal/framework-file-storage.d.ts +3 -1
  162. package/dist/internal/framework-file-storage.d.ts.map +1 -1
  163. package/dist/internal/framework-file-storage.js +3 -1
  164. package/dist/internal/guest-network.d.ts +5 -2
  165. package/dist/internal/guest-network.d.ts.map +1 -1
  166. package/dist/internal/guest-network.js +7 -2
  167. package/dist/internal/hosted-delivery.d.ts +7 -0
  168. package/dist/internal/hosted-delivery.d.ts.map +1 -1
  169. package/dist/internal/hosted-delivery.js +41 -3
  170. package/dist/internal/hosted-managed-automation.d.ts.map +1 -1
  171. package/dist/internal/hosted-managed-automation.js +27 -2
  172. package/dist/internal/init-project.d.ts.map +1 -1
  173. package/dist/internal/init-project.js +4 -1
  174. package/dist/internal/sdk-runner.d.ts +13 -1
  175. package/dist/internal/sdk-runner.d.ts.map +1 -1
  176. package/dist/internal/sdk-runner.js +21 -1
  177. package/dist/internal/server.d.ts.map +1 -1
  178. package/dist/internal/server.js +11 -3
  179. package/dist/internal/session-engine.d.ts +30 -0
  180. package/dist/internal/session-engine.d.ts.map +1 -1
  181. package/dist/internal/session-engine.js +484 -82
  182. package/dist/internal/store-mirror.d.ts +2 -2
  183. package/dist/internal/store-mirror.js +2 -2
  184. package/dist/internal/tenant-slack/relay.d.ts +2 -0
  185. package/dist/internal/tenant-slack/relay.d.ts.map +1 -1
  186. package/dist/internal/tenant-slack/relay.js +18 -8
  187. package/dist/internal/testing/factory-resource-fixtures.d.ts +48 -0
  188. package/dist/internal/testing/factory-resource-fixtures.d.ts.map +1 -0
  189. package/dist/internal/testing/factory-resource-fixtures.js +41 -0
  190. package/dist/internal/workspace-sync.d.ts +31 -6
  191. package/dist/internal/workspace-sync.d.ts.map +1 -1
  192. package/dist/internal/workspace-sync.js +67 -12
  193. package/dist/internal/workspace.d.ts +9 -0
  194. package/dist/internal/workspace.d.ts.map +1 -1
  195. package/dist/internal/workspace.js +16 -0
  196. package/dist/playground/assets/{index-59KvgREd.js → index-BaQzjaNK.js} +40 -40
  197. package/dist/playground/assets/index-CceqnLTX.css +1 -0
  198. package/dist/playground/index.html +2 -2
  199. package/dist/types.d.ts +60 -11
  200. package/dist/types.d.ts.map +1 -1
  201. package/docs/README.md +6 -1
  202. package/docs/design/filesystem.md +376 -0
  203. package/docs/guides/github.md +5 -0
  204. package/docs/guides/grokbot-agents.md +93 -0
  205. package/docs/reference/channels.md +20 -0
  206. package/docs/reference/cli.md +2 -1
  207. package/docs/reference/extensions.md +2 -0
  208. package/docs/templates/grokbot-agents.md +53 -0
  209. package/package.json +25 -2
  210. package/src/channels/change-monitors/change-monitors-channel.ts +62 -0
  211. package/src/channels/change-monitors/index.ts +8 -0
  212. package/src/channels/change-monitors/types.ts +44 -0
  213. package/src/channels/deployments/deployments-channel.ts +1 -0
  214. package/src/channels/deployments/types.ts +2 -0
  215. package/src/channels/github/defaults.ts +4 -0
  216. package/src/channels/github/progress.ts +76 -10
  217. package/src/channels/issues/index.ts +9 -0
  218. package/src/channels/issues/issues-channel.ts +51 -0
  219. package/src/channels/issues/types.ts +41 -0
  220. package/src/files.ts +9 -2
  221. package/src/filesystem.ts +2074 -0
  222. package/src/index.ts +28 -0
  223. package/src/internal/continuation-channel.ts +29 -12
  224. package/src/internal/continuation-identity.ts +122 -37
  225. package/src/internal/cursor-agent-template.ts +1 -0
  226. package/src/internal/discovery/agent.ts +87 -1
  227. package/src/internal/discovery/info.ts +3 -0
  228. package/src/internal/factory-resource-channel.ts +122 -0
  229. package/src/internal/filesystem/errors.ts +220 -0
  230. package/src/internal/filesystem/format.ts +276 -0
  231. package/src/internal/filesystem/merge.ts +195 -0
  232. package/src/internal/filesystem/scratch.ts +255 -0
  233. package/src/internal/filesystem/sdk-schemas.ts +204 -0
  234. package/src/internal/filesystem/tools.ts +821 -0
  235. package/src/internal/filesystem/walk.ts +369 -0
  236. package/src/internal/framework-file-storage.ts +3 -1
  237. package/src/internal/guest-network.ts +8 -2
  238. package/src/internal/hosted-delivery.ts +71 -2
  239. package/src/internal/hosted-managed-automation.ts +49 -5
  240. package/src/internal/init-project.ts +4 -1
  241. package/src/internal/sdk-runner.ts +23 -0
  242. package/src/internal/server.ts +16 -0
  243. package/src/internal/session-engine.ts +595 -73
  244. package/src/internal/store-mirror.ts +2 -2
  245. package/src/internal/tenant-slack/relay.ts +28 -4
  246. package/src/internal/testing/factory-resource-fixtures.ts +85 -0
  247. package/src/internal/workspace-sync.ts +84 -12
  248. package/src/internal/workspace.ts +20 -0
  249. package/src/types.ts +58 -11
  250. package/templates/grokbot-agents/README.md +26 -0
  251. package/templates/grokbot-agents/agent/agent.ts +6 -0
  252. package/templates/grokbot-agents/agent/extensions/grokbot.ts +5 -0
  253. package/templates/grokbot-agents/agent/instructions.md +7 -0
  254. package/templates/grokbot-agents/evals/evals.config.ts +5 -0
  255. package/templates/grokbot-agents/evals/grokbot-agents.eval.ts +18 -0
  256. package/templates/grokbot-agents/init.json +18 -0
  257. package/templates/grokbot-agents/package.json +17 -0
  258. package/templates/grokbot-agents/tsconfig.json +12 -0
  259. package/dist/docs/assets/chunks/@localSearchIndexroot.nrl1ifBq.js +0 -1
  260. package/dist/docs/assets/index.md.D75GWhPl.js +0 -5
  261. package/dist/docs/assets/index.md.D75GWhPl.lean.js +0 -1
  262. package/dist/playground/assets/index-MbMxXg-y.css +0 -1
  263. /package/dist/docs/assets/{reference_cli.md.CJNc_xYK.lean.js → reference_cli.md.C6Lo8SEd.lean.js} +0 -0
  264. /package/dist/docs/assets/{reference_extensions.md.DykHW3qL.lean.js → reference_extensions.md.CGmMLblt.lean.js} +0 -0
@@ -0,0 +1,196 @@
1
+ /**
2
+ * K-way merge of already-sorted streams. Each source must be ordered
3
+ * under the same `compare`; the merge does not re-sort a source.
4
+ *
5
+ * A binary heap of heads keeps the next yield O(log k) in the number of
6
+ * sources. `unique` skips later copies of a key so an earlier source can
7
+ * shadow a later one (the union rule).
8
+ */
9
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
10
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11
+ return new (P || (P = Promise))(function (resolve, reject) {
12
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
14
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
15
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
16
+ });
17
+ };
18
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
19
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
20
+ var m = o[Symbol.asyncIterator], i;
21
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
22
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
23
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
24
+ };
25
+ var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
26
+ var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
27
+ var i, p;
28
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
29
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
30
+ };
31
+ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
32
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
33
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
34
+ return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
35
+ function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
36
+ function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
37
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
38
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
39
+ function fulfill(value) { resume("next", value); }
40
+ function reject(value) { resume("throw", value); }
41
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
42
+ };
43
+ /**
44
+ * Merge already-sorted iterables / async iterables under `compare`.
45
+ * Equal keys (`compare === 0`) keep source order: earlier `sources`
46
+ * index wins. With `unique`, those later copies are skipped.
47
+ */
48
+ export function mergeSorted(sources, options) {
49
+ return __asyncGenerator(this, arguments, function* mergeSorted_1() {
50
+ const { compare, unique = false } = options;
51
+ const heap = new MinHeap((left, right) => {
52
+ const byValue = compare(left.value, right.value);
53
+ return byValue !== 0 ? byValue : left.source - right.source;
54
+ });
55
+ const iterators = sources.map((source, sourceIndex) => {
56
+ const iterator = Symbol.asyncIterator in source
57
+ ? source[Symbol.asyncIterator]()
58
+ : (function () {
59
+ return __asyncGenerator(this, arguments, function* () {
60
+ yield __await(yield* __asyncDelegator(__asyncValues(source)));
61
+ });
62
+ })();
63
+ return { iterator, sourceIndex };
64
+ });
65
+ yield __await(Promise.all(iterators.map((_a) => __awaiter(this, [_a], void 0, function* ({ iterator, sourceIndex }) {
66
+ const next = yield iterator.next();
67
+ if (!next.done) {
68
+ heap.push({ value: next.value, iterator, source: sourceIndex });
69
+ }
70
+ }))));
71
+ while (heap.size > 0) {
72
+ const best = heap.pop();
73
+ if (best === undefined) {
74
+ return yield __await(void 0);
75
+ }
76
+ yield yield __await(best.value);
77
+ if (unique) {
78
+ yield __await(advanceMatching(heap, best, compare));
79
+ }
80
+ else {
81
+ yield __await(pushNext(heap, best));
82
+ }
83
+ }
84
+ });
85
+ }
86
+ function pushNext(heap, head) {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ const next = yield head.iterator.next();
89
+ if (!next.done) {
90
+ heap.push({
91
+ value: next.value,
92
+ iterator: head.iterator,
93
+ source: head.source,
94
+ });
95
+ }
96
+ });
97
+ }
98
+ /** Advance every head whose key equals `best` (compare === 0). */
99
+ function advanceMatching(heap, best, compare) {
100
+ return __awaiter(this, void 0, void 0, function* () {
101
+ yield pushNext(heap, best);
102
+ while (heap.size > 0) {
103
+ const peek = heap.peek();
104
+ if (peek === undefined || compare(peek.value, best.value) !== 0) {
105
+ return;
106
+ }
107
+ const duplicate = heap.pop();
108
+ if (duplicate === undefined) {
109
+ return;
110
+ }
111
+ yield pushNext(heap, duplicate);
112
+ }
113
+ });
114
+ }
115
+ /**
116
+ * Binary min-heap. `compare(a, b) < 0` means `a` is before `b`.
117
+ * Exported for the invariant tests; composers use {@link mergeSorted}.
118
+ */
119
+ export class MinHeap {
120
+ constructor(compare) {
121
+ this.compare = compare;
122
+ this.items = [];
123
+ }
124
+ get size() {
125
+ return this.items.length;
126
+ }
127
+ peek() {
128
+ return this.items[0];
129
+ }
130
+ push(item) {
131
+ this.items.push(item);
132
+ this.bubbleUp(this.items.length - 1);
133
+ }
134
+ pop() {
135
+ const first = this.items[0];
136
+ if (first === undefined) {
137
+ return undefined;
138
+ }
139
+ const last = this.items.pop();
140
+ if (last === undefined || this.items.length === 0) {
141
+ return first;
142
+ }
143
+ this.items[0] = last;
144
+ this.bubbleDown(0);
145
+ return first;
146
+ }
147
+ bubbleUp(index) {
148
+ let current = index;
149
+ while (current > 0) {
150
+ const parent = Math.floor((current - 1) / 2);
151
+ const parentItem = this.items[parent];
152
+ const currentItem = this.items[current];
153
+ if (parentItem === undefined ||
154
+ currentItem === undefined ||
155
+ this.compare(currentItem, parentItem) >= 0) {
156
+ return;
157
+ }
158
+ this.items[parent] = currentItem;
159
+ this.items[current] = parentItem;
160
+ current = parent;
161
+ }
162
+ }
163
+ bubbleDown(index) {
164
+ let current = index;
165
+ for (;;) {
166
+ const left = current * 2 + 1;
167
+ const right = left + 1;
168
+ let smallest = current;
169
+ const currentItem = this.items[smallest];
170
+ const leftItem = this.items[left];
171
+ if (leftItem !== undefined &&
172
+ currentItem !== undefined &&
173
+ this.compare(leftItem, currentItem) < 0) {
174
+ smallest = left;
175
+ }
176
+ const smallestItem = this.items[smallest];
177
+ const rightItem = this.items[right];
178
+ if (rightItem !== undefined &&
179
+ smallestItem !== undefined &&
180
+ this.compare(rightItem, smallestItem) < 0) {
181
+ smallest = right;
182
+ }
183
+ if (smallest === current) {
184
+ return;
185
+ }
186
+ const swapCurrent = this.items[current];
187
+ const swapSmallest = this.items[smallest];
188
+ if (swapCurrent === undefined || swapSmallest === undefined) {
189
+ return;
190
+ }
191
+ this.items[current] = swapSmallest;
192
+ this.items[smallest] = swapCurrent;
193
+ current = smallest;
194
+ }
195
+ }
196
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Host `{cwd}/agent-tools/{uuid}.txt` → `/tmp/{uuid}.txt`.
3
+ *
4
+ * Native WebSearch / WebFetch still scratch large output on the host.
5
+ * The session engine mounts `tempFs()` at `/tmp` with `unionFs` and
6
+ * copies only those files onto that tree. This module is the host-path
7
+ * translation, not a FileSystem type.
8
+ */
9
+ import type { FileSystem } from "../../filesystem.js";
10
+ export declare const TMP_SCRATCH_PREFIX = "/tmp";
11
+ export declare const HOST_AGENT_TOOLS_DIR = "agent-tools";
12
+ export declare const WEB_SCRATCH_TOOLS: readonly ["webSearch", "webFetch"];
13
+ export declare function isWebScratchTool(name: string | undefined): boolean;
14
+ export declare function tmpScratchPath(fileName: string): string;
15
+ export declare function hostAgentToolsDir(cwd: string): string;
16
+ /**
17
+ * Basename of `{cwd}/agent-tools/{uuid}.txt`, or undefined. Other
18
+ * paths in a result are ignored.
19
+ */
20
+ export declare function hostAgentToolsFileName(args: {
21
+ cwd: string;
22
+ candidate: string;
23
+ }): string | undefined;
24
+ export declare function remapScratchPath(args: {
25
+ cwd: string;
26
+ path: string;
27
+ }): string;
28
+ export declare function remapScratchPaths(input: Record<string, unknown>, cwd: string): Record<string, unknown>;
29
+ export declare function rewriteWebScratchText(args: {
30
+ cwd: string;
31
+ text: string;
32
+ }): string;
33
+ /** Rewrite host agent-tools paths in a string or a structured tool result. */
34
+ export declare function rewriteWebScratchValue(args: {
35
+ cwd: string;
36
+ value: unknown;
37
+ }): unknown;
38
+ /**
39
+ * WebSearch / WebFetch result. Ingest the host spill and rewrite
40
+ * paths onto `/tmp`. Other tools are a no-op.
41
+ */
42
+ export declare function finishWebScratchTool(args: {
43
+ toolName: string | undefined;
44
+ result: unknown;
45
+ cwd: string;
46
+ root: FileSystem;
47
+ }): Promise<unknown>;
48
+ /** Finish a native web tool on the SDK update that carried its result. */
49
+ export declare function applyWebScratchUpdate<T>(args: {
50
+ cwd: string;
51
+ root: FileSystem;
52
+ update: T;
53
+ }): Promise<T>;
54
+ export declare function ingestHostAgentToolsScratch(args: {
55
+ cwd: string;
56
+ root: FileSystem;
57
+ hostPath?: string;
58
+ }): Promise<string[]>;
59
+ //# sourceMappingURL=scratch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scratch.d.ts","sourceRoot":"","sources":["../../../src/internal/filesystem/scratch.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,eAAO,MAAM,kBAAkB,SAAS,CAAC;AACzC,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAClD,eAAO,MAAM,iBAAiB,YAAI,WAAW,EAAE,UAAU,CAAU,CAAC;AAEpE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAElE;AAgBD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,MAAM,GAAG,SAAS,CAUrB;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAM5E;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,GAAG,EAAE,MAAM,GACV,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASzB;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,MAAM,CAUT;AAED,8EAA8E;AAC9E,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAgBV;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;CAClB,GAAG,OAAO,CAAC,OAAO,CAAC,CAMnB;AA0BD,0EAA0E;AAC1E,wBAAsB,qBAAqB,CAAC,CAAC,EAAE,IAAI,EAAE;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,CAAC,CAAC;CACX,GAAG,OAAO,CAAC,CAAC,CAAC,CAYb;AAED,wBAAsB,2BAA2B,CAAC,IAAI,EAAE;IACtD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAiBpB"}
@@ -0,0 +1,212 @@
1
+ /**
2
+ * Host `{cwd}/agent-tools/{uuid}.txt` → `/tmp/{uuid}.txt`.
3
+ *
4
+ * Native WebSearch / WebFetch still scratch large output on the host.
5
+ * The session engine mounts `tempFs()` at `/tmp` with `unionFs` and
6
+ * copies only those files onto that tree. This module is the host-path
7
+ * translation, not a FileSystem type.
8
+ */
9
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
10
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11
+ return new (P || (P = Promise))(function (resolve, reject) {
12
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
14
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
15
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
16
+ });
17
+ };
18
+ import { readdir, readFile, rm } from "node:fs/promises";
19
+ import path from "node:path";
20
+ export const TMP_SCRATCH_PREFIX = "/tmp";
21
+ export const HOST_AGENT_TOOLS_DIR = "agent-tools";
22
+ export const WEB_SCRATCH_TOOLS = ["webSearch", "webFetch"];
23
+ export function isWebScratchTool(name) {
24
+ return name === "webSearch" || name === "webFetch";
25
+ }
26
+ const UUID_TXT = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.txt$/i;
27
+ const HOST_FOLLOW_UP = /Use shell \/ grep \/ read_file on this path to inspect the page/g;
28
+ const OVERLAY_FOLLOW_UP = "Use Read / Grep on this path to inspect the page";
29
+ const PATH_KEYS = [
30
+ "path",
31
+ "dir",
32
+ "targetDirectory",
33
+ "target_directory",
34
+ ];
35
+ export function tmpScratchPath(fileName) {
36
+ return `${TMP_SCRATCH_PREFIX}/${fileName}`;
37
+ }
38
+ export function hostAgentToolsDir(cwd) {
39
+ return path.resolve(cwd, HOST_AGENT_TOOLS_DIR);
40
+ }
41
+ /**
42
+ * Basename of `{cwd}/agent-tools/{uuid}.txt`, or undefined. Other
43
+ * paths in a result are ignored.
44
+ */
45
+ export function hostAgentToolsFileName(args) {
46
+ if (args.candidate === "") {
47
+ return undefined;
48
+ }
49
+ const resolved = path.resolve(args.candidate);
50
+ if (path.dirname(resolved) !== hostAgentToolsDir(args.cwd)) {
51
+ return undefined;
52
+ }
53
+ const base = path.basename(resolved);
54
+ return UUID_TXT.test(base) ? base : undefined;
55
+ }
56
+ export function remapScratchPath(args) {
57
+ const fileName = hostAgentToolsFileName({
58
+ cwd: args.cwd,
59
+ candidate: args.path,
60
+ });
61
+ return fileName === undefined ? args.path : tmpScratchPath(fileName);
62
+ }
63
+ export function remapScratchPaths(input, cwd) {
64
+ const next = Object.assign({}, input);
65
+ for (const key of PATH_KEYS) {
66
+ const value = next[key];
67
+ if (typeof value === "string") {
68
+ next[key] = remapScratchPath({ cwd, path: value });
69
+ }
70
+ }
71
+ return next;
72
+ }
73
+ export function rewriteWebScratchText(args) {
74
+ const dir = hostAgentToolsDir(args.cwd);
75
+ const escaped = dir.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
76
+ const pattern = new RegExp(`${escaped}[/\\\\]([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\.txt)`, "gi");
77
+ return args.text
78
+ .replace(pattern, (_match, fileName) => tmpScratchPath(fileName))
79
+ .replace(HOST_FOLLOW_UP, OVERLAY_FOLLOW_UP);
80
+ }
81
+ /** Rewrite host agent-tools paths in a string or a structured tool result. */
82
+ export function rewriteWebScratchValue(args) {
83
+ const { cwd, value } = args;
84
+ if (typeof value === "string") {
85
+ return rewriteWebScratchText({ cwd, text: value });
86
+ }
87
+ if (Array.isArray(value)) {
88
+ return value.map((item) => rewriteWebScratchValue({ cwd, value: item }));
89
+ }
90
+ if (value !== null && typeof value === "object") {
91
+ const next = {};
92
+ for (const [key, item] of Object.entries(value)) {
93
+ next[key] = rewriteWebScratchValue({ cwd, value: item });
94
+ }
95
+ return next;
96
+ }
97
+ return value;
98
+ }
99
+ /**
100
+ * WebSearch / WebFetch result. Ingest the host spill and rewrite
101
+ * paths onto `/tmp`. Other tools are a no-op.
102
+ */
103
+ export function finishWebScratchTool(args) {
104
+ return __awaiter(this, void 0, void 0, function* () {
105
+ if (!isWebScratchTool(args.toolName)) {
106
+ return args.result;
107
+ }
108
+ yield ingestHostAgentToolsScratch({ cwd: args.cwd, root: args.root });
109
+ return rewriteWebScratchValue({ cwd: args.cwd, value: args.result });
110
+ });
111
+ }
112
+ function completedWebToolCall(update) {
113
+ var _a;
114
+ if (update === null || typeof update !== "object") {
115
+ return undefined;
116
+ }
117
+ const rec = update;
118
+ const call = rec.type === "tool-call-completed"
119
+ ? rec.toolCall
120
+ : rec.type === "tool-call-delta" &&
121
+ ((_a = rec.taskUpdate) === null || _a === void 0 ? void 0 : _a.type) === "tool-call-completed"
122
+ ? rec.taskUpdate.toolCall
123
+ : undefined;
124
+ if (call === undefined || !isWebScratchTool(call.type)) {
125
+ return undefined;
126
+ }
127
+ return call;
128
+ }
129
+ /** Finish a native web tool on the SDK update that carried its result. */
130
+ export function applyWebScratchUpdate(args) {
131
+ return __awaiter(this, void 0, void 0, function* () {
132
+ const call = completedWebToolCall(args.update);
133
+ if (call === undefined) {
134
+ return args.update;
135
+ }
136
+ call.result = yield finishWebScratchTool({
137
+ toolName: call.type,
138
+ result: call.result,
139
+ cwd: args.cwd,
140
+ root: args.root,
141
+ });
142
+ return args.update;
143
+ });
144
+ }
145
+ export function ingestHostAgentToolsScratch(args) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ const written = [];
148
+ const names = args.hostPath === undefined
149
+ ? yield listHostAgentToolsFiles(args.cwd)
150
+ : [args.hostPath];
151
+ for (const hostPath of names) {
152
+ const dest = yield copyHostAgentToolsFile({
153
+ cwd: args.cwd,
154
+ root: args.root,
155
+ hostPath,
156
+ });
157
+ if (dest !== undefined) {
158
+ written.push(dest);
159
+ }
160
+ }
161
+ return written;
162
+ });
163
+ }
164
+ function listHostAgentToolsFiles(cwd) {
165
+ return __awaiter(this, void 0, void 0, function* () {
166
+ const dir = hostAgentToolsDir(cwd);
167
+ try {
168
+ const entries = yield readdir(dir, { withFileTypes: true });
169
+ return entries
170
+ .filter((entry) => entry.isFile() && UUID_TXT.test(entry.name))
171
+ .map((entry) => path.join(dir, entry.name));
172
+ }
173
+ catch (error) {
174
+ if (isEnoent(error)) {
175
+ return [];
176
+ }
177
+ throw error;
178
+ }
179
+ });
180
+ }
181
+ function copyHostAgentToolsFile(args) {
182
+ return __awaiter(this, void 0, void 0, function* () {
183
+ const fileName = hostAgentToolsFileName({
184
+ cwd: args.cwd,
185
+ candidate: args.hostPath,
186
+ });
187
+ if (fileName === undefined) {
188
+ return undefined;
189
+ }
190
+ const dest = tmpScratchPath(fileName);
191
+ const hostPath = path.resolve(args.hostPath);
192
+ let bytes;
193
+ try {
194
+ bytes = yield readFile(hostPath);
195
+ }
196
+ catch (error) {
197
+ if (isEnoent(error)) {
198
+ return undefined;
199
+ }
200
+ throw error;
201
+ }
202
+ yield args.root.write(dest, bytes.toString("utf8"));
203
+ yield rm(hostPath, { force: true });
204
+ return dest;
205
+ });
206
+ }
207
+ function isEnoent(error) {
208
+ return (typeof error === "object" &&
209
+ error !== null &&
210
+ "code" in error &&
211
+ error.code === "ENOENT");
212
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Advertised native-tool schemas. These are the `@cursor/sdk`
3
+ * tool-call types (`@anysphere/cursor-sdk-shared/tool-call-types`)
4
+ * reconstructed here so `@cursor/july` does not take an unpublished
5
+ * workspace dependency. The contract test pins JSON-schema equality
6
+ * against the SDK originals.
7
+ *
8
+ * Runtime aliases (`contents` → `fileText`, `old_string` → `oldText`)
9
+ * live on the `defineTool` input schema, not on these objects.
10
+ */
11
+ import { z } from "zod";
12
+ export declare const sdkReadArgs: z.ZodTypeAny;
13
+ export declare const sdkReadResult: z.ZodTypeAny;
14
+ export declare const sdkWriteArgs: z.ZodTypeAny;
15
+ export declare const sdkWriteResult: z.ZodTypeAny;
16
+ export declare const sdkDeleteArgs: z.ZodTypeAny;
17
+ export declare const sdkDeleteResult: z.ZodTypeAny;
18
+ export declare const sdkGlobArgs: z.ZodTypeAny;
19
+ export declare const sdkGlobResult: z.ZodTypeAny;
20
+ export declare const sdkGrepArgs: z.ZodTypeAny;
21
+ export declare const sdkGrepResult: z.ZodTypeAny;
22
+ export declare const sdkLsArgs: z.ZodTypeAny;
23
+ export declare const sdkLsResult: z.ZodTypeAny;
24
+ /** StrReplace is SDK `edit` plus the str-replace args the model actually sends. */
25
+ export declare const sdkStrReplaceArgs: z.ZodTypeAny;
26
+ export declare const sdkEditResult: z.ZodTypeAny;
27
+ export declare const sdkSemSearchArgs: z.ZodTypeAny;
28
+ export declare const sdkSemSearchResult: z.ZodTypeAny;
29
+ //# sourceMappingURL=sdk-schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk-schemas.d.ts","sourceRoot":"","sources":["../../../src/internal/filesystem/sdk-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmBxB,eAAO,MAAM,WAAW,EAAE,CAAC,CAAC,UAE1B,CAAC;AAEH,eAAO,MAAM,aAAa,EAAE,CAAC,CAAC,UAM7B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,CAAC,CAAC,UAI3B,CAAC;AAEH,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,UAO9B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,CAAC,CAAC,UAE5B,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,CAAC,CAAC,UAI/B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,CAAC,CAAC,UAG1B,CAAC;AAEH,eAAO,MAAM,aAAa,EAAE,CAAC,CAAC,UAO7B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,CAAC,CAAC,UAe1B,CAAC;AAuCH,eAAO,MAAM,aAAa,EAAE,CAAC,CAAC,UAK7B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,CAAC,CAAC,UAGxB,CAAC;AA0BH,eAAO,MAAM,WAAW,EAAE,CAAC,CAAC,UAI3B,CAAC;AAEF,mFAAmF;AACnF,eAAO,MAAM,iBAAiB,EAAE,CAAC,CAAC,UAKhC,CAAC;AAEH,eAAO,MAAM,aAAa,EAAE,CAAC,CAAC,UAM7B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,UAI/B,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,UAIlC,CAAC"}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Advertised native-tool schemas. These are the `@cursor/sdk`
3
+ * tool-call types (`@anysphere/cursor-sdk-shared/tool-call-types`)
4
+ * reconstructed here so `@cursor/july` does not take an unpublished
5
+ * workspace dependency. The contract test pins JSON-schema equality
6
+ * against the SDK originals.
7
+ *
8
+ * Runtime aliases (`contents` → `fileText`, `old_string` → `oldText`)
9
+ * live on the `defineTool` input schema, not on these objects.
10
+ */
11
+ import { z } from "zod";
12
+ const simpleError = z.object({
13
+ message: z.string(),
14
+ });
15
+ function resultSchema(success) {
16
+ return z.discriminatedUnion("status", [
17
+ z.object({
18
+ status: z.literal("success"),
19
+ value: success,
20
+ }),
21
+ z.object({
22
+ status: z.literal("error"),
23
+ error: simpleError,
24
+ }),
25
+ ]);
26
+ }
27
+ export const sdkReadArgs = z.object({
28
+ path: z.string(),
29
+ });
30
+ export const sdkReadResult = resultSchema(z.object({
31
+ content: z.string(),
32
+ totalLines: z.number(),
33
+ fileSize: z.number(),
34
+ }));
35
+ export const sdkWriteArgs = z.object({
36
+ path: z.string(),
37
+ fileText: z.string(),
38
+ returnFileContentAfterWrite: z.boolean().optional(),
39
+ });
40
+ export const sdkWriteResult = resultSchema(z.object({
41
+ path: z.string(),
42
+ linesCreated: z.number(),
43
+ fileSize: z.number(),
44
+ fileContentAfterWrite: z.string().optional(),
45
+ }));
46
+ export const sdkDeleteArgs = z.object({
47
+ path: z.string(),
48
+ });
49
+ export const sdkDeleteResult = resultSchema(z.object({
50
+ fileSize: z.number(),
51
+ }));
52
+ export const sdkGlobArgs = z.object({
53
+ targetDirectory: z.string().optional(),
54
+ globPattern: z.string(),
55
+ });
56
+ export const sdkGlobResult = resultSchema(z.object({
57
+ files: z.array(z.string()),
58
+ totalFiles: z.number(),
59
+ clientTruncated: z.boolean(),
60
+ ripgrepTruncated: z.boolean(),
61
+ }));
62
+ export const sdkGrepArgs = z.object({
63
+ pattern: z.string(),
64
+ path: z.string().optional(),
65
+ glob: z.string().optional(),
66
+ outputMode: z.string().optional(),
67
+ contextBefore: z.number().optional(),
68
+ contextAfter: z.number().optional(),
69
+ context: z.number().optional(),
70
+ caseInsensitive: z.boolean().optional(),
71
+ type: z.string().optional(),
72
+ headLimit: z.number().optional(),
73
+ offset: z.number().optional(),
74
+ multiline: z.boolean().optional(),
75
+ sort: z.string().optional(),
76
+ sortAscending: z.boolean().optional(),
77
+ });
78
+ const grepContentMatch = z.object({
79
+ file: z.string(),
80
+ lineNumber: z.number().optional(),
81
+ line: z.string(),
82
+ beforeContext: z.array(z.string()).optional(),
83
+ afterContext: z.array(z.string()).optional(),
84
+ });
85
+ const grepFileCount = z.object({
86
+ file: z.string(),
87
+ count: z.number(),
88
+ });
89
+ const grepUnion = z.discriminatedUnion("type", [
90
+ z.object({
91
+ type: z.literal("content"),
92
+ output: z.object({
93
+ matches: z.array(grepContentMatch),
94
+ totalMatches: z.number(),
95
+ }),
96
+ }),
97
+ z.object({
98
+ type: z.literal("files"),
99
+ output: z.object({
100
+ files: z.array(z.string()),
101
+ count: z.number(),
102
+ }),
103
+ }),
104
+ z.object({
105
+ type: z.literal("count"),
106
+ output: z.object({
107
+ counts: z.array(grepFileCount),
108
+ total: z.number(),
109
+ }),
110
+ }),
111
+ ]);
112
+ export const sdkGrepResult = resultSchema(z.object({
113
+ workspaceResults: z.record(grepUnion).optional(),
114
+ activeEditorResult: grepUnion.optional(),
115
+ }));
116
+ export const sdkLsArgs = z.object({
117
+ path: z.string(),
118
+ ignore: z.array(z.string()).optional(),
119
+ });
120
+ const lsDirectoryTreeNodeFile = z.object({
121
+ name: z.string(),
122
+ });
123
+ const lsDirectoryTreeNode = z.lazy(() => z.object({
124
+ absPath: z.string(),
125
+ childrenDirs: z.array(lsDirectoryTreeNode),
126
+ childrenFiles: z.array(lsDirectoryTreeNodeFile),
127
+ childrenWereProcessed: z.boolean(),
128
+ fullSubtreeExtensionCounts: z.record(z.number()),
129
+ numFiles: z.number(),
130
+ }));
131
+ export const sdkLsResult = resultSchema(z.object({
132
+ directoryTreeRoot: lsDirectoryTreeNode,
133
+ }));
134
+ /** StrReplace is SDK `edit` plus the str-replace args the model actually sends. */
135
+ export const sdkStrReplaceArgs = z.object({
136
+ path: z.string(),
137
+ oldText: z.string(),
138
+ newText: z.string(),
139
+ replaceAll: z.boolean().optional(),
140
+ });
141
+ export const sdkEditResult = resultSchema(z.object({
142
+ linesAdded: z.number().optional(),
143
+ linesRemoved: z.number().optional(),
144
+ diffString: z.string().optional(),
145
+ }));
146
+ export const sdkSemSearchArgs = z.object({
147
+ query: z.string(),
148
+ targetDirectories: z.array(z.string()).optional(),
149
+ explanation: z.string().optional(),
150
+ });
151
+ export const sdkSemSearchResult = resultSchema(z.object({
152
+ results: z.string(),
153
+ }));