@sourcegraph/amp 0.0.1749096401-g3a8a18 → 0.0.1749110552-g9daa42

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 (48) hide show
  1. package/dist/amp.js +3 -3
  2. package/dist/{client-CT0UspN7.js → client-Co7dVied.js} +2 -2
  3. package/dist/{client-CT0UspN7.js.map → client-Co7dVied.js.map} +1 -1
  4. package/dist/{console-CZXURH0C.js → console-9ChYTAuP.js} +20 -14
  5. package/dist/console-9ChYTAuP.js.map +1 -0
  6. package/dist/create_file.node-hHqtsH6T.js +22 -0
  7. package/dist/create_file.node-hHqtsH6T.js.map +1 -0
  8. package/dist/{edit_file.node-BqRltvHA.js → edit_file.node-C_QnSUCA.js} +3 -3
  9. package/dist/{edit_file.node-BqRltvHA.js.map → edit_file.node-C_QnSUCA.js.map} +1 -1
  10. package/dist/{executable-Dy1dmJR0.js → executable-Cos2zJOT.js} +2 -2
  11. package/dist/{executable-Dy1dmJR0.js.map → executable-Cos2zJOT.js.map} +1 -1
  12. package/dist/{files-yat9N0vH.js → files-DuJQGx_l.js} +2 -2
  13. package/dist/{files-yat9N0vH.js.map → files-DuJQGx_l.js.map} +1 -1
  14. package/dist/{glob.node-h1Swo4vr.js → glob.node-Ca3WEmvJ.js} +4 -4
  15. package/dist/{glob.node-h1Swo4vr.js.map → glob.node-Ca3WEmvJ.js.map} +1 -1
  16. package/dist/{index-D5lm6ANC.js → index-qB8r0Uhu.js} +2 -2
  17. package/dist/{index-D5lm6ANC.js.map → index-qB8r0Uhu.js.map} +1 -1
  18. package/dist/{list_directory.node-CEUOBF5h.js → list_directory.node-B2wxSFMa.js} +2 -2
  19. package/dist/{list_directory.node-CEUOBF5h.js.map → list_directory.node-B2wxSFMa.js.map} +1 -1
  20. package/dist/{load-profile-Dk7ZUf3s.js → load-profile-DpyLbaYS.js} +2 -2
  21. package/dist/{load-profile-Dk7ZUf3s.js.map → load-profile-DpyLbaYS.js.map} +1 -1
  22. package/dist/{main-CS_jpDsP.js → main-DcFXyTPo.js} +21 -16
  23. package/dist/main-DcFXyTPo.js.map +1 -0
  24. package/dist/{node-BtKYcfrH.js → node-BBnb2R8E.js} +3 -3
  25. package/dist/{node-BtKYcfrH.js.map → node-BBnb2R8E.js.map} +1 -1
  26. package/dist/{node-DVHX-oeS.js → node-BUT6Nvpy.js} +2 -2
  27. package/dist/{node-DVHX-oeS.js.map → node-BUT6Nvpy.js.map} +1 -1
  28. package/dist/{node-CRrSwIMO.js → node-BYuqVOkK.js} +4 -4
  29. package/dist/{node-CRrSwIMO.js.map → node-BYuqVOkK.js.map} +1 -1
  30. package/dist/{node-dAg24OS_.js → node-DJwpqsh_.js} +3 -3
  31. package/dist/{node-dAg24OS_.js.map → node-DJwpqsh_.js.map} +1 -1
  32. package/dist/{node-BJyrP3Sj.js → node-Dm9KQUgx.js} +2 -2
  33. package/dist/{node-BJyrP3Sj.js.map → node-Dm9KQUgx.js.map} +1 -1
  34. package/dist/{node-COZM4qQd.js → node-DzhEX6Qs.js} +1077 -1063
  35. package/dist/node-DzhEX6Qs.js.map +1 -0
  36. package/dist/{read_file.node-DbAEjkEn.js → read_file.node-QXBL6A9B.js} +2 -2
  37. package/dist/{read_file.node-DbAEjkEn.js.map → read_file.node-QXBL6A9B.js.map} +1 -1
  38. package/dist/{stdio-BxgTnYre.js → stdio-evwhHRf7.js} +3 -3
  39. package/dist/{stdio-BxgTnYre.js.map → stdio-evwhHRf7.js.map} +1 -1
  40. package/dist/storybook.js +1 -1
  41. package/dist/{undo_edit.node-DL1deBcE.js → undo_edit.node-CBJHZjZk.js} +2 -2
  42. package/dist/{undo_edit.node-DL1deBcE.js.map → undo_edit.node-CBJHZjZk.js.map} +1 -1
  43. package/package.json +1 -1
  44. package/dist/console-CZXURH0C.js.map +0 -1
  45. package/dist/create_file.node-Bg2Ha2Q0.js +0 -24
  46. package/dist/create_file.node-Bg2Ha2Q0.js.map +0 -1
  47. package/dist/main-CS_jpDsP.js.map +0 -1
  48. package/dist/node-COZM4qQd.js.map +0 -1
package/dist/amp.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import "./console-CZXURH0C.js";
3
- import "./main-CS_jpDsP.js";
2
+ import "./console-9ChYTAuP.js";
3
+ import "./main-DcFXyTPo.js";
4
4
  import "node:crypto";
