@aid-framework/runtime 0.0.0 → 0.1.48

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 (188) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +183 -0
  3. package/dist/.tsbuildinfo +1 -0
  4. package/dist/agents/deep_agents.d.ts +78 -0
  5. package/dist/agents/deep_agents.d.ts.map +1 -0
  6. package/dist/agents/deep_agents.js +477 -0
  7. package/dist/agents/deep_agents.js.map +1 -0
  8. package/dist/agents/engine.d.ts +85 -0
  9. package/dist/agents/engine.d.ts.map +1 -0
  10. package/dist/agents/engine.js +129 -0
  11. package/dist/agents/engine.js.map +1 -0
  12. package/dist/agents/gateway_chat_model.d.ts +151 -0
  13. package/dist/agents/gateway_chat_model.d.ts.map +1 -0
  14. package/dist/agents/gateway_chat_model.js +350 -0
  15. package/dist/agents/gateway_chat_model.js.map +1 -0
  16. package/dist/agents/guardrail_middleware.d.ts +57 -0
  17. package/dist/agents/guardrail_middleware.d.ts.map +1 -0
  18. package/dist/agents/guardrail_middleware.js +85 -0
  19. package/dist/agents/guardrail_middleware.js.map +1 -0
  20. package/dist/agents/guardrails.d.ts +124 -0
  21. package/dist/agents/guardrails.d.ts.map +1 -0
  22. package/dist/agents/guardrails.js +336 -0
  23. package/dist/agents/guardrails.js.map +1 -0
  24. package/dist/agents/index.d.ts +15 -0
  25. package/dist/agents/index.d.ts.map +1 -0
  26. package/dist/agents/index.js +15 -0
  27. package/dist/agents/index.js.map +1 -0
  28. package/dist/agents/ir.d.ts +144 -0
  29. package/dist/agents/ir.d.ts.map +1 -0
  30. package/dist/agents/ir.js +513 -0
  31. package/dist/agents/ir.js.map +1 -0
  32. package/dist/agents/loop.d.ts +145 -0
  33. package/dist/agents/loop.d.ts.map +1 -0
  34. package/dist/agents/loop.js +1025 -0
  35. package/dist/agents/loop.js.map +1 -0
  36. package/dist/agents/memory.d.ts +115 -0
  37. package/dist/agents/memory.d.ts.map +1 -0
  38. package/dist/agents/memory.js +258 -0
  39. package/dist/agents/memory.js.map +1 -0
  40. package/dist/agents/state.d.ts +137 -0
  41. package/dist/agents/state.d.ts.map +1 -0
  42. package/dist/agents/state.js +255 -0
  43. package/dist/agents/state.js.map +1 -0
  44. package/dist/concurrency.d.ts +36 -0
  45. package/dist/concurrency.d.ts.map +1 -0
  46. package/dist/concurrency.js +86 -0
  47. package/dist/concurrency.js.map +1 -0
  48. package/dist/control.d.ts +116 -0
  49. package/dist/control.d.ts.map +1 -0
  50. package/dist/control.js +281 -0
  51. package/dist/control.js.map +1 -0
  52. package/dist/cost.d.ts +95 -0
  53. package/dist/cost.d.ts.map +1 -0
  54. package/dist/cost.js +161 -0
  55. package/dist/cost.js.map +1 -0
  56. package/dist/errors.d.ts +213 -0
  57. package/dist/errors.d.ts.map +1 -0
  58. package/dist/errors.js +316 -0
  59. package/dist/errors.js.map +1 -0
  60. package/dist/evals/dataset.d.ts +45 -0
  61. package/dist/evals/dataset.d.ts.map +1 -0
  62. package/dist/evals/dataset.js +147 -0
  63. package/dist/evals/dataset.js.map +1 -0
  64. package/dist/evals/gate.d.ts +236 -0
  65. package/dist/evals/gate.d.ts.map +1 -0
  66. package/dist/evals/gate.js +572 -0
  67. package/dist/evals/gate.js.map +1 -0
  68. package/dist/evals/metrics.d.ts +141 -0
  69. package/dist/evals/metrics.d.ts.map +1 -0
  70. package/dist/evals/metrics.js +364 -0
  71. package/dist/evals/metrics.js.map +1 -0
  72. package/dist/evals/predicate.d.ts +79 -0
  73. package/dist/evals/predicate.d.ts.map +1 -0
  74. package/dist/evals/predicate.js +178 -0
  75. package/dist/evals/predicate.js.map +1 -0
  76. package/dist/evals/runner.d.ts +94 -0
  77. package/dist/evals/runner.d.ts.map +1 -0
  78. package/dist/evals/runner.js +202 -0
  79. package/dist/evals/runner.js.map +1 -0
  80. package/dist/gateway.d.ts +118 -0
  81. package/dist/gateway.d.ts.map +1 -0
  82. package/dist/gateway.js +250 -0
  83. package/dist/gateway.js.map +1 -0
  84. package/dist/index.d.ts +83 -0
  85. package/dist/index.d.ts.map +1 -0
  86. package/dist/index.js +59 -0
  87. package/dist/index.js.map +1 -0
  88. package/dist/internal/json.d.ts +44 -0
  89. package/dist/internal/json.d.ts.map +1 -0
  90. package/dist/internal/json.js +90 -0
  91. package/dist/internal/json.js.map +1 -0
  92. package/dist/internal/text.d.ts +17 -0
  93. package/dist/internal/text.d.ts.map +1 -0
  94. package/dist/internal/text.js +22 -0
  95. package/dist/internal/text.js.map +1 -0
  96. package/dist/pipeline.d.ts +80 -0
  97. package/dist/pipeline.d.ts.map +1 -0
  98. package/dist/pipeline.js +159 -0
  99. package/dist/pipeline.js.map +1 -0
  100. package/dist/policy.d.ts +52 -0
  101. package/dist/policy.d.ts.map +1 -0
  102. package/dist/policy.js +199 -0
  103. package/dist/policy.js.map +1 -0
  104. package/dist/prompts.d.ts +86 -0
  105. package/dist/prompts.d.ts.map +1 -0
  106. package/dist/prompts.js +337 -0
  107. package/dist/prompts.js.map +1 -0
  108. package/dist/providers/base.d.ts +19 -0
  109. package/dist/providers/base.d.ts.map +1 -0
  110. package/dist/providers/base.js +13 -0
  111. package/dist/providers/base.js.map +1 -0
  112. package/dist/providers/fake.d.ts +98 -0
  113. package/dist/providers/fake.d.ts.map +1 -0
  114. package/dist/providers/fake.js +181 -0
  115. package/dist/providers/fake.js.map +1 -0
  116. package/dist/providers/http.d.ts +62 -0
  117. package/dist/providers/http.d.ts.map +1 -0
  118. package/dist/providers/http.js +245 -0
  119. package/dist/providers/http.js.map +1 -0
  120. package/dist/retrieval/chunking.d.ts +88 -0
  121. package/dist/retrieval/chunking.d.ts.map +1 -0
  122. package/dist/retrieval/chunking.js +188 -0
  123. package/dist/retrieval/chunking.js.map +1 -0
  124. package/dist/retrieval/citations.d.ts +98 -0
  125. package/dist/retrieval/citations.d.ts.map +1 -0
  126. package/dist/retrieval/citations.js +134 -0
  127. package/dist/retrieval/citations.js.map +1 -0
  128. package/dist/retrieval/connectors.d.ts +74 -0
  129. package/dist/retrieval/connectors.d.ts.map +1 -0
  130. package/dist/retrieval/connectors.js +218 -0
  131. package/dist/retrieval/connectors.js.map +1 -0
  132. package/dist/retrieval/embedding.d.ts +116 -0
  133. package/dist/retrieval/embedding.d.ts.map +1 -0
  134. package/dist/retrieval/embedding.js +282 -0
  135. package/dist/retrieval/embedding.js.map +1 -0
  136. package/dist/retrieval/gate.d.ts +52 -0
  137. package/dist/retrieval/gate.d.ts.map +1 -0
  138. package/dist/retrieval/gate.js +91 -0
  139. package/dist/retrieval/gate.js.map +1 -0
  140. package/dist/retrieval/hybrid.d.ts +76 -0
  141. package/dist/retrieval/hybrid.d.ts.map +1 -0
  142. package/dist/retrieval/hybrid.js +150 -0
  143. package/dist/retrieval/hybrid.js.map +1 -0
  144. package/dist/retrieval/metrics.d.ts +126 -0
  145. package/dist/retrieval/metrics.d.ts.map +1 -0
  146. package/dist/retrieval/metrics.js +200 -0
  147. package/dist/retrieval/metrics.js.map +1 -0
  148. package/dist/retrieval/pgvector.d.ts +62 -0
  149. package/dist/retrieval/pgvector.d.ts.map +1 -0
  150. package/dist/retrieval/pgvector.js +262 -0
  151. package/dist/retrieval/pgvector.js.map +1 -0
  152. package/dist/retrieval/rerank.d.ts +61 -0
  153. package/dist/retrieval/rerank.d.ts.map +1 -0
  154. package/dist/retrieval/rerank.js +105 -0
  155. package/dist/retrieval/rerank.js.map +1 -0
  156. package/dist/retrieval/retriever.d.ts +125 -0
  157. package/dist/retrieval/retriever.d.ts.map +1 -0
  158. package/dist/retrieval/retriever.js +281 -0
  159. package/dist/retrieval/retriever.js.map +1 -0
  160. package/dist/retrieval/stores.d.ts +106 -0
  161. package/dist/retrieval/stores.d.ts.map +1 -0
  162. package/dist/retrieval/stores.js +142 -0
  163. package/dist/retrieval/stores.js.map +1 -0
  164. package/dist/retrieval/types.d.ts +314 -0
  165. package/dist/retrieval/types.d.ts.map +1 -0
  166. package/dist/retrieval/types.js +388 -0
  167. package/dist/retrieval/types.js.map +1 -0
  168. package/dist/steps.d.ts +156 -0
  169. package/dist/steps.d.ts.map +1 -0
  170. package/dist/steps.js +199 -0
  171. package/dist/steps.js.map +1 -0
  172. package/dist/structured.d.ts +91 -0
  173. package/dist/structured.d.ts.map +1 -0
  174. package/dist/structured.js +155 -0
  175. package/dist/structured.js.map +1 -0
  176. package/dist/tools.d.ts +100 -0
  177. package/dist/tools.d.ts.map +1 -0
  178. package/dist/tools.js +201 -0
  179. package/dist/tools.js.map +1 -0
  180. package/dist/tracing.d.ts +104 -0
  181. package/dist/tracing.d.ts.map +1 -0
  182. package/dist/tracing.js +155 -0
  183. package/dist/tracing.js.map +1 -0
  184. package/dist/types.d.ts +240 -0
  185. package/dist/types.d.ts.map +1 -0
  186. package/dist/types.js +357 -0
  187. package/dist/types.js.map +1 -0
  188. package/package.json +80 -14
