@agentuity/cli 3.0.0-alpha.6 → 3.0.0-alpha.7

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 (164) hide show
  1. package/dist/build-report.d.ts +1 -1
  2. package/dist/build-report.d.ts.map +1 -1
  3. package/dist/build-report.js +0 -1
  4. package/dist/build-report.js.map +1 -1
  5. package/dist/cmd/cloud/deploy.d.ts.map +1 -1
  6. package/dist/cmd/cloud/deploy.js +101 -46
  7. package/dist/cmd/cloud/deploy.js.map +1 -1
  8. package/dist/cmd/cloud/index.d.ts.map +1 -1
  9. package/dist/cmd/cloud/index.js +0 -4
  10. package/dist/cmd/cloud/index.js.map +1 -1
  11. package/dist/cmd/cloud/sandbox/exec.d.ts.map +1 -1
  12. package/dist/cmd/cloud/sandbox/exec.js +41 -24
  13. package/dist/cmd/cloud/sandbox/exec.js.map +1 -1
  14. package/dist/cmd/cloud/sandbox/job/logs.d.ts.map +1 -1
  15. package/dist/cmd/cloud/sandbox/job/logs.js +1 -0
  16. package/dist/cmd/cloud/sandbox/job/logs.js.map +1 -1
  17. package/dist/cmd/cloud/sandbox/run.d.ts.map +1 -1
  18. package/dist/cmd/cloud/sandbox/run.js +34 -5
  19. package/dist/cmd/cloud/sandbox/run.js.map +1 -1
  20. package/dist/cmd/cloud/sandbox/util.d.ts +9 -0
  21. package/dist/cmd/cloud/sandbox/util.d.ts.map +1 -1
  22. package/dist/cmd/cloud/sandbox/util.js +20 -1
  23. package/dist/cmd/cloud/sandbox/util.js.map +1 -1
  24. package/dist/cmd/cloud/session/get.d.ts.map +1 -1
  25. package/dist/cmd/cloud/session/get.js +1 -41
  26. package/dist/cmd/cloud/session/get.js.map +1 -1
  27. package/dist/cmd/coder/start.d.ts.map +1 -1
  28. package/dist/cmd/coder/start.js +2 -0
  29. package/dist/cmd/coder/start.js.map +1 -1
  30. package/dist/cmd/coder/tui-init.js +1 -1
  31. package/dist/cmd/coder/tui-init.js.map +1 -1
  32. package/dist/cmd/project/create.d.ts.map +1 -1
  33. package/dist/cmd/project/create.js +0 -2
  34. package/dist/cmd/project/create.js.map +1 -1
  35. package/dist/cmd/project/frameworks.d.ts.map +1 -1
  36. package/dist/cmd/project/frameworks.js +1 -0
  37. package/dist/cmd/project/frameworks.js.map +1 -1
  38. package/dist/cmd/project/index.d.ts.map +1 -1
  39. package/dist/cmd/project/index.js +0 -3
  40. package/dist/cmd/project/index.js.map +1 -1
  41. package/dist/cmd/project/template-flow.d.ts +0 -1
  42. package/dist/cmd/project/template-flow.d.ts.map +1 -1
  43. package/dist/cmd/project/template-flow.js +1 -104
  44. package/dist/cmd/project/template-flow.js.map +1 -1
  45. package/dist/index.d.ts +1 -1
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js.map +1 -1
  48. package/dist/onboarding/agentPrompt.d.ts.map +1 -1
  49. package/dist/onboarding/agentPrompt.js +5 -8
  50. package/dist/onboarding/agentPrompt.js.map +1 -1
  51. package/dist/types.d.ts +0 -167
  52. package/dist/types.d.ts.map +1 -1
  53. package/dist/types.js.map +1 -1
  54. package/package.json +6 -20
  55. package/src/build-report.ts +0 -1
  56. package/src/cmd/ai/prompt/web.md +43 -17
  57. package/src/cmd/cloud/deploy.ts +120 -56
  58. package/src/cmd/cloud/index.ts +0 -4
  59. package/src/cmd/cloud/sandbox/exec.ts +49 -23
  60. package/src/cmd/cloud/sandbox/job/logs.ts +1 -0
  61. package/src/cmd/cloud/sandbox/run.ts +47 -9
  62. package/src/cmd/cloud/sandbox/util.ts +20 -1
  63. package/src/cmd/cloud/session/get.ts +1 -51
  64. package/src/cmd/coder/start.ts +2 -0
  65. package/src/cmd/coder/tui-init.ts +1 -1
  66. package/src/cmd/project/create.ts +0 -2
  67. package/src/cmd/project/frameworks.ts +1 -0
  68. package/src/cmd/project/index.ts +0 -3
  69. package/src/cmd/project/template-flow.ts +0 -127
  70. package/src/cmd/project/templates/vite-react/vite.config.ts +8 -0
  71. package/src/index.ts +0 -4
  72. package/src/onboarding/agentPrompt.ts +5 -8
  73. package/src/runtime-bootstrap.md +2 -3
  74. package/src/types.ts +0 -186
  75. package/dist/cmd/build/app-config-extractor.d.ts +0 -27
  76. package/dist/cmd/build/app-config-extractor.d.ts.map +0 -1
  77. package/dist/cmd/build/app-config-extractor.js +0 -152
  78. package/dist/cmd/build/app-config-extractor.js.map +0 -1
  79. package/dist/cmd/cloud/eval/get.d.ts +0 -2
  80. package/dist/cmd/cloud/eval/get.d.ts.map +0 -1
  81. package/dist/cmd/cloud/eval/get.js +0 -80
  82. package/dist/cmd/cloud/eval/get.js.map +0 -1
  83. package/dist/cmd/cloud/eval/index.d.ts +0 -2
  84. package/dist/cmd/cloud/eval/index.d.ts.map +0 -1
  85. package/dist/cmd/cloud/eval/index.js +0 -16
  86. package/dist/cmd/cloud/eval/index.js.map +0 -1
  87. package/dist/cmd/cloud/eval/list.d.ts +0 -2
  88. package/dist/cmd/cloud/eval/list.d.ts.map +0 -1
  89. package/dist/cmd/cloud/eval/list.js +0 -124
  90. package/dist/cmd/cloud/eval/list.js.map +0 -1
  91. package/dist/cmd/cloud/eval-run/get.d.ts +0 -2
  92. package/dist/cmd/cloud/eval-run/get.d.ts.map +0 -1
  93. package/dist/cmd/cloud/eval-run/get.js +0 -107
  94. package/dist/cmd/cloud/eval-run/get.js.map +0 -1
  95. package/dist/cmd/cloud/eval-run/index.d.ts +0 -2
  96. package/dist/cmd/cloud/eval-run/index.d.ts.map +0 -1
  97. package/dist/cmd/cloud/eval-run/index.js +0 -16
  98. package/dist/cmd/cloud/eval-run/index.js.map +0 -1
  99. package/dist/cmd/cloud/eval-run/list.d.ts +0 -2
  100. package/dist/cmd/cloud/eval-run/list.d.ts.map +0 -1
  101. package/dist/cmd/cloud/eval-run/list.js +0 -149
  102. package/dist/cmd/cloud/eval-run/list.js.map +0 -1
  103. package/dist/cmd/project/auth/generate.d.ts +0 -5
  104. package/dist/cmd/project/auth/generate.d.ts.map +0 -1
  105. package/dist/cmd/project/auth/generate.js +0 -102
  106. package/dist/cmd/project/auth/generate.js.map +0 -1
  107. package/dist/cmd/project/auth/index.d.ts +0 -2
  108. package/dist/cmd/project/auth/index.d.ts.map +0 -1
  109. package/dist/cmd/project/auth/index.js +0 -21
  110. package/dist/cmd/project/auth/index.js.map +0 -1
  111. package/dist/cmd/project/auth/init.d.ts +0 -2
  112. package/dist/cmd/project/auth/init.d.ts.map +0 -1
  113. package/dist/cmd/project/auth/init.js +0 -213
  114. package/dist/cmd/project/auth/init.js.map +0 -1
  115. package/dist/cmd/project/auth/shared.d.ts +0 -93
  116. package/dist/cmd/project/auth/shared.d.ts.map +0 -1
  117. package/dist/cmd/project/auth/shared.js +0 -451
  118. package/dist/cmd/project/auth/shared.js.map +0 -1
  119. package/dist/utils/bun-version-checker.d.ts +0 -11
  120. package/dist/utils/bun-version-checker.d.ts.map +0 -1
  121. package/dist/utils/bun-version-checker.js +0 -56
  122. package/dist/utils/bun-version-checker.js.map +0 -1
  123. package/dist/utils/dependency-checker.d.ts +0 -20
  124. package/dist/utils/dependency-checker.d.ts.map +0 -1
  125. package/dist/utils/dependency-checker.js +0 -160
  126. package/dist/utils/dependency-checker.js.map +0 -1
  127. package/dist/utils/detectSubagent.d.ts +0 -15
  128. package/dist/utils/detectSubagent.d.ts.map +0 -1
  129. package/dist/utils/detectSubagent.js +0 -28
  130. package/dist/utils/detectSubagent.js.map +0 -1
  131. package/dist/utils/stream-capture.d.ts +0 -9
  132. package/dist/utils/stream-capture.d.ts.map +0 -1
  133. package/dist/utils/stream-capture.js +0 -34
  134. package/dist/utils/stream-capture.js.map +0 -1
  135. package/dist/utils/string.d.ts +0 -6
  136. package/dist/utils/string.d.ts.map +0 -1
  137. package/dist/utils/string.js +0 -6
  138. package/dist/utils/string.js.map +0 -1
  139. package/dist/utils/version-mismatch.d.ts +0 -39
  140. package/dist/utils/version-mismatch.d.ts.map +0 -1
  141. package/dist/utils/version-mismatch.js +0 -161
  142. package/dist/utils/version-mismatch.js.map +0 -1
  143. package/dist/utils/workbench-notify.d.ts +0 -29
  144. package/dist/utils/workbench-notify.d.ts.map +0 -1
  145. package/dist/utils/workbench-notify.js +0 -56
  146. package/dist/utils/workbench-notify.js.map +0 -1
  147. package/src/cmd/build/app-config-extractor.ts +0 -186
  148. package/src/cmd/cloud/eval/get.ts +0 -86
  149. package/src/cmd/cloud/eval/index.ts +0 -16
  150. package/src/cmd/cloud/eval/list.ts +0 -135
  151. package/src/cmd/cloud/eval-run/get.ts +0 -114
  152. package/src/cmd/cloud/eval-run/index.ts +0 -16
  153. package/src/cmd/cloud/eval-run/list.ts +0 -160
  154. package/src/cmd/project/auth/generate.ts +0 -116
  155. package/src/cmd/project/auth/index.ts +0 -21
  156. package/src/cmd/project/auth/init.ts +0 -256
  157. package/src/cmd/project/auth/shared.ts +0 -566
  158. package/src/utils/bun-version-checker.ts +0 -70
  159. package/src/utils/dependency-checker.ts +0 -205
  160. package/src/utils/detectSubagent.ts +0 -36
  161. package/src/utils/stream-capture.ts +0 -39
  162. package/src/utils/string.ts +0 -6
  163. package/src/utils/version-mismatch.ts +0 -204
  164. package/src/utils/workbench-notify.ts +0 -67
