@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
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
  import { join } from 'node:path';
3
3
  import { createSubcommand } from '../../../types';
4
4
  import * as tui from '../../../tui';
5
- import { projectGet } from '@agentuity/server';
5
+ import { projectGet, orgEnvGet } from '@agentuity/server';
6
6
  import {
7
7
  findExistingEnvFile,
8
8
  readEnvFile,
@@ -11,41 +11,99 @@ import {
11
11
  isReservedAgentuityKey,
12
12
  } from '../../../env-util';
13
13
  import { getCommand } from '../../../command-prefix';
14
+ import { resolveOrgId, isOrgScope } from './org-util';
14
15
 
15
16
  const EnvPullResponseSchema = z.object({
16
17
  success: z.boolean().describe('Whether pull succeeded'),
17
18
  pulled: z.number().describe('Number of items pulled'),
18
19
  path: z.string().describe('Local file path where variables were saved'),
19
20
  force: z.boolean().describe('Whether force mode was used'),
21
+ scope: z.enum(['project', 'org']).describe('The scope from which variables were pulled'),
20
22
  });
21
23
 
22
24
  export const pullSubcommand = createSubcommand({
23
25
  name: 'pull',
24
26
  description: 'Pull environment variables from cloud to local .env file',
25
- tags: ['slow', 'requires-auth', 'requires-project'],
27
+ tags: ['slow', 'requires-auth'],
26
28
  idempotent: true,
27
29
  examples: [
28
- { command: getCommand('env pull'), description: 'Run pull command' },
29
- { command: getCommand('env pull --force'), description: 'Use force option' },
30
+ { command: getCommand('env pull'), description: 'Pull from project' },
31
+ { command: getCommand('env pull --force'), description: 'Overwrite local with cloud values' },
32
+ { command: getCommand('env pull --org'), description: 'Pull from organization' },
30
33
  ],
31
- requires: { auth: true, project: true, apiClient: true },
34
+ requires: { auth: true, apiClient: true },
35
+ optional: { project: true },
32
36
  prerequisites: ['cloud deploy'],
33
37
  schema: {
34
38
  options: z.object({
35
39
  force: z.boolean().default(false).describe('overwrite local values with cloud values'),
40
+ org: z
41
+ .union([z.boolean(), z.string()])
42
+ .optional()
43
+ .describe('pull from organization level (use --org for default org)'),
36
44
  }),
37
45
  response: EnvPullResponseSchema,
38
46
  },
39
47
 
40
48
  async handler(ctx) {
41
- const { opts, apiClient, project, projectDir } = ctx;
49
+ const { opts, apiClient, project, projectDir, config } = ctx;
50
+ const useOrgScope = isOrgScope(opts?.org);
42
51
 
43
- // Fetch project with unmasked secrets
44
- const projectData = await tui.spinner('Pulling environment variables from cloud', () => {
45
- return projectGet(apiClient, { id: project.projectId, mask: false });
46
- });
52
+ // Require project context for local file operations
53
+ if (!projectDir) {
54
+ tui.fatal('Project context required. Run from a project directory.');
55
+ }
56
+
57
+ let cloudEnv: Record<string, string>;
58
+ let scope: 'project' | 'org';
59
+
60
+ if (useOrgScope) {
61
+ // Organization scope
62
+ const orgId = await resolveOrgId(apiClient, config, opts!.org!);
63
+
64
+ const orgData = await tui.spinner(
65
+ 'Pulling environment variables from organization',
66
+ () => {
67
+ return orgEnvGet(apiClient, { id: orgId, mask: false });
68
+ }
69
+ );
70
+
71
+ cloudEnv = { ...orgData.env, ...orgData.secrets };
72
+ scope = 'org';
73
+ } else {
74
+ // Project scope
75
+ if (!project) {
76
+ tui.fatal(
77
+ 'Project context required. Run from a project directory or use --org for organization scope.'
78
+ );
79
+ }
47
80
 
48
- const cloudEnv = { ...projectData.env, ...projectData.secrets }; // env pull with actually do both secrets and env since thats likely what the user would want
81
+ const projectData = await tui.spinner('Pulling environment variables from cloud', () => {
82
+ return projectGet(apiClient, { id: project.projectId, mask: false });
83
+ });
84
+
85
+ cloudEnv = { ...projectData.env, ...projectData.secrets };
86
+ scope = 'project';
87
+
88
+ // Write AGENTUITY_SDK_KEY to .env if present and missing locally (project scope only)
89
+ if (projectData.api_key) {
90
+ const dotEnvPath = join(projectDir, '.env');
91
+ const dotEnv = await readEnvFile(dotEnvPath);
92
+
93
+ if (!dotEnv.AGENTUITY_SDK_KEY) {
94
+ dotEnv.AGENTUITY_SDK_KEY = projectData.api_key;
95
+ await writeEnvFile(dotEnvPath, dotEnv, {
96
+ addComment: (key) => {
97
+ if (key === 'AGENTUITY_SDK_KEY') {
98
+ return 'AGENTUITY_SDK_KEY is a sensitive value and should not be committed to version control.';
99
+ }
100
+ return null;
101
+ },
102
+ });
103
+ tui.info(`Wrote AGENTUITY_SDK_KEY to ${dotEnvPath}`);
104
+ }
105
+ }
106
+ }
49
107
 
50
108
  // Target file is always .env
51
109
  const targetEnvPath = await findExistingEnvFile(projectDir);
@@ -66,28 +124,10 @@ export const pullSubcommand = createSubcommand({
66
124
  skipKeys: Object.keys(mergedEnv).filter(isReservedAgentuityKey),
67
125
  });
68
126
 
69
- // Write AGENTUITY_SDK_KEY to .env if present and missing locally
70
- if (projectData.api_key) {
71
- const dotEnvPath = join(projectDir, '.env');
72
- const dotEnv = await readEnvFile(dotEnvPath);
73
-
74
- if (!dotEnv.AGENTUITY_SDK_KEY) {
75
- dotEnv.AGENTUITY_SDK_KEY = projectData.api_key;
76
- await writeEnvFile(dotEnvPath, dotEnv, {
77
- addComment: (key) => {
78
- if (key === 'AGENTUITY_SDK_KEY') {
79
- return 'AGENTUITY_SDK_KEY is a sensitive value and should not be committed to version control.';
80
- }
81
- return null;
82
- },
83
- });
84
- tui.info(`Wrote AGENTUITY_SDK_KEY to ${dotEnvPath}`);
85
- }
86
- }
87
-
88
127
  const count = Object.keys(cloudEnv).length;
128
+ const scopeLabel = useOrgScope ? 'organization' : 'project';
89
129
  tui.success(
90
- `Pulled ${count} environment variable${count !== 1 ? 's' : ''} to ${targetEnvPath}`
130
+ `Pulled ${count} environment variable${count !== 1 ? 's' : ''} from ${scopeLabel} to ${targetEnvPath}`
91
131
  );
92
132
 
93
133
  return {
@@ -95,6 +135,7 @@ export const pullSubcommand = createSubcommand({
95
135
  pulled: count,
96
136
  path: targetEnvPath,
97
137
  force: opts?.force ?? false,
138
+ scope,
98
139
  };
99
140
  },
100
141
  });
@@ -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 { projectEnvUpdate } from '@agentuity/server';
4
+ import { projectEnvUpdate, orgEnvUpdate } from '@agentuity/server';
5
5
  import {
6
6
  findExistingEnvFile,
7
7
  readEnvFile,
@@ -10,6 +10,7 @@ import {
10
10
  validateNoPublicSecrets,
11
11
  } from '../../../env-util';
12
12
  import { getCommand } from '../../../command-prefix';
13
+ import { resolveOrgId, isOrgScope } from './org-util';
13
14
 
14
15
  const EnvPushResponseSchema = z.object({
15
16
  success: z.boolean().describe('Whether push succeeded'),
@@ -17,29 +18,39 @@ const EnvPushResponseSchema = z.object({
17
18
  envCount: z.number().describe('Number of env vars pushed'),
18
19
  secretCount: z.number().describe('Number of secrets pushed'),
19
20
  source: z.string().describe('Source file path'),
21
+ scope: z.enum(['project', 'org']).describe('The scope where variables were pushed'),
20
22
  });
21
23
 
22
24
  export const pushSubcommand = createSubcommand({
23
25
  name: 'push',
24
26
  description: 'Push environment variables and secrets from local .env file to cloud',
25
- tags: [
26
- 'mutating',
27
- 'updates-resource',
28
- 'slow',
29
- 'api-intensive',
30
- 'requires-auth',
31
- 'requires-project',
32
- ],
27
+ tags: ['mutating', 'updates-resource', 'slow', 'api-intensive', 'requires-auth'],
33
28
  idempotent: true,
34
- examples: [{ command: getCommand('env push'), description: 'Push all variables to cloud' }],
35
- requires: { auth: true, project: true, apiClient: true },
29
+ examples: [
30
+ { command: getCommand('env push'), description: 'Push all variables to cloud (project)' },
31
+ { command: getCommand('env push --org'), description: 'Push all variables to organization' },
32
+ ],
33
+ requires: { auth: true, apiClient: true },
34
+ optional: { project: true },
36
35
  prerequisites: ['env set'],
37
36
  schema: {
37
+ options: z.object({
38
+ org: z
39
+ .union([z.boolean(), z.string()])
40
+ .optional()
41
+ .describe('push to organization level (use --org for default org)'),
42
+ }),
38
43
  response: EnvPushResponseSchema,
39
44
  },
40
45
 
41
46
  async handler(ctx) {
42
- const { apiClient, project, projectDir } = ctx;
47
+ const { apiClient, project, projectDir, config, opts } = ctx;
48
+ const useOrgScope = isOrgScope(opts?.org);
49
+
50
+ // Always require projectDir since push reads from local .env file
51
+ if (!projectDir) {
52
+ tui.fatal('Project directory required. Run from a project directory.');
53
+ }
43
54
 
44
55
  // Read local env file
45
56
  const envFilePath = await findExistingEnvFile(projectDir);
@@ -56,6 +67,7 @@ export const pushSubcommand = createSubcommand({
56
67
  envCount: 0,
57
68
  secretCount: 0,
58
69
  source: envFilePath,
70
+ scope: useOrgScope ? ('org' as const) : ('project' as const),
59
71
  };
60
72
  }
61
73
 
@@ -74,29 +86,66 @@ export const pushSubcommand = createSubcommand({
74
86
  }
75
87
  }
76
88
 
77
- // Push to cloud
78
- await tui.spinner('Pushing variables to cloud', () => {
79
- return projectEnvUpdate(apiClient, {
80
- id: project.projectId,
81
- env,
82
- secrets,
89
+ if (useOrgScope) {
90
+ // Organization scope
91
+ const orgId = await resolveOrgId(apiClient, config, opts!.org!);
92
+
93
+ await tui.spinner('Pushing variables to organization', () => {
94
+ return orgEnvUpdate(apiClient, {
95
+ id: orgId,
96
+ env,
97
+ secrets,
98
+ });
83
99
  });
84
- });
85
-
86
- const envCount = Object.keys(env).length;
87
- const secretCount = Object.keys(secrets).length;
88
- const totalCount = envCount + secretCount;
89
-
90
- tui.success(
91
- `Pushed ${totalCount} variable${totalCount !== 1 ? 's' : ''} to cloud (${envCount} env, ${secretCount} secret${secretCount !== 1 ? 's' : ''})`
92
- );
93
-
94
- return {
95
- success: true,
96
- pushed: totalCount,
97
- envCount,
98
- secretCount,
99
- source: envFilePath,
100
- };
100
+
101
+ const envCount = Object.keys(env).length;
102
+ const secretCount = Object.keys(secrets).length;
103
+ const totalCount = envCount + secretCount;
104
+
105
+ tui.success(
106
+ `Pushed ${totalCount} variable${totalCount !== 1 ? 's' : ''} to organization (${envCount} env, ${secretCount} secret${secretCount !== 1 ? 's' : ''})`
107
+ );
108
+
109
+ return {
110
+ success: true,
111
+ pushed: totalCount,
112
+ envCount,
113
+ secretCount,
114
+ source: envFilePath,
115
+ scope: 'org' as const,
116
+ };
117
+ } else {
118
+ // Project scope (existing behavior)
119
+ if (!project) {
120
+ tui.fatal(
121
+ 'Project context required. Run from a project directory or use --org for organization scope.'
122
+ );
123
+ }
124
+
125
+ await tui.spinner('Pushing variables to cloud', () => {
126
+ return projectEnvUpdate(apiClient, {
127
+ id: project.projectId,
128
+ env,
129
+ secrets,
130
+ });
131
+ });
132
+
133
+ const envCount = Object.keys(env).length;
134
+ const secretCount = Object.keys(secrets).length;
135
+ const totalCount = envCount + secretCount;
136
+
137
+ tui.success(
138
+ `Pushed ${totalCount} variable${totalCount !== 1 ? 's' : ''} to cloud (${envCount} env, ${secretCount} secret${secretCount !== 1 ? 's' : ''})`
139
+ );
140
+
141
+ return {
142
+ success: true,
143
+ pushed: totalCount,
144
+ envCount,
145
+ secretCount,
146
+ source: envFilePath,
147
+ scope: 'project' as const,
148
+ };
149
+ }
101
150
  },
102
151
  });
@@ -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 { projectEnvUpdate } from '@agentuity/server';
4
+ import { projectEnvUpdate, orgEnvUpdate } from '@agentuity/server';
5
5
  import {
6
6
  findExistingEnvFile,
7
7
  readEnvFile,
@@ -13,20 +13,26 @@ import {
13
13
  PUBLIC_VAR_PREFIXES,
14
14
  } from '../../../env-util';
15
15
  import { getCommand } from '../../../command-prefix';
16
+ import { resolveOrgId, isOrgScope } from './org-util';
16
17
 
17
18
  const EnvSetResponseSchema = z.object({
18
19
  success: z.boolean().describe('Whether the operation succeeded'),
19
20
  key: z.string().describe('Environment variable key'),
20
- path: z.string().describe('Local file path where env var was saved'),
21
+ path: z
22
+ .string()
23
+ .optional()
24
+ .describe('Local file path where env var was saved (project scope only)'),
21
25
  secret: z.boolean().describe('Whether the value was stored as a secret'),
26
+ scope: z.enum(['project', 'org']).describe('The scope where the variable was set'),
22
27
  });
23
28
 
24
29
  export const setSubcommand = createSubcommand({
25
30
  name: 'set',
26
31
  description: 'Set an environment variable or secret',
27
- tags: ['mutating', 'updates-resource', 'slow', 'requires-auth', 'requires-project'],
32
+ tags: ['mutating', 'updates-resource', 'slow', 'requires-auth'],
28
33
  idempotent: true,
29
- requires: { auth: true, project: true, apiClient: true },
34
+ requires: { auth: true, apiClient: true },
35
+ optional: { project: true },
30
36
  examples: [
31
37
  {
32
38
  command: getCommand('env set NODE_ENV production'),
@@ -37,6 +43,10 @@ export const setSubcommand = createSubcommand({
37
43
  command: getCommand('env set API_KEY "sk_..." --secret'),
38
44
  description: 'Set a secret value',
39
45
  },
46
+ {
47
+ command: getCommand('env set OPENAI_API_KEY "sk_..." --secret --org'),
48
+ description: 'Set an organization-wide secret',
49
+ },
40
50
  ],
41
51
  schema: {
42
52
  args: z.object({
@@ -48,12 +58,27 @@ export const setSubcommand = createSubcommand({
48
58
  .boolean()
49
59
  .default(false)
50
60
  .describe('store as a secret (encrypted and masked in UI)'),
61
+ org: z
62
+ .union([z.boolean(), z.string()])
63
+ .optional()
64
+ .describe(
65
+ 'set at organization level (use --org for default org, or --org <orgId> for specific org)'
66
+ ),
51
67
  }),
52
68
  response: EnvSetResponseSchema,
53
69
  },
54
70
 
55
71
  async handler(ctx) {
56
- const { args, opts, apiClient, project, projectDir } = ctx;
72
+ const { args, opts, apiClient, project, projectDir, config } = ctx;
73
+ const useOrgScope = isOrgScope(opts?.org);
74
+
75
+ // Require project context if not using org scope
76
+ if (!useOrgScope && !project) {
77
+ tui.fatal(
78
+ 'Project context required. Run from a project directory or use --org for organization scope.'
79
+ );
80
+ }
81
+
57
82
  let isSecret = opts?.secret ?? false;
58
83
  const isPublic = isPublicVarKey(args.key);
59
84
 
@@ -81,34 +106,65 @@ export const setSubcommand = createSubcommand({
81
106
  }
82
107
  }
83
108
 
84
- // Set in cloud
85
- const updatePayload = isSecret
86
- ? { id: project.projectId, secrets: { [args.key]: args.value } }
87
- : { id: project.projectId, env: { [args.key]: args.value } };
88
-
89
109
  const label = isSecret ? 'secret' : 'environment variable';
90
- await tui.spinner(`Setting ${label} in cloud`, () => {
91
- return projectEnvUpdate(apiClient, updatePayload);
92
- });
93
-
94
- // Update local .env file
95
- const envFilePath = await findExistingEnvFile(projectDir);
96
- const currentEnv = await readEnvFile(envFilePath);
97
- currentEnv[args.key] = args.value;
98
-
99
- // Filter out AGENTUITY_ keys before writing
100
- const filteredEnv = filterAgentuitySdkKeys(currentEnv);
101
- await writeEnvFile(envFilePath, filteredEnv);
102
-
103
- tui.success(
104
- `${isSecret ? 'Secret' : 'Environment variable'} '${args.key}' set successfully (cloud + ${envFilePath})`
105
- );
106
-
107
- return {
108
- success: true,
109
- key: args.key,
110
- path: envFilePath,
111
- secret: isSecret,
112
- };
110
+
111
+ if (useOrgScope) {
112
+ // Organization scope
113
+ const orgId = await resolveOrgId(apiClient, config, opts!.org!);
114
+
115
+ const updatePayload = isSecret
116
+ ? { id: orgId, secrets: { [args.key]: args.value } }
117
+ : { id: orgId, env: { [args.key]: args.value } };
118
+
119
+ await tui.spinner(`Setting organization ${label} in cloud`, () => {
120
+ return orgEnvUpdate(apiClient, updatePayload);
121
+ });
122
+
123
+ tui.success(
124
+ `Organization ${isSecret ? 'secret' : 'environment variable'} '${args.key}' set successfully (affects all projects in org)`
125
+ );
126
+
127
+ return {
128
+ success: true,
129
+ key: args.key,
130
+ secret: isSecret,
131
+ scope: 'org' as const,
132
+ };
133
+ } else {
134
+ // Project scope (existing behavior)
135
+ const updatePayload = isSecret
136
+ ? { id: project!.projectId, secrets: { [args.key]: args.value } }
137
+ : { id: project!.projectId, env: { [args.key]: args.value } };
138
+
139
+ await tui.spinner(`Setting ${label} in cloud`, () => {
140
+ return projectEnvUpdate(apiClient, updatePayload);
141
+ });
142
+
143
+ // Update local .env file only if we have a project directory
144
+ // (not when using --project-id without being in a project folder)
145
+ let envFilePath: string | undefined;
146
+ if (projectDir) {
147
+ envFilePath = await findExistingEnvFile(projectDir);
148
+ const currentEnv = await readEnvFile(envFilePath);
149
+ currentEnv[args.key] = args.value;
150
+
151
+ // Filter out AGENTUITY_ keys before writing
152
+ const filteredEnv = filterAgentuitySdkKeys(currentEnv);
153
+ await writeEnvFile(envFilePath, filteredEnv);
154
+ }
155
+
156
+ const successMsg = envFilePath
157
+ ? `${isSecret ? 'Secret' : 'Environment variable'} '${args.key}' set successfully (cloud + ${envFilePath})`
158
+ : `${isSecret ? 'Secret' : 'Environment variable'} '${args.key}' set successfully (cloud only)`;
159
+ tui.success(successMsg);
160
+
161
+ return {
162
+ success: true,
163
+ key: args.key,
164
+ path: envFilePath,
165
+ secret: isSecret,
166
+ scope: 'project' as const,
167
+ };
168
+ }
113
169
  },
114
170
  });
@@ -9,6 +9,7 @@ import { sshSubcommand } from './ssh';
9
9
  import { scpSubcommand } from './scp';
10
10
  import { deploymentCommand } from './deployment';
11
11
  import keyvalueCommand from './keyvalue';
12
+ import queueCommand from './queue';
12
13
  import { agentCommand } from './agent';
13
14
  import envCommand from './env';
14
15
  import apikeyCommand from './apikey';
@@ -30,6 +31,7 @@ export const command = createCommand({
30
31
  subcommands: [
31
32
  apikeyCommand,
32
33
  keyvalueCommand,
34
+ queueCommand,
33
35
  agentCommand,
34
36
  streamCommand,
35
37
  vectorCommand,
@@ -9,7 +9,7 @@ export const createNamespaceSubcommand = createCommand({
9
9
  description: 'Create a new keyvalue namespace',
10
10
  tags: ['mutating', 'creates-resource', 'slow', 'requires-auth'],
11
11
  idempotent: false,
12
- requires: { auth: true, project: true },
12
+ requires: { auth: true },
13
13
  examples: [
14
14
  {
15
15
  command: getCommand('kv create-namespace production'),
@@ -8,9 +8,9 @@ export const deleteNamespaceSubcommand = createCommand({
8
8
  name: 'delete-namespace',
9
9
  aliases: ['rm-namespace'],
10
10
  description: 'Delete a keyvalue namespace and all its keys',
11
- tags: ['destructive', 'deletes-resource', 'slow', 'requires-auth', 'requires-project'],
11
+ tags: ['destructive', 'deletes-resource', 'slow', 'requires-auth'],
12
12
  idempotent: true,
13
- requires: { auth: true, project: true },
13
+ requires: { auth: true },
14
14
  examples: [
15
15
  {
16
16
  command: getCommand('kv delete-namespace staging'),
@@ -16,7 +16,7 @@ export const deleteSubcommand = createCommand({
16
16
  description: 'Delete a key from the keyvalue storage',
17
17
  tags: ['destructive', 'deletes-resource', 'slow', 'requires-auth'],
18
18
  idempotent: true,
19
- requires: { auth: true, project: true },
19
+ requires: { auth: true },
20
20
  examples: [
21
21
  { command: getCommand('kv delete production user:123'), description: 'Delete user data' },
22
22
  { command: getCommand('kv delete cache session:abc'), description: 'Delete cached session' },
@@ -14,7 +14,7 @@ export const getSubcommand = createCommand({
14
14
  name: 'get',
15
15
  description: 'Get a value from the keyvalue storage',
16
16
  tags: ['read-only', 'fast', 'requires-auth'],
17
- requires: { auth: true, project: true },
17
+ requires: { auth: true },
18
18
  examples: [
19
19
  { command: getCommand('kv get production user:123'), description: 'Get user data' },
20
20
  { command: getCommand('kv get cache session:abc'), description: 'Get cached session' },
@@ -35,6 +35,6 @@ export const command = createCommand({
35
35
  createNamespaceSubcommand,
36
36
  deleteNamespaceSubcommand,
37
37
  ],
38
- requires: { auth: true, project: true },
38
+ requires: { auth: true },
39
39
  });
40
40
  export default command;
@@ -13,7 +13,7 @@ export const keysSubcommand = createCommand({
13
13
  aliases: ['ls', 'list'],
14
14
  description: 'List all keys in a keyvalue namespace',
15
15
  tags: ['read-only', 'slow', 'requires-auth'],
16
- requires: { auth: true, project: true },
16
+ requires: { auth: true },
17
17
  idempotent: true,
18
18
  examples: [
19
19
  { command: getCommand('kv keys production'), description: 'List all keys in production' },
@@ -10,7 +10,7 @@ export const listNamespacesSubcommand = createCommand({
10
10
  aliases: ['namespaces', 'ns'],
11
11
  description: 'List all keyvalue namespaces',
12
12
  tags: ['read-only', 'fast', 'requires-auth'],
13
- requires: { auth: true, project: true },
13
+ requires: { auth: true },
14
14
  examples: [
15
15
  { command: getCommand('kv list-namespaces'), description: 'List all namespaces' },
16
16
  { command: getCommand('kv namespaces'), description: 'List namespaces (using alias)' },
@@ -11,16 +11,19 @@ export const replSubcommand = createCommand({
11
11
  description: 'Start an interactive repl for working with keyvalue database',
12
12
  tags: ['slow', 'requires-auth'],
13
13
  idempotent: false,
14
- requires: { auth: true, project: true },
14
+ requires: { auth: true },
15
+ optional: { project: true },
15
16
  examples: [{ command: getCommand('kv repl'), description: 'Start interactive KV session' }],
16
17
 
17
18
  async handler(ctx) {
18
19
  showBanner(undefined, true);
19
- tui.info('Managing keyvalue store for project');
20
- tui.newline();
21
- console.log(tui.bold('Org:'.padEnd(10, ' ')), ' ', tui.muted(ctx.project.orgId));
22
- console.log(tui.bold('Project:'.padEnd(10, ' ')), ' ', tui.muted(ctx.project.projectId));
20
+ tui.info('Managing keyvalue store');
23
21
  tui.newline();
22
+ if (ctx.project) {
23
+ console.log(tui.bold('Org:'.padEnd(10, ' ')), ' ', tui.muted(ctx.project.orgId));
24
+ console.log(tui.bold('Project:'.padEnd(10, ' ')), ' ', tui.muted(ctx.project.projectId));
25
+ tui.newline();
26
+ }
24
27
 
25
28
  const storage = await createStorageAdapter(ctx);
26
29
 
@@ -20,7 +20,7 @@ export const searchSubcommand = createCommand({
20
20
  name: 'search',
21
21
  description: 'Search for keys matching a keyword in a keyvalue namespace',
22
22
  tags: ['read-only', 'slow', 'requires-auth'],
23
- requires: { auth: true, project: true },
23
+ requires: { auth: true },
24
24
  idempotent: true,
25
25
  examples: [
26
26
  {
@@ -19,7 +19,7 @@ export const setSubcommand = createCommand({
19
19
  description: 'Set a key and value in the keyvalue storage',
20
20
  tags: ['mutating', 'updates-resource', 'slow', 'requires-auth'],
21
21
  idempotent: true,
22
- requires: { auth: true, project: true },
22
+ requires: { auth: true },
23
23
  examples: [
24
24
  {
25
25
  command: getCommand(
@@ -26,7 +26,7 @@ export const statsSubcommand = createCommand({
26
26
  name: 'stats',
27
27
  description: 'Get statistics for keyvalue storage',
28
28
  tags: ['read-only', 'fast', 'requires-auth'],
29
- requires: { auth: true, project: true },
29
+ requires: { auth: true },
30
30
  idempotent: true,
31
31
  examples: [
32
32
  { command: getCommand('kv stats'), description: 'Show stats for all namespaces' },