5
5
  import "node:fs/promises";
6
6
  import "node:path";
7
7
  import "node:process";
8
- import "./client-CT0UspN7.js";
8
+ import "./client-Co7dVied.js";
9
9
  //# sourceMappingURL=amp.js.map
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { f as i, E as o, aQ as c, s as p, p as u } from "./console-CZXURH0C.js";
2
+ import { f as i, E as o, aQ as c, s as p, p as u } from "./console-9ChYTAuP.js";
3
3
  const m = !0;
4
4
  function f() {
5
5
  return new Proxy(
@@ -52,4 +52,4 @@ export {
52
52
  h as f,
53
53
  y as i
54
54
  };
55
- //# sourceMappingURL=client-CT0UspN7.js.map
55
+ //# sourceMappingURL=client-Co7dVied.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-CT0UspN7.js","sources":["../../core/src/server-api/internal-api-client.ts","../../core/src/server-api/client.ts"],"sourcesContent":["import type { InternalAPI } from '@sourcegraph/amp-api-types/src/internal-api'\nimport { fetchFromAmpServer } from './client'\n\n/**\n * The new POST /api/internal API was deployed on 2025-06-01. Until we are confident that the server\n * side of the new API is deployed *and* we will NOT need to roll back to a version prior to it, we\n * still fall back to the old API if the new API does not work. (Of course, this assumes that\n * operations are idempotent.)\n *\n * TODO(sqs): Remove this after we are sure that we will not need to roll back ampcode.com to a\n * version prior to the new POST /api/internal API. Then we can remove dead client code. Still need\n * to keep the server code for these API endpoints for older clients.\n */\nexport const FALLBACK_TO_OLD_INTERNAL_API: boolean = true\n\n/**\n * Transform the server-side InternalAPI into a client-side interface by:\n * 1. Removing the first 'ctx' parameter\n * 2. Adding an optional 'options' parameter with AbortSignal support\n */\ntype TransformToClientAPI<T> = {\n\t[K in keyof T]: T[K] extends (ctx: never, params: infer Params) => infer Return\n\t\t? (params: Params, options?: Options) => Return\n\t\t: T[K]\n}\n\ninterface Options {\n\tsignal?: AbortSignal\n}\n\n/**\n * Client-side interface for the InternalAPI that includes client-specific features like AbortSignal.\n * This interface omits the 'ctx' parameter which is handled server-side.\n */\nexport type InternalAPIClient = TransformToClientAPI<InternalAPI<never>>\n\n/**\n * Create a client for the InternalAPI interface that sends requests to the Amp server. Uses a\n * Proxy to dynamically call the appropriate API methods.\n */\nfunction createInternalAPIClient(): InternalAPIClient {\n\treturn new Proxy(\n\t\t{},\n\t\t{\n\t\t\tget: (_target, method: string) => {\n\t\t\t\treturn async (...args: any[]) => {\n\t\t\t\t\tconst options = args.at(1) as Options\n\t\t\t\t\tconst params = args.at(0)\n\n\t\t\t\t\t// Send request to the server.\n\t\t\t\t\tconst resp = await fetchFromAmpServer('/api/internal', {\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\tbody: JSON.stringify({ method, params }),\n\t\t\t\t\t\tsignal: options?.signal,\n\t\t\t\t\t})\n\n\t\t\t\t\tif (!resp.ok) {\n\t\t\t\t\t\tthrow new Error(`API request failed: ${resp.status}`)\n\t\t\t\t\t}\n\n\t\t\t\t\treturn await resp.json()\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t) as InternalAPIClient\n}\n\n/**\n * Singleton instance of the internal API client.\n */\nexport const internalAPIClient: InternalAPIClient = createInternalAPIClient()\n","import type { ThreadOperatorShare } from '@sourcegraph/amp-api-types'\nimport type { Observable } from '@sourcegraph/observable'\nimport {\n\tdistinctUntilChanged,\n\tfirstValueFrom,\n\tmap,\n\ttype pendingOperation,\n\tpromiseFactoryToObservable,\n\tswitchMap,\n\tswitchMapReplayOperation,\n} from '@sourcegraph/observable'\nimport { isEqualJSON } from '../common/isEqualJSON'\nimport { type PickResolvedConfiguration, resolvedConfig } from '../configuration/resolver'\nimport { clientIdentificationHeaders } from '../misc/known-clients'\nimport type { ThreadID } from '../threads/thread'\nimport type { ThreadService } from '../threads/thread-service'\nimport { FALLBACK_TO_OLD_INTERNAL_API, internalAPIClient } from './internal-api-client'\n\nexport const isAmpServerConfigured = resolvedConfig.pipe(\n\tswitchMap(({ settings, secrets }) => {\n\t\treturn promiseFactoryToObservable(async () => {\n\t\t\tconst apiKey = await secrets.getToken('apiKey', settings.url)\n\t\t\treturn apiKey !== undefined\n\t\t})\n\t}),\n)\n\n/**\n * Returns the URL to a thread on the Amp server.\n */\nexport function threadURL(ampURL: URL, threadID: ThreadID): URL {\n\treturn new URL(`/threads/${threadID}`, ampURL)\n}\n\n/**\n * Makes a request to the Amp API with the proper configuration\n */\nexport async function fetchFromAmpServer(\n\tpathAndQuery: string,\n\tinit?: RequestInit,\n): Promise<Response> {\n\tconst config = await firstValueFrom(resolvedConfig, init?.signal ?? undefined)\n\treturn fetchFromAmpServerWithConfig(config, pathAndQuery, init)\n}\n\nexport function watchOnAmpServer<T>(\n\tpathAndQuery: string,\n\tinit?: Omit<RequestInit, 'signal'>,\n): Observable<T | typeof pendingOperation | Error> {\n\treturn resolvedConfig.pipe(\n\t\tmap(\n\t\t\t({ settings, secrets }) =>\n\t\t\t\t({\n\t\t\t\t\tsettings: {\n\t\t\t\t\t\turl: settings.url,\n\t\t\t\t\t},\n\t\t\t\t\tsecrets,\n\t\t\t\t}) satisfies PickResolvedConfiguration<{\n\t\t\t\t\tsettings: 'url'\n\t\t\t\t\tsecrets: true\n\t\t\t\t}>,\n\t\t),\n\t\tdistinctUntilChanged(\n\t\t\t(a, b) => isEqualJSON(a.settings, b.settings) && a.secrets === b.secrets,\n\t\t),\n\t\tswitchMapReplayOperation((config) =>\n\t\t\tpromiseFactoryToObservable(async (signal) => {\n\t\t\t\tconst resp = await fetchFromAmpServerWithConfig(config, pathAndQuery, {\n\t\t\t\t\t...init,\n\t\t\t\t\tsignal,\n\t\t\t\t})\n\t\t\t\tif (!resp.ok) {\n\t\t\t\t\tconst text = await resp.text()\n\t\t\t\t\tif (text) {\n\t\t\t\t\t\tthrow new Error(`HTTP ${resp.status}: ${text}`)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new Error(`HTTP ${resp.status}`)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn (await resp.json()) as T\n\t\t\t}),\n\t\t),\n\t)\n}\n\n/**\n * Share a thread with the operator (i.e., the Amp team).\n */\nexport async function shareThreadWithOperator(\n\tthreadService: ThreadService,\n\tthreadID: ThreadID,\n): Promise<void> {\n\tconst thread = await firstValueFrom(threadService.observe(threadID))\n\tif (!thread) {\n\t\tthrow new Error(`Thread not found: ${threadID}`)\n\t}\n\n\ttry {\n\t\tconst resp = await internalAPIClient.shareThreadWithOperator({ threadData: thread })\n\t\tif (!resp.ok) {\n\t\t\tthrow new Error(`Failed to share thread: ${resp.error.message}`)\n\t\t}\n\t} catch (error) {\n\t\tif (FALLBACK_TO_OLD_INTERNAL_API) {\n\t\t\tconst response = await fetchFromAmpServer('/api/internal/share-thread-with-operator', {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t},\n\t\t\t\tbody: JSON.stringify({ threadData: thread } as Pick<\n\t\t\t\t\tThreadOperatorShare,\n\t\t\t\t\t'threadData'\n\t\t\t\t>),\n\t\t\t})\n\t\t\tif (!response.ok) {\n\t\t\t\tconst text = await response.text()\n\t\t\t\tthrow new Error(`Failed to share thread: ${response.status} ${text}`)\n\t\t\t}\n\t\t} else {\n\t\t\tthrow error\n\t\t}\n\t}\n}\n\n/**\n * Submit autoedit feedback to the server.\n */\nexport async function submitAutoeditFeedback(feedbackData: {\n\tfile_path: string\n\tprefix: string\n\tsuffix: string\n\tcode_to_replace_prefix: string\n\tcode_to_replace_suffix: string\n\tcontext: Array<{\n\t\tidentifier: string\n\t\tcontent: string\n\t\tfile_path: string\n\t\tstart_line?: number\n\t\tend_line?: number\n\t\tmetadata?: {\n\t\t\ttime_since_action_ms?: number\n\t\t\tretriever_metadata?: Record<string, number | string>\n\t\t}\n\t}>\n\tchosen: string\n\trejected: string\n\tassertions: string\n}): Promise<void> {\n\tconst response = await fetchFromAmpServer('/api/tab/feedback', {\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\t'Content-Type': 'application/json',\n\t\t},\n\t\tbody: JSON.stringify(feedbackData),\n\t})\n\n\tif (!response.ok) {\n\t\tconst text = await response.text()\n\t\tlet errorMessage: string\n\t\ttry {\n\t\t\tconst errorData = JSON.parse(text)\n\t\t\terrorMessage = errorData.error || `HTTP ${response.status}`\n\t\t} catch {\n\t\t\terrorMessage = text || `HTTP ${response.status}`\n\t\t}\n\t\tthrow new Error(`Failed to submit feedback: ${errorMessage}`)\n\t}\n}\n\nasync function fetchFromAmpServerWithConfig(\n\tconfig: PickResolvedConfiguration<{\n\t\tsettings: 'url'\n\t\tsecrets: true\n\t}>,\n\tpathAndQuery: string,\n\tinit?: RequestInit,\n): Promise<Response> {\n\tif (pathAndQuery.startsWith('http:') || pathAndQuery.startsWith('https:')) {\n\t\tthrow new Error('input must be a path, not an absolute URL')\n\t}\n\tif (!pathAndQuery.startsWith('/')) {\n\t\tthrow new Error('pathAndQuery must start with /')\n\t}\n\n\tconst baseURL = config.settings.url\n\tif (!baseURL) {\n\t\tthrow new Error('amp.url is not set')\n\t}\n\n\tconst apiKey = await config.secrets.getToken('apiKey', baseURL)\n\tif (!apiKey) {\n\t\tthrow new Error('Amp API key is not set')\n\t}\n\n\treturn fetch(new URL(pathAndQuery, baseURL), {\n\t\t...init,\n\t\theaders: {\n\t\t\t...init?.headers,\n\t\t\t...clientIdentificationHeaders(),\n\t\t\t'Content-Type': 'application/json',\n\t\t\tAuthorization: `Bearer ${apiKey}`,\n\t\t},\n\t})\n}\n"],"names":["FALLBACK_TO_OLD_INTERNAL_API","createInternalAPIClient","_target","method","args","options","params","resp","fetchFromAmpServer","internalAPIClient","isAmpServerConfigured","resolvedConfig","switchMap","settings","secrets","promiseFactoryToObservable","pathAndQuery","init","config","firstValueFrom","fetchFromAmpServerWithConfig","baseURL","apiKey","clientIdentificationHeaders"],"mappings":";;AAaO,MAAMA,IAAwC;AA2BrD,SAASC,IAA6C;AACrD,SAAO,IAAI;AAAA,IACV,CAAC;AAAA,IACD;AAAA,MACC,KAAK,CAACC,GAASC,MACP,UAAUC,MAAgB;AAC1B,cAAAC,IAAUD,EAAK,GAAG,CAAC,GACnBE,IAASF,EAAK,GAAG,CAAC,GAGlBG,IAAO,MAAMC,EAAmB,iBAAiB;AAAA,UACtD,QAAQ;AAAA,UACR,MAAM,KAAK,UAAU,EAAE,QAAAL,GAAQ,QAAAG,GAAQ;AAAA,UACvC,QAAQD,GAAS;AAAA,QAAA,CACjB;AAEG,YAAA,CAACE,EAAK;AACT,gBAAM,IAAI,MAAM,uBAAuBA,EAAK,MAAM,EAAE;AAG9C,eAAA,MAAMA,EAAK,KAAK;AAAA,MACxB;AAAA,IACD;AAAA,EAEF;AACD;AAKO,MAAME,IAAuCR,EAAwB,GCpD/DS,IAAwBC,EAAe;AAAA,EACnDC,EAAU,CAAC,EAAE,UAAAC,GAAU,SAAAC,QACfC,EAA2B,YAClB,MAAMD,EAAQ,SAAS,UAAUD,EAAS,GAAG,MAC1C,MAClB,CACD;AACF;AAYsB,eAAAL,EACrBQ,GACAC,GACoB;AACpB,QAAMC,IAAS,MAAMC,EAAeR,GAAgBM,GAAM,UAAU,MAAS;AACtE,SAAAG,EAA6BF,GAAQF,GAAcC,CAAI;AAC/D;AA8HA,eAAeG,EACdF,GAIAF,GACAC,GACoB;AACpB,MAAID,EAAa,WAAW,OAAO,KAAKA,EAAa,WAAW,QAAQ;AACjE,UAAA,IAAI,MAAM,2CAA2C;AAE5D,MAAI,CAACA,EAAa,WAAW,GAAG;AACzB,UAAA,IAAI,MAAM,gCAAgC;AAG3C,QAAAK,IAAUH,EAAO,SAAS;AAChC,MAAI,CAACG;AACE,UAAA,IAAI,MAAM,oBAAoB;AAGrC,QAAMC,IAAS,MAAMJ,EAAO,QAAQ,SAAS,UAAUG,CAAO;AAC9D,MAAI,CAACC;AACE,UAAA,IAAI,MAAM,wBAAwB;AAGzC,SAAO,MAAM,IAAI,IAAIN,GAAcK,CAAO,GAAG;AAAA,IAC5C,GAAGJ;AAAA,IACH,SAAS;AAAA,MACR,GAAGA,GAAM;AAAA,MACT,GAAGM,EAA4B;AAAA,MAC/B,gBAAgB;AAAA,MAChB,eAAe,UAAUD,CAAM;AAAA,IAAA;AAAA,EAChC,CACA;AACF;"}
1
+ {"version":3,"file":"client-Co7dVied.js","sources":["../../core/src/server-api/internal-api-client.ts","../../core/src/server-api/client.ts"],"sourcesContent":["import type { InternalAPI } from '@sourcegraph/amp-api-types/src/internal-api'\nimport { fetchFromAmpServer } from './client'\n\n/**\n * The new POST /api/internal API was deployed on 2025-06-01. Until we are confident that the server\n * side of the new API is deployed *and* we will NOT need to roll back to a version prior to it, we\n * still fall back to the old API if the new API does not work. (Of course, this assumes that\n * operations are idempotent.)\n *\n * TODO(sqs): Remove this after we are sure that we will not need to roll back ampcode.com to a\n * version prior to the new POST /api/internal API. Then we can remove dead client code. Still need\n * to keep the server code for these API endpoints for older clients.\n */\nexport const FALLBACK_TO_OLD_INTERNAL_API: boolean = true\n\n/**\n * Transform the server-side InternalAPI into a client-side interface by:\n * 1. Removing the first 'ctx' parameter\n * 2. Adding an optional 'options' parameter with AbortSignal support\n */\ntype TransformToClientAPI<T> = {\n\t[K in keyof T]: T[K] extends (ctx: never, params: infer Params) => infer Return\n\t\t? (params: Params, options?: Options) => Return\n\t\t: T[K]\n}\n\ninterface Options {\n\tsignal?: AbortSignal\n}\n\n/**\n * Client-side interface for the InternalAPI that includes client-specific features like AbortSignal.\n * This interface omits the 'ctx' parameter which is handled server-side.\n */\nexport type InternalAPIClient = TransformToClientAPI<InternalAPI<never>>\n\n/**\n * Create a client for the InternalAPI interface that sends requests to the Amp server. Uses a\n * Proxy to dynamically call the appropriate API methods.\n */\nfunction createInternalAPIClient(): InternalAPIClient {\n\treturn new Proxy(\n\t\t{},\n\t\t{\n\t\t\tget: (_target, method: string) => {\n\t\t\t\treturn async (...args: any[]) => {\n\t\t\t\t\tconst options = args.at(1) as Options\n\t\t\t\t\tconst params = args.at(0)\n\n\t\t\t\t\t// Send request to the server.\n\t\t\t\t\tconst resp = await fetchFromAmpServer('/api/internal', {\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\tbody: JSON.stringify({ method, params }),\n\t\t\t\t\t\tsignal: options?.signal,\n\t\t\t\t\t})\n\n\t\t\t\t\tif (!resp.ok) {\n\t\t\t\t\t\tthrow new Error(`API request failed: ${resp.status}`)\n\t\t\t\t\t}\n\n\t\t\t\t\treturn await resp.json()\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t) as InternalAPIClient\n}\n\n/**\n * Singleton instance of the internal API client.\n */\nexport const internalAPIClient: InternalAPIClient = createInternalAPIClient()\n","import type { ThreadOperatorShare } from '@sourcegraph/amp-api-types'\nimport type { Observable } from '@sourcegraph/observable'\nimport {\n\tdistinctUntilChanged,\n\tfirstValueFrom,\n\tmap,\n\ttype pendingOperation,\n\tpromiseFactoryToObservable,\n\tswitchMap,\n\tswitchMapReplayOperation,\n} from '@sourcegraph/observable'\nimport { isEqualJSON } from '../common/isEqualJSON'\nimport { type PickResolvedConfiguration, resolvedConfig } from '../configuration/resolver'\nimport { clientIdentificationHeaders } from '../misc/known-clients'\nimport type { ThreadID } from '../threads/thread'\nimport type { ThreadService } from '../threads/thread-service'\nimport { FALLBACK_TO_OLD_INTERNAL_API, internalAPIClient } from './internal-api-client'\n\nexport const isAmpServerConfigured = resolvedConfig.pipe(\n\tswitchMap(({ settings, secrets }) => {\n\t\treturn promiseFactoryToObservable(async () => {\n\t\t\tconst apiKey = await secrets.getToken('apiKey', settings.url)\n\t\t\treturn apiKey !== undefined\n\t\t})\n\t}),\n)\n\n/**\n * Returns the URL to a thread on the Amp server.\n */\nexport function threadURL(ampURL: URL, threadID: ThreadID): URL {\n\treturn new URL(`/threads/${threadID}`, ampURL)\n}\n\n/**\n * Makes a request to the Amp API with the proper configuration\n */\nexport async function fetchFromAmpServer(\n\tpathAndQuery: string,\n\tinit?: RequestInit,\n): Promise<Response> {\n\tconst config = await firstValueFrom(resolvedConfig, init?.signal ?? undefined)\n\treturn fetchFromAmpServerWithConfig(config, pathAndQuery, init)\n}\n\nexport function watchOnAmpServer<T>(\n\tpathAndQuery: string,\n\tinit?: Omit<RequestInit, 'signal'>,\n): Observable<T | typeof pendingOperation | Error> {\n\treturn resolvedConfig.pipe(\n\t\tmap(\n\t\t\t({ settings, secrets }) =>\n\t\t\t\t({\n\t\t\t\t\tsettings: {\n\t\t\t\t\t\turl: settings.url,\n\t\t\t\t\t},\n\t\t\t\t\tsecrets,\n\t\t\t\t}) satisfies PickResolvedConfiguration<{\n\t\t\t\t\tsettings: 'url'\n\t\t\t\t\tsecrets: true\n\t\t\t\t}>,\n\t\t),\n\t\tdistinctUntilChanged(\n\t\t\t(a, b) => isEqualJSON(a.settings, b.settings) && a.secrets === b.secrets,\n\t\t),\n\t\tswitchMapReplayOperation((config) =>\n\t\t\tpromiseFactoryToObservable(async (signal) => {\n\t\t\t\tconst resp = await fetchFromAmpServerWithConfig(config, pathAndQuery, {\n\t\t\t\t\t...init,\n\t\t\t\t\tsignal,\n\t\t\t\t})\n\t\t\t\tif (!resp.ok) {\n\t\t\t\t\tconst text = await resp.text()\n\t\t\t\t\tif (text) {\n\t\t\t\t\t\tthrow new Error(`HTTP ${resp.status}: ${text}`)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new Error(`HTTP ${resp.status}`)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn (await resp.json()) as T\n\t\t\t}),\n\t\t),\n\t)\n}\n\n/**\n * Share a thread with the operator (i.e., the Amp team).\n */\nexport async function shareThreadWithOperator(\n\tthreadService: ThreadService,\n\tthreadID: ThreadID,\n): Promise<void> {\n\tconst thread = await firstValueFrom(threadService.observe(threadID))\n\tif (!thread) {\n\t\tthrow new Error(`Thread not found: ${threadID}`)\n\t}\n\n\ttry {\n\t\tconst resp = await internalAPIClient.shareThreadWithOperator({ threadData: thread })\n\t\tif (!resp.ok) {\n\t\t\tthrow new Error(`Failed to share thread: ${resp.error.message}`)\n\t\t}\n\t} catch (error) {\n\t\tif (FALLBACK_TO_OLD_INTERNAL_API) {\n\t\t\tconst response = await fetchFromAmpServer('/api/internal/share-thread-with-operator', {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t},\n\t\t\t\tbody: JSON.stringify({ threadData: thread } as Pick<\n\t\t\t\t\tThreadOperatorShare,\n\t\t\t\t\t'threadData'\n\t\t\t\t>),\n\t\t\t})\n\t\t\tif (!response.ok) {\n\t\t\t\tconst text = await response.text()\n\t\t\t\tthrow new Error(`Failed to share thread: ${response.status} ${text}`)\n\t\t\t}\n\t\t} else {\n\t\t\tthrow error\n\t\t}\n\t}\n}\n\n/**\n * Submit autoedit feedback to the server.\n */\nexport async function submitAutoeditFeedback(feedbackData: {\n\tfile_path: string\n\tprefix: string\n\tsuffix: string\n\tcode_to_replace_prefix: string\n\tcode_to_replace_suffix: string\n\tcontext: Array<{\n\t\tidentifier: string\n\t\tcontent: string\n\t\tfile_path: string\n\t\tstart_line?: number\n\t\tend_line?: number\n\t\tmetadata?: {\n\t\t\ttime_since_action_ms?: number\n\t\t\tretriever_metadata?: Record<string, number | string>\n\t\t}\n\t}>\n\tchosen: string\n\trejected: string\n\tassertions: string\n}): Promise<void> {\n\tconst response = await fetchFromAmpServer('/api/tab/feedback', {\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\t'Content-Type': 'application/json',\n\t\t},\n\t\tbody: JSON.stringify(feedbackData),\n\t})\n\n\tif (!response.ok) {\n\t\tconst text = await response.text()\n\t\tlet errorMessage: string\n\t\ttry {\n\t\t\tconst errorData = JSON.parse(text)\n\t\t\terrorMessage = errorData.error || `HTTP ${response.status}`\n\t\t} catch {\n\t\t\terrorMessage = text || `HTTP ${response.status}`\n\t\t}\n\t\tthrow new Error(`Failed to submit feedback: ${errorMessage}`)\n\t}\n}\n\nasync function fetchFromAmpServerWithConfig(\n\tconfig: PickResolvedConfiguration<{\n\t\tsettings: 'url'\n\t\tsecrets: true\n\t}>,\n\tpathAndQuery: string,\n\tinit?: RequestInit,\n): Promise<Response> {\n\tif (pathAndQuery.startsWith('http:') || pathAndQuery.startsWith('https:')) {\n\t\tthrow new Error('input must be a path, not an absolute URL')\n\t}\n\tif (!pathAndQuery.startsWith('/')) {\n\t\tthrow new Error('pathAndQuery must start with /')\n\t}\n\n\tconst baseURL = config.settings.url\n\tif (!baseURL) {\n\t\tthrow new Error('amp.url is not set')\n\t}\n\n\tconst apiKey = await config.secrets.getToken('apiKey', baseURL)\n\tif (!apiKey) {\n\t\tthrow new Error('Amp API key is not set')\n\t}\n\n\treturn fetch(new URL(pathAndQuery, baseURL), {\n\t\t...init,\n\t\theaders: {\n\t\t\t...init?.headers,\n\t\t\t...clientIdentificationHeaders(),\n\t\t\t'Content-Type': 'application/json',\n\t\t\tAuthorization: `Bearer ${apiKey}`,\n\t\t},\n\t})\n}\n"],"names":["FALLBACK_TO_OLD_INTERNAL_API","createInternalAPIClient","_target","method","args","options","params","resp","fetchFromAmpServer","internalAPIClient","isAmpServerConfigured","resolvedConfig","switchMap","settings","secrets","promiseFactoryToObservable","pathAndQuery","init","config","firstValueFrom","fetchFromAmpServerWithConfig","baseURL","apiKey","clientIdentificationHeaders"],"mappings":";;AAaO,MAAMA,IAAwC;AA2BrD,SAASC,IAA6C;AACrD,SAAO,IAAI;AAAA,IACV,CAAC;AAAA,IACD;AAAA,MACC,KAAK,CAACC,GAASC,MACP,UAAUC,MAAgB;AAC1B,cAAAC,IAAUD,EAAK,GAAG,CAAC,GACnBE,IAASF,EAAK,GAAG,CAAC,GAGlBG,IAAO,MAAMC,EAAmB,iBAAiB;AAAA,UACtD,QAAQ;AAAA,UACR,MAAM,KAAK,UAAU,EAAE,QAAAL,GAAQ,QAAAG,GAAQ;AAAA,UACvC,QAAQD,GAAS;AAAA,QAAA,CACjB;AAEG,YAAA,CAACE,EAAK;AACT,gBAAM,IAAI,MAAM,uBAAuBA,EAAK,MAAM,EAAE;AAG9C,eAAA,MAAMA,EAAK,KAAK;AAAA,MACxB;AAAA,IACD;AAAA,EAEF;AACD;AAKO,MAAME,IAAuCR,EAAwB,GCpD/DS,IAAwBC,EAAe;AAAA,EACnDC,EAAU,CAAC,EAAE,UAAAC,GAAU,SAAAC,QACfC,EAA2B,YAClB,MAAMD,EAAQ,SAAS,UAAUD,EAAS,GAAG,MAC1C,MAClB,CACD;AACF;AAYsB,eAAAL,EACrBQ,GACAC,GACoB;AACpB,QAAMC,IAAS,MAAMC,EAAeR,GAAgBM,GAAM,UAAU,MAAS;AACtE,SAAAG,EAA6BF,GAAQF,GAAcC,CAAI;AAC/D;AA8HA,eAAeG,EACdF,GAIAF,GACAC,GACoB;AACpB,MAAID,EAAa,WAAW,OAAO,KAAKA,EAAa,WAAW,QAAQ;AACjE,UAAA,IAAI,MAAM,2CAA2C;AAE5D,MAAI,CAACA,EAAa,WAAW,GAAG;AACzB,UAAA,IAAI,MAAM,gCAAgC;AAG3C,QAAAK,IAAUH,EAAO,SAAS;AAChC,MAAI,CAACG;AACE,UAAA,IAAI,MAAM,oBAAoB;AAGrC,QAAMC,IAAS,MAAMJ,EAAO,QAAQ,SAAS,UAAUG,CAAO;AAC9D,MAAI,CAACC;AACE,UAAA,IAAI,MAAM,wBAAwB;AAGzC,SAAO,MAAM,IAAI,IAAIN,GAAcK,CAAO,GAAG;AAAA,IAC5C,GAAGJ;AAAA,IACH,SAAS;AAAA,MACR,GAAGA,GAAM;AAAA,MACT,GAAGM,EAA4B;AAAA,MAC/B,gBAAgB;AAAA,MAChB,eAAe,UAAUD,CAAM;AAAA,IAAA;AAAA,EAChC,CACA;AACF;"}
@@ -1045,7 +1045,7 @@ COMPLEMENTARY USE WITH CODEBASE_SEARCH:
1045
1045
  },
1046
1046
  source: "builtin"
1047
1047
  },
