@agentuity/cli 0.1.15 → 0.1.17

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 (255) hide show
  1. package/dist/cli.d.ts.map +1 -1
  2. package/dist/cli.js +18 -2
  3. package/dist/cli.js.map +1 -1
  4. package/dist/cmd/ai/opencode/install.js +1 -1
  5. package/dist/cmd/ai/opencode/install.js.map +1 -1
  6. package/dist/cmd/build/ast.d.ts.map +1 -1
  7. package/dist/cmd/build/ast.js +68 -2
  8. package/dist/cmd/build/ast.js.map +1 -1
  9. package/dist/cmd/build/vite/registry-generator.d.ts.map +1 -1
  10. package/dist/cmd/build/vite/registry-generator.js +112 -23
  11. package/dist/cmd/build/vite/registry-generator.js.map +1 -1
  12. package/dist/cmd/build/vite/route-discovery.d.ts +4 -0
  13. package/dist/cmd/build/vite/route-discovery.d.ts.map +1 -1
  14. package/dist/cmd/build/vite/route-discovery.js +4 -0
  15. package/dist/cmd/build/vite/route-discovery.js.map +1 -1
  16. package/dist/cmd/cloud/env/delete.d.ts.map +1 -1
  17. package/dist/cmd/cloud/env/delete.js +93 -34
  18. package/dist/cmd/cloud/env/delete.js.map +1 -1
  19. package/dist/cmd/cloud/env/get.d.ts.map +1 -1
  20. package/dist/cmd/cloud/env/get.js +53 -16
  21. package/dist/cmd/cloud/env/get.js.map +1 -1
  22. package/dist/cmd/cloud/env/import.d.ts.map +1 -1
  23. package/dist/cmd/cloud/env/import.js +80 -39
  24. package/dist/cmd/cloud/env/import.js.map +1 -1
  25. package/dist/cmd/cloud/env/index.d.ts.map +1 -1
  26. package/dist/cmd/cloud/env/index.js +6 -2
  27. package/dist/cmd/cloud/env/index.js.map +1 -1
  28. package/dist/cmd/cloud/env/list.d.ts.map +1 -1
  29. package/dist/cmd/cloud/env/list.js +99 -23
  30. package/dist/cmd/cloud/env/list.js.map +1 -1
  31. package/dist/cmd/cloud/env/org-util.d.ts +16 -0
  32. package/dist/cmd/cloud/env/org-util.d.ts.map +1 -0
  33. package/dist/cmd/cloud/env/org-util.js +28 -0
  34. package/dist/cmd/cloud/env/org-util.js.map +1 -0
  35. package/dist/cmd/cloud/env/pull.d.ts.map +1 -1
  36. package/dist/cmd/cloud/env/pull.js +61 -29
  37. package/dist/cmd/cloud/env/pull.js.map +1 -1
  38. package/dist/cmd/cloud/env/push.d.ts.map +1 -1
  39. package/dist/cmd/cloud/env/push.js +70 -30
  40. package/dist/cmd/cloud/env/push.js.map +1 -1
  41. package/dist/cmd/cloud/env/set.d.ts.map +1 -1
  42. package/dist/cmd/cloud/env/set.js +72 -26
  43. package/dist/cmd/cloud/env/set.js.map +1 -1
  44. package/dist/cmd/cloud/index.d.ts.map +1 -1
  45. package/dist/cmd/cloud/index.js +2 -0
  46. package/dist/cmd/cloud/index.js.map +1 -1
  47. package/dist/cmd/cloud/keyvalue/create-namespace.js +1 -1
  48. package/dist/cmd/cloud/keyvalue/create-namespace.js.map +1 -1
  49. package/dist/cmd/cloud/keyvalue/delete-namespace.js +2 -2
  50. package/dist/cmd/cloud/keyvalue/delete-namespace.js.map +1 -1
  51. package/dist/cmd/cloud/keyvalue/delete.js +1 -1
  52. package/dist/cmd/cloud/keyvalue/delete.js.map +1 -1
  53. package/dist/cmd/cloud/keyvalue/get.js +1 -1
  54. package/dist/cmd/cloud/keyvalue/get.js.map +1 -1
  55. package/dist/cmd/cloud/keyvalue/index.js +1 -1
  56. package/dist/cmd/cloud/keyvalue/index.js.map +1 -1
  57. package/dist/cmd/cloud/keyvalue/keys.js +1 -1
  58. package/dist/cmd/cloud/keyvalue/keys.js.map +1 -1
  59. package/dist/cmd/cloud/keyvalue/list-namespaces.js +1 -1
  60. package/dist/cmd/cloud/keyvalue/list-namespaces.js.map +1 -1
  61. package/dist/cmd/cloud/keyvalue/repl.d.ts.map +1 -1
  62. package/dist/cmd/cloud/keyvalue/repl.js +8 -5
  63. package/dist/cmd/cloud/keyvalue/repl.js.map +1 -1
  64. package/dist/cmd/cloud/keyvalue/search.js +1 -1
  65. package/dist/cmd/cloud/keyvalue/search.js.map +1 -1
  66. package/dist/cmd/cloud/keyvalue/set.js +1 -1
  67. package/dist/cmd/cloud/keyvalue/set.js.map +1 -1
  68. package/dist/cmd/cloud/keyvalue/stats.js +1 -1
  69. package/dist/cmd/cloud/keyvalue/stats.js.map +1 -1
  70. package/dist/cmd/cloud/keyvalue/util.d.ts +4 -4
  71. package/dist/cmd/cloud/keyvalue/util.d.ts.map +1 -1
  72. package/dist/cmd/cloud/keyvalue/util.js +4 -9
  73. package/dist/cmd/cloud/keyvalue/util.js.map +1 -1
  74. package/dist/cmd/cloud/queue/ack.d.ts +3 -0
  75. package/dist/cmd/cloud/queue/ack.d.ts.map +1 -0
  76. package/dist/cmd/cloud/queue/ack.js +45 -0
  77. package/dist/cmd/cloud/queue/ack.js.map +1 -0
  78. package/dist/cmd/cloud/queue/create.d.ts +3 -0
  79. package/dist/cmd/cloud/queue/create.d.ts.map +1 -0
  80. package/dist/cmd/cloud/queue/create.js +80 -0
  81. package/dist/cmd/cloud/queue/create.js.map +1 -0
  82. package/dist/cmd/cloud/queue/delete.d.ts +3 -0
  83. package/dist/cmd/cloud/queue/delete.d.ts.map +1 -0
  84. package/dist/cmd/cloud/queue/delete.js +50 -0
  85. package/dist/cmd/cloud/queue/delete.js.map +1 -0
  86. package/dist/cmd/cloud/queue/destinations.d.ts +3 -0
  87. package/dist/cmd/cloud/queue/destinations.d.ts.map +1 -0
  88. package/dist/cmd/cloud/queue/destinations.js +232 -0
  89. package/dist/cmd/cloud/queue/destinations.js.map +1 -0
  90. package/dist/cmd/cloud/queue/dlq.d.ts +3 -0
  91. package/dist/cmd/cloud/queue/dlq.d.ts.map +1 -0
  92. package/dist/cmd/cloud/queue/dlq.js +168 -0
  93. package/dist/cmd/cloud/queue/dlq.js.map +1 -0
  94. package/dist/cmd/cloud/queue/get.d.ts +3 -0
  95. package/dist/cmd/cloud/queue/get.d.ts.map +1 -0
  96. package/dist/cmd/cloud/queue/get.js +130 -0
  97. package/dist/cmd/cloud/queue/get.js.map +1 -0
  98. package/dist/cmd/cloud/queue/index.d.ts +3 -0
  99. package/dist/cmd/cloud/queue/index.d.ts.map +1 -0
  100. package/dist/cmd/cloud/queue/index.js +65 -0
  101. package/dist/cmd/cloud/queue/index.js.map +1 -0
  102. package/dist/cmd/cloud/queue/list.d.ts +3 -0
  103. package/dist/cmd/cloud/queue/list.d.ts.map +1 -0
  104. package/dist/cmd/cloud/queue/list.js +71 -0
  105. package/dist/cmd/cloud/queue/list.js.map +1 -0
  106. package/dist/cmd/cloud/queue/messages.d.ts +3 -0
  107. package/dist/cmd/cloud/queue/messages.d.ts.map +1 -0
  108. package/dist/cmd/cloud/queue/messages.js +137 -0
  109. package/dist/cmd/cloud/queue/messages.js.map +1 -0
  110. package/dist/cmd/cloud/queue/nack.d.ts +3 -0
  111. package/dist/cmd/cloud/queue/nack.d.ts.map +1 -0
  112. package/dist/cmd/cloud/queue/nack.js +45 -0
  113. package/dist/cmd/cloud/queue/nack.js.map +1 -0
  114. package/dist/cmd/cloud/queue/pause.d.ts +3 -0
  115. package/dist/cmd/cloud/queue/pause.d.ts.map +1 -0
  116. package/dist/cmd/cloud/queue/pause.js +36 -0
  117. package/dist/cmd/cloud/queue/pause.js.map +1 -0
  118. package/dist/cmd/cloud/queue/publish.d.ts +3 -0
  119. package/dist/cmd/cloud/queue/publish.d.ts.map +1 -0
  120. package/dist/cmd/cloud/queue/publish.js +76 -0
  121. package/dist/cmd/cloud/queue/publish.js.map +1 -0
  122. package/dist/cmd/cloud/queue/receive.d.ts +3 -0
  123. package/dist/cmd/cloud/queue/receive.d.ts.map +1 -0
  124. package/dist/cmd/cloud/queue/receive.js +67 -0
  125. package/dist/cmd/cloud/queue/receive.js.map +1 -0
  126. package/dist/cmd/cloud/queue/resume.d.ts +3 -0
  127. package/dist/cmd/cloud/queue/resume.d.ts.map +1 -0
  128. package/dist/cmd/cloud/queue/resume.js +35 -0
  129. package/dist/cmd/cloud/queue/resume.js.map +1 -0
  130. package/dist/cmd/cloud/queue/sources.d.ts +3 -0
  131. package/dist/cmd/cloud/queue/sources.d.ts.map +1 -0
  132. package/dist/cmd/cloud/queue/sources.js +290 -0
  133. package/dist/cmd/cloud/queue/sources.js.map +1 -0
  134. package/dist/cmd/cloud/queue/stats.d.ts +3 -0
  135. package/dist/cmd/cloud/queue/stats.d.ts.map +1 -0
  136. package/dist/cmd/cloud/queue/stats.js +239 -0
  137. package/dist/cmd/cloud/queue/stats.js.map +1 -0
  138. package/dist/cmd/cloud/queue/util.d.ts +26 -0
  139. package/dist/cmd/cloud/queue/util.d.ts.map +1 -0
  140. package/dist/cmd/cloud/queue/util.js +19 -0
  141. package/dist/cmd/cloud/queue/util.js.map +1 -0
  142. package/dist/cmd/cloud/sandbox/snapshot/build.d.ts.map +1 -1
  143. package/dist/cmd/cloud/sandbox/snapshot/build.js +122 -28
  144. package/dist/cmd/cloud/sandbox/snapshot/build.js.map +1 -1
  145. package/dist/cmd/cloud/sandbox/snapshot/create.d.ts.map +1 -1
  146. package/dist/cmd/cloud/sandbox/snapshot/create.js +19 -7
  147. package/dist/cmd/cloud/sandbox/snapshot/create.js.map +1 -1
  148. package/dist/cmd/cloud/sandbox/snapshot/get.d.ts.map +1 -1
  149. package/dist/cmd/cloud/sandbox/snapshot/get.js +16 -0
  150. package/dist/cmd/cloud/sandbox/snapshot/get.js.map +1 -1
  151. package/dist/cmd/cloud/sandbox/snapshot/list.d.ts.map +1 -1
  152. package/dist/cmd/cloud/sandbox/snapshot/list.js +4 -0
  153. package/dist/cmd/cloud/sandbox/snapshot/list.js.map +1 -1
  154. package/dist/cmd/cloud/vector/stats.d.ts.map +1 -1
  155. package/dist/cmd/cloud/vector/stats.js +8 -0
  156. package/dist/cmd/cloud/vector/stats.js.map +1 -1
  157. package/dist/cmd/project/create.d.ts.map +1 -1
  158. package/dist/cmd/project/create.js +12 -0
  159. package/dist/cmd/project/create.js.map +1 -1
  160. package/dist/cmd/project/template-flow.d.ts +3 -0
  161. package/dist/cmd/project/template-flow.d.ts.map +1 -1
  162. package/dist/cmd/project/template-flow.js +157 -68
  163. package/dist/cmd/project/template-flow.js.map +1 -1
  164. package/dist/cmd/setup/index.d.ts.map +1 -1
  165. package/dist/cmd/setup/index.js +2 -1
  166. package/dist/cmd/setup/index.js.map +1 -1
  167. package/dist/env-util.d.ts +6 -1
  168. package/dist/env-util.d.ts.map +1 -1
  169. package/dist/env-util.js +16 -2
  170. package/dist/env-util.js.map +1 -1
  171. package/dist/errors.d.ts +4 -2
  172. package/dist/errors.d.ts.map +1 -1
  173. package/dist/errors.js +6 -0
  174. package/dist/errors.js.map +1 -1
  175. package/dist/onboarding/agentPrompt.d.ts +8 -0
  176. package/dist/onboarding/agentPrompt.d.ts.map +1 -0
  177. package/dist/onboarding/agentPrompt.js +263 -0
  178. package/dist/onboarding/agentPrompt.js.map +1 -0
  179. package/dist/schema-generator.d.ts +1 -1
  180. package/dist/schema-generator.d.ts.map +1 -1
  181. package/dist/schema-parser.d.ts +1 -1
  182. package/dist/schema-parser.d.ts.map +1 -1
  183. package/dist/schema-parser.js +36 -1
  184. package/dist/schema-parser.js.map +1 -1
  185. package/dist/tui/box.d.ts +4 -0
  186. package/dist/tui/box.d.ts.map +1 -1
  187. package/dist/tui/box.js +39 -0
  188. package/dist/tui/box.js.map +1 -1
  189. package/dist/tui.d.ts +11 -1
  190. package/dist/tui.d.ts.map +1 -1
  191. package/dist/tui.js +33 -15
  192. package/dist/tui.js.map +1 -1
  193. package/dist/types.d.ts.map +1 -1
  194. package/dist/types.js.map +1 -1
  195. package/package.json +6 -6
  196. package/src/cli.ts +19 -2
  197. package/src/cmd/ai/opencode/install.ts +1 -1
  198. package/src/cmd/build/ast.ts +88 -2
  199. package/src/cmd/build/vite/registry-generator.ts +120 -24
  200. package/src/cmd/build/vite/route-discovery.ts +16 -0
  201. package/src/cmd/cloud/env/delete.ts +113 -41
  202. package/src/cmd/cloud/env/get.ts +60 -16
  203. package/src/cmd/cloud/env/import.ts +92 -44
  204. package/src/cmd/cloud/env/index.ts +6 -2
  205. package/src/cmd/cloud/env/list.ts +112 -27
  206. package/src/cmd/cloud/env/org-util.ts +37 -0
  207. package/src/cmd/cloud/env/pull.ts +72 -31
  208. package/src/cmd/cloud/env/push.ts +84 -35
  209. package/src/cmd/cloud/env/set.ts +89 -33
  210. package/src/cmd/cloud/index.ts +2 -0
  211. package/src/cmd/cloud/keyvalue/create-namespace.ts +1 -1
  212. package/src/cmd/cloud/keyvalue/delete-namespace.ts +2 -2
  213. package/src/cmd/cloud/keyvalue/delete.ts +1 -1
  214. package/src/cmd/cloud/keyvalue/get.ts +1 -1
  215. package/src/cmd/cloud/keyvalue/index.ts +1 -1
  216. package/src/cmd/cloud/keyvalue/keys.ts +1 -1
  217. package/src/cmd/cloud/keyvalue/list-namespaces.ts +1 -1
  218. package/src/cmd/cloud/keyvalue/repl.ts +8 -5
  219. package/src/cmd/cloud/keyvalue/search.ts +1 -1
  220. package/src/cmd/cloud/keyvalue/set.ts +1 -1
  221. package/src/cmd/cloud/keyvalue/stats.ts +1 -1
  222. package/src/cmd/cloud/keyvalue/util.ts +8 -17
  223. package/src/cmd/cloud/queue/ack.ts +50 -0
  224. package/src/cmd/cloud/queue/create.ts +91 -0
  225. package/src/cmd/cloud/queue/delete.ts +57 -0
  226. package/src/cmd/cloud/queue/destinations.ts +287 -0
  227. package/src/cmd/cloud/queue/dlq.ts +203 -0
  228. package/src/cmd/cloud/queue/get.ts +158 -0
  229. package/src/cmd/cloud/queue/index.ts +66 -0
  230. package/src/cmd/cloud/queue/list.ts +81 -0
  231. package/src/cmd/cloud/queue/messages.ts +160 -0
  232. package/src/cmd/cloud/queue/nack.ts +50 -0
  233. package/src/cmd/cloud/queue/pause.ts +41 -0
  234. package/src/cmd/cloud/queue/publish.ts +88 -0
  235. package/src/cmd/cloud/queue/receive.ts +76 -0
  236. package/src/cmd/cloud/queue/resume.ts +40 -0
  237. package/src/cmd/cloud/queue/sources.ts +352 -0
  238. package/src/cmd/cloud/queue/stats.ts +297 -0
  239. package/src/cmd/cloud/queue/util.ts +34 -0
  240. package/src/cmd/cloud/sandbox/snapshot/build.ts +146 -29
  241. package/src/cmd/cloud/sandbox/snapshot/create.ts +24 -7
  242. package/src/cmd/cloud/sandbox/snapshot/get.ts +16 -0
  243. package/src/cmd/cloud/sandbox/snapshot/list.ts +4 -0
  244. package/src/cmd/cloud/vector/stats.ts +9 -0
  245. package/src/cmd/project/create.ts +12 -0
  246. package/src/cmd/project/template-flow.ts +181 -69
  247. package/src/cmd/setup/index.ts +2 -1
  248. package/src/env-util.ts +17 -2
  249. package/src/errors.ts +8 -0
  250. package/src/onboarding/agentPrompt.ts +263 -0
  251. package/src/schema-generator.ts +1 -1
  252. package/src/schema-parser.ts +45 -3
  253. package/src/tui/box.ts +52 -0
  254. package/src/tui.ts +47 -17
  255. package/src/types.ts +0 -1
