@falai/agent 4.0.0-alpha.2 → 4.0.0-alpha.21

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 (300) hide show
  1. package/README.md +5 -3
  2. package/dist/cjs/core/Agent.d.ts +8 -1
  3. package/dist/cjs/core/Agent.d.ts.map +1 -1
  4. package/dist/cjs/core/Agent.js +18 -0
  5. package/dist/cjs/core/Agent.js.map +1 -1
  6. package/dist/cjs/core/CompactionEngine.d.ts.map +1 -1
  7. package/dist/cjs/core/CompactionEngine.js +8 -3
  8. package/dist/cjs/core/CompactionEngine.js.map +1 -1
  9. package/dist/cjs/core/FlowSpec.d.ts +21 -2
  10. package/dist/cjs/core/FlowSpec.d.ts.map +1 -1
  11. package/dist/cjs/core/FlowSpec.js +324 -51
  12. package/dist/cjs/core/FlowSpec.js.map +1 -1
  13. package/dist/cjs/core/Migrate.d.ts.map +1 -1
  14. package/dist/cjs/core/Migrate.js +3 -1
  15. package/dist/cjs/core/Migrate.js.map +1 -1
  16. package/dist/cjs/core/Prompt.d.ts +16 -0
  17. package/dist/cjs/core/Prompt.d.ts.map +1 -1
  18. package/dist/cjs/core/Prompt.js +46 -1
  19. package/dist/cjs/core/Prompt.js.map +1 -1
  20. package/dist/cjs/core/Runner.d.ts +42 -4
  21. package/dist/cjs/core/Runner.d.ts.map +1 -1
  22. package/dist/cjs/core/Runner.js +292 -72
  23. package/dist/cjs/core/Runner.js.map +1 -1
  24. package/dist/cjs/core/Speak.d.ts.map +1 -1
  25. package/dist/cjs/core/Speak.js +60 -21
  26. package/dist/cjs/core/Speak.js.map +1 -1
  27. package/dist/cjs/core/Understand.d.ts +6 -3
  28. package/dist/cjs/core/Understand.d.ts.map +1 -1
  29. package/dist/cjs/core/Understand.js +34 -55
  30. package/dist/cjs/core/Understand.js.map +1 -1
  31. package/dist/cjs/core/contracts.d.ts +21 -6
  32. package/dist/cjs/core/contracts.d.ts.map +1 -1
  33. package/dist/cjs/index.d.ts +1 -1
  34. package/dist/cjs/index.d.ts.map +1 -1
  35. package/dist/cjs/persistence/OpenSearchStore.d.ts +2 -1
  36. package/dist/cjs/persistence/OpenSearchStore.d.ts.map +1 -1
  37. package/dist/cjs/persistence/OpenSearchStore.js +2 -2
  38. package/dist/cjs/persistence/OpenSearchStore.js.map +1 -1
  39. package/dist/cjs/persistence/RedisStore.d.ts +1 -1
  40. package/dist/cjs/persistence/RedisStore.d.ts.map +1 -1
  41. package/dist/cjs/providers/AnthropicProvider.d.ts +2 -5
  42. package/dist/cjs/providers/AnthropicProvider.d.ts.map +1 -1
  43. package/dist/cjs/providers/AnthropicProvider.js +3 -4
  44. package/dist/cjs/providers/AnthropicProvider.js.map +1 -1
  45. package/dist/cjs/providers/DeepSeekProvider.d.ts.map +1 -1
  46. package/dist/cjs/providers/DeepSeekProvider.js +3 -4
  47. package/dist/cjs/providers/DeepSeekProvider.js.map +1 -1
  48. package/dist/cjs/providers/FallbackAiProvider.js +1 -1
  49. package/dist/cjs/providers/FallbackAiProvider.js.map +1 -1
  50. package/dist/cjs/providers/GeminiProvider.d.ts +1 -2
  51. package/dist/cjs/providers/GeminiProvider.d.ts.map +1 -1
  52. package/dist/cjs/providers/GeminiProvider.js +3 -4
  53. package/dist/cjs/providers/GeminiProvider.js.map +1 -1
  54. package/dist/cjs/providers/GenericOpenAICompatibleProvider.js +4 -4
  55. package/dist/cjs/providers/GenericOpenAICompatibleProvider.js.map +1 -1
  56. package/dist/cjs/providers/OpenAIProvider.d.ts.map +1 -1
  57. package/dist/cjs/providers/OpenAIProvider.js +3 -4
  58. package/dist/cjs/providers/OpenAIProvider.js.map +1 -1
  59. package/dist/cjs/providers/OpenRouterProvider.d.ts.map +1 -1
  60. package/dist/cjs/providers/OpenRouterProvider.js +4 -3
  61. package/dist/cjs/providers/OpenRouterProvider.js.map +1 -1
  62. package/dist/cjs/providers/ProviderAdapter.d.ts +15 -10
  63. package/dist/cjs/providers/ProviderAdapter.d.ts.map +1 -1
  64. package/dist/cjs/providers/ProviderAdapter.js +8 -3
  65. package/dist/cjs/providers/ProviderAdapter.js.map +1 -1
  66. package/dist/cjs/providers/ZaiProvider.js +1 -1
  67. package/dist/cjs/providers/ZaiProvider.js.map +1 -1
  68. package/dist/cjs/types/agent.d.ts +19 -4
  69. package/dist/cjs/types/agent.d.ts.map +1 -1
  70. package/dist/cjs/types/ai.d.ts +4 -6
  71. package/dist/cjs/types/ai.d.ts.map +1 -1
  72. package/dist/cjs/types/compaction.d.ts +1 -0
  73. package/dist/cjs/types/compaction.d.ts.map +1 -1
  74. package/dist/cjs/types/errors.d.ts +4 -9
  75. package/dist/cjs/types/errors.d.ts.map +1 -1
  76. package/dist/cjs/types/errors.js +12 -12
  77. package/dist/cjs/types/errors.js.map +1 -1
  78. package/dist/cjs/types/flow.d.ts +16 -1
  79. package/dist/cjs/types/flow.d.ts.map +1 -1
  80. package/dist/cjs/types/history.d.ts +0 -7
  81. package/dist/cjs/types/history.d.ts.map +1 -1
  82. package/dist/cjs/types/index.d.ts +2 -2
  83. package/dist/cjs/types/index.d.ts.map +1 -1
  84. package/dist/cjs/types/session.d.ts +4 -2
  85. package/dist/cjs/types/session.d.ts.map +1 -1
  86. package/dist/cjs/utils/clock.js +1 -1
  87. package/dist/cjs/utils/clock.js.map +1 -1
  88. package/dist/cjs/utils/outcomes.d.ts +1 -0
  89. package/dist/cjs/utils/outcomes.d.ts.map +1 -1
  90. package/dist/cjs/utils/outcomes.js +1 -0
  91. package/dist/cjs/utils/outcomes.js.map +1 -1
  92. package/dist/cjs/utils/phrases.d.ts +25 -0
  93. package/dist/cjs/utils/phrases.d.ts.map +1 -0
  94. package/dist/cjs/utils/phrases.js +38 -0
  95. package/dist/cjs/utils/phrases.js.map +1 -0
  96. package/dist/cjs/utils/schema.d.ts +3 -12
  97. package/dist/cjs/utils/schema.d.ts.map +1 -1
  98. package/dist/cjs/utils/schema.js +3 -43
  99. package/dist/cjs/utils/schema.js.map +1 -1
  100. package/dist/cjs/utils/template.d.ts +8 -0
  101. package/dist/cjs/utils/template.d.ts.map +1 -1
  102. package/dist/cjs/utils/template.js +47 -3
  103. package/dist/cjs/utils/template.js.map +1 -1
  104. package/dist/core/Agent.d.ts +8 -1
  105. package/dist/core/Agent.d.ts.map +1 -1
  106. package/dist/core/Agent.js +19 -1
  107. package/dist/core/Agent.js.map +1 -1
  108. package/dist/core/CompactionEngine.d.ts.map +1 -1
  109. package/dist/core/CompactionEngine.js +8 -3
  110. package/dist/core/CompactionEngine.js.map +1 -1
  111. package/dist/core/FlowSpec.d.ts +21 -2
  112. package/dist/core/FlowSpec.d.ts.map +1 -1
  113. package/dist/core/FlowSpec.js +323 -52
  114. package/dist/core/FlowSpec.js.map +1 -1
  115. package/dist/core/Migrate.d.ts.map +1 -1
  116. package/dist/core/Migrate.js +3 -1
  117. package/dist/core/Migrate.js.map +1 -1
  118. package/dist/core/Prompt.d.ts +16 -0
  119. package/dist/core/Prompt.d.ts.map +1 -1
  120. package/dist/core/Prompt.js +44 -1
  121. package/dist/core/Prompt.js.map +1 -1
  122. package/dist/core/Runner.d.ts +42 -4
  123. package/dist/core/Runner.d.ts.map +1 -1
  124. package/dist/core/Runner.js +293 -73
  125. package/dist/core/Runner.js.map +1 -1
  126. package/dist/core/Speak.d.ts.map +1 -1
  127. package/dist/core/Speak.js +61 -22
  128. package/dist/core/Speak.js.map +1 -1
  129. package/dist/core/Understand.d.ts +6 -3
  130. package/dist/core/Understand.d.ts.map +1 -1
  131. package/dist/core/Understand.js +34 -55
  132. package/dist/core/Understand.js.map +1 -1
  133. package/dist/core/contracts.d.ts +21 -6
  134. package/dist/core/contracts.d.ts.map +1 -1
  135. package/dist/index.d.ts +1 -1
  136. package/dist/index.d.ts.map +1 -1
  137. package/dist/persistence/OpenSearchStore.d.ts +2 -1
  138. package/dist/persistence/OpenSearchStore.d.ts.map +1 -1
  139. package/dist/persistence/OpenSearchStore.js +2 -2
  140. package/dist/persistence/OpenSearchStore.js.map +1 -1
  141. package/dist/persistence/RedisStore.d.ts +1 -1
  142. package/dist/persistence/RedisStore.d.ts.map +1 -1
  143. package/dist/providers/AnthropicProvider.d.ts +2 -5
  144. package/dist/providers/AnthropicProvider.d.ts.map +1 -1
  145. package/dist/providers/AnthropicProvider.js +3 -4
  146. package/dist/providers/AnthropicProvider.js.map +1 -1
  147. package/dist/providers/DeepSeekProvider.d.ts.map +1 -1
  148. package/dist/providers/DeepSeekProvider.js +3 -4
  149. package/dist/providers/DeepSeekProvider.js.map +1 -1
  150. package/dist/providers/FallbackAiProvider.js +1 -1
  151. package/dist/providers/FallbackAiProvider.js.map +1 -1
  152. package/dist/providers/GeminiProvider.d.ts +1 -2
  153. package/dist/providers/GeminiProvider.d.ts.map +1 -1
  154. package/dist/providers/GeminiProvider.js +3 -4
  155. package/dist/providers/GeminiProvider.js.map +1 -1
  156. package/dist/providers/GenericOpenAICompatibleProvider.js +4 -4
  157. package/dist/providers/GenericOpenAICompatibleProvider.js.map +1 -1
  158. package/dist/providers/OpenAIProvider.d.ts.map +1 -1
  159. package/dist/providers/OpenAIProvider.js +3 -4
  160. package/dist/providers/OpenAIProvider.js.map +1 -1
  161. package/dist/providers/OpenRouterProvider.d.ts.map +1 -1
  162. package/dist/providers/OpenRouterProvider.js +4 -3
  163. package/dist/providers/OpenRouterProvider.js.map +1 -1
  164. package/dist/providers/ProviderAdapter.d.ts +15 -10
  165. package/dist/providers/ProviderAdapter.d.ts.map +1 -1
  166. package/dist/providers/ProviderAdapter.js +8 -3
  167. package/dist/providers/ProviderAdapter.js.map +1 -1
  168. package/dist/providers/ZaiProvider.js +1 -1
  169. package/dist/providers/ZaiProvider.js.map +1 -1
  170. package/dist/types/agent.d.ts +19 -4
  171. package/dist/types/agent.d.ts.map +1 -1
  172. package/dist/types/ai.d.ts +4 -6
  173. package/dist/types/ai.d.ts.map +1 -1
  174. package/dist/types/compaction.d.ts +1 -0
  175. package/dist/types/compaction.d.ts.map +1 -1
  176. package/dist/types/errors.d.ts +4 -9
  177. package/dist/types/errors.d.ts.map +1 -1
  178. package/dist/types/errors.js +12 -12
  179. package/dist/types/errors.js.map +1 -1
  180. package/dist/types/flow.d.ts +16 -1
  181. package/dist/types/flow.d.ts.map +1 -1
  182. package/dist/types/history.d.ts +0 -7
  183. package/dist/types/history.d.ts.map +1 -1
  184. package/dist/types/index.d.ts +2 -2
  185. package/dist/types/index.d.ts.map +1 -1
  186. package/dist/types/session.d.ts +4 -2
  187. package/dist/types/session.d.ts.map +1 -1
  188. package/dist/utils/clock.js +1 -1
  189. package/dist/utils/clock.js.map +1 -1
  190. package/dist/utils/outcomes.d.ts +1 -0
  191. package/dist/utils/outcomes.d.ts.map +1 -1
  192. package/dist/utils/outcomes.js +1 -0
  193. package/dist/utils/outcomes.js.map +1 -1
  194. package/dist/utils/phrases.d.ts +25 -0
  195. package/dist/utils/phrases.d.ts.map +1 -0
  196. package/dist/utils/phrases.js +35 -0
  197. package/dist/utils/phrases.js.map +1 -0
  198. package/dist/utils/schema.d.ts +3 -12
  199. package/dist/utils/schema.d.ts.map +1 -1
  200. package/dist/utils/schema.js +3 -42
  201. package/dist/utils/schema.js.map +1 -1
  202. package/dist/utils/template.d.ts +8 -0
  203. package/dist/utils/template.d.ts.map +1 -1
  204. package/dist/utils/template.js +47 -3
  205. package/dist/utils/template.js.map +1 -1
  206. package/docs/concepts/architecture.md +3 -3
  207. package/docs/concepts/collection.md +40 -5
  208. package/docs/concepts/pipeline.md +13 -10
  209. package/docs/concepts/runs-and-waits.md +2 -2
  210. package/docs/guides/actions-and-events.md +2 -2
  211. package/docs/guides/branching.md +4 -2
  212. package/docs/guides/compaction.md +2 -2
  213. package/docs/guides/conditions.md +1 -1
  214. package/docs/guides/error-handling.md +3 -1
  215. package/docs/guides/flow-control.md +4 -2
  216. package/docs/guides/persistence.md +2 -2
  217. package/docs/guides/testing.md +1 -1
  218. package/docs/guides/triggers.md +5 -5
  219. package/docs/migration/v3-to-v4.md +16 -11
  220. package/docs/reference/actions-events-conditions.md +2 -2
  221. package/docs/reference/agent.md +11 -7
  222. package/docs/reference/branches.md +1 -1
  223. package/docs/reference/errors.md +10 -7
  224. package/docs/reference/fields.md +5 -3
  225. package/docs/reference/flow-spec.md +36 -9
  226. package/docs/reference/flow.md +8 -3
  227. package/docs/reference/outcomes.md +3 -2
  228. package/docs/reference/providers.md +2 -0
  229. package/docs/reference/session.md +2 -0
  230. package/docs/reference/step.md +9 -5
  231. package/docs/reference/stores.md +5 -3
  232. package/docs/reference/trigger.md +24 -4
  233. package/docs/rfc/v4-one-flow.md +7 -5
  234. package/docs/start/01-install.md +5 -3
  235. package/docs/start/04-add-tools.md +1 -1
  236. package/docs/start/05-go-to-production.md +18 -1
  237. package/examples/05-branches.ts +1 -1
  238. package/examples/06-triggers-and-waits.ts +4 -3
  239. package/package.json +5 -3
  240. package/src/core/Agent.ts +23 -2
  241. package/src/core/CompactionEngine.ts +10 -3
  242. package/src/core/FlowSpec.ts +352 -60
  243. package/src/core/Migrate.ts +2 -1
  244. package/src/core/Prompt.ts +47 -1
  245. package/src/core/Runner.ts +290 -69
  246. package/src/core/Speak.ts +64 -21
  247. package/src/core/Understand.ts +35 -55
  248. package/src/core/contracts.ts +21 -4
  249. package/src/index.ts +1 -1
  250. package/src/persistence/OpenSearchStore.ts +3 -2
  251. package/src/persistence/RedisStore.ts +1 -1
  252. package/src/providers/AnthropicProvider.ts +4 -9
  253. package/src/providers/DeepSeekProvider.ts +2 -4
  254. package/src/providers/FallbackAiProvider.ts +1 -1
  255. package/src/providers/GeminiProvider.ts +3 -6
  256. package/src/providers/GenericOpenAICompatibleProvider.ts +4 -4
  257. package/src/providers/OpenAIProvider.ts +3 -4
  258. package/src/providers/OpenRouterProvider.ts +4 -2
  259. package/src/providers/ProviderAdapter.ts +18 -13
  260. package/src/providers/ZaiProvider.ts +1 -1
  261. package/src/types/agent.ts +20 -5
  262. package/src/types/ai.ts +4 -6
  263. package/src/types/compaction.ts +1 -0
  264. package/src/types/errors.ts +11 -12
  265. package/src/types/flow.ts +16 -1
  266. package/src/types/history.ts +0 -10
  267. package/src/types/index.ts +1 -1
  268. package/src/types/session.ts +4 -1
  269. package/src/utils/clock.ts +1 -1
  270. package/src/utils/outcomes.ts +1 -0
  271. package/src/utils/phrases.ts +40 -0
  272. package/src/utils/schema.ts +3 -48
  273. package/src/utils/template.ts +46 -3
  274. package/dist/cjs/providers/index.d.ts +0 -26
  275. package/dist/cjs/providers/index.d.ts.map +0 -1
  276. package/dist/cjs/providers/index.js +0 -30
  277. package/dist/cjs/providers/index.js.map +0 -1
  278. package/dist/cjs/utils/clone.d.ts +0 -8
  279. package/dist/cjs/utils/clone.d.ts.map +0 -1
  280. package/dist/cjs/utils/clone.js +0 -32
  281. package/dist/cjs/utils/clone.js.map +0 -1
  282. package/dist/cjs/utils/index.d.ts +0 -9
  283. package/dist/cjs/utils/index.d.ts.map +0 -1
  284. package/dist/cjs/utils/index.js +0 -29
  285. package/dist/cjs/utils/index.js.map +0 -1
  286. package/dist/providers/index.d.ts +0 -26
  287. package/dist/providers/index.d.ts.map +0 -1
  288. package/dist/providers/index.js +0 -17
  289. package/dist/providers/index.js.map +0 -1
  290. package/dist/utils/clone.d.ts +0 -8
  291. package/dist/utils/clone.d.ts.map +0 -1
  292. package/dist/utils/clone.js +0 -29
  293. package/dist/utils/clone.js.map +0 -1
  294. package/dist/utils/index.d.ts +0 -9
  295. package/dist/utils/index.d.ts.map +0 -1
  296. package/dist/utils/index.js +0 -9
  297. package/dist/utils/index.js.map +0 -1
  298. package/src/providers/index.ts +0 -38
  299. package/src/utils/clone.ts +0 -34
  300. package/src/utils/index.ts +0 -18
