@ai-sdk/harness 1.0.101 → 1.0.102

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.102
4
+
5
+ ### Patch Changes
6
+
7
+ - fe86f8f: feat(harness): support established lifecycle callbacks from `ToolLoopAgent` on `HarnessAgent` too
8
+ - 255cccf: feat(harness): add `writeInstructions` helper and support filesystem based `instructionsMapping` in ACP backed harness adapters
9
+ - eeed977: feat(harness): allow passing arbitrary headers with inference requests via `headers` property in `HarnessAgentSettings`
10
+ - a39c8bf: chore(harness): clarify `writeSkills` helper intent to require materializing skills in HOME directory
11
+ - Updated dependencies [df6c009]
12
+ - Updated dependencies [6ee74a3]
13
+ - Updated dependencies [f13d371]
14
+ - Updated dependencies [d4485fe]
15
+ - Updated dependencies [4f201cc]
16
+ - Updated dependencies [8cdb2a7]
17
+ - Updated dependencies [0f2281e]
18
+ - Updated dependencies [fc8e8ac]
19
+ - Updated dependencies [ee8391e]
20
+ - ai@7.0.93
21
+
3
22
  ## 1.0.101
4
23
 
5
24
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
2
2
  import { Experimental_SandboxSession, UserModelMessage, ToolResultPart, ProviderOptions, ToolSet, FlexibleSchema, Tool, Context, MaybePromiseLike, Arrayable, ToolApprovalResponse, ModelMessage } from '@ai-sdk/provider-utils';
3
- import { OutputInterface, AgentCallParameters, Prompt, StopCondition, ToolApprovalStatus, TelemetryOptions, ActiveTools, StreamTextResult, Agent, GenerateTextResult, AgentStreamParameters, Telemetry } from 'ai';
3
+ import { OutputInterface, AgentCallParameters, Prompt, StopCondition, GenerateTextOnStartCallback, GenerateTextOnStepStartCallback, OnLanguageModelCallStartCallback, OnLanguageModelCallEndCallback, OnToolExecutionStartCallback, OnToolExecutionEndCallback, GenerateTextOnStepEndCallback, GenerateTextOnEndCallback, ToolApprovalStatus, TelemetryOptions, ActiveTools, StreamTextResult, Agent, GenerateTextResult, AgentStreamParameters, Telemetry } from 'ai';
4
4
  import { z } from 'zod/v4';
5
5
  import { JSONSchema7, JSONValue, LanguageModelV4StreamPart, LanguageModelV4ToolCall, LanguageModelV4ToolApprovalRequest, LanguageModelV4ToolResult, LanguageModelV4FinishReason, LanguageModelV4Usage, AISDKError } from '@ai-sdk/provider';
6
6
 