@@ -0,0 +1,213 @@
1
+ /**
2
+ * Error hierarchy for the AID TypeScript runtime.
3
+ *
4
+ * Every error this library raises derives from {@link AidRuntimeError}, so an
5
+ * application can distinguish "the framework refused to proceed" from "the network
6
+ * was flaky" with a single `instanceof` check.
7
+ */
8
+ /** Base class for every error raised by this library. */
9
+ export declare class AidRuntimeError extends Error {
10
+ constructor(message: string, options?: ErrorOptions);
11
+ }
12
+ /** The runtime was configured with something it cannot use. */
13
+ export declare class ConfigurationError extends AidRuntimeError {
14
+ }
15
+ /**
16
+ * An alias was requested that the gateway has no pinned model for.
17
+ *
18
+ * Model pinning means the alias table is closed: an unknown alias is a
19
+ * configuration error, never a silent pass-through to a provider default.
20
+ */
21
+ export declare class UnknownModelAliasError extends ConfigurationError {
22
+ readonly alias: string;
23
+ readonly known: readonly string[];
24
+ constructor(alias: string, known: Iterable<string>);
25
+ }
26
+ /** A pinned model does not declare a capability the caller requires. */
27
+ export declare class CapabilityMismatchError extends ConfigurationError {
28
+ readonly alias: string;
29
+ readonly missing: readonly string[];
30
+ constructor(alias: string, missing: Iterable<string>);
31
+ }
32
+ /**
33
+ * A cost or token budget was crossed.
34
+ *
35
+ * Raised after a call is charged, so the ledger it reports has already recorded
36
+ * the spend that crossed the line: a caller that catches this still sees truthful
37
+ * accounting rather than a pre-call estimate.
38
+ */
39
+ export declare class BudgetExceededError extends AidRuntimeError {
40
+ readonly scope: string;
41
+ readonly limit: number;
42
+ readonly spent: number;
43
+ readonly unit: string;
44
+ constructor(scope: string, limit: number, spent: number, unit?: string);
45
+ }
46
+ /**
47
+ * A capability is declared for the IR contract but not implemented yet.
48
+ *
49
+ * Streaming is the motivating case: the runtime is request/response only, no target
50
+ * declares the `streaming` capability, and this error is what `stream()` raises
51
+ * instead of returning a silently non-streaming "stream". Phase 2 layer L5 implements
52
+ * streaming and restores the declaration.
53
+ */
54
+ export declare class FeatureDeferredError extends AidRuntimeError {
55
+ }
56
+ /** A provider call failed after exhausting retries. */
57
+ export declare class ProviderError extends AidRuntimeError {
58
+ }
59
+ /** The provider answered with a body we could not interpret. */
60
+ export declare class ProviderResponseError extends ProviderError {
61
+ readonly body: string | undefined;
62
+ constructor(message: string, body?: string);
63
+ }
64
+ /** No prompt is registered under the requested name and version. */
65
+ export declare class PromptNotFoundError extends AidRuntimeError {
66
+ readonly promptName: string;
67
+ readonly version: string | undefined;
68
+ constructor(name: string, version: string | undefined, known: Iterable<string>);
69
+ }
70
+ /** A prompt template could not be rendered from the supplied variables. */
71
+ export declare class PromptRenderError extends AidRuntimeError {
72
+ }
73
+ /** A model response could not be coerced into the requested output type. */
74
+ export declare class StructuredOutputError extends AidRuntimeError {
75
+ readonly attempts: number;
76
+ readonly problems: readonly string[];
77
+ constructor(message: string, options: {
78
+ readonly attempts: number;
79
+ readonly problems?: readonly string[];
80
+ });
81
+ }
82
+ /** A tool call named a tool the executor does not have. */
83
+ export declare class ToolNotFoundError extends AidRuntimeError {
84
+ readonly toolName: string;
85
+ constructor(name: string, known: Iterable<string>);
86
+ }
87
+ /** Tool call arguments failed schema validation. */
88
+ export declare class ToolArgumentError extends AidRuntimeError {
89
+ readonly tool: string;
90
+ readonly problems: readonly string[];
91
+ constructor(tool: string, problems: readonly string[]);
92
+ }
93
+ /** A tool handler threw. */
94
+ export declare class ToolExecutionError extends AidRuntimeError {
95
+ }
96
+ /** A pipeline step failed or the pipeline was wired incorrectly. */
97
+ export declare class PipelineError extends AidRuntimeError {
98
+ }
99
+ /**
100
+ * A policy could not be evaluated to a boolean.
101
+ *
102
+ * Separate from {@link PipelineError} because it is raised from the evaluator, not from
103
+ * a step's wiring: an unknown builtin or a non-boolean operand is a malformed policy,
104
+ * and for a human-in-the-loop gate "could not decide" must never degrade into "do not
105
+ * ask".
106
+ */
107
+ export declare class PolicyEvaluationError extends AidRuntimeError {
108
+ }
109
+ /**
110
+ * A guardrail stopped the run before (or after) the guarded effect.
111
+ *
112
+ * Raised by the `block` action, and by any guardrail the engine cannot evaluate. An
113
+ * undecidable policy is a block, never an allow: the failure mode this class exists to
114
+ * prevent is a check that quietly returns "no violation" because its input did not
115
+ * match what it expected.
116
+ */
117
+ export declare class GuardrailBlockedError extends AidRuntimeError {
118
+ readonly guardrail: string;
119
+ readonly stage: string;
120
+ readonly reason: string;
121
+ constructor(guardrail: string, stage: string, reason: string);
122
+ }
123
+ /**
124
+ * An agent asked for a tool it was not granted, or one its auth policy denies.
125
+ *
126
+ * Raised before the handler body runs. The check is deliberately not a tool result: a
127
+ * model can repair a bad argument, but it cannot repair a missing grant, so the caller
128
+ * is the party that has to fix this.
129
+ */
130
+ export declare class ToolPermissionError extends AidRuntimeError {
131
+ readonly agent: string;
132
+ readonly tool: string;
133
+ readonly reason: string;
134
+ constructor(agent: string, tool: string, reason: string);
135
+ }
136
+ /**
137
+ * A transfer chain revisited an agent that already held control.
138
+ *
139
+ * `agents/handoff-cycles` rejects this at build time; the runtime refuses it again
140
+ * rather than trusting that every caller came through the gate.
141
+ */
142
+ export declare class AgentTransferCycleError extends AidRuntimeError {
143
+ readonly path: readonly string[];
144
+ constructor(path: readonly string[]);
145
+ }
146
+ /**
147
+ * A budget was crossed and there is no cheaper alias left to route to.
148
+ *
149
+ * `ir/agents-budget-degrade` rejects this at build time for declared specs; this is
150
+ * the run-time counterpart for a hand-built IR.
151
+ */
152
+ export declare class AgentBudgetDegradedError extends AidRuntimeError {
153
+ }
154
+ export declare class AgentHandoffUnsupportedError extends AidRuntimeError {
155
+ readonly agent: string;
156
+ readonly targets: readonly string[];
157
+ readonly engine: string;
158
+ constructor(agent: string, targets: readonly string[], engine: string);
159
+ }
160
+ /** Base for the refusals that belong to the optional `deepagents` backend. */
161
+ export declare class DeepAgentsEngineError extends AidRuntimeError {
162
+ }
163
+ /**
164
+ * `engineVersion` does not match the release this runtime is pinned to.
165
+ *
166
+ * The mismatch fires in both directions -- a declared version this runtime is not built
167
+ * for, and a runtime that cannot find the declaration at all.
168
+ */
169
+ export declare class DeepAgentsVersionMismatchError extends DeepAgentsEngineError {
170
+ readonly agent: string;
171
+ readonly declared: string;
172
+ readonly pinned: string;
173
+ constructor(agent: string, declared: string, pinned: string);
174
+ }
175
+ /**
176
+ * The `deepagents` optional extra is not installed.
177
+ *
178
+ * A named error rather than an import failure because the fix is an install
179
+ * instruction the caller can act on, and because an agent silently falling back to the
180
+ * native loop would leave `engine` in the IR meaning nothing.
181
+ */
182
+ export declare class DeepAgentsUnavailableError extends DeepAgentsEngineError {
183
+ readonly extra: string;
184
+ readonly distribution: string;
185
+ constructor(extra: string, distribution: string);
186
+ }
187
+ /**
188
+ * The harness asked for one model call more than `maxSteps` allows.
189
+ *
190
+ * The harness has its own limiter, and when it trips it appends a synthetic
191
+ * "model call limits exceeded" answer and *completes* -- reporting an exhausted agent as a
192
+ * success. So the adapter counts calls itself and raises this instead, from inside
193
+ * {@link GatewayChatModel}, before the over-budget call reaches the gateway. Parity is with
194
+ * the native loop's `max-steps` status, not with the harness's synthetic answer.
195
+ */
196
+ export declare class DeepAgentsMaxStepsError extends DeepAgentsEngineError {
197
+ readonly alias: string;
198
+ readonly maxSteps: number;
199
+ constructor(alias: string, maxSteps: number);
200
+ }
201
+ /** An eval run could not be completed. */
202
+ export declare class EvalError extends AidRuntimeError {
203
+ }
204
+ /**
205
+ * The gate was configured in a way that cannot be trusted as a CI signal.
206
+ *
207
+ * The load-bearing case: a threshold that references a metric whose result is
208
+ * itself produced by a model. Gating on one source of non-determinism using
209
+ * another is not a gate.
210
+ */
211
+ export declare class GateConfigurationError extends EvalError {
212
+ }
213
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,yDAAyD;AACzD,qBAAa,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAGlD;CACF;AAED,+DAA+D;AAC/D,qBAAa,kBAAmB,SAAQ,eAAe;CAAG;AAE1D;;;;;GAKG;AACH,qBAAa,sBAAuB,SAAQ,kBAAkB;IAC5D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAElC,YAAY,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EAMjD;CACF;AAED,wEAAwE;AACxE,qBAAa,uBAAwB,SAAQ,kBAAkB;IAC7D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAEpC,YAAY,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,EAKnD;CACF;AAED;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,eAAe;IACtD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE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K,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,YAAY,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EASpE;CACF;AAED,8EAA8E;AAC9E,qBAAa,qBAAsB,SAAQ,eAAe;CAAG;AAE7D;;;;;GAKG;AACH,qBAAa,8BAA+B,SAAQ,qBAAqB;IACvE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,YAAY,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAY1D;CACF;AAED;;;;;;GAMG;AACH,qBAAa,0BAA2B,SAAQ,qBAAqB;IACnE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B,YAAY,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAQ9C;CACF;AAED;;;;;;;;GAQG;AACH,qBAAa,uBAAwB,SAAQ,qBAAqB;IAChE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B,YAAY,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAO1C;CACF;AAED,0CAA0C;AAE1C,qBAAa,SAAU,SAAQ,eAAe;CAAG;AAEjD;;;;;;GAMG;AACH,qBAAa,sBAAuB,SAAQ,SAAS;CAAG"}
package/dist/errors.js ADDED
@@ -0,0 +1,316 @@
1
+ /**
2
+ * Error hierarchy for the AID TypeScript runtime.
3
+ *
4
+ * Every error this library raises derives from {@link AidRuntimeError}, so an
5
+ * application can distinguish "the framework refused to proceed" from "the network
6
+ * was flaky" with a single `instanceof` check.
7
+ */
8
+ import { repr } from './internal/json.js';
9
+ /** Base class for every error raised by this library. */
10
+ export class AidRuntimeError extends Error {
11
+ constructor(message, options) {
12
+ super(message, options);
13
+ this.name = new.target.name;
14
+ }
15
+ }
16
+ /** The runtime was configured with something it cannot use. */
17
+ export class ConfigurationError extends AidRuntimeError {
18
+ }
19
+ /**
20
+ * An alias was requested that the gateway has no pinned model for.
21
+ *
22
+ * Model pinning means the alias table is closed: an unknown alias is a
23
+ * configuration error, never a silent pass-through to a provider default.
24
+ */
25
+ export class UnknownModelAliasError extends ConfigurationError {
26
+ alias;
27
+ known;
28
+ constructor(alias, known) {
29
+ const sorted = [...known].sort();
30
+ const listed = sorted.join(', ') || '<none>';
31
+ super(`unknown model alias ${repr(alias)}; pinned aliases: ${listed}`);
32
+ this.alias = alias;
33
+ this.known = sorted;
34
+ }
35
+ }
36
+ /** A pinned model does not declare a capability the caller requires. */
37
+ export class CapabilityMismatchError extends ConfigurationError {
38
+ alias;
39
+ missing;
40
+ constructor(alias, missing) {
41
+ const sorted = [...missing].sort();
42
+ super(`model alias ${repr(alias)} does not support: ${sorted.join(', ')}`);
43
+ this.alias = alias;
44
+ this.missing = sorted;
45
+ }
46
+ }
47
+ /**
48
+ * A cost or token budget was crossed.
49
+ *
50
+ * Raised after a call is charged, so the ledger it reports has already recorded
51
+ * the spend that crossed the line: a caller that catches this still sees truthful
52
+ * accounting rather than a pre-call estimate.
53
+ */
54
+ export class BudgetExceededError extends AidRuntimeError {
55
+ scope;
56
+ limit;
57
+ spent;
58
+ unit;
59
+ constructor(scope, limit, spent, unit = 'usd') {
60
+ const asUsd = unit === 'usd';
61
+ const format = (value) => asUsd ? `$${value.toFixed(6)}` : `${value.toFixed(0)} ${unit}`;
62
+ super(`budget ${repr(scope)} exceeded: limit ${format(limit)}, spent ${format(spent)} ` +
63
+ `(over by ${format(spent - limit)})`);
64
+ this.scope = scope;
65
+ this.limit = limit;
66
+ this.spent = spent;
67
+ this.unit = unit;
68
+ }
69
+ }
70
+ /**
71
+ * A capability is declared for the IR contract but not implemented yet.
72
+ *
73
+ * Streaming is the motivating case: the runtime is request/response only, no target
74
+ * declares the `streaming` capability, and this error is what `stream()` raises
75
+ * instead of returning a silently non-streaming "stream". Phase 2 layer L5 implements
76
+ * streaming and restores the declaration.
77
+ */
78
+ export class FeatureDeferredError extends AidRuntimeError {
79
+ }
80
+ /** A provider call failed after exhausting retries. */
81
+ export class ProviderError extends AidRuntimeError {
82
+ }
83
+ /** The provider answered with a body we could not interpret. */
84
+ export class ProviderResponseError extends ProviderError {
85
+ body;
86
+ constructor(message, body) {
87
+ super(body === undefined ? message : `${message}: ${body.slice(0, 500)}`);
88
+ this.body = body;
89
+ }
90
+ }
91
+ /** No prompt is registered under the requested name and version. */
92
+ export class PromptNotFoundError extends AidRuntimeError {
93
+ promptName;
94
+ version;
95
+ constructor(name, version, known) {
96
+ const suffix = version === undefined ? ' (latest)' : ` version ${repr(version)}`;
97
+ const listed = [...known].sort().join(', ') || '<none>';
98
+ super(`no prompt ${repr(name)}${suffix}; registered: ${listed}`);
99
+ this.promptName = name;
100
+ this.version = version;
101
+ }
102
+ }
103
+ /** A prompt template could not be rendered from the supplied variables. */
104
+ export class PromptRenderError extends AidRuntimeError {
105
+ }
106
+ /** A model response could not be coerced into the requested output type. */
107
+ export class StructuredOutputError extends AidRuntimeError {
108
+ attempts;
109
+ problems;
110
+ constructor(message, options) {
111
+ const problems = options.problems ?? [];
112
+ let detail = ` after ${options.attempts} attempt(s)`;
113
+ if (problems.length > 0)
114
+ detail += `: ${problems.join('; ')}`;
115
+ super(message + detail);
116
+ this.attempts = options.attempts;
117
+ this.problems = [...problems];
118
+ }
119
+ }
120
+ /** A tool call named a tool the executor does not have. */
121
+ export class ToolNotFoundError extends AidRuntimeError {
122
+ toolName;
123
+ constructor(name, known) {
124
+ const listed = [...known].sort().join(', ') || '<none>';
125
+ super(`unknown tool ${repr(name)}; registered: ${listed}`);
126
+ this.toolName = name;
127
+ }
128
+ }
129
+ /** Tool call arguments failed schema validation. */
130
+ export class ToolArgumentError extends AidRuntimeError {
131
+ tool;
132
+ problems;
133
+ constructor(tool, problems) {
134
+ super(`invalid arguments for tool ${repr(tool)}: ${problems.join('; ')}`);
135
+ this.tool = tool;
136
+ this.problems = [...problems];
137
+ }
138
+ }
139
+ /** A tool handler threw. */
140
+ export class ToolExecutionError extends AidRuntimeError {
141
+ }
142
+ /** A pipeline step failed or the pipeline was wired incorrectly. */
143
+ export class PipelineError extends AidRuntimeError {
144
+ }
145
+ /**
146
+ * A policy could not be evaluated to a boolean.
147
+ *
148
+ * Separate from {@link PipelineError} because it is raised from the evaluator, not from
149
+ * a step's wiring: an unknown builtin or a non-boolean operand is a malformed policy,
150
+ * and for a human-in-the-loop gate "could not decide" must never degrade into "do not
151
+ * ask".
152
+ */
153
+ export class PolicyEvaluationError extends AidRuntimeError {
154
+ }
155
+ /**
156
+ * A guardrail stopped the run before (or after) the guarded effect.
157
+ *
158
+ * Raised by the `block` action, and by any guardrail the engine cannot evaluate. An
159
+ * undecidable policy is a block, never an allow: the failure mode this class exists to
160
+ * prevent is a check that quietly returns "no violation" because its input did not
161
+ * match what it expected.
162
+ */
163
+ export class GuardrailBlockedError extends AidRuntimeError {
164
+ guardrail;
165
+ stage;
166
+ reason;
167
+ constructor(guardrail, stage, reason) {
168
+ super(`guardrail ${repr(guardrail)} blocked the ${stage} stage: ${reason}`);
169
+ this.guardrail = guardrail;
170
+ this.stage = stage;
171
+ this.reason = reason;
172
+ }
173
+ }
174
+ /**
175
+ * An agent asked for a tool it was not granted, or one its auth policy denies.
176
+ *
177
+ * Raised before the handler body runs. The check is deliberately not a tool result: a
178
+ * model can repair a bad argument, but it cannot repair a missing grant, so the caller
179
+ * is the party that has to fix this.
180
+ */
181
+ export class ToolPermissionError extends AidRuntimeError {
182
+ agent;
183
+ tool;
184
+ reason;
185
+ constructor(agent, tool, reason) {
186
+ super(`agent ${repr(agent)} may not call tool ${repr(tool)}: ${reason}`);
187
+ this.agent = agent;
188
+ this.tool = tool;
189
+ this.reason = reason;
190
+ }
191
+ }
192
+ /**
193
+ * A transfer chain revisited an agent that already held control.
194
+ *
195
+ * `agents/handoff-cycles` rejects this at build time; the runtime refuses it again
196
+ * rather than trusting that every caller came through the gate.
197
+ */
198
+ export class AgentTransferCycleError extends AidRuntimeError {
199
+ path;
200
+ constructor(path) {
201
+ super(`transfer cycle: ${path.join(' -> ')}`);
202
+ this.path = [...path];
203
+ }
204
+ }
205
+ /**
206
+ * A budget was crossed and there is no cheaper alias left to route to.
207
+ *
208
+ * `ir/agents-budget-degrade` rejects this at build time for declared specs; this is
209
+ * the run-time counterpart for a hand-built IR.
210
+ */
211
+ export class AgentBudgetDegradedError extends AidRuntimeError {
212
+ }
213
+ /**
214
+ * An agent asked for `handoffs` on an engine that has no transfer primitive.
215
+ *
216
+ * Deep Agents has `subagents` -- delegation that *returns* -- and no transfer: control
217
+ * never moves, the caller always resumes and always authors the final answer. Emulating
218
+ * transfer with a delegate would change who answers, so the engine refuses instead of
219
+ * silently degrading `handoffs` into a delegate.
220
+ */
221
+ /**
222
+ * `['a', 'b']`, the shape Python's `{list(...)}` puts in a message. `repr` from
223
+ * `internal/json` quotes one string; a diagnostic that names a set of targets needs the
224
+ * bracket as well.
225
+ */
226
+ function listRepr(values) {
227
+ return `[${values.map((value) => repr(value)).join(', ')}]`;
228
+ }
229
+ export class AgentHandoffUnsupportedError extends AidRuntimeError {
230
+ agent;
231
+ targets;
232
+ engine;
233
+ constructor(agent, targets, engine) {
234
+ super(`agent ${repr(agent)} declares handoffs ${listRepr([...targets])} but runs on the ` +
235
+ `${repr(engine)} engine, which has no transfer primitive; transfer is native-only, ` +
236
+ 'and delegation (delegates) is the deepagents equivalent');
237
+ this.agent = agent;
238
+ this.targets = [...targets];
239
+ this.engine = engine;
240
+ }
241
+ }
242
+ /** Base for the refusals that belong to the optional `deepagents` backend. */
243
+ export class DeepAgentsEngineError extends AidRuntimeError {
244
+ }
245
+ /**
246
+ * `engineVersion` does not match the release this runtime is pinned to.
247
+ *
248
+ * The mismatch fires in both directions -- a declared version this runtime is not built
249
+ * for, and a runtime that cannot find the declaration at all.
250
+ */
251
+ export class DeepAgentsVersionMismatchError extends DeepAgentsEngineError {
252
+ agent;
253
+ declared;
254
+ pinned;
255
+ constructor(agent, declared, pinned) {
256
+ const detail = declared === ''
257
+ ? 'the IR declares no engineVersion'
258
+ : `the IR declares engineVersion ${repr(declared)}`;
259
+ super(`agent ${repr(agent)}: ${detail}, but this runtime is pinned to deepagents==${pinned}; ` +
260
+ `set engineVersion to ${repr(pinned)} or install the runtime that matches`);
261
+ this.agent = agent;
262
+ this.declared = declared;
263
+ this.pinned = pinned;
264
+ }
265
+ }
266
+ /**
267
+ * The `deepagents` optional extra is not installed.
268
+ *
269
+ * A named error rather than an import failure because the fix is an install
270
+ * instruction the caller can act on, and because an agent silently falling back to the
271
+ * native loop would leave `engine` in the IR meaning nothing.
272
+ */
273
+ export class DeepAgentsUnavailableError extends DeepAgentsEngineError {
274
+ extra;
275
+ distribution;
276
+ constructor(extra, distribution) {
277
+ super("this agent runs on the 'deepagents' engine, but the " +
278
+ `${repr(distribution)} package is not installed; install the optional peer set ` +
279
+ `with: npm install ${extra}`);
280
+ this.extra = extra;
281
+ this.distribution = distribution;
282
+ }
283
+ }
284
+ /**
285
+ * The harness asked for one model call more than `maxSteps` allows.
286
+ *
287
+ * The harness has its own limiter, and when it trips it appends a synthetic
288
+ * "model call limits exceeded" answer and *completes* -- reporting an exhausted agent as a
289
+ * success. So the adapter counts calls itself and raises this instead, from inside
290
+ * {@link GatewayChatModel}, before the over-budget call reaches the gateway. Parity is with
291
+ * the native loop's `max-steps` status, not with the harness's synthetic answer.
292
+ */
293
+ export class DeepAgentsMaxStepsError extends DeepAgentsEngineError {
294
+ alias;
295
+ maxSteps;
296
+ constructor(alias, maxSteps) {
297
+ super(`the deepagents harness requested model call ${maxSteps + 1} on alias ${repr(alias)}, ` +
298
+ `exceeding maxSteps ${maxSteps}; the run is exhausted`);
299
+ this.alias = alias;
300
+ this.maxSteps = maxSteps;
301
+ }
302
+ }
303
+ /** An eval run could not be completed. */
304
+ // biome-ignore lint/suspicious/noShadowRestrictedNames: the framework's own error name, matching the Python runtime's public surface
305
+ export class EvalError extends AidRuntimeError {
306
+ }
307
+ /**
308
+ * The gate was configured in a way that cannot be trusted as a CI signal.
309
+ *
310
+ * The load-bearing case: a threshold that references a metric whose result is
311
+ * itself produced by a model. Gating on one source of non-determinism using
312
+ * another is not a gate.
313
+ */
314
+ export class GateConfigurationError extends EvalError {
315
+ }
316
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,yDAAyD;AACzD,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe,EAAE,OAAsB;QACjD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AAED,+DAA+D;AAC/D,MAAM,OAAO,kBAAmB,SAAQ,eAAe;CAAG;AAE1D;;;;;GAKG;AACH,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IACnD,KAAK,CAAS;IACd,KAAK,CAAoB;IAElC,YAAY,KAAa,EAAE,KAAuB;QAChD,MAAM,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC;QAC7C,KAAK,CAAC,uBAAuB,IAAI,CAAC,KAAK,CAAC,qBAAqB,MAAM,EAAE,CAAC,CAAC;QACvE,IAAI,CAAC,KA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IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO,0BAA2B,SAAQ,qBAAqB;IAC1D,KAAK,CAAS;IACd,YAAY,CAAS;IAE9B,YAAY,KAAa,EAAE,YAAoB;QAC7C,KAAK,CACH,sDAAsD;YACpD,GAAG,IAAI,CAAC,YAAY,CAAC,2DAA2D;YAChF,qBAAqB,KAAK,EAAE,CAC/B,CAAC;QACF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF;AAED;;;;;;;;GAQG;AACH,MAAM,OAAO,uBAAwB,SAAQ,qBAAqB;IACvD,KAAK,CAAS;IACd,QAAQ,CAAS;IAE1B,YAAY,KAAa,EAAE,QAAgB;QACzC,KAAK,CACH,+CAA+C,QAAQ,GAAG,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,IAAI;YACrF,sBAAsB,QAAQ,wBAAwB,CACzD,CAAC;QACF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAED,0CAA0C;AAC1C,qIAAqI;AACrI,MAAM,OAAO,SAAU,SAAQ,eAAe;CAAG;AAEjD;;;;;;GAMG;AACH,MAAM,OAAO,sBAAuB,SAAQ,SAAS;CAAG"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Eval datasets: the probabilistic analogue of a golden fixture.
3
+ *
4
+ * A dataset is versioned and committed. The version matters as much as the cases:
5
+ * comparing a run against a baseline recorded on a *different* dataset version is the
6
+ * most common way an eval gate becomes noise, so the gate refuses it.
7
+ */
8
+ export interface EvalCaseInit {
9
+ readonly id: string;
10
+ readonly input: string;
11
+ readonly expected?: string | null;
12
+ readonly tags?: readonly string[];
13
+ readonly metadata?: Readonly<Record<string, string>>;
14
+ }
15
+ /** One input, its expected output, and any tags the metrics key off. */
16
+ export declare class EvalCase {
17
+ readonly id: string;
18
+ readonly input: string;
19
+ readonly expected: string | null;
20
+ readonly tags: readonly string[];
21
+ readonly metadata: Readonly<Record<string, string>>;
22
+ constructor(init: EvalCaseInit);
23
+ toJSON(): Record<string, unknown>;
24
+ }
25
+ /** An ordered, versioned set of cases. */
26
+ export declare class Dataset {
27
+ readonly name: string;
28
+ readonly version: string;
29
+ readonly cases: readonly EvalCase[];
30
+ constructor(init: {
31
+ readonly name: string;
32
+ readonly version: string;
33
+ readonly cases: readonly EvalCase[];
34
+ });
35
+ get length(): number;
36
+ ids(): string[];
37
+ case(caseId: string): EvalCase;
38
+ byTag(tag: string): EvalCase[];
39
+ static fromRecords(name: string, version: string, records: readonly Readonly<Record<string, unknown>>[]): Dataset;
40
+ static fromJson(payload: string): Dataset;
41
+ static fromPath(path: string | URL): Dataset;
42
+ /** Canonical JSON: sorted keys, so a dataset diff is reviewable. */
43
+ toJson(): string;
44
+ }
45
+ //# sourceMappingURL=dataset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataset.d.ts","sourceRoot":"","sources":["../../src/evals/dataset.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACtD;AAED,wEAAwE;AACxE,qBAAa,QAAQ;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM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