1048
- fn: import("./node-CRrSwIMO.js").then(({ nodeGrepTool: n }) => n)
1048
+ fn: import("./node-BYuqVOkK.js").then(({ nodeGrepTool: n }) => n)
1049
1049
  };
1050
1050
  var Wc = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
1051
1051
  function ms(n) {
@@ -1952,7 +1952,7 @@ It's VERY IMPORTANT to use specific tools when searching for files, instead of i
1952
1952
  },
1953
1953
  source: "builtin"
1954
1954
  },
1955
- fn: import("./node-COZM4qQd.js").then(({ nodeBashTool: n }) => n),
1955
+ fn: import("./node-DzhEX6Qs.js").then(({ nodeBashTool: n }) => n),
1956
1956
  preprocessArgs: (n) => {
1957
1957
  if (!n.cwd)
1958
1958
  try {
@@ -2005,7 +2005,13 @@ Prefer this tool over \`edit_file\` when you want to ovewrite the entire content
2005
2005
  },
2006
2006
  source: "builtin"
2007
2007
  },
2008
- fn: import("./create_file.node-Bg2Ha2Q0.js").then(
2008
+ preprocessArgs: (n) => n.content.endsWith(`
2009
+ `) ? n : {
2010
+ ...n,
2011
+ content: n.content + `
2012
+ `
2013
+ },
2014
+ fn: import("./create_file.node-hHqtsH6T.js").then(
2009
2015
  ({ nodeCreateFileTool: n }) => n
2010
2016
  )
2011
2017
  };
@@ -4837,7 +4843,7 @@ Returns the contents of the file with each line prefixed by its line number. For
4837
4843
  switch ("node") {
4838
4844
  case "node":
4839
4845
  case "vscode":
4840
- return import("./read_file.node-DbAEjkEn.js").then(({ nodeReadFileTool: n }) => n);
4846
+ return import("./read_file.node-QXBL6A9B.js").then(({ nodeReadFileTool: n }) => n);
4841
4847
  }
4842
4848
  })()
4843
4849
  }, oB = F8({
@@ -4866,7 +4872,7 @@ If you need to replace the entire contents of a file, use \`${Yu}\` instead, sin
4866
4872
  inputSchema: j4(oB),
4867
4873
  source: "builtin"
4868
4874
  },
4869
- fn: import("./edit_file.node-BqRltvHA.js").then(({ nodeEditFileTool: n }) => n)
4875
+ fn: import("./edit_file.node-C_QnSUCA.js").then(({ nodeEditFileTool: n }) => n)
4870
4876
  };
4871
4877
  function YS(n) {
4872
4878
  return n.replace(/\\\\n/g, "\\n").replace(/\\\\t/g, "\\t").replace(/\\\\/g, "\\").replace(/\\"/g, '"').replace(/\\'/g, "'").replace(/\\n/g, `
@@ -5047,7 +5053,7 @@ Note: Results are sorted by modification time with the most recently modified fi
5047
5053
  },
5048
5054
  source: "builtin"
5049
5055
  },
