attention-manifest-protocol 0.4.0 → 0.4.2
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 +250 -226
- package/CHANGELOG.zh-CN.md +63 -39
- package/README.md +22 -1
- package/README.zh-CN.md +22 -1
- package/docs/probes/calibration-imported.json +141 -141
- package/docs/probes/eval-recorded-replay.json +597 -597
- package/docs/probes/eval-replay.json +124 -124
- package/docs/probes/eval-summary.json +42 -42
- package/docs/probes/runtime-eval.json +4230 -4230
- package/lib/attention/attention.d.ts +153 -0
- package/lib/attention/attention.js +209 -0
- package/lib/attention/budget.d.ts +31 -0
- package/lib/attention/budget.js +55 -0
- package/lib/attention/cognition.d.ts +230 -0
- package/lib/attention/cognition.js +245 -0
- package/lib/attention/index.d.ts +8 -0
- package/lib/attention/index.js +7 -0
- package/lib/attention/interrupts.d.ts +97 -0
- package/lib/attention/interrupts.js +151 -0
- package/lib/attention/resource.d.ts +167 -0
- package/lib/attention/resource.js +148 -0
- package/lib/attention/social.d.ts +74 -0
- package/lib/attention/social.js +153 -0
- package/lib/attention/socialTypes.d.ts +102 -0
- package/lib/attention/socialTypes.js +1 -0
- package/lib/authz/authz.d.ts +75 -0
- package/lib/authz/authz.js +176 -0
- package/lib/authz/index.d.ts +1 -0
- package/lib/authz/index.js +1 -0
- package/lib/bayes/calibration.d.ts +67 -0
- package/lib/bayes/calibration.js +114 -0
- package/lib/bayes/calibrationRegistry.d.ts +39 -0
- package/lib/bayes/calibrationRegistry.js +61 -0
- package/lib/bayes/calibrationSelection.d.ts +40 -0
- package/lib/bayes/calibrationSelection.js +89 -0
- package/lib/bayes/engine.d.ts +163 -0
- package/lib/bayes/engine.js +354 -0
- package/lib/bayes/index.d.ts +6 -0
- package/lib/bayes/index.js +6 -0
- package/lib/bayes/reliability.d.ts +27 -0
- package/lib/bayes/reliability.js +38 -0
- package/lib/bayes/scopedPriors.d.ts +34 -0
- package/lib/bayes/scopedPriors.js +70 -0
- package/lib/boundary/frame.d.ts +63 -0
- package/lib/boundary/frame.js +239 -0
- package/lib/boundary/ids.d.ts +8 -0
- package/lib/boundary/ids.js +12 -0
- package/lib/boundary/index.d.ts +12 -0
- package/lib/boundary/index.js +8 -0
- package/lib/boundary/refTable.d.ts +49 -0
- package/lib/boundary/refTable.js +92 -0
- package/lib/boundary/toolCall.d.ts +33 -0
- package/lib/boundary/toolCall.js +173 -0
- package/lib/concept/concept.d.ts +67 -0
- package/lib/concept/concept.js +1 -0
- package/lib/concept/conceptBudget.d.ts +56 -0
- package/lib/concept/conceptBudget.js +281 -0
- package/lib/concept/conceptBudgetTypes.d.ts +74 -0
- package/lib/concept/conceptBudgetTypes.js +1 -0
- package/lib/concept/index.d.ts +3 -0
- package/lib/concept/index.js +3 -0
- package/lib/concurrency/idempotency.d.ts +16 -0
- package/lib/concurrency/idempotency.js +21 -0
- package/lib/concurrency/index.d.ts +5 -0
- package/lib/concurrency/index.js +5 -0
- package/lib/concurrency/mutex.d.ts +13 -0
- package/lib/concurrency/mutex.js +26 -0
- package/lib/concurrency/namedLocks.d.ts +7 -0
- package/lib/concurrency/namedLocks.js +31 -0
- package/lib/concurrency/retry.d.ts +23 -0
- package/lib/concurrency/retry.js +38 -0
- package/lib/concurrency/worker.d.ts +42 -0
- package/lib/concurrency/worker.js +67 -0
- package/lib/context/agentContext.d.ts +58 -0
- package/lib/context/agentContext.js +197 -0
- package/lib/context/ast.d.ts +98 -0
- package/lib/context/ast.js +414 -0
- package/lib/context/contentStore.d.ts +16 -0
- package/lib/context/contentStore.js +61 -0
- package/lib/context/context.d.ts +15 -0
- package/lib/context/context.js +39 -0
- package/lib/context/contextIndex.d.ts +40 -0
- package/lib/context/contextIndex.js +64 -0
- package/lib/context/document.d.ts +102 -0
- package/lib/context/document.js +22 -0
- package/lib/context/fileStorePath.d.ts +1 -0
- package/lib/context/fileStorePath.js +13 -0
- package/lib/context/index.d.ts +22 -0
- package/lib/context/index.js +11 -0
- package/lib/context/lifecycle.d.ts +91 -0
- package/lib/context/lifecycle.js +163 -0
- package/lib/context/projections.d.ts +20 -0
- package/lib/context/projections.js +127 -0
- package/lib/context/workspace.d.ts +111 -0
- package/lib/context/workspace.js +318 -0
- package/lib/context/workspaceProtocol.d.ts +30 -0
- package/lib/context/workspaceProtocol.js +49 -0
- package/lib/context/workspaceService.d.ts +63 -0
- package/lib/context/workspaceService.js +352 -0
- package/lib/cooperation/board.d.ts +47 -0
- package/lib/cooperation/board.js +66 -0
- package/lib/cooperation/collaboration.d.ts +55 -0
- package/lib/cooperation/collaboration.js +1 -0
- package/lib/cooperation/index.d.ts +6 -0
- package/lib/cooperation/index.js +6 -0
- package/lib/cooperation/merge.d.ts +69 -0
- package/lib/cooperation/merge.js +109 -0
- package/lib/cooperation/metrics.d.ts +39 -0
- package/lib/cooperation/metrics.js +17 -0
- package/lib/cooperation/session.d.ts +75 -0
- package/lib/cooperation/session.js +74 -0
- package/lib/cooperation/unified.d.ts +38 -0
- package/lib/cooperation/unified.js +40 -0
- package/lib/database/adapter/adapters.d.ts +24 -0
- package/lib/database/adapter/adapters.js +31 -0
- package/lib/database/adapter/index.d.ts +4 -0
- package/lib/database/adapter/index.js +4 -0
- package/lib/database/adapter/runtimeSink.d.ts +20 -0
- package/lib/database/adapter/runtimeSink.js +50 -0
- package/lib/database/adapter/sessionStore.d.ts +11 -0
- package/lib/database/adapter/sessionStore.js +23 -0
- package/lib/database/adapter/turnStore.d.ts +10 -0
- package/lib/database/adapter/turnStore.js +15 -0
- package/lib/database/entity/agent.d.ts +133 -0
- package/lib/database/entity/agent.js +61 -0
- package/lib/database/entity/entity.d.ts +715 -0
- package/lib/database/entity/entity.js +372 -0
- package/lib/database/entity/handle.d.ts +31 -0
- package/lib/database/entity/handle.js +53 -0
- package/lib/database/entity/index.d.ts +32 -0
- package/lib/database/entity/index.js +22 -0
- package/lib/database/entity/message.d.ts +27 -0
- package/lib/database/entity/message.js +52 -0
- package/lib/database/entity/meta.d.ts +11 -0
- package/lib/database/entity/meta.js +1 -0
- package/lib/database/entity/object.d.ts +23 -0
- package/lib/database/entity/object.js +24 -0
- package/lib/database/entity/outbox.d.ts +9 -0
- package/lib/database/entity/outbox.js +5 -0
- package/lib/database/entity/process.d.ts +30 -0
- package/lib/database/entity/process.js +40 -0
- package/lib/database/entity/registry.d.ts +81 -0
- package/lib/database/entity/registry.js +91 -0
- package/lib/database/entity/runtimeApproval.d.ts +23 -0
- package/lib/database/entity/runtimeApproval.js +5 -0
- package/lib/database/entity/runtimeSession.d.ts +7 -0
- package/lib/database/entity/runtimeSession.js +5 -0
- package/lib/database/entity/runtimeTurn.d.ts +9 -0
- package/lib/database/entity/runtimeTurn.js +5 -0
- package/lib/database/entity/thread.d.ts +35 -0
- package/lib/database/entity/thread.js +55 -0
- package/lib/database/entity/window.d.ts +39 -0
- package/lib/database/entity/window.js +56 -0
- package/lib/database/entity/worker.d.ts +42 -0
- package/lib/database/entity/worker.js +58 -0
- package/lib/database/index.d.ts +6 -0
- package/lib/database/index.js +6 -0
- package/lib/database/repository/addressSpaceRepository.d.ts +18 -0
- package/lib/database/repository/addressSpaceRepository.js +40 -0
- package/lib/database/repository/agentRepository.d.ts +41 -0
- package/lib/database/repository/agentRepository.js +398 -0
- package/lib/database/repository/base.d.ts +31 -0
- package/lib/database/repository/base.js +23 -0
- package/lib/database/repository/executionRepository.d.ts +64 -0
- package/lib/database/repository/executionRepository.js +379 -0
- package/lib/database/repository/handleRepository.d.ts +35 -0
- package/lib/database/repository/handleRepository.js +57 -0
- package/lib/database/repository/index.d.ts +20 -0
- package/lib/database/repository/index.js +17 -0
- package/lib/database/repository/messageRepository.d.ts +33 -0
- package/lib/database/repository/messageRepository.js +45 -0
- package/lib/database/repository/objectRepository.d.ts +43 -0
- package/lib/database/repository/objectRepository.js +60 -0
- package/lib/database/repository/outboxRepository.d.ts +15 -0
- package/lib/database/repository/outboxRepository.js +51 -0
- package/lib/database/repository/processRepository.d.ts +31 -0
- package/lib/database/repository/processRepository.js +48 -0
- package/lib/database/repository/registryRepository.d.ts +72 -0
- package/lib/database/repository/registryRepository.js +95 -0
- package/lib/database/repository/repository.d.ts +322 -0
- package/lib/database/repository/repository.js +332 -0
- package/lib/database/repository/runtimeApprovalRepository.d.ts +14 -0
- package/lib/database/repository/runtimeApprovalRepository.js +35 -0
- package/lib/database/repository/runtimeSessionRepository.d.ts +9 -0
- package/lib/database/repository/runtimeSessionRepository.js +21 -0
- package/lib/database/repository/runtimeTurnRepository.d.ts +10 -0
- package/lib/database/repository/runtimeTurnRepository.js +32 -0
- package/lib/database/repository/socialRepository.d.ts +22 -0
- package/lib/database/repository/socialRepository.js +155 -0
- package/lib/database/repository/threadRepository.d.ts +29 -0
- package/lib/database/repository/threadRepository.js +48 -0
- package/lib/database/repository/windowRepository.d.ts +46 -0
- package/lib/database/repository/windowRepository.js +68 -0
- package/lib/database/repository/workerRepository.d.ts +38 -0
- package/lib/database/repository/workerRepository.js +61 -0
- package/lib/database/service/database.d.ts +55 -0
- package/lib/database/service/database.js +77 -0
- package/lib/database/service/handleService.d.ts +20 -0
- package/lib/database/service/handleService.js +34 -0
- package/lib/database/service/index.d.ts +16 -0
- package/lib/database/service/index.js +11 -0
- package/lib/database/service/messageService.d.ts +26 -0
- package/lib/database/service/messageService.js +40 -0
- package/lib/database/service/objectService.d.ts +32 -0
- package/lib/database/service/objectService.js +31 -0
- package/lib/database/service/processService.d.ts +22 -0
- package/lib/database/service/processService.js +45 -0
- package/lib/database/service/registryServices.d.ts +43 -0
- package/lib/database/service/registryServices.js +60 -0
- package/lib/database/service/service.d.ts +131 -0
- package/lib/database/service/service.js +153 -0
- package/lib/database/service/stepService.d.ts +23 -0
- package/lib/database/service/stepService.js +35 -0
- package/lib/database/service/threadService.d.ts +23 -0
- package/lib/database/service/threadService.js +48 -0
- package/lib/database/service/windowService.d.ts +15 -0
- package/lib/database/service/windowService.js +22 -0
- package/lib/database/service/workerService.d.ts +28 -0
- package/lib/database/service/workerService.js +34 -0
- package/lib/database/sql/index.d.ts +3 -0
- package/lib/database/sql/index.js +2 -0
- package/lib/database/sql/schema.d.ts +5 -0
- package/lib/database/sql/schema.js +416 -0
- package/lib/database/sql/sql.d.ts +290 -0
- package/lib/database/sql/sql.js +430 -0
- package/lib/database/store/database.d.ts +75 -0
- package/lib/database/store/database.js +143 -0
- package/lib/database/store/index.d.ts +3 -0
- package/lib/database/store/index.js +2 -0
- package/lib/database/store/store.d.ts +145 -0
- package/lib/database/store/store.js +192 -0
- package/lib/delegate/index.d.ts +2 -0
- package/lib/delegate/index.js +2 -0
- package/lib/delegate/team.d.ts +92 -0
- package/lib/delegate/team.js +200 -0
- package/lib/delegate/teamTypes.d.ts +43 -0
- package/lib/delegate/teamTypes.js +1 -0
- package/lib/diagnosis/checklist.d.ts +16 -0
- package/lib/diagnosis/checklist.js +61 -0
- package/lib/diagnosis/context.d.ts +19 -0
- package/lib/diagnosis/context.js +79 -0
- package/lib/diagnosis/frame.d.ts +34 -0
- package/lib/diagnosis/frame.js +230 -0
- package/lib/diagnosis/index.d.ts +5 -0
- package/lib/diagnosis/index.js +5 -0
- package/lib/diagnosis/router.d.ts +22 -0
- package/lib/diagnosis/router.js +47 -0
- package/lib/diagnosis/types.d.ts +78 -0
- package/lib/diagnosis/types.js +2 -0
- package/lib/error/agentError.d.ts +9 -0
- package/lib/error/agentError.js +13 -0
- package/lib/error/ampError.d.ts +14 -0
- package/lib/error/ampError.js +19 -0
- package/lib/error/authzError.d.ts +10 -0
- package/lib/error/authzError.js +11 -0
- package/lib/error/boundaryRejection.d.ts +16 -0
- package/lib/error/boundaryRejection.js +14 -0
- package/lib/error/index.d.ts +7 -0
- package/lib/error/index.js +7 -0
- package/lib/error/kernelError.d.ts +11 -0
- package/lib/error/kernelError.js +12 -0
- package/lib/error/mailboxError.d.ts +5 -0
- package/lib/error/mailboxError.js +6 -0
- package/lib/error/windowError.d.ts +8 -0
- package/lib/error/windowError.js +9 -0
- package/lib/evaluation/agreement.d.ts +22 -0
- package/lib/evaluation/agreement.js +82 -0
- package/lib/evaluation/index.d.ts +2 -0
- package/lib/evaluation/index.js +2 -0
- package/lib/evaluation/labels.d.ts +56 -0
- package/lib/evaluation/labels.js +206 -0
- package/lib/evidence/evidenceGraph.d.ts +37 -0
- package/lib/evidence/evidenceGraph.js +165 -0
- package/lib/evidence/index.d.ts +4 -0
- package/lib/evidence/index.js +2 -0
- package/lib/evidence/revalidation.d.ts +70 -0
- package/lib/evidence/revalidation.js +146 -0
- package/lib/execution/exec.d.ts +151 -0
- package/lib/execution/exec.js +282 -0
- package/lib/execution/handles.d.ts +25 -0
- package/lib/execution/handles.js +45 -0
- package/lib/execution/index.d.ts +3 -0
- package/lib/execution/index.js +3 -0
- package/lib/execution/pin.d.ts +60 -0
- package/lib/execution/pin.js +103 -0
- package/lib/frame/frame.d.ts +61 -0
- package/lib/frame/frame.js +1 -0
- package/lib/frame/index.d.ts +1 -0
- package/lib/frame/index.js +1 -0
- package/lib/goal/goal.d.ts +19 -0
- package/lib/goal/goal.js +21 -0
- package/lib/goal/index.d.ts +2 -0
- package/lib/goal/index.js +1 -0
- package/lib/goal/plan.d.ts +125 -0
- package/lib/goal/plan.js +60 -0
- package/lib/governance/attentionManifest.d.ts +279 -0
- package/lib/governance/attentionManifest.js +467 -0
- package/lib/governance/audit.d.ts +123 -0
- package/lib/governance/audit.js +263 -0
- package/lib/governance/budget.d.ts +219 -0
- package/lib/governance/budget.js +424 -0
- package/lib/governance/context.d.ts +159 -0
- package/lib/governance/context.js +229 -0
- package/lib/governance/control.d.ts +65 -0
- package/lib/governance/control.js +89 -0
- package/lib/governance/cooperation.d.ts +163 -0
- package/lib/governance/cooperation.js +350 -0
- package/lib/governance/credential.d.ts +117 -0
- package/lib/governance/credential.js +229 -0
- package/lib/governance/httpServer.d.ts +18 -0
- package/lib/governance/httpServer.js +74 -0
- package/lib/governance/index.d.ts +32 -0
- package/lib/governance/index.js +32 -0
- package/lib/governance/legal.d.ts +222 -0
- package/lib/governance/legal.js +371 -0
- package/lib/governance/matrix.d.ts +170 -0
- package/lib/governance/matrix.js +365 -0
- package/lib/governance/perspectives.d.ts +98 -0
- package/lib/governance/perspectives.js +340 -0
- package/lib/governance/signing.d.ts +131 -0
- package/lib/governance/signing.js +241 -0
- package/lib/governance/store.d.ts +33 -0
- package/lib/governance/store.js +89 -0
- package/lib/governance/switching.d.ts +183 -0
- package/lib/governance/switching.js +257 -0
- package/lib/governance/toolPolicy.d.ts +37 -0
- package/lib/governance/toolPolicy.js +42 -0
- package/lib/governance/transport.d.ts +76 -0
- package/lib/governance/transport.js +124 -0
- package/lib/governance/types.d.ts +218 -0
- package/lib/governance/types.js +72 -0
- package/lib/governance/workflow.d.ts +174 -0
- package/lib/governance/workflow.js +612 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +11 -0
- package/lib/interaction/index.d.ts +1 -0
- package/lib/interaction/index.js +1 -0
- package/lib/interaction/interaction.d.ts +83 -0
- package/lib/interaction/interaction.js +256 -0
- package/lib/ipc/index.d.ts +4 -0
- package/lib/ipc/index.js +3 -0
- package/lib/ipc/mailbox.d.ts +37 -0
- package/lib/ipc/mailbox.js +77 -0
- package/lib/ipc/memorySocialStore.d.ts +14 -0
- package/lib/ipc/memorySocialStore.js +83 -0
- package/lib/ipc/social.d.ts +80 -0
- package/lib/ipc/social.js +1 -0
- package/lib/kernel/index.d.ts +2 -0
- package/lib/kernel/index.js +1 -0
- package/lib/kernel/scheduler.d.ts +195 -0
- package/lib/kernel/scheduler.js +334 -0
- package/lib/ledger/checkpoint.d.ts +116 -0
- package/lib/ledger/checkpoint.js +223 -0
- package/lib/ledger/index.d.ts +4 -0
- package/lib/ledger/index.js +4 -0
- package/lib/ledger/ledger.d.ts +21 -0
- package/lib/ledger/ledger.js +23 -0
- package/lib/ledger/persistence.d.ts +46 -0
- package/lib/ledger/persistence.js +106 -0
- package/lib/ledger/share.d.ts +29 -0
- package/lib/ledger/share.js +39 -0
- package/lib/lock/index.d.ts +2 -0
- package/lib/lock/index.js +1 -0
- package/lib/lock/lease.d.ts +23 -0
- package/lib/lock/lease.js +42 -0
- package/lib/manifest/agentCard.d.ts +35 -0
- package/lib/manifest/agentCard.js +38 -0
- package/lib/manifest/cardSign.d.ts +25 -0
- package/lib/manifest/cardSign.js +70 -0
- package/lib/manifest/federation.d.ts +64 -0
- package/lib/manifest/federation.js +187 -0
- package/lib/manifest/federationTypes.d.ts +51 -0
- package/lib/manifest/federationTypes.js +1 -0
- package/lib/manifest/index.d.ts +8 -0
- package/lib/manifest/index.js +8 -0
- package/lib/manifest/keys.d.ts +221 -0
- package/lib/manifest/keys.js +484 -0
- package/lib/manifest/manifest.d.ts +102 -0
- package/lib/manifest/manifest.js +1 -0
- package/lib/manifest/sign.d.ts +38 -0
- package/lib/manifest/sign.js +90 -0
- package/lib/manifest/trust.d.ts +54 -0
- package/lib/manifest/trust.js +87 -0
- package/lib/mission/index.d.ts +2 -0
- package/lib/mission/index.js +1 -0
- package/lib/mission/missionQueue.d.ts +19 -0
- package/lib/mission/missionQueue.js +62 -0
- package/lib/module/index.d.ts +9 -0
- package/lib/module/index.js +9 -0
- package/lib/module/llm/deepseek.d.ts +43 -0
- package/lib/module/llm/deepseek.js +162 -0
- package/lib/module/llm/llm.d.ts +64 -0
- package/lib/module/llm/llm.js +16 -0
- package/lib/module/mcp/client.d.ts +32 -0
- package/lib/module/mcp/client.js +84 -0
- package/lib/module/mcp/http.d.ts +32 -0
- package/lib/module/mcp/http.js +83 -0
- package/lib/module/mcp/protocol.d.ts +62 -0
- package/lib/module/mcp/protocol.js +20 -0
- package/lib/module/mcp/server.d.ts +22 -0
- package/lib/module/mcp/server.js +138 -0
- package/lib/module/mcp/transport.d.ts +19 -0
- package/lib/module/mcp/transport.js +16 -0
- package/lib/module/mcp/workspaceServer.d.ts +20 -0
- package/lib/module/mcp/workspaceServer.js +90 -0
- package/lib/module/sandbox/sandbox.d.ts +24 -0
- package/lib/module/sandbox/sandbox.js +5 -0
- package/lib/module/tool/mcpExecutor.d.ts +18 -0
- package/lib/module/tool/mcpExecutor.js +41 -0
- package/lib/module/tool/policy.d.ts +30 -0
- package/lib/module/tool/policy.js +23 -0
- package/lib/module/tool/redact.d.ts +9 -0
- package/lib/module/tool/redact.js +19 -0
- package/lib/module/tool/tool.d.ts +26 -0
- package/lib/module/tool/tool.js +24 -0
- package/lib/module/tool/workspaceExecutor.d.ts +12 -0
- package/lib/module/tool/workspaceExecutor.js +25 -0
- package/lib/policy/guard.d.ts +115 -0
- package/lib/policy/guard.js +154 -0
- package/lib/policy/index.d.ts +2 -0
- package/lib/policy/index.js +2 -0
- package/lib/policy/policy.d.ts +249 -0
- package/lib/policy/policy.js +364 -0
- package/lib/process/agent.d.ts +295 -0
- package/lib/process/agent.js +1 -0
- package/lib/process/agentService.d.ts +87 -0
- package/lib/process/agentService.js +128 -0
- package/lib/process/agentStore.d.ts +35 -0
- package/lib/process/agentStore.js +328 -0
- package/lib/process/executionStore.d.ts +79 -0
- package/lib/process/executionStore.js +71 -0
- package/lib/process/index.d.ts +5 -0
- package/lib/process/index.js +5 -0
- package/lib/process/process.d.ts +120 -0
- package/lib/process/process.js +111 -0
- package/lib/process/transitions.d.ts +11 -0
- package/lib/process/transitions.js +8 -0
- package/lib/progress/index.d.ts +2 -0
- package/lib/progress/index.js +1 -0
- package/lib/progress/progress.d.ts +26 -0
- package/lib/progress/progress.js +42 -0
- package/lib/protocol/a2a.d.ts +51 -0
- package/lib/protocol/a2a.js +79 -0
- package/lib/protocol/channel.d.ts +25 -0
- package/lib/protocol/channel.js +27 -0
- package/lib/protocol/envelope.d.ts +180 -0
- package/lib/protocol/envelope.js +495 -0
- package/lib/protocol/httpChannel.d.ts +33 -0
- package/lib/protocol/httpChannel.js +59 -0
- package/lib/protocol/index.d.ts +6 -0
- package/lib/protocol/index.js +6 -0
- package/lib/protocol/protocol.d.ts +120 -0
- package/lib/protocol/protocol.js +1 -0
- package/lib/protocol/wire.d.ts +12 -0
- package/lib/protocol/wire.js +55 -0
- package/lib/receipt/index.d.ts +1 -0
- package/lib/receipt/index.js +1 -0
- package/lib/receipt/receipt.d.ts +43 -0
- package/lib/receipt/receipt.js +1 -0
- package/lib/registry/content.d.ts +10 -0
- package/lib/registry/content.js +58 -0
- package/lib/registry/index.d.ts +4 -0
- package/lib/registry/index.js +2 -0
- package/lib/registry/registry.d.ts +109 -0
- package/lib/registry/registry.js +299 -0
- package/lib/runtime/action.d.ts +46 -0
- package/lib/runtime/action.js +39 -0
- package/lib/runtime/behavior.d.ts +110 -0
- package/lib/runtime/behavior.js +179 -0
- package/lib/runtime/behaviorTuning.d.ts +59 -0
- package/lib/runtime/behaviorTuning.js +95 -0
- package/lib/runtime/cognitiveRuntime.d.ts +189 -0
- package/lib/runtime/cognitiveRuntime.js +490 -0
- package/lib/runtime/escalation.d.ts +22 -0
- package/lib/runtime/escalation.js +15 -0
- package/lib/runtime/governedTask.d.ts +57 -0
- package/lib/runtime/governedTask.js +150 -0
- package/lib/runtime/index.d.ts +15 -0
- package/lib/runtime/index.js +15 -0
- package/lib/runtime/kernelRuntime.d.ts +33 -0
- package/lib/runtime/kernelRuntime.js +105 -0
- package/lib/runtime/operation.d.ts +30 -0
- package/lib/runtime/operation.js +1 -0
- package/lib/runtime/replay.d.ts +24 -0
- package/lib/runtime/replay.js +38 -0
- package/lib/runtime/routing.d.ts +12 -0
- package/lib/runtime/routing.js +44 -0
- package/lib/runtime/safety.d.ts +15 -0
- package/lib/runtime/safety.js +28 -0
- package/lib/runtime/session.d.ts +147 -0
- package/lib/runtime/session.js +214 -0
- package/lib/runtime/sessionStore.d.ts +24 -0
- package/lib/runtime/sessionStore.js +20 -0
- package/lib/runtime/telemetry.d.ts +24 -0
- package/lib/runtime/telemetry.js +33 -0
- package/lib/runtime/turnStore.d.ts +16 -0
- package/lib/runtime/turnStore.js +15 -0
- package/lib/scenario/index.d.ts +1 -0
- package/lib/scenario/index.js +1 -0
- package/lib/scenario/scenario.d.ts +52 -0
- package/lib/scenario/scenario.js +210 -0
- package/lib/semantic/canonical.d.ts +6 -0
- package/lib/semantic/canonical.js +22 -0
- package/lib/semantic/index.d.ts +2 -0
- package/lib/semantic/index.js +2 -0
- package/lib/semantic/sha256.d.ts +1 -0
- package/lib/semantic/sha256.js +66 -0
- package/lib/storage/appendLog.d.ts +145 -0
- package/lib/storage/appendLog.js +299 -0
- package/lib/storage/fileAppendSink.d.ts +7 -0
- package/lib/storage/fileAppendSink.js +34 -0
- package/lib/storage/index.d.ts +2 -0
- package/lib/storage/index.js +2 -0
- package/lib/store/bindCache.d.ts +9 -0
- package/lib/store/bindCache.js +18 -0
- package/lib/store/cache.d.ts +48 -0
- package/lib/store/cache.js +162 -0
- package/lib/store/context.d.ts +10 -0
- package/lib/store/context.js +27 -0
- package/lib/store/handleStore.d.ts +9 -0
- package/lib/store/handleStore.js +25 -0
- package/lib/store/index.d.ts +9 -0
- package/lib/store/index.js +8 -0
- package/lib/store/messageStore.d.ts +9 -0
- package/lib/store/messageStore.js +25 -0
- package/lib/store/objectStore.d.ts +9 -0
- package/lib/store/objectStore.js +25 -0
- package/lib/store/processStore.d.ts +9 -0
- package/lib/store/processStore.js +25 -0
- package/lib/store/threadStore.d.ts +9 -0
- package/lib/store/threadStore.js +25 -0
- package/lib/store/windowStore.d.ts +9 -0
- package/lib/store/windowStore.js +25 -0
- package/lib/structure/abstractSyntaxTree.d.ts +181 -0
- package/lib/structure/abstractSyntaxTree.js +400 -0
- package/lib/structure/avlTree.d.ts +125 -0
- package/lib/structure/avlTree.js +369 -0
- package/lib/structure/binarySearchTree.d.ts +125 -0
- package/lib/structure/binarySearchTree.js +306 -0
- package/lib/structure/binaryTree.d.ts +174 -0
- package/lib/structure/binaryTree.js +495 -0
- package/lib/structure/bloomFilter.d.ts +126 -0
- package/lib/structure/bloomFilter.js +177 -0
- package/lib/structure/compare.d.ts +55 -0
- package/lib/structure/compare.js +96 -0
- package/lib/structure/cuckooFilter.d.ts +149 -0
- package/lib/structure/cuckooFilter.js +267 -0
- package/lib/structure/deque.d.ts +117 -0
- package/lib/structure/deque.js +205 -0
- package/lib/structure/filterKey.d.ts +19 -0
- package/lib/structure/filterKey.js +28 -0
- package/lib/structure/hash.d.ts +129 -0
- package/lib/structure/hash.js +241 -0
- package/lib/structure/heap.d.ts +152 -0
- package/lib/structure/heap.js +227 -0
- package/lib/structure/index.d.ts +20 -0
- package/lib/structure/index.js +20 -0
- package/lib/structure/iterator.d.ts +6 -0
- package/lib/structure/iterator.js +16 -0
- package/lib/structure/lru.d.ts +235 -0
- package/lib/structure/lru.js +524 -0
- package/lib/structure/ordered.d.ts +89 -0
- package/lib/structure/ordered.js +336 -0
- package/lib/structure/priority.d.ts +499 -0
- package/lib/structure/priority.js +756 -0
- package/lib/structure/queue.d.ts +90 -0
- package/lib/structure/queue.js +154 -0
- package/lib/structure/redBlackTree.d.ts +142 -0
- package/lib/structure/redBlackTree.js +644 -0
- package/lib/structure/segmentTree.d.ts +129 -0
- package/lib/structure/segmentTree.js +205 -0
- package/lib/structure/stack.d.ts +77 -0
- package/lib/structure/stack.js +107 -0
- package/lib/structure/unordered.d.ts +99 -0
- package/lib/structure/unordered.js +341 -0
- package/lib/thread/index.d.ts +2 -0
- package/lib/thread/index.js +2 -0
- package/lib/thread/thread.d.ts +107 -0
- package/lib/thread/thread.js +81 -0
- package/lib/thread/transitions.d.ts +8 -0
- package/lib/thread/transitions.js +9 -0
- package/lib/types/common.d.ts +80 -0
- package/lib/types/common.js +5 -0
- package/lib/types/index.d.ts +23 -0
- package/lib/types/index.js +1 -0
- package/lib/warrant/epistemic.d.ts +141 -0
- package/lib/warrant/epistemic.js +1 -0
- package/lib/warrant/index.d.ts +3 -0
- package/lib/warrant/index.js +3 -0
- package/lib/warrant/inquiry.d.ts +69 -0
- package/lib/warrant/inquiry.js +119 -0
- package/lib/warrant/warrant.d.ts +46 -0
- package/lib/warrant/warrant.js +153 -0
- package/lib/window/compaction.d.ts +57 -0
- package/lib/window/compaction.js +334 -0
- package/lib/window/compactionTypes.d.ts +113 -0
- package/lib/window/compactionTypes.js +1 -0
- package/lib/window/index.d.ts +7 -0
- package/lib/window/index.js +3 -0
- package/lib/window/page.d.ts +16 -0
- package/lib/window/page.js +2 -0
- package/lib/window/window.d.ts +68 -0
- package/lib/window/window.js +194 -0
- package/package.json +22 -1
- package/src/authz/index.ts +1 -0
- package/src/concept/index.ts +3 -0
- package/src/concurrency/index.ts +5 -0
- package/src/cooperation/index.ts +6 -0
- package/src/delegate/index.ts +2 -0
- package/src/error/index.ts +7 -0
- package/src/evaluation/index.ts +2 -0
- package/src/execution/index.ts +3 -0
- package/src/frame/index.ts +1 -0
- package/src/index.ts +11 -0
- package/src/ledger/index.ts +4 -0
- package/src/manifest/index.ts +8 -0
- package/src/policy/index.ts +2 -0
- package/src/protocol/index.ts +6 -0
- package/src/receipt/index.ts +1 -0
- package/src/semantic/index.ts +2 -0
- package/src/storage/index.ts +2 -0
- package/src/structure/index.ts +20 -0
- package/src/thread/index.ts +2 -0
- package/src/warrant/index.ts +3 -0
- package/src/window/index.ts +7 -4
- package/tools/rewrite-declaration-extensions.ts +98 -0
- package/tsconfig.build.json +14 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { getObject, putObject, verifyObjectChain } from "../database/store/database.js";
|
|
2
|
+
import { isId } from "../boundary/ids.js";
|
|
3
|
+
import { Stack } from "../structure/stack.js";
|
|
4
|
+
import { UnorderedMap } from "../structure/unordered.js";
|
|
5
|
+
import { UnorderedSet } from "../structure/unordered.js";
|
|
6
|
+
const requireText = (value, field) => {
|
|
7
|
+
if (value.trim().length === 0) {
|
|
8
|
+
throw new Error(`${field} must not be empty`);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export const declareConcept = (db, input, at) => {
|
|
12
|
+
if (!isId(input.id)) {
|
|
13
|
+
throw new Error(`concept id ${input.id} is not a valid AMP id`);
|
|
14
|
+
}
|
|
15
|
+
requireText(input.label, "label");
|
|
16
|
+
requireText(input.definition, "definition");
|
|
17
|
+
const existing = db.prepare("SELECT * FROM concepts WHERE id = ?").get(input.id);
|
|
18
|
+
const version = existing === (void 0) ? 1 : existing.version + 1;
|
|
19
|
+
const objectId = `concept.${input.id}.v${version}`;
|
|
20
|
+
const body = {
|
|
21
|
+
amp: "0.1",
|
|
22
|
+
kind: "concept",
|
|
23
|
+
id: input.id,
|
|
24
|
+
label: input.label,
|
|
25
|
+
definition: input.definition,
|
|
26
|
+
status: input.status ?? "active",
|
|
27
|
+
version,
|
|
28
|
+
at,
|
|
29
|
+
};
|
|
30
|
+
const object = putObject(db, "concept", objectId, body, at);
|
|
31
|
+
db.prepare(`INSERT INTO concepts (id, label, definition, status, version, object_seq, digest, created_at, updated_at)
|
|
32
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
33
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
34
|
+
label = excluded.label,
|
|
35
|
+
definition = excluded.definition,
|
|
36
|
+
status = excluded.status,
|
|
37
|
+
version = excluded.version,
|
|
38
|
+
object_seq = excluded.object_seq,
|
|
39
|
+
digest = excluded.digest,
|
|
40
|
+
updated_at = excluded.updated_at`).run(input.id, input.label, input.definition, input.status ?? "active", version, object.seq, object.hash, existing?.created_at ?? at, at);
|
|
41
|
+
const row = db.prepare("SELECT * FROM concepts WHERE id = ?").get(input.id);
|
|
42
|
+
return { row, objectId, hash: object.hash };
|
|
43
|
+
};
|
|
44
|
+
export const declareModule = (db, input, at) => {
|
|
45
|
+
if (!isId(input.id)) {
|
|
46
|
+
throw new Error(`module id ${input.id} is not a valid AMP id`);
|
|
47
|
+
}
|
|
48
|
+
requireText(input.entry, "entry");
|
|
49
|
+
requireText(input.description, "description");
|
|
50
|
+
const existing = db.prepare("SELECT * FROM modules WHERE id = ?").get(input.id);
|
|
51
|
+
const version = existing === (void 0) ? 1 : existing.version + 1;
|
|
52
|
+
const objectId = `module.${input.id}.v${version}`;
|
|
53
|
+
const body = {
|
|
54
|
+
amp: "0.1",
|
|
55
|
+
kind: "module",
|
|
56
|
+
id: input.id,
|
|
57
|
+
moduleKind: input.kind,
|
|
58
|
+
entry: input.entry,
|
|
59
|
+
description: input.description,
|
|
60
|
+
status: input.status ?? "active",
|
|
61
|
+
contentDigest: input.contentDigest ?? null,
|
|
62
|
+
version,
|
|
63
|
+
at,
|
|
64
|
+
};
|
|
65
|
+
const object = putObject(db, "module", objectId, body, at);
|
|
66
|
+
db.prepare(`INSERT INTO modules (id, kind, entry, description, status, version, object_seq, digest, content_digest, created_at, updated_at)
|
|
67
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
68
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
69
|
+
kind = excluded.kind,
|
|
70
|
+
entry = excluded.entry,
|
|
71
|
+
description = excluded.description,
|
|
72
|
+
status = excluded.status,
|
|
73
|
+
version = excluded.version,
|
|
74
|
+
object_seq = excluded.object_seq,
|
|
75
|
+
digest = excluded.digest,
|
|
76
|
+
content_digest = excluded.content_digest,
|
|
77
|
+
updated_at = excluded.updated_at`).run(input.id, input.kind, input.entry, input.description, input.status ?? "active", version, object.seq, object.hash, input.contentDigest ?? null, existing?.created_at ?? at, at);
|
|
78
|
+
const row = db.prepare("SELECT * FROM modules WHERE id = ?").get(input.id);
|
|
79
|
+
return { row, objectId, hash: object.hash };
|
|
80
|
+
};
|
|
81
|
+
export const linkConcept = (db, moduleId, conceptId, role) => {
|
|
82
|
+
const module = db.prepare("SELECT mid FROM modules WHERE id = ?").get(moduleId);
|
|
83
|
+
if (module === (void 0)) {
|
|
84
|
+
throw new Error(`unknown module ${moduleId}`);
|
|
85
|
+
}
|
|
86
|
+
const concept = db.prepare("SELECT cid FROM concepts WHERE id = ?").get(conceptId);
|
|
87
|
+
if (concept === (void 0)) {
|
|
88
|
+
throw new Error(`unknown concept ${conceptId}`);
|
|
89
|
+
}
|
|
90
|
+
const result = db
|
|
91
|
+
.prepare("INSERT OR IGNORE INTO module_concepts (mid, cid, role) VALUES (?, ?, ?)")
|
|
92
|
+
.run(module.mid, concept.cid, role);
|
|
93
|
+
return Number(result.changes) === 1;
|
|
94
|
+
};
|
|
95
|
+
export const dependencies = (db, moduleId) => {
|
|
96
|
+
return db
|
|
97
|
+
.prepare(`SELECT m.id AS moduleId, d.id AS dependsOn, md.reason AS reason
|
|
98
|
+
FROM module_dependencies md
|
|
99
|
+
JOIN modules m ON m.mid = md.mid
|
|
100
|
+
JOIN modules d ON d.mid = md.depends_on_mid
|
|
101
|
+
WHERE m.id = ? ORDER BY d.id ASC`)
|
|
102
|
+
.all(moduleId);
|
|
103
|
+
};
|
|
104
|
+
export const linkDependency = (db, moduleId, dependencyId, reason = "") => {
|
|
105
|
+
if (moduleId === dependencyId) {
|
|
106
|
+
throw new Error(`module ${moduleId} cannot depend on itself`);
|
|
107
|
+
}
|
|
108
|
+
const module = db.prepare("SELECT mid FROM modules WHERE id = ?").get(moduleId);
|
|
109
|
+
if (module === (void 0)) {
|
|
110
|
+
throw new Error(`unknown module ${moduleId}`);
|
|
111
|
+
}
|
|
112
|
+
const dependency = db.prepare("SELECT mid FROM modules WHERE id = ?").get(dependencyId);
|
|
113
|
+
if (dependency === (void 0)) {
|
|
114
|
+
throw new Error(`unknown module ${dependencyId}`);
|
|
115
|
+
}
|
|
116
|
+
const result = db
|
|
117
|
+
.prepare("INSERT OR IGNORE INTO module_dependencies (mid, depends_on_mid, reason) VALUES (?, ?, ?)")
|
|
118
|
+
.run(module.mid, dependency.mid, reason);
|
|
119
|
+
if (Number(result.changes) === 0) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
if (hasDependencyCycle(db)) {
|
|
123
|
+
db.prepare("DELETE FROM module_dependencies WHERE mid = ? AND depends_on_mid = ?").run(module.mid, dependency.mid);
|
|
124
|
+
throw new Error(`linking ${moduleId} -> ${dependencyId} would create a dependency cycle`);
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* DFS over the dependency graph; uses the structure library's Stack/Set.
|
|
130
|
+
*/
|
|
131
|
+
export const hasDependencyCycle = (db) => {
|
|
132
|
+
const modules = db.prepare("SELECT mid, id FROM modules").all();
|
|
133
|
+
const idByMid = new UnorderedMap();
|
|
134
|
+
for (let index = 0; index < modules.length; index += 1) {
|
|
135
|
+
const module = modules[index];
|
|
136
|
+
idByMid.set(module.mid, module.id);
|
|
137
|
+
}
|
|
138
|
+
const edges = db.prepare("SELECT mid, depends_on_mid FROM module_dependencies").all();
|
|
139
|
+
const adjacency = new UnorderedMap();
|
|
140
|
+
for (let index = 0; index < edges.length; index += 1) {
|
|
141
|
+
const edge = edges[index];
|
|
142
|
+
const from = idByMid.get(edge.mid);
|
|
143
|
+
const to = idByMid.get(edge.depends_on_mid);
|
|
144
|
+
if (from === (void 0) || to === (void 0)) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const next = adjacency.get(from) ?? [];
|
|
148
|
+
next.push(to);
|
|
149
|
+
adjacency.set(from, next);
|
|
150
|
+
}
|
|
151
|
+
const visiting = new UnorderedSet();
|
|
152
|
+
const visited = new UnorderedSet();
|
|
153
|
+
for (let index = 0; index < modules.length; index += 1) {
|
|
154
|
+
const module = modules[index];
|
|
155
|
+
if (visited.has(module.id)) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
const stack = new Stack();
|
|
159
|
+
stack.push({ id: module.id, next: 0, neighbors: adjacency.get(module.id) ?? [] });
|
|
160
|
+
visiting.add(module.id);
|
|
161
|
+
while (!stack.isEmpty) {
|
|
162
|
+
const frame = stack.peek();
|
|
163
|
+
if (frame === (void 0)) {
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
if (frame.next >= frame.neighbors.length) {
|
|
167
|
+
stack.pop();
|
|
168
|
+
visiting.delete(frame.id);
|
|
169
|
+
visited.add(frame.id);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const next = frame.neighbors[frame.next];
|
|
173
|
+
frame.next += 1;
|
|
174
|
+
if (visiting.has(next)) {
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
if (!visited.has(next)) {
|
|
178
|
+
visiting.add(next);
|
|
179
|
+
stack.push({ id: next, next: 0, neighbors: adjacency.get(next) ?? [] });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return false;
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Recompute each module directory's digest and compare it with the declaration.
|
|
187
|
+
*/
|
|
188
|
+
export const verifyModuleContent = async (db, compute) => {
|
|
189
|
+
const reasons = [];
|
|
190
|
+
const rows = db
|
|
191
|
+
.prepare("SELECT id, entry, content_digest FROM modules WHERE content_digest IS NOT NULL ORDER BY id ASC")
|
|
192
|
+
.all();
|
|
193
|
+
for (let index = 0; index < rows.length; index += 1) {
|
|
194
|
+
const row = rows[index];
|
|
195
|
+
const actual = await compute(row.entry);
|
|
196
|
+
if (actual !== row.content_digest) {
|
|
197
|
+
reasons.push(`module ${row.id}: content changed since declaration`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return { ok: reasons.length === 0, reasons };
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Attest a registry row with a claim. The attestation is an `evidence` object
|
|
204
|
+
* in the chain plus a row that points at it, so a module can be justified by
|
|
205
|
+
* something stronger than "the directory exists".
|
|
206
|
+
*/
|
|
207
|
+
export const attest = (db, subjectKind, subjectId, claimId, at) => {
|
|
208
|
+
const subject = subjectKind === "module"
|
|
209
|
+
? db.prepare("SELECT mid FROM modules WHERE id = ?").get(subjectId)
|
|
210
|
+
: db.prepare("SELECT cid FROM concepts WHERE id = ?").get(subjectId);
|
|
211
|
+
if (subject === (void 0)) {
|
|
212
|
+
throw new Error(`unknown ${subjectKind} ${subjectId}`);
|
|
213
|
+
}
|
|
214
|
+
if (getObject(db, "claim", claimId) === (void 0)) {
|
|
215
|
+
throw new Error(`unknown claim ${claimId}`);
|
|
216
|
+
}
|
|
217
|
+
const count = db
|
|
218
|
+
.prepare("SELECT COUNT(*) AS n FROM attestations WHERE subject_kind = ? AND subject_id = ?")
|
|
219
|
+
.get(subjectKind, subjectId);
|
|
220
|
+
const objectId = `ev.registry.${subjectKind}.${subjectId}.${count.n + 1}`;
|
|
221
|
+
const body = {
|
|
222
|
+
amp: "0.1",
|
|
223
|
+
kind: "evidence",
|
|
224
|
+
id: objectId,
|
|
225
|
+
at,
|
|
226
|
+
subject: { kind: subjectKind, id: subjectId },
|
|
227
|
+
claim: claimId,
|
|
228
|
+
note: `registry attestation for ${subjectKind} ${subjectId}`,
|
|
229
|
+
};
|
|
230
|
+
const object = putObject(db, "evidence", objectId, body, at);
|
|
231
|
+
const result = db
|
|
232
|
+
.prepare("INSERT INTO attestations (subject_kind, subject_id, claim_id, object_seq, at) VALUES (?, ?, ?, ?, ?)")
|
|
233
|
+
.run(subjectKind, subjectId, claimId, object.seq, at);
|
|
234
|
+
return { aid: Number(result.lastInsertRowid), objectId, hash: object.hash };
|
|
235
|
+
};
|
|
236
|
+
export const verifyRegistry = (db) => {
|
|
237
|
+
const reasons = [...verifyObjectChain(db).reasons];
|
|
238
|
+
const rows = db
|
|
239
|
+
.prepare(`SELECT 'concept' AS kind, id, version, object_seq, digest, NULL AS content_digest FROM concepts
|
|
240
|
+
UNION ALL
|
|
241
|
+
SELECT 'module', id, version, object_seq, digest, content_digest FROM modules`)
|
|
242
|
+
.all();
|
|
243
|
+
for (let index = 0; index < rows.length; index += 1) {
|
|
244
|
+
const row = rows[index];
|
|
245
|
+
if (row.object_seq === null) {
|
|
246
|
+
reasons.push(`${row.kind} ${row.id}: no declaration object`);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
const object = db.prepare("SELECT id, body, hash FROM objects WHERE seq = ?").get(row.object_seq);
|
|
250
|
+
if (object === (void 0)) {
|
|
251
|
+
reasons.push(`${row.kind} ${row.id}: declaration object is missing`);
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
const body = JSON.parse(object.body);
|
|
255
|
+
if (body.id !== row.id) {
|
|
256
|
+
reasons.push(`${row.kind} ${row.id}: object id is ${`${body.id}`}`);
|
|
257
|
+
}
|
|
258
|
+
if (body.version !== row.version) {
|
|
259
|
+
reasons.push(`${row.kind} ${row.id}: object version ${`${body.version}`} != row ${row.version}`);
|
|
260
|
+
}
|
|
261
|
+
if (row.digest !== null && row.digest !== object.hash) {
|
|
262
|
+
reasons.push(`${row.kind} ${row.id}: digest does not match the object`);
|
|
263
|
+
}
|
|
264
|
+
if ((body.contentDigest ?? null) !== row.content_digest) {
|
|
265
|
+
reasons.push(`${row.kind} ${row.id}: content digest does not match the declaration object`);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
const danglingLinks = db
|
|
269
|
+
.prepare("SELECT COUNT(*) AS n FROM module_concepts mc LEFT JOIN modules m ON m.mid = mc.mid LEFT JOIN concepts c ON c.cid = mc.cid WHERE m.mid IS NULL OR c.cid IS NULL")
|
|
270
|
+
.get();
|
|
271
|
+
if (danglingLinks.n > 0) {
|
|
272
|
+
reasons.push(`${danglingLinks.n} module_concepts link(s) point at missing rows`);
|
|
273
|
+
}
|
|
274
|
+
const danglingDependencies = db
|
|
275
|
+
.prepare(`SELECT COUNT(*) AS n FROM module_dependencies md
|
|
276
|
+
LEFT JOIN modules m ON m.mid = md.mid
|
|
277
|
+
LEFT JOIN modules d ON d.mid = md.depends_on_mid
|
|
278
|
+
WHERE m.mid IS NULL OR d.mid IS NULL`)
|
|
279
|
+
.get();
|
|
280
|
+
if (danglingDependencies.n > 0) {
|
|
281
|
+
reasons.push(`${danglingDependencies.n} module_dependencies link(s) point at missing rows`);
|
|
282
|
+
}
|
|
283
|
+
if (hasDependencyCycle(db)) {
|
|
284
|
+
reasons.push("module dependency graph contains a cycle");
|
|
285
|
+
}
|
|
286
|
+
const attestations = db
|
|
287
|
+
.prepare("SELECT aid, subject_kind, subject_id, claim_id, object_seq FROM attestations ORDER BY aid ASC")
|
|
288
|
+
.all();
|
|
289
|
+
for (let index = 0; index < attestations.length; index += 1) {
|
|
290
|
+
const attestation = attestations[index];
|
|
291
|
+
if (attestation.object_seq === null || db.prepare("SELECT seq FROM objects WHERE seq = ?").get(attestation.object_seq) === (void 0)) {
|
|
292
|
+
reasons.push(`attestation ${attestation.aid}: evidence object is missing`);
|
|
293
|
+
}
|
|
294
|
+
if (getObject(db, "claim", attestation.claim_id) === (void 0)) {
|
|
295
|
+
reasons.push(`attestation ${attestation.aid}: claim ${attestation.claim_id} is missing`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return { ok: reasons.length === 0, reasons };
|
|
299
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action = goal-directed intent. It is not a permission verb and not an
|
|
3
|
+
* operation.
|
|
4
|
+
*/
|
|
5
|
+
import type { BehaviorPlan } from "./behavior.js";
|
|
6
|
+
import type { ScenarioPlan } from "../scenario/scenario.js";
|
|
7
|
+
import type { InteractionPlan } from "../interaction/interaction.js";
|
|
8
|
+
export type ActionId = string;
|
|
9
|
+
export type ActionRisk = "none" | "read" | "write" | "destructive";
|
|
10
|
+
export type ActionStatus = "planned" | "running" | "done" | "failed" | "abandoned";
|
|
11
|
+
export interface ActionRecord {
|
|
12
|
+
id: ActionId;
|
|
13
|
+
turnId: string;
|
|
14
|
+
goal: string;
|
|
15
|
+
intent: string;
|
|
16
|
+
expectedEffect: string;
|
|
17
|
+
preconditions: string[];
|
|
18
|
+
successCriteria: string[];
|
|
19
|
+
risk: ActionRisk;
|
|
20
|
+
status: ActionStatus;
|
|
21
|
+
operationIds: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface ActionPlan {
|
|
24
|
+
goal: string;
|
|
25
|
+
intent: string;
|
|
26
|
+
expectedEffect: string;
|
|
27
|
+
preconditions?: string[];
|
|
28
|
+
successCriteria?: string[];
|
|
29
|
+
risk?: ActionRisk;
|
|
30
|
+
}
|
|
31
|
+
export interface ActionPlannerInput {
|
|
32
|
+
turnId: string;
|
|
33
|
+
text: string;
|
|
34
|
+
behavior: BehaviorPlan;
|
|
35
|
+
scenario: ScenarioPlan;
|
|
36
|
+
interaction: InteractionPlan;
|
|
37
|
+
}
|
|
38
|
+
export interface ActionPlanner {
|
|
39
|
+
plan(input: ActionPlannerInput): Promise<ActionPlan[]>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* One bounded action per turn; later planners can split by goal.
|
|
43
|
+
*/
|
|
44
|
+
export declare class SingleActionPlanner implements ActionPlanner {
|
|
45
|
+
plan(input: ActionPlannerInput): Promise<ActionPlan[]>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One bounded action per turn; later planners can split by goal.
|
|
3
|
+
*/
|
|
4
|
+
export class SingleActionPlanner {
|
|
5
|
+
async plan(input) {
|
|
6
|
+
const preferred = input.behavior.preferredActions;
|
|
7
|
+
if (preferred.includes("acknowledge")) {
|
|
8
|
+
return [
|
|
9
|
+
{
|
|
10
|
+
goal: "acknowledge affect and converge on a next step",
|
|
11
|
+
intent: "acknowledge_then_converge",
|
|
12
|
+
expectedEffect: "user is heard and has one concrete next step",
|
|
13
|
+
successCriteria: ["answer acknowledges affect", "answer gives a bounded next step"],
|
|
14
|
+
risk: "none",
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
if (preferred.includes("clarify")) {
|
|
19
|
+
return [
|
|
20
|
+
{
|
|
21
|
+
goal: "clarify the underspecified request",
|
|
22
|
+
intent: "clarify",
|
|
23
|
+
expectedEffect: "the missing constraint is supplied",
|
|
24
|
+
successCriteria: ["one focused question is returned"],
|
|
25
|
+
risk: "none",
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
goal: "respond to the user's request",
|
|
32
|
+
intent: "respond",
|
|
33
|
+
expectedEffect: "an answer is produced",
|
|
34
|
+
successCriteria: ["answer is returned"],
|
|
35
|
+
risk: "read",
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Behavior = durable, context-conditioned policy. It selects/constrains
|
|
3
|
+
* actions; it never executes operations directly.
|
|
4
|
+
*/
|
|
5
|
+
import type { UserScore } from "../bayes/engine.js";
|
|
6
|
+
import type { ScenarioPlan } from "../scenario/scenario.js";
|
|
7
|
+
import type { InteractionPlan } from "../interaction/interaction.js";
|
|
8
|
+
import type { AttentionPlan } from "../attention/resource.js";
|
|
9
|
+
import type { ActionRisk } from "./action.js";
|
|
10
|
+
export type BehaviorId = string;
|
|
11
|
+
export interface BehaviorTrigger {
|
|
12
|
+
scenario?: string[];
|
|
13
|
+
interaction?: string[];
|
|
14
|
+
minUncertainty?: number;
|
|
15
|
+
maxAttentionHealth?: number;
|
|
16
|
+
risk?: "none" | "read" | "write" | "destructive";
|
|
17
|
+
textPattern?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface BehaviorPolicy {
|
|
20
|
+
preferActions?: string[];
|
|
21
|
+
forbidOperations?: string[];
|
|
22
|
+
requireApproval?: boolean;
|
|
23
|
+
maxActionsPerTurn?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Hard guardrails cannot be outvoted; only their action preference competes.
|
|
26
|
+
*/
|
|
27
|
+
hardGuardrail?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface Behavior {
|
|
30
|
+
id: BehaviorId;
|
|
31
|
+
name: string;
|
|
32
|
+
/**
|
|
33
|
+
* Higher wins when two soft/hard behaviors prefer different actions.
|
|
34
|
+
*/
|
|
35
|
+
priority: number;
|
|
36
|
+
trigger: BehaviorTrigger;
|
|
37
|
+
policy: BehaviorPolicy;
|
|
38
|
+
guardrails: string[];
|
|
39
|
+
metrics: string[];
|
|
40
|
+
version: number;
|
|
41
|
+
}
|
|
42
|
+
export interface BehaviorActivation {
|
|
43
|
+
behaviorId: BehaviorId;
|
|
44
|
+
turnId: string;
|
|
45
|
+
trigger: string;
|
|
46
|
+
confidence: number;
|
|
47
|
+
priority: number;
|
|
48
|
+
}
|
|
49
|
+
export interface BehaviorConflict {
|
|
50
|
+
winner: BehaviorId;
|
|
51
|
+
loser: BehaviorId;
|
|
52
|
+
reason: string;
|
|
53
|
+
winnerPriority: number;
|
|
54
|
+
loserPriority: number;
|
|
55
|
+
}
|
|
56
|
+
export interface BehaviorPlan {
|
|
57
|
+
activations: BehaviorActivation[];
|
|
58
|
+
guardrails: string[];
|
|
59
|
+
maxActionsPerTurn: number;
|
|
60
|
+
preferredActions: string[];
|
|
61
|
+
winner?: BehaviorId;
|
|
62
|
+
conflicts: BehaviorConflict[];
|
|
63
|
+
}
|
|
64
|
+
export interface BehaviorContext {
|
|
65
|
+
turnId: string;
|
|
66
|
+
text: string;
|
|
67
|
+
user: UserScore;
|
|
68
|
+
scenario: ScenarioPlan;
|
|
69
|
+
interaction: InteractionPlan;
|
|
70
|
+
attention: AttentionPlan;
|
|
71
|
+
risk?: ActionRisk;
|
|
72
|
+
}
|
|
73
|
+
export interface BehaviorMatch {
|
|
74
|
+
matched: boolean;
|
|
75
|
+
reason: string;
|
|
76
|
+
confidence: number;
|
|
77
|
+
}
|
|
78
|
+
export interface BehaviorRule {
|
|
79
|
+
behavior: Behavior;
|
|
80
|
+
match(context: BehaviorContext): BehaviorMatch;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Six conservative defaults; they are trace-only until an ActionPlanner uses them.
|
|
84
|
+
*/
|
|
85
|
+
export declare const DefaultBehaviors: readonly BehaviorRule[];
|
|
86
|
+
export declare class BehaviorRegistry {
|
|
87
|
+
private readonly rules;
|
|
88
|
+
private tuningVersion;
|
|
89
|
+
private readonly tuningSnapshots;
|
|
90
|
+
constructor(rules?: readonly BehaviorRule[]);
|
|
91
|
+
register(rule: BehaviorRule): this;
|
|
92
|
+
list(): Behavior[];
|
|
93
|
+
/**
|
|
94
|
+
* Apply reviewed priority changes; hard guardrails are never lowered.
|
|
95
|
+
*/
|
|
96
|
+
applyPriorities(changes: Readonly<Record<string, number>>): {
|
|
97
|
+
version: number;
|
|
98
|
+
applied: Array<{
|
|
99
|
+
id: string;
|
|
100
|
+
from: number;
|
|
101
|
+
to: number;
|
|
102
|
+
}>;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Roll back to the snapshot before `version`; returns false if unknown.
|
|
106
|
+
*/
|
|
107
|
+
rollbackPriorities(version: number): boolean;
|
|
108
|
+
tuning(): number;
|
|
109
|
+
select(context: BehaviorContext): BehaviorPlan;
|
|
110
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
const clamp01 = (value) => Math.max(0, Math.min(1, value));
|
|
2
|
+
const builtin = (id, name, priority, policy, guardrails, match) => ({
|
|
3
|
+
behavior: { id, name, priority, trigger: {}, policy, guardrails, metrics: [], version: 1 },
|
|
4
|
+
match,
|
|
5
|
+
});
|
|
6
|
+
/**
|
|
7
|
+
* Six conservative defaults; they are trace-only until an ActionPlanner uses them.
|
|
8
|
+
*/
|
|
9
|
+
export const DefaultBehaviors = [
|
|
10
|
+
builtin("clarify_when_uncertain", "Clarify when uncertain", 75, { preferActions: ["clarify"], maxActionsPerTurn: 1 }, ["ask one focused question when the request is underspecified"], (context) => {
|
|
11
|
+
const clarity = context.user.dimensions.clarity.mean;
|
|
12
|
+
const sufficiency = context.user.dimensions.contextSufficiency.mean;
|
|
13
|
+
const shortRequest = context.text.trim().split(/\s+/).length <= 4;
|
|
14
|
+
const matched = (shortRequest && clarity < 0.55) || sufficiency < 0.4;
|
|
15
|
+
return {
|
|
16
|
+
matched,
|
|
17
|
+
reason: `clarity=${clarity.toFixed(2)} sufficiency=${sufficiency.toFixed(2)} short=${shortRequest}`,
|
|
18
|
+
confidence: clamp01(1 - Math.min(clarity, sufficiency)),
|
|
19
|
+
};
|
|
20
|
+
}),
|
|
21
|
+
builtin("evidence_before_claim", "Evidence before claim", 70, { preferActions: ["retrieve_evidence", "verify"], maxActionsPerTurn: 3 }, ["do not assert external facts without evidence", "mark inference as inference"], (context) => {
|
|
22
|
+
const matched = context.scenario.active.some((kind) => ["research", "investigation", "engineering"].includes(kind));
|
|
23
|
+
return { matched, reason: `scenario=${context.scenario.active.join(",")}`, confidence: matched ? 0.7 : 0.2 };
|
|
24
|
+
}),
|
|
25
|
+
builtin("approval_before_destructive", "Approval before destructive operation", 100, { requireApproval: true, maxActionsPerTurn: 3, hardGuardrail: true }, ["destructive operations require explicit approval", "refuse unapproved destructive operations"], (context) => ({
|
|
26
|
+
matched: context.risk === "destructive" || context.scenario.active.includes("engineering"),
|
|
27
|
+
reason: context.risk === "destructive" ? "destructive risk" : "engineering scenario baseline",
|
|
28
|
+
confidence: context.risk === "destructive" ? 0.95 : 0.5,
|
|
29
|
+
})),
|
|
30
|
+
builtin("affect_then_converge", "Affect then converge", 80, { preferActions: ["acknowledge", "clarify", "converge"], maxActionsPerTurn: 2 }, ["acknowledge affect before giving steps", "do not diagnose"], (context) => {
|
|
31
|
+
const emotion = context.user.state.emotionalIntensity;
|
|
32
|
+
const urgency = context.user.state.urgency;
|
|
33
|
+
const affectText = /\b(overwhelmed|anxious|panic|scared|afraid|stressed|sad|angry|frustrated|lonely|grief)\w*\b/i.test(context.text);
|
|
34
|
+
return {
|
|
35
|
+
matched: affectText || emotion > 0.55 || urgency > 0.65,
|
|
36
|
+
reason: `emotion=${emotion.toFixed(2)} urgency=${urgency.toFixed(2)} affectText=${affectText}`,
|
|
37
|
+
confidence: clamp01(Math.max(emotion, urgency)),
|
|
38
|
+
};
|
|
39
|
+
}),
|
|
40
|
+
builtin("rest_when_fatigued", "Rest when fatigued", 90, { preferActions: ["rest", "defer"], maxActionsPerTurn: 1, hardGuardrail: true }, ["suggest rest instead of pushing through low attention health"], (context) => ({
|
|
41
|
+
matched: context.attention.rest || context.attention.utilization > 0.85,
|
|
42
|
+
reason: `rest=${context.attention.rest} utilization=${context.attention.utilization.toFixed(2)}`,
|
|
43
|
+
confidence: clamp01(context.attention.utilization),
|
|
44
|
+
})),
|
|
45
|
+
builtin("no_diagnosis", "No diagnosis", 100, { forbidOperations: ["medical.diagnose"], maxActionsPerTurn: 3, hardGuardrail: true }, ["do not diagnose or claim a therapeutic relationship"], (context) => ({
|
|
46
|
+
matched: context.user.state.emotionalIntensity > 0.3 || /\b(feel|anxious|depress|therapy|diagnos|overwhelmed|panic|grief)\w*\b/i.test(context.text),
|
|
47
|
+
reason: "affect/health-adjacent language",
|
|
48
|
+
confidence: 0.8,
|
|
49
|
+
})),
|
|
50
|
+
];
|
|
51
|
+
export class BehaviorRegistry {
|
|
52
|
+
rules = [];
|
|
53
|
+
tuningVersion = 0;
|
|
54
|
+
tuningSnapshots = [];
|
|
55
|
+
constructor(rules = DefaultBehaviors) {
|
|
56
|
+
for (const rule of rules) {
|
|
57
|
+
this.register(rule);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
register(rule) {
|
|
61
|
+
if (this.rules.some((entry) => entry.behavior.id === rule.behavior.id)) {
|
|
62
|
+
throw new Error(`duplicate behavior ${rule.behavior.id}`);
|
|
63
|
+
}
|
|
64
|
+
this.rules.push(rule);
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
list() {
|
|
68
|
+
return this.rules.map((rule) => rule.behavior);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Apply reviewed priority changes; hard guardrails are never lowered.
|
|
72
|
+
*/
|
|
73
|
+
applyPriorities(changes) {
|
|
74
|
+
const priorities = {};
|
|
75
|
+
for (const rule of this.rules) {
|
|
76
|
+
priorities[rule.behavior.id] = rule.behavior.priority;
|
|
77
|
+
}
|
|
78
|
+
this.tuningSnapshots.push({ version: this.tuningVersion, priorities });
|
|
79
|
+
const applied = [];
|
|
80
|
+
for (let index = 0; index < this.rules.length; index += 1) {
|
|
81
|
+
const rule = this.rules[index];
|
|
82
|
+
const requested = changes[rule.behavior.id];
|
|
83
|
+
if (requested === (void 0)) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const next = Math.max(0, Math.min(100, requested));
|
|
87
|
+
if (rule.behavior.policy.hardGuardrail === true && next < rule.behavior.priority) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (next === rule.behavior.priority) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
applied.push({ id: rule.behavior.id, from: rule.behavior.priority, to: next });
|
|
94
|
+
this.rules[index] = { ...rule, behavior: { ...rule.behavior, priority: next, version: rule.behavior.version + 1 } };
|
|
95
|
+
}
|
|
96
|
+
if (applied.length > 0) {
|
|
97
|
+
this.tuningVersion += 1;
|
|
98
|
+
}
|
|
99
|
+
return { version: this.tuningVersion, applied };
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Roll back to the snapshot before `version`; returns false if unknown.
|
|
103
|
+
*/
|
|
104
|
+
rollbackPriorities(version) {
|
|
105
|
+
const snapshot = [...this.tuningSnapshots].reverse().find((entry) => entry.version === version - 1);
|
|
106
|
+
if (snapshot === (void 0)) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
for (let index = 0; index < this.rules.length; index += 1) {
|
|
110
|
+
const rule = this.rules[index];
|
|
111
|
+
const priority = snapshot.priorities[rule.behavior.id];
|
|
112
|
+
if (priority === (void 0) || priority === rule.behavior.priority) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
this.rules[index] = { ...rule, behavior: { ...rule.behavior, priority, version: rule.behavior.version + 1 } };
|
|
116
|
+
}
|
|
117
|
+
this.tuningVersion += 1;
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
tuning() {
|
|
121
|
+
return this.tuningVersion;
|
|
122
|
+
}
|
|
123
|
+
select(context) {
|
|
124
|
+
const activations = [];
|
|
125
|
+
const guardrails = new Set();
|
|
126
|
+
let maxActionsPerTurn = 3;
|
|
127
|
+
const contenders = [];
|
|
128
|
+
for (const rule of this.rules) {
|
|
129
|
+
const result = rule.match(context);
|
|
130
|
+
if (!result.matched) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const activation = {
|
|
134
|
+
behaviorId: rule.behavior.id,
|
|
135
|
+
turnId: context.turnId,
|
|
136
|
+
trigger: result.reason,
|
|
137
|
+
confidence: result.confidence,
|
|
138
|
+
priority: rule.behavior.priority,
|
|
139
|
+
};
|
|
140
|
+
activations.push(activation);
|
|
141
|
+
for (const guardrail of rule.behavior.guardrails) {
|
|
142
|
+
guardrails.add(guardrail);
|
|
143
|
+
}
|
|
144
|
+
if (rule.behavior.policy.maxActionsPerTurn !== (void 0)) {
|
|
145
|
+
maxActionsPerTurn = Math.min(maxActionsPerTurn, rule.behavior.policy.maxActionsPerTurn);
|
|
146
|
+
}
|
|
147
|
+
if ((rule.behavior.policy.preferActions ?? []).length > 0) {
|
|
148
|
+
contenders.push({ activation, rule });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
contenders.sort((left, right) => right.activation.priority - left.activation.priority || right.activation.confidence - left.activation.confidence);
|
|
152
|
+
const winner = contenders[0];
|
|
153
|
+
const preferredActions = winner === (void 0) ? [] : [...(winner.rule.behavior.policy.preferActions ?? [])];
|
|
154
|
+
const conflicts = [];
|
|
155
|
+
if (winner !== (void 0)) {
|
|
156
|
+
for (const loser of contenders.slice(1)) {
|
|
157
|
+
const loserActions = loser.rule.behavior.policy.preferActions ?? [];
|
|
158
|
+
if (JSON.stringify(loserActions) === JSON.stringify(preferredActions)) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
conflicts.push({
|
|
162
|
+
winner: winner.activation.behaviorId,
|
|
163
|
+
loser: loser.activation.behaviorId,
|
|
164
|
+
reason: `preferred actions ${preferredActions.join(",")} vs ${loserActions.join(",")}`,
|
|
165
|
+
winnerPriority: winner.activation.priority,
|
|
166
|
+
loserPriority: loser.activation.priority,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
activations,
|
|
172
|
+
guardrails: [...guardrails],
|
|
173
|
+
maxActionsPerTurn: Math.max(1, maxActionsPerTurn),
|
|
174
|
+
preferredActions,
|
|
175
|
+
...(winner === (void 0) ? {} : { winner: winner.activation.behaviorId }),
|
|
176
|
+
conflicts,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}
|