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,350 @@
|
|
|
1
|
+
import { GovernanceError } from "./types.js";
|
|
2
|
+
import { verifyAttentionManifest } from "./attentionManifest.js";
|
|
3
|
+
import { verifyCredential } from "./credential.js";
|
|
4
|
+
import { betaMean } from "../bayes/engine.js";
|
|
5
|
+
import { digestOf } from "../semantic/canonical.js";
|
|
6
|
+
const Messages = new Set(["manifest", "task", "receipt", "escalation", "audit-request"]);
|
|
7
|
+
const DefaultMaxRefs = 16;
|
|
8
|
+
const DefaultMaxSummary = 280;
|
|
9
|
+
export const manifestSummaryOf = (manifest) => ({
|
|
10
|
+
id: manifest.id,
|
|
11
|
+
version: manifest.version,
|
|
12
|
+
scenario: manifest.scenario,
|
|
13
|
+
modes: { ...manifest.modes },
|
|
14
|
+
evidenceFloor: manifest.evidenceFloor,
|
|
15
|
+
focus: manifest.focus.length,
|
|
16
|
+
digest: manifest.digest,
|
|
17
|
+
});
|
|
18
|
+
const messageDigest = (message) => {
|
|
19
|
+
const body = { ...message };
|
|
20
|
+
delete body.digest;
|
|
21
|
+
return digestOf(body);
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Verify a message digest after transport.
|
|
25
|
+
*/
|
|
26
|
+
export const verifyAgentMessage = (message) => messageDigest(message) === message.digest;
|
|
27
|
+
export class CooperationBus {
|
|
28
|
+
now;
|
|
29
|
+
legal;
|
|
30
|
+
maxRefs;
|
|
31
|
+
maxSummary;
|
|
32
|
+
agents = new Map();
|
|
33
|
+
inboxes = new Map();
|
|
34
|
+
seen = new Set();
|
|
35
|
+
board = [];
|
|
36
|
+
counter = 0;
|
|
37
|
+
constructor(options) {
|
|
38
|
+
if (typeof (options.now) !== "function") {
|
|
39
|
+
throw new TypeError("CooperationBus requires a clock");
|
|
40
|
+
}
|
|
41
|
+
this.now = options.now;
|
|
42
|
+
this.legal = options.legal;
|
|
43
|
+
this.maxRefs = options.maxRefs ?? DefaultMaxRefs;
|
|
44
|
+
this.maxSummary = options.maxSummary ?? DefaultMaxSummary;
|
|
45
|
+
}
|
|
46
|
+
register(agent) {
|
|
47
|
+
if (this.agents.has(agent.agentId)) {
|
|
48
|
+
throw new GovernanceError("registry-invalid", `${agent.agentId} is already registered`);
|
|
49
|
+
}
|
|
50
|
+
this.agents.set(agent.agentId, {
|
|
51
|
+
...agent,
|
|
52
|
+
manifest: agent.manifest,
|
|
53
|
+
reliability: { ...agent.reliability },
|
|
54
|
+
budget: { ...agent.budget },
|
|
55
|
+
});
|
|
56
|
+
this.inboxes.set(agent.agentId, []);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Replace an agent's manifest after a legitimate re-derivation.
|
|
60
|
+
*/
|
|
61
|
+
refresh(agentId, manifest) {
|
|
62
|
+
const agent = this.agents.get(agentId);
|
|
63
|
+
if (agent === (void 0)) {
|
|
64
|
+
throw new GovernanceError("registry-invalid", `${agentId} is not registered`);
|
|
65
|
+
}
|
|
66
|
+
agent.manifest = manifest;
|
|
67
|
+
}
|
|
68
|
+
unregister(agentId) {
|
|
69
|
+
this.inboxes.delete(agentId);
|
|
70
|
+
return this.agents.delete(agentId);
|
|
71
|
+
}
|
|
72
|
+
agent(agentId) {
|
|
73
|
+
const found = this.agents.get(agentId);
|
|
74
|
+
return found === (void 0) ? undefined : { ...found, manifest: found.manifest, reliability: { ...found.reliability }, budget: { ...found.budget } };
|
|
75
|
+
}
|
|
76
|
+
agentsOf(perspective) {
|
|
77
|
+
return [...this.agents.values()].filter((agent) => agent.perspective === perspective);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Broadcast a manifest summary. This is the only message that needs no
|
|
81
|
+
* credential: it contains no payload and no private context.
|
|
82
|
+
*/
|
|
83
|
+
announce(from, at) {
|
|
84
|
+
const deliveries = [];
|
|
85
|
+
const ids = [...this.agents.keys()];
|
|
86
|
+
for (let index = 0; index < ids.length; index += 1) {
|
|
87
|
+
const to = ids[index];
|
|
88
|
+
if (to === from) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
deliveries.push(this.send({ from, to, kind: "manifest", at }));
|
|
92
|
+
}
|
|
93
|
+
return deliveries;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Send one structured message. The sender's manifest and, for task or
|
|
97
|
+
* escalation messages, the credential are validated before delivery.
|
|
98
|
+
*/
|
|
99
|
+
send(input) {
|
|
100
|
+
const sender = this.agents.get(input.from);
|
|
101
|
+
if (sender === (void 0)) {
|
|
102
|
+
return { ok: false, code: "unknown-sender", detail: `${input.from} is not registered` };
|
|
103
|
+
}
|
|
104
|
+
const recipient = this.agents.get(input.to);
|
|
105
|
+
if (recipient === (void 0)) {
|
|
106
|
+
return { ok: false, code: "unknown-recipient", detail: `${input.to} is not registered` };
|
|
107
|
+
}
|
|
108
|
+
if (input.from === input.to) {
|
|
109
|
+
return { ok: false, code: "self-send", detail: "an agent cannot message itself" };
|
|
110
|
+
}
|
|
111
|
+
if (this.legal !== (void 0) && (this.legal.isBlocked() || this.legal.isFrozen(sender.perspective))) {
|
|
112
|
+
return { ok: false, code: "legal-blocked", detail: "the sender is frozen or the breaker is active" };
|
|
113
|
+
}
|
|
114
|
+
const verdict = verifyAttentionManifest(sender.manifest, input.at);
|
|
115
|
+
if (!verdict.ok) {
|
|
116
|
+
return { ok: false, code: "manifest-invalid", detail: verdict.detail ?? "sender manifest is not valid" };
|
|
117
|
+
}
|
|
118
|
+
if (input.summary !== (void 0) && input.summary.length > this.maxSummary) {
|
|
119
|
+
return { ok: false, code: "payload-too-large", detail: `summary exceeds ${this.maxSummary} characters` };
|
|
120
|
+
}
|
|
121
|
+
const refs = input.refs ?? [];
|
|
122
|
+
if (refs.length > this.maxRefs) {
|
|
123
|
+
return { ok: false, code: "payload-too-large", detail: `more than ${this.maxRefs} refs` };
|
|
124
|
+
}
|
|
125
|
+
if (input.kind === "task" || input.kind === "escalation") {
|
|
126
|
+
if (input.credential === (void 0)) {
|
|
127
|
+
return { ok: false, code: "credential-missing", detail: `${input.kind} messages need a switch credential` };
|
|
128
|
+
}
|
|
129
|
+
const checked = verifyCredential(input.credential, {
|
|
130
|
+
at: input.at,
|
|
131
|
+
to: recipient.perspective,
|
|
132
|
+
manifest: { id: recipient.manifest.id, version: recipient.manifest.version },
|
|
133
|
+
readRefs: refs,
|
|
134
|
+
});
|
|
135
|
+
if (!checked.valid) {
|
|
136
|
+
return {
|
|
137
|
+
ok: false,
|
|
138
|
+
code: checked.code === "credential-scope" ? "scope-escape" : "credential-invalid",
|
|
139
|
+
detail: `${checked.code}: ${checked.detail}`,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (input.kind === "receipt") {
|
|
144
|
+
if (input.receipt === (void 0) || input.receipt.conclusion.trim().length === 0 || input.receipt.confidence < 0 || input.receipt.confidence > 1) {
|
|
145
|
+
return { ok: false, code: "receipt-invalid", detail: "a receipt needs a conclusion and confidence in [0, 1]" };
|
|
146
|
+
}
|
|
147
|
+
if (input.receipt.manifest.id !== sender.manifest.id || input.receipt.manifest.version !== sender.manifest.version) {
|
|
148
|
+
return { ok: false, code: "receipt-invalid", detail: "the receipt cites a different manifest version" };
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (input.kind === "audit-request" && recipient.perspective !== "supervisory") {
|
|
152
|
+
return { ok: false, code: "credential-invalid", detail: "audit requests go to the supervisory perspective" };
|
|
153
|
+
}
|
|
154
|
+
this.counter += 1;
|
|
155
|
+
const body = {
|
|
156
|
+
id: `msg.${this.counter}`,
|
|
157
|
+
from: input.from,
|
|
158
|
+
to: input.to,
|
|
159
|
+
kind: input.kind,
|
|
160
|
+
at: input.at,
|
|
161
|
+
manifest: manifestSummaryOf(sender.manifest),
|
|
162
|
+
...(input.summary === (void 0) ? {} : { summary: input.summary }),
|
|
163
|
+
...(refs.length === 0 ? {} : { refs: refs.map((ref) => ({ ...ref })) }),
|
|
164
|
+
...(input.credential === (void 0) ? {} : { credential: input.credential }),
|
|
165
|
+
...(input.receipt === (void 0) ? {} : { receipt: { ...input.receipt, evidence: input.receipt.evidence.map((ref) => ({ ...ref })) } }),
|
|
166
|
+
...(input.escalation === (void 0) ? {} : { escalation: { ...input.escalation, evidence: input.escalation.evidence.map((ref) => ({ ...ref })) } }),
|
|
167
|
+
};
|
|
168
|
+
const message = { ...body, digest: messageDigest(body) };
|
|
169
|
+
const inbox = this.inboxes.get(input.to) ?? [];
|
|
170
|
+
inbox.push(message);
|
|
171
|
+
this.inboxes.set(input.to, inbox);
|
|
172
|
+
this.seen.add(message.id);
|
|
173
|
+
this.board.push(message);
|
|
174
|
+
return { ok: true, code: "delivered", detail: `${message.id} delivered`, message };
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Admit a message that arrived over a transport. The receiver re-verifies
|
|
178
|
+
* the digest, the sender's current manifest, the credential and the receipt
|
|
179
|
+
* version before the message enters the inbox.
|
|
180
|
+
*/
|
|
181
|
+
receive(message) {
|
|
182
|
+
const sender = this.agents.get(message.from);
|
|
183
|
+
if (sender === (void 0)) {
|
|
184
|
+
return { ok: false, code: "unknown-sender", detail: `${message.from} is not registered` };
|
|
185
|
+
}
|
|
186
|
+
const recipient = this.agents.get(message.to);
|
|
187
|
+
if (recipient === (void 0)) {
|
|
188
|
+
return { ok: false, code: "unknown-recipient", detail: `${message.to} is not registered` };
|
|
189
|
+
}
|
|
190
|
+
if (message.from === message.to) {
|
|
191
|
+
return { ok: false, code: "self-send", detail: "an agent cannot message itself" };
|
|
192
|
+
}
|
|
193
|
+
if (!Messages.has(message.kind)) {
|
|
194
|
+
return { ok: false, code: "manifest-invalid", detail: `${`${message.kind}`} is not a message kind` };
|
|
195
|
+
}
|
|
196
|
+
if (!verifyAgentMessage(message)) {
|
|
197
|
+
return { ok: false, code: "manifest-invalid", detail: "message digest does not match" };
|
|
198
|
+
}
|
|
199
|
+
if (message.manifest.id !== sender.manifest.id || message.manifest.version !== sender.manifest.version) {
|
|
200
|
+
return { ok: false, code: "manifest-invalid", detail: "the message cites a stale manifest version" };
|
|
201
|
+
}
|
|
202
|
+
if (this.legal !== (void 0) && (this.legal.isBlocked() || this.legal.isFrozen(sender.perspective))) {
|
|
203
|
+
return { ok: false, code: "legal-blocked", detail: "the sender is frozen or the breaker is active" };
|
|
204
|
+
}
|
|
205
|
+
const verdict = verifyAttentionManifest(sender.manifest, message.at);
|
|
206
|
+
if (!verdict.ok) {
|
|
207
|
+
return { ok: false, code: "manifest-invalid", detail: verdict.detail ?? "sender manifest is not valid" };
|
|
208
|
+
}
|
|
209
|
+
if (message.summary !== (void 0) && message.summary.length > this.maxSummary) {
|
|
210
|
+
return { ok: false, code: "payload-too-large", detail: `summary exceeds ${this.maxSummary} characters` };
|
|
211
|
+
}
|
|
212
|
+
const refs = message.refs ?? [];
|
|
213
|
+
if (refs.length > this.maxRefs) {
|
|
214
|
+
return { ok: false, code: "payload-too-large", detail: `more than ${this.maxRefs} refs` };
|
|
215
|
+
}
|
|
216
|
+
if (message.kind === "task" || message.kind === "escalation") {
|
|
217
|
+
if (message.credential === (void 0)) {
|
|
218
|
+
return { ok: false, code: "credential-missing", detail: `${message.kind} messages need a switch credential` };
|
|
219
|
+
}
|
|
220
|
+
const checked = verifyCredential(message.credential, {
|
|
221
|
+
at: message.at,
|
|
222
|
+
to: recipient.perspective,
|
|
223
|
+
manifest: { id: recipient.manifest.id, version: recipient.manifest.version },
|
|
224
|
+
readRefs: refs,
|
|
225
|
+
});
|
|
226
|
+
if (!checked.valid) {
|
|
227
|
+
return {
|
|
228
|
+
ok: false,
|
|
229
|
+
code: checked.code === "credential-scope" ? "scope-escape" : "credential-invalid",
|
|
230
|
+
detail: `${checked.code}: ${checked.detail}`,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (message.kind === "receipt") {
|
|
235
|
+
if (message.receipt === (void 0) || message.receipt.conclusion.trim().length === 0 || message.receipt.confidence < 0 || message.receipt.confidence > 1) {
|
|
236
|
+
return { ok: false, code: "receipt-invalid", detail: "a receipt needs a conclusion and confidence in [0, 1]" };
|
|
237
|
+
}
|
|
238
|
+
if (message.receipt.manifest.id !== sender.manifest.id || message.receipt.manifest.version !== sender.manifest.version) {
|
|
239
|
+
return { ok: false, code: "receipt-invalid", detail: "the receipt cites a different manifest version" };
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (message.kind === "audit-request" && recipient.perspective !== "supervisory") {
|
|
243
|
+
return { ok: false, code: "credential-invalid", detail: "audit requests go to the supervisory perspective" };
|
|
244
|
+
}
|
|
245
|
+
if (this.seen.has(message.id)) {
|
|
246
|
+
return { ok: true, code: "delivered", detail: `${message.id} duplicate ignored`, message };
|
|
247
|
+
}
|
|
248
|
+
this.seen.add(message.id);
|
|
249
|
+
const inbox = this.inboxes.get(message.to) ?? [];
|
|
250
|
+
inbox.push(message);
|
|
251
|
+
this.inboxes.set(message.to, inbox);
|
|
252
|
+
this.board.push(message);
|
|
253
|
+
return { ok: true, code: "delivered", detail: `${message.id} received`, message };
|
|
254
|
+
}
|
|
255
|
+
inbox(agentId, at) {
|
|
256
|
+
const agent = this.agents.get(agentId);
|
|
257
|
+
if (agent === (void 0)) {
|
|
258
|
+
throw new GovernanceError("registry-invalid", `${agentId} is not registered`);
|
|
259
|
+
}
|
|
260
|
+
const messages = this.inboxes.get(agentId) ?? [];
|
|
261
|
+
return messages.map((message) => {
|
|
262
|
+
if (!verifyAgentMessage(message)) {
|
|
263
|
+
return { ok: false, code: "manifest-invalid", detail: "message digest does not match" };
|
|
264
|
+
}
|
|
265
|
+
if (message.credential !== (void 0)) {
|
|
266
|
+
const checked = verifyCredential(message.credential, {
|
|
267
|
+
at,
|
|
268
|
+
to: agent.perspective,
|
|
269
|
+
manifest: { id: agent.manifest.id, version: agent.manifest.version },
|
|
270
|
+
});
|
|
271
|
+
if (!checked.valid) {
|
|
272
|
+
return { ok: false, code: "credential-invalid", detail: `${checked.code}: ${checked.detail}` };
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return { ok: true, code: "delivered", detail: message.id, message };
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Prune the communication graph: reliability x information value.
|
|
280
|
+
*/
|
|
281
|
+
route(from, candidates, options = {}) {
|
|
282
|
+
const limit = Math.max(0, options.limit ?? 3);
|
|
283
|
+
const scored = [];
|
|
284
|
+
for (let index = 0; index < candidates.length; index += 1) {
|
|
285
|
+
const id = candidates[index];
|
|
286
|
+
if (id === from) {
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
const agent = this.agents.get(id);
|
|
290
|
+
if (agent === (void 0)) {
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
const value = Math.max(0, options.voi?.[id] ?? 0);
|
|
294
|
+
scored.push({ id, score: betaMean(agent.reliability) * (1 + value) });
|
|
295
|
+
}
|
|
296
|
+
scored.sort((left, right) => right.score - left.score || left.id.localeCompare(right.id));
|
|
297
|
+
return scored.slice(0, limit).map((entry) => entry.id);
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Update a recipient's reliability from an observed outcome.
|
|
301
|
+
*/
|
|
302
|
+
observe(agentId, success, weight = 1) {
|
|
303
|
+
const agent = this.agents.get(agentId);
|
|
304
|
+
if (agent === (void 0)) {
|
|
305
|
+
throw new GovernanceError("registry-invalid", `${agentId} is not registered`);
|
|
306
|
+
}
|
|
307
|
+
const delta = Math.max(0, weight);
|
|
308
|
+
agent.reliability = {
|
|
309
|
+
alpha: agent.reliability.alpha + (success ? delta : 0),
|
|
310
|
+
beta: agent.reliability.beta + (success ? 0 : delta),
|
|
311
|
+
};
|
|
312
|
+
return { ...agent.reliability };
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* The shared, structured board. It contains message summaries, not private
|
|
316
|
+
* reasoning, so supervisory audit can read it without inheriting execution
|
|
317
|
+
* context.
|
|
318
|
+
*/
|
|
319
|
+
boardEntries() {
|
|
320
|
+
return this.board.map((message) => message);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* An independent audit request: evidence refs only, no receipt body and no
|
|
324
|
+
* private context. The supervisory agent can trace by reference.
|
|
325
|
+
*/
|
|
326
|
+
auditRequest(from, evidence, at) {
|
|
327
|
+
const supervisory = [...this.agents.values()].find((agent) => agent.perspective === "supervisory");
|
|
328
|
+
if (supervisory === (void 0)) {
|
|
329
|
+
return { ok: false, code: "unknown-recipient", detail: "no supervisory agent is registered" };
|
|
330
|
+
}
|
|
331
|
+
return this.send({ from, to: supervisory.agentId, kind: "audit-request", at, refs: [...evidence], summary: "independent evidence audit" });
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Convenience: hand a task to a target with a credential.
|
|
335
|
+
*/
|
|
336
|
+
handoff(from, to, credential, refs, at, summary) {
|
|
337
|
+
return this.send({
|
|
338
|
+
from,
|
|
339
|
+
to,
|
|
340
|
+
kind: "task",
|
|
341
|
+
at,
|
|
342
|
+
credential,
|
|
343
|
+
refs: [...refs],
|
|
344
|
+
...(summary === (void 0) ? {} : { summary }),
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
nowValue() {
|
|
348
|
+
return this.now();
|
|
349
|
+
}
|
|
350
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The switch credential (spec section 5).
|
|
3
|
+
*
|
|
4
|
+
* A credential authorises a target perspective to look at a named scope for a
|
|
5
|
+
* short time. It carries references, not content. It is issued by the general
|
|
6
|
+
* manager and countersigned by legal and finance; all three sign-offs are
|
|
7
|
+
* required before it is valid.
|
|
8
|
+
*
|
|
9
|
+
* A credential never replaces a manifest: the credential says what may be
|
|
10
|
+
* seen, the manifest says what to look at, how deep and at what cost.
|
|
11
|
+
*/
|
|
12
|
+
import type { Digest, Id, Ref, Timestamp } from "../types/common.js";
|
|
13
|
+
import type { BehaviorConstraints, CredentialBudget, ManifestRef, ModeWeights, PerspectiveId, ScenarioId, Signoff, SignerInput } from "./types.js";
|
|
14
|
+
export declare const DefaultCredentialTtlMs: number;
|
|
15
|
+
export declare const MaxCredentialTtlMs: number;
|
|
16
|
+
/**
|
|
17
|
+
* A credential before the three sign-offs are attached.
|
|
18
|
+
*/
|
|
19
|
+
export interface CredentialDraft {
|
|
20
|
+
id?: Id;
|
|
21
|
+
from: PerspectiveId;
|
|
22
|
+
to: PerspectiveId;
|
|
23
|
+
reason: string;
|
|
24
|
+
/**
|
|
25
|
+
* What the target may read. Refs only; no bodies.
|
|
26
|
+
*/
|
|
27
|
+
visibleScope: Ref[];
|
|
28
|
+
/**
|
|
29
|
+
* The payload handed over. Must be a subset of the visible scope.
|
|
30
|
+
*/
|
|
31
|
+
payloadRefs: Ref[];
|
|
32
|
+
budget: CredentialBudget;
|
|
33
|
+
constraints: BehaviorConstraints;
|
|
34
|
+
manifest: ManifestRef;
|
|
35
|
+
scenario: ScenarioId;
|
|
36
|
+
modes?: Partial<ModeWeights>;
|
|
37
|
+
issuedAt: Timestamp;
|
|
38
|
+
ttlMs?: number;
|
|
39
|
+
notes?: string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The signed credential.
|
|
43
|
+
*/
|
|
44
|
+
export interface SwitchCredential {
|
|
45
|
+
kind: "switch-credential";
|
|
46
|
+
id: Id;
|
|
47
|
+
from: PerspectiveId;
|
|
48
|
+
to: PerspectiveId;
|
|
49
|
+
reason: string;
|
|
50
|
+
visibleScope: Ref[];
|
|
51
|
+
payloadRefs: Ref[];
|
|
52
|
+
budget: CredentialBudget;
|
|
53
|
+
constraints: BehaviorConstraints;
|
|
54
|
+
manifest: ManifestRef;
|
|
55
|
+
scenario: ScenarioId;
|
|
56
|
+
modes: ModeWeights;
|
|
57
|
+
issuedAt: Timestamp;
|
|
58
|
+
expires: Timestamp;
|
|
59
|
+
digest: Digest;
|
|
60
|
+
signoffs: Signoff[];
|
|
61
|
+
notes?: string[];
|
|
62
|
+
}
|
|
63
|
+
export interface CredentialRevocation {
|
|
64
|
+
credentialId: Id;
|
|
65
|
+
by: PerspectiveId;
|
|
66
|
+
at: Timestamp;
|
|
67
|
+
reason: string;
|
|
68
|
+
}
|
|
69
|
+
export interface CredentialVerdict {
|
|
70
|
+
valid: boolean;
|
|
71
|
+
code: string;
|
|
72
|
+
detail: string;
|
|
73
|
+
}
|
|
74
|
+
export interface VerifyCredentialRequest {
|
|
75
|
+
at: Timestamp;
|
|
76
|
+
to: PerspectiveId;
|
|
77
|
+
manifest?: ManifestRef;
|
|
78
|
+
readRefs?: Ref[];
|
|
79
|
+
revoked?: readonly CredentialRevocation[];
|
|
80
|
+
}
|
|
81
|
+
type CredentialDigestFn = (credential: Omit<SwitchCredential, "digest" | "signoffs"> | SwitchCredential) => Digest;
|
|
82
|
+
export declare const credentialDigest: CredentialDigestFn;
|
|
83
|
+
/**
|
|
84
|
+
* Issue a credential. Throws when the direction, the time window or the
|
|
85
|
+
* three-party signature set is wrong; a credential that needs a fourth
|
|
86
|
+
* signature (board authorisation for a strategic target) is issued with it.
|
|
87
|
+
*/
|
|
88
|
+
type IssueCredential = (draft: CredentialDraft, signers: readonly SignerInput[]) => SwitchCredential;
|
|
89
|
+
export declare const issueCredential: IssueCredential;
|
|
90
|
+
/**
|
|
91
|
+
* Verify a credential against a request. Codes are stable so callers can map
|
|
92
|
+
* them to receipts without parsing prose.
|
|
93
|
+
*/
|
|
94
|
+
type VerifyCredential = (credential: SwitchCredential, request: VerifyCredentialRequest) => CredentialVerdict;
|
|
95
|
+
export declare const verifyCredential: VerifyCredential;
|
|
96
|
+
/**
|
|
97
|
+
* Minimal read check: the ref must be inside the visible scope.
|
|
98
|
+
*/
|
|
99
|
+
type CanRead = (credential: SwitchCredential, ref: Ref) => boolean;
|
|
100
|
+
export declare const canRead: CanRead;
|
|
101
|
+
/**
|
|
102
|
+
* Revocation is an event, not an edit: the credential stays byte-identical and
|
|
103
|
+
* the verifier consults the revocation list.
|
|
104
|
+
*/
|
|
105
|
+
type RevokeCredential = (credential: SwitchCredential, by: PerspectiveId, reason: string, at: Timestamp) => CredentialRevocation;
|
|
106
|
+
export declare const revokeCredential: RevokeCredential;
|
|
107
|
+
/**
|
|
108
|
+
* One-line audit text for a frame or receipt.
|
|
109
|
+
*/
|
|
110
|
+
type CredentialText = (credential: SwitchCredential) => string;
|
|
111
|
+
export declare const credentialSummary: CredentialText;
|
|
112
|
+
/**
|
|
113
|
+
* The target perspective's layer, exposed so callers do not import the
|
|
114
|
+
* registry just to log a handoff.
|
|
115
|
+
*/
|
|
116
|
+
export declare const credentialTargetLayer: CredentialText;
|
|
117
|
+
export {};
|