@inflexa-ai/harness 0.36.4 → 0.38.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.
Files changed (96) hide show
  1. package/README.md +1 -2
  2. package/dist/auth/local-run-authorizer.js +5 -4
  3. package/dist/auth/types.d.ts +28 -9
  4. package/dist/auth/types.js +5 -3
  5. package/dist/billing/noop-run-charge.js +3 -2
  6. package/dist/billing/noop-usage-recorder.js +2 -1
  7. package/dist/billing/run-charge.d.ts +18 -5
  8. package/dist/billing/run-charge.js +5 -1
  9. package/dist/billing/usage-recorder.d.ts +11 -9
  10. package/dist/billing/usage-recorder.js +2 -3
  11. package/dist/contracts/chat-events.d.ts +4 -1
  12. package/dist/contracts/chat-parts.d.ts +1 -1
  13. package/dist/contracts/message.d.ts +15 -0
  14. package/dist/contracts/schemas/chat-parts.d.ts +4 -4
  15. package/dist/execution/artifact-registration.d.ts +6 -1
  16. package/dist/execution/artifact-registration.js +12 -4
  17. package/dist/execution/artifact-registry.d.ts +10 -3
  18. package/dist/execution/noop-artifact-registry.js +3 -4
  19. package/dist/execution/post-step-pipeline.d.ts +14 -3
  20. package/dist/execution/post-step-pipeline.js +21 -8
  21. package/dist/execution/run-authorizer.d.ts +5 -3
  22. package/dist/execution/run-canceler.js +4 -20
  23. package/dist/index.d.ts +13 -7
  24. package/dist/index.js +12 -6
  25. package/dist/lib/hooks.d.ts +49 -0
  26. package/dist/lib/hooks.js +39 -0
  27. package/dist/lib/result.d.ts +22 -11
  28. package/dist/lib/result.js +24 -14
  29. package/dist/loop/run-agent.d.ts +2 -2
  30. package/dist/loop/run-agent.js +5 -4
  31. package/dist/memory/conversation-display-replay.js +14 -1
  32. package/dist/memory/thread-history.d.ts +24 -0
  33. package/dist/memory/thread-history.js +19 -6
  34. package/dist/provenance/seam.d.ts +1 -1
  35. package/dist/providers/ai-sdk.d.ts +43 -5
  36. package/dist/providers/ai-sdk.js +55 -52
  37. package/dist/providers/anthropic.d.ts +2 -3
  38. package/dist/providers/anthropic.js +2 -2
  39. package/dist/providers/embedding.d.ts +13 -7
  40. package/dist/providers/embedding.js +26 -6
  41. package/dist/providers/errors.d.ts +67 -37
  42. package/dist/providers/errors.js +57 -58
  43. package/dist/providers/request-headers.d.ts +18 -0
  44. package/dist/providers/request-headers.js +22 -0
  45. package/dist/report-model/production-resolver.d.ts +5 -2
  46. package/dist/report-model/production-resolver.js +12 -2
  47. package/dist/runtime/assemble.d.ts +3 -2
  48. package/dist/runtime/dbos.d.ts +4 -3
  49. package/dist/runtime/dbos.js +18 -3
  50. package/dist/runtime/result-serialization.d.ts +29 -0
  51. package/dist/runtime/result-serialization.js +45 -0
  52. package/dist/sandbox/client.d.ts +11 -3
  53. package/dist/sandbox/create-sandbox.d.ts +5 -2
  54. package/dist/sandbox/create-sandbox.js +51 -25
  55. package/dist/sandbox/docker-client.d.ts +4 -3
  56. package/dist/sandbox/docker-client.js +23 -31
  57. package/dist/sandbox/k8s-client.d.ts +4 -13
  58. package/dist/sandbox/k8s-client.js +28 -61
  59. package/dist/sandbox/labels.d.ts +34 -0
  60. package/dist/sandbox/labels.js +47 -0
  61. package/dist/sandbox/mount-plan.d.ts +3 -1
  62. package/dist/sandbox/mount-plan.js +9 -0
  63. package/dist/sandbox/sandbox-error.d.ts +36 -13
  64. package/dist/sandbox/sandbox-error.js +32 -17
  65. package/dist/sandbox/types.d.ts +13 -9
  66. package/dist/schemas/validate-plan.js +13 -0
  67. package/dist/schemas/workflow-state.d.ts +4 -4
  68. package/dist/state/analyses.d.ts +4 -4
  69. package/dist/state/analyses.js +4 -4
  70. package/dist/state/init.js +11 -0
  71. package/dist/state/schema.d.ts +5 -5
  72. package/dist/tasks/data-profile.d.ts +5 -8
  73. package/dist/tasks/data-profile.js +88 -43
  74. package/dist/tasks/derive-table-exec.d.ts +10 -6
  75. package/dist/tasks/derive-table-exec.js +17 -12
  76. package/dist/tasks/extract-values.d.ts +16 -10
  77. package/dist/tasks/extract-values.js +34 -18
  78. package/dist/tools/execute-analysis.js +22 -15
  79. package/dist/tools/report-session/derive-table.d.ts +9 -1
  80. package/dist/tools/report-session/derive-table.js +25 -22
  81. package/dist/tools/research/inspect-run.d.ts +1 -1
  82. package/dist/workflows/execute-analysis.d.ts +25 -16
  83. package/dist/workflows/execute-analysis.js +223 -216
  84. package/dist/workflows/metrics.d.ts +4 -3
  85. package/dist/workflows/metrics.js +4 -3
  86. package/dist/workflows/sandbox-step.d.ts +20 -29
  87. package/dist/workflows/sandbox-step.js +71 -127
  88. package/dist/workflows/suspension.d.ts +32 -0
  89. package/dist/workflows/suspension.js +38 -0
  90. package/package.json +1 -1
  91. package/dist/billing/noop-resolver.d.ts +0 -6
  92. package/dist/billing/noop-resolver.js +0 -7
  93. package/dist/billing/resolver.d.ts +0 -64
  94. package/dist/billing/resolver.js +0 -24
  95. package/dist/loop/budget-exceeded.d.ts +0 -38
  96. package/dist/loop/budget-exceeded.js +0 -88
