@agentuity/cli 0.0.107 → 0.0.108

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 (53) hide show
  1. package/dist/cmd/build/entry-generator.d.ts.map +1 -1
  2. package/dist/cmd/build/entry-generator.js +43 -50
  3. package/dist/cmd/build/entry-generator.js.map +1 -1
  4. package/dist/cmd/build/index.d.ts.map +1 -1
  5. package/dist/cmd/build/index.js +9 -9
  6. package/dist/cmd/build/index.js.map +1 -1
  7. package/dist/cmd/build/typecheck.d.ts +23 -0
  8. package/dist/cmd/build/typecheck.d.ts.map +1 -0
  9. package/dist/cmd/build/typecheck.js +38 -0
  10. package/dist/cmd/build/typecheck.js.map +1 -0
  11. package/dist/cmd/build/vite/vite-asset-server-config.d.ts.map +1 -1
  12. package/dist/cmd/build/vite/vite-asset-server-config.js +15 -8
  13. package/dist/cmd/build/vite/vite-asset-server-config.js.map +1 -1
  14. package/dist/cmd/build/vite/vite-asset-server.d.ts.map +1 -1
  15. package/dist/cmd/build/vite/vite-asset-server.js +6 -2
  16. package/dist/cmd/build/vite/vite-asset-server.js.map +1 -1
  17. package/dist/cmd/build/vite/vite-builder.d.ts.map +1 -1
  18. package/dist/cmd/build/vite/vite-builder.js +14 -2
  19. package/dist/cmd/build/vite/vite-builder.js.map +1 -1
  20. package/dist/cmd/cloud/deploy.d.ts.map +1 -1
  21. package/dist/cmd/cloud/deploy.js +67 -6
  22. package/dist/cmd/cloud/deploy.js.map +1 -1
  23. package/dist/cmd/dev/index.d.ts.map +1 -1
  24. package/dist/cmd/dev/index.js +623 -578
  25. package/dist/cmd/dev/index.js.map +1 -1
  26. package/dist/schema-parser.d.ts.map +1 -1
  27. package/dist/schema-parser.js +17 -3
  28. package/dist/schema-parser.js.map +1 -1
  29. package/dist/tsc-output-parser.d.ts +54 -0
  30. package/dist/tsc-output-parser.d.ts.map +1 -0
  31. package/dist/tsc-output-parser.js +926 -0
  32. package/dist/tsc-output-parser.js.map +1 -0
  33. package/dist/tui.d.ts +77 -0
  34. package/dist/tui.d.ts.map +1 -1
  35. package/dist/tui.js +27 -2
  36. package/dist/tui.js.map +1 -1
  37. package/dist/typescript-errors.d.ts +26 -0
  38. package/dist/typescript-errors.d.ts.map +1 -0
  39. package/dist/typescript-errors.js +249 -0
  40. package/dist/typescript-errors.js.map +1 -0
  41. package/package.json +4 -4
  42. package/src/cmd/build/entry-generator.ts +43 -51
  43. package/src/cmd/build/index.ts +13 -10
  44. package/src/cmd/build/typecheck.ts +55 -0
  45. package/src/cmd/build/vite/vite-asset-server-config.ts +17 -8
  46. package/src/cmd/build/vite/vite-asset-server.ts +6 -2
  47. package/src/cmd/build/vite/vite-builder.ts +13 -2
  48. package/src/cmd/cloud/deploy.ts +80 -8
  49. package/src/cmd/dev/index.ts +713 -657
  50. package/src/schema-parser.ts +17 -3
  51. package/src/tsc-output-parser.ts +1115 -0
  52. package/src/tui.ts +40 -2
  53. package/src/typescript-errors.ts +382 -0
@@ -44,6 +44,7 @@ import { encryptFIPSKEMDEMStream } from '../../crypto/box';
44
44
  import { getCommand } from '../../command-prefix';
45
45
  import * as domain from '../../domain';
46
46
  import { ErrorCode } from '../../errors';
47
+ import { typecheck } from '../build/typecheck';
47
48
 