@@ -61,11 +61,9 @@ export interface RetryConfig {
61
61
  /**
62
62
  * How long a stream may stay SILENT before it is considered wedged.
63
63
  *
64
- * In v2 this was a total wall-clock cap on a non-streaming call, so a healthy
65
- * but long generation died at the one-minute mark. It now bounds silence
66
- * instead: time to the first byte, and the gap between any two after it. A
67
- * request that never gets a reply still fails at the same moment; one that is
68
- * steadily producing tokens is left alone.
64
+ * It bounds silence, not the whole call: time to the first byte, and the gap
65
+ * between any two after it. A request that never gets a reply fails at that
66
+ * moment; one that is steadily producing tokens is left alone, however long.
69
67
  */
70
68
  timeout: number;
71
69
  /** Retries AFTER the first attempt, so `0` still performs one call. */
@@ -90,10 +88,8 @@ export function resolveRetryConfig(input?: { timeout?: number; retries?: number
90
88
  /**
91
89
  * Request defaults sent with every call.
92
90
  *
93
- * Only the fields every supported shape has. In v2 each provider took its own
94
- * vendor's SDK parameter type here — which is how one vendor's package ended
95
- * up in the dependency tree of consumers who used a different vendor, and how
96
- * a field set on one provider silently vanished on another.
91
+ * Only the fields every supported shape has, so a field set on one provider
92
+ * means the same on another and no vendor's package enters the dependency tree.
97
93
  */
98
94
  export interface RequestConfig {
99
95
  temperature?: number;
@@ -104,7 +100,9 @@ export interface RequestConfig {
104
100
  * How hard the model thinks, bound as this provider's default. What absent
105
101
  * means is the shape's own business, not one rule: on Gemini it is the
106
102
  * model's dynamic thinking; on the OpenAI and OpenRouter dialects nothing is
107
- * sent and not thinking is the default anyway; on the Anthropic shape — so
103
+ * sent, so the model decides — `medium` on GPT-5 and older, and on
104
+ * OpenRouter GLM 5.3 Flash thinks on most of the hosts that serve it. Set
105
+ * `"none"` where a turn must not think; on the Anthropic shape — so
108
106
  * `AnthropicProvider` and `ZaiProvider` — `@providerkit/core` resolves an
109
107
  * absent effort to `"none"`, and Z.ai is sent an explicit disabled marker
110
108
  * because its endpoint reads silence as thinking ON. Set a level to ask for
@@ -290,6 +288,8 @@ export abstract class ProviderAdapter implements AiProvider {
290
288
  public abstract readonly capabilities: ProviderCapabilities;
291
289
 
292
290
  protected readonly provider: Provider;
291
+ /** `provider` without the fallback chain: the one model this adapter was built for. */
292
+ private readonly primary: Provider;
293
293
  protected readonly primaryModel: string;
294
294
  protected readonly backupModels: string[];
295
295
  protected readonly retryConfig: RetryConfig;
@@ -304,6 +304,7 @@ export abstract class ProviderAdapter implements AiProvider {
304
304
  this.primaryModel = init.model;
305
305
  this.backupModels = init.backupModels ?? [];
306
306
  this.retryConfig = resolveRetryConfig(init.retryConfig);
307
+ this.primary = init.provider;
307
308
 
308
309
  if (init.fallbacks && init.fallbacks.length > 0) {
309
310
  const coreProviders: Provider[] = [
@@ -337,9 +338,14 @@ export abstract class ProviderAdapter implements AiProvider {
337
338
  * boot when it is `null` — that model cannot serve this framework's turns).
338
339
  * Log `calls`: `0/3 and 3/3` is what makes the next model swap's regression
339
340
  * obvious. Costs `samples × 2` short calls, and errors propagate.
341
+ *
342
+ * It asks the primary alone, never the fallback chain. The answer configures
343
+ * this adapter's model; a call the chain handed to a fallback would score
344
+ * another model as this one. Each fallback is an adapter of its own: probe it
345
+ * the same way.
340
346
  */
341
347
  async probeJsonWithTools(opts?: ProbeOptions): Promise<JsonWithToolsProbe> {
342
- return probeJsonWithTools(this.provider, {
348
+ return probeJsonWithTools(this.primary, {
343
349
  model: this.primaryModel,
344
350
  ...(opts ?? {}),
345
351
  });
@@ -468,8 +474,7 @@ export abstract class ProviderAdapter implements AiProvider {
468
474
  tokensUsed: acc.promptTokens + (acc.completionTokens ?? 0),
469
475
  promptTokens: acc.promptTokens,
470
476
  completionTokens: acc.completionTokens,
471
- // New in v3: the cache-hit subset of the prompt, which the old
472
- // adapters never read and which is billed far cheaper.
477
+ // The cache-hit subset of the prompt, billed far cheaper.
473
478
  cachedInputTokens: acc.cachedInputTokens,
474
479
  }
475
480
  : {}),
@@ -51,7 +51,7 @@ export class ZaiProvider extends ProviderAdapter {
51
51
  };
52
52
 
53
53
  constructor(options: ZaiProviderOptions) {
54
- if (!options.apiKey) throw new Error("Z.ai Coding Plan API key is required");
54
+ if (!options.apiKey) throw new Error(`[ZaiProvider] apiKey is empty: the provider cannot authenticate. Pass { apiKey: process.env.ZAI_API_KEY } and check the variable is set.`);
55
55
 
56
56
  const model = options.model ?? "glm-5.3-flash";
57
57
  super({
@@ -78,8 +78,12 @@ export interface AgentOptions<C = unknown, D = unknown> {
78
78
 
79
79
  // ── turn() input ────────────────────────────────────────────────────────
80
80
 
81
- /** The host's reason the assistant cannot speak. Zero calls unless `understand: true`. */
82
- export type Silenced = string | { reason: string; understand?: boolean };
81
+ /**
82
+ * The host's reason the assistant cannot speak. Zero calls unless `understand: true`.
83
+ * A talk or `say` step a run reaches under it ends the run; with `skip: true` the step is
84
+ * skipped and the run goes on, for a gate that only stops messages (a closed channel window).
85
+ */
86
+ export type Silenced = string | { reason: string; understand?: boolean; skip?: boolean };
83
87
 
84
88
  type ContextField<C> = undefined extends C ? { context?: C } : { context: C };
85
89
 
@@ -87,7 +91,11 @@ export type TurnBase<C = unknown, D = unknown> = ContextField<C> & {
87
91
  sessionId: string;
88
92
  /** Absent on a first turn. A wake never creates a session. */
89
93
  session?: Session<D>;
90
- /** Pass on every input kind, wakes included. */
94
+ /**
95
+ * The conversation BEFORE this input. Pass it on every input kind, wakes included.
96
+ * Leave out the message this turn carries: both calls quote it on their own, so a
97
+ * history that ends with it makes the model read it twice.
98
+ */
91
99
  history?: History;
92
100
  silenced?: Silenced;
93
101
  /** Host anchors this session belongs to, e.g. `{ lead: { key: 'lead:456', lastInboundAt } }`. */
@@ -108,6 +116,13 @@ export type TurnKind =
108
116
 
109
117
  export type TurnInput<C = unknown, D = unknown> = TurnBase<C, D> & TurnKind;
110
118
 
119
+ /** A saved session and the host inputs a turn on it would carry: what `pendingWakes` reads. */
120
+ export type PendingWakesInput<C = unknown, D = unknown> = ContextField<C> & {
121
+ session: Session<D>;
122
+ anchors?: TurnBase<C, D>["anchors"];
123
+ claims?: TurnBase<C, D>["claims"];
124
+ };
125
+
111
126
  // ── turn() result ───────────────────────────────────────────────────────
112
127
 
113
128
  export interface OutboundMessage {
@@ -123,7 +138,7 @@ export interface OutboundMessage {
123
138
  stepId?: string;
124
139
  }
125
140
 
126
- /** A wake to enqueue with `jobId = key`; at fire time call `turn({ wake: key })`. */
141
+ /** A wake to enqueue, keyed by `key` (encode it as a queue job id: BullMQ refuses a `:`); at fire time call `turn({ wake: key })`. */
127
142
  export interface ScheduleEntry {
128
143
  key: string;
129
144
  at: Date;
@@ -134,7 +149,7 @@ export interface ScheduleEntry {
134
149
  export type EndReason = "end" | "flow" | "reset" | "skipped" | "failed" | "replaced";
135
150
 
136
151
  export interface TurnResult<D = unknown> {
137
- /** Version unchanged; the host bumps it on save. */
152
+ /** Version unchanged by a turn; `Store.save` bumps it and returns the saved session. */
138
153
  session: Session<D>;
139
154
  /** False: save nothing, send nothing. */
140
155
  changed: boolean;
package/src/types/ai.ts CHANGED
@@ -8,12 +8,10 @@ import type { HistoryItem } from "./history.js";
8
8
  /**
9
9
  * How hard the model thinks before answering.
10
10
  *
11
- * v3 takes `@providerkit/core`'s effort union, which every provider speaks:
12
- * "none" | "low" | "medium" | "high" | "max". Absent means the provider's own
13
- * default and is never sent. v2's "minimal" is spelled "low"; `summary` and
14
- * `includeThoughts` are gone because they are no longer choices — the shapes
15
- * that need them get them switched on whenever an effort is set, which is the
16
- * only setting that ever produced reasoning output.
11
+ * `@providerkit/core`'s effort union, which every provider speaks: "none" |
12
+ * "low" | "medium" | "high" | "max". Absent means the provider's own default
13
+ * and is never sent. The shapes that need a thought summary switched on get it
14
+ * whenever an effort is set, so there is no separate setting for it.
17
15
  */
18
16
  export interface ReasoningConfig {
19
17
  effort?: Effort;
@@ -9,6 +9,7 @@ import type { HistoryItem } from "./history.js";
9
9
  * Configuration for the compaction engine.
10
10
  *
11
11
  * Validation constraints:
12
+ * - `maxTokens` must be > 0
12
13
  * - `compactionThreshold` must be between 0.5 and 0.95
13
14
  * - `preserveRecentCount` must be >= 2
14
15
  * - `maxToolResultChars` must be > 0
@@ -5,16 +5,11 @@
5
5
  /**
6
6
  * The normalized provider failure, and the kinds it comes in.
7
7
  *
8
- * v3 re-exports these from `@providerkit/core` rather than keeping a second
9
- * copy. The taxonomy is wider there — thirteen kinds named by what actually
10
- * fixes them, where this package had eight — so a caller can now tell an
8
+ * `ProviderError` comes from `@providerkit/core` and is re-exported here. Its
9
+ * thirteen kinds are named by what fixes them, so a caller can tell an
11
10
  * exhausted balance from a per-minute throttle, a plan that never included the
12
- * API from a wrong key, and an outgrown context window from a bad request.
13
- *
14
- * Breaking: the kind lives on `error.kind`, not `error.code`, and the spellings
15
- * changed with the taxonomy (`rate_limited` is `rate`, `overloaded` is
16
- * `overload`, `invalid_request` splits into `invalid`, `context`, `model` and
17
- * `content`). `schema_rejected` is gone: nothing ever produced it.
11
+ * API from a wrong key, and an outgrown context window from a bad request. The
12
+ * kind lives on `error.kind`.
18
13
  */
19
14
  export { ProviderError } from "@providerkit/core";
20
15
  export type { ErrorKind } from "@providerkit/core";
@@ -33,9 +28,13 @@ export class SessionConflictError extends Error {
33
28
  public readonly actualVersion: number | undefined,
34
29
  ) {
35
30
  super(
36
- `[SessionConflictError] Session "${sessionId}" was modified concurrently: ` +
37
- `expected version ${expectedVersion}, found ${actualVersion ?? 'none'}. ` +
38
- `Reload the session and retry the operation.`
31
+ // A row that vanished between load and save (a TTL expiry, a delete) is not a race.
32
+ actualVersion === undefined && expectedVersion > 0
33
+ ? `[SessionConflictError] Session "${sessionId}" is gone from the store: it was at version ${expectedVersion} ` +
34
+ `and has since been deleted or expired. Load it again; a load that finds nothing starts a new conversation.`
35
+ : `[SessionConflictError] Session "${sessionId}" was modified concurrently: ` +
36
+ `expected version ${expectedVersion}, found ${actualVersion ?? 'none'}. ` +
37
+ `Reload the session and retry the operation.`
39
38
  );
40
39
  this.name = 'SessionConflictError';
41
40
  }
package/src/types/flow.ts CHANGED
@@ -45,6 +45,8 @@ export interface ScalarDef<T extends ScalarType = ScalarType> {
45
45
 
46
46
  /** One collectable field, authored once on the agent. */
47
47
  export interface FieldDef<T extends ScalarType = ScalarType> extends ScalarDef<T> {
48
+ /** The name a person reads, in an editor or next to a collected value. The model never sees it. */
49
+ label?: string;
48
50
  /** How the AI should ask for this field when a step collects it. */
49
51
  ask?: string;
50
52
  /**
@@ -185,6 +187,13 @@ export type TalkStep<C = unknown, D = unknown> = (
185
187
  ) & {
186
188
  /** Per-flow wording for a field; the field's own `ask` is the default. */
187
189
  ask?: Partial<Record<keyof D & string, string>>;
190
+ /**
191
+ * A fixed first question, sent word for word when the step first asks: every
192
+ * field it collects is still unknown and none was asked yet. No model call,
193
+ * unless the customer's message asks something: then the step answers first
194
+ * and the question follows. Any later ask is the AI's own wording. Needs `collect`.
195
+ */
196
+ question?: Template;
188
197
  /** Times a field may be asked before it is skipped. Default 3. */
189
198
  maxAsks?: number;
190
199
  branches?: Branch<C, D>[];
@@ -253,9 +262,15 @@ export interface Flow<C = unknown, D = unknown> {
253
262
  anchor?: string;
254
263
  /** Re-checked whenever the run moves. Default: the trigger's `if`. */
255
264
  while?: Pred<C, D>;
265
+ /**
266
+ * The data this flow needs, as agent field slugs. Its talk steps' `collect`
267
+ * says which of it to ask, and in what order; a field no step asks is still
268
+ * noted whenever the lead gives it while the flow holds the conversation.
269
+ */
270
+ collect?: (keyof D & string)[];
256
271
  clearOnStart?: (keyof D & string)[];
257
272
  steps: Step<C, D>[];
258
- /** What the run does after its last step. Default `'end'`. */
273
+ /** What the run does after its last step. Default `'end'`. `'stay'`: the last talk step the run took answers every later message. */
259
274
  onEnd?: "end" | "stay" | "reset";
260
275
  instructions?: Instruction<C, D>[];
261
276
  tools?: string[];
@@ -176,13 +176,3 @@ export interface Event<
176
176
  /** Unique event identifier */
177
177
  id?: string;
178
178
  }
179
-
180
- /**
181
- * An emitted event (staged for inclusion)
182
- */
183
- export interface EmittedEvent<
184
- TData = MessageEventData | ToolEventData | StatusEventData
185
- > extends Event<TData> {
186
- /** Whether this event has been committed */
187
- committed?: boolean;
188
- }
@@ -10,6 +10,7 @@ export type {
10
10
  EndReason,
11
11
  Idle,
12
12
  OutboundMessage,
13
+ PendingWakesInput,
13
14
  ScheduleEntry,
14
15
  Silenced,
15
16
  TurnBase,
@@ -84,7 +85,6 @@ export type {
84
85
 
85
86
  export type {
86
87
  AssistantHistoryItem,
87
- EmittedEvent,
88
88
  Event,
89
89
  History,
90
90
  HistoryItem,
@@ -28,6 +28,8 @@ export interface Run {
28
28
  startedAt: string;
29
29
  /** Set while `suspended`; the most recently suspended run resumes first. */
30
30
  suspendedAt?: string;
31
+ /** Set once an `onEnd: 'stay'` run has finished its steps: it sits on its last talk step and answers every message from there. Any other move clears it. */
32
+ staying?: true;
31
33
  waiting?: {
32
34
  kind: "timer" | "event";
33
35
  /** The wake key; only a `wake` equal to it is honoured. */
@@ -75,6 +77,7 @@ export type StepOutcomeCode =
75
77
  | "silenced"
76
78
  // A step
77
79
  | "already-known"
80
+ | "asked-fixed"
78
81
  | "another-reply"
79
82
  | "already-sent"
80
83
  | "branch"
@@ -124,7 +127,7 @@ export interface StepOutcome {
124
127
  export interface Session<D = unknown> {
125
128
  id: string;
126
129
  v: 4;
127
- /** Optimistic-concurrency version; the host bumps it on save. */
130
+ /** Optimistic-concurrency version. A turn leaves it unchanged; `Store.save` bumps it and returns the saved session. */
128
131
  version: number;
129
132
  data: Partial<D>;
130
133
  /** Live runs only. */
@@ -34,7 +34,7 @@ export function fakeClock(iso: string): FakeClock {
34
34
 
35
35
  function parseIso(iso: string): number {
36
36
  const ms = Date.parse(iso);
37
- if (Number.isNaN(ms)) throw new Error(`fakeClock: "${iso}" is not a date.`);
37
+ if (Number.isNaN(ms)) throw new Error(`[fakeClock] "${iso}" is not a date: Date.parse cannot read it. Pass ISO text, e.g. "2026-09-20T10:00:00.000Z".`);
38
38
  return ms;
39
39
  }
40
40
 
@@ -28,6 +28,7 @@ export const OUTCOME_MESSAGES = {
28
28
  silenced: "the host cannot speak right now",
29
29
 
30
30
  "already-known": "every field this step collects is known",
31
+ "asked-fixed": "the step's fixed question went out word for word",
31
32
  "another-reply": "another run already answered this turn",
32
33
  "already-sent": "this message was already sent once",
33
34
  branch: "a branch of this step fired",
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Splitting an AI-judged phrase list into what counts and what rules it out.
3
+ *
4
+ * A trigger's phrases are alternatives: one match is enough. That makes the
5
+ * list useless for saying "but not this" — and "but not this" is what keeps a
6
+ * classifier honest. A customer answering "pode sim" to an offer of a meeting
7
+ * is agreeing to the meeting, not asking for a human, and without a way to say
8
+ * so every cheerful yes reads as a handoff request.
9
+ *
10
+ * So a phrase that opens with `!` is an exclusion: it does not make the trigger
11
+ * fire, it stops it. Exclusions win over matches, and the model is told both
12
+ * lists separately.
13
+ */
14
+
15
+ export interface Phrases {
16
+ /** Any one of these makes it true. */
17
+ counts: string[];
18
+ /** Any one of these makes it false, whatever matched. */
19
+ excludes: string[];
20
+ }
21
+
22
+ /**
23
+ * Split a phrase list on the leading `!`. Blank entries and a bare `"!"` are
24
+ * dropped: they would render as an empty bullet and mean nothing to the model.
25
+ */
26
+ export function splitPhrases(phrases: readonly string[]): Phrases {
27
+ const counts: string[] = [];
28
+ const excludes: string[] = [];
29
+ for (const phrase of phrases) {
30
+ const trimmed = phrase.trim();
31
+ if (!trimmed) continue;
32
+ if (trimmed.startsWith("!")) {
33
+ const body = trimmed.slice(1).trim();
34
+ if (body) excludes.push(body);
35
+ continue;
36
+ }
37
+ counts.push(trimmed);
38
+ }
39
+ return { counts, excludes };
40
+ }
@@ -3,7 +3,6 @@
3
3
  * how a raw extracted value becomes a typed one.
4
4
  */
5
5
 
6
- import { FlowConfigurationError } from "../types/errors.js";
7
6
  import type { FieldDef, FieldDefs, ParamDef, ParamDefs, ScalarDef } from "../types/flow.js";
8
7
  import type { StructuredSchema } from "../types/schema.js";
9
8
 
@@ -34,8 +33,8 @@ export type Coerced = { ok: true; value: string | number | boolean } | { ok: fal
34
33
 
35
34
  /**
36
35
  * Turn a raw value from the model into the field's type. Strings are coerced
37
- * to numbers and booleans; enum membership is enforced. The `detail` is the
38
- * outcome line the host shows when a value is dropped.
36
+ * to numbers and booleans; enum membership is enforced. Returns the coerced
37
+ * value, or the code saying why it was rejected (`bad-value`, `not-in-enum`).
39
38
  */
40
39
  export function coerceField(def: ScalarDef, raw: unknown): Coerced {
41
40
  const value = coerceScalar(def, raw);
@@ -76,7 +75,7 @@ export interface WireOptions {
76
75
 
77
76
  /**
78
77
  * The JSON schema a provider sees: an allow-list of JSON-schema keys, with
79
- * `ask`, `extract` and `optional` stripped. Closed (`additionalProperties:
78
+ * `label`, `ask`, `extract` and `optional` stripped. Closed (`additionalProperties:
80
79
  * false`); every property required unless a parameter says `optional`.
81
80
  */
82
81
  export function toWireSchema(defs: FieldDefs | ParamDefs, options: WireOptions = {}): StructuredSchema {
@@ -99,47 +98,3 @@ function wireProperty(def: FieldDef | ParamDef, nullable: boolean): StructuredSc
99
98
  if (nullable) out.type = [def.type, "null"];
100
99
  return out;
101
100
  }
102
-
103
- /**
104
- * Merge field rows authored per flow into the agent's one field set. Two
105
- * rows for one slug must agree on type and enum; the first non-empty `ask`
106
- * and `description` win.
107
- */
108
- export function buildSchema(groups: Array<{ id: string; fields: FieldDefs }>): FieldDefs {
109
- const merged: FieldDefs = {};
110
- const owner: Record<string, string> = {};
111
- for (const group of groups) {
112
- for (const [slug, def] of Object.entries(group.fields)) {
113
- const seen = merged[slug];
114
- if (!seen) {
115
- merged[slug] = { ...def };
116
- owner[slug] = group.id;
117
- continue;
118
- }
119
- if (seen.type !== def.type) {
120
- throw new FlowConfigurationError(
121
- `[FlowConfigurationError] field "${slug}" has two types: "${seen.type}" in "${owner[slug]}", ` +
122
- `"${def.type}" in "${group.id}". Give one slug one type.`,
123
- );
124
- }
125
- if (seen.enum && def.enum && !sameList(seen.enum, def.enum)) {
126
- throw new FlowConfigurationError(
127
- `[FlowConfigurationError] field "${slug}" has two option lists: in "${owner[slug]}" and "${group.id}". ` +
128
- `Give one slug one list.`,
129
- );
130
- }
131
- merged[slug] = {
132
- ...seen,
133
- enum: seen.enum ?? def.enum,
134
- ask: seen.ask ?? def.ask,
135
- description: seen.description ?? def.description,
136
- extract: seen.extract ?? def.extract,
137
- };
138
- }
139
- }
140
- return merged;
141
- }
142
-
143
- function sameList(a: readonly (string | number)[], b: readonly (string | number)[]): boolean {
144
- return a.length === b.length && a.every((v, i) => v === b[i]);
145
- }
@@ -5,6 +5,14 @@
5
5
  * per-turn context) and `input` (the run's trigger payload). A path that
6
6
  * resolves to nothing keeps its placeholder, so a typo stays visible instead
7
7
  * of vanishing into an empty string.
8
+ *
9
+ * A path the host answered with nothing is a different case: it knows the
10
+ * field and knows it is blank. Then the placeholder goes and `tidy` closes the
11
+ * gap it left, so "Ola {{context.lead.name}}, tudo bem?" sends "Ola, tudo bem?"
12
+ * and never "Ola , tudo bem?". Two things count as blank: an empty string, and
13
+ * a path that walks THROUGH a null — `context.lead` being `null` means there
14
+ * is no lead, so "the lead's name" is blank, not mistyped. A null at the end of
15
+ * a path is still unknown: a field that collected nothing keeps its braces.
8
16
  */
9
17
 
10
18
  export interface TemplateScope {
@@ -15,11 +23,45 @@ export interface TemplateScope {
15
23
 
16
24
  const PLACEHOLDER = /\{\{\s*([^}\s]+)\s*\}\}/g;
17
25
 
26
+ /** The path ran into a `null` on its way down: the container the host named is absent. */
27
+ const ABSENT = Symbol("absent");
28
+
18
29
  export function render(template: string, scope: TemplateScope): string {
19
- return template.replace(PLACEHOLDER, (match, path: string) => {
30
+ let emptied = false;
31
+ const out = template.replace(PLACEHOLDER, (match, path: string) => {
20
32
  const value = lookup(scope, path.split("."));
21
- return value === undefined || value === null ? match : stringify(value);
33
+ if (value === ABSENT) {
34
+ emptied = true;
35
+ return "";
36
+ }
37
+ if (value === undefined || value === null) return match;
38
+ const text = stringify(value);
39
+ if (text === "") emptied = true;
40
+ return text;
22
41
  });
42
+ return emptied ? tidy(out) : out;
43
+ }
44
+
45
+ /**
46
+ * Close the hole an empty value leaves: a doubled space, a space before
47
+ * punctuation, a comma left before the end of a sentence or before another
48
+ * comma ("Oi, {{name}}!" gives "Oi!", not "Oi,!"; "Oi, {{name}}, tudo bem?"
49
+ * gives "Oi, tudo bem?", not "Oi,, tudo bem?"), punctuation stranded at the
50
+ * start of a line ("{{greeting}}, {{name}}! Tudo bem?" gives "Tudo bem?"), a
51
+ * space at the end of a line.
52
+ *
53
+ * Deliberately narrow. It only runs on a string where something substituted to
54
+ * "", and it only collapses a run of spaces that follows a visible character,
55
+ * so indentation in a markdown list survives. A line that is only punctuation
56
+ * keeps it, so a message never renders to nothing.
57
+ */
58
+ function tidy(text: string): string {
59
+ return text
60
+ .replace(/(?<=\S)[ \t]{2,}/g, " ")
61
+ .replace(/ +([,.;:!?\u2026])/g, "$1")
62
+ .replace(/[,;]+(?=[,;.!?\u2026])/g, "")
63
+ .replace(/^([ \t]*)[,;:!?]+[ \t]+(?=\S)/gm, "$1")
64
+ .replace(/[ \t]+$/gm, "");
23
65
  }
24
66
 
25
67
  /** `render` over every string inside a value, recursively. Non-strings pass through. */
@@ -37,7 +79,8 @@ export function renderDeep<T>(value: T, scope: TemplateScope): T {
37
79
  function lookup(root: unknown, keys: string[]): unknown {
38
80
  let current = root;
39
81
  for (const key of keys) {
40
- if (current === null || typeof current !== "object") return undefined;
82
+ if (current === null) return ABSENT;
83
+ if (typeof current !== "object") return undefined;
41
84
  current = (current as Record<string, unknown>)[key];
42
85
  }
43
86
  return current;
@@ -1,26 +0,0 @@
1
- /**
2
- * AI provider exports.
3
- *
4
- * Every provider here is a thin binding over `@providerkit/core`: the vendor
5
- * knowledge lives in that package, and these classes supply the naming,
6
- * capabilities and construction this framework's seam expects.
7
- */
8
- export { AnthropicProvider } from "./AnthropicProvider.js";
9
- export type { AnthropicProviderOptions } from "./AnthropicProvider.js";
10
- export { GeminiProvider } from "./GeminiProvider.js";
11
- export type { GeminiProviderOptions } from "./GeminiProvider.js";
12
- export { OpenAIProvider } from "./OpenAIProvider.js";
13
- export type { OpenAIProviderOptions } from "./OpenAIProvider.js";
14
- export { OpenRouterProvider } from "./OpenRouterProvider.js";
15
- export type { OpenRouterProviderOptions } from "./OpenRouterProvider.js";
16
- export { DeepSeekProvider } from "./DeepSeekProvider.js";
17
- export type { DeepSeekProviderOptions } from "./DeepSeekProvider.js";
18
- export { OpenAICompatibleProvider } from "./OpenAICompatibleProvider.js";
19
- export type { JsonWithTools, OpenAICompatibleProviderInit, StructuredOutputMode, } from "./OpenAICompatibleProvider.js";
20
- export { createOpenAICompatibleProvider } from "./GenericOpenAICompatibleProvider.js";
21
- export type { OpenAICompatibleOptions } from "./GenericOpenAICompatibleProvider.js";
22
- export { ProviderAdapter, resolveRetryConfig } from "./ProviderAdapter.js";
23
- export type { ProviderAdapterInit, RequestConfig, RetryConfig } from "./ProviderAdapter.js";
24
- export { ZaiProvider } from "./ZaiProvider.js";
25
- export type { ZaiProviderOptions } from "./ZaiProvider.js";
26
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,YAAY,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,YAAY,EACV,aAAa,EACb,4BAA4B,EAC5B,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AACtF,YAAY,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAEpF,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE5F,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -1,30 +0,0 @@
1
- "use strict";
2
- /**
3
- * AI provider exports.
4
- *
5
- * Every provider here is a thin binding over `@providerkit/core`: the vendor
6
- * knowledge lives in that package, and these classes supply the naming,
7
- * capabilities and construction this framework's seam expects.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ZaiProvider = exports.resolveRetryConfig = exports.ProviderAdapter = exports.createOpenAICompatibleProvider = exports.OpenAICompatibleProvider = exports.DeepSeekProvider = exports.OpenRouterProvider = exports.OpenAIProvider = exports.GeminiProvider = exports.AnthropicProvider = void 0;
11
- var AnthropicProvider_js_1 = require("./AnthropicProvider.js");
12
- Object.defineProperty(exports, "AnthropicProvider", { enumerable: true, get: function () { return AnthropicProvider_js_1.AnthropicProvider; } });
13
- var GeminiProvider_js_1 = require("./GeminiProvider.js");
14
- Object.defineProperty(exports, "GeminiProvider", { enumerable: true, get: function () { return GeminiProvider_js_1.GeminiProvider; } });
15
- var OpenAIProvider_js_1 = require("./OpenAIProvider.js");
16
- Object.defineProperty(exports, "OpenAIProvider", { enumerable: true, get: function () { return OpenAIProvider_js_1.OpenAIProvider; } });
17
- var OpenRouterProvider_js_1 = require("./OpenRouterProvider.js");
18
- Object.defineProperty(exports, "OpenRouterProvider", { enumerable: true, get: function () { return OpenRouterProvider_js_1.OpenRouterProvider; } });
19
- var DeepSeekProvider_js_1 = require("./DeepSeekProvider.js");
20
- Object.defineProperty(exports, "DeepSeekProvider", { enumerable: true, get: function () { return DeepSeekProvider_js_1.DeepSeekProvider; } });
21
- var OpenAICompatibleProvider_js_1 = require("./OpenAICompatibleProvider.js");
22
- Object.defineProperty(exports, "OpenAICompatibleProvider", { enumerable: true, get: function () { return OpenAICompatibleProvider_js_1.OpenAICompatibleProvider; } });
23
- var GenericOpenAICompatibleProvider_js_1 = require("./GenericOpenAICompatibleProvider.js");
24
- Object.defineProperty(exports, "createOpenAICompatibleProvider", { enumerable: true, get: function () { return GenericOpenAICompatibleProvider_js_1.createOpenAICompatibleProvider; } });
25
- var ProviderAdapter_js_1 = require("./ProviderAdapter.js");
26
- Object.defineProperty(exports, "ProviderAdapter", { enumerable: true, get: function () { return ProviderAdapter_js_1.ProviderAdapter; } });
27
- Object.defineProperty(exports, "resolveRetryConfig", { enumerable: true, get: function () { return ProviderAdapter_js_1.resolveRetryConfig; } });
28
- var ZaiProvider_js_1 = require("./ZaiProvider.js");
29
- Object.defineProperty(exports, "ZaiProvider", { enumerable: true, get: function () { return ZaiProvider_js_1.ZaiProvider; } });
30
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/providers/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAG1B,yDAAqD;AAA5C,mHAAA,cAAc,OAAA;AAGvB,yDAAqD;AAA5C,mHAAA,cAAc,OAAA;AAGvB,iEAA6D;AAApD,2HAAA,kBAAkB,OAAA;AAG3B,6DAAyD;AAAhD,uHAAA,gBAAgB,OAAA;AAGzB,6EAAyE;AAAhE,uIAAA,wBAAwB,OAAA;AAOjC,2FAAsF;AAA7E,oJAAA,8BAA8B,OAAA;AAGvC,2DAA2E;AAAlE,qHAAA,eAAe,OAAA;AAAE,wHAAA,kBAAkB,OAAA;AAG5C,mDAA+C;AAAtC,6GAAA,WAAW,OAAA"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Deep clone utility to avoid adding large dependencies like lodash.
3
- * Handles objects, arrays, dates, and primitives.
4
- * @param obj - The object to clone
5
- * @returns A deep copy of the object
6
- */
7
- export declare function cloneDeep<T>(obj: T): T;
8
- //# sourceMappingURL=clone.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../../src/utils/clone.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CA0BtC"}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cloneDeep = cloneDeep;
4
- /**
5
- * Deep clone utility to avoid adding large dependencies like lodash.
6
- * Handles objects, arrays, dates, and primitives.
7
- * @param obj - The object to clone
8
- * @returns A deep copy of the object
9
- */
10
- function cloneDeep(obj) {
11
- if (obj === null || typeof obj !== "object") {
12
- return obj;
13
- }
14
- if (obj instanceof Date) {
15
- return new Date(obj.getTime());
16
- }
17
- if (Array.isArray(obj)) {
18
- const arrCopy = [];
19
- for (let i = 0; i < obj.length; i++) {
20
- arrCopy[i] = cloneDeep(obj[i]);
21
- }
22
- return arrCopy;
23
- }
24
- const objCopy = {};
25
- for (const key in obj) {
26
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
27
- objCopy[key] = cloneDeep(obj[key]);
28
- }
29
- }
30
- return objCopy;
31
- }
32
- //# sourceMappingURL=clone.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clone.js","sourceRoot":"","sources":["../../../src/utils/clone.ts"],"names":[],"mappings":";;AAOA,8BA0BC;AAhCD;;;;;GAKG;AACH,SAAgB,SAAS,CAAI,GAAM;IACjC,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5C,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAI,GAAG,YAAY,IAAI,EAAE,CAAC;QACxB,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAM,CAAC;IACtC,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,OAAO,GAAc,EAAE,CAAC;QAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAEpC,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,OAAY,CAAC;IACtB,CAAC;IAED,MAAM,OAAO,GAA4B,EAAE,CAAC;IAC5C,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;YACnD,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED,OAAO,OAAY,CAAC;AACtB,CAAC"}