@@ -1,38 +0,0 @@
1
- /**
2
- * HTTP 402 `budget_exceeded` classifier.
3
- *
4
- * Detects when an LLM call failed because the billing gateway reported the
5
- * caller's budget was exhausted. This is NOT a transient error — retrying
6
- * is wasteful because every subsequent call charged to the same budget will
7
- * also fail until the user tops up.
8
- *
9
- * Classification order (first hit wins), and the order is load-bearing:
10
- * 1. Structured `statusCode === 402` (or `status === 402`) on any
11
- * link of the cause chain. The gateway emits 402 exclusively for
12
- * `budget_exceeded`, so a structured 402 is unambiguous.
13
- * 2. A `ProviderError` on the value or its cause chain that was decided on
14
- * a status: its `type` answers, and the text patterns are skipped.
15
- * 3. Pattern fallback: `/budget.?exceeded/i` on the stringified
16
- * top-level error message. Covers stringified throws and paths
17
- * where no `statusCode` is attached (ops scripts, sandbox-server
18
- * surfacing upstream billing errors as text).
19
- *
20
- * Step 2 exists because the text heuristic must never outrank a real
21
- * classification. A `ProviderError` message carries an excerpt of the provider's
22
- * response body, so a non-retryable 400 whose body merely mentions a budget would
23
- * otherwise match step 3 — and the callers of this predicate act on it fatally
24
- * (`sandbox-step` self-cancels the workflow, `execute-analysis` re-raises it as a
25
- * budget throw). A phrase inside a quoted body is not evidence against the status
26
- * the failure actually carried.
27
- *
28
- * "Decided on a status" is the load-bearing qualifier. `toProviderError` wraps
29
- * every throwable, including ones `classifyProviderError` had no status for — it
30
- * returns `provider` as a fall-through default there, which is an absence of
31
- * classification, not a determination. Treating that as authoritative would
32
- * silence step 3 in precisely the case it was written for.
33
- *
34
- * Returns `false` for all other errors. Safe to call with any value;
35
- * non-Error inputs hit the stringified-pattern branch and return `false`
36
- * unless the string happens to match.
37
- */
38
- export declare function isBudgetExceeded(err: unknown): boolean;
@@ -1,88 +0,0 @@
1
- /**
2
- * HTTP 402 `budget_exceeded` classifier.
3
- *
4
- * Detects when an LLM call failed because the billing gateway reported the
5
- * caller's budget was exhausted. This is NOT a transient error — retrying
6
- * is wasteful because every subsequent call charged to the same budget will
7
- * also fail until the user tops up.
8
- *
9
- * Classification order (first hit wins), and the order is load-bearing:
10
- * 1. Structured `statusCode === 402` (or `status === 402`) on any
11
- * link of the cause chain. The gateway emits 402 exclusively for
12
- * `budget_exceeded`, so a structured 402 is unambiguous.
13
- * 2. A `ProviderError` on the value or its cause chain that was decided on
14
- * a status: its `type` answers, and the text patterns are skipped.
15
- * 3. Pattern fallback: `/budget.?exceeded/i` on the stringified
16
- * top-level error message. Covers stringified throws and paths
17
- * where no `statusCode` is attached (ops scripts, sandbox-server
18
- * surfacing upstream billing errors as text).
19
- *
20
- * Step 2 exists because the text heuristic must never outrank a real
21
- * classification. A `ProviderError` message carries an excerpt of the provider's
22
- * response body, so a non-retryable 400 whose body merely mentions a budget would
23
- * otherwise match step 3 — and the callers of this predicate act on it fatally
24
- * (`sandbox-step` self-cancels the workflow, `execute-analysis` re-raises it as a
25
- * budget throw). A phrase inside a quoted body is not evidence against the status
26
- * the failure actually carried.
27
- *
28
- * "Decided on a status" is the load-bearing qualifier. `toProviderError` wraps
29
- * every throwable, including ones `classifyProviderError` had no status for — it
30
- * returns `provider` as a fall-through default there, which is an absence of
31
- * classification, not a determination. Treating that as authoritative would
32
- * silence step 3 in precisely the case it was written for.
33
- *
34
- * Returns `false` for all other errors. Safe to call with any value;
35
- * non-Error inputs hit the stringified-pattern branch and return `false`
36
- * unless the string happens to match.
37
- */
38
- import { extractStatus, isProviderError } from "../providers/errors.js";
39
- const BUDGET_EXCEEDED_PATTERNS = [/budget.?exceeded/i];
40
- /** Max depth walked on the cause chain looking for a structured statusCode. */
41
- const MAX_CAUSE_HOPS = 5;
42
- function hasStatus402(err) {
43
- let cursor = err;
44
- for (let i = 0; i < MAX_CAUSE_HOPS && cursor; i++) {
45
- const e = cursor;
46
- const code = e.statusCode ?? e.status;
47
- if (code === 402)
48
- return true;
49
- cursor = e.cause;
50
- }
51
- return false;
52
- }
53
- /**
54
- * Find a `ProviderError` on the value or its cause chain. A `ResultError`
55
- * thrown at a step boundary carries the structured value on `.cause`, which is
56
- * the shape the callers of this predicate actually catch.
57
- */
58
- function findProviderError(err) {
59
- let cursor = err;
60
- for (let i = 0; i < MAX_CAUSE_HOPS && cursor; i++) {
61
- if (isProviderError(cursor))
62
- return cursor;
63
- cursor = cursor.cause;
64
- }
65
- return undefined;
66
- }
67
- export function isBudgetExceeded(err) {
68
- if (hasStatus402(err))
69
- return true;
70
- const classified = findProviderError(err);
71
- if (classified) {
72
- if (classified.type === "budget")
73
- return true;
74
- // `auth` and `tenant-blocked` exist only because a status produced them, and
75
- // a `provider` arm that carried a status was decided on it. None can be
76
- // overturned by a phrase inside a response body the message merely quotes.
77
- //
78
- // A `provider` arm with NO status is the one exception: there
79
- // `classifyProviderError` had nothing to key on and applied a fall-through
80
- // default, so it made no determination to respect. That is exactly the shape
81
- // a gateway reporting `budget_exceeded` as plain text arrives in, and the
82
- // patterns below are the reason it is still caught.
83
- if (classified.type !== "provider" || extractStatus(classified) !== undefined)
84
- return false;
85
- }
86
- const msg = err instanceof Error ? err.message : String(err ?? "");
87
- return BUDGET_EXCEEDED_PATTERNS.some((p) => p.test(msg));
88
- }