5050
- fn: import("./glob.node-h1Swo4vr.js").then(({ nodeGlobTool: n }) => n)
5056
+ fn: import("./glob.node-Ca3WEmvJ.js").then(({ nodeGlobTool: n }) => n)
5051
5057
  }, Wu = "list_directory", vE = {
5052
5058
  spec: {
5053
5059
  name: Wu,
@@ -5068,7 +5074,7 @@ Note: Results are sorted by modification time with the most recently modified fi
5068
5074
  switch ("node") {
5069
5075
  case "node":
5070
5076
  case "vscode":
5071
- return import("./list_directory.node-CEUOBF5h.js").then(
5077
+ return import("./list_directory.node-B2wxSFMa.js").then(
5072
5078
  ({ nodeListDirectoryTool: n }) => n
5073
5079
  );
5074
5080
  }
@@ -5155,7 +5161,7 @@ This tool converts web content to markdown format for better readability.`,
5155
5161
  requiresNetwork: !0
5156
5162
  }
5157
5163
  },
5158
- fn: import("./node-BJyrP3Sj.js").then(({ nodeReadWebPageTool: n }) => n)
5164
+ fn: import("./node-Dm9KQUgx.js").then(({ nodeReadWebPageTool: n }) => n)
5159
5165
  }, pB = "web_search", mB = `Search the web for information.
5160
5166
 
5161
5167
  Returns search result titles, associated URLs, and a small summary of the
@@ -5203,7 +5209,7 @@ the \`${O1}\` with the url.
5203
5209
  requiresNetwork: !0
5204
5210
  }
5205
5211
  },
5206
- fn: import("./node-BtKYcfrH.js").then(({ nodeWebSearchTool: n }) => n)
5212
+ fn: import("./node-BBnb2R8E.js").then(({ nodeWebSearchTool: n }) => n)
5207
5213
  };
5208
5214
  function HN({ onlyFirst: n = !1 } = {}) {
5209
5215
  const t = [
@@ -8570,7 +8576,7 @@ function RU(n) {
8570
8576
  o.startsWith("+") && !o.startsWith("+++") && t++, o.startsWith("-") && !o.startsWith("---") && r++, o.startsWith("@") && a++;
8571
8577
  const i = n.reverted, s = n.isNewFile === !0;
8572
8578
  return s && (t = n.after.split(`
8573
- `).filter((c) => c.trim().length > 0).length, r = 0, a = 0), { added: t, removed: r, modified: a, created: s, reverted: i };
8579
+ `).length, r = 0, a = 0), { added: t, removed: r, modified: a, created: s, reverted: i };
8574
8580
  }
