@agent-native/core 0.167.4 → 0.168.0

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/corpus/README.md +1 -1
  2. package/corpus/templates/brain/actions/list-sources.ts +17 -7
  3. package/corpus/templates/brain/app/components/brain/Surface.tsx +4 -2
  4. package/corpus/templates/brain/app/lib/brain.ts +13 -3
  5. package/corpus/templates/brain/server/lib/brain-health.ts +5 -8
  6. package/corpus/templates/brain/server/lib/brain.ts +1 -0
  7. package/corpus/templates/brain/server/lib/capture-sanitization.ts +5 -0
  8. package/corpus/templates/brain/server/routes/api/brain/queue/run.post.ts +3 -2
  9. package/corpus/templates/clips/desktop/src/app.tsx +11 -10
  10. package/corpus/templates/clips/desktop/src/lib/desktop-oauth-window.ts +23 -0
  11. package/dist/client/AboutAgentNativeDialog.d.ts +5 -0
  12. package/dist/client/AboutAgentNativeDialog.js +56 -0
  13. package/dist/client/CommandMenu.d.ts +6 -1
  14. package/dist/client/CommandMenu.js +46 -3
  15. package/dist/client/EnvironmentBadge.js +4 -1
  16. package/dist/client/agent-native-version.d.ts +12 -0
  17. package/dist/client/agent-native-version.js +36 -0
  18. package/dist/collab/awareness.d.ts +2 -2
  19. package/dist/collab/routes.d.ts +1 -1
  20. package/dist/collab/struct-routes.d.ts +1 -1
  21. package/dist/config.d.ts +3 -1
  22. package/dist/config.js +14 -9
  23. package/dist/localization/core-messages/ar-SA.js +6 -0
  24. package/dist/localization/core-messages/de-DE.js +6 -0
  25. package/dist/localization/core-messages/en-US.d.ts +6 -0
  26. package/dist/localization/core-messages/en-US.js +6 -0
  27. package/dist/localization/core-messages/es-ES.js +6 -0
  28. package/dist/localization/core-messages/fr-FR.js +6 -0
  29. package/dist/localization/core-messages/hi-IN.js +6 -0
  30. package/dist/localization/core-messages/ja-JP.js +6 -0
  31. package/dist/localization/core-messages/ko-KR.js +6 -0
  32. package/dist/localization/core-messages/pt-BR.js +6 -0
  33. package/dist/localization/core-messages/zh-CN.js +6 -0
  34. package/dist/localization/core-messages/zh-TW.js +6 -0
  35. package/dist/localization/core-messages.d.ts +6 -0
  36. package/dist/notifications/routes.d.ts +3 -3
  37. package/dist/provider-api/actions/custom-provider-registration.d.ts +4 -4
  38. package/dist/provider-api/actions/provider-api.d.ts +8 -8
  39. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  40. package/dist/resources/handlers.d.ts +2 -2
  41. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  42. package/dist/vite/agent-native-config-loader.js +1 -1
  43. package/dist/vite/client.js +9 -8
  44. package/dist/vite/package-versions.d.ts +1 -0
  45. package/dist/vite/package-versions.js +97 -0
  46. package/docs/content/agent-native-config.mdx +55 -31
  47. package/docs/content/environment-variables.mdx +51 -14
  48. package/package.json +1 -1
package/dist/config.js CHANGED
@@ -315,7 +315,8 @@ export function normalizeAgentNativeConfig(input, source = "agent-native config"
315
315
  }
316
316
  return normalized;
317
317
  }
