@agentuity/cli 0.1.10 → 0.1.12

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 (126) hide show
  1. package/dist/auth.d.ts.map +1 -1
  2. package/dist/auth.js +6 -10
  3. package/dist/auth.js.map +1 -1
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/cli.js +89 -41
  6. package/dist/cli.js.map +1 -1
  7. package/dist/cmd/auth/login.d.ts.map +1 -1
  8. package/dist/cmd/auth/login.js +49 -5
  9. package/dist/cmd/auth/login.js.map +1 -1
  10. package/dist/cmd/build/patch/_util.d.ts.map +1 -1
  11. package/dist/cmd/build/patch/_util.js +6 -2
  12. package/dist/cmd/build/patch/_util.js.map +1 -1
  13. package/dist/cmd/cloud/agent/get.d.ts.map +1 -1
  14. package/dist/cmd/cloud/agent/get.js +10 -6
  15. package/dist/cmd/cloud/agent/get.js.map +1 -1
  16. package/dist/cmd/cloud/db/create.d.ts.map +1 -1
  17. package/dist/cmd/cloud/db/create.js +14 -3
  18. package/dist/cmd/cloud/db/create.js.map +1 -1
  19. package/dist/cmd/cloud/db/get.d.ts.map +1 -1
  20. package/dist/cmd/cloud/db/get.js +13 -3
  21. package/dist/cmd/cloud/db/get.js.map +1 -1
  22. package/dist/cmd/cloud/db/list.d.ts.map +1 -1
  23. package/dist/cmd/cloud/db/list.js +17 -25
  24. package/dist/cmd/cloud/db/list.js.map +1 -1
  25. package/dist/cmd/cloud/deployment/show.d.ts.map +1 -1
  26. package/dist/cmd/cloud/deployment/show.js +50 -37
  27. package/dist/cmd/cloud/deployment/show.js.map +1 -1
  28. package/dist/cmd/cloud/sandbox/create.d.ts.map +1 -1
  29. package/dist/cmd/cloud/sandbox/create.js +19 -2
  30. package/dist/cmd/cloud/sandbox/create.js.map +1 -1
  31. package/dist/cmd/cloud/sandbox/execution/get.d.ts.map +1 -1
  32. package/dist/cmd/cloud/sandbox/execution/get.js +14 -11
  33. package/dist/cmd/cloud/sandbox/execution/get.js.map +1 -1
  34. package/dist/cmd/cloud/sandbox/get.d.ts.map +1 -1
  35. package/dist/cmd/cloud/sandbox/get.js +48 -39
  36. package/dist/cmd/cloud/sandbox/get.js.map +1 -1
  37. package/dist/cmd/cloud/sandbox/list.d.ts.map +1 -1
  38. package/dist/cmd/cloud/sandbox/list.js +6 -1
  39. package/dist/cmd/cloud/sandbox/list.js.map +1 -1
  40. package/dist/cmd/cloud/sandbox/run.d.ts.map +1 -1
  41. package/dist/cmd/cloud/sandbox/run.js +5 -1
  42. package/dist/cmd/cloud/sandbox/run.js.map +1 -1
  43. package/dist/cmd/cloud/sandbox/snapshot/build.d.ts +5 -0
  44. package/dist/cmd/cloud/sandbox/snapshot/build.d.ts.map +1 -0
  45. package/dist/cmd/cloud/sandbox/snapshot/build.js +590 -0
  46. package/dist/cmd/cloud/sandbox/snapshot/build.js.map +1 -0
  47. package/dist/cmd/cloud/sandbox/snapshot/generate.d.ts +3 -0
  48. package/dist/cmd/cloud/sandbox/snapshot/generate.d.ts.map +1 -0
  49. package/dist/cmd/cloud/sandbox/snapshot/generate.js +129 -0
  50. package/dist/cmd/cloud/sandbox/snapshot/generate.js.map +1 -0
  51. package/dist/cmd/cloud/sandbox/snapshot/get.d.ts.map +1 -1
  52. package/dist/cmd/cloud/sandbox/snapshot/get.js +25 -6
  53. package/dist/cmd/cloud/sandbox/snapshot/get.js.map +1 -1
  54. package/dist/cmd/cloud/sandbox/snapshot/index.d.ts.map +1 -1
  55. package/dist/cmd/cloud/sandbox/snapshot/index.js +19 -1
  56. package/dist/cmd/cloud/sandbox/snapshot/index.js.map +1 -1
  57. package/dist/cmd/cloud/session/get.d.ts.map +1 -1
  58. package/dist/cmd/cloud/session/get.js +24 -23
  59. package/dist/cmd/cloud/session/get.js.map +1 -1
  60. package/dist/cmd/cloud/session/list.d.ts.map +1 -1
  61. package/dist/cmd/cloud/session/list.js +7 -2
  62. package/dist/cmd/cloud/session/list.js.map +1 -1
  63. package/dist/cmd/cloud/thread/get.d.ts.map +1 -1
  64. package/dist/cmd/cloud/thread/get.js +11 -8
  65. package/dist/cmd/cloud/thread/get.js.map +1 -1
  66. package/dist/cmd/cloud/thread/list.d.ts.map +1 -1
  67. package/dist/cmd/cloud/thread/list.js +6 -1
  68. package/dist/cmd/cloud/thread/list.js.map +1 -1
  69. package/dist/cmd/dev/file-watcher.d.ts.map +1 -1
  70. package/dist/cmd/dev/file-watcher.js +2 -0
  71. package/dist/cmd/dev/file-watcher.js.map +1 -1
  72. package/dist/cmd/dev/index.d.ts.map +1 -1
  73. package/dist/cmd/dev/index.js +62 -4
  74. package/dist/cmd/dev/index.js.map +1 -1
  75. package/dist/cmd/project/auth/shared.js +1 -1
  76. package/dist/cmd/project/auth/shared.js.map +1 -1
  77. package/dist/cmd/project/template-flow.d.ts.map +1 -1
  78. package/dist/cmd/project/template-flow.js +15 -1
  79. package/dist/cmd/project/template-flow.js.map +1 -1
  80. package/dist/cmd/setup/index.d.ts.map +1 -1
  81. package/dist/cmd/setup/index.js +40 -3
  82. package/dist/cmd/setup/index.js.map +1 -1
  83. package/dist/config.d.ts.map +1 -1
  84. package/dist/config.js +10 -5
  85. package/dist/config.js.map +1 -1
  86. package/dist/steps.d.ts.map +1 -1
  87. package/dist/steps.js +4 -2
  88. package/dist/steps.js.map +1 -1
  89. package/dist/tui.d.ts +11 -1
  90. package/dist/tui.d.ts.map +1 -1
  91. package/dist/tui.js +47 -12
  92. package/dist/tui.js.map +1 -1
  93. package/dist/utils/apt-validator.js +3 -3
  94. package/dist/utils/apt-validator.js.map +1 -1
  95. package/package.json +6 -6
  96. package/src/auth.ts +12 -11
  97. package/src/cli.ts +121 -43
  98. package/src/cmd/auth/login.ts +57 -5
  99. package/src/cmd/build/patch/_util.ts +6 -2
  100. package/src/cmd/cloud/agent/get.ts +14 -6
  101. package/src/cmd/cloud/db/create.ts +15 -3
  102. package/src/cmd/cloud/db/get.ts +14 -3
  103. package/src/cmd/cloud/db/list.ts +16 -26
  104. package/src/cmd/cloud/deployment/show.ts +53 -47
  105. package/src/cmd/cloud/sandbox/create.ts +20 -2
  106. package/src/cmd/cloud/sandbox/execution/get.ts +16 -13
  107. package/src/cmd/cloud/sandbox/get.ts +48 -38
  108. package/src/cmd/cloud/sandbox/list.ts +6 -1
  109. package/src/cmd/cloud/sandbox/run.ts +5 -1
  110. package/src/cmd/cloud/sandbox/snapshot/build.ts +723 -0
  111. package/src/cmd/cloud/sandbox/snapshot/generate.ts +136 -0
  112. package/src/cmd/cloud/sandbox/snapshot/get.ts +29 -6
  113. package/src/cmd/cloud/sandbox/snapshot/index.ts +19 -1
  114. package/src/cmd/cloud/session/get.ts +25 -29
  115. package/src/cmd/cloud/session/list.ts +7 -2
  116. package/src/cmd/cloud/thread/get.ts +12 -8
  117. package/src/cmd/cloud/thread/list.ts +6 -1
  118. package/src/cmd/dev/file-watcher.ts +2 -0
  119. package/src/cmd/dev/index.ts +76 -4
  120. package/src/cmd/project/auth/shared.ts +1 -1
  121. package/src/cmd/project/template-flow.ts +15 -1
  122. package/src/cmd/setup/index.ts +41 -3
  123. package/src/config.ts +11 -5
  124. package/src/steps.ts +4 -2
  125. package/src/tui.ts +61 -12
  126. package/src/utils/apt-validator.ts +3 -3
