@ai-sdk/harness 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 +30 -0
- package/agent/index.ts +2 -8
- package/dist/agent/index.d.ts +128 -48
- package/dist/agent/index.js +586 -512
- package/dist/agent/index.js.map +1 -1
- package/dist/bridge/index.d.ts +11 -1
- package/dist/bridge/index.js +37 -7
- package/dist/bridge/index.js.map +1 -1
- package/dist/index.d.ts +84 -2
- package/dist/index.js +286 -229
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +17 -3
- package/dist/utils/index.js +323 -19
- package/dist/utils/index.js.map +1 -1
- package/package.json +3 -3
- package/src/agent/harness-agent-session.ts +9 -8
- package/src/agent/harness-agent-settings.ts +82 -3
- package/src/agent/harness-agent-tool-approval-continuation.ts +6 -32
- package/src/agent/harness-agent-tool-result-continuation.ts +4 -53
- package/src/agent/harness-agent.ts +107 -18
- package/src/agent/internal/harness-stream-text-result.ts +33 -13
- package/src/agent/internal/run-prompt.ts +309 -122
- package/src/agent/internal/turn-telemetry.ts +293 -444
- package/src/bridge/index.ts +82 -11
- package/src/utils/index.ts +5 -0
- package/src/utils/write-instructions.ts +373 -0
- package/src/utils/write-skills.ts +59 -2
- package/src/v1/harness-v1-bridge-protocol.ts +1 -0
- package/src/v1/harness-v1-builtin-tool.ts +2 -0
- package/src/v1/harness-v1-lifecycle-state.ts +2 -0
- package/src/v1/harness-v1-prompt-control.ts +3 -0
- package/src/v1/harness-v1-questions-tool.ts +72 -0
- package/src/v1/harness-v1-session.ts +5 -0
- package/src/v1/index.ts +9 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DelayedPromise,
|
|
3
|
-
|
|
3
|
+
type InferToolSetContext,
|
|
4
4
|
type AssistantModelMessage,
|
|
5
5
|
type Context,
|
|
6
6
|
type ToolModelMessage,
|
|
@@ -154,9 +154,10 @@ export class HarnessStreamTextResult<
|
|
|
154
154
|
|
|
155
155
|
private readonly tools: TOOLS;
|
|
156
156
|
private readonly runtimeContext: RUNTIME_CONTEXT;
|
|
157
|
-
private readonly toolsContext:
|
|
157
|
+
private readonly toolsContext: InferToolSetContext<TOOLS>;
|
|
158
158
|
private readonly providerName: string;
|
|
159
|
-
private readonly
|
|
159
|
+
private readonly callId: string;
|
|
160
|
+
private modelId: string;
|
|
160
161
|
private readonly outputSpecification: OUTPUT | undefined;
|
|
161
162
|
|
|
162
163
|
// Accumulators that span the whole turn.
|
|
@@ -170,16 +171,18 @@ export class HarnessStreamTextResult<
|
|
|
170
171
|
constructor(options: {
|
|
171
172
|
tools: TOOLS;
|
|
172
173
|
runtimeContext: RUNTIME_CONTEXT;
|
|
173
|
-
toolsContext:
|
|
174
|
+
toolsContext: InferToolSetContext<TOOLS>;
|
|
174
175
|
harnessId: string;
|
|
175
|
-
|
|
176
|
+
callId: string;
|
|
177
|
+
modelId: string;
|
|
176
178
|
output: OUTPUT | undefined;
|
|
177
179
|
}) {
|
|
178
180
|
this.tools = options.tools;
|
|
179
181
|
this.runtimeContext = options.runtimeContext;
|
|
180
182
|
this.toolsContext = options.toolsContext;
|
|
181
183
|
this.providerName = `harness:${options.harnessId}`;
|
|
182
|
-
this.
|
|
184
|
+
this.callId = options.callId;
|
|
185
|
+
this.modelId = options.modelId;
|
|
183
186
|
this.outputSpecification = options.output;
|
|
184
187
|
|
|
185
188
|
let controllerRef!: ReadableStreamDefaultController<TextStreamPart<TOOLS>>;
|
|
@@ -224,6 +227,12 @@ export class HarnessStreamTextResult<
|
|
|
224
227
|
this.appendToCurrentStepContent(part);
|
|
225
228
|
}
|
|
226
229
|
|
|
230
|
+
setModelId(modelId: string): void {
|
|
231
|
+
if (this.stepsBuffer.length === 0) {
|
|
232
|
+
this.modelId = modelId;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
227
236
|
/**
|
|
228
237
|
* Push a continuation input into the consumer stream without attributing it
|
|
229
238
|
* to the next model step. Approval responses and client tool results arrive
|
|
@@ -262,7 +271,7 @@ export class HarnessStreamTextResult<
|
|
|
262
271
|
const rawFinishReason = input.finishReason.raw;
|
|
263
272
|
|
|
264
273
|
const step = new DefaultStepResult<TOOLS, RUNTIME_CONTEXT>({
|
|
265
|
-
callId:
|
|
274
|
+
callId: this.callId,
|
|
266
275
|
stepNumber: this.stepNumber,
|
|
267
276
|
provider: this.providerName,
|
|
268
277
|
modelId: this.modelId,
|
|
@@ -276,7 +285,7 @@ export class HarnessStreamTextResult<
|
|
|
276
285
|
warnings: input.warnings.length > 0 ? input.warnings : undefined,
|
|
277
286
|
request: {},
|
|
278
287
|
response: {
|
|
279
|
-
id:
|
|
288
|
+
id: `${this.callId}-${this.stepNumber}`,
|
|
280
289
|
timestamp: new Date(),
|
|
281
290
|
modelId: this.modelId,
|
|
282
291
|
messages: [],
|
|
@@ -363,7 +372,7 @@ export class HarnessStreamTextResult<
|
|
|
363
372
|
this.stepsBuffer.length > 0
|
|
364
373
|
? this.stepsBuffer[this.stepsBuffer.length - 1]!
|
|
365
374
|
: new DefaultStepResult<TOOLS, RUNTIME_CONTEXT>({
|
|
366
|
-
callId:
|
|
375
|
+
callId: this.callId,
|
|
367
376
|
stepNumber: 0,
|
|
368
377
|
provider: this.providerName,
|
|
369
378
|
modelId: this.modelId,
|
|
@@ -377,7 +386,7 @@ export class HarnessStreamTextResult<
|
|
|
377
386
|
warnings: undefined,
|
|
378
387
|
request: {},
|
|
379
388
|
response: {
|
|
380
|
-
id:
|
|
389
|
+
id: `${this.callId}-0`,
|
|
381
390
|
timestamp: new Date(),
|
|
382
391
|
modelId: this.modelId,
|
|
383
392
|
messages: [],
|
|
@@ -823,6 +832,19 @@ export class HarnessStreamTextResult<
|
|
|
823
832
|
}
|
|
824
833
|
return;
|
|
825
834
|
}
|
|
835
|
+
case 'reasoning-delta': {
|
|
836
|
+
const last =
|
|
837
|
+
this.currentStepContent[this.currentStepContent.length - 1];
|
|
838
|
+
if (last && last.type === 'reasoning') {
|
|
839
|
+
(last as { text: string }).text += part.text;
|
|
840
|
+
} else {
|
|
841
|
+
this.currentStepContent.push({
|
|
842
|
+
type: 'reasoning',
|
|
843
|
+
text: part.text,
|
|
844
|
+
} as ContentPart<TOOLS>);
|
|
845
|
+
}
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
826
848
|
case 'tool-call':
|
|
827
849
|
case 'tool-approval-request':
|
|
828
850
|
case 'tool-approval-response':
|
|
@@ -833,9 +855,7 @@ export class HarnessStreamTextResult<
|
|
|
833
855
|
} as ContentPart<TOOLS>);
|
|
834
856
|
return;
|
|
835
857
|
default:
|
|
836
|
-
//
|
|
837
|
-
// not directly stored as ContentParts. (Reasoning content parts
|
|
838
|
-
// would belong here; we omit them for v0.)
|
|
858
|
+
// Boundary, raw, error, and finish parts are not ContentParts.
|
|
839
859
|
return;
|
|
840
860
|
}
|
|
841
861
|
}
|