@sourcegraph/amp 0.0.1749196899-g16ba82 → 0.0.1749225700-gc8788d

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 (47) hide show
  1. package/dist/amp.js +3 -3
  2. package/dist/{client-D1Pmx669.js → client-D0gbNDFf.js} +2 -2
  3. package/dist/{client-D1Pmx669.js.map → client-D0gbNDFf.js.map} +1 -1
  4. package/dist/{console-DZmALLuA.js → console-CDi5rFHv.js} +55 -44
  5. package/dist/console-CDi5rFHv.js.map +1 -0
  6. package/dist/{create_file.node-CygrebBY.js → create_file.node-DL2WuEa4.js} +2 -2
  7. package/dist/{create_file.node-CygrebBY.js.map → create_file.node-DL2WuEa4.js.map} +1 -1
  8. package/dist/{edit_file.node-D_cMkiLI.js → edit_file.node-SSEQ1h3o.js} +3 -3
  9. package/dist/{edit_file.node-D_cMkiLI.js.map → edit_file.node-SSEQ1h3o.js.map} +1 -1
  10. package/dist/{executable-C8qYZU1W.js → executable-CxioKGk7.js} +2 -2
  11. package/dist/{executable-C8qYZU1W.js.map → executable-CxioKGk7.js.map} +1 -1
  12. package/dist/{files--h2VjD8F.js → files-BQmddBey.js} +2 -2
  13. package/dist/{files--h2VjD8F.js.map → files-BQmddBey.js.map} +1 -1
  14. package/dist/fuzzy-server.js +116 -113
  15. package/dist/fuzzy-server.js.map +1 -1
  16. package/dist/{glob.node-AB34HaNl.js → glob.node-C8xrYICA.js} +4 -4
  17. package/dist/{glob.node-AB34HaNl.js.map → glob.node-C8xrYICA.js.map} +1 -1
  18. package/dist/{index-nQBDDlvh.js → index-BY5vhogw.js} +2 -2
  19. package/dist/{index-nQBDDlvh.js.map → index-BY5vhogw.js.map} +1 -1
  20. package/dist/{list_directory.node-DZamBwOx.js → list_directory.node-p_ArdqyT.js} +2 -2
  21. package/dist/{list_directory.node-DZamBwOx.js.map → list_directory.node-p_ArdqyT.js.map} +1 -1
  22. package/dist/{load-profile-DzDzDOIq.js → load-profile-DxrviVkC.js} +2 -2
  23. package/dist/{load-profile-DzDzDOIq.js.map → load-profile-DxrviVkC.js.map} +1 -1
  24. package/dist/{main-WXbdYG4Z.js → main-DIn8dJ9L.js} +409 -398
  25. package/dist/{main-WXbdYG4Z.js.map → main-DIn8dJ9L.js.map} +1 -1
  26. package/dist/{node-CBRPqFin.js → node-C9D1REPh.js} +374 -320
  27. package/dist/node-C9D1REPh.js.map +1 -0
  28. package/dist/{node-D2Ho0W-v.js → node-CHCdepF2.js} +3 -3
  29. package/dist/{node-D2Ho0W-v.js.map → node-CHCdepF2.js.map} +1 -1
  30. package/dist/{node-B9XNCq_w.js → node-CU0lZEVr.js} +2 -2
  31. package/dist/{node-B9XNCq_w.js.map → node-CU0lZEVr.js.map} +1 -1
  32. package/dist/{node-CUCcBUhU.js → node-CrPwEb6e.js} +4 -4
  33. package/dist/{node-CUCcBUhU.js.map → node-CrPwEb6e.js.map} +1 -1
  34. package/dist/{node-Cs3K2AKs.js → node-D-xGtMhE.js} +3 -3
  35. package/dist/{node-Cs3K2AKs.js.map → node-D-xGtMhE.js.map} +1 -1
  36. package/dist/{node-SvjAOtkw.js → node-DQLcKPbG.js} +2 -2
  37. package/dist/{node-SvjAOtkw.js.map → node-DQLcKPbG.js.map} +1 -1
  38. package/dist/{read_file.node-CveQp78z.js → read_file.node-DTbjOJwN.js} +2 -2
  39. package/dist/{read_file.node-CveQp78z.js.map → read_file.node-DTbjOJwN.js.map} +1 -1
  40. package/dist/{stdio-CRvROLK4.js → stdio-DuUbi3RX.js} +3 -3
  41. package/dist/{stdio-CRvROLK4.js.map → stdio-DuUbi3RX.js.map} +1 -1
  42. package/dist/storybook.js +1 -1
  43. package/dist/{undo_edit.node-C3I02TEE.js → undo_edit.node-qujh3sgI.js} +2 -2
  44. package/dist/{undo_edit.node-C3I02TEE.js.map → undo_edit.node-qujh3sgI.js.map} +1 -1
  45. package/package.json +1 -1
  46. package/dist/console-DZmALLuA.js.map +0 -1
  47. package/dist/node-CBRPqFin.js.map +0 -1
