@sourcegraph/amp 0.0.1748390507-geb181a → 0.0.1748419293-g63ac77

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 (44) hide show
  1. package/dist/amp.js +3 -3
  2. package/dist/{client-D37xwk4h.js → client-BG3r9aH9.js} +2 -2
  3. package/dist/{client-D37xwk4h.js.map → client-BG3r9aH9.js.map} +1 -1
  4. package/dist/{color-BV9wbewg.js → color-Cj45sRkS.js} +87 -87
  5. package/dist/color-Cj45sRkS.js.map +1 -0
  6. package/dist/{create_file.node-D2LDnTZ6.js → create_file.node-0vS2hejR.js} +2 -2
  7. package/dist/{create_file.node-D2LDnTZ6.js.map → create_file.node-0vS2hejR.js.map} +1 -1
  8. package/dist/{edit_file.node-Ccrf_Tyh.js → edit_file.node-it4wJ5TR.js} +3 -3
  9. package/dist/{edit_file.node-Ccrf_Tyh.js.map → edit_file.node-it4wJ5TR.js.map} +1 -1
  10. package/dist/{executable-DndKF3B_.js → executable-9B5WLKFI.js} +2 -2
  11. package/dist/{executable-DndKF3B_.js.map → executable-9B5WLKFI.js.map} +1 -1
  12. package/dist/{files-CApLN3XI.js → files-B2BG6wGh.js} +2 -2
  13. package/dist/{files-CApLN3XI.js.map → files-B2BG6wGh.js.map} +1 -1
  14. package/dist/{glob.node-C_0Pojo_.js → glob.node-CSXwSKG2.js} +3 -3
  15. package/dist/{glob.node-C_0Pojo_.js.map → glob.node-CSXwSKG2.js.map} +1 -1
  16. package/dist/{list_directory.node-CChuHPoL.js → list_directory.node-BFm1qTEf.js} +2 -2
  17. package/dist/{list_directory.node-CChuHPoL.js.map → list_directory.node-BFm1qTEf.js.map} +1 -1
  18. package/dist/{load-profile-CBXx5Izf.js → load-profile-Cj-UxFl1.js} +2 -2
  19. package/dist/{load-profile-CBXx5Izf.js.map → load-profile-Cj-UxFl1.js.map} +1 -1
  20. package/dist/main-B3QXAnGP.js +40203 -0
  21. package/dist/main-B3QXAnGP.js.map +1 -0
  22. package/dist/{node-gL35nPzg.js → node--F98eUbP.js} +2 -2
  23. package/dist/{node-gL35nPzg.js.map → node--F98eUbP.js.map} +1 -1
  24. package/dist/{node-BGD834Zv.js → node-3f9fJ7aL.js} +2 -2
  25. package/dist/{node-BGD834Zv.js.map → node-3f9fJ7aL.js.map} +1 -1
  26. package/dist/{node-B8I2GAD6.js → node-COM1O9lA.js} +3 -3
  27. package/dist/{node-B8I2GAD6.js.map → node-COM1O9lA.js.map} +1 -1
  28. package/dist/{node-BcU66Cp7.js → node-CPx25-dA.js} +3 -3
  29. package/dist/{node-BcU66Cp7.js.map → node-CPx25-dA.js.map} +1 -1
  30. package/dist/{node-BolndRJs.js → node-goKryvqE.js} +23 -23
  31. package/dist/{node-BolndRJs.js.map → node-goKryvqE.js.map} +1 -1
  32. package/dist/{node-DgFnFiEl.js → node-z_wuLuYG.js} +3 -3
  33. package/dist/{node-DgFnFiEl.js.map → node-z_wuLuYG.js.map} +1 -1
  34. package/dist/{read_file.node-FBiGQRUp.js → read_file.node-BPyNHNAZ.js} +2 -2
  35. package/dist/{read_file.node-FBiGQRUp.js.map → read_file.node-BPyNHNAZ.js.map} +1 -1
  36. package/dist/{stdio-BWKt1HvU.js → stdio-BHqN64gs.js} +20 -20
  37. package/dist/{stdio-BWKt1HvU.js.map → stdio-BHqN64gs.js.map} +1 -1
  38. package/dist/storybook.js +4 -4
  39. package/dist/{undo_edit.node-NCKppvcB.js → undo_edit.node-BdqjDOxO.js} +10 -10
  40. package/dist/{undo_edit.node-NCKppvcB.js.map → undo_edit.node-BdqjDOxO.js.map} +1 -1
  41. package/package.json +1 -1
  42. package/dist/color-BV9wbewg.js.map +0 -1
  43. package/dist/main-BzLjPVuG.js +0 -36499
  44. package/dist/main-BzLjPVuG.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { f as a } from "./client-D37xwk4h.js";
