@jangts/agent-core 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/development/docs/api/reference.md +1907 -1874
- package/development/docs/api/support.md +27 -0
- package/development/skills/agent-core-app/scripts/create-app.mjs +267 -70
- package/development/skills/agent-core-app/scripts/lib/knowledge.mjs +40 -15
- package/development/skills/agent-core-app/scripts/lib/source.mjs +30 -2
- package/development/skills/agent-core-app/scripts/plan.mjs +37 -12
- package/development/skills/agent-core-app/scripts/prepare-source.mjs +61 -10
- package/development/skills/agent-core-app/scripts/resources.mjs +45 -17
- package/development/skills/agent-core-app/scripts/validate-knowledge.mjs +18 -1
- package/development/skills/agent-core-app/templates/catalog.json +36 -22
- package/dist/cjs/capabilities/index.js +13 -0
- package/dist/cjs/capabilities/invocation.js +80 -10
- package/dist/cjs/capabilities/model.js +126 -13
- package/dist/cjs/capabilities/tool-runtime.js +64 -12
- package/dist/cjs/capabilities/tools.js +266 -31
- package/dist/cjs/context/assembly.js +46 -5
- package/dist/cjs/context/audit.js +31 -6
- package/dist/cjs/context/fragments.js +54 -11
- package/dist/cjs/context/index.js +12 -0
- package/dist/cjs/context/journal.js +84 -7
- package/dist/cjs/context/plan.js +30 -2
- package/dist/cjs/diagnostics/catalog.js +11 -3
- package/dist/cjs/diagnostics/index.js +149 -29
- package/dist/cjs/diagnostics/sub-flow.js +240 -40
- package/dist/cjs/errors.js +99 -17
- package/dist/cjs/execution/branch.js +20 -4
- package/dist/cjs/execution/engine.js +470 -56
- package/dist/cjs/execution/events.js +136 -18
- package/dist/cjs/execution/index.js +7 -0
- package/dist/cjs/execution/reporting.js +75 -6
- package/dist/cjs/execution/state.js +161 -22
- package/dist/cjs/execution/workflow.js +224 -32
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/kits/aggregation.js +45 -3
- package/dist/cjs/kits/answering/batch.js +23 -4
- package/dist/cjs/kits/answering/check-result.js +31 -8
- package/dist/cjs/kits/answering/checks.js +24 -3
- package/dist/cjs/kits/answering/flow.js +192 -36
- package/dist/cjs/kits/answering/index.js +19 -1
- package/dist/cjs/kits/answering/tasks.js +88 -13
- package/dist/cjs/kits/artifacts.js +36 -4
- package/dist/cjs/kits/candidates.js +47 -5
- package/dist/cjs/kits/delivery.js +40 -5
- package/dist/cjs/kits/durable.js +155 -31
- package/dist/cjs/kits/evidence.js +66 -15
- package/dist/cjs/kits/family.js +152 -22
- package/dist/cjs/kits/index.js +12 -1
- package/dist/cjs/kits/inference.js +104 -16
- package/dist/cjs/kits/intents/catalog.js +67 -16
- package/dist/cjs/kits/intents/index.js +11 -0
- package/dist/cjs/kits/intents/registry.js +188 -43
- package/dist/cjs/kits/intents/scopes.js +215 -46
- package/dist/cjs/kits/interaction/command.js +140 -36
- package/dist/cjs/kits/interaction/commands.js +86 -11
- package/dist/cjs/kits/interaction/handlers.js +27 -10
- package/dist/cjs/kits/interaction/index.js +10 -0
- package/dist/cjs/kits/interaction/transfer.js +80 -14
- package/dist/cjs/kits/knowledge/catalog.js +62 -11
- package/dist/cjs/kits/knowledge/index.js +16 -1
- package/dist/cjs/kits/knowledge/publication.js +99 -23
- package/dist/cjs/kits/knowledge/sections.js +33 -4
- package/dist/cjs/kits/normalization.js +51 -7
- package/dist/cjs/kits/policies.js +79 -15
- package/dist/cjs/kits/presentation/events.js +54 -10
- package/dist/cjs/kits/presentation/index.js +24 -1
- package/dist/cjs/kits/presentation/outputs.js +176 -38
- package/dist/cjs/kits/presentation/templates.js +33 -5
- package/dist/cjs/kits/presentation/variants.js +31 -2
- package/dist/cjs/kits/projection.js +63 -8
- package/dist/cjs/kits/rank-fusion.js +27 -4
- package/dist/cjs/kits/reflection-log-source.js +89 -16
- package/dist/cjs/kits/reflection.js +234 -60
- package/dist/cjs/kits/retrieval.js +98 -18
- package/dist/cjs/kits/search.js +180 -27
- package/dist/cjs/kits/text-skills.js +104 -19
- package/dist/cjs/kits/tools.js +415 -74
- package/dist/cjs/kits/vector-search.js +50 -16
- package/dist/cjs/mock/node.js +7 -1
- package/dist/cjs/mock/web.js +7 -1
- package/dist/cjs/mock.js +7 -1
- package/dist/cjs/model/binding.js +68 -17
- package/dist/cjs/model/call-budget.js +45 -4
- package/dist/cjs/model/decision-retry.js +19 -1
- package/dist/cjs/model/defaults.js +27 -4
- package/dist/cjs/model/index.js +7 -0
- package/dist/cjs/model/interactions/arguments.js +36 -1
- package/dist/cjs/model/interactions/json-object.js +48 -12
- package/dist/cjs/model/interactions/native-functions.js +52 -10
- package/dist/cjs/model/message-diagnostics.js +17 -4
- package/dist/cjs/model/options.js +9 -1
- package/dist/cjs/model/preparation.js +86 -12
- package/dist/cjs/model/runner.js +413 -79
- package/dist/cjs/model/selection-transport.js +48 -8
- package/dist/cjs/model/settings.js +67 -13
- package/dist/cjs/model/token-budget.js +69 -11
- package/dist/cjs/model/transports.js +59 -6
- package/dist/cjs/structs/common.js +11 -0
- package/dist/cjs/structs/debug.js +34 -5
- package/dist/cjs/structs/errors.js +26 -1
- package/dist/cjs/structs/index.js +11 -1
- package/dist/cjs/structs/kits/durable.js +7 -0
- package/dist/cjs/structs/kits/family.js +1 -0
- package/dist/cjs/structs/kits/interaction.js +8 -1
- package/dist/cjs/structs/kits/knowledge-publication.js +1 -0
- package/dist/cjs/structs/kits/reflection.js +18 -3
- package/dist/cjs/structs/model/chat-provider.js +6 -0
- package/dist/cjs/structs/support/model/completion.js +2 -0
- package/dist/cjs/structs/support/model/messages.js +2 -0
- package/dist/cjs/support/capabilities.js +43 -6
- package/dist/cjs/support/context/assembly.js +88 -16
- package/dist/cjs/support/context/compression.js +48 -6
- package/dist/cjs/support/context/fragments.js +6 -0
- package/dist/cjs/support/context/history.js +36 -1
- package/dist/cjs/support/context/index.js +11 -0
- package/dist/cjs/support/context/nodes.js +164 -35
- package/dist/cjs/support/context/processing.js +319 -61
- package/dist/cjs/support/context/selection-policy.js +98 -21
- package/dist/cjs/support/context/selection.js +61 -10
- package/dist/cjs/support/context/snapshot.js +29 -7
- package/dist/cjs/support/context/strategies.js +120 -28
- package/dist/cjs/support/index.js +9 -1
- package/dist/cjs/support/model/capabilities.js +20 -1
- package/dist/cjs/support/model/chat-completions.js +92 -20
- package/dist/cjs/support/model/children.js +34 -6
- package/dist/cjs/support/model/compatible-provider.js +189 -59
- package/dist/cjs/support/model/completion/calls.js +61 -0
- package/dist/cjs/support/model/completion/default.js +32 -0
- package/dist/cjs/support/model/completion/index.js +28 -0
- package/dist/cjs/support/model/completion/session.js +102 -0
- package/dist/cjs/support/model/index.js +12 -0
- package/dist/cjs/support/model/interactions/index.js +12 -1
- package/dist/cjs/support/model/interactions/json-object.js +6 -0
- package/dist/cjs/support/model/interactions/native-functions.js +6 -0
- package/dist/cjs/support/model/observer.js +32 -6
- package/dist/cjs/support/model/preview-rules.js +66 -16
- package/dist/cjs/support/model/reply-preview.js +77 -17
- package/dist/cjs/support/model/stage-transport.js +33 -7
- package/dist/cjs/support/model/strategies.js +75 -14
- package/dist/cjs/support/model/transports.js +53 -11
- package/dist/cjs/support/registration.js +49 -7
- package/dist/cjs/support/schema.js +46 -4
- package/dist/cjs/support/stream-events.js +60 -8
- package/dist/cjs/support/tool-runtime.js +6 -0
- package/dist/cjs/support/tools.js +79 -10
- package/dist/cjs/support/transport/index.js +7 -0
- package/dist/cjs/support/transport/json.js +28 -4
- package/dist/cjs/support/transport/sse.js +25 -2
- package/dist/cjs/utils/break-observer.js +20 -2
- package/dist/cjs/utils/cancellation.js +77 -9
- package/dist/cjs/utils/catalog.js +19 -4
- package/dist/cjs/utils/debug.js +14 -2
- package/dist/cjs/utils/index.js +8 -0
- package/dist/cjs/utils/interaction-definition.js +26 -6
- package/dist/cjs/utils/invocation.js +42 -4
- package/dist/cjs/utils/model-protocol.js +20 -1
- package/dist/cjs/utils/object.js +16 -0
- package/dist/cjs/utils/observer.js +22 -2
- package/dist/cjs/utils/protocol-registry.js +47 -4
- package/dist/cjs/utils/query-key.js +21 -2
- package/dist/cjs/utils/registration.js +18 -2
- package/dist/cjs/utils/rules.js +39 -11
- package/dist/cjs/utils/schema-adapter.js +25 -2
- package/dist/cjs/utils/synchronous.js +64 -7
- package/dist/cjs/utils/text.js +15 -1
- package/dist/esm/capabilities/index.d.ts +13 -0
- package/dist/esm/capabilities/index.js +13 -0
- package/dist/esm/capabilities/invocation.d.ts +16 -2
- package/dist/esm/capabilities/invocation.js +80 -10
- package/dist/esm/capabilities/model.d.ts +68 -1
- package/dist/esm/capabilities/model.js +126 -13
- package/dist/esm/capabilities/tool-runtime.d.ts +11 -0
- package/dist/esm/capabilities/tool-runtime.js +64 -12
- package/dist/esm/capabilities/tools.d.ts +96 -3
- package/dist/esm/capabilities/tools.js +267 -32
- package/dist/esm/context/assembly.d.ts +13 -2
- package/dist/esm/context/assembly.js +46 -5
- package/dist/esm/context/audit.d.ts +23 -1
- package/dist/esm/context/audit.js +31 -6
- package/dist/esm/context/fragments.d.ts +37 -3
- package/dist/esm/context/fragments.js +54 -11
- package/dist/esm/context/index.d.ts +12 -0
- package/dist/esm/context/index.js +12 -0
- package/dist/esm/context/journal.d.ts +32 -1
- package/dist/esm/context/journal.js +84 -7
- package/dist/esm/context/plan.d.ts +11 -1
- package/dist/esm/context/plan.js +30 -2
- package/dist/esm/diagnostics/catalog.js +11 -3
- package/dist/esm/diagnostics/index.d.ts +30 -2
- package/dist/esm/diagnostics/index.js +149 -29
- package/dist/esm/diagnostics/sub-flow.d.ts +41 -3
- package/dist/esm/diagnostics/sub-flow.js +240 -40
- package/dist/esm/errors.d.ts +22 -2
- package/dist/esm/errors.js +99 -17
- package/dist/esm/execution/branch.d.ts +19 -1
- package/dist/esm/execution/branch.js +20 -4
- package/dist/esm/execution/engine.d.ts +291 -5
- package/dist/esm/execution/engine.js +471 -57
- package/dist/esm/execution/events.d.ts +16 -2
- package/dist/esm/execution/events.js +136 -18
- package/dist/esm/execution/index.d.ts +7 -0
- package/dist/esm/execution/index.js +7 -0
- package/dist/esm/execution/reporting.d.ts +49 -1
- package/dist/esm/execution/reporting.js +75 -6
- package/dist/esm/execution/state.d.ts +126 -10
- package/dist/esm/execution/state.js +161 -22
- package/dist/esm/execution/workflow.d.ts +121 -3
- package/dist/esm/execution/workflow.js +224 -32
- package/dist/esm/index.d.ts +17 -1
- package/dist/esm/index.js +18 -0
- package/dist/esm/kits/aggregation.d.ts +34 -2
- package/dist/esm/kits/aggregation.js +45 -3
- package/dist/esm/kits/answering/batch.d.ts +17 -0
- package/dist/esm/kits/answering/batch.js +23 -4
- package/dist/esm/kits/answering/check-result.d.ts +18 -1
- package/dist/esm/kits/answering/check-result.js +31 -8
- package/dist/esm/kits/answering/checks.d.ts +11 -0
- package/dist/esm/kits/answering/checks.js +24 -3
- package/dist/esm/kits/answering/flow.d.ts +25 -2
- package/dist/esm/kits/answering/flow.js +192 -36
- package/dist/esm/kits/answering/index.d.ts +12 -0
- package/dist/esm/kits/answering/index.js +19 -1
- package/dist/esm/kits/answering/tasks.d.ts +32 -1
- package/dist/esm/kits/answering/tasks.js +88 -13
- package/dist/esm/kits/artifacts.d.ts +11 -0
- package/dist/esm/kits/artifacts.js +36 -4
- package/dist/esm/kits/candidates.d.ts +23 -1
- package/dist/esm/kits/candidates.js +47 -5
- package/dist/esm/kits/delivery.d.ts +34 -0
- package/dist/esm/kits/delivery.js +40 -5
- package/dist/esm/kits/durable.d.ts +19 -0
- package/dist/esm/kits/durable.js +155 -31
- package/dist/esm/kits/evidence.d.ts +28 -5
- package/dist/esm/kits/evidence.js +66 -15
- package/dist/esm/kits/family.d.ts +17 -1
- package/dist/esm/kits/family.js +152 -22
- package/dist/esm/kits/index.d.ts +12 -1
- package/dist/esm/kits/index.js +12 -1
- package/dist/esm/kits/inference.d.ts +64 -0
- package/dist/esm/kits/inference.js +104 -16
- package/dist/esm/kits/intents/catalog.d.ts +13 -1
- package/dist/esm/kits/intents/catalog.js +67 -16
- package/dist/esm/kits/intents/index.d.ts +11 -0
- package/dist/esm/kits/intents/index.js +11 -0
- package/dist/esm/kits/intents/registry.d.ts +61 -3
- package/dist/esm/kits/intents/registry.js +188 -43
- package/dist/esm/kits/intents/scopes.d.ts +73 -3
- package/dist/esm/kits/intents/scopes.js +215 -46
- package/dist/esm/kits/interaction/command.d.ts +38 -4
- package/dist/esm/kits/interaction/command.js +140 -36
- package/dist/esm/kits/interaction/commands.d.ts +66 -2
- package/dist/esm/kits/interaction/commands.js +86 -11
- package/dist/esm/kits/interaction/handlers.d.ts +19 -2
- package/dist/esm/kits/interaction/handlers.js +27 -10
- package/dist/esm/kits/interaction/index.d.ts +10 -0
- package/dist/esm/kits/interaction/index.js +10 -0
- package/dist/esm/kits/interaction/transfer.d.ts +39 -2
- package/dist/esm/kits/interaction/transfer.js +80 -14
- package/dist/esm/kits/knowledge/catalog.d.ts +13 -0
- package/dist/esm/kits/knowledge/catalog.js +62 -11
- package/dist/esm/kits/knowledge/index.d.ts +11 -0
- package/dist/esm/kits/knowledge/index.js +16 -1
- package/dist/esm/kits/knowledge/publication.d.ts +15 -1
- package/dist/esm/kits/knowledge/publication.js +99 -23
- package/dist/esm/kits/knowledge/sections.d.ts +31 -1
- package/dist/esm/kits/knowledge/sections.js +33 -4
- package/dist/esm/kits/normalization.d.ts +25 -2
- package/dist/esm/kits/normalization.js +51 -7
- package/dist/esm/kits/policies.d.ts +26 -3
- package/dist/esm/kits/policies.js +79 -15
- package/dist/esm/kits/presentation/events.d.ts +51 -4
- package/dist/esm/kits/presentation/events.js +54 -10
- package/dist/esm/kits/presentation/index.d.ts +12 -0
- package/dist/esm/kits/presentation/index.js +25 -2
- package/dist/esm/kits/presentation/outputs.d.ts +30 -1
- package/dist/esm/kits/presentation/outputs.js +176 -38
- package/dist/esm/kits/presentation/templates.d.ts +32 -3
- package/dist/esm/kits/presentation/templates.js +33 -5
- package/dist/esm/kits/presentation/variants.d.ts +29 -0
- package/dist/esm/kits/presentation/variants.js +31 -2
- package/dist/esm/kits/projection.d.ts +42 -5
- package/dist/esm/kits/projection.js +63 -8
- package/dist/esm/kits/rank-fusion.d.ts +21 -1
- package/dist/esm/kits/rank-fusion.js +28 -5
- package/dist/esm/kits/reflection-log-source.d.ts +28 -1
- package/dist/esm/kits/reflection-log-source.js +89 -16
- package/dist/esm/kits/reflection.d.ts +17 -1
- package/dist/esm/kits/reflection.js +235 -61
- package/dist/esm/kits/retrieval.d.ts +18 -2
- package/dist/esm/kits/retrieval.js +98 -18
- package/dist/esm/kits/search.d.ts +56 -3
- package/dist/esm/kits/search.js +180 -27
- package/dist/esm/kits/text-skills.d.ts +16 -2
- package/dist/esm/kits/text-skills.js +104 -19
- package/dist/esm/kits/tools.d.ts +122 -2
- package/dist/esm/kits/tools.js +416 -74
- package/dist/esm/kits/vector-search.d.ts +47 -1
- package/dist/esm/kits/vector-search.js +51 -17
- package/dist/esm/mock/node.d.ts +7 -0
- package/dist/esm/mock/node.js +7 -1
- package/dist/esm/mock/web.d.ts +7 -0
- package/dist/esm/mock/web.js +7 -1
- package/dist/esm/mock.d.ts +7 -0
- package/dist/esm/mock.js +7 -1
- package/dist/esm/model/binding.d.ts +32 -3
- package/dist/esm/model/binding.js +68 -17
- package/dist/esm/model/call-budget.d.ts +30 -2
- package/dist/esm/model/call-budget.js +45 -4
- package/dist/esm/model/decision-retry.d.ts +10 -1
- package/dist/esm/model/decision-retry.js +19 -1
- package/dist/esm/model/defaults.d.ts +13 -2
- package/dist/esm/model/defaults.js +27 -4
- package/dist/esm/model/index.d.ts +7 -0
- package/dist/esm/model/index.js +7 -0
- package/dist/esm/model/interactions/arguments.d.ts +27 -0
- package/dist/esm/model/interactions/arguments.js +36 -1
- package/dist/esm/model/interactions/json-object.d.ts +7 -1
- package/dist/esm/model/interactions/json-object.js +48 -12
- package/dist/esm/model/interactions/native-functions.d.ts +6 -0
- package/dist/esm/model/interactions/native-functions.js +52 -10
- package/dist/esm/model/message-diagnostics.d.ts +17 -1
- package/dist/esm/model/message-diagnostics.js +17 -4
- package/dist/esm/model/options.d.ts +18 -1
- package/dist/esm/model/options.js +9 -1
- package/dist/esm/model/preparation.d.ts +30 -2
- package/dist/esm/model/preparation.js +86 -12
- package/dist/esm/model/runner.d.ts +129 -5
- package/dist/esm/model/runner.js +414 -80
- package/dist/esm/model/selection-transport.d.ts +14 -1
- package/dist/esm/model/selection-transport.js +48 -8
- package/dist/esm/model/settings.d.ts +11 -0
- package/dist/esm/model/settings.js +67 -13
- package/dist/esm/model/token-budget.d.ts +59 -1
- package/dist/esm/model/token-budget.js +69 -11
- package/dist/esm/model/transports.d.ts +20 -2
- package/dist/esm/model/transports.js +59 -6
- package/dist/esm/structs/capabilities/invocation.d.ts +36 -0
- package/dist/esm/structs/capabilities/model.d.ts +27 -0
- package/dist/esm/structs/capabilities/tools.d.ts +38 -0
- package/dist/esm/structs/common.d.ts +62 -2
- package/dist/esm/structs/common.js +11 -0
- package/dist/esm/structs/context/fragments.d.ts +28 -0
- package/dist/esm/structs/context/journal.d.ts +28 -3
- package/dist/esm/structs/context/processing.d.ts +11 -0
- package/dist/esm/structs/debug.d.ts +58 -1
- package/dist/esm/structs/debug.js +34 -5
- package/dist/esm/structs/diagnostics.d.ts +119 -1
- package/dist/esm/structs/errors.d.ts +42 -1
- package/dist/esm/structs/errors.js +26 -1
- package/dist/esm/structs/execution/engine.d.ts +24 -1
- package/dist/esm/structs/execution/events.d.ts +12 -0
- package/dist/esm/structs/execution/workflow.d.ts +71 -0
- package/dist/esm/structs/index.d.ts +11 -1
- package/dist/esm/structs/index.js +11 -1
- package/dist/esm/structs/invocation.d.ts +30 -0
- package/dist/esm/structs/kits/aggregation.d.ts +12 -0
- package/dist/esm/structs/kits/answering/checks.d.ts +11 -0
- package/dist/esm/structs/kits/answering/flow.d.ts +35 -1
- package/dist/esm/structs/kits/answering/state.d.ts +21 -0
- package/dist/esm/structs/kits/answering/tasks.d.ts +21 -0
- package/dist/esm/structs/kits/artifacts.d.ts +14 -0
- package/dist/esm/structs/kits/candidates.d.ts +19 -0
- package/dist/esm/structs/kits/delivery.d.ts +22 -0
- package/dist/esm/structs/kits/durable.d.ts +56 -3
- package/dist/esm/structs/kits/durable.js +7 -0
- package/dist/esm/structs/kits/evidence.d.ts +23 -0
- package/dist/esm/structs/kits/family.d.ts +49 -1
- package/dist/esm/structs/kits/family.js +1 -0
- package/dist/esm/structs/kits/intents/catalog.d.ts +26 -0
- package/dist/esm/structs/kits/intents/registry.d.ts +34 -0
- package/dist/esm/structs/kits/intents/scopes.d.ts +36 -1
- package/dist/esm/structs/kits/interaction.d.ts +64 -0
- package/dist/esm/structs/kits/interaction.js +8 -1
- package/dist/esm/structs/kits/knowledge-publication.d.ts +43 -1
- package/dist/esm/structs/kits/knowledge-publication.js +1 -0
- package/dist/esm/structs/kits/knowledge.d.ts +39 -2
- package/dist/esm/structs/kits/normalization.d.ts +15 -0
- package/dist/esm/structs/kits/policies.d.ts +25 -1
- package/dist/esm/structs/kits/presentation/events.d.ts +28 -4
- package/dist/esm/structs/kits/presentation/outputs.d.ts +38 -1
- package/dist/esm/structs/kits/presentation/templates.d.ts +15 -0
- package/dist/esm/structs/kits/projection.d.ts +21 -0
- package/dist/esm/structs/kits/reflection.d.ts +61 -2
- package/dist/esm/structs/kits/reflection.js +18 -3
- package/dist/esm/structs/kits/retrieval.d.ts +38 -0
- package/dist/esm/structs/kits/search.d.ts +22 -0
- package/dist/esm/structs/kits/text-skills.d.ts +36 -0
- package/dist/esm/structs/kits/tools.d.ts +87 -0
- package/dist/esm/structs/model/chat-provider.d.ts +24 -1
- package/dist/esm/structs/model/chat-provider.js +6 -0
- package/dist/esm/structs/model/interactions.d.ts +38 -0
- package/dist/esm/structs/model/messages.d.ts +30 -0
- package/dist/esm/structs/model/runtime.d.ts +104 -6
- package/dist/esm/structs/support/capabilities.d.ts +19 -2
- package/dist/esm/structs/support/context-processing.d.ts +88 -9
- package/dist/esm/structs/support/context.d.ts +29 -1
- package/dist/esm/structs/support/model/completion.d.ts +50 -0
- package/dist/esm/structs/support/model/completion.js +1 -0
- package/dist/esm/structs/support/model/interactions.d.ts +13 -1
- package/dist/esm/structs/support/model/messages.d.ts +52 -0
- package/dist/esm/structs/support/model/messages.js +1 -0
- package/dist/esm/structs/support/model/provider-observer.d.ts +22 -1
- package/dist/esm/structs/support/model/provider.d.ts +71 -6
- package/dist/esm/structs/support/registration.d.ts +13 -0
- package/dist/esm/structs/support/schema.d.ts +14 -0
- package/dist/esm/structs/support/tools.d.ts +28 -0
- package/dist/esm/structs/support/transport/json.d.ts +16 -0
- package/dist/esm/structs/support/transport/sse.d.ts +15 -0
- package/dist/esm/structs/utils/rules.d.ts +19 -0
- package/dist/esm/support/capabilities.d.ts +25 -2
- package/dist/esm/support/capabilities.js +43 -6
- package/dist/esm/support/context/assembly.d.ts +35 -4
- package/dist/esm/support/context/assembly.js +88 -16
- package/dist/esm/support/context/compression.d.ts +17 -1
- package/dist/esm/support/context/compression.js +48 -6
- package/dist/esm/support/context/fragments.d.ts +6 -0
- package/dist/esm/support/context/fragments.js +6 -0
- package/dist/esm/support/context/history.d.ts +43 -0
- package/dist/esm/support/context/history.js +36 -1
- package/dist/esm/support/context/index.d.ts +13 -2
- package/dist/esm/support/context/index.js +12 -1
- package/dist/esm/support/context/nodes.d.ts +49 -3
- package/dist/esm/support/context/nodes.js +165 -36
- package/dist/esm/support/context/processing.d.ts +145 -1
- package/dist/esm/support/context/processing.js +320 -62
- package/dist/esm/support/context/selection-policy.d.ts +42 -2
- package/dist/esm/support/context/selection-policy.js +98 -21
- package/dist/esm/support/context/selection.d.ts +14 -1
- package/dist/esm/support/context/selection.js +61 -10
- package/dist/esm/support/context/snapshot.d.ts +23 -1
- package/dist/esm/support/context/snapshot.js +29 -7
- package/dist/esm/support/context/strategies.d.ts +35 -2
- package/dist/esm/support/context/strategies.js +120 -28
- package/dist/esm/support/index.d.ts +9 -1
- package/dist/esm/support/index.js +9 -1
- package/dist/esm/support/model/capabilities.d.ts +10 -0
- package/dist/esm/support/model/capabilities.js +20 -1
- package/dist/esm/support/model/chat-completions.d.ts +44 -15
- package/dist/esm/support/model/chat-completions.js +92 -20
- package/dist/esm/support/model/children.d.ts +32 -2
- package/dist/esm/support/model/children.js +34 -6
- package/dist/esm/support/model/compatible-provider.d.ts +29 -3
- package/dist/esm/support/model/compatible-provider.js +190 -60
- package/dist/esm/support/model/completion/calls.d.ts +40 -0
- package/dist/esm/support/model/completion/calls.js +58 -0
- package/dist/esm/support/model/completion/default.d.ts +10 -0
- package/dist/esm/support/model/completion/default.js +29 -0
- package/dist/esm/support/model/completion/index.d.ts +10 -0
- package/dist/esm/support/model/completion/index.js +22 -0
- package/dist/esm/support/model/completion/session.d.ts +11 -0
- package/dist/esm/support/model/completion/session.js +99 -0
- package/dist/esm/support/model/index.d.ts +14 -0
- package/dist/esm/support/model/index.js +12 -0
- package/dist/esm/support/model/interactions/index.d.ts +1 -1
- package/dist/esm/support/model/interactions/index.js +12 -1
- package/dist/esm/support/model/interactions/json-object.d.ts +6 -0
- package/dist/esm/support/model/interactions/json-object.js +6 -0
- package/dist/esm/support/model/interactions/native-functions.d.ts +6 -0
- package/dist/esm/support/model/interactions/native-functions.js +6 -0
- package/dist/esm/support/model/observer.d.ts +25 -2
- package/dist/esm/support/model/observer.js +32 -6
- package/dist/esm/support/model/preview-rules.d.ts +20 -2
- package/dist/esm/support/model/preview-rules.js +66 -16
- package/dist/esm/support/model/reply-preview.d.ts +15 -1
- package/dist/esm/support/model/reply-preview.js +77 -17
- package/dist/esm/support/model/stage-transport.d.ts +9 -1
- package/dist/esm/support/model/stage-transport.js +33 -7
- package/dist/esm/support/model/strategies.d.ts +24 -2
- package/dist/esm/support/model/strategies.js +75 -14
- package/dist/esm/support/model/transports.d.ts +17 -1
- package/dist/esm/support/model/transports.js +53 -11
- package/dist/esm/support/registration.d.ts +20 -1
- package/dist/esm/support/registration.js +49 -7
- package/dist/esm/support/schema.d.ts +31 -1
- package/dist/esm/support/schema.js +46 -4
- package/dist/esm/support/stream-events.d.ts +22 -1
- package/dist/esm/support/stream-events.js +60 -8
- package/dist/esm/support/tool-runtime.d.ts +6 -0
- package/dist/esm/support/tool-runtime.js +6 -0
- package/dist/esm/support/tools.d.ts +22 -0
- package/dist/esm/support/tools.js +79 -10
- package/dist/esm/support/transport/index.d.ts +7 -0
- package/dist/esm/support/transport/index.js +7 -0
- package/dist/esm/support/transport/json.d.ts +29 -2
- package/dist/esm/support/transport/json.js +28 -4
- package/dist/esm/support/transport/sse.d.ts +31 -1
- package/dist/esm/support/transport/sse.js +25 -2
- package/dist/esm/types.d.ts +9 -1
- package/dist/esm/utils/break-observer.d.ts +27 -2
- package/dist/esm/utils/break-observer.js +20 -2
- package/dist/esm/utils/cancellation.d.ts +56 -5
- package/dist/esm/utils/cancellation.js +77 -9
- package/dist/esm/utils/catalog.d.ts +20 -1
- package/dist/esm/utils/catalog.js +19 -4
- package/dist/esm/utils/debug.d.ts +20 -1
- package/dist/esm/utils/debug.js +14 -2
- package/dist/esm/utils/index.d.ts +8 -0
- package/dist/esm/utils/index.js +8 -0
- package/dist/esm/utils/interaction-definition.d.ts +18 -1
- package/dist/esm/utils/interaction-definition.js +26 -6
- package/dist/esm/utils/invocation.d.ts +36 -1
- package/dist/esm/utils/invocation.js +42 -4
- package/dist/esm/utils/model-protocol.d.ts +8 -0
- package/dist/esm/utils/model-protocol.js +20 -1
- package/dist/esm/utils/object.d.ts +16 -0
- package/dist/esm/utils/object.js +16 -0
- package/dist/esm/utils/observer.d.ts +19 -1
- package/dist/esm/utils/observer.js +22 -2
- package/dist/esm/utils/protocol-registry.d.ts +38 -1
- package/dist/esm/utils/protocol-registry.js +47 -4
- package/dist/esm/utils/query-key.d.ts +11 -1
- package/dist/esm/utils/query-key.js +21 -2
- package/dist/esm/utils/registration.d.ts +34 -2
- package/dist/esm/utils/registration.js +18 -2
- package/dist/esm/utils/rules.d.ts +81 -4
- package/dist/esm/utils/rules.js +39 -11
- package/dist/esm/utils/schema-adapter.d.ts +12 -1
- package/dist/esm/utils/schema-adapter.js +25 -2
- package/dist/esm/utils/synchronous.d.ts +60 -4
- package/dist/esm/utils/synchronous.js +64 -7
- package/dist/esm/utils/text.d.ts +15 -1
- package/dist/esm/utils/text.js +15 -1
- package/package.json +3 -2
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createReplyPreview = createReplyPreview;
|
|
4
|
+
/**
|
|
5
|
+
* Incremental reply preview: project partial model output into presentable bubbles.
|
|
6
|
+
*
|
|
7
|
+
* The projection is a lexical scan, deliberately separate from authoritative JSON or schema
|
|
8
|
+
* validation, and it only reads explicitly registered prose fields. It is presentation only: it
|
|
9
|
+
* must never authorize, persist or execute a proposal.
|
|
10
|
+
*
|
|
11
|
+
* Main export: `createReplyPreview` and its rule/settings types.
|
|
12
|
+
*/
|
|
4
13
|
const synchronous_js_1 = require("../../utils/synchronous.js");
|
|
5
14
|
/** Incremental lexical projection, deliberately separate from authoritative JSON/schema validation. */
|
|
6
15
|
class StringProjection {
|
|
@@ -44,7 +53,16 @@ class StringProjection {
|
|
|
44
53
|
if (ch === 'u')
|
|
45
54
|
token.unicode = '';
|
|
46
55
|
else {
|
|
47
|
-
const escapes = {
|
|
56
|
+
const escapes = {
|
|
57
|
+
'"': '"',
|
|
58
|
+
'\\': '\\',
|
|
59
|
+
'/': '/',
|
|
60
|
+
b: '\b',
|
|
61
|
+
f: '\f',
|
|
62
|
+
n: '\n',
|
|
63
|
+
r: '\r',
|
|
64
|
+
t: '\t',
|
|
65
|
+
};
|
|
48
66
|
if (!(ch in escapes))
|
|
49
67
|
throw new Error('Invalid escape');
|
|
50
68
|
token.text += escapes[ch];
|
|
@@ -89,7 +107,9 @@ class StringProjection {
|
|
|
89
107
|
}
|
|
90
108
|
const frame = this.stack.at(-1);
|
|
91
109
|
if (ch === '}' || ch === ']') {
|
|
92
|
-
if (!frame ||
|
|
110
|
+
if (!frame ||
|
|
111
|
+
(ch === '}' ? frame.kind !== '{' : frame.kind !== '[') ||
|
|
112
|
+
!['key', 'value', 'comma'].includes(frame.state))
|
|
93
113
|
throw new Error('Invalid close');
|
|
94
114
|
this.stack.pop();
|
|
95
115
|
this.complete();
|
|
@@ -111,8 +131,16 @@ class StringProjection {
|
|
|
111
131
|
if (!frame || !['key', 'value'].includes(frame.state))
|
|
112
132
|
throw new Error('Invalid string position');
|
|
113
133
|
const key = frame.state === 'key', path = this.path();
|
|
114
|
-
const projected = !key &&
|
|
115
|
-
|
|
134
|
+
const projected = !key &&
|
|
135
|
+
this.paths.some((pattern) => path.length === pattern.length &&
|
|
136
|
+
pattern.every((key, i) => (key === '*' ? /^\d+$/.test(path[i]) : key === path[i])));
|
|
137
|
+
this.token = {
|
|
138
|
+
key,
|
|
139
|
+
path,
|
|
140
|
+
text: '',
|
|
141
|
+
projectionKey: projected ? JSON.stringify(path) : undefined,
|
|
142
|
+
escape: false,
|
|
143
|
+
};
|
|
116
144
|
continue;
|
|
117
145
|
}
|
|
118
146
|
if (frame && frame.state !== 'value')
|
|
@@ -123,23 +151,46 @@ class StringProjection {
|
|
|
123
151
|
if (ch === '{' || ch === '[') {
|
|
124
152
|
if (this.stack.length >= 32)
|
|
125
153
|
throw new Error('Too deep');
|
|
126
|
-
this.stack.push({
|
|
154
|
+
this.stack.push({
|
|
155
|
+
path: this.path(),
|
|
156
|
+
kind: ch,
|
|
157
|
+
state: ch === '{' ? 'key' : 'value',
|
|
158
|
+
index: 0,
|
|
159
|
+
keys: new Set(),
|
|
160
|
+
});
|
|
127
161
|
}
|
|
128
162
|
else
|
|
129
163
|
this.primitive = true;
|
|
130
164
|
}
|
|
131
165
|
}
|
|
132
|
-
string(path) {
|
|
166
|
+
string(path) {
|
|
167
|
+
const key = JSON.stringify(path);
|
|
168
|
+
return this.completedStrings.has(key) ? this.values.get(key)?.text : undefined;
|
|
169
|
+
}
|
|
133
170
|
texts(paths = this.paths) {
|
|
134
171
|
// Later bubbles can arrive first in JSON; keep their indices stable until the leading prose exists.
|
|
135
172
|
const first = paths[0];
|
|
136
173
|
if (first && !first.includes('*') && !this.values.has(JSON.stringify(first)))
|
|
137
174
|
return [];
|
|
138
|
-
return paths
|
|
139
|
-
.
|
|
175
|
+
return paths
|
|
176
|
+
.flatMap((pattern) => [...this.values.values()]
|
|
177
|
+
.filter(({ path }) => path.length === pattern.length &&
|
|
178
|
+
pattern.every((key, i) => (key === '*' ? /^\d+$/.test(path[i]) : key === path[i])))
|
|
179
|
+
.sort((a, b) => Number(a.path.at(-1)) - Number(b.path.at(-1))))
|
|
180
|
+
.map((value) => value.text);
|
|
140
181
|
}
|
|
141
182
|
}
|
|
142
|
-
/**
|
|
183
|
+
/**
|
|
184
|
+
* Create a model-output event handler that publishes preview bubbles.
|
|
185
|
+
*
|
|
186
|
+
* The handler resets on `model.start`, ignores other invocations, disables itself on unexpected
|
|
187
|
+
* output, and clears the preview when a call ends unsuccessfully. Rules are snapshotted at
|
|
188
|
+
* creation, and only explicitly registered prose fields are projected.
|
|
189
|
+
*
|
|
190
|
+
* @param options Rules, optional renderer, character budget and the bubble sink.
|
|
191
|
+
* @returns An async handler for `ModelOutputEvent`.
|
|
192
|
+
* @throws {TypeError} When the sink is missing or `maxChars` is not a positive integer.
|
|
193
|
+
*/
|
|
143
194
|
function createReplyPreview(options) {
|
|
144
195
|
if (typeof options.sink !== 'function')
|
|
145
196
|
throw new TypeError('A reply preview sink is required');
|
|
@@ -147,7 +198,7 @@ function createReplyPreview(options) {
|
|
|
147
198
|
const maxChars = options.maxChars ?? 16000;
|
|
148
199
|
if (!Number.isSafeInteger(maxChars) || maxChars < 1)
|
|
149
200
|
throw new TypeError('Invalid reply preview budget');
|
|
150
|
-
const rules = options.rules.map(rule => Object.freeze({
|
|
201
|
+
const rules = options.rules.map((rule) => Object.freeze({
|
|
151
202
|
capabilityId: rule.capabilityId,
|
|
152
203
|
stageId: rule.stageId,
|
|
153
204
|
paths: rule.paths === undefined ? undefined : structuredClone(rule.paths),
|
|
@@ -158,10 +209,13 @@ function createReplyPreview(options) {
|
|
|
158
209
|
let selected;
|
|
159
210
|
let activeCall;
|
|
160
211
|
const publish = async (texts) => {
|
|
161
|
-
// Hold incomplete surrogate pairs and never show internal control characters.
|
|
212
|
+
// Hold incomplete surrogate pairs and never show internal control characters. The bubble cap
|
|
213
|
+
// is independent of `maxChars`: at most five bubbles and 16000 characters reach the sink.
|
|
162
214
|
let remaining = 16000;
|
|
163
|
-
const bubbles = texts.slice(0, 5).map(text => {
|
|
164
|
-
const value = (render ? (0, synchronous_js_1.synchronous)(render(text), 'Reply preview renderers must be synchronous') : text)
|
|
215
|
+
const bubbles = texts.slice(0, 5).map((text) => {
|
|
216
|
+
const value = (render ? (0, synchronous_js_1.synchronous)(render(text), 'Reply preview renderers must be synchronous') : text)
|
|
217
|
+
.slice(0, remaining)
|
|
218
|
+
.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]|[\ud800-\udbff]$/gu, '');
|
|
165
219
|
remaining -= value.length;
|
|
166
220
|
return value;
|
|
167
221
|
});
|
|
@@ -197,14 +251,17 @@ function createReplyPreview(options) {
|
|
|
197
251
|
if (disabled)
|
|
198
252
|
return;
|
|
199
253
|
const part = event.payload.part;
|
|
200
|
-
chars +=
|
|
254
|
+
chars +=
|
|
255
|
+
typeof part === 'string'
|
|
256
|
+
? part.length
|
|
257
|
+
: (part.name?.length ?? 0) + (part.arguments?.length ?? 0);
|
|
201
258
|
if (chars > maxChars) {
|
|
202
259
|
disabled = true;
|
|
203
260
|
await publish([]);
|
|
204
261
|
return;
|
|
205
262
|
}
|
|
206
263
|
if (typeof part === 'string') {
|
|
207
|
-
const rule = rules.find(rule => !rule.capabilityId && rule.stageId === event.payload.stageId);
|
|
264
|
+
const rule = rules.find((rule) => !rule.capabilityId && rule.stageId === event.payload.stageId);
|
|
208
265
|
if (!rule) {
|
|
209
266
|
if (part.trim()) {
|
|
210
267
|
disabled = true;
|
|
@@ -222,7 +279,7 @@ function createReplyPreview(options) {
|
|
|
222
279
|
return;
|
|
223
280
|
}
|
|
224
281
|
name += part.name ?? '';
|
|
225
|
-
const rule = rules.find(rule => rule.capabilityId === name && (!rule.stageId || rule.stageId === event.payload.stageId));
|
|
282
|
+
const rule = rules.find((rule) => rule.capabilityId === name && (!rule.stageId || rule.stageId === event.payload.stageId));
|
|
226
283
|
if (!rule) {
|
|
227
284
|
if (selected) {
|
|
228
285
|
disabled = true;
|
|
@@ -235,7 +292,10 @@ function createReplyPreview(options) {
|
|
|
235
292
|
try {
|
|
236
293
|
if (!selected) {
|
|
237
294
|
selected = rule;
|
|
238
|
-
parser = new StringProjection([
|
|
295
|
+
parser = new StringProjection([
|
|
296
|
+
...(rule.paths ?? [['text'], ['bubbles', '*']]),
|
|
297
|
+
...(rule.when ? [rule.when.path] : []),
|
|
298
|
+
]);
|
|
239
299
|
parser.push(argumentsText);
|
|
240
300
|
argumentsText = '';
|
|
241
301
|
}
|
|
@@ -1,17 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createStageModelTransport = createStageModelTransport;
|
|
4
|
+
/**
|
|
5
|
+
* Stage-scoped model transport: expose only the capabilities declared for each stage.
|
|
6
|
+
*
|
|
7
|
+
* Static capability sources are projected once at construction; dynamic sources are re-projected
|
|
8
|
+
* at the model boundary. Either way, an undeclared stage or capability is rejected rather than
|
|
9
|
+
* silently omitted.
|
|
10
|
+
*
|
|
11
|
+
* Main export: `createStageModelTransport`.
|
|
12
|
+
*/
|
|
4
13
|
const synchronous_js_1 = require("../../utils/synchronous.js");
|
|
5
14
|
const model_js_1 = require("../../capabilities/model.js");
|
|
6
15
|
const rules_js_1 = require("../../utils/rules.js");
|
|
7
16
|
const transports_js_1 = require("./transports.js");
|
|
8
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Build a transport that projects a capability source through declared stage references.
|
|
19
|
+
*
|
|
20
|
+
* @param registration Transport declaration: unique ID, stage-to-capability references, interaction
|
|
21
|
+
* adapter, options and a static or per-stage capability source.
|
|
22
|
+
* @returns A Core model transport with `capabilities(stage)`.
|
|
23
|
+
* @throws {Error} When a stage ID repeats, has no capability IDs, the declaration has no stages, a
|
|
24
|
+
* stage or capability is not registered, or a dynamic capability source is asynchronous.
|
|
25
|
+
*/
|
|
9
26
|
function createStageModelTransport(registration) {
|
|
10
27
|
const stages = new Map();
|
|
11
28
|
for (const stage of registration.stages) {
|
|
12
29
|
const ids = stage.capabilityIds;
|
|
13
|
-
(0, rules_js_1.breakWhile)(!stage.id?.trim() ||
|
|
14
|
-
|
|
30
|
+
(0, rules_js_1.breakWhile)(!stage.id?.trim() ||
|
|
31
|
+
stages.has(stage.id) ||
|
|
32
|
+
!Array.isArray(ids) ||
|
|
33
|
+
!ids.length ||
|
|
34
|
+
new Set(ids).size !== ids.length, `Invalid model stage: ${stage.id}`);
|
|
15
35
|
stages.set(stage.id, Object.freeze([...ids]));
|
|
16
36
|
}
|
|
17
37
|
(0, rules_js_1.breakWhile)(!stages.size, 'Model transport requires declared stages');
|
|
@@ -33,13 +53,19 @@ function createStageModelTransport(registration) {
|
|
|
33
53
|
},
|
|
34
54
|
});
|
|
35
55
|
};
|
|
36
|
-
const fixed = typeof source === 'function'
|
|
37
|
-
|
|
56
|
+
const fixed = typeof source === 'function'
|
|
57
|
+
? undefined
|
|
58
|
+
: new Map([...stages.keys()].map((stage) => [stage, project(stage, source)]));
|
|
38
59
|
return (0, transports_js_1.createModelTransport)({
|
|
39
|
-
id,
|
|
60
|
+
id,
|
|
61
|
+
adapter,
|
|
62
|
+
options,
|
|
63
|
+
requireStrictArguments,
|
|
40
64
|
capabilities(stage) {
|
|
41
65
|
(0, rules_js_1.breakWhile)(!stages.has(stage), `Unregistered model stage: ${id} -> ${stage}`);
|
|
42
|
-
return fixed
|
|
66
|
+
return fixed
|
|
67
|
+
? fixed.get(stage)
|
|
68
|
+
: project(stage, (0, synchronous_js_1.synchronous)(source.call(registration, stage), 'Model capability sources must be synchronous'));
|
|
43
69
|
},
|
|
44
70
|
});
|
|
45
71
|
}
|
|
@@ -2,21 +2,70 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.modelBudgetStrategies = void 0;
|
|
4
4
|
exports.createModelStrategy = createModelStrategy;
|
|
5
|
+
/**
|
|
6
|
+
* Model strategy presets: compose a Core `ModelRunnerOptions` from named sources.
|
|
7
|
+
*
|
|
8
|
+
* A strategy selects a model definition (inline or by catalog ID), optional reasoning variant and
|
|
9
|
+
* a budget preset, then layers any explicit Core fields last. Values are local admission
|
|
10
|
+
* allowances, not claims about provider capacity or performance.
|
|
11
|
+
*
|
|
12
|
+
* Main exports: `modelBudgetStrategies`, `createModelStrategy` and the strategy option types.
|
|
13
|
+
*/
|
|
5
14
|
const binding_js_1 = require("../../model/binding.js");
|
|
6
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Budget presets by expected workload size.
|
|
17
|
+
*
|
|
18
|
+
* `maxCalls` counts model calls per run; `maxInputChars`/`maxOutputChars` are character budgets;
|
|
19
|
+
* `maxOutputTokens` is the per-call output reservation; `callTimeoutMs` bounds one call in
|
|
20
|
+
* milliseconds. These are local admission and output allowances, never a claim about provider
|
|
21
|
+
* capacity or performance.
|
|
22
|
+
*/
|
|
7
23
|
exports.modelBudgetStrategies = Object.freeze({
|
|
8
|
-
small: Object.freeze({
|
|
9
|
-
|
|
10
|
-
|
|
24
|
+
small: Object.freeze({
|
|
25
|
+
maxCalls: 2,
|
|
26
|
+
maxInputChars: 8000,
|
|
27
|
+
maxOutputChars: 4000,
|
|
28
|
+
maxOutputTokens: 512,
|
|
29
|
+
callTimeoutMs: 15000,
|
|
30
|
+
}),
|
|
31
|
+
medium: Object.freeze({
|
|
32
|
+
maxCalls: 8,
|
|
33
|
+
maxInputChars: 32000,
|
|
34
|
+
maxOutputChars: 16000,
|
|
35
|
+
maxOutputTokens: 1024,
|
|
36
|
+
callTimeoutMs: 30000,
|
|
37
|
+
}),
|
|
38
|
+
large: Object.freeze({
|
|
39
|
+
maxCalls: 16,
|
|
40
|
+
maxInputChars: 64000,
|
|
41
|
+
maxOutputChars: 32000,
|
|
42
|
+
maxOutputTokens: 4096,
|
|
43
|
+
callTimeoutMs: 60000,
|
|
44
|
+
}),
|
|
11
45
|
});
|
|
12
|
-
// Exhaustiveness ensures new Core settings cannot silently disappear at this boundary
|
|
46
|
+
// Exhaustiveness ensures new Core settings cannot silently disappear at this boundary: adding a
|
|
47
|
+
// setting to `ModelRunnerSettings` without listing it here fails type checking.
|
|
13
48
|
const budgetSettingKeys = {
|
|
14
|
-
maxCalls: true,
|
|
15
|
-
|
|
49
|
+
maxCalls: true,
|
|
50
|
+
callTimeoutMs: true,
|
|
51
|
+
maxOutputChars: true,
|
|
52
|
+
usage: true,
|
|
53
|
+
children: true,
|
|
54
|
+
maxInputChars: true,
|
|
55
|
+
maxSchemaChars: true,
|
|
56
|
+
tokenBudget: true,
|
|
57
|
+
maxOutputTokens: true,
|
|
16
58
|
};
|
|
17
59
|
const settingKeys = {
|
|
18
|
-
...budgetSettingKeys,
|
|
60
|
+
...budgetSettingKeys,
|
|
61
|
+
provider: true,
|
|
62
|
+
execution: true,
|
|
63
|
+
transports: true,
|
|
64
|
+
sink: true,
|
|
65
|
+
errors: true,
|
|
19
66
|
};
|
|
67
|
+
// Copy only known Core keys, so helper fields such as `model`, `models` or `budget` in a selected
|
|
68
|
+
// definition are not forwarded as runner options.
|
|
20
69
|
function settings(source) {
|
|
21
70
|
const result = {};
|
|
22
71
|
for (const key of Object.keys(settingKeys))
|
|
@@ -42,20 +91,32 @@ function createModelStrategy(options) {
|
|
|
42
91
|
if (typeof model !== 'string' && models !== undefined)
|
|
43
92
|
throw new TypeError('Use a model ID with configured models');
|
|
44
93
|
const selected = typeof model === 'string'
|
|
45
|
-
? models && Object.hasOwn(models, model)
|
|
94
|
+
? models && Object.hasOwn(models, model)
|
|
95
|
+
? models[model]
|
|
96
|
+
: undefined
|
|
97
|
+
: model;
|
|
46
98
|
if (!selected || typeof selected !== 'object')
|
|
47
99
|
throw new TypeError(`Unknown model strategy: ${String(model)}`);
|
|
48
|
-
const reasoningSettings = reasoning === undefined
|
|
49
|
-
|
|
100
|
+
const reasoningSettings = reasoning === undefined
|
|
101
|
+
? undefined
|
|
102
|
+
: reasoningOptions && Object.hasOwn(reasoningOptions, reasoning)
|
|
103
|
+
? reasoningOptions[reasoning]
|
|
104
|
+
: undefined;
|
|
50
105
|
if (reasoning !== undefined && !reasoningSettings)
|
|
51
106
|
throw new TypeError(`Unknown reasoning strategy: ${reasoning}`);
|
|
52
107
|
if (typeof budget === 'string' && !Object.hasOwn(exports.modelBudgetStrategies, budget))
|
|
53
108
|
throw new TypeError(`Unknown model budget: ${budget}`);
|
|
54
|
-
if (!budget ||
|
|
109
|
+
if (!budget ||
|
|
110
|
+
(typeof budget !== 'string' && (typeof budget !== 'object' || Array.isArray(budget))))
|
|
55
111
|
throw new TypeError('Invalid model budget strategy');
|
|
56
112
|
const preset = typeof budget === 'string' ? exports.modelBudgetStrategies[budget] : exports.modelBudgetStrategies.medium;
|
|
57
|
-
const result = {
|
|
58
|
-
...
|
|
113
|
+
const result = {
|
|
114
|
+
...preset,
|
|
115
|
+
...settings(selected),
|
|
116
|
+
...(reasoningSettings && settings(reasoningSettings)),
|
|
117
|
+
...(typeof budget === 'object' && budgetSettings(budget)),
|
|
118
|
+
...settings(options),
|
|
119
|
+
};
|
|
59
120
|
// Validate through the same Core rules without creating a request runner or spending calls.
|
|
60
121
|
(0, binding_js_1.snapshotModelBinding)(result);
|
|
61
122
|
return Object.freeze(result);
|
|
@@ -3,32 +3,71 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createModelTransport = void 0;
|
|
4
4
|
exports.createTextTransport = createTextTransport;
|
|
5
5
|
exports.createJsonTransport = createJsonTransport;
|
|
6
|
+
/**
|
|
7
|
+
* Model transport creators for plain text and typed JSON values.
|
|
8
|
+
*
|
|
9
|
+
* Both produce Core `ModelTransportDefinition` objects with an ID, so a runner can select them by
|
|
10
|
+
* name. Neither invokes a model: preparation, response assembly and parsing stay in Core.
|
|
11
|
+
*
|
|
12
|
+
* Main exports: `createTextTransport`, `createJsonTransport`, `createModelTransport` and the
|
|
13
|
+
* transport registration type.
|
|
14
|
+
*/
|
|
6
15
|
const schema_adapter_js_1 = require("../../utils/schema-adapter.js");
|
|
7
16
|
const options_js_1 = require("../../model/options.js");
|
|
8
17
|
const model_protocol_js_1 = require("../../utils/model-protocol.js");
|
|
9
18
|
const transports_js_1 = require("../../model/transports.js");
|
|
10
19
|
var selection_transport_js_1 = require("../../model/selection-transport.js");
|
|
11
20
|
Object.defineProperty(exports, "createModelTransport", { enumerable: true, get: function () { return selection_transport_js_1.createModelTransport; } });
|
|
21
|
+
/**
|
|
22
|
+
* Create a plain-text transport that trims the assembled response.
|
|
23
|
+
*
|
|
24
|
+
* @param definition Transport ID and optional temperature.
|
|
25
|
+
* @returns A frozen Core transport definition typed as string output.
|
|
26
|
+
*/
|
|
12
27
|
function createTextTransport(definition) {
|
|
13
28
|
return (0, transports_js_1.createPlainTextTransport)(definition.id, definition.options);
|
|
14
29
|
}
|
|
15
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Create a typed JSON transport without a capability-selection envelope.
|
|
32
|
+
*
|
|
33
|
+
* The transport embeds the JSON Schema in the instruction and requires the response to be one
|
|
34
|
+
* complete JSON value. The returned response parser rejects native call events and invalid JSON,
|
|
35
|
+
* then validates the value through the supplied schema.
|
|
36
|
+
*
|
|
37
|
+
* @param definition Transport ID, output schema and optional temperature/json settings.
|
|
38
|
+
* @returns A frozen Core transport definition typed as `Output`.
|
|
39
|
+
* @throws {TypeError} When the ID is blank or the schema adapter cannot be snapshotted.
|
|
40
|
+
*/
|
|
16
41
|
function createJsonTransport(definition) {
|
|
17
42
|
const { id, outputSchema, options } = definition;
|
|
18
43
|
if (typeof id !== 'string' || !id.trim())
|
|
19
44
|
throw new TypeError('JSON transport requires an ID');
|
|
20
45
|
const schema = (0, schema_adapter_js_1.snapshotSchemaAdapter)(outputSchema);
|
|
21
|
-
const settings = Object.freeze({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
46
|
+
const settings = Object.freeze({
|
|
47
|
+
...(0, options_js_1.snapshotModelOptions)({ temperature: options?.temperature, json: options?.json ?? true }),
|
|
48
|
+
});
|
|
49
|
+
const instruction = 'Return exactly one complete JSON value matching this JSON Schema: ' +
|
|
50
|
+
JSON.stringify(schema.jsonSchema) +
|
|
51
|
+
'\nReturn the value itself, without prose, fences, a schema document or a capability-selection envelope.';
|
|
52
|
+
return Object.freeze({
|
|
53
|
+
id,
|
|
54
|
+
prepare() {
|
|
55
|
+
return {
|
|
56
|
+
options: settings,
|
|
57
|
+
instruction,
|
|
58
|
+
schemaChars: instruction.length,
|
|
59
|
+
createResponse() {
|
|
26
60
|
let raw = '';
|
|
27
|
-
return {
|
|
61
|
+
return {
|
|
62
|
+
get outputChars() {
|
|
63
|
+
return raw.length;
|
|
64
|
+
},
|
|
65
|
+
push(part) {
|
|
28
66
|
if (typeof part !== 'string')
|
|
29
67
|
(0, model_protocol_js_1.modelProtocolError)('JSON value transport does not accept native call events');
|
|
30
68
|
raw += part;
|
|
31
|
-
},
|
|
69
|
+
},
|
|
70
|
+
finish() {
|
|
32
71
|
let value;
|
|
33
72
|
try {
|
|
34
73
|
value = JSON.parse(raw);
|
|
@@ -37,7 +76,10 @@ function createJsonTransport(definition) {
|
|
|
37
76
|
(0, model_protocol_js_1.modelProtocolError)('JSON value transport requires complete JSON');
|
|
38
77
|
}
|
|
39
78
|
return schema.parse(value);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
});
|
|
43
85
|
}
|
|
@@ -1,24 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defineRegistrationCatalog = defineRegistrationCatalog;
|
|
4
|
+
/**
|
|
5
|
+
* Conditional registration support: compile an ordered list of install steps for an application.
|
|
6
|
+
*
|
|
7
|
+
* Steps are validated and bound once, then installed per invocation. Predicates run at install
|
|
8
|
+
* time and only see what previous steps already installed, so ordering is part of the contract.
|
|
9
|
+
* This is app-side composition for Core-facing handlers; it defines no new scheduling protocol.
|
|
10
|
+
*
|
|
11
|
+
* Main export: `defineRegistrationCatalog`.
|
|
12
|
+
*/
|
|
4
13
|
const catalog_js_1 = require("../utils/catalog.js");
|
|
5
14
|
const synchronous_js_1 = require("../utils/synchronous.js");
|
|
6
15
|
const rules_js_1 = require("../utils/rules.js");
|
|
7
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Compile an ordered installation plan.
|
|
18
|
+
*
|
|
19
|
+
* Predicates observe the effects of preceding installations at request time; a predicate that
|
|
20
|
+
* throws rejects the install instead of being treated as `false`. Callbacks are bound to their
|
|
21
|
+
* declaring definition so implementations may rely on `this`.
|
|
22
|
+
*
|
|
23
|
+
* @param definitions Registration steps in execution order.
|
|
24
|
+
* @returns A frozen catalog plus `install(context)`, which runs enabled steps sequentially.
|
|
25
|
+
* @throws {Error} When a `register` handler is missing or a `when` predicate is not a function.
|
|
26
|
+
*/
|
|
8
27
|
function defineRegistrationCatalog(definitions) {
|
|
9
|
-
const catalog = (0, catalog_js_1.readonlyCatalog)(definitions.map(definition => {
|
|
28
|
+
const catalog = (0, catalog_js_1.readonlyCatalog)(definitions.map((definition) => {
|
|
10
29
|
const { id, when, register } = definition;
|
|
11
30
|
(0, rules_js_1.breakWhile)([
|
|
12
|
-
{
|
|
13
|
-
|
|
31
|
+
{
|
|
32
|
+
occur: typeof register !== 'function',
|
|
33
|
+
error: 'Missing registration handler',
|
|
34
|
+
tags: ['handler'],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
occur: when !== undefined && typeof when !== 'function',
|
|
38
|
+
error: 'Invalid registration predicate',
|
|
39
|
+
tags: ['predicate'],
|
|
40
|
+
},
|
|
14
41
|
], ['agent-core', 'registration']);
|
|
15
|
-
return Object.freeze({
|
|
16
|
-
|
|
42
|
+
return Object.freeze({
|
|
43
|
+
id,
|
|
44
|
+
when: when?.bind(definition),
|
|
45
|
+
register: register.bind(definition),
|
|
46
|
+
});
|
|
47
|
+
}), (id) => new TypeError(`Unknown registration: ${id}`));
|
|
17
48
|
return Object.freeze({
|
|
18
49
|
...catalog,
|
|
50
|
+
/**
|
|
51
|
+
* Run every enabled step in declaration order against `context`.
|
|
52
|
+
*
|
|
53
|
+
* Stops at the first failing predicate or handler; earlier installations are not rolled back.
|
|
54
|
+
*
|
|
55
|
+
* @param context Value passed to each predicate and registration handler.
|
|
56
|
+
* @throws {TypeError} When a predicate is asynchronous or does not return a boolean, or when
|
|
57
|
+
* a handler is asynchronous.
|
|
58
|
+
*/
|
|
19
59
|
install(context) {
|
|
20
60
|
for (const entry of catalog.definitions) {
|
|
21
|
-
const enabled = entry.when
|
|
61
|
+
const enabled = entry.when
|
|
62
|
+
? (0, synchronous_js_1.booleanResult)(entry.when(context), 'Registration predicates must be synchronous', 'Registration predicates must return boolean')
|
|
63
|
+
: true;
|
|
22
64
|
if (enabled) {
|
|
23
65
|
(0, synchronous_js_1.synchronous)(entry.register(context), 'Registration handlers must be synchronous');
|
|
24
66
|
}
|
|
@@ -3,10 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fromJsonSchema = fromJsonSchema;
|
|
4
4
|
exports.fromParserSchema = fromParserSchema;
|
|
5
5
|
exports.defineSchema = defineSchema;
|
|
6
|
+
/**
|
|
7
|
+
* Schema adapter helpers: turn JSON Schema compilers and library parsers into Core adapters.
|
|
8
|
+
*
|
|
9
|
+
* Support supplies the adapter shape and snapshotting; the compiler, validator package and error
|
|
10
|
+
* messages remain application choices. A plain JSON Schema without a typed compiler stays unknown
|
|
11
|
+
* instead of being silently treated as permissive.
|
|
12
|
+
*
|
|
13
|
+
* Main exports: `fromJsonSchema`, `fromParserSchema` and `defineSchema`.
|
|
14
|
+
*/
|
|
6
15
|
const schema_adapter_js_1 = require("../utils/schema-adapter.js");
|
|
7
16
|
const object_js_1 = require("../utils/object.js");
|
|
8
17
|
const synchronous_js_1 = require("../utils/synchronous.js");
|
|
9
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Build an adapter from a caller-owned typed JSON Schema compiler.
|
|
20
|
+
*
|
|
21
|
+
* The schema is cloned and frozen before it reaches the compiler, so later mutation of the input
|
|
22
|
+
* cannot change validation. Compilation and validation must both be synchronous.
|
|
23
|
+
*
|
|
24
|
+
* @param schema JSON Schema describing the accepted value.
|
|
25
|
+
* @param options Compiler plus an optional error factory for rejected values.
|
|
26
|
+
* @returns A frozen adapter exposing `jsonSchema` and a `parse` that returns the input as `Value`.
|
|
27
|
+
* @throws {TypeError} When the compiler is asynchronous or does not return a validator, or when no
|
|
28
|
+
* custom error applies; also when the validator is asynchronous or does not return a boolean.
|
|
29
|
+
*/
|
|
10
30
|
function fromJsonSchema(schema, options) {
|
|
11
31
|
const jsonSchema = structuredClone(schema);
|
|
12
32
|
(0, object_js_1.freezeSchema)(jsonSchema);
|
|
@@ -14,19 +34,41 @@ function fromJsonSchema(schema, options) {
|
|
|
14
34
|
if (typeof validate !== 'function')
|
|
15
35
|
throw new TypeError('Schema compilers must return a validator');
|
|
16
36
|
const error = options.error?.bind(options);
|
|
17
|
-
return (0, schema_adapter_js_1.snapshotSchemaAdapter)({
|
|
37
|
+
return (0, schema_adapter_js_1.snapshotSchemaAdapter)({
|
|
38
|
+
jsonSchema,
|
|
39
|
+
parse(value) {
|
|
18
40
|
const valid = (0, synchronous_js_1.booleanResult)(validate(value), 'Schema validators must be synchronous', 'Schema validators must return boolean');
|
|
19
41
|
if (!valid)
|
|
20
|
-
throw (0, synchronous_js_1.synchronous)(error?.(value, validate.errors), 'Schema error factories must be synchronous') ?? new TypeError('Input does not match JSON Schema');
|
|
42
|
+
throw ((0, synchronous_js_1.synchronous)(error?.(value, validate.errors), 'Schema error factories must be synchronous') ?? new TypeError('Input does not match JSON Schema'));
|
|
21
43
|
return value;
|
|
22
|
-
}
|
|
44
|
+
},
|
|
45
|
+
});
|
|
23
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Wrap a library schema that already parses values (for example Zod or Valibot style).
|
|
49
|
+
*
|
|
50
|
+
* `parse` is delegated unchanged, so the library keeps ownership of coercion and error reporting;
|
|
51
|
+
* only the JSON Schema projection is produced here.
|
|
52
|
+
*
|
|
53
|
+
* @param schema Object exposing a `parse` method.
|
|
54
|
+
* @param options Converter that projects the schema into JSON Schema.
|
|
55
|
+
* @returns A frozen adapter whose `parse` returns the wrapped parser's result type.
|
|
56
|
+
* @throws {TypeError} When the JSON Schema conversion is asynchronous.
|
|
57
|
+
*/
|
|
24
58
|
function fromParserSchema(schema, options) {
|
|
25
59
|
return (0, schema_adapter_js_1.snapshotSchemaAdapter)({
|
|
26
60
|
jsonSchema: (0, synchronous_js_1.synchronous)(options.toJsonSchema(schema), 'Schema conversion must be synchronous'),
|
|
27
61
|
parse: schema.parse.bind(schema),
|
|
28
62
|
});
|
|
29
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Re-snapshot an existing adapter without changing its behavior.
|
|
66
|
+
*
|
|
67
|
+
* Used to detach a caller-owned adapter from later mutation before it is exposed or reused.
|
|
68
|
+
*
|
|
69
|
+
* @param definition Adapter to copy.
|
|
70
|
+
* @returns A frozen adapter with the same validation and parsing behavior.
|
|
71
|
+
*/
|
|
30
72
|
function defineSchema(definition) {
|
|
31
73
|
return (0, schema_adapter_js_1.snapshotSchemaAdapter)(definition);
|
|
32
74
|
}
|