@standardagents/builder 0.15.0 → 0.15.1

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 (34) hide show
  1. package/dist/built-in-routes.js +1650 -502
  2. package/dist/built-in-routes.js.map +1 -1
  3. package/dist/client/ApiKeysView.js +1 -1
  4. package/dist/client/CenteredContentView.js +1 -1
  5. package/dist/client/CompositionView.js +5 -5
  6. package/dist/client/ConfirmDialog.vue_vue_type_script_setup_true_lang.js +1 -1
  7. package/dist/client/CopyButton.vue_vue_type_script_setup_true_lang.js +1 -1
  8. package/dist/client/DataTable.vue_vue_type_script_setup_true_lang.js +1 -0
  9. package/dist/client/JsonViewer.js +1 -1
  10. package/dist/client/LoginView.js +1 -1
  11. package/dist/client/Modal.vue_vue_type_script_setup_true_lang.js +1 -1
  12. package/dist/client/ModelModal.vue_vue_type_script_setup_true_lang.js +1 -1
  13. package/dist/client/ModelsView.js +1 -1
  14. package/dist/client/PromptEditView.js +1 -1
  15. package/dist/client/PromptModal.js +1 -1
  16. package/dist/client/PromptsView.js +1 -1
  17. package/dist/client/ProvidersView.js +2 -2
  18. package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang.js +19 -19
  19. package/dist/client/ToolsView.js +1 -1
  20. package/dist/client/UsersView.js +1 -1
  21. package/dist/client/VariablesView.js +1 -0
  22. package/dist/client/assets/CompositionView.css +1 -1
  23. package/dist/client/assets/ThreadInspectorPane.css +1 -1
  24. package/dist/client/assets/VariablesView.css +1 -0
  25. package/dist/client/assets/index.css +1 -1
  26. package/dist/client/index.js +6 -6
  27. package/dist/{index-D6_KjpVv.d.ts → index-BwqQtJ4r.d.ts} +47 -0
  28. package/dist/index.d.ts +116 -4
  29. package/dist/index.js +1547 -706
  30. package/dist/index.js.map +1 -1
  31. package/dist/plugin.js +548 -372
  32. package/dist/plugin.js.map +1 -1
  33. package/dist/test.d.ts +1 -1
  34. package/package.json +5 -5
package/dist/plugin.js CHANGED
@@ -1,7 +1,7 @@
1
- import * as fs7 from 'fs';
2
- import fs7__default from 'fs';
3
- import * as path7 from 'path';
4
- import path7__default from 'path';
1
+ import * as fs8 from 'fs';
2
+ import fs8__default from 'fs';
3
+ import * as path8 from 'path';
4
+ import path8__default from 'path';
5
5
  import { fileURLToPath } from 'url';
6
6
  import MagicString from 'magic-string';
7
7
  import { exec } from 'child_process';
@@ -40,15 +40,15 @@ function extractSchemaFields(content) {
40
40
  }
