@hmharness/kernel 0.6.8 → 0.7.0

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/dist/loop.d.ts CHANGED
@@ -24,6 +24,9 @@ export interface LoopResult {
24
24
  promptTokens: number;
25
25
  completionTokens: number;
26
26
  };
27
+ /** Why the loop stopped: final answer, idle detection, a safety valve, or
28
+ * user interrupt - trajectory outcomes (M1) and UI labels consume it. */
29
+ reason: 'final' | 'idle' | 'turn-valve' | 'token-valve' | 'interrupted';
27
30
  }
28
31
  export declare function runLoop(opts: {
29
32
  provider: ProviderConfig;
package/dist/loop.js CHANGED
@@ -90,7 +90,7 @@ export async function runLoop(opts) {
90
90
  if (calls.length === 0) {
91
91
  const text = message.content ?? '';
92
92
  events?.onFinal?.(text, turn);
93
- return { text, turns: turn, toolUses, messages: working, usage };
93
+ return { text, turns: turn, toolUses, messages: working, usage, reason: 'final' };
94
94
  }
95
95
  working.push({ role: 'assistant', content: message.content ?? null, tool_calls: calls });
96
96
  const planned = [];
@@ -180,5 +180,5 @@ export async function runLoop(opts) {
180
180
  ? `Turn limit reached (${executedTurns} turns). The session is preserved — send another message to continue.`
181
181
  : `Token budget limit reached (~${usage.promptTokens + usage.completionTokens} tokens). The session is preserved — send another message to continue.`;
182
182
  events?.onFinal?.(text, executedTurns);
183
- return { text, turns: executedTurns, toolUses, messages: working, usage };
183
+ return { text, turns: executedTurns, toolUses, messages: working, usage, reason };
184
184
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/kernel",
3
- "version": "0.6.8",
3
+ "version": "0.7.0",
4
4
  "description": "hmharness kernel: tool registry, provider adapters, the agent loop, session log, config. Zero runtime dependencies (Node >=22 native fetch).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",