@jangts/agent-core 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +59 -0
- package/development/docs/api/reference.md +1907 -1874
- package/development/docs/api/support.md +27 -0
- package/development/docs/assets/agent-core-icon.png +0 -0
- package/development/docs/assets/agent-core-logo.png +0 -0
- package/development/docs/assets/character-agent-core.png +0 -0
- package/development/skills/agent-core-app/scripts/create-app.mjs +267 -70
- package/development/skills/agent-core-app/scripts/lib/knowledge.mjs +40 -15
- package/development/skills/agent-core-app/scripts/lib/source.mjs +30 -2
- package/development/skills/agent-core-app/scripts/plan.mjs +37 -12
- package/development/skills/agent-core-app/scripts/prepare-source.mjs +61 -10
- package/development/skills/agent-core-app/scripts/resources.mjs +45 -17
- package/development/skills/agent-core-app/scripts/validate-knowledge.mjs +18 -1
- package/development/skills/agent-core-app/templates/catalog.json +36 -22
- package/dist/cjs/capabilities/index.js +13 -0
- package/dist/cjs/capabilities/invocation.js +80 -10
- package/dist/cjs/capabilities/model.js +126 -13
- package/dist/cjs/capabilities/tool-runtime.js +64 -12
- package/dist/cjs/capabilities/tools.js +266 -31
- package/dist/cjs/context/assembly.js +46 -5
- package/dist/cjs/context/audit.js +31 -6
- package/dist/cjs/context/fragments.js +54 -11
- package/dist/cjs/context/index.js +12 -0
- package/dist/cjs/context/journal.js +84 -7
- package/dist/cjs/context/plan.js +30 -2
- package/dist/cjs/diagnostics/catalog.js +11 -3
- package/dist/cjs/diagnostics/index.js +149 -29
- package/dist/cjs/diagnostics/sub-flow.js +240 -40
- package/dist/cjs/errors.js +99 -17
- package/dist/cjs/execution/branch.js +20 -4
- package/dist/cjs/execution/engine.js +470 -56
- package/dist/cjs/execution/events.js +136 -18
- package/dist/cjs/execution/index.js +7 -0
- package/dist/cjs/execution/reporting.js +75 -6
- package/dist/cjs/execution/state.js +161 -22
- package/dist/cjs/execution/workflow.js +224 -32
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/kits/aggregation.js +45 -3
- package/dist/cjs/kits/answering/batch.js +23 -4
- package/dist/cjs/kits/answering/check-result.js +31 -8
- package/dist/cjs/kits/answering/checks.js +24 -3
- package/dist/cjs/kits/answering/flow.js +192 -36
- package/dist/cjs/kits/answering/index.js +19 -1
- package/dist/cjs/kits/answering/tasks.js +88 -13
- package/dist/cjs/kits/artifacts.js +36 -4
- package/dist/cjs/kits/candidates.js +47 -5
- package/dist/cjs/kits/delivery.js +40 -5
- package/dist/cjs/kits/durable.js +155 -31
- package/dist/cjs/kits/evidence.js +66 -15
- package/dist/cjs/kits/family.js +152 -22
- package/dist/cjs/kits/index.js +12 -1
- package/dist/cjs/kits/inference.js +104 -16
- package/dist/cjs/kits/intents/catalog.js +67 -16
- package/dist/cjs/kits/intents/index.js +11 -0
- package/dist/cjs/kits/intents/registry.js +188 -43
- package/dist/cjs/kits/intents/scopes.js +215 -46
- package/dist/cjs/kits/interaction/command.js +140 -36
- package/dist/cjs/kits/interaction/commands.js +86 -11
- package/dist/cjs/kits/interaction/handlers.js +27 -10
- package/dist/cjs/kits/interaction/index.js +10 -0
- package/dist/cjs/kits/interaction/transfer.js +80 -14
- package/dist/cjs/kits/knowledge/catalog.js +62 -11
- package/dist/cjs/kits/knowledge/index.js +16 -1
- package/dist/cjs/kits/knowledge/publication.js +99 -23
- package/dist/cjs/kits/knowledge/sections.js +33 -4
- package/dist/cjs/kits/normalization.js +51 -7
- package/dist/cjs/kits/policies.js +79 -15
- package/dist/cjs/kits/presentation/events.js +54 -10
- package/dist/cjs/kits/presentation/index.js +24 -1
- package/dist/cjs/kits/presentation/outputs.js +176 -38
- package/dist/cjs/kits/presentation/templates.js +33 -5
- package/dist/cjs/kits/presentation/variants.js +31 -2
- package/dist/cjs/kits/projection.js +63 -8
- package/dist/cjs/kits/rank-fusion.js +27 -4
- package/dist/cjs/kits/reflection-log-source.js +89 -16
- package/dist/cjs/kits/reflection.js +234 -60
- package/dist/cjs/kits/retrieval.js +98 -18
- package/dist/cjs/kits/search.js +180 -27
- package/dist/cjs/kits/text-skills.js +104 -19
- package/dist/cjs/kits/tools.js +415 -74
- package/dist/cjs/kits/vector-search.js +50 -16
- package/dist/cjs/mock/node.js +7 -1
- package/dist/cjs/mock/web.js +7 -1
- package/dist/cjs/mock.js +7 -1
- package/dist/cjs/model/binding.js +68 -17
- package/dist/cjs/model/call-budget.js +45 -4
- package/dist/cjs/model/decision-retry.js +19 -1
- package/dist/cjs/model/defaults.js +27 -4
- package/dist/cjs/model/index.js +7 -0
- package/dist/cjs/model/interactions/arguments.js +36 -1
- package/dist/cjs/model/interactions/json-object.js +48 -12
- package/dist/cjs/model/interactions/native-functions.js +52 -10
- package/dist/cjs/model/message-diagnostics.js +17 -4
- package/dist/cjs/model/options.js +9 -1
- package/dist/cjs/model/preparation.js +86 -12
- package/dist/cjs/model/runner.js +413 -79
- package/dist/cjs/model/selection-transport.js +48 -8
- package/dist/cjs/model/settings.js +67 -13
- package/dist/cjs/model/token-budget.js +69 -11
- package/dist/cjs/model/transports.js +59 -6
- package/dist/cjs/structs/common.js +11 -0
- package/dist/cjs/structs/debug.js +34 -5
- package/dist/cjs/structs/errors.js +26 -1
- package/dist/cjs/structs/index.js +11 -1
- package/dist/cjs/structs/kits/durable.js +7 -0
- package/dist/cjs/structs/kits/family.js +1 -0
- package/dist/cjs/structs/kits/interaction.js +8 -1
- package/dist/cjs/structs/kits/knowledge-publication.js +1 -0
- package/dist/cjs/structs/kits/reflection.js +18 -3
- package/dist/cjs/structs/model/chat-provider.js +6 -0
- package/dist/cjs/structs/support/model/completion.js +2 -0
- package/dist/cjs/structs/support/model/messages.js +2 -0
- package/dist/cjs/support/capabilities.js +43 -6
- package/dist/cjs/support/context/assembly.js +88 -16
- package/dist/cjs/support/context/compression.js +48 -6
- package/dist/cjs/support/context/fragments.js +6 -0
- package/dist/cjs/support/context/history.js +36 -1
- package/dist/cjs/support/context/index.js +11 -0
- package/dist/cjs/support/context/nodes.js +164 -35
- package/dist/cjs/support/context/processing.js +319 -61
- package/dist/cjs/support/context/selection-policy.js +98 -21
- package/dist/cjs/support/context/selection.js +61 -10
- package/dist/cjs/support/context/snapshot.js +29 -7
- package/dist/cjs/support/context/strategies.js +120 -28
- package/dist/cjs/support/index.js +9 -1
- package/dist/cjs/support/model/capabilities.js +20 -1
- package/dist/cjs/support/model/chat-completions.js +92 -20
- package/dist/cjs/support/model/children.js +34 -6
- package/dist/cjs/support/model/compatible-provider.js +189 -59
- package/dist/cjs/support/model/completion/calls.js +61 -0
- package/dist/cjs/support/model/completion/default.js +32 -0
- package/dist/cjs/support/model/completion/index.js +28 -0
- package/dist/cjs/support/model/completion/session.js +102 -0
- package/dist/cjs/support/model/index.js +12 -0
- package/dist/cjs/support/model/interactions/index.js +12 -1
- package/dist/cjs/support/model/interactions/json-object.js +6 -0
- package/dist/cjs/support/model/interactions/native-functions.js +6 -0
- package/dist/cjs/support/model/observer.js +32 -6
- package/dist/cjs/support/model/preview-rules.js +66 -16
- package/dist/cjs/support/model/reply-preview.js +77 -17
- package/dist/cjs/support/model/stage-transport.js +33 -7
- package/dist/cjs/support/model/strategies.js +75 -14
- package/dist/cjs/support/model/transports.js +53 -11
- package/dist/cjs/support/registration.js +49 -7
- package/dist/cjs/support/schema.js +46 -4
- package/dist/cjs/support/stream-events.js +60 -8
- package/dist/cjs/support/tool-runtime.js +6 -0
- package/dist/cjs/support/tools.js +79 -10
- package/dist/cjs/support/transport/index.js +7 -0
- package/dist/cjs/support/transport/json.js +28 -4
- package/dist/cjs/support/transport/sse.js +25 -2
- package/dist/cjs/utils/break-observer.js +20 -2
- package/dist/cjs/utils/cancellation.js +77 -9
- package/dist/cjs/utils/catalog.js +19 -4
- package/dist/cjs/utils/debug.js +14 -2
- package/dist/cjs/utils/index.js +8 -0
- package/dist/cjs/utils/interaction-definition.js +26 -6
- package/dist/cjs/utils/invocation.js +42 -4
- package/dist/cjs/utils/model-protocol.js +20 -1
- package/dist/cjs/utils/object.js +16 -0
- package/dist/cjs/utils/observer.js +22 -2
- package/dist/cjs/utils/protocol-registry.js +47 -4
- package/dist/cjs/utils/query-key.js +21 -2
- package/dist/cjs/utils/registration.js +18 -2
- package/dist/cjs/utils/rules.js +39 -11
- package/dist/cjs/utils/schema-adapter.js +25 -2
- package/dist/cjs/utils/synchronous.js +64 -7
- package/dist/cjs/utils/text.js +15 -1
- package/dist/esm/capabilities/index.d.ts +13 -0
- package/dist/esm/capabilities/index.js +13 -0
- package/dist/esm/capabilities/invocation.d.ts +16 -2
- package/dist/esm/capabilities/invocation.js +80 -10
- package/dist/esm/capabilities/model.d.ts +68 -1
- package/dist/esm/capabilities/model.js +126 -13
- package/dist/esm/capabilities/tool-runtime.d.ts +11 -0
- package/dist/esm/capabilities/tool-runtime.js +64 -12
- package/dist/esm/capabilities/tools.d.ts +96 -3
- package/dist/esm/capabilities/tools.js +267 -32
- package/dist/esm/context/assembly.d.ts +13 -2
- package/dist/esm/context/assembly.js +46 -5
- package/dist/esm/context/audit.d.ts +23 -1
- package/dist/esm/context/audit.js +31 -6
- package/dist/esm/context/fragments.d.ts +37 -3
- package/dist/esm/context/fragments.js +54 -11
- package/dist/esm/context/index.d.ts +12 -0
- package/dist/esm/context/index.js +12 -0
- package/dist/esm/context/journal.d.ts +32 -1
- package/dist/esm/context/journal.js +84 -7
- package/dist/esm/context/plan.d.ts +11 -1
- package/dist/esm/context/plan.js +30 -2
- package/dist/esm/diagnostics/catalog.js +11 -3
- package/dist/esm/diagnostics/index.d.ts +30 -2
- package/dist/esm/diagnostics/index.js +149 -29
- package/dist/esm/diagnostics/sub-flow.d.ts +41 -3
- package/dist/esm/diagnostics/sub-flow.js +240 -40
- package/dist/esm/errors.d.ts +22 -2
- package/dist/esm/errors.js +99 -17
- package/dist/esm/execution/branch.d.ts +19 -1
- package/dist/esm/execution/branch.js +20 -4
- package/dist/esm/execution/engine.d.ts +291 -5
- package/dist/esm/execution/engine.js +471 -57
- package/dist/esm/execution/events.d.ts +16 -2
- package/dist/esm/execution/events.js +136 -18
- package/dist/esm/execution/index.d.ts +7 -0
- package/dist/esm/execution/index.js +7 -0
- package/dist/esm/execution/reporting.d.ts +49 -1
- package/dist/esm/execution/reporting.js +75 -6
- package/dist/esm/execution/state.d.ts +126 -10
- package/dist/esm/execution/state.js +161 -22
- package/dist/esm/execution/workflow.d.ts +121 -3
- package/dist/esm/execution/workflow.js +224 -32
- package/dist/esm/index.d.ts +17 -1
- package/dist/esm/index.js +18 -0
- package/dist/esm/kits/aggregation.d.ts +34 -2
- package/dist/esm/kits/aggregation.js +45 -3
- package/dist/esm/kits/answering/batch.d.ts +17 -0
- package/dist/esm/kits/answering/batch.js +23 -4
- package/dist/esm/kits/answering/check-result.d.ts +18 -1
- package/dist/esm/kits/answering/check-result.js +31 -8
- package/dist/esm/kits/answering/checks.d.ts +11 -0
- package/dist/esm/kits/answering/checks.js +24 -3
- package/dist/esm/kits/answering/flow.d.ts +25 -2
- package/dist/esm/kits/answering/flow.js +192 -36
- package/dist/esm/kits/answering/index.d.ts +12 -0
- package/dist/esm/kits/answering/index.js +19 -1
- package/dist/esm/kits/answering/tasks.d.ts +32 -1
- package/dist/esm/kits/answering/tasks.js +88 -13
- package/dist/esm/kits/artifacts.d.ts +11 -0
- package/dist/esm/kits/artifacts.js +36 -4
- package/dist/esm/kits/candidates.d.ts +23 -1
- package/dist/esm/kits/candidates.js +47 -5
- package/dist/esm/kits/delivery.d.ts +34 -0
- package/dist/esm/kits/delivery.js +40 -5
- package/dist/esm/kits/durable.d.ts +19 -0
- package/dist/esm/kits/durable.js +155 -31
- package/dist/esm/kits/evidence.d.ts +28 -5
- package/dist/esm/kits/evidence.js +66 -15
- package/dist/esm/kits/family.d.ts +17 -1
- package/dist/esm/kits/family.js +152 -22
- package/dist/esm/kits/index.d.ts +12 -1
- package/dist/esm/kits/index.js +12 -1
- package/dist/esm/kits/inference.d.ts +64 -0
- package/dist/esm/kits/inference.js +104 -16
- package/dist/esm/kits/intents/catalog.d.ts +13 -1
- package/dist/esm/kits/intents/catalog.js +67 -16
- package/dist/esm/kits/intents/index.d.ts +11 -0
- package/dist/esm/kits/intents/index.js +11 -0
- package/dist/esm/kits/intents/registry.d.ts +61 -3
- package/dist/esm/kits/intents/registry.js +188 -43
- package/dist/esm/kits/intents/scopes.d.ts +73 -3
- package/dist/esm/kits/intents/scopes.js +215 -46
- package/dist/esm/kits/interaction/command.d.ts +38 -4
- package/dist/esm/kits/interaction/command.js +140 -36
- package/dist/esm/kits/interaction/commands.d.ts +66 -2
- package/dist/esm/kits/interaction/commands.js +86 -11
- package/dist/esm/kits/interaction/handlers.d.ts +19 -2
- package/dist/esm/kits/interaction/handlers.js +27 -10
- package/dist/esm/kits/interaction/index.d.ts +10 -0
- package/dist/esm/kits/interaction/index.js +10 -0
- package/dist/esm/kits/interaction/transfer.d.ts +39 -2
- package/dist/esm/kits/interaction/transfer.js +80 -14
- package/dist/esm/kits/knowledge/catalog.d.ts +13 -0
- package/dist/esm/kits/knowledge/catalog.js +62 -11
- package/dist/esm/kits/knowledge/index.d.ts +11 -0
- package/dist/esm/kits/knowledge/index.js +16 -1
- package/dist/esm/kits/knowledge/publication.d.ts +15 -1
- package/dist/esm/kits/knowledge/publication.js +99 -23
- package/dist/esm/kits/knowledge/sections.d.ts +31 -1
- package/dist/esm/kits/knowledge/sections.js +33 -4
- package/dist/esm/kits/normalization.d.ts +25 -2
- package/dist/esm/kits/normalization.js +51 -7
- package/dist/esm/kits/policies.d.ts +26 -3
- package/dist/esm/kits/policies.js +79 -15
- package/dist/esm/kits/presentation/events.d.ts +51 -4
- package/dist/esm/kits/presentation/events.js +54 -10
- package/dist/esm/kits/presentation/index.d.ts +12 -0
- package/dist/esm/kits/presentation/index.js +25 -2
- package/dist/esm/kits/presentation/outputs.d.ts +30 -1
- package/dist/esm/kits/presentation/outputs.js +176 -38
- package/dist/esm/kits/presentation/templates.d.ts +32 -3
- package/dist/esm/kits/presentation/templates.js +33 -5
- package/dist/esm/kits/presentation/variants.d.ts +29 -0
- package/dist/esm/kits/presentation/variants.js +31 -2
- package/dist/esm/kits/projection.d.ts +42 -5
- package/dist/esm/kits/projection.js +63 -8
- package/dist/esm/kits/rank-fusion.d.ts +21 -1
- package/dist/esm/kits/rank-fusion.js +28 -5
- package/dist/esm/kits/reflection-log-source.d.ts +28 -1
- package/dist/esm/kits/reflection-log-source.js +89 -16
- package/dist/esm/kits/reflection.d.ts +17 -1
- package/dist/esm/kits/reflection.js +235 -61
- package/dist/esm/kits/retrieval.d.ts +18 -2
- package/dist/esm/kits/retrieval.js +98 -18
- package/dist/esm/kits/search.d.ts +56 -3
- package/dist/esm/kits/search.js +180 -27
- package/dist/esm/kits/text-skills.d.ts +16 -2
- package/dist/esm/kits/text-skills.js +104 -19
- package/dist/esm/kits/tools.d.ts +122 -2
- package/dist/esm/kits/tools.js +416 -74
- package/dist/esm/kits/vector-search.d.ts +47 -1
- package/dist/esm/kits/vector-search.js +51 -17
- package/dist/esm/mock/node.d.ts +7 -0
- package/dist/esm/mock/node.js +7 -1
- package/dist/esm/mock/web.d.ts +7 -0
- package/dist/esm/mock/web.js +7 -1
- package/dist/esm/mock.d.ts +7 -0
- package/dist/esm/mock.js +7 -1
- package/dist/esm/model/binding.d.ts +32 -3
- package/dist/esm/model/binding.js +68 -17
- package/dist/esm/model/call-budget.d.ts +30 -2
- package/dist/esm/model/call-budget.js +45 -4
- package/dist/esm/model/decision-retry.d.ts +10 -1
- package/dist/esm/model/decision-retry.js +19 -1
- package/dist/esm/model/defaults.d.ts +13 -2
- package/dist/esm/model/defaults.js +27 -4
- package/dist/esm/model/index.d.ts +7 -0
- package/dist/esm/model/index.js +7 -0
- package/dist/esm/model/interactions/arguments.d.ts +27 -0
- package/dist/esm/model/interactions/arguments.js +36 -1
- package/dist/esm/model/interactions/json-object.d.ts +7 -1
- package/dist/esm/model/interactions/json-object.js +48 -12
- package/dist/esm/model/interactions/native-functions.d.ts +6 -0
- package/dist/esm/model/interactions/native-functions.js +52 -10
- package/dist/esm/model/message-diagnostics.d.ts +17 -1
- package/dist/esm/model/message-diagnostics.js +17 -4
- package/dist/esm/model/options.d.ts +18 -1
- package/dist/esm/model/options.js +9 -1
- package/dist/esm/model/preparation.d.ts +30 -2
- package/dist/esm/model/preparation.js +86 -12
- package/dist/esm/model/runner.d.ts +129 -5
- package/dist/esm/model/runner.js +414 -80
- package/dist/esm/model/selection-transport.d.ts +14 -1
- package/dist/esm/model/selection-transport.js +48 -8
- package/dist/esm/model/settings.d.ts +11 -0
- package/dist/esm/model/settings.js +67 -13
- package/dist/esm/model/token-budget.d.ts +59 -1
- package/dist/esm/model/token-budget.js +69 -11
- package/dist/esm/model/transports.d.ts +20 -2
- package/dist/esm/model/transports.js +59 -6
- package/dist/esm/structs/capabilities/invocation.d.ts +36 -0
- package/dist/esm/structs/capabilities/model.d.ts +27 -0
- package/dist/esm/structs/capabilities/tools.d.ts +38 -0
- package/dist/esm/structs/common.d.ts +62 -2
- package/dist/esm/structs/common.js +11 -0
- package/dist/esm/structs/context/fragments.d.ts +28 -0
- package/dist/esm/structs/context/journal.d.ts +28 -3
- package/dist/esm/structs/context/processing.d.ts +11 -0
- package/dist/esm/structs/debug.d.ts +58 -1
- package/dist/esm/structs/debug.js +34 -5
- package/dist/esm/structs/diagnostics.d.ts +119 -1
- package/dist/esm/structs/errors.d.ts +42 -1
- package/dist/esm/structs/errors.js +26 -1
- package/dist/esm/structs/execution/engine.d.ts +24 -1
- package/dist/esm/structs/execution/events.d.ts +12 -0
- package/dist/esm/structs/execution/workflow.d.ts +71 -0
- package/dist/esm/structs/index.d.ts +11 -1
- package/dist/esm/structs/index.js +11 -1
- package/dist/esm/structs/invocation.d.ts +30 -0
- package/dist/esm/structs/kits/aggregation.d.ts +12 -0
- package/dist/esm/structs/kits/answering/checks.d.ts +11 -0
- package/dist/esm/structs/kits/answering/flow.d.ts +35 -1
- package/dist/esm/structs/kits/answering/state.d.ts +21 -0
- package/dist/esm/structs/kits/answering/tasks.d.ts +21 -0
- package/dist/esm/structs/kits/artifacts.d.ts +14 -0
- package/dist/esm/structs/kits/candidates.d.ts +19 -0
- package/dist/esm/structs/kits/delivery.d.ts +22 -0
- package/dist/esm/structs/kits/durable.d.ts +56 -3
- package/dist/esm/structs/kits/durable.js +7 -0
- package/dist/esm/structs/kits/evidence.d.ts +23 -0
- package/dist/esm/structs/kits/family.d.ts +49 -1
- package/dist/esm/structs/kits/family.js +1 -0
- package/dist/esm/structs/kits/intents/catalog.d.ts +26 -0
- package/dist/esm/structs/kits/intents/registry.d.ts +34 -0
- package/dist/esm/structs/kits/intents/scopes.d.ts +36 -1
- package/dist/esm/structs/kits/interaction.d.ts +64 -0
- package/dist/esm/structs/kits/interaction.js +8 -1
- package/dist/esm/structs/kits/knowledge-publication.d.ts +43 -1
- package/dist/esm/structs/kits/knowledge-publication.js +1 -0
- package/dist/esm/structs/kits/knowledge.d.ts +39 -2
- package/dist/esm/structs/kits/normalization.d.ts +15 -0
- package/dist/esm/structs/kits/policies.d.ts +25 -1
- package/dist/esm/structs/kits/presentation/events.d.ts +28 -4
- package/dist/esm/structs/kits/presentation/outputs.d.ts +38 -1
- package/dist/esm/structs/kits/presentation/templates.d.ts +15 -0
- package/dist/esm/structs/kits/projection.d.ts +21 -0
- package/dist/esm/structs/kits/reflection.d.ts +61 -2
- package/dist/esm/structs/kits/reflection.js +18 -3
- package/dist/esm/structs/kits/retrieval.d.ts +38 -0
- package/dist/esm/structs/kits/search.d.ts +22 -0
- package/dist/esm/structs/kits/text-skills.d.ts +36 -0
- package/dist/esm/structs/kits/tools.d.ts +87 -0
- package/dist/esm/structs/model/chat-provider.d.ts +24 -1
- package/dist/esm/structs/model/chat-provider.js +6 -0
- package/dist/esm/structs/model/interactions.d.ts +38 -0
- package/dist/esm/structs/model/messages.d.ts +30 -0
- package/dist/esm/structs/model/runtime.d.ts +104 -6
- package/dist/esm/structs/support/capabilities.d.ts +19 -2
- package/dist/esm/structs/support/context-processing.d.ts +88 -9
- package/dist/esm/structs/support/context.d.ts +29 -1
- package/dist/esm/structs/support/model/completion.d.ts +50 -0
- package/dist/esm/structs/support/model/completion.js +1 -0
- package/dist/esm/structs/support/model/interactions.d.ts +13 -1
- package/dist/esm/structs/support/model/messages.d.ts +52 -0
- package/dist/esm/structs/support/model/messages.js +1 -0
- package/dist/esm/structs/support/model/provider-observer.d.ts +22 -1
- package/dist/esm/structs/support/model/provider.d.ts +71 -6
- package/dist/esm/structs/support/registration.d.ts +13 -0
- package/dist/esm/structs/support/schema.d.ts +14 -0
- package/dist/esm/structs/support/tools.d.ts +28 -0
- package/dist/esm/structs/support/transport/json.d.ts +16 -0
- package/dist/esm/structs/support/transport/sse.d.ts +15 -0
- package/dist/esm/structs/utils/rules.d.ts +19 -0
- package/dist/esm/support/capabilities.d.ts +25 -2
- package/dist/esm/support/capabilities.js +43 -6
- package/dist/esm/support/context/assembly.d.ts +35 -4
- package/dist/esm/support/context/assembly.js +88 -16
- package/dist/esm/support/context/compression.d.ts +17 -1
- package/dist/esm/support/context/compression.js +48 -6
- package/dist/esm/support/context/fragments.d.ts +6 -0
- package/dist/esm/support/context/fragments.js +6 -0
- package/dist/esm/support/context/history.d.ts +43 -0
- package/dist/esm/support/context/history.js +36 -1
- package/dist/esm/support/context/index.d.ts +13 -2
- package/dist/esm/support/context/index.js +12 -1
- package/dist/esm/support/context/nodes.d.ts +49 -3
- package/dist/esm/support/context/nodes.js +165 -36
- package/dist/esm/support/context/processing.d.ts +145 -1
- package/dist/esm/support/context/processing.js +320 -62
- package/dist/esm/support/context/selection-policy.d.ts +42 -2
- package/dist/esm/support/context/selection-policy.js +98 -21
- package/dist/esm/support/context/selection.d.ts +14 -1
- package/dist/esm/support/context/selection.js +61 -10
- package/dist/esm/support/context/snapshot.d.ts +23 -1
- package/dist/esm/support/context/snapshot.js +29 -7
- package/dist/esm/support/context/strategies.d.ts +35 -2
- package/dist/esm/support/context/strategies.js +120 -28
- package/dist/esm/support/index.d.ts +9 -1
- package/dist/esm/support/index.js +9 -1
- package/dist/esm/support/model/capabilities.d.ts +10 -0
- package/dist/esm/support/model/capabilities.js +20 -1
- package/dist/esm/support/model/chat-completions.d.ts +44 -15
- package/dist/esm/support/model/chat-completions.js +92 -20
- package/dist/esm/support/model/children.d.ts +32 -2
- package/dist/esm/support/model/children.js +34 -6
- package/dist/esm/support/model/compatible-provider.d.ts +29 -3
- package/dist/esm/support/model/compatible-provider.js +190 -60
- package/dist/esm/support/model/completion/calls.d.ts +40 -0
- package/dist/esm/support/model/completion/calls.js +58 -0
- package/dist/esm/support/model/completion/default.d.ts +10 -0
- package/dist/esm/support/model/completion/default.js +29 -0
- package/dist/esm/support/model/completion/index.d.ts +10 -0
- package/dist/esm/support/model/completion/index.js +22 -0
- package/dist/esm/support/model/completion/session.d.ts +11 -0
- package/dist/esm/support/model/completion/session.js +99 -0
- package/dist/esm/support/model/index.d.ts +14 -0
- package/dist/esm/support/model/index.js +12 -0
- package/dist/esm/support/model/interactions/index.d.ts +1 -1
- package/dist/esm/support/model/interactions/index.js +12 -1
- package/dist/esm/support/model/interactions/json-object.d.ts +6 -0
- package/dist/esm/support/model/interactions/json-object.js +6 -0
- package/dist/esm/support/model/interactions/native-functions.d.ts +6 -0
- package/dist/esm/support/model/interactions/native-functions.js +6 -0
- package/dist/esm/support/model/observer.d.ts +25 -2
- package/dist/esm/support/model/observer.js +32 -6
- package/dist/esm/support/model/preview-rules.d.ts +20 -2
- package/dist/esm/support/model/preview-rules.js +66 -16
- package/dist/esm/support/model/reply-preview.d.ts +15 -1
- package/dist/esm/support/model/reply-preview.js +77 -17
- package/dist/esm/support/model/stage-transport.d.ts +9 -1
- package/dist/esm/support/model/stage-transport.js +33 -7
- package/dist/esm/support/model/strategies.d.ts +24 -2
- package/dist/esm/support/model/strategies.js +75 -14
- package/dist/esm/support/model/transports.d.ts +17 -1
- package/dist/esm/support/model/transports.js +53 -11
- package/dist/esm/support/registration.d.ts +20 -1
- package/dist/esm/support/registration.js +49 -7
- package/dist/esm/support/schema.d.ts +31 -1
- package/dist/esm/support/schema.js +46 -4
- package/dist/esm/support/stream-events.d.ts +22 -1
- package/dist/esm/support/stream-events.js +60 -8
- package/dist/esm/support/tool-runtime.d.ts +6 -0
- package/dist/esm/support/tool-runtime.js +6 -0
- package/dist/esm/support/tools.d.ts +22 -0
- package/dist/esm/support/tools.js +79 -10
- package/dist/esm/support/transport/index.d.ts +7 -0
- package/dist/esm/support/transport/index.js +7 -0
- package/dist/esm/support/transport/json.d.ts +29 -2
- package/dist/esm/support/transport/json.js +28 -4
- package/dist/esm/support/transport/sse.d.ts +31 -1
- package/dist/esm/support/transport/sse.js +25 -2
- package/dist/esm/types.d.ts +9 -1
- package/dist/esm/utils/break-observer.d.ts +27 -2
- package/dist/esm/utils/break-observer.js +20 -2
- package/dist/esm/utils/cancellation.d.ts +56 -5
- package/dist/esm/utils/cancellation.js +77 -9
- package/dist/esm/utils/catalog.d.ts +20 -1
- package/dist/esm/utils/catalog.js +19 -4
- package/dist/esm/utils/debug.d.ts +20 -1
- package/dist/esm/utils/debug.js +14 -2
- package/dist/esm/utils/index.d.ts +8 -0
- package/dist/esm/utils/index.js +8 -0
- package/dist/esm/utils/interaction-definition.d.ts +18 -1
- package/dist/esm/utils/interaction-definition.js +26 -6
- package/dist/esm/utils/invocation.d.ts +36 -1
- package/dist/esm/utils/invocation.js +42 -4
- package/dist/esm/utils/model-protocol.d.ts +8 -0
- package/dist/esm/utils/model-protocol.js +20 -1
- package/dist/esm/utils/object.d.ts +16 -0
- package/dist/esm/utils/object.js +16 -0
- package/dist/esm/utils/observer.d.ts +19 -1
- package/dist/esm/utils/observer.js +22 -2
- package/dist/esm/utils/protocol-registry.d.ts +38 -1
- package/dist/esm/utils/protocol-registry.js +47 -4
- package/dist/esm/utils/query-key.d.ts +11 -1
- package/dist/esm/utils/query-key.js +21 -2
- package/dist/esm/utils/registration.d.ts +34 -2
- package/dist/esm/utils/registration.js +18 -2
- package/dist/esm/utils/rules.d.ts +81 -4
- package/dist/esm/utils/rules.js +39 -11
- package/dist/esm/utils/schema-adapter.d.ts +12 -1
- package/dist/esm/utils/schema-adapter.js +25 -2
- package/dist/esm/utils/synchronous.d.ts +60 -4
- package/dist/esm/utils/synchronous.js +64 -7
- package/dist/esm/utils/text.d.ts +15 -1
- package/dist/esm/utils/text.js +15 -1
- package/package.json +23 -3
|
@@ -1,25 +1,65 @@
|
|
|
1
1
|
import { WorkflowContractError } from '../structs/errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Read a state field that must already be present.
|
|
4
|
+
*
|
|
5
|
+
* Used by `requires` declarations and terminal deliveries, so a node cannot observe a
|
|
6
|
+
* field as undefined and silently produce a wrong result.
|
|
7
|
+
*
|
|
8
|
+
* @param state - Current workflow state.
|
|
9
|
+
* @param key - Field to read.
|
|
10
|
+
* @returns The field value, narrowed to exclude undefined.
|
|
11
|
+
* @throws WorkflowContractError When the field is undefined.
|
|
12
|
+
*/
|
|
2
13
|
export function requireWorkflowValue(state, key) {
|
|
3
14
|
const value = state[key];
|
|
4
15
|
if (value === undefined)
|
|
5
16
|
throw new WorkflowContractError(`Missing workflow state: ${String(key)}`);
|
|
6
17
|
return value;
|
|
7
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Build a reader for one state path.
|
|
21
|
+
*
|
|
22
|
+
* Dotted string paths traverse nested objects and stop safely at undefined; any other key
|
|
23
|
+
* is read directly from the state. Both forms share the returned reader so route
|
|
24
|
+
* conditions stay uniform.
|
|
25
|
+
*
|
|
26
|
+
* @param path - Dotted path or direct key.
|
|
27
|
+
* @returns A function reading the value from a state object.
|
|
28
|
+
*/
|
|
8
29
|
function readPath(path) {
|
|
9
30
|
const keys = typeof path === 'string' ? path.split('.') : [path];
|
|
10
31
|
return (state) => keys.reduce((value, key) => value?.[key], state);
|
|
11
32
|
}
|
|
12
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Unconditional jump with a stable, target-derived route ID.
|
|
35
|
+
*
|
|
36
|
+
* @param target - Destination node id.
|
|
37
|
+
* @param id - Optional explicit route id.
|
|
38
|
+
* @returns A terminal-free route that always matches.
|
|
39
|
+
*/
|
|
13
40
|
const routeTo = function route(target, id) {
|
|
14
41
|
return { id: id ?? `to-${target}`, targetNodeId: target };
|
|
15
42
|
};
|
|
16
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* One conditional jump, using the same strict equality as a handwritten route.
|
|
45
|
+
*
|
|
46
|
+
* A derived route id is only produced for symbol-free paths and primitive values,
|
|
47
|
+
* because those are the cases where `String(value)` is stable and unique enough to name
|
|
48
|
+
* the condition.
|
|
49
|
+
*
|
|
50
|
+
* @param target - Destination node id.
|
|
51
|
+
* @param path - State path to compare.
|
|
52
|
+
* @param value - Expected value, compared with `===`.
|
|
53
|
+
* @param options - Optional id, condition id and description.
|
|
54
|
+
* @returns A route that matches when the path equals `value`.
|
|
55
|
+
*/
|
|
17
56
|
function toIfEqual(target, path, value, options) {
|
|
18
57
|
const stableValue = value === null || ['undefined', 'string', 'boolean', 'number', 'bigint'].includes(typeof value);
|
|
19
58
|
const condition = typeof path !== 'symbol' && stableValue
|
|
20
59
|
? JSON.stringify([String(path), typeof value, String(value)])
|
|
21
60
|
: undefined;
|
|
22
|
-
const id = options?.id ??
|
|
61
|
+
const id = options?.id ??
|
|
62
|
+
(condition === undefined ? undefined : `route:${JSON.stringify([condition, target])}`);
|
|
23
63
|
const conditionId = options?.conditionId ?? (id === undefined ? undefined : '{nid}.{rid}');
|
|
24
64
|
const read = readPath(path);
|
|
25
65
|
return {
|
|
@@ -30,52 +70,138 @@ function toIfEqual(target, path, value, options) {
|
|
|
30
70
|
targetNodeId: target,
|
|
31
71
|
};
|
|
32
72
|
}
|
|
33
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Jump when two state paths resolve to strictly equal values.
|
|
75
|
+
*
|
|
76
|
+
* No derived route id is produced for symbol paths, because a symbol cannot be embedded
|
|
77
|
+
* in a stable name.
|
|
78
|
+
*
|
|
79
|
+
* @param target - Destination node id.
|
|
80
|
+
* @param leftPath - First state path.
|
|
81
|
+
* @param rightPath - Second state path.
|
|
82
|
+
* @param options - Optional id, condition id and description.
|
|
83
|
+
* @returns A route that matches when both paths are strictly equal.
|
|
84
|
+
*/
|
|
34
85
|
function toIfEqualWith(target, leftPath, rightPath, options) {
|
|
35
86
|
const left = readPath(leftPath);
|
|
36
87
|
const right = readPath(rightPath);
|
|
37
|
-
const id = options?.id ??
|
|
38
|
-
|
|
88
|
+
const id = options?.id ??
|
|
89
|
+
(typeof leftPath === 'symbol' || typeof rightPath === 'symbol'
|
|
90
|
+
? undefined
|
|
91
|
+
: `route:with:${JSON.stringify([String(leftPath), String(rightPath), target])}`);
|
|
39
92
|
return {
|
|
40
|
-
...options,
|
|
93
|
+
...options,
|
|
94
|
+
id,
|
|
41
95
|
conditionId: options?.conditionId ?? (id === undefined ? undefined : '{nid}.{rid}'),
|
|
42
96
|
when: (state) => left(state) === right(state),
|
|
43
97
|
targetNodeId: target,
|
|
44
98
|
};
|
|
45
99
|
}
|
|
46
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* Jump when a state array contains at least one entry.
|
|
102
|
+
*
|
|
103
|
+
* A non-array value never matches, so a mistyped field cannot be treated as populated.
|
|
104
|
+
*
|
|
105
|
+
* @param target - Destination node id.
|
|
106
|
+
* @param key - State path expected to hold an array.
|
|
107
|
+
* @param options - Optional id, condition id and description.
|
|
108
|
+
* @returns A route that matches for a non-empty array.
|
|
109
|
+
*/
|
|
47
110
|
function toIfNotEmpty(target, key, options) {
|
|
48
111
|
const read = readPath(key);
|
|
49
|
-
return {
|
|
112
|
+
return {
|
|
113
|
+
...options,
|
|
114
|
+
...routeTo(target, options?.id),
|
|
115
|
+
conditionId: options?.conditionId ?? '{nid}.{rid}',
|
|
116
|
+
when: (state) => {
|
|
50
117
|
const value = read(state);
|
|
51
118
|
return Array.isArray(value) && value.length > 0;
|
|
52
|
-
}
|
|
119
|
+
},
|
|
120
|
+
};
|
|
53
121
|
}
|
|
54
|
-
/**
|
|
122
|
+
/**
|
|
123
|
+
* Jump once a state field has a value.
|
|
124
|
+
*
|
|
125
|
+
* `null` counts as present: only `undefined` means the field is still unset.
|
|
126
|
+
*
|
|
127
|
+
* @param target - Destination node id.
|
|
128
|
+
* @param field - State path to inspect.
|
|
129
|
+
* @param options - Optional id, condition id and description.
|
|
130
|
+
* @returns A route that matches when the field is not undefined.
|
|
131
|
+
*/
|
|
55
132
|
function toIfDefined(target, field, options) {
|
|
56
133
|
const read = readPath(field);
|
|
57
|
-
return {
|
|
134
|
+
return {
|
|
135
|
+
...options,
|
|
136
|
+
...routeTo(target, options?.id),
|
|
137
|
+
conditionId: options?.conditionId ?? '{nid}.{rid}',
|
|
138
|
+
when: (state) => read(state) !== undefined,
|
|
139
|
+
};
|
|
58
140
|
}
|
|
59
|
-
/**
|
|
141
|
+
/**
|
|
142
|
+
* Jump to the node named by a truthy state field.
|
|
143
|
+
*
|
|
144
|
+
* The same field is used as the condition and as the destination, which is the usual
|
|
145
|
+
* shape of a dispatcher that stored its own next node.
|
|
146
|
+
*
|
|
147
|
+
* @param target - Field holding the destination node id.
|
|
148
|
+
* @param options - Optional id, condition id and description.
|
|
149
|
+
* @returns A route that matches when the field is truthy.
|
|
150
|
+
*/
|
|
60
151
|
function toIf(target, options) {
|
|
61
|
-
return {
|
|
152
|
+
return {
|
|
153
|
+
...toIfDefined(target, target, options),
|
|
154
|
+
when: (state) => Boolean(state[target]),
|
|
155
|
+
};
|
|
62
156
|
}
|
|
63
157
|
function toIfError(target, { errorKey = 'error', ...options } = {}) {
|
|
64
158
|
return toIfDefined(target, errorKey, options);
|
|
65
159
|
}
|
|
66
|
-
/**
|
|
160
|
+
/**
|
|
161
|
+
* At a terminal node, the result must already exist.
|
|
162
|
+
*
|
|
163
|
+
* Completing reads the field with `requireWorkflowValue`, so a node that forgot to
|
|
164
|
+
* produce its result fails instead of returning undefined.
|
|
165
|
+
*
|
|
166
|
+
* @param field - State field holding the final result.
|
|
167
|
+
* @param options - Optional id and description; a condition id is meaningless here.
|
|
168
|
+
* @returns A completion route with the default id `complete`.
|
|
169
|
+
*/
|
|
67
170
|
function deliver(field, options) {
|
|
68
171
|
const id = options?.id ?? 'complete';
|
|
69
172
|
return {
|
|
70
|
-
...options,
|
|
173
|
+
...options,
|
|
174
|
+
id,
|
|
71
175
|
complete: (state) => requireWorkflowValue(state, field),
|
|
72
176
|
};
|
|
73
177
|
}
|
|
74
|
-
/**
|
|
178
|
+
/**
|
|
179
|
+
* Deliver an available result, or let the next route decide.
|
|
180
|
+
*
|
|
181
|
+
* Unlike `deliver`, this route carries a condition so a following route still has a
|
|
182
|
+
* chance to match when the field is still unset.
|
|
183
|
+
*
|
|
184
|
+
* @param field - State field holding the result.
|
|
185
|
+
* @param options - Optional route metadata.
|
|
186
|
+
* @returns A conditional completion route.
|
|
187
|
+
*/
|
|
75
188
|
function deliverIfReady(field, options) {
|
|
76
|
-
return {
|
|
189
|
+
return {
|
|
190
|
+
...deliver(field, options),
|
|
191
|
+
conditionId: options?.conditionId ?? '{nid}.{rid}',
|
|
192
|
+
when: (state) => state[field] !== undefined,
|
|
193
|
+
};
|
|
77
194
|
}
|
|
78
|
-
/**
|
|
195
|
+
/**
|
|
196
|
+
* Apply the shared continue/complete outcome contract.
|
|
197
|
+
*
|
|
198
|
+
* The field holds a `StepOutcome`; only the `complete` variant ends the workflow, and the
|
|
199
|
+
* completion asserts the variant instead of trusting the condition.
|
|
200
|
+
*
|
|
201
|
+
* @param field - State field holding the outcome.
|
|
202
|
+
* @param options - Optional route metadata.
|
|
203
|
+
* @returns A conditional completion route that unwraps the outcome value.
|
|
204
|
+
*/
|
|
79
205
|
function deliverWhenComplete(field, options) {
|
|
80
206
|
return {
|
|
81
207
|
...options,
|
|
@@ -90,8 +216,21 @@ function deliverWhenComplete(field, options) {
|
|
|
90
216
|
},
|
|
91
217
|
};
|
|
92
218
|
}
|
|
93
|
-
/**
|
|
219
|
+
/**
|
|
220
|
+
* Callable route catalog; aliases share the same function without namespace initialization.
|
|
221
|
+
*
|
|
222
|
+
* `route(...)` and `route.to(...)` are the same function, so both call styles stay
|
|
223
|
+
* interchangeable and no module-level setup is required to use either.
|
|
224
|
+
*/
|
|
94
225
|
export const route = Object.assign(routeTo, {
|
|
95
|
-
to: routeTo,
|
|
96
|
-
|
|
226
|
+
to: routeTo,
|
|
227
|
+
toIfEqual,
|
|
228
|
+
toIfEqualWith,
|
|
229
|
+
toIfNotEmpty,
|
|
230
|
+
toIfDefined,
|
|
231
|
+
toIf,
|
|
232
|
+
toIfError,
|
|
233
|
+
deliver,
|
|
234
|
+
deliverIfReady,
|
|
235
|
+
deliverWhenComplete,
|
|
97
236
|
});
|
|
@@ -1,20 +1,77 @@
|
|
|
1
1
|
import type { AgentWorkflowDefinition, WorkflowExtension, WorkflowNode } from '../structs/execution/workflow.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Executable catalog: validate references and bounded cycles before any handler runs.
|
|
4
|
+
*
|
|
5
|
+
* Validation happens once, at construction, so traversal can assume every target exists
|
|
6
|
+
* and every cycle is budget-bounded.
|
|
7
|
+
*/
|
|
3
8
|
export declare class AgentWorkflow<State, Result, Runtime = undefined> {
|
|
9
|
+
/** Workflow id, also used in diagnostics and error messages. */
|
|
4
10
|
readonly id: string;
|
|
11
|
+
/** First node visited; always starts a round. */
|
|
5
12
|
readonly entryNodeId: string;
|
|
13
|
+
/** Optional revision passed through to diagnostics. */
|
|
6
14
|
readonly revision?: string;
|
|
15
|
+
/** Optional result guard; when present it must return exactly true. */
|
|
7
16
|
readonly isResult?: (result: Result) => boolean;
|
|
8
17
|
private readonly nodes;
|
|
18
|
+
/**
|
|
19
|
+
* Build and validate a workflow.
|
|
20
|
+
*
|
|
21
|
+
* The entry node must start a round, because otherwise a workflow could loop forever
|
|
22
|
+
* without consuming the round budget. Renamed top-level fields are rejected as well.
|
|
23
|
+
*
|
|
24
|
+
* @param definition - Nodes, entry, id, optional revision and result guard.
|
|
25
|
+
* @throws TypeError When the definition, a node, a route or a graph invariant is invalid.
|
|
26
|
+
*/
|
|
9
27
|
constructor(definition: AgentWorkflowDefinition<State, Result, Runtime>);
|
|
28
|
+
/**
|
|
29
|
+
* Derive an extended workflow without mutating this catalog.
|
|
30
|
+
*
|
|
31
|
+
* Every node is copied with its callbacks rebound, so the new catalog keeps the same
|
|
32
|
+
* entry and result guard and can be composed repeatedly. Route overrides are keyed by
|
|
33
|
+
* node id and must name a node that exists after the merge.
|
|
34
|
+
*
|
|
35
|
+
* @param extension - Extension patch, or another workflow whose definitions are merged.
|
|
36
|
+
* @param routes - Route overrides keyed by node id.
|
|
37
|
+
* @returns A new, fully re-validated workflow.
|
|
38
|
+
* @throws TypeError When an override names an unknown node or a node is invalid.
|
|
39
|
+
*/
|
|
10
40
|
add(extension: WorkflowExtension<State, Result, Runtime> | AgentWorkflow<State, Result, Runtime>, routes?: WorkflowExtension<State, Result, Runtime>['routes']): AgentWorkflow<State, Result, Runtime>;
|
|
41
|
+
/**
|
|
42
|
+
* Look up a node that must exist.
|
|
43
|
+
*
|
|
44
|
+
* @param id - Node id.
|
|
45
|
+
* @returns The registered node.
|
|
46
|
+
* @throws TypeError When the node is unknown.
|
|
47
|
+
*/
|
|
11
48
|
require(id: string): WorkflowNode<State, Result, Runtime>;
|
|
49
|
+
/** Frozen snapshot of all nodes, in registration order. */
|
|
12
50
|
get definitions(): readonly Readonly<WorkflowNode<State, Result, Runtime>>[];
|
|
51
|
+
/** @returns A frozen array of node ids in registration order. */
|
|
13
52
|
ids(): readonly string[];
|
|
53
|
+
/** @returns An iterator over the registered nodes. */
|
|
14
54
|
values(): MapIterator<WorkflowNode<State, Result, Runtime>>;
|
|
55
|
+
/** @returns An iterator over id/node pairs. */
|
|
15
56
|
entries(): MapIterator<[string, WorkflowNode<State, Result, Runtime>]>;
|
|
57
|
+
/**
|
|
58
|
+
* @param id - Node id.
|
|
59
|
+
* @returns Whether the node is registered.
|
|
60
|
+
*/
|
|
16
61
|
has(id: string): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* @param id - Node id.
|
|
64
|
+
* @returns The node, or undefined when it is not registered.
|
|
65
|
+
*/
|
|
17
66
|
get(id: string): WorkflowNode<State, Result, Runtime> | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Produce a serializable description of every node and route.
|
|
69
|
+
*
|
|
70
|
+
* Used by documentation and registration listings; it reports resolved ids and which
|
|
71
|
+
* routes are terminal or conditional, never the handler implementations.
|
|
72
|
+
*
|
|
73
|
+
* @returns An array of plain description objects in registration order.
|
|
74
|
+
*/
|
|
18
75
|
describe(): {
|
|
19
76
|
startsRound: boolean;
|
|
20
77
|
onErrorNodeId: string | undefined;
|
|
@@ -32,22 +89,83 @@ export declare class AgentWorkflow<State, Result, Runtime = undefined> {
|
|
|
32
89
|
id: string;
|
|
33
90
|
description: string;
|
|
34
91
|
}[];
|
|
92
|
+
/**
|
|
93
|
+
* Validate and freeze one node, then add it to the catalog.
|
|
94
|
+
*
|
|
95
|
+
* A route must be either a jump with a target or a completion, never both; an
|
|
96
|
+
* unconditional route must be last, because it would shadow every later route. Route
|
|
97
|
+
* ids and condition ids are resolved here so the engine never interpolates templates at
|
|
98
|
+
* run time.
|
|
99
|
+
*
|
|
100
|
+
* @param node - Node supplied by the workflow definition.
|
|
101
|
+
* @throws TypeError When the node, a route or a state contract is invalid.
|
|
102
|
+
*/
|
|
35
103
|
private register;
|
|
104
|
+
/**
|
|
105
|
+
* Collect every node a visit can hand control to.
|
|
106
|
+
*
|
|
107
|
+
* Error targets are included so a recovery node is treated as reachable and is subject
|
|
108
|
+
* to the same cycle rule as a normal transition.
|
|
109
|
+
*
|
|
110
|
+
* @param node - Node whose outgoing edges are collected.
|
|
111
|
+
* @returns Target node ids, including the error node.
|
|
112
|
+
*/
|
|
36
113
|
private targets;
|
|
114
|
+
/**
|
|
115
|
+
* Require every route target to name a registered node.
|
|
116
|
+
*
|
|
117
|
+
* @throws TypeError When any target is unknown.
|
|
118
|
+
*/
|
|
37
119
|
private checkReferences;
|
|
120
|
+
/**
|
|
121
|
+
* Require every node to be reachable from the entry.
|
|
122
|
+
*
|
|
123
|
+
* An unreachable node is a declaration mistake: it would never run, yet it still
|
|
124
|
+
* appears in listings and documentation.
|
|
125
|
+
*
|
|
126
|
+
* @throws TypeError When any node cannot be reached.
|
|
127
|
+
*/
|
|
38
128
|
private checkReachability;
|
|
129
|
+
/**
|
|
130
|
+
* Require every cycle to cross a round boundary.
|
|
131
|
+
*
|
|
132
|
+
* @throws TypeError When a cycle can be traversed without ever starting a new round.
|
|
133
|
+
*/
|
|
39
134
|
private checkBoundedCycles;
|
|
40
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Build a validated workflow from a definition.
|
|
138
|
+
*
|
|
139
|
+
* @param definition - Workflow definition; validated like the constructor argument.
|
|
140
|
+
* @returns A validated, immutable workflow catalog.
|
|
141
|
+
* @throws TypeError When the definition is invalid.
|
|
142
|
+
*/
|
|
41
143
|
export declare function defineWorkflow<State, Result, Runtime = undefined>(definition: AgentWorkflowDefinition<State, Result, Runtime>): AgentWorkflow<State, Result, Runtime>;
|
|
42
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* Successful acquisitions consume attempts; a refused acquisition never grants another.
|
|
146
|
+
*
|
|
147
|
+
* `available` is a snapshot of the counter, not a reservation: a caller must still call
|
|
148
|
+
* `take` and honor its boolean result before acting.
|
|
149
|
+
*/
|
|
43
150
|
export declare class AttemptBudget {
|
|
44
151
|
readonly limit: number;
|
|
45
152
|
private consumed;
|
|
153
|
+
/**
|
|
154
|
+
* @param limit - Total attempts allowed; must be a nonnegative integer.
|
|
155
|
+
* @throws TypeError When `limit` is not a nonnegative integer.
|
|
156
|
+
*/
|
|
46
157
|
constructor(limit: number);
|
|
158
|
+
/** Attempts consumed so far. */
|
|
47
159
|
get used(): number;
|
|
160
|
+
/** Whether at least one attempt remains unspent. */
|
|
48
161
|
get available(): boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Consume one attempt if one remains.
|
|
164
|
+
*
|
|
165
|
+
* @returns True when the attempt was granted, false when the budget is exhausted.
|
|
166
|
+
*/
|
|
49
167
|
take(): boolean;
|
|
50
168
|
}
|
|
51
169
|
export { requireWorkflowValue, route } from './state.js';
|
|
52
|
-
export type { WorkflowContext, WorkflowModel, WorkflowRoute, WorkflowNode, WorkflowNodeReport, WorkflowExtension, AgentWorkflowDefinition, WorkflowEvent } from '../structs/execution/workflow.js';
|
|
170
|
+
export type { WorkflowContext, WorkflowModel, WorkflowRoute, WorkflowNode, WorkflowNodeReport, WorkflowExtension, AgentWorkflowDefinition, WorkflowEvent, } from '../structs/execution/workflow.js';
|
|
53
171
|
export { WorkflowContractError } from '../structs/errors.js';
|