Skip to content

Commit 79927b9

Browse files
committed
fix: resolve type errors from merge conflict resolution
- Export ConnectionError, ResourceNotFoundError, ValidationError from lib/errors barrel - Remove duplicate imports in dev/command.tsx - Fix ConnectionError constructor calls (expects string, not Error) - Fix InvokeResult/Result type mismatch in invoke telemetry wrapper - Add missing harnesses field to test fixture - Remove unused serializeResult import - Fix unnecessary type assertion
1 parent cac76c1 commit 79927b9

6 files changed

Lines changed: 20 additions & 38 deletions

File tree

package-lock.json

Lines changed: 0 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli/commands/dev/command.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import {
32
ConnectionError,
43
ResourceNotFoundError,
@@ -11,7 +10,6 @@ import { getErrorMessage } from '../../errors';
1110
import { detectContainerRuntime } from '../../external-requirements';
1211
import { ExecLogger } from '../../logging';
1312
import {
14-
ConnectionError,
1513
callMcpTool,
1614
createDevServer,
1715
findAvailablePort,
@@ -37,7 +35,6 @@ import { requireProject, requireTTY } from '../../tui/guards';
3735
import { runCliDeploy } from '../deploy/progress';
3836
import { parseHeaderFlags } from '../shared/header-utils';
3937
import { launchTuiDevScreenWithPicker, runBrowserMode } from './browser-mode';
40-
import { ResourceNotFoundError, ValidationError } from '@/lib/errors/types.js';
4138
import type { Command } from '@commander-js/extra-typings';
4239
import { spawn } from 'child_process';
4340
import { render } from 'ink';
@@ -67,7 +64,7 @@ async function invokeDevServer(
6764
}
6865
} catch (err) {
6966
throw isConnectionRefused(err)
70-
? new ConnectionError(new Error(`Dev server not running on port ${port}. Start it with: agentcore dev --logs`))
67+
? new ConnectionError(`Dev server not running on port ${port}. Start it with: agentcore dev --logs`)
7168
: err;
7269
}
7370
}
@@ -80,7 +77,7 @@ async function invokeA2ADevServer(port: number, prompt: string, headers?: Record
8077
process.stdout.write('\n');
8178
} catch (err) {
8279
throw isConnectionRefused(err)
83-
? new ConnectionError(new Error(`Dev server not running on port ${port}. Start it with: agentcore dev --logs`))
80+
? new ConnectionError(`Dev server not running on port ${port}. Start it with: agentcore dev --logs`)
8481
: err;
8582
}
8683
}
@@ -136,7 +133,7 @@ async function handleMcpInvoke(
136133
}
137134
} catch (err) {
138135
throw isConnectionRefused(err)
139-
? new ConnectionError(new Error(`Dev server not running on port ${port}. Start it with: agentcore dev --logs`))
136+
? new ConnectionError(`Dev server not running on port ${port}. Start it with: agentcore dev --logs`)
140137
: err;
141138
}
142139
}

