@hmharness/kernel 0.23.8 → 0.23.10

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.
@@ -15,6 +15,15 @@ export interface ChatResponse {
15
15
  };
16
16
  }
17
17
  export type DeltaKind = 'text' | 'reasoning' | 'reset';
18
+ /** Permanent provider-side auth/payment failures: 401 (bad key), 402
19
+ * (balance exhausted), 403 (forbidden). These fail EVERY subsequent task
20
+ * identically, so task queues must stop draining when one lands - burning
21
+ * the whole queue into the same 402 marks N tasks failed for one unpaid
22
+ * bill. Frontends keep the queued items and let the user fix the cause.
23
+ * Matches both throw shapes: the direct `provider: HTTP 402: ...` and the
24
+ * retry-exhaustion wrapper `provider: failed after N attempts (...): HTTP
25
+ * 402 ...`; the `provider:` anchor keeps unrelated tool errors out. */
26
+ export declare function isProviderAuthError(msg: string): boolean;
18
27
  /** Parse a Retry-After header into a delay in ms (MDN: exactly two legal
19
28
  * forms - delta-seconds or HTTP-date), clamped to [0, 120s]. Returns 0 when
20
29
  * absent/illegal (caller falls back to exponential backoff). Deliberately
package/dist/provider.js CHANGED
@@ -14,6 +14,17 @@ function transientHint(msg) {
14
14
  return ' - the provider endpoint was unreachable (network/DNS)';
15
15
  return '';
16
16
  }
17
+ /** Permanent provider-side auth/payment failures: 401 (bad key), 402
18
+ * (balance exhausted), 403 (forbidden). These fail EVERY subsequent task
19
+ * identically, so task queues must stop draining when one lands - burning
20
+ * the whole queue into the same 402 marks N tasks failed for one unpaid
21
+ * bill. Frontends keep the queued items and let the user fix the cause.
22
+ * Matches both throw shapes: the direct `provider: HTTP 402: ...` and the
23
+ * retry-exhaustion wrapper `provider: failed after N attempts (...): HTTP
24
+ * 402 ...`; the `provider:` anchor keeps unrelated tool errors out. */
25
+ export function isProviderAuthError(msg) {
26
+ return /provider:[\s\S]*HTTP 40[123]\b/.test(msg);
27
+ }
17
28
  /** Parse a Retry-After header into a delay in ms (MDN: exactly two legal
18
29
  * forms - delta-seconds or HTTP-date), clamped to [0, 120s]. Returns 0 when
19
30
  * absent/illegal (caller falls back to exponential backoff). Deliberately
package/dist/session.d.ts CHANGED
@@ -19,6 +19,7 @@ export type SessionEvent = {
19
19
  time: string;
20
20
  text: string | null;
21
21
  tool_calls?: unknown[];
22
+ model?: string;
22
23
  } | {
23
24
  t: 'tool';
24
25
  time: string;
@@ -59,7 +60,9 @@ export declare class Session {
59
60
  static resume(home: string, idOrFile: string): Promise<Session | null>;
60
61
  append(event: SessionEvent): Promise<void>;
61
62
  user(text: string): Promise<void>;
62
- assistant(text: string | null, toolCalls?: unknown[]): Promise<void>;
63
+ /** `model` (when known) lands on the event so mid-session route switches
64
+ * stay auditable - the rollout is the record of WHO said WHAT. */
65
+ assistant(text: string | null, toolCalls?: unknown[], model?: string): Promise<void>;
63
66
  tool(name: string, output: string, isError: boolean): Promise<void>;
64
67
  approval(tool: string, granted: boolean): Promise<void>;
65
68
  final(text: string, turns: number, toolUses: number): Promise<void>;
package/dist/session.js CHANGED
@@ -121,8 +121,10 @@ export class Session {
121
121
  user(text) {
122
122
  return this.append({ t: 'user', time: new Date().toISOString(), text });
123
123
  }
124
- assistant(text, toolCalls) {
125
- return this.append({ t: 'assistant', time: new Date().toISOString(), text, ...(toolCalls ? { tool_calls: toolCalls } : {}) });
124
+ /** `model` (when known) lands on the event so mid-session route switches
125
+ * stay auditable - the rollout is the record of WHO said WHAT. */
126
+ assistant(text, toolCalls, model) {
127
+ return this.append({ t: 'assistant', time: new Date().toISOString(), text, ...(toolCalls ? { tool_calls: toolCalls } : {}), ...(model ? { model } : {}) });
126
128
  }
127
129
  tool(name, output, isError) {
128
130
  return this.append({ t: 'tool', time: new Date().toISOString(), name, output, isError });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/kernel",
3
- "version": "0.23.8",
3
+ "version": "0.23.10",
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",