@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,27 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Invocation identity and success receipts.
|
|
3
|
+
*
|
|
4
|
+
* Every Core-initiated model call or tool call returns its value together with the metadata that
|
|
5
|
+
* identifies the invocation, so callers can correlate results with diagnostics without parsing
|
|
6
|
+
* logs. These records describe completed calls only; failures surface as thrown errors.
|
|
7
|
+
*
|
|
8
|
+
* Exports: `InvocationMetadata`, `InvocationResult`, `ModelCallRecord`, `ToolCallRecord`,
|
|
9
|
+
* `ModelResult`, `ToolResult`.
|
|
10
|
+
*/
|
|
1
11
|
import type { ModelUsage } from './model/messages.js';
|
|
12
|
+
/** Identity and timing shared by every invocation receipt. */
|
|
2
13
|
export interface InvocationMetadata {
|
|
14
|
+
/** Root run this invocation belongs to, when the host runs inside a diagnostics scope. */
|
|
3
15
|
readonly runId?: string;
|
|
16
|
+
/** Diagnostics span of this invocation. */
|
|
4
17
|
readonly spanId?: string;
|
|
18
|
+
/** Span that caused this invocation; absent for a root invocation. */
|
|
5
19
|
readonly parentSpanId?: string;
|
|
20
|
+
/** Enclosing invocation when one call triggers another. */
|
|
6
21
|
readonly parentInvocationId?: string;
|
|
22
|
+
/** Opaque per-invocation id shared by receipt, events and diagnostic records. */
|
|
7
23
|
readonly invocationId: string;
|
|
24
|
+
/** Start instant in epoch milliseconds. */
|
|
8
25
|
readonly startedAtMs: number;
|
|
26
|
+
/** Elapsed milliseconds from start to completion. */
|
|
9
27
|
readonly durationMs: number;
|
|
10
28
|
}
|
|
29
|
+
/** A produced value together with the receipt of the invocation that produced it. */
|
|
11
30
|
export interface InvocationResult<Value, Metadata extends InvocationMetadata = InvocationMetadata> {
|
|
12
31
|
readonly value: Value;
|
|
13
32
|
readonly invocation: Readonly<Metadata>;
|
|
14
33
|
}
|
|
34
|
+
/** Receipt of a model call that returned successfully. */
|
|
15
35
|
export interface ModelCallRecord extends InvocationMetadata {
|
|
36
|
+
/** Records are only emitted for successful calls; failures are thrown instead. */
|
|
16
37
|
readonly status: 'success';
|
|
38
|
+
/** Workflow stage that requested the call. */
|
|
17
39
|
readonly stageId?: string;
|
|
40
|
+
/** Configured model binding used for the call. */
|
|
18
41
|
readonly modelId?: string;
|
|
42
|
+
/** One-based position of the call within its runner's lifetime. */
|
|
19
43
|
readonly callSequence: number;
|
|
44
|
+
/** Provider-reported token usage; present only when the provider supplied it. */
|
|
20
45
|
readonly usage?: Readonly<ModelUsage>;
|
|
21
46
|
}
|
|
47
|
+
/** Receipt of a tool call that returned successfully. */
|
|
22
48
|
export interface ToolCallRecord extends InvocationMetadata {
|
|
49
|
+
/** Records are only emitted for successful calls; failures are thrown instead. */
|
|
23
50
|
readonly status: 'success';
|
|
51
|
+
/** Registered tool that produced the value. */
|
|
24
52
|
readonly toolId: string;
|
|
25
53
|
}
|
|
54
|
+
/** Model call result with its model-call receipt. */
|
|
26
55
|
export type ModelResult<Value> = InvocationResult<Value, ModelCallRecord>;
|
|
56
|
+
/** Tool call result with its tool-call receipt. */
|
|
27
57
|
export type ToolResult<Value> = InvocationResult<Value, ToolCallRecord>;
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query aggregation contract: several ordered reads collapsed into one item list.
|
|
3
|
+
*
|
|
4
|
+
* Place in the package: an optional App-side helper for merging results of the same query shape
|
|
5
|
+
* run against several inputs. The Kit owns ordering and optional stable-key merging; every real
|
|
6
|
+
* read, the merge policy and the meaning of an item stay with the App.
|
|
7
|
+
*
|
|
8
|
+
* Exports: `QueryAggregationOptions`.
|
|
9
|
+
*/
|
|
1
10
|
export interface QueryAggregationOptions<Input, Item, Context> {
|
|
11
|
+
/** Reads one input. Called once per input, in caller order, and must return synchronously. */
|
|
2
12
|
readonly execute: (input: Input, context: Context) => readonly Item[];
|
|
13
|
+
/** Optional stable merge key. Items with the same key collapse into the first position seen. */
|
|
3
14
|
readonly key?: (item: Item, input: Input, context: Context) => string;
|
|
15
|
+
/** Combines a duplicate with the value merged so far; receives `undefined` for the first item. */
|
|
4
16
|
readonly merge?: (item: Item, previous: Item | undefined, input: Input, context: Context) => Item;
|
|
5
17
|
}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Answer checker contract for the Answering Kit.
|
|
3
|
+
*
|
|
4
|
+
* Place in the package: part of the `answering` Kit. A checker is one named validation unit over
|
|
5
|
+
* a generated value; the flow owns when it runs and what a failure means for the result.
|
|
6
|
+
*
|
|
7
|
+
* Exports: `AnswerChecker`.
|
|
8
|
+
*/
|
|
1
9
|
import type { OperationContext, CheckResult } from '../../common.js';
|
|
10
|
+
/** One named check applied to a generated answer value. */
|
|
2
11
|
export interface AnswerChecker<Value, App> {
|
|
12
|
+
/** Check id, reported with the issue and matched against a task's `checkIds`. */
|
|
3
13
|
readonly id: string;
|
|
14
|
+
/** Returns the verdict; `unavailable` and `not-run` are not verdicts on the value. */
|
|
4
15
|
check(value: Value, context: OperationContext<App>): CheckResult<Value>;
|
|
5
16
|
}
|
|
@@ -1,50 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Answer flow contract for the Answering Kit.
|
|
3
|
+
*
|
|
4
|
+
* Place in the package: the only `answering` module that composes the others. Generation, checking,
|
|
5
|
+
* review, fallback and budget checks are App handlers; the flow owns the stage graph, cell state,
|
|
6
|
+
* repair budget and per-item result statuses.
|
|
7
|
+
*
|
|
8
|
+
* Exports: `AnswerIssue`, `AnswerCheck`, `AnswerItem`, `AnswerResult`, `AnswerFlowDefinition`.
|
|
9
|
+
*/
|
|
1
10
|
import type { CheckResult, Issue, OperationContext, MaybePromise } from '../../common.js';
|
|
2
11
|
import type { RecoveryResult } from '../policies.js';
|
|
12
|
+
/** Validation problem produced while checking a generated answer. */
|
|
3
13
|
export interface AnswerIssue extends Issue {
|
|
4
14
|
}
|
|
15
|
+
/** Result of one local or review check over a generated answer. */
|
|
5
16
|
export interface AnswerCheck<Value> extends CheckResult<Value> {
|
|
6
17
|
}
|
|
18
|
+
/** One unit an answer batch must produce. */
|
|
7
19
|
export interface AnswerItem<Data> {
|
|
20
|
+
/** Unique item id inside the batch; also the key used for values and repairs. */
|
|
8
21
|
readonly id: string;
|
|
22
|
+
/** Input ids this item answers; every batch input must be covered exactly once overall. */
|
|
9
23
|
readonly inputIds: readonly string[];
|
|
24
|
+
/** App-owned data the generator and readers consume. */
|
|
10
25
|
readonly data: Data;
|
|
26
|
+
/** Availability of the item's source material; anything but `ready` cannot be answered. */
|
|
11
27
|
readonly sourceStatus: 'ready' | 'unavailable' | 'conflict';
|
|
12
28
|
}
|
|
29
|
+
/** Final outcome for one item. */
|
|
13
30
|
export interface AnswerResult<Data, Value> {
|
|
14
31
|
readonly item: AnswerItem<Data>;
|
|
32
|
+
/** Accepted or recovered value; absent when the item was blocked. */
|
|
15
33
|
readonly value?: Value;
|
|
34
|
+
/** `accepted` needs both checks resolved; `fallback` used recovery; `blocked` has no value. */
|
|
16
35
|
readonly status: 'accepted' | 'fallback' | 'blocked';
|
|
36
|
+
/** Combined local and review issues, plus generated codes such as a missing value. */
|
|
17
37
|
readonly issues: readonly AnswerIssue[];
|
|
38
|
+
/** Verdicts that produced this result. */
|
|
18
39
|
readonly checks: {
|
|
19
40
|
readonly local: AnswerCheck<Value>;
|
|
20
41
|
readonly review: AnswerCheck<Value>;
|
|
21
42
|
};
|
|
22
43
|
}
|
|
23
|
-
/** Static handlers and limits
|
|
44
|
+
/** Static handlers and limits; signal, diagnostics and App dependencies arrive at run. */
|
|
24
45
|
export interface AnswerFlowDefinition<Data, Value, App = undefined> {
|
|
46
|
+
/** Maximum items in one batch; must be a positive integer. */
|
|
25
47
|
readonly maxItems: number;
|
|
48
|
+
/** Repair rounds; the flow runs at most `maxRepairs + 1` rounds in total. */
|
|
26
49
|
readonly maxRepairs: number;
|
|
50
|
+
/** Review policy; defaults to `optional`, `required` blocks on an unresolved review. */
|
|
27
51
|
readonly reviewPolicy?: 'optional' | 'required' | 'off';
|
|
52
|
+
/** Request-level budget guard; must return boolean synchronously. */
|
|
28
53
|
canInvoke(context: OperationContext<App>): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Produces values for the items that still need one.
|
|
56
|
+
*
|
|
57
|
+
* `repairs` carries the issues of a failed attempt and `previous` its rejected values.
|
|
58
|
+
*/
|
|
29
59
|
generate(input: {
|
|
30
60
|
readonly items: readonly AnswerItem<Data>[];
|
|
31
61
|
readonly repairs?: ReadonlyMap<string, readonly AnswerIssue[]>;
|
|
32
62
|
readonly previous?: ReadonlyMap<string, Value>;
|
|
33
63
|
}, context: OperationContext<App>): Promise<ReadonlyMap<string, Value>>;
|
|
64
|
+
/** Local check for one generated value; must return synchronously. */
|
|
34
65
|
check(input: {
|
|
35
66
|
readonly item: AnswerItem<Data>;
|
|
36
67
|
readonly value: Value;
|
|
37
68
|
}, context: OperationContext<App>): AnswerCheck<Value>;
|
|
69
|
+
/** Batch review; returns one check per reviewed item and must cover the submitted items. */
|
|
38
70
|
review?(input: {
|
|
39
71
|
readonly items: readonly {
|
|
40
72
|
item: AnswerItem<Data>;
|
|
41
73
|
value: Value;
|
|
42
74
|
}[];
|
|
43
75
|
}, context: OperationContext<App>): Promise<ReadonlyMap<string, AnswerCheck<Value>>>;
|
|
76
|
+
/** Last resort for a failed item; `handled` supplies a replacement value. */
|
|
44
77
|
fallback(input: {
|
|
45
78
|
readonly item: AnswerItem<Data>;
|
|
46
79
|
readonly issues: readonly AnswerIssue[];
|
|
47
80
|
}, context: OperationContext<App>): RecoveryResult<Value>;
|
|
81
|
+
/** Observes a stage outcome; failures must not affect the flow result. */
|
|
48
82
|
observe?(input: {
|
|
49
83
|
readonly stageId: string;
|
|
50
84
|
readonly results: readonly AnswerResult<Data, Value>[];
|
|
@@ -1,19 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Answer flow state for the Answering Kit.
|
|
3
|
+
*
|
|
4
|
+
* Place in the package: mutable bookkeeping owned by the flow for one request. Cells are never
|
|
5
|
+
* shared between requests, and the repair budget is consumed by the flow itself.
|
|
6
|
+
*
|
|
7
|
+
* Exports: `AnswerCell`, `AnswerFlowState`.
|
|
8
|
+
*/
|
|
1
9
|
import type { AnswerItem, AnswerCheck, AnswerResult } from './flow.js';
|
|
10
|
+
/** One item's progress through generate, check, review and repair. */
|
|
2
11
|
export interface AnswerCell<D, V> {
|
|
12
|
+
/** Item being answered. */
|
|
3
13
|
item: AnswerItem<D>;
|
|
14
|
+
/** Latest generated value; absent before generation or when generation produced none. */
|
|
4
15
|
value?: V;
|
|
16
|
+
/** True when `value` is present, kept explicit so a valid `undefined` value is representable. */
|
|
5
17
|
hasValue: boolean;
|
|
18
|
+
/** Latest local check verdict. */
|
|
6
19
|
local: AnswerCheck<V>;
|
|
20
|
+
/** Latest review verdict. */
|
|
7
21
|
review: AnswerCheck<V>;
|
|
22
|
+
/** Sticky marker: a review once failed, so review must resolve before the item is accepted. */
|
|
8
23
|
knownReviewFailure: boolean;
|
|
24
|
+
/** Whether the most recent generation pass produced this cell's value. */
|
|
9
25
|
generated?: boolean;
|
|
10
26
|
}
|
|
27
|
+
/** Whole-flow state for one request. */
|
|
11
28
|
export interface AnswerFlowState<D, V> {
|
|
29
|
+
/** All cells of the batch, in request order. */
|
|
12
30
|
cells: AnswerCell<D, V>[];
|
|
31
|
+
/** Cells still being processed in the current round. */
|
|
13
32
|
pending: AnswerCell<D, V>[];
|
|
33
|
+
/** Repair allowance; `take()` returns false once the configured rounds are spent. */
|
|
14
34
|
repairBudget: {
|
|
15
35
|
readonly available: boolean;
|
|
16
36
|
take(): boolean;
|
|
17
37
|
};
|
|
38
|
+
/** Final results, present only after the flow completes. */
|
|
18
39
|
result?: AnswerResult<D, V>[];
|
|
19
40
|
}
|
|
@@ -1,21 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Answer task contract for the Answering Kit.
|
|
3
|
+
*
|
|
4
|
+
* Place in the package: part of the `answering` Kit. A task binds an intent set, an optional scope,
|
|
5
|
+
* one reader, one output contract and a list of checks; readers remain App-owned I/O.
|
|
6
|
+
*
|
|
7
|
+
* Exports: `AnswerTaskDefinition`, `AnswerReader`, `AnswerTaskPorts`.
|
|
8
|
+
*/
|
|
1
9
|
import type { MaybePromise, OperationContext, SchemaAdapter, ReadonlyCatalog } from '../../common.js';
|
|
10
|
+
/** Static binding of one answerable task. */
|
|
2
11
|
export interface AnswerTaskDefinition<Input = unknown, Data = unknown> {
|
|
12
|
+
/** Unique task id. */
|
|
3
13
|
readonly id: string;
|
|
4
14
|
readonly description: string;
|
|
15
|
+
/** Reader that produces the evidence for this task; must be registered. */
|
|
5
16
|
readonly readerId: string;
|
|
17
|
+
/** Output contract the answer must satisfy; must be registered. */
|
|
6
18
|
readonly outputId: string;
|
|
19
|
+
/** Intents this task serves; non-empty. */
|
|
7
20
|
readonly intentIds: readonly string[];
|
|
21
|
+
/** Optional scope narrowing the task. */
|
|
8
22
|
readonly scopeId?: string;
|
|
23
|
+
/** Checks applied to the produced value; every id must be registered. */
|
|
9
24
|
readonly checkIds: readonly string[];
|
|
25
|
+
/** Schema for the task input, validated before the reader runs. */
|
|
10
26
|
readonly inputSchema: SchemaAdapter<Input>;
|
|
27
|
+
/** App metadata passed back through the reader context; opaque to the Kit. */
|
|
11
28
|
readonly metadata: Data;
|
|
12
29
|
}
|
|
30
|
+
/** App-owned reader that gathers evidence for one task. */
|
|
13
31
|
export interface AnswerReader<Input, Evidence, App, Data = unknown> {
|
|
14
32
|
readonly id: string;
|
|
33
|
+
/** Produces evidence for the validated input; the task is passed through for context. */
|
|
15
34
|
read(input: Input, context: OperationContext<App> & {
|
|
16
35
|
readonly task: Readonly<AnswerTaskDefinition<Input, Data>>;
|
|
17
36
|
}): MaybePromise<Evidence>;
|
|
18
37
|
}
|
|
38
|
+
/** Registries a task catalog validates its references against. */
|
|
19
39
|
export interface AnswerTaskPorts<Input, Evidence, App, Data = unknown> {
|
|
20
40
|
readonly readers: ReadonlyCatalog<AnswerReader<Input, Evidence, App, Data>>;
|
|
21
41
|
readonly outputs: ReadonlyCatalog<{
|
|
@@ -24,5 +44,6 @@ export interface AnswerTaskPorts<Input, Evidence, App, Data = unknown> {
|
|
|
24
44
|
readonly checks: ReadonlyCatalog<{
|
|
25
45
|
readonly id: string;
|
|
26
46
|
}>;
|
|
47
|
+
/** Extra App assertion over a raw definition, before it is compiled. */
|
|
27
48
|
assertDefinition?(task: Readonly<AnswerTaskDefinition<Input, Data>>): void;
|
|
28
49
|
}
|
|
@@ -1,11 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact reference contract for the Artifacts Kit.
|
|
3
|
+
*
|
|
4
|
+
* Place in the package: an optional App-side library. A reference only names a resolver and an
|
|
5
|
+
* artifact; the resolver, not Core, establishes access, provenance and whether the referenced
|
|
6
|
+
* revision is still current. Nothing is cached or persisted by these types.
|
|
7
|
+
*
|
|
8
|
+
* Exports: `ArtifactReference`, `ArtifactResolver`.
|
|
9
|
+
*/
|
|
1
10
|
import type { MaybePromise, OperationContext } from '../common.js';
|
|
2
11
|
/** References locate artifacts; only the App resolver establishes access and current validity. */
|
|
3
12
|
export interface ArtifactReference {
|
|
13
|
+
/** Resolver that owns the artifact namespace. */
|
|
4
14
|
readonly resolverId: string;
|
|
15
|
+
/** Artifact identity inside that namespace; never blank. */
|
|
5
16
|
readonly artifactId: string;
|
|
17
|
+
/** Optional pinned revision; omission asks the resolver for its current revision. */
|
|
6
18
|
readonly revision?: string;
|
|
7
19
|
}
|
|
20
|
+
/** App-registered resolver that turns a reference into an App value. */
|
|
8
21
|
export interface ArtifactResolver<Value, App> {
|
|
9
22
|
readonly id: string;
|
|
23
|
+
/** Resolves the reference; throws when the artifact is unknown or not accessible. */
|
|
10
24
|
resolve(reference: ArtifactReference, context: OperationContext<App>): MaybePromise<Value>;
|
|
11
25
|
}
|
|
@@ -1,8 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Candidate envelope contract for the Candidates Kit.
|
|
3
|
+
*
|
|
4
|
+
* Place in the package: an optional App-side validator for a model reply that may offer several
|
|
5
|
+
* alternatives under one named field. The definition only declares the shape and bounds; which
|
|
6
|
+
* alternatives are acceptable, and what happens after the user picks one, stays with the App.
|
|
7
|
+
*
|
|
8
|
+
* Exports: `CandidateSelectionDefinition`.
|
|
9
|
+
*/
|
|
1
10
|
import type { BreakReason } from '../utils/rules.js';
|
|
11
|
+
/**
|
|
12
|
+
* Declares the alternative-proposal envelope.
|
|
13
|
+
*
|
|
14
|
+
* A value without the declared field is treated as a single implicit candidate.
|
|
15
|
+
*/
|
|
2
16
|
export interface CandidateSelectionDefinition {
|
|
17
|
+
/** Reply field that carries the alternatives. */
|
|
3
18
|
readonly field: string;
|
|
19
|
+
/** Minimum number of distinct candidates once the envelope is present; defaults to 1. */
|
|
4
20
|
readonly minCandidates?: number;
|
|
21
|
+
/** Maximum number of candidates; must be a safe integer not below the minimum. */
|
|
5
22
|
readonly maxCandidates: number;
|
|
23
|
+
/** Rejection wording, either fixed, a pre-built error or a lazy factory. */
|
|
6
24
|
readonly error?: BreakReason;
|
|
25
|
+
/** Diagnostic tags attached to every rejection from this contract. */
|
|
7
26
|
readonly tags?: readonly string[];
|
|
8
27
|
}
|
|
@@ -1,15 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delivery pipeline contract for the Delivery Kit.
|
|
3
|
+
*
|
|
4
|
+
* Place in the package: an optional App-side pipeline that ends with one result, for example
|
|
5
|
+
* formatting and sending a reply. The Kit owns ordering, cancellation checks and outcome
|
|
6
|
+
* validation; the stages, their state and the real side effects belong to the App.
|
|
7
|
+
*
|
|
8
|
+
* Exports: `DeliveryStage`, `DeliveryOptions`.
|
|
9
|
+
*/
|
|
1
10
|
import type { ExecutionContext, OperationContext } from '../common.js';
|
|
2
11
|
import type { StepOutcome } from '../execution/engine.js';
|
|
12
|
+
/** One pipeline stage, identified for reporting and optional observation. */
|
|
3
13
|
export interface DeliveryStage<Input, State, Result, StageId extends string> {
|
|
14
|
+
/** Unique, non-blank stage id in declaration order. */
|
|
4
15
|
readonly id: StageId;
|
|
16
|
+
/**
|
|
17
|
+
* Handles this stage.
|
|
18
|
+
*
|
|
19
|
+
* Returning `complete` ends the pipeline immediately; `continue` moves to the next stage.
|
|
20
|
+
* Omitting the handler makes the stage a named hook that only `beforeStage` observes.
|
|
21
|
+
*/
|
|
5
22
|
readonly handle?: (state: State, context: OperationContext<Input>) => StepOutcome<Result>;
|
|
6
23
|
}
|
|
24
|
+
/** Pipeline construction options. */
|
|
7
25
|
export interface DeliveryOptions<Input, State, Result, StageId extends string> {
|
|
26
|
+
/** Creates the mutable per-run state; must return synchronously. */
|
|
8
27
|
readonly createState: (input: Input, context: ExecutionContext) => State;
|
|
28
|
+
/** Stages in execution order; ids must be unique. */
|
|
9
29
|
readonly stages: readonly DeliveryStage<Input, State, Result, StageId>[];
|
|
30
|
+
/** Observes every stage before it runs, including stages without a handler. */
|
|
10
31
|
readonly beforeStage?: (input: {
|
|
11
32
|
stageId: StageId;
|
|
12
33
|
state: State;
|
|
13
34
|
}, context: OperationContext<Input>) => void;
|
|
35
|
+
/** Builds the error thrown when every stage returned `continue`. */
|
|
14
36
|
readonly missingResult: () => Error;
|
|
15
37
|
}
|
|
@@ -1,15 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable task contract for the Durable Kit.
|
|
3
|
+
*
|
|
4
|
+
* Place in the package: an optional App-side library for sequential work that must survive a
|
|
5
|
+
* restart. The Kit owns step ordering, attempt and model-call accounting, deadline checks,
|
|
6
|
+
* checkpoint validation and the exclusive-store protocol; the store, its atomicity and the real
|
|
7
|
+
* side effects stay with the App. Core itself never imports this module.
|
|
8
|
+
*
|
|
9
|
+
* Exports: `durableStatuses`, `durableReplayPolicies`, `DurableCheckpoint`, `DurableStore`,
|
|
10
|
+
* `DurableStep`, `DurableStepContext`, `DurableTaskDefinition`, `DurableTaskOptions`,
|
|
11
|
+
* `DurableTask`.
|
|
12
|
+
*/
|
|
1
13
|
import type { OperationContext } from '../common.js';
|
|
14
|
+
/** Checkpoint lifecycle values, in the order a task passes through them. */
|
|
2
15
|
export declare const durableStatuses: readonly ["ready", "running", "completed", "cancelled"];
|
|
16
|
+
/**
|
|
17
|
+
* How an interrupted step is resumed.
|
|
18
|
+
*
|
|
19
|
+
* `safe` re-runs `run` (the step must tolerate repeating its side effect); `reconcile` requires a
|
|
20
|
+
* `reconcile` handler because the previous attempt may have taken effect already.
|
|
21
|
+
*/
|
|
3
22
|
export declare const durableReplayPolicies: readonly ["safe", "reconcile"];
|
|
23
|
+
/** Persisted task progress; the only state a resume reads back. */
|
|
4
24
|
export interface DurableCheckpoint<State> {
|
|
25
|
+
/** Checkpoint format version; other versions are rejected on load. */
|
|
5
26
|
version: 2;
|
|
27
|
+
/** Definition that produced the checkpoint; a mismatch invalidates it. */
|
|
6
28
|
definitionId: string;
|
|
29
|
+
/** Definition revision that produced the checkpoint; a mismatch invalidates it. */
|
|
7
30
|
revision: string;
|
|
31
|
+
/** Zero-based index of the next step to run. */
|
|
8
32
|
nextStepIndex: number;
|
|
33
|
+
/** Attempts already spent; one is spent per step entry. */
|
|
9
34
|
attemptCount: number;
|
|
35
|
+
/** Total attempts allowed for the whole task. */
|
|
10
36
|
maxAttempts: number;
|
|
37
|
+
/** Absolute deadline in epoch milliseconds; expiry cancels the task. */
|
|
11
38
|
deadlineAtMs: number;
|
|
12
|
-
status: typeof durableStatuses[number];
|
|
39
|
+
status: (typeof durableStatuses)[number];
|
|
40
|
+
/** App-owned task state; only `isState` decides whether it is still valid. */
|
|
13
41
|
state: State;
|
|
14
42
|
/** Durable, conservative reservations. An interrupted attempt never refunds its allowance. */
|
|
15
43
|
modelBudget?: {
|
|
@@ -20,34 +48,59 @@ export interface DurableCheckpoint<State> {
|
|
|
20
48
|
}
|
|
21
49
|
/** App implements an exclusive lock across every writer and validates/serializes stored state. */
|
|
22
50
|
export interface DurableStore<State> {
|
|
51
|
+
/** Runs `operation` under the exclusive lock for `id`; other writers must wait or fail. */
|
|
23
52
|
exclusive<T>(id: string, operation: () => Promise<T>): Promise<T>;
|
|
53
|
+
/** Returns the stored checkpoint, or `undefined` when the task has never been saved. */
|
|
24
54
|
load(id: string): Promise<DurableCheckpoint<State> | undefined>;
|
|
55
|
+
/** Persists a checkpoint; must be durable before the promise resolves. */
|
|
25
56
|
save(id: string, checkpoint: DurableCheckpoint<State>): Promise<void>;
|
|
26
57
|
}
|
|
58
|
+
/** One step of a durable task. */
|
|
27
59
|
export interface DurableStep<State, App> {
|
|
60
|
+
/** Unique step id used in errors and diagnostics. */
|
|
28
61
|
readonly id: string;
|
|
29
|
-
|
|
62
|
+
/** Resume behaviour when a previous attempt was interrupted mid-step. */
|
|
63
|
+
readonly replayPolicy: (typeof durableReplayPolicies)[number];
|
|
64
|
+
/** Executes the step and returns the complete next state. */
|
|
30
65
|
run(state: Readonly<State>, context: DurableStepContext<App>): Promise<State>;
|
|
66
|
+
/** Required when `replayPolicy` is `reconcile`; repairs state after an interrupted attempt. */
|
|
31
67
|
reconcile?(state: Readonly<State>, context: DurableStepContext<App>): Promise<State>;
|
|
32
68
|
}
|
|
69
|
+
/** Execution facts handed to a durable step. */
|
|
33
70
|
export interface DurableStepContext<App> extends OperationContext<App> {
|
|
71
|
+
/** One-based attempt number currently executing (already counted and persisted). */
|
|
34
72
|
readonly attemptCount: number;
|
|
35
|
-
/** App binds its real Runner to this reserved per-attempt maximum,
|
|
73
|
+
/** App binds its real Runner to this reserved per-attempt maximum, keeping request limits. */
|
|
36
74
|
readonly maxModelCalls?: number;
|
|
37
75
|
}
|
|
76
|
+
/** Task definition, including the App hooks that guard every resume. */
|
|
38
77
|
export interface DurableTaskDefinition<State, App> {
|
|
39
78
|
readonly id: string;
|
|
79
|
+
/** Definition revision; stored in the checkpoint so resumed work matches its code. */
|
|
40
80
|
readonly revision: string;
|
|
81
|
+
/** Steps in execution order; the checkpoint stores an index into this list. */
|
|
41
82
|
readonly steps: readonly DurableStep<State, App>[];
|
|
83
|
+
/** Validates a loaded checkpoint state before any step runs. */
|
|
42
84
|
isState(state: unknown): state is State;
|
|
43
85
|
/** Recheck current identity, source versions and grants on every explicit resume. */
|
|
44
86
|
authorize?(checkpoint: Readonly<DurableCheckpoint<State>>, context: import('../common.js').OperationContext<App>): import('../common.js').MaybePromise<void>;
|
|
45
87
|
}
|
|
88
|
+
/** Runtime options for a compiled durable task. */
|
|
46
89
|
export interface DurableTaskOptions<State = unknown> {
|
|
90
|
+
/** Clock override for deadlines and timestamps; defaults to `Date.now`. */
|
|
47
91
|
readonly now?: () => number;
|
|
92
|
+
/** Default store; a call may pass its own store instead. */
|
|
48
93
|
readonly store?: DurableStore<State>;
|
|
49
94
|
}
|
|
95
|
+
/** Compiled task: resumes from the store and returns the final state. */
|
|
50
96
|
export interface DurableTask<State, App> {
|
|
97
|
+
/**
|
|
98
|
+
* Runs or resumes the task.
|
|
99
|
+
*
|
|
100
|
+
* @param request - Task id and an optional store overriding the definition's default.
|
|
101
|
+
* @param context - App host object, cancellation and diagnostics.
|
|
102
|
+
* @returns The completed state; a completed checkpoint returns a detached copy.
|
|
103
|
+
*/
|
|
51
104
|
run(request: {
|
|
52
105
|
readonly taskId: string;
|
|
53
106
|
readonly store?: DurableStore<State>;
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
/** Checkpoint lifecycle values, in the order a task passes through them. */
|
|
1
2
|
export const durableStatuses = ['ready', 'running', 'completed', 'cancelled'];
|
|
3
|
+
/**
|
|
4
|
+
* How an interrupted step is resumed.
|
|
5
|
+
*
|
|
6
|
+
* `safe` re-runs `run` (the step must tolerate repeating its side effect); `reconcile` requires a
|
|
7
|
+
* `reconcile` handler because the previous attempt may have taken effect already.
|
|
8
|
+
*/
|
|
2
9
|
export const durableReplayPolicies = ['safe', 'reconcile'];
|
|
@@ -1,20 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evidence contract for the Evidence Kit.
|
|
3
|
+
*
|
|
4
|
+
* Place in the package: an optional App-side library for "did we actually observe enough" logic.
|
|
5
|
+
* A requirement may only be satisfied by an observation; a model's claim that it succeeded is
|
|
6
|
+
* never itself evidence. What counts as evidence and where observations come from stay App-owned.
|
|
7
|
+
*
|
|
8
|
+
* Exports: `EvidenceRequirement`, `EvidenceProvider`, `EvidenceProjectionProvider`,
|
|
9
|
+
* `EvidenceProjectionDefinition`.
|
|
10
|
+
*/
|
|
1
11
|
/** Requirements describe evidence that must already exist, never a model's assertion of success. */
|
|
2
12
|
export interface EvidenceRequirement {
|
|
13
|
+
/** Evidence kind; selects the provider that adjudicates satisfaction. */
|
|
3
14
|
readonly kind: string;
|
|
15
|
+
/** Identity inside that kind, for example a document or record id. */
|
|
4
16
|
readonly id: string;
|
|
17
|
+
/** Optional operation the evidence must cover; interpreted by the provider. */
|
|
5
18
|
readonly operation?: string;
|
|
6
19
|
}
|
|
20
|
+
/** Adjudicates one evidence kind against real observations. */
|
|
7
21
|
export interface EvidenceProvider<Observation, Requirement extends EvidenceRequirement> {
|
|
22
|
+
/** Kind this provider answers; one provider per kind. */
|
|
8
23
|
readonly kind: Requirement['kind'];
|
|
9
24
|
readonly description: string;
|
|
25
|
+
/** Returns whether one observation satisfies one requirement; must be synchronous boolean. */
|
|
10
26
|
isSatisfied(observation: Observation, requirement: Requirement): boolean;
|
|
11
27
|
}
|
|
28
|
+
/** Describes which sources an observation can cite, and how to narrow it to cited ones. */
|
|
12
29
|
export interface EvidenceProjectionProvider<Observation, Source> {
|
|
30
|
+
/** All sources the observation currently carries. */
|
|
13
31
|
sources(observation: Observation): readonly Source[];
|
|
32
|
+
/** Returns a copy of the observation restricted to `sources`. */
|
|
14
33
|
withSources(observation: Observation, sources: Source[]): Observation;
|
|
15
34
|
}
|
|
35
|
+
/** Projection configuration, keyed by the tool that produced an observation. */
|
|
16
36
|
export interface EvidenceProjectionDefinition<Observation, Source> {
|
|
37
|
+
/** One provider per tool id; observations without a provider pass through unchanged. */
|
|
17
38
|
readonly providers: Readonly<Record<string, EvidenceProjectionProvider<Observation, Source>>>;
|
|
39
|
+
/** Stable citation id for a source. */
|
|
18
40
|
readonly sourceId: (source: Source) => string;
|
|
41
|
+
/** Selects the tool id of an observation; defaults to its `toolId` (or legacy `tool`) field. */
|
|
19
42
|
readonly toolId?: (observation: Observation) => string;
|
|
20
43
|
}
|
|
@@ -1,36 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Family version contract for the Family Kit.
|
|
3
|
+
*
|
|
4
|
+
* Place in the package: an optional App-side library that versions App state hanging off Core
|
|
5
|
+
* branches. A family is a bounded, expiring record of immutable versions; the Kit owns revision
|
|
6
|
+
* checks, capacity, retention and lineage rules, while the store, authorization, validation and
|
|
7
|
+
* merge policy stay with the App. No executable function or authority is restored here.
|
|
8
|
+
*
|
|
9
|
+
* Exports: `familyOperations`, `FamilyOperation`, `FamilyVersion`, `FamilyRecord`, `FamilyStore`,
|
|
10
|
+
* `FamilyDefinition`, `AgentFamily`.
|
|
11
|
+
*/
|
|
1
12
|
import type { OperationContext, MaybePromise } from '../common.js';
|
|
2
13
|
import type { AgentBranch } from '../../execution/engine.js';
|
|
14
|
+
/** Operation names accepted by the family `authorize` hook. */
|
|
3
15
|
export declare const familyOperations: readonly ["create", "fork", "merge", "promote"];
|
|
4
|
-
|
|
16
|
+
/** One of the four family mutations. */
|
|
17
|
+
export type FamilyOperation = (typeof familyOperations)[number];
|
|
18
|
+
/** Immutable snapshot of App state at one point on a branch. */
|
|
5
19
|
export interface FamilyVersion<State> {
|
|
20
|
+
/** Unique version id, generated by the Kit. */
|
|
6
21
|
readonly id: string;
|
|
22
|
+
/** Version this one was forked or merged from, when lineage applies. */
|
|
7
23
|
readonly parentId?: string;
|
|
24
|
+
/** Source version of a merge; present only on versions created by `merge`. */
|
|
8
25
|
readonly mergeSourceId?: string;
|
|
26
|
+
/** Common ancestor recorded for fork/merge bookkeeping. */
|
|
9
27
|
readonly baseId?: string;
|
|
28
|
+
/** Core branch snapshot paired with this state. */
|
|
10
29
|
readonly branch: AgentBranch;
|
|
30
|
+
/** App state; treated as immutable by the Kit and snapshotted on write. */
|
|
11
31
|
readonly state: State;
|
|
32
|
+
/** Creation instant in epoch milliseconds. */
|
|
12
33
|
readonly createdAtMs: number;
|
|
13
34
|
}
|
|
35
|
+
/** A whole family: its versions and which version is currently active. */
|
|
14
36
|
export interface FamilyRecord<State> {
|
|
37
|
+
/** Family id; also the store key. */
|
|
15
38
|
readonly id: string;
|
|
39
|
+
/** Optimistic concurrency token; every accepted mutation increments it by one. */
|
|
16
40
|
readonly revision: number;
|
|
41
|
+
/** Id of the active version; promotion moves this pointer. */
|
|
17
42
|
readonly activeId: string;
|
|
43
|
+
/** Instant after which the record is no longer retained, in epoch milliseconds. */
|
|
18
44
|
readonly expiresAtMs: number;
|
|
45
|
+
/** Versions in creation order; bounded by `maxVersions` when configured. */
|
|
19
46
|
readonly versions: readonly FamilyVersion<State>[];
|
|
20
47
|
}
|
|
21
48
|
/** CAS must cover every writer and the active pointer in one real storage commit. */
|
|
22
49
|
export interface FamilyStore<State> {
|
|
50
|
+
/** Returns the record, or `undefined` when it does not exist. */
|
|
23
51
|
load(id: string): Promise<FamilyRecord<State> | undefined>;
|
|
52
|
+
/** Commits `next` only when the stored revision equals `expectedRevision`; returns success. */
|
|
24
53
|
compareAndSwap(id: string, expectedRevision: number | undefined, next: FamilyRecord<State>): Promise<boolean>;
|
|
25
54
|
}
|
|
55
|
+
/** App-owned hooks and limits for one family. */
|
|
26
56
|
export interface FamilyDefinition<State, App> {
|
|
27
57
|
readonly store: FamilyStore<State>;
|
|
58
|
+
/** Maximum retained versions; older versions are dropped once the bound is exceeded. */
|
|
28
59
|
readonly maxVersions?: number;
|
|
60
|
+
/** Retention window in milliseconds, measured from a write. */
|
|
29
61
|
readonly retentionMs?: number;
|
|
62
|
+
/** Clock override for timestamps and expiry; defaults to `Date.now`. */
|
|
30
63
|
readonly now?: () => number;
|
|
64
|
+
/** Validates a state loaded from the store before it is used. */
|
|
31
65
|
isState(value: unknown): value is State;
|
|
66
|
+
/** Guards one mutation; called before any write, including with an absent record. */
|
|
32
67
|
authorize(operation: FamilyOperation, record: FamilyRecord<State> | undefined, context: OperationContext<App>): MaybePromise<void>;
|
|
68
|
+
/** Validates a candidate version before it is appended. */
|
|
33
69
|
validate(candidate: FamilyVersion<State>, context: OperationContext<App>): MaybePromise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Resolves a three-way merge.
|
|
72
|
+
*
|
|
73
|
+
* Returns the merged state and any conflicts. A non-empty conflict list aborts the merge without
|
|
74
|
+
* writing a version, so `value` is ignored in that case.
|
|
75
|
+
*/
|
|
34
76
|
merge?(input: {
|
|
35
77
|
base: State;
|
|
36
78
|
target: State;
|
|
@@ -40,13 +82,17 @@ export interface FamilyDefinition<State, App> {
|
|
|
40
82
|
conflicts: readonly string[];
|
|
41
83
|
}>;
|
|
42
84
|
}
|
|
85
|
+
/** Compiled family API. Every mutation returns the record after the write. */
|
|
43
86
|
export interface AgentFamily<State, App> {
|
|
87
|
+
/** Reads the record; throws when the family does not exist or has expired. */
|
|
44
88
|
read(id: string, context: OperationContext<App>): Promise<FamilyRecord<State>>;
|
|
89
|
+
/** Creates the first version and makes it active. */
|
|
45
90
|
create(request: {
|
|
46
91
|
id: string;
|
|
47
92
|
branch: AgentBranch;
|
|
48
93
|
state: State;
|
|
49
94
|
}, context: OperationContext<App>): Promise<FamilyRecord<State>>;
|
|
95
|
+
/** Appends a version forked from `parentId`; the active pointer does not change. */
|
|
50
96
|
fork(request: {
|
|
51
97
|
id: string;
|
|
52
98
|
revision: number;
|
|
@@ -54,6 +100,7 @@ export interface AgentFamily<State, App> {
|
|
|
54
100
|
branch: AgentBranch;
|
|
55
101
|
state: State;
|
|
56
102
|
}, context: OperationContext<App>): Promise<FamilyRecord<State>>;
|
|
103
|
+
/** Merges `source` into `target`; `saved` is false when the merge reported conflicts. */
|
|
57
104
|
merge(request: {
|
|
58
105
|
id: string;
|
|
59
106
|
revision: number;
|
|
@@ -65,6 +112,7 @@ export interface AgentFamily<State, App> {
|
|
|
65
112
|
record: FamilyRecord<State>;
|
|
66
113
|
conflicts: readonly string[];
|
|
67
114
|
}>;
|
|
115
|
+
/** Makes `candidateId` active; fails when the active version changed since `expectedActiveId`. */
|
|
68
116
|
promote(request: {
|
|
69
117
|
id: string;
|
|
70
118
|
revision: number;
|