@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.
- package/README.md +2 -0
- package/dist/cjs/core/Agent.d.ts +8 -1
- package/dist/cjs/core/Agent.d.ts.map +1 -1
- package/dist/cjs/core/Agent.js +18 -0
- package/dist/cjs/core/Agent.js.map +1 -1
- package/dist/cjs/core/CompactionEngine.d.ts.map +1 -1
- package/dist/cjs/core/CompactionEngine.js +21 -7
- package/dist/cjs/core/CompactionEngine.js.map +1 -1
- package/dist/cjs/core/FlowSpec.d.ts +21 -2
- package/dist/cjs/core/FlowSpec.d.ts.map +1 -1
- package/dist/cjs/core/FlowSpec.js +282 -60
- package/dist/cjs/core/FlowSpec.js.map +1 -1
- package/dist/cjs/core/Migrate.d.ts.map +1 -1
- package/dist/cjs/core/Migrate.js +3 -1
- package/dist/cjs/core/Migrate.js.map +1 -1
- package/dist/cjs/core/Prompt.d.ts +16 -0
- package/dist/cjs/core/Prompt.d.ts.map +1 -1
- package/dist/cjs/core/Prompt.js +39 -0
- package/dist/cjs/core/Prompt.js.map +1 -1
- package/dist/cjs/core/Runner.d.ts +37 -4
- package/dist/cjs/core/Runner.d.ts.map +1 -1
- package/dist/cjs/core/Runner.js +281 -72
- package/dist/cjs/core/Runner.js.map +1 -1
- package/dist/cjs/core/Speak.d.ts.map +1 -1
- package/dist/cjs/core/Speak.js +63 -19
- package/dist/cjs/core/Speak.js.map +1 -1
- package/dist/cjs/core/Understand.d.ts +6 -3
- package/dist/cjs/core/Understand.d.ts.map +1 -1
- package/dist/cjs/core/Understand.js +18 -42
- package/dist/cjs/core/Understand.js.map +1 -1
- package/dist/cjs/core/contracts.d.ts +26 -6
- package/dist/cjs/core/contracts.d.ts.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/persistence/OpenSearchStore.d.ts +2 -1
- package/dist/cjs/persistence/OpenSearchStore.d.ts.map +1 -1
- package/dist/cjs/persistence/OpenSearchStore.js +2 -2
- package/dist/cjs/persistence/OpenSearchStore.js.map +1 -1
- package/dist/cjs/persistence/RedisStore.d.ts +1 -1
- package/dist/cjs/persistence/RedisStore.d.ts.map +1 -1
- package/dist/cjs/providers/AnthropicProvider.d.ts +2 -5
- package/dist/cjs/providers/AnthropicProvider.d.ts.map +1 -1
- package/dist/cjs/providers/AnthropicProvider.js +3 -4
- package/dist/cjs/providers/AnthropicProvider.js.map +1 -1
- package/dist/cjs/providers/DeepSeekProvider.d.ts.map +1 -1
- package/dist/cjs/providers/DeepSeekProvider.js +3 -4
- package/dist/cjs/providers/DeepSeekProvider.js.map +1 -1
- package/dist/cjs/providers/FallbackAiProvider.js +1 -1
- package/dist/cjs/providers/FallbackAiProvider.js.map +1 -1
- package/dist/cjs/providers/GeminiProvider.d.ts +1 -2
- package/dist/cjs/providers/GeminiProvider.d.ts.map +1 -1
- package/dist/cjs/providers/GeminiProvider.js +3 -4
- package/dist/cjs/providers/GeminiProvider.js.map +1 -1
- package/dist/cjs/providers/GenericOpenAICompatibleProvider.js +4 -4
- package/dist/cjs/providers/GenericOpenAICompatibleProvider.js.map +1 -1
- package/dist/cjs/providers/OpenAIProvider.d.ts.map +1 -1
- package/dist/cjs/providers/OpenAIProvider.js +3 -4
- package/dist/cjs/providers/OpenAIProvider.js.map +1 -1
- package/dist/cjs/providers/OpenRouterProvider.d.ts.map +1 -1
- package/dist/cjs/providers/OpenRouterProvider.js +4 -3
- package/dist/cjs/providers/OpenRouterProvider.js.map +1 -1
- package/dist/cjs/providers/ProviderAdapter.d.ts +26 -11
- package/dist/cjs/providers/ProviderAdapter.d.ts.map +1 -1
- package/dist/cjs/providers/ProviderAdapter.js +13 -13
- package/dist/cjs/providers/ProviderAdapter.js.map +1 -1
- package/dist/cjs/providers/ZaiProvider.js +1 -1
- package/dist/cjs/providers/ZaiProvider.js.map +1 -1
- package/dist/cjs/types/agent.d.ts +14 -3
- package/dist/cjs/types/agent.d.ts.map +1 -1
- package/dist/cjs/types/ai.d.ts +10 -6
- package/dist/cjs/types/ai.d.ts.map +1 -1
- package/dist/cjs/types/compaction.d.ts +1 -0
- package/dist/cjs/types/compaction.d.ts.map +1 -1
- package/dist/cjs/types/errors.d.ts +4 -9
- package/dist/cjs/types/errors.d.ts.map +1 -1
- package/dist/cjs/types/errors.js +12 -12
- package/dist/cjs/types/errors.js.map +1 -1
- package/dist/cjs/types/flow.d.ts +17 -1
- package/dist/cjs/types/flow.d.ts.map +1 -1
- package/dist/cjs/types/history.d.ts +0 -7
- package/dist/cjs/types/history.d.ts.map +1 -1
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/session.d.ts +4 -2
- package/dist/cjs/types/session.d.ts.map +1 -1
- package/dist/cjs/utils/clock.js +1 -1
- package/dist/cjs/utils/clock.js.map +1 -1
- package/dist/cjs/utils/outcomes.d.ts +2 -0
- package/dist/cjs/utils/outcomes.d.ts.map +1 -1
- package/dist/cjs/utils/outcomes.js +2 -0
- package/dist/cjs/utils/outcomes.js.map +1 -1
- package/dist/cjs/utils/schema.d.ts +3 -12
- package/dist/cjs/utils/schema.d.ts.map +1 -1
- package/dist/cjs/utils/schema.js +3 -43
- package/dist/cjs/utils/schema.js.map +1 -1
- package/dist/cjs/utils/template.d.ts.map +1 -1
- package/dist/cjs/utils/template.js +9 -2
- package/dist/cjs/utils/template.js.map +1 -1
- package/dist/core/Agent.d.ts +8 -1
- package/dist/core/Agent.d.ts.map +1 -1
- package/dist/core/Agent.js +19 -1
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/CompactionEngine.d.ts.map +1 -1
- package/dist/core/CompactionEngine.js +21 -7
- package/dist/core/CompactionEngine.js.map +1 -1
- package/dist/core/FlowSpec.d.ts +21 -2
- package/dist/core/FlowSpec.d.ts.map +1 -1
- package/dist/core/FlowSpec.js +281 -61
- package/dist/core/FlowSpec.js.map +1 -1
- package/dist/core/Migrate.d.ts.map +1 -1
- package/dist/core/Migrate.js +3 -1
- package/dist/core/Migrate.js.map +1 -1
- package/dist/core/Prompt.d.ts +16 -0
- package/dist/core/Prompt.d.ts.map +1 -1
- package/dist/core/Prompt.js +37 -0
- package/dist/core/Prompt.js.map +1 -1
- package/dist/core/Runner.d.ts +37 -4
- package/dist/core/Runner.d.ts.map +1 -1
- package/dist/core/Runner.js +282 -73
- package/dist/core/Runner.js.map +1 -1
- package/dist/core/Speak.d.ts.map +1 -1
- package/dist/core/Speak.js +64 -20
- package/dist/core/Speak.js.map +1 -1
- package/dist/core/Understand.d.ts +6 -3
- package/dist/core/Understand.d.ts.map +1 -1
- package/dist/core/Understand.js +18 -42
- package/dist/core/Understand.js.map +1 -1
- package/dist/core/contracts.d.ts +26 -6
- package/dist/core/contracts.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/persistence/OpenSearchStore.d.ts +2 -1
- package/dist/persistence/OpenSearchStore.d.ts.map +1 -1
- package/dist/persistence/OpenSearchStore.js +2 -2
- package/dist/persistence/OpenSearchStore.js.map +1 -1
- package/dist/persistence/RedisStore.d.ts +1 -1
- package/dist/persistence/RedisStore.d.ts.map +1 -1
- package/dist/providers/AnthropicProvider.d.ts +2 -5
- package/dist/providers/AnthropicProvider.d.ts.map +1 -1
- package/dist/providers/AnthropicProvider.js +3 -4
- package/dist/providers/AnthropicProvider.js.map +1 -1
- package/dist/providers/DeepSeekProvider.d.ts.map +1 -1
- package/dist/providers/DeepSeekProvider.js +3 -4
- package/dist/providers/DeepSeekProvider.js.map +1 -1
- package/dist/providers/FallbackAiProvider.js +1 -1
- package/dist/providers/FallbackAiProvider.js.map +1 -1
- package/dist/providers/GeminiProvider.d.ts +1 -2
- package/dist/providers/GeminiProvider.d.ts.map +1 -1
- package/dist/providers/GeminiProvider.js +3 -4
- package/dist/providers/GeminiProvider.js.map +1 -1
- package/dist/providers/GenericOpenAICompatibleProvider.js +4 -4
- package/dist/providers/GenericOpenAICompatibleProvider.js.map +1 -1
- package/dist/providers/OpenAIProvider.d.ts.map +1 -1
- package/dist/providers/OpenAIProvider.js +3 -4
- package/dist/providers/OpenAIProvider.js.map +1 -1
- package/dist/providers/OpenRouterProvider.d.ts.map +1 -1
- package/dist/providers/OpenRouterProvider.js +4 -3
- package/dist/providers/OpenRouterProvider.js.map +1 -1
- package/dist/providers/ProviderAdapter.d.ts +26 -11
- package/dist/providers/ProviderAdapter.d.ts.map +1 -1
- package/dist/providers/ProviderAdapter.js +14 -14
- package/dist/providers/ProviderAdapter.js.map +1 -1
- package/dist/providers/ZaiProvider.js +1 -1
- package/dist/providers/ZaiProvider.js.map +1 -1
- package/dist/types/agent.d.ts +14 -3
- package/dist/types/agent.d.ts.map +1 -1
- package/dist/types/ai.d.ts +10 -6
- package/dist/types/ai.d.ts.map +1 -1
- package/dist/types/compaction.d.ts +1 -0
- package/dist/types/compaction.d.ts.map +1 -1
- package/dist/types/errors.d.ts +4 -9
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +12 -12
- package/dist/types/errors.js.map +1 -1
- package/dist/types/flow.d.ts +17 -1
- package/dist/types/flow.d.ts.map +1 -1
- package/dist/types/history.d.ts +0 -7
- package/dist/types/history.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/session.d.ts +4 -2
- package/dist/types/session.d.ts.map +1 -1
- package/dist/utils/clock.js +1 -1
- package/dist/utils/clock.js.map +1 -1
- package/dist/utils/outcomes.d.ts +2 -0
- package/dist/utils/outcomes.d.ts.map +1 -1
- package/dist/utils/outcomes.js +2 -0
- package/dist/utils/outcomes.js.map +1 -1
- package/dist/utils/schema.d.ts +3 -12
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +3 -42
- package/dist/utils/schema.js.map +1 -1
- package/dist/utils/template.d.ts.map +1 -1
- package/dist/utils/template.js +9 -2
- package/dist/utils/template.js.map +1 -1
- package/docs/concepts/architecture.md +2 -2
- package/docs/concepts/collection.md +40 -5
- package/docs/concepts/pipeline.md +10 -7
- package/docs/concepts/runs-and-waits.md +2 -2
- package/docs/guides/actions-and-events.md +1 -1
- package/docs/guides/branching.md +4 -2
- package/docs/guides/compaction.md +2 -2
- package/docs/guides/error-handling.md +2 -2
- package/docs/guides/flow-control.md +4 -2
- package/docs/guides/persistence.md +2 -2
- package/docs/guides/testing.md +1 -1
- package/docs/guides/triggers.md +3 -3
- package/docs/migration/v3-to-v4.md +8 -7
- package/docs/reference/actions-events-conditions.md +1 -1
- package/docs/reference/agent.md +9 -5
- package/docs/reference/branches.md +1 -1
- package/docs/reference/errors.md +14 -11
- package/docs/reference/fields.md +5 -3
- package/docs/reference/flow-spec.md +35 -8
- package/docs/reference/flow.md +8 -3
- package/docs/reference/outcomes.md +4 -2
- package/docs/reference/providers.md +5 -3
- package/docs/reference/session.md +2 -0
- package/docs/reference/step.md +9 -5
- package/docs/reference/stores.md +5 -3
- package/docs/reference/trigger.md +2 -2
- package/docs/rfc/v4-one-flow.md +5 -3
- package/docs/start/01-install.md +2 -0
- package/docs/start/05-go-to-production.md +18 -1
- package/examples/05-branches.ts +1 -1
- package/examples/06-triggers-and-waits.ts +4 -3
- package/package.json +4 -3
- package/src/core/Agent.ts +23 -2
- package/src/core/CompactionEngine.ts +25 -9
- package/src/core/FlowSpec.ts +296 -70
- package/src/core/Migrate.ts +2 -1
- package/src/core/Prompt.ts +40 -0
- package/src/core/Runner.ts +279 -69
- package/src/core/Speak.ts +67 -19
- package/src/core/Understand.ts +24 -44
- package/src/core/contracts.ts +26 -4
- package/src/index.ts +1 -1
- package/src/persistence/OpenSearchStore.ts +3 -2
- package/src/persistence/RedisStore.ts +1 -1
- package/src/providers/AnthropicProvider.ts +4 -9
- package/src/providers/DeepSeekProvider.ts +2 -4
- package/src/providers/FallbackAiProvider.ts +1 -1
- package/src/providers/GeminiProvider.ts +3 -6
- package/src/providers/GenericOpenAICompatibleProvider.ts +4 -4
- package/src/providers/OpenAIProvider.ts +3 -4
- package/src/providers/OpenRouterProvider.ts +4 -2
- package/src/providers/ProviderAdapter.ts +35 -33
- package/src/providers/ZaiProvider.ts +1 -1
- package/src/types/agent.ts +15 -4
- package/src/types/ai.ts +10 -6
- package/src/types/compaction.ts +1 -0
- package/src/types/errors.ts +11 -12
- package/src/types/flow.ts +17 -1
- package/src/types/history.ts +0 -10
- package/src/types/index.ts +1 -1
- package/src/types/session.ts +5 -1
- package/src/utils/clock.ts +1 -1
- package/src/utils/outcomes.ts +2 -0
- package/src/utils/schema.ts +3 -48
- package/src/utils/template.ts +9 -2
- package/dist/cjs/providers/index.d.ts +0 -26
- package/dist/cjs/providers/index.d.ts.map +0 -1
- package/dist/cjs/providers/index.js +0 -30
- package/dist/cjs/providers/index.js.map +0 -1
- package/dist/cjs/utils/clone.d.ts +0 -8
- package/dist/cjs/utils/clone.d.ts.map +0 -1
- package/dist/cjs/utils/clone.js +0 -32
- package/dist/cjs/utils/clone.js.map +0 -1
- package/dist/cjs/utils/index.d.ts +0 -9
- package/dist/cjs/utils/index.d.ts.map +0 -1
- package/dist/cjs/utils/index.js +0 -29
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/providers/index.d.ts +0 -26
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -17
- package/dist/providers/index.js.map +0 -1
- package/dist/utils/clone.d.ts +0 -8
- package/dist/utils/clone.d.ts.map +0 -1
- package/dist/utils/clone.js +0 -29
- package/dist/utils/clone.js.map +0 -1
- package/dist/utils/index.d.ts +0 -9
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -9
- package/dist/utils/index.js.map +0 -1
- package/src/providers/index.ts +0 -38
- package/src/utils/clone.ts +0 -34
- 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
|
|
60
|
+
* How long a stream may stay SILENT, once the response has started, before
|
|
61
|
+
* it is considered dead.
|
|
63
62
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
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
|
|
94
|
-
*
|
|
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
|
|
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.
|
|
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
|
-
|
|
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
|
-
//
|
|
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(
|
|
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({
|
package/src/types/agent.ts
CHANGED
|
@@ -78,8 +78,12 @@ export interface AgentOptions<C = unknown, D = unknown> {
|
|
|
78
78
|
|
|
79
79
|
// ── turn() input ────────────────────────────────────────────────────────
|
|
80
80
|
|
|
81
|
-
/**
|
|
82
|
-
|
|
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
|
|
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;
|
|
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
|
-
*
|
|
12
|
-
* "
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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
|
/**
|
package/src/types/compaction.ts
CHANGED
|
@@ -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
|
package/src/types/errors.ts
CHANGED
|
@@ -5,16 +5,11 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* The normalized provider failure, and the kinds it comes in.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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[];
|
package/src/types/history.ts
CHANGED
|
@@ -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
|
-
}
|
package/src/types/index.ts
CHANGED
|
@@ -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,
|
package/src/types/session.ts
CHANGED
|
@@ -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;
|
|
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. */
|
package/src/utils/clock.ts
CHANGED
|
@@ -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
|
|
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
|
|
package/src/utils/outcomes.ts
CHANGED
|
@@ -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",
|
package/src/utils/schema.ts
CHANGED
|
@@ -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.
|
|
38
|
-
*
|
|
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
|
-
}
|
package/src/utils/template.ts
CHANGED
|
@@ -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
|
|
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"}
|
package/dist/cjs/utils/clone.js
DELETED
|
@@ -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"}
|