@@ -1362,8 +1362,16 @@ export async function parseRoute(
1362
1362
  let exportName: string | undefined;
1363
1363
  let variableName: string | undefined;
1364
1364
 
1365
+ // Import info structure for tracking where identifiers come from
1366
+ interface ImportInfo {
1367
+ modulePath: string;
1368
+ importedName: string; // The exported name from the source module
1369
+ importKind: 'named' | 'default';
1370
+ }
1371
+
1365
1372
  // Extract import statements to map variable names to their import sources
1366
- const importMap = new Map<string, string>(); // Maps variable name to import path
1373
+ const importMap = new Map<string, string>(); // Maps variable name to import path (for backwards compat)
1374
+ const importInfoMap = new Map<string, ImportInfo>(); // Maps variable name to full import info
1367
1375
  for (const body of ast.body) {
1368
1376
  if (body.type === 'ImportDeclaration') {
1369
1377
  const importDecl = body as {
@@ -1371,6 +1379,7 @@ export async function parseRoute(
1371
1379
  specifiers?: Array<{
1372
1380
  type: string;
1373
1381
  local?: { name?: string };
1382
+ imported?: { name?: string }; // For named imports: the exported name
1374
1383
  }>;
1375
1384
  };
1376
1385
  const importPath = importDecl.source?.value;
@@ -1379,9 +1388,20 @@ export async function parseRoute(
1379
1388
  if (spec.type === 'ImportDefaultSpecifier' && spec.local?.name) {
1380
1389
  // import hello from '@agent/hello'
1381
1390
  importMap.set(spec.local.name, importPath);
1391
+ importInfoMap.set(spec.local.name, {
1392
+ modulePath: importPath,
1393
+ importedName: 'default',
1394
+ importKind: 'default',
1395
+ });
1382
1396
  } else if (spec.type === 'ImportSpecifier' && spec.local?.name) {
1383
- // import { hello } from './shared'
1397
+ // import { hello } from './shared' or import { hello as h } from './shared'
1398
+ const importedName = spec.imported?.name ?? spec.local.name;
1384
1399
  importMap.set(spec.local.name, importPath);
1400
+ importInfoMap.set(spec.local.name, {
1401
+ modulePath: importPath,
1402
+ importedName,
1403
+ importKind: 'named',
1404
+ });
1385
1405
  }
1386
1406
  }
1387
1407
  }
@@ -1620,10 +1640,29 @@ export async function parseRoute(
1620
1640
  if (validatorInfo.inputSchemaVariable) {
1621
1641
  routeConfig.inputSchemaVariable =
1622
1642
  validatorInfo.inputSchemaVariable;
1643
+ // Track where the schema is imported from (if imported)
1644
+ const inputImportInfo = importInfoMap.get(
1645
+ validatorInfo.inputSchemaVariable
1646
+ );
1647
+ if (inputImportInfo) {
1648
+ routeConfig.inputSchemaImportPath = inputImportInfo.modulePath;
1649
+ routeConfig.inputSchemaImportedName =
1650
+ inputImportInfo.importedName;
1651
+ }
1623
1652
  }
1624
1653
  if (validatorInfo.outputSchemaVariable) {
1625
1654
  routeConfig.outputSchemaVariable =
1626
1655
  validatorInfo.outputSchemaVariable;
1656
+ // Track where the schema is imported from (if imported)
1657
+ const outputImportInfo = importInfoMap.get(
1658
+ validatorInfo.outputSchemaVariable
1659
+ );
1660
+ if (outputImportInfo) {
1661
+ routeConfig.outputSchemaImportPath =
1662
+ outputImportInfo.modulePath;
1663
+ routeConfig.outputSchemaImportedName =
1664
+ outputImportInfo.importedName;
1665
+ }
1627
1666
  }
1628
1667
  if (validatorInfo.stream !== undefined) {
1629
1668
  routeConfig.stream = validatorInfo.stream;
@@ -1700,10 +1739,29 @@ export async function parseRoute(
1700
1739
  if (validatorInfo.inputSchemaVariable) {
1701
1740
  routeConfig.inputSchemaVariable =
1702
1741
  validatorInfo.inputSchemaVariable;
1742
+ // Track where the schema is imported from (if imported)
1743
+ const inputImportInfo = importInfoMap.get(
1744
+ validatorInfo.inputSchemaVariable
1745
+ );
1746
+ if (inputImportInfo) {
1747
+ routeConfig.inputSchemaImportPath = inputImportInfo.modulePath;
1748
+ routeConfig.inputSchemaImportedName =
1749
+ inputImportInfo.importedName;
1750
+ }
1703
1751
  }
1704
1752
  if (validatorInfo.outputSchemaVariable) {
1705
1753
  routeConfig.outputSchemaVariable =
1706
1754
  validatorInfo.outputSchemaVariable;
1755
+ // Track where the schema is imported from (if imported)
1756
+ const outputImportInfo = importInfoMap.get(
1757
+ validatorInfo.outputSchemaVariable
1758
+ );
1759
+ if (outputImportInfo) {
1760
+ routeConfig.outputSchemaImportPath =
1761
+ outputImportInfo.modulePath;
1762
+ routeConfig.outputSchemaImportedName =
1763
+ outputImportInfo.importedName;
1764
+ }
1707
1765
  }
1708
1766
  if (validatorInfo.stream !== undefined) {
1709
1767
  routeConfig.stream = validatorInfo.stream;
@@ -1879,9 +1937,25 @@ export async function parseRoute(
1879
1937
  );
1880
1938
  if (validatorInfo.inputSchemaVariable) {
1881
1939
  routeConfig.inputSchemaVariable = validatorInfo.inputSchemaVariable;
1940
+ // Track where the schema is imported from (if imported)
1941
+ const inputImportInfo = importInfoMap.get(
1942
+ validatorInfo.inputSchemaVariable
1943
+ );
1944
+ if (inputImportInfo) {
1945
+ routeConfig.inputSchemaImportPath = inputImportInfo.modulePath;
1946
+ routeConfig.inputSchemaImportedName = inputImportInfo.importedName;
1947
+ }
1882
1948
  }
1883
1949
  if (validatorInfo.outputSchemaVariable) {
1884
1950
  routeConfig.outputSchemaVariable = validatorInfo.outputSchemaVariable;
1951
+ // Track where the schema is imported from (if imported)
1952
+ const outputImportInfo = importInfoMap.get(
1953
+ validatorInfo.outputSchemaVariable
1954
+ );
1955
+ if (outputImportInfo) {
1956
+ routeConfig.outputSchemaImportPath = outputImportInfo.modulePath;
1957
+ routeConfig.outputSchemaImportedName = outputImportInfo.importedName;
1958
+ }
1885
1959
  }
1886
1960
  if (validatorInfo.stream !== undefined) {
1887
1961
  routeConfig.stream = validatorInfo.stream;
@@ -1894,9 +1968,21 @@ export async function parseRoute(
1894
1968
  // which is useful when using zValidator (input-only) but needing typed outputs
1895
1969
  if (!routeConfig.inputSchemaVariable && exportedInputSchemaName) {
1896
1970
  routeConfig.inputSchemaVariable = exportedInputSchemaName;
1971
+ // Check if exported schema name is also imported
1972
+ const inputImportInfo = importInfoMap.get(exportedInputSchemaName);
1973
+ if (inputImportInfo) {
1974
+ routeConfig.inputSchemaImportPath = inputImportInfo.modulePath;
1975
+ routeConfig.inputSchemaImportedName = inputImportInfo.importedName;
1976
+ }
1897
1977
  }
1898
1978
  if (!routeConfig.outputSchemaVariable && exportedOutputSchemaName) {
1899
1979
  routeConfig.outputSchemaVariable = exportedOutputSchemaName;
1980
+ // Check if exported schema name is also imported
1981
+ const outputImportInfo = importInfoMap.get(exportedOutputSchemaName);
1982
+ if (outputImportInfo) {
1983
+ routeConfig.outputSchemaImportPath = outputImportInfo.modulePath;
1984
+ routeConfig.outputSchemaImportedName = outputImportInfo.importedName;
1985
+ }
1900
1986
  }
1901
1987
 
1902
1988
  routes.push({
@@ -4,7 +4,7 @@
4
4
  * Generates src/generated/registry.ts from discovered agents
5
5
  */
6
6
 
7
- import { join } from 'node:path';
7
+ import { join, dirname, relative, resolve } from 'node:path';
8
8
  import { writeFileSync, mkdirSync, existsSync, unlinkSync, readFileSync } from 'node:fs';
9
9
  import { stat } from 'node:fs/promises';
10
10
  import { StructuredError } from '@agentuity/core';
@@ -12,6 +12,45 @@ import { toCamelCase, toPascalCase } from '../../../utils/string';
12
12
  import type { AgentMetadata } from './agent-discovery';
13
13
  import type { RouteInfo } from './route-discovery';
14
14
 
15
+ /**
16
+ * Rebase a relative import path from the route file's location to the generated file's location.
17
+ * @param routeFilename - The route file path (e.g., 'api/example/route.ts' or './api/example/route.ts')
18
+ * @param schemaImportPath - The import path as written in the route file (e.g., '../../utils/schemas')
19
+ * @param srcDir - The src directory path
20
+ * @returns The rebased import path relative to src/generated/
21
+ */
22
+ function rebaseImportPath(routeFilename: string, schemaImportPath: string, srcDir: string): string {
23
+ // Non-relative imports (bare modules like '@company/schemas') should be used as-is
24
+ if (!schemaImportPath.startsWith('.') && !schemaImportPath.startsWith('/')) {
25
+ return schemaImportPath;
26
+ }
27
+
28
+ // Normalize route filename to get its directory relative to srcDir
29
+ let routeDir: string;
30
+ const cleanFilename = routeFilename.replace(/\\/g, '/');
31
+ if (cleanFilename.startsWith('./')) {
32
+ routeDir = dirname(join(srcDir, cleanFilename.substring(2)));
33
+ } else if (cleanFilename.startsWith('src/')) {
34
+ routeDir = dirname(join(srcDir, '..', cleanFilename));
35
+ } else {
36
+ routeDir = dirname(join(srcDir, cleanFilename));
37
+ }
38
+
39
+ // Resolve the schema module path from the route file's directory
40
+ const resolvedSchemaPath = resolve(routeDir, schemaImportPath);
41
+
42
+ // Calculate the relative path from src/generated/ to the resolved schema path
43
+ const generatedDir = join(srcDir, 'generated');
44
+ let rebasedPath = relative(generatedDir, resolvedSchemaPath).replace(/\\/g, '/');
45
+
46
+ // Ensure it starts with './' or '../'
47
+ if (!rebasedPath.startsWith('.') && !rebasedPath.startsWith('/')) {
48
+ rebasedPath = './' + rebasedPath;
49
+ }
50
+
51
+ return rebasedPath;
52
+ }
53
+
15
54
  const AgentIdentifierCollisionError = StructuredError('AgentIdentifierCollisionError');
16
55
 
17
56
  /**
@@ -617,6 +656,8 @@ export async function generateRouteRegistry(
617
656
  const imports: string[] = [];
618
657
  const agentImports = new Map<string, string>();
619
658
  const routeFileImports = new Map<string, Set<string>>();
659
+ // Track per-route which import path and schema name to use for alias lookup
660
+ const routeSchemaImportInfo = new Map<string, { importPath: string; schemaName: string }>();
620
661
 
621
662
  // Collect agent and schema imports from routes with validators or exported schemas
622
663
  allRoutes.forEach((route) => {
@@ -690,25 +731,76 @@ export async function generateRouteRegistry(
690
731
  }
691
732
 
692
733
  // Collect schema variable imports
693
- if (route.inputSchemaVariable || route.outputSchemaVariable) {
694
- const filename = route.filename.replace(/\\/g, '/');
695
- // Remove 'src/' prefix if present (routes.filename might be './api/...' or 'src/api/...')
696
- const withoutSrc = filename.startsWith('src/') ? filename.substring(4) : filename;
697
- const withoutLeadingDot = withoutSrc.startsWith('./')
698
- ? withoutSrc.substring(2)
699
- : withoutSrc;
700
- const importPath = `../${withoutLeadingDot.replace(/\.ts$/, '')}`;
734
+ // If the schema is imported from another file, use that file's path (rebased)
735
+ // Otherwise fall back to the route file path (for locally defined schemas)
736
+ if (route.inputSchemaVariable) {
737
+ let importPath: string;
738
+ let schemaNameToImport: string;
739
+
740
+ if (route.inputSchemaImportPath) {
741
+ // Schema is imported - rebase the import path from route file to generated file
742
+ importPath = rebaseImportPath(route.filename, route.inputSchemaImportPath, srcDir);
743
+ // Use the actual exported name (handles aliased imports like `import { A as B }`)
744
+ schemaNameToImport =
745
+ route.inputSchemaImportedName === 'default'
746
+ ? route.inputSchemaVariable
747
+ : (route.inputSchemaImportedName ?? route.inputSchemaVariable);
748
+ } else {
749
+ // Schema is locally defined - import from the route file
750
+ const filename = route.filename.replace(/\\/g, '/');
751
+ const withoutSrc = filename.startsWith('src/') ? filename.substring(4) : filename;
752
+ const withoutLeadingDot = withoutSrc.startsWith('./')
753
+ ? withoutSrc.substring(2)
754
+ : withoutSrc;
755
+ importPath = `../${withoutLeadingDot.replace(/\.ts$/, '')}`;
756
+ schemaNameToImport = route.inputSchemaVariable;
757
+ }
701
758
 
702
759
  if (!routeFileImports.has(importPath)) {
703
760
  routeFileImports.set(importPath, new Set());
704
761
  }
762
+ routeFileImports.get(importPath)!.add(schemaNameToImport);
705
763
 
706
- if (route.inputSchemaVariable) {
707
- routeFileImports.get(importPath)!.add(route.inputSchemaVariable);
764
+ // Store the resolved import info for later alias lookup
765
+ routeSchemaImportInfo.set(`input:${route.path}:${route.method}`, {
766
+ importPath,
767
+ schemaName: schemaNameToImport,
768
+ });
769
+ }
770
+
771
+ if (route.outputSchemaVariable) {
772
+ let importPath: string;
773
+ let schemaNameToImport: string;
774
+
775
+ if (route.outputSchemaImportPath) {
776
+ // Schema is imported - rebase the import path from route file to generated file
777
+ importPath = rebaseImportPath(route.filename, route.outputSchemaImportPath, srcDir);
778
+ // Use the actual exported name (handles aliased imports like `import { A as B }`)
779
+ schemaNameToImport =
780
+ route.outputSchemaImportedName === 'default'
781
+ ? route.outputSchemaVariable
782
+ : (route.outputSchemaImportedName ?? route.outputSchemaVariable);
783
+ } else {
784
+ // Schema is locally defined - import from the route file
785
+ const filename = route.filename.replace(/\\/g, '/');
786
+ const withoutSrc = filename.startsWith('src/') ? filename.substring(4) : filename;
787
+ const withoutLeadingDot = withoutSrc.startsWith('./')
788
+ ? withoutSrc.substring(2)
789
+ : withoutSrc;
790
+ importPath = `../${withoutLeadingDot.replace(/\.ts$/, '')}`;
791
+ schemaNameToImport = route.outputSchemaVariable;
708
792
  }
709
- if (route.outputSchemaVariable) {
710
- routeFileImports.get(importPath)!.add(route.outputSchemaVariable);
793
+
794
+ if (!routeFileImports.has(importPath)) {
795
+ routeFileImports.set(importPath, new Set());
711
796
  }
797
+ routeFileImports.get(importPath)!.add(schemaNameToImport);
798
+
799
+ // Store the resolved import info for later alias lookup
800
+ routeSchemaImportInfo.set(`output:${route.path}:${route.method}`, {
801
+ importPath,
802
+ schemaName: schemaNameToImport,
803
+ });
712
804
  }
713
805
  });
714
806
 
@@ -774,18 +866,22 @@ export async function generateRouteRegistry(
774
866
  inputSchemaType = `typeof ${importName} extends { inputSchema?: infer I } ? I : never`;
775
867
  outputSchemaType = `typeof ${importName} extends { outputSchema?: infer O } ? O : never`;
776
868
  } else if (route.inputSchemaVariable || route.outputSchemaVariable) {
777
- // Get the aliased schema names for this route's file
778
- const filename = route.filename.replace(/\\/g, '/');
779
- const withoutSrc = filename.startsWith('src/') ? filename.substring(4) : filename;
780
- const withoutLeadingDot = withoutSrc.startsWith('./')
781
- ? withoutSrc.substring(2)
782
- : withoutSrc;
783
- const importPath = `../${withoutLeadingDot.replace(/\.ts$/, '')}`;
784
- const aliases = schemaImportAliases.get(importPath);
869
+ // Get the aliased schema names using the stored import info
870
+ // (which correctly handles schemas imported from shared files)
871
+ const inputInfo = routeSchemaImportInfo.get(`input:${route.path}:${route.method}`);
872
+ const outputInfo = routeSchemaImportInfo.get(`output:${route.path}:${route.method}`);
873
+
874
+ let inputAlias: string | undefined;
875
+ let outputAlias: string | undefined;
785
876
 
786
- const inputAlias = route.inputSchemaVariable && aliases?.get(route.inputSchemaVariable);
787
- const outputAlias =
788
- route.outputSchemaVariable && aliases?.get(route.outputSchemaVariable);
877
+ if (inputInfo) {
878
+ const aliases = schemaImportAliases.get(inputInfo.importPath);
879
+ inputAlias = aliases?.get(inputInfo.schemaName);
880
+ }
881
+ if (outputInfo) {
882
+ const aliases = schemaImportAliases.get(outputInfo.importPath);
883
+ outputAlias = aliases?.get(outputInfo.schemaName);
884
+ }
789
885
 
790
886
  inputType = inputAlias ? `InferInput<typeof ${inputAlias}>` : 'never';
791
887
  outputType = outputAlias ? `InferOutput<typeof ${outputAlias}>` : 'never';
@@ -37,6 +37,10 @@ export interface RouteInfo {
37
37
  agentDescription?: string;
38
38
  inputSchemaVariable?: string;
39
39
  outputSchemaVariable?: string;
40
+ inputSchemaImportPath?: string;
41
+ inputSchemaImportedName?: string;
42
+ outputSchemaImportPath?: string;
43
+ outputSchemaImportedName?: string;
40
44
  inputSchemaCode?: string;
41
45
  outputSchemaCode?: string;
42
46
  stream?: boolean;
@@ -119,6 +123,18 @@ export async function discoverRoutes(
119
123
  agentImportPath: route.config?.agentImportPath as string | undefined,
120
124
  inputSchemaVariable: route.config?.inputSchemaVariable as string | undefined,
121
125
  outputSchemaVariable: route.config?.outputSchemaVariable as string | undefined,
126
+ inputSchemaImportPath: route.config?.inputSchemaImportPath as
127
+ | string
128
+ | undefined,
129
+ inputSchemaImportedName: route.config?.inputSchemaImportedName as
130
+ | string
131
+ | undefined,
132
+ outputSchemaImportPath: route.config?.outputSchemaImportPath as
133
+ | string
134
+ | undefined,
135
+ outputSchemaImportedName: route.config?.outputSchemaImportedName as
136
+ | string
137
+ | undefined,
122
138
  stream:
123
139
  route.config?.stream !== undefined && route.config.stream !== null
124
140
  ? Boolean(route.config.stream)
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { createSubcommand } from '../../../types';
3
3
  import * as tui from '../../../tui';
4
- import { projectEnvDelete, projectGet } from '@agentuity/server';
4
+ import { projectEnvDelete, projectGet, orgEnvDelete, orgEnvGet } from '@agentuity/server';
5
5
  import {
6
6
  findExistingEnvFile,
7
7
  readEnvFile,
@@ -11,34 +11,60 @@ import {
11
11
  } from '../../../env-util';
12
12
  import { getCommand } from '../../../command-prefix';
13
13
  import { ErrorCode } from '../../../errors';
14
+ import { resolveOrgId, isOrgScope } from './org-util';
14
15
 
15
16
  const EnvDeleteResponseSchema = z.object({
16
17
  success: z.boolean().describe('Whether the operation succeeded'),
17
18
  key: z.string().describe('Variable key that was deleted'),
18
- path: z.string().describe('Local file path where variable was removed'),
19
+ path: z
20
+ .string()
21
+ .optional()
22
+ .describe('Local file path where variable was removed (project scope only)'),
19
23
  secret: z.boolean().describe('Whether a secret was deleted'),
24
+ scope: z.enum(['project', 'org']).describe('The scope from which the variable was deleted'),
20
25
  });
21
26
 
22
27
  export const deleteSubcommand = createSubcommand({
23
28
  name: 'delete',
24
29
  aliases: ['del', 'remove', 'rm'],
25
30
  description: 'Delete an environment variable or secret',
26
- tags: ['destructive', 'deletes-resource', 'slow', 'requires-auth', 'requires-project'],
31
+ tags: ['destructive', 'deletes-resource', 'slow', 'requires-auth'],
27
32
  idempotent: true,
28
33
  examples: [
29
34
  { command: getCommand('env delete OLD_FEATURE_FLAG'), description: 'Delete variable' },
30
35
  { command: getCommand('env rm API_KEY'), description: 'Delete a secret' },
36
+ {
37
+ command: getCommand('env rm OPENAI_API_KEY --org'),
38
+ description: 'Delete org-level secret',
39
+ },
31
40
  ],
32
- requires: { auth: true, project: true, apiClient: true },
41
+ requires: { auth: true, apiClient: true },
42
+ optional: { project: true },
33
43
  schema: {
34
44
  args: z.object({
35
45
  key: z.string().describe('the variable or secret key to delete'),
36
46
  }),
47
+ options: z.object({
48
+ org: z
49
+ .union([z.boolean(), z.string()])
50
+ .optional()
51
+ .describe(
52
+ 'delete from organization level (use --org for default org, or --org <orgId> for specific org)'
53
+ ),
54
+ }),
37
55
  response: EnvDeleteResponseSchema,
38
56
  },
39
57
 
40
58
  async handler(ctx) {
41
- const { args, project, projectDir, apiClient } = ctx;
59
+ const { args, project, projectDir, apiClient, config, opts } = ctx;
60
+ const useOrgScope = isOrgScope(opts?.org);
61
+
62
+ // Require project context if not using org scope
63
+ if (!useOrgScope && !project) {
64
+ tui.fatal(
65
+ 'Project context required. Run from a project directory or use --org for organization scope.'
66
+ );
67
+ }
42
68
 
43
69
  // Validate key doesn't start with reserved AGENTUITY_ prefix (except AGENTUITY_PUBLIC_)
44
70
  if (isReservedAgentuityKey(args.key)) {
@@ -47,45 +73,91 @@ export const deleteSubcommand = createSubcommand({
47
73
  );
48
74
  }
49
75
 
50
- // First, determine if this key exists in env or secrets
51
- const projectData = await tui.spinner('Checking variable', () => {
52
- return projectGet(apiClient, { id: project.projectId, mask: true });
53
- });
76
+ if (useOrgScope) {
77
+ // Organization scope
78
+ const orgId = await resolveOrgId(apiClient, config, opts!.org!);
54
79
 
55
- const isSecret = projectData.secrets?.[args.key] !== undefined;
56
- const isEnv = projectData.env?.[args.key] !== undefined;
80
+ // First, determine if this key exists in env or secrets
81
+ const orgData = await tui.spinner('Checking organization variable', () => {
82
+ return orgEnvGet(apiClient, { id: orgId, mask: true });
83
+ });
57
84
 
58
- if (!isSecret && !isEnv) {
59
- tui.fatal(`Variable '${args.key}' not found`, ErrorCode.RESOURCE_NOT_FOUND);
60
- }
85
+ const isSecret = orgData.secrets?.[args.key] !== undefined;
86
+ const isEnv = orgData.env?.[args.key] !== undefined;
87
+
88
+ if (!isSecret && !isEnv) {
89
+ tui.fatal(
90
+ `Variable '${args.key}' not found in organization`,
91
+ ErrorCode.RESOURCE_NOT_FOUND
92
+ );
93
+ }
61
94
 
62
- // Delete from cloud using the correct field
63
- const label = isSecret ? 'secret' : 'environment variable';
64
- await tui.spinner(`Deleting ${label} from cloud`, () => {
65
- return projectEnvDelete(apiClient, {
66
- id: project.projectId,
67
- ...(isSecret ? { secrets: [args.key] } : { env: [args.key] }),
95
+ // Delete from cloud
96
+ const label = isSecret ? 'secret' : 'environment variable';
97
+ await tui.spinner(`Deleting organization ${label} from cloud`, () => {
98
+ return orgEnvDelete(apiClient, {
99
+ id: orgId,
100
+ ...(isSecret ? { secrets: [args.key] } : { env: [args.key] }),
101
+ });
68
102
  });
69
- });
70
-
71
- // Update local .env file
72
- const envFilePath = await findExistingEnvFile(projectDir);
73
- const currentEnv = await readEnvFile(envFilePath);
74
- delete currentEnv[args.key];
75
-
76
- // Filter out AGENTUITY_ keys before writing
77
- const filteredEnv = filterAgentuitySdkKeys(currentEnv);
78
- await writeEnvFile(envFilePath, filteredEnv);
79
-
80
- tui.success(
81
- `${isSecret ? 'Secret' : 'Environment variable'} '${args.key}' deleted successfully (cloud + ${envFilePath})`
82
- );
83
-
84
- return {
85
- success: true,
86
- key: args.key,
87
- path: envFilePath,
88
- secret: isSecret,
89
- };
103
+
104
+ tui.success(
105
+ `Organization ${isSecret ? 'secret' : 'environment variable'} '${args.key}' deleted successfully`
106
+ );
107
+
108
+ return {
109
+ success: true,
110
+ key: args.key,
111
+ secret: isSecret,
112
+ scope: 'org' as const,
113
+ };
114
+ } else {
115
+ // Project scope (existing behavior)
116
+ const projectData = await tui.spinner('Checking variable', () => {
117
+ return projectGet(apiClient, { id: project!.projectId, mask: true });
118
+ });
119
+
120
+ const isSecret = projectData.secrets?.[args.key] !== undefined;
121
+ const isEnv = projectData.env?.[args.key] !== undefined;
122
+
123
+ if (!isSecret && !isEnv) {
124
+ tui.fatal(`Variable '${args.key}' not found`, ErrorCode.RESOURCE_NOT_FOUND);
125
+ }
126
+
127
+ // Delete from cloud using the correct field
128
+ const label = isSecret ? 'secret' : 'environment variable';
129
+ await tui.spinner(`Deleting ${label} from cloud`, () => {
130
+ return projectEnvDelete(apiClient, {
131
+ id: project!.projectId,
132
+ ...(isSecret ? { secrets: [args.key] } : { env: [args.key] }),
133
+ });
134
+ });
135
+
136
+ // Update local .env file only if we have a project directory
137
+ // (not when using --project-id without being in a project folder)
138
+ let envFilePath: string | undefined;
139
+ if (projectDir) {
140
+ envFilePath = await findExistingEnvFile(projectDir);
141
+ const currentEnv = await readEnvFile(envFilePath);
142
+ delete currentEnv[args.key];
143
+
144
+ // Filter out AGENTUITY_ keys before writing
145
+ const filteredEnv = filterAgentuitySdkKeys(currentEnv);
146
+ await writeEnvFile(envFilePath, filteredEnv);
147
+ }
148
+
149
+ const successMsg = envFilePath
150
+ ? `${isSecret ? 'Secret' : 'Environment variable'} '${args.key}' deleted successfully (cloud + ${envFilePath})`
151
+ : `${isSecret ? 'Secret' : 'Environment variable'} '${args.key}' deleted successfully (cloud only)`;
152
+ tui.success(successMsg);
153
+
154
+ return {
155
+ success: true,
156
+ key: args.key,
157
+ path: envFilePath,
158
+ secret: isSecret,
159
+ scope: 'project' as const,
160
+ };
161
+ }
90
162
  },
91
163
  });