src/cli/commands/invoke/command.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type Result, ValidationError, serializeResult } from '../../../lib';
1+
import { type Result, ValidationError } from '../../../lib';
22
import { getErrorMessage } from '../../errors';
33
import { withCommandRunTelemetry } from '../../telemetry/cli-command-run.js';
44
import { AuthType, Protocol, standardize } from '../../telemetry/schemas/common-shapes.js';
@@ -39,7 +39,7 @@ function resolveProtocol(options: InvokeOptions, projectProtocol?: string): stri
3939
async function handleInvokeCLI(options: InvokeOptions, preloadedContext?: InvokeContext): Promise<InvokeResult> {
4040
const validation = validateInvokeOptions(options);
4141
if (!validation.valid) {
42-
return { success: false, error: new ValidationError(validation.error ?? 'Validation failed') };
42+
return { success: false, error: validation.error ?? 'Validation failed' };
4343
}
4444

4545
let spinner: NodeJS.Timeout | undefined;
@@ -65,7 +65,7 @@ async function handleInvokeCLI(options: InvokeOptions, preloadedContext?: Invoke
6565
process.exit(result.success ? 0 : 1);
6666
}
6767

68-
const context = preloadedContext ??await loadInvokeConfig();
68+
const context = preloadedContext ?? (await loadInvokeConfig());
6969

7070
// Show spinner for non-streaming, non-json, non-exec invocations
7171
// Harness invoke always streams directly to stdout, so skip spinner for harness
@@ -120,7 +120,7 @@ async function handleInvokeCLI(options: InvokeOptions, preloadedContext?: Invoke
120120

121121
function printInvokeResult(result: InvokeResult, options: InvokeOptions): void {
122122
if (options.json) {
123-
console.log(JSON.stringify(serializeResult(result)));
123+
console.log(JSON.stringify(result));
124124
} else if (options.stream) {
125125
// Streaming already wrote to stdout, just show session and log path
126126
if (result.sessionId) {
@@ -135,7 +135,7 @@ function printInvokeResult(result: InvokeResult, options: InvokeOptions): void {
135135
if (result.success && result.response) {
136136
console.log(result.response);
137137
} else if (!result.success && result.error) {
138-
console.error(result.error.message);
138+
console.error(result.error);
139139
}
140140
if (result.sessionId) {
141141
console.error(`\nSession: ${result.sessionId}`);
@@ -277,12 +277,9 @@ export const registerInvoke = (program: Command) => {
277277
has_stream: cliOptions.stream ?? false,
278278
has_session_id: !!cliOptions.sessionId,
279279
auth_type: standardize(AuthType, cliOptions.bearerToken ? 'bearer_token' : 'sigv4'),
280-
protocol: standardize(
281-
Protocol,
282-
resolveProtocol({ tool: cliOptions.tool } as InvokeOptions, agentProtocol)
283-
),
280+
protocol: standardize(Protocol, resolveProtocol({ tool: cliOptions.tool }, agentProtocol)),
284281
},
285-
async (): Promise<InvokeResult> => {
282+
async (): Promise<Result> => {
286283
if (!resolved.success) {
287284
return { success: false, error: new ValidationError(resolved.error ?? 'Prompt resolution failed') };
288285
}
@@ -324,14 +321,15 @@ export const registerInvoke = (program: Command) => {
324321
actorId: cliOptions.actorId,
325322
};
326323

327-
return handleInvokeCLI(options, invokeContext);
324+
const invokeResult = await handleInvokeCLI(options, invokeContext);
325+
printInvokeResult(invokeResult, options);
326+
if (invokeResult.success) {
327+
return { success: true };
328+
}
329+
return { success: false, error: new Error(invokeResult.error ?? 'Invoke failed') };
328330
}
329331
);
330332

331-
printInvokeResult(result, {
332-
json: cliOptions.json,
333-
stream: cliOptions.stream,
334-
});
335333
process.exit(result.success ? 0 : 1);
336334
} else {
337335
// No CLI options - interactive TUI mode (headers still passed if provided)

src/cli/commands/traces/action.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ export async function handleTracesList(
3131
if (!isPython) {
3232
return {
3333
success: false,
34-
error: new ValidationError(
35-
'Traces are only supported for Python agents. TypeScript agents do not support observability traces.'
36-
),
34+
error: 'Traces are only supported for Python agents. TypeScript agents do not support observability traces.',
3735
};
3836
}
3937

@@ -109,9 +107,7 @@ export async function handleTracesGet(
109107
if (!isPython) {
110108
return {
111109
success: false,
112-
error: new ValidationError(
113-
'Traces are only supported for Python agents. TypeScript agents do not support observability traces.'
114-
),
110+
error: 'Traces are only supported for Python agents. TypeScript agents do not support observability traces.',
115111
};
116112
}
117113

src/cli/operations/dev/__tests__/config.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ describe('getDevSupportedAgents', () => {
614614
configBundles: [],
615615
abTests: [],
616616
httpGateways: [],
617+
harnesses: [],
617618
};
618619

619620
const supported = getDevSupportedAgents(project);

src/lib/errors/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './config';
2+
export { ConnectionError, ResourceNotFoundError, ValidationError } from './types';

0 commit comments

Comments
 (0)