@ai-sdk/harness-deepagents 1.0.100 → 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-deepagents
2
2
 
3
+ ## 1.0.102
4
+
5
+ ### Patch Changes
6
+
7
+ - eeed977: feat(harness): allow passing arbitrary headers with inference requests via `headers` property in `HarnessAgentSettings`
8
+ - a39c8bf: chore(harness): clarify `writeSkills` helper intent to require materializing skills in HOME directory
9
+ - Updated dependencies [fe86f8f]
10
+ - Updated dependencies [255cccf]
11
+ - Updated dependencies [eeed977]
12
+ - Updated dependencies [a39c8bf]
13
+ - @ai-sdk/harness@1.0.102
14
+
15
+ ## 1.0.101
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [951c54d]
20
+ - @ai-sdk/harness@1.0.101
21
+
3
22
  ## 1.0.100
4
23
 
5
24
  ### Patch Changes
@@ -218,6 +218,7 @@ async function runBridge(options) {
218
218
  }
219
219
  }
220
220
  const pendingToolResults = /* @__PURE__ */ new Map();
221
+ const bufferedToolResults = [];
221
222
  const pendingToolApprovals = /* @__PURE__ */ new Map();
222
223
  const writeBridgeMeta = async (state) => {
223
224
  try {
@@ -397,9 +398,23 @@ async function runBridge(options) {
397
398
  const userMessages = createBridgeUserMessageQueue({ respond: emit });
398
399
  const turn = {
399
400
  emit,
400
- requestToolResult: (toolCallId) => new Promise((resolve) => {
401
- pendingToolResults.set(toolCallId, resolve);
402
- }),
401
+ requestToolResult: (requestInput) => {
402
+ const request = typeof requestInput === "string" ? { toolCallId: requestInput } : requestInput;
403
+ const bufferedIndex = bufferedToolResults.findIndex(
404
+ (buffered) => buffered.toolCallId === request.toolCallId || request.matches?.(buffered.result) === true
405
+ );
406
+ if (bufferedIndex >= 0) {
407
+ return Promise.resolve(
408
+ bufferedToolResults.splice(bufferedIndex, 1)[0].result
409
+ );
410
+ }
411
+ return new Promise((resolve) => {
412
+ pendingToolResults.set(request.toolCallId, {
413
+ resolve,
414
+ matches: request.matches
415
+ });
416
+ });
417
+ },
403
418
  requestToolApproval: (approvalId) => new Promise((resolve) => {
404
419
  pendingToolApprovals.set(approvalId, resolve);
405
420
  }),
@@ -441,10 +456,25 @@ async function runBridge(options) {
441
456
  return;
442
457
  }
443
458
  case "tool-result": {
444
- const resolver = pendingToolResults.get(msg.toolCallId);
445
- if (resolver) {
446
- pendingToolResults.delete(msg.toolCallId);
447
- resolver({ output: msg.output, isError: msg.isError });
459
+ const result = {
460
+ output: msg.output,
461
+ isError: msg.isError,
462
+ toolResult: msg.toolResult
463
+ };
464
+ const exactPending = pendingToolResults.get(msg.toolCallId);
465
+ const matchingPending = exactPending == null ? Array.from(pendingToolResults.entries()).find(
466
+ ([, pending2]) => pending2.matches?.(result) === true
467
+ ) : void 0;
468
+ const pending = exactPending ?? matchingPending?.[1];
469
+ const pendingId = exactPending != null ? msg.toolCallId : matchingPending?.[0];
470
+ if (pending != null && pendingId != null) {
471
+ pendingToolResults.delete(pendingId);
472
+ pending.resolve(result);
473
+ } else {
474
+ bufferedToolResults.push({
475
+ toolCallId: msg.toolCallId,
476
+ result
477
+ });
448
478
  }
449
479
  return;
450
480
  }
@@ -2105,7 +2135,8 @@ function parseArgs(rawArgs) {
2105
2135
  function buildModel({
2106
2136
  rawModel,
2107
2137
  thinking,
2108
- effort
2138
+ effort,
2139
+ headers
2109
2140
  }) {
2110
2141
  if (!rawModel) return void 0;
2111
2142
  const baseUrl = procEnv2.ANTHROPIC_BASE_URL;
@@ -2116,11 +2147,14 @@ function buildModel({
2116
2147
  ...effort ? { outputConfig: { effort } } : {},
2117
2148
  ...procEnv2.ANTHROPIC_API_KEY ? { apiKey: procEnv2.ANTHROPIC_API_KEY } : {},
2118
2149
  ...baseUrl ? { anthropicApiUrl: baseUrl } : {},
2119
- ...procEnv2.AI_GATEWAY_API_KEY && HARNESS_CLIENT_APP ? {
2150
+ ...headers != null || procEnv2.AI_GATEWAY_API_KEY ? {
2120
2151
  clientOptions: {
2121
2152
  defaultHeaders: {
2122
- "User-Agent": HARNESS_CLIENT_APP,
2123
- "x-client-app": HARNESS_CLIENT_APP
2153
+ ...headers,
2154
+ ...procEnv2.AI_GATEWAY_API_KEY && HARNESS_CLIENT_APP ? {
2155
+ "User-Agent": HARNESS_CLIENT_APP,
2156
+ "x-client-app": HARNESS_CLIENT_APP
2157
+ } : {}
2124
2158
  }
2125
2159
  }
2126
2160
  } : {}
@@ -2130,14 +2164,15 @@ function createModelMiddleware() {
2130
2164
  return createMiddleware({
2131
2165
  name: "harnessModel",
2132
2166
  wrapModelCall: async (request, handler) => {
2133
- if (!activeModel && !activeThinking && !activeEffort) {
2167
+ if (!activeModel && !activeThinking && !activeEffort && !activeHeaders) {
2134
2168
  return handler(request);
2135
2169
  }
2136
2170
  if (activeModel) {
2137
2171
  const configuredModel2 = buildModel({
2138
2172
  rawModel: activeModel,
2139
2173
  thinking: activeThinking,
2140
- effort: activeEffort
2174
+ effort: activeEffort,
2175
+ headers: activeHeaders
2141
2176
  });
2142
2177
  if (!configuredModel2) throw new Error("Deep Agents model is missing");
2143
2178
  return handler({ ...request, model: configuredModel2 });
@@ -2152,7 +2187,8 @@ function createModelMiddleware() {
2152
2187
  const configuredModel = buildModel({
2153
2188
  rawModel: model.model,
2154
2189
  thinking: activeThinking,
2155
- effort: activeEffort
2190
+ effort: activeEffort,
2191
+ headers: activeHeaders
2156
2192
  });
2157
2193
  if (!configuredModel) throw new Error("Deep Agents model is missing");
2158
2194
  return handler({ ...request, model: configuredModel });
@@ -2185,6 +2221,7 @@ var agentConfigurationSignature;
2185
2221
  var activeModel;
2186
2222
  var activeThinking;
2187
2223
  var activeEffort;
2224
+ var activeHeaders;
2188
2225
  var modelMiddleware = createModelMiddleware();
2189
2226
  var responseFormatMiddleware = createMiddleware({
2190
2227
  name: "HarnessResponseFormat",
@@ -2225,6 +2262,7 @@ async function runTurn(start, turn) {
2225
2262
  if (start.model) activeModel = start.model;
2226
2263
  activeThinking = start.thinking;
2227
2264
  activeEffort = start.effort;
2265
+ activeHeaders = start.headers;
2228
2266
  currentResponseFormat = start.responseFormat?.type === "json" && start.responseFormat.schema != null ? toolStrategy(start.responseFormat.schema) : void 0;
2229
2267
  const emit = (event) => turn.emit(event);
2230
2268
  const interruptOn = buildInterruptOn(