@falai/agent 3.4.5 → 4.0.0-alpha.10
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 +29 -378
- package/dist/cjs/core/Agent.d.ts.map +1 -1
- package/dist/cjs/core/Agent.js +113 -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 +573 -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 +149 -0
- package/dist/cjs/core/Prompt.js.map +1 -0
- package/dist/cjs/core/Runner.d.ts +171 -0
- package/dist/cjs/core/Runner.d.ts.map +1 -0
- package/dist/cjs/core/Runner.js +1158 -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 +373 -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 +357 -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 +163 -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/phrases.d.ts +25 -0
- package/dist/cjs/utils/phrases.d.ts.map +1 -0
- package/dist/cjs/utils/phrases.js +38 -0
- package/dist/cjs/utils/phrases.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 +22 -150
- package/dist/cjs/utils/template.d.ts.map +1 -1
- package/dist/cjs/utils/template.js +64 -359
- 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 +29 -378
- package/dist/core/Agent.d.ts.map +1 -1
- package/dist/core/Agent.js +116 -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 +567 -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 +139 -0
- package/dist/core/Prompt.js.map +1 -0
- package/dist/core/Runner.d.ts +171 -0
- package/dist/core/Runner.d.ts.map +1 -0
- package/dist/core/Runner.js +1154 -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 +369 -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 +353 -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 +163 -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/phrases.d.ts +25 -0
- package/dist/utils/phrases.d.ts.map +1 -0
- package/dist/utils/phrases.js +35 -0
- package/dist/utils/phrases.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 +22 -150
- package/dist/utils/template.d.ts.map +1 -1
- package/dist/utils/template.js +61 -351
- 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 +170 -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 +457 -0
- package/docs/reference/actions-events-conditions.md +396 -0
- package/docs/reference/agent.md +248 -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 +200 -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 +181 -163
- 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 +149 -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 +11 -6
- package/src/core/Agent.ts +126 -1512
- package/src/core/CompactionEngine.ts +7 -4
- package/src/core/FlowSpec.ts +778 -0
- package/src/core/Migrate.ts +256 -0
- package/src/core/Prompt.ts +162 -0
- package/src/core/Runner.ts +1214 -0
- package/src/core/Speak.ts +460 -0
- package/src/core/Understand.ts +423 -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 +120 -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 +135 -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 +88 -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/phrases.ts +40 -0
- package/src/utils/schema.ts +145 -0
- package/src/utils/streamingMessage.ts +34 -4
- package/src/utils/template.ts +63 -418
- 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/dist/cjs/core/Agent.js
CHANGED
|
@@ -1,1198 +1,133 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Agent: immutable configuration plus one entry point, `turn`.
|
|
4
|
+
*
|
|
5
|
+
* One instance serves every session; context and history arrive per turn.
|
|
6
|
+
* A turn is the eight phases of docs/rfc/v4-one-flow.md §4 in one line each:
|
|
7
|
+
* Runner moves the runs by code, Understand and Speak spend at most one
|
|
8
|
+
* provider call apiece, and Runner settles what they returned.
|
|
4
9
|
*/
|
|
5
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
11
|
exports.Agent = void 0;
|
|
7
12
|
const errors_js_1 = require("../types/errors.js");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const index_js_1 = require("../utils/index.js");
|
|
11
|
-
const Flow_js_1 = require("./Flow.js");
|
|
12
|
-
const Step_js_1 = require("./Step.js");
|
|
13
|
-
const PersistenceManager_js_1 = require("./PersistenceManager.js");
|
|
14
|
-
const SessionManager_js_1 = require("./SessionManager.js");
|
|
15
|
-
const FlowRouter_js_1 = require("./FlowRouter.js");
|
|
16
|
-
const PromptSectionCache_js_1 = require("./PromptSectionCache.js");
|
|
17
|
-
const ResponseModal_js_1 = require("./ResponseModal.js");
|
|
18
|
-
const ToolManager_js_1 = require("./ToolManager.js");
|
|
13
|
+
const logger_js_1 = require("../utils/logger.js");
|
|
14
|
+
const usage_js_1 = require("../utils/usage.js");
|
|
19
15
|
const CompactionEngine_js_1 = require("./CompactionEngine.js");
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
constructor(errors, message) {
|
|
25
|
-
super(message || "Data validation failed");
|
|
26
|
-
this.errors = errors;
|
|
27
|
-
this.name = "DataValidationError";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Error thrown when flow configuration is invalid
|
|
32
|
-
*/
|
|
33
|
-
class FlowConfigurationError extends Error {
|
|
34
|
-
constructor(flowTitle, invalidFields, message) {
|
|
35
|
-
super(message || `Flow configuration error in '${flowTitle}'`);
|
|
36
|
-
this.flowTitle = flowTitle;
|
|
37
|
-
this.invalidFields = invalidFields;
|
|
38
|
-
this.name = "FlowConfigurationError";
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Main Agent class with generic context and data support
|
|
43
|
-
*/
|
|
16
|
+
const FlowSpec_js_1 = require("./FlowSpec.js");
|
|
17
|
+
const Runner_js_1 = require("./Runner.js");
|
|
18
|
+
const Speak_js_1 = require("./Speak.js");
|
|
19
|
+
const Understand_js_1 = require("./Understand.js");
|
|
44
20
|
class Agent {
|
|
45
21
|
constructor(options) {
|
|
46
22
|
this.options = options;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.
|
|
51
|
-
this.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.
|
|
59
|
-
this.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
throw new Step_js_1.FlowConfigurationError(`[FlowConfigurationError] Signal "${signal.id}" has an invalid extract schema. ` +
|
|
110
|
-
`Expected a JSON Schema object, got: ${typeof signal.extract}.`);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
this._signals = rawSignals;
|
|
115
|
-
// Requirement 2.3: Only instantiate SignalProcessor when signals are present
|
|
116
|
-
if (rawSignals.length > 0) {
|
|
117
|
-
const evaluator = new SignalEvaluator_js_1.SignalEvaluator(options.provider);
|
|
118
|
-
this.signalProcessor = new SignalProcessor_js_1.SignalProcessor(rawSignals, options.provider, evaluator, { batchSize: options.signalBatchSize ?? 10 });
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
this.signalProcessor = undefined;
|
|
122
|
-
}
|
|
123
|
-
// Set log level based on debug option. NOTE: loglevel's default logger is
|
|
124
|
-
// process-global — one agent enabling debug turns on DEBUG for every agent
|
|
125
|
-
// in the process. Warned so multi-tenant embedders aren't surprised.
|
|
126
|
-
if (options.debug) {
|
|
127
|
-
index_js_1.logger.warn(`[Agent] "${options.name}" enabled debug logging via the PROCESS-GLOBAL loglevel level. ` +
|
|
128
|
-
`Every agent in this process now logs at DEBUG. Scope logging in your host if needed.`);
|
|
129
|
-
index_js_1.logger.setLevel(index_js_1.LoggerLevel.DEBUG);
|
|
130
|
-
}
|
|
131
|
-
// Validate context configuration
|
|
132
|
-
if (options.context !== undefined && options.contextProvider) {
|
|
133
|
-
throw new Error("Cannot provide both 'context' and 'contextProvider'. Choose one.");
|
|
134
|
-
}
|
|
135
|
-
// Initialize and validate agent-level schema if provided
|
|
136
|
-
if (options.schema) {
|
|
137
|
-
this._schema = options.schema;
|
|
138
|
-
this.validateSchema(this._schema);
|
|
139
|
-
index_js_1.logger.debug("[Agent] Agent-level schema initialized and validated");
|
|
140
|
-
}
|
|
141
|
-
// Initialize context if provided
|
|
142
|
-
this._context = options.context;
|
|
143
|
-
// Initialize collected data with initial data if provided
|
|
144
|
-
if (options.initialData) {
|
|
145
|
-
if (this._schema) {
|
|
146
|
-
const validation = this.validateData(options.initialData);
|
|
147
|
-
if (!validation.valid) {
|
|
148
|
-
throw new Error(`Initial data validation failed: ${validation.errors.map(e => e.message).join(', ')}`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
this._pendingData = { ...options.initialData };
|
|
152
|
-
index_js_1.logger.debug("[Agent] Initial data set:", this._pendingData);
|
|
153
|
-
}
|
|
154
|
-
// Initialize prompt section cache
|
|
155
|
-
this._promptSectionCache = new PromptSectionCache_js_1.PromptSectionCache(options.promptCache);
|
|
156
|
-
// Initialize flow router
|
|
157
|
-
this._routingEngine = new FlowRouter_js_1.FlowRouter({
|
|
158
|
-
flowSwitchMargin: options.flowSwitchMargin,
|
|
159
|
-
onFlowSwitch: () => this.invalidateFlowSections(),
|
|
160
|
-
promptSectionCache: this._promptSectionCache,
|
|
161
|
-
});
|
|
162
|
-
// Initialize tool manager BEFORE ResponseModal (it reads agent.tool in constructor)
|
|
163
|
-
this.tool = new ToolManager_js_1.ToolManager(this);
|
|
164
|
-
// Initialize ResponseModal for handling all response generation
|
|
165
|
-
this._responseModal = new ResponseModal_js_1.ResponseModal(this, {
|
|
166
|
-
maxToolLoops: options.maxToolLoops,
|
|
167
|
-
});
|
|
168
|
-
// Initialize persistence if configured
|
|
169
|
-
if (options.persistence) {
|
|
170
|
-
try {
|
|
171
|
-
// Validate persistence configuration
|
|
172
|
-
if (!options.persistence.adapter) {
|
|
173
|
-
throw new Error("Persistence adapter is required when persistence is configured");
|
|
174
|
-
}
|
|
175
|
-
if (!options.persistence.adapter.sessionRepository) {
|
|
176
|
-
throw new Error("Persistence adapter must provide a sessionRepository");
|
|
177
|
-
}
|
|
178
|
-
if (!options.persistence.adapter.messageRepository) {
|
|
179
|
-
throw new Error("Persistence adapter must provide a messageRepository");
|
|
180
|
-
}
|
|
181
|
-
this._persistenceManager = new PersistenceManager_js_1.PersistenceManager(options.persistence);
|
|
182
|
-
// Initialize the adapter if it has an initialize method
|
|
183
|
-
if (options.persistence.adapter.initialize) {
|
|
184
|
-
options.persistence.adapter.initialize().catch((error) => {
|
|
185
|
-
index_js_1.logger.error("[Agent] Persistence adapter initialization failed:", error instanceof Error ? error.message : String(error));
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
catch (error) {
|
|
190
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
191
|
-
index_js_1.logger.error("[Agent] Failed to initialize persistence:", errorMessage);
|
|
192
|
-
throw new Error(`Failed to initialize persistence: ${errorMessage}`);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
// Initialize from options - use create methods for consistency
|
|
196
|
-
if (options.terms) {
|
|
197
|
-
options.terms.forEach((term) => {
|
|
198
|
-
this.createTerm(term);
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
// Initialize instructions (new unified form)
|
|
202
|
-
if (options.instructions) {
|
|
203
|
-
options.instructions.forEach((instruction) => {
|
|
204
|
-
this.createInstruction(instruction);
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
if (options.tools) {
|
|
208
|
-
options.tools.forEach((tool) => {
|
|
209
|
-
this.addTool(tool);
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
if (options.flows) {
|
|
213
|
-
options.flows.forEach((flowOptions) => {
|
|
214
|
-
this.createFlow(flowOptions);
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
// Validate deferred branch `then` string references against the flow registry.
|
|
218
|
-
// This catches strings that don't match a local step id AND don't match any flow id/title.
|
|
219
|
-
this.validateBranchReferences();
|
|
220
|
-
// Initialize knowledge base
|
|
221
|
-
if (options.knowledgeBase) {
|
|
222
|
-
this._knowledgeBase = { ...options.knowledgeBase };
|
|
223
|
-
}
|
|
224
|
-
// Initialize compaction options if configured
|
|
225
|
-
if (options.compaction && options.compaction.enabled !== false) {
|
|
226
|
-
const compactionOptions = {
|
|
227
|
-
maxTokens: options.compaction.maxTokens,
|
|
228
|
-
compactionThreshold: options.compaction.compactionThreshold ?? 0.8,
|
|
229
|
-
preserveRecentCount: options.compaction.preserveRecentCount ?? 4,
|
|
230
|
-
maxToolResultChars: options.compaction.maxToolResultChars ?? 5000,
|
|
231
|
-
provider: options.provider,
|
|
232
|
-
};
|
|
233
|
-
CompactionEngine_js_1.CompactionEngine.validateOptions(compactionOptions);
|
|
234
|
-
this._compactionOptions = compactionOptions;
|
|
235
|
-
index_js_1.logger.debug("[Agent] Compaction options initialized and validated");
|
|
236
|
-
}
|
|
237
|
-
// Initialize session manager — the single owner of the live session
|
|
238
|
-
this.session = new SessionManager_js_1.SessionManager(this._persistenceManager, this);
|
|
239
|
-
// Adopt an explicitly provided session
|
|
240
|
-
if (options.session) {
|
|
241
|
-
this.session.syncSession(options.session);
|
|
242
|
-
}
|
|
243
|
-
// Store sessionId for later use in getOrCreate calls
|
|
244
|
-
if (options.sessionId) {
|
|
245
|
-
this.session.setDefaultSessionId(options.sessionId);
|
|
246
|
-
// The session will be loaded on first getOrCreate call; session.data
|
|
247
|
-
// is the source of truth, so no data sync is needed here
|
|
248
|
-
this.session.getOrCreate(options.sessionId).catch((err) => {
|
|
249
|
-
index_js_1.logger.error("Failed to start session", err);
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Drain the pre-session data staging buffer.
|
|
255
|
-
* @internal Called by SessionManager when a session is created or loaded.
|
|
256
|
-
*/
|
|
257
|
-
consumePendingData() {
|
|
258
|
-
const pending = this._pendingData;
|
|
259
|
-
this._pendingData = {};
|
|
260
|
-
return pending;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Validate the agent-level schema structure
|
|
264
|
-
* @private
|
|
265
|
-
*/
|
|
266
|
-
validateSchema(schema) {
|
|
267
|
-
if (!schema || typeof schema !== 'object') {
|
|
268
|
-
throw new Error("Agent schema must be a valid JSON Schema object. " +
|
|
269
|
-
"Provide a schema with 'type': 'object' and 'properties' to define the data structure.");
|
|
270
|
-
}
|
|
271
|
-
if (schema.type !== 'object') {
|
|
272
|
-
throw new Error(`Agent schema must be of type 'object', but received '${String(schema.type)}'. ` +
|
|
273
|
-
"Agent-level schemas must define object structures for data collection.");
|
|
274
|
-
}
|
|
275
|
-
if (!schema.properties || typeof schema.properties !== 'object') {
|
|
276
|
-
throw new Error("Agent schema must have a 'properties' field defining the data fields. " +
|
|
277
|
-
"Example: { type: 'object', properties: { name: { type: 'string' }, email: { type: 'string' } } }");
|
|
278
|
-
}
|
|
279
|
-
index_js_1.logger.debug("[Agent] Schema validation passed");
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Walk every flow's steps and resolve deferred string `then` values in branches
|
|
283
|
-
* against the agent's flow registry. Strings that match neither a local step id
|
|
284
|
-
* nor any flow id/title throw FlowConfigurationError.
|
|
285
|
-
* @private
|
|
286
|
-
*/
|
|
287
|
-
validateBranchReferences() {
|
|
288
|
-
for (const flow of this._flows) {
|
|
289
|
-
this.validateFlowBranchReferences(flow);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Validate branch `then` string references for a single flow against the agent's
|
|
294
|
-
* flow registry. Throws FlowConfigurationError for unresolved references.
|
|
295
|
-
* @private
|
|
296
|
-
*/
|
|
297
|
-
validateFlowBranchReferences(flow) {
|
|
298
|
-
const steps = flow.getAllSteps();
|
|
299
|
-
const localStepIds = new Set(steps.map(s => s.id));
|
|
300
|
-
for (const step of steps) {
|
|
301
|
-
if (!step.branches)
|
|
302
|
-
continue;
|
|
303
|
-
for (const entry of step.branches) {
|
|
304
|
-
if (typeof entry.then !== 'string')
|
|
305
|
-
continue;
|
|
306
|
-
// Already matches a local step id — no deferred resolution needed
|
|
307
|
-
if (localStepIds.has(entry.then))
|
|
308
|
-
continue;
|
|
309
|
-
// Check against the agent's flow registry (id or title)
|
|
310
|
-
const matchesFlow = this._flows.some(f => f.id === entry.then || f.title === entry.then);
|
|
311
|
-
if (!matchesFlow) {
|
|
312
|
-
throw new Step_js_1.FlowConfigurationError(`[FlowConfigurationError] Unresolved branch target: "${entry.then}" in ${flow.id}.${step.id} does not match any step in the flow or any flow in the agent. ` +
|
|
313
|
-
`Fix the branch "then" value to reference a valid step id or flow id/title.`);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Validate that every step's `collect` fields in a flow reference valid keys
|
|
320
|
-
* from the agent-level schema. Throws FlowConfigurationError at construction
|
|
321
|
-
* time if any collect field is not a valid schema key.
|
|
322
|
-
*
|
|
323
|
-
* This enforces Requirement 14.5: generic inference is preserved AND every
|
|
324
|
-
* `collect` field reference is a valid key of the inferred TData.
|
|
325
|
-
* @private
|
|
326
|
-
*/
|
|
327
|
-
validateFlowCollectFields(flow) {
|
|
328
|
-
const schemaKeys = Object.keys(this._schema.properties);
|
|
329
|
-
const schemaKeySet = new Set(schemaKeys);
|
|
330
|
-
const steps = flow.getAllSteps();
|
|
331
|
-
for (const step of steps) {
|
|
332
|
-
if (!step.collect || step.collect.length === 0)
|
|
333
|
-
continue;
|
|
334
|
-
const invalidFields = step.collect.filter(field => !schemaKeySet.has(String(field)));
|
|
335
|
-
if (invalidFields.length > 0) {
|
|
336
|
-
throw new Step_js_1.FlowConfigurationError(`[FlowConfigurationError] Step "${step.id}" in flow "${flow.title}" references invalid collect fields: ${invalidFields.map(f => String(f)).join(', ')}. ` +
|
|
337
|
-
`Must be valid keys from agent schema. Available fields: ${schemaKeys.join(', ')}.`);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Validate data against the agent-level schema.
|
|
343
|
-
*
|
|
344
|
-
* A field the schema does not declare is a warning, not an error: a model
|
|
345
|
-
* can extract a key nobody asked for, and `updateCollectedData` drops it
|
|
346
|
-
* instead of failing the turn. `valid` is false only when `errors` is not empty.
|
|
347
|
-
*/
|
|
348
|
-
validateData(data) {
|
|
349
|
-
if (!this._schema) {
|
|
350
|
-
// No schema defined, consider all data valid
|
|
351
|
-
return { valid: true, errors: [], warnings: [] };
|
|
352
|
-
}
|
|
353
|
-
const errors = [];
|
|
354
|
-
const warnings = [];
|
|
355
|
-
// Undeclared fields are warnings — updateCollectedData drops them
|
|
356
|
-
if (this._schema.properties) {
|
|
357
|
-
for (const [key, value] of Object.entries(data)) {
|
|
358
|
-
if (!(key in this._schema.properties)) {
|
|
359
|
-
warnings.push({
|
|
360
|
-
field: key,
|
|
361
|
-
value,
|
|
362
|
-
message: `Field '${key}' is not defined in agent schema`,
|
|
363
|
-
schemaPath: `properties.${key}`
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
// Check required fields if specified
|
|
369
|
-
if (this._schema.required && Array.isArray(this._schema.required)) {
|
|
370
|
-
for (const requiredField of this._schema.required) {
|
|
371
|
-
if (!(requiredField in data) || data[requiredField] === undefined) {
|
|
372
|
-
warnings.push({
|
|
373
|
-
field: requiredField,
|
|
374
|
-
value: undefined,
|
|
375
|
-
message: `Required field '${requiredField}' is missing`,
|
|
376
|
-
schemaPath: `required`
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
return {
|
|
382
|
-
valid: errors.length === 0,
|
|
383
|
-
errors,
|
|
384
|
-
warnings
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* Check if a field is valid according to the agent schema
|
|
389
|
-
* @param field - The field key to validate
|
|
390
|
-
* @returns true if field exists in schema or no schema is defined, false otherwise
|
|
391
|
-
*/
|
|
392
|
-
isValidSchemaField(field) {
|
|
393
|
-
if (!this._schema || !this._schema.properties) {
|
|
394
|
-
// No schema defined, consider all fields valid
|
|
395
|
-
return true;
|
|
396
|
-
}
|
|
397
|
-
return field in this._schema.properties;
|
|
398
|
-
}
|
|
399
|
-
/**
|
|
400
|
-
* Get the current collected data.
|
|
401
|
-
* Reads from the live session when one exists; otherwise from the
|
|
402
|
-
* pre-session staging buffer.
|
|
403
|
-
*/
|
|
404
|
-
getCollectedData() {
|
|
405
|
-
const session = this.session.current;
|
|
406
|
-
return session ? { ...session.data } : { ...this._pendingData };
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* Update collected data with validation.
|
|
410
|
-
* Writes to the live session when one exists; otherwise stages the data
|
|
411
|
-
* for the session that will be created. Fields the agent schema does not
|
|
412
|
-
* declare are dropped with a warning, never stored.
|
|
413
|
-
*/
|
|
414
|
-
async updateCollectedData(updates) {
|
|
415
|
-
const declaredUpdates = (0, index_js_1.dropUndeclaredFields)(updates, this._schema);
|
|
416
|
-
// Validate the updates
|
|
417
|
-
const validation = this.validateData(declaredUpdates);
|
|
418
|
-
if (!validation.valid) {
|
|
419
|
-
const errorMessages = validation.errors.map(e => e.message).join(', ');
|
|
420
|
-
throw new DataValidationError(validation.errors, `[DataValidationError] Data validation failed: fields [${errorMessages}] did not pass schema validation. Fix the offending values to match the declared schema.`);
|
|
421
|
-
}
|
|
422
|
-
// Log warnings if any
|
|
423
|
-
if (validation.warnings.length > 0) {
|
|
424
|
-
const warningMessages = validation.warnings.map(w => w.message).join(', ');
|
|
425
|
-
index_js_1.logger.warn(`[Agent] Data validation warnings: ${warningMessages}`);
|
|
426
|
-
}
|
|
427
|
-
const session = this.session.current;
|
|
428
|
-
const previousData = session ? { ...session.data } : { ...this._pendingData };
|
|
429
|
-
let newData = {
|
|
430
|
-
...previousData,
|
|
431
|
-
...declaredUpdates
|
|
432
|
-
};
|
|
433
|
-
// Trigger agent-level lifecycle hook if configured
|
|
434
|
-
if (this.options.hooks?.onDataUpdate) {
|
|
435
|
-
newData = await this.options.hooks.onDataUpdate(newData, previousData);
|
|
436
|
-
}
|
|
437
|
-
if (session) {
|
|
438
|
-
session.data = newData;
|
|
439
|
-
session.metadata.lastUpdatedAt = new Date();
|
|
440
|
-
}
|
|
441
|
-
else {
|
|
442
|
-
this._pendingData = newData;
|
|
443
|
-
}
|
|
444
|
-
index_js_1.logger.debug("[Agent] Collected data updated:", declaredUpdates);
|
|
445
|
-
}
|
|
446
|
-
// ---------------------------------------------------------------------------
|
|
447
|
-
// Property accessors (get / set)
|
|
448
|
-
// ---------------------------------------------------------------------------
|
|
449
|
-
/**
|
|
450
|
-
* Get agent name
|
|
451
|
-
*/
|
|
452
|
-
get name() {
|
|
453
|
-
return this.options.name;
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* Set agent name
|
|
457
|
-
*/
|
|
458
|
-
set name(value) {
|
|
459
|
-
this.options.name = value;
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* Get agent persona
|
|
463
|
-
*/
|
|
464
|
-
get persona() {
|
|
465
|
-
return this.options.persona;
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* Set agent persona
|
|
469
|
-
*/
|
|
470
|
-
set persona(value) {
|
|
471
|
-
this.options.persona = value;
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* Get agent goal
|
|
475
|
-
*/
|
|
476
|
-
get goal() {
|
|
477
|
-
return this.options.goal;
|
|
478
|
-
}
|
|
479
|
-
/**
|
|
480
|
-
* Set agent goal
|
|
481
|
-
*/
|
|
482
|
-
set goal(value) {
|
|
483
|
-
this.options.goal = value;
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* Get whether debug mode is enabled
|
|
487
|
-
*/
|
|
488
|
-
get debug() {
|
|
489
|
-
return this.options.debug ?? false;
|
|
490
|
-
}
|
|
491
|
-
/**
|
|
492
|
-
* Set debug mode (also updates logger level)
|
|
493
|
-
*/
|
|
494
|
-
set debug(value) {
|
|
495
|
-
this.options.debug = value;
|
|
496
|
-
index_js_1.logger.setLevel(value ? index_js_1.LoggerLevel.DEBUG : index_js_1.LoggerLevel.INFO);
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Get the AI provider
|
|
500
|
-
*/
|
|
501
|
-
get provider() {
|
|
502
|
-
return this.options.provider;
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* Set the AI provider
|
|
506
|
-
*/
|
|
507
|
-
set provider(value) {
|
|
508
|
-
this.options.provider = value;
|
|
509
|
-
}
|
|
510
|
-
/**
|
|
511
|
-
* Get the flow switch margin
|
|
512
|
-
* @default 15
|
|
513
|
-
*/
|
|
514
|
-
get flowSwitchMargin() {
|
|
515
|
-
return this.options.flowSwitchMargin ?? 15;
|
|
516
|
-
}
|
|
517
|
-
/**
|
|
518
|
-
* Set the flow switch margin
|
|
519
|
-
*/
|
|
520
|
-
set flowSwitchMargin(value) {
|
|
521
|
-
this.options.flowSwitchMargin = value;
|
|
522
|
-
}
|
|
523
|
-
/**
|
|
524
|
-
* Get the prompt section cache instance
|
|
525
|
-
*/
|
|
526
|
-
get promptSectionCache() {
|
|
527
|
-
return this._promptSectionCache;
|
|
528
|
-
}
|
|
529
|
-
/**
|
|
530
|
-
* Get all terms
|
|
531
|
-
*/
|
|
532
|
-
get terms() {
|
|
533
|
-
return [...this._terms];
|
|
534
|
-
}
|
|
535
|
-
/**
|
|
536
|
-
* Get all instructions
|
|
537
|
-
*/
|
|
538
|
-
get instructions() {
|
|
539
|
-
return [...this._instructions];
|
|
540
|
-
}
|
|
541
|
-
/**
|
|
542
|
-
* Get all tools
|
|
543
|
-
*/
|
|
544
|
-
get tools() {
|
|
545
|
-
return [...this._tools];
|
|
546
|
-
}
|
|
547
|
-
/**
|
|
548
|
-
* Get all flows
|
|
549
|
-
*/
|
|
550
|
-
get flows() {
|
|
551
|
-
return [...this._flows];
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
* Get current schema
|
|
555
|
-
*/
|
|
556
|
-
get schema() {
|
|
557
|
-
return this._schema;
|
|
558
|
-
}
|
|
559
|
-
/**
|
|
560
|
-
* Set schema (validates structure)
|
|
561
|
-
*/
|
|
562
|
-
set schema(value) {
|
|
563
|
-
if (value) {
|
|
564
|
-
this.validateSchema(value);
|
|
565
|
-
}
|
|
566
|
-
this._schema = value;
|
|
567
|
-
}
|
|
568
|
-
/**
|
|
569
|
-
* Get the configured signals.
|
|
570
|
-
*/
|
|
571
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
572
|
-
get signals() {
|
|
573
|
-
return this._signals;
|
|
574
|
-
}
|
|
575
|
-
/**
|
|
576
|
-
* Get the agent's knowledge base
|
|
577
|
-
*/
|
|
578
|
-
get knowledgeBase() {
|
|
579
|
-
return { ...this._knowledgeBase };
|
|
580
|
-
}
|
|
581
|
-
/**
|
|
582
|
-
* Set the agent's knowledge base
|
|
583
|
-
*/
|
|
584
|
-
set knowledgeBase(value) {
|
|
585
|
-
this._knowledgeBase = { ...value };
|
|
586
|
-
}
|
|
587
|
-
/**
|
|
588
|
-
* Get the current session (if set). Delegates to the SessionManager —
|
|
589
|
-
* the single owner of the live session.
|
|
590
|
-
*/
|
|
591
|
-
get currentSession() {
|
|
592
|
-
return this.session.current;
|
|
593
|
-
}
|
|
594
|
-
/**
|
|
595
|
-
* Set the current session for convenience methods
|
|
596
|
-
* Set to undefined to clear the current session
|
|
597
|
-
*/
|
|
598
|
-
set currentSession(value) {
|
|
599
|
-
this.session.syncSession(value);
|
|
600
|
-
this._promptSectionCache.invalidateAll();
|
|
601
|
-
}
|
|
602
|
-
/**
|
|
603
|
-
* Get all flows
|
|
604
|
-
*/
|
|
605
|
-
getFlows() {
|
|
606
|
-
return this.flows;
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* Get all terms
|
|
610
|
-
*/
|
|
611
|
-
getTerms() {
|
|
612
|
-
return this.terms;
|
|
613
|
-
}
|
|
614
|
-
/**
|
|
615
|
-
* Get all tools
|
|
616
|
-
*/
|
|
617
|
-
getTools() {
|
|
618
|
-
return this.tools;
|
|
619
|
-
}
|
|
620
|
-
/**
|
|
621
|
-
* Get all instructions
|
|
622
|
-
*/
|
|
623
|
-
getInstructions() {
|
|
624
|
-
return this.instructions;
|
|
625
|
-
}
|
|
626
|
-
/**
|
|
627
|
-
* Invalidate flow-dependent prompt cache sections.
|
|
628
|
-
* Called automatically when the active flow changes.
|
|
629
|
-
*/
|
|
630
|
-
invalidateFlowSections() {
|
|
631
|
-
this._promptSectionCache.invalidate('activeFlows');
|
|
632
|
-
this._promptSectionCache.invalidate('flowKnowledgeBase');
|
|
633
|
-
this._promptSectionCache.invalidate('instructionsFlow');
|
|
634
|
-
}
|
|
635
|
-
/**
|
|
636
|
-
* Get the persistence manager (if configured)
|
|
637
|
-
*/
|
|
638
|
-
getPersistenceManager() {
|
|
639
|
-
return this._persistenceManager;
|
|
640
|
-
}
|
|
641
|
-
/**
|
|
642
|
-
* Check if persistence is enabled
|
|
643
|
-
*/
|
|
644
|
-
hasPersistence() {
|
|
645
|
-
return this._persistenceManager !== undefined;
|
|
646
|
-
}
|
|
647
|
-
/**
|
|
648
|
-
* Get the resolved compaction options (if compaction is configured)
|
|
649
|
-
*/
|
|
650
|
-
getCompactionOptions() {
|
|
651
|
-
return this._compactionOptions;
|
|
652
|
-
}
|
|
653
|
-
// ---------------------------------------------------------------------------
|
|
654
|
-
// Core methods
|
|
655
|
-
// ---------------------------------------------------------------------------
|
|
656
|
-
/**
|
|
657
|
-
* Create a new flow (journey) using agent-level data type
|
|
658
|
-
*/
|
|
659
|
-
createFlow(options) {
|
|
660
|
-
// Validate that requiredFields exist in agent schema
|
|
661
|
-
if (options.requiredFields && this._schema?.properties) {
|
|
662
|
-
const invalidRequiredFields = options.requiredFields.filter(field => !(String(field) in this._schema.properties));
|
|
663
|
-
if (invalidRequiredFields.length > 0) {
|
|
664
|
-
throw new FlowConfigurationError(options.title, invalidRequiredFields.map(f => String(f)), `[FlowConfigurationError] Invalid required fields in flow "${options.title}": [${invalidRequiredFields.join(', ')}] are not declared in the agent schema. ` +
|
|
665
|
-
`Use valid schema keys. Available fields: ${Object.keys(this._schema.properties).join(', ')}.`);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
// Validate that optionalFields exist in agent schema
|
|
669
|
-
if (options.optionalFields && this._schema?.properties) {
|
|
670
|
-
const invalidOptionalFields = options.optionalFields.filter(field => !(String(field) in this._schema.properties));
|
|
671
|
-
if (invalidOptionalFields.length > 0) {
|
|
672
|
-
throw new FlowConfigurationError(options.title, invalidOptionalFields.map(f => String(f)), `[FlowConfigurationError] Invalid optional fields in flow "${options.title}": [${invalidOptionalFields.join(', ')}] are not declared in the agent schema. ` +
|
|
673
|
-
`Use valid schema keys. Available fields: ${Object.keys(this._schema.properties).join(', ')}.`);
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
// Overlap detection: warn (don't throw) when the incoming flow's
|
|
677
|
-
// requiredFields intersect another registered flow's — the schema is
|
|
678
|
-
// agent-level, so both flows complete together and one is silently
|
|
679
|
-
// excluded from routing.
|
|
680
|
-
if (options.requiredFields && options.requiredFields.length > 0) {
|
|
681
|
-
const incoming = new Set(options.requiredFields.map(String));
|
|
682
|
-
for (const existing of this._flows) {
|
|
683
|
-
const shared = (existing.requiredFields ?? [])
|
|
684
|
-
.map(String)
|
|
685
|
-
.filter((f) => incoming.has(f));
|
|
686
|
-
if (shared.length > 0) {
|
|
687
|
-
index_js_1.logger.warn(`[FlowConfigurationError] Overlapping requiredFields: flows "${existing.title}" and "${options.title}" share [${shared.join(', ')}]. ` +
|
|
688
|
-
`The schema is agent-level, so data collected for one flow marks the other complete and excludes it from routing. ` +
|
|
689
|
-
`Give each flow distinct requiredFields, or set \`reentrant: true\` on flows that legitimately share fields.`);
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
const flow = new Flow_js_1.Flow(options, this);
|
|
694
|
-
// Validate that step collect fields reference valid schema keys
|
|
695
|
-
if (this._schema?.properties) {
|
|
696
|
-
this.validateFlowCollectFields(flow);
|
|
697
|
-
}
|
|
698
|
-
this._flows.push(flow);
|
|
699
|
-
return flow;
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* Create a domain term for the glossary
|
|
703
|
-
*/
|
|
704
|
-
createTerm(term) {
|
|
705
|
-
this._terms.push(term);
|
|
706
|
-
return this;
|
|
707
|
-
}
|
|
708
|
-
/**
|
|
709
|
-
* Create an instruction (unified behavioral primitive).
|
|
710
|
-
*/
|
|
711
|
-
createInstruction(instruction) {
|
|
712
|
-
const instructionWithId = {
|
|
713
|
-
...instruction,
|
|
714
|
-
kind: instruction.kind || 'should',
|
|
715
|
-
id: instruction.id || `instruction_${this._instructions.length}`,
|
|
716
|
-
enabled: instruction.enabled !== false, // Default to true
|
|
717
|
-
};
|
|
718
|
-
this._instructions.push(instructionWithId);
|
|
719
|
-
this._promptSectionCache.invalidate('instructionsGlobal');
|
|
720
|
-
return this;
|
|
721
|
-
}
|
|
722
|
-
/**
|
|
723
|
-
* Add a tool to the agent using the unified Tool interface
|
|
724
|
-
* Creates and adds the tool to agent scope in one operation
|
|
725
|
-
*/
|
|
726
|
-
addTool(tool) {
|
|
727
|
-
// Validate tool before adding
|
|
728
|
-
if (!tool || !tool.id || !tool.handler) {
|
|
729
|
-
throw new Error('Invalid tool: must have id and handler properties');
|
|
730
|
-
}
|
|
731
|
-
// Add directly to agent's tools array, preserving the TResult type
|
|
732
|
-
this._tools.push(tool);
|
|
733
|
-
index_js_1.logger.debug(`[Agent] Added tool to agent scope: ${tool.id}`);
|
|
734
|
-
return this;
|
|
735
|
-
}
|
|
736
|
-
/**
|
|
737
|
-
* Register multiple tools at the agent level
|
|
738
|
-
*/
|
|
739
|
-
registerTools(tools) {
|
|
740
|
-
tools.forEach((tool) => {
|
|
741
|
-
// Validate each tool before adding
|
|
742
|
-
if (!tool || !tool.id || !tool.handler) {
|
|
743
|
-
throw new Error(`Invalid tool in batch: must have id and handler properties (tool: ${tool?.id || 'unknown'})`);
|
|
744
|
-
}
|
|
745
|
-
this._tools.push(tool);
|
|
746
|
-
});
|
|
747
|
-
index_js_1.logger.debug(`[Agent] Registered ${tools.length} tools`);
|
|
748
|
-
return this;
|
|
749
|
-
}
|
|
750
|
-
/**
|
|
751
|
-
* Update the agent's context
|
|
752
|
-
* Triggers both agent-level and flow-specific onContextUpdate lifecycle hooks if configured
|
|
753
|
-
*/
|
|
754
|
-
async updateContext(updates) {
|
|
755
|
-
const previousContext = this._context;
|
|
756
|
-
// Merge updates with current context
|
|
757
|
-
this._context = {
|
|
758
|
-
...this._context,
|
|
759
|
-
...updates,
|
|
760
|
-
};
|
|
761
|
-
// Trigger flow-specific lifecycle hook if configured and session has current flow
|
|
762
|
-
const activeSession = this.session.current;
|
|
763
|
-
if (activeSession?.currentFlow) {
|
|
764
|
-
const currentFlow = this._flows.find((r) => r.id === activeSession.currentFlow?.id);
|
|
765
|
-
if (currentFlow?.hooks?.onContextUpdate &&
|
|
766
|
-
previousContext !== undefined) {
|
|
767
|
-
await currentFlow.handleContextUpdate(this._context, previousContext);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
// Trigger agent-level lifecycle hook if configured
|
|
771
|
-
if (this.options.hooks?.onContextUpdate && previousContext !== undefined) {
|
|
772
|
-
await this.options.hooks.onContextUpdate(this._context, previousContext);
|
|
773
|
-
}
|
|
774
|
-
// Invalidate context-dependent prompt cache sections
|
|
775
|
-
this._promptSectionCache.invalidate('agentMeta');
|
|
776
|
-
this._promptSectionCache.invalidate('knowledgeBase');
|
|
777
|
-
this._promptSectionCache.invalidate('instructionsGlobal');
|
|
778
|
-
}
|
|
779
|
-
/**
|
|
780
|
-
* Update collected data in session with lifecycle hook support
|
|
781
|
-
* Triggers both agent-level and flow-specific onDataUpdate lifecycle hooks if configured
|
|
782
|
-
* @internal
|
|
783
|
-
*/
|
|
784
|
-
async updateData(session, dataUpdate) {
|
|
785
|
-
const previousCollected = { ...session.data };
|
|
786
|
-
// Merge new collected data
|
|
787
|
-
let newCollected = {
|
|
788
|
-
...session.data,
|
|
789
|
-
...dataUpdate,
|
|
790
|
-
};
|
|
791
|
-
// Trigger flow-specific lifecycle hook if configured and session has a current flow
|
|
792
|
-
if (session.currentFlow) {
|
|
793
|
-
const currentFlow = this._flows.find((r) => r.id === session.currentFlow?.id);
|
|
794
|
-
if (currentFlow?.hooks?.onDataUpdate) {
|
|
795
|
-
newCollected = await currentFlow.handleDataUpdate(newCollected, previousCollected);
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
// Trigger agent-level lifecycle hook if configured
|
|
799
|
-
if (this.options.hooks?.onDataUpdate) {
|
|
800
|
-
newCollected = (await this.options.hooks.onDataUpdate(newCollected, previousCollected));
|
|
801
|
-
}
|
|
802
|
-
// Return updated session — session.data is the single source of truth,
|
|
803
|
-
// so no agent-side copy is kept
|
|
804
|
-
return (0, index_js_1.mergeCollected)(session, newCollected);
|
|
805
|
-
}
|
|
806
|
-
/**
|
|
807
|
-
* Get current context (fetches from provider if configured)
|
|
808
|
-
*/
|
|
809
|
-
async getContext() {
|
|
810
|
-
// If context provider is configured, use it to fetch fresh context
|
|
811
|
-
if (this.options.contextProvider) {
|
|
812
|
-
return await this.options.contextProvider();
|
|
813
|
-
}
|
|
814
|
-
// Otherwise return the stored context
|
|
815
|
-
return this._context;
|
|
816
|
-
}
|
|
817
|
-
/**
|
|
818
|
-
* Generate a response based on history and context as a stream
|
|
819
|
-
*/
|
|
820
|
-
async *respondStream(params) {
|
|
821
|
-
// Delegate to ResponseModal
|
|
822
|
-
yield* this._responseModal.respondStream(params);
|
|
823
|
-
}
|
|
824
|
-
/**
|
|
825
|
-
* Generate a response based on history and context
|
|
826
|
-
*/
|
|
827
|
-
async respond(params) {
|
|
828
|
-
// Delegate to ResponseModal
|
|
829
|
-
return this._responseModal.respond(params);
|
|
830
|
-
}
|
|
831
|
-
/**
|
|
832
|
-
* Get agent options
|
|
833
|
-
* @internal Used by ResponseModal
|
|
834
|
-
*/
|
|
835
|
-
getAgentOptions() {
|
|
836
|
-
return this.options;
|
|
837
|
-
}
|
|
838
|
-
/**
|
|
839
|
-
* Get flow router
|
|
840
|
-
* @internal Used by ResponseModal
|
|
841
|
-
*/
|
|
842
|
-
getFlowRouter() {
|
|
843
|
-
return this._routingEngine;
|
|
844
|
-
}
|
|
845
|
-
/**
|
|
846
|
-
* Get the updateData method bound to this agent
|
|
847
|
-
* @internal Used by ResponseModal
|
|
848
|
-
*/
|
|
849
|
-
getUpdateDataMethod() {
|
|
850
|
-
return this.updateData.bind(this);
|
|
851
|
-
}
|
|
852
|
-
/**
|
|
853
|
-
* Execute a prepare or finalize function/tool
|
|
854
|
-
* @internal Used by ResponseModal
|
|
855
|
-
*/
|
|
856
|
-
async executePrepareFinalize(prepareOrFinalize, context, data, flow, step) {
|
|
857
|
-
if (!prepareOrFinalize)
|
|
858
|
-
return;
|
|
859
|
-
if (typeof prepareOrFinalize === "function") {
|
|
860
|
-
// It's a function - call it directly
|
|
861
|
-
await prepareOrFinalize(context, data);
|
|
862
|
-
}
|
|
863
|
-
else {
|
|
864
|
-
// It's a tool reference - find and execute the tool
|
|
865
|
-
let tool;
|
|
866
|
-
if (typeof prepareOrFinalize === "string") {
|
|
867
|
-
// Tool ID - use ToolManager to find it across all scopes
|
|
868
|
-
tool = this.tool.find(prepareOrFinalize, undefined, step, flow);
|
|
869
|
-
}
|
|
870
|
-
else {
|
|
871
|
-
// Tool object - validate it has required properties
|
|
872
|
-
if (prepareOrFinalize.id && typeof prepareOrFinalize.handler === 'function') {
|
|
873
|
-
tool = prepareOrFinalize;
|
|
874
|
-
}
|
|
875
|
-
else {
|
|
876
|
-
index_js_1.logger.error(`[Agent] Invalid tool object for prepare/finalize: missing id or invalid handler`);
|
|
877
|
-
return;
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
if (tool) {
|
|
881
|
-
// Use ToolManager for execution
|
|
882
|
-
const result = await this.tool.executeTool({
|
|
883
|
-
tool,
|
|
884
|
-
context,
|
|
885
|
-
updateContext: this.updateContext.bind(this),
|
|
886
|
-
updateData: this.updateCollectedData.bind(this),
|
|
887
|
-
history: [], // Empty history for prepare/finalize
|
|
888
|
-
data,
|
|
889
|
-
});
|
|
890
|
-
if (!result.success) {
|
|
891
|
-
index_js_1.logger.error(`[Agent] Tool execution failed in prepare/finalize: ${result.error}`);
|
|
892
|
-
throw new Error(`Tool execution failed: ${result.error}`);
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
else {
|
|
896
|
-
index_js_1.logger.warn(`[Agent] Tool not found for prepare/finalize: ${typeof prepareOrFinalize === "string"
|
|
897
|
-
? prepareOrFinalize
|
|
898
|
-
: "inline tool"}`);
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
/**
|
|
903
|
-
* Get collected data from the current session (or the pre-session staging
|
|
904
|
-
* buffer when no session exists yet). Alias of getCollectedData().
|
|
905
|
-
*/
|
|
906
|
-
getData() {
|
|
907
|
-
return this.getCollectedData();
|
|
23
|
+
if (options.debug)
|
|
24
|
+
logger_js_1.logger.setLevel(logger_js_1.LoggerLevel.DEBUG);
|
|
25
|
+
validate(options);
|
|
26
|
+
this.compaction = compactionOptions(options);
|
|
27
|
+
this.runner = new Runner_js_1.Runner(options);
|
|
28
|
+
this.understand = new Understand_js_1.Understand(options);
|
|
29
|
+
this.speak = new Speak_js_1.Speak(options);
|
|
30
|
+
}
|
|
31
|
+
/** Take whatever just happened and return the messages to send and the timers to set. */
|
|
32
|
+
async turn(input) {
|
|
33
|
+
const { turn, talk } = await this.open(input);
|
|
34
|
+
await this.runner.settle(turn, talk ? await this.speak.run(this.runner.speakRequest(turn, talk)) : null);
|
|
35
|
+
return this.runner.finish(turn);
|
|
36
|
+
}
|
|
37
|
+
/** `turn`, streaming the spoken text as it is generated; the last chunk carries the result. */
|
|
38
|
+
async *turnStream(input) {
|
|
39
|
+
const { turn, talk } = await this.open(input);
|
|
40
|
+
let outcome = null;
|
|
41
|
+
if (talk) {
|
|
42
|
+
for await (const chunk of this.speak.stream(this.runner.speakRequest(turn, talk))) {
|
|
43
|
+
if ("delta" in chunk)
|
|
44
|
+
yield { delta: chunk.delta };
|
|
45
|
+
else
|
|
46
|
+
outcome = chunk.outcome;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
await this.runner.settle(turn, outcome);
|
|
50
|
+
yield { done: true, result: this.runner.finish(turn) };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Every wake a saved session is waiting on, as its turns scheduled them: each parked run's,
|
|
54
|
+
* and each silence flow's since the assistant last spoke. For a queue that lost its jobs, and
|
|
55
|
+
* for sessions no turn has armed yet, such as blobs lifted by `migrateSession`. It changes
|
|
56
|
+
* nothing and spends no call: enqueue the entries as you would a turn's `schedule[]`.
|
|
57
|
+
*/
|
|
58
|
+
pendingWakes(input) {
|
|
59
|
+
return this.runner.pendingWakes(input);
|
|
60
|
+
}
|
|
61
|
+
/** Load, Ingest, Understand, Decide and Run: everything before the one speaker is known. */
|
|
62
|
+
async open(input) {
|
|
63
|
+
const { runner } = this;
|
|
64
|
+
const compacted = await this.compacted(input);
|
|
65
|
+
const turn = runner.begin(compacted.input);
|
|
66
|
+
turn.llmCalls += compacted.llmCalls;
|
|
67
|
+
turn.usage = (0, usage_js_1.addUsage)(turn.usage, compacted.usage);
|
|
68
|
+
const request = runner.understandRequest(turn);
|
|
69
|
+
runner.decide(turn, request ? await this.understand.run(request) : null);
|
|
70
|
+
return { turn, talk: await runner.advance(turn) };
|
|
71
|
+
}
|
|
72
|
+
/** With `compaction` set, the history both calls see is trimmed once per turn; a summarization is one model call. */
|
|
73
|
+
async compacted(input) {
|
|
74
|
+
const history = input.history ?? input.session?.history;
|
|
75
|
+
if (!this.compaction || !history?.length)
|
|
76
|
+
return { input, llmCalls: 0 };
|
|
77
|
+
const result = await CompactionEngine_js_1.CompactionEngine.checkAndCompact(history, this.compaction);
|
|
78
|
+
const llmCalls = result.strategy === "auto_compact" ? 1 : 0;
|
|
79
|
+
const usage = result.usage ? { usage: result.usage } : {};
|
|
80
|
+
if (result.history === history)
|
|
81
|
+
return { input, llmCalls, ...usage };
|
|
82
|
+
const trimmed = Object.assign({}, input);
|
|
83
|
+
trimmed.history = result.history;
|
|
84
|
+
return { input: trimmed, llmCalls, ...usage };
|
|
908
85
|
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
* @example
|
|
932
|
-
* // String shorthand — desugars to { goTo: 'Feedback' }
|
|
933
|
-
* const updated = await agent.dispatch('Feedback', session);
|
|
934
|
-
*
|
|
935
|
-
* @example
|
|
936
|
-
* // Full directive
|
|
937
|
-
* const updated = await agent.dispatch({ goTo: 'Billing', reply: 'Transferring you now.' }, session);
|
|
938
|
-
*/
|
|
939
|
-
async dispatch(target, session) {
|
|
940
|
-
const targetSession = session || this.session.current;
|
|
941
|
-
if (!targetSession) {
|
|
942
|
-
throw new Error("No session provided and no current session available. Please provide a session to dispatch into.");
|
|
943
|
-
}
|
|
944
|
-
// Desugar string form to { goTo: target }
|
|
945
|
-
const directive = typeof target === 'string'
|
|
946
|
-
? { goTo: target }
|
|
947
|
-
: target;
|
|
948
|
-
// Validate the directive: check for multiple position fields, empty goTo, etc.
|
|
949
|
-
this.validateDirective(directive);
|
|
950
|
-
// If goTo is a string, validate it references a known flow
|
|
951
|
-
if (typeof directive.goTo === 'string') {
|
|
952
|
-
const flowTarget = directive.goTo;
|
|
953
|
-
const matchesFlow = this._flows.some(f => f.id === flowTarget || f.title === flowTarget);
|
|
954
|
-
if (!matchesFlow) {
|
|
955
|
-
throw new Step_js_1.FlowConfigurationError(`[FlowConfigurationError] Unknown flow: "${flowTarget}" does not match any flow id or title. ` +
|
|
956
|
-
`Available flows: ${this._flows.map(f => f.title).join(', ')}.`);
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
else if (directive.goTo && typeof directive.goTo === 'object' && directive.goTo.flow) {
|
|
960
|
-
const flowTarget = directive.goTo.flow;
|
|
961
|
-
const matchesFlow = this._flows.some(f => f.id === flowTarget || f.title === flowTarget);
|
|
962
|
-
if (!matchesFlow) {
|
|
963
|
-
throw new Step_js_1.FlowConfigurationError(`[FlowConfigurationError] Unknown flow: "${flowTarget}" does not match any flow id or title. ` +
|
|
964
|
-
`Available flows: ${this._flows.map(f => f.title).join(', ')}.`);
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
// Strip pre-LLM-only fields before storing
|
|
968
|
-
const stripped = this.stripPreDirectiveFields(directive);
|
|
969
|
-
// Set pendingDirective on the session without applying it
|
|
970
|
-
const updatedSession = {
|
|
971
|
-
...targetSession,
|
|
972
|
-
pendingDirective: stripped,
|
|
973
|
-
metadata: {
|
|
974
|
-
...targetSession.metadata,
|
|
975
|
-
lastUpdatedAt: new Date(),
|
|
976
|
-
},
|
|
977
|
-
};
|
|
978
|
-
// Durability: with an adapter + autoSave configured, dispatch persists
|
|
979
|
-
// immediately — webhooks/cron run out-of-process from the responder, and a
|
|
980
|
-
// memory-only queue would evaporate with this process. The save stamps the
|
|
981
|
-
// new version back onto updatedSession, so the next turn's auto-save CAS
|
|
982
|
-
// stays clean. Persisting BEFORE the in-memory sync keeps the existing
|
|
983
|
-
// invariant: a throwing dispatch leaves the session untouched.
|
|
984
|
-
if (this._persistenceManager && this.options.persistence?.autoSave !== false) {
|
|
985
|
-
await this._persistenceManager.saveSessionState(updatedSession.id, updatedSession);
|
|
986
|
-
index_js_1.logger.debug(`[Agent] Dispatched directive persisted to adapter for session ${updatedSession.id}`);
|
|
987
|
-
}
|
|
988
|
-
// Update current session in place if no explicit session was passed
|
|
989
|
-
if (!session && this.session.current) {
|
|
990
|
-
this.session.syncSession(updatedSession);
|
|
86
|
+
}
|
|
87
|
+
exports.Agent = Agent;
|
|
88
|
+
function compactionOptions(options) {
|
|
89
|
+
const config = options.compaction;
|
|
90
|
+
if (!config || config.enabled === false)
|
|
91
|
+
return undefined;
|
|
92
|
+
const resolved = {
|
|
93
|
+
maxTokens: config.maxTokens,
|
|
94
|
+
compactionThreshold: config.compactionThreshold ?? 0.8,
|
|
95
|
+
preserveRecentCount: config.preserveRecentCount ?? 4,
|
|
96
|
+
maxToolResultChars: config.maxToolResultChars ?? 5000,
|
|
97
|
+
provider: options.provider,
|
|
98
|
+
};
|
|
99
|
+
CompactionEngine_js_1.CompactionEngine.validateOptions(resolved);
|
|
100
|
+
return resolved;
|
|
101
|
+
}
|
|
102
|
+
/** Every name a flow uses must resolve now, not on the turn that first reaches it. */
|
|
103
|
+
function validate(options) {
|
|
104
|
+
const ids = new Set();
|
|
105
|
+
for (const flow of options.flows ?? []) {
|
|
106
|
+
if (ids.has(flow.id)) {
|
|
107
|
+
throw new errors_js_1.FlowConfigurationError(`[FlowConfigurationError] flow "${flow.id}" is declared twice: flow ids must be unique. Rename one of them.`);
|
|
991
108
|
}
|
|
992
|
-
|
|
993
|
-
|
|
109
|
+
ids.add(flow.id);
|
|
110
|
+
for (const warning of (0, FlowSpec_js_1.validateFlow)(flow, options).warnings)
|
|
111
|
+
logger_js_1.logger.warn(`[Agent] ${warning}`);
|
|
994
112
|
}
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
* @param session - The session to apply the directive to
|
|
1004
|
-
* @returns The updated session with the directive applied
|
|
1005
|
-
*/
|
|
1006
|
-
applyDirective(directive, session) {
|
|
1007
|
-
// Validate the directive
|
|
1008
|
-
this.validateDirective(directive);
|
|
1009
|
-
let updatedSession = { ...session };
|
|
1010
|
-
const now = new Date();
|
|
1011
|
-
// Apply state writes
|
|
1012
|
-
if (directive.contextUpdate) {
|
|
1013
|
-
// Context updates are applied to the agent, not the session
|
|
1014
|
-
this._context = {
|
|
1015
|
-
...this._context,
|
|
1016
|
-
...directive.contextUpdate,
|
|
1017
|
-
};
|
|
1018
|
-
}
|
|
1019
|
-
if (directive.dataUpdate) {
|
|
1020
|
-
updatedSession = {
|
|
1021
|
-
...updatedSession,
|
|
1022
|
-
data: {
|
|
1023
|
-
...updatedSession.data,
|
|
1024
|
-
...directive.dataUpdate,
|
|
1025
|
-
},
|
|
1026
|
-
};
|
|
1027
|
-
}
|
|
1028
|
-
// Apply position control
|
|
1029
|
-
if (directive.goTo) {
|
|
1030
|
-
const flowTarget = typeof directive.goTo === 'string'
|
|
1031
|
-
? directive.goTo
|
|
1032
|
-
: directive.goTo.flow;
|
|
1033
|
-
if (flowTarget) {
|
|
1034
|
-
const targetFlow = this._flows.find(f => f.id === flowTarget || f.title === flowTarget);
|
|
1035
|
-
if (targetFlow) {
|
|
1036
|
-
// Merge goTo.data if present
|
|
1037
|
-
if (typeof directive.goTo === 'object' && directive.goTo.data) {
|
|
1038
|
-
updatedSession = {
|
|
1039
|
-
...updatedSession,
|
|
1040
|
-
data: {
|
|
1041
|
-
...updatedSession.data,
|
|
1042
|
-
...directive.goTo.data,
|
|
1043
|
-
},
|
|
1044
|
-
};
|
|
1045
|
-
}
|
|
1046
|
-
updatedSession = (0, index_js_1.enterFlow)(updatedSession, targetFlow.id, targetFlow.title);
|
|
1047
|
-
// If a specific step is targeted
|
|
1048
|
-
if (typeof directive.goTo === 'object' && directive.goTo.step) {
|
|
1049
|
-
updatedSession = (0, index_js_1.enterStep)(updatedSession, directive.goTo.step);
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
else if (directive.goToStep) {
|
|
1055
|
-
const stepTarget = typeof directive.goToStep === 'string'
|
|
1056
|
-
? directive.goToStep
|
|
1057
|
-
: directive.goToStep.step;
|
|
1058
|
-
// Merge goToStep.data if present
|
|
1059
|
-
if (typeof directive.goToStep === 'object' && directive.goToStep.data) {
|
|
1060
|
-
updatedSession = {
|
|
1061
|
-
...updatedSession,
|
|
1062
|
-
data: {
|
|
1063
|
-
...updatedSession.data,
|
|
1064
|
-
...directive.goToStep.data,
|
|
1065
|
-
},
|
|
1066
|
-
};
|
|
1067
|
-
}
|
|
1068
|
-
updatedSession = (0, index_js_1.enterStep)(updatedSession, stepTarget);
|
|
1069
|
-
}
|
|
1070
|
-
else if (directive.complete) {
|
|
1071
|
-
updatedSession = (0, index_js_1.completeCurrentFlow)(updatedSession);
|
|
1072
|
-
// If complete carries a chained directive, set it as pendingDirective
|
|
1073
|
-
if (typeof directive.complete === 'object' && directive.complete.next) {
|
|
1074
|
-
updatedSession = {
|
|
1075
|
-
...updatedSession,
|
|
1076
|
-
pendingDirective: directive.complete.next,
|
|
1077
|
-
};
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
else if (directive.abort) {
|
|
1081
|
-
const clearSession = typeof directive.abort === 'object'
|
|
1082
|
-
? directive.abort.clearSession !== false
|
|
1083
|
-
: true;
|
|
1084
|
-
if (clearSession) {
|
|
1085
|
-
updatedSession = {
|
|
1086
|
-
...updatedSession,
|
|
1087
|
-
currentFlow: undefined,
|
|
1088
|
-
currentStep: undefined,
|
|
1089
|
-
data: {},
|
|
1090
|
-
};
|
|
1091
|
-
}
|
|
1092
|
-
else {
|
|
1093
|
-
updatedSession = {
|
|
1094
|
-
...updatedSession,
|
|
1095
|
-
currentFlow: undefined,
|
|
1096
|
-
currentStep: undefined,
|
|
1097
|
-
};
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
else if (directive.reset) {
|
|
1101
|
-
const currentFlowId = updatedSession.currentFlow?.id;
|
|
1102
|
-
const currentFlowTitle = updatedSession.currentFlow?.title;
|
|
1103
|
-
if (currentFlowId && currentFlowTitle) {
|
|
1104
|
-
// Clear data if requested
|
|
1105
|
-
if (typeof directive.reset === 'object' && directive.reset.clearData) {
|
|
1106
|
-
const currentFlow = this._flows.find(f => f.id === currentFlowId);
|
|
1107
|
-
if (currentFlow) {
|
|
1108
|
-
const ownedFields = [
|
|
1109
|
-
...(currentFlow.requiredFields || []),
|
|
1110
|
-
...(currentFlow.optionalFields || []),
|
|
1111
|
-
];
|
|
1112
|
-
updatedSession = (0, index_js_1.completeCurrentFlow)(updatedSession, { clearOwnedFields: ownedFields });
|
|
1113
|
-
// Re-enter the same flow
|
|
1114
|
-
updatedSession = (0, index_js_1.enterFlow)(updatedSession, currentFlowId, currentFlowTitle);
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
else {
|
|
1118
|
-
// Re-enter the flow from the beginning (or specified step)
|
|
1119
|
-
updatedSession = (0, index_js_1.enterFlow)(updatedSession, currentFlowId, currentFlowTitle);
|
|
1120
|
-
}
|
|
1121
|
-
// If a specific step is targeted for reset
|
|
1122
|
-
if (typeof directive.reset === 'object' && directive.reset.step) {
|
|
1123
|
-
updatedSession = (0, index_js_1.enterStep)(updatedSession, directive.reset.step);
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
113
|
+
for (const tool of options.tools ?? []) {
|
|
114
|
+
// A function's parameters are a JSON Schema object, so anything else is a
|
|
115
|
+
// mistake — most often the action's `{ name: { type } }` map written in a
|
|
116
|
+
// tool. Only DeepSeek rejects it on the wire; everywhere else the tool is
|
|
117
|
+
// simply never callable, and nothing says so.
|
|
118
|
+
if (tool.parameters && tool.parameters.type !== "object") {
|
|
119
|
+
throw new errors_js_1.FlowConfigurationError(`[FlowConfigurationError] tool "${tool.id}": parameters must be a JSON Schema object. ` +
|
|
120
|
+
`Write { type: "object", properties: { ... }, required: [...] }.`);
|
|
1126
121
|
}
|
|
1127
|
-
// Update metadata
|
|
1128
|
-
updatedSession = {
|
|
1129
|
-
...updatedSession,
|
|
1130
|
-
metadata: {
|
|
1131
|
-
...updatedSession.metadata,
|
|
1132
|
-
lastUpdatedAt: now,
|
|
1133
|
-
},
|
|
1134
|
-
};
|
|
1135
|
-
return updatedSession;
|
|
1136
122
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
// Check for multiple position fields
|
|
1144
|
-
const positionFields = ['goTo', 'goToStep', 'complete', 'abort', 'reset'];
|
|
1145
|
-
const setPositionFields = positionFields.filter(field => directive[field] !== undefined);
|
|
1146
|
-
if (setPositionFields.length > 1) {
|
|
1147
|
-
throw new Step_js_1.FlowConfigurationError(`[FlowConfigurationError] Multiple position fields: a Directive may set at most one position field. ` +
|
|
1148
|
-
`Found: ${setPositionFields.join(', ')}. Remove all but one.`);
|
|
1149
|
-
}
|
|
1150
|
-
// Check for empty goTo object
|
|
1151
|
-
if (directive.goTo && typeof directive.goTo === 'object') {
|
|
1152
|
-
const goToObj = directive.goTo;
|
|
1153
|
-
if (!goToObj.flow && !goToObj.step) {
|
|
1154
|
-
throw new Step_js_1.FlowConfigurationError(`[FlowConfigurationError] Empty goTo: "goTo" requires at least a "flow" field. ` +
|
|
1155
|
-
`Provide { goTo: { flow: '<id>' } } or use the string shorthand { goTo: '<id>' }.`);
|
|
123
|
+
const { idle } = options;
|
|
124
|
+
if (idle && idle !== "silent") {
|
|
125
|
+
const known = new Set((options.tools ?? []).map((tool) => tool.id));
|
|
126
|
+
for (const name of idle.tools ?? []) {
|
|
127
|
+
if (!known.has(name)) {
|
|
128
|
+
throw new errors_js_1.FlowConfigurationError(`[FlowConfigurationError] idle: unknown tool "${name}". Register it in the agent's tools or fix the name.`);
|
|
1156
129
|
}
|
|
1157
130
|
}
|
|
1158
131
|
}
|
|
1159
|
-
/**
|
|
1160
|
-
* Strip pre-LLM-only fields (appendPrompt, injectTools, halt) from a directive.
|
|
1161
|
-
* These fields are transient (one-turn lifetime) and must not be persisted.
|
|
1162
|
-
* @private
|
|
1163
|
-
*/
|
|
1164
|
-
stripPreDirectiveFields(directive) {
|
|
1165
|
-
const raw = directive;
|
|
1166
|
-
if (!raw.appendPrompt && !raw.injectTools && raw.halt === undefined) {
|
|
1167
|
-
return directive;
|
|
1168
|
-
}
|
|
1169
|
-
const { appendPrompt, injectTools, halt, ...rest } = raw;
|
|
1170
|
-
if (appendPrompt || injectTools || halt !== undefined) {
|
|
1171
|
-
index_js_1.logger.warn(`[Agent] Ignoring pre-LLM-only fields on pendingDirective (these only take effect in onEnter/prepare hooks): ` +
|
|
1172
|
-
`${[appendPrompt && 'appendPrompt', injectTools && 'injectTools', halt !== undefined && 'halt'].filter(Boolean).join(', ')}`);
|
|
1173
|
-
}
|
|
1174
|
-
return rest;
|
|
1175
|
-
}
|
|
1176
|
-
/**
|
|
1177
|
-
* Simplified respond method using SessionManager
|
|
1178
|
-
* Automatically manages conversation history through the session
|
|
1179
|
-
*/
|
|
1180
|
-
async chat(message, options) {
|
|
1181
|
-
// Delegate to ResponseModal.generate()
|
|
1182
|
-
return this._responseModal.generate(message, options);
|
|
1183
|
-
}
|
|
1184
|
-
/**
|
|
1185
|
-
* Modern streaming API - simple interface like chat() but returns a stream
|
|
1186
|
-
* Automatically manages conversation history through the session
|
|
1187
|
-
*/
|
|
1188
|
-
async *stream(message, options) {
|
|
1189
|
-
// Delegate to ResponseModal with the same options structure as chat()
|
|
1190
|
-
yield* this._responseModal.stream(message, {
|
|
1191
|
-
history: options?.history,
|
|
1192
|
-
contextOverride: options?.contextOverride,
|
|
1193
|
-
signal: options?.signal,
|
|
1194
|
-
});
|
|
1195
|
-
}
|
|
1196
132
|
}
|
|
1197
|
-
exports.Agent = Agent;
|
|
1198
133
|
//# sourceMappingURL=Agent.js.map
|