@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.
- package/dist/cmd/build/entry-generator.d.ts.map +1 -1
- package/dist/cmd/build/entry-generator.js +43 -50
- package/dist/cmd/build/entry-generator.js.map +1 -1
- package/dist/cmd/build/index.d.ts.map +1 -1
- package/dist/cmd/build/index.js +9 -9
- package/dist/cmd/build/index.js.map +1 -1
- package/dist/cmd/build/typecheck.d.ts +23 -0
- package/dist/cmd/build/typecheck.d.ts.map +1 -0
- package/dist/cmd/build/typecheck.js +38 -0
- package/dist/cmd/build/typecheck.js.map +1 -0
- package/dist/cmd/build/vite/vite-asset-server-config.d.ts.map +1 -1
- package/dist/cmd/build/vite/vite-asset-server-config.js +15 -8
- package/dist/cmd/build/vite/vite-asset-server-config.js.map +1 -1
- package/dist/cmd/build/vite/vite-asset-server.d.ts.map +1 -1
- package/dist/cmd/build/vite/vite-asset-server.js +6 -2
- package/dist/cmd/build/vite/vite-asset-server.js.map +1 -1
- package/dist/cmd/build/vite/vite-builder.d.ts.map +1 -1
- package/dist/cmd/build/vite/vite-builder.js +14 -2
- package/dist/cmd/build/vite/vite-builder.js.map +1 -1
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.js +67 -6
- package/dist/cmd/cloud/deploy.js.map +1 -1
- package/dist/cmd/dev/index.d.ts.map +1 -1
- package/dist/cmd/dev/index.js +623 -578
- package/dist/cmd/dev/index.js.map +1 -1
- package/dist/schema-parser.d.ts.map +1 -1
- package/dist/schema-parser.js +17 -3
- package/dist/schema-parser.js.map +1 -1
- package/dist/tsc-output-parser.d.ts +54 -0
- package/dist/tsc-output-parser.d.ts.map +1 -0
- package/dist/tsc-output-parser.js +926 -0
- package/dist/tsc-output-parser.js.map +1 -0
- package/dist/tui.d.ts +77 -0
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +27 -2
- package/dist/tui.js.map +1 -1
- package/dist/typescript-errors.d.ts +26 -0
- package/dist/typescript-errors.d.ts.map +1 -0
- package/dist/typescript-errors.js +249 -0
- package/dist/typescript-errors.js.map +1 -0
- package/package.json +4 -4
- package/src/cmd/build/entry-generator.ts +43 -51
- package/src/cmd/build/index.ts +13 -10
- package/src/cmd/build/typecheck.ts +55 -0
- package/src/cmd/build/vite/vite-asset-server-config.ts +17 -8
- package/src/cmd/build/vite/vite-asset-server.ts +6 -2
- package/src/cmd/build/vite/vite-builder.ts +13 -2
- package/src/cmd/cloud/deploy.ts +80 -8
- package/src/cmd/dev/index.ts +713 -657
- package/src/schema-parser.ts +17 -3
- package/src/tsc-output-parser.ts +1115 -0
- package/src/tui.ts +40 -2
- package/src/typescript-errors.ts +382 -0
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rust-style TypeScript error formatting
|
|
3
|
+
*
|
|
4
|
+
* Formats TypeScript compiler errors in a style similar to Rust's compiler output,
|
|
5
|
+
* with source code context, error highlighting, and helpful formatting.
|
|
6
|
+
*/
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { colorError, colorPrimary, colorInfo, colorMuted, bold, link, getDisplayWidth, getColor, plural, sourceLink, truncateToWidth, } from './tui';
|
|
9
|
+
import { symbols } from './tui/symbols';
|
|
10
|
+
/**
|
|
11
|
+
* Check if a GrammarItem is a TypeScript error (not a warning or other diagnostic)
|
|
12
|
+
*/
|
|
13
|
+
function isTsErrorItem(item) {
|
|
14
|
+
return item.type === 'Item' && item.value?.tsError?.value?.type === 'error';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Parse GrammarItem array into structured TypeScript errors
|
|
18
|
+
*/
|
|
19
|
+
function parseErrors(items) {
|
|
20
|
+
const errors = [];
|
|
21
|
+
for (const item of items) {
|
|
22
|
+
if (!isTsErrorItem(item) || !item.value)
|
|
23
|
+
continue;
|
|
24
|
+
const val = item.value;
|
|
25
|
+
errors.push({
|
|
26
|
+
path: val.path?.value ?? 'unknown',
|
|
27
|
+
line: val.cursor?.value?.line ?? 0,
|
|
28
|
+
col: val.cursor?.value?.col ?? 0,
|
|
29
|
+
errorCode: val.tsError?.value?.errorString ?? 'TS0000',
|
|
30
|
+
message: (val.message?.value ?? '').trim(),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return errors;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Read source lines with context (line before, current, line after)
|
|
37
|
+
*/
|
|
38
|
+
async function getSourceContext(filePath, lineNumber) {
|
|
39
|
+
try {
|
|
40
|
+
const file = Bun.file(filePath);
|
|
41
|
+
if (!(await file.exists())) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const content = await file.text();
|
|
45
|
+
const lines = content.split('\n');
|
|
46
|
+
if (lineNumber <= 0 || lineNumber > lines.length) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const current = lines[lineNumber - 1];
|
|
50
|
+
const before = lineNumber > 1 ? lines[lineNumber - 2] : null;
|
|
51
|
+
const after = lineNumber < lines.length ? lines[lineNumber] : null;
|
|
52
|
+
return {
|
|
53
|
+
before: before !== null && before.trim() !== '' ? before : null,
|
|
54
|
+
beforeLineNum: lineNumber - 1,
|
|
55
|
+
current,
|
|
56
|
+
after: after !== null && after.trim() !== '' ? after : null,
|
|
57
|
+
afterLineNum: lineNumber + 1,
|
|
58
|
+
total: lines.length,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Prepare error data without rendering (first pass)
|
|
67
|
+
*/
|
|
68
|
+
async function prepareError(error, projectDir, maxAvailableWidth) {
|
|
69
|
+
const fullPath = error.path.startsWith('/') ? error.path : `${projectDir}/${error.path}`;
|
|
70
|
+
// Error header
|
|
71
|
+
const url = link(`https://typescript.tv/errors/#${error.errorCode}`, `error[${error.errorCode}]`, getColor('error'));
|
|
72
|
+
const header = ' ' + url + colorMuted(': ') + bold(error.message);
|
|
73
|
+
// File location
|
|
74
|
+
const vscodelink = sourceLink(join(projectDir, error.path), error.line, error.col, `${error.path}:${error.line}:${error.col}`, getColor('info'));
|
|
75
|
+
const location = colorInfo(` ${vscodelink}`);
|
|
76
|
+
const codeLines = [];
|
|
77
|
+
// Get source code context
|
|
78
|
+
const context = await getSourceContext(fullPath, error.line);
|
|
79
|
+
if (context !== null) {
|
|
80
|
+
const maxLineNum = Math.max(context.before !== null ? context.beforeLineNum : error.line, error.line, context.after !== null ? context.afterLineNum : error.line);
|
|
81
|
+
const lineNumWidth = String(maxLineNum).length;
|
|
82
|
+
const formatLineNum = (num) => String(num).padStart(lineNumWidth);
|
|
83
|
+
const padding = ' '.repeat(lineNumWidth);
|
|
84
|
+
const linePrefix = lineNumWidth + 3;
|
|
85
|
+
const truncateCodeLine = (lineNum, separator, code) => {
|
|
86
|
+
const prefixWidth = getDisplayWidth(lineNum) + getDisplayWidth(separator) + 1;
|
|
87
|
+
const availableForCode = maxAvailableWidth - prefixWidth;
|
|
88
|
+
if (availableForCode > 10 && getDisplayWidth(code) > availableForCode) {
|
|
89
|
+
return `${lineNum}${separator} ${truncateToWidth(code, availableForCode, '…')}`;
|
|
90
|
+
}
|
|
91
|
+
return `${lineNum}${separator} ${code}`;
|
|
92
|
+
};
|
|
93
|
+
if (context.beforeLineNum > 1) {
|
|
94
|
+
const dots = '.'.repeat(String(context.beforeLineNum).length);
|
|
95
|
+
const content = colorMuted(`${dots} ${symbols.bar}`);
|
|
96
|
+
codeLines.push({ content, rawWidth: getDisplayWidth(content) });
|
|
97
|
+
}
|
|
98
|
+
// Context line before (muted)
|
|
99
|
+
if (context.before !== null) {
|
|
100
|
+
const lineContent = truncateCodeLine(formatLineNum(context.beforeLineNum), ` ${symbols.bar}`, context.before);
|
|
101
|
+
const content = colorMuted(lineContent);
|
|
102
|
+
codeLines.push({ content, rawWidth: getDisplayWidth(content) });
|
|
103
|
+
}
|
|
104
|
+
// Error line (primary color)
|
|
105
|
+
const truncatedCurrent = getDisplayWidth(context.current) > maxAvailableWidth - linePrefix
|
|
106
|
+
? truncateToWidth(context.current, maxAvailableWidth - linePrefix, '…')
|
|
107
|
+
: context.current;
|
|
108
|
+
const errorLineContent = `${colorInfo(formatLineNum(error.line))} ${colorMuted(symbols.bar)} ${colorPrimary(truncatedCurrent)}`;
|
|
109
|
+
codeLines.push({ content: errorLineContent, rawWidth: getDisplayWidth(errorLineContent) });
|
|
110
|
+
// Error pointer line with carets
|
|
111
|
+
const col = Math.max(0, error.col - 1);
|
|
112
|
+
let underlineLength = 1;
|
|
113
|
+
const restOfLine = context.current.slice(col);
|
|
114
|
+
const identifierMatch = restOfLine.match(/^[a-zA-Z_$][a-zA-Z0-9_$]*/);
|
|
115
|
+
if (identifierMatch) {
|
|
116
|
+
underlineLength = identifierMatch[0].length;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
const tokenMatch = restOfLine.match(/^\S+/);
|
|
120
|
+
if (tokenMatch) {
|
|
121
|
+
underlineLength = Math.min(tokenMatch[0].length, 20);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const maxCaretWidth = maxAvailableWidth - linePrefix;
|
|
125
|
+
const caretStart = Math.min(col, maxCaretWidth - 1);
|
|
126
|
+
const caretLen = Math.min(underlineLength, maxCaretWidth - caretStart);
|
|
127
|
+
const carets = caretLen > 0 ? '^'.repeat(caretLen) : '^';
|
|
128
|
+
const caretPadding = ' '.repeat(caretStart);
|
|
129
|
+
const caretLine = `${padding} ${colorMuted(symbols.bar)} ${caretPadding}${colorError(carets)}`;
|
|
130
|
+
codeLines.push({ content: caretLine, rawWidth: getDisplayWidth(caretLine) });
|
|
131
|
+
// Context line after (muted)
|
|
132
|
+
if (context.after !== null) {
|
|
133
|
+
const lineContent = truncateCodeLine(formatLineNum(context.afterLineNum), ` ${symbols.bar}`, context.after);
|
|
134
|
+
const content = colorMuted(lineContent);
|
|
135
|
+
codeLines.push({ content, rawWidth: getDisplayWidth(content) });
|
|
136
|
+
}
|
|
137
|
+
if (context.afterLineNum + 1 < context.total) {
|
|
138
|
+
const dots = '.'.repeat(String(context.afterLineNum).length);
|
|
139
|
+
const content = colorMuted(`${dots} ${symbols.bar}`);
|
|
140
|
+
codeLines.push({ content, rawWidth: getDisplayWidth(content) });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const maxContentWidth = codeLines.length > 0 ? Math.max(...codeLines.map((l) => l.rawWidth)) : 0;
|
|
144
|
+
return {
|
|
145
|
+
error,
|
|
146
|
+
header,
|
|
147
|
+
location,
|
|
148
|
+
codeLines,
|
|
149
|
+
maxContentWidth,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Render a prepared error with a specific box width
|
|
154
|
+
*/
|
|
155
|
+
function renderError(prepared, boxContentWidth) {
|
|
156
|
+
const lines = [];
|
|
157
|
+
lines.push(prepared.header);
|
|
158
|
+
lines.push(prepared.location);
|
|
159
|
+
if (prepared.codeLines.length > 0) {
|
|
160
|
+
const boxWidth = boxContentWidth + 2;
|
|
161
|
+
// Draw box
|
|
162
|
+
lines.push(colorMuted(` ${symbols.cornerTL}${symbols.barH.repeat(boxWidth)}${symbols.cornerTR}`));
|
|
163
|
+
for (const codeLine of prepared.codeLines) {
|
|
164
|
+
const rightPad = ' '.repeat(Math.max(0, boxContentWidth - codeLine.rawWidth));
|
|
165
|
+
lines.push(colorMuted(` ${symbols.bar}`) +
|
|
166
|
+
` ${codeLine.content}${rightPad} ` +
|
|
167
|
+
colorMuted(symbols.bar));
|
|
168
|
+
}
|
|
169
|
+
lines.push(colorMuted(` ${symbols.cornerBL}${symbols.barH.repeat(boxWidth)}${symbols.cornerBR}`));
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
lines.push(colorMuted(' (source not available)'));
|
|
173
|
+
}
|
|
174
|
+
return lines.join('\n') + '\n';
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Group errors by file for better organization
|
|
178
|
+
*/
|
|
179
|
+
function groupErrorsByFile(errors) {
|
|
180
|
+
const grouped = new Map();
|
|
181
|
+
for (const error of errors) {
|
|
182
|
+
const existing = grouped.get(error.path) ?? [];
|
|
183
|
+
existing.push(error);
|
|
184
|
+
grouped.set(error.path, existing);
|
|
185
|
+
}
|
|
186
|
+
for (const errors of grouped.values()) {
|
|
187
|
+
errors.sort((a, b) => a.line - b.line || a.col - b.col);
|
|
188
|
+
}
|
|
189
|
+
return grouped;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Format TypeScript errors in Rust-style output
|
|
193
|
+
*/
|
|
194
|
+
export async function formatTypeScriptErrors(items, options) {
|
|
195
|
+
const errors = parseErrors(items);
|
|
196
|
+
if (errors.length === 0) {
|
|
197
|
+
return '';
|
|
198
|
+
}
|
|
199
|
+
// Calculate terminal constraints
|
|
200
|
+
const terminalWidth = process.stdout.columns || 80;
|
|
201
|
+
const boxChrome = 6;
|
|
202
|
+
const maxAvailableWidth = terminalWidth - boxChrome;
|
|
203
|
+
// First pass: prepare all errors and collect their widths
|
|
204
|
+
const groupedErrors = groupErrorsByFile(errors);
|
|
205
|
+
const maxErrors = options.maxErrors ?? errors.length;
|
|
206
|
+
const preparedErrors = [];
|
|
207
|
+
let displayedCount = 0;
|
|
208
|
+
for (const [, fileErrors] of groupedErrors) {
|
|
209
|
+
for (const error of fileErrors) {
|
|
210
|
+
if (displayedCount >= maxErrors)
|
|
211
|
+
break;
|
|
212
|
+
const prepared = await prepareError(error, options.projectDir, maxAvailableWidth);
|
|
213
|
+
preparedErrors.push(prepared);
|
|
214
|
+
displayedCount++;
|
|
215
|
+
}
|
|
216
|
+
if (displayedCount >= maxErrors)
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
// Calculate uniform box width (max content width across all errors, capped at terminal width)
|
|
220
|
+
const globalMaxContentWidth = Math.max(...preparedErrors.map((p) => p.maxContentWidth));
|
|
221
|
+
const uniformBoxContentWidth = Math.min(globalMaxContentWidth, maxAvailableWidth);
|
|
222
|
+
// Second pass: render all errors with uniform width
|
|
223
|
+
const output = [];
|
|
224
|
+
for (const prepared of preparedErrors) {
|
|
225
|
+
output.push(renderError(prepared, uniformBoxContentWidth));
|
|
226
|
+
}
|
|
227
|
+
// Summary line
|
|
228
|
+
const totalErrors = errors.length;
|
|
229
|
+
const hiddenCount = totalErrors - displayedCount;
|
|
230
|
+
let msg = bold(colorPrimary(`aborting due to ${totalErrors} TypeScript compiler ${plural(totalErrors, 'error', 'errors')}`));
|
|
231
|
+
if (hiddenCount > 0) {
|
|
232
|
+
msg += colorMuted(` (${hiddenCount} not shown)`);
|
|
233
|
+
}
|
|
234
|
+
output.push(`${bold(colorError('error'))}: ${msg}`);
|
|
235
|
+
return output.join('\n');
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Check if the parsed result contains any errors
|
|
239
|
+
*/
|
|
240
|
+
export function hasErrors(items) {
|
|
241
|
+
return items.some(isTsErrorItem);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Get the count of errors
|
|
245
|
+
*/
|
|
246
|
+
export function getErrorCount(items) {
|
|
247
|
+
return items.filter(isTsErrorItem).length;
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=typescript-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript-errors.js","sourceRoot":"","sources":["../src/typescript-errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACN,UAAU,EACV,YAAY,EACZ,SAAS,EACT,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,eAAe,EACf,QAAQ,EACR,MAAM,EACN,UAAU,EACV,eAAe,GACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAuBxC;;GAE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
|
+
"version": "0.0.108",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "Agentuity employees and contributors",
|
|
6
6
|
"type": "module",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"prepublishOnly": "bun run clean && bun run build"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@agentuity/core": "0.0.
|
|
44
|
-
"@agentuity/server": "0.0.
|
|
43
|
+
"@agentuity/core": "0.0.108",
|
|
44
|
+
"@agentuity/server": "0.0.108",
|
|
45
45
|
"@datasert/cronjs-parser": "^1.4.0",
|
|
46
46
|
"@terascope/fetch-github-release": "^2.2.1",
|
|
47
47
|
"@vitejs/plugin-react": "^5.1.2",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"zod": "^4.1.12"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@agentuity/test-utils": "0.0.
|
|
64
|
+
"@agentuity/test-utils": "0.0.108",
|
|
65
65
|
"@types/adm-zip": "^0.5.7",
|
|
66
66
|
"@types/bun": "latest",
|
|
67
67
|
"@types/tar-fs": "^2.0.4",
|
|
@@ -67,25 +67,22 @@ export async function generateEntryFile(options: GenerateEntryOptions): Promise<
|
|
|
67
67
|
` setGlobalRouter,`,
|
|
68
68
|
` enableProcessExitProtection,`,
|
|
69
69
|
` hasWaitUntilPending,`,
|
|
70
|
+
` loadBuildMetadata,`,
|
|
71
|
+
` createWorkbenchRouter,`,
|
|
72
|
+
` bootstrapRuntimeEnv,`,
|
|
73
|
+
` patchBunS3ForStorageDev,`,
|
|
70
74
|
];
|
|
71
75
|
|
|
72
|
-
if (hasWorkbench) {
|
|
73
|
-
runtimeImports.push(` createWorkbenchRouter,`);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
76
|
const imports = [
|
|
77
77
|
`import { `,
|
|
78
78
|
...runtimeImports,
|
|
79
79
|
`} from '@agentuity/runtime';`,
|
|
80
80
|
`import type { Context } from 'hono';`,
|
|
81
|
-
`import { websocket } from 'hono/bun';`,
|
|
82
|
-
|
|
83
|
-
hasWebFrontend || hasWorkbench ? `import { serveStatic } from 'hono/bun';` : '',
|
|
84
|
-
hasWebFrontend || hasWorkbench ? `import { readFileSync, existsSync } from 'node:fs';` : '',
|
|
81
|
+
`import { websocket${hasWebFrontend ? ', serveStatic' : ''} } from 'hono/bun';`,
|
|
82
|
+
hasWebFrontend ? `import { readFileSync, existsSync } from 'node:fs';` : '',
|
|
85
83
|
].filter(Boolean);
|
|
86
84
|
|
|
87
85
|
imports.push(`import { type LogLevel } from '@agentuity/core';`);
|
|
88
|
-
imports.push(`import { bootstrapRuntimeEnv, patchBunS3ForStorageDev } from '@agentuity/runtime';`);
|
|
89
86
|
|
|
90
87
|
// Generate route mounting code for all discovered routes
|
|
91
88
|
const routeImportsAndMounts: string[] = [];
|
|
@@ -124,13 +121,14 @@ ${routeImportsAndMounts.join('\n')}
|
|
|
124
121
|
: '';
|
|
125
122
|
|
|
126
123
|
// Workbench API routes mounting (if enabled)
|
|
127
|
-
const workbenchApiMount =
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
124
|
+
const workbenchApiMount = `
|
|
125
|
+
const hasWorkbench = ${hasWorkbench};
|
|
126
|
+
if (hasWorkbench) {
|
|
127
|
+
// Mount workbench API routes (/_agentuity/workbench/*)
|
|
128
|
+
const workbenchRouter = createWorkbenchRouter();
|
|
129
|
+
app.route('/', workbenchRouter);
|
|
130
|
+
}
|
|
131
|
+
`;
|
|
134
132
|
|
|
135
133
|
// Asset proxy routes - Always generated, but only active at runtime when:
|
|
136
134
|
// - NODE_ENV !== 'production' (isDevelopment())
|
|
@@ -142,20 +140,16 @@ if (isDevelopment() && process.env.VITE_PORT) {
|
|
|
142
140
|
|
|
143
141
|
const proxyToVite = async (c: Context) => {
|
|
144
142
|
const viteUrl = \`http://127.0.0.1:\${VITE_ASSET_PORT}\${c.req.path}\`;
|
|
145
|
-
const controller = new AbortController();
|
|
146
|
-
const timeout = setTimeout(() => controller.abort(), 10000); // 10s timeout
|
|
147
143
|
try {
|
|
148
144
|
otel.logger.debug(\`[Proxy] \${c.req.method} \${c.req.path} -> Vite:\${VITE_ASSET_PORT}\`);
|
|
149
|
-
const res = await fetch(viteUrl, { signal:
|
|
150
|
-
clearTimeout(timeout);
|
|
145
|
+
const res = await fetch(viteUrl, { signal: AbortSignal.timeout(10000) });
|
|
151
146
|
otel.logger.debug(\`[Proxy] \${c.req.path} -> \${res.status} (\${res.headers.get('content-type')})\`);
|
|
152
147
|
return new Response(res.body, {
|
|
153
148
|
status: res.status,
|
|
154
149
|
headers: res.headers,
|
|
155
150
|
});
|
|
156
151
|
} catch (err) {
|
|
157
|
-
|
|
158
|
-
if (err instanceof Error && err.name === 'AbortError') {
|
|
152
|
+
if (err instanceof Error && err.name === 'TimeoutError') {
|
|
159
153
|
otel.logger.error(\`Vite proxy timeout: \${c.req.path}\`);
|
|
160
154
|
return c.text('Vite asset server timeout', 504);
|
|
161
155
|
}
|
|
@@ -243,7 +237,9 @@ if (isDevelopment()) {
|
|
|
243
237
|
// 404 for unmatched API/system routes
|
|
244
238
|
app.all('/_agentuity/*', (c: Context) => c.notFound());
|
|
245
239
|
app.all('/api/*', (c: Context) => c.notFound());
|
|
246
|
-
|
|
240
|
+
if (hasWorkbench) {
|
|
241
|
+
app.all('/workbench/*', (c: Context) => c.notFound());
|
|
242
|
+
}
|
|
247
243
|
|
|
248
244
|
// SPA fallback - serve index.html for client-side routing
|
|
249
245
|
app.get('*', (c: Context) => {
|
|
@@ -276,7 +272,9 @@ if (isDevelopment()) {
|
|
|
276
272
|
// 404 for unmatched API/system routes (IMPORTANT: comes before SPA fallback)
|
|
277
273
|
app.all('/_agentuity/*', (c: Context) => c.notFound());
|
|
278
274
|
app.all('/api/*', (c: Context) => c.notFound());
|
|
279
|
-
|
|
275
|
+
if (hasWorkbench) {
|
|
276
|
+
app.all('/workbench/*', (c: Context) => c.notFound());
|
|
277
|
+
}
|
|
280
278
|
|
|
281
279
|
// SPA fallback with asset protection
|
|
282
280
|
app.get('*', (c: Context) => {
|
|
@@ -293,36 +291,25 @@ if (isDevelopment()) {
|
|
|
293
291
|
|
|
294
292
|
// Workbench routes (if enabled) - runtime mode detection
|
|
295
293
|
const workbenchRoute = workbench?.route ?? '/workbench';
|
|
296
|
-
const workbenchRoutes =
|
|
297
|
-
|
|
298
|
-
// Workbench routes - Runtime mode detection
|
|
299
|
-
// Both dev and prod run from .agentuity/app.js (dev bundles before running)
|
|
300
|
-
// So workbench-src is always in the same directory
|
|
301
|
-
const workbenchSrcDir = import.meta.dir + '/workbench-src';
|
|
302
|
-
const workbenchIndexPath = import.meta.dir + '/workbench/index.html';
|
|
303
|
-
const workbenchIndex = existsSync(workbenchIndexPath)
|
|
304
|
-
? readFileSync(workbenchIndexPath, 'utf-8')
|
|
305
|
-
: '';
|
|
306
|
-
|
|
307
|
-
if (isDevelopment()) {
|
|
294
|
+
const workbenchRoutes = `
|
|
295
|
+
if (hasWorkbench) {
|
|
308
296
|
// Development mode: Let Vite serve source files with HMR
|
|
309
|
-
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
297
|
+
if (isDevelopment()) {
|
|
298
|
+
const workbenchSrcDir = import.meta.dir + '/workbench-src';
|
|
299
|
+
const workbenchIndexPath = import.meta.dir + '/workbench-src/index.html';
|
|
300
|
+
app.get('${workbenchRoute}', async (c: Context) => {
|
|
301
|
+
const html = await Bun.file(workbenchIndexPath).text();
|
|
302
|
+
// Rewrite script/css paths to use Vite's @fs protocol
|
|
303
|
+
const withVite = html
|
|
304
|
+
.replace('src="./main.tsx"', \`src="/@fs\${workbenchSrcDir}/main.tsx"\`)
|
|
305
|
+
.replace('href="./styles.css"', \`href="/@fs\${workbenchSrcDir}/styles.css"\`);
|
|
306
|
+
return c.html(withVite);
|
|
307
|
+
});
|
|
308
|
+
} else {
|
|
309
|
+
// Production mode disables the workbench assets
|
|
322
310
|
}
|
|
323
311
|
}
|
|
324
|
-
|
|
325
|
-
: '';
|
|
312
|
+
`;
|
|
326
313
|
|
|
327
314
|
// Server startup (same for dev and prod - Bun.serve with native WebSocket)
|
|
328
315
|
const serverStartup = `
|
|
@@ -345,6 +332,7 @@ if (typeof Bun !== 'undefined') {
|
|
|
345
332
|
});
|
|
346
333
|
|
|
347
334
|
// Make server available globally for health checks
|
|
335
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
348
336
|
(globalThis as any).__AGENTUITY_SERVER__ = server;
|
|
349
337
|
|
|
350
338
|
otel.logger.info(\`Server listening on http://127.0.0.1:\${port}\`);
|
|
@@ -366,6 +354,7 @@ if (!isDevelopment()) {
|
|
|
366
354
|
};
|
|
367
355
|
const idleHandler = (c: Context) => {
|
|
368
356
|
// Check if server is idle (no pending requests/connections)
|
|
357
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
369
358
|
const server = (globalThis as any).__AGENTUITY_SERVER__;
|
|
370
359
|
if (!server) return c.text('NO', 200, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
371
360
|
|
|
@@ -429,6 +418,9 @@ if (isDevelopment()) {
|
|
|
429
418
|
await bootstrapRuntimeEnv({ projectDir: import.meta.dir + '/../..' });
|
|
430
419
|
}
|
|
431
420
|
|
|
421
|
+
// Step 0.25: load our runtime metadata and cache it
|
|
422
|
+
loadBuildMetadata();
|
|
423
|
+
|
|
432
424
|
// Step 0.5: Patch Bun's S3 client for Agentuity storage endpoints
|
|
433
425
|
// Agentuity storage uses virtual-hosted-style URLs (*.storage.dev)
|
|
434
426
|
// This patches s3.file() to automatically set virtualHostedStyle: true
|
package/src/cmd/build/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { viteBundle } from './vite-bundler';
|
|
|
5
5
|
import * as tui from '../../tui';
|
|
6
6
|
import { getCommand } from '../../command-prefix';
|
|
7
7
|
import { ErrorCode } from '../../errors';
|
|
8
|
+
import { typecheck } from './typecheck';
|
|
8
9
|
|
|
9
10
|
const BuildResponseSchema = z.object({
|
|
10
11
|
success: z.boolean().describe('Whether the build succeeded'),
|
|
@@ -78,22 +79,24 @@ export const command = createCommand({
|
|
|
78
79
|
if (!opts.dev && !opts.skipTypeCheck) {
|
|
79
80
|
try {
|
|
80
81
|
tui.info('Running type check...');
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
.nothrow();
|
|
84
|
-
|
|
85
|
-
if (result.exitCode === 0) {
|
|
82
|
+
const typeResult = await typecheck(absoluteProjectDir);
|
|
83
|
+
if (typeResult.success) {
|
|
86
84
|
tui.success('Type check passed');
|
|
87
85
|
} else {
|
|
88
|
-
|
|
89
|
-
console.error(
|
|
90
|
-
|
|
86
|
+
console.error('');
|
|
87
|
+
console.error(typeResult.output);
|
|
88
|
+
console.error('');
|
|
89
|
+
const msg =
|
|
90
|
+
'errors' in typeResult ? 'Fix type errors before building' : 'Build error';
|
|
91
|
+
tui.fatal(msg, ErrorCode.BUILD_FAILED);
|
|
91
92
|
}
|
|
92
93
|
} catch (error: unknown) {
|
|
93
|
-
// If tsc fails to run, show error and fail
|
|
94
94
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
95
95
|
tui.error(`Type check failed to run: ${errorMsg}`);
|
|
96
|
-
tui.fatal(
|
|
96
|
+
tui.fatal(
|
|
97
|
+
'Unable to run TypeScript type checking. Ensure TypeScript is installed.',
|
|
98
|
+
ErrorCode.BUILD_FAILED
|
|
99
|
+
);
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
102
|
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { parse, type GrammarItem } from '../../tsc-output-parser';
|
|
2
|
+
import { formatTypeScriptErrors, hasErrors } from '../../typescript-errors';
|
|
3
|
+
|
|
4
|
+
interface TypeError {
|
|
5
|
+
success: false;
|
|
6
|
+
errors: GrammarItem[];
|
|
7
|
+
output: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface TypeUnknownError {
|
|
11
|
+
success: false;
|
|
12
|
+
output: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface TypeSuccess {
|
|
16
|
+
success: true;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type TypeResult = TypeError | TypeSuccess | TypeUnknownError;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* run the typescript compiler and result formatted results
|
|
23
|
+
*
|
|
24
|
+
* @param dir the absolute path to the directory containing the project (must have tsconfig.json in this folder)
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
export async function typecheck(dir: string): Promise<TypeResult> {
|
|
28
|
+
const result = await Bun.$`bunx tsc --noEmit --skipLibCheck --pretty false`
|
|
29
|
+
.cwd(dir)
|
|
30
|
+
.quiet()
|
|
31
|
+
.nothrow();
|
|
32
|
+
|
|
33
|
+
const output = await result.text();
|
|
34
|
+
const errors = parse(output) as GrammarItem[];
|
|
35
|
+
|
|
36
|
+
if (result.exitCode === 0) {
|
|
37
|
+
return {
|
|
38
|
+
success: true,
|
|
39
|
+
};
|
|
40
|
+
} else if (errors && hasErrors(errors)) {
|
|
41
|
+
const formattedErrors = await formatTypeScriptErrors(errors, {
|
|
42
|
+
projectDir: dir,
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
success: false,
|
|
46
|
+
errors,
|
|
47
|
+
output: formattedErrors,
|
|
48
|
+
};
|
|
49
|
+
} else {
|
|
50
|
+
return {
|
|
51
|
+
success: false,
|
|
52
|
+
output: output || result.stderr.toString(),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { join } from 'node:path';
|
|
9
|
+
import { createRequire } from 'node:module';
|
|
9
10
|
import type { InlineConfig } from 'vite';
|
|
10
11
|
import type { Logger } from '../../../types';
|
|
11
12
|
|
|
@@ -116,14 +117,22 @@ export async function generateAssetServerConfig(
|
|
|
116
117
|
},
|
|
117
118
|
|
|
118
119
|
// Plugins: User plugins first (e.g., Tailwind), then React and browser env
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
120
|
+
// Resolve @vitejs/plugin-react from the project's node_modules
|
|
121
|
+
plugins: await (async () => {
|
|
122
|
+
const projectRequire = createRequire(join(rootDir, 'package.json'));
|
|
123
|
+
const reactPlugin = (
|
|
124
|
+
await import(projectRequire.resolve('@vitejs/plugin-react'))
|
|
125
|
+
).default();
|
|
126
|
+
const { browserEnvPlugin } = await import('./browser-env-plugin');
|
|
127
|
+
return [
|
|
128
|
+
// User-defined plugins from agentuity.config.ts (e.g., Tailwind CSS)
|
|
129
|
+
...userPlugins,
|
|
130
|
+
// React plugin for JSX/TSX transformation and Fast Refresh
|
|
131
|
+
reactPlugin,
|
|
132
|
+
// Browser env plugin to map process.env to import.meta.env
|
|
133
|
+
browserEnvPlugin(),
|
|
134
|
+
];
|
|
135
|
+
})(),
|
|
127
136
|
|
|
128
137
|
// Suppress build-related options (this is dev-only)
|
|
129
138
|
build: {
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* Does NOT handle API routes or WebSocket - the Bun server proxies to this.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { createRequire } from 'node:module';
|
|
8
10
|
import type { ViteDevServer } from 'vite';
|
|
9
11
|
import type { Logger } from '../../../types';
|
|
10
12
|
import { generateAssetServerConfig } from './vite-asset-server-config';
|
|
@@ -43,8 +45,10 @@ export async function startViteAssetServer(
|
|
|
43
45
|
port: preferredPort,
|
|
44
46
|
});
|
|
45
47
|
|
|
46
|
-
// Dynamically import vite
|
|
47
|
-
|
|
48
|
+
// Dynamically import vite from the project's node_modules
|
|
49
|
+
// This ensures we resolve from the target project directory, not the CWD
|
|
50
|
+
const projectRequire = createRequire(join(rootDir, 'package.json'));
|
|
51
|
+
const { createServer } = await import(projectRequire.resolve('vite'));
|
|
48
52
|
|
|
49
53
|
// Create Vite server with config
|
|
50
54
|
const server = await createServer(config);
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { join } from 'node:path';
|
|
8
8
|
import { existsSync, renameSync, rmSync } from 'node:fs';
|
|
9
|
+
import { createRequire } from 'node:module';
|
|
9
10
|
import type { InlineConfig, Plugin } from 'vite';
|
|
10
11
|
import type { Logger, DeployOptions } from '../../../types';
|
|
11
12
|
import { browserEnvPlugin } from './browser-env-plugin';
|
|
@@ -106,8 +107,18 @@ export async function runViteBuild(options: ViteBuildOptions): Promise<void> {
|
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
// Dynamically import vite and react plugin
|
|
109
|
-
|
|
110
|
-
const
|
|
110
|
+
// Try project's node_modules first (for custom vite configs), fall back to CLI's
|
|
111
|
+
const projectRequire = createRequire(join(rootDir, 'package.json'));
|
|
112
|
+
let vitePath = 'vite';
|
|
113
|
+
let reactPluginPath = '@vitejs/plugin-react';
|
|
114
|
+
try {
|
|
115
|
+
vitePath = projectRequire.resolve('vite');
|
|
116
|
+
reactPluginPath = projectRequire.resolve('@vitejs/plugin-react');
|
|
117
|
+
} catch {
|
|
118
|
+
// Project doesn't have vite, use CLI's bundled version
|
|
119
|
+
}
|
|
120
|
+
const { build: viteBuild } = await import(vitePath);
|
|
121
|
+
const reactModule = await import(reactPluginPath);
|
|
111
122
|
const react = reactModule.default;
|
|
112
123
|
|
|
113
124
|
// For client/workbench, use inline config (no agentuity plugin needed)
|