@falai/agent 4.0.0-alpha.9 → 4.0.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 (287) hide show
  1. package/README.md +2 -0
  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 +21 -7
  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 +282 -60
  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 +39 -0
  19. package/dist/cjs/core/Prompt.js.map +1 -1
  20. package/dist/cjs/core/Runner.d.ts +37 -4
  21. package/dist/cjs/core/Runner.d.ts.map +1 -1
  22. package/dist/cjs/core/Runner.js +281 -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 +63 -19
  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 +18 -42
  30. package/dist/cjs/core/Understand.js.map +1 -1
  31. package/dist/cjs/core/contracts.d.ts +26 -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 +26 -11
  63. package/dist/cjs/providers/ProviderAdapter.d.ts.map +1 -1
  64. package/dist/cjs/providers/ProviderAdapter.js +13 -13
  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 +14 -3
  69. package/dist/cjs/types/agent.d.ts.map +1 -1
  70. package/dist/cjs/types/ai.d.ts +10 -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 +17 -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 +2 -0
  89. package/dist/cjs/utils/outcomes.d.ts.map +1 -1
  90. package/dist/cjs/utils/outcomes.js +2 -0
  91. package/dist/cjs/utils/outcomes.js.map +1 -1
  92. package/dist/cjs/utils/schema.d.ts +3 -12
  93. package/dist/cjs/utils/schema.d.ts.map +1 -1
  94. package/dist/cjs/utils/schema.js +3 -43
  95. package/dist/cjs/utils/schema.js.map +1 -1
  96. package/dist/cjs/utils/template.d.ts.map +1 -1
  97. package/dist/cjs/utils/template.js +9 -2
  98. package/dist/cjs/utils/template.js.map +1 -1
  99. package/dist/core/Agent.d.ts +8 -1
  100. package/dist/core/Agent.d.ts.map +1 -1
  101. package/dist/core/Agent.js +19 -1
  102. package/dist/core/Agent.js.map +1 -1
  103. package/dist/core/CompactionEngine.d.ts.map +1 -1
  104. package/dist/core/CompactionEngine.js +21 -7
  105. package/dist/core/CompactionEngine.js.map +1 -1
  106. package/dist/core/FlowSpec.d.ts +21 -2
  107. package/dist/core/FlowSpec.d.ts.map +1 -1
  108. package/dist/core/FlowSpec.js +281 -61
  109. package/dist/core/FlowSpec.js.map +1 -1
  110. package/dist/core/Migrate.d.ts.map +1 -1
  111. package/dist/core/Migrate.js +3 -1
  112. package/dist/core/Migrate.js.map +1 -1
  113. package/dist/core/Prompt.d.ts +16 -0
  114. package/dist/core/Prompt.d.ts.map +1 -1
  115. package/dist/core/Prompt.js +37 -0
  116. package/dist/core/Prompt.js.map +1 -1
  117. package/dist/core/Runner.d.ts +37 -4
  118. package/dist/core/Runner.d.ts.map +1 -1
  119. package/dist/core/Runner.js +282 -73
  120. package/dist/core/Runner.js.map +1 -1
  121. package/dist/core/Speak.d.ts.map +1 -1
  122. package/dist/core/Speak.js +64 -20
  123. package/dist/core/Speak.js.map +1 -1
  124. package/dist/core/Understand.d.ts +6 -3
  125. package/dist/core/Understand.d.ts.map +1 -1
  126. package/dist/core/Understand.js +18 -42
  127. package/dist/core/Understand.js.map +1 -1
  128. package/dist/core/contracts.d.ts +26 -6
  129. package/dist/core/contracts.d.ts.map +1 -1
  130. package/dist/index.d.ts +1 -1
  131. package/dist/index.d.ts.map +1 -1
  132. package/dist/persistence/OpenSearchStore.d.ts +2 -1
  133. package/dist/persistence/OpenSearchStore.d.ts.map +1 -1
  134. package/dist/persistence/OpenSearchStore.js +2 -2
  135. package/dist/persistence/OpenSearchStore.js.map +1 -1
  136. package/dist/persistence/RedisStore.d.ts +1 -1
  137. package/dist/persistence/RedisStore.d.ts.map +1 -1
  138. package/dist/providers/AnthropicProvider.d.ts +2 -5
  139. package/dist/providers/AnthropicProvider.d.ts.map +1 -1
  140. package/dist/providers/AnthropicProvider.js +3 -4
  141. package/dist/providers/AnthropicProvider.js.map +1 -1
  142. package/dist/providers/DeepSeekProvider.d.ts.map +1 -1
  143. package/dist/providers/DeepSeekProvider.js +3 -4
  144. package/dist/providers/DeepSeekProvider.js.map +1 -1
  145. package/dist/providers/FallbackAiProvider.js +1 -1
  146. package/dist/providers/FallbackAiProvider.js.map +1 -1
  147. package/dist/providers/GeminiProvider.d.ts +1 -2
  148. package/dist/providers/GeminiProvider.d.ts.map +1 -1
  149. package/dist/providers/GeminiProvider.js +3 -4
  150. package/dist/providers/GeminiProvider.js.map +1 -1
  151. package/dist/providers/GenericOpenAICompatibleProvider.js +4 -4
  152. package/dist/providers/GenericOpenAICompatibleProvider.js.map +1 -1
  153. package/dist/providers/OpenAIProvider.d.ts.map +1 -1
  154. package/dist/providers/OpenAIProvider.js +3 -4
  155. package/dist/providers/OpenAIProvider.js.map +1 -1
  156. package/dist/providers/OpenRouterProvider.d.ts.map +1 -1
  157. package/dist/providers/OpenRouterProvider.js +4 -3
  158. package/dist/providers/OpenRouterProvider.js.map +1 -1
  159. package/dist/providers/ProviderAdapter.d.ts +26 -11
  160. package/dist/providers/ProviderAdapter.d.ts.map +1 -1
  161. package/dist/providers/ProviderAdapter.js +14 -14
  162. package/dist/providers/ProviderAdapter.js.map +1 -1
  163. package/dist/providers/ZaiProvider.js +1 -1
  164. package/dist/providers/ZaiProvider.js.map +1 -1
  165. package/dist/types/agent.d.ts +14 -3
  166. package/dist/types/agent.d.ts.map +1 -1
  167. package/dist/types/ai.d.ts +10 -6
  168. package/dist/types/ai.d.ts.map +1 -1
  169. package/dist/types/compaction.d.ts +1 -0
  170. package/dist/types/compaction.d.ts.map +1 -1
  171. package/dist/types/errors.d.ts +4 -9
  172. package/dist/types/errors.d.ts.map +1 -1
  173. package/dist/types/errors.js +12 -12
  174. package/dist/types/errors.js.map +1 -1
  175. package/dist/types/flow.d.ts +17 -1
  176. package/dist/types/flow.d.ts.map +1 -1
  177. package/dist/types/history.d.ts +0 -7
  178. package/dist/types/history.d.ts.map +1 -1
  179. package/dist/types/index.d.ts +2 -2
  180. package/dist/types/index.d.ts.map +1 -1
  181. package/dist/types/session.d.ts +4 -2
  182. package/dist/types/session.d.ts.map +1 -1
  183. package/dist/utils/clock.js +1 -1
  184. package/dist/utils/clock.js.map +1 -1
  185. package/dist/utils/outcomes.d.ts +2 -0
  186. package/dist/utils/outcomes.d.ts.map +1 -1
  187. package/dist/utils/outcomes.js +2 -0
  188. package/dist/utils/outcomes.js.map +1 -1
  189. package/dist/utils/schema.d.ts +3 -12
  190. package/dist/utils/schema.d.ts.map +1 -1
  191. package/dist/utils/schema.js +3 -42
  192. package/dist/utils/schema.js.map +1 -1
  193. package/dist/utils/template.d.ts.map +1 -1
  194. package/dist/utils/template.js +9 -2
  195. package/dist/utils/template.js.map +1 -1
  196. package/docs/concepts/architecture.md +2 -2
  197. package/docs/concepts/collection.md +40 -5
  198. package/docs/concepts/pipeline.md +10 -7
  199. package/docs/concepts/runs-and-waits.md +2 -2
  200. package/docs/guides/actions-and-events.md +1 -1
  201. package/docs/guides/branching.md +4 -2
  202. package/docs/guides/compaction.md +2 -2
  203. package/docs/guides/error-handling.md +2 -2
  204. package/docs/guides/flow-control.md +4 -2
  205. package/docs/guides/persistence.md +2 -2
  206. package/docs/guides/testing.md +1 -1
  207. package/docs/guides/triggers.md +3 -3
  208. package/docs/migration/v3-to-v4.md +8 -7
  209. package/docs/reference/actions-events-conditions.md +1 -1
  210. package/docs/reference/agent.md +9 -5
  211. package/docs/reference/branches.md +1 -1
  212. package/docs/reference/errors.md +14 -11
  213. package/docs/reference/fields.md +5 -3
  214. package/docs/reference/flow-spec.md +35 -8
  215. package/docs/reference/flow.md +8 -3
  216. package/docs/reference/outcomes.md +4 -2
  217. package/docs/reference/providers.md +5 -3
  218. package/docs/reference/session.md +2 -0
  219. package/docs/reference/step.md +9 -5
  220. package/docs/reference/stores.md +5 -3
  221. package/docs/reference/trigger.md +2 -2
  222. package/docs/rfc/v4-one-flow.md +5 -3
  223. package/docs/start/01-install.md +2 -0
  224. package/docs/start/05-go-to-production.md +18 -1
  225. package/examples/05-branches.ts +1 -1
  226. package/examples/06-triggers-and-waits.ts +4 -3
  227. package/package.json +4 -3
  228. package/src/core/Agent.ts +23 -2
  229. package/src/core/CompactionEngine.ts +25 -9
  230. package/src/core/FlowSpec.ts +296 -70
  231. package/src/core/Migrate.ts +2 -1
  232. package/src/core/Prompt.ts +40 -0
  233. package/src/core/Runner.ts +279 -69
  234. package/src/core/Speak.ts +67 -19
  235. package/src/core/Understand.ts +24 -44
  236. package/src/core/contracts.ts +26 -4
  237. package/src/index.ts +1 -1
  238. package/src/persistence/OpenSearchStore.ts +3 -2
  239. package/src/persistence/RedisStore.ts +1 -1
  240. package/src/providers/AnthropicProvider.ts +4 -9
  241. package/src/providers/DeepSeekProvider.ts +2 -4
  242. package/src/providers/FallbackAiProvider.ts +1 -1
  243. package/src/providers/GeminiProvider.ts +3 -6
  244. package/src/providers/GenericOpenAICompatibleProvider.ts +4 -4
  245. package/src/providers/OpenAIProvider.ts +3 -4
  246. package/src/providers/OpenRouterProvider.ts +4 -2
  247. package/src/providers/ProviderAdapter.ts +35 -33
  248. package/src/providers/ZaiProvider.ts +1 -1
  249. package/src/types/agent.ts +15 -4
  250. package/src/types/ai.ts +10 -6
  251. package/src/types/compaction.ts +1 -0
  252. package/src/types/errors.ts +11 -12
  253. package/src/types/flow.ts +17 -1
  254. package/src/types/history.ts +0 -10
  255. package/src/types/index.ts +1 -1
  256. package/src/types/session.ts +5 -1
  257. package/src/utils/clock.ts +1 -1
  258. package/src/utils/outcomes.ts +2 -0
  259. package/src/utils/schema.ts +3 -48
  260. package/src/utils/template.ts +9 -2
  261. package/dist/cjs/providers/index.d.ts +0 -26
  262. package/dist/cjs/providers/index.d.ts.map +0 -1
  263. package/dist/cjs/providers/index.js +0 -30
  264. package/dist/cjs/providers/index.js.map +0 -1
  265. package/dist/cjs/utils/clone.d.ts +0 -8
  266. package/dist/cjs/utils/clone.d.ts.map +0 -1
  267. package/dist/cjs/utils/clone.js +0 -32
  268. package/dist/cjs/utils/clone.js.map +0 -1
  269. package/dist/cjs/utils/index.d.ts +0 -9
  270. package/dist/cjs/utils/index.d.ts.map +0 -1
  271. package/dist/cjs/utils/index.js +0 -29
  272. package/dist/cjs/utils/index.js.map +0 -1
  273. package/dist/providers/index.d.ts +0 -26
  274. package/dist/providers/index.d.ts.map +0 -1
  275. package/dist/providers/index.js +0 -17
  276. package/dist/providers/index.js.map +0 -1
  277. package/dist/utils/clone.d.ts +0 -8
  278. package/dist/utils/clone.d.ts.map +0 -1
  279. package/dist/utils/clone.js +0 -29
  280. package/dist/utils/clone.js.map +0 -1
  281. package/dist/utils/index.d.ts +0 -9
  282. package/dist/utils/index.d.ts.map +0 -1
  283. package/dist/utils/index.js +0 -9
  284. package/dist/utils/index.js.map +0 -1
  285. package/src/providers/index.ts +0 -38
  286. package/src/utils/clone.ts +0 -34
  287. package/src/utils/index.ts +0 -18
