@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,34 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool definition, execution and registry contracts.
|
|
3
|
+
*
|
|
4
|
+
* A tool declares its model-visible schema, a host authorization step and one execution unit. The
|
|
5
|
+
* registry binds an App context, validates input/output at the boundary and produces receipts, so
|
|
6
|
+
* individual tools never handle transportation, budget accounting or event emission.
|
|
7
|
+
*
|
|
8
|
+
* Exports: `ToolDefinition`, `ToolExecutionContext`, `ExecutableTool`, `RegisteredTool`,
|
|
9
|
+
* `ToolExecutionEvent`, `ToolRegistryPorts`, `ToolInvocationRequest`, `ToolRegistryOptions`.
|
|
10
|
+
*/
|
|
1
11
|
import type { InvocationMetadata } from '../invocation.js';
|
|
2
12
|
import type { ExecutionContext, MaybePromise, OperationContext, SchemaAdapter } from '../common.js';
|
|
3
13
|
import type { DiagnosticContext } from '../diagnostics.js';
|
|
4
14
|
import type { RegistrationProjection } from '../../utils/registration.js';
|
|
5
15
|
import type { NodeReportingContext } from '../debug.js';
|
|
16
|
+
/** One registered tool, typed by its input, output, host context and id literal. */
|
|
6
17
|
export interface ToolDefinition<Input = unknown, Output = unknown, App = unknown, Id extends string = string> {
|
|
18
|
+
/** Stable id; also the name the model calls. */
|
|
7
19
|
readonly id: Id;
|
|
20
|
+
/** Declared grouping used by registries and documentation; not an authorization boundary. */
|
|
8
21
|
readonly kind: string;
|
|
22
|
+
/** Model-visible explanation of when to call the tool. */
|
|
9
23
|
readonly description: string;
|
|
24
|
+
/** Schema applied to raw model arguments before `authorize` and `execute`. */
|
|
10
25
|
readonly inputSchema: SchemaAdapter<Input>;
|
|
26
|
+
/** Host permission check. Runs before execution and may be asynchronous. */
|
|
11
27
|
authorize(input: Input, context: OperationContext<App>): MaybePromise<void>;
|
|
28
|
+
/** Executes the already-authorized input; must not repeat authorization decisions. */
|
|
12
29
|
execute(input: Input, context: OperationContext<App> & import('../debug.js').NodeReportingContext): MaybePromise<Output>;
|
|
30
|
+
/** Optional reporting hook that turns the result into self-reported sub-steps. */
|
|
13
31
|
debugSteps?(result: Output, context: import('../debug.js').NodeReportingContext): import('../debug.js').SubFlowLogger;
|
|
32
|
+
/** Validates untrusted output (for example a cached replay) before it is returned. */
|
|
14
33
|
parseOutput(value: unknown): Output;
|
|
15
34
|
}
|
|
35
|
+
/** Execution facts handed to a tool for one invocation. */
|
|
16
36
|
export interface ToolExecutionContext extends ExecutionContext, NodeReportingContext {
|
|
37
|
+
/** Diagnostic scope of the invocation, when recording is enabled. */
|
|
17
38
|
readonly diagnostics?: DiagnosticContext;
|
|
39
|
+
/** Declared execution discipline; mirrors whether the registry accepted an async tool. */
|
|
18
40
|
readonly mode: 'sync' | 'async';
|
|
41
|
+
/** Opaque invocation id shared by receipt, events and diagnostics. */
|
|
19
42
|
readonly invocationId: string;
|
|
43
|
+
/** Non-optional cancellation for this invocation. */
|
|
20
44
|
readonly signal: AbortSignal;
|
|
21
45
|
}
|
|
46
|
+
/** Type-erased tool shape the registry executes after parsing at the boundary. */
|
|
22
47
|
export interface ExecutableTool {
|
|
23
48
|
readonly id: string;
|
|
24
49
|
readonly kind: string;
|
|
50
|
+
/** Optional here because the erased view does not require model-facing prose. */
|
|
25
51
|
readonly description?: string;
|
|
26
52
|
readonly debugSteps?: (result: unknown, context: NodeReportingContext) => import('../debug.js').SubFlowLogger;
|
|
27
53
|
parseInput(value: unknown): unknown;
|
|
28
54
|
parseOutput(value: unknown): unknown;
|
|
29
55
|
execute(input: unknown, context: ToolExecutionContext): unknown;
|
|
30
56
|
}
|
|
57
|
+
/** Registered snapshot: public data is retained, implementation helpers are not a contract. */
|
|
31
58
|
export type RegisteredTool<Tool extends ExecutableTool = ExecutableTool> = RegistrationProjection<Tool, ExecutableTool>;
|
|
59
|
+
/** Fact emitted when one tool call settles, correlated by `invocationId`. */
|
|
32
60
|
export interface ToolExecutionEvent<Kind extends string = string> extends InvocationMetadata {
|
|
33
61
|
toolId: string;
|
|
34
62
|
/** Opaque identity shared by result and diagnostic records; not an App message ID. */
|
|
@@ -36,22 +64,32 @@ export interface ToolExecutionEvent<Kind extends string = string> extends Invoca
|
|
|
36
64
|
kind: Kind;
|
|
37
65
|
durationMs: number;
|
|
38
66
|
status: import('../common.js').InvocationStatus;
|
|
67
|
+
/** Error classification when the call failed. */
|
|
39
68
|
errorCode?: string;
|
|
40
69
|
}
|
|
70
|
+
/** Host ports a tool registry needs in addition to the tool definitions. */
|
|
41
71
|
export interface ToolRegistryPorts {
|
|
42
72
|
/** Request lifetime; late external results cannot become successful receipts. */
|
|
43
73
|
signal?: AbortSignal;
|
|
44
74
|
diagnostics?: DiagnosticContext;
|
|
75
|
+
/** Builds the error for a tool id that is not available in this request. */
|
|
45
76
|
unavailable?(name: string): Error;
|
|
77
|
+
/** Maps an arbitrary thrown value to a stable error code for events. */
|
|
46
78
|
errorCode?(error: unknown): string;
|
|
47
79
|
}
|
|
80
|
+
/** One invocation request; the registry supplies signal and diagnostics when omitted. */
|
|
48
81
|
export interface ToolInvocationRequest<Id extends string = string> {
|
|
49
82
|
readonly toolId: Id;
|
|
83
|
+
/** Raw model arguments; parsed by the tool's input schema before authorization. */
|
|
50
84
|
readonly input: unknown;
|
|
85
|
+
/** Per-call cancellation; can only shorten the surrounding execution lifetime. */
|
|
51
86
|
readonly signal?: AbortSignal;
|
|
52
87
|
readonly diagnostics?: DiagnosticContext;
|
|
53
88
|
}
|
|
89
|
+
/** Registry construction options. */
|
|
54
90
|
export interface ToolRegistryOptions {
|
|
91
|
+
/** Execution defaults applied to invocations that do not pass their own. */
|
|
55
92
|
readonly execution?: import('../common.js').ExecutionOptions;
|
|
93
|
+
/** Error factories shared by every tool in the registry. */
|
|
56
94
|
readonly errors?: Pick<ToolRegistryPorts, 'unavailable' | 'errorCode'>;
|
|
57
95
|
}
|
|
@@ -1,58 +1,118 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Package-wide vocabulary shared by every agent-core contract.
|
|
3
|
+
*
|
|
4
|
+
* These aliases and envelopes are the neutral layer between App-owned business types and the
|
|
5
|
+
* Core runtime modules: identifiers stay opaque, application identities are deliberately absent,
|
|
6
|
+
* and every catalog or result shape is read-only so a registered snapshot cannot be mutated later.
|
|
7
|
+
*
|
|
8
|
+
* Exports: `Id`, `TimestampMs`, `DurationMs`, `Observer`, `AsyncSink`, `InvocationStatus`,
|
|
9
|
+
* `JsonSchema`, `MaybePromise`, `SchemaAdapter`, `Issue`, `CheckResult`, `ReadonlyCatalog`,
|
|
10
|
+
* `Registry`, `ExecutionOptions`, `ExecutionContext`, `OperationContext`, `SearchHit`.
|
|
11
|
+
*/
|
|
12
|
+
/** Opaque identifier. Format and meaning belong to the App or to the registering module. */
|
|
2
13
|
export type Id = string;
|
|
14
|
+
/** Wall-clock instant in milliseconds since the Unix epoch. */
|
|
3
15
|
export type TimestampMs = number;
|
|
16
|
+
/** Elapsed time in milliseconds; never an absolute instant. */
|
|
4
17
|
export type DurationMs = number;
|
|
18
|
+
/** Notification callback. A rejected promise propagates to the emitter. */
|
|
5
19
|
export type Observer<Event> = (event: Readonly<Event>) => void | Promise<void>;
|
|
20
|
+
/** Awaitable sink for an ordered stream. A rejection propagates to the emitter. */
|
|
6
21
|
export type AsyncSink<Event> = (event: Readonly<Event>) => Promise<void>;
|
|
22
|
+
/** Terminal state of one invocation; `cancelled` is distinct from a failure. */
|
|
7
23
|
export type InvocationStatus = 'success' | 'error' | 'cancelled';
|
|
24
|
+
/** JSON Schema as consumed by the App's validator; Core never interprets its contents. */
|
|
8
25
|
export type JsonSchema = Readonly<Record<string, unknown>>;
|
|
26
|
+
/** A value that may already be resolved or still pending. */
|
|
9
27
|
export type MaybePromise<Value> = Value | Promise<Value>;
|
|
28
|
+
/** Compiled schema pair: the JSON form shown to the model and the runtime parser. */
|
|
10
29
|
export interface SchemaAdapter<Value = unknown> {
|
|
30
|
+
/** Schema advertised to the model and used for documentation. */
|
|
11
31
|
readonly jsonSchema: JsonSchema;
|
|
32
|
+
/** Validates or coerces untrusted input into `Value`; throws when the input is invalid. */
|
|
12
33
|
parse(input: unknown): Value;
|
|
13
34
|
}
|
|
35
|
+
/** One validation problem, locatable by code and, when available, by field path. */
|
|
14
36
|
export interface Issue {
|
|
37
|
+
/** Stable machine-readable reason code; the primary key for programmatic handling. */
|
|
15
38
|
readonly code: string;
|
|
39
|
+
/** Human-readable description; not guaranteed stable for matching. */
|
|
16
40
|
readonly message: string;
|
|
41
|
+
/** Path of the offending field inside the checked value, outermost segment first. */
|
|
17
42
|
readonly path?: readonly (string | number)[];
|
|
43
|
+
/** Registered check that produced the issue, when the check belongs to a catalog. */
|
|
18
44
|
readonly checkId?: string;
|
|
19
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Verdict of one registered check.
|
|
48
|
+
*
|
|
49
|
+
* `unavailable` and `not-run` are not verdicts on the value: they state that the check could not
|
|
50
|
+
* produce an answer, so callers must not treat them as failures.
|
|
51
|
+
*/
|
|
20
52
|
export interface CheckResult<Value = never> {
|
|
21
53
|
readonly status: 'passed' | 'failed' | 'unavailable' | 'not-run';
|
|
54
|
+
/** Problems found; expected to be empty when the status is `passed`. */
|
|
22
55
|
readonly issues: readonly Issue[];
|
|
56
|
+
/** Checked or produced value; present only when the check yields one. */
|
|
23
57
|
readonly value?: Value;
|
|
24
58
|
}
|
|
59
|
+
/** Read-only projection of a definition set; the implementation owns ordering and validation. */
|
|
25
60
|
export interface ReadonlyCatalog<Definition extends {
|
|
26
61
|
readonly id: string;
|
|
27
62
|
}> {
|
|
63
|
+
/** Definitions in registration order; each entry is frozen by the implementation. */
|
|
28
64
|
readonly definitions: readonly Readonly<Definition>[];
|
|
65
|
+
/** Ids in the same order as `definitions`. */
|
|
29
66
|
ids(): readonly string[];
|
|
30
67
|
values(): IterableIterator<Readonly<Definition>>;
|
|
31
68
|
entries(): IterableIterator<readonly [string, Readonly<Definition>]>;
|
|
32
69
|
has(id: string): boolean;
|
|
70
|
+
/** Returns the definition or `undefined`; the caller decides whether absence is an error. */
|
|
33
71
|
get(id: string): Readonly<Definition> | undefined;
|
|
72
|
+
/** Returns the definition or throws; use when the id is a required reference. */
|
|
34
73
|
require(id: string): Readonly<Definition>;
|
|
35
74
|
}
|
|
75
|
+
/** Mutable catalog. Registrations append; `seal` freezes the set against later writes. */
|
|
36
76
|
export interface Registry<Definition extends {
|
|
37
77
|
readonly id: string;
|
|
38
78
|
}> extends ReadonlyCatalog<Definition> {
|
|
79
|
+
/** Adds one definition; implementations reject blank or duplicate ids. */
|
|
39
80
|
register(definition: Definition): this;
|
|
40
81
|
registerAll(definitions: Iterable<Definition>): this;
|
|
82
|
+
/** Rejects every later registration on this instance. */
|
|
41
83
|
seal(): this;
|
|
42
84
|
}
|
|
85
|
+
/** Optional controls accepted by any public Core call. */
|
|
43
86
|
export interface ExecutionOptions {
|
|
87
|
+
/** Cancellation for the whole call; children must not extend it. */
|
|
44
88
|
readonly signal?: AbortSignal;
|
|
89
|
+
/** Diagnostic scope that records the call; omission disables recording. */
|
|
45
90
|
readonly diagnostics?: import('./diagnostics.js').DiagnosticContext;
|
|
91
|
+
/** Live observation of the same facts that diagnostics would record. */
|
|
46
92
|
readonly observe?: import('./execution/events.js').ExecutionObserver;
|
|
47
93
|
}
|
|
94
|
+
/** Required execution facts available inside a running call. */
|
|
48
95
|
export interface ExecutionContext {
|
|
96
|
+
/** Non-optional cancellation signal; never `undefined` once execution has started. */
|
|
49
97
|
readonly signal: AbortSignal;
|
|
98
|
+
/** Diagnostic scope of the enclosing call, when recording is enabled. */
|
|
50
99
|
readonly diagnostics?: import('./diagnostics.js').DiagnosticContext;
|
|
51
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Execution context plus the App-owned host object.
|
|
103
|
+
*
|
|
104
|
+
* `app` carries services, identity and per-request dependencies supplied by the host; Core treats
|
|
105
|
+
* it as opaque and must not depend on application-specific fields.
|
|
106
|
+
*/
|
|
52
107
|
export interface OperationContext<App = unknown> extends ExecutionContext {
|
|
53
108
|
readonly app: Readonly<App>;
|
|
54
109
|
}
|
|
55
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* One search result.
|
|
112
|
+
*
|
|
113
|
+
* `score` semantics stay algorithm-specific (direction and scale are not part of this contract),
|
|
114
|
+
* and `document` may be a projection that only exposes stored fields rather than the full record.
|
|
115
|
+
*/
|
|
56
116
|
export interface SearchHit<Document> {
|
|
57
117
|
readonly id: string;
|
|
58
118
|
readonly score: number;
|
|
@@ -1 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-wide vocabulary shared by every agent-core contract.
|
|
3
|
+
*
|
|
4
|
+
* These aliases and envelopes are the neutral layer between App-owned business types and the
|
|
5
|
+
* Core runtime modules: identifiers stay opaque, application identities are deliberately absent,
|
|
6
|
+
* and every catalog or result shape is read-only so a registered snapshot cannot be mutated later.
|
|
7
|
+
*
|
|
8
|
+
* Exports: `Id`, `TimestampMs`, `DurationMs`, `Observer`, `AsyncSink`, `InvocationStatus`,
|
|
9
|
+
* `JsonSchema`, `MaybePromise`, `SchemaAdapter`, `Issue`, `CheckResult`, `ReadonlyCatalog`,
|
|
10
|
+
* `Registry`, `ExecutionOptions`, `ExecutionContext`, `OperationContext`, `SearchHit`.
|
|
11
|
+
*/
|
|
1
12
|
export {};
|
|
@@ -1,26 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context fragment contract: the unit of model-visible input assembled by Core.
|
|
3
|
+
*
|
|
4
|
+
* Fragments carry both content and provenance. Trust and lifetime are declarations by the
|
|
5
|
+
* producing module, while `maxChars` is enforced when the fragment is formatted and counted into
|
|
6
|
+
* the shared input budget. A system-role fragment may only carry trusted string content.
|
|
7
|
+
*
|
|
8
|
+
* Exports: `ContextTrust`, `ContextLifetime`, `ContextFragment`, `ContextFragmentUsage`,
|
|
9
|
+
* `BuiltContext`.
|
|
10
|
+
*/
|
|
1
11
|
import type { ModelMessage } from '../model/messages.js';
|
|
12
|
+
/** Who produced the content, and therefore how much it may influence the model. */
|
|
2
13
|
export type ContextTrust = 'instruction' | 'server' | 'user' | 'tool';
|
|
14
|
+
/** Declared validity window of a fragment's content. */
|
|
3
15
|
export type ContextLifetime = 'configuration' | 'turn' | 'step';
|
|
16
|
+
/** One piece of model-visible input before assembly. */
|
|
4
17
|
export interface ContextFragment {
|
|
18
|
+
/** Unique, stable id matching `^[a-z][a-zA-Z0-9:._-]*$`; duplicates are rejected. */
|
|
5
19
|
id: string;
|
|
20
|
+
/** Owning source (module or registration) used to explain where the content came from. */
|
|
6
21
|
sourceId: string;
|
|
22
|
+
/** Producer trust level. `user` and `tool` content cannot become a system message. */
|
|
7
23
|
trust: ContextTrust;
|
|
24
|
+
/** Declared validity window of this content. */
|
|
8
25
|
lifetime: ContextLifetime;
|
|
26
|
+
/** Hard upper bound in JSON characters; must be a positive safe integer. */
|
|
9
27
|
maxChars: number;
|
|
28
|
+
/** Message slot the fragment occupies when assembled. */
|
|
10
29
|
role: 'system' | 'user';
|
|
30
|
+
/** Rendered content. A system message accepts a string only, never a record. */
|
|
11
31
|
value: string | Record<string, unknown>;
|
|
12
32
|
}
|
|
33
|
+
/** Accounting entry reported for one fragment that actually entered the context. */
|
|
13
34
|
export interface ContextFragmentUsage {
|
|
14
35
|
id: string;
|
|
15
36
|
sourceId: string;
|
|
16
37
|
trust: ContextTrust;
|
|
17
38
|
lifetime: ContextLifetime;
|
|
39
|
+
/** Characters consumed after formatting. */
|
|
18
40
|
chars: number;
|
|
41
|
+
/** Budget that applied to this fragment. */
|
|
19
42
|
maxChars: number;
|
|
20
43
|
}
|
|
44
|
+
/** Assembled context plus the accounting needed to explain the budget decision. */
|
|
21
45
|
export interface BuiltContext {
|
|
46
|
+
/** Messages in final model order. */
|
|
22
47
|
messages: ModelMessage[];
|
|
48
|
+
/** Per-fragment accounting in the same order as the fragments were merged. */
|
|
23
49
|
fragmentUsage: ContextFragmentUsage[];
|
|
50
|
+
/** Total counted characters across messages and usage. */
|
|
24
51
|
inputChars: number;
|
|
52
|
+
/** Budget the assembly was validated against; `Infinity` means unbounded. */
|
|
25
53
|
maxInputChars: number;
|
|
26
54
|
}
|
|
@@ -1,18 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request journal contract: the ordered record of what one request actually did.
|
|
3
|
+
*
|
|
4
|
+
* A journal is request-local. It records model and tool facts with a monotonic sequence so an App
|
|
5
|
+
* can rebuild context or receipts without reading Core diagnostics; the record payloads are opaque
|
|
6
|
+
* to Core.
|
|
7
|
+
*
|
|
8
|
+
* Exports: `ContextRecord`.
|
|
9
|
+
*/
|
|
1
10
|
import type { InvocationMetadata } from '../invocation.js';
|
|
11
|
+
/** Identity every journal record carries, in addition to its type-specific fields. */
|
|
2
12
|
type RecordIdentity = InvocationMetadata & {
|
|
13
|
+
/** Invocation that produced the record. */
|
|
3
14
|
readonly invocationId: string;
|
|
15
|
+
/** Monotonic order within this journal; starts at 1 and never repeats. */
|
|
4
16
|
readonly producerSequence: number;
|
|
17
|
+
/** Instant the record was written, in epoch milliseconds. */
|
|
5
18
|
readonly occurredAtMs: number;
|
|
6
19
|
};
|
|
7
|
-
|
|
20
|
+
/**
|
|
21
|
+
* One journal entry: a model call, a tool request or a tool result.
|
|
22
|
+
*
|
|
23
|
+
* The three variants are distinguished by `type`; `value`/`input` stay `unknown` because their
|
|
24
|
+
* domain meaning belongs to the App.
|
|
25
|
+
*/
|
|
26
|
+
export type ContextRecord = RecordIdentity &
|
|
27
|
+
/** A model call was made for `stageId`; `value` is what the call produced. */
|
|
28
|
+
({
|
|
8
29
|
readonly type: 'model';
|
|
9
30
|
readonly stageId: string;
|
|
10
31
|
readonly value: unknown;
|
|
11
|
-
}
|
|
32
|
+
}
|
|
33
|
+
/** A tool call was requested; `input` is the raw request payload. */
|
|
34
|
+
| {
|
|
12
35
|
readonly type: 'tool';
|
|
13
36
|
readonly toolId: string;
|
|
14
37
|
readonly input: unknown;
|
|
15
|
-
}
|
|
38
|
+
}
|
|
39
|
+
/** A tool call settled; `value` carries the result or the failure detail. */
|
|
40
|
+
| {
|
|
16
41
|
readonly type: 'tool-result';
|
|
17
42
|
readonly toolId: string;
|
|
18
43
|
readonly status: 'success' | 'error' | 'cancelled';
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context plan contract: the unassembled input handed to the Core budget boundary.
|
|
3
|
+
*
|
|
4
|
+
* App-side nodes may still process a plan (mutate declared fragments, add protected messages)
|
|
5
|
+
* before Core assembles and validates it. The plan therefore separates sendable content from the
|
|
6
|
+
* trusted originals used to audit structural mutation.
|
|
7
|
+
*
|
|
8
|
+
* Exports: `ContextPlan`.
|
|
9
|
+
*/
|
|
1
10
|
import type { ContextFragment } from './fragments.js';
|
|
2
11
|
import type { ModelMessage } from '../model/messages.js';
|
|
3
12
|
/** Unassembled input; App-side nodes may process it before the Core budget boundary. */
|
|
4
13
|
export interface ContextPlan {
|
|
14
|
+
/** Fragments in the order supplied by the App; assembly preserves it. */
|
|
5
15
|
readonly fragments: readonly ContextFragment[];
|
|
16
|
+
/** Character budget Core validates after assembly. */
|
|
6
17
|
maxInputChars: number;
|
|
7
18
|
/** Protected user messages (for example image inputs); text counts toward the same budget. */
|
|
8
19
|
additionalMessages?: readonly (ModelMessage & {
|
|
@@ -1,13 +1,33 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Self-reported execution detail supplied by App nodes and tools.
|
|
3
|
+
*
|
|
4
|
+
* The data here is optional evidence of what an App chose to report, never proof that Core
|
|
5
|
+
* performed the work, and it is collected only through the diagnostic context that owns the
|
|
6
|
+
* current node visit. The status catalog below is the single source of truth for legal reported
|
|
7
|
+
* statuses, their terminal flag and the transitions that `fix` may apply.
|
|
8
|
+
*
|
|
9
|
+
* Exports: `reportedStepStatusCatalog`, `reportedStepStatuses`, `ReportedStepStatus`,
|
|
10
|
+
* `ReportedStep`, `SubFlowValue`, `RecordedSubStep`, `SubFlowStepInput`, `SubFlowStepFix`,
|
|
11
|
+
* `SubFlowLogger`, `NodeReportingContext`, `SubStepProgress`, `DebugStepsOutput`.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Legal self-reported step statuses and their transitions.
|
|
15
|
+
*
|
|
16
|
+
* `terminal: true` means the step is finished and its status can no longer change; `next` lists the
|
|
17
|
+
* statuses a later `fix` may assign to a non-terminal step.
|
|
18
|
+
*/
|
|
2
19
|
export declare const reportedStepStatusCatalog: {
|
|
20
|
+
/** No status reported yet; only `fix` uses this as an intermediate state. */
|
|
3
21
|
readonly unknown: {
|
|
4
22
|
readonly terminal: false;
|
|
5
23
|
readonly next: readonly ["unknown", "planned", "running", "success", "error", "cancelled", "skipped"];
|
|
6
24
|
};
|
|
25
|
+
/** Declared by the node but not started. */
|
|
7
26
|
readonly planned: {
|
|
8
27
|
readonly terminal: false;
|
|
9
28
|
readonly next: readonly ["planned", "running", "success", "error", "cancelled", "skipped"];
|
|
10
29
|
};
|
|
30
|
+
/** Started and still active; may only stay running or finish. */
|
|
11
31
|
readonly running: {
|
|
12
32
|
readonly terminal: false;
|
|
13
33
|
readonly next: readonly ["running", "success", "error", "cancelled"];
|
|
@@ -29,38 +49,59 @@ export declare const reportedStepStatusCatalog: {
|
|
|
29
49
|
readonly next: readonly [];
|
|
30
50
|
};
|
|
31
51
|
};
|
|
52
|
+
/** Frozen list of reported statuses in catalog order, used for membership validation. */
|
|
32
53
|
export declare const reportedStepStatuses: readonly (keyof typeof reportedStepStatusCatalog)[];
|
|
54
|
+
/** A status a node may report; derived from the catalog, never declared separately. */
|
|
33
55
|
export type ReportedStepStatus = keyof typeof reportedStepStatusCatalog;
|
|
56
|
+
/** One step as reported by a node; fields beyond identity are optional detail. */
|
|
34
57
|
export interface ReportedStep {
|
|
58
|
+
/** Step identity, unique within one node visit. */
|
|
35
59
|
readonly stepId: string;
|
|
60
|
+
/** Reported parent step, forming a tree; absent for a top-level step. */
|
|
36
61
|
readonly parentStepId?: string;
|
|
37
62
|
/** Self-reported reference only; never a workflow dispatch identity. */
|
|
38
63
|
readonly relatedDefinitionId?: string;
|
|
64
|
+
/** Short reported label. */
|
|
39
65
|
readonly name: string;
|
|
66
|
+
/** Reported step kind (for example a tool or model call); free-form and node-owned. */
|
|
40
67
|
readonly kind: string;
|
|
68
|
+
/** Reported lifecycle status; omission means the node did not report one. */
|
|
41
69
|
readonly status?: ReportedStepStatus;
|
|
42
70
|
/** This step's own reported model use, never a descendant rollup. */
|
|
43
71
|
readonly usedModel?: boolean;
|
|
72
|
+
/** Reported start instant in epoch milliseconds. */
|
|
44
73
|
readonly startedAtMs?: number;
|
|
74
|
+
/** Reported end instant in epoch milliseconds; only meaningful for terminal statuses. */
|
|
45
75
|
readonly endedAtMs?: number;
|
|
76
|
+
/** Reported successor step ids, for display only. */
|
|
46
77
|
readonly nextStepIds?: readonly string[];
|
|
78
|
+
/** Reported case or variant id, interpreted by the App. */
|
|
47
79
|
readonly caseId?: string;
|
|
80
|
+
/** Reported one-line summary. */
|
|
48
81
|
readonly summary?: string;
|
|
49
82
|
}
|
|
83
|
+
/** JSON-like value accepted in reported payloads; depth and size are bounded by the recorder. */
|
|
50
84
|
export type SubFlowValue = null | boolean | number | string | readonly SubFlowValue[] | {
|
|
51
85
|
readonly [key: string]: SubFlowValue;
|
|
52
86
|
};
|
|
87
|
+
/** A step already accepted by a logger, carrying recorder-assigned bookkeeping fields. */
|
|
53
88
|
export interface RecordedSubStep extends ReportedStep {
|
|
89
|
+
/** Historical marker: only self-reported steps are recorded. */
|
|
54
90
|
readonly origin: 'reported';
|
|
91
|
+
/** One-based write order within the node visit. */
|
|
55
92
|
readonly sequence: number;
|
|
56
93
|
/** Optional only for historical records produced before the logger contract. */
|
|
57
94
|
readonly createdAtMs?: number;
|
|
95
|
+
/** Revision number, incremented by each accepted `fix`. */
|
|
58
96
|
readonly revision?: number;
|
|
97
|
+
/** Reported payload; the recorder snapshots it and bounds the total size. */
|
|
59
98
|
readonly payload?: Readonly<Record<string, SubFlowValue>>;
|
|
60
99
|
}
|
|
100
|
+
/** Input accepted by `write`; the logger assigns the step id and sequence. */
|
|
61
101
|
export interface SubFlowStepInput extends Omit<ReportedStep, 'stepId'> {
|
|
62
102
|
readonly payload?: Readonly<Record<string, SubFlowValue>>;
|
|
63
103
|
}
|
|
104
|
+
/** Fields a later `fix` may change on an already written step. */
|
|
64
105
|
export interface SubFlowStepFix {
|
|
65
106
|
readonly status?: ReportedStepStatus;
|
|
66
107
|
readonly usedModel?: boolean;
|
|
@@ -74,27 +115,43 @@ export interface SubFlowStepFix {
|
|
|
74
115
|
declare const subFlowLoggerBrand: unique symbol;
|
|
75
116
|
/** Execution-owned instance. Obtain it from the active node/tool context. */
|
|
76
117
|
export interface SubFlowLogger {
|
|
118
|
+
/** Brand makes structural lookalikes incompatible with the recorder's own instance. */
|
|
77
119
|
readonly [subFlowLoggerBrand]: true;
|
|
120
|
+
/** Appends one step and returns its assigned step id. */
|
|
78
121
|
write(input: SubFlowStepInput): string;
|
|
122
|
+
/** Applies a partial update; illegal status transitions and replacements are rejected. */
|
|
79
123
|
fix(stepId: string, patch: SubFlowStepFix): void;
|
|
124
|
+
/** Snapshot of the steps recorded so far, in write order. */
|
|
80
125
|
readAll(): readonly Readonly<RecordedSubStep>[];
|
|
81
126
|
}
|
|
127
|
+
/** Reporting surface handed to a node or tool for the duration of one visit. */
|
|
82
128
|
export interface NodeReportingContext {
|
|
129
|
+
/** Reports progress for the active node; Core supplies the execution identity. */
|
|
83
130
|
report(update: import('./execution/workflow.js').WorkflowNodeReport): void;
|
|
84
131
|
/** One logger per node visit; repeated calls return the same instance. */
|
|
85
132
|
createSubFlowLogger(): SubFlowLogger;
|
|
86
133
|
}
|
|
134
|
+
/** Compact progress notification emitted for each accepted sub-step write or fix. */
|
|
87
135
|
export interface SubStepProgress {
|
|
88
136
|
readonly operation: 'write' | 'fix';
|
|
137
|
+
/** Step the operation applied to. */
|
|
89
138
|
readonly stepId: string;
|
|
139
|
+
/** Write sequence of that step within the node visit. */
|
|
90
140
|
readonly sequence: number;
|
|
141
|
+
/** Revision after the operation; `write` starts at 1. */
|
|
91
142
|
readonly revision: number;
|
|
143
|
+
/** Instant the progress fact was recorded, in epoch milliseconds. */
|
|
92
144
|
readonly createdAtMs: number;
|
|
145
|
+
/** Status after the operation. */
|
|
93
146
|
readonly status: ReportedStepStatus;
|
|
147
|
+
/** Reported model use after the operation, when the node stated it. */
|
|
94
148
|
readonly usedModel?: boolean;
|
|
95
149
|
}
|
|
150
|
+
/** Debug material a handler contributes to a diagnostic event. */
|
|
96
151
|
export interface DebugStepsOutput {
|
|
152
|
+
/** Model use reported by this handler; omitted when unknown. */
|
|
97
153
|
readonly usedModel?: boolean;
|
|
154
|
+
/** Accessor invoked at emit time so recording can be skipped when disabled. */
|
|
98
155
|
readonly subSteps?: () => SubFlowLogger | undefined;
|
|
99
156
|
}
|
|
100
157
|
export {};
|
|
@@ -1,9 +1,38 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Self-reported execution detail supplied by App nodes and tools.
|
|
3
|
+
*
|
|
4
|
+
* The data here is optional evidence of what an App chose to report, never proof that Core
|
|
5
|
+
* performed the work, and it is collected only through the diagnostic context that owns the
|
|
6
|
+
* current node visit. The status catalog below is the single source of truth for legal reported
|
|
7
|
+
* statuses, their terminal flag and the transitions that `fix` may apply.
|
|
8
|
+
*
|
|
9
|
+
* Exports: `reportedStepStatusCatalog`, `reportedStepStatuses`, `ReportedStepStatus`,
|
|
10
|
+
* `ReportedStep`, `SubFlowValue`, `RecordedSubStep`, `SubFlowStepInput`, `SubFlowStepFix`,
|
|
11
|
+
* `SubFlowLogger`, `NodeReportingContext`, `SubStepProgress`, `DebugStepsOutput`.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Legal self-reported step statuses and their transitions.
|
|
15
|
+
*
|
|
16
|
+
* `terminal: true` means the step is finished and its status can no longer change; `next` lists the
|
|
17
|
+
* statuses a later `fix` may assign to a non-terminal step.
|
|
18
|
+
*/
|
|
2
19
|
export const reportedStepStatusCatalog = {
|
|
3
|
-
|
|
4
|
-
|
|
20
|
+
/** No status reported yet; only `fix` uses this as an intermediate state. */
|
|
21
|
+
unknown: {
|
|
22
|
+
terminal: false,
|
|
23
|
+
next: ['unknown', 'planned', 'running', 'success', 'error', 'cancelled', 'skipped'],
|
|
24
|
+
},
|
|
25
|
+
/** Declared by the node but not started. */
|
|
26
|
+
planned: {
|
|
27
|
+
terminal: false,
|
|
28
|
+
next: ['planned', 'running', 'success', 'error', 'cancelled', 'skipped'],
|
|
29
|
+
},
|
|
30
|
+
/** Started and still active; may only stay running or finish. */
|
|
5
31
|
running: { terminal: false, next: ['running', 'success', 'error', 'cancelled'] },
|
|
6
|
-
success: { terminal: true, next: [] },
|
|
7
|
-
|
|
32
|
+
success: { terminal: true, next: [] },
|
|
33
|
+
error: { terminal: true, next: [] },
|
|
34
|
+
cancelled: { terminal: true, next: [] },
|
|
35
|
+
skipped: { terminal: true, next: [] },
|
|
8
36
|
};
|
|
37
|
+
/** Frozen list of reported statuses in catalog order, used for membership validation. */
|
|
9
38
|
export const reportedStepStatuses = Object.freeze(Object.keys(reportedStepStatusCatalog));
|