@falai/agent 3.4.5 → 4.0.0-alpha.2
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 +41 -34
- package/dist/cjs/core/Agent.d.ts +22 -378
- package/dist/cjs/core/Agent.d.ts.map +1 -1
- package/dist/cjs/core/Agent.js +104 -1178
- 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 +5 -3
- package/dist/cjs/core/CompactionEngine.js.map +1 -1
- package/dist/cjs/core/FlowSpec.d.ts +136 -0
- package/dist/cjs/core/FlowSpec.d.ts.map +1 -0
- package/dist/cjs/core/FlowSpec.js +522 -0
- package/dist/cjs/core/FlowSpec.js.map +1 -0
- package/dist/cjs/core/Migrate.d.ts +38 -0
- package/dist/cjs/core/Migrate.d.ts.map +1 -0
- package/dist/cjs/core/Migrate.js +270 -0
- package/dist/cjs/core/Migrate.js.map +1 -0
- package/dist/cjs/core/Prompt.d.ts +54 -0
- package/dist/cjs/core/Prompt.d.ts.map +1 -0
- package/dist/cjs/core/Prompt.js +143 -0
- package/dist/cjs/core/Prompt.js.map +1 -0
- package/dist/cjs/core/Runner.d.ts +160 -0
- package/dist/cjs/core/Runner.d.ts.map +1 -0
- package/dist/cjs/core/Runner.js +1131 -0
- package/dist/cjs/core/Runner.js.map +1 -0
- package/dist/cjs/core/Speak.d.ts +37 -0
- package/dist/cjs/core/Speak.d.ts.map +1 -0
- package/dist/cjs/core/Speak.js +364 -0
- package/dist/cjs/core/Speak.js.map +1 -0
- package/dist/cjs/core/Understand.d.ts +28 -0
- package/dist/cjs/core/Understand.d.ts.map +1 -0
- package/dist/cjs/core/Understand.js +353 -0
- package/dist/cjs/core/Understand.js.map +1 -0
- package/dist/cjs/core/contracts.d.ts +122 -0
- package/dist/cjs/core/contracts.d.ts.map +1 -0
- package/dist/cjs/core/contracts.js +11 -0
- package/dist/cjs/core/contracts.js.map +1 -0
- package/dist/cjs/core/falai.d.ts +57 -0
- package/dist/cjs/core/falai.d.ts.map +1 -0
- package/dist/cjs/core/falai.js +43 -0
- package/dist/cjs/core/falai.js.map +1 -0
- package/dist/cjs/core/predicate.d.ts +9 -0
- package/dist/cjs/core/predicate.d.ts.map +1 -0
- package/dist/cjs/core/predicate.js +58 -0
- package/dist/cjs/core/predicate.js.map +1 -0
- package/dist/cjs/index.d.ts +26 -31
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +46 -68
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/persistence/MemoryStore.d.ts +15 -0
- package/dist/cjs/persistence/MemoryStore.d.ts.map +1 -0
- package/dist/cjs/persistence/MemoryStore.js +39 -0
- package/dist/cjs/persistence/MemoryStore.js.map +1 -0
- package/dist/cjs/persistence/MongoStore.d.ts +42 -0
- package/dist/cjs/persistence/MongoStore.d.ts.map +1 -0
- package/dist/cjs/persistence/MongoStore.js +60 -0
- package/dist/cjs/persistence/MongoStore.js.map +1 -0
- package/dist/cjs/persistence/OpenSearchStore.d.ts +86 -0
- package/dist/cjs/persistence/OpenSearchStore.d.ts.map +1 -0
- package/dist/cjs/persistence/OpenSearchStore.js +120 -0
- package/dist/cjs/persistence/OpenSearchStore.js.map +1 -0
- package/dist/cjs/persistence/PostgresStore.d.ts +41 -0
- package/dist/cjs/persistence/PostgresStore.d.ts.map +1 -0
- package/dist/cjs/persistence/PostgresStore.js +58 -0
- package/dist/cjs/persistence/PostgresStore.js.map +1 -0
- package/dist/cjs/persistence/PrismaStore.d.ts +65 -0
- package/dist/cjs/persistence/PrismaStore.d.ts.map +1 -0
- package/dist/cjs/persistence/PrismaStore.js +95 -0
- package/dist/cjs/persistence/PrismaStore.js.map +1 -0
- package/dist/cjs/persistence/RedisStore.d.ts +34 -0
- package/dist/cjs/persistence/RedisStore.d.ts.map +1 -0
- package/dist/cjs/persistence/RedisStore.js +61 -0
- package/dist/cjs/persistence/RedisStore.js.map +1 -0
- package/dist/cjs/persistence/SQLiteStore.d.ts +45 -0
- package/dist/cjs/persistence/SQLiteStore.d.ts.map +1 -0
- package/dist/cjs/persistence/SQLiteStore.js +74 -0
- package/dist/cjs/persistence/SQLiteStore.js.map +1 -0
- package/dist/cjs/persistence/sessionRow.d.ts +14 -0
- package/dist/cjs/persistence/sessionRow.d.ts.map +1 -0
- package/dist/cjs/persistence/sessionRow.js +50 -0
- package/dist/cjs/persistence/sessionRow.js.map +1 -0
- package/dist/cjs/providers/DeepSeekProvider.d.ts.map +1 -1
- package/dist/cjs/providers/DeepSeekProvider.js +8 -3
- package/dist/cjs/providers/DeepSeekProvider.js.map +1 -1
- package/dist/cjs/providers/GeminiProvider.d.ts +4 -3
- package/dist/cjs/providers/GeminiProvider.d.ts.map +1 -1
- package/dist/cjs/providers/GeminiProvider.js +4 -3
- package/dist/cjs/providers/GeminiProvider.js.map +1 -1
- package/dist/cjs/providers/OpenAICompatibleProvider.d.ts +4 -0
- package/dist/cjs/providers/OpenAICompatibleProvider.d.ts.map +1 -1
- package/dist/cjs/providers/OpenAICompatibleProvider.js +2 -0
- package/dist/cjs/providers/OpenAICompatibleProvider.js.map +1 -1
- package/dist/cjs/providers/OpenRouterProvider.d.ts.map +1 -1
- package/dist/cjs/providers/OpenRouterProvider.js +2 -4
- package/dist/cjs/providers/OpenRouterProvider.js.map +1 -1
- package/dist/cjs/providers/ProviderAdapter.d.ts +11 -6
- package/dist/cjs/providers/ProviderAdapter.d.ts.map +1 -1
- package/dist/cjs/providers/ProviderAdapter.js +33 -10
- package/dist/cjs/providers/ProviderAdapter.js.map +1 -1
- package/dist/cjs/providers/ZaiProvider.d.ts +6 -4
- package/dist/cjs/providers/ZaiProvider.d.ts.map +1 -1
- package/dist/cjs/providers/ZaiProvider.js +6 -4
- package/dist/cjs/providers/ZaiProvider.js.map +1 -1
- package/dist/cjs/types/agent.d.ts +153 -383
- package/dist/cjs/types/agent.d.ts.map +1 -1
- package/dist/cjs/types/agent.js +1 -1
- package/dist/cjs/types/ai.d.ts +32 -1
- package/dist/cjs/types/ai.d.ts.map +1 -1
- package/dist/cjs/types/compaction.d.ts +3 -1
- package/dist/cjs/types/compaction.d.ts.map +1 -1
- package/dist/cjs/types/errors.d.ts +9 -12
- package/dist/cjs/types/errors.d.ts.map +1 -1
- package/dist/cjs/types/errors.js +14 -17
- package/dist/cjs/types/errors.js.map +1 -1
- package/dist/cjs/types/flow.d.ts +265 -513
- package/dist/cjs/types/flow.d.ts.map +1 -1
- package/dist/cjs/types/flow.js +7 -1
- package/dist/cjs/types/flow.js.map +1 -1
- package/dist/cjs/types/history.d.ts +7 -18
- package/dist/cjs/types/history.d.ts.map +1 -1
- package/dist/cjs/types/history.js.map +1 -1
- package/dist/cjs/types/index.d.ts +9 -15
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js +4 -14
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/types/session.d.ts +94 -64
- package/dist/cjs/types/session.d.ts.map +1 -1
- package/dist/cjs/types/session.js +5 -1
- package/dist/cjs/types/session.js.map +1 -1
- package/dist/cjs/types/tool.d.ts +37 -207
- package/dist/cjs/types/tool.d.ts.map +1 -1
- package/dist/cjs/types/tool.js +5 -14
- package/dist/cjs/types/tool.js.map +1 -1
- package/dist/cjs/utils/clock.d.ts +28 -0
- package/dist/cjs/utils/clock.d.ts.map +1 -0
- package/dist/cjs/utils/clock.js +64 -0
- package/dist/cjs/utils/clock.js.map +1 -0
- package/dist/cjs/utils/duration.d.ts +11 -0
- package/dist/cjs/utils/duration.d.ts.map +1 -0
- package/dist/cjs/utils/duration.js +31 -0
- package/dist/cjs/utils/duration.js.map +1 -0
- package/dist/cjs/utils/history.d.ts +4 -1
- package/dist/cjs/utils/history.d.ts.map +1 -1
- package/dist/cjs/utils/history.js +2 -2
- package/dist/cjs/utils/history.js.map +1 -1
- package/dist/cjs/utils/index.d.ts +4 -10
- package/dist/cjs/utils/index.d.ts.map +1 -1
- package/dist/cjs/utils/index.js +14 -61
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/json.d.ts +2 -0
- package/dist/cjs/utils/json.d.ts.map +1 -1
- package/dist/cjs/utils/json.js +5 -0
- package/dist/cjs/utils/json.js.map +1 -1
- package/dist/cjs/utils/outcomes.d.ts +48 -0
- package/dist/cjs/utils/outcomes.d.ts.map +1 -0
- package/dist/cjs/utils/outcomes.js +51 -0
- package/dist/cjs/utils/outcomes.js.map +1 -0
- package/dist/cjs/utils/schema.d.ts +50 -0
- package/dist/cjs/utils/schema.d.ts.map +1 -0
- package/dist/cjs/utils/schema.js +138 -0
- package/dist/cjs/utils/schema.js.map +1 -0
- package/dist/cjs/utils/streamingMessage.d.ts +3 -2
- package/dist/cjs/utils/streamingMessage.d.ts.map +1 -1
- package/dist/cjs/utils/streamingMessage.js +38 -4
- package/dist/cjs/utils/streamingMessage.js.map +1 -1
- package/dist/cjs/utils/template.d.ts +13 -149
- package/dist/cjs/utils/template.d.ts.map +1 -1
- package/dist/cjs/utils/template.js +31 -363
- package/dist/cjs/utils/template.js.map +1 -1
- package/dist/cjs/utils/usage.d.ts +19 -0
- package/dist/cjs/utils/usage.d.ts.map +1 -0
- package/dist/cjs/utils/usage.js +35 -0
- package/dist/cjs/utils/usage.js.map +1 -0
- package/dist/core/Agent.d.ts +22 -378
- package/dist/core/Agent.d.ts.map +1 -1
- package/dist/core/Agent.js +107 -1181
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/CompactionEngine.d.ts.map +1 -1
- package/dist/core/CompactionEngine.js +5 -3
- package/dist/core/CompactionEngine.js.map +1 -1
- package/dist/core/FlowSpec.d.ts +136 -0
- package/dist/core/FlowSpec.d.ts.map +1 -0
- package/dist/core/FlowSpec.js +516 -0
- package/dist/core/FlowSpec.js.map +1 -0
- package/dist/core/Migrate.d.ts +38 -0
- package/dist/core/Migrate.d.ts.map +1 -0
- package/dist/core/Migrate.js +264 -0
- package/dist/core/Migrate.js.map +1 -0
- package/dist/core/Prompt.d.ts +54 -0
- package/dist/core/Prompt.d.ts.map +1 -0
- package/dist/core/Prompt.js +133 -0
- package/dist/core/Prompt.js.map +1 -0
- package/dist/core/Runner.d.ts +160 -0
- package/dist/core/Runner.d.ts.map +1 -0
- package/dist/core/Runner.js +1127 -0
- package/dist/core/Runner.js.map +1 -0
- package/dist/core/Speak.d.ts +37 -0
- package/dist/core/Speak.d.ts.map +1 -0
- package/dist/core/Speak.js +360 -0
- package/dist/core/Speak.js.map +1 -0
- package/dist/core/Understand.d.ts +28 -0
- package/dist/core/Understand.d.ts.map +1 -0
- package/dist/core/Understand.js +349 -0
- package/dist/core/Understand.js.map +1 -0
- package/dist/core/contracts.d.ts +122 -0
- package/dist/core/contracts.d.ts.map +1 -0
- package/dist/core/contracts.js +10 -0
- package/dist/core/contracts.js.map +1 -0
- package/dist/core/falai.d.ts +57 -0
- package/dist/core/falai.d.ts.map +1 -0
- package/dist/core/falai.js +40 -0
- package/dist/core/falai.js.map +1 -0
- package/dist/core/predicate.d.ts +9 -0
- package/dist/core/predicate.d.ts.map +1 -0
- package/dist/core/predicate.js +54 -0
- package/dist/core/predicate.js.map +1 -0
- package/dist/index.d.ts +26 -31
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -24
- package/dist/index.js.map +1 -1
- package/dist/persistence/MemoryStore.d.ts +15 -0
- package/dist/persistence/MemoryStore.d.ts.map +1 -0
- package/dist/persistence/MemoryStore.js +35 -0
- package/dist/persistence/MemoryStore.js.map +1 -0
- package/dist/persistence/MongoStore.d.ts +42 -0
- package/dist/persistence/MongoStore.d.ts.map +1 -0
- package/dist/persistence/MongoStore.js +56 -0
- package/dist/persistence/MongoStore.js.map +1 -0
- package/dist/persistence/OpenSearchStore.d.ts +86 -0
- package/dist/persistence/OpenSearchStore.d.ts.map +1 -0
- package/dist/persistence/OpenSearchStore.js +116 -0
- package/dist/persistence/OpenSearchStore.js.map +1 -0
- package/dist/persistence/PostgresStore.d.ts +41 -0
- package/dist/persistence/PostgresStore.d.ts.map +1 -0
- package/dist/persistence/PostgresStore.js +54 -0
- package/dist/persistence/PostgresStore.js.map +1 -0
- package/dist/persistence/PrismaStore.d.ts +65 -0
- package/dist/persistence/PrismaStore.d.ts.map +1 -0
- package/dist/persistence/PrismaStore.js +91 -0
- package/dist/persistence/PrismaStore.js.map +1 -0
- package/dist/persistence/RedisStore.d.ts +34 -0
- package/dist/persistence/RedisStore.d.ts.map +1 -0
- package/dist/persistence/RedisStore.js +57 -0
- package/dist/persistence/RedisStore.js.map +1 -0
- package/dist/persistence/SQLiteStore.d.ts +45 -0
- package/dist/persistence/SQLiteStore.d.ts.map +1 -0
- package/dist/persistence/SQLiteStore.js +70 -0
- package/dist/persistence/SQLiteStore.js.map +1 -0
- package/dist/persistence/sessionRow.d.ts +14 -0
- package/dist/persistence/sessionRow.d.ts.map +1 -0
- package/dist/persistence/sessionRow.js +45 -0
- package/dist/persistence/sessionRow.js.map +1 -0
- package/dist/providers/DeepSeekProvider.d.ts.map +1 -1
- package/dist/providers/DeepSeekProvider.js +8 -3
- package/dist/providers/DeepSeekProvider.js.map +1 -1
- package/dist/providers/GeminiProvider.d.ts +4 -3
- package/dist/providers/GeminiProvider.d.ts.map +1 -1
- package/dist/providers/GeminiProvider.js +4 -3
- package/dist/providers/GeminiProvider.js.map +1 -1
- package/dist/providers/OpenAICompatibleProvider.d.ts +4 -0
- package/dist/providers/OpenAICompatibleProvider.d.ts.map +1 -1
- package/dist/providers/OpenAICompatibleProvider.js +2 -0
- package/dist/providers/OpenAICompatibleProvider.js.map +1 -1
- package/dist/providers/OpenRouterProvider.d.ts.map +1 -1
- package/dist/providers/OpenRouterProvider.js +2 -4
- package/dist/providers/OpenRouterProvider.js.map +1 -1
- package/dist/providers/ProviderAdapter.d.ts +11 -6
- package/dist/providers/ProviderAdapter.d.ts.map +1 -1
- package/dist/providers/ProviderAdapter.js +34 -11
- package/dist/providers/ProviderAdapter.js.map +1 -1
- package/dist/providers/ZaiProvider.d.ts +6 -4
- package/dist/providers/ZaiProvider.d.ts.map +1 -1
- package/dist/providers/ZaiProvider.js +6 -4
- package/dist/providers/ZaiProvider.js.map +1 -1
- package/dist/types/agent.d.ts +153 -383
- package/dist/types/agent.d.ts.map +1 -1
- package/dist/types/agent.js +1 -1
- package/dist/types/ai.d.ts +32 -1
- package/dist/types/ai.d.ts.map +1 -1
- package/dist/types/compaction.d.ts +3 -1
- package/dist/types/compaction.d.ts.map +1 -1
- package/dist/types/errors.d.ts +9 -12
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +12 -15
- package/dist/types/errors.js.map +1 -1
- package/dist/types/flow.d.ts +265 -513
- package/dist/types/flow.d.ts.map +1 -1
- package/dist/types/flow.js +7 -1
- package/dist/types/flow.js.map +1 -1
- package/dist/types/history.d.ts +7 -18
- package/dist/types/history.d.ts.map +1 -1
- package/dist/types/history.js.map +1 -1
- package/dist/types/index.d.ts +9 -15
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -7
- package/dist/types/index.js.map +1 -1
- package/dist/types/session.d.ts +94 -64
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types/session.js +5 -1
- package/dist/types/session.js.map +1 -1
- package/dist/types/tool.d.ts +37 -207
- package/dist/types/tool.d.ts.map +1 -1
- package/dist/types/tool.js +6 -13
- package/dist/types/tool.js.map +1 -1
- package/dist/utils/clock.d.ts +28 -0
- package/dist/utils/clock.d.ts.map +1 -0
- package/dist/utils/clock.js +59 -0
- package/dist/utils/clock.js.map +1 -0
- package/dist/utils/duration.d.ts +11 -0
- package/dist/utils/duration.d.ts.map +1 -0
- package/dist/utils/duration.js +26 -0
- package/dist/utils/duration.js.map +1 -0
- package/dist/utils/history.d.ts +4 -1
- package/dist/utils/history.d.ts.map +1 -1
- package/dist/utils/history.js +2 -2
- package/dist/utils/history.js.map +1 -1
- package/dist/utils/index.d.ts +4 -10
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +4 -21
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/json.d.ts +2 -0
- package/dist/utils/json.d.ts.map +1 -1
- package/dist/utils/json.js +4 -0
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/outcomes.d.ts +48 -0
- package/dist/utils/outcomes.d.ts.map +1 -0
- package/dist/utils/outcomes.js +48 -0
- package/dist/utils/outcomes.js.map +1 -0
- package/dist/utils/schema.d.ts +50 -0
- package/dist/utils/schema.d.ts.map +1 -0
- package/dist/utils/schema.js +129 -0
- package/dist/utils/schema.js.map +1 -0
- package/dist/utils/streamingMessage.d.ts +3 -2
- package/dist/utils/streamingMessage.d.ts.map +1 -1
- package/dist/utils/streamingMessage.js +38 -4
- package/dist/utils/streamingMessage.js.map +1 -1
- package/dist/utils/template.d.ts +13 -149
- package/dist/utils/template.d.ts.map +1 -1
- package/dist/utils/template.js +28 -355
- package/dist/utils/template.js.map +1 -1
- package/dist/utils/usage.d.ts +19 -0
- package/dist/utils/usage.d.ts.map +1 -0
- package/dist/utils/usage.js +31 -0
- package/dist/utils/usage.js.map +1 -0
- package/docs/README.md +37 -19
- package/docs/concepts/architecture.md +117 -239
- package/docs/concepts/collection.md +170 -0
- package/docs/concepts/pipeline.md +132 -378
- package/docs/concepts/runs-and-waits.md +192 -0
- package/docs/guides/actions-and-events.md +276 -0
- package/docs/guides/branching.md +119 -208
- package/docs/guides/compaction.md +63 -158
- package/docs/guides/conditions.md +164 -128
- package/docs/guides/error-handling.md +168 -164
- package/docs/guides/flow-control.md +210 -349
- package/docs/guides/flows-from-json.md +224 -0
- package/docs/guides/instructions.md +125 -161
- package/docs/guides/persistence.md +182 -206
- package/docs/guides/streaming.md +50 -114
- package/docs/guides/testing.md +284 -0
- package/docs/guides/triggers.md +401 -0
- package/docs/migration/README.md +8 -15
- package/docs/migration/v1-to-v2.md +1 -1
- package/docs/migration/v2-3-to-v2-4.md +2 -2
- package/docs/migration/v2-6-to-v2-7.md +4 -4
- package/docs/migration/v3-to-v4.md +452 -0
- package/docs/reference/actions-events-conditions.md +396 -0
- package/docs/reference/agent.md +244 -0
- package/docs/reference/branches.md +75 -203
- package/docs/reference/errors.md +188 -144
- package/docs/reference/fields.md +125 -0
- package/docs/reference/flow-spec.md +248 -0
- package/docs/reference/flow.md +104 -192
- package/docs/reference/instruction.md +83 -137
- package/docs/reference/outcomes.md +273 -0
- package/docs/reference/providers.md +525 -302
- package/docs/reference/session.md +210 -0
- package/docs/reference/step.md +194 -312
- package/docs/reference/stores.md +496 -0
- package/docs/reference/tool.md +162 -231
- package/docs/reference/trigger.md +180 -0
- package/docs/rfc/v4-one-flow.md +477 -0
- package/docs/start/01-install.md +59 -44
- package/docs/start/02-first-agent.md +97 -147
- package/docs/start/03-collect-data.md +78 -183
- package/docs/start/04-add-tools.md +159 -227
- package/docs/start/05-go-to-production.md +167 -164
- package/examples/01-quickstart.ts +26 -16
- package/examples/02-fields.ts +75 -0
- package/examples/03-tools.ts +79 -119
- package/examples/04-instructions.ts +60 -87
- package/examples/05-branches.ts +78 -0
- package/examples/06-triggers-and-waits.ts +148 -0
- package/examples/07-streaming.ts +34 -60
- package/examples/08-store-and-migration.ts +97 -0
- package/examples/09-flows-from-json.ts +107 -0
- package/package.json +9 -6
- package/src/core/Agent.ts +116 -1512
- package/src/core/CompactionEngine.ts +7 -4
- package/src/core/FlowSpec.ts +712 -0
- package/src/core/Migrate.ts +256 -0
- package/src/core/Prompt.ts +156 -0
- package/src/core/Runner.ts +1181 -0
- package/src/core/Speak.ts +451 -0
- package/src/core/Understand.ts +422 -0
- package/src/core/contracts.ts +111 -0
- package/src/core/falai.ts +86 -0
- package/src/core/predicate.ts +56 -0
- package/src/index.ts +119 -147
- package/src/persistence/MemoryStore.ts +37 -0
- package/src/persistence/MongoStore.ts +89 -0
- package/src/persistence/OpenSearchStore.ts +153 -0
- package/src/persistence/PostgresStore.ts +89 -0
- package/src/persistence/PrismaStore.ts +127 -0
- package/src/persistence/RedisStore.ts +90 -0
- package/src/persistence/SQLiteStore.ts +103 -0
- package/src/persistence/sessionRow.ts +45 -0
- package/src/providers/DeepSeekProvider.ts +8 -3
- package/src/providers/GeminiProvider.ts +4 -3
- package/src/providers/OpenAICompatibleProvider.ts +6 -0
- package/src/providers/OpenRouterProvider.ts +2 -4
- package/src/providers/ProviderAdapter.ts +46 -13
- package/src/providers/ZaiProvider.ts +6 -4
- package/src/types/agent.ts +124 -397
- package/src/types/ai.ts +33 -1
- package/src/types/compaction.ts +3 -1
- package/src/types/errors.ts +13 -16
- package/src/types/flow.ts +249 -550
- package/src/types/history.ts +7 -20
- package/src/types/index.ts +87 -139
- package/src/types/session.ts +135 -70
- package/src/types/tool.ts +42 -267
- package/src/utils/clock.ts +70 -0
- package/src/utils/duration.ts +33 -0
- package/src/utils/history.ts +3 -2
- package/src/utils/index.ts +8 -66
- package/src/utils/json.ts +5 -0
- package/src/utils/outcomes.ts +56 -0
- package/src/utils/schema.ts +145 -0
- package/src/utils/streamingMessage.ts +34 -4
- package/src/utils/template.ts +32 -423
- package/src/utils/usage.ts +37 -0
- package/dist/adapters/MemoryAdapter.d.ts +0 -47
- package/dist/adapters/MemoryAdapter.d.ts.map +0 -1
- package/dist/adapters/MemoryAdapter.js +0 -204
- package/dist/adapters/MemoryAdapter.js.map +0 -1
- package/dist/adapters/MongoAdapter.d.ts +0 -97
- package/dist/adapters/MongoAdapter.d.ts.map +0 -1
- package/dist/adapters/MongoAdapter.js +0 -196
- package/dist/adapters/MongoAdapter.js.map +0 -1
- package/dist/adapters/OpenSearchAdapter.d.ts +0 -169
- package/dist/adapters/OpenSearchAdapter.d.ts.map +0 -1
- package/dist/adapters/OpenSearchAdapter.js +0 -471
- package/dist/adapters/OpenSearchAdapter.js.map +0 -1
- package/dist/adapters/PostgreSQLAdapter.d.ts +0 -85
- package/dist/adapters/PostgreSQLAdapter.d.ts.map +0 -1
- package/dist/adapters/PostgreSQLAdapter.js +0 -308
- package/dist/adapters/PostgreSQLAdapter.js.map +0 -1
- package/dist/adapters/PrismaAdapter.d.ts +0 -115
- package/dist/adapters/PrismaAdapter.d.ts.map +0 -1
- package/dist/adapters/PrismaAdapter.js +0 -406
- package/dist/adapters/PrismaAdapter.js.map +0 -1
- package/dist/adapters/RedisAdapter.d.ts +0 -72
- package/dist/adapters/RedisAdapter.d.ts.map +0 -1
- package/dist/adapters/RedisAdapter.js +0 -286
- package/dist/adapters/RedisAdapter.js.map +0 -1
- package/dist/adapters/SQLiteAdapter.d.ts +0 -86
- package/dist/adapters/SQLiteAdapter.d.ts.map +0 -1
- package/dist/adapters/SQLiteAdapter.js +0 -337
- package/dist/adapters/SQLiteAdapter.js.map +0 -1
- package/dist/adapters/index.d.ts +0 -17
- package/dist/adapters/index.d.ts.map +0 -1
- package/dist/adapters/index.js +0 -11
- package/dist/adapters/index.js.map +0 -1
- package/dist/adapters/sessionRow.d.ts +0 -22
- package/dist/adapters/sessionRow.d.ts.map +0 -1
- package/dist/adapters/sessionRow.js +0 -48
- package/dist/adapters/sessionRow.js.map +0 -1
- package/dist/cjs/adapters/MemoryAdapter.d.ts +0 -47
- package/dist/cjs/adapters/MemoryAdapter.d.ts.map +0 -1
- package/dist/cjs/adapters/MemoryAdapter.js +0 -208
- package/dist/cjs/adapters/MemoryAdapter.js.map +0 -1
- package/dist/cjs/adapters/MongoAdapter.d.ts +0 -97
- package/dist/cjs/adapters/MongoAdapter.d.ts.map +0 -1
- package/dist/cjs/adapters/MongoAdapter.js +0 -200
- package/dist/cjs/adapters/MongoAdapter.js.map +0 -1
- package/dist/cjs/adapters/OpenSearchAdapter.d.ts +0 -169
- package/dist/cjs/adapters/OpenSearchAdapter.d.ts.map +0 -1
- package/dist/cjs/adapters/OpenSearchAdapter.js +0 -475
- package/dist/cjs/adapters/OpenSearchAdapter.js.map +0 -1
- package/dist/cjs/adapters/PostgreSQLAdapter.d.ts +0 -85
- package/dist/cjs/adapters/PostgreSQLAdapter.d.ts.map +0 -1
- package/dist/cjs/adapters/PostgreSQLAdapter.js +0 -312
- package/dist/cjs/adapters/PostgreSQLAdapter.js.map +0 -1
- package/dist/cjs/adapters/PrismaAdapter.d.ts +0 -115
- package/dist/cjs/adapters/PrismaAdapter.d.ts.map +0 -1
- package/dist/cjs/adapters/PrismaAdapter.js +0 -410
- package/dist/cjs/adapters/PrismaAdapter.js.map +0 -1
- package/dist/cjs/adapters/RedisAdapter.d.ts +0 -72
- package/dist/cjs/adapters/RedisAdapter.d.ts.map +0 -1
- package/dist/cjs/adapters/RedisAdapter.js +0 -290
- package/dist/cjs/adapters/RedisAdapter.js.map +0 -1
- package/dist/cjs/adapters/SQLiteAdapter.d.ts +0 -86
- package/dist/cjs/adapters/SQLiteAdapter.d.ts.map +0 -1
- package/dist/cjs/adapters/SQLiteAdapter.js +0 -341
- package/dist/cjs/adapters/SQLiteAdapter.js.map +0 -1
- package/dist/cjs/adapters/index.d.ts +0 -17
- package/dist/cjs/adapters/index.d.ts.map +0 -1
- package/dist/cjs/adapters/index.js +0 -21
- package/dist/cjs/adapters/index.js.map +0 -1
- package/dist/cjs/adapters/sessionRow.d.ts +0 -22
- package/dist/cjs/adapters/sessionRow.d.ts.map +0 -1
- package/dist/cjs/adapters/sessionRow.js +0 -52
- package/dist/cjs/adapters/sessionRow.js.map +0 -1
- package/dist/cjs/constants/index.d.ts +0 -1
- package/dist/cjs/constants/index.d.ts.map +0 -1
- package/dist/cjs/constants/index.js +0 -4
- package/dist/cjs/constants/index.js.map +0 -1
- package/dist/cjs/core/AutoChainExecutor.d.ts +0 -97
- package/dist/cjs/core/AutoChainExecutor.d.ts.map +0 -1
- package/dist/cjs/core/AutoChainExecutor.js +0 -288
- package/dist/cjs/core/AutoChainExecutor.js.map +0 -1
- package/dist/cjs/core/BranchEvaluator.d.ts +0 -55
- package/dist/cjs/core/BranchEvaluator.d.ts.map +0 -1
- package/dist/cjs/core/BranchEvaluator.js +0 -125
- package/dist/cjs/core/BranchEvaluator.js.map +0 -1
- package/dist/cjs/core/DirectiveChainTracker.d.ts +0 -49
- package/dist/cjs/core/DirectiveChainTracker.d.ts.map +0 -1
- package/dist/cjs/core/DirectiveChainTracker.js +0 -121
- package/dist/cjs/core/DirectiveChainTracker.js.map +0 -1
- package/dist/cjs/core/Events.d.ts +0 -26
- package/dist/cjs/core/Events.d.ts.map +0 -1
- package/dist/cjs/core/Events.js +0 -144
- package/dist/cjs/core/Events.js.map +0 -1
- package/dist/cjs/core/Flow.d.ts +0 -183
- package/dist/cjs/core/Flow.d.ts.map +0 -1
- package/dist/cjs/core/Flow.js +0 -551
- package/dist/cjs/core/Flow.js.map +0 -1
- package/dist/cjs/core/FlowRouter.d.ts +0 -183
- package/dist/cjs/core/FlowRouter.d.ts.map +0 -1
- package/dist/cjs/core/FlowRouter.js +0 -1047
- package/dist/cjs/core/FlowRouter.js.map +0 -1
- package/dist/cjs/core/PersistenceManager.d.ts +0 -114
- package/dist/cjs/core/PersistenceManager.d.ts.map +0 -1
- package/dist/cjs/core/PersistenceManager.js +0 -336
- package/dist/cjs/core/PersistenceManager.js.map +0 -1
- package/dist/cjs/core/PromptComposer.d.ts +0 -47
- package/dist/cjs/core/PromptComposer.d.ts.map +0 -1
- package/dist/cjs/core/PromptComposer.js +0 -397
- package/dist/cjs/core/PromptComposer.js.map +0 -1
- package/dist/cjs/core/PromptSectionCache.d.ts +0 -48
- package/dist/cjs/core/PromptSectionCache.d.ts.map +0 -1
- package/dist/cjs/core/PromptSectionCache.js +0 -108
- package/dist/cjs/core/PromptSectionCache.js.map +0 -1
- package/dist/cjs/core/ResponseEngine.d.ts +0 -43
- package/dist/cjs/core/ResponseEngine.d.ts.map +0 -1
- package/dist/cjs/core/ResponseEngine.js +0 -235
- package/dist/cjs/core/ResponseEngine.js.map +0 -1
- package/dist/cjs/core/ResponseGenerationError.d.ts +0 -30
- package/dist/cjs/core/ResponseGenerationError.d.ts.map +0 -1
- package/dist/cjs/core/ResponseGenerationError.js +0 -35
- package/dist/cjs/core/ResponseGenerationError.js.map +0 -1
- package/dist/cjs/core/ResponseModal.d.ts +0 -305
- package/dist/cjs/core/ResponseModal.d.ts.map +0 -1
- package/dist/cjs/core/ResponseModal.js +0 -1414
- package/dist/cjs/core/ResponseModal.js.map +0 -1
- package/dist/cjs/core/ResponsePipeline.d.ts +0 -220
- package/dist/cjs/core/ResponsePipeline.d.ts.map +0 -1
- package/dist/cjs/core/ResponsePipeline.js +0 -1040
- package/dist/cjs/core/ResponsePipeline.js.map +0 -1
- package/dist/cjs/core/SessionFinalizer.d.ts +0 -34
- package/dist/cjs/core/SessionFinalizer.d.ts.map +0 -1
- package/dist/cjs/core/SessionFinalizer.js +0 -88
- package/dist/cjs/core/SessionFinalizer.js.map +0 -1
- package/dist/cjs/core/SessionManager.d.ts +0 -112
- package/dist/cjs/core/SessionManager.d.ts.map +0 -1
- package/dist/cjs/core/SessionManager.js +0 -308
- package/dist/cjs/core/SessionManager.js.map +0 -1
- package/dist/cjs/core/SignalCoordinator.d.ts +0 -103
- package/dist/cjs/core/SignalCoordinator.d.ts.map +0 -1
- package/dist/cjs/core/SignalCoordinator.js +0 -207
- package/dist/cjs/core/SignalCoordinator.js.map +0 -1
- package/dist/cjs/core/SignalEvaluator.d.ts +0 -86
- package/dist/cjs/core/SignalEvaluator.d.ts.map +0 -1
- package/dist/cjs/core/SignalEvaluator.js +0 -319
- package/dist/cjs/core/SignalEvaluator.js.map +0 -1
- package/dist/cjs/core/SignalProcessor.d.ts +0 -152
- package/dist/cjs/core/SignalProcessor.d.ts.map +0 -1
- package/dist/cjs/core/SignalProcessor.js +0 -505
- package/dist/cjs/core/SignalProcessor.js.map +0 -1
- package/dist/cjs/core/Step.d.ts +0 -184
- package/dist/cjs/core/Step.d.ts.map +0 -1
- package/dist/cjs/core/Step.js +0 -599
- package/dist/cjs/core/Step.js.map +0 -1
- package/dist/cjs/core/StepLifecycle.d.ts +0 -43
- package/dist/cjs/core/StepLifecycle.d.ts.map +0 -1
- package/dist/cjs/core/StepLifecycle.js +0 -180
- package/dist/cjs/core/StepLifecycle.js.map +0 -1
- package/dist/cjs/core/StreamingToolExecutor.d.ts +0 -142
- package/dist/cjs/core/StreamingToolExecutor.d.ts.map +0 -1
- package/dist/cjs/core/StreamingToolExecutor.js +0 -490
- package/dist/cjs/core/StreamingToolExecutor.js.map +0 -1
- package/dist/cjs/core/ToolLoopExecutor.d.ts +0 -133
- package/dist/cjs/core/ToolLoopExecutor.d.ts.map +0 -1
- package/dist/cjs/core/ToolLoopExecutor.js +0 -568
- package/dist/cjs/core/ToolLoopExecutor.js.map +0 -1
- package/dist/cjs/core/ToolManager.d.ts +0 -250
- package/dist/cjs/core/ToolManager.d.ts.map +0 -1
- package/dist/cjs/core/ToolManager.js +0 -1104
- package/dist/cjs/core/ToolManager.js.map +0 -1
- package/dist/cjs/core/createAgent.d.ts +0 -35
- package/dist/cjs/core/createAgent.d.ts.map +0 -1
- package/dist/cjs/core/createAgent.js +0 -39
- package/dist/cjs/core/createAgent.js.map +0 -1
- package/dist/cjs/core/flow-namespace.d.ts +0 -64
- package/dist/cjs/core/flow-namespace.d.ts.map +0 -1
- package/dist/cjs/core/flow-namespace.js +0 -182
- package/dist/cjs/core/flow-namespace.js.map +0 -1
- package/dist/cjs/core/toolGates.d.ts +0 -24
- package/dist/cjs/core/toolGates.d.ts.map +0 -1
- package/dist/cjs/core/toolGates.js +0 -52
- package/dist/cjs/core/toolGates.js.map +0 -1
- package/dist/cjs/types/persistence.d.ts +0 -254
- package/dist/cjs/types/persistence.d.ts.map +0 -1
- package/dist/cjs/types/persistence.js +0 -7
- package/dist/cjs/types/persistence.js.map +0 -1
- package/dist/cjs/types/prompt-cache.d.ts +0 -15
- package/dist/cjs/types/prompt-cache.d.ts.map +0 -1
- package/dist/cjs/types/prompt-cache.js +0 -6
- package/dist/cjs/types/prompt-cache.js.map +0 -1
- package/dist/cjs/types/signals.d.ts +0 -263
- package/dist/cjs/types/signals.d.ts.map +0 -1
- package/dist/cjs/types/signals.js +0 -11
- package/dist/cjs/types/signals.js.map +0 -1
- package/dist/cjs/types/template.d.ts +0 -84
- package/dist/cjs/types/template.d.ts.map +0 -1
- package/dist/cjs/types/template.js +0 -3
- package/dist/cjs/types/template.js.map +0 -1
- package/dist/cjs/utils/condition.d.ts +0 -63
- package/dist/cjs/utils/condition.d.ts.map +0 -1
- package/dist/cjs/utils/condition.js +0 -239
- package/dist/cjs/utils/condition.js.map +0 -1
- package/dist/cjs/utils/event.d.ts +0 -6
- package/dist/cjs/utils/event.d.ts.map +0 -1
- package/dist/cjs/utils/event.js +0 -20
- package/dist/cjs/utils/event.js.map +0 -1
- package/dist/cjs/utils/id.d.ts +0 -33
- package/dist/cjs/utils/id.d.ts.map +0 -1
- package/dist/cjs/utils/id.js +0 -84
- package/dist/cjs/utils/id.js.map +0 -1
- package/dist/cjs/utils/serialize.d.ts +0 -36
- package/dist/cjs/utils/serialize.d.ts.map +0 -1
- package/dist/cjs/utils/serialize.js +0 -77
- package/dist/cjs/utils/serialize.js.map +0 -1
- package/dist/cjs/utils/session.d.ts +0 -124
- package/dist/cjs/utils/session.d.ts.map +0 -1
- package/dist/cjs/utils/session.js +0 -396
- package/dist/cjs/utils/session.js.map +0 -1
- package/dist/constants/index.d.ts +0 -2
- package/dist/constants/index.d.ts.map +0 -1
- package/dist/constants/index.js +0 -4
- package/dist/constants/index.js.map +0 -1
- package/dist/core/AutoChainExecutor.d.ts +0 -97
- package/dist/core/AutoChainExecutor.d.ts.map +0 -1
- package/dist/core/AutoChainExecutor.js +0 -284
- package/dist/core/AutoChainExecutor.js.map +0 -1
- package/dist/core/BranchEvaluator.d.ts +0 -55
- package/dist/core/BranchEvaluator.d.ts.map +0 -1
- package/dist/core/BranchEvaluator.js +0 -121
- package/dist/core/BranchEvaluator.js.map +0 -1
- package/dist/core/DirectiveChainTracker.d.ts +0 -49
- package/dist/core/DirectiveChainTracker.d.ts.map +0 -1
- package/dist/core/DirectiveChainTracker.js +0 -117
- package/dist/core/DirectiveChainTracker.js.map +0 -1
- package/dist/core/Events.d.ts +0 -26
- package/dist/core/Events.d.ts.map +0 -1
- package/dist/core/Events.js +0 -137
- package/dist/core/Events.js.map +0 -1
- package/dist/core/Flow.d.ts +0 -183
- package/dist/core/Flow.d.ts.map +0 -1
- package/dist/core/Flow.js +0 -547
- package/dist/core/Flow.js.map +0 -1
- package/dist/core/FlowRouter.d.ts +0 -183
- package/dist/core/FlowRouter.d.ts.map +0 -1
- package/dist/core/FlowRouter.js +0 -1043
- package/dist/core/FlowRouter.js.map +0 -1
- package/dist/core/PersistenceManager.d.ts +0 -114
- package/dist/core/PersistenceManager.d.ts.map +0 -1
- package/dist/core/PersistenceManager.js +0 -332
- package/dist/core/PersistenceManager.js.map +0 -1
- package/dist/core/PromptComposer.d.ts +0 -47
- package/dist/core/PromptComposer.d.ts.map +0 -1
- package/dist/core/PromptComposer.js +0 -393
- package/dist/core/PromptComposer.js.map +0 -1
- package/dist/core/PromptSectionCache.d.ts +0 -48
- package/dist/core/PromptSectionCache.d.ts.map +0 -1
- package/dist/core/PromptSectionCache.js +0 -104
- package/dist/core/PromptSectionCache.js.map +0 -1
- package/dist/core/ResponseEngine.d.ts +0 -43
- package/dist/core/ResponseEngine.d.ts.map +0 -1
- package/dist/core/ResponseEngine.js +0 -231
- package/dist/core/ResponseEngine.js.map +0 -1
- package/dist/core/ResponseGenerationError.d.ts +0 -30
- package/dist/core/ResponseGenerationError.d.ts.map +0 -1
- package/dist/core/ResponseGenerationError.js +0 -31
- package/dist/core/ResponseGenerationError.js.map +0 -1
- package/dist/core/ResponseModal.d.ts +0 -305
- package/dist/core/ResponseModal.d.ts.map +0 -1
- package/dist/core/ResponseModal.js +0 -1410
- package/dist/core/ResponseModal.js.map +0 -1
- package/dist/core/ResponsePipeline.d.ts +0 -220
- package/dist/core/ResponsePipeline.d.ts.map +0 -1
- package/dist/core/ResponsePipeline.js +0 -1035
- package/dist/core/ResponsePipeline.js.map +0 -1
- package/dist/core/SessionFinalizer.d.ts +0 -34
- package/dist/core/SessionFinalizer.d.ts.map +0 -1
- package/dist/core/SessionFinalizer.js +0 -84
- package/dist/core/SessionFinalizer.js.map +0 -1
- package/dist/core/SessionManager.d.ts +0 -112
- package/dist/core/SessionManager.d.ts.map +0 -1
- package/dist/core/SessionManager.js +0 -301
- package/dist/core/SessionManager.js.map +0 -1
- package/dist/core/SignalCoordinator.d.ts +0 -103
- package/dist/core/SignalCoordinator.d.ts.map +0 -1
- package/dist/core/SignalCoordinator.js +0 -203
- package/dist/core/SignalCoordinator.js.map +0 -1
- package/dist/core/SignalEvaluator.d.ts +0 -86
- package/dist/core/SignalEvaluator.d.ts.map +0 -1
- package/dist/core/SignalEvaluator.js +0 -312
- package/dist/core/SignalEvaluator.js.map +0 -1
- package/dist/core/SignalProcessor.d.ts +0 -152
- package/dist/core/SignalProcessor.d.ts.map +0 -1
- package/dist/core/SignalProcessor.js +0 -498
- package/dist/core/SignalProcessor.js.map +0 -1
- package/dist/core/Step.d.ts +0 -184
- package/dist/core/Step.d.ts.map +0 -1
- package/dist/core/Step.js +0 -594
- package/dist/core/Step.js.map +0 -1
- package/dist/core/StepLifecycle.d.ts +0 -43
- package/dist/core/StepLifecycle.d.ts.map +0 -1
- package/dist/core/StepLifecycle.js +0 -176
- package/dist/core/StepLifecycle.js.map +0 -1
- package/dist/core/StreamingToolExecutor.d.ts +0 -142
- package/dist/core/StreamingToolExecutor.d.ts.map +0 -1
- package/dist/core/StreamingToolExecutor.js +0 -483
- package/dist/core/StreamingToolExecutor.js.map +0 -1
- package/dist/core/ToolLoopExecutor.d.ts +0 -133
- package/dist/core/ToolLoopExecutor.d.ts.map +0 -1
- package/dist/core/ToolLoopExecutor.js +0 -564
- package/dist/core/ToolLoopExecutor.js.map +0 -1
- package/dist/core/ToolManager.d.ts +0 -250
- package/dist/core/ToolManager.d.ts.map +0 -1
- package/dist/core/ToolManager.js +0 -1098
- package/dist/core/ToolManager.js.map +0 -1
- package/dist/core/createAgent.d.ts +0 -35
- package/dist/core/createAgent.d.ts.map +0 -1
- package/dist/core/createAgent.js +0 -36
- package/dist/core/createAgent.js.map +0 -1
- package/dist/core/flow-namespace.d.ts +0 -64
- package/dist/core/flow-namespace.d.ts.map +0 -1
- package/dist/core/flow-namespace.js +0 -179
- package/dist/core/flow-namespace.js.map +0 -1
- package/dist/core/toolGates.d.ts +0 -24
- package/dist/core/toolGates.d.ts.map +0 -1
- package/dist/core/toolGates.js +0 -49
- package/dist/core/toolGates.js.map +0 -1
- package/dist/types/persistence.d.ts +0 -254
- package/dist/types/persistence.d.ts.map +0 -1
- package/dist/types/persistence.js +0 -6
- package/dist/types/persistence.js.map +0 -1
- package/dist/types/prompt-cache.d.ts +0 -15
- package/dist/types/prompt-cache.d.ts.map +0 -1
- package/dist/types/prompt-cache.js +0 -5
- package/dist/types/prompt-cache.js.map +0 -1
- package/dist/types/signals.d.ts +0 -263
- package/dist/types/signals.d.ts.map +0 -1
- package/dist/types/signals.js +0 -10
- package/dist/types/signals.js.map +0 -1
- package/dist/types/template.d.ts +0 -84
- package/dist/types/template.d.ts.map +0 -1
- package/dist/types/template.js +0 -2
- package/dist/types/template.js.map +0 -1
- package/dist/utils/condition.d.ts +0 -63
- package/dist/utils/condition.d.ts.map +0 -1
- package/dist/utils/condition.js +0 -230
- package/dist/utils/condition.js.map +0 -1
- package/dist/utils/event.d.ts +0 -6
- package/dist/utils/event.d.ts.map +0 -1
- package/dist/utils/event.js +0 -17
- package/dist/utils/event.js.map +0 -1
- package/dist/utils/id.d.ts +0 -33
- package/dist/utils/id.d.ts.map +0 -1
- package/dist/utils/id.js +0 -77
- package/dist/utils/id.js.map +0 -1
- package/dist/utils/serialize.d.ts +0 -36
- package/dist/utils/serialize.d.ts.map +0 -1
- package/dist/utils/serialize.js +0 -72
- package/dist/utils/serialize.js.map +0 -1
- package/dist/utils/session.d.ts +0 -124
- package/dist/utils/session.d.ts.map +0 -1
- package/dist/utils/session.js +0 -379
- package/dist/utils/session.js.map +0 -1
- package/docs/concepts/directives.md +0 -369
- package/docs/reference/adapters.md +0 -543
- package/docs/reference/create-agent.md +0 -216
- package/docs/reference/directive.md +0 -242
- package/docs/reference/signals.md +0 -368
- package/examples/02-data-extraction.ts +0 -90
- package/examples/05-branching.ts +0 -140
- package/examples/06-flow-control.ts +0 -103
- package/examples/08-persistence.ts +0 -98
- package/examples/09-signals.ts +0 -144
- package/src/adapters/MemoryAdapter.ts +0 -281
- package/src/adapters/MongoAdapter.ts +0 -341
- package/src/adapters/OpenSearchAdapter.ts +0 -693
- package/src/adapters/PostgreSQLAdapter.ts +0 -487
- package/src/adapters/PrismaAdapter.ts +0 -617
- package/src/adapters/RedisAdapter.ts +0 -439
- package/src/adapters/SQLiteAdapter.ts +0 -496
- package/src/adapters/index.ts +0 -43
- package/src/adapters/sessionRow.ts +0 -57
- package/src/constants/index.ts +0 -2
- package/src/core/AutoChainExecutor.ts +0 -397
- package/src/core/BranchEvaluator.ts +0 -161
- package/src/core/DirectiveChainTracker.ts +0 -144
- package/src/core/Events.ts +0 -164
- package/src/core/Flow.ts +0 -665
- package/src/core/FlowRouter.ts +0 -1540
- package/src/core/PersistenceManager.ts +0 -446
- package/src/core/PromptComposer.ts +0 -448
- package/src/core/PromptSectionCache.ts +0 -125
- package/src/core/ResponseEngine.ts +0 -338
- package/src/core/ResponseGenerationError.ts +0 -53
- package/src/core/ResponseModal.ts +0 -1902
- package/src/core/ResponsePipeline.ts +0 -1404
- package/src/core/SessionFinalizer.ts +0 -108
- package/src/core/SessionManager.ts +0 -372
- package/src/core/SignalCoordinator.ts +0 -263
- package/src/core/SignalEvaluator.ts +0 -404
- package/src/core/SignalProcessor.ts +0 -663
- package/src/core/Step.ts +0 -782
- package/src/core/StepLifecycle.ts +0 -242
- package/src/core/StreamingToolExecutor.ts +0 -609
- package/src/core/ToolLoopExecutor.ts +0 -749
- package/src/core/ToolManager.ts +0 -1379
- package/src/core/createAgent.ts +0 -40
- package/src/core/flow-namespace.ts +0 -227
- package/src/core/toolGates.ts +0 -72
- package/src/types/persistence.ts +0 -303
- package/src/types/prompt-cache.ts +0 -17
- package/src/types/signals.ts +0 -338
- package/src/types/template.ts +0 -98
- package/src/utils/condition.ts +0 -296
- package/src/utils/event.ts +0 -16
- package/src/utils/id.ts +0 -91
- package/src/utils/serialize.ts +0 -86
- package/src/utils/session.ts +0 -501
package/src/types/flow.ts
CHANGED
|
@@ -1,608 +1,307 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The authoring surface: fields, flows, steps, triggers, actions, conditions.
|
|
3
|
+
*
|
|
4
|
+
* A Flow is a trigger plus an ordered list of steps. Everything here is a
|
|
5
|
+
* plain object literal, so the same shape round-trips through JSON (FlowSpec).
|
|
6
|
+
* Two generics thread through: `C` is the host's ambient context, passed on
|
|
7
|
+
* every turn; `D` is the data collected across all flows, inferred from the
|
|
8
|
+
* agent's fields with `InferData`.
|
|
3
9
|
*/
|
|
4
10
|
|
|
5
|
-
import type {
|
|
6
|
-
import type { StructuredSchema } from "./schema.js";
|
|
7
|
-
import type { Instruction, HookContext, ExitReason } from "./agent.js";
|
|
8
|
-
import type { Template } from "./template.js";
|
|
11
|
+
import type { Run } from "./session.js";
|
|
9
12
|
|
|
10
|
-
//
|
|
13
|
+
// ── Scalars ─────────────────────────────────────────────────────────────
|
|
11
14
|
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
* May be async. Used on `if` fields (free to evaluate, no LLM cost).
|
|
15
|
-
*/
|
|
16
|
-
export type ConditionPredicate<TContext = unknown, TData = unknown> = (
|
|
17
|
-
ctx: { data: Partial<TData>; context: TContext; session: import("./session.js").SessionState<TData>; history: Event[] }
|
|
18
|
-
) => boolean | Promise<boolean>;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The `if` field shape: a single predicate or an array of predicates (AND semantics).
|
|
22
|
-
*/
|
|
23
|
-
export type ConditionIf<TContext = unknown, TData = unknown> =
|
|
24
|
-
| ConditionPredicate<TContext, TData>
|
|
25
|
-
| ConditionPredicate<TContext, TData>[];
|
|
15
|
+
/** A time span: `'30s'`, `'5m'`, `'24h'`, `'3d'`. */
|
|
16
|
+
export type Duration = `${number}${"s" | "m" | "h" | "d"}`;
|
|
26
17
|
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
* Non-`!` entries use OR semantics. `!`-prefixed entries are OR exclusions:
|
|
30
|
-
* any matching exclusion inhibits the condition. Functions are NOT allowed on
|
|
31
|
-
* `when` — they belong on `if` only.
|
|
32
|
-
*/
|
|
33
|
-
export type ConditionWhen = string | string[];
|
|
34
|
-
import type { SessionState } from "./session.js";
|
|
35
|
-
import type { Event } from "./history.js";
|
|
18
|
+
/** How often a trigger may start a run for one session or anchor. */
|
|
19
|
+
export type Repeat = "once" | "always" | { cooldown: Duration };
|
|
36
20
|
|
|
37
21
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* v2 vocabulary — see Requirements 17.1–17.9.
|
|
22
|
+
* Prompt text. `{{data.x}}`, `{{context.x}}` and `{{input.x}}` are filled in
|
|
23
|
+
* before the text is used.
|
|
42
24
|
*/
|
|
43
|
-
export type
|
|
44
|
-
| 'needs_input' // Waiting for user input
|
|
45
|
-
| 'last_step' // Flow ended because the last step had no successor
|
|
46
|
-
| 'completed' // Flow ended because an explicit `complete` directive fired
|
|
47
|
-
| 'aborted' // Conversation aborted via `abort` directive
|
|
48
|
-
| 'goto' // Turn ended because a goTo/goToStep directive redirected
|
|
49
|
-
| 'reset' // Turn ended because a `reset` directive fired
|
|
50
|
-
| 'halt' // Pre-LLM halt directive — turn ends without LLM call
|
|
51
|
-
| 'reply' // Turn ended because a verbatim reply was emitted (no LLM call)
|
|
52
|
-
| 'max_auto_steps' // Auto-step chain exceeded maxAutoStepsPerTurn cap
|
|
53
|
-
| 'prepare_error' // Error in prepare hook
|
|
54
|
-
| 'llm_error' // Error during LLM call
|
|
55
|
-
| 'validation_error' // Error validating collected data
|
|
56
|
-
| 'finalize_error'; // Error in finalize hook (non-fatal, logged)
|
|
25
|
+
export type Template = string;
|
|
57
26
|
|
|
58
27
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
28
|
+
* Where a step sends the run next: a step id, `'end'` (reserved; ends the
|
|
29
|
+
* run), a step with fields to clear first, or another flow to start.
|
|
61
30
|
*/
|
|
62
|
-
export
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
contextUpdate?: Partial<TContext>;
|
|
67
|
-
/** If true, stop the auto-step chain and end the turn with `reply` */
|
|
68
|
-
halt?: boolean;
|
|
69
|
-
/** Verbatim reply to send when halting */
|
|
70
|
-
reply?: string;
|
|
71
|
-
/** Jump to a step within the current flow */
|
|
72
|
-
goToStep?: string | { step: string; flow?: string; data?: Partial<TData>; reason?: string; };
|
|
73
|
-
/** Jump to another flow */
|
|
74
|
-
goTo?: string | { flow?: string; step?: string; data?: Partial<TData>; reason?: string; carry?: 'preserve' | 'reset'; };
|
|
75
|
-
/** Mark the current flow as complete */
|
|
76
|
-
complete?: true | { next?: Directive<unknown, unknown>; reason?: string; };
|
|
77
|
-
/**
|
|
78
|
-
* Prompt lines appended to this turn's generation prompt. Pre-LLM
|
|
79
|
-
* augmentation: honored by auto steps' prepare; other step kinds drop it
|
|
80
|
-
* with a loud warning rather than silently ignoring it.
|
|
81
|
-
*/
|
|
82
|
-
appendPrompt?: string[];
|
|
83
|
-
/**
|
|
84
|
-
* Extra tools made available for this turn only. Same auto-step-only
|
|
85
|
-
* honoring as {@link appendPrompt}.
|
|
86
|
-
*/
|
|
87
|
-
injectTools?: Tool[];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
31
|
+
export type Next<D = unknown> =
|
|
32
|
+
| string
|
|
33
|
+
| { step: string; clear?: (keyof D & string)[] }
|
|
34
|
+
| { flow: Template; input?: unknown };
|
|
91
35
|
|
|
92
|
-
//
|
|
36
|
+
// ── Fields and parameters ───────────────────────────────────────────────
|
|
93
37
|
|
|
94
|
-
|
|
95
|
-
* A programmatic transition directive. The single shape any tool, hook, branch,
|
|
96
|
-
* or signal handler returns to write state, redirect the conversation, or speak
|
|
97
|
-
* verbatim.
|
|
98
|
-
*
|
|
99
|
-
* At most one position field (`goTo`, `goToStep`, `complete`, `abort`, `reset`)
|
|
100
|
-
* may be set per Directive. Non-position fields (`reply`, `contextUpdate`,
|
|
101
|
-
* `dataUpdate`) may accompany any position field.
|
|
102
|
-
*
|
|
103
|
-
* Pre-LLM augmentation fields (`appendPrompt`, `injectTools`, `halt`) are
|
|
104
|
-
* one-turn-lifetime: they only take effect in pre-LLM hooks (`onEnter`,
|
|
105
|
-
* `prepare`). When emitted from post-LLM hooks (`finalize`, `onComplete`) or
|
|
106
|
-
* persisted to `session.pendingDirective`, these fields are ignored and a WARN
|
|
107
|
-
* log is emitted. They are never serialized across turns.
|
|
108
|
-
*/
|
|
109
|
-
export interface Directive<TContext = unknown, TData = unknown> {
|
|
110
|
-
// ── Position fields (mutually exclusive: at most one) ────────────
|
|
111
|
-
/** Jump to a flow (string) or a flow with options (object). */
|
|
112
|
-
goTo?: string | { flow?: string; step?: string; data?: Partial<TData>; reason?: string; carry?: 'preserve' | 'reset'; };
|
|
113
|
-
/** Jump to a specific step, optionally in another flow. */
|
|
114
|
-
goToStep?: string | { step: string; flow?: string; data?: Partial<TData>; reason?: string; };
|
|
115
|
-
/** Mark the current flow as complete. */
|
|
116
|
-
complete?: true | { next?: Directive<unknown, unknown>; reason?: string; };
|
|
117
|
-
/** Abort the current flow. */
|
|
118
|
-
abort?: string | { reason: string; clearSession?: boolean; };
|
|
119
|
-
/** Reset the current flow (or jump to a step within it). */
|
|
120
|
-
reset?: true | { step?: string; clearData?: boolean; reason?: string; };
|
|
121
|
-
|
|
122
|
-
// ── Verbatim utterance ───────────────────────────────────────────
|
|
123
|
-
/** Verbatim reply text to send to the user. */
|
|
124
|
-
reply?: string;
|
|
125
|
-
|
|
126
|
-
// ── State writes ─────────────────────────────────────────────────
|
|
127
|
-
/** Partial context update applied before the next turn. */
|
|
128
|
-
contextUpdate?: Partial<TContext>;
|
|
129
|
-
/** Partial data update applied before the next turn. */
|
|
130
|
-
dataUpdate?: Partial<TData>;
|
|
131
|
-
|
|
132
|
-
// ── Pre-LLM augmentation (one-turn lifetime) ─────────────────────
|
|
133
|
-
/**
|
|
134
|
-
* Sentences to append to the system prompt for THIS turn only.
|
|
135
|
-
* Wired through PromptComposer's per-turn appendage slot.
|
|
136
|
-
*
|
|
137
|
-
* Only meaningful in pre-LLM hooks (`onEnter`, `prepare`). Ignored with
|
|
138
|
-
* a WARN log when emitted from post-LLM hooks or persisted.
|
|
139
|
-
*/
|
|
140
|
-
appendPrompt?: string[];
|
|
38
|
+
export type ScalarType = "string" | "number" | "integer" | "boolean";
|
|
141
39
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
* a WARN log when emitted from post-LLM hooks or persisted.
|
|
148
|
-
*/
|
|
149
|
-
injectTools?: Tool[];
|
|
40
|
+
export interface ScalarDef<T extends ScalarType = ScalarType> {
|
|
41
|
+
type: T;
|
|
42
|
+
description?: string;
|
|
43
|
+
enum?: readonly (string | number)[];
|
|
44
|
+
}
|
|
150
45
|
|
|
46
|
+
/** One collectable field, authored once on the agent. */
|
|
47
|
+
export interface FieldDef<T extends ScalarType = ScalarType> extends ScalarDef<T> {
|
|
48
|
+
/** How the AI should ask for this field when a step collects it. */
|
|
49
|
+
ask?: string;
|
|
151
50
|
/**
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
* assistant output (`stoppedReason: 'reply'`). When `halt` is true
|
|
156
|
-
* without `reply`, the turn produces an empty assistant message
|
|
157
|
-
* (`stoppedReason: 'halt'`).
|
|
158
|
-
*
|
|
159
|
-
* Only meaningful in pre-LLM hooks (`onEnter`, `prepare`). Ignored with
|
|
160
|
-
* a WARN log when emitted from post-LLM hooks or persisted.
|
|
51
|
+
* Where the value may be harvested from. `'anywhere'` (default for strings
|
|
52
|
+
* and numbers): any lead message. `'asked'` (default for booleans): only the
|
|
53
|
+
* reply to the step that lists the field, so a stray "sim" never opens a gate.
|
|
161
54
|
*/
|
|
162
|
-
|
|
55
|
+
extract?: "anywhere" | "asked";
|
|
163
56
|
}
|
|
164
57
|
|
|
165
|
-
|
|
58
|
+
export type FieldDefs = Record<string, FieldDef>;
|
|
59
|
+
|
|
60
|
+
/** One parameter of a host action. All parameters are required unless `optional: true`. */
|
|
61
|
+
export type ParamDef =
|
|
62
|
+
| (ScalarDef & { optional?: true })
|
|
63
|
+
| { type: "array"; items: ScalarDef; description?: string; optional?: true };
|
|
64
|
+
|
|
65
|
+
export type ParamDefs = Record<string, ParamDef>;
|
|
66
|
+
|
|
67
|
+
type Simplify<T> = { [K in keyof T]: T[K] };
|
|
68
|
+
|
|
69
|
+
type TypeValue<T extends ScalarType> = T extends "string"
|
|
70
|
+
? string
|
|
71
|
+
: T extends "boolean"
|
|
72
|
+
? boolean
|
|
73
|
+
: number;
|
|
74
|
+
|
|
75
|
+
type ScalarValue<Def extends ScalarDef> = Def extends { enum: readonly (infer E)[] }
|
|
76
|
+
? E
|
|
77
|
+
: TypeValue<Def["type"]>;
|
|
78
|
+
|
|
79
|
+
type ParamValue<Def extends ParamDef> = Def extends { type: "array"; items: infer I extends ScalarDef }
|
|
80
|
+
? ScalarValue<I>[]
|
|
81
|
+
: Def extends ScalarDef
|
|
82
|
+
? ScalarValue<Def>
|
|
83
|
+
: never;
|
|
84
|
+
|
|
85
|
+
type OptionalKeys<P extends ParamDefs> = {
|
|
86
|
+
[K in keyof P]: P[K] extends { optional: true } ? K : never;
|
|
87
|
+
}[keyof P];
|
|
88
|
+
|
|
89
|
+
/** The collected-data type of a set of fields. Enums become literal unions. */
|
|
90
|
+
export type InferData<F extends FieldDefs> = Simplify<{ [K in keyof F]: ScalarValue<F[K]> }>;
|
|
91
|
+
|
|
92
|
+
/** The `with` shape of a host action, from its parameter definitions. */
|
|
93
|
+
export type InferParams<P extends ParamDefs> = Simplify<
|
|
94
|
+
{ [K in Exclude<keyof P, OptionalKeys<P>>]: ParamValue<P[K]> } & {
|
|
95
|
+
[K in OptionalKeys<P>]?: ParamValue<P[K]>;
|
|
96
|
+
}
|
|
97
|
+
>;
|
|
98
|
+
|
|
99
|
+
// ── Predicates ──────────────────────────────────────────────────────────
|
|
100
|
+
|
|
101
|
+
/** What a code predicate sees. `run` is the run about to move or start. */
|
|
102
|
+
export interface PredCtx<C = unknown, D = unknown, P = unknown> {
|
|
103
|
+
context: C;
|
|
104
|
+
data: Partial<D>;
|
|
105
|
+
input: P;
|
|
106
|
+
/** The run being judged. Absent only for an agent-level instruction while the idle speaker answers. */
|
|
107
|
+
run?: Run;
|
|
108
|
+
/** The host's reason the assistant cannot speak right now, when it cannot. */
|
|
109
|
+
silenced?: string;
|
|
110
|
+
now: Date;
|
|
111
|
+
}
|
|
166
112
|
|
|
167
113
|
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
* any field not declared in the source step's `requires`. Fields covered by
|
|
172
|
-
* `requires` are guaranteed present by the engine when the predicate runs;
|
|
173
|
-
* everything else is `T | undefined`.
|
|
114
|
+
* A named host condition, used by name (with its argument) in JSON specs.
|
|
115
|
+
* Declared as a method so a condition typed for one argument fits the map;
|
|
116
|
+
* the argument arrives from JSON unvalidated, so the check should test it.
|
|
174
117
|
*/
|
|
175
|
-
export interface
|
|
176
|
-
|
|
177
|
-
data: Partial<TData>;
|
|
178
|
-
/** Agent-level context. */
|
|
179
|
-
context: TContext;
|
|
180
|
-
/** Full session state. */
|
|
181
|
-
session: SessionState<TData>;
|
|
182
|
-
/** Conversation history as events. */
|
|
183
|
-
history: Event[];
|
|
118
|
+
export interface Condition<C = unknown, D = unknown, Arg = unknown> {
|
|
119
|
+
check(ctx: PredCtx<C, D>, arg: Arg): boolean;
|
|
184
120
|
}
|
|
185
121
|
|
|
186
|
-
|
|
187
|
-
* A code predicate for branch evaluation. Returns `true` to pass, `false`
|
|
188
|
-
* to skip the entry. May be async.
|
|
189
|
-
*
|
|
190
|
-
* Predicates are evaluated **before** any AI condition (`when`) on the same
|
|
191
|
-
* entry — code-first evaluation saves tokens when the predicate fails.
|
|
192
|
-
*/
|
|
193
|
-
export type BranchPredicate<TContext = unknown, TData = unknown> = (
|
|
194
|
-
ctx: BranchPredicateContext<TContext, TData>,
|
|
195
|
-
) => boolean | Promise<boolean>;
|
|
122
|
+
export type ConditionMap<C = unknown, D = unknown> = Record<string, Condition<C, D>>;
|
|
196
123
|
|
|
197
124
|
/**
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
* 1. String matching a step id in the current flow → enter that step.
|
|
203
|
-
* 2. String matching a flow id/title in the agent → treated as
|
|
204
|
-
* `applyDirective({ goTo: <string> })`.
|
|
205
|
-
* 3. `Directive` object → applied via `applyDirective` directly.
|
|
206
|
-
*
|
|
207
|
-
* An entry with neither `when` nor `if` is an unconditional fallback and
|
|
208
|
-
* is only legal as the **last** entry in the array.
|
|
125
|
+
* The JSON form of a predicate. Every listed entry must hold. Built-ins:
|
|
126
|
+
* `equals` (fields equal the given values), `known` (fields are known),
|
|
127
|
+
* `silenced` (the host gate is closed). Any other key names one of the
|
|
128
|
+
* agent's conditions and carries its argument.
|
|
209
129
|
*/
|
|
210
|
-
export interface
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
* Only evaluated if `if` passes (or is absent) — code-first short-circuit.
|
|
216
|
-
*/
|
|
217
|
-
when?: string | string[];
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Code predicate. Function or array of functions (AND semantics).
|
|
221
|
-
* Free to evaluate. When both `when` and `if` are set, `if` runs first;
|
|
222
|
-
* `when` is only evaluated if all `if` predicates pass (token-saving).
|
|
223
|
-
*/
|
|
224
|
-
if?: BranchPredicate<TContext, TData> | BranchPredicate<TContext, TData>[];
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Where to go when this entry matches.
|
|
228
|
-
* - **String:** step id in the current flow, or flow id/title for cross-flow.
|
|
229
|
-
* - **Directive:** full programmatic transition (cross-flow with data,
|
|
230
|
-
* complete, abort, reset, etc.).
|
|
231
|
-
*/
|
|
232
|
-
then: string | Directive<TContext, TData>;
|
|
233
|
-
|
|
234
|
-
/** Optional label for event traces and flow visualization. */
|
|
235
|
-
label?: string;
|
|
130
|
+
export interface ConditionSpec<D = unknown> {
|
|
131
|
+
equals?: Partial<D>;
|
|
132
|
+
known?: (keyof D & string)[];
|
|
133
|
+
silenced?: boolean;
|
|
134
|
+
[condition: string]: unknown;
|
|
236
135
|
}
|
|
237
136
|
|
|
238
|
-
/**
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
*/
|
|
243
|
-
export type BranchMap<TContext = unknown, TData = unknown> = Array<BranchEntry<TContext, TData>>;
|
|
137
|
+
/** A code predicate (free) or its JSON form. */
|
|
138
|
+
export type Pred<C = unknown, D = unknown, P = unknown> =
|
|
139
|
+
| ((ctx: PredCtx<C, D, P>) => boolean)
|
|
140
|
+
| ConditionSpec<D>;
|
|
244
141
|
|
|
245
|
-
|
|
142
|
+
/** A fork judged while a step is asking: `when` by the AI, `if` by code. */
|
|
143
|
+
export type Branch<C = unknown, D = unknown> = { then: Next<D> } & (
|
|
144
|
+
| { when: string }
|
|
145
|
+
| { if: Pred<C, D> }
|
|
146
|
+
);
|
|
246
147
|
|
|
247
|
-
|
|
248
|
-
* Reference to a flow
|
|
249
|
-
*/
|
|
250
|
-
export interface FlowRef {
|
|
251
|
-
/** Flow identifier */
|
|
252
|
-
id: string;
|
|
253
|
-
}
|
|
148
|
+
// ── Triggers ────────────────────────────────────────────────────────────
|
|
254
149
|
|
|
255
150
|
/**
|
|
256
|
-
*
|
|
151
|
+
* When a run starts. `repeat` defaults to `'once'` for message, mention and
|
|
152
|
+
* silence triggers and to `'always'` for events.
|
|
257
153
|
*/
|
|
258
|
-
export
|
|
259
|
-
/**
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
|
|
154
|
+
export type Trigger<C = unknown, D = unknown> = { repeat?: Repeat } & (
|
|
155
|
+
/** The lead asks for this; the run takes the conversation. `[]` = catch-all. */
|
|
156
|
+
| { message: string[]; if?: Pred<C, D> }
|
|
157
|
+
/** The lead mentions this; the run reacts beside the conversation. `[]` + `if` = code-only. */
|
|
158
|
+
| { mention: string[]; extract?: ParamDefs; if?: Pred<C, D> }
|
|
159
|
+
/** The lead has been quiet since the assistant last spoke. */
|
|
160
|
+
| { silence: Duration; if?: Pred<C, D>; businessHours?: boolean }
|
|
161
|
+
/** The host reported an event; its payload is the run's `input`. */
|
|
162
|
+
| { event: string; if?: Pred<C, D>; after?: Duration; businessHours?: boolean }
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
// ── Instructions ────────────────────────────────────────────────────────
|
|
166
|
+
|
|
167
|
+
/** A behavioural statement rendered into the prompt while it applies. */
|
|
168
|
+
export interface Instruction<C = unknown, D = unknown> {
|
|
169
|
+
id?: string;
|
|
170
|
+
/** `'must'` always, `'never'` a prohibition, `'should'` (default) a nudge. */
|
|
171
|
+
kind?: "must" | "never" | "should";
|
|
172
|
+
/** AI-judged activation, rendered into the prompt. */
|
|
173
|
+
when?: string | string[];
|
|
174
|
+
/** Code-judged activation, free. */
|
|
175
|
+
if?: Pred<C, D>;
|
|
176
|
+
prompt: Template;
|
|
263
177
|
}
|
|
264
178
|
|
|
179
|
+
// ── Steps ───────────────────────────────────────────────────────────────
|
|
180
|
+
|
|
181
|
+
/** The AI talks: a guideline, fields to collect, or both. */
|
|
182
|
+
export type TalkStep<C = unknown, D = unknown> = (
|
|
183
|
+
| { prompt: Template; collect?: (keyof D & string)[] }
|
|
184
|
+
| { collect: (keyof D & string)[]; prompt?: Template }
|
|
185
|
+
) & {
|
|
186
|
+
/** Per-flow wording for a field; the field's own `ask` is the default. */
|
|
187
|
+
ask?: Partial<Record<keyof D & string, string>>;
|
|
188
|
+
/** Times a field may be asked before it is skipped. Default 3. */
|
|
189
|
+
maxAsks?: number;
|
|
190
|
+
branches?: Branch<C, D>[];
|
|
191
|
+
tools?: string[];
|
|
192
|
+
instructions?: Instruction<C, D>[];
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
/** A fixed message goes out, verbatim. */
|
|
196
|
+
export interface SayStep {
|
|
197
|
+
say: Template;
|
|
198
|
+
media?: { slug: string };
|
|
199
|
+
/** Send at most once per session. */
|
|
200
|
+
once?: boolean;
|
|
201
|
+
}
|
|
265
202
|
|
|
203
|
+
/** The host does something. `with` is checked against the action's parameters. */
|
|
204
|
+
export interface DoStep<D = unknown> {
|
|
205
|
+
do: string;
|
|
206
|
+
with?: Record<string, unknown>;
|
|
207
|
+
/** Where to go when the action reports `failed`. Default: continue. */
|
|
208
|
+
onFail?: Next<D>;
|
|
209
|
+
}
|
|
266
210
|
|
|
267
|
-
/**
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
*/
|
|
275
|
-
export interface FlowLifecycleHooks<TContext = unknown, TData = unknown> {
|
|
276
|
-
/**
|
|
277
|
-
* Called when the flow is first entered.
|
|
278
|
-
* May return a Directive to augment the prompt, inject tools, halt, or redirect.
|
|
279
|
-
* Pre-LLM fields (`appendPrompt`, `injectTools`, `halt`) are honored here.
|
|
280
|
-
*/
|
|
281
|
-
onEnter?: (
|
|
282
|
-
ctx: HookContext<TContext, TData>
|
|
283
|
-
) => void | Directive<TContext, TData> | Promise<void | Directive<TContext, TData>>;
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Called when the flow is exited. Informational only — cannot influence flow control.
|
|
287
|
-
* Receives the reason the flow was exited.
|
|
288
|
-
*/
|
|
289
|
-
onExit?: (
|
|
290
|
-
ctx: HookContext<TContext, TData>,
|
|
291
|
-
reason: ExitReason
|
|
292
|
-
) => void | Promise<void>;
|
|
211
|
+
/** Park for a while. `then` = the time passed; `else` = the lead replied first. */
|
|
212
|
+
export interface WaitStep<C = unknown, D = unknown> {
|
|
213
|
+
wait: Duration;
|
|
214
|
+
businessHours?: boolean;
|
|
215
|
+
else?: Next<D>;
|
|
216
|
+
branches?: Branch<C, D>[];
|
|
217
|
+
}
|
|
293
218
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
ctx: HookContext<TContext, TData>
|
|
300
|
-
) => void | Directive<TContext, TData> | Promise<void | Directive<TContext, TData>>;
|
|
219
|
+
/** Park until an event. `then` = it came; `else` = `upTo` passed (default 30 days). */
|
|
220
|
+
export interface WaitEventStep<D = unknown> {
|
|
221
|
+
wait: { event: string; upTo?: Duration };
|
|
222
|
+
else?: Next<D>;
|
|
223
|
+
}
|
|
301
224
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
* Unlike Agent-level onDataUpdate, this only triggers for data changes in this specific flow.
|
|
308
|
-
*/
|
|
309
|
-
onDataUpdate?: (
|
|
310
|
-
data: Partial<TData>,
|
|
311
|
-
previousCollected: Partial<TData>
|
|
312
|
-
) => Partial<TData> | Promise<Partial<TData>>;
|
|
225
|
+
/** The code forks. `then` = true; `else` = false (default `'end'`). */
|
|
226
|
+
export interface IfStep<C = unknown, D = unknown> {
|
|
227
|
+
if: Pred<C, D>;
|
|
228
|
+
else?: Next<D>;
|
|
229
|
+
}
|
|
313
230
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
newContext: TContext,
|
|
322
|
-
previousContext: TContext
|
|
323
|
-
) => void | Promise<void>;
|
|
231
|
+
export interface StepBase<D = unknown> {
|
|
232
|
+
/** Required, unique inside the flow, never `'end'`. */
|
|
233
|
+
id: string;
|
|
234
|
+
label?: string;
|
|
235
|
+
then?: Next<D>;
|
|
236
|
+
/** Editor-only data the framework carries but never reads. */
|
|
237
|
+
ui?: Record<string, unknown>;
|
|
324
238
|
}
|
|
325
239
|
|
|
240
|
+
export type Step<C = unknown, D = unknown> = StepBase<D> &
|
|
241
|
+
(TalkStep<C, D> | SayStep | DoStep<D> | WaitStep<C, D> | WaitEventStep<D> | IfStep<C, D>);
|
|
326
242
|
|
|
243
|
+
// ── Flow ────────────────────────────────────────────────────────────────
|
|
327
244
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
*/
|
|
332
|
-
export interface FlowOptions<TContext = unknown, TData = unknown> {
|
|
333
|
-
/** Custom ID for the flow (optional - will generate deterministic ID from title if not provided) */
|
|
334
|
-
id?: string;
|
|
335
|
-
/** Title of the flow */
|
|
336
|
-
title: string;
|
|
337
|
-
/** Description of what this flow accomplishes */
|
|
245
|
+
export interface Flow<C = unknown, D = unknown> {
|
|
246
|
+
id: string;
|
|
247
|
+
name: string;
|
|
248
|
+
/** When this flow should be used; the AI reads it when routing. */
|
|
338
249
|
description?: string;
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
if?: ConditionIf<TContext, TData>;
|
|
352
|
-
/**
|
|
353
|
-
* Instructions for this flow.
|
|
354
|
-
*/
|
|
355
|
-
instructions?: Instruction<TContext, TData>[];
|
|
356
|
-
/** Tools available in this flow */
|
|
357
|
-
tools?: (string | Tool<TContext, TData>)[];
|
|
358
|
-
|
|
359
|
-
/** Optional: extractions the router may return (added to routing schema) */
|
|
360
|
-
routingExtrasSchema?: StructuredSchema;
|
|
361
|
-
/** Optional: structured response data for this flow's message generation */
|
|
362
|
-
responseOutputSchema?: StructuredSchema;
|
|
363
|
-
/**
|
|
364
|
-
* Required fields for flow completion - must be valid keys from agent's TData type
|
|
365
|
-
* Flow is considered complete when all required fields are present in agent data
|
|
366
|
-
*/
|
|
367
|
-
requiredFields?: (keyof TData)[];
|
|
368
|
-
/**
|
|
369
|
-
* Optional fields that enhance the flow but aren't required for completion
|
|
370
|
-
* Must be valid keys from agent's TData type
|
|
371
|
-
*/
|
|
372
|
-
optionalFields?: (keyof TData)[];
|
|
373
|
-
/**
|
|
374
|
-
* Initial data to pre-populate when entering this flow
|
|
375
|
-
* Useful for restoring sessions or pre-filling known information
|
|
376
|
-
* Steps with skip conditions will be automatically bypassed if data is present
|
|
377
|
-
* Now refers to agent-level data
|
|
378
|
-
*/
|
|
379
|
-
initialData?: Partial<TData>;
|
|
380
|
-
/**
|
|
381
|
-
* Sequential steps for simple linear flows
|
|
382
|
-
* If provided, automatically chains the steps from initialStep
|
|
383
|
-
* The last step in the array is the implicit terminus of the flow
|
|
384
|
-
* For complex flows with branching, build the step machine manually instead
|
|
385
|
-
*/
|
|
386
|
-
steps?: StepOptions<TContext, TData>[];
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* Optional transition when the flow completes (last step finishes).
|
|
390
|
-
*
|
|
391
|
-
* Accepts a flow ID or title string — sugar for
|
|
392
|
-
* `hooks.onComplete = () => ({ goTo: '<id>' })`.
|
|
393
|
-
*
|
|
394
|
-
* For dynamic completion logic, use `hooks.onComplete` instead.
|
|
395
|
-
* Setting both `onComplete` and `hooks.onComplete` on the same flow
|
|
396
|
-
* throws `FlowConfigurationError` at construction time.
|
|
397
|
-
*
|
|
398
|
-
* @example
|
|
399
|
-
* // Simple string — transitions to "Collect Feedback" on completion
|
|
400
|
-
* onComplete: "Collect Feedback"
|
|
401
|
-
*/
|
|
402
|
-
onComplete?: string;
|
|
403
|
-
/**
|
|
404
|
-
* If true, this flow can be re-selected by the router after it has
|
|
405
|
-
* completed in the current session — useful for "do another?" patterns
|
|
406
|
-
* (re-book, re-search, repeat-task).
|
|
407
|
-
*
|
|
408
|
-
* Default: `false`. Once a flow completes (and `onComplete` is not set
|
|
409
|
-
* or returns `undefined`), the flow is excluded from routing candidates
|
|
410
|
-
* for the rest of the session unless `reentrant: true`.
|
|
411
|
-
*
|
|
412
|
-
* On re-entry, the engine clears every field declared in this flow's
|
|
413
|
-
* `requiredFields` and `optionalFields` (so the flow starts fresh from
|
|
414
|
-
* its initial step). Fields not declared as owned by this flow are
|
|
415
|
-
* preserved in `session.data`.
|
|
416
|
-
*
|
|
417
|
-
* `onComplete` always wins over `reentrant`. If `onComplete` returns a
|
|
418
|
-
* target flow, the session transitions there immediately on completion;
|
|
419
|
-
* `reentrant` is consulted only when `onComplete` is absent or returns
|
|
420
|
-
* `undefined`.
|
|
421
|
-
*/
|
|
422
|
-
reentrant?: boolean;
|
|
423
|
-
/**
|
|
424
|
-
* Flow lifecycle hooks
|
|
425
|
-
*/
|
|
426
|
-
hooks?: FlowLifecycleHooks<TContext, TData>;
|
|
250
|
+
/** Absent or empty: the flow only starts when the host calls `start`. */
|
|
251
|
+
on?: Trigger<C, D>[];
|
|
252
|
+
/** `'session'` (default) or a host anchor name such as `'lead'`. */
|
|
253
|
+
anchor?: string;
|
|
254
|
+
/** Re-checked whenever the run moves. Default: the trigger's `if`. */
|
|
255
|
+
while?: Pred<C, D>;
|
|
256
|
+
clearOnStart?: (keyof D & string)[];
|
|
257
|
+
steps: Step<C, D>[];
|
|
258
|
+
/** What the run does after its last step. Default `'end'`. */
|
|
259
|
+
onEnd?: "end" | "stay" | "reset";
|
|
260
|
+
instructions?: Instruction<C, D>[];
|
|
261
|
+
tools?: string[];
|
|
427
262
|
}
|
|
428
263
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
|
|
451
|
-
* persistence). May return a Directive to redirect flow or write state.
|
|
452
|
-
*/
|
|
453
|
-
finalize?: (
|
|
454
|
-
context: TContext,
|
|
455
|
-
data?: Partial<TData>
|
|
456
|
-
) => void | Directive<TContext, TData> | Promise<void | Directive<TContext, TData>>;
|
|
264
|
+
// ── Actions and events ──────────────────────────────────────────────────
|
|
265
|
+
|
|
266
|
+
export type ActionResult =
|
|
267
|
+
| { ok: true; detail?: string; spoke?: true }
|
|
268
|
+
| { skipped: string }
|
|
269
|
+
| { failed: string }
|
|
270
|
+
| { defer: Duration; detail: string };
|
|
271
|
+
|
|
272
|
+
/** What a host action sees. Handlers run at-least-once; make them idempotent on `key`. */
|
|
273
|
+
export interface ActionCtx<C = unknown, D = unknown> {
|
|
274
|
+
context: C;
|
|
275
|
+
data: Partial<D>;
|
|
276
|
+
input: unknown;
|
|
277
|
+
run: Run;
|
|
278
|
+
/** `${runId}:${stepId}:${visit}`; the same on a replay of the same input. */
|
|
279
|
+
key: string;
|
|
280
|
+
/** `${flowId}:${anchor}:${nonce}`; shared across a lead's sessions. */
|
|
281
|
+
dedupeKey: string;
|
|
282
|
+
silenced?: string;
|
|
283
|
+
now: Date;
|
|
284
|
+
/** Write collected data from inside the action. */
|
|
285
|
+
set(patch: Partial<D>): void;
|
|
457
286
|
}
|
|
458
287
|
|
|
459
|
-
|
|
460
|
-
* Specification for a step transition
|
|
461
|
-
*/
|
|
462
|
-
export interface StepOptions<TContext = unknown, TData = unknown> {
|
|
463
|
-
/** Custom ID for this step (optional - will generate deterministic ID if not provided) */
|
|
464
|
-
id?: string;
|
|
465
|
-
/** Description of the transition */
|
|
288
|
+
export interface Action<C = unknown, D = unknown, P = Record<string, unknown>> {
|
|
466
289
|
description?: string;
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
tools?: (string | Tool<TContext, TData>)[];
|
|
471
|
-
/** Programmatic function or tool to run before AI responds */
|
|
472
|
-
prepare?:
|
|
473
|
-
| string
|
|
474
|
-
| Tool<TContext, TData>
|
|
475
|
-
| ((context: TContext, data?: Partial<TData>) => void | PrepareResult<TContext, TData> | Promise<void | PrepareResult<TContext, TData>>);
|
|
476
|
-
/** Programmatic function or tool to run after AI responds */
|
|
477
|
-
finalize?:
|
|
478
|
-
| string
|
|
479
|
-
| Tool<TContext, TData>
|
|
480
|
-
| ((context: TContext, data?: Partial<TData>) => void | PrepareResult<TContext, TData> | Promise<void | PrepareResult<TContext, TData>>);
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* Fields to collect from the conversation in this step
|
|
484
|
-
* These should match keys in the agent's TData schema
|
|
485
|
-
*/
|
|
486
|
-
collect?: (keyof TData)[];
|
|
487
|
-
/**
|
|
488
|
-
* Code-evaluated skip condition. If evaluates to true, the step will be bypassed.
|
|
489
|
-
* Function or array of functions (OR semantics) — if any returns true, step is skipped.
|
|
490
|
-
* Only code predicates are allowed here (no AI strings).
|
|
491
|
-
*
|
|
492
|
-
* Renamed from v1 `skipIf` to clarify the if-only shape.
|
|
493
|
-
*/
|
|
494
|
-
skip?: ConditionIf<TContext, TData>;
|
|
495
|
-
/**
|
|
496
|
-
* Required data fields that must be present before entering this step
|
|
497
|
-
* If any required field is missing, step cannot be entered
|
|
498
|
-
* Must be valid keys from agent's TData type
|
|
499
|
-
*/
|
|
500
|
-
requires?: (keyof TData)[];
|
|
501
|
-
/**
|
|
502
|
-
* AI-evaluated activation condition(s). Non-`!` strings are OR alternatives;
|
|
503
|
-
* `!` strings are OR exclusions where any match inhibits activation.
|
|
504
|
-
* Costs LLM tokens. Functions are NOT allowed here — use `if` for code predicates.
|
|
505
|
-
*/
|
|
506
|
-
when?: ConditionWhen;
|
|
507
|
-
/**
|
|
508
|
-
* Code-evaluated activation condition(s). Function or array of functions (AND semantics).
|
|
509
|
-
* Free to evaluate. When both `when` and `if` are set, `if` runs first;
|
|
510
|
-
* `when` is only evaluated when `if` passes.
|
|
511
|
-
*/
|
|
512
|
-
if?: ConditionIf<TContext, TData>;
|
|
513
|
-
/**
|
|
514
|
-
* Instructions for this step. Replaces v1's `guidelines`.
|
|
515
|
-
*/
|
|
516
|
-
instructions?: Instruction<TContext, TData>[];
|
|
517
|
-
|
|
518
|
-
/**
|
|
519
|
-
* If true, this step runs without an LLM call. Pre-LLM hooks
|
|
520
|
-
* (`onEnter`, `prepare`) and branch resolution still execute.
|
|
521
|
-
*
|
|
522
|
-
* An auto-step **cannot** define `prompt`, `collect`, `tools`, or `finalize`.
|
|
523
|
-
* Defining any of these will throw `FlowConfigurationError` at construction time.
|
|
524
|
-
*
|
|
525
|
-
* Use auto-steps for:
|
|
526
|
-
* - Data enrichment between user-facing steps (CRM lookup, pricing calc).
|
|
527
|
-
* - Deterministic decision points (pair with `branches`).
|
|
528
|
-
* - Programmatic short-circuits (`prepare` returning `{ halt: true, reply }`).
|
|
529
|
-
*
|
|
530
|
-
* @default false
|
|
531
|
-
*/
|
|
532
|
-
auto?: boolean;
|
|
533
|
-
|
|
534
|
-
/**
|
|
535
|
-
* Verbatim assistant output for this step. When set, the template is
|
|
536
|
-
* rendered via the same engine as `prompt` and emitted as the assistant
|
|
537
|
-
* message without invoking the LLM.
|
|
538
|
-
*
|
|
539
|
-
* A reply step **cannot** define `prompt`, `collect`, `tools`, `finalize`,
|
|
540
|
-
* or `auto: true`. Defining any of these will throw `FlowConfigurationError`
|
|
541
|
-
* at construction time.
|
|
542
|
-
*
|
|
543
|
-
* `onEnter` and `prepare` hooks fire normally before the reply is rendered.
|
|
544
|
-
* If `prepare` returns a Directive with its own `reply` field, the
|
|
545
|
-
* hook-emitted reply wins (last-emission-wins per Algorithm 4).
|
|
546
|
-
*
|
|
547
|
-
* After emission, `onExit` fires and `branches` are resolved for next step.
|
|
548
|
-
* `stoppedReason: 'reply'`.
|
|
549
|
-
*
|
|
550
|
-
* Use reply steps for: confirmations, hand-offs, farewells, acks — anything
|
|
551
|
-
* that doesn't need LLM reasoning.
|
|
552
|
-
*/
|
|
553
|
-
reply?: Template<TContext, TData>;
|
|
290
|
+
parameters: ParamDefs;
|
|
291
|
+
run(params: P, ctx: ActionCtx<C, D>): ActionResult | Promise<ActionResult>;
|
|
292
|
+
}
|
|
554
293
|
|
|
555
|
-
|
|
556
|
-
* Explicit source-local fork. An array of branch entries evaluated in
|
|
557
|
-
* declaration order — the first entry whose conditions pass wins; its
|
|
558
|
-
* `then` resolves to the next step or a Directive.
|
|
559
|
-
*
|
|
560
|
-
* Coexists with `nextStep`. If `branches` is absent or no entry matches,
|
|
561
|
-
* resolution falls through to linear nextStep / AI step selection.
|
|
562
|
-
*
|
|
563
|
-
* Runs **after** the step's post-LLM phase (tool execution, `finalize`)
|
|
564
|
-
* and **before** linear successor selection.
|
|
565
|
-
*/
|
|
566
|
-
branches?: BranchMap<TContext, TData>;
|
|
294
|
+
export type ActionMap<C = unknown, D = unknown> = Record<string, Action<C, D>>;
|
|
567
295
|
|
|
296
|
+
/** A host event the agent may react to. `P` is the payload type. */
|
|
297
|
+
export interface EventDef<P = unknown> {
|
|
568
298
|
/**
|
|
569
|
-
*
|
|
570
|
-
* `
|
|
571
|
-
* returns are merged via Algorithm 4.
|
|
299
|
+
* `'inbound'` counts as the lead speaking (resolves reply waits);
|
|
300
|
+
* `'outbound'` as the assistant speaking (re-arms silence).
|
|
572
301
|
*/
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* Specification for a branch in the conversation flow
|
|
578
|
-
*/
|
|
579
|
-
export interface BranchSpec<TContext = unknown, TData = unknown> {
|
|
580
|
-
/** User-friendly identifier for this branch (used as object key) */
|
|
581
|
-
name: string;
|
|
582
|
-
/** Optional ID for this branch (auto-generated if not provided) */
|
|
583
|
-
id?: string;
|
|
584
|
-
/** Step configuration for this branch */
|
|
585
|
-
step: StepOptions<TContext, TData>;
|
|
302
|
+
direction?: "inbound" | "outbound";
|
|
303
|
+
/** Phantom: the payload type, for inference. Never set at runtime. */
|
|
304
|
+
readonly payload?: P;
|
|
586
305
|
}
|
|
587
306
|
|
|
588
|
-
|
|
589
|
-
* Result of a branch operation
|
|
590
|
-
* Maps branch names to their respective step results for continued chaining
|
|
591
|
-
*/
|
|
592
|
-
export interface BranchResult<TContext = unknown, TData = unknown> {
|
|
593
|
-
[branchName: string]: StepResult<TContext, TData>;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* Result of a transition operation
|
|
598
|
-
* Combines step reference with the ability to chain transitions and create branches
|
|
599
|
-
*/
|
|
600
|
-
export interface StepResult<TContext = unknown, TData = unknown>
|
|
601
|
-
extends StepRef {
|
|
602
|
-
/** Allow chaining transitions */
|
|
603
|
-
nextStep: (spec: StepOptions<TContext, TData>) => StepResult<TContext, TData>;
|
|
604
|
-
/** Create multiple branches from this step */
|
|
605
|
-
branch: (
|
|
606
|
-
branches: BranchSpec<TContext, TData>[]
|
|
607
|
-
) => BranchResult<TContext, TData>;
|
|
608
|
-
}
|
|
307
|
+
export type EventMap = Record<string, EventDef>;
|