48
49
  const DeploymentCancelledError = StructuredError(
49
50
  'DeploymentCancelled',
@@ -89,7 +90,12 @@ export const deploySubcommand = createSubcommand({
89
90
  requires: { auth: true, project: true, apiClient: true },
90
91
  prerequisites: ['auth login'],
91
92
  schema: {
92
- options: DeployOptionsSchema,
93
+ options: z.intersection(
94
+ DeployOptionsSchema,
95
+ z.object({
96
+ saveTypeErrors: z.string().optional().describe('file path to save typecheck errors'),
97
+ })
98
+ ),
93
99
  response: DeployResponseSchema,
94
100
  },
95
101
 
@@ -108,10 +114,38 @@ export const deploySubcommand = createSubcommand({
108
114
  // Ensure SDK key is present before proceeding
109
115
  if (!sdkKey) {
110
116
  ctx.logger.fatal(
111
- 'SDK key not found. Run "agentuity auth login" to authenticate or set AGENTUITY_SDK_KEY environment variable.'
117
+ 'The AGENTUITY_SDK_KEY value not found in the .env file in this folder. Ensure you are inside a valid Agentuity project folder and run "%s" to pull your environment from the cloud.',
118
+ getCommand('cloud env pull')
112
119
  );
113
120
  }
114
121
 
122
+ // Check for pre-created deployment from CI build environment
123
+ const deploymentEnv = process.env.AGENTUITY_DEPLOYMENT;
124
+ let useExistingDeployment = false;
125
+ if (deploymentEnv) {
126
+ const ExistingDeploymentSchema = z.object({
127
+ id: z.string(),
128
+ orgId: z.string(),
129
+ publicKey: z.string(),
130
+ });
131
+ try {
132
+ const parsed = JSON.parse(deploymentEnv);
133
+ const result = ExistingDeploymentSchema.safeParse(parsed);
134
+ if (result.success) {
135
+ deployment = result.data;
136
+ useExistingDeployment = true;
137
+ logger.debug('Using existing deployment: %s', result.data.id);
138
+ } else {
139
+ const errors = result.error.issues
140
+ .map((i) => `${i.path.join('.')}: ${i.message}`)
141
+ .join(', ');
142
+ logger.fatal(`Invalid AGENTUITY_DEPLOYMENT schema: ${errors}`);
143
+ }
144
+ } catch (err) {
145
+ logger.fatal(`Failed to parse AGENTUITY_DEPLOYMENT: ${err}`);
146
+ }
147
+ }
148
+
115
149
  try {
116
150
  await saveProjectDir(projectDir);
117
151
 
@@ -142,6 +176,9 @@ export const deploySubcommand = createSubcommand({
142
176
  label: 'Sync Env & Secrets',
143
177
  run: async () => {
144
178
  try {
179
+ if (useExistingDeployment) {
180
+ return stepSkipped('skipped in CI build');
181
+ }
145
182
  // Read env file
146
183
  const envFilePath = await findExistingEnvFile(projectDir);
147
184
  const localEnv = await readEnvFile(envFilePath);
@@ -178,6 +215,9 @@ export const deploySubcommand = createSubcommand({
178
215
  {
179
216
  label: 'Create Deployment',
180
217
  run: async () => {
218
+ if (useExistingDeployment) {
219
+ return stepSkipped('skipped in CI build');
220
+ }
181
221
  try {
182
222
  deployment = await projectDeploymentCreate(
183
223
  apiClient,
@@ -198,9 +238,25 @@ export const deploySubcommand = createSubcommand({
198
238
  return stepError('deployment was null');
199
239
  }
200
240
  let capturedOutput: string[] = [];
241
+ const rootDir = resolve(projectDir);
242
+ const started = Date.now();
243
+ const typeResult = await typecheck(rootDir);
244
+ if (typeResult.success) {
245
+ capturedOutput.push(
246
+ tui.muted(
247
+ `✓ Typechecked in ${Math.floor(Date.now() - started).toFixed(0)}ms`
248
+ )
249
+ );
250
+ } else {
251
+ if ('errors' in typeResult && opts.saveTypeErrors) {
252
+ const f = Bun.file(opts.saveTypeErrors);
253
+ await f.write(JSON.stringify(typeResult.errors));
254
+ }
255
+ return stepError('Typecheck failed\n\n' + typeResult.output);
256
+ }
201
257
  try {
202
258
  const bundleResult = await viteBundle({
203
- rootDir: resolve(projectDir),
259
+ rootDir,
204
260
  dev: false,
205
261
  deploymentId: deployment.id,
206
262
  orgId: deployment.orgId,
@@ -209,7 +265,7 @@ export const deploySubcommand = createSubcommand({
209
265
  logger: ctx.logger,
210
266
  deploymentOptions: opts,
211
267
  });
212
- capturedOutput = bundleResult.output;
268
+ capturedOutput = [...capturedOutput, ...bundleResult.output];
213
269
  build = await loadBuildMetadata(join(projectDir, '.agentuity'));
214
270
  instructions = await projectDeploymentUpdate(
215
271
  apiClient,
@@ -437,7 +493,14 @@ export const deploySubcommand = createSubcommand({
437
493
  };
438
494
  }
439
495
 
496
+ // TODO: send the deployment failure to the backend otherwise we staying in a deploying state
497
+
440
498
  const streamId = complete?.streamId;
499
+ const appUrl = getAppBaseURL(
500
+ process.env.AGENTUITY_REGION ?? config?.name,
501
+ config?.overrides
502
+ );
503
+ const dashboard = `${appUrl}/r/${deployment.id}`;
441
504
 
442
505
  // Poll for deployment status with optional log streaming
443
506
  const pollInterval = 500;
@@ -626,15 +689,24 @@ export const deploySubcommand = createSubcommand({
626
689
 
627
690
  tui.success('Your project was deployed!');
628
691
  }
692
+ } catch (ex) {
693
+ const lines = [`${ex}`, ''];
694
+ lines.push(
695
+ `${tui.ICONS.arrow} ${
696
+ tui.bold(tui.padRight('Dashboard:', 12)) + tui.link(dashboard)
697
+ }`
698
+ );
699
+ tui.banner(tui.colorError(`Deployment: ${deployment.id} Failed`), lines.join('\n'), {
700
+ centerTitle: false,
701
+ topSpacer: false,
702
+ bottomSpacer: false,
703
+ });
704
+ tui.fatal('Deployment failed', ErrorCode.BUILD_FAILED);
629
705
  } finally {
630
706
  // Clean up signal handler
631
707
  process.off('SIGINT', sigintHandler);
632
708
  }
633
709
 
634
- const appUrl = getAppBaseURL(config?.name, config?.overrides);
635
-
636
- const dashboard = `${appUrl}/r/${deployment.id}`;
637
-
638
710
  // Show deployment URLs
639
711
  if (complete?.publicUrls) {
640
712
  const lines: string[] = [];