@jangts/agent-core 0.1.1 → 0.2.1
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 +25 -0
- package/LICENSE +55 -0
- package/NOTICE +6 -0
- package/README.md +8 -0
- package/development/docs/README.en.md +70 -0
- package/development/docs/README.md +1 -1
- package/development/docs/acceptance.en.md +34 -0
- package/development/docs/agent-development.en.md +42 -0
- package/development/docs/api/README.en.md +62 -0
- package/development/docs/api/advanced-agents.en.md +135 -0
- package/development/docs/api/context-processing.en.md +110 -0
- package/development/docs/api/core.en.md +274 -0
- package/development/docs/api/examples.en.md +118 -0
- package/development/docs/api/kits.en.md +183 -0
- package/development/docs/api/knowledge-answering.en.md +166 -0
- package/development/docs/api/mock.en.md +186 -0
- package/development/docs/api/observability.en.md +166 -0
- package/development/docs/api/reference.en.md +2235 -0
- package/development/docs/api/reference.md +1907 -1874
- package/development/docs/api/support.en.md +252 -0
- package/development/docs/api/support.md +27 -0
- package/development/docs/api/types.en.md +181 -0
- package/development/docs/api/workflow.en.md +188 -0
- package/development/docs/basic-usage.en.md +78 -0
- package/development/docs/create-app.en.md +76 -0
- package/development/docs/examples/offline-agent.en.md +273 -0
- package/development/docs/examples.en.md +36 -0
- package/development/docs/flows/knowledge-maintenance.en.md +38 -0
- package/development/docs/getting-started.en.md +71 -0
- package/development/docs/knowledge.en.md +89 -0
- package/development/docs/maintenance.en.md +62 -0
- package/development/docs/materials.en.md +38 -0
- package/development/docs/mechanisms.en.md +227 -0
- package/development/docs/memory-and-learning.en.md +42 -0
- package/development/docs/operations.en.md +51 -0
- package/development/docs/records.en.md +63 -0
- package/development/docs/registration.en.md +63 -0
- package/development/skills/agent-core-app/scripts/create-app.mjs +286 -70
- package/development/skills/agent-core-app/scripts/lib/knowledge.mjs +77 -16
- package/development/skills/agent-core-app/scripts/lib/source.mjs +30 -2
- package/development/skills/agent-core-app/scripts/plan.mjs +46 -12
- package/development/skills/agent-core-app/scripts/prepare-source.mjs +61 -10
- package/development/skills/agent-core-app/scripts/resources.mjs +62 -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 +17 -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 +33 -0
- package/dist/cjs/support/model/completion/index.js +28 -0
- package/dist/cjs/support/model/completion/session.js +107 -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.d.ts +6 -0
- package/dist/esm/diagnostics/catalog.js +17 -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 +39 -0
- package/dist/esm/structs/kits/search.d.ts +24 -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 +34 -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 +54 -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 +65 -3
- package/dist/esm/support/context/nodes.js +165 -36
- package/dist/esm/support/context/processing.d.ts +152 -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 +34 -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 +11 -0
- package/dist/esm/support/model/completion/default.js +30 -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 +16 -0
- package/dist/esm/support/model/completion/session.js +104 -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 +26 -2
- package/dist/esm/support/model/preview-rules.js +66 -16
- package/dist/esm/support/model/reply-preview.d.ts +22 -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 +28 -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 +7 -3
|
@@ -1,16 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intents Kit: an ordered, sealable registry of scope declarations and their aliases.
|
|
3
|
+
*
|
|
4
|
+
* Place in the package: part of the `intents` Kit. Categories, extra fields and intent
|
|
5
|
+
* acceptance policy are App configuration; this class owns validation, alias normalization,
|
|
6
|
+
* relationship lookups and sealing.
|
|
7
|
+
*
|
|
8
|
+
* Exports: `ScopeRegistry`, `createScopeRegistry`, and the scope registry types.
|
|
9
|
+
*/
|
|
1
10
|
import type { ScopeDefinition, ScopeDescription, ScopeRegistryPolicy, RegisteredScope, RegisteredScopeEvidence } from '../../structs/kits/intents/scopes.js';
|
|
2
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Generic scope relationships; categories, intent policy and extra fields belong to the host.
|
|
13
|
+
*
|
|
14
|
+
* A scope is addressable by its id or by any of its aliases; aliases resolve to the declaring
|
|
15
|
+
* scope, and a name may be claimed only once across both namespaces.
|
|
16
|
+
*/
|
|
3
17
|
export declare class ScopeRegistry<Definition extends ScopeDefinition = ScopeDefinition> {
|
|
18
|
+
/** Create and seal a complete scope catalog in one call. */
|
|
4
19
|
static readonly create: typeof createScopeRegistry;
|
|
5
20
|
private readonly byId;
|
|
6
21
|
private readonly sources;
|
|
7
22
|
private readonly aliases;
|
|
8
23
|
private sealed;
|
|
9
24
|
private readonly policy;
|
|
25
|
+
/**
|
|
26
|
+
* @param policy - Optional id pattern, categories, required-binding switches, intent
|
|
27
|
+
* acceptance override, error wording and assertion hook; lists are copied on construction.
|
|
28
|
+
*/
|
|
10
29
|
constructor(policy?: ScopeRegistryPolicy<Definition>);
|
|
30
|
+
/**
|
|
31
|
+
* Validate, freeze and add one scope together with its aliases.
|
|
32
|
+
*
|
|
33
|
+
* Every name is checked for conflicts before any of them is stored, so a rejected scope
|
|
34
|
+
* leaves no partial alias entry behind.
|
|
35
|
+
*
|
|
36
|
+
* @param input - Scope declaration; the raw object is retained for `acceptsIntent` overrides
|
|
37
|
+
* while the compiled copy serves lookups.
|
|
38
|
+
* @returns This registry, for chaining.
|
|
39
|
+
* @throws A configured error for a sealed registry, an invalid name/description/category,
|
|
40
|
+
* a missing required binding, duplicate intent ids or an already-claimed name.
|
|
41
|
+
*/
|
|
11
42
|
register(input: Definition): this;
|
|
43
|
+
/** Register every scope in iteration order. */
|
|
12
44
|
registerAll(definitions: Iterable<Definition>): this;
|
|
45
|
+
/** Finalize the registry; no registration is accepted afterwards. */
|
|
13
46
|
seal(): this;
|
|
47
|
+
/** Registered scopes in registration order. */
|
|
14
48
|
get definitions(): readonly Readonly<Omit<Readonly<ScopeDefinition & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof ScopeDefinition>>>, "evidence" | ("toolIds" | "intentIds" | "queryScopeIds" | "knowledgeTopicIds" | "aliases")> & {
|
|
15
49
|
readonly toolIds: [NonNullable<Definition["toolIds"]>] extends [never] ? readonly [] : NonNullable<Definition["toolIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["toolIds"]> : readonly string[];
|
|
16
50
|
readonly intentIds: [NonNullable<Definition["intentIds"]>] extends [never] ? readonly [] : NonNullable<Definition["intentIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["intentIds"]> : readonly string[];
|
|
@@ -20,7 +54,9 @@ export declare class ScopeRegistry<Definition extends ScopeDefinition = ScopeDef
|
|
|
20
54
|
} & {
|
|
21
55
|
evidence: [NonNullable<Definition["evidence"]>] extends [never] ? readonly [] : NonNullable<Definition["evidence"]> extends readonly import("../evidence.js").EvidenceRequirement[] ? readonly import("../evidence.js").EvidenceRequirement[] & Definition["evidence"] extends infer T extends readonly import("../evidence.js").EvidenceRequirement[] ? { readonly [Index in keyof T]: Readonly<import("../../utils/registration.js").RegistrationData<T[Index]>>; } : never : readonly Readonly<import("../../utils/registration.js").RegistrationData<NonNullable<Definition["evidence"]>[number]>>[];
|
|
22
56
|
}>[];
|
|
57
|
+
/** Registered scope ids in registration order; aliases are not included. */
|
|
23
58
|
ids(): readonly string[];
|
|
59
|
+
/** Iterate the registered scopes. */
|
|
24
60
|
values(): MapIterator<Readonly<Omit<Readonly<ScopeDefinition & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof ScopeDefinition>>>, "evidence" | ("toolIds" | "intentIds" | "queryScopeIds" | "knowledgeTopicIds" | "aliases")> & {
|
|
25
61
|
readonly toolIds: [NonNullable<Definition["toolIds"]>] extends [never] ? readonly [] : NonNullable<Definition["toolIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["toolIds"]> : readonly string[];
|
|
26
62
|
readonly intentIds: [NonNullable<Definition["intentIds"]>] extends [never] ? readonly [] : NonNullable<Definition["intentIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["intentIds"]> : readonly string[];
|
|
@@ -30,6 +66,7 @@ export declare class ScopeRegistry<Definition extends ScopeDefinition = ScopeDef
|
|
|
30
66
|
} & {
|
|
31
67
|
evidence: [NonNullable<Definition["evidence"]>] extends [never] ? readonly [] : NonNullable<Definition["evidence"]> extends readonly import("../evidence.js").EvidenceRequirement[] ? readonly import("../evidence.js").EvidenceRequirement[] & Definition["evidence"] extends infer T extends readonly import("../evidence.js").EvidenceRequirement[] ? { readonly [Index in keyof T]: Readonly<import("../../utils/registration.js").RegistrationData<T[Index]>>; } : never : readonly Readonly<import("../../utils/registration.js").RegistrationData<NonNullable<Definition["evidence"]>[number]>>[];
|
|
32
68
|
}>>;
|
|
69
|
+
/** Iterate `[id, scope]` pairs. */
|
|
33
70
|
entries(): MapIterator<[string, Readonly<Omit<Readonly<ScopeDefinition & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof ScopeDefinition>>>, "evidence" | ("toolIds" | "intentIds" | "queryScopeIds" | "knowledgeTopicIds" | "aliases")> & {
|
|
34
71
|
readonly toolIds: [NonNullable<Definition["toolIds"]>] extends [never] ? readonly [] : NonNullable<Definition["toolIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["toolIds"]> : readonly string[];
|
|
35
72
|
readonly intentIds: [NonNullable<Definition["intentIds"]>] extends [never] ? readonly [] : NonNullable<Definition["intentIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["intentIds"]> : readonly string[];
|
|
@@ -39,6 +76,11 @@ export declare class ScopeRegistry<Definition extends ScopeDefinition = ScopeDef
|
|
|
39
76
|
} & {
|
|
40
77
|
evidence: [NonNullable<Definition["evidence"]>] extends [never] ? readonly [] : NonNullable<Definition["evidence"]> extends readonly import("../evidence.js").EvidenceRequirement[] ? readonly import("../evidence.js").EvidenceRequirement[] & Definition["evidence"] extends infer T extends readonly import("../evidence.js").EvidenceRequirement[] ? { readonly [Index in keyof T]: Readonly<import("../../utils/registration.js").RegistrationData<T[Index]>>; } : never : readonly Readonly<import("../../utils/registration.js").RegistrationData<NonNullable<Definition["evidence"]>[number]>>[];
|
|
41
78
|
}>]>;
|
|
79
|
+
/**
|
|
80
|
+
* Registered scope for an id or alias.
|
|
81
|
+
*
|
|
82
|
+
* @throws TypeError When the name resolves to nothing.
|
|
83
|
+
*/
|
|
42
84
|
require(id: string): Readonly<Omit<Readonly<ScopeDefinition & import("../../utils/registration.js").RegistrationData<Definition> & Pick<Definition, Extract<keyof Definition, keyof ScopeDefinition>>>, "evidence" | ("toolIds" | "intentIds" | "queryScopeIds" | "knowledgeTopicIds" | "aliases")> & {
|
|
43
85
|
readonly toolIds: [NonNullable<Definition["toolIds"]>] extends [never] ? readonly [] : NonNullable<Definition["toolIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["toolIds"]> : readonly string[];
|
|
44
86
|
readonly intentIds: [NonNullable<Definition["intentIds"]>] extends [never] ? readonly [] : NonNullable<Definition["intentIds"]> extends readonly string[] ? Readonly<readonly string[] & Definition["intentIds"]> : readonly string[];
|
|
@@ -48,18 +90,46 @@ export declare class ScopeRegistry<Definition extends ScopeDefinition = ScopeDef
|
|
|
48
90
|
} & {
|
|
49
91
|
evidence: [NonNullable<Definition["evidence"]>] extends [never] ? readonly [] : NonNullable<Definition["evidence"]> extends readonly import("../evidence.js").EvidenceRequirement[] ? readonly import("../evidence.js").EvidenceRequirement[] & Definition["evidence"] extends infer T extends readonly import("../evidence.js").EvidenceRequirement[] ? { readonly [Index in keyof T]: Readonly<import("../../utils/registration.js").RegistrationData<T[Index]>>; } : never : readonly Readonly<import("../../utils/registration.js").RegistrationData<NonNullable<Definition["evidence"]>[number]>>[];
|
|
50
92
|
}>;
|
|
93
|
+
/** Resolve an alias to its scope id; unknown names are returned unchanged. */
|
|
51
94
|
normalize(scope: string): string;
|
|
95
|
+
/** Registered scope for an id or alias, or `undefined` for a null/unknown name. */
|
|
52
96
|
get(scope?: string | null): RegisteredScope<Definition> | undefined;
|
|
97
|
+
/** Whether the name resolves to a registered scope. */
|
|
53
98
|
has(scope?: string | null): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Whether a scope accepts an intent.
|
|
101
|
+
*
|
|
102
|
+
* The App may override the declared `intentIds` through `acceptsIntent`; without an
|
|
103
|
+
* override the membership check applies.
|
|
104
|
+
*/
|
|
54
105
|
acceptsIntent(scope: string, goal: string): boolean;
|
|
106
|
+
/** Whether the scope declares this query scope; a null scope accepts nothing. */
|
|
55
107
|
acceptsQuery(scope: string | null, queryScope: string): boolean;
|
|
108
|
+
/** Whether the scope belongs to the given App category. */
|
|
56
109
|
is(scope: string | null | undefined, category: Definition['category']): boolean;
|
|
110
|
+
/** Every query scope declared by any registered scope, deduplicated. */
|
|
57
111
|
queryScopeIds(): string[];
|
|
112
|
+
/** Knowledge topic ids of one scope; copied so callers cannot mutate the registry. */
|
|
58
113
|
topics(scope?: string | null): string[];
|
|
114
|
+
/** Evidence declarations of one scope; copied so callers cannot mutate the registry. */
|
|
59
115
|
evidence(scope?: string | null): RegisteredScopeEvidence<Definition>[];
|
|
116
|
+
/** Declared context tier of one scope, if any. */
|
|
60
117
|
contextTier(scope?: string | null): Definition['contextTier'] | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Copy the scopes that accept at least one of the given intents.
|
|
120
|
+
*
|
|
121
|
+
* @param goals - Intent ids to filter by; omit to include every registered scope.
|
|
122
|
+
* @returns Descriptions whose arrays are copied so callers cannot mutate registry state.
|
|
123
|
+
*/
|
|
61
124
|
describe(goals?: readonly string[]): ScopeDescription<Definition>[];
|
|
62
125
|
}
|
|
63
|
-
/**
|
|
126
|
+
/**
|
|
127
|
+
* Create and seal a complete catalog; use the constructor for incremental installation.
|
|
128
|
+
*
|
|
129
|
+
* @param definitions - Scope declarations registered in iteration order.
|
|
130
|
+
* @param policy - Optional registry policy forwarded to the constructor.
|
|
131
|
+
* @returns A sealed registry.
|
|
132
|
+
* @throws A configured error for the first invalid or duplicate declaration.
|
|
133
|
+
*/
|
|
64
134
|
export declare function createScopeRegistry<Definition extends ScopeDefinition>(definitions: Iterable<Definition>, policy?: ScopeRegistryPolicy<Definition>): ScopeRegistry<Definition>;
|
|
65
|
-
export type { ScopeDefinition, ScopeDescription, ScopeRegistryPolicy, RegisteredScope, RegisteredScopeEvidence } from '../../structs/kits/intents/scopes.js';
|
|
135
|
+
export type { ScopeDefinition, ScopeDescription, ScopeRegistryPolicy, RegisteredScope, RegisteredScopeEvidence, } from '../../structs/kits/intents/scopes.js';
|
|
@@ -1,62 +1,148 @@
|
|
|
1
1
|
import { assertion, booleanResult } from '../../utils/synchronous.js';
|
|
2
2
|
import { breakWhile } from '../../utils/rules.js';
|
|
3
3
|
import { registrationData } from '../../utils/registration.js';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Generic scope relationships; categories, intent policy and extra fields belong to the host.
|
|
6
|
+
*
|
|
7
|
+
* A scope is addressable by its id or by any of its aliases; aliases resolve to the declaring
|
|
8
|
+
* scope, and a name may be claimed only once across both namespaces.
|
|
9
|
+
*/
|
|
5
10
|
export class ScopeRegistry {
|
|
11
|
+
/** Create and seal a complete scope catalog in one call. */
|
|
6
12
|
static create = createScopeRegistry;
|
|
7
13
|
byId = new Map();
|
|
8
14
|
sources = new Map();
|
|
9
15
|
aliases = new Map();
|
|
10
16
|
sealed = false;
|
|
11
17
|
policy;
|
|
18
|
+
/**
|
|
19
|
+
* @param policy - Optional id pattern, categories, required-binding switches, intent
|
|
20
|
+
* acceptance override, error wording and assertion hook; lists are copied on construction.
|
|
21
|
+
*/
|
|
12
22
|
constructor(policy = {}) {
|
|
13
23
|
const pattern = policy.idPattern;
|
|
14
24
|
const errorPorts = policy.errors, { sealed, invalid } = errorPorts ?? {};
|
|
15
25
|
const listFields = ['categories', 'tags'];
|
|
16
|
-
const lists = Object.fromEntries(listFields.map(key => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
const lists = Object.fromEntries(listFields.map((key) => {
|
|
27
|
+
const value = policy[key];
|
|
28
|
+
return [key, value === undefined ? undefined : Object.freeze([...value])];
|
|
29
|
+
}));
|
|
30
|
+
this.policy = Object.freeze({
|
|
31
|
+
...registrationData(policy, [
|
|
32
|
+
'idPattern',
|
|
33
|
+
'assertDefinition',
|
|
34
|
+
'acceptsIntent',
|
|
35
|
+
'errors',
|
|
36
|
+
...listFields,
|
|
37
|
+
]),
|
|
38
|
+
...lists,
|
|
39
|
+
idPattern: pattern ? new RegExp(pattern.source, pattern.flags) : undefined,
|
|
40
|
+
errors: errorPorts &&
|
|
41
|
+
Object.freeze({
|
|
42
|
+
sealed: typeof sealed === 'function' ? sealed.bind(errorPorts) : sealed,
|
|
43
|
+
invalid: typeof invalid === 'function' ? invalid.bind(errorPorts) : invalid,
|
|
44
|
+
}),
|
|
45
|
+
assertDefinition: policy.assertDefinition?.bind(policy),
|
|
46
|
+
acceptsIntent: policy.acceptsIntent?.bind(policy),
|
|
47
|
+
});
|
|
21
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Validate, freeze and add one scope together with its aliases.
|
|
51
|
+
*
|
|
52
|
+
* Every name is checked for conflicts before any of them is stored, so a rejected scope
|
|
53
|
+
* leaves no partial alias entry behind.
|
|
54
|
+
*
|
|
55
|
+
* @param input - Scope declaration; the raw object is retained for `acceptsIntent` overrides
|
|
56
|
+
* while the compiled copy serves lookups.
|
|
57
|
+
* @returns This registry, for chaining.
|
|
58
|
+
* @throws A configured error for a sealed registry, an invalid name/description/category,
|
|
59
|
+
* a missing required binding, duplicate intent ids or an already-claimed name.
|
|
60
|
+
*/
|
|
22
61
|
register(input) {
|
|
23
|
-
const definition = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
62
|
+
const definition = {
|
|
63
|
+
...registrationData(input, [
|
|
64
|
+
'id',
|
|
65
|
+
'description',
|
|
66
|
+
'category',
|
|
67
|
+
'intentIds',
|
|
68
|
+
'queryScopeIds',
|
|
69
|
+
'knowledgeTopicIds',
|
|
70
|
+
'toolIds',
|
|
71
|
+
'aliases',
|
|
72
|
+
'evidence',
|
|
73
|
+
'contextTier',
|
|
74
|
+
]),
|
|
75
|
+
id: input.id,
|
|
76
|
+
description: input.description,
|
|
77
|
+
category: input.category,
|
|
78
|
+
intentIds: input.intentIds ?? [],
|
|
79
|
+
queryScopeIds: input.queryScopeIds ?? [],
|
|
80
|
+
knowledgeTopicIds: input.knowledgeTopicIds ?? [],
|
|
81
|
+
toolIds: input.toolIds ?? [],
|
|
82
|
+
aliases: input.aliases,
|
|
83
|
+
evidence: input.evidence,
|
|
84
|
+
contextTier: input.contextTier,
|
|
27
85
|
};
|
|
28
86
|
const names = [definition.id, ...(definition.aliases ?? [])];
|
|
29
87
|
const policy = this.policy, tags = policy.tags ?? [];
|
|
30
88
|
const invalid = policy.errors?.invalid ?? 'Invalid scope definition';
|
|
31
|
-
const validName = (name) => {
|
|
32
|
-
|
|
33
|
-
|
|
89
|
+
const validName = (name) => {
|
|
90
|
+
if (typeof name !== 'string' || !name.trim())
|
|
91
|
+
return false;
|
|
92
|
+
if (!policy.idPattern)
|
|
93
|
+
return true;
|
|
94
|
+
policy.idPattern.lastIndex = 0;
|
|
95
|
+
return policy.idPattern.test(name);
|
|
96
|
+
};
|
|
34
97
|
breakWhile([
|
|
35
|
-
{
|
|
98
|
+
{
|
|
99
|
+
occur: () => this.sealed,
|
|
100
|
+
error: policy.errors?.sealed ?? 'Scope registry is sealed',
|
|
101
|
+
tags: ['sealed'],
|
|
102
|
+
},
|
|
36
103
|
{
|
|
37
104
|
occur: [
|
|
38
105
|
() => !names.every(validName),
|
|
39
106
|
() => !definition.description.trim(),
|
|
40
107
|
() => policy.categories !== undefined && !policy.categories.includes(definition.category),
|
|
41
|
-
],
|
|
108
|
+
],
|
|
109
|
+
error: invalid,
|
|
110
|
+
tags: ['identity'],
|
|
42
111
|
},
|
|
43
|
-
{ occur: () => policy.requireIntents === true && !definition.intentIds.length, error: invalid, tags: ['intents', 'required'] },
|
|
44
112
|
{
|
|
45
|
-
occur:
|
|
46
|
-
error: invalid,
|
|
113
|
+
occur: () => policy.requireIntents === true && !definition.intentIds.length,
|
|
114
|
+
error: invalid,
|
|
115
|
+
tags: ['intents', 'required'],
|
|
47
116
|
},
|
|
48
117
|
{
|
|
49
|
-
occur: [
|
|
50
|
-
|
|
118
|
+
occur: [
|
|
119
|
+
() => policy.requireSources === true &&
|
|
120
|
+
!definition.queryScopeIds.length &&
|
|
121
|
+
!definition.knowledgeTopicIds.length,
|
|
122
|
+
() => policy.requireTools === true && !definition.toolIds.length,
|
|
123
|
+
],
|
|
124
|
+
error: invalid,
|
|
125
|
+
tags: ['capability-bindings'],
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
occur: [
|
|
129
|
+
() => definition.intentIds.some((intent) => typeof intent !== 'string'),
|
|
130
|
+
() => new Set(definition.intentIds).size !== definition.intentIds.length,
|
|
131
|
+
],
|
|
132
|
+
error: invalid,
|
|
133
|
+
tags: ['intents', 'values'],
|
|
51
134
|
},
|
|
52
135
|
], tags);
|
|
53
136
|
assertion(policy.assertDefinition?.(input), 'Registry definition assertions must return void synchronously');
|
|
54
|
-
breakWhile(names.some(name => this.byId.has(name) || this.aliases.has(name)), invalid, [...tags, 'duplicate']);
|
|
137
|
+
breakWhile(names.some((name) => this.byId.has(name) || this.aliases.has(name)), invalid, [...tags, 'duplicate']);
|
|
55
138
|
const frozen = Object.freeze({
|
|
56
|
-
...definition,
|
|
57
|
-
|
|
139
|
+
...definition,
|
|
140
|
+
intentIds: Object.freeze([...definition.intentIds]),
|
|
141
|
+
toolIds: Object.freeze([...definition.toolIds]),
|
|
142
|
+
queryScopeIds: Object.freeze([...definition.queryScopeIds]),
|
|
143
|
+
knowledgeTopicIds: Object.freeze([...definition.knowledgeTopicIds]),
|
|
58
144
|
aliases: Object.freeze([...(definition.aliases ?? [])]),
|
|
59
|
-
evidence: Object.freeze([...(definition.evidence ?? [])].map(item => Object.freeze(registrationData(item)))),
|
|
145
|
+
evidence: Object.freeze([...(definition.evidence ?? [])].map((item) => Object.freeze(registrationData(item)))),
|
|
60
146
|
});
|
|
61
147
|
this.byId.set(definition.id, frozen);
|
|
62
148
|
this.sources.set(definition.id, input);
|
|
@@ -64,42 +150,125 @@ export class ScopeRegistry {
|
|
|
64
150
|
this.aliases.set(alias, definition.id);
|
|
65
151
|
return this;
|
|
66
152
|
}
|
|
153
|
+
/** Register every scope in iteration order. */
|
|
67
154
|
registerAll(definitions) {
|
|
68
155
|
for (const definition of definitions)
|
|
69
156
|
this.register(definition);
|
|
70
157
|
return this;
|
|
71
158
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
159
|
+
/** Finalize the registry; no registration is accepted afterwards. */
|
|
160
|
+
seal() {
|
|
161
|
+
this.sealed = true;
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
/** Registered scopes in registration order. */
|
|
165
|
+
get definitions() {
|
|
166
|
+
return Object.freeze([...this.byId.values()]);
|
|
167
|
+
}
|
|
168
|
+
/** Registered scope ids in registration order; aliases are not included. */
|
|
169
|
+
ids() {
|
|
170
|
+
return Object.freeze([...this.byId.keys()]);
|
|
171
|
+
}
|
|
172
|
+
/** Iterate the registered scopes. */
|
|
173
|
+
values() {
|
|
174
|
+
return this.byId.values();
|
|
175
|
+
}
|
|
176
|
+
/** Iterate `[id, scope]` pairs. */
|
|
177
|
+
entries() {
|
|
178
|
+
return this.byId.entries();
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Registered scope for an id or alias.
|
|
182
|
+
*
|
|
183
|
+
* @throws TypeError When the name resolves to nothing.
|
|
184
|
+
*/
|
|
185
|
+
require(id) {
|
|
186
|
+
const value = this.get(id);
|
|
187
|
+
if (!value)
|
|
188
|
+
throw new TypeError(`Unknown scope: ${id}`);
|
|
189
|
+
return value;
|
|
190
|
+
}
|
|
191
|
+
/** Resolve an alias to its scope id; unknown names are returned unchanged. */
|
|
192
|
+
normalize(scope) {
|
|
193
|
+
return this.aliases.get(scope) ?? scope;
|
|
194
|
+
}
|
|
195
|
+
/** Registered scope for an id or alias, or `undefined` for a null/unknown name. */
|
|
196
|
+
get(scope) {
|
|
197
|
+
return scope ? this.byId.get(this.normalize(scope)) : undefined;
|
|
198
|
+
}
|
|
199
|
+
/** Whether the name resolves to a registered scope. */
|
|
200
|
+
has(scope) {
|
|
201
|
+
return !!this.get(scope);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Whether a scope accepts an intent.
|
|
205
|
+
*
|
|
206
|
+
* The App may override the declared `intentIds` through `acceptsIntent`; without an
|
|
207
|
+
* override the membership check applies.
|
|
208
|
+
*/
|
|
82
209
|
acceptsIntent(scope, goal) {
|
|
83
210
|
const definition = this.get(scope);
|
|
84
211
|
if (!definition)
|
|
85
212
|
return false;
|
|
86
213
|
const ids = definition.intentIds;
|
|
87
|
-
return this.policy.acceptsIntent
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
214
|
+
return this.policy.acceptsIntent
|
|
215
|
+
? booleanResult(this.policy.acceptsIntent(this.sources.get(this.normalize(scope)), goal), 'Scope intent predicates must return boolean synchronously')
|
|
216
|
+
: ids.includes(goal);
|
|
217
|
+
}
|
|
218
|
+
/** Whether the scope declares this query scope; a null scope accepts nothing. */
|
|
219
|
+
acceptsQuery(scope, queryScope) {
|
|
220
|
+
const ids = this.get(scope)?.queryScopeIds ?? [];
|
|
221
|
+
return !!scope && ids.includes(queryScope);
|
|
222
|
+
}
|
|
223
|
+
/** Whether the scope belongs to the given App category. */
|
|
224
|
+
is(scope, category) {
|
|
225
|
+
return this.get(scope)?.category === category;
|
|
226
|
+
}
|
|
227
|
+
/** Every query scope declared by any registered scope, deduplicated. */
|
|
228
|
+
queryScopeIds() {
|
|
229
|
+
return [...new Set([...this.byId.values()].flatMap((item) => item.queryScopeIds))];
|
|
230
|
+
}
|
|
231
|
+
/** Knowledge topic ids of one scope; copied so callers cannot mutate the registry. */
|
|
232
|
+
topics(scope) {
|
|
233
|
+
return [...(this.get(scope)?.knowledgeTopicIds ?? [])];
|
|
234
|
+
}
|
|
235
|
+
/** Evidence declarations of one scope; copied so callers cannot mutate the registry. */
|
|
236
|
+
evidence(scope) {
|
|
237
|
+
return [...(this.get(scope)?.evidence ?? [])];
|
|
238
|
+
}
|
|
239
|
+
/** Declared context tier of one scope, if any. */
|
|
240
|
+
contextTier(scope) {
|
|
241
|
+
return this.get(scope)?.contextTier;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Copy the scopes that accept at least one of the given intents.
|
|
245
|
+
*
|
|
246
|
+
* @param goals - Intent ids to filter by; omit to include every registered scope.
|
|
247
|
+
* @returns Descriptions whose arrays are copied so callers cannot mutate registry state.
|
|
248
|
+
*/
|
|
95
249
|
describe(goals) {
|
|
96
250
|
const selected = goals ? new Set(goals) : undefined;
|
|
97
|
-
return [...this.byId.values()]
|
|
98
|
-
.
|
|
99
|
-
|
|
251
|
+
return [...this.byId.values()]
|
|
252
|
+
.filter((item) => !selected || item.intentIds.some((goal) => selected.has(goal)))
|
|
253
|
+
.map((item) => ({
|
|
254
|
+
...item,
|
|
255
|
+
intentIds: [...item.intentIds],
|
|
256
|
+
queryScopeIds: [...item.queryScopeIds],
|
|
257
|
+
knowledgeTopicIds: [...item.knowledgeTopicIds],
|
|
258
|
+
toolIds: [...item.toolIds],
|
|
259
|
+
aliases: [...item.aliases],
|
|
260
|
+
evidence: [...item.evidence],
|
|
261
|
+
}));
|
|
100
262
|
}
|
|
101
263
|
}
|
|
102
|
-
/**
|
|
264
|
+
/**
|
|
265
|
+
* Create and seal a complete catalog; use the constructor for incremental installation.
|
|
266
|
+
*
|
|
267
|
+
* @param definitions - Scope declarations registered in iteration order.
|
|
268
|
+
* @param policy - Optional registry policy forwarded to the constructor.
|
|
269
|
+
* @returns A sealed registry.
|
|
270
|
+
* @throws A configured error for the first invalid or duplicate declaration.
|
|
271
|
+
*/
|
|
103
272
|
export function createScopeRegistry(definitions, policy = {}) {
|
|
104
273
|
return new ScopeRegistry(policy).registerAll(definitions).seal();
|
|
105
274
|
}
|
|
@@ -1,8 +1,42 @@
|
|
|
1
1
|
import type { Command, CommandDefinition, ProtocolShape } from '../../structs/kits/interaction.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Compile declarations once. Parsing is synchronous and never executes a registered tool.
|
|
4
|
+
*
|
|
5
|
+
* Two schemas are produced from one declaration: `modelJsonSchema` marks only fields the model
|
|
6
|
+
* must fill, while `inputJsonSchema` marks every required field. A discriminator, when present,
|
|
7
|
+
* is prepended as a required constant field.
|
|
8
|
+
*
|
|
9
|
+
* @param definition - Fields, discriminator, checks, tags, error wording and optional
|
|
10
|
+
* formatter; predicates and formatters are bound to this object.
|
|
11
|
+
* @returns A frozen command with `keys`, `assert`, `parse` and the three schemas.
|
|
12
|
+
* @throws TypeError For an unknown category, a duplicate field or discriminator field, a check
|
|
13
|
+
* that still uses the retired `condition`/`conditions` names, or a non-synchronous predicate.
|
|
14
|
+
*/
|
|
3
15
|
export declare function defineCommand<Value extends object = Record<string, unknown>, Result = Value, Args extends unknown[] = []>(definition: CommandDefinition<Value, Result, Args>): Command<Value, Result, Args>;
|
|
4
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Compile a whole catalog with shared envelope fields.
|
|
18
|
+
*
|
|
19
|
+
* Applications declare only their own data and handlers. Defaults are merged in this order:
|
|
20
|
+
* unrelated default keys, then the command's own keys, with `fields`, `checks` and `tags`
|
|
21
|
+
* concatenated so shared envelope checks always run before per-command checks.
|
|
22
|
+
*
|
|
23
|
+
* @param definitions - Commands keyed by their wire id.
|
|
24
|
+
* @param defaults - Shared envelope definition; its discriminator field is removed per command.
|
|
25
|
+
* @returns A frozen record from id to compiled command.
|
|
26
|
+
* @throws TypeError From `defineCommand` for the first invalid declaration.
|
|
27
|
+
*/
|
|
5
28
|
export declare function compileCommands<Value extends object, Result = Value, Args extends unknown[] = [], Id extends string = string>(definitions: Readonly<Record<Id, CommandDefinition<Value, Result, Args>>>, defaults?: Partial<CommandDefinition<Value, Result, Args>>): Readonly<Record<Id, Command<Value, Result, Args>>>;
|
|
6
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Build a JSON schema for one command id.
|
|
31
|
+
*
|
|
32
|
+
* Prefer compiled schemas; retain the existing open-schema contract for dynamic host protocols.
|
|
33
|
+
* A protocol without `fieldSchemas` falls back to an open object that only pins the
|
|
34
|
+
* discriminator, which keeps legacy hosts working without weakening compiled ones.
|
|
35
|
+
*
|
|
36
|
+
* @param id - Command id used as the discriminator value.
|
|
37
|
+
* @param protocol - Compiled command, or a shape carrying only `fieldSchemas`/`keys`.
|
|
38
|
+
* @param discriminator - Field name carrying the command id; defaults to `type`.
|
|
39
|
+
* @returns The compiled model schema, or a generated open schema.
|
|
40
|
+
*/
|
|
7
41
|
export declare function commandSchema(id: string, protocol: ProtocolShape, discriminator?: string): Record<string, unknown>;
|
|
8
|
-
export type { Command, CommandDefinition, ProtocolCheck, ProtocolField, ProtocolReason, ProtocolPredicate, ProtocolShape, RegisteredProtocol } from '../../structs/kits/interaction.js';
|
|
42
|
+
export type { Command, CommandDefinition, ProtocolCheck, ProtocolField, ProtocolReason, ProtocolPredicate, ProtocolShape, RegisteredProtocol, } from '../../structs/kits/interaction.js';
|