@bluecopa/harness 0.1.0-snapshot.41 → 0.1.0-snapshot.42

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.41",
3
+ "version": "0.1.0-snapshot.42",
4
4
  "description": "Provider-agnostic TypeScript agent framework",
5
5
  "license": "UNLICENSED",
6
6
  "scripts": {
@@ -344,6 +344,26 @@ export class AgentRunner {
344
344
  const text = rawText || 'Done.';
345
345
  messages.push({ role: 'assistant', content: text });
346
346
 
347
+ // RunComplete hook: allow middleware to inspect and optionally continue
348
+ if (config.hookRunner) {
349
+ const decision = await config.hookRunner.run({
350
+ event: 'RunComplete',
351
+ metadata: {
352
+ messages,
353
+ steps: step + 1,
354
+ output: text,
355
+ },
356
+ });
357
+ if (!decision.allow) {
358
+ // Hook wants the agent to keep going — inject reason as user guidance
359
+ messages.push({
360
+ role: 'user',
361
+ content: decision.reason ?? 'Continue — a required post-completion step was not performed.',
362
+ });
363
+ continue; // re-enter the loop for one more LLM step
364
+ }
365
+ }
366
+
347
367
  // Structured output: use generateObject on terminal step when schema is set
348
368
  if (config.outputSchema) {
349
369
  try {
@@ -6,7 +6,8 @@ export type HookEventName =
6
6
  | 'SessionStart'
7
7
  | 'SessionEnd'
8
8
  | 'CompactionStart'
9
- | 'CompactionEnd';
9
+ | 'CompactionEnd'
10
+ | 'RunComplete';
10
11
 
11
12
  export interface HookContext {
12
13
  event: HookEventName;