@@ -697,6 +697,10 @@ type HarnessV1BuiltinToolFiltering = {
697
697
  * calling the adapter, so adapters never need to derive provider-specific paths.
698
698
  */
699
699
  type HarnessV1StartOptions = {
700
+ /**
701
+ * Additional normalized HTTP headers to send with model requests.
702
+ */
703
+ readonly headers?: Readonly<Record<string, string>>;
700
704
  /**
701
705
  * Stable identifier for this harness session. Used as the underlying
702
706
  * resource name where the adapter has a notion of a named session
@@ -1284,10 +1288,12 @@ type HarnessTools<TOOLS extends ToolSet> = ActiveTools<NoInfer<TOOLS>>;
1284
1288
  /**
1285
1289
  * Construction-time settings for a `HarnessAgent`.
1286
1290
  *
1287
- * Prompt, abortSignal, callbacks, and custom call options belong on the
1291
+ * Prompt, abortSignal, and custom call options belong on the
1288
1292
  * `AgentCallParameters` / `AgentStreamParameters` passed to `generate` /
1289
- * `stream`. `prepareCall` can derive turn-scoped model, skills, instructions,
1290
- * and tools from those custom call options.
1293
+ * `stream`. Lifecycle callbacks can be configured here for every call, while
1294
+ * the callbacks supported by `AgentCallParameters` can also be added per call.
1295
+ * `prepareCall` can derive turn-scoped model, skills, instructions, and tools
1296
+ * from custom call options.
1291
1297
  */
1292
1298
  type HarnessAgentToolFilteringSettings<TOOLS extends ToolSet> = {
1293
1299
  /**
@@ -1344,6 +1350,13 @@ type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAge
1344
1350
  * turns.
1345
1351
  */
1346
1352
  readonly instructions?: string;
1353
+ /**
1354
+ * Additional HTTP headers to be sent with every model request.
1355
+ *
1356
+ * `authorization`, `x-api-key`, `user-agent`, and `x-client-app` are
1357
+ * managed by the harness and are not allowed.
1358
+ */
1359
+ readonly headers?: Record<string, string | undefined>;
1347
1360
  /**
1348
1361
  * Schema for validating the custom options passed to each agent call.
1349
1362
  */
@@ -1379,6 +1392,39 @@ type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAge
1379
1392
  * When omitted, the harness runs until the turn naturally finishes or pauses.
1380
1393
  */
1381
1394
  readonly stopWhen?: Arrayable<StopCondition<NoInfer<HarnessAllTools<THarness, TUserTools>>, RUNTIME_CONTEXT>>;
1395
+ /**
1396
+ * Called when an agent call begins, before any model steps.
1397
+ */
1398
+ readonly onStart?: GenerateTextOnStartCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>, RUNTIME_CONTEXT, NoInfer<OUTPUT>>;
1399
+ /**
1400
+ * Called when a model step begins.
1401
+ */
1402
+ readonly onStepStart?: GenerateTextOnStepStartCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>, NoInfer<RUNTIME_CONTEXT>, NoInfer<OUTPUT>>;
1403
+ /**
1404
+ * Called immediately before the harness begins emitting a model response.
1405
+ */
1406
+ readonly onLanguageModelCallStart?: OnLanguageModelCallStartCallback;
1407
+ /**
1408
+ * Called after a model response is complete and before its tool execution
1409
+ * lifecycle callbacks are delivered.
1410
+ */
1411
+ readonly onLanguageModelCallEnd?: OnLanguageModelCallEndCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>>;
1412
+ /**
1413
+ * Called before each harness or host tool execution is reported.
1414
+ */
1415
+ readonly onToolExecutionStart?: OnToolExecutionStartCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>>;
1416
+ /**
1417
+ * Called after each harness or host tool execution is reported.
1418
+ */
1419
+ readonly onToolExecutionEnd?: OnToolExecutionEndCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>>;
1420
+ /**
1421
+ * Called after each completed model step.
1422
+ */
1423
+ readonly onStepEnd?: GenerateTextOnStepEndCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>, NoInfer<RUNTIME_CONTEXT>>;
1424
+ /**
1425
+ * Called when an agent call completes successfully.
1426
+ */
1427
+ readonly onEnd?: GenerateTextOnEndCallback<NoInfer<HarnessAllTools<THarness, TUserTools>>, NoInfer<RUNTIME_CONTEXT>>;
1382
1428
  /**
1383
1429
  * Built-in tool permission mode. Defaults to `'allow-all'`, preserving the
1384
1430
  * existing bypass-permissions behavior unless users opt in.
@@ -1427,6 +1473,17 @@ type HarnessAgentSettings<THarness extends HarnessAgentAdapter<any> = HarnessAge
1427
1473
  readonly onLog?: (event: HarnessDiagnostic) => void;
1428
1474
  } & HarnessAgentToolFilteringSettings<HarnessAllTools<THarness, TUserTools>>;
1429
1475
 
1476
+ type HarnessAgentLifecycleCallbacks<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface> = {
1477
+ onStart?: GenerateTextOnStartCallback<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1478
+ onStepStart?: GenerateTextOnStepStartCallback<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1479
+ onLanguageModelCallStart?: OnLanguageModelCallStartCallback;
1480
+ onLanguageModelCallEnd?: OnLanguageModelCallEndCallback<TOOLS>;
1481
+ onToolExecutionStart?: OnToolExecutionStartCallback<TOOLS>;
1482
+ onToolExecutionEnd?: OnToolExecutionEndCallback<TOOLS>;
1483
+ onStepEnd?: GenerateTextOnStepEndCallback<TOOLS, RUNTIME_CONTEXT>;
1484
+ onEnd?: GenerateTextOnEndCallback<TOOLS, RUNTIME_CONTEXT>;
1485
+ };
1486
+
1430
1487
  type HarnessAgentTurnResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface> = {
1431
1488
  result: StreamTextResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1432
1489
  done: Promise<void>;
@@ -1501,6 +1558,7 @@ declare class HarnessAgentSession {
1501
1558
  responseFormat: HarnessV1ResponseFormat | undefined;
1502
1559
  output: OUTPUT | undefined;
1503
1560
  telemetry: TelemetryOptions | undefined;
1561
+ callbacks: HarnessAgentLifecycleCallbacks<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1504
1562
  stopConditions: ReadonlyArray<StopCondition<TOOLS, RUNTIME_CONTEXT>>;
1505
1563
  }): HarnessAgentTurnResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1506
1564
  continueTurn<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends OutputInterface>(options: {
@@ -1516,6 +1574,7 @@ declare class HarnessAgentSession {
1516
1574
  responseFormat: HarnessV1ResponseFormat | undefined;
1517
1575
  output: OUTPUT | undefined;
1518
1576
  telemetry: TelemetryOptions | undefined;
1577
+ callbacks: HarnessAgentLifecycleCallbacks<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
1519
1578
  stopConditions: ReadonlyArray<StopCondition<TOOLS, RUNTIME_CONTEXT>>;
1520
1579
  toolApprovalContinuations?: readonly ToolApprovalResponse[] | undefined;
1521
1580
  toolResultContinuations?: readonly ToolResultPart[] | undefined;
@@ -1654,6 +1713,7 @@ declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAg
1654
1713
  private readonly sandboxConfig;
1655
1714
  private readonly builtinToolFiltering;
1656
1715
  private readonly permissionMode;
1716
+ private readonly headers;
1657
1717
  constructor(settings: HarnessAgentSettings<THarness, TUserTools, RUNTIME_CONTEXT, OUTPUT, CALL_OPTIONS>);
1658
1718
  /** Identifier of the harness backing this agent. */
1659
1719
  get harnessId(): string;
@@ -1733,6 +1793,7 @@ declare class HarnessAgent<THarness extends HarnessAgentAdapter<any> = HarnessAg
1733
1793
  private _startPromptTurn;
1734
1794
  private _startContinueTurn;
1735
1795
  private _buildTurnOptions;
1796
+ private _resolveLifecycleCallbacks;
1736
1797
  private _resolveContinueTurnInput;
1737
1798
  private _resolvePromptTurnInput;
1738
1799
  private _preparePromptTurnInput;