318
- export function mergeAgentNativeConfigs(base, override) {
318
+ export function mergeAgentNativeConfigs(base, override, options = {}) {
319
+ const arrayStrategy = options.arrayStrategy ?? "merge";
319
320
  return {
320
321
  ...(base.version === undefined && override.version === undefined
321
322
  ? {}
@@ -348,7 +349,7 @@ export function mergeAgentNativeConfigs(base, override) {
348
349
  ? {
349
350
  ...base.runtime?.environment,
350
351
  ...override.runtime?.environment,
351
- required: mergeStringLists(base.runtime?.environment?.required, override.runtime?.environment?.required),
352
+ required: mergeStringLists(base.runtime?.environment?.required, override.runtime?.environment?.required, arrayStrategy),
352
353
  }
353
354
  : undefined,
354
355
  }
@@ -390,7 +391,7 @@ export function mergeAgentNativeConfigs(base, override) {
390
391
  ...override.changelog,
391
392
  }
392
393
  : undefined,
393
- harness: mergeHarnessSettings(base.harness, override.harness),
394
+ harness: mergeHarnessSettings(base.harness, override.harness, arrayStrategy),
394
395
  };
395
396
  }
396
397
  export function resolveAgentNativeConfig(input, context) {
@@ -551,7 +552,7 @@ function normalizeHarnessConfig(value, source) {
551
552
  : { runtimes: [...new Set(runtimes)] }),
552
553
  };
553
554
  }
554
- function mergeHarnessSettings(base, override) {
555
+ function mergeHarnessSettings(base, override, arrayStrategy = "merge") {
555
556
  if (override === undefined)
556
557
  return base;
557
558
  if (typeof override === "boolean")
@@ -563,10 +564,12 @@ function mergeHarnessSettings(base, override) {
563
564
  }
564
565
  return {
565
566
  runtimes: [
566
- ...new Set([
567
- ...(base.runtimes ?? []),
568
- ...(override.runtimes ?? []),
569
- ]),
567
+ ...(arrayStrategy === "replace"
568
+ ? (override.runtimes ?? base.runtimes ?? [])
569
+ : new Set([
570
+ ...(base.runtimes ?? []),
571
+ ...(override.runtimes ?? []),
572
+ ])),
570
573
  ],
571
574
  };
572
575
  }
@@ -592,9 +595,11 @@ function normalizeRequiredEnvKeys(value, source) {
592
595
  }
593
596
  return [...new Set(keys)];
594
597
  }
595
- function mergeStringLists(base, override) {
598
+ function mergeStringLists(base, override, arrayStrategy = "merge") {
596
599
  if (base === undefined && override === undefined)
597
600
  return undefined;
601
+ if (arrayStrategy === "replace")
602
+ return override ?? base;
598
603
  return [...new Set([...(base ?? []), ...(override ?? [])])];
599
604
  }
600
605
  function isFirstRunMode(value) {
@@ -24,6 +24,12 @@ const messages = {
24
24
  "commands.mention": "الإشارة إلى ملفات أو وكلاء أو موارد",
25
25
  "commands.new": "مثل /clear",
26
26
  "commands.plan": "التبديل إلى التخطيط للقراءة فقط",
27
+ "aboutAgentNative.title": "حول Agent Native",
28
+ "aboutAgentNative.version": "الإصدار",
29
+ "aboutAgentNative.environment": "البيئة",
30
+ "aboutAgentNative.build": "البنية",
31
+ "aboutAgentNative.copyDiagnostics": "نسخ بيانات التشخيص",
32
+ "aboutAgentNative.unknown": "غير معروف",
27
33
  "common.agent": "الوكيل",
28
34
  "common.cancel": "إلغاء",
29
35
  "common.collapse": "طي",
@@ -24,6 +24,12 @@ const messages = {
24
24
  "commands.mention": "Dateien, Agenten oder Ressourcen erwähnen",
25
25
  "commands.new": "Entspricht /clear",
26
26
  "commands.plan": "Zum schreibgeschützten Planungsmodus wechseln",
27
+ "aboutAgentNative.title": "Über Agent Native",
28
+ "aboutAgentNative.version": "Version",
29
+ "aboutAgentNative.environment": "Umgebung",
30
+ "aboutAgentNative.build": "Build",
31
+ "aboutAgentNative.copyDiagnostics": "Diagnosedaten kopieren",
32
+ "aboutAgentNative.unknown": "Unbekannt",
27
33
  "common.agent": "Agent",
28
34
  "common.cancel": "Abbrechen",
29
35
  "common.collapse": "Einklappen",
@@ -24,6 +24,12 @@ declare const messages: {
24
24
  readonly "commands.mention": "Mention files, agents, or resources";
25
25
  readonly "commands.new": "Same as /clear";
26
26
  readonly "commands.plan": "Switch to read-only planning";
27
+ readonly "aboutAgentNative.title": "About Agent Native";
28
+ readonly "aboutAgentNative.version": "Version";
29
+ readonly "aboutAgentNative.environment": "Environment";
30
+ readonly "aboutAgentNative.build": "Build";
31
+ readonly "aboutAgentNative.copyDiagnostics": "Copy diagnostics";
32
+ readonly "aboutAgentNative.unknown": "Unknown";
27
33
  readonly "common.agent": "Agent";
28
34
  readonly "common.cancel": "Cancel";
29
35
  readonly "common.collapse": "Collapse";
@@ -24,6 +24,12 @@ const messages = {
24
24
  "commands.mention": "Mention files, agents, or resources",
25
25
  "commands.new": "Same as /clear",
26
26
  "commands.plan": "Switch to read-only planning",
27
+ "aboutAgentNative.title": "About Agent Native",
28
+ "aboutAgentNative.version": "Version",
29
+ "aboutAgentNative.environment": "Environment",
30
+ "aboutAgentNative.build": "Build",
31
+ "aboutAgentNative.copyDiagnostics": "Copy diagnostics",
32
+ "aboutAgentNative.unknown": "Unknown",
27
33
  "common.agent": "Agent",
28
34
  "common.cancel": "Cancel",
29
35
  "common.collapse": "Collapse",
@@ -24,6 +24,12 @@ const messages = {
24
24
  "commands.mention": "Mencionar archivos, agentes o recursos",
25
25
  "commands.new": "Igual que /clear",
26
26
  "commands.plan": "Cambiar a la planificación de solo lectura",
27
+ "aboutAgentNative.title": "Acerca de Agent Native",
28
+ "aboutAgentNative.version": "Versión",
29
+ "aboutAgentNative.environment": "Entorno",
30
+ "aboutAgentNative.build": "Compilación",
31
+ "aboutAgentNative.copyDiagnostics": "Copiar diagnóstico",
32
+ "aboutAgentNative.unknown": "Desconocida",
27
33
  "common.agent": "Agente",
28
34
  "common.cancel": "Cancelar",
29
35
  "common.collapse": "Contraer",
@@ -24,6 +24,12 @@ const messages = {
24
24
  "commands.mention": "Mentionner des fichiers, des agents ou des ressources",
25
25
  "commands.new": "Identique à /clear",
26
26
  "commands.plan": "Passer à la planification en lecture seule",
27
+ "aboutAgentNative.title": "À propos d’Agent Native",
28
+ "aboutAgentNative.version": "Version",
29
+ "aboutAgentNative.environment": "Environnement",
30
+ "aboutAgentNative.build": "Build",
31
+ "aboutAgentNative.copyDiagnostics": "Copier les diagnostics",
32
+ "aboutAgentNative.unknown": "Inconnue",
27
33
  "common.agent": "Agent",
28
34
  "common.cancel": "Annuler",
29
35
  "common.collapse": "Réduire",
@@ -24,6 +24,12 @@ const messages = {
24
24
  "commands.mention": "फ़ाइलों, एजेंटों या संसाधनों का उल्लेख करें",
25
25
  "commands.new": "/clear के समान",
26
26
  "commands.plan": "केवल-पढ़ने योग्य योजना मोड पर जाएँ",
27
+ "aboutAgentNative.title": "Agent Native के बारे में",
28
+ "aboutAgentNative.version": "संस्करण",
29
+ "aboutAgentNative.environment": "पर्यावरण",
30
+ "aboutAgentNative.build": "बिल्ड",
31
+ "aboutAgentNative.copyDiagnostics": "डायग्नोस्टिक कॉपी करें",
32
+ "aboutAgentNative.unknown": "अज्ञात",
27
33
  "common.agent": "एजेंट",
28
34
  "common.cancel": "रद्द करें",
29
35
  "common.collapse": "समेटें",
@@ -24,6 +24,12 @@ const messages = {
24
24
  "commands.mention": "ファイル、エージェント、リソースをメンション",
25
25
  "commands.new": "/clear と同じ",
26
26
  "commands.plan": "読み取り専用の計画モードに切り替え",
27
+ "aboutAgentNative.title": "Agent Native について",
28
+ "aboutAgentNative.version": "バージョン",
29
+ "aboutAgentNative.environment": "環境",
30
+ "aboutAgentNative.build": "ビルド",
31
+ "aboutAgentNative.copyDiagnostics": "診断情報をコピー",
32
+ "aboutAgentNative.unknown": "不明",
27
33
  "common.agent": "エージェント",
28
34
  "common.cancel": "キャンセル",
29
35
  "common.collapse": "折りたたむ",
@@ -24,6 +24,12 @@ const messages = {
24
24
  "commands.mention": "파일, 에이전트 또는 리소스 멘션",
25
25
  "commands.new": "/clear와 동일",
26
26
  "commands.plan": "읽기 전용 계획 모드로 전환",
27
+ "aboutAgentNative.title": "Agent Native 정보",
28
+ "aboutAgentNative.version": "버전",
29
+ "aboutAgentNative.environment": "환경",
30
+ "aboutAgentNative.build": "빌드",
31
+ "aboutAgentNative.copyDiagnostics": "진단 정보 복사",
32
+ "aboutAgentNative.unknown": "알 수 없음",
27
33
  "common.agent": "에이전트",
28
34
  "common.cancel": "취소",
29
35
  "common.collapse": "접기",
@@ -24,6 +24,12 @@ const messages = {
24
24
  "commands.mention": "Mencionar arquivos, agentes ou recursos",
25
25
  "commands.new": "O mesmo que /clear",
26
26
  "commands.plan": "Mudar para o planejamento somente leitura",
27
+ "aboutAgentNative.title": "Sobre o Agent Native",
28
+ "aboutAgentNative.version": "Versão",
29
+ "aboutAgentNative.environment": "Ambiente",
30
+ "aboutAgentNative.build": "Build",
31
+ "aboutAgentNative.copyDiagnostics": "Copiar diagnósticos",
32
+ "aboutAgentNative.unknown": "Desconhecida",
27
33
  "common.agent": "Agente",
28
34
  "common.cancel": "Cancelar",
29
35
  "common.collapse": "Recolher",
@@ -24,6 +24,12 @@ const messages = {
24
24
  "commands.mention": "提及文件、智能体或资源",
25
25
  "commands.new": "与 /clear 相同",
26
26
  "commands.plan": "切换到只读规划模式",
27
+ "aboutAgentNative.title": "关于 Agent Native",
28
+ "aboutAgentNative.version": "版本",
29
+ "aboutAgentNative.environment": "环境",
30
+ "aboutAgentNative.build": "构建",
31
+ "aboutAgentNative.copyDiagnostics": "复制诊断信息",
32
+ "aboutAgentNative.unknown": "未知",
27
33
  "common.agent": "智能体",
28
34
  "common.cancel": "取消",
29
35
  "common.collapse": "收起",
@@ -24,6 +24,12 @@ const messages = {
24
24
  "commands.mention": "提及檔案、代理或資源",
25
25
  "commands.new": "與 /clear 相同",
26
26
  "commands.plan": "切換到唯讀規劃模式",
27
+ "aboutAgentNative.title": "關於 Agent Native",
28
+ "aboutAgentNative.version": "版本",
29
+ "aboutAgentNative.environment": "環境",
30
+ "aboutAgentNative.build": "建置",
31
+ "aboutAgentNative.copyDiagnostics": "複製診斷資訊",
32
+ "aboutAgentNative.unknown": "未知",
27
33
  "common.agent": "代理",
28
34
  "common.cancel": "取消",
29
35
  "common.collapse": "收合",
@@ -26,6 +26,12 @@ export declare const englishAgentChatMessages: {
26
26
  readonly "commands.mention": "Mention files, agents, or resources";
27
27
  readonly "commands.new": "Same as /clear";
28
28
  readonly "commands.plan": "Switch to read-only planning";
29
+ readonly "aboutAgentNative.title": "About Agent Native";
30
+ readonly "aboutAgentNative.version": "Version";
31
+ readonly "aboutAgentNative.environment": "Environment";
32
+ readonly "aboutAgentNative.build": "Build";
33
+ readonly "aboutAgentNative.copyDiagnostics": "Copy diagnostics";
34
+ readonly "aboutAgentNative.unknown": "Unknown";
29
35
  readonly "common.agent": "Agent";
30
36
  readonly "common.cancel": "Cancel";
31
37
  readonly "common.collapse": "Collapse";
@@ -11,14 +11,14 @@
11
11
  * DELETE /_agent-native/notifications/:id — delete
12
12
  */
13
13
  export declare function createNotificationsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<"" | import("./types.js").Notification[] | {
14
- error?: undefined;
15
14
  count: number;
16
15
  updated?: undefined;
16
+ error?: undefined;
17
17
  ok?: undefined;
18
18
  } | {
19
- error?: undefined;
20
19
  count?: undefined;
21
20
  updated: number;
21
+ error?: undefined;
22
22
  ok?: undefined;
23
23
  } | {
24
24
  count?: undefined;
@@ -26,8 +26,8 @@ export declare function createNotificationsHandler(): import("h3").EventHandlerW
26
26
  error: string;
27
27
  ok?: undefined;
28
28
  } | {
29
- error?: undefined;
30
29
  count?: undefined;
31
30
  updated?: undefined;
32
31
  ok: boolean;
32
+ error?: undefined;
33
33
  }>>;
@@ -93,29 +93,29 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
93
93
  label?: undefined;
94
94
  message?: undefined;
95
95
  } | {
96
+ count?: undefined;
96
97
  id?: undefined;
97
98
  deleted?: undefined;
98
99
  providers?: undefined;
99
- count?: undefined;
100
100
  found: boolean;
101
101
  provider: import("../custom-registry.js").CustomProviderConfig;
102
102
  registered?: undefined;
103
103
  label?: undefined;
104
104
  message?: undefined;
105
105
  } | {
106
+ count?: undefined;
106
107
  provider?: undefined;
107
108
  deleted?: undefined;
108
109
  providers?: undefined;
109
- count?: undefined;
110
110
  found: boolean;
111
111
  id: string;
112
112
  registered?: undefined;
113
113
  label?: undefined;
114
114
  message?: undefined;
115
115
  } | {
116
+ count?: undefined;
116
117
  provider?: undefined;
117
118
  providers?: undefined;
118
- count?: undefined;
119
119
  found?: undefined;
120
120
  deleted: boolean;
121
121
  id: string;
@@ -123,10 +123,10 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
123
123
  label?: undefined;
124
124
  message?: undefined;
125
125
  } | {
126
+ count?: undefined;
126
127
  provider?: undefined;
127
128
  deleted?: undefined;
128
129
  providers?: undefined;
129
- count?: undefined;
130
130
  found?: undefined;
131
131
  registered: boolean;
132
132
  id: string;
@@ -313,7 +313,6 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
313
313
  }, {
314
314
  id?: undefined;
315
315
  provider?: undefined;
316
- deleted?: undefined;
317
316
  providers: {
318
317
  id: string;
319
318
  label: string;
@@ -325,33 +324,34 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
325
324
  }[];
326
325
  count: number;
327
326
  found?: undefined;
327
+ deleted?: undefined;
328
328
  registered?: undefined;
329
329
  label?: undefined;
330
330
  message?: undefined;
331
331
  } | {
332
- count?: undefined;
333
332
  id?: undefined;
334
- deleted?: undefined;
335
333
  providers?: undefined;
334
+ count?: undefined;
336
335
  found: boolean;
337
336
  provider: import("../custom-registry.js").CustomProviderConfig;
337
+ deleted?: undefined;
338
338
  registered?: undefined;
339
339
  label?: undefined;
340
340
  message?: undefined;
341
341
  } | {
342
- count?: undefined;
343
342
  provider?: undefined;
344
- deleted?: undefined;
345
343
  providers?: undefined;
344
+ count?: undefined;
346
345
  found: boolean;
347
346
  id: string;
347
+ deleted?: undefined;
348
348
  registered?: undefined;
349
349
  label?: undefined;
350
350
  message?: undefined;
351
351
  } | {
352
- count?: undefined;
353
352
  provider?: undefined;
354
353
  providers?: undefined;
354
+ count?: undefined;
355
355
  found?: undefined;
356
356
  deleted: boolean;
357
357
  id: string;
@@ -359,11 +359,11 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
359
359
  label?: undefined;
360
360
  message?: undefined;
361
361
  } | {
362
- count?: undefined;
363
362
  provider?: undefined;
364
- deleted?: undefined;
365
363
  providers?: undefined;
364
+ count?: undefined;
366
365
  found?: undefined;
366
+ deleted?: undefined;
367
367
  registered: boolean;
368
368
  id: string;
369
369
  label: string;
@@ -73,6 +73,7 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
73
73
  offset?: unknown;
74
74
  limit?: unknown;
75
75
  }, {
76
+ deleted?: undefined;
76
77
  jobs: {
77
78
  id: string;
78
79
  name: string;
@@ -83,7 +84,6 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
83
84
  updatedAt: string;
84
85
  }[];
85
86
  total: number;
86
- deleted?: undefined;
87
87
  jobId?: undefined;
88
88
  } | {
89
89
  jobs?: undefined;
@@ -91,9 +91,9 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
91
91
  deleted: boolean;
92
92
  jobId: string;
93
93
  } | {
94
+ deleted?: undefined;
94
95
  jobs?: undefined;
95
96
  total?: undefined;
96
- deleted?: undefined;
97
97
  jobId?: undefined;
98
98
  hits: Record<string, unknown>[];
99
99
  offset: number;
@@ -51,8 +51,8 @@ export declare function handleDeleteResource(event: any): Promise<{
51
51
  error: string;
52
52
  ok?: undefined;
53
53
  } | {
54
- error?: undefined;
55
54
  ok: boolean;
55
+ error?: undefined;
56
56
  }>;
57
57
  /** POST /_agent-native/resources/upload — upload a file as a resource */
58
58
  export declare function handleUploadResource(event: any): Promise<import("./store.js").Resource | {
@@ -73,10 +73,10 @@ export declare function handleUploadResource(event: any): Promise<import("./stor
73
73
  runId: string | null;
74
74
  expiresAt: number | null;
75
75
  metadata: string | null;
76
- error?: undefined;
77
76
  url: string;
78
77
  provider: string;
79
78
  storageSetupRequired?: undefined;
79
+ error?: undefined;
80
80
  } | {
81
81
  error: string;
82
82
  storageSetupRequired: boolean;
@@ -27,10 +27,10 @@ export declare function resolveAgentEngineApiKeyWriteTarget(event: H3Event, scop
27
27
  export declare function createAgentEngineApiKeyHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
28
28
  error: any;
29
29
  } | {
30
- error?: undefined;
31
30
  ok: boolean;
32
31
  key: string;
33
32
  baseUrlKey?: string;
34
33
  scope: AgentEngineApiKeyScope;
34
+ error?: undefined;
35
35
  }>>;
36
36
  export {};
@@ -81,7 +81,7 @@ export async function loadResolvedAgentNativeConfig(cwd, context, options = {})
81
81
  : await loadAgentNativeConfigFile(cwd));
82
82
  return resolveAgentNativeConfig(mergeAgentNativeConfigs(mergeAgentNativeConfigs(mergeAgentNativeConfigs(workspaceConfig
83
83
  ? resolveAgentNativeConfig(workspaceConfig, context)
84
- : {}, readAgentNativeJsonConfig(cwd)), readAgentNativeConfigEnv(options.environment ?? process.env)), projectConfig ? resolveAgentNativeConfig(projectConfig, context) : {}), context);
84
+ : {}, readAgentNativeJsonConfig(cwd)), projectConfig ? resolveAgentNativeConfig(projectConfig, context) : {}), readAgentNativeConfigEnv(options.environment ?? process.env), { arrayStrategy: "replace" }), context);
85
85
  }
86
86
  function findConfigPath(cwd) {
87
87
  return AGENT_NATIVE_CONFIG_FILE_CANDIDATES.map((filename) => path.join(cwd, filename)).find((candidate) => fs.existsSync(candidate));
@@ -20,6 +20,7 @@ import { formatRuntimeConfigReport, getRuntimeConfigReport, isTruthyRuntimeValue
20
20
  import { actionTypesPlugin } from "./action-types-plugin.js";
21
21
  import { createAgentNativeConfigContext, loadAgentNativeConfigFile, loadWorkspaceAgentNativeConfigFile, readAgentNativeJsonConfig, } from "./agent-native-config-loader.js";
22
22
  import { agentsBundlePlugin } from "./agents-bundle-plugin.js";
23
+ import { resolveAgentNativePackageVersions } from "./package-versions.js";
23
24
  const require = createRequire(import.meta.url);
24
25
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
25
26
  let nitroFsWatchGuardInstalled = false;
@@ -2806,7 +2807,7 @@ function reportRuntimeConfigDiagnostics(appConfig, context, mode, env = process.
2806
2807
  }
2807
2808
  console.warn(message);
2808
2809
  }
2809
- function createAgentNativeConfig(options = {}, command, userConfig = {}, mode = process.env.NODE_ENV === "production" ? "production" : "development", projectConfig) {
2810
+ function createAgentNativeConfig(options = {}, command, userConfig = {}, mode = process.env.NODE_ENV === "production" ? "production" : "development", projectConfig, workspaceConfig) {
2810
2811
  const cwd = process.cwd();
2811
2812
  const configContext = createAgentNativeConfigContext(command, mode);
2812
2813
  const projectConfigInput = projectConfig ?? options.agentNativeConfig;
@@ -2822,9 +2823,11 @@ function createAgentNativeConfig(options = {}, command, userConfig = {}, mode =
2822
2823
  ...loadEnv(mode, cwd, ""),
2823
2824
  ...process.env,
2824
2825
  };
2825
- const appConfig = resolveAgentNativeConfig(mergeAgentNativeConfigs(mergeAgentNativeConfigs(readAgentNativeJsonConfig(cwd), readAgentNativeConfigEnv(runtimeEnv)), projectConfigInput
2826
+ const appConfig = resolveAgentNativeConfig(mergeAgentNativeConfigs(mergeAgentNativeConfigs(mergeAgentNativeConfigs(workspaceConfig
2827
+ ? resolveAgentNativeConfig(workspaceConfig, configContext)
2828
+ : {}, readAgentNativeJsonConfig(cwd)), projectConfigInput
2826
2829
  ? resolveAgentNativeConfig(projectConfigInput, configContext)
2827
- : {}), configContext);
2830
+ : {}), readAgentNativeConfigEnv(runtimeEnv), { arrayStrategy: "replace" }), configContext);
2828
2831
  const inferredDeploymentEnvironment = appConfig.deployment?.environment ??
2829
2832
  inferAgentNativeDeploymentEnvironment(process.env, mode);
2830
2833
  const resolvedAppConfig = appConfig.deployment?.environment === undefined &&
@@ -2840,6 +2843,7 @@ function createAgentNativeConfig(options = {}, command, userConfig = {}, mode =
2840
2843
  process.env.CF_PAGES_COMMIT_SHA?.trim() ||
2841
2844
  process.env.AGENT_NATIVE_BUILD_SHA?.trim() ||
2842
2845
  "development";
2846
+ const packageVersions = resolveAgentNativePackageVersions(cwd);
2843
2847
  // Preload workspace-root .env into process.env so Nitro server code sees
2844
2848
  // shared keys during dev (Nitro reads process.env, not vite's envDir).
2845
2849
  if (workspaceRoot && workspaceRoot !== cwd) {
@@ -2910,6 +2914,7 @@ function createAgentNativeConfig(options = {}, command, userConfig = {}, mode =
2910
2914
  ...(userConfig.define ?? {}),
2911
2915
  ...(options.define ?? {}),
2912
2916
  __AGENT_NATIVE_BUILD_ID__: JSON.stringify(buildId),
2917
+ __AGENT_NATIVE_PACKAGE_VERSIONS__: JSON.stringify(packageVersions),
2913
2918
  __AGENT_NATIVE_CLIENT_COMPATIBILITY_VERSION__: JSON.stringify(options.clientCompatibilityVersion?.trim() || ""),
2914
2919
  __AGENT_NATIVE_APP_CONFIG__: JSON.stringify(resolvedAppConfig),
2915
2920
  __AGENT_NATIVE_BUILD_GA_MEASUREMENT_ID__: JSON.stringify(process.env.GA_MEASUREMENT_ID?.trim() || ""),
@@ -3139,14 +3144,10 @@ function createAgentNativeConfigPlugin(options) {
3139
3144
  name: "agent-native-config",
3140
3145
  enforce: "pre",
3141
3146
  async config(config, env) {
3142
- const context = createAgentNativeConfigContext(env.command, env.mode);
3143
3147
  const workspaceConfig = await loadWorkspaceAgentNativeConfigFile(process.cwd());
3144
3148
  const projectConfig = options.agentNativeConfig ??
3145
3149
  (await loadAgentNativeConfigFile(process.cwd()));
3146
- const resolvedConfig = mergeAgentNativeConfigs(workspaceConfig
3147
- ? resolveAgentNativeConfig(workspaceConfig, context)
3148
- : {}, projectConfig ? resolveAgentNativeConfig(projectConfig, context) : {});
3149
- return createAgentNativeConfig(options, env.command, config, env.mode, resolvedConfig);
3150
+ return createAgentNativeConfig(options, env.command, config, env.mode, projectConfig, workspaceConfig);
3150
3151
  },
3151
3152
  };
3152
3153
  }
@@ -0,0 +1 @@
1
+ export declare function resolveAgentNativePackageVersions(cwd: string): Record<string, string>;
@@ -0,0 +1,97 @@
1
+ import fs from "fs";
2
+ import { createRequire } from "module";
3
+ import path from "path";
4
+ import { fileURLToPath } from "url";
5
+ const AGENT_NATIVE_PACKAGE_PREFIX = "@agent-native/";
6
+ function readPackageManifest(manifestPath) {
7
+ try {
8
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
9
+ return manifest && typeof manifest === "object"
10
+ ? manifest
11
+ : null;
12
+ }
13
+ catch {
14
+ // coercion-ok: missing or malformed manifests are typed absence from the optional version inventory.
15
+ return null;
16
+ }
17
+ }
18
+ function dependencyNames(manifest, includeDevDependencies = false) {
19
+ if (!manifest) {
20
+ return [];
21
+ }
22
+ return [
23
+ ...Object.keys(manifest.dependencies ?? {}),
24
+ ...Object.keys(manifest.optionalDependencies ?? {}),
25
+ ...Object.keys(manifest.peerDependencies ?? {}),
26
+ ...(includeDevDependencies
27
+ ? Object.keys(manifest.devDependencies ?? {})
28
+ : []),
29
+ ];
30
+ }
31
+ function resolvePackageManifest(packageName, resolutionBase) {
32
+ let entryPath;
33
+ const packageRequire = createRequire(path.join(resolutionBase, "package.json"));
34
+ try {
35
+ entryPath = packageRequire.resolve(packageName);
36
+ }
37
+ catch {
38
+ if (packageName !== "@agent-native/core") {
39
+ return null;
40
+ }
41
+ const coreManifestPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../package.json");
42
+ const coreManifest = readPackageManifest(coreManifestPath);
43
+ return coreManifest?.name === packageName
44
+ ? { manifest: coreManifest, manifestPath: coreManifestPath }
45
+ : null;
46
+ }
47
+ let directory = path.dirname(entryPath);
48
+ for (let depth = 0; depth < 20; depth += 1) {
49
+ const manifestPath = path.join(directory, "package.json");
50
+ const manifest = readPackageManifest(manifestPath);
51
+ if (manifest?.name === packageName) {
52
+ return { manifest, manifestPath };
53
+ }
54
+ const parent = path.dirname(directory);
55
+ if (parent === directory) {
56
+ break;
57
+ }
58
+ directory = parent;
59
+ }
60
+ return null;
61
+ }
62
+ export function resolveAgentNativePackageVersions(cwd) {
63
+ const appManifest = readPackageManifest(path.join(cwd, "package.json"));
64
+ const packageNames = new Set([
65
+ "@agent-native/core",
66
+ ...dependencyNames(appManifest, true).filter((name) => name.startsWith(AGENT_NATIVE_PACKAGE_PREFIX)),
67
+ ]);
68
+ const resolvedVersions = new Map();
69
+ const queuedPackages = [...packageNames].map((packageName) => ({
70
+ packageName,
71
+ resolutionBase: cwd,
72
+ }));
73
+ while (queuedPackages.length > 0) {
74
+ const queuedPackage = queuedPackages.shift();
75
+ if (!queuedPackage)
76
+ continue;
77
+ const resolvedPackage = resolvePackageManifest(queuedPackage.packageName, queuedPackage.resolutionBase);
78
+ if (!resolvedPackage) {
79
+ continue;
80
+ }
81
+ const { manifest } = resolvedPackage;
82
+ if (typeof manifest.version === "string" && manifest.version.trim()) {
83
+ resolvedVersions.set(queuedPackage.packageName, manifest.version.trim());
84
+ }
85
+ for (const dependencyName of dependencyNames(manifest)) {
86
+ if (dependencyName.startsWith(AGENT_NATIVE_PACKAGE_PREFIX) &&
87
+ !packageNames.has(dependencyName)) {
88
+ packageNames.add(dependencyName);
89
+ queuedPackages.push({
90
+ packageName: dependencyName,
91
+ resolutionBase: path.dirname(resolvedPackage.manifestPath),
92
+ });
93
+ }
94
+ }
95
+ }
96
+ return Object.fromEntries([...resolvedVersions.entries()].sort(([left], [right]) => left.localeCompare(right)));
97
+ }