@ai-sdk/harness 1.0.39 → 1.0.41

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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # @ai-sdk/harness
2
2
 
3
+ ## 1.0.41
4
+
5
+ ### Patch Changes
6
+
7
+ - a94425b: fix(harness): ensure harness telemetry hooks are awaited before stream processing continues
8
+ - 2de0611: fix(harness): avoid incorrectly marked invalid tool calls due to `dynamic` flag being dropped
9
+ - Updated dependencies [7fa85b2]
10
+ - ai@7.0.36
11
+
12
+ ## 1.0.40
13
+
14
+ ### Patch Changes
15
+
16
+ - 59a2306: fix(harness): execute host tools through telemetry context wrappers
17
+ - 5f65e61: feat(harness): add support for `stopWhen` control to `HarnessAgent` (e.g. `isStepCount(1)`)
18
+ - Updated dependencies [7f6650b]
19
+ - Updated dependencies [106ea59]
20
+ - ai@7.0.35
21
+
3
22
  ## 1.0.39
4
23
 
5
24
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
2
- import { Experimental_SandboxSession, UserModelMessage, ToolSet, FlexibleSchema, Tool, ToolApprovalResponse, ModelMessage, Context } from '@ai-sdk/provider-utils';
3
- import { ToolApprovalStatus, TelemetryOptions, ActiveTools, StreamTextResult, Agent, AgentCallParameters, GenerateTextResult, AgentStreamParameters, Telemetry } from 'ai';
2
+ import { Experimental_SandboxSession, UserModelMessage, ToolSet, FlexibleSchema, Tool, Context, Arrayable, ToolApprovalResponse, ModelMessage } from '@ai-sdk/provider-utils';
3
+ import { StopCondition, ToolApprovalStatus, TelemetryOptions, ActiveTools, StreamTextResult, Agent, AgentCallParameters, GenerateTextResult, AgentStreamParameters, Telemetry } from 'ai';
4
4
  import { z } from 'zod/v4';
5
5
  import { JSONValue, LanguageModelV4ToolCall, LanguageModelV4ToolApprovalRequest, LanguageModelV4ToolResult, LanguageModelV4FinishReason, LanguageModelV4Usage, JSONSchema7, AISDKError } from '@ai-sdk/provider';
6
6
 
@@ -1143,7 +1143,7 @@ type HarnessAgentToolFilteringSettings<TOOLS extends ToolSet> = {
1143
1143
  */
1144
1144
  readonly inactiveTools?: HarnessTools<TOOLS>;
1145
1145
  };
1146
- type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAgentAdapter, TUserTools extends ToolSet = {}> = {
1146
+ type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAgentAdapter, TUserTools extends ToolSet = {}, RUNTIME_CONTEXT extends Context = Context> = {
1147
1147
  /**
1148
1148
  * The harness adapter driving the underlying agent runtime. Its
1149
1149
  * `builtinTools` are merged with the user-defined `tools` and exposed to
@@ -1177,6 +1177,16 @@ type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAge
1177
1177
  * later turns or when resuming a previously ended session.
1178
1178
  */
1179
1179
  readonly instructions?: string;
1180
+ /**
1181
+ * Conditions that stop the current result after a completed harness tool
1182
+ * step that can continue into another model step. The underlying turn remains
1183
+ * unfinished and can be suspended and continued.
1184
+ *
1185
+ * A terminal text-only step finishes naturally and is not stopped early.
1186
+ *
1187
+ * When omitted, the harness runs until the turn naturally finishes or pauses.
1188
+ */
1189
+ readonly stopWhen?: Arrayable<StopCondition<NoInfer<HarnessAllTools<THarness, TUserTools>>, RUNTIME_CONTEXT>>;
1180
1190
  /**
1181
1191
  * Built-in tool permission mode. Defaults to `'allow-all'`, preserving the
1182
1192
  * existing bypass-permissions behavior unless users opt in.
@@ -1303,6 +1313,7 @@ declare class HarnessAgentSession {
1303
1313
  private turnState;
1304
1314
  private turnSequence;
1305
1315
  private activeTurnSequence;
1316
+ private suspendedTurnState;
1306
1317
  /**
1307
1318
  * Whether this session was created from `resumeFrom` or `continueFrom`.
1308
1319
  * Captured at construction so it survives lifecycle cleanup.
@@ -1332,6 +1343,7 @@ declare class HarnessAgentSession {
1332
1343
  runtimeContext: RUNTIME_CONTEXT;
1333
1344
  abortSignal: AbortSignal | undefined;
1334
1345
  telemetry: TelemetryOptions | undefined;
1346
+ stopConditions: ReadonlyArray<StopCondition<TOOLS, RUNTIME_CONTEXT>>;
1335
1347
  }): HarnessAgentTurnResult<TOOLS, RUNTIME_CONTEXT>;
1336
1348
  continueTurn<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context>(options: {
1337
1349
  instructions: string | undefined;
@@ -1342,6 +1354,7 @@ declare class HarnessAgentSession {
1342
1354
  runtimeContext: RUNTIME_CONTEXT;
1343
1355
  abortSignal: AbortSignal | undefined;
1344
1356
  telemetry: TelemetryOptions | undefined;
1357
+ stopConditions: ReadonlyArray<StopCondition<TOOLS, RUNTIME_CONTEXT>>;
1345
1358
  toolApprovalContinuations?: readonly HarnessAgentToolApprovalContinuation[] | undefined;
1346
1359
  toolResultContinuations?: readonly HarnessAgentToolResultContinuation[] | undefined;
1347
1360
  }): HarnessAgentTurnResult<TOOLS, RUNTIME_CONTEXT>;
@@ -1392,6 +1405,7 @@ declare class HarnessAgentSession {
1392
1405
  private getPendingToolResults;
1393
1406
  private addPendingToolState;
1394
1407
  private suspendCurrentTurn;
1408
+ private captureStopConditionBoundary;
1395
1409
  private toResumeStateWithContinuation;
1396
1410
  private requirePromptableTurn;
1397
1411
  private requireContinuableTurn;
@@ -1461,11 +1475,12 @@ declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAg
1461
1475
  */
1462
1476
  readonly tools: HarnessAllTools<THarness, TUserTools>;
1463
1477
  private readonly settings;
1478
+ private readonly stopConditions;
1464
1479
  private readonly sandboxConfig;
1465
1480
  private readonly activeUserTools;
1466
1481
  private readonly builtinToolFiltering;
1467
1482
  private readonly permissionMode;
1468
- constructor(settings: HarnessAgentSettings<THarness, TUserTools>);
1483
+ constructor(settings: HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT>);
1469
1484
  /** Identifier of the harness backing this agent. */
1470
1485
  get harnessId(): string;
1471
1486
  /**