3
- import { p as u, H as c } from "./color-BV9wbewg.js";
2
+ import { f as a } from "./client-BG3r9aH9.js";
3
+ import { p as u, H as c } from "./color-Cj45sRkS.js";
4
4
  const l = ({ args: o }, { threadID: t }) => u(async (s) => {
5
5
  try {
6
6
  const r = `/api/web-search?query=${encodeURIComponent(o.query)}&numResults=${o.num_results || 5}`, e = await a(r, {
@@ -23,4 +23,4 @@ const l = ({ args: o }, { threadID: t }) => u(async (s) => {
23
23
  export {
24
24
  l as nodeWebSearchTool
25
25
  };
26
- //# sourceMappingURL=node-BcU66Cp7.js.map
26
+ //# sourceMappingURL=node-CPx25-dA.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-BcU66Cp7.js","sources":["../../core/src/tools/builtin/web_search/node.ts"],"sourcesContent":["import { promiseFactoryToObservable } from '@sourcegraph/observable'\nimport { fetchFromAmpServer } from '../../../server-api/client'\nimport { HEADER_KEY_THREAD_ID } from '../../../server-api/headers'\nimport type { webSearchToolReg } from './common'\n\nexport const nodeWebSearchTool: NonNullable<(typeof webSearchToolReg)['fn']> = (\n\t{ args },\n\t{ threadID },\n) => {\n\treturn promiseFactoryToObservable(async (signal) => {\n\t\ttry {\n\t\t\t// Call the server endpoint using the fetchFromAmpServer helper\n\t\t\tconst url = `/api/web-search?query=${encodeURIComponent(args.query)}&numResults=${args.num_results || 5}`\n\t\t\tconst response = await fetchFromAmpServer(url, {\n\t\t\t\tmethod: 'GET',\n\t\t\t\tsignal,\n\t\t\t\theaders: threadID ? { [HEADER_KEY_THREAD_ID]: threadID } : undefined,\n\t\t\t})\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst errorText = await response.text()\n\t\t\t\tthrow new Error(`Server returned ${response.status}: ${errorText}`)\n\t\t\t}\n\n\t\t\tconst results = await response.json()\n\t\t\treturn {\n\t\t\t\tstatus: 'done' as const,\n\t\t\t\tresult: results,\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Failed to perform web search: ${(error as Error).message}`)\n\t\t}\n\t})\n}\n"],"names":["nodeWebSearchTool","args","threadID","promiseFactoryToObservable","signal","url","response","fetchFromAmpServer","HEADER_KEY_THREAD_ID","errorText","error"],"mappings":";;;AAKO,MAAMA,IAAkE,CAC9E,EAAE,MAAAC,KACF,EAAE,UAAAC,QAEKC,EAA2B,OAAOC,MAAW;AAC/C,MAAA;AAEG,UAAAC,IAAM,yBAAyB,mBAAmBJ,EAAK,KAAK,CAAC,eAAeA,EAAK,eAAe,CAAC,IACjGK,IAAW,MAAMC,EAAmBF,GAAK;AAAA,MAC9C,QAAQ;AAAA,MACR,QAAAD;AAAA,MACA,SAASF,IAAW,EAAE,CAACM,CAAoB,GAAGN,EAAa,IAAA;AAAA,IAAA,CAC3D;AAEG,QAAA,CAACI,EAAS,IAAI;AACX,YAAAG,IAAY,MAAMH,EAAS,KAAK;AACtC,YAAM,IAAI,MAAM,mBAAmBA,EAAS,MAAM,KAAKG,CAAS,EAAE;AAAA,IAAA;AAI5D,WAAA;AAAA,MACN,QAAQ;AAAA,MACR,QAHe,MAAMH,EAAS,KAAK;AAAA,IAIpC;AAAA,WACQI,GAAO;AACf,UAAM,IAAI,MAAM,iCAAkCA,EAAgB,OAAO,EAAE;AAAA,EAAA;AAC5E,CACA;"}
1
+ {"version":3,"file":"node-CPx25-dA.js","sources":["../../core/src/tools/builtin/web_search/node.ts"],"sourcesContent":["import { promiseFactoryToObservable } from '@sourcegraph/observable'\nimport { fetchFromAmpServer } from '../../../server-api/client'\nimport { HEADER_KEY_THREAD_ID } from '../../../server-api/headers'\nimport type { webSearchToolReg } from './common'\n\nexport const nodeWebSearchTool: NonNullable<(typeof webSearchToolReg)['fn']> = (\n\t{ args },\n\t{ threadID },\n) => {\n\treturn promiseFactoryToObservable(async (signal) => {\n\t\ttry {\n\t\t\t// Call the server endpoint using the fetchFromAmpServer helper\n\t\t\tconst url = `/api/web-search?query=${encodeURIComponent(args.query)}&numResults=${args.num_results || 5}`\n\t\t\tconst response = await fetchFromAmpServer(url, {\n\t\t\t\tmethod: 'GET',\n\t\t\t\tsignal,\n\t\t\t\theaders: threadID ? { [HEADER_KEY_THREAD_ID]: threadID } : undefined,\n\t\t\t})\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst errorText = await response.text()\n\t\t\t\tthrow new Error(`Server returned ${response.status}: ${errorText}`)\n\t\t\t}\n\n\t\t\tconst results = await response.json()\n\t\t\treturn {\n\t\t\t\tstatus: 'done' as const,\n\t\t\t\tresult: results,\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Failed to perform web search: ${(error as Error).message}`)\n\t\t}\n\t})\n}\n"],"names":["nodeWebSearchTool","args","threadID","promiseFactoryToObservable","signal","url","response","fetchFromAmpServer","HEADER_KEY_THREAD_ID","errorText","error"],"mappings":";;;AAKO,MAAMA,IAAkE,CAC9E,EAAE,MAAAC,KACF,EAAE,UAAAC,QAEKC,EAA2B,OAAOC,MAAW;AAC/C,MAAA;AAEG,UAAAC,IAAM,yBAAyB,mBAAmBJ,EAAK,KAAK,CAAC,eAAeA,EAAK,eAAe,CAAC,IACjGK,IAAW,MAAMC,EAAmBF,GAAK;AAAA,MAC9C,QAAQ;AAAA,MACR,QAAAD;AAAA,MACA,SAASF,IAAW,EAAE,CAACM,CAAoB,GAAGN,EAAa,IAAA;AAAA,IAAA,CAC3D;AAEG,QAAA,CAACI,EAAS,IAAI;AACX,YAAAG,IAAY,MAAMH,EAAS,KAAK;AACtC,YAAM,IAAI,MAAM,mBAAmBA,EAAS,MAAM,KAAKG,CAAS,EAAE;AAAA,IAAA;AAI5D,WAAA;AAAA,MACN,QAAQ;AAAA,MACR,QAHe,MAAMH,EAAS,KAAK;AAAA,IAIpC;AAAA,WACQI,GAAO;AACf,UAAM,IAAI,MAAM,iCAAkCA,EAAgB,OAAO,EAAE;AAAA,EAAA;AAC5E,CACA;"}
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
- import { Z as Y, a4 as k, $ as I, av as C, a0 as L, aH as D, f as j, a3 as J, bb as V, C as Z, O as z, X as M, ak as W, au as H, k as X } from "./color-BV9wbewg.js";
3
- import { a as x, o as A, s as g, d as q, b as G, l as h, r as _, u as K, e as Q, c as F, p as ee, Z as te, f as se, g as N } from "./main-BzLjPVuG.js";
2
+ import { _ as B, a5 as $, a0 as k, av as L, a1 as C, aH as D, f as j, a4 as J, bb as V, D as z, O as W, Y as M, al as Z, au as H, n as q } from "./color-Cj45sRkS.js";
3
+ import { a as x, o as A, s as g, d as G, b as K, l as h, r as _, u as Q, e as X, c as F, p as ee, Z as te, f as se, g as N } from "./main-B3QXAnGP.js";
4
4
  const S = A({
5
- context: Q(["continue", "none"]).optional().default("continue"),
6
- tools: K([h("all"), x(g())]).optional(),
5
+ context: X(["continue", "none"]).optional().default("continue"),
6
+ tools: Q([h("all"), x(g())]).optional(),
7
7
  prompt: g(),
8
8
  verify: _(F()).optional()
9
9
  }), oe = S.extend({
10
10
  type: h("agent"),
11
11
  model: g().optional(),
12
12
  // Default could be set in implementation
13
- interactive_confirmation: G().optional()
13
+ interactive_confirmation: K().optional()
14
14
  }), re = S.extend({
15
15
  type: h("llm"),
16
16
  model: g().optional()
@@ -29,7 +29,7 @@ const S = A({
29
29
  }), le = A({
30
30
  type: h("bash"),
31
31
  command: g()
32
- }), pe = q("type", [
32
+ }), pe = G("type", [
33
33
  oe,
34
34
  re,
35
35
  ne,
@@ -107,7 +107,7 @@ async function ge(r, e, t, s, o, a) {
107
107
  status: "in-progress",
108
108
  progress: { type: "message", speaker: "user", message: c }
109
109
  });
110
- const u = (await j(l.tools, a)).map((p) => p.spec), T = I;
110
+ const u = (await j(l.tools, a)).map((p) => p.spec), T = k;
111
111
  let f = 0;
112
112
  const d = 100;
113
113
  for (; f < d; ) {
@@ -125,8 +125,8 @@ async function ge(r, e, t, s, o, a) {
125
125
  a.throwIfAborted();
126
126
  let b;
127
127
  try {
128
- const n = k.fromNativeThread(i);
129
- b = await C(
128
+ const n = $.fromNativeThread(i);
129
+ b = await L(
130
130
  n,
131
131
  u,
132
132
  U,
@@ -140,7 +140,7 @@ async function ge(r, e, t, s, o, a) {
140
140
  throw new Error("Unexpected response format from Anthropic");
141
141
  if (b.message.content.length === 0)
142
142
  break;
143
- const v = L(b.message);
143
+ const v = C(b.message);
144
144
  m(v);
145
145
  const E = b.message.content.filter((n) => n.type === "text").map((n) => "text" in n ? n.text : "").join(" ").trim();
146
146
  if (E && s.update({
@@ -148,11 +148,11 @@ async function ge(r, e, t, s, o, a) {
148
148
  progress: { type: "message", speaker: "assistant", message: E }
149
149
  }), v.type !== "assistant:message")
150
150
  break;
151
- const B = ye(
151
+ const Y = ye(
152
152
  i,
153
153
  v.message
154
154
  );
155
- for (const n of B) {
155
+ for (const n of Y) {
156
156
  s.update({
157
157
  status: "in-progress",
158
158
  progress: {
@@ -172,13 +172,13 @@ async function ge(r, e, t, s, o, a) {
172
172
  a
173
173
  ), a.throwIfAborted(), y.status !== "done")
174
174
  throw new Error(JSON.stringify(y));
175
- } catch ($) {
175
+ } catch (I) {
176
176
  m({
177
177
  type: "tool:data",
178
178
  toolUse: n.id,
179
179
  data: {
180
180
  status: "error",
181
- error: { message: `Tool call error: ${$}` }
181
+ error: { message: `Tool call error: ${I}` }
182
182
  }
183
183
  }), s.update({
184
184
  status: "in-progress",
@@ -186,7 +186,7 @@ async function ge(r, e, t, s, o, a) {
186
186
  id: n.id,
187
187
  type: "toolResult",
188
188
  toolName: n.name,
189
- result: `Tool call error: ${$}`
189
+ result: `Tool call error: ${I}`
190
190
  }
191
191
  });
192
192
  continue;
@@ -226,7 +226,7 @@ async function fe(r, e, t, s, o) {
226
226
  status: "in-progress",
227
227
  progress: { type: "message", speaker: "user", message: a }
228
228
  });
229
- const i = k.fromNativeThread(l), m = r.model || I, u = await C(
229
+ const i = $.fromNativeThread(l), m = r.model || k, u = await L(
230
230
  i,
231
231
  [],
232
232
  // No tools for LLM-only step
@@ -237,7 +237,7 @@ async function fe(r, e, t, s, o) {
237
237
  );
238
238
  if (!u.message)
239
239
  throw new Error("Failed to get response from Anthropic");
240
- const T = L(u.message);
240
+ const T = C(u.message);
241
241
  c(T);
242
242
  const f = u.message.content.filter((d) => d.type === "text").map((d) => d.type === "text" ? d.text : "").join(" ").trim();
243
243
  return t.update({
@@ -246,7 +246,7 @@ async function fe(r, e, t, s, o) {
246
246
  }), l;
247
247
  }
248
248
  function ye(r, e) {
249
- const t = Z(r);
249
+ const t = z(r);
250
250
  return e.content.filter((s) => s.type === "tool_use").filter((s) => !s.inputPartialJSON).filter(
251
251
  (s) => (
252
252
  // Only include tools that haven't been invoked yet.
@@ -259,7 +259,7 @@ async function R(r, e, t, s, o = new AbortController().signal, a) {
259
259
  let i = !1;
260
260
  const m = r.invokeTool(e, { args: t, userInput: a }, s).subscribe({
261
261
  next: (u) => {
262
- Y(u) && (m.unsubscribe(), i || (i = !0, l(u)));
262
+ B(u) && (m.unsubscribe(), i || (i = !0, l(u)));
263
263
  },
264
264
  error: (u) => {
265
265
  i || (i = !0, c(u));
@@ -272,7 +272,7 @@ async function R(r, e, t, s, o = new AbortController().signal, a) {
272
272
  });
273
273
  });
274
274
  }
275
- const Te = ({ args: r }, e) => new z((t) => {
275
+ const Te = ({ args: r }, e) => new W((t) => {
276
276
  const s = new AbortController(), o = new me(t, s.signal);
277
277
  return he(r, e, o, s.signal).catch((a) => {
278
278
  M(a) ? (o.update({
@@ -291,7 +291,7 @@ async function he(r, e, t, s) {
291
291
  progress: { type: "meta", message: `Loading routine: ${o} from ${l}` }
292
292
  });
293
293
  const c = D();
294
- c.registerTool(W);
294
+ c.registerTool(Z);
295
295
  const i = await R(
296
296
  c,
297
297
  "read_file",
@@ -357,7 +357,7 @@ async function he(r, e, t, s) {
357
357
  type: "meta",
358
358
  message: "Operation cancelled"
359
359
  }
360
- }), t.complete()) : (X.error("Error in run_routine", {
360
+ }), t.complete()) : (q.error("Error in run_routine", {
361
361
  error: o,
362
362
  stack: o instanceof Error ? o.stack : ""
363
363
  }), t.error(o));
@@ -366,4 +366,4 @@ async function he(r, e, t, s) {
366
366
  export {
367
367
  Te as runRoutine
368
368
  };
369
- //# sourceMappingURL=node-BolndRJs.js.map
369
+ //# sourceMappingURL=node-goKryvqE.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-BolndRJs.js","sources":["../../core/src/tools/builtin/run_routine/types.ts","../../core/src/tools/builtin/run_routine/serialization.ts","../../core/src/tools/builtin/run_routine/util.ts","../../core/src/tools/builtin/run_routine/step.ts","../../core/src/tools/builtin/run_routine/node.ts"],"sourcesContent":["import { z } from 'zod'\n\n// Base Step interface\nconst BaseStep = z.object({\n\tcontext: z.enum(['continue', 'none']).optional().default('continue'),\n\ttools: z.union([z.literal('all'), z.array(z.string())]).optional(),\n\tprompt: z.string(),\n\tverify: z.record(z.any()).optional(),\n}) satisfies z.ZodType<{\n\tcontext?: 'continue' | 'none'\n\ttools?: 'all' | string[]\n\tprompt: string\n\tverify?: Record<string, any>\n}>\n\n// Agent Step\nconst AgentStep = BaseStep.extend({\n\ttype: z.literal('agent'),\n\tmodel: z.string().optional(), // Default could be set in implementation\n\tinteractive_confirmation: z.boolean().optional(),\n})\n\n// LLM Step\nconst LLMStep = BaseStep.extend({\n\ttype: z.literal('llm'),\n\tmodel: z.string().optional(),\n})\n\n// Loop Agent Step\nconst LoopAgentStep = BaseStep.extend({\n\ttype: z.literal('loop_agent'),\n\tmodel: z.string().optional(),\n\tinput_file: z.string(),\n})\n\n// Loop LLM Step\nconst LoopLLMStep = BaseStep.extend({\n\ttype: z.literal('loop_llm'),\n\tmodel: z.string().optional(),\n\tinput_file: z.string(),\n})\n\n// Tool Call Step\nconst ToolCallStep = z.object({\n\ttype: z.literal('tool_call'),\n\ttool: z.string(),\n\tparameters: z.record(z.any()).optional(),\n})\n\n// Bash Step\nconst BashStep = z.object({\n\ttype: z.literal('bash'),\n\tcommand: z.string(),\n})\n\n// Union of all step types\nconst Step = z.discriminatedUnion('type', [\n\tAgentStep,\n\tLLMStep,\n\tLoopAgentStep,\n\tLoopLLMStep,\n\tToolCallStep,\n\tBashStep,\n])\n\n// Routine Block\nconst RoutineBlock = z.object({\n\tid: z.string(),\n\tsteps: z.array(Step),\n})\n\n// Routine (array of RoutineBlocks)\nconst Routine = z.array(RoutineBlock)\n\nconst Routines = z.array(Routine)\n\nexport type RoutineSchema = z.infer<typeof Routine>\nexport type RoutinesSchema = z.infer<typeof Routines>\nexport type RoutineBlockSchema = z.infer<typeof RoutineBlock>\nexport type StepSchema = z.infer<typeof Step>\nexport type AgentStepSchema = z.infer<typeof AgentStep>\nexport type LLMStepSchema = z.infer<typeof LLMStep>\nexport type LoopAgentStepSchema = z.infer<typeof LoopAgentStep>\nexport type LoopLLMStepSchema = z.infer<typeof LoopLLMStep>\nexport type ToolCallStepSchema = z.infer<typeof ToolCallStep>\nexport type BashStepSchema = z.infer<typeof BashStep>\n\nexport { Routine, RoutineBlock, Routines, Step }\n","import { parse } from 'yaml'\nimport { z } from 'zod'\nimport type { RoutineSchema } from './types'\nimport { Routine } from './types'\n\n/**\n * Deserialize a YAML string into a Routine\n * @param yamlString The YAML string representation of a Routine\n * @returns The parsed and validated Routine\n * @throws Error if the YAML is invalid or doesn't match the Routine schema\n */\nexport function deserializeRoutineFromYAML(yamlString: string): RoutineSchema {\n\ttry {\n\t\t// Parse the YAML string to a JavaScript object\n\t\tconst parsedYaml = parse(yamlString)\n\n\t\t// Validate and transform the parsed YAML against the Routine schema\n\t\tconst validatedRoutine = Routine.parse(parsedYaml)\n\n\t\treturn validatedRoutine\n\t} catch (error) {\n\t\tif (error instanceof z.ZodError) {\n\t\t\t// Enhance Zod validation errors with better context\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid routine format: ${error.errors\n\t\t\t\t\t.map((err) => `${err.path.join('.')} - ${err.message}`)\n\t\t\t\t\t.join(', ')}`,\n\t\t\t)\n\t\t} else if (error instanceof Error) {\n\t\t\t// Handle YAML parsing errors\n\t\t\tthrow new Error(`Failed to parse YAML: ${error.message}`)\n\t\t} else {\n\t\t\tthrow new Error(`Unknown error during routine deserialization: ${String(error)}`)\n\t\t}\n\t}\n}\n","import type { SubscriptionObserver } from '@sourcegraph/observable'\nimport type { ToolRun } from '../../tool-service'\nimport type { RunRoutineProgressMessage, RunRoutineToolDef } from './common'\n\n/**\n * Class that maintains state for status messages in run_routine implementation.\n * Keeps track of all status messages and reports them through the observer.\n */\nexport class ProgressReporter {\n\tprivate progressMessages: RunRoutineProgressMessage[] = []\n\n\tconstructor(\n\t\tprivate observer: SubscriptionObserver<ToolRun<RunRoutineToolDef>>,\n\t\tprivate signal: AbortSignal,\n\t) {}\n\n\t/**\n\t * Adds the latest message to the list of all status updates and then invokes the observer\n\t * with the updated 'in-progress' status.\n\t */\n\tupdate(update: ToolRun<RunRoutineToolDef>): void {\n\t\tthis.signal.throwIfAborted()\n\t\tif ('progress' in update && update.progress) {\n\t\t\tif (Array.isArray(update.progress)) {\n\t\t\t\tthis.progressMessages.push(...update.progress)\n\t\t\t} else {\n\t\t\t\tthis.progressMessages.push(update.progress)\n\t\t\t}\n\t\t\tthis.observer.next({\n\t\t\t\t...update,\n\t\t\t\tprogress: this.progressMessages,\n\t\t\t})\n\t\t} else {\n\t\t\tthis.observer.next(update)\n\t\t}\n\t}\n\n\terror(error: unknown): void {\n\t\tthis.observer.error(error)\n\t}\n\n\tcomplete(): void {\n\t\tthis.observer.complete()\n\t}\n}\n\n/**\n * Apply variable substitutions to a prompt string\n */\nexport function substitutePromptVars(prompt: string, vars: { userInput?: string }): string {\n\tlet result = prompt\n\n\t// Replace {{userInput}} with the actual user input if provided\n\tif (vars.userInput) {\n\t\tresult = result.replace(/\\{\\{\\s*userInput\\s*\\}\\}/g, vars.userInput)\n\t\tresult = result.replace(/\\{\\{\\s*user_input\\s*\\}\\}/g, vars.userInput)\n\t}\n\n\treturn result\n}\n","import { firstValueFrom } from '@sourcegraph/observable'\nimport {\n\tACTIVE_MODEL,\n\tAnthropicConverters,\n\tfromAnthropicResultToThreadDelta,\n\trunAnthropicSync,\n} from '../../../inference/backends/anthropic'\nimport { buildSystemPrompt, DefaultSystemPromptService } from '../../../threads/system-prompt'\nimport type { ToolUseBlock } from '../../../threads/thread'\nimport {\n\ttoolResultBlocks,\n\ttype Thread,\n\ttype ThreadAssistantMessage,\n\ttype ToolRunUserInput,\n} from '../../../threads/thread'\nimport type { ThreadDelta } from '../../../threads/thread-delta'\nimport { applyThreadDelta } from '../../../threads/thread-delta'\nimport type {\n\tToolDefinition,\n\tToolRun,\n\tToolRunEnvironment,\n\tToolService,\n} from '../../../tools/tool-service'\nimport { createToolService, isToolRunTerminalState } from '../../../tools/tool-service'\nimport { registerBuiltinToolsToToolService } from '../../tools'\nimport type { AgentStepSchema, LLMStepSchema, StepSchema } from './types'\nimport { substitutePromptVars, type ProgressReporter } from './util'\n\n/**\n * Run a step with the given conversation\n */\nexport function runStep(\n\tstep: StepSchema,\n\tconversation: Thread,\n\tenv: ToolRunEnvironment,\n\tprogressReporter: ProgressReporter,\n\tvars: { userInput?: string },\n\tsignal: AbortSignal = new AbortController().signal,\n): Promise<Thread> {\n\tswitch (step.type) {\n\t\tcase 'agent':\n\t\t\treturn runStepAgent(step, conversation, env, progressReporter, vars, signal)\n\t\t\tbreak\n\t\tcase 'llm':\n\t\t\treturn runStepLLM(step, conversation, progressReporter, vars, signal)\n\t\t\tbreak\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown step type: ${(step as any).type}`)\n\t}\n}\n\n/**\n * Run an agent step that implements a full agentic loop\n * Follows the pattern: inference -> tool calls -> tool results -> inference\n * until there are no more tool calls or the process is complete\n */\nasync function runStepAgent(\n\tstep: AgentStepSchema,\n\torigConversation: Thread,\n\tenv: ToolRunEnvironment,\n\tprogressReporter: ProgressReporter,\n\tvars: { userInput?: string },\n\tsignal: AbortSignal,\n): Promise<Thread> {\n\tconst toolService = createToolService()\n\tawait registerBuiltinToolsToToolService(toolService)\n\n\t// Process prompt template with variables if provided\n\tconst promptText = substitutePromptVars(step.prompt, vars)\n\n\t// Clone convo\n\tlet conversation = origConversation\n\tconst recordThreadDelta = (delta: ThreadDelta) => {\n\t\tconversation = applyThreadDelta(conversation, delta)\n\t}\n\n\trecordThreadDelta({\n\t\ttype: 'user:message',\n\t\tmessage: {\n\t\t\tcontent: [{ type: 'text', text: promptText }],\n\t\t\tmeta: {\n\t\t\t\tsentAt: Date.now(),\n\t\t\t},\n\t\t},\n\t})\n\n\t// Update progress with user message added\n\tprogressReporter.update({\n\t\tstatus: 'in-progress',\n\t\tprogress: { type: 'message', speaker: 'user', message: promptText },\n\t})\n\n\t// Get enabled tools from toolService (all tools for now)\n\tconst enabledToolSpecs = (await firstValueFrom(toolService.tools, signal)).map((t) => t.spec)\n\n\t// Set up parameters for the initial API call\n\tconst model = ACTIVE_MODEL\n\n\t// The agent loop will continue until there are no more tool calls needed\n\tlet loopCount = 0\n\tconst maxLoops = 100 // Prevent infinite loops\n\n\twhile (loopCount < maxLoops) {\n\t\tsignal.throwIfAborted()\n\t\tloopCount++\n\n\t\t// Get system prompt blocks from the main system prompt builder\n\t\tconst systemPromptService = new DefaultSystemPromptService()\n\t\t// Get the main system prompt blocks\n\t\tconst systemPromptBlocks = await buildSystemPrompt(\n\t\t\tsystemPromptService,\n\t\t\tenv.threadEnvironment,\n\t\t\tfalse,\n\t\t)\n\n\t\t// Add the subagent-specific instruction as the final block\n\t\tsystemPromptBlocks.push({\n\t\t\ttype: 'text' as const,\n\t\t\ttext: 'You are a helpful AI assistant running as a subagent within a larger system. Your task is to handle this specific step in a routine. You can use tools to complete your task. When you are completely done, do not ask to use more tools.',\n\t\t})\n\n\t\t// Use the combined system prompt\n\t\tconst systemPrompt = systemPromptBlocks\n\n\t\tsignal.throwIfAborted()\n\n\t\t// Use runAnthropicSync to get a response\n\t\tlet result\n\t\ttry {\n\t\t\tconst anthropicMessages = AnthropicConverters.fromNativeThread(conversation)\n\t\t\tresult = await runAnthropicSync(\n\t\t\t\tanthropicMessages,\n\t\t\t\tenabledToolSpecs,\n\t\t\t\tsystemPrompt,\n\t\t\t\tmodel,\n\t\t\t\tsignal,\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Anthropic API error: ${error}`)\n\t\t}\n\n\t\tif (!result.message || !('content' in result.message)) {\n\t\t\tthrow new Error('Unexpected response format from Anthropic')\n\t\t}\n\t\tif (result.message.content.length === 0) {\n\t\t\tbreak\n\t\t}\n\n\t\tconst assistantResponseDelta = fromAnthropicResultToThreadDelta(result.message)\n\t\trecordThreadDelta(assistantResponseDelta)\n\n\t\t// Extract text for progress reporting\n\t\tconst assistantText = result.message.content\n\t\t\t.filter((item) => item.type === 'text')\n\t\t\t.map((item) => ('text' in item ? item.text : ''))\n\t\t\t.join(' ')\n\t\t\t.trim()\n\t\tif (assistantText) {\n\t\t\t// Show assistant message\n\t\t\tprogressReporter.update({\n\t\t\t\tstatus: 'in-progress',\n\t\t\t\tprogress: { type: 'message', speaker: 'assistant', message: assistantText },\n\t\t\t})\n\t\t}\n\n\t\tif (assistantResponseDelta.type !== 'assistant:message') {\n\t\t\t// No tool calls\n\t\t\tbreak\n\t\t}\n\n\t\tconst toolCalls = findToolUsesNeedingInvocation(\n\t\t\tconversation,\n\t\t\tassistantResponseDelta.message,\n\t\t)\n\t\tfor (const toolCall of toolCalls) {\n\t\t\tprogressReporter.update({\n\t\t\t\tstatus: 'in-progress',\n\t\t\t\tprogress: {\n\t\t\t\t\tid: toolCall.id,\n\t\t\t\t\ttype: 'toolCall',\n\t\t\t\t\ttoolName: toolCall.name,\n\t\t\t\t\targs: JSON.stringify(toolCall.input),\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tlet toolResult\n\t\t\ttry {\n\t\t\t\ttoolResult = await invokeToolAndWaitForResult(\n\t\t\t\t\ttoolService,\n\t\t\t\t\ttoolCall.name,\n\t\t\t\t\ttoolCall.input,\n\t\t\t\t\tenv,\n\t\t\t\t\tsignal,\n\t\t\t\t)\n\t\t\t\tsignal.throwIfAborted()\n\t\t\t\tif (toolResult.status !== 'done') {\n\t\t\t\t\tthrow new Error(JSON.stringify(toolResult))\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\trecordThreadDelta({\n\t\t\t\t\ttype: 'tool:data',\n\t\t\t\t\ttoolUse: toolCall.id,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tstatus: 'error',\n\t\t\t\t\t\terror: { message: `Tool call error: ${error}` },\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tprogressReporter.update({\n\t\t\t\t\tstatus: 'in-progress',\n\t\t\t\t\tprogress: {\n\t\t\t\t\t\tid: toolCall.id,\n\t\t\t\t\t\ttype: 'toolResult',\n\t\t\t\t\t\ttoolName: toolCall.name,\n\t\t\t\t\t\tresult: `Tool call error: ${error}`,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\trecordThreadDelta({\n\t\t\t\ttype: 'tool:data',\n\t\t\t\ttoolUse: toolCall.id,\n\t\t\t\tdata: toolResult,\n\t\t\t})\n\t\t\tprogressReporter.update({\n\t\t\t\tstatus: 'in-progress',\n\t\t\t\tprogress: {\n\t\t\t\t\tid: toolCall.id,\n\t\t\t\t\ttype: 'toolResult',\n\t\t\t\t\ttoolName: toolCall.name,\n\t\t\t\t\tresult:\n\t\t\t\t\t\ttypeof toolResult.result === 'string'\n\t\t\t\t\t\t\t? toolResult.result\n\t\t\t\t\t\t\t: JSON.stringify(toolResult.result),\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t}\n\treturn conversation\n}\n\n/**\n * Mock implementation of tool execution for the subagent\n * In a real implementation, this would connect to the actual tool execution system\n */\n// Removed mock implementation in favor of actual toolService\n\n/**\n * Run an LLM step\n */\nasync function runStepLLM(\n\tstep: LLMStepSchema,\n\torigConversation: Thread,\n\tprogressReporter: ProgressReporter,\n\tvars: { userInput?: string },\n\tsignal: AbortSignal,\n): Promise<Thread> {\n\t// Process prompt template with variables if provided\n\tconst promptText = substitutePromptVars(step.prompt, vars)\n\n\t// Create a copy of the conversation to avoid mutating the original\n\tlet conversation = origConversation\n\tconst recordThreadDelta = (delta: ThreadDelta) => {\n\t\tconversation = applyThreadDelta(conversation, delta)\n\t}\n\n\trecordThreadDelta({\n\t\ttype: 'user:message',\n\t\tmessage: {\n\t\t\tcontent: [{ type: 'text', text: promptText }],\n\t\t\tmeta: {\n\t\t\t\tsentAt: Date.now(),\n\t\t\t},\n\t\t},\n\t})\n\n\t// Update progress with user message added\n\tprogressReporter.update({\n\t\tstatus: 'in-progress',\n\t\tprogress: { type: 'message', speaker: 'user', message: promptText },\n\t})\n\n\t// Use runAnthropicSync to get a response\n\tconst anthropicMessages = AnthropicConverters.fromNativeThread(conversation)\n\tconst model = step.model || ACTIVE_MODEL\n\tconst result = await runAnthropicSync(\n\t\tanthropicMessages,\n\t\t[], // No tools for LLM-only step\n\t\t[], // No system prompt\n\t\tmodel,\n\t\tsignal,\n\t)\n\n\tif (!result.message) {\n\t\tthrow new Error('Failed to get response from Anthropic')\n\t}\n\n\tconst assistantResponseDelta = fromAnthropicResultToThreadDelta(result.message)\n\trecordThreadDelta(assistantResponseDelta)\n\n\t// Display message\n\tconst assistantText = result.message.content\n\t\t.filter((item) => item.type === 'text')\n\t\t.map((item) => (item.type === 'text' ? item.text : ''))\n\t\t.join(' ')\n\t\t.trim()\n\tprogressReporter.update({\n\t\tstatus: 'in-progress',\n\t\tprogress: { type: 'message', speaker: 'assistant', message: assistantText },\n\t})\n\treturn conversation\n}\n\nfunction findToolUsesNeedingInvocation(\n\tthread: Thread,\n\tmessage: ThreadAssistantMessage,\n): ToolUseBlock[] {\n\tconst toolResults = toolResultBlocks(thread)\n\treturn message.content\n\t\t.filter((block): block is ToolUseBlock => block.type === 'tool_use')\n\t\t.filter((block) => !block.inputPartialJSON)\n\t\t.filter(\n\t\t\t(block) =>\n\t\t\t\t// Only include tools that haven't been invoked yet.\n\t\t\t\t!toolResults.has(block.id),\n\t\t)\n}\n\n/**\n * Helper function that invokes a tool and returns a Promise with the final result\n */\nexport async function invokeToolAndWaitForResult<T extends ToolDefinition>(\n\ttoolService: ToolService,\n\ttoolName: string,\n\tinput: unknown,\n\tenv: ToolRunEnvironment,\n\tsignal: AbortSignal = new AbortController().signal,\n\tuserInput?: ToolRunUserInput,\n): Promise<ToolRun<T>> {\n\treturn new Promise((resolve, reject) => {\n\t\tlet settled = false\n\t\tconst sub = toolService\n\t\t\t.invokeTool(toolName, { args: input as any, userInput }, env)\n\t\t\t.subscribe({\n\t\t\t\tnext: (run: ToolRun) => {\n\t\t\t\t\tif (isToolRunTerminalState(run)) {\n\t\t\t\t\t\tsub.unsubscribe()\n\t\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\t\tsettled = true\n\t\t\t\t\t\t\tresolve(run)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\terror: (error) => {\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true\n\t\t\t\t\t\treject(error)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tcomplete: () => {},\n\t\t\t})\n\n\t\t// Handle abort signal\n\t\tsignal.addEventListener('abort', () => {\n\t\t\tsub.unsubscribe()\n\t\t\tif (!settled) {\n\t\t\t\tsettled = true\n\t\t\t\treject(new Error('Tool execution was aborted'))\n\t\t\t}\n\t\t})\n\t})\n}\n","import { Observable } from '@sourcegraph/observable'\nimport { isAbortError } from '../../../common/abort'\nimport logger from '../../../common/logger'\nimport type { Thread } from '../../../threads/thread'\nimport { newThreadID } from '../../../threads/thread'\nimport type { ToolRunEnvironment } from '../../tool-service'\nimport { createToolService } from '../../tool-service'\nimport type { ReadFileToolDef } from '../filesystem/read_file.common'\nimport { readFileToolReg } from '../filesystem/read_file.common'\nimport type { runRoutineToolReg } from './common'\nimport { deserializeRoutineFromYAML } from './serialization'\nimport { invokeToolAndWaitForResult, runStep } from './step'\nimport { ProgressReporter } from './util'\n\nexport const runRoutine: NonNullable<(typeof runRoutineToolReg)['fn']> = ({ args }, env) => {\n\treturn new Observable((observer) => {\n\t\tconst abortController = new AbortController()\n\t\tconst progressReporter = new ProgressReporter(observer, abortController.signal)\n\n\t\trunRoutineImpl(args, env, progressReporter, abortController.signal).catch((error) => {\n\t\t\t// Don't report AbortError as an error - it's expected when cancelling\n\t\t\tif (!isAbortError(error)) {\n\t\t\t\tprogressReporter.error(error)\n\t\t\t} else {\n\t\t\t\tprogressReporter.update({\n\t\t\t\t\tstatus: 'cancelled' as const,\n\t\t\t\t\tprogress: { type: 'meta', message: 'Operation cancelled' },\n\t\t\t\t})\n\t\t\t\tprogressReporter.complete()\n\t\t\t}\n\t\t})\n\n\t\treturn () => {\n\t\t\tabortController.abort()\n\t\t}\n\t})\n}\n\nasync function runRoutineImpl(\n\targs: { id: string; file?: string; userInput?: string },\n\tenv: ToolRunEnvironment,\n\tprogressReporter: ProgressReporter,\n\tsignal: AbortSignal,\n) {\n\ttry {\n\t\tconst { id, file } = args\n\t\tconst routineFile = file || 'routines.amp.yaml'\n\n\t\t// Report initial progress\n\t\tprogressReporter.update({\n\t\t\tstatus: 'in-progress',\n\t\t\tprogress: { type: 'meta', message: `Loading routine: ${id} from ${routineFile}` },\n\t\t})\n\n\t\t// Create a tool service and register the read_file tool\n\t\tconst toolService = createToolService()\n\t\ttoolService.registerTool(readFileToolReg)\n\n\t\t// Read the routine file using the tool service\n\t\tconst readFileResult = await invokeToolAndWaitForResult<ReadFileToolDef>(\n\t\t\ttoolService,\n\t\t\t'read_file',\n\t\t\t{ path: routineFile },\n\t\t\tenv,\n\t\t\tsignal,\n\t\t)\n\n\t\t// Process the file content by removing line numbers that read_file adds\n\t\tif (readFileResult.status !== 'done') {\n\t\t\tthrow new Error(`Failed to read routine file: ${routineFile}`)\n\t\t}\n\t\t// At this point TypeScript knows readFileResult has a 'result' property\n\t\tconst fileContents =\n\t\t\ttypeof readFileResult.result === 'string'\n\t\t\t\t? readFileResult.result\n\t\t\t\t: readFileResult.result.content\n\t\tconst routineContent = String(fileContents)\n\t\t\t.split('\\n')\n\t\t\t.map((line: string) => line.replace(/^\\d+:\\s/, ''))\n\t\t\t.join('\\n')\n\n\t\tsignal.throwIfAborted()\n\n\t\t// Parse the routines\n\t\tconst routines = deserializeRoutineFromYAML(routineContent)\n\t\tsignal.throwIfAborted()\n\n\t\t// Find the requested routine\n\t\tconst routine = routines.find((routine) => routine.id === id)\n\t\tif (!routine) {\n\t\t\tthrow new Error(`Routine with id \"${id}\" not found in ${routineFile}`)\n\t\t}\n\n\t\t// Initialize a Thread for the conversation\n\t\tlet conversation: Thread = {\n\t\t\tid: newThreadID(),\n\t\t\tcreated: Date.now(),\n\t\t\tv: 0,\n\t\t\tmessages: [],\n\t\t}\n\n\t\t// Report progress before executing steps\n\t\tprogressReporter.update({\n\t\t\tstatus: 'in-progress',\n\t\t\tprogress: [\n\t\t\t\t{\n\t\t\t\t\ttype: 'meta',\n\t\t\t\t\tmessage: `Executing routine ${id}`,\n\t\t\t\t},\n\t\t\t],\n\t\t})\n\n\t\t// Execute each step in the routine\n\t\tfor (let i = 0; i < routine.steps.length; i++) {\n\t\t\tconst step = routine.steps[i]\n\t\t\tif (!step) continue // Skip undefined steps\n\n\t\t\tprogressReporter.update({\n\t\t\t\tstatus: 'in-progress',\n\t\t\t\tprogress: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'meta',\n\t\t\t\t\t\tmessage: `Executing step ${i + 1}/${routine.steps.length}: ${step.type}`,\n\t\t\t\t\t\tvariant: 'header',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t})\n\n\t\t\tsignal.throwIfAborted()\n\n\t\t\t// Execute the step and update the conversation\n\t\t\tconversation = await runStep(step, conversation, env, progressReporter, {\n\t\t\t\tuserInput: args.userInput,\n\t\t\t})\n\t\t}\n\n\t\tprogressReporter.update({\n\t\t\tstatus: 'done' as const,\n\t\t\tprogress: {\n\t\t\t\ttype: 'meta',\n\t\t\t\tmessage: `Finished executing all ${routine.steps.length} steps of routine: ${id}.`,\n\t\t\t\tvariant: 'header',\n\t\t\t},\n\t\t\tresult: '', // No output for now\n\t\t})\n\n\t\tprogressReporter.complete()\n\t} catch (error) {\n\t\tif (isAbortError(error)) {\n\t\t\tprogressReporter.update({\n\t\t\t\tstatus: 'cancelled' as const,\n\t\t\t\tprogress: {\n\t\t\t\t\ttype: 'meta',\n\t\t\t\t\tmessage: 'Operation cancelled',\n\t\t\t\t},\n\t\t\t})\n\t\t\tprogressReporter.complete()\n\t\t} else {\n\t\t\tlogger.error('Error in run_routine', {\n\t\t\t\terror,\n\t\t\t\tstack: error instanceof Error ? error.stack : '',\n\t\t\t})\n\t\t\tprogressReporter.error(error)\n\t\t}\n\t}\n}\n"],"names":["BaseStep","z.object","z.enum","z.union","z.literal","z.array","z.string","z.record","z.any","AgentStep","z.boolean","LLMStep","LoopAgentStep","LoopLLMStep","ToolCallStep","BashStep","Step","z.discriminatedUnion","RoutineBlock","Routine","deserializeRoutineFromYAML","yamlString","parsedYaml","parse","error","z.ZodError","err","ProgressReporter","observer","signal","update","substitutePromptVars","prompt","vars","result","runStep","step","conversation","env","progressReporter","runStepAgent","runStepLLM","origConversation","toolService","createToolService","registerBuiltinToolsToToolService","promptText","recordThreadDelta","delta","applyThreadDelta","enabledToolSpecs","firstValueFrom","t","model","ACTIVE_MODEL","loopCount","maxLoops","systemPromptService","DefaultSystemPromptService","systemPromptBlocks","buildSystemPrompt","systemPrompt","anthropicMessages","AnthropicConverters","runAnthropicSync","assistantResponseDelta","fromAnthropicResultToThreadDelta","assistantText","item","toolCalls","findToolUsesNeedingInvocation","toolCall","toolResult","invokeToolAndWaitForResult","thread","message","toolResults","toolResultBlocks","block","toolName","input","userInput","resolve","reject","settled","sub","run","isToolRunTerminalState","runRoutine","args","Observable","abortController","runRoutineImpl","isAbortError","id","file","routineFile","readFileToolReg","readFileResult","fileContents","routineContent","line","routines","routine","newThreadID","i","logger"],"mappings":";;;AAGA,MAAMA,IAAWC,EAAS;AAAA,EACzB,SAASC,EAAO,CAAC,YAAY,MAAM,CAAC,EAAE,SAAA,EAAW,QAAQ,UA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A,IAAIF,EAAQ,MAAM,QAAQE,KAAK;AACxC,YAAArE,IAAOmE,EAAQ,MAAME,CAAC;AAC5B,MAAKrE,MAELG,EAAiB,OAAO;AAAA,QACvB,QAAQ;AAAA,QACR,UAAU;AAAA,UACT;AAAA,YACC,MAAM;AAAA,YACN,SAAS,kBAAkBkE,IAAI,CAAC,IAAIF,EAAQ,MAAM,MAAM,KAAKnE,EAAK,IAAI;AAAA,YACtE,SAAS;AAAA,UAAA;AAAA,QACV;AAAA,MACD,CACA,GAEDP,EAAO,eAAe,GAGtBQ,IAAe,MAAMF,GAAQC,GAAMC,GAAcC,GAAKC,GAAkB;AAAA,QACvE,WAAWkD,EAAK;AAAA,MAAA,CAChB;AAAA,IAAA;AAGF,IAAAlD,EAAiB,OAAO;AAAA,MACvB,QAAQ;AAAA,MACR,UAAU;AAAA,QACT,MAAM;AAAA,QACN,SAAS,0BAA0BgE,EAAQ,MAAM,MAAM,sBAAsBT,CAAE;AAAA,QAC/E,SAAS;AAAA,MACV;AAAA,MACA,QAAQ;AAAA;AAAA,IAAA,CACR,GAEDvD,EAAiB,SAAS;AAAA,WAClBf,GAAO;AACX,IAAAqE,EAAarE,CAAK,KACrBe,EAAiB,OAAO;AAAA,MACvB,QAAQ;AAAA,MACR,UAAU;AAAA,QACT,MAAM;AAAA,QACN,SAAS;AAAA,MAAA;AAAA,IACV,CACA,GACDA,EAAiB,SAAS,MAE1BmE,EAAO,MAAM,wBAAwB;AAAA,MACpC,OAAAlF;AAAA,MACA,OAAOA,aAAiB,QAAQA,EAAM,QAAQ;AAAA,IAAA,CAC9C,GACDe,EAAiB,MAAMf,CAAK;AAAA,EAC7B;AAEF;"}
1
+ {"version":3,"file":"node-goKryvqE.js","sources":["../../core/src/tools/builtin/run_routine/types.ts","../../core/src/tools/builtin/run_routine/serialization.ts","../../core/src/tools/builtin/run_routine/util.ts","../../core/src/tools/builtin/run_routine/step.ts","../../core/src/tools/builtin/run_routine/node.ts"],"sourcesContent":["import { z } from 'zod'\n\n// Base Step interface\nconst BaseStep = z.object({\n\tcontext: z.enum(['continue', 'none']).optional().default('continue'),\n\ttools: z.union([z.literal('all'), z.array(z.string())]).optional(),\n\tprompt: z.string(),\n\tverify: z.record(z.any()).optional(),\n}) satisfies z.ZodType<{\n\tcontext?: 'continue' | 'none'\n\ttools?: 'all' | string[]\n\tprompt: string\n\tverify?: Record<string, any>\n}>\n\n// Agent Step\nconst AgentStep = BaseStep.extend({\n\ttype: z.literal('agent'),\n\tmodel: z.string().optional(), // Default could be set in implementation\n\tinteractive_confirmation: z.boolean().optional(),\n})\n\n// LLM Step\nconst LLMStep = BaseStep.extend({\n\ttype: z.literal('llm'),\n\tmodel: z.string().optional(),\n})\n\n// Loop Agent Step\nconst LoopAgentStep = BaseStep.extend({\n\ttype: z.literal('loop_agent'),\n\tmodel: z.string().optional(),\n\tinput_file: z.string(),\n})\n\n// Loop LLM Step\nconst LoopLLMStep = BaseStep.extend({\n\ttype: z.literal('loop_llm'),\n\tmodel: z.string().optional(),\n\tinput_file: z.string(),\n})\n\n// Tool Call Step\nconst ToolCallStep = z.object({\n\ttype: z.literal('tool_call'),\n\ttool: z.string(),\n\tparameters: z.record(z.any()).optional(),\n})\n\n// Bash Step\nconst BashStep = z.object({\n\ttype: z.literal('bash'),\n\tcommand: z.string(),\n})\n\n// Union of all step types\nconst Step = z.discriminatedUnion('type', [\n\tAgentStep,\n\tLLMStep,\n\tLoopAgentStep,\n\tLoopLLMStep,\n\tToolCallStep,\n\tBashStep,\n])\n\n// Routine Block\nconst RoutineBlock = z.object({\n\tid: z.string(),\n\tsteps: z.array(Step),\n})\n\n// Routine (array of RoutineBlocks)\nconst Routine = z.array(RoutineBlock)\n\nconst Routines = z.array(Routine)\n\nexport type RoutineSchema = z.infer<typeof Routine>\nexport type RoutinesSchema = z.infer<typeof Routines>\nexport type RoutineBlockSchema = z.infer<typeof RoutineBlock>\nexport type StepSchema = z.infer<typeof Step>\nexport type AgentStepSchema = z.infer<typeof AgentStep>\nexport type LLMStepSchema = z.infer<typeof LLMStep>\nexport type LoopAgentStepSchema = z.infer<typeof LoopAgentStep>\nexport type LoopLLMStepSchema = z.infer<typeof LoopLLMStep>\nexport type ToolCallStepSchema = z.infer<typeof ToolCallStep>\nexport type BashStepSchema = z.infer<typeof BashStep>\n\nexport { Routine, RoutineBlock, Routines, Step }\n","import { parse } from 'yaml'\nimport { z } from 'zod'\nimport type { RoutineSchema } from './types'\nimport { Routine } from './types'\n\n/**\n * Deserialize a YAML string into a Routine\n * @param yamlString The YAML string representation of a Routine\n * @returns The parsed and validated Routine\n * @throws Error if the YAML is invalid or doesn't match the Routine schema\n */\nexport function deserializeRoutineFromYAML(yamlString: string): RoutineSchema {\n\ttry {\n\t\t// Parse the YAML string to a JavaScript object\n\t\tconst parsedYaml = parse(yamlString)\n\n\t\t// Validate and transform the parsed YAML against the Routine schema\n\t\tconst validatedRoutine = Routine.parse(parsedYaml)\n\n\t\treturn validatedRoutine\n\t} catch (error) {\n\t\tif (error instanceof z.ZodError) {\n\t\t\t// Enhance Zod validation errors with better context\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid routine format: ${error.errors\n\t\t\t\t\t.map((err) => `${err.path.join('.')} - ${err.message}`)\n\t\t\t\t\t.join(', ')}`,\n\t\t\t)\n\t\t} else if (error instanceof Error) {\n\t\t\t// Handle YAML parsing errors\n\t\t\tthrow new Error(`Failed to parse YAML: ${error.message}`)\n\t\t} else {\n\t\t\tthrow new Error(`Unknown error during routine deserialization: ${String(error)}`)\n\t\t}\n\t}\n}\n","import type { SubscriptionObserver } from '@sourcegraph/observable'\nimport type { ToolRun } from '../../tool-service'\nimport type { RunRoutineProgressMessage, RunRoutineToolDef } from './common'\n\n/**\n * Class that maintains state for status messages in run_routine implementation.\n * Keeps track of all status messages and reports them through the observer.\n */\nexport class ProgressReporter {\n\tprivate progressMessages: RunRoutineProgressMessage[] = []\n\n\tconstructor(\n\t\tprivate observer: SubscriptionObserver<ToolRun<RunRoutineToolDef>>,\n\t\tprivate signal: AbortSignal,\n\t) {}\n\n\t/**\n\t * Adds the latest message to the list of all status updates and then invokes the observer\n\t * with the updated 'in-progress' status.\n\t */\n\tupdate(update: ToolRun<RunRoutineToolDef>): void {\n\t\tthis.signal.throwIfAborted()\n\t\tif ('progress' in update && update.progress) {\n\t\t\tif (Array.isArray(update.progress)) {\n\t\t\t\tthis.progressMessages.push(...update.progress)\n\t\t\t} else {\n\t\t\t\tthis.progressMessages.push(update.progress)\n\t\t\t}\n\t\t\tthis.observer.next({\n\t\t\t\t...update,\n\t\t\t\tprogress: this.progressMessages,\n\t\t\t})\n\t\t} else {\n\t\t\tthis.observer.next(update)\n\t\t}\n\t}\n\n\terror(error: unknown): void {\n\t\tthis.observer.error(error)\n\t}\n\n\tcomplete(): void {\n\t\tthis.observer.complete()\n\t}\n}\n\n/**\n * Apply variable substitutions to a prompt string\n */\nexport function substitutePromptVars(prompt: string, vars: { userInput?: string }): string {\n\tlet result = prompt\n\n\t// Replace {{userInput}} with the actual user input if provided\n\tif (vars.userInput) {\n\t\tresult = result.replace(/\\{\\{\\s*userInput\\s*\\}\\}/g, vars.userInput)\n\t\tresult = result.replace(/\\{\\{\\s*user_input\\s*\\}\\}/g, vars.userInput)\n\t}\n\n\treturn result\n}\n","import { firstValueFrom } from '@sourcegraph/observable'\nimport {\n\tACTIVE_MODEL,\n\tAnthropicConverters,\n\tfromAnthropicResultToThreadDelta,\n\trunAnthropicSync,\n} from '../../../inference/backends/anthropic'\nimport { buildSystemPrompt, DefaultSystemPromptService } from '../../../threads/system-prompt'\nimport type { ToolUseBlock } from '../../../threads/thread'\nimport {\n\ttoolResultBlocks,\n\ttype Thread,\n\ttype ThreadAssistantMessage,\n\ttype ToolRunUserInput,\n} from '../../../threads/thread'\nimport type { ThreadDelta } from '../../../threads/thread-delta'\nimport { applyThreadDelta } from '../../../threads/thread-delta'\nimport type {\n\tToolDefinition,\n\tToolRun,\n\tToolRunEnvironment,\n\tToolService,\n} from '../../../tools/tool-service'\nimport { createToolService, isToolRunTerminalState } from '../../../tools/tool-service'\nimport { registerBuiltinToolsToToolService } from '../../tools'\nimport type { AgentStepSchema, LLMStepSchema, StepSchema } from './types'\nimport { substitutePromptVars, type ProgressReporter } from './util'\n\n/**\n * Run a step with the given conversation\n */\nexport function runStep(\n\tstep: StepSchema,\n\tconversation: Thread,\n\tenv: ToolRunEnvironment,\n\tprogressReporter: ProgressReporter,\n\tvars: { userInput?: string },\n\tsignal: AbortSignal = new AbortController().signal,\n): Promise<Thread> {\n\tswitch (step.type) {\n\t\tcase 'agent':\n\t\t\treturn runStepAgent(step, conversation, env, progressReporter, vars, signal)\n\t\t\tbreak\n\t\tcase 'llm':\n\t\t\treturn runStepLLM(step, conversation, progressReporter, vars, signal)\n\t\t\tbreak\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown step type: ${(step as any).type}`)\n\t}\n}\n\n/**\n * Run an agent step that implements a full agentic loop\n * Follows the pattern: inference -> tool calls -> tool results -> inference\n * until there are no more tool calls or the process is complete\n */\nasync function runStepAgent(\n\tstep: AgentStepSchema,\n\torigConversation: Thread,\n\tenv: ToolRunEnvironment,\n\tprogressReporter: ProgressReporter,\n\tvars: { userInput?: string },\n\tsignal: AbortSignal,\n): Promise<Thread> {\n\tconst toolService = createToolService()\n\tawait registerBuiltinToolsToToolService(toolService)\n\n\t// Process prompt template with variables if provided\n\tconst promptText = substitutePromptVars(step.prompt, vars)\n\n\t// Clone convo\n\tlet conversation = origConversation\n\tconst recordThreadDelta = (delta: ThreadDelta) => {\n\t\tconversation = applyThreadDelta(conversation, delta)\n\t}\n\n\trecordThreadDelta({\n\t\ttype: 'user:message',\n\t\tmessage: {\n\t\t\tcontent: [{ type: 'text', text: promptText }],\n\t\t\tmeta: {\n\t\t\t\tsentAt: Date.now(),\n\t\t\t},\n\t\t},\n\t})\n\n\t// Update progress with user message added\n\tprogressReporter.update({\n\t\tstatus: 'in-progress',\n\t\tprogress: { type: 'message', speaker: 'user', message: promptText },\n\t})\n\n\t// Get enabled tools from toolService (all tools for now)\n\tconst enabledToolSpecs = (await firstValueFrom(toolService.tools, signal)).map((t) => t.spec)\n\n\t// Set up parameters for the initial API call\n\tconst model = ACTIVE_MODEL\n\n\t// The agent loop will continue until there are no more tool calls needed\n\tlet loopCount = 0\n\tconst maxLoops = 100 // Prevent infinite loops\n\n\twhile (loopCount < maxLoops) {\n\t\tsignal.throwIfAborted()\n\t\tloopCount++\n\n\t\t// Get system prompt blocks from the main system prompt builder\n\t\tconst systemPromptService = new DefaultSystemPromptService()\n\t\t// Get the main system prompt blocks\n\t\tconst systemPromptBlocks = await buildSystemPrompt(\n\t\t\tsystemPromptService,\n\t\t\tenv.threadEnvironment,\n\t\t\tfalse,\n\t\t)\n\n\t\t// Add the subagent-specific instruction as the final block\n\t\tsystemPromptBlocks.push({\n\t\t\ttype: 'text' as const,\n\t\t\ttext: 'You are a helpful AI assistant running as a subagent within a larger system. Your task is to handle this specific step in a routine. You can use tools to complete your task. When you are completely done, do not ask to use more tools.',\n\t\t})\n\n\t\t// Use the combined system prompt\n\t\tconst systemPrompt = systemPromptBlocks\n\n\t\tsignal.throwIfAborted()\n\n\t\t// Use runAnthropicSync to get a response\n\t\tlet result\n\t\ttry {\n\t\t\tconst anthropicMessages = AnthropicConverters.fromNativeThread(conversation)\n\t\t\tresult = await runAnthropicSync(\n\t\t\t\tanthropicMessages,\n\t\t\t\tenabledToolSpecs,\n\t\t\t\tsystemPrompt,\n\t\t\t\tmodel,\n\t\t\t\tsignal,\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Anthropic API error: ${error}`)\n\t\t}\n\n\t\tif (!result.message || !('content' in result.message)) {\n\t\t\tthrow new Error('Unexpected response format from Anthropic')\n\t\t}\n\t\tif (result.message.content.length === 0) {\n\t\t\tbreak\n\t\t}\n\n\t\tconst assistantResponseDelta = fromAnthropicResultToThreadDelta(result.message)\n\t\trecordThreadDelta(assistantResponseDelta)\n\n\t\t// Extract text for progress reporting\n\t\tconst assistantText = result.message.content\n\t\t\t.filter((item) => item.type === 'text')\n\t\t\t.map((item) => ('text' in item ? item.text : ''))\n\t\t\t.join(' ')\n\t\t\t.trim()\n\t\tif (assistantText) {\n\t\t\t// Show assistant message\n\t\t\tprogressReporter.update({\n\t\t\t\tstatus: 'in-progress',\n\t\t\t\tprogress: { type: 'message', speaker: 'assistant', message: assistantText },\n\t\t\t})\n\t\t}\n\n\t\tif (assistantResponseDelta.type !== 'assistant:message') {\n\t\t\t// No tool calls\n\t\t\tbreak\n\t\t}\n\n\t\tconst toolCalls = findToolUsesNeedingInvocation(\n\t\t\tconversation,\n\t\t\tassistantResponseDelta.message,\n\t\t)\n\t\tfor (const toolCall of toolCalls) {\n\t\t\tprogressReporter.update({\n\t\t\t\tstatus: 'in-progress',\n\t\t\t\tprogress: {\n\t\t\t\t\tid: toolCall.id,\n\t\t\t\t\ttype: 'toolCall',\n\t\t\t\t\ttoolName: toolCall.name,\n\t\t\t\t\targs: JSON.stringify(toolCall.input),\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tlet toolResult\n\t\t\ttry {\n\t\t\t\ttoolResult = await invokeToolAndWaitForResult(\n\t\t\t\t\ttoolService,\n\t\t\t\t\ttoolCall.name,\n\t\t\t\t\ttoolCall.input,\n\t\t\t\t\tenv,\n\t\t\t\t\tsignal,\n\t\t\t\t)\n\t\t\t\tsignal.throwIfAborted()\n\t\t\t\tif (toolResult.status !== 'done') {\n\t\t\t\t\tthrow new Error(JSON.stringify(toolResult))\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\trecordThreadDelta({\n\t\t\t\t\ttype: 'tool:data',\n\t\t\t\t\ttoolUse: toolCall.id,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tstatus: 'error',\n\t\t\t\t\t\terror: { message: `Tool call error: ${error}` },\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tprogressReporter.update({\n\t\t\t\t\tstatus: 'in-progress',\n\t\t\t\t\tprogress: {\n\t\t\t\t\t\tid: toolCall.id,\n\t\t\t\t\t\ttype: 'toolResult',\n\t\t\t\t\t\ttoolName: toolCall.name,\n\t\t\t\t\t\tresult: `Tool call error: ${error}`,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\trecordThreadDelta({\n\t\t\t\ttype: 'tool:data',\n\t\t\t\ttoolUse: toolCall.id,\n\t\t\t\tdata: toolResult,\n\t\t\t})\n\t\t\tprogressReporter.update({\n\t\t\t\tstatus: 'in-progress',\n\t\t\t\tprogress: {\n\t\t\t\t\tid: toolCall.id,\n\t\t\t\t\ttype: 'toolResult',\n\t\t\t\t\ttoolName: toolCall.name,\n\t\t\t\t\tresult:\n\t\t\t\t\t\ttypeof toolResult.result === 'string'\n\t\t\t\t\t\t\t? toolResult.result\n\t\t\t\t\t\t\t: JSON.stringify(toolResult.result),\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t}\n\treturn conversation\n}\n\n/**\n * Mock implementation of tool execution for the subagent\n * In a real implementation, this would connect to the actual tool execution system\n */\n// Removed mock implementation in favor of actual toolService\n\n/**\n * Run an LLM step\n */\nasync function runStepLLM(\n\tstep: LLMStepSchema,\n\torigConversation: Thread,\n\tprogressReporter: ProgressReporter,\n\tvars: { userInput?: string },\n\tsignal: AbortSignal,\n): Promise<Thread> {\n\t// Process prompt template with variables if provided\n\tconst promptText = substitutePromptVars(step.prompt, vars)\n\n\t// Create a copy of the conversation to avoid mutating the original\n\tlet conversation = origConversation\n\tconst recordThreadDelta = (delta: ThreadDelta) => {\n\t\tconversation = applyThreadDelta(conversation, delta)\n\t}\n\n\trecordThreadDelta({\n\t\ttype: 'user:message',\n\t\tmessage: {\n\t\t\tcontent: [{ type: 'text', text: promptText }],\n\t\t\tmeta: {\n\t\t\t\tsentAt: Date.now(),\n\t\t\t},\n\t\t},\n\t})\n\n\t// Update progress with user message added\n\tprogressReporter.update({\n\t\tstatus: 'in-progress',\n\t\tprogress: { type: 'message', speaker: 'user', message: promptText },\n\t})\n\n\t// Use runAnthropicSync to get a response\n\tconst anthropicMessages = AnthropicConverters.fromNativeThread(conversation)\n\tconst model = step.model || ACTIVE_MODEL\n\tconst result = await runAnthropicSync(\n\t\tanthropicMessages,\n\t\t[], // No tools for LLM-only step\n\t\t[], // No system prompt\n\t\tmodel,\n\t\tsignal,\n\t)\n\n\tif (!result.message) {\n\t\tthrow new Error('Failed to get response from Anthropic')\n\t}\n\n\tconst assistantResponseDelta = fromAnthropicResultToThreadDelta(result.message)\n\trecordThreadDelta(assistantResponseDelta)\n\n\t// Display message\n\tconst assistantText = result.message.content\n\t\t.filter((item) => item.type === 'text')\n\t\t.map((item) => (item.type === 'text' ? item.text : ''))\n\t\t.join(' ')\n\t\t.trim()\n\tprogressReporter.update({\n\t\tstatus: 'in-progress',\n\t\tprogress: { type: 'message', speaker: 'assistant', message: assistantText },\n\t})\n\treturn conversation\n}\n\nfunction findToolUsesNeedingInvocation(\n\tthread: Thread,\n\tmessage: ThreadAssistantMessage,\n): ToolUseBlock[] {\n\tconst toolResults = toolResultBlocks(thread)\n\treturn message.content\n\t\t.filter((block): block is ToolUseBlock => block.type === 'tool_use')\n\t\t.filter((block) => !block.inputPartialJSON)\n\t\t.filter(\n\t\t\t(block) =>\n\t\t\t\t// Only include tools that haven't been invoked yet.\n\t\t\t\t!toolResults.has(block.id),\n\t\t)\n}\n\n/**\n * Helper function that invokes a tool and returns a Promise with the final result\n */\nexport async function invokeToolAndWaitForResult<T extends ToolDefinition>(\n\ttoolService: ToolService,\n\ttoolName: string,\n\tinput: unknown,\n\tenv: ToolRunEnvironment,\n\tsignal: AbortSignal = new AbortController().signal,\n\tuserInput?: ToolRunUserInput,\n): Promise<ToolRun<T>> {\n\treturn new Promise((resolve, reject) => {\n\t\tlet settled = false\n\t\tconst sub = toolService\n\t\t\t.invokeTool(toolName, { args: input as any, userInput }, env)\n\t\t\t.subscribe({\n\t\t\t\tnext: (run: ToolRun) => {\n\t\t\t\t\tif (isToolRunTerminalState(run)) {\n\t\t\t\t\t\tsub.unsubscribe()\n\t\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\t\tsettled = true\n\t\t\t\t\t\t\tresolve(run)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\terror: (error) => {\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true\n\t\t\t\t\t\treject(error)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tcomplete: () => {},\n\t\t\t})\n\n\t\t// Handle abort signal\n\t\tsignal.addEventListener('abort', () => {\n\t\t\tsub.unsubscribe()\n\t\t\tif (!settled) {\n\t\t\t\tsettled = true\n\t\t\t\treject(new Error('Tool execution was aborted'))\n\t\t\t}\n\t\t})\n\t})\n}\n","import { Observable } from '@sourcegraph/observable'\nimport { isAbortError } from '../../../common/abort'\nimport logger from '../../../common/logger'\nimport type { Thread } from '../../../threads/thread'\nimport { newThreadID } from '../../../threads/thread'\nimport type { ToolRunEnvironment } from '../../tool-service'\nimport { createToolService } from '../../tool-service'\nimport type { ReadFileToolDef } from '../filesystem/read_file.common'\nimport { readFileToolReg } from '../filesystem/read_file.common'\nimport type { runRoutineToolReg } from './common'\nimport { deserializeRoutineFromYAML } from './serialization'\nimport { invokeToolAndWaitForResult, runStep } from './step'\nimport { ProgressReporter } from './util'\n\nexport const runRoutine: NonNullable<(typeof runRoutineToolReg)['fn']> = ({ args }, env) => {\n\treturn new Observable((observer) => {\n\t\tconst abortController = new AbortController()\n\t\tconst progressReporter = new ProgressReporter(observer, abortController.signal)\n\n\t\trunRoutineImpl(args, env, progressReporter, abortController.signal).catch((error) => {\n\t\t\t// Don't report AbortError as an error - it's expected when cancelling\n\t\t\tif (!isAbortError(error)) {\n\t\t\t\tprogressReporter.error(error)\n\t\t\t} else {\n\t\t\t\tprogressReporter.update({\n\t\t\t\t\tstatus: 'cancelled' as const,\n\t\t\t\t\tprogress: { type: 'meta', message: 'Operation cancelled' },\n\t\t\t\t})\n\t\t\t\tprogressReporter.complete()\n\t\t\t}\n\t\t})\n\n\t\treturn () => {\n\t\t\tabortController.abort()\n\t\t}\n\t})\n}\n\nasync function runRoutineImpl(\n\targs: { id: string; file?: string; userInput?: string },\n\tenv: ToolRunEnvironment,\n\tprogressReporter: ProgressReporter,\n\tsignal: AbortSignal,\n) {\n\ttry {\n\t\tconst { id, file } = args\n\t\tconst routineFile = file || 'routines.amp.yaml'\n\n\t\t// Report initial progress\n\t\tprogressReporter.update({\n\t\t\tstatus: 'in-progress',\n\t\t\tprogress: { type: 'meta', message: `Loading routine: ${id} from ${routineFile}` },\n\t\t})\n\n\t\t// Create a tool service and register the read_file tool\n\t\tconst toolService = createToolService()\n\t\ttoolService.registerTool(readFileToolReg)\n\n\t\t// Read the routine file using the tool service\n\t\tconst readFileResult = await invokeToolAndWaitForResult<ReadFileToolDef>(\n\t\t\ttoolService,\n\t\t\t'read_file',\n\t\t\t{ path: routineFile },\n\t\t\tenv,\n\t\t\tsignal,\n\t\t)\n\n\t\t// Process the file content by removing line numbers that read_file adds\n\t\tif (readFileResult.status !== 'done') {\n\t\t\tthrow new Error(`Failed to read routine file: ${routineFile}`)\n\t\t}\n\t\t// At this point TypeScript knows readFileResult has a 'result' property\n\t\tconst fileContents =\n\t\t\ttypeof readFileResult.result === 'string'\n\t\t\t\t? readFileResult.result\n\t\t\t\t: readFileResult.result.content\n\t\tconst routineContent = String(fileContents)\n\t\t\t.split('\\n')\n\t\t\t.map((line: string) => line.replace(/^\\d+:\\s/, ''))\n\t\t\t.join('\\n')\n\n\t\tsignal.throwIfAborted()\n\n\t\t// Parse the routines\n\t\tconst routines = deserializeRoutineFromYAML(routineContent)\n\t\tsignal.throwIfAborted()\n\n\t\t// Find the requested routine\n\t\tconst routine = routines.find((routine) => routine.id === id)\n\t\tif (!routine) {\n\t\t\tthrow new Error(`Routine with id \"${id}\" not found in ${routineFile}`)\n\t\t}\n\n\t\t// Initialize a Thread for the conversation\n\t\tlet conversation: Thread = {\n\t\t\tid: newThreadID(),\n\t\t\tcreated: Date.now(),\n\t\t\tv: 0,\n\t\t\tmessages: [],\n\t\t}\n\n\t\t// Report progress before executing steps\n\t\tprogressReporter.update({\n\t\t\tstatus: 'in-progress',\n\t\t\tprogress: [\n\t\t\t\t{\n\t\t\t\t\ttype: 'meta',\n\t\t\t\t\tmessage: `Executing routine ${id}`,\n\t\t\t\t},\n\t\t\t],\n\t\t})\n\n\t\t// Execute each step in the routine\n\t\tfor (let i = 0; i < routine.steps.length; i++) {\n\t\t\tconst step = routine.steps[i]\n\t\t\tif (!step) continue // Skip undefined steps\n\n\t\t\tprogressReporter.update({\n\t\t\t\tstatus: 'in-progress',\n\t\t\t\tprogress: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'meta',\n\t\t\t\t\t\tmessage: `Executing step ${i + 1}/${routine.steps.length}: ${step.type}`,\n\t\t\t\t\t\tvariant: 'header',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t})\n\n\t\t\tsignal.throwIfAborted()\n\n\t\t\t// Execute the step and update the conversation\n\t\t\tconversation = await runStep(step, conversation, env, progressReporter, {\n\t\t\t\tuserInput: args.userInput,\n\t\t\t})\n\t\t}\n\n\t\tprogressReporter.update({\n\t\t\tstatus: 'done' as const,\n\t\t\tprogress: {\n\t\t\t\ttype: 'meta',\n\t\t\t\tmessage: `Finished executing all ${routine.steps.length} steps of routine: ${id}.`,\n\t\t\t\tvariant: 'header',\n\t\t\t},\n\t\t\tresult: '', // No output for now\n\t\t})\n\n\t\tprogressReporter.complete()\n\t} catch (error) {\n\t\tif (isAbortError(error)) {\n\t\t\tprogressReporter.update({\n\t\t\t\tstatus: 'cancelled' as const,\n\t\t\t\tprogress: {\n\t\t\t\t\ttype: 'meta',\n\t\t\t\t\tmessage: 'Operation cancelled',\n\t\t\t\t},\n\t\t\t})\n\t\t\tprogressReporter.complete()\n\t\t} else {\n\t\t\tlogger.error('Error in run_routine', {\n\t\t\t\terror,\n\t\t\t\tstack: error instanceof Error ? error.stack : '',\n\t\t\t})\n\t\t\tprogressReporter.error(error)\n\t\t}\n\t}\n}\n"],"names":["BaseStep","z.object","z.enum","z.union","z.literal","z.array","z.string","z.record","z.any","AgentStep","z.boolean","LLMStep","LoopAgentStep","LoopLLMStep","ToolCallStep","BashStep","Step","z.discriminatedUnion","RoutineBlock","Routine","deserializeRoutineFromYAML","yamlString","parsedYaml","parse","error","z.ZodError","err","ProgressReporter","observer","signal","update","substitutePromptVars","prompt","vars","result","runStep","step","conversation","env","progressReporter","runStepAgent","runStepLLM","origConversation","toolService","createToolService","registerBuiltinToolsToToolService","promptText","recordThreadDelta","delta","applyThreadDelta","enabledToolSpecs","firstValueFrom","t","model","ACTIVE_MODEL","loopCount","maxLoops","systemPromptService","DefaultSystemPromptService","systemPromptBlocks","buildSystemPrompt","systemPrompt","anthropicMessages","AnthropicConverters","runAnthropicSync","assistantResponseDelta","fromAnthropicResultToThreadDelta","assistantText","item","toolCalls","findToolUsesNeedingInvocation","toolCall","toolResult","invokeToolAndWaitForResult","thread","message","toolResults","toolResultBlocks","block","toolName","input","userInput","resolve","reject","settled","sub","run","isToolRunTerminalState","runRoutine","args","Observable","abortController","runRoutineImpl","isAbortError","id","file","routineFile","readFileToolReg","readFileResult","fileContents","routineContent","line","routines","routine","newThreadID","i","logger"],"mappings":";;;AAGA,MAAMA,IAAWC,EAAS;AAAA,EACzB,SAASC,EAAO,CAAC,YAAY,MAAM,CAAC,EAAE,SAAA,EAAW,QAAQ,UAAU;AAAA,EACnE,OAAOC,EAAQ,CAACC,EAAU,KAAK,GAAGC,EAAQC,EAAU,CAAA,CAAC,CAAC,EAAE,SAAS;AAAA,EACjE,QAAQA,EAAS;AAAA,EACjB,QAAQC,EAASC,EAAO,CAAA,EAAE,SAAS;AACpC,CAAC,GAQKC,KAAYT,EAAS,OAAO;AAAA,EACjC,MAAMI,EAAU,OAAO;AAAA,EACvB,OAAOE,EAAS,EAAE,SAAS;AAAA;A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AAA;AAAA,QACV;AAAA,MACD,CACA,GAEDP,EAAO,eAAe,GAGtBQ,IAAe,MAAMF,GAAQC,GAAMC,GAAcC,GAAKC,GAAkB;AAAA,QACvE,WAAWkD,EAAK;AAAA,MAAA,CAChB;AAAA,IAAA;AAGF,IAAAlD,EAAiB,OAAO;AAAA,MACvB,QAAQ;AAAA,MACR,UAAU;AAAA,QACT,MAAM;AAAA,QACN,SAAS,0BAA0BgE,EAAQ,MAAM,MAAM,sBAAsBT,CAAE;AAAA,QAC/E,SAAS;AAAA,MACV;AAAA,MACA,QAAQ;AAAA;AAAA,IAAA,CACR,GAEDvD,EAAiB,SAAS;AAAA,WAClBf,GAAO;AACX,IAAAqE,EAAarE,CAAK,KACrBe,EAAiB,OAAO;AAAA,MACvB,QAAQ;AAAA,MACR,UAAU;AAAA,QACT,MAAM;AAAA,QACN,SAAS;AAAA,MAAA;AAAA,IACV,CACA,GACDA,EAAiB,SAAS,MAE1BmE,EAAO,MAAM,wBAAwB;AAAA,MACpC,OAAAlF;AAAA,MACA,OAAOA,aAAiB,QAAQA,EAAM,QAAQ;AAAA,IAAA,CAC9C,GACDe,EAAiB,MAAMf,CAAK;AAAA,EAC7B;AAEF;"}
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { aV as c, g, m as p, b3 as l, b4 as f, b5 as m, aT as h, c as d, O as b } from "./color-BV9wbewg.js";
3
- import { r as E } from "./executable-DndKF3B_.js";
2
+ import { aV as c, g, m as p, b3 as l, b4 as f, b5 as m, aT as h, c as d, O as b } from "./color-Cj45sRkS.js";
3
+ import { r as E } from "./executable-9B5WLKFI.js";
4
4
  const A = ({ args: a }, { dirs: t }) => {
5
5
  for (const e of t)
6
6
  c(e);
@@ -69,4 +69,4 @@ function _(a, t) {
69
69
  export {
70
70
  A as nodeGrepTool
71
71
  };
72
- //# sourceMappingURL=node-DgFnFiEl.js.map
72
+ //# sourceMappingURL=node-z_wuLuYG.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-DgFnFiEl.js","sources":["../../core/src/tools/builtin/grep/node.ts"],"sourcesContent":["import { catchError, combineLatest, map, Observable } from '@sourcegraph/observable'\nimport type { URI } from 'vscode-uri'\nimport type { ToolRun } from '../../tool-service'\nimport { checkArgSafety, checkDirURIIsFile, spawnAndObserveChildProcess } from '../node-helpers'\nimport type { GrepToolArgs } from './common'\nimport {\n\tGREP_MAX_COLUMN_LENGTH,\n\tGREP_MAX_RESULTS_PER_FILE,\n\ttype GrepToolDef,\n\ttype grepToolReg,\n} from './common'\nimport { ripgrepExecutable } from './executable'\n\nexport const nodeGrepTool: NonNullable<(typeof grepToolReg)['fn']> = ({ args }, { dirs }) => {\n\tfor (const dir of dirs) {\n\t\tcheckDirURIIsFile(dir)\n\t}\n\treturn combineLatest(...dirs.map((dir) => ripgrepFiles(dir, args))).pipe(\n\t\tmap<ToolRun<GrepToolDef>[], ToolRun<GrepToolDef>>((results) => {\n\t\t\tconst progress: string[] = []\n\t\t\tfor (const result of results) {\n\t\t\t\tif (result.status === 'in-progress') {\n\t\t\t\t\tprogress.push(...(result?.progress ?? []))\n\t\t\t\t} else if (result.status === 'done') {\n\t\t\t\t\tprogress.push(...result.result)\n\t\t\t\t} else if (result.status === 'cancelled') {\n\t\t\t\t\tprogress.push(...(result.progress ?? []))\n\t\t\t\t} else if (result.status === 'error') {\n\t\t\t\t\tprogress.push(...(result.progress ?? []))\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst errors = results.filter((result) => result.status === 'error')\n\t\t\tif (errors.length > 0) {\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tprogress,\n\t\t\t\t\terror: {\n\t\t\t\t\t\tmessage: errors\n\t\t\t\t\t\t\t.map<string>((error) => error?.error?.message ?? '')\n\t\t\t\t\t\t\t.join('\\n'),\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst status = results.every((result) => result.status === 'done')\n\t\t\t\t? 'done'\n\t\t\t\t: results.some((result) => result.status === 'cancelled')\n\t\t\t\t\t? 'cancelled'\n\t\t\t\t\t: 'in-progress'\n\t\t\treturn {\n\t\t\t\tstatus,\n\t\t\t\tprogress,\n\t\t\t\tresult: progress,\n\t\t\t}\n\t\t}),\n\t)\n}\n\nfunction ripgrepFiles(dir: URI, args: GrepToolArgs): Observable<ToolRun<GrepToolDef>> {\n\tconst ripgrepArgs: string[] = [\n\t\t'--with-filename',\n\t\t'--line-number',\n\t\t'--no-heading',\n\t\t'--no-require-git',\n\t\t'--max-columns',\n\t\tGREP_MAX_COLUMN_LENGTH.toString(),\n\t\t'--trim',\n\t\t'--max-count',\n\t\tGREP_MAX_RESULTS_PER_FILE.toString(),\n\t]\n\tif (!args.caseSensitive) {\n\t\tripgrepArgs.push('-i')\n\t}\n\tripgrepArgs.push('--regexp', args.pattern)\n\tif (args.path) {\n\t\tcheckArgSafety(args.path)\n\t\tripgrepArgs.push(args.path)\n\t}\n\n\treturn spawnAndObserveChildProcess(ripgrepExecutable(), ripgrepArgs, {\n\t\tcwd: dir.fsPath,\n\t\tstdio: ['ignore', 'pipe', 'pipe'],\n\t}).pipe(\n\t\tmap(({ stdout, stderr: _stderr, exitCode, exited }): ToolRun<GrepToolDef> => {\n\t\t\tconst matches = stdout\n\t\t\t\t.trim()\n\t\t\t\t.split('\\n')\n\t\t\t\t.filter((line) => line.length > 0)\n\n\t\t\tif (!exited) {\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'in-progress',\n\t\t\t\t\tprogress: matches,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ripgrep exit code 1 means \"no matches found\"\n\t\t\tif (exited && exitCode && exitCode >= 2) {\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tprogress: matches,\n\t\t\t\t\terror: { message: `ripgrep exited with code ${exitCode}` },\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tstatus: 'done',\n\t\t\t\tprogress: matches,\n\t\t\t\tresult: matches,\n\t\t\t}\n\t\t}),\n\t\tcatchError((error) =>\n\t\t\tObservable.of({\n\t\t\t\tstatus: 'error',\n\t\t\t\tprogress: [],\n\t\t\t\terror: { message: String(error) },\n\t\t\t}),\n\t\t),\n\t)\n}\n"],"names":["nodeGrepTool","args","dirs","dir","checkDirURIIsFile","combineLatest","ripgrepFiles","map","results","progress","result","errors","error","ripgrepArgs","GREP_MAX_COLUMN_LENGTH","GREP_MAX_RESULTS_PER_FILE","checkArgSafety","spawnAndObserveChildProcess","ripgrepExecutable","stdout","_stderr","exitCode","exited","matches","line","catchError","Observable"],"mappings":";;;AAaO,MAAMA,IAAwD,CAAC,EAAE,MAAAC,KAAQ,EAAE,MAAAC,QAAW;AAC5F,aAAWC,KAAOD;AACjB,IAAAE,EAAkBD,CAAG;AAEf,SAAAE,EAAc,GAAGH,EAAK,IAAI,CAACC,MAAQG,EAAaH,GAAKF,CAAI,CAAC,CAAC,EAAE;AAAA,IACnEM,EAAkD,CAACC,MAAY;AAC9D,YAAMC,IAAqB,CAAC;AAC5B,iBAAWC,KAAUF;AAChB,QAAAE,EAAO,WAAW,gBACrBD,EAAS,KAAK,GAAIC,GAAQ,YAAY,CAAA,CAAG,IAC/BA,EAAO,WAAW,SACnBD,EAAA,KAAK,GAAGC,EAAO,MAAM,IACpBA,EAAO,WAAW,cAC5BD,EAAS,KAAK,GAAIC,EAAO,YAAY,CAAA,CAAG,IAC9BA,EAAO,WAAW,WAC5BD,EAAS,KAAK,GAAIC,EAAO,YAAY,CAAA,CAAG;AAG1C,YAAMC,IAASH,EAAQ,OAAO,CAACE,MAAWA,EAAO,WAAW,OAAO;AAC/D,aAAAC,EAAO,SAAS,IACZ;AAAA,QACN,QAAQ;AAAA,QACR,UAAAF;AAAA,QACA,OAAO;AAAA,UACN,SAASE,EACP,IAAY,CAACC,MAAUA,GAAO,OAAO,WAAW,EAAE,EAClD,KAAK;AAAA,CAAI;AAAA,QAAA;AAAA,MAEb,IAOM;AAAA,QACN,QANcJ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CAAC;AAAA,QACX,OAAO,EAAE,SAAS,OAAOd,CAAK,EAAE;AAAA,MAChC,CAAA;AAAA,IAAA;AAAA,EAEH;AACD;"}
1
+ {"version":3,"file":"node-z_wuLuYG.js","sources":["../../core/src/tools/builtin/grep/node.ts"],"sourcesContent":["import { catchError, combineLatest, map, Observable } from '@sourcegraph/observable'\nimport type { URI } from 'vscode-uri'\nimport type { ToolRun } from '../../tool-service'\nimport { checkArgSafety, checkDirURIIsFile, spawnAndObserveChildProcess } from '../node-helpers'\nimport type { GrepToolArgs } from './common'\nimport {\n\tGREP_MAX_COLUMN_LENGTH,\n\tGREP_MAX_RESULTS_PER_FILE,\n\ttype GrepToolDef,\n\ttype grepToolReg,\n} from './common'\nimport { ripgrepExecutable } from './executable'\n\nexport const nodeGrepTool: NonNullable<(typeof grepToolReg)['fn']> = ({ args }, { dirs }) => {\n\tfor (const dir of dirs) {\n\t\tcheckDirURIIsFile(dir)\n\t}\n\treturn combineLatest(...dirs.map((dir) => ripgrepFiles(dir, args))).pipe(\n\t\tmap<ToolRun<GrepToolDef>[], ToolRun<GrepToolDef>>((results) => {\n\t\t\tconst progress: string[] = []\n\t\t\tfor (const result of results) {\n\t\t\t\tif (result.status === 'in-progress') {\n\t\t\t\t\tprogress.push(...(result?.progress ?? []))\n\t\t\t\t} else if (result.status === 'done') {\n\t\t\t\t\tprogress.push(...result.result)\n\t\t\t\t} else if (result.status === 'cancelled') {\n\t\t\t\t\tprogress.push(...(result.progress ?? []))\n\t\t\t\t} else if (result.status === 'error') {\n\t\t\t\t\tprogress.push(...(result.progress ?? []))\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst errors = results.filter((result) => result.status === 'error')\n\t\t\tif (errors.length > 0) {\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tprogress,\n\t\t\t\t\terror: {\n\t\t\t\t\t\tmessage: errors\n\t\t\t\t\t\t\t.map<string>((error) => error?.error?.message ?? '')\n\t\t\t\t\t\t\t.join('\\n'),\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst status = results.every((result) => result.status === 'done')\n\t\t\t\t? 'done'\n\t\t\t\t: results.some((result) => result.status === 'cancelled')\n\t\t\t\t\t? 'cancelled'\n\t\t\t\t\t: 'in-progress'\n\t\t\treturn {\n\t\t\t\tstatus,\n\t\t\t\tprogress,\n\t\t\t\tresult: progress,\n\t\t\t}\n\t\t}),\n\t)\n}\n\nfunction ripgrepFiles(dir: URI, args: GrepToolArgs): Observable<ToolRun<GrepToolDef>> {\n\tconst ripgrepArgs: string[] = [\n\t\t'--with-filename',\n\t\t'--line-number',\n\t\t'--no-heading',\n\t\t'--no-require-git',\n\t\t'--max-columns',\n\t\tGREP_MAX_COLUMN_LENGTH.toString(),\n\t\t'--trim',\n\t\t'--max-count',\n\t\tGREP_MAX_RESULTS_PER_FILE.toString(),\n\t]\n\tif (!args.caseSensitive) {\n\t\tripgrepArgs.push('-i')\n\t}\n\tripgrepArgs.push('--regexp', args.pattern)\n\tif (args.path) {\n\t\tcheckArgSafety(args.path)\n\t\tripgrepArgs.push(args.path)\n\t}\n\n\treturn spawnAndObserveChildProcess(ripgrepExecutable(), ripgrepArgs, {\n\t\tcwd: dir.fsPath,\n\t\tstdio: ['ignore', 'pipe', 'pipe'],\n\t}).pipe(\n\t\tmap(({ stdout, stderr: _stderr, exitCode, exited }): ToolRun<GrepToolDef> => {\n\t\t\tconst matches = stdout\n\t\t\t\t.trim()\n\t\t\t\t.split('\\n')\n\t\t\t\t.filter((line) => line.length > 0)\n\n\t\t\tif (!exited) {\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'in-progress',\n\t\t\t\t\tprogress: matches,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// ripgrep exit code 1 means \"no matches found\"\n\t\t\tif (exited && exitCode && exitCode >= 2) {\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tprogress: matches,\n\t\t\t\t\terror: { message: `ripgrep exited with code ${exitCode}` },\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tstatus: 'done',\n\t\t\t\tprogress: matches,\n\t\t\t\tresult: matches,\n\t\t\t}\n\t\t}),\n\t\tcatchError((error) =>\n\t\t\tObservable.of({\n\t\t\t\tstatus: 'error',\n\t\t\t\tprogress: [],\n\t\t\t\terror: { message: String(error) },\n\t\t\t}),\n\t\t),\n\t)\n}\n"],"names":["nodeGrepTool","args","dirs","dir","checkDirURIIsFile","combineLatest","ripgrepFiles","map","results","progress","result","errors","error","ripgrepArgs","GREP_MAX_COLUMN_LENGTH","GREP_MAX_RESULTS_PER_FILE","checkArgSafety","spawnAndObserveChildProcess","ripgrepExecutable","stdout","_stderr","exitCode","exited","matches","line","catchError","Observable"],"mappings":";;;AAaO,MAAMA,IAAwD,CAAC,EAAE,MAAAC,KAAQ,EAAE,MAAAC,QAAW;AAC5F,aAAWC,KAAOD;AACjB,IAAAE,EAAkBD,CAAG;AAEf,SAAAE,EAAc,GAAGH,EAAK,IAAI,CAACC,MAAQG,EAAaH,GAAKF,CAAI,CAAC,CAAC,EAAE;AAAA,IACnEM,EAAkD,CAACC,MAAY;AAC9D,YAAMC,IAAqB,CAAC;AAC5B,iBAAWC,KAAUF;AAChB,QAAAE,EAAO,WAAW,gBACrBD,EAAS,KAAK,GAAIC,GAAQ,YAAY,CAAA,CAAG,IAC/BA,EAAO,WAAW,SACnBD,EAAA,KAAK,GAAGC,EAAO,MAAM,IACpBA,EAAO,WAAW,cAC5BD,EAAS,KAAK,GAAIC,EAAO,YAAY,CAAA,CAAG,IAC9BA,EAAO,WAAW,WAC5BD,EAAS,KAAK,GAAIC,EAAO,YAAY,CAAA,CAAG;AAG1C,YAAMC,IAASH,EAAQ,OAAO,CAACE,MAAWA,EAAO,WAAW,OAAO;AAC/D,aAAAC,EAAO,SAAS,IACZ;AAAA,QACN,QAAQ;AAAA,QACR,UAAAF;AAAA,QACA,OAAO;AAAA,UACN,SAASE,EAC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AUA;AAAA,MACX;AAAA,IAgBD,CACA;AAAA,IACDE;AAAA,MAAW,CAACb,MACXc,EAAW,GAAG;AAAA,QACb,QAAQ;AAAA,QACR,UAAU,CAAC;AAAA,QACX,OAAO,EAAE,SAAS,OAAOd,CAAK,EAAE;AAAA,MAChC,CAAA;AAAA,IAAA;AAAA,EAEH;AACD;"}
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { b0 as F, p as d } from "./color-BV9wbewg.js";
2
+ import { b0 as F, p as d } from "./color-Cj45sRkS.js";
3
3
  const s = ({ args: n }, { dir: o, dirs: r, threadID: a, filesystem: e }) => {
4
4
  const t = F({ readFileFn: e.readFile });
5
5
  return d(
@@ -9,4 +9,4 @@ const s = ({ args: n }, { dir: o, dirs: r, threadID: a, filesystem: e }) => {
9
9
  export {
10
10
  s as nodeReadFileTool
11
11
  };
12
- //# sourceMappingURL=read_file.node-FBiGQRUp.js.map
12
+ //# sourceMappingURL=read_file.node-BPyNHNAZ.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"read_file.node-FBiGQRUp.js","sources":["../../core/src/tools/builtin/filesystem/read_file.node.ts"],"sourcesContent":["import { promiseFactoryToObservable } from '@sourcegraph/observable'\nimport { type readFileToolReg } from './read_file.common'\nimport { readFileContentWith } from './read_file.util'\n\nexport const nodeReadFileTool: NonNullable<typeof readFileToolReg.fn> = (\n\t{ args },\n\t{ dir, dirs, threadID, filesystem },\n) => {\n\tconst readFileContentFn = readFileContentWith({ readFileFn: filesystem.readFile })\n\treturn promiseFactoryToObservable(async (signal) =>\n\t\treadFileContentFn({ args }, { dir, dirs, threadID, filesystem }, signal),\n\t)\n}\n"],"names":["nodeReadFileTool","args","dir","dirs","threadID","filesystem","readFileContentFn","readFileContentWith","promiseFactoryToObservable","signal"],"mappings":";;AAIa,MAAAA,IAA2D,CACvE,EAAE,MAAAC,KACF,EAAE,KAAAC,GAAK,MAAAC,GAAM,UAAAC,GAAU,YAAAC,QACnB;AACJ,QAAMC,IAAoBC,EAAoB,EAAE,YAAYF,EAAW,UAAU;AAC1E,SAAAG;AAAA,IAA2B,OAAOC,MACxCH,EAAkB,EAAE,MAAAL,EAAK,GAAG,EAAE,KAAAC,GAAK,MAAAC,GAAM,UAAAC,GAAU,YAAAC,EAAW,GAAGI,CAAM;AAAA,EACxE;AACD;"}
1
+ {"version":3,"file":"read_file.node-BPyNHNAZ.js","sources":["../../core/src/tools/builtin/filesystem/read_file.node.ts"],"sourcesContent":["import { promiseFactoryToObservable } from '@sourcegraph/observable'\nimport { type readFileToolReg } from './read_file.common'\nimport { readFileContentWith } from './read_file.util'\n\nexport const nodeReadFileTool: NonNullable<typeof readFileToolReg.fn> = (\n\t{ args },\n\t{ dir, dirs, threadID, filesystem },\n) => {\n\tconst readFileContentFn = readFileContentWith({ readFileFn: filesystem.readFile })\n\treturn promiseFactoryToObservable(async (signal) =>\n\t\treadFileContentFn({ args }, { dir, dirs, threadID, filesystem }, signal),\n\t)\n}\n"],"names":["nodeReadFileTool","args","dir","dirs","threadID","filesystem","readFileContentFn","readFileContentWith","promiseFactoryToObservable","signal"],"mappings":";;AAIa,MAAAA,IAA2D,CACvE,EAAE,MAAAC,KACF,EAAE,KAAAC,GAAK,MAAAC,GAAM,UAAAC,GAAU,YAAAC,QACnB;AACJ,QAAMC,IAAoBC,EAAoB,EAAE,YAAYF,EAAW,UAAU;AAC1E,SAAAG;AAAA,IAA2B,OAAOC,MACxCH,EAAkB,EAAE,MAAAL,EAAK,GAAG,EAAE,KAAAC,GAAK,MAAAC,GAAM,UAAAC,GAAU,YAAAC,EAAW,GAAGI,CAAM;AAAA,EACxE;AACD;"}
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
- import { z as ee, at as re } from "./color-BV9wbewg.js";
2
+ import { A as ee, k as re } from "./color-Cj45sRkS.js";
3
3
  import ne from "node:child_process";
4
- import D from "node:path";
5
- import L from "node:fs";
4
+ import k from "node:path";
5
+ import D from "node:fs";
6
6
  import R from "node:process";
7
7
  import { PassThrough as te } from "node:stream";
8
- import { J as se } from "./main-BzLjPVuG.js";
9
- var S = { exports: {} }, T, k;
8
+ import { J as se } from "./main-B3QXAnGP.js";
9
+ var S = { exports: {} }, T, L;
10
10
  function oe() {
11
- if (k) return T;
12
- k = 1, T = n, n.sync = u;
13
- var c = L;
11
+ if (L) return T;
12
+ L = 1, T = n, n.sync = u;
13
+ var c = D;
14
14
  function t(e, o) {
15
15
  var f = o.pathExt !== void 0 ? o.pathExt : process.env.PATHEXT;
16
16
  if (!f || (f = f.split(";"), f.indexOf("") !== -1))
@@ -39,7 +39,7 @@ var O, B;
39
39
  function ie() {
40
40
  if (B) return O;
41
41
  B = 1, O = t, t.sync = a;
42
- var c = L;
42
+ var c = D;
43
43
  function t(e, o, f) {
44
44
  c.stat(e, function(i, s) {
45
45
  f(i, i ? !1 : n(s, o));
@@ -92,7 +92,7 @@ var q, F;
92
92
  function ae() {
93
93
  if (F) return q;
94
94
  F = 1;
95
- const c = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys", t = D, a = c ? ";" : ":", n = ce(), u = (i) => Object.assign(new Error(`not found: ${i}`), { code: "ENOENT" }), e = (i, s) => {
95
+ const c = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys", t = k, a = c ? ";" : ":", n = ce(), u = (i) => Object.assign(new Error(`not found: ${i}`), { code: "ENOENT" }), e = (i, s) => {
96
96
  const r = s.colon || a, l = i.match(/\//) || c && i.match(/\\/) ? [""] : [
97
97
  // windows always checks the cwd first
98
98
  ...c ? [process.cwd()] : [],
@@ -150,21 +150,21 @@ function ae() {
150
150
  };
151
151
  return q = o, o.sync = f, q;
152
152
  }
153
- var b = { exports: {} }, z;
153
+ var b = { exports: {} }, U;
154
154
  function ue() {
155
- if (z) return b.exports;
156
- z = 1;
155
+ if (U) return b.exports;
156
+ U = 1;
157
157
  const c = (t = {}) => {
158
158
  const a = t.env || process.env;
159
159
  return (t.platform || process.platform) !== "win32" ? "PATH" : Object.keys(a).reverse().find((u) => u.toUpperCase() === "PATH") || "Path";
160
160
  };
161
161
  return b.exports = c, b.exports.default = c, b.exports;
162
162
  }
163
- var N, U;
163
+ var N, z;
164
164
  function fe() {
165
- if (U) return N;
166
- U = 1;
167
- const c = D, t = ae(), a = ue();
165
+ if (z) return N;
166
+ z = 1;
167
+ const c = k, t = ae(), a = ue();
168
168
  function n(e, o) {
169
169
  const f = e.options.env || process.env, i = process.cwd(), s = e.options.cwd != null, r = s && process.chdir !== void 0 && !process.chdir.disabled;
170
170
  if (r)
@@ -223,7 +223,7 @@ var H, J;
223
223
  function pe() {
224
224
  if (J) return H;
225
225
  J = 1;
226
- const c = L, t = de();
226
+ const c = D, t = de();
227
227
  function a(n) {
228
228
  const e = Buffer.alloc(150);
229
229
  let o;
@@ -239,7 +239,7 @@ var I, Y;
239
239
  function me() {
240
240
  if (Y) return I;
241
241
  Y = 1;
242
- const c = D, t = fe(), a = le(), n = pe(), u = process.platform === "win32", e = /\.(?:com|exe)$/i, o = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
242
+ const c = k, t = fe(), a = le(), n = pe(), u = process.platform === "win32", e = /\.(?:com|exe)$/i, o = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
243
243
  function f(r) {
244
244
  r.file = t(r);
245
245
  const l = r.file && n(r.file);
@@ -464,4 +464,4 @@ export {
464
464
  $e as StdioClientTransport,
465
465
  be as getDefaultEnvironment
466
466
  };
467
- //# sourceMappingURL=stdio-BWKt1HvU.js.map
467
+ //# sourceMappingURL=stdio-BHqN64gs.js.map