@@ -1,205 +0,0 @@
1
- import { $ } from 'bun';
2
- import { join } from 'node:path';
3
- import { readFileSync, writeFileSync } from 'node:fs';
4
- import { getVersion } from '../version';
5
- import type { Logger } from '../types';
6
-
7
- interface PackageJson {
8
- dependencies?: Record<string, string>;
9
- devDependencies?: Record<string, string>;
10
- }
11
-
12
- export interface UpgradeResult {
13
- upgraded: string[];
14
- skipped: string[];
15
- failed: string[];
16
- }
17
-
18
- /**
19
- * Checks if a version specifier should be upgraded
20
- * @param specifier - The version specifier from package.json (e.g., "latest", "^1.0.0", "1.2.3")
21
- * @returns true if the package should be upgraded
22
- */
23
- export function shouldUpgradeVersion(specifier: string): boolean {
24
- // Always upgrade "latest" and "*"
25
- if (specifier === 'latest' || specifier === '*') {
26
- return true;
27
- }
28
-
29
- // Skip pinned versions (exact semver like "1.2.3")
30
- if (/^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?$/.test(specifier)) {
31
- return false;
32
- }
33
-
34
- // Upgrade ranges (^1.0.0, ~1.0.0, >=1.0.0, etc.)
35
- // Check if the specifier is a range pattern
36
- if (/^[~^>=<]/.test(specifier)) {
37
- return true;
38
- }
39
-
40
- // Default to not upgrading if we can't determine
41
- return false;
42
- }
43
-
44
- /**
45
- * Check and upgrade @agentuity/* dependencies to match CLI version
46
- * @param projectDir - Root directory of the user's project
47
- * @param logger - Logger instance
48
- * @returns Result of the upgrade operation
49
- */
50
- export async function checkAndUpgradeDependencies(
51
- projectDir: string,
52
- logger: Logger
53
- ): Promise<UpgradeResult> {
54
- const result: UpgradeResult = {
55
- upgraded: [],
56
- skipped: [],
57
- failed: [],
58
- };
59
-
60
- const cliVersion = getVersion();
61
- logger.debug('CLI version: %s', cliVersion);
62
-
63
- // check if this is a canary and if so, skip this check
64
- if (cliVersion.includes('-')) {
65
- return result;
66
- }
67
-
68
- const packageJsonPath = join(projectDir, 'package.json');
69
- // Read package.json
70
- let packageJson: PackageJson;
71
- try {
72
- packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
73
- } catch (error) {
74
- logger.debug('Failed to read package.json: %s', error);
75
- return result;
76
- }
77
-
78
- // Collect all @agentuity/* packages and their original specifiers
79
- const allDeps = {
80
- ...packageJson.dependencies,
81
- ...packageJson.devDependencies,
82
- };
83
-
84
- const agentuitPackages = Object.entries(allDeps)
85
- .filter(([name]) => name.startsWith('@agentuity/'))
86
- .map(([name, specifier]) => ({ name, specifier }));
87
-
88
- if (agentuitPackages.length === 0) {
89
- logger.debug('No @agentuity/* packages found in package.json');
90
- return result;
91
- }
92
-
93
- // Check which packages need upgrading
94
- const packagesToUpgrade = agentuitPackages.filter(({ specifier }) =>
95
- shouldUpgradeVersion(specifier)
96
- );
97
-
98
- if (packagesToUpgrade.length === 0) {
99
- logger.debug('All @agentuity/* packages are pinned, skipping upgrade');
100
- for (const pkg of agentuitPackages) {
101
- result.skipped.push(pkg.name);
102
- }
103
- return result;
104
- }
105
-
106
- // Check if CLI version is different from installed packages
107
- let needsUpgrade = false;
108
- for (const { name } of packagesToUpgrade) {
109
- try {
110
- const installedPackageJson = JSON.parse(
111
- readFileSync(join(projectDir, 'node_modules', name, 'package.json'), 'utf-8')
112
- );
113
- const installedVersion: string = installedPackageJson.version;
114
- if (installedVersion !== cliVersion) {
115
- logger.debug(
116
- '%s: installed=%s, cli=%s (needs upgrade)',
117
- name,
118
- installedVersion,
119
- cliVersion
120
- );
121
- needsUpgrade = true;
122
- } else {
123
- logger.debug('%s: already at correct version %s', name, installedVersion);
124
- }
125
- } catch {
126
- // Package not installed or can't read version - needs upgrade
127
- logger.debug('%s: not installed or unreadable, needs upgrade', name);
128
- needsUpgrade = true;
129
- }
130
- }
131
-
132
- if (!needsUpgrade) {
133
- logger.debug('All @agentuity/* packages are already at CLI version');
134
- for (const pkg of packagesToUpgrade) {
135
- result.skipped.push(pkg.name);
136
- }
137
- return result;
138
- }
139
-
140
- // Upgrade packages
141
- logger.debug('Upgrading %d @agentuity/* package(s) to %s', packagesToUpgrade.length, cliVersion);
142
-
143
- for (const { name } of packagesToUpgrade) {
144
- try {
145
- logger.debug('Installing %s@%s', name, cliVersion);
146
- const installResult = await $`bun add ${name}@${cliVersion}`
147
- .cwd(projectDir)
148
- .quiet()
149
- .nothrow();
150
-
151
- if (installResult.exitCode !== 0) {
152
- logger.error(
153
- 'Failed to install %s@%s: %s',
154
- name,
155
- cliVersion,
156
- installResult.stderr.toString()
157
- );
158
- result.failed.push(name);
159
- } else {
160
- logger.debug('Successfully installed %s@%s', name, cliVersion);
161
- result.upgraded.push(name);
162
- }
163
- } catch (_error) {
164
- logger.error('Error installing %s: %s', name, _error);
165
- result.failed.push(name);
166
- }
167
- }
168
-
169
- // Restore original version specifiers in package.json
170
- // (bun add replaces them with specific versions)
171
- if (result.upgraded.length > 0) {
172
- try {
173
- const updatedPackageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
174
- let modified = false;
175
-
176
- for (const { name, specifier } of packagesToUpgrade) {
177
- // Only restore if we successfully upgraded
178
- if (!result.upgraded.includes(name)) {
179
- continue;
180
- }
181
-
182
- // Check both dependencies and devDependencies
183
- if (updatedPackageJson.dependencies?.[name]) {
184
- updatedPackageJson.dependencies[name] = specifier;
185
- modified = true;
186
- logger.debug('Restored %s to "%s" in dependencies', name, specifier);
187
- }
188
- if (updatedPackageJson.devDependencies?.[name]) {
189
- updatedPackageJson.devDependencies[name] = specifier;
190
- modified = true;
191
- logger.debug('Restored %s to "%s" in devDependencies', name, specifier);
192
- }
193
- }
194
-
195
- if (modified) {
196
- writeFileSync(packageJsonPath, JSON.stringify(updatedPackageJson, null, 2) + '\n');
197
- logger.debug('Restored original version specifiers in package.json');
198
- }
199
- } catch (_error) {
200
- logger.warn('Failed to restore version specifiers in package.json: %s', _error);
201
- }
202
- }
203
-
204
- return result;
205
- }
@@ -1,36 +0,0 @@
1
- import { toForwardSlash } from './normalize-path';
2
-
3
- /**
4
- * Detects if a file path represents a subagent based on path structure.
5
- *
6
- * Subagents follow the pattern: agent/parent/child/agent.ts or agent/parent/child/route.ts
7
- * The path structure is currently hardcoded to 4 segments but could be made configurable later.
8
- *
9
- * @param filePath - The file path to analyze (can include leading './')
10
- * @param srcDir - Optional source directory to strip from the path
11
- * @returns Object with isSubagent flag and parentName if detected
12
- */
13
- export function detectSubagent(
14
- filePath: string,
15
- srcDir?: string
16
- ): { isSubagent: boolean; parentName: string | null } {
17
- let normalizedPath = filePath;
18
-
19
- // Strip srcDir if provided
20
- if (srcDir && normalizedPath.startsWith(srcDir)) {
21
- normalizedPath = normalizedPath.replace(srcDir, '');
22
- }
23
-
24
- // Normalize path separators for cross-platform compatibility
25
- normalizedPath = toForwardSlash(normalizedPath);
26
-
27
- // Strip leading './' and split into parts, filtering out empty segments
28
- const pathParts = normalizedPath.replace(/^\.\//, '').split('/').filter(Boolean);
29
-
30
- // Path structure assumption: ['agent', 'parent', 'child', 'agent.ts' | 'route.ts' | 'route']
31
- // Currently hardcoded to 4 segments - consider making configurable in the future
32
- const isSubagent = pathParts.length === 4 && pathParts[0] === 'agent';
33
- const parentName = isSubagent ? (pathParts[1] ?? null) : null;
34
-
35
- return { isSubagent, parentName };
36
- }
@@ -1,39 +0,0 @@
1
- import { createWriteStream } from 'node:fs';
2
-
3
- /**
4
- * Stream a ReadableStream of raw bytes to a file on disk.
5
- *
6
- * This mirrors the pattern used by the deploy fork wrapper to capture child
7
- * process stdout/stderr without accumulating the output in memory. Returns
8
- * the total number of bytes written.
9
- */
10
- export async function captureStreamToFile(
11
- stream: ReadableStream<Uint8Array>,
12
- filePath: string
13
- ): Promise<number> {
14
- const writer = createWriteStream(filePath);
15
- const reader = stream.getReader();
16
- let totalBytes = 0;
17
-
18
- try {
19
- while (true) {
20
- const { done, value } = await reader.read();
21
- if (done) break;
22
-
23
- const ok = writer.write(value);
24
- totalBytes += value.byteLength;
25
-
26
- // Respect backpressure: wait for drain when the internal buffer is full
27
- if (!ok) {
28
- await new Promise<void>((resolve) => writer.once('drain', resolve));
29
- }
30
- }
31
- } finally {
32
- await new Promise<void>((resolve, reject) => {
33
- writer.once('error', reject);
34
- writer.end(resolve);
35
- });
36
- }
37
-
38
- return totalBytes;
39
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * String utility functions for identifier conversion
3
- * Re-exported from @agentuity/core for convenience
4
- */
5
-
6
- export { toCamelCase, toPascalCase } from '@agentuity/core';
@@ -1,204 +0,0 @@
1
- /**
2
- * Version mismatch detection for @agentuity/* packages.
3
- *
4
- * Detects when a project uses outdated v1 SDK packages while the CLI is v2,
5
- * and recommends running the migration tool.
6
- */
7
-
8
- import { existsSync, readFileSync } from 'node:fs';
9
- import { join } from 'node:path';
10
- import { getVersion } from '../version';
11
- import type { Logger } from '../types';
12
-
13
- export interface VersionInfo {
14
- name: string;
15
- version: string;
16
- major: number;
17
- }
18
-
19
- export interface VersionMismatchResult {
20
- /** CLI major version */
21
- cliMajor: number;
22
- /** All @agentuity/* packages found */
23
- packages: VersionInfo[];
24
- /** Packages with major version mismatch */
25
- mismatched: VersionInfo[];
26
- /** Packages that are v1 when CLI is v2+ */
27
- outdated: VersionInfo[];
28
- /** Whether any v1 packages were found */
29
- hasV1Packages: boolean;
30
- /** Whether there are major version mismatches across packages */
31
- hasMajorMismatches: boolean;
32
- }
33
-
34
- /**
35
- * Extract major version from semver string
36
- */
37
- function extractMajor(version: string): number {
38
- // Handle ranges like ^1.0.0, ~2.0.0, >=1.0.0
39
- const match = version.match(/(\d+)\.\d+\.\d+/);
40
- if (match?.[1]) {
41
- return parseInt(match[1], 10);
42
- }
43
- // Handle "latest" or "*"
44
- if (version === 'latest' || version === '*') {
45
- return 0; // Unknown major
46
- }
47
- return 0;
48
- }
49
-
50
- /**
51
- * Get installed version from node_modules
52
- */
53
- function getInstalledVersion(projectDir: string, packageName: string): string | null {
54
- try {
55
- const pkgPath = join(projectDir, 'node_modules', packageName, 'package.json');
56
- if (!existsSync(pkgPath)) {
57
- return null;
58
- }
59
- const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
60
- return pkg.version || null;
61
- } catch {
62
- return null;
63
- }
64
- }
65
-
66
- /**
67
- * Detect version mismatches in @agentuity/* packages.
68
- *
69
- * @param projectDir - Root directory of the user's project
70
- * @param logger - Logger instance
71
- * @returns Version mismatch detection result
72
- */
73
- export function detectVersionMismatch(projectDir: string, logger: Logger): VersionMismatchResult {
74
- const cliVersion = getVersion();
75
- const cliMajor = extractMajor(cliVersion);
76
-
77
- const result: VersionMismatchResult = {
78
- cliMajor,
79
- packages: [],
80
- mismatched: [],
81
- outdated: [],
82
- hasV1Packages: false,
83
- hasMajorMismatches: false,
84
- };
85
-
86
- // Skip check for canary versions
87
- if (cliVersion.includes('-')) {
88
- logger.debug('Skipping version mismatch check for canary version: %s', cliVersion);
89
- return result;
90
- }
91
-
92
- // Read package.json
93
- const packageJsonPath = join(projectDir, 'package.json');
94
- if (!existsSync(packageJsonPath)) {
95
- logger.debug('No package.json found, skipping version mismatch check');
96
- return result;
97
- }
98
-
99
- let packageJson: {
100
- dependencies?: Record<string, string>;
101
- devDependencies?: Record<string, string>;
102
- };
103
- try {
104
- packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
105
- } catch (error) {
106
- logger.debug('Failed to read package.json: %s', error);
107
- return result;
108
- }
109
-
110
- // Collect all @agentuity/* packages
111
- const allDeps = {
112
- ...packageJson.dependencies,
113
- ...packageJson.devDependencies,
114
- };
115
-
116
- const agentuitPackages = Object.entries(allDeps)
117
- .filter(([name]) => name.startsWith('@agentuity/'))
118
- .map(([name, specifier]) => ({ name, specifier }));
119
-
120
- if (agentuitPackages.length === 0) {
121
- logger.debug('No @agentuity/* packages found in package.json');
122
- return result;
123
- }
124
-
125
- // Check each package's installed version
126
- for (const { name } of agentuitPackages) {
127
- const installedVersion = getInstalledVersion(projectDir, name);
128
- if (!installedVersion) {
129
- logger.debug('%s: not installed, skipping', name);
130
- continue;
131
- }
132
-
133
- const major = extractMajor(installedVersion);
134
- const info: VersionInfo = {
135
- name,
136
- version: installedVersion,
137
- major,
138
- };
139
-
140
- result.packages.push(info);
141
-
142
- // Check if this is a v1 package when CLI is v2+
143
- if (major === 1 && cliMajor >= 2) {
144
- result.outdated.push(info);
145
- result.hasV1Packages = true;
146
- }
147
- }
148
-
149
- // Check for major version mismatches across installed packages
150
- if (result.packages.length > 1) {
151
- const majors = new Set(result.packages.map((p) => p.major));
152
- if (majors.size > 1) {
153
- result.hasMajorMismatches = true;
154
- // Find packages that don't match the most common major version
155
- const majorCounts = new Map<number, number>();
156
- for (const pkg of result.packages) {
157
- majorCounts.set(pkg.major, (majorCounts.get(pkg.major) || 0) + 1);
158
- }
159
- const mostCommonMajor =
160
- [...majorCounts.entries()].sort((a, b) => b[1] - a[1])[0]?.[0] || cliMajor;
161
-
162
- for (const pkg of result.packages) {
163
- if (pkg.major !== mostCommonMajor) {
164
- result.mismatched.push(pkg);
165
- }
166
- }
167
- }
168
- }
169
-
170
- return result;
171
- }
172
-
173
- /**
174
- * Format a warning message for version mismatches.
175
- */
176
- export function formatVersionMismatchWarning(result: VersionMismatchResult): string {
177
- const lines: string[] = [];
178
-
179
- if (result.hasV1Packages) {
180
- lines.push('You are using Agentuity SDK v1 packages, but v2 is now available.');
181
- lines.push('');
182
- lines.push(' Outdated packages:');
183
- for (const pkg of result.outdated) {
184
- lines.push(` • ${pkg.name}@${pkg.version}`);
185
- }
186
- lines.push('');
187
- lines.push(' → Run `npx @agentuity/migrate` to upgrade your project to v2.');
188
- lines.push(' This will automatically update your code and dependencies.');
189
- lines.push('');
190
- lines.push(' See the migration guide: https://docs.agentuity.com/migration/v1-to-v2');
191
- } else if (result.hasMajorMismatches) {
192
- lines.push('Your project has mismatched major versions across @agentuity/* packages.');
193
- lines.push('');
194
- lines.push(' Packages:');
195
- for (const pkg of result.packages) {
196
- const marker = result.mismatched.includes(pkg) ? ' ⚠️' : '';
197
- lines.push(` • ${pkg.name}@${pkg.version} (v${pkg.major})${marker}`);
198
- }
199
- lines.push('');
200
- lines.push(' → Run `bun install` to sync versions, or pin to the same major version.');
201
- }
202
-
203
- return lines.join('\n');
204
- }
@@ -1,67 +0,0 @@
1
- /**
2
- * Utility to send notifications directly to workbench clients via WebSocket
3
- */
4
-
5
- export interface WorkbenchNotifyOptions {
6
- port?: number;
7
- message: 'restarting' | 'alive';
8
- }
9
-
10
- /**
11
- * Send a notification directly to workbench clients via WebSocket
12
- *
13
- * @param options - Configuration for the notification
14
- * @returns Promise that resolves when notification is sent
15
- *
16
- * @example
17
- * ```typescript
18
- * // Notify clients that server is restarting
19
- * await notifyWorkbenchClients({
20
- * baseUrl: 'ws://localhost:3500',
21
- * message: 'restarting'
22
- * });
23
- *
24
- * // Notify clients that server is alive
25
- * await notifyWorkbenchClients({
26
- * message: 'alive'
27
- * });
28
- * ```
29
- */
30
- export async function notifyWorkbenchClients(options: WorkbenchNotifyOptions): Promise<void> {
31
- const { port = 3500, message } = options;
32
-
33
- const wsUrl = new URL(`ws://localhost:${port}`);
34
-
35
- return new Promise((resolve) => {
36
- try {
37
- wsUrl.pathname = '/_agentuity/workbench/ws';
38
-
39
- const ws = new WebSocket(wsUrl.toString());
40
-
41
- // Set a timeout to avoid hanging
42
- const timeout = setTimeout(() => {
43
- ws.close();
44
- resolve();
45
- }, 2000);
46
-
47
- ws.onopen = () => {
48
- ws.send(message);
49
- ws.close();
50
- };
51
-
52
- ws.onclose = () => {
53
- clearTimeout(timeout);
54
- resolve();
55
- };
56
-
57
- ws.onerror = () => {
58
- clearTimeout(timeout);
59
- ws.close();
60
- resolve();
61
- };
62
- } catch (_error) {
63
- // Silently fail - this ensures the CLI doesn't fail if the app server isn't running
64
- resolve();
65
- }
66
- });
67
- }