@@ -25,12 +25,10 @@ import {
25
25
  isCompleteJson,
26
26
  parseToolArgs,
27
27
  probeJsonWithTools,
28
- requireContent,
29
- streamWatch,
30
28
  streamWithBackupModels,
31
- watchChunks,
32
29
  withFallbackProviders,
33
30
  withStreamRetry,
31
+ withWatchdog,
34
32
  type ChatMessage,
35
33
  type Effort,
36
34
  type FallbackOptions,
@@ -59,13 +57,15 @@ import { logger } from "../utils/logger.js";
59
57
  /** Provider timeout (ms) + retry count, after defaults are applied. */
60
58
  export interface RetryConfig {
61
59
  /**
62
- * How long a stream may stay SILENT before it is considered wedged.
60
+ * How long a stream may stay SILENT, once the response has started, before
61
+ * it is considered dead.
63
62
  *
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.
63
+ * It bounds silence, not the whole call: the gap between any two bytes,
64
+ * keep-alives included, so a provider that pings while it works is left
65
+ * alone. The wait for the first chunk, and a stream that sends only
66
+ * keep-alives, are bounded by core's progress clock instead: five minutes
67
+ * (`STREAM_PROGRESS_MS`), or `timeout` when that is longer. Some backends
68
+ * send nothing for minutes on a large turn and are healthy the whole time.
69
69
  */
70
70
  timeout: number;
71
71
  /** Retries AFTER the first attempt, so `0` still performs one call. */
@@ -90,10 +90,8 @@ export function resolveRetryConfig(input?: { timeout?: number; retries?: number
90
90
  /**
91
91
  * Request defaults sent with every call.
92
92
  *
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.
93
+ * Only the fields every supported shape has, so a field set on one provider
94
+ * means the same on another and no vendor's package enters the dependency tree.
97
95
  */
98
96
  export interface RequestConfig {
99
97
  temperature?: number;
@@ -104,7 +102,9 @@ export interface RequestConfig {
104
102
  * How hard the model thinks, bound as this provider's default. What absent
105
103
  * means is the shape's own business, not one rule: on Gemini it is the
106
104
  * 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
105
+ * sent, so the model decides — `medium` on GPT-5 and older, and on
106
+ * OpenRouter GLM 5.3 Flash thinks on most of the hosts that serve it. Set
107
+ * `"none"` where a turn must not think; on the Anthropic shape — so
108
108
  * `AnthropicProvider` and `ZaiProvider` — `@providerkit/core` resolves an
109
109
  * absent effort to `"none"`, and Z.ai is sent an explicit disabled marker
110
110
  * because its endpoint reads silence as thinking ON. Set a level to ask for
@@ -290,6 +290,14 @@ export abstract class ProviderAdapter implements AiProvider {
290
290
  public abstract readonly capabilities: ProviderCapabilities;
291
291
 
292
292
  protected readonly provider: Provider;
293
+ /** `provider` without the fallback chain: the one model this adapter was built for. */
294
+ private readonly primary: Provider;
295
+ /**
296
+ * `provider` behind core's watchdog, for this adapter's own calls only. Kept
297
+ * apart from `coreProvider`, which another adapter's fallback chain wraps in
298
+ * its own watchdog.
299
+ */
300
+ private readonly watched: Provider;
293
301
  protected readonly primaryModel: string;
294
302
  protected readonly backupModels: string[];
295
303
  protected readonly retryConfig: RetryConfig;
@@ -304,6 +312,7 @@ export abstract class ProviderAdapter implements AiProvider {
304
312
  this.primaryModel = init.model;
305
313
  this.backupModels = init.backupModels ?? [];
306
314
  this.retryConfig = resolveRetryConfig(init.retryConfig);
315
+ this.primary = init.provider;
307
316
 
308
317
  if (init.fallbacks && init.fallbacks.length > 0) {
309
318
  const coreProviders: Provider[] = [
@@ -320,6 +329,9 @@ export abstract class ProviderAdapter implements AiProvider {
320
329
  } else {
321
330
  this.provider = init.provider;
322
331
  }
332
+ // No progressMs: core raises it to idleMs when that is longer, so a long
333
+ // timeout (an OpenCode Go chain rotating under it) is not cut at five minutes.
334
+ this.watched = withWatchdog(this.provider, { idleMs: this.retryConfig.timeout });
323
335
  }
324
336
 
325
337
  /**
@@ -337,9 +349,14 @@ export abstract class ProviderAdapter implements AiProvider {
337
349
  * boot when it is `null` — that model cannot serve this framework's turns).
338
350
  * Log `calls`: `0/3 and 3/3` is what makes the next model swap's regression
339
351
  * obvious. Costs `samples × 2` short calls, and errors propagate.
352
+ *
353
+ * It asks the primary alone, never the fallback chain. The answer configures
354
+ * this adapter's model; a call the chain handed to a fallback would score
355
+ * another model as this one. Each fallback is an adapter of its own: probe it
356
+ * the same way.
340
357
  */
341
358
  async probeJsonWithTools(opts?: ProbeOptions): Promise<JsonWithToolsProbe> {
342
- return probeJsonWithTools(this.provider, {
359
+ return probeJsonWithTools(this.primary, {
343
360
  model: this.primaryModel,
344
361
  ...(opts ?? {}),
345
362
  });
@@ -373,28 +390,14 @@ export abstract class ProviderAdapter implements AiProvider {
373
390
  : {}),
374
391
  ...(input.parameters?.reasoning?.effort ? { effort: input.parameters.reasoning.effort } : {}),
375
392
  ...(json ? { json } : {}),
393
+ ...(input.sessionId ? { sessionId: input.sessionId } : {}),
376
394
  };
377
395
 
378
396
  const attempt = (model: string) =>
379
397
  withStreamRetry<ProviderChunk>(
380
398
  (signal) => {
381
399
  acc.model = model;
382
- const watch = streamWatch({
383
- provider: this.name,
384
- idleMs: this.retryConfig.timeout,
385
- signal,
386
- });
387
- return requireContent(
388
- this.name,
389
- watchChunks(
390
- watch,
391
- this.provider.createStream(messages, tools, {
392
- ...opts,
393
- model,
394
- signal: watch.signal,
395
- }),
396
- ),
397
- );
400
+ return this.watched.createStream(messages, tools, { ...opts, model, signal });
398
401
  },
399
402
  {
400
403
  maxAttempts: this.retryConfig.retries + 1,
@@ -468,8 +471,7 @@ export abstract class ProviderAdapter implements AiProvider {
468
471
  tokensUsed: acc.promptTokens + (acc.completionTokens ?? 0),
469
472
  promptTokens: acc.promptTokens,
470
473
  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.
474
+ // The cache-hit subset of the prompt, billed far cheaper.
473
475
  cachedInputTokens: acc.cachedInputTokens,
474
476
  }
475
477
  : {}),
@@ -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
 
@@ -112,6 +116,13 @@ export type TurnKind =
112
116
 
113
117
  export type TurnInput<C = unknown, D = unknown> = TurnBase<C, D> & TurnKind;
114
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
+
115
126
  // ── turn() result ───────────────────────────────────────────────────────
116
127
 
117
128
  export interface OutboundMessage {
@@ -127,7 +138,7 @@ export interface OutboundMessage {
127
138
  stepId?: string;
128
139
  }
129
140
 
130
- /** 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 })`. */
131
142
  export interface ScheduleEntry {
132
143
  key: string;
133
144
  at: Date;
@@ -138,7 +149,7 @@ export interface ScheduleEntry {
138
149
  export type EndReason = "end" | "flow" | "reset" | "skipped" | "failed" | "replaced";
139
150
 
140
151
  export interface TurnResult<D = unknown> {
141
- /** Version unchanged; the host bumps it on save. */
152
+ /** Version unchanged by a turn; `Store.save` bumps it and returns the saved session. */
142
153
  session: Session<D>;
143
154
  /** False: save nothing, send nothing. */
144
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;
@@ -56,6 +54,12 @@ export interface GenerateMessageInput<TContext = unknown> {
56
54
  };
57
55
  /** Abort signal for cancellation */
58
56
  signal?: AbortSignal;
57
+ /**
58
+ * The conversation this call belongs to. Gateways that route and cache per
59
+ * conversation read it (OpenCode Go takes it as `x-opencode-session`);
60
+ * every other endpoint ignores it. A turn sets it to the session id.
61
+ */
62
+ sessionId?: string;
59
63
  }
60
64
 
61
65
  /**
@@ -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,14 @@ 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 one AI reply answers it
194
+ * and asks this question, in these words where they fit. Either way it counts
195
+ * as one ask. Any later ask is the AI's own wording. Needs `collect`.
196
+ */
197
+ question?: Template;
188
198
  /** Times a field may be asked before it is skipped. Default 3. */
189
199
  maxAsks?: number;
190
200
  branches?: Branch<C, D>[];
@@ -253,9 +263,15 @@ export interface Flow<C = unknown, D = unknown> {
253
263
  anchor?: string;
254
264
  /** Re-checked whenever the run moves. Default: the trigger's `if`. */
255
265
  while?: Pred<C, D>;
266
+ /**
267
+ * The data this flow needs, as agent field slugs. Its talk steps' `collect`
268
+ * says which of it to ask, and in what order; a field no step asks is still
269
+ * noted whenever the lead gives it while the flow holds the conversation.
270
+ */
271
+ collect?: (keyof D & string)[];
256
272
  clearOnStart?: (keyof D & string)[];
257
273
  steps: Step<C, D>[];
258
- /** What the run does after its last step. Default `'end'`. */
274
+ /** What the run does after its last step. Default `'end'`. `'stay'`: the last talk step the run took answers every later message. */
259
275
  onEnd?: "end" | "stay" | "reset";
260
276
  instructions?: Instruction<C, D>[];
261
277
  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,8 @@ export type StepOutcomeCode =
75
77
  | "silenced"
76
78
  // A step
77
79
  | "already-known"
80
+ | "asked-fixed"
81
+ | "fixed-in-reply"
78
82
  | "another-reply"
79
83
  | "already-sent"
80
84
  | "branch"
@@ -124,7 +128,7 @@ export interface StepOutcome {
124
128
  export interface Session<D = unknown> {
125
129
  id: string;
126
130
  v: 4;
127
- /** Optimistic-concurrency version; the host bumps it on save. */
131
+ /** Optimistic-concurrency version. A turn leaves it unchanged; `Store.save` bumps it and returns the saved session. */
128
132
  version: number;
129
133
  data: Partial<D>;
130
134
  /** 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,8 @@ 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",
32
+ "fixed-in-reply": "the customer asked something, so the reply answered it and asked the step's fixed question",
31
33
  "another-reply": "another run already answered this turn",
32
34
  "already-sent": "this message was already sent once",
33
35
  branch: "a branch of this step fired",
@@ -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
- }
@@ -44,16 +44,23 @@ export function render(template: string, scope: TemplateScope): string {
44
44
 
45
45
  /**
46
46
  * Close the hole an empty value leaves: a doubled space, a space before
47
- * punctuation, a space at the end of a line.
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.
48
52
  *
49
53
  * Deliberately narrow. It only runs on a string where something substituted to
50
54
  * "", and it only collapses a run of spaces that follows a visible character,
51
- * so indentation in a markdown list survives.
55
+ * so indentation in a markdown list survives. A line that is only punctuation
56
+ * keeps it, so a message never renders to nothing.
52
57
  */
53
58
  function tidy(text: string): string {
54
59
  return text
55
60
  .replace(/(?<=\S)[ \t]{2,}/g, " ")
56
61
  .replace(/ +([,.;:!?\u2026])/g, "$1")
62
+ .replace(/[,;]+(?=[,;.!?\u2026])/g, "")
63
+ .replace(/^([ \t]*)[,;:!?]+[ \t]+(?=\S)/gm, "$1")
57
64
  .replace(/[ \t]+$/gm, "");
58
65
  }
59
66
 
@@ -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"}
@@ -1,9 +0,0 @@
1
- /**
2
- * Utility functions and helpers
3
- */
4
- export { cloneDeep } from "./clone.js";
5
- export { assertUsableCompletion, effectiveMessageText } from "./completion.js";
6
- export { assistantMessage, eventsToHistory, eventToHistoryItem, historyItemToEvent, historyToEvents, systemMessage, toolMessage, userMessage, } from "./history.js";
7
- export { extractEmbeddedJSONObject, isJSONShaped, parseJSONResponse, tryParseJSONResponse } from "./json.js";
8
- export { logger, LoggerLevel } from "./logger.js";
9
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,WAAW,EACX,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,yBAAyB,EAAE,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC7G,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}