41
41
  function scanPromptsWithSchemas(dir) {
42
42
  const results = [];
43
- if (!fs7__default.existsSync(dir)) {
43
+ if (!fs8__default.existsSync(dir)) {
44
44
  return results;
45
45
  }
46
46
  try {
47
- const entries = fs7__default.readdirSync(dir, { withFileTypes: true });
47
+ const entries = fs8__default.readdirSync(dir, { withFileTypes: true });
48
48
  for (const entry of entries) {
49
49
  if (entry.isFile() && entry.name.endsWith(".ts")) {
50
- const filePath = path7__default.join(dir, entry.name);
51
- const content = fs7__default.readFileSync(filePath, "utf-8");
50
+ const filePath = path8__default.join(dir, entry.name);
51
+ const content = fs8__default.readFileSync(filePath, "utf-8");
52
52
  const nameMatch = content.match(/name:\s*['"]([^'"]+)['"]/);
53
53
  if (nameMatch) {
54
54
  const name = nameMatch[1];
@@ -64,15 +64,15 @@ function scanPromptsWithSchemas(dir) {
64
64
  }
65
65
  function scanAgentsWithSideA(dir) {
66
66
  const results = [];
67
- if (!fs7__default.existsSync(dir)) {
67
+ if (!fs8__default.existsSync(dir)) {
68
68
  return results;
69
69
  }
70
70
  try {
71
- const entries = fs7__default.readdirSync(dir, { withFileTypes: true });
71
+ const entries = fs8__default.readdirSync(dir, { withFileTypes: true });
72
72
  for (const entry of entries) {
73
73
  if (entry.isFile() && entry.name.endsWith(".ts")) {
74
- const filePath = path7__default.join(dir, entry.name);
75
- const content = fs7__default.readFileSync(filePath, "utf-8");
74
+ const filePath = path8__default.join(dir, entry.name);
75
+ const content = fs8__default.readFileSync(filePath, "utf-8");
76
76
  const nameMatch = content.match(/name:\s*['"]([^'"]+)['"]/);
77
77
  if (nameMatch) {
78
78
  const name = nameMatch[1];
@@ -92,15 +92,15 @@ function scanAgentsWithSideA(dir) {
92
92
  }
93
93
  function scanForNames(dir, useFilename = false) {
94
94
  const names = [];
95
- if (!fs7__default.existsSync(dir)) {
95
+ if (!fs8__default.existsSync(dir)) {
96
96
  return names;
97
97
  }
98
98
  try {
99
- const entries = fs7__default.readdirSync(dir, { withFileTypes: true });
99
+ const entries = fs8__default.readdirSync(dir, { withFileTypes: true });
100
100
  for (const entry of entries) {
101
101
  if (entry.isFile() && entry.name.endsWith(".ts")) {
102
- const filePath = path7__default.join(dir, entry.name);
103
- const content = fs7__default.readFileSync(filePath, "utf-8");
102
+ const filePath = path8__default.join(dir, entry.name);
103
+ const content = fs8__default.readFileSync(filePath, "utf-8");
104
104
  if (useFilename) {
105
105
  const toolName = entry.name.replace(/\.ts$/, "");
106
106
  if (content.includes("defineTool")) {
@@ -121,18 +121,18 @@ function scanForNames(dir, useFilename = false) {
121
121
  }
122
122
  function scanHooksForIds(dir) {
123
123
  const hookIds = [];
124
- if (!fs7__default.existsSync(dir)) {
124
+ if (!fs8__default.existsSync(dir)) {
125
125
  return hookIds;
126
126
  }
127
127
  try {
128
- const entries = fs7__default.readdirSync(dir, { withFileTypes: true });
128
+ const entries = fs8__default.readdirSync(dir, { withFileTypes: true });
129
129
  for (const entry of entries) {
130
130
  if (entry.isFile() && entry.name.endsWith(".ts")) {
131
131
  if (entry.name === "index.ts") {
132
132
  continue;
133
133
  }
134
- const filePath = path7__default.join(dir, entry.name);
135
- const content = fs7__default.readFileSync(filePath, "utf-8");
134
+ const filePath = path8__default.join(dir, entry.name);
135
+ const content = fs8__default.readFileSync(filePath, "utf-8");
136
136
  const idMatch = content.match(/defineHook\s*\(\s*\{[^}]*id:\s*['"]([^'"]+)['"]/s);
137
137
  if (idMatch) {
138
138
  hookIds.push(idMatch[1]);
@@ -599,6 +599,34 @@ declare module 'virtual:@standardagents/builder' {
599
599
  property: string;
600
600
  promptName?: string;
601
601
  }): Promise<'text' | 'secret'>;
602
+ getInstanceEnv(): Promise<Record<string, string>>;
603
+ getInstanceEnvTypes(): Promise<Record<string, 'text' | 'secret'>>;
604
+ getInstanceEnvEntries(): Promise<Array<{
605
+ name: string;
606
+ value: string;
607
+ type: 'text' | 'secret';
608
+ created_at: number;
609
+ updated_at: number;
610
+ }>>;
611
+ patchInstanceEnv(params: {
612
+ env_patch?: Record<string, unknown> | null;
613
+ env_type_patch?: Record<string, unknown> | null;
614
+ env_delete?: string[] | null;
615
+ }): Promise<void>;
616
+ getUserEnv(userId: string): Promise<Record<string, string>>;
617
+ getUserEnvTypes(userId: string): Promise<Record<string, 'text' | 'secret'>>;
618
+ getUserEnvEntries(userId: string): Promise<Array<{
619
+ name: string;
620
+ value: string;
621
+ type: 'text' | 'secret';
622
+ created_at: number;
623
+ updated_at: number;
624
+ }>>;
625
+ patchUserEnv(userId: string, params: {
626
+ env_patch?: Record<string, unknown> | null;
627
+ env_type_patch?: Record<string, unknown> | null;
628
+ env_delete?: string[] | null;
629
+ }): Promise<void>;
602
630
  listThreads(params?: {
603
631
  agent_name?: string;
604
632
  user_id?: string;
@@ -756,44 +784,44 @@ declare module 'virtual:@standardagents/router' {
756
784
  `;
757
785
  }
758
786
  function ensureDir(dir) {
759
- if (!fs7__default.existsSync(dir)) {
760
- fs7__default.mkdirSync(dir, { recursive: true });
787
+ if (!fs8__default.existsSync(dir)) {
788
+ fs8__default.mkdirSync(dir, { recursive: true });
761
789
  }
762
790
  }
763
791
  function writeFileIfChanged(filePath, content) {
764
- if (fs7__default.existsSync(filePath)) {
765
- const existing = fs7__default.readFileSync(filePath, "utf-8");
792
+ if (fs8__default.existsSync(filePath)) {
793
+ const existing = fs8__default.readFileSync(filePath, "utf-8");
766
794
  if (existing === content) {
767
795
  return;
768
796
  }
769
797
  }
770
- fs7__default.writeFileSync(filePath, content);
798
+ fs8__default.writeFileSync(filePath, content);
771
799
  }
772
800
  function generateTypes(config) {
773
801
  ensureDir(config.outputDir);
774
802
  const typesContent = generateTypesContent(config);
775
- writeFileIfChanged(path7__default.join(config.outputDir, "types.d.ts"), typesContent);
803
+ writeFileIfChanged(path8__default.join(config.outputDir, "types.d.ts"), typesContent);
776
804
  const virtualModuleContent = generateVirtualModuleContent();
777
- writeFileIfChanged(path7__default.join(config.outputDir, "virtual-module.d.ts"), virtualModuleContent);
778
- writeFileIfChanged(path7__default.join(config.outputDir, "tsconfig.json"), TSCONFIG_CONTENT);
779
- writeFileIfChanged(path7__default.join(config.outputDir, ".gitignore"), "*\n");
805
+ writeFileIfChanged(path8__default.join(config.outputDir, "virtual-module.d.ts"), virtualModuleContent);
806
+ writeFileIfChanged(path8__default.join(config.outputDir, "tsconfig.json"), TSCONFIG_CONTENT);
807
+ writeFileIfChanged(path8__default.join(config.outputDir, ".gitignore"), "*\n");
780
808
  }
781
809
  function needsRegeneration(config) {
782
- const typesPath = path7__default.join(config.outputDir, "types.d.ts");
783
- if (!fs7__default.existsSync(typesPath)) {
810
+ const typesPath = path8__default.join(config.outputDir, "types.d.ts");
811
+ if (!fs8__default.existsSync(typesPath)) {
784
812
  return true;
785
813
  }
786
- const typesMtime = fs7__default.statSync(typesPath).mtime;
814
+ const typesMtime = fs8__default.statSync(typesPath).mtime;
787
815
  const dirs = [config.modelsDir, config.promptsDir, config.agentsDir, config.toolsDir, config.hooksDir];
788
816
  for (const dir of dirs) {
789
- if (!fs7__default.existsSync(dir)) {
817
+ if (!fs8__default.existsSync(dir)) {
790
818
  continue;
791
819
  }
792
- const entries = fs7__default.readdirSync(dir, { withFileTypes: true });
820
+ const entries = fs8__default.readdirSync(dir, { withFileTypes: true });
793
821
  for (const entry of entries) {
794
822
  if (entry.isFile() && entry.name.endsWith(".ts")) {
795
- const filePath = path7__default.join(dir, entry.name);
796
- const fileMtime = fs7__default.statSync(filePath).mtime;
823
+ const filePath = path8__default.join(dir, entry.name);
824
+ const fileMtime = fs8__default.statSync(filePath).mtime;
797
825
  if (fileMtime > typesMtime) {
798
826
  return true;
799
827
  }
@@ -980,7 +1008,7 @@ function createHmrReloader() {
980
1008
  versions,
981
1009
  invalidateSourceFileModule(server, filePath) {
982
1010
  if (!filePath) return;
983
- const absolutePath = path7__default.resolve(filePath);
1011
+ const absolutePath = path8__default.resolve(filePath);
984
1012
  for (const [envName, env] of Object.entries(server.environments)) {
985
1013
  const modules = env.moduleGraph.getModulesByFile(absolutePath);
986
1014
  if (!modules) continue;
@@ -991,10 +1019,10 @@ function createHmrReloader() {
991
1019
  }
992
1020
  },
993
1021
  invalidateSourceDirectoryModules(server, dirPath) {
994
- if (!fs7__default.existsSync(dirPath)) return;
1022
+ if (!fs8__default.existsSync(dirPath)) return;
995
1023
  const scan = (currentDir) => {
996
- for (const entry of fs7__default.readdirSync(currentDir, { withFileTypes: true })) {
997
- const nextPath = path7__default.join(currentDir, entry.name);
1024
+ for (const entry of fs8__default.readdirSync(currentDir, { withFileTypes: true })) {
1025
+ const nextPath = path8__default.join(currentDir, entry.name);
998
1026
  if (entry.isDirectory()) {
999
1027
  scan(nextPath);
1000
1028
  } else if (entry.isFile() && entry.name.endsWith(".ts")) {
@@ -1146,6 +1174,73 @@ function createHmrReloader() {
1146
1174
  };
1147
1175
  return reloader;
1148
1176
  }
1177
+ var STATE_RELATIVE_PATH = path8__default.join(".agents", "bootstrap-session.json");
1178
+ var PROJECT_ROOT_ENV_KEYS = ["INIT_CWD", "PWD", "npm_config_local_prefix"];
1179
+ function uniquePaths(paths) {
1180
+ return Array.from(
1181
+ new Set(
1182
+ paths.filter((value) => !!value?.trim()).map((value) => path8__default.resolve(value))
1183
+ )
1184
+ );
1185
+ }
1186
+ function isBootstrapSessionRoute(routePath) {
1187
+ return routePath === "/api/platform-auth/me" || routePath === "/api/platform-session" || routePath.startsWith("/api/platform-session/");
1188
+ }
1189
+ function hasSessionCookie(cookieHeader) {
1190
+ const raw = Array.isArray(cookieHeader) ? cookieHeader.join("; ") : cookieHeader || "";
1191
+ return /(?:^|;\s*)session=/.test(raw);
1192
+ }
1193
+ function mergeCookieHeader(cookieHeader, injectedCookie) {
1194
+ const raw = Array.isArray(cookieHeader) ? cookieHeader.join("; ") : cookieHeader || "";
1195
+ return raw ? `${raw}; ${injectedCookie}` : injectedCookie;
1196
+ }
1197
+ function loadLocalBootstrapSession(projectRoot) {
1198
+ const statePath = path8__default.join(projectRoot, STATE_RELATIVE_PATH);
1199
+ if (!fs8__default.existsSync(statePath)) return null;
1200
+ try {
1201
+ const parsed = JSON.parse(
1202
+ fs8__default.readFileSync(statePath, "utf-8")
1203
+ );
1204
+ if (parsed.version !== 1) return null;
1205
+ if (!parsed.endpoint || !parsed.user?.id || !parsed.account?.id) return null;
1206
+ if (!parsed.session_cookie || typeof parsed.session_cookie !== "string") return null;
1207
+ return parsed;
1208
+ } catch {
1209
+ return null;
1210
+ }
1211
+ }
1212
+ function loadLocalBootstrapSessionFromEnv(env) {
1213
+ return null;
1214
+ }
1215
+ function findLocalBootstrapSession(projectRoot, env) {
1216
+ const envSession = loadLocalBootstrapSessionFromEnv();
1217
+ if (envSession) {
1218
+ return {
1219
+ projectRoot: projectRoot ? path8__default.resolve(projectRoot) : process.cwd(),
1220
+ session: envSession
1221
+ };
1222
+ }
1223
+ const candidates = uniquePaths([
1224
+ projectRoot,
1225
+ process.cwd(),
1226
+ ...PROJECT_ROOT_ENV_KEYS.map((key) => process.env[key])
1227
+ ]);
1228
+ for (const candidate of candidates) {
1229
+ const session = loadLocalBootstrapSession(candidate);
1230
+ if (session) {
1231
+ return {
1232
+ projectRoot: candidate,
1233
+ session
1234
+ };
1235
+ }
1236
+ }
1237
+ return null;
1238
+ }
1239
+ function resolveLocalBootstrapCookie(projectRoot, routePath, cookieHeader) {
1240
+ if (!isBootstrapSessionRoute(routePath)) return null;
1241
+ if (hasSessionCookie(cookieHeader)) return null;
1242
+ return findLocalBootstrapSession(projectRoot)?.session.session_cookie ?? null;
1243
+ }
1149
1244
 
1150
1245
  // src/sdk/generators/generateModelFile.ts
1151
1246
  function generateModelFile(data, options) {
@@ -1766,19 +1861,19 @@ function nameToFilename(name) {
1766
1861
  }
1767
1862
  function getModelFilePath(modelsDir, name) {
1768
1863
  const filename = nameToFilename(name);
1769
- return path7__default.join(modelsDir, `${filename}.ts`);
1864
+ return path8__default.join(modelsDir, `${filename}.ts`);
1770
1865
  }
1771
1866
  function modelExists(modelsDir, name) {
1772
1867
  const filePath = getModelFilePath(modelsDir, name);
1773
- return fs7__default.existsSync(filePath);
1868
+ return fs8__default.existsSync(filePath);
1774
1869
  }
1775
1870
  async function saveModel(modelsDir, data, overwrite = false, providerPackageMap = defaultProviderPackageMap) {
1776
1871
  try {
1777
- if (!fs7__default.existsSync(modelsDir)) {
1778
- fs7__default.mkdirSync(modelsDir, { recursive: true });
1872
+ if (!fs8__default.existsSync(modelsDir)) {
1873
+ fs8__default.mkdirSync(modelsDir, { recursive: true });
1779
1874
  }
1780
1875
  const filePath = getModelFilePath(modelsDir, data.name);
1781
- if (!overwrite && fs7__default.existsSync(filePath)) {
1876
+ if (!overwrite && fs8__default.existsSync(filePath)) {
1782
1877
  return {
1783
1878
  success: false,
1784
1879
  error: `Model file already exists: ${filePath}. Use update to modify existing models.`
@@ -1795,7 +1890,7 @@ async function saveModel(modelsDir, data, overwrite = false, providerPackageMap
1795
1890
  providerName: providerInfo.name,
1796
1891
  providerPackage: providerInfo.package
1797
1892
  });
1798
- await fs7__default.promises.writeFile(filePath, content, "utf-8");
1893
+ await fs8__default.promises.writeFile(filePath, content, "utf-8");
1799
1894
  return {
1800
1895
  success: true,
1801
1896
  filePath
@@ -1810,13 +1905,13 @@ async function saveModel(modelsDir, data, overwrite = false, providerPackageMap
1810
1905
  async function deleteModel(modelsDir, name) {
1811
1906
  try {
1812
1907
  const filePath = getModelFilePath(modelsDir, name);
1813
- if (!fs7__default.existsSync(filePath)) {
1908
+ if (!fs8__default.existsSync(filePath)) {
1814
1909
  return {
1815
1910
  success: false,
1816
1911
  error: `Model file not found: ${filePath}`
1817
1912
  };
1818
1913
  }
1819
- await fs7__default.promises.unlink(filePath);
1914
+ await fs8__default.promises.unlink(filePath);
1820
1915
  return {
1821
1916
  success: true,
1822
1917
  filePath
@@ -2077,26 +2172,26 @@ function transformPromptData(data) {
2077
2172
  }
2078
2173
  function getPromptFilePath(promptsDir, name) {
2079
2174
  const filename = nameToFilename(name);
2080
- return path7__default.join(promptsDir, `${filename}.ts`);
2175
+ return path8__default.join(promptsDir, `${filename}.ts`);
2081
2176
  }
2082
2177
  function promptExists(promptsDir, name) {
2083
2178
  const filePath = getPromptFilePath(promptsDir, name);
2084
- return fs7__default.existsSync(filePath);
2179
+ return fs8__default.existsSync(filePath);
2085
2180
  }
2086
2181
  async function savePrompt(promptsDir, data, overwrite = false) {
2087
2182
  try {
2088
- if (!fs7__default.existsSync(promptsDir)) {
2089
- fs7__default.mkdirSync(promptsDir, { recursive: true });
2183
+ if (!fs8__default.existsSync(promptsDir)) {
2184
+ fs8__default.mkdirSync(promptsDir, { recursive: true });
2090
2185
  }
2091
2186
  const filePath = getPromptFilePath(promptsDir, data.name);
2092
- if (!overwrite && fs7__default.existsSync(filePath)) {
2187
+ if (!overwrite && fs8__default.existsSync(filePath)) {
2093
2188
  return {
2094
2189
  success: false,
2095
2190
  error: `Prompt file already exists: ${filePath}. Use update to modify existing prompts.`
2096
2191
  };
2097
2192
  }
2098
2193
  const content = generatePromptFile(data);
2099
- await fs7__default.promises.writeFile(filePath, content, "utf-8");
2194
+ await fs8__default.promises.writeFile(filePath, content, "utf-8");
2100
2195
  return {
2101
2196
  success: true,
2102
2197
  filePath
@@ -2111,13 +2206,13 @@ async function savePrompt(promptsDir, data, overwrite = false) {
2111
2206
  async function deletePrompt(promptsDir, name) {
2112
2207
  try {
2113
2208
  const filePath = getPromptFilePath(promptsDir, name);
2114
- if (!fs7__default.existsSync(filePath)) {
2209
+ if (!fs8__default.existsSync(filePath)) {
2115
2210
  return {
2116
2211
  success: false,
2117
2212
  error: `Prompt file not found: ${filePath}`
2118
2213
  };
2119
2214
  }
2120
- await fs7__default.promises.unlink(filePath);
2215
+ await fs8__default.promises.unlink(filePath);
2121
2216
  return {
2122
2217
  success: true,
2123
2218
  filePath
@@ -2133,25 +2228,25 @@ async function renamePrompt(promptsDir, oldName, newName) {
2133
2228
  try {
2134
2229
  const oldFilePath = getPromptFilePath(promptsDir, oldName);
2135
2230
  const newFilePath = getPromptFilePath(promptsDir, newName);
2136
- if (!fs7__default.existsSync(oldFilePath)) {
2231
+ if (!fs8__default.existsSync(oldFilePath)) {
2137
2232
  return {
2138
2233
  success: false,
2139
2234
  error: `Prompt file not found: ${oldFilePath}`
2140
2235
  };
2141
2236
  }
2142
- if (fs7__default.existsSync(newFilePath)) {
2237
+ if (fs8__default.existsSync(newFilePath)) {
2143
2238
  return {
2144
2239
  success: false,
2145
2240
  error: `Prompt file already exists: ${newFilePath}`
2146
2241
  };
2147
2242
  }
2148
- const content = await fs7__default.promises.readFile(oldFilePath, "utf-8");
2243
+ const content = await fs8__default.promises.readFile(oldFilePath, "utf-8");
2149
2244
  const updatedContent = content.replace(
2150
2245
  /name:\s*['"]([^'"]+)['"]/,
2151
2246
  `name: '${newName}'`
2152
2247
  );
2153
- await fs7__default.promises.writeFile(newFilePath, updatedContent, "utf-8");
2154
- await fs7__default.promises.unlink(oldFilePath);
2248
+ await fs8__default.promises.writeFile(newFilePath, updatedContent, "utf-8");
2249
+ await fs8__default.promises.unlink(oldFilePath);
2155
2250
  return {
2156
2251
  success: true,
2157
2252
  filePath: newFilePath
@@ -2451,15 +2546,15 @@ function transformAgentData(data) {
2451
2546
  }
2452
2547
  function getAgentFilePath(agentsDir, name) {
2453
2548
  const filename = nameToFilename(name);
2454
- return path7__default.join(agentsDir, `${filename}.ts`);
2549
+ return path8__default.join(agentsDir, `${filename}.ts`);
2455
2550
  }
2456
2551
  function agentExists(agentsDir, name) {
2457
2552
  const filePath = getAgentFilePath(agentsDir, name);
2458
- return fs7__default.existsSync(filePath);
2553
+ return fs8__default.existsSync(filePath);
2459
2554
  }
2460
2555
  function extractAgentMetadata(filePath) {
2461
2556
  try {
2462
- const content = fs7__default.readFileSync(filePath, "utf-8");
2557
+ const content = fs8__default.readFileSync(filePath, "utf-8");
2463
2558
  const metadata = {};
2464
2559
  const packageNameMatch = content.match(/packageName:\s*['"]([^'"]+)['"]/);
2465
2560
  if (packageNameMatch) metadata.packageName = packageNameMatch[1];
@@ -2476,17 +2571,17 @@ function extractAgentMetadata(filePath) {
2476
2571
  }
2477
2572
  async function saveAgent(agentsDir, data, overwrite = false) {
2478
2573
  try {
2479
- if (!fs7__default.existsSync(agentsDir)) {
2480
- fs7__default.mkdirSync(agentsDir, { recursive: true });
2574
+ if (!fs8__default.existsSync(agentsDir)) {
2575
+ fs8__default.mkdirSync(agentsDir, { recursive: true });
2481
2576
  }
2482
2577
  const filePath = getAgentFilePath(agentsDir, data.name);
2483
- if (!overwrite && fs7__default.existsSync(filePath)) {
2578
+ if (!overwrite && fs8__default.existsSync(filePath)) {
2484
2579
  return {
2485
2580
  success: false,
2486
2581
  error: `Agent file already exists: ${filePath}. Use update to modify existing agents.`
2487
2582
  };
2488
2583
  }
2489
- if (overwrite && fs7__default.existsSync(filePath)) {
2584
+ if (overwrite && fs8__default.existsSync(filePath)) {
2490
2585
  const existingMetadata = extractAgentMetadata(filePath);
2491
2586
  if (existingMetadata.packageName && !data.packageName) {
2492
2587
  data.packageName = existingMetadata.packageName;
@@ -2502,7 +2597,7 @@ async function saveAgent(agentsDir, data, overwrite = false) {
2502
2597
  }
2503
2598
  }
2504
2599
  const content = generateAgentFile(data);
2505
- await fs7__default.promises.writeFile(filePath, content, "utf-8");
2600
+ await fs8__default.promises.writeFile(filePath, content, "utf-8");
2506
2601
  return {
2507
2602
  success: true,
2508
2603
  filePath
@@ -2517,13 +2612,13 @@ async function saveAgent(agentsDir, data, overwrite = false) {
2517
2612
  async function deleteAgent(agentsDir, name) {
2518
2613
  try {
2519
2614
  const filePath = getAgentFilePath(agentsDir, name);
2520
- if (!fs7__default.existsSync(filePath)) {
2615
+ if (!fs8__default.existsSync(filePath)) {
2521
2616
  return {
2522
2617
  success: false,
2523
2618
  error: `Agent file not found: ${filePath}`
2524
2619
  };
2525
2620
  }
2526
- await fs7__default.promises.unlink(filePath);
2621
+ await fs8__default.promises.unlink(filePath);
2527
2622
  return {
2528
2623
  success: true,
2529
2624
  filePath
@@ -2539,25 +2634,25 @@ async function renameModel(modelsDir, oldName, newName) {
2539
2634
  try {
2540
2635
  const oldFilePath = getModelFilePath(modelsDir, oldName);
2541
2636
  const newFilePath = getModelFilePath(modelsDir, newName);
2542
- if (!fs7__default.existsSync(oldFilePath)) {
2637
+ if (!fs8__default.existsSync(oldFilePath)) {
2543
2638
  return {
2544
2639
  success: false,
2545
2640
  error: `Model file not found: ${oldFilePath}`
2546
2641
  };
2547
2642
  }
2548
- if (fs7__default.existsSync(newFilePath)) {
2643
+ if (fs8__default.existsSync(newFilePath)) {
2549
2644
  return {
2550
2645
  success: false,
2551
2646
  error: `Model file already exists: ${newFilePath}`
2552
2647
  };
2553
2648
  }
2554
- const content = await fs7__default.promises.readFile(oldFilePath, "utf-8");
2649
+ const content = await fs8__default.promises.readFile(oldFilePath, "utf-8");
2555
2650
  const updatedContent = content.replace(
2556
2651
  /name:\s*['"]([^'"]+)['"]/,
2557
2652
  `name: '${newName}'`
2558
2653
  );
2559
- await fs7__default.promises.writeFile(newFilePath, updatedContent, "utf-8");
2560
- await fs7__default.promises.unlink(oldFilePath);
2654
+ await fs8__default.promises.writeFile(newFilePath, updatedContent, "utf-8");
2655
+ await fs8__default.promises.unlink(oldFilePath);
2561
2656
  return {
2562
2657
  success: true,
2563
2658
  filePath: newFilePath
@@ -2571,17 +2666,17 @@ async function renameModel(modelsDir, oldName, newName) {
2571
2666
  }
2572
2667
  async function updateModelReferencesInPrompts(promptsDir, oldModelName, newModelName) {
2573
2668
  const updatedFiles = [];
2574
- if (!fs7__default.existsSync(promptsDir)) {
2669
+ if (!fs8__default.existsSync(promptsDir)) {
2575
2670
  return updatedFiles;
2576
2671
  }
2577
- const files = fs7__default.readdirSync(promptsDir).filter((f) => f.endsWith(".ts"));
2672
+ const files = fs8__default.readdirSync(promptsDir).filter((f) => f.endsWith(".ts"));
2578
2673
  for (const file of files) {
2579
- const filePath = path7__default.join(promptsDir, file);
2580
- let content = await fs7__default.promises.readFile(filePath, "utf-8");
2674
+ const filePath = path8__default.join(promptsDir, file);
2675
+ let content = await fs8__default.promises.readFile(filePath, "utf-8");
2581
2676
  const modelRegex = new RegExp(`model:\\s*['"]${escapeRegExp(oldModelName)}['"]`, "g");
2582
2677
  if (modelRegex.test(content)) {
2583
2678
  content = content.replace(modelRegex, `model: '${newModelName}'`);
2584
- await fs7__default.promises.writeFile(filePath, content, "utf-8");
2679
+ await fs8__default.promises.writeFile(filePath, content, "utf-8");
2585
2680
  updatedFiles.push(filePath);
2586
2681
  }
2587
2682
  }
@@ -2589,13 +2684,13 @@ async function updateModelReferencesInPrompts(promptsDir, oldModelName, newModel
2589
2684
  }
2590
2685
  async function updatePromptReferencesInPrompts(promptsDir, oldPromptName, newPromptName) {
2591
2686
  const updatedFiles = [];
2592
- if (!fs7__default.existsSync(promptsDir)) {
2687
+ if (!fs8__default.existsSync(promptsDir)) {
2593
2688
  return updatedFiles;
2594
2689
  }
2595
- const files = fs7__default.readdirSync(promptsDir).filter((f) => f.endsWith(".ts"));
2690
+ const files = fs8__default.readdirSync(promptsDir).filter((f) => f.endsWith(".ts"));
2596
2691
  for (const file of files) {
2597
- const filePath = path7__default.join(promptsDir, file);
2598
- let content = await fs7__default.promises.readFile(filePath, "utf-8");
2692
+ const filePath = path8__default.join(promptsDir, file);
2693
+ let content = await fs8__default.promises.readFile(filePath, "utf-8");
2599
2694
  let modified = false;
2600
2695
  const toolsArrayRegex = /tools:\s*\[([^\]]*)\]/gs;
2601
2696
  const newContent = content.replace(toolsArrayRegex, (match) => {
@@ -2608,7 +2703,7 @@ async function updatePromptReferencesInPrompts(promptsDir, oldPromptName, newPro
2608
2703
  return replaced;
2609
2704
  });
2610
2705
  if (modified) {
2611
- await fs7__default.promises.writeFile(filePath, newContent, "utf-8");
2706
+ await fs8__default.promises.writeFile(filePath, newContent, "utf-8");
2612
2707
  updatedFiles.push(filePath);
2613
2708
  }
2614
2709
  }
@@ -2616,17 +2711,17 @@ async function updatePromptReferencesInPrompts(promptsDir, oldPromptName, newPro
2616
2711
  }
2617
2712
  async function updatePromptReferencesInAgents(agentsDir, oldPromptName, newPromptName) {
2618
2713
  const updatedFiles = [];
2619
- if (!fs7__default.existsSync(agentsDir)) {
2714
+ if (!fs8__default.existsSync(agentsDir)) {
2620
2715
  return updatedFiles;
2621
2716
  }
2622
- const files = fs7__default.readdirSync(agentsDir).filter((f) => f.endsWith(".ts"));
2717
+ const files = fs8__default.readdirSync(agentsDir).filter((f) => f.endsWith(".ts"));
2623
2718
  for (const file of files) {
2624
- const filePath = path7__default.join(agentsDir, file);
2625
- let content = await fs7__default.promises.readFile(filePath, "utf-8");
2719
+ const filePath = path8__default.join(agentsDir, file);
2720
+ let content = await fs8__default.promises.readFile(filePath, "utf-8");
2626
2721
  const promptRegex = new RegExp(`prompt:\\s*['"]${escapeRegExp(oldPromptName)}['"]`, "g");
2627
2722
  if (promptRegex.test(content)) {
2628
2723
  content = content.replace(promptRegex, `prompt: '${newPromptName}'`);
2629
- await fs7__default.promises.writeFile(filePath, content, "utf-8");
2724
+ await fs8__default.promises.writeFile(filePath, content, "utf-8");
2630
2725
  updatedFiles.push(filePath);
2631
2726
  }
2632
2727
  }
@@ -2753,16 +2848,16 @@ function parseThreadEndpointRouteKey(input) {
2753
2848
  };
2754
2849
  }
2755
2850
  function scanThreadEndpointFiles(dir, options = {}) {
2756
- if (!fs7__default.existsSync(dir)) {
2851
+ if (!fs8__default.existsSync(dir)) {
2757
2852
  return [];
2758
2853
  }
2759
2854
  const extensions = options.extensions ?? [".ts"];
2760
2855
  const routes = [];
2761
2856
  const scan = (currentDir, relativeDir = "") => {
2762
- const entries = fs7__default.readdirSync(currentDir, { withFileTypes: true });
2857
+ const entries = fs8__default.readdirSync(currentDir, { withFileTypes: true });
2763
2858
  for (const entry of entries) {
2764
- const filePath = path7__default.join(currentDir, entry.name);
2765
- const relativePath = relativeDir ? path7__default.posix.join(relativeDir, entry.name) : entry.name;
2859
+ const filePath = path8__default.join(currentDir, entry.name);
2860
+ const relativePath = relativeDir ? path8__default.posix.join(relativeDir, entry.name) : entry.name;
2766
2861
  if (entry.isDirectory()) {
2767
2862
  scan(filePath, relativePath);
2768
2863
  continue;
@@ -2796,7 +2891,7 @@ function scanApiDirectory(dir) {
2796
2891
  try {
2797
2892
  return scanThreadEndpointFiles(dir, {
2798
2893
  extensions: [".ts"],
2799
- importPathForFile: (filePath) => "./" + path7__default.relative(process.cwd(), filePath).replace(/\\/g, "/")
2894
+ importPathForFile: (filePath) => "./" + path8__default.relative(process.cwd(), filePath).replace(/\\/g, "/")
2800
2895
  }).map(({ method, route, importPath }) => ({
2801
2896
  method,
2802
2897
  route,
@@ -2808,26 +2903,26 @@ function scanApiDirectory(dir) {
2808
2903
  }
2809
2904
  }
2810
2905
  function discoverPackedPackageDirectories(packedDir) {
2811
- if (!fs7__default.existsSync(packedDir)) {
2906
+ if (!fs8__default.existsSync(packedDir)) {
2812
2907
  return [];
2813
2908
  }
2814
2909
  const packageDirs = [];
2815
- const entries = fs7__default.readdirSync(packedDir, { withFileTypes: true }).filter((entry) => entry.isDirectory());
2910
+ const entries = fs8__default.readdirSync(packedDir, { withFileTypes: true }).filter((entry) => entry.isDirectory());
2816
2911
  for (const entry of entries) {
2817
- const fullPath = path7__default.join(packedDir, entry.name);
2818
- const packageJsonPath = path7__default.join(fullPath, "package.json");
2819
- if (fs7__default.existsSync(packageJsonPath)) {
2912
+ const fullPath = path8__default.join(packedDir, entry.name);
2913
+ const packageJsonPath = path8__default.join(fullPath, "package.json");
2914
+ if (fs8__default.existsSync(packageJsonPath)) {
2820
2915
  packageDirs.push(fullPath);
2821
2916
  continue;
2822
2917
  }
2823
2918
  if (!entry.name.startsWith("@")) {
2824
2919
  continue;
2825
2920
  }
2826
- const scopedEntries = fs7__default.readdirSync(fullPath, { withFileTypes: true }).filter((scopedEntry) => scopedEntry.isDirectory());
2921
+ const scopedEntries = fs8__default.readdirSync(fullPath, { withFileTypes: true }).filter((scopedEntry) => scopedEntry.isDirectory());
2827
2922
  for (const scopedEntry of scopedEntries) {
2828
- const scopedPackagePath = path7__default.join(fullPath, scopedEntry.name);
2829
- const scopedPackageJson = path7__default.join(scopedPackagePath, "package.json");
2830
- if (fs7__default.existsSync(scopedPackageJson)) {
2923
+ const scopedPackagePath = path8__default.join(fullPath, scopedEntry.name);
2924
+ const scopedPackageJson = path8__default.join(scopedPackagePath, "package.json");
2925
+ if (fs8__default.existsSync(scopedPackageJson)) {
2831
2926
  packageDirs.push(scopedPackagePath);
2832
2927
  }
2833
2928
  }
@@ -2835,26 +2930,26 @@ function discoverPackedPackageDirectories(packedDir) {
2835
2930
  return packageDirs;
2836
2931
  }
2837
2932
  function scanPackedDistDirectory(packagePath, outputDir, subDir) {
2838
- const fullPath = path7__default.join(packagePath, outputDir, subDir);
2839
- if (!fs7__default.existsSync(fullPath)) {
2933
+ const fullPath = path8__default.join(packagePath, outputDir, subDir);
2934
+ if (!fs8__default.existsSync(fullPath)) {
2840
2935
  return [];
2841
2936
  }
2842
- return fs7__default.readdirSync(fullPath).filter((fileName) => fileName.endsWith(".js") || fileName.endsWith(".ts")).map((fileName) => ({
2937
+ return fs8__default.readdirSync(fullPath).filter((fileName) => fileName.endsWith(".js") || fileName.endsWith(".ts")).map((fileName) => ({
2843
2938
  name: fileName.replace(/\.(js|ts)$/, ""),
2844
- path: path7__default.join(fullPath, fileName).replace(/\\/g, "/")
2939
+ path: path8__default.join(fullPath, fileName).replace(/\\/g, "/")
2845
2940
  }));
2846
2941
  }
2847
2942
  function scanPackedThreadEndpoints(packagePath, outputDir) {
2848
- const rootDir = path7__default.join(packagePath, outputDir, "thread-endpoints");
2849
- if (!fs7__default.existsSync(rootDir)) {
2943
+ const rootDir = path8__default.join(packagePath, outputDir, "thread-endpoints");
2944
+ if (!fs8__default.existsSync(rootDir)) {
2850
2945
  return [];
2851
2946
  }
2852
2947
  const endpoints = [];
2853
2948
  const scan = (dir, relativeDir = "") => {
2854
- const entries = fs7__default.readdirSync(dir, { withFileTypes: true });
2949
+ const entries = fs8__default.readdirSync(dir, { withFileTypes: true });
2855
2950
  for (const entry of entries) {
2856
- const nextRelative = relativeDir ? path7__default.posix.join(relativeDir, entry.name) : entry.name;
2857
- const absolutePath = path7__default.join(dir, entry.name);
2951
+ const nextRelative = relativeDir ? path8__default.posix.join(relativeDir, entry.name) : entry.name;
2952
+ const absolutePath = path8__default.join(dir, entry.name);
2858
2953
  if (entry.isDirectory()) {
2859
2954
  scan(absolutePath, nextRelative);
2860
2955
  continue;
@@ -2884,7 +2979,7 @@ function isSnakeCase(str) {
2884
2979
  }
2885
2980
  function validateToolFile(filePath, fileName) {
2886
2981
  try {
2887
- const content = fs7__default.readFileSync(filePath, "utf-8");
2982
+ const content = fs8__default.readFileSync(filePath, "utf-8");
2888
2983
  const hasDefaultExport = /export\s+default\s+defineTool/.test(content);
2889
2984
  if (!hasDefaultExport) {
2890
2985
  return `Tool file '${fileName}.ts' must have a default export using defineTool()`;
@@ -2896,15 +2991,15 @@ function validateToolFile(filePath, fileName) {
2896
2991
  }
2897
2992
  async function scanToolsDirectory(dir) {
2898
2993
  const tools = [];
2899
- if (!fs7__default.existsSync(dir)) {
2994
+ if (!fs8__default.existsSync(dir)) {
2900
2995
  return tools;
2901
2996
  }
2902
- const entries = await fs7__default.promises.readdir(dir, { withFileTypes: true });
2997
+ const entries = await fs8__default.promises.readdir(dir, { withFileTypes: true });
2903
2998
  for (const entry of entries) {
2904
2999
  if (entry.isFile() && entry.name.endsWith(".ts")) {
2905
3000
  const fileName = entry.name.replace(".ts", "");
2906
- const filePath = path7__default.join(dir, entry.name);
2907
- const importPath = "./" + path7__default.relative(process.cwd(), filePath).replace(/\\/g, "/");
3001
+ const filePath = path8__default.join(dir, entry.name);
3002
+ const importPath = "./" + path8__default.relative(process.cwd(), filePath).replace(/\\/g, "/");
2908
3003
  let toolError;
2909
3004
  const validationError = validateToolFile(filePath, fileName);
2910
3005
  if (validationError) {
@@ -2931,18 +3026,18 @@ async function scanToolsDirectory(dir) {
2931
3026
  }
2932
3027
  async function scanHooksDirectory(dir) {
2933
3028
  const hooks = [];
2934
- if (!fs7__default.existsSync(dir)) {
3029
+ if (!fs8__default.existsSync(dir)) {
2935
3030
  return hooks;
2936
3031
  }
2937
- const entries = await fs7__default.promises.readdir(dir, { withFileTypes: true });
3032
+ const entries = await fs8__default.promises.readdir(dir, { withFileTypes: true });
2938
3033
  for (const entry of entries) {
2939
3034
  if (entry.isFile() && entry.name.endsWith(".ts")) {
2940
3035
  const fileName = entry.name.replace(".ts", "");
2941
3036
  if (fileName === "index") continue;
2942
- const filePath = path7__default.join(dir, entry.name);
2943
- const importPath = "./" + path7__default.relative(process.cwd(), filePath).replace(/\\/g, "/");
3037
+ const filePath = path8__default.join(dir, entry.name);
3038
+ const importPath = "./" + path8__default.relative(process.cwd(), filePath).replace(/\\/g, "/");
2944
3039
  try {
2945
- const content = fs7__default.readFileSync(filePath, "utf-8");
3040
+ const content = fs8__default.readFileSync(filePath, "utf-8");
2946
3041
  const idMatch = content.match(/id:\s*['"]([^'"]+)['"]/);
2947
3042
  const hookMatch = content.match(/hook:\s*['"]([^'"]+)['"]/);
2948
3043
  if (idMatch && hookMatch) {
@@ -2965,16 +3060,16 @@ async function scanHooksDirectory(dir) {
2965
3060
  }
2966
3061
  async function scanConfigDirectory(dir, definePattern) {
2967
3062
  const items = [];
2968
- if (!fs7__default.existsSync(dir)) {
3063
+ if (!fs8__default.existsSync(dir)) {
2969
3064
  return items;
2970
3065
  }
2971
- const entries = await fs7__default.promises.readdir(dir, { withFileTypes: true });
3066
+ const entries = await fs8__default.promises.readdir(dir, { withFileTypes: true });
2972
3067
  for (const entry of entries) {
2973
3068
  if (entry.isFile() && entry.name.endsWith(".ts")) {
2974
- const filePath = path7__default.join(dir, entry.name);
2975
- const importPath = "./" + path7__default.relative(process.cwd(), filePath).replace(/\\/g, "/");
3069
+ const filePath = path8__default.join(dir, entry.name);
3070
+ const importPath = "./" + path8__default.relative(process.cwd(), filePath).replace(/\\/g, "/");
2976
3071
  try {
2977
- const content = fs7__default.readFileSync(filePath, "utf-8");
3072
+ const content = fs8__default.readFileSync(filePath, "utf-8");
2978
3073
  const hasDefaultExport = definePattern.test(content);
2979
3074
  if (!hasDefaultExport) {
2980
3075
  items.push({
@@ -3016,20 +3111,20 @@ async function scanAgentsDirectory(dir) {
3016
3111
  }
3017
3112
  async function scanEffectsDirectory(dir) {
3018
3113
  const effects = [];
3019
- if (!fs7__default.existsSync(dir)) {
3114
+ if (!fs8__default.existsSync(dir)) {
3020
3115
  return effects;
3021
3116
  }
3022
- const entries = await fs7__default.promises.readdir(dir, { withFileTypes: true });
3117
+ const entries = await fs8__default.promises.readdir(dir, { withFileTypes: true });
3023
3118
  for (const entry of entries) {
3024
3119
  if (entry.isFile() && entry.name.endsWith(".ts")) {
3025
3120
  const fileName = entry.name.replace(".ts", "");
3026
- const filePath = path7__default.join(dir, entry.name);
3027
- const importPath = "./" + path7__default.relative(process.cwd(), filePath).replace(/\\/g, "/");
3121
+ const filePath = path8__default.join(dir, entry.name);
3122
+ const importPath = "./" + path8__default.relative(process.cwd(), filePath).replace(/\\/g, "/");
3028
3123
  if (fileName === "CLAUDE" || fileName.startsWith("_")) {
3029
3124
  continue;
3030
3125
  }
3031
3126
  try {
3032
- const content = fs7__default.readFileSync(filePath, "utf-8");
3127
+ const content = fs8__default.readFileSync(filePath, "utf-8");
3033
3128
  if (!content.includes("defineEffect")) {
3034
3129
  continue;
3035
3130
  }
@@ -3516,7 +3611,7 @@ var MetadataService = class {
3516
3611
  * @param agentsDir - Path to the agents/ directory
3517
3612
  */
3518
3613
  constructor(agentsDir) {
3519
- this.metadataDir = path7.join(agentsDir, ".standardagent");
3614
+ this.metadataDir = path8.join(agentsDir, ".standardagent");
3520
3615
  }
3521
3616
  /**
3522
3617
  * Read metadata for an agent.
@@ -3526,11 +3621,11 @@ var MetadataService = class {
3526
3621
  */
3527
3622
  async read(agentName) {
3528
3623
  const filePath = this.getMetadataPath(agentName);
3529
- if (!fs7.existsSync(filePath)) {
3624
+ if (!fs8.existsSync(filePath)) {
3530
3625
  return null;
3531
3626
  }
3532
3627
  try {
3533
- const content = fs7.readFileSync(filePath, "utf-8");
3628
+ const content = fs8.readFileSync(filePath, "utf-8");
3534
3629
  return JSON.parse(content);
3535
3630
  } catch {
3536
3631
  return null;
@@ -3543,11 +3638,11 @@ var MetadataService = class {
3543
3638
  * @param metadata - Metadata to write
3544
3639
  */
3545
3640
  async write(agentName, metadata) {
3546
- if (!fs7.existsSync(this.metadataDir)) {
3547
- fs7.mkdirSync(this.metadataDir, { recursive: true });
3641
+ if (!fs8.existsSync(this.metadataDir)) {
3642
+ fs8.mkdirSync(this.metadataDir, { recursive: true });
3548
3643
  }
3549
3644
  const filePath = this.getMetadataPath(agentName);
3550
- fs7.writeFileSync(filePath, JSON.stringify(metadata, null, 2));
3645
+ fs8.writeFileSync(filePath, JSON.stringify(metadata, null, 2));
3551
3646
  }
3552
3647
  /**
3553
3648
  * Delete metadata for an agent.
@@ -3556,8 +3651,8 @@ var MetadataService = class {
3556
3651
  */
3557
3652
  async delete(agentName) {
3558
3653
  const filePath = this.getMetadataPath(agentName);
3559
- if (fs7.existsSync(filePath)) {
3560
- fs7.unlinkSync(filePath);
3654
+ if (fs8.existsSync(filePath)) {
3655
+ fs8.unlinkSync(filePath);
3561
3656
  }
3562
3657
  }
3563
3658
  /**
@@ -3638,7 +3733,7 @@ var MetadataService = class {
3638
3733
  * Get the file path for an agent's metadata.
3639
3734
  */
3640
3735
  getMetadataPath(agentName) {
3641
- return path7.join(this.metadataDir, `${agentName}.json`);
3736
+ return path8.join(this.metadataDir, `${agentName}.json`);
3642
3737
  }
3643
3738
  };
3644
3739
  var _ts;
@@ -4010,9 +4105,9 @@ var PackingService = class {
4010
4105
  * @returns Version specifier (e.g., '^1.2.3') or '*' if not found
4011
4106
  */
4012
4107
  resolvePackageVersion(pkgName, rootDir) {
4013
- const pkgJsonPath = path7.join(rootDir, "node_modules", pkgName, "package.json");
4108
+ const pkgJsonPath = path8.join(rootDir, "node_modules", pkgName, "package.json");
4014
4109
  try {
4015
- const pkgJson = JSON.parse(fs7.readFileSync(pkgJsonPath, "utf-8"));
4110
+ const pkgJson = JSON.parse(fs8.readFileSync(pkgJsonPath, "utf-8"));
4016
4111
  return `^${pkgJson.version}`;
4017
4112
  } catch {
4018
4113
  return "*";
@@ -4029,7 +4124,7 @@ var PackingService = class {
4029
4124
  * @returns Analysis result with all discovered constituents
4030
4125
  */
4031
4126
  async analyzeAgent(agentName, rootDir) {
4032
- const agentsDir = path7.join(rootDir, "agents");
4127
+ const agentsDir = path8.join(rootDir, "agents");
4033
4128
  const analysis = {
4034
4129
  agent: agentName,
4035
4130
  primaryPrompt: "",
@@ -4053,7 +4148,7 @@ var PackingService = class {
4053
4148
  warnings: [],
4054
4149
  errors: []
4055
4150
  };
4056
- const agentFilePath = await this.findFile(path7.join(agentsDir, "agents"), agentName);
4151
+ const agentFilePath = await this.findFile(path8.join(agentsDir, "agents"), agentName);
4057
4152
  if (!agentFilePath) {
4058
4153
  analysis.errors.push(`Agent file not found: ${agentName}`);
4059
4154
  return analysis;
@@ -4064,7 +4159,7 @@ var PackingService = class {
4064
4159
  discoveredVia: "static",
4065
4160
  sharedWith: []
4066
4161
  });
4067
- const agentSource = fs7.readFileSync(agentFilePath, "utf-8");
4162
+ const agentSource = fs8.readFileSync(agentFilePath, "utf-8");
4068
4163
  const agentPrompts = await extractAgentPrompts(agentSource);
4069
4164
  if (agentPrompts.sideA) {
4070
4165
  analysis.primaryPrompt = agentPrompts.sideA;
@@ -4089,13 +4184,13 @@ var PackingService = class {
4089
4184
  * @returns Object with generatedReadme and agentDescription
4090
4185
  */
4091
4186
  async generateReadmeForAnalysis(analysis, rootDir) {
4092
- const agentsDir = path7.join(rootDir, "agents");
4187
+ const agentsDir = path8.join(rootDir, "agents");
4093
4188
  const metadataService = new MetadataService(agentsDir);
4094
4189
  let agentDescription;
4095
4190
  const agentItem = analysis.constituents.agents.find((a) => a.name === analysis.agent);
4096
4191
  if (agentItem?.filePath) {
4097
4192
  try {
4098
- const agentSource = fs7.readFileSync(agentItem.filePath, "utf-8");
4193
+ const agentSource = fs8.readFileSync(agentItem.filePath, "utf-8");
4099
4194
  agentDescription = await extractAgentDescription(agentSource) || void 0;
4100
4195
  } catch {
4101
4196
  }
@@ -4119,7 +4214,7 @@ var PackingService = class {
4119
4214
  * include all endpoint modules discovered under agents/api.
4120
4215
  */
4121
4216
  async analyzeThreadEndpoints(agentsDir, analysis) {
4122
- const apiDir = path7.join(agentsDir, "api");
4217
+ const apiDir = path8.join(agentsDir, "api");
4123
4218
  const endpoints = this.scanThreadEndpointFiles(apiDir);
4124
4219
  for (const endpoint of endpoints) {
4125
4220
  if (analysis.constituents.threadEndpoints.some((item) => item.name === endpoint.name)) {
@@ -4141,15 +4236,15 @@ var PackingService = class {
4141
4236
  * - `admin/users/[userId]/sync.post`
4142
4237
  */
4143
4238
  scanThreadEndpointFiles(apiDir, relativeDir = "") {
4144
- if (!fs7.existsSync(apiDir)) {
4239
+ if (!fs8.existsSync(apiDir)) {
4145
4240
  return [];
4146
4241
  }
4147
4242
  const endpoints = [];
4148
- const currentDir = relativeDir ? path7.join(apiDir, relativeDir) : apiDir;
4149
- if (!fs7.existsSync(currentDir)) {
4243
+ const currentDir = relativeDir ? path8.join(apiDir, relativeDir) : apiDir;
4244
+ if (!fs8.existsSync(currentDir)) {
4150
4245
  return endpoints;
4151
4246
  }
4152
- const entries = fs7.readdirSync(currentDir, { withFileTypes: true });
4247
+ const entries = fs8.readdirSync(currentDir, { withFileTypes: true });
4153
4248
  if (entries.length > 0 && typeof entries[0] === "string") {
4154
4249
  return endpoints;
4155
4250
  }
@@ -4157,8 +4252,8 @@ var PackingService = class {
4157
4252
  const entryName = typeof entry === "string" ? entry : entry.name;
4158
4253
  const isDirectory = typeof entry === "string" ? false : entry.isDirectory();
4159
4254
  const isFile = typeof entry === "string" ? true : entry.isFile();
4160
- const entryRelative = relativeDir ? path7.posix.join(relativeDir.replace(/\\/g, "/"), entryName) : entryName;
4161
- const absolutePath = path7.join(apiDir, entryRelative);
4255
+ const entryRelative = relativeDir ? path8.posix.join(relativeDir.replace(/\\/g, "/"), entryName) : entryName;
4256
+ const absolutePath = path8.join(apiDir, entryRelative);
4162
4257
  if (isDirectory) {
4163
4258
  endpoints.push(...this.scanThreadEndpointFiles(apiDir, entryRelative));
4164
4259
  continue;
@@ -4185,7 +4280,7 @@ var PackingService = class {
4185
4280
  * include all effect modules discovered under agents/effects.
4186
4281
  */
4187
4282
  async analyzeEffects(agentsDir, analysis) {
4188
- const effectsDir = path7.join(agentsDir, "effects");
4283
+ const effectsDir = path8.join(agentsDir, "effects");
4189
4284
  const effects = this.scanEffectFiles(effectsDir);
4190
4285
  for (const effect of effects) {
4191
4286
  if (analysis.constituents.effects.some((item) => item.name === effect.name)) {
@@ -4207,15 +4302,15 @@ var PackingService = class {
4207
4302
  * - `notifications/digest`
4208
4303
  */
4209
4304
  scanEffectFiles(effectsDir, relativeDir = "") {
4210
- if (!fs7.existsSync(effectsDir)) {
4305
+ if (!fs8.existsSync(effectsDir)) {
4211
4306
  return [];
4212
4307
  }
4213
4308
  const effects = [];
4214
- const currentDir = relativeDir ? path7.join(effectsDir, relativeDir) : effectsDir;
4215
- if (!fs7.existsSync(currentDir)) {
4309
+ const currentDir = relativeDir ? path8.join(effectsDir, relativeDir) : effectsDir;
4310
+ if (!fs8.existsSync(currentDir)) {
4216
4311
  return effects;
4217
4312
  }
4218
- const entries = fs7.readdirSync(currentDir, { withFileTypes: true });
4313
+ const entries = fs8.readdirSync(currentDir, { withFileTypes: true });
4219
4314
  if (entries.length > 0 && typeof entries[0] === "string") {
4220
4315
  return effects;
4221
4316
  }
@@ -4223,8 +4318,8 @@ var PackingService = class {
4223
4318
  const entryName = typeof entry === "string" ? entry : entry.name;
4224
4319
  const isDirectory = typeof entry === "string" ? false : entry.isDirectory();
4225
4320
  const isFile = typeof entry === "string" ? true : entry.isFile();
4226
- const entryRelative = relativeDir ? path7.posix.join(relativeDir.replace(/\\/g, "/"), entryName) : entryName;
4227
- const absolutePath = path7.join(effectsDir, entryRelative);
4321
+ const entryRelative = relativeDir ? path8.posix.join(relativeDir.replace(/\\/g, "/"), entryName) : entryName;
4322
+ const absolutePath = path8.join(effectsDir, entryRelative);
4228
4323
  if (isDirectory) {
4229
4324
  effects.push(...this.scanEffectFiles(effectsDir, entryRelative));
4230
4325
  continue;
@@ -4248,7 +4343,7 @@ var PackingService = class {
4248
4343
  * Recursively analyze a prompt and its dependencies.
4249
4344
  */
4250
4345
  async analyzePrompt(promptName, agentsDir, analysis, visited, parentKey) {
4251
- const promptFilePath = await this.findFile(path7.join(agentsDir, "prompts"), promptName);
4346
+ const promptFilePath = await this.findFile(path8.join(agentsDir, "prompts"), promptName);
4252
4347
  if (!promptFilePath) {
4253
4348
  analysis.warnings.push(`Prompt file not found: ${promptName}`);
4254
4349
  return;
@@ -4267,7 +4362,7 @@ var PackingService = class {
4267
4362
  return;
4268
4363
  }
4269
4364
  visited.add(`prompt:${promptName}`);
4270
- const promptSource = fs7.readFileSync(promptFilePath, "utf-8");
4365
+ const promptSource = fs8.readFileSync(promptFilePath, "utf-8");
4271
4366
  const modelName = await extractPromptModel(promptSource);
4272
4367
  if (modelName) {
4273
4368
  await this.analyzeModel(modelName, agentsDir, analysis, visited, thisKey);
@@ -4293,17 +4388,17 @@ var PackingService = class {
4293
4388
  */
4294
4389
  async analyzeTool(toolName, agentsDir, analysis, visited, discoveredVia, parentKey) {
4295
4390
  const thisKey = `tool:${toolName}`;
4296
- const promptFilePath = await this.findFile(path7.join(agentsDir, "prompts"), toolName);
4391
+ const promptFilePath = await this.findFile(path8.join(agentsDir, "prompts"), toolName);
4297
4392
  if (promptFilePath) {
4298
4393
  await this.analyzePrompt(toolName, agentsDir, analysis, visited, parentKey);
4299
4394
  return;
4300
4395
  }
4301
- const agentFilePath = await this.findFile(path7.join(agentsDir, "agents"), toolName);
4396
+ const agentFilePath = await this.findFile(path8.join(agentsDir, "agents"), toolName);
4302
4397
  if (agentFilePath) {
4303
4398
  await this.analyzeNestedAgent(toolName, agentsDir, analysis, visited, parentKey);
4304
4399
  return;
4305
4400
  }
4306
- const toolFilePath = await this.findFile(path7.join(agentsDir, "tools"), toolName);
4401
+ const toolFilePath = await this.findFile(path8.join(agentsDir, "tools"), toolName);
4307
4402
  if (!toolFilePath) {
4308
4403
  analysis.warnings.push(`Tool file not found: ${toolName}`);
4309
4404
  return;
@@ -4321,7 +4416,7 @@ var PackingService = class {
4321
4416
  return;
4322
4417
  }
4323
4418
  visited.add(`tool:${toolName}`);
4324
- const toolSource = fs7.readFileSync(toolFilePath, "utf-8");
4419
+ const toolSource = fs8.readFileSync(toolFilePath, "utf-8");
4325
4420
  const { uses } = await extractToolUses(toolSource);
4326
4421
  for (const usedItem of uses) {
4327
4422
  await this.analyzeTool(usedItem, agentsDir, analysis, visited, "uses", thisKey);
@@ -4331,7 +4426,7 @@ var PackingService = class {
4331
4426
  * Analyze a nested agent (used as a handoff target).
4332
4427
  */
4333
4428
  async analyzeNestedAgent(agentName, agentsDir, analysis, visited, parentKey) {
4334
- const agentFilePath = await this.findFile(path7.join(agentsDir, "agents"), agentName);
4429
+ const agentFilePath = await this.findFile(path8.join(agentsDir, "agents"), agentName);
4335
4430
  if (!agentFilePath) {
4336
4431
  analysis.warnings.push(`Agent file not found: ${agentName}`);
4337
4432
  return;
@@ -4350,7 +4445,7 @@ var PackingService = class {
4350
4445
  return;
4351
4446
  }
4352
4447
  visited.add(`agent:${agentName}`);
4353
- const agentSource = fs7.readFileSync(agentFilePath, "utf-8");
4448
+ const agentSource = fs8.readFileSync(agentFilePath, "utf-8");
4354
4449
  const agentPrompts = await extractAgentPrompts(agentSource);
4355
4450
  if (agentPrompts.sideA) {
4356
4451
  await this.analyzePrompt(agentPrompts.sideA, agentsDir, analysis, visited, thisKey);
@@ -4363,7 +4458,7 @@ var PackingService = class {
4363
4458
  * Analyze a model and its fallbacks.
4364
4459
  */
4365
4460
  async analyzeModel(modelName, agentsDir, analysis, visited, parentKey) {
4366
- const modelFilePath = await this.findFile(path7.join(agentsDir, "models"), modelName);
4461
+ const modelFilePath = await this.findFile(path8.join(agentsDir, "models"), modelName);
4367
4462
  if (!modelFilePath) {
4368
4463
  analysis.warnings.push(`Model file not found: ${modelName}`);
4369
4464
  return;
@@ -4382,7 +4477,7 @@ var PackingService = class {
4382
4477
  return;
4383
4478
  }
4384
4479
  visited.add(`model:${modelName}`);
4385
- const modelSource = fs7.readFileSync(modelFilePath, "utf-8");
4480
+ const modelSource = fs8.readFileSync(modelFilePath, "utf-8");
4386
4481
  const fallbacks = await extractModelFallbacks(modelSource);
4387
4482
  for (const fallbackName of fallbacks) {
4388
4483
  await this.analyzeModel(fallbackName, agentsDir, analysis, visited, thisKey);
@@ -4392,13 +4487,13 @@ var PackingService = class {
4392
4487
  * Check which items are shared with other agents.
4393
4488
  */
4394
4489
  async checkSharedItems(agentsDir, analysis) {
4395
- const agentsPath = path7.join(agentsDir, "agents");
4396
- if (!fs7.existsSync(agentsPath)) return;
4397
- const agentFiles = fs7.readdirSync(agentsPath).filter((f) => f.endsWith(".ts"));
4490
+ const agentsPath = path8.join(agentsDir, "agents");
4491
+ if (!fs8.existsSync(agentsPath)) return;
4492
+ const agentFiles = fs8.readdirSync(agentsPath).filter((f) => f.endsWith(".ts"));
4398
4493
  for (const agentFile of agentFiles) {
4399
4494
  const otherAgentName = agentFile.replace(".ts", "");
4400
4495
  if (otherAgentName === analysis.agent) continue;
4401
- const otherAnalysis = await this.analyzeAgentLight(otherAgentName, path7.dirname(agentsDir));
4496
+ const otherAnalysis = await this.analyzeAgentLight(otherAgentName, path8.dirname(agentsDir));
4402
4497
  for (const prompt of analysis.constituents.prompts) {
4403
4498
  if (otherAnalysis.prompts.includes(prompt.name)) {
4404
4499
  prompt.sharedWith.push(otherAgentName);
@@ -4430,19 +4525,19 @@ var PackingService = class {
4430
4525
  */
4431
4526
  async analyzeAgentLight(agentName, rootDir) {
4432
4527
  const result = { prompts: [], tools: [], models: [] };
4433
- const agentsDir = path7.join(rootDir, "agents");
4528
+ const agentsDir = path8.join(rootDir, "agents");
4434
4529
  const visited = /* @__PURE__ */ new Set();
4435
- const agentFilePath = await this.findFile(path7.join(agentsDir, "agents"), agentName);
4530
+ const agentFilePath = await this.findFile(path8.join(agentsDir, "agents"), agentName);
4436
4531
  if (!agentFilePath) return result;
4437
- const agentSource = fs7.readFileSync(agentFilePath, "utf-8");
4532
+ const agentSource = fs8.readFileSync(agentFilePath, "utf-8");
4438
4533
  const agentPrompts = await extractAgentPrompts(agentSource);
4439
4534
  const analyzePromptLight = async (promptName) => {
4440
4535
  if (visited.has(promptName)) return;
4441
4536
  visited.add(promptName);
4442
4537
  result.prompts.push(promptName);
4443
- const promptFilePath = await this.findFile(path7.join(agentsDir, "prompts"), promptName);
4538
+ const promptFilePath = await this.findFile(path8.join(agentsDir, "prompts"), promptName);
4444
4539
  if (!promptFilePath) return;
4445
- const promptSource = fs7.readFileSync(promptFilePath, "utf-8");
4540
+ const promptSource = fs8.readFileSync(promptFilePath, "utf-8");
4446
4541
  const modelName = await extractPromptModel(promptSource);
4447
4542
  if (modelName && !result.models.includes(modelName)) {
4448
4543
  result.models.push(modelName);
@@ -4515,14 +4610,14 @@ var PackingService = class {
4515
4610
  return result;
4516
4611
  }
4517
4612
  result.warnings = analysis.warnings;
4518
- const pkgOutputDir = path7.join(outputDir, packageId);
4519
- fs7.mkdirSync(path7.join(pkgOutputDir, "dist", "agents"), { recursive: true });
4520
- fs7.mkdirSync(path7.join(pkgOutputDir, "dist", "prompts"), { recursive: true });
4521
- fs7.mkdirSync(path7.join(pkgOutputDir, "dist", "tools"), { recursive: true });
4522
- fs7.mkdirSync(path7.join(pkgOutputDir, "dist", "models"), { recursive: true });
4523
- fs7.mkdirSync(path7.join(pkgOutputDir, "dist", "hooks"), { recursive: true });
4524
- fs7.mkdirSync(path7.join(pkgOutputDir, "dist", "effects"), { recursive: true });
4525
- fs7.mkdirSync(path7.join(pkgOutputDir, "dist", "thread-endpoints"), { recursive: true });
4613
+ const pkgOutputDir = path8.join(outputDir, packageId);
4614
+ fs8.mkdirSync(path8.join(pkgOutputDir, "dist", "agents"), { recursive: true });
4615
+ fs8.mkdirSync(path8.join(pkgOutputDir, "dist", "prompts"), { recursive: true });
4616
+ fs8.mkdirSync(path8.join(pkgOutputDir, "dist", "tools"), { recursive: true });
4617
+ fs8.mkdirSync(path8.join(pkgOutputDir, "dist", "models"), { recursive: true });
4618
+ fs8.mkdirSync(path8.join(pkgOutputDir, "dist", "hooks"), { recursive: true });
4619
+ fs8.mkdirSync(path8.join(pkgOutputDir, "dist", "effects"), { recursive: true });
4620
+ fs8.mkdirSync(path8.join(pkgOutputDir, "dist", "thread-endpoints"), { recursive: true });
4526
4621
  const seenItems = /* @__PURE__ */ new Set();
4527
4622
  const allItems = [];
4528
4623
  for (const a of analysis.constituents.agents) {
@@ -4576,13 +4671,13 @@ var PackingService = class {
4576
4671
  }
4577
4672
  const externalDeps = /* @__PURE__ */ new Map();
4578
4673
  for (const item of allItems) {
4579
- const outputPath = path7.join(
4674
+ const outputPath = path8.join(
4580
4675
  pkgOutputDir,
4581
4676
  "dist",
4582
4677
  this.getTypeDir(item.type),
4583
4678
  `${item.name}.js`
4584
4679
  );
4585
- fs7.mkdirSync(path7.dirname(outputPath), { recursive: true });
4680
+ fs8.mkdirSync(path8.dirname(outputPath), { recursive: true });
4586
4681
  const deps = await this.bundleFile(item.filePath, outputPath, rootDir);
4587
4682
  for (const [depName, depVersion] of deps) {
4588
4683
  if (!externalDeps.has(depName)) {
@@ -4592,12 +4687,12 @@ var PackingService = class {
4592
4687
  result.filesCreated.push(outputPath);
4593
4688
  }
4594
4689
  const indexJs = this.generateReExportIndex(analysis, meta);
4595
- const indexJsPath = path7.join(pkgOutputDir, "dist", "index.js");
4596
- fs7.writeFileSync(indexJsPath, indexJs);
4690
+ const indexJsPath = path8.join(pkgOutputDir, "dist", "index.js");
4691
+ fs8.writeFileSync(indexJsPath, indexJs);
4597
4692
  result.filesCreated.push(indexJsPath);
4598
4693
  const indexDts = this.generateIndexDts(analysis);
4599
- const indexDtsPath = path7.join(pkgOutputDir, "dist", "index.d.ts");
4600
- fs7.writeFileSync(indexDtsPath, indexDts);
4694
+ const indexDtsPath = path8.join(pkgOutputDir, "dist", "index.d.ts");
4695
+ fs8.writeFileSync(indexDtsPath, indexDts);
4601
4696
  result.filesCreated.push(indexDtsPath);
4602
4697
  const pkgJson = this.generatePackageJson(
4603
4698
  finalPackageName,
@@ -4610,13 +4705,13 @@ var PackingService = class {
4610
4705
  license,
4611
4706
  licenseOwner
4612
4707
  );
4613
- const pkgJsonPath = path7.join(pkgOutputDir, "package.json");
4614
- fs7.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
4708
+ const pkgJsonPath = path8.join(pkgOutputDir, "package.json");
4709
+ fs8.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
4615
4710
  result.filesCreated.push(pkgJsonPath);
4616
4711
  if (license) {
4617
4712
  const licenseContent = this.generateLicenseFile(license, licenseOwner);
4618
- const licensePath = path7.join(pkgOutputDir, "LICENSE");
4619
- fs7.writeFileSync(licensePath, licenseContent);
4713
+ const licensePath = path8.join(pkgOutputDir, "LICENSE");
4714
+ fs8.writeFileSync(licensePath, licenseContent);
4620
4715
  result.filesCreated.push(licensePath);
4621
4716
  }
4622
4717
  let readmeContent = readme;
@@ -4624,7 +4719,7 @@ var PackingService = class {
4624
4719
  const agentItem = analysis.constituents.agents.find((a) => a.name === agentName);
4625
4720
  let agentDescription;
4626
4721
  if (agentItem?.filePath) {
4627
- const agentSource = fs7.readFileSync(agentItem.filePath, "utf-8");
4722
+ const agentSource = fs8.readFileSync(agentItem.filePath, "utf-8");
4628
4723
  agentDescription = await extractAgentDescription(agentSource) || void 0;
4629
4724
  }
4630
4725
  readmeContent = this.generateReadme(
@@ -4635,21 +4730,21 @@ var PackingService = class {
4635
4730
  agentDescription
4636
4731
  );
4637
4732
  }
4638
- const readmePath = path7.join(pkgOutputDir, "README.md");
4639
- fs7.writeFileSync(readmePath, readmeContent);
4733
+ const readmePath = path8.join(pkgOutputDir, "README.md");
4734
+ fs8.writeFileSync(readmePath, readmeContent);
4640
4735
  result.filesCreated.push(readmePath);
4641
4736
  if (removeOriginals || itemSelections) {
4642
4737
  result.filesRemoved = [];
4643
4738
  for (const item of allItems) {
4644
4739
  const selection = itemSelections?.find((s) => s.name === item.name && s.type === item.type);
4645
4740
  const shouldRemove = selection ? selection.mode === "extract" : removeOriginals && item.sharedWith.length === 0 && item.type !== "thread-endpoint" && item.type !== "effect";
4646
- if (shouldRemove && fs7.existsSync(item.filePath)) {
4647
- fs7.unlinkSync(item.filePath);
4741
+ if (shouldRemove && fs8.existsSync(item.filePath)) {
4742
+ fs8.unlinkSync(item.filePath);
4648
4743
  result.filesRemoved.push(item.filePath);
4649
4744
  }
4650
4745
  }
4651
4746
  }
4652
- const agentsDir = path7.join(rootDir, "agents");
4747
+ const agentsDir = path8.join(rootDir, "agents");
4653
4748
  const metadataService = new MetadataService(agentsDir);
4654
4749
  const metadata = {
4655
4750
  packageName: finalPackageName,
@@ -4683,7 +4778,7 @@ var PackingService = class {
4683
4778
  const commonjs = (await import('@rollup/plugin-commonjs')).default;
4684
4779
  const esbuild = (await import('rollup-plugin-esbuild')).default;
4685
4780
  const externalDeps = /* @__PURE__ */ new Map();
4686
- const agentsDir = path7.join(rootDir, "agents");
4781
+ const agentsDir = path8.join(rootDir, "agents");
4687
4782
  const resolveVersion = this.resolvePackageVersion.bind(this);
4688
4783
  const trackExternalsPlugin = {
4689
4784
  name: "track-externals",
@@ -4692,14 +4787,14 @@ var PackingService = class {
4692
4787
  return null;
4693
4788
  }
4694
4789
  if (source.startsWith("./") || source.startsWith("../")) {
4695
- const resolved = path7.resolve(path7.dirname(importer), source);
4790
+ const resolved = path8.resolve(path8.dirname(importer), source);
4696
4791
  let tsResolved = resolved;
4697
4792
  if (!resolved.endsWith(".ts") && !resolved.endsWith(".js")) {
4698
- if (fs7.existsSync(`${resolved}.ts`)) {
4793
+ if (fs8.existsSync(`${resolved}.ts`)) {
4699
4794
  tsResolved = `${resolved}.ts`;
4700
- } else if (fs7.existsSync(`${resolved}.js`)) {
4795
+ } else if (fs8.existsSync(`${resolved}.js`)) {
4701
4796
  tsResolved = `${resolved}.js`;
4702
- } else if (fs7.existsSync(`${resolved}/index.ts`)) {
4797
+ } else if (fs8.existsSync(`${resolved}/index.ts`)) {
4703
4798
  tsResolved = `${resolved}/index.ts`;
4704
4799
  }
4705
4800
  }
@@ -4748,11 +4843,11 @@ var PackingService = class {
4748
4843
  exports: "named"
4749
4844
  });
4750
4845
  const bundledCode = output[0].code;
4751
- const header = `// Bundled from: ${path7.relative(rootDir, inputPath)}
4846
+ const header = `// Bundled from: ${path8.relative(rootDir, inputPath)}
4752
4847
  // Local dependencies have been inlined
4753
4848
 
4754
4849
  `;
4755
- fs7.writeFileSync(outputPath, header + bundledCode);
4850
+ fs8.writeFileSync(outputPath, header + bundledCode);
4756
4851
  await bundle.close();
4757
4852
  } catch (error) {
4758
4853
  await bundle.close();
@@ -5177,30 +5272,30 @@ Copyright (c) ${year} ${copyrightHolder}
5177
5272
  * @returns Package info or null if not found
5178
5273
  */
5179
5274
  getPackedInfo(packageId, rootDir) {
5180
- const packedDir = path7.join(rootDir, "agents", "packed");
5181
- let packageDir = path7.join(packedDir, packageId);
5182
- if (!fs7.existsSync(packageDir)) {
5183
- if (!fs7.existsSync(packedDir)) {
5275
+ const packedDir = path8.join(rootDir, "agents", "packed");
5276
+ let packageDir = path8.join(packedDir, packageId);
5277
+ if (!fs8.existsSync(packageDir)) {
5278
+ if (!fs8.existsSync(packedDir)) {
5184
5279
  return null;
5185
5280
  }
5186
- const dirs = fs7.readdirSync(packedDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
5281
+ const dirs = fs8.readdirSync(packedDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
5187
5282
  const matchingDir = dirs.find(
5188
5283
  (d) => d === packageId || d === `standardagent-${packageId}` || d === `standardagent-${packageId.replace(/_/g, "-")}`
5189
5284
  );
5190
5285
  if (!matchingDir) {
5191
5286
  return null;
5192
5287
  }
5193
- packageDir = path7.join(packedDir, matchingDir);
5288
+ packageDir = path8.join(packedDir, matchingDir);
5194
5289
  }
5195
- const pkgJsonPath = path7.join(packageDir, "package.json");
5196
- if (!fs7.existsSync(pkgJsonPath)) {
5290
+ const pkgJsonPath = path8.join(packageDir, "package.json");
5291
+ if (!fs8.existsSync(pkgJsonPath)) {
5197
5292
  return null;
5198
5293
  }
5199
- const pkgJson = JSON.parse(fs7.readFileSync(pkgJsonPath, "utf-8"));
5294
+ const pkgJson = JSON.parse(fs8.readFileSync(pkgJsonPath, "utf-8"));
5200
5295
  let readme;
5201
- const readmePath = path7.join(packageDir, "README.md");
5202
- if (fs7.existsSync(readmePath)) {
5203
- readme = fs7.readFileSync(readmePath, "utf-8");
5296
+ const readmePath = path8.join(packageDir, "README.md");
5297
+ if (fs8.existsSync(readmePath)) {
5298
+ readme = fs8.readFileSync(readmePath, "utf-8");
5204
5299
  }
5205
5300
  return {
5206
5301
  packageName: pkgJson.name,
@@ -5218,11 +5313,11 @@ Copyright (c) ${year} ${copyrightHolder}
5218
5313
  * @returns Array of package directory names
5219
5314
  */
5220
5315
  listPackedPackages(rootDir) {
5221
- const packedDir = path7.join(rootDir, "agents", "packed");
5222
- if (!fs7.existsSync(packedDir)) {
5316
+ const packedDir = path8.join(rootDir, "agents", "packed");
5317
+ if (!fs8.existsSync(packedDir)) {
5223
5318
  return [];
5224
5319
  }
5225
- return fs7.readdirSync(packedDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
5320
+ return fs8.readdirSync(packedDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
5226
5321
  }
5227
5322
  /**
5228
5323
  * Generate README.md content for a packed agent.
@@ -5269,17 +5364,17 @@ ${license || "See LICENSE file"}
5269
5364
  * Find a file by name in a directory.
5270
5365
  */
5271
5366
  async findFile(dir, name) {
5272
- if (!fs7.existsSync(dir)) {
5367
+ if (!fs8.existsSync(dir)) {
5273
5368
  return null;
5274
5369
  }
5275
- const exactPath = path7.join(dir, `${name}.ts`);
5276
- if (fs7.existsSync(exactPath)) {
5370
+ const exactPath = path8.join(dir, `${name}.ts`);
5371
+ if (fs8.existsSync(exactPath)) {
5277
5372
  return exactPath;
5278
5373
  }
5279
- const files = fs7.readdirSync(dir).filter((f) => f.endsWith(".ts"));
5374
+ const files = fs8.readdirSync(dir).filter((f) => f.endsWith(".ts"));
5280
5375
  for (const file of files) {
5281
- const filePath = path7.join(dir, file);
5282
- const source = fs7.readFileSync(filePath, "utf-8");
5376
+ const filePath = path8.join(dir, file);
5377
+ const source = fs8.readFileSync(filePath, "utf-8");
5283
5378
  const extractedName = await extractDefinitionName(source);
5284
5379
  if (extractedName === name) {
5285
5380
  return filePath;
@@ -5291,15 +5386,15 @@ ${license || "See LICENSE file"}
5291
5386
  * List all agents in the workspace.
5292
5387
  */
5293
5388
  async listAgents(rootDir) {
5294
- const agentsDir = path7.join(rootDir, "agents", "agents");
5295
- if (!fs7.existsSync(agentsDir)) {
5389
+ const agentsDir = path8.join(rootDir, "agents", "agents");
5390
+ if (!fs8.existsSync(agentsDir)) {
5296
5391
  return [];
5297
5392
  }
5298
- const files = fs7.readdirSync(agentsDir).filter((f) => f.endsWith(".ts"));
5393
+ const files = fs8.readdirSync(agentsDir).filter((f) => f.endsWith(".ts"));
5299
5394
  const agents = [];
5300
5395
  for (const file of files) {
5301
- const filePath = path7.join(agentsDir, file);
5302
- const source = fs7.readFileSync(filePath, "utf-8");
5396
+ const filePath = path8.join(agentsDir, file);
5397
+ const source = fs8.readFileSync(filePath, "utf-8");
5303
5398
  const name = await extractDefinitionName(source);
5304
5399
  if (name) {
5305
5400
  agents.push(name);
@@ -5315,7 +5410,7 @@ var PackageDiscoveryService = class {
5315
5410
  constructor(config) {
5316
5411
  this.config = {
5317
5412
  rootDir: config.rootDir,
5318
- packedDir: config.packedDir ?? path7.join(config.rootDir, "agents", "packed"),
5413
+ packedDir: config.packedDir ?? path8.join(config.rootDir, "agents", "packed"),
5319
5414
  scanNpm: config.scanNpm ?? true,
5320
5415
  scanLocal: config.scanLocal ?? true
5321
5416
  };
@@ -5348,19 +5443,19 @@ var PackageDiscoveryService = class {
5348
5443
  */
5349
5444
  async discoverNpmPackages() {
5350
5445
  const packages = [];
5351
- const nodeModulesDir = path7.join(this.config.rootDir, "node_modules");
5352
- if (!fs7.existsSync(nodeModulesDir)) {
5446
+ const nodeModulesDir = path8.join(this.config.rootDir, "node_modules");
5447
+ if (!fs8.existsSync(nodeModulesDir)) {
5353
5448
  return packages;
5354
5449
  }
5355
5450
  const rootEntries = await this.scanDirectory(nodeModulesDir);
5356
5451
  for (const entry of rootEntries) {
5357
5452
  if (entry.startsWith(".")) continue;
5358
5453
  if (entry.startsWith("@")) {
5359
- const scopeDir = path7.join(nodeModulesDir, entry);
5454
+ const scopeDir = path8.join(nodeModulesDir, entry);
5360
5455
  const scopeEntries = await this.scanDirectory(scopeDir);
5361
5456
  for (const scopedPkg of scopeEntries) {
5362
5457
  if (scopedPkg.startsWith(".")) continue;
5363
- const pkgDir = path7.join(scopeDir, scopedPkg);
5458
+ const pkgDir = path8.join(scopeDir, scopedPkg);
5364
5459
  const fullName = `${entry}/${scopedPkg}`;
5365
5460
  const pkg = await this.checkNpmPackage(pkgDir, fullName);
5366
5461
  if (pkg) {
@@ -5368,7 +5463,7 @@ var PackageDiscoveryService = class {
5368
5463
  }
5369
5464
  }
5370
5465
  } else {
5371
- const pkgDir = path7.join(nodeModulesDir, entry);
5466
+ const pkgDir = path8.join(nodeModulesDir, entry);
5372
5467
  const pkg = await this.checkNpmPackage(pkgDir, entry);
5373
5468
  if (pkg) {
5374
5469
  packages.push(pkg);
@@ -5384,12 +5479,12 @@ var PackageDiscoveryService = class {
5384
5479
  * which must contain `entryAgents` array.
5385
5480
  */
5386
5481
  async checkNpmPackage(pkgDir, pkgName) {
5387
- const pkgJsonPath = path7.join(pkgDir, "package.json");
5388
- if (!fs7.existsSync(pkgJsonPath)) {
5482
+ const pkgJsonPath = path8.join(pkgDir, "package.json");
5483
+ if (!fs8.existsSync(pkgJsonPath)) {
5389
5484
  return null;
5390
5485
  }
5391
5486
  try {
5392
- const pkgJson = JSON.parse(fs7.readFileSync(pkgJsonPath, "utf-8"));
5487
+ const pkgJson = JSON.parse(fs8.readFileSync(pkgJsonPath, "utf-8"));
5393
5488
  const isStandardAgent = (
5394
5489
  // Has "standardagent" keyword
5395
5490
  pkgJson.keywords?.includes("standardagent") || // Has "standardagent-*" prefix
@@ -5426,21 +5521,21 @@ var PackageDiscoveryService = class {
5426
5521
  */
5427
5522
  async discoverLocalPackages() {
5428
5523
  const packages = [];
5429
- if (!fs7.existsSync(this.config.packedDir)) {
5524
+ if (!fs8.existsSync(this.config.packedDir)) {
5430
5525
  return packages;
5431
5526
  }
5432
5527
  const entries = await this.scanDirectory(this.config.packedDir);
5433
5528
  for (const entry of entries) {
5434
5529
  if (entry.startsWith(".")) continue;
5435
- const pkgDir = path7.join(this.config.packedDir, entry);
5436
- const stat = fs7.statSync(pkgDir);
5530
+ const pkgDir = path8.join(this.config.packedDir, entry);
5531
+ const stat = fs8.statSync(pkgDir);
5437
5532
  if (!stat.isDirectory()) continue;
5438
5533
  if (entry.startsWith("@")) {
5439
5534
  const scopeEntries = await this.scanDirectory(pkgDir);
5440
5535
  for (const scopedPkg of scopeEntries) {
5441
5536
  if (scopedPkg.startsWith(".")) continue;
5442
- const scopedPkgDir = path7.join(pkgDir, scopedPkg);
5443
- const scopedStat = fs7.statSync(scopedPkgDir);
5537
+ const scopedPkgDir = path8.join(pkgDir, scopedPkg);
5538
+ const scopedStat = fs8.statSync(scopedPkgDir);
5444
5539
  if (!scopedStat.isDirectory()) continue;
5445
5540
  const fullName = `${entry}/${scopedPkg}`;
5446
5541
  const pkg = await this.checkLocalPackage(scopedPkgDir, fullName);
@@ -5463,12 +5558,12 @@ var PackageDiscoveryService = class {
5463
5558
  * Detection is based on the `standardagent` field in package.json.
5464
5559
  */
5465
5560
  async checkLocalPackage(pkgDir, dirName) {
5466
- const pkgJsonPath = path7.join(pkgDir, "package.json");
5467
- if (!fs7.existsSync(pkgJsonPath)) {
5561
+ const pkgJsonPath = path8.join(pkgDir, "package.json");
5562
+ if (!fs8.existsSync(pkgJsonPath)) {
5468
5563
  return null;
5469
5564
  }
5470
5565
  try {
5471
- const pkgJson = JSON.parse(fs7.readFileSync(pkgJsonPath, "utf-8"));
5566
+ const pkgJson = JSON.parse(fs8.readFileSync(pkgJsonPath, "utf-8"));
5472
5567
  if (!pkgJson.standardagent?.entryAgents) {
5473
5568
  return null;
5474
5569
  }
@@ -5493,10 +5588,10 @@ var PackageDiscoveryService = class {
5493
5588
  * Scan a directory and return entry names.
5494
5589
  */
5495
5590
  async scanDirectory(dir) {
5496
- if (!fs7.existsSync(dir)) {
5591
+ if (!fs8.existsSync(dir)) {
5497
5592
  return [];
5498
5593
  }
5499
- const entries = fs7.readdirSync(dir);
5594
+ const entries = fs8.readdirSync(dir);
5500
5595
  return entries;
5501
5596
  }
5502
5597
  /**
@@ -5589,29 +5684,29 @@ var UnpackingService = class {
5589
5684
  }
5590
5685
  analysis.version = pkg.version;
5591
5686
  analysis.source = pkg.source;
5592
- const indexPath = path7.join(pkg.path, "dist", "index.js");
5593
- if (!fs7.existsSync(indexPath)) {
5687
+ const indexPath = path8.join(pkg.path, "dist", "index.js");
5688
+ if (!fs8.existsSync(indexPath)) {
5594
5689
  analysis.errors.push(`Package index not found: ${indexPath}`);
5595
5690
  return analysis;
5596
5691
  }
5597
- const indexContent = fs7.readFileSync(indexPath, "utf-8");
5692
+ const indexContent = fs8.readFileSync(indexPath, "utf-8");
5598
5693
  const registryItems = await this.parseIndexExports(indexContent);
5599
5694
  const availableItems = /* @__PURE__ */ new Map();
5600
5695
  for (const item of registryItems) {
5601
5696
  availableItems.set(`${item.type}:${item.name}`, item);
5602
5697
  }
5603
- const agentsDir = path7.join(rootDir, "agents");
5698
+ const agentsDir = path8.join(rootDir, "agents");
5604
5699
  const itemsWithRelations = [];
5605
5700
  for (const item of registryItems) {
5606
- const targetPath = path7.join(agentsDir, TYPE_TO_TARGET_DIR[item.type], `${item.name}.ts`);
5607
- const sourcePath = path7.join(pkg.path, "dist", TYPE_TO_DIR[item.type], `${item.name}.js`);
5701
+ const targetPath = path8.join(agentsDir, TYPE_TO_TARGET_DIR[item.type], `${item.name}.ts`);
5702
+ const sourcePath = path8.join(pkg.path, "dist", TYPE_TO_DIR[item.type], `${item.name}.js`);
5608
5703
  const existsGlobally = this.fileExists(targetPath);
5609
- const sourceExists = fs7.existsSync(sourcePath);
5704
+ const sourceExists = fs8.existsSync(sourcePath);
5610
5705
  if (!sourceExists) {
5611
5706
  analysis.warnings.push(`Source file not found for ${item.type} "${item.name}": ${sourcePath}`);
5612
5707
  continue;
5613
5708
  }
5614
- const bundledCode = fs7.readFileSync(sourcePath, "utf-8");
5709
+ const bundledCode = fs8.readFileSync(sourcePath, "utf-8");
5615
5710
  const children = await this.discoverRelationships(item.type, item.name, bundledCode, availableItems);
5616
5711
  itemsWithRelations.push({
5617
5712
  name: item.name,
@@ -5621,10 +5716,10 @@ var UnpackingService = class {
5621
5716
  action: existsGlobally ? "skip" : "generate"
5622
5717
  });
5623
5718
  for (const child of children) {
5624
- const childTargetPath = path7.join(agentsDir, TYPE_TO_TARGET_DIR[child.type], `${child.name}.ts`);
5625
- const childSourcePath = path7.join(pkg.path, "dist", TYPE_TO_DIR[child.type], `${child.name}.js`);
5719
+ const childTargetPath = path8.join(agentsDir, TYPE_TO_TARGET_DIR[child.type], `${child.name}.ts`);
5720
+ const childSourcePath = path8.join(pkg.path, "dist", TYPE_TO_DIR[child.type], `${child.name}.js`);
5626
5721
  const childExists = this.fileExists(childTargetPath);
5627
- const childSourceExists = fs7.existsSync(childSourcePath);
5722
+ const childSourceExists = fs8.existsSync(childSourcePath);
5628
5723
  if (!childSourceExists) {
5629
5724
  continue;
5630
5725
  }
@@ -5727,8 +5822,8 @@ var UnpackingService = class {
5727
5822
  return result;
5728
5823
  }
5729
5824
  const itemsToProcess = this.applySelections(analysis.items, itemSelections);
5730
- const pkgJsonPath = path7.join(pkg.path, "package.json");
5731
- const pkgJson = JSON.parse(fs7.readFileSync(pkgJsonPath, "utf-8"));
5825
+ const pkgJsonPath = path8.join(pkg.path, "package.json");
5826
+ const pkgJson = JSON.parse(fs8.readFileSync(pkgJsonPath, "utf-8"));
5732
5827
  let author = "";
5733
5828
  if (typeof pkgJson.author === "string") {
5734
5829
  author = pkgJson.author;
@@ -5753,17 +5848,17 @@ var UnpackingService = class {
5753
5848
  continue;
5754
5849
  }
5755
5850
  try {
5756
- const sourcePath = path7.join(pkg.path, "dist", TYPE_TO_DIR[item.type], `${item.name}.js`);
5757
- const bundledCode = fs7.readFileSync(sourcePath, "utf-8");
5851
+ const sourcePath = path8.join(pkg.path, "dist", TYPE_TO_DIR[item.type], `${item.name}.js`);
5852
+ const bundledCode = fs8.readFileSync(sourcePath, "utf-8");
5758
5853
  let tsCode = await transformBundledJs(bundledCode);
5759
5854
  if (item.type === "agent") {
5760
5855
  tsCode = await injectAgentMetadata(tsCode, agentMetadata);
5761
5856
  }
5762
- const dir = path7.dirname(item.targetPath);
5763
- if (!fs7.existsSync(dir)) {
5764
- fs7.mkdirSync(dir, { recursive: true });
5857
+ const dir = path8.dirname(item.targetPath);
5858
+ if (!fs8.existsSync(dir)) {
5859
+ fs8.mkdirSync(dir, { recursive: true });
5765
5860
  }
5766
- fs7.writeFileSync(item.targetPath, tsCode);
5861
+ fs8.writeFileSync(item.targetPath, tsCode);
5767
5862
  result.filesGenerated.push(item.targetPath);
5768
5863
  } catch (error) {
5769
5864
  result.warnings.push(
@@ -5852,14 +5947,14 @@ var UnpackingService = class {
5852
5947
  */
5853
5948
  async resolvePackage(pkgIdentifier, rootDir) {
5854
5949
  if (pkgIdentifier.startsWith("/") || pkgIdentifier.startsWith("./")) {
5855
- const absolutePath = path7.isAbsolute(pkgIdentifier) ? pkgIdentifier : path7.join(rootDir, pkgIdentifier);
5856
- const pkgJsonPath2 = path7.join(absolutePath, "package.json");
5857
- if (fs7.existsSync(pkgJsonPath2)) {
5950
+ const absolutePath = path8.isAbsolute(pkgIdentifier) ? pkgIdentifier : path8.join(rootDir, pkgIdentifier);
5951
+ const pkgJsonPath2 = path8.join(absolutePath, "package.json");
5952
+ if (fs8.existsSync(pkgJsonPath2)) {
5858
5953
  try {
5859
- const pkgJson = JSON.parse(fs7.readFileSync(pkgJsonPath2, "utf-8"));
5954
+ const pkgJson = JSON.parse(fs8.readFileSync(pkgJsonPath2, "utf-8"));
5860
5955
  if (pkgJson.standardagent?.entryAgents) {
5861
5956
  return {
5862
- packageId: pkgJson.name || path7.basename(absolutePath),
5957
+ packageId: pkgJson.name || path8.basename(absolutePath),
5863
5958
  version: pkgJson.version || "0.0.0",
5864
5959
  source: "local",
5865
5960
  path: absolutePath,
@@ -5871,11 +5966,11 @@ var UnpackingService = class {
5871
5966
  }
5872
5967
  return null;
5873
5968
  }
5874
- const packedDir = path7.join(rootDir, "agents", "packed", pkgIdentifier);
5875
- const pkgJsonPath = path7.join(packedDir, "package.json");
5876
- if (fs7.existsSync(pkgJsonPath)) {
5969
+ const packedDir = path8.join(rootDir, "agents", "packed", pkgIdentifier);
5970
+ const pkgJsonPath = path8.join(packedDir, "package.json");
5971
+ if (fs8.existsSync(pkgJsonPath)) {
5877
5972
  try {
5878
- const pkgJson = JSON.parse(fs7.readFileSync(pkgJsonPath, "utf-8"));
5973
+ const pkgJson = JSON.parse(fs8.readFileSync(pkgJsonPath, "utf-8"));
5879
5974
  if (pkgJson.standardagent?.entryAgents) {
5880
5975
  return {
5881
5976
  packageId: pkgJson.name || pkgIdentifier,
@@ -5916,18 +6011,18 @@ var UnpackingService = class {
5916
6011
  * Check if a file exists.
5917
6012
  */
5918
6013
  fileExists(filePath) {
5919
- if (fs7.existsSync(filePath)) {
6014
+ if (fs8.existsSync(filePath)) {
5920
6015
  return true;
5921
6016
  }
5922
6017
  const withoutExt = filePath.replace(/\.(ts|js)$/, "");
5923
- return fs7.existsSync(`${withoutExt}.ts`) || fs7.existsSync(`${withoutExt}.js`);
6018
+ return fs8.existsSync(`${withoutExt}.ts`) || fs8.existsSync(`${withoutExt}.js`);
5924
6019
  }
5925
6020
  /**
5926
6021
  * Recursively delete a directory.
5927
6022
  */
5928
6023
  deleteDirectory(dirPath) {
5929
- if (fs7.existsSync(dirPath)) {
5930
- fs7.rmSync(dirPath, { recursive: true, force: true });
6024
+ if (fs8.existsSync(dirPath)) {
6025
+ fs8.rmSync(dirPath, { recursive: true, force: true });
5931
6026
  }
5932
6027
  }
5933
6028
  /**
@@ -6003,8 +6098,8 @@ var NpmPublishService = class {
6003
6098
  error: "Registry URL must use HTTPS"
6004
6099
  };
6005
6100
  }
6006
- const pkgJsonPath = path7.join(packageDir, "package.json");
6007
- if (!fs7.existsSync(pkgJsonPath)) {
6101
+ const pkgJsonPath = path8.join(packageDir, "package.json");
6102
+ if (!fs8.existsSync(pkgJsonPath)) {
6008
6103
  return {
6009
6104
  success: false,
6010
6105
  output: "",
@@ -6014,7 +6109,7 @@ var NpmPublishService = class {
6014
6109
  let packageName;
6015
6110
  let version;
6016
6111
  try {
6017
- const pkgJson = JSON.parse(fs7.readFileSync(pkgJsonPath, "utf-8"));
6112
+ const pkgJson = JSON.parse(fs8.readFileSync(pkgJsonPath, "utf-8"));
6018
6113
  packageName = pkgJson.name;
6019
6114
  version = pkgJson.version;
6020
6115
  } catch (e) {
@@ -6024,13 +6119,13 @@ var NpmPublishService = class {
6024
6119
  error: `Failed to read package.json: ${e instanceof Error ? e.message : String(e)}`
6025
6120
  };
6026
6121
  }
6027
- const npmrcPath = path7.join(packageDir, ".npmrc");
6122
+ const npmrcPath = path8.join(packageDir, ".npmrc");
6028
6123
  const registryHost = new URL(registry).host;
6029
6124
  const npmrcContent = `//${registryHost}/:_authToken=${token}
6030
6125
  registry=${registry}
6031
6126
  `;
6032
6127
  try {
6033
- fs7.writeFileSync(npmrcPath, npmrcContent, { mode: 384 });
6128
+ fs8.writeFileSync(npmrcPath, npmrcContent, { mode: 384 });
6034
6129
  const args = ["publish"];
6035
6130
  if (dryRun) {
6036
6131
  args.push("--dry-run");
@@ -6062,8 +6157,8 @@ registry=${registry}
6062
6157
  };
6063
6158
  } finally {
6064
6159
  try {
6065
- if (fs7.existsSync(npmrcPath)) {
6066
- fs7.unlinkSync(npmrcPath);
6160
+ if (fs8.existsSync(npmrcPath)) {
6161
+ fs8.unlinkSync(npmrcPath);
6067
6162
  }
6068
6163
  } catch {
6069
6164
  }
@@ -6156,7 +6251,7 @@ async function handlePackingApiRequest(context) {
6156
6251
  const body = await parseRequestBody(req);
6157
6252
  const packingService = new PackingService();
6158
6253
  const rootDir = process.cwd();
6159
- const outputDir = path7__default.join(rootDir, "agents", "packed");
6254
+ const outputDir = path8__default.join(rootDir, "agents", "packed");
6160
6255
  const result = await packingService.pack({
6161
6256
  agentName,
6162
6257
  rootDir,
@@ -6209,8 +6304,8 @@ async function handlePackingApiRequest(context) {
6209
6304
  res.end(JSON.stringify({ error: "Cannot delete npm packages. Use npm uninstall instead." }));
6210
6305
  return true;
6211
6306
  }
6212
- const fs17 = await import('fs');
6213
- fs17.rmSync(pkg.path, { recursive: true, force: true });
6307
+ const fs18 = await import('fs');
6308
+ fs18.rmSync(pkg.path, { recursive: true, force: true });
6214
6309
  await reloadAllAgentModules(context);
6215
6310
  res.statusCode = 200;
6216
6311
  res.setHeader("Content-Type", "application/json");
@@ -6238,8 +6333,8 @@ async function handlePackingApiRequest(context) {
6238
6333
  return true;
6239
6334
  }
6240
6335
  const { spawn } = await import('child_process');
6241
- const parentDir = path7__default.dirname(pkg.path);
6242
- const dirName = path7__default.basename(pkg.path);
6336
+ const parentDir = path8__default.dirname(pkg.path);
6337
+ const dirName = path8__default.basename(pkg.path);
6243
6338
  res.setHeader("Content-Type", "application/gzip");
6244
6339
  res.setHeader("Content-Disposition", `attachment; filename="${packageId}.tar.gz"`);
6245
6340
  const tar = spawn("tar", ["-czf", "-", "-C", parentDir, dirName]);
@@ -6295,16 +6390,16 @@ async function handlePackingApiRequest(context) {
6295
6390
  const packageId = decodeURIComponent(packPublishMatch[1]);
6296
6391
  const body = await parseRequestBody(req);
6297
6392
  const rootDir = process.cwd();
6298
- const packedDir = path7__default.join(rootDir, "agents", "packed");
6299
- let packageDir = path7__default.join(packedDir, packageId);
6300
- if (!fs7__default.existsSync(packageDir)) {
6301
- if (!fs7__default.existsSync(packedDir)) {
6393
+ const packedDir = path8__default.join(rootDir, "agents", "packed");
6394
+ let packageDir = path8__default.join(packedDir, packageId);
6395
+ if (!fs8__default.existsSync(packageDir)) {
6396
+ if (!fs8__default.existsSync(packedDir)) {
6302
6397
  res.statusCode = 400;
6303
6398
  res.setHeader("Content-Type", "application/json");
6304
6399
  res.end(JSON.stringify({ error: "No packed packages found. Pack the agent first." }));
6305
6400
  return true;
6306
6401
  }
6307
- const dirs = fs7__default.readdirSync(packedDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
6402
+ const dirs = fs8__default.readdirSync(packedDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
6308
6403
  const matchingDir = dirs.find(
6309
6404
  (d) => d === packageId || d === `standardagent-${packageId}` || d === `standardagent-${packageId.replace(/_/g, "-")}`
6310
6405
  );
@@ -6316,14 +6411,14 @@ async function handlePackingApiRequest(context) {
6316
6411
  }));
6317
6412
  return true;
6318
6413
  }
6319
- packageDir = path7__default.join(packedDir, matchingDir);
6414
+ packageDir = path8__default.join(packedDir, matchingDir);
6320
6415
  }
6321
6416
  let token = body.token || process.env.NPM_TOKEN;
6322
6417
  let tokenSource = body.token ? "provided" : "environment";
6323
6418
  if (!token) {
6324
- const devVarsPath = path7__default.join(rootDir, ".dev.vars");
6325
- if (fs7__default.existsSync(devVarsPath)) {
6326
- const devVars = fs7__default.readFileSync(devVarsPath, "utf-8");
6419
+ const devVarsPath = path8__default.join(rootDir, ".dev.vars");
6420
+ if (fs8__default.existsSync(devVarsPath)) {
6421
+ const devVars = fs8__default.readFileSync(devVarsPath, "utf-8");
6327
6422
  const match = devVars.match(/^NPM_TOKEN=(.+)$/m);
6328
6423
  if (match) {
6329
6424
  token = match[1].trim();
@@ -6435,6 +6530,23 @@ async function handlePackingApiRequest(context) {
6435
6530
  }
6436
6531
 
6437
6532
  // src/plugin/dev-middleware.ts
6533
+ function readRawRequestBody(req) {
6534
+ return new Promise((resolve2, reject) => {
6535
+ const chunks = [];
6536
+ req.on("data", (chunk) => {
6537
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
6538
+ });
6539
+ req.on("end", () => {
6540
+ resolve2(chunks.length > 0 ? Buffer.concat(chunks) : void 0);
6541
+ });
6542
+ req.on("error", reject);
6543
+ });
6544
+ }
6545
+ function injectUiConfigIntoHtml(htmlContent, mountPoint) {
6546
+ const configScript = `<script>window.__AGENTBUILDER_CONFIG__ = { mountPoint: "${mountPoint}", devMode: true };</script>`;
6547
+ const assetPrefix = mountPoint === "/" ? "/" : `${mountPoint}/`;
6548
+ return htmlContent.replace(/\/agents\//g, assetPrefix).replace("</head>", `${configScript}</head>`);
6549
+ }
6438
6550
  function createDevMiddleware(server, context) {
6439
6551
  const {
6440
6552
  mountPoint,
@@ -6466,6 +6578,19 @@ function createDevMiddleware(server, context) {
6466
6578
  pathWithoutMount = "/" + pathWithoutMount;
6467
6579
  }
6468
6580
  const method = req.method?.toUpperCase();
6581
+ const legacyMountPoint = "/agentbuilder";
6582
+ if (mountPoint === "/" && (pathWithoutMount === legacyMountPoint || pathWithoutMount.startsWith(`${legacyMountPoint}/`))) {
6583
+ const normalizedPath = pathWithoutMount.slice(legacyMountPoint.length) || "/";
6584
+ if (normalizedPath.startsWith("/api/")) {
6585
+ req.url = normalizedPath;
6586
+ pathWithoutMount = normalizedPath;
6587
+ } else if (method === "GET" || method === "HEAD") {
6588
+ res.statusCode = 302;
6589
+ res.setHeader("Location", normalizedPath);
6590
+ res.end();
6591
+ return;
6592
+ }
6593
+ }
6469
6594
  if (await handleConfigApiRequest({
6470
6595
  req,
6471
6596
  res,
@@ -6496,6 +6621,14 @@ function createDevMiddleware(server, context) {
6496
6621
  })) {
6497
6622
  return;
6498
6623
  }
6624
+ const bootstrapCookie = resolveLocalBootstrapCookie(
6625
+ process.cwd(),
6626
+ pathWithoutMount,
6627
+ req.headers.cookie
6628
+ );
6629
+ if (bootstrapCookie) {
6630
+ req.headers.cookie = mergeCookieHeader(req.headers.cookie, bootstrapCookie);
6631
+ }
6499
6632
  if (pathWithoutMount.startsWith("/api/")) {
6500
6633
  next();
6501
6634
  return;
@@ -6504,13 +6637,38 @@ function createDevMiddleware(server, context) {
6504
6637
  if (uiDevServer && !pathWithoutMount.startsWith("/api/")) {
6505
6638
  const targetUrl = `${uiDevServer}${pathWithoutMount}`;
6506
6639
  try {
6507
- const proxyRes = await fetch(targetUrl);
6640
+ const proxyHeaders = new Headers();
6641
+ for (const [key, value] of Object.entries(req.headers)) {
6642
+ if (value === void 0) continue;
6643
+ if (Array.isArray(value)) {
6644
+ for (const item of value) {
6645
+ proxyHeaders.append(key, item);
6646
+ }
6647
+ continue;
6648
+ }
6649
+ proxyHeaders.set(key, value);
6650
+ }
6651
+ proxyHeaders.delete("host");
6652
+ const proxyBody = method === "GET" || method === "HEAD" ? void 0 : await readRawRequestBody(req);
6653
+ const proxyRes = await fetch(targetUrl, {
6654
+ method: method || "GET",
6655
+ headers: proxyHeaders,
6656
+ body: proxyBody
6657
+ });
6508
6658
  res.statusCode = proxyRes.status;
6509
6659
  proxyRes.headers.forEach((value, key) => {
6510
- if (!["content-encoding", "transfer-encoding"].includes(key.toLowerCase())) {
6660
+ if (!["content-encoding", "transfer-encoding", "content-length"].includes(key.toLowerCase())) {
6511
6661
  res.setHeader(key, value);
6512
6662
  }
6513
6663
  });
6664
+ const contentType = proxyRes.headers.get("content-type") || "";
6665
+ if (contentType.includes("text/html")) {
6666
+ const htmlBody = await proxyRes.text();
6667
+ const injectedHtml = Buffer.from(injectUiConfigIntoHtml(htmlBody, mountPoint));
6668
+ res.setHeader("content-length", String(injectedHtml.byteLength));
6669
+ res.end(injectedHtml);
6670
+ return;
6671
+ }
6514
6672
  const body = await proxyRes.arrayBuffer();
6515
6673
  res.end(Buffer.from(body));
6516
6674
  return;
@@ -6521,30 +6679,27 @@ function createDevMiddleware(server, context) {
6521
6679
  const clientPath = mountPoint === "/" && pathWithoutMount.startsWith("/agents/") ? pathWithoutMount.slice("/agents".length) || "/" : pathWithoutMount;
6522
6680
  const isStaticAsset = clientPath.startsWith("/assets/") || clientPath.startsWith("/vendor.js") || clientPath.startsWith("/vue.js") || clientPath.startsWith("/monaco.js") || clientPath.startsWith("/index.js") || clientPath.startsWith("/index.css") || clientPath.match(/\.(js|css|png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot|ico)$/);
6523
6681
  {
6524
- const currentDir = path7__default.dirname(fileURLToPath(import.meta.url));
6682
+ const currentDir = path8__default.dirname(fileURLToPath(import.meta.url));
6525
6683
  const isInDist = currentDir.endsWith("dist");
6526
- const clientDir = path7__default.resolve(
6684
+ const clientDir = path8__default.resolve(
6527
6685
  currentDir,
6528
6686
  isInDist ? "./client" : "../dist/client"
6529
6687
  );
6530
6688
  let filePath;
6531
6689
  if (isStaticAsset) {
6532
6690
  const cleanUrl = clientPath.split("?")[0];
6533
- filePath = path7__default.join(clientDir, cleanUrl);
6691
+ filePath = path8__default.join(clientDir, cleanUrl);
6534
6692
  } else {
6535
- filePath = path7__default.join(clientDir, "index.html");
6693
+ filePath = path8__default.join(clientDir, "index.html");
6536
6694
  }
6537
6695
  try {
6538
- if (fs7__default.existsSync(filePath)) {
6539
- let content = fs7__default.readFileSync(filePath);
6540
- const ext = path7__default.extname(filePath).toLowerCase();
6696
+ if (fs8__default.existsSync(filePath)) {
6697
+ let content = fs8__default.readFileSync(filePath);
6698
+ const ext = path8__default.extname(filePath).toLowerCase();
6541
6699
  if (ext === ".html") {
6542
- const configScript = `<script>window.__AGENTBUILDER_CONFIG__ = { mountPoint: "${mountPoint}", devMode: true };</script>`;
6543
- let htmlContent = content.toString();
6544
- const assetPrefix = mountPoint === "/" ? "/" : `${mountPoint}/`;
6545
- htmlContent = htmlContent.replace(/\/agents\//g, assetPrefix);
6546
- htmlContent = htmlContent.replace("</head>", `${configScript}</head>`);
6547
- content = Buffer.from(htmlContent);
6700
+ content = Buffer.from(
6701
+ injectUiConfigIntoHtml(content.toString(), mountPoint)
6702
+ );
6548
6703
  }
6549
6704
  const mimeTypes = {
6550
6705
  ".html": "text/html",
@@ -6579,7 +6734,7 @@ async function loadBuilderVirtualModule(context) {
6579
6734
  const effects = await scanEffectsDirectory(effectsDir);
6580
6735
  const toAbsolutePath = (relativePath) => {
6581
6736
  if (relativePath.startsWith("./")) {
6582
- return path7__default.resolve(process.cwd(), relativePath).replace(/\\/g, "/");
6737
+ return path8__default.resolve(process.cwd(), relativePath).replace(/\\/g, "/");
6583
6738
  }
6584
6739
  return relativePath;
6585
6740
  };
@@ -6809,7 +6964,7 @@ async function loadRegistryVirtualModule(context) {
6809
6964
  const effects = await scanEffectsDirectory(effectsDir);
6810
6965
  const toAbsolutePath = (relativePath) => {
6811
6966
  if (relativePath.startsWith("./")) {
6812
- return path7__default.resolve(process.cwd(), relativePath).replace(/\\/g, "/");
6967
+ return path8__default.resolve(process.cwd(), relativePath).replace(/\\/g, "/");
6813
6968
  }
6814
6969
  return relativePath;
6815
6970
  };
@@ -6837,23 +6992,23 @@ async function loadRegistryVirtualModule(context) {
6837
6992
  const absPath = toAbsolutePath(importPath);
6838
6993
  return ` "${name}": async () => (await import("${absPath}")).default,`;
6839
6994
  }).join("\n");
6840
- const packedDir = path7__default.resolve(process.cwd(), "agents/packed");
6995
+ const packedDir = path8__default.resolve(process.cwd(), "agents/packed");
6841
6996
  const packedPackages = [];
6842
- if (fs7__default.existsSync(packedDir)) {
6997
+ if (fs8__default.existsSync(packedDir)) {
6843
6998
  console.log(`[vite-plugin-agent] Scanning packed directory: ${packedDir}`);
6844
6999
  const packageDirs = discoverPackedPackageDirectories(packedDir);
6845
7000
  console.log(`[vite-plugin-agent] Found package dirs: ${packageDirs.join(", ")}`);
6846
7001
  for (const pkgPath of packageDirs) {
6847
- const pkgJsonPath = path7__default.join(pkgPath, "package.json");
6848
- if (fs7__default.existsSync(pkgJsonPath)) {
7002
+ const pkgJsonPath = path8__default.join(pkgPath, "package.json");
7003
+ if (fs8__default.existsSync(pkgJsonPath)) {
6849
7004
  try {
6850
- const pkgJson = JSON.parse(fs7__default.readFileSync(pkgJsonPath, "utf-8"));
7005
+ const pkgJson = JSON.parse(fs8__default.readFileSync(pkgJsonPath, "utf-8"));
6851
7006
  console.log(`[vite-plugin-agent] Loaded ${pkgPath} package.json, standardagent:`, pkgJson.standardagent);
6852
7007
  if (!pkgJson.standardagent) {
6853
7008
  continue;
6854
7009
  }
6855
7010
  const mainEntry = pkgJson.main || "./dist/index.js";
6856
- const outputDir = path7__default.dirname(mainEntry).replace(/^\.\//, "");
7011
+ const outputDir = path8__default.dirname(mainEntry).replace(/^\.\//, "");
6857
7012
  const pkg = {
6858
7013
  packageId: pkgJson.name,
6859
7014
  version: pkgJson.version,
@@ -6971,7 +7126,7 @@ export function getVisibleToolNames() {
6971
7126
  async function loadRoutesVirtualModule(context) {
6972
7127
  const { mountPoint, threadApiDir, rou3Code, hmr } = context;
6973
7128
  const threadRoutes = scanApiDirectory(threadApiDir);
6974
- const toAbsolutePath = (inputPath) => path7__default.resolve(process.cwd(), inputPath).replace(/\\/g, "/");
7129
+ const toAbsolutePath = (inputPath) => path8__default.resolve(process.cwd(), inputPath).replace(/\\/g, "/");
6975
7130
  const threadRouteCode = threadRoutes.map(({ method, route, importPath }) => {
6976
7131
  const apiRoute = `/api/threads/:threadId${route}`;
6977
7132
  return ` addRoute(
@@ -6982,20 +7137,20 @@ async function loadRoutesVirtualModule(context) {
6982
7137
  );`;
6983
7138
  }).join("\n");
6984
7139
  const packedThreadRoutes = [];
6985
- const packedDir = path7__default.resolve(process.cwd(), "agents/packed");
7140
+ const packedDir = path8__default.resolve(process.cwd(), "agents/packed");
6986
7141
  const packedPackageDirs = discoverPackedPackageDirectories(packedDir);
6987
7142
  for (const packagePath of packedPackageDirs) {
6988
- const packageJsonPath = path7__default.join(packagePath, "package.json");
6989
- if (!fs7__default.existsSync(packageJsonPath)) {
7143
+ const packageJsonPath = path8__default.join(packagePath, "package.json");
7144
+ if (!fs8__default.existsSync(packageJsonPath)) {
6990
7145
  continue;
6991
7146
  }
6992
7147
  try {
6993
- const packageJson = JSON.parse(fs7__default.readFileSync(packageJsonPath, "utf-8"));
7148
+ const packageJson = JSON.parse(fs8__default.readFileSync(packageJsonPath, "utf-8"));
6994
7149
  if (!packageJson.standardagent) {
6995
7150
  continue;
6996
7151
  }
6997
7152
  const mainEntry = packageJson.main || "./dist/index.js";
6998
- const outputDir = path7__default.dirname(mainEntry).replace(/^\.\//, "");
7153
+ const outputDir = path8__default.dirname(mainEntry).replace(/^\.\//, "");
6999
7154
  const threadEndpoints = scanPackedThreadEndpoints(packagePath, outputDir);
7000
7155
  for (const endpoint of threadEndpoints) {
7001
7156
  const apiRoute = `/api/threads/:threadId${endpoint.route}`;
@@ -7035,12 +7190,19 @@ const MOUNT_POINT = "${mountPoint}";
7035
7190
 
7036
7191
  // Routes that don't require authentication
7037
7192
  const PUBLIC_ROUTES = [
7193
+ '/api/auth/bootstrap',
7038
7194
  '/api/auth/login',
7195
+ '/api/auth/bootstrap',
7039
7196
  '/api/auth/config',
7197
+ '/api/config',
7040
7198
  '/api/auth/oauth/github',
7041
7199
  '/api/auth/oauth/google',
7042
7200
  '/api/auth/oauth/github/callback',
7043
7201
  '/api/auth/oauth/google/callback',
7202
+ '/api/platform-auth/bootstrap',
7203
+ '/api/platform-auth/login',
7204
+ '/api/platform-auth/logout',
7205
+ '/api/platform-auth/me',
7044
7206
  '/api/hooks' // Hook metadata is safe to expose publicly
7045
7207
  ];
7046
7208
 
@@ -7061,6 +7223,20 @@ function isPublicRoute(routePath) {
7061
7223
  return true;
7062
7224
  }
7063
7225
 
7226
+ // Platform proxy routes handle their own auth.
7227
+ if (routePath.startsWith('/api/platform/') || routePath === '/api/platform') {
7228
+ return true;
7229
+ }
7230
+
7231
+ // Platform session proxy and auth bridge handle auth via platform cookies.
7232
+ if (routePath.startsWith('/api/platform-session/') || routePath === '/api/platform-session') {
7233
+ return true;
7234
+ }
7235
+
7236
+ if (routePath.startsWith('/api/platform-auth/') || routePath === '/api/platform-auth') {
7237
+ return true;
7238
+ }
7239
+
7064
7240
  return false;
7065
7241
  }
7066
7242
 
@@ -7325,12 +7501,12 @@ ${hooksCode}
7325
7501
  };`;
7326
7502
  }
7327
7503
  if (id === RESOLVED_VIRTUAL_CONFIG_ID) {
7328
- const relativeToolsDir = path7__default.relative(process.cwd(), toolsDir).replace(/\\/g, "/");
7329
- const relativeHooksDir = path7__default.relative(process.cwd(), hooksDir).replace(/\\/g, "/");
7330
- const relativeApiDir = path7__default.relative(process.cwd(), threadApiDir).replace(/\\/g, "/");
7331
- const relativeModelsDir = path7__default.relative(process.cwd(), modelsDir).replace(/\\/g, "/");
7332
- const relativePromptsDir = path7__default.relative(process.cwd(), promptsDir).replace(/\\/g, "/");
7333
- const relativeAgentsDir = path7__default.relative(process.cwd(), agentsDir).replace(/\\/g, "/");
7504
+ const relativeToolsDir = path8__default.relative(process.cwd(), toolsDir).replace(/\\/g, "/");
7505
+ const relativeHooksDir = path8__default.relative(process.cwd(), hooksDir).replace(/\\/g, "/");
7506
+ const relativeApiDir = path8__default.relative(process.cwd(), threadApiDir).replace(/\\/g, "/");
7507
+ const relativeModelsDir = path8__default.relative(process.cwd(), modelsDir).replace(/\\/g, "/");
7508
+ const relativePromptsDir = path8__default.relative(process.cwd(), promptsDir).replace(/\\/g, "/");
7509
+ const relativeAgentsDir = path8__default.relative(process.cwd(), agentsDir).replace(/\\/g, "/");
7334
7510
  return `// Virtual agent config module
7335
7511
  export const config = {
7336
7512
  toolsDir: "${relativeToolsDir}",
@@ -7500,14 +7676,14 @@ var packingDeps = [
7500
7676
  "typescript"
7501
7677
  ];
7502
7678
  function createPluginViteConfig(pluginModuleUrl) {
7503
- const currentDir = path7__default.dirname(fileURLToPath(pluginModuleUrl));
7679
+ const currentDir = path8__default.dirname(fileURLToPath(pluginModuleUrl));
7504
7680
  const isInDist = currentDir.endsWith("dist");
7505
- const builderClientDir = path7__default.resolve(
7681
+ const builderClientDir = path8__default.resolve(
7506
7682
  currentDir,
7507
7683
  isInDist ? "./client" : "../dist/client"
7508
7684
  );
7509
7685
  return {
7510
- publicDir: fs7__default.existsSync(builderClientDir) ? builderClientDir : void 0,
7686
+ publicDir: fs8__default.existsSync(builderClientDir) ? builderClientDir : void 0,
7511
7687
  build: {
7512
7688
  rollupOptions: {
7513
7689
  external: [...packingDeps]
@@ -7564,14 +7740,14 @@ function agentbuilder(options = {}) {
7564
7740
  if (mountPoint.endsWith("/") && mountPoint.length > 1) {
7565
7741
  mountPoint = mountPoint.slice(0, -1);
7566
7742
  }
7567
- const toolsDir = options.toolsDir ? path7__default.resolve(process.cwd(), options.toolsDir) : path7__default.resolve(process.cwd(), "agents/tools");
7568
- const hooksDir = options.hooksDir ? path7__default.resolve(process.cwd(), options.hooksDir) : path7__default.resolve(process.cwd(), "agents/hooks");
7569
- const threadApiDir = options.apiDir ? path7__default.resolve(process.cwd(), options.apiDir) : path7__default.resolve(process.cwd(), "agents/api");
7570
- const modelsDir = options.modelsDir ? path7__default.resolve(process.cwd(), options.modelsDir) : path7__default.resolve(process.cwd(), "agents/models");
7571
- const promptsDir = options.promptsDir ? path7__default.resolve(process.cwd(), options.promptsDir) : path7__default.resolve(process.cwd(), "agents/prompts");
7572
- const agentsDir = options.agentsDir ? path7__default.resolve(process.cwd(), options.agentsDir) : path7__default.resolve(process.cwd(), "agents/agents");
7573
- const effectsDir = options.effectsDir ? path7__default.resolve(process.cwd(), options.effectsDir) : path7__default.resolve(process.cwd(), "agents/effects");
7574
- const outputDir = path7__default.resolve(process.cwd(), ".agents");
7743
+ const toolsDir = options.toolsDir ? path8__default.resolve(process.cwd(), options.toolsDir) : path8__default.resolve(process.cwd(), "agents/tools");
7744
+ const hooksDir = options.hooksDir ? path8__default.resolve(process.cwd(), options.hooksDir) : path8__default.resolve(process.cwd(), "agents/hooks");
7745
+ const threadApiDir = options.apiDir ? path8__default.resolve(process.cwd(), options.apiDir) : path8__default.resolve(process.cwd(), "agents/api");
7746
+ const modelsDir = options.modelsDir ? path8__default.resolve(process.cwd(), options.modelsDir) : path8__default.resolve(process.cwd(), "agents/models");
7747
+ const promptsDir = options.promptsDir ? path8__default.resolve(process.cwd(), options.promptsDir) : path8__default.resolve(process.cwd(), "agents/prompts");
7748
+ const agentsDir = options.agentsDir ? path8__default.resolve(process.cwd(), options.agentsDir) : path8__default.resolve(process.cwd(), "agents/agents");
7749
+ const effectsDir = options.effectsDir ? path8__default.resolve(process.cwd(), options.effectsDir) : path8__default.resolve(process.cwd(), "agents/effects");
7750
+ const outputDir = path8__default.resolve(process.cwd(), ".agents");
7575
7751
  const installedProviders = buildInstalledProviderCatalog(options.providers || []);
7576
7752
  const installedProviderPackageMap = buildProviderPackageMap(options.providers || []);
7577
7753
  const typeGenConfig = {
@@ -7588,11 +7764,11 @@ function agentbuilder(options = {}) {
7588
7764
  }
7589
7765
  }
7590
7766
  const __filename = fileURLToPath(import.meta.url);
7591
- const __dirname = path7__default.dirname(__filename);
7592
- const rou3Path = path7__default.join(__dirname, "../dist/rou3.js");
7767
+ const __dirname = path8__default.dirname(__filename);
7768
+ const rou3Path = path8__default.join(__dirname, "../dist/rou3.js");
7593
7769
  let rou3Code = "";
7594
7770
  try {
7595
- rou3Code = fs7__default.readFileSync(rou3Path, "utf-8").replace(/^export \{[^}]+\};?\s*$/gm, "").replace(/\/\/# sourceMappingURL=.+$/gm, "").trim();
7771
+ rou3Code = fs8__default.readFileSync(rou3Path, "utf-8").replace(/^export \{[^}]+\};?\s*$/gm, "").replace(/\/\/# sourceMappingURL=.+$/gm, "").trim();
7596
7772
  } catch (err) {
7597
7773
  console.warn("[vite-plugin-agent] Could not read rou3.js for inlining:", err);
7598
7774
  }
@@ -7702,28 +7878,28 @@ function agentbuilder(options = {}) {
7702
7878
  writeBundle(options2, bundle) {
7703
7879
  const outDir = options2.dir || "dist";
7704
7880
  const mountPath = mountPoint.slice(1);
7705
- const mountDir = mountPath ? path7__default.join(outDir, "../client", mountPath) : path7__default.join(outDir, "../client");
7706
- const currentDir = path7__default.dirname(fileURLToPath(import.meta.url));
7881
+ const mountDir = mountPath ? path8__default.join(outDir, "../client", mountPath) : path8__default.join(outDir, "../client");
7882
+ const currentDir = path8__default.dirname(fileURLToPath(import.meta.url));
7707
7883
  const isInDist = currentDir.endsWith("dist");
7708
- const clientDir = path7__default.resolve(
7884
+ const clientDir = path8__default.resolve(
7709
7885
  currentDir,
7710
7886
  isInDist ? "./client" : "../dist/client"
7711
7887
  );
7712
- if (!fs7__default.existsSync(clientDir)) {
7888
+ if (!fs8__default.existsSync(clientDir)) {
7713
7889
  console.warn(`[agentbuilder] Client directory not found at ${clientDir}`);
7714
7890
  return;
7715
7891
  }
7716
- fs7__default.mkdirSync(mountDir, { recursive: true });
7892
+ fs8__default.mkdirSync(mountDir, { recursive: true });
7717
7893
  function copyRecursive(src, dest) {
7718
- const entries = fs7__default.readdirSync(src, { withFileTypes: true });
7894
+ const entries = fs8__default.readdirSync(src, { withFileTypes: true });
7719
7895
  for (const entry of entries) {
7720
- const srcPath = path7__default.join(src, entry.name);
7721
- const destPath = path7__default.join(dest, entry.name);
7896
+ const srcPath = path8__default.join(src, entry.name);
7897
+ const destPath = path8__default.join(dest, entry.name);
7722
7898
  if (entry.isDirectory()) {
7723
- fs7__default.mkdirSync(destPath, { recursive: true });
7899
+ fs8__default.mkdirSync(destPath, { recursive: true });
7724
7900
  copyRecursive(srcPath, destPath);
7725
7901
  } else {
7726
- let content = fs7__default.readFileSync(srcPath);
7902
+ let content = fs8__default.readFileSync(srcPath);
7727
7903
  if (entry.name === "index.html") {
7728
7904
  const configScript = `<script>window.__AGENTBUILDER_CONFIG__ = { mountPoint: "${mountPoint}" };</script>`;
7729
7905
  let htmlContent = content.toString();
@@ -7732,7 +7908,7 @@ function agentbuilder(options = {}) {
7732
7908
  htmlContent = htmlContent.replace("</head>", `${configScript}</head>`);
7733
7909
  content = Buffer.from(htmlContent);
7734
7910
  }
7735
- fs7__default.writeFileSync(destPath, content);
7911
+ fs8__default.writeFileSync(destPath, content);
7736
7912
  }
7737
7913
  }
7738
7914
  }