@bluecopa/harness 0.1.0-snapshot.50 → 0.1.0-snapshot.51

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluecopa/harness",
3
- "version": "0.1.0-snapshot.50",
3
+ "version": "0.1.0-snapshot.51",
4
4
  "description": "Provider-agnostic TypeScript agent framework",
5
5
  "license": "UNLICENSED",
6
6
  "scripts": {
@@ -565,6 +565,50 @@ export class AgentRunner {
565
565
  }
566
566
  }
567
567
 
568
+ // RunComplete hook at maxSteps boundary (e.g., enforce DownloadRawFile even if loop exhausted)
569
+ if (config.hookRunner) {
570
+ const decision = await config.hookRunner.run({
571
+ event: 'RunComplete',
572
+ metadata: { messages, steps: config.maxSteps, output: 'max steps reached' },
573
+ });
574
+ if (!decision.allow) {
575
+ messages.push({ role: 'user', content: decision.reason ?? 'Continue — a required post-completion step was not performed.' });
576
+ // One extra step to satisfy the hook
577
+ const extra = await (generateText as any)({
578
+ model: (config.createModel ?? defaultAnthropicProvider)(config.model),
579
+ tools: normalizeTools(effectiveTools),
580
+ messages: toModelMessages(messages),
581
+ system: cachedSystem,
582
+ abortSignal: config.signal,
583
+ });
584
+ const extraCalls: Array<{ toolName: string; input: Record<string, unknown>; toolCallId?: string }> =
585
+ extra.toolCalls ?? [];
586
+ if (extraCalls.length > 0) {
587
+ const tc = extraCalls[0]!;
588
+ const info: ToolCallInfo = {
589
+ toolCallId: (tc as any).toolCallId ?? randomUUID(),
590
+ toolName: tc.toolName,
591
+ args: tc.input ?? {},
592
+ };
593
+ messages.push({ role: 'assistant', content: '', toolCalls: [info] });
594
+ const toolResult = await executeTool(
595
+ { name: tc.toolName, args: tc.input ?? {} },
596
+ config.toolProvider,
597
+ {
598
+ ...(config.executeToolAction != null ? { executeToolAction: config.executeToolAction } : {}),
599
+ ...(config.hookRunner != null ? { hookRunner: config.hookRunner } : {}),
600
+ ...(config.downloadRawFile != null ? { downloadRawFile: config.downloadRawFile } : {}),
601
+ },
602
+ );
603
+ messages.push({
604
+ role: 'tool',
605
+ content: toolResult.output,
606
+ toolResults: [{ toolCallId: info.toolCallId, toolName: tc.toolName, result: toolResult.output, isError: !toolResult.success }],
607
+ });
608
+ }
609
+ }
610
+ }
611
+
568
612
  return { messages, output: 'max steps reached', steps: config.maxSteps };
569
613
  }
570
614
  }