package/dist/amp.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import "./console-DZmALLuA.js";
3
- import "./main-WXbdYG4Z.js";
2
+ import "./console-CDi5rFHv.js";
3
+ import "./main-DIn8dJ9L.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-D1Pmx669.js";
8
+ import "./client-D0gbNDFf.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, aS as c, s as p, p as u } from "./console-DZmALLuA.js";
2
+ import { f as i, E as o, aS as c, s as p, p as u } from "./console-CDi5rFHv.js";
3
3
  const m = !0;
4
4
  function f() {
5
5
  return new Proxy(
@@ -54,4 +54,4 @@ export {
54
54
  h as f,
55
55
  y as i
56
56
  };
57
- //# sourceMappingURL=client-D1Pmx669.js.map
57
+ //# sourceMappingURL=client-D0gbNDFf.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-D1Pmx669.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\n\tif (!apiKey || apiKey.trim() === '') {\n\t\tconst error = new Error('Amp API key is not set')\n\t\terror.name = 'MissingApiKeyError'\n\t\tthrow error\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","error","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;AAE9D,MAAI,CAACC,KAAUA,EAAO,KAAA,MAAW,IAAI;AAC9B,UAAAC,IAAQ,IAAI,MAAM,wBAAwB;AAChD,UAAAA,EAAM,OAAO,sBACPA;AAAA,EAAA;AAGP,SAAO,MAAM,IAAI,IAAIP,GAAcK,CAAO,GAAG;AAAA,IAC5C,GAAGJ;AAAA,IACH,SAAS;AAAA,MACR,GAAGA,GAAM;AAAA,MACT,GAAGO,EAA4B;AAAA,MAC/B,gBAAgB;AAAA,MAChB,eAAe,UAAUF,CAAM;AAAA,IAAA;AAAA,EAChC,CACA;AACF;"}
1
+ {"version":3,"file":"client-D0gbNDFf.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\n\tif (!apiKey || apiKey.trim() === '') {\n\t\tconst error = new Error('Amp API key is not set')\n\t\terror.name = 'MissingApiKeyError'\n\t\tthrow error\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","error","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;AAE9D,MAAI,CAACC,KAAUA,EAAO,KAAA,MAAW,IAAI;AAC9B,UAAAC,IAAQ,IAAI,MAAM,wBAAwB;AAChD,UAAAA,EAAM,OAAO,sBACPA;AAAA,EAAA;AAGP,SAAO,MAAM,IAAI,IAAIP,GAAcK,CAAO,GAAG;AAAA,IAC5C,GAAGJ;AAAA,IACH,SAAS;AAAA,MACR,GAAGA,GAAM;AAAA,MACT,GAAGO,EAA4B;AAAA,MAC/B,gBAAgB;AAAA,MAChB,eAAe,UAAUF,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-CUCcBUhU.js").then(({ nodeGrepTool: n }) => n)
1048
+ fn: import("./node-CrPwEb6e.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-CBRPqFin.js").then(({ nodeBashTool: n }) => n),
1955
+ fn: import("./node-C9D1REPh.js").then(({ nodeBashTool: n }) => n),
1956
1956
  preprocessArgs: (n) => {
1957
1957
  if (!n.cwd)
1958
1958
  try {
@@ -2011,7 +2011,7 @@ Prefer this tool over \`edit_file\` when you want to ovewrite the entire content
2011
2011
  content: n.content + `
2012
2012
  `
2013
2013
  },
2014
- fn: import("./create_file.node-CygrebBY.js").then(
2014
+ fn: import("./create_file.node-DL2WuEa4.js").then(
2015
2015
  ({ nodeCreateFileTool: n }) => n
2016
2016
  )
2017
2017
  };
@@ -4843,7 +4843,7 @@ Returns the contents of the file with each line prefixed by its line number. For
4843
4843
  switch ("node") {
4844
4844
  case "node":
4845
4845
  case "vscode":
4846
- return import("./read_file.node-CveQp78z.js").then(({ nodeReadFileTool: n }) => n);
4846
+ return import("./read_file.node-DTbjOJwN.js").then(({ nodeReadFileTool: n }) => n);
4847
4847
  }
4848
4848
  })()
4849
4849
  }, oB = F8({
@@ -4872,7 +4872,7 @@ If you need to replace the entire contents of a file, use \`${Yu}\` instead, sin
4872
4872
  inputSchema: j4(oB),
4873
4873
  source: "builtin"
4874
4874
  },
4875
- fn: import("./edit_file.node-D_cMkiLI.js").then(({ nodeEditFileTool: n }) => n)
4875
+ fn: import("./edit_file.node-SSEQ1h3o.js").then(({ nodeEditFileTool: n }) => n)
4876
4876
  };
4877
4877
  function $S(n) {
4878
4878
  return n.replace(/\\\\n/g, "\\n").replace(/\\\\t/g, "\\t").replace(/\\\\/g, "\\").replace(/\\"/g, '"').replace(/\\'/g, "'").replace(/\\n/g, `
@@ -5053,7 +5053,7 @@ Note: Results are sorted by modification time with the most recently modified fi
5053
5053
  },
5054
5054
  source: "builtin"
5055
5055
  },
5056
- fn: import("./glob.node-AB34HaNl.js").then(({ nodeGlobTool: n }) => n)
5056
+ fn: import("./glob.node-C8xrYICA.js").then(({ nodeGlobTool: n }) => n)
5057
5057
  }, Wu = "list_directory", RE = {
5058
5058
  spec: {
5059
5059
  name: Wu,
@@ -5074,7 +5074,7 @@ Note: Results are sorted by modification time with the most recently modified fi
5074
5074
  switch ("node") {
5075
5075
  case "node":
5076
5076
  case "vscode":
5077
- return import("./list_directory.node-DZamBwOx.js").then(
5077
+ return import("./list_directory.node-p_ArdqyT.js").then(
5078
5078
  ({ nodeListDirectoryTool: n }) => n
5079
5079
  );
5080
5080
  }
@@ -5161,7 +5161,7 @@ This tool converts web content to markdown format for better readability.`,
5161
5161
  requiresNetwork: !0
5162
5162
  }
5163
5163
  },
5164
- fn: import("./node-B9XNCq_w.js").then(({ nodeReadWebPageTool: n }) => n)
5164
+ fn: import("./node-CU0lZEVr.js").then(({ nodeReadWebPageTool: n }) => n)
5165
5165
  }, pB = "web_search", mB = `Search the web for information.
5166
5166
 
5167
5167
  Returns search result titles, associated URLs, and a small summary of the
@@ -5209,7 +5209,7 @@ the \`${k1}\` with the url.
5209
5209
  requiresNetwork: !0
5210
5210
  }
5211
5211
  },
5212
- fn: import("./node-D2Ho0W-v.js").then(({ nodeWebSearchTool: n }) => n)
5212
+ fn: import("./node-CHCdepF2.js").then(({ nodeWebSearchTool: n }) => n)
5213
5213
  };
5214
5214
  function $N({ onlyFirst: n = !1 } = {}) {
5215
5215
  const t = [
@@ -9008,22 +9008,22 @@ function zU(n) {
9008
9008
  }
9009
9009
  }
9010
9010
  const uo = "claude-sonnet-4-20250514", GU = uo, qU = 32e3, Lw = 32e3, YU = 2e5 - qU, F1 = 2e5 - Lw, HU = 8e3, $U = 8e3, VU = 4e3;
9011
- async function* WU(n, e, t, r, a) {
9012
- const i = await Zn(di, a);
9011
+ async function* WU(n, e, t, r, a, i) {
9012
+ const s = await Zn(di, a);
9013
9013
  a?.throwIfAborted();
9014
- const s = await Pd(i, { threadID: r });
9014
+ const o = await Pd(s, { threadID: r });
9015
9015
  a?.throwIfAborted();
9016
- const o = uo, c = Lw;
9016
+ const c = uo, u = i ?? Lw;
9017
9017
  t = [
9018
9018
  ...t,
9019
9019
  {
9020
9020
  type: "text",
9021
- text: `You are using Anthropic's ${o} model, but don't mention this unless asked about your model.`
9021
+ text: `You are using Anthropic's ${c} model, but don't mention this unless asked about your model.`
9022
9022
  }
9023
9023
  ];
9024
- const u = {
9025
- model: o,
9026
- max_tokens: c,
9024
+ const _ = {
9025
+ model: c,
9026
+ max_tokens: u,
9027
9027
  messages: Pw(n),
9028
9028
  system: t,
9029
9029
  tools: Bw(e),
@@ -9035,38 +9035,38 @@ async function* WU(n, e, t, r, a) {
9035
9035
  // betas: ['token-efficient-tools-2025-02-19'],
9036
9036
  // }
9037
9037
  // : {}),
9038
- }, _ = i.settings["anthropic.thinking.enabled"] ?? !0;
9039
- _ && (u.thinking = {
9038
+ }, g = s.settings["anthropic.thinking.enabled"] ?? !0;
9039
+ g && (_.thinking = {
9040
9040
  type: "enabled",
9041
9041
  budget_tokens: VU
9042
9042
  });
9043
- const g = i.settings["anthropic.temperature"];
9044
- g !== void 0 && !_ && (u.temperature = g);
9045
- const p = s.messages.stream(u, { signal: a });
9043
+ const p = s.settings["anthropic.temperature"];
9044
+ p !== void 0 && !g && (_.temperature = p);
9045
+ const f = o.messages.stream(_, { signal: a });
9046
9046
  try {
9047
- yield* p;
9048
- } catch (S) {
9049
- throw S instanceof sa ? new DOMException("Aborted", "AbortError") : S;
9047
+ yield* f;
9048
+ } catch (b) {
9049
+ throw b instanceof sa ? new DOMException("Aborted", "AbortError") : b;
9050
9050
  }
9051
- let f;
9051
+ let S;
9052
9052
  try {
9053
- f = await p.finalMessage();
9054
- } catch (S) {
9055
- if (S instanceof Li.AnthropicError && S.message.includes("without producing a Message"))
9056
- f = void 0;
9053
+ S = await f.finalMessage();
9054
+ } catch (b) {
9055
+ if (b instanceof Li.AnthropicError && b.message.includes("without producing a Message"))
9056
+ S = void 0;
9057
9057
  else
9058
- throw S;
9058
+ throw b;
9059
9059
  }
9060
9060
  return {
9061
- message: f,
9062
- "~debugParamsUsed": u,
9063
- "~debugUsage": f ? {
9061
+ message: S,
9062
+ "~debugParamsUsed": _,
9063
+ "~debugUsage": S ? {
9064
9064
  maxInputTokens: F1,
9065
- inputTokens: f.usage.input_tokens,
9066
- outputTokens: f.usage.output_tokens,
9067
- cacheCreationInputTokens: f.usage.cache_creation_input_tokens,
9068
- cacheReadInputTokens: f.usage.cache_read_input_tokens,
9069
- totalInputTokens: f.usage.input_tokens + (f.usage.cache_creation_input_tokens ?? 0) + (f.usage.cache_read_input_tokens ?? 0)
9065
+ inputTokens: S.usage.input_tokens,
9066
+ outputTokens: S.usage.output_tokens,
9067
+ cacheCreationInputTokens: S.usage.cache_creation_input_tokens,
9068
+ cacheReadInputTokens: S.usage.cache_read_input_tokens,
9069
+ totalInputTokens: S.usage.input_tokens + (S.usage.cache_creation_input_tokens ?? 0) + (S.usage.cache_read_input_tokens ?? 0)
9070
9070
  } : {
9071
9071
  maxInputTokens: F1,
9072
9072
  inputTokens: 0,
@@ -28427,7 +28427,7 @@ async function lV(n, e) {
28427
28427
  }
28428
28428
  }
28429
28429
  async function cV(n, e) {
28430
- return (await import("./list_directory.node-DZamBwOx.js")).resolveArgumentDirectoryNode(n, e);
28430
+ return (await import("./list_directory.node-p_ArdqyT.js")).resolveArgumentDirectoryNode(n, e);
28431
28431
  }
28432
28432
  class uV extends vd {
28433
28433
  #e = new AbortController();
@@ -30128,6 +30128,10 @@ function CV(n, e) {
30128
30128
  t.title = e.value || void 0;
30129
30129
  break;
30130
30130
  }
30131
+ case "max-tokens": {
30132
+ t.maxTokens = e.value || void 0;
30133
+ break;
30134
+ }
30131
30135
  case "main-thread": {
30132
30136
  t.mainThreadID = e.value || void 0;
30133
30137
  break;
@@ -30415,7 +30419,7 @@ async function OV({
30415
30419
  fileMentions: void 0,
30416
30420
  userState: void 0
30417
30421
  };
30418
- const i = (await import("./files--h2VjD8F.js").then(
30422
+ const i = (await import("./files-BQmddBey.js").then(
30419
30423
  ({ getFileMentions: o }) => o(
30420
30424
  QN(t.content),
30421
30425
  a,
@@ -31101,7 +31105,14 @@ class Al {
31101
31105
  }
31102
31106
  }
31103
31107
  async runInference(e, t) {
31104
- const { messages: r, tools: a, systemPrompt: i } = await this.getInferenceParameters(e, t), s = WU(r, a, i, e.id, t);
31108
+ const { messages: r, tools: a, systemPrompt: i } = await this.getInferenceParameters(e, t), s = WU(
31109
+ r,
31110
+ a,
31111
+ i,
31112
+ e.id,
31113
+ t,
31114
+ e.maxTokens
31115
+ );
31105
31116
  return t?.throwIfAborted(), s;
31106
31117
  }
31107
31118
  async getInferenceParameters(e, t) {
@@ -31559,7 +31570,7 @@ Returns a git-style diff showing the changes that were undone as formatted markd
31559
31570
  switch ("node") {
31560
31571
  case "node":
31561
31572
  case "vscode":
31562
- return import("./undo_edit.node-C3I02TEE.js").then(({ nodeUndoEditTool: n }) => n);
31573
+ return import("./undo_edit.node-qujh3sgI.js").then(({ nodeUndoEditTool: n }) => n);
31563
31574
  }
31564
31575
  })()
31565
31576
  }, ey = globalThis.window?.document !== void 0;
@@ -75884,4 +75895,4 @@ export {
75884
75895
  IAe as y,
75885
75896
  ms as z
75886
75897
  };
75887
- //# sourceMappingURL=console-DZmALLuA.js.map
75898
+ //# sourceMappingURL=console-CDi5rFHv.js.map