package/src/config.ts CHANGED
@@ -298,11 +298,12 @@ export async function saveAuth(auth: AuthData): Promise<void> {
298
298
  try {
299
299
  await saveAuthToKeychain(profileName, authData);
300
300
 
301
- // Successfully stored in keychain, remove from config if present
301
+ // Successfully stored in keychain, remove auth from config if present
302
+ // but always save config to ensure profile file exists
302
303
  if (config.auth) {
303
304
  delete config.auth;
304
- await saveConfig(config);
305
305
  }
306
+ await saveConfig(config);
306
307
  return;
307
308
  } catch (error) {
308
309
  // Keychain failed, fall back to config file
@@ -732,7 +733,12 @@ export async function getDefaultRegion(profileName = 'production'): Promise<stri
732
733
  return process.env.AGENTUITY_REGION;
733
734
  }
734
735
 
735
- // 2. Check cached regions file (sorted by distance)
736
+ // 2. Local profile always uses 'local' region
737
+ if (profileName === 'local') {
738
+ return 'local';
739
+ }
740
+
741
+ // 3. Check cached regions file (sorted by distance)
736
742
  try {
737
743
  const cachePath = join(getDefaultConfigDir(), `regions-${profileName}.json`);
738
744
  const file = Bun.file(cachePath);
@@ -746,8 +752,8 @@ export async function getDefaultRegion(profileName = 'production'): Promise<stri
746
752
  // Fall through to default
747
753
  }
748
754
 
749
- // 3. Final fallback - 'local' for local profile, 'usc' otherwise
750
- return profileName === 'local' ? 'local' : 'usc';
755
+ // 4. Final fallback
756
+ return 'usc';
751
757
  }