8575
8581
  async function NU(n) {
8576
8582
  const e = await n.listBackupFiles(), t = /* @__PURE__ */ new Map();
@@ -28404,7 +28410,7 @@ async function oV(n, e) {
28404
28410
  }
28405
28411
  }
28406
28412
  async function lV(n, e) {
28407
- return (await import("./list_directory.node-CEUOBF5h.js")).resolveArgumentDirectoryNode(n, e);
28413
+ return (await import("./list_directory.node-B2wxSFMa.js")).resolveArgumentDirectoryNode(n, e);
28408
28414
  }
28409
28415
  class cV extends vd {
28410
28416
  #e = new AbortController();
@@ -30368,7 +30374,7 @@ async function IV({
30368
30374
  fileMentions: void 0,
30369
30375
  userState: void 0
30370
30376
  };
30371
- const i = (await import("./files-yat9N0vH.js").then(
30377
+ const i = (await import("./files-DuJQGx_l.js").then(
30372
30378
  ({ getFileMentions: o }) => o(
30373
30379
  KN(t.content),
30374
30380
  a,
@@ -31510,7 +31516,7 @@ Returns a git-style diff showing the changes that were undone as formatted markd
31510
31516
  switch ("node") {
31511
31517
  case "node":
31512
31518
  case "vscode":
31513
- return import("./undo_edit.node-DL1deBcE.js").then(({ nodeUndoEditTool: n }) => n);
31519
+ return import("./undo_edit.node-CBJHZjZk.js").then(({ nodeUndoEditTool: n }) => n);
31514
31520
  }
31515
31521
  })()
31516
31522
  }, JE = globalThis.window?.document !== void 0;
@@ -75785,4 +75791,4 @@ export {
75785
75791
  NAe as y,
75786
75792
  ms as z
75787
75793
  };
75788
- //# sourceMappingURL=console-CZXURH0C.js.map
75794
+ //# sourceMappingURL=console-9ChYTAuP.js.map