@ai-sdk/harness 1.0.36 → 1.0.38
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/CHANGELOG.md +22 -0
- package/agent/index.ts +5 -0
- package/dist/agent/index.d.ts +36 -4
- package/dist/agent/index.js +290 -102
- package/dist/agent/index.js.map +1 -1
- package/dist/index.d.ts +11 -1
- package/package.json +3 -3
- package/src/agent/harness-agent-session.ts +66 -20
- package/src/agent/harness-agent-tool-result-continuation.ts +62 -0
- package/src/agent/harness-agent-types.ts +2 -0
- package/src/agent/harness-agent.ts +23 -2
- package/src/agent/internal/harness-stream-text-result.ts +60 -35
- package/src/agent/internal/lifecycle-state-validation.ts +13 -0
- package/src/agent/internal/run-prompt.ts +159 -42
- package/src/agent/internal/translate-stream-part.ts +3 -2
- package/src/v1/harness-v1-lifecycle-state.ts +12 -0
- package/src/v1/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @ai-sdk/harness
|
|
2
2
|
|
|
3
|
+
## 1.0.38
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [02ffdcb]
|
|
8
|
+
- Updated dependencies [76cb673]
|
|
9
|
+
- Updated dependencies [e808fa5]
|
|
10
|
+
- Updated dependencies [33647d7]
|
|
11
|
+
- @ai-sdk/provider-utils@5.0.12
|
|
12
|
+
- ai@7.0.33
|
|
13
|
+
|
|
14
|
+
## 1.0.37
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- b460541: fix(harness): properly support client-side / host-side tools and handle unfinished turn semantics
|
|
19
|
+
- 079591e: fix (harness): emit the message-level `start` part on HarnessAgent streams so `toUIMessageStream` persistence mode can inject the response message id
|
|
20
|
+
- Updated dependencies [6cd7c74]
|
|
21
|
+
- Updated dependencies [e35bcae]
|
|
22
|
+
- Updated dependencies [a4eb3f3]
|
|
23
|
+
- ai@7.0.32
|
|
24
|
+
|
|
3
25
|
## 1.0.36
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/agent/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type {
|
|
|
16
16
|
HarnessAgentContinueTurnState,
|
|
17
17
|
HarnessAgentLifecycleState,
|
|
18
18
|
HarnessAgentPendingToolApproval,
|
|
19
|
+
HarnessAgentPendingToolResult,
|
|
19
20
|
HarnessAgentPermissionMode,
|
|
20
21
|
HarnessAgentPrompt,
|
|
21
22
|
HarnessAgentPromptControl,
|
|
@@ -31,6 +32,10 @@ export {
|
|
|
31
32
|
collectHarnessAgentToolApprovalContinuations,
|
|
32
33
|
type HarnessAgentToolApprovalContinuation,
|
|
33
34
|
} from '../src/agent/harness-agent-tool-approval-continuation';
|
|
35
|
+
export {
|
|
36
|
+
collectHarnessAgentToolResultContinuations,
|
|
37
|
+
type HarnessAgentToolResultContinuation,
|
|
38
|
+
} from '../src/agent/harness-agent-tool-result-continuation';
|
|
34
39
|
export {
|
|
35
40
|
prepareHarnessSandboxTemplate,
|
|
36
41
|
prewarmHarness,
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -366,6 +366,11 @@ type HarnessV1PendingToolApproval = {
|
|
|
366
366
|
readonly providerExecuted?: boolean;
|
|
367
367
|
readonly nativeName?: string;
|
|
368
368
|
};
|
|
369
|
+
type HarnessV1PendingToolResult = {
|
|
370
|
+
readonly toolCallId: string;
|
|
371
|
+
readonly toolName: string;
|
|
372
|
+
readonly input: string;
|
|
373
|
+
};
|
|
369
374
|
type HarnessV1LifecycleStateBase = {
|
|
370
375
|
/**
|
|
371
376
|
* Identifier of the harness that produced this state. Used by adapters to
|
|
@@ -408,6 +413,11 @@ type HarnessV1ContinueTurnState = HarnessV1LifecycleStateBase & {
|
|
|
408
413
|
* without the harness framework owning storage.
|
|
409
414
|
*/
|
|
410
415
|
readonly pendingToolApprovals?: readonly HarnessV1PendingToolApproval[];
|
|
416
|
+
/**
|
|
417
|
+
* Framework-owned client tool calls that are waiting for a caller-provided
|
|
418
|
+
* result before the underlying turn can continue.
|
|
419
|
+
*/
|
|
420
|
+
readonly pendingToolResults?: readonly HarnessV1PendingToolResult[];
|
|
411
421
|
};
|
|
412
422
|
type HarnessV1LifecycleState = HarnessV1ResumeSessionState | HarnessV1ContinueTurnState;
|
|
413
423
|
|
|
@@ -1059,6 +1069,7 @@ type HarnessAgentLifecycleState = HarnessV1LifecycleState;
|
|
|
1059
1069
|
type HarnessAgentResumeSessionState = HarnessV1ResumeSessionState;
|
|
1060
1070
|
type HarnessAgentContinueTurnState = HarnessV1ContinueTurnState;
|
|
1061
1071
|
type HarnessAgentPendingToolApproval = HarnessV1PendingToolApproval;
|
|
1072
|
+
type HarnessAgentPendingToolResult = HarnessV1PendingToolResult;
|
|
1062
1073
|
type HarnessAgentSkill = HarnessV1Skill;
|
|
1063
1074
|
type HarnessAgentPermissionMode = HarnessV1PermissionMode;
|
|
1064
1075
|
|
|
@@ -1239,11 +1250,25 @@ declare function collectHarnessAgentToolApprovalContinuations(input: {
|
|
|
1239
1250
|
messages: readonly ModelMessage[];
|
|
1240
1251
|
}): readonly HarnessAgentToolApprovalContinuation[];
|
|
1241
1252
|
|
|
1253
|
+
type HarnessAgentToolResultContinuation = {
|
|
1254
|
+
readonly toolCallId: string;
|
|
1255
|
+
readonly output: unknown;
|
|
1256
|
+
readonly isError?: boolean;
|
|
1257
|
+
};
|
|
1258
|
+
/**
|
|
1259
|
+
* Extract client-provided tool results from the trailing tool message and
|
|
1260
|
+
* convert AI SDK model-output wrappers back into values a harness runtime can
|
|
1261
|
+
* return from its pending host-tool invocation.
|
|
1262
|
+
*/
|
|
1263
|
+
declare function collectHarnessAgentToolResultContinuations(input: {
|
|
1264
|
+
messages: readonly ModelMessage[];
|
|
1265
|
+
}): readonly HarnessAgentToolResultContinuation[];
|
|
1266
|
+
|
|
1242
1267
|
type HarnessAgentTurnResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context> = {
|
|
1243
1268
|
result: StreamTextResult<TOOLS, RUNTIME_CONTEXT, never>;
|
|
1244
1269
|
done: Promise<void>;
|
|
1245
1270
|
};
|
|
1246
|
-
type HarnessAgentTurnState = 'idle' | 'running' | 'awaiting-approval' | 'suspended';
|
|
1271
|
+
type HarnessAgentTurnState = 'idle' | 'running' | 'awaiting-approval' | 'awaiting-tool-result' | 'suspended';
|
|
1247
1272
|
/**
|
|
1248
1273
|
* Live harness session held by the caller.
|
|
1249
1274
|
*
|
|
@@ -1273,6 +1298,7 @@ declare class HarnessAgentSession {
|
|
|
1273
1298
|
private leasedBridgePort;
|
|
1274
1299
|
private readonly toolApproval;
|
|
1275
1300
|
private readonly pendingToolApprovals;
|
|
1301
|
+
private readonly pendingToolResults;
|
|
1276
1302
|
private sessionState;
|
|
1277
1303
|
private turnState;
|
|
1278
1304
|
private turnSequence;
|
|
@@ -1292,8 +1318,10 @@ declare class HarnessAgentSession {
|
|
|
1292
1318
|
sessionWorkDir: string;
|
|
1293
1319
|
toolApproval: HarnessAgentToolApprovalConfiguration | undefined;
|
|
1294
1320
|
pendingToolApprovals?: readonly HarnessAgentPendingToolApproval[];
|
|
1321
|
+
pendingToolResults?: readonly HarnessAgentPendingToolResult[];
|
|
1295
1322
|
turnState?: HarnessAgentTurnState;
|
|
1296
1323
|
});
|
|
1324
|
+
hasUnfinishedTurn(): boolean;
|
|
1297
1325
|
promptTurn<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context>(options: {
|
|
1298
1326
|
prompt: HarnessAgentPrompt;
|
|
1299
1327
|
instructions: string | undefined;
|
|
@@ -1315,6 +1343,7 @@ declare class HarnessAgentSession {
|
|
|
1315
1343
|
abortSignal: AbortSignal | undefined;
|
|
1316
1344
|
telemetry: TelemetryOptions | undefined;
|
|
1317
1345
|
toolApprovalContinuations?: readonly HarnessAgentToolApprovalContinuation[] | undefined;
|
|
1346
|
+
toolResultContinuations?: readonly HarnessAgentToolResultContinuation[] | undefined;
|
|
1318
1347
|
}): HarnessAgentTurnResult<TOOLS, RUNTIME_CONTEXT>;
|
|
1319
1348
|
/**
|
|
1320
1349
|
* Ask the underlying runtime to compact its context. The runtime performs
|
|
@@ -1360,14 +1389,15 @@ declare class HarnessAgentSession {
|
|
|
1360
1389
|
*/
|
|
1361
1390
|
suspendTurn(): Promise<HarnessAgentContinueTurnState>;
|
|
1362
1391
|
private getPendingToolApprovals;
|
|
1363
|
-
private
|
|
1392
|
+
private getPendingToolResults;
|
|
1393
|
+
private addPendingToolState;
|
|
1364
1394
|
private suspendCurrentTurn;
|
|
1365
1395
|
private toResumeStateWithContinuation;
|
|
1366
1396
|
private requirePromptableTurn;
|
|
1367
1397
|
private requireContinuableTurn;
|
|
1368
1398
|
private markAwaitingApprovalIfActive;
|
|
1399
|
+
private markAwaitingToolResultIfActive;
|
|
1369
1400
|
private startTrackedTurn;
|
|
1370
|
-
private trackTurnCompletion;
|
|
1371
1401
|
private finishTrackedTurn;
|
|
1372
1402
|
private endLocalHandle;
|
|
1373
1403
|
private releasePortLease;
|
|
@@ -1478,6 +1508,7 @@ declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAg
|
|
|
1478
1508
|
continueGenerate(options: {
|
|
1479
1509
|
session: HarnessAgentSession;
|
|
1480
1510
|
toolApprovalContinuations?: readonly HarnessAgentToolApprovalContinuation[];
|
|
1511
|
+
toolResultContinuations?: readonly HarnessAgentToolResultContinuation[];
|
|
1481
1512
|
abortSignal?: AbortSignal;
|
|
1482
1513
|
}): Promise<GenerateTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, never>>;
|
|
1483
1514
|
/**
|
|
@@ -1491,6 +1522,7 @@ declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAg
|
|
|
1491
1522
|
continueStream(options: {
|
|
1492
1523
|
session: HarnessAgentSession;
|
|
1493
1524
|
toolApprovalContinuations?: readonly HarnessAgentToolApprovalContinuation[];
|
|
1525
|
+
toolResultContinuations?: readonly HarnessAgentToolResultContinuation[];
|
|
1494
1526
|
abortSignal?: AbortSignal;
|
|
1495
1527
|
}): Promise<StreamTextResult<HarnessAllTools<THarness, TUserTools>, RUNTIME_CONTEXT, never>>;
|
|
1496
1528
|
private _startTurn;
|
|
@@ -1628,4 +1660,4 @@ interface TraceTreeReporterOptions {
|
|
|
1628
1660
|
}
|
|
1629
1661
|
declare function createTraceTreeReporter(options?: TraceTreeReporterOptions): Telemetry;
|
|
1630
1662
|
|
|
1631
|
-
export { type FileReporter, type FileReporterOptions, HarnessAgent, type HarnessAgentAdapter, type HarnessAgentAdapterSession, type HarnessAgentBuiltinTool, type HarnessAgentBuiltinToolName, type HarnessAgentBuiltinToolUseKind, type HarnessAgentBuiltinTools, type HarnessAgentContinueTurnOptions, type HarnessAgentContinueTurnState, type HarnessAgentLifecycleState, type HarnessAgentPendingToolApproval, type HarnessAgentPermissionMode, type HarnessAgentPrompt, type HarnessAgentPromptControl, type HarnessAgentPromptTurnOptions, type HarnessAgentResumeSessionState, type HarnessAgentSandboxConfig, HarnessAgentSession, type HarnessAgentSettings, type HarnessAgentSkill, type HarnessAgentStartOptions, type HarnessAgentStreamPart, type HarnessAgentToolApprovalConfiguration, type HarnessAgentToolApprovalContinuation, type HarnessAgentToolSpec, type HarnessAllTools, HarnessCapabilityUnsupportedError, type HarnessDebugConfig, type HarnessDebugLevel, type HarnessDiagnostic, type HarnessDiagnosticConsumer, HarnessError, type PrepareSandboxForHarnessResult, type TraceTreeReporterOptions, collectHarnessAgentToolApprovalContinuations, createFileReporter, createTraceTreeReporter, prepareHarnessSandboxTemplate, prepareSandboxForHarness, prewarmHarness };
|
|
1663
|
+
export { type FileReporter, type FileReporterOptions, HarnessAgent, type HarnessAgentAdapter, type HarnessAgentAdapterSession, type HarnessAgentBuiltinTool, type HarnessAgentBuiltinToolName, type HarnessAgentBuiltinToolUseKind, type HarnessAgentBuiltinTools, type HarnessAgentContinueTurnOptions, type HarnessAgentContinueTurnState, type HarnessAgentLifecycleState, type HarnessAgentPendingToolApproval, type HarnessAgentPendingToolResult, type HarnessAgentPermissionMode, type HarnessAgentPrompt, type HarnessAgentPromptControl, type HarnessAgentPromptTurnOptions, type HarnessAgentResumeSessionState, type HarnessAgentSandboxConfig, HarnessAgentSession, type HarnessAgentSettings, type HarnessAgentSkill, type HarnessAgentStartOptions, type HarnessAgentStreamPart, type HarnessAgentToolApprovalConfiguration, type HarnessAgentToolApprovalContinuation, type HarnessAgentToolResultContinuation, type HarnessAgentToolSpec, type HarnessAllTools, HarnessCapabilityUnsupportedError, type HarnessDebugConfig, type HarnessDebugLevel, type HarnessDiagnostic, type HarnessDiagnosticConsumer, HarnessError, type PrepareSandboxForHarnessResult, type TraceTreeReporterOptions, collectHarnessAgentToolApprovalContinuations, collectHarnessAgentToolResultContinuations, createFileReporter, createTraceTreeReporter, prepareHarnessSandboxTemplate, prepareSandboxForHarness, prewarmHarness };
|