752
758
 
753
759
  /**
package/src/steps.ts CHANGED
@@ -518,7 +518,8 @@ async function runStepsTUI(steps: Step[]): Promise<void> {
518
518
  // Handle errors
519
519
  if (stepState.status === 'error') {
520
520
  const errorColor = getColor('red');
521
- console.error(`\n${errorColor}Error: ${stepState.errorMessage}${COLORS.reset}`);
521
+ const errorMsg = stepState.errorMessage || 'An unknown error occurred';
522
+ console.error(`\n${errorColor}Error: ${errorMsg}${COLORS.reset}`);
522
523
  if (
523
524
  stepState.errorCause instanceof ValidationInputError ||
524
525
  stepState.errorCause instanceof ValidationOutputError
@@ -611,7 +612,8 @@ async function runStepsPlain(steps: Step[]): Promise<void> {
611
612
  console.log('');
612
613
  }
613
614
  const errorColor = getColor('red');
614
- console.error(`\n${errorColor}Error: ${outcome.message}${COLORS.reset}`);
615
+ const errorMsg = outcome.message || 'An unknown error occurred';
616
+ console.error(`\n${errorColor}Error: ${errorMsg}${COLORS.reset}`);
615
617
  if (
616
618
  outcome.cause instanceof ValidationInputError ||
617
619
  outcome.cause instanceof ValidationOutputError
package/src/tui.ts CHANGED
@@ -807,19 +807,26 @@ export function showSignupBenefits(): void {
807
807
 
808
808
  /**
809
809
  * Display a message when unauthenticated to let the user know certain capabilities are disabled
810
+ * @param hasProfile - If true, user has logged in before so only show "Login" instead of "Sign up / Login"
810
811
  */
811
- export function showLoggedOutMessage(): void {
812
+ export function showLoggedOutMessage(appBaseUrl: string, hasProfile = false): void {
812
813
  const YELLOW = Bun.color('yellow', 'ansi-16m');
813
814
  const TEXT =
814
815
  currentColorScheme === 'dark' ? Bun.color('white', 'ansi') : Bun.color('black', 'ansi');
815
816
  const RESET = '\x1b[0m';
816
817
 
817
- const signupTitle = 'Sign up / Login';
818
+ const signupTitle = hasProfile ? 'Login' : 'Sign up / Login';
819
+ const signupURL = hasProfile
820
+ ? `${appBaseUrl}/sign-in`
821
+ : `${appBaseUrl}/sign-up`;
818
822
  const showInline = supportsHyperlinks();
819
- const signupURL = 'https://app-v1.agentuity.com/sign-up';
820
823
  const signupLink = showInline
821
824
  ? link(signupURL, signupTitle)
822
825
  : ' '.repeat(stringWidth(signupTitle));
826
+ // Box inner width is 46 chars, "unauthenticated. " = 17 chars
827
+ // Padding needed: 46 - 17 - signupTitle.length - 1 (space before link) = 28 - signupTitle.length
828
+ const paddingLength = 28 - signupTitle.length;
829
+ const padding = ' '.repeat(paddingLength);
823
830
  const showNewLine = showInline ? '' : `║ ${RESET}${link(signupURL)}${YELLOW} ║`;
824
831
 
825
832
  const lines = [
@@ -828,7 +835,7 @@ export function showLoggedOutMessage(): void {
828
835
  '║ ║',
829
836
  `║ ${TEXT}Certain capabilities such as the AI services${YELLOW} ║`,
830
837
  `║ ${TEXT}and devmode remote are unavailable when${YELLOW} ║`,
831
- `║ ${TEXT}unauthenticated.${YELLOW} ${signupLink}${YELLOW} ║`,
838
+ `║ ${TEXT}unauthenticated.${YELLOW} ${signupLink}${YELLOW}${padding}║`,
832
839
  showNewLine,
833
840
  '╚══════════════════════════════════════════════╝',
834
841
  ];
@@ -837,6 +844,36 @@ export function showLoggedOutMessage(): void {
837
844
  lines.filter(Boolean).map((line) => console.log(YELLOW + line + RESET));
838
845
  }
839
846
 
847
+ /**
848
+ * Display a warning when running in local-only mode (no agentuity.json project config)
849
+ * This is shown during `agentuity dev` when the project hasn't been registered with Agentuity Cloud
850
+ */
851
+ export function showLocalOnlyWarning(): void {
852
+ const YELLOW = Bun.color('yellow', 'ansi-16m');
853
+ const TEXT =
854
+ currentColorScheme === 'dark' ? Bun.color('white', 'ansi') : Bun.color('black', 'ansi');
855
+ const RESET = '\x1b[0m';
856
+
857
+ const lines = [
858
+ '╔═══════════════════════════════════════════════════════════════╗',
859
+ `║ ⨺ Local-only mode ║`,
860
+ '║ ║',
861
+ `║ ${TEXT}This project is not registered with Agentuity Cloud.${YELLOW} ║`,
862
+ `║ ${TEXT}The following features are disabled:${YELLOW} ║`,
863
+ `║ ${TEXT}• AI Gateway (LLM calls require provider API keys)${YELLOW} ║`,
864
+ `║ ${TEXT}• Public URL / Remote access${YELLOW} ║`,
865
+ `║ ${TEXT}• Dashboard / Tracing / Observability${YELLOW} ║`,
866
+ '║ ║',
867
+ `║ ${TEXT}To enable cloud features, create a project and login.${YELLOW} ║`,
868
+ `║ ${TEXT}Or set provider API keys (e.g. OPENAI_API_KEY) in .env${YELLOW} ║`,
869
+ '╚═══════════════════════════════════════════════════════════════╝',
870
+ ];
871
+
872
+ console.log('');
873
+ lines.map((line) => console.log(YELLOW + line + RESET));
874
+ console.log('');
875
+ }
876
+
840
877
  /**
841
878
  * Copy text to clipboard
842
879
  * Returns true if successful, false otherwise
@@ -1675,11 +1712,14 @@ export async function selectOrganization(
1675
1712
  );
1676
1713
  }
1677
1714
 
1715
+ // Find the index of the initial org to pre-select it in the list
1716
+ const initialIndex = initial ? orgs.findIndex((o) => o.id === initial) : -1;
1717
+
1678
1718
  const response = await enquirer.prompt<{ action: string }>({
1679
1719
  type: 'select',
1680
1720
  name: 'action',
1681
1721
  message: 'Select an organization',
1682
- initial: initial || (orgs.length === 1 ? orgs[0].id : undefined),
1722
+ initial: initialIndex >= 0 ? initialIndex : 0,
1683
1723
  choices: orgs.map((o) => ({ message: o.name, name: o.id })),
1684
1724
  });
1685
1725
 
@@ -1830,6 +1870,11 @@ export interface TableOptions {
1830
1870
  * - 'auto': Automatically choose based on terminal width (default)
1831
1871
  */
1832
1872
  layout?: 'horizontal' | 'vertical' | 'auto';
1873
+
1874
+ /**
1875
+ * the padding before any label
1876
+ */
1877
+ padStart?: string;
1833
1878
  }
1834
1879
 
1835
1880
  /**
@@ -1838,10 +1883,11 @@ export interface TableOptions {
1838
1883
  */
1839
1884
  function calculateTableWidth<T extends Record<string, unknown>>(
1840
1885
  data: T[],
1841
- columnNames: string[]
1886
+ columnNames: string[],
1887
+ padStart = ''
1842
1888
  ): number {
1843
1889
  const columnWidths = columnNames.map((colName) => {
1844
- let maxWidth = getDisplayWidth(colName);
1890
+ let maxWidth = getDisplayWidth(padStart + colName);
1845
1891
  for (const row of data) {
1846
1892
  const value = row[colName];
1847
1893
  const valueStr = value !== undefined && value !== null ? String(value) : '';
@@ -1866,14 +1912,17 @@ function calculateTableWidth<T extends Record<string, unknown>>(
1866
1912
  */
1867
1913
  function renderVerticalTable<T extends Record<string, unknown>>(
1868
1914
  data: T[],
1869
- columnNames: string[]
1915
+ columnNames: string[],
1916
+ padStart = ''
1870
1917
  ): string {
1871
1918
  const lines: string[] = [];
1872
1919
  const mutedColor = getColor('muted');
1873
1920
  const reset = getColor('reset');
1874
1921
 
1875
1922
  // Calculate max column name width for alignment
1876
- const maxLabelWidth = Math.max(...columnNames.map((name) => 1 + getDisplayWidth(name)));
1923
+ const maxLabelWidth = Math.max(
1924
+ ...columnNames.map((name) => 1 + getDisplayWidth(padStart + name))
1925
+ );
1877
1926
 
1878
1927
  for (let i = 0; i < data.length; i++) {
1879
1928
  const row = data[i];
@@ -1881,7 +1930,7 @@ function renderVerticalTable<T extends Record<string, unknown>>(
1881
1930
  for (const colName of columnNames) {
1882
1931
  const value = row[colName];
1883
1932
  const valueStr = value !== undefined && value !== null ? String(value) : '';
1884
- const paddedLabel = `${colName}:`.padEnd(maxLabelWidth);
1933
+ const paddedLabel = `${padStart}${colName}:`.padEnd(maxLabelWidth);
1885
1934
  lines.push(`${mutedColor}${paddedLabel}${reset} ${valueStr}`);
1886
1935
  }
1887
1936
 
@@ -1942,13 +1991,13 @@ export function table<T extends Record<string, unknown>>(
1942
1991
  // Determine layout mode
1943
1992
  const layout = options?.layout ?? 'auto';
1944
1993
  const termWidth = getTerminalWidth(80);
1945
- const tableWidth = calculateTableWidth(data, columnNames);
1994
+ const tableWidth = calculateTableWidth(data, columnNames, options?.padStart);
1946
1995
  const useVertical = layout === 'vertical' || (layout === 'auto' && tableWidth > termWidth);
1947
1996
 
1948
1997
  let output: string;
1949
1998
 
1950
1999
  if (useVertical) {
1951
- output = renderVerticalTable(data, columnNames);
2000
+ output = renderVerticalTable(data, columnNames, options?.padStart);
1952
2001
  } else {
1953
2002
  // eslint-disable-next-line @typescript-eslint/no-require-imports
1954
2003
  const Table = require('cli-table3') as new (options?: {
@@ -1,6 +1,6 @@
1
1
  import { StructuredError, type Logger } from '@agentuity/core';
2
2
  import type { Config } from '../types';
3
- import { getAppBaseURL } from '@agentuity/server';
3
+ import { getAPIBaseURL } from '@agentuity/server';
4
4
  import { getUserAgent } from '../api';
5
5
  import { getDefaultConfigDir } from '../config';
6
6
  import { join, dirname } from 'node:path';
@@ -145,8 +145,8 @@ export async function validateAptDependencies(
145
145
  packages.length - uncachedPackages.length
146
146
  );
147
147
 
148
- const appBaseUrl = getAppBaseURL(region, config?.overrides);
149
- const url = `${appBaseUrl}/api/cli/validate/apt-dependencies`;
148
+ const apiBaseUrl = getAPIBaseURL(region, config?.overrides ?? undefined);
149
+ const url = `${apiBaseUrl}/cli/validate/apt-dependencies`;
150
150
 
151
151
  const response = await fetch(url, {
152
152
  method: 'POST',