chainlesschain 0.166.17 → 0.166.20
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/README.md +14 -7
- package/package.json +2 -2
- package/src/assets/web-panel/assets/{AIOps-CVW2n2rh.js → AIOps-CcJst5Zs.js} +1 -1
- package/src/assets/web-panel/assets/{ActionButton-DtuM163O.js → ActionButton-BpHPFKd3.js} +1 -1
- package/src/assets/web-panel/assets/{Analytics-BXvl_qHu.js → Analytics-DHAsASuS.js} +3 -3
- package/src/assets/web-panel/assets/{AppLayout-VDBTFKOp.js → AppLayout-BTKwo5RC.js} +3 -3
- package/src/assets/web-panel/assets/{Artifacts-BNz2xCiG.js → Artifacts-BcCBTggA.js} +1 -1
- package/src/assets/web-panel/assets/{Audit-DTu9Hn9P.js → Audit-z1JvJYbT.js} +1 -1
- package/src/assets/web-panel/assets/{BackgroundAgents-D2OCPzLe.js → BackgroundAgents-CJ7DCMDR.js} +1 -1
- package/src/assets/web-panel/assets/{Backup-C9M-vG7G.js → Backup-CKpxw4uw.js} +1 -1
- package/src/assets/web-panel/assets/{BaseInput-BUkCNiUQ.js → BaseInput-2jI_IlUB.js} +1 -1
- package/src/assets/web-panel/assets/{Chat-OJ2ajF7l.js → Chat-C_4RfBeN.js} +5 -5
- package/src/assets/web-panel/assets/ChatBubbleRenderer-eMmw1eZF.js +1 -0
- package/src/assets/web-panel/assets/{Checkbox-C1gXKDsc.js → Checkbox-BnF4z4N1.js} +1 -1
- package/src/assets/web-panel/assets/{Codegen-BXbznLg7.js → Codegen-m_LMamhM.js} +1 -1
- package/src/assets/web-panel/assets/{Col-CbCq5N0i.js → Col-DzMbA760.js} +1 -1
- package/src/assets/web-panel/assets/{Community-V8Ks6Yun.js → Community-SScuZUcW.js} +1 -1
- package/src/assets/web-panel/assets/{Compact-DkeHQTpQ.js → Compact-CiOHRvwQ.js} +1 -1
- package/src/assets/web-panel/assets/{Compliance-JeLKwn4Q.js → Compliance-97FzYz-6.js} +1 -1
- package/src/assets/web-panel/assets/{Cowork-azfetcBz.js → Cowork-C0ss-SRl.js} +3 -3
- package/src/assets/web-panel/assets/{Cron-Q691i_Gp.js → Cron-CCbdc9fp.js} +2 -2
- package/src/assets/web-panel/assets/{Crosschain-BLjDRbr_.js → Crosschain-BPnabXej.js} +1 -1
- package/src/assets/web-panel/assets/{DID-D8ptXplK.js → DID-B65hFnHs.js} +2 -2
- package/src/assets/web-panel/assets/{Dashboard-Ctj2VVZL.js → Dashboard-B6qR_TF2.js} +2 -2
- package/src/assets/web-panel/assets/{Dropdown-D8VgkMJ8.js → Dropdown-6c-2Fxm-.js} +1 -1
- package/src/assets/web-panel/assets/{EmailListRenderer-CQPe5S6q.js → EmailListRenderer-GD57mfiz.js} +1 -1
- package/src/assets/web-panel/assets/{FamilyGuardDashboard-ySA-7SiN.js → FamilyGuardDashboard-B2mxG6LN.js} +1 -1
- package/src/assets/web-panel/assets/{Federation-1PMD-fBf.js → Federation-cZS-uvAo.js} +1 -1
- package/src/assets/web-panel/assets/{FormItemContext-C_jr6U4Q.js → FormItemContext-UbSfBIe1.js} +1 -1
- package/src/assets/web-panel/assets/{GenericCardRenderer-Bu3bKf2B.js → GenericCardRenderer-BMAtvGt1.js} +1 -1
- package/src/assets/web-panel/assets/{Git-Dv4Fa_T5.js → Git-DAlhOiDA.js} +2 -2
- package/src/assets/web-panel/assets/{Governance-DOEy1n1k.js → Governance-B-RRVaP8.js} +1 -1
- package/src/assets/web-panel/assets/{Inference-DkvqzWcJ.js → Inference-DBl-pXYR.js} +1 -1
- package/src/assets/web-panel/assets/{KnowledgeGraph-DdUJK949.js → KnowledgeGraph-DjqOkvgY.js} +1 -1
- package/src/assets/web-panel/assets/{Logs-CRelcdUZ.js → Logs-CEV7AEAD.js} +2 -2
- package/src/assets/web-panel/assets/{MarkdownRenderer-0AHbbTA4.js → MarkdownRenderer-BDCxa4d1.js} +1 -1
- package/src/assets/web-panel/assets/{Marketplace-BuuBKsev.js → Marketplace-oRjzfmYJ.js} +1 -1
- package/src/assets/web-panel/assets/{McpTools-DlgpEmA1.js → McpTools-BiTnznLw.js} +3 -3
- package/src/assets/web-panel/assets/{Memory-DTfdqUGy.js → Memory-DR0C5K4N.js} +2 -2
- package/src/assets/web-panel/assets/{MobileBridge-CXLE5ZFO.js → MobileBridge--oR8wEcp.js} +1 -1
- package/src/assets/web-panel/assets/{MobileProjects-Dz25OB0n.js → MobileProjects-DKqpYMuG.js} +1 -1
- package/src/assets/web-panel/assets/{Mtc-kEL0fhgD.js → Mtc-Dg0D6fDQ.js} +2 -2
- package/src/assets/web-panel/assets/{MtcAudit-BE4UvFJU.js → MtcAudit-D4_-yWTK.js} +2 -2
- package/src/assets/web-panel/assets/{Multisig-CSApSn8c.js → Multisig-Coz55FxA.js} +3 -3
- package/src/assets/web-panel/assets/{NLProgramming-D11FpKWx.js → NLProgramming-BWVjgW9Y.js} +1 -1
- package/src/assets/web-panel/assets/{Notes-CDL-D2CS.js → Notes-BflVuGwr.js} +3 -3
- package/src/assets/web-panel/assets/{NotificationSettings-C0Q6lO-c.js → NotificationSettings-CT0F_dJ7.js} +1 -1
- package/src/assets/web-panel/assets/{OrderTableRenderer-ZRE0OKbj.js → OrderTableRenderer-Dyrnqy_o.js} +1 -1
- package/src/assets/web-panel/assets/{Organization-Dc-maVAq.js → Organization-CMDTM2z5.js} +4 -4
- package/src/assets/web-panel/assets/{Overflow-B5mUpSvi.js → Overflow-acKvvYpC.js} +1 -1
- package/src/assets/web-panel/assets/{P2P-TjXV53wq.js → P2P-CRq5j9Ax.js} +2 -2
- package/src/assets/web-panel/assets/PdhVaultBrowser-DmtzN6Kn.js +7 -0
- package/src/assets/web-panel/assets/{Permissions-DKRzQ2O6.js → Permissions-SZ-kjJDa.js} +4 -4
- package/src/assets/web-panel/assets/{PersonalDataHub-Dx2eqft8.js → PersonalDataHub-DXh-ZfgJ.js} +6 -6
- package/src/assets/web-panel/assets/{Pipeline-CnYZMB5p.js → Pipeline-DhBU9ftP.js} +1 -1
- package/src/assets/web-panel/assets/{Privacy-BonKpPnp.js → Privacy-BgEXpO_V.js} +1 -1
- package/src/assets/web-panel/assets/{ProjectInit-DWO0Du3J.js → ProjectInit-B2DJ-dmK.js} +2 -2
- package/src/assets/web-panel/assets/{ProjectSettings-C9jqyYRv.js → ProjectSettings-ve3SocWc.js} +2 -2
- package/src/assets/web-panel/assets/{Projects-CYpKwXbz.js → Projects-5ZvFasSJ.js} +1 -1
- package/src/assets/web-panel/assets/{Providers-CW-fkwJq.js → Providers-C8fcF3BK.js} +1 -1
- package/src/assets/web-panel/assets/{QrScannerModal-Cw0J3Zud.js → QrScannerModal-unjO8lNO.js} +1 -1
- package/src/assets/web-panel/assets/{QuickAsk-BH4A4IpR.js → QuickAsk-BT1QtT7D.js} +1 -1
- package/src/assets/web-panel/assets/{Recommend-CDwMwJus.js → Recommend-BSjFrY1w.js} +1 -1
- package/src/assets/web-panel/assets/{RemoteSession-DKIPwzTf.js → RemoteSession-CWV0bICg.js} +2 -2
- package/src/assets/web-panel/assets/{Reputation-CklDj7qS.js → Reputation-BMjiMsk2.js} +1 -1
- package/src/assets/web-panel/assets/{Row-DJWZKsH0.js → Row-9XCY22PM.js} +1 -1
- package/src/assets/web-panel/assets/{RssFeed-BfSLCewo.js → RssFeed-DQ9PDy7Q.js} +2 -2
- package/src/assets/web-panel/assets/{Search-B0IST--x.js → Search-Boym2HwG.js} +1 -1
- package/src/assets/web-panel/assets/{Security-h1sYNWtt.js → Security-Gbq3lGQb.js} +4 -4
- package/src/assets/web-panel/assets/{Services-Gh0-oxI_.js → Services-OcUfLdnu.js} +2 -2
- package/src/assets/web-panel/assets/{Skeleton-CNDV_jOs.js → Skeleton-BjTog6cA.js} +1 -1
- package/src/assets/web-panel/assets/{Skills-ByCLTh1n.js → Skills-Dny4ft_1.js} +1 -1
- package/src/assets/web-panel/assets/{Sla-BfyrJTJz.js → Sla-Cy_VnhpZ.js} +1 -1
- package/src/assets/web-panel/assets/{SpeechSettings-BQzo9kNX.js → SpeechSettings-CrFuL_lp.js} +1 -1
- package/src/assets/web-panel/assets/{SyncSettings-B6fS6z_1.js → SyncSettings-k-FnjuOR.js} +2 -2
- package/src/assets/web-panel/assets/{Tasks-C-uKCP-l.js → Tasks-ZEqDSo0_.js} +1 -1
- package/src/assets/web-panel/assets/{Templates-D6oDy7wL.js → Templates-CYYksYV5.js} +1 -1
- package/src/assets/web-panel/assets/{Tenant-D3LT2wNQ.js → Tenant-BvTTRTHS.js} +1 -1
- package/src/assets/web-panel/assets/{Terminal-BteLcv_O.js → Terminal-DMOQOtkj.js} +2 -2
- package/src/assets/web-panel/assets/{TimelineRenderer-DHHuxfqH.js → TimelineRenderer-CnudkJxk.js} +1 -1
- package/src/assets/web-panel/assets/{Tokens-BRQeykXw.js → Tokens-VW6Wocdp.js} +1 -1
- package/src/assets/web-panel/assets/{Trigger-p2XaFWEu.js → Trigger-BtOxZqP6.js} +1 -1
- package/src/assets/web-panel/assets/{Trust-BxadBMft.js → Trust-XcGJoTQx.js} +1 -1
- package/src/assets/web-panel/assets/{UkeySign-DRBP7LDk.js → UkeySign-aASNCs5j.js} +1 -1
- package/src/assets/web-panel/assets/{VideoEditing-CZ3NZkh7.js → VideoEditing-Bz89M52u.js} +1 -1
- package/src/assets/web-panel/assets/{Wallet-C3NTBN7G.js → Wallet-uU4dSS_N.js} +4 -4
- package/src/assets/web-panel/assets/{WebAuthn-C7LVgMlb.js → WebAuthn-Brrroxgr.js} +2 -2
- package/src/assets/web-panel/assets/{WorkflowEditor-0_Iveog7.js → WorkflowEditor-Cny-evI9.js} +1 -1
- package/src/assets/web-panel/assets/{chat-DzzluYo3.js → chat-CJ5iSwWq.js} +1 -1
- package/src/assets/web-panel/assets/{colors-DSMYXpaj.js → colors-DWa-2flG.js} +1 -1
- package/src/assets/web-panel/assets/{compact-item-W76u1VSV.js → compact-item-DFwUfptU.js} +1 -1
- package/src/assets/web-panel/assets/{createContext-otsESjb5.js → createContext-FHWWcyeB.js} +1 -1
- package/src/assets/web-panel/assets/devWarning-DxufPwXC.js +1 -0
- package/src/assets/web-panel/assets/{hasIn-3sNLrvug.js → hasIn-QY_TElrN.js} +1 -1
- package/src/assets/web-panel/assets/{index-CENWwjef.js → index-0umhind6.js} +1 -1
- package/src/assets/web-panel/assets/{index-B5LOYdYm.js → index-2ufsNuVn.js} +1 -1
- package/src/assets/web-panel/assets/{index-DdU7IkKX.js → index-B18zERdP.js} +1 -1
- package/src/assets/web-panel/assets/{index-CtFOt5x1.js → index-B33frlaD.js} +1 -1
- package/src/assets/web-panel/assets/{index-Cg86EzNp.js → index-BEjwv2x6.js} +1 -1
- package/src/assets/web-panel/assets/{index-uSCkbpZH.js → index-BQCtBurK.js} +1 -1
- package/src/assets/web-panel/assets/{index-BdtmEKat.js → index-BR4RMPnB.js} +1 -1
- package/src/assets/web-panel/assets/{index-ClOFeZ-t.js → index-BRsGZBHc.js} +1 -1
- package/src/assets/web-panel/assets/{index-C2aht9-M.js → index-BUNwuu5v.js} +1 -1
- package/src/assets/web-panel/assets/{index-B9X_jqXe.js → index-BYbwQ7SP.js} +1 -1
- package/src/assets/web-panel/assets/{index-DMmdIpLA.js → index-BcVr-LOk.js} +1 -1
- package/src/assets/web-panel/assets/{index-BpcQYzP7.js → index-Bd7McYpJ.js} +1 -1
- package/src/assets/web-panel/assets/{index-BA8mZxd-.js → index-BiHRihC0.js} +1 -1
- package/src/assets/web-panel/assets/{index-DTA8Iavv.js → index-C5F1vwec.js} +3 -3
- package/src/assets/web-panel/assets/{index-B1I1AYJs.js → index-CGv5In_T.js} +1 -1
- package/src/assets/web-panel/assets/{index-vBKPcmAP.js → index-CKS7n6mE.js} +1 -1
- package/src/assets/web-panel/assets/{index-NaO9AE-F.js → index-CUiTugu3.js} +1 -1
- package/src/assets/web-panel/assets/{index-CKoFyHYQ.js → index-CUoLd1dt.js} +1 -1
- package/src/assets/web-panel/assets/{index-DS9WYDMf.js → index-CeGn0A4W.js} +1 -1
- package/src/assets/web-panel/assets/{index-D7A5U2IH.js → index-CjejB-z9.js} +1 -1
- package/src/assets/web-panel/assets/{index-DmpaC2yk.js → index-CkmgbT7h.js} +1 -1
- package/src/assets/web-panel/assets/{index-vUmYkqmu.js → index-D-Mhq8K6.js} +1 -1
- package/src/assets/web-panel/assets/{index-DH4cl52p.js → index-D2rPJ6Sv.js} +1 -1
- package/src/assets/web-panel/assets/{index-GlIOE4ja.js → index-DCHMVYG1.js} +1 -1
- package/src/assets/web-panel/assets/{index-q7ftLqNt.js → index-DDpXDi4J.js} +1 -1
- package/src/assets/web-panel/assets/{index-MhQQ3h8q.js → index-DUepuy7O.js} +1 -1
- package/src/assets/web-panel/assets/{index-BRsD1PT2.js → index-DUfILsc-.js} +1 -1
- package/src/assets/web-panel/assets/{index-pVm_iUre.js → index-DaHvj4jA.js} +1 -1
- package/src/assets/web-panel/assets/{index-BcGJtmHM.js → index-Dlq-u9E4.js} +1 -1
- package/src/assets/web-panel/assets/{index-BJsQio5O.js → index-Dy2PnKZx.js} +1 -1
- package/src/assets/web-panel/assets/index-ZMTB9p5z.js +1 -0
- package/src/assets/web-panel/assets/index-_PvIDelE.js +1 -0
- package/src/assets/web-panel/assets/{index-CE7tSow-.js → index-aTiI7lOQ.js} +1 -1
- package/src/assets/web-panel/assets/{index-BXLx9HfA.js → index-hw1J_Oxs.js} +1 -1
- package/src/assets/web-panel/assets/{index-DZKAzEge.js → index-th467RN6.js} +1 -1
- package/src/assets/web-panel/assets/{index-UUHCwfNq.js → index-uRUZdL7I.js} +1 -1
- package/src/assets/web-panel/assets/{index-DLDh1OW3.js → index-va4Rt-yM.js} +1 -1
- package/src/assets/web-panel/assets/{index-BDlDO2px.js → index-w3SdYwaC.js} +1 -1
- package/src/assets/web-panel/assets/{index-Ddd4mird.js → index-wqiOz655.js} +1 -1
- package/src/assets/web-panel/assets/{initDefaultProps-DF6llUXV.js → initDefaultProps-BeSPUFDz.js} +1 -1
- package/src/assets/web-panel/assets/{motion-vtDV8_5K.js → motion-Dcajvjm9.js} +1 -1
- package/src/assets/web-panel/assets/{move-B6c0bdy2.js → move-B76orau-.js} +1 -1
- package/src/assets/web-panel/assets/{mtc-parser-DlLYWuBK.js → mtc-parser-zB6yFwcX.js} +1 -1
- package/src/assets/web-panel/assets/{omit-BH0zOxLN.js → omit-BsbNjz8w.js} +1 -1
- package/src/assets/web-panel/assets/{pickAttrs-D9di8_In.js → pickAttrs-BiJ9tssQ.js} +1 -1
- package/src/assets/web-panel/assets/{placementArrow-BDSngufM.js → placementArrow-BdfMjMeN.js} +1 -1
- package/src/assets/web-panel/assets/{responsiveObserve-C_EawMvP.js → responsiveObserve-rV4LGpbU.js} +1 -1
- package/src/assets/web-panel/assets/{slide-B_4wShxA.js → slide-HsVw1qFQ.js} +1 -1
- package/src/assets/web-panel/assets/{statusUtils-CbQu6qJ-.js → statusUtils-D1ry8XPE.js} +1 -1
- package/src/assets/web-panel/assets/{styleChecker-CvXJWYXb.js → styleChecker-B1t6aQQ_.js} +1 -1
- package/src/assets/web-panel/assets/{useFlexGapSupport-jjY1XknO.js → useFlexGapSupport-C8qbl-9w.js} +1 -1
- package/src/assets/web-panel/assets/{useFs-CMXBdsK_.js → useFs-R7g_mYTC.js} +1 -1
- package/src/assets/web-panel/assets/{usePersonalDataHub-YbAhhPXx.js → usePersonalDataHub-Cd-kCe7Z.js} +1 -1
- package/src/assets/web-panel/assets/{vnode-BFCTKc0H.js → vnode-9WhK5UWA.js} +1 -1
- package/src/assets/web-panel/assets/{zoom-CY9aBl5O.js → zoom-CUqppPco.js} +1 -1
- package/src/assets/web-panel/index.html +1 -1
- package/src/command-help-index.json +1 -1
- package/src/commands/agent.js +80 -2
- package/src/commands/evolution.js +33 -27
- package/src/commands/serve.js +11 -2
- package/src/data/changelog.json +18 -5
- package/src/gateways/ws/session-protocol.js +1 -0
- package/src/gateways/ws/ws-agent-handler.js +70 -2
- package/src/gateways/ws/ws-server.js +8 -0
- package/src/lib/app-server/cli-agent-kernel-adapter.js +4 -0
- package/src/lib/app-server/graph-runtime.js +115 -8
- package/src/lib/app-server/server.js +21 -2
- package/src/lib/app-server/websocket-transport.js +2 -0
- package/src/lib/evolution/agent-evolution-ingress.js +300 -0
- package/src/lib/evolution/agent-evolution-runtime-composition-brand.js +22 -0
- package/src/lib/evolution/agent-evolution-runtime-composition.js +369 -0
- package/src/lib/evolution/evidence-backed-wiki-maintainer.js +752 -0
- package/src/lib/evolution/evolution-artifact-ports.js +48 -0
- package/src/lib/evolution/evolution-eval-gate.js +11 -4
- package/src/lib/evolution/evolution-evidence-artifact-adapter.js +499 -0
- package/src/lib/evolution/evolution-evidence-projector.js +61 -1
- package/src/lib/evolution/evolution-file-witness.js +601 -0
- package/src/lib/evolution/evolution-ledger-file-backend.js +176 -0
- package/src/lib/evolution/evolution-ledger-ports.js +353 -16
- package/src/lib/evolution/evolution-ledger.js +1355 -54
- package/src/lib/evolution/evolution-run-ledger-adapter.js +409 -0
- package/src/lib/evolution/evolution-run-wiki-maintenance-source.js +300 -0
- package/src/lib/evolution/scheduled-batch-wiki-maintenance-source.js +368 -0
- package/src/lib/evolution/skill-candidate-registry.js +649 -0
- package/src/lib/evolution/skill-promotion-controller.js +109 -38
- package/src/lib/evolution/skill-promotion-review-ledger-adapter.js +451 -0
- package/src/lib/evolution/skill-promotion-review.js +793 -0
- package/src/lib/evolution/skill-registry-transition-capability.js +55 -0
- package/src/lib/evolution/skill-registry-transition-ledger-adapter.js +1280 -0
- package/src/lib/evolution/skill-registry-transition-source.js +372 -0
- package/src/lib/evolution/skill-release-registry.js +2191 -11
- package/src/lib/evolution/skill-target-matrix-eval.js +133 -10
- package/src/lib/evolution/structured-memory-agent-control-plane.js +222 -0
- package/src/lib/evolution/structured-memory-authority-ledger-adapter.js +351 -0
- package/src/lib/evolution/structured-memory-ledger-adapter.js +220 -0
- package/src/lib/evolution/structured-memory-policy-receipt-writer.js +164 -0
- package/src/lib/evolution/structured-memory-post-compact-hook.js +87 -0
- package/src/lib/evolution/structured-memory-promotion-receipt-writer.js +221 -0
- package/src/lib/evolution/structured-memory-semantic-review-pipeline.js +313 -0
- package/src/lib/evolution/wiki-maintainer-ledger-adapter.js +200 -0
- package/src/lib/evolution/wiki-maintenance-trigger-ledger-adapter.js +687 -0
- package/src/lib/evolution-system.js +65 -30
- package/src/lib/mcp-lifecycle-authority.js +21 -2
- package/src/lib/remote-approval-bridge.js +24 -0
- package/src/lib/scheduler-kernel/store.js +62 -14
- package/src/repl/agent-repl.js +45 -0
- package/src/runtime/agent-runtime.js +114 -1
- package/src/runtime/headless-runner.js +19 -0
- package/src/runtime/headless-stream.js +43 -0
- package/src/runtime/runtime-factory.js +19 -1
- package/src/assets/web-panel/assets/ChatBubbleRenderer-BdZt76Ab.js +0 -1
- package/src/assets/web-panel/assets/PdhVaultBrowser-DvV2btIr.js +0 -7
- package/src/assets/web-panel/assets/devWarning-BztaXF84.js +0 -1
- package/src/assets/web-panel/assets/index-4jP_hG_4.js +0 -1
- package/src/assets/web-panel/assets/index-zxwuAXL5.js +0 -1
- package/src/lib/learning/learning-hooks.js +0 -123
|
@@ -108,7 +108,7 @@ export function loadFromDb(db) {
|
|
|
108
108
|
} catch {
|
|
109
109
|
parameters = {};
|
|
110
110
|
}
|
|
111
|
-
// keyed by id (matches
|
|
111
|
+
// keyed by id (matches recordIncrementalModelMetrics modelId)
|
|
112
112
|
models.set(row.id, {
|
|
113
113
|
id: row.id,
|
|
114
114
|
name: row.name,
|
|
@@ -220,10 +220,19 @@ export function assessCapability(db, name, score, category = "general") {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
/**
|
|
223
|
-
*
|
|
224
|
-
*
|
|
223
|
+
* Record a synthetic model metric projection.
|
|
224
|
+
*
|
|
225
|
+
* This does not load a model, execute a trainer, update weights, or evaluate
|
|
226
|
+
* predictions. The legacy `accuracy` column is retained for database
|
|
227
|
+
* compatibility and stores only this formula estimate:
|
|
228
|
+
* min(0.99, previousEstimate + 0.01 * log(1 + dataPoints)).
|
|
225
229
|
*/
|
|
226
|
-
export function
|
|
230
|
+
export function recordIncrementalModelMetrics(
|
|
231
|
+
db,
|
|
232
|
+
modelId,
|
|
233
|
+
newData,
|
|
234
|
+
options = {},
|
|
235
|
+
) {
|
|
227
236
|
ensureEvolutionTables(db);
|
|
228
237
|
loadFromDb(db);
|
|
229
238
|
|
|
@@ -261,11 +270,11 @@ export function trainIncremental(db, modelId, newData, options = {}) {
|
|
|
261
270
|
JSON.stringify(model.parameters),
|
|
262
271
|
);
|
|
263
272
|
|
|
264
|
-
//
|
|
273
|
+
// Record an observation, not evidence that training or evaluation occurred.
|
|
265
274
|
const logEntry = {
|
|
266
275
|
id: crypto.randomUUID(),
|
|
267
|
-
eventType: "model-
|
|
268
|
-
description: `
|
|
276
|
+
eventType: "model-metrics-recorded",
|
|
277
|
+
description: `Recorded formula metrics for ${modelId}: +${dataSize} data points, estimate=${model.accuracy.toFixed(4)}`,
|
|
269
278
|
capabilityId: null,
|
|
270
279
|
delta: dataSize,
|
|
271
280
|
timestamp: new Date().toISOString(),
|
|
@@ -284,7 +293,20 @@ export function trainIncremental(db, modelId, newData, options = {}) {
|
|
|
284
293
|
logEntry.timestamp,
|
|
285
294
|
);
|
|
286
295
|
|
|
287
|
-
return {
|
|
296
|
+
return {
|
|
297
|
+
...model,
|
|
298
|
+
metricKind: "synthetic-formula-estimate",
|
|
299
|
+
status: "metrics_recorded",
|
|
300
|
+
performedTraining: false,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* @deprecated Use recordIncrementalModelMetrics. This compatibility alias does
|
|
306
|
+
* not train a model and returns the same metrics-only record.
|
|
307
|
+
*/
|
|
308
|
+
export function trainIncremental(db, modelId, newData, options = {}) {
|
|
309
|
+
return recordIncrementalModelMetrics(db, modelId, newData, options);
|
|
288
310
|
}
|
|
289
311
|
|
|
290
312
|
/**
|
|
@@ -435,7 +457,7 @@ export function selfRepair(db, issue) {
|
|
|
435
457
|
break;
|
|
436
458
|
}
|
|
437
459
|
case "degraded-model": {
|
|
438
|
-
// Reset low
|
|
460
|
+
// Reset low formula estimates for fresh metric collection.
|
|
439
461
|
for (const [, model] of models) {
|
|
440
462
|
if (model.accuracy < 0.6) {
|
|
441
463
|
model.accuracy = 0.5;
|
|
@@ -446,7 +468,7 @@ export function selfRepair(db, issue) {
|
|
|
446
468
|
db.prepare(
|
|
447
469
|
`UPDATE evolution_models SET accuracy = ?, data_points = ?, updated_at = datetime('now') WHERE id = ?`,
|
|
448
470
|
).run(model.accuracy, model.dataPoints, model.id);
|
|
449
|
-
actions.push(`Reset
|
|
471
|
+
actions.push(`Reset metric record ${model.id} for reassessment`);
|
|
450
472
|
}
|
|
451
473
|
}
|
|
452
474
|
break;
|
|
@@ -486,6 +508,7 @@ export function selfRepair(db, issue) {
|
|
|
486
508
|
* Predict user behavior based on historical patterns.
|
|
487
509
|
*/
|
|
488
510
|
export function predictBehavior(db, userId, options = {}) {
|
|
511
|
+
void options;
|
|
489
512
|
ensureEvolutionTables(db);
|
|
490
513
|
loadFromDb(db);
|
|
491
514
|
|
|
@@ -641,7 +664,7 @@ const TRAIN_STRATEGY = Object.freeze({
|
|
|
641
664
|
});
|
|
642
665
|
|
|
643
666
|
const _v2CapabilitiesByDim = new Map(); // dimension → { id, dimension, score, previousScore, trend, sampleCount, assessedAt, metadata }
|
|
644
|
-
const
|
|
667
|
+
const _v2TrainingMetricRecords = []; // caller-supplied losses plus derived retention assessment
|
|
645
668
|
const _v2DiagnosisById = new Map(); // diagnosisId → { id, scope, severity, anomaliesDetected, rootCause, repairSuggestion, repairStatus, repairedAt, createdAt }
|
|
646
669
|
const _v2Milestones = []; // { id, type, description, capabilityId?, details, timestamp }
|
|
647
670
|
const _v2Config = {
|
|
@@ -721,7 +744,11 @@ export function listCapabilitiesV2() {
|
|
|
721
744
|
.sort((a, b) => a.dimension.localeCompare(b.dimension));
|
|
722
745
|
}
|
|
723
746
|
|
|
724
|
-
|
|
747
|
+
/**
|
|
748
|
+
* Record caller-supplied before/after loss metrics and derive a retention
|
|
749
|
+
* ratio. No training, model mutation, or independent evaluation occurs.
|
|
750
|
+
*/
|
|
751
|
+
export function recordTrainingMetricsV2({
|
|
725
752
|
strategy,
|
|
726
753
|
dataSize,
|
|
727
754
|
lossBefore,
|
|
@@ -750,31 +777,39 @@ export function trainIncrementalV2({
|
|
|
750
777
|
lossAfter,
|
|
751
778
|
knowledgeRetention,
|
|
752
779
|
durationMs,
|
|
753
|
-
|
|
780
|
+
retentionAssessment:
|
|
754
781
|
knowledgeRetention >= _v2Config.knowledgeRetentionThreshold
|
|
755
|
-
? "
|
|
782
|
+
? "threshold_met"
|
|
756
783
|
: "retention_low",
|
|
784
|
+
status: "metrics_recorded",
|
|
785
|
+
performedTraining: false,
|
|
757
786
|
createdAt: Date.now(),
|
|
758
787
|
};
|
|
759
|
-
|
|
760
|
-
if (entry.status === "completed" && lossAfter < lossBefore) {
|
|
761
|
-
recordMilestone({
|
|
762
|
-
type: GROWTH_MILESTONE.KNOWLEDGE_EXPANSION,
|
|
763
|
-
description: `${strategy} training reduced loss ${lossBefore}→${lossAfter}`,
|
|
764
|
-
details: { strategy, dataSize, knowledgeRetention },
|
|
765
|
-
});
|
|
766
|
-
}
|
|
788
|
+
_v2TrainingMetricRecords.push(entry);
|
|
767
789
|
return { ...entry };
|
|
768
790
|
}
|
|
769
791
|
|
|
770
|
-
|
|
771
|
-
|
|
792
|
+
/**
|
|
793
|
+
* @deprecated Use recordTrainingMetricsV2. This compatibility alias records
|
|
794
|
+
* metrics only and never reports training completion.
|
|
795
|
+
*/
|
|
796
|
+
export function trainIncrementalV2(options) {
|
|
797
|
+
return recordTrainingMetricsV2(options);
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
export function listTrainingMetricRecordsV2({ strategy, limit } = {}) {
|
|
801
|
+
let list = [..._v2TrainingMetricRecords];
|
|
772
802
|
if (strategy) list = list.filter((e) => e.strategy === strategy);
|
|
773
803
|
list.sort((a, b) => b.createdAt - a.createdAt);
|
|
774
804
|
if (Number.isFinite(limit) && limit > 0) list = list.slice(0, limit);
|
|
775
805
|
return list;
|
|
776
806
|
}
|
|
777
807
|
|
|
808
|
+
/** @deprecated Use listTrainingMetricRecordsV2. */
|
|
809
|
+
export function listTrainingLogV2({ strategy, limit } = {}) {
|
|
810
|
+
return listTrainingMetricRecordsV2({ strategy, limit });
|
|
811
|
+
}
|
|
812
|
+
|
|
778
813
|
export function selfDiagnoseV2({ scope = "system", depth = "shallow" } = {}) {
|
|
779
814
|
const anomalies = [];
|
|
780
815
|
let severity = DIAGNOSIS_SEVERITY.NORMAL;
|
|
@@ -793,9 +828,9 @@ export function selfDiagnoseV2({ scope = "system", depth = "shallow" } = {}) {
|
|
|
793
828
|
}
|
|
794
829
|
}
|
|
795
830
|
|
|
796
|
-
//
|
|
797
|
-
const
|
|
798
|
-
const lowRetention =
|
|
831
|
+
// Retention anomalies in caller-supplied metric records.
|
|
832
|
+
const recentMetricRecords = _v2TrainingMetricRecords.slice(-10);
|
|
833
|
+
const lowRetention = recentMetricRecords.filter(
|
|
799
834
|
(t) => t.knowledgeRetention < _v2Config.knowledgeRetentionThreshold,
|
|
800
835
|
);
|
|
801
836
|
if (lowRetention.length >= 3) {
|
|
@@ -814,7 +849,7 @@ export function selfDiagnoseV2({ scope = "system", depth = "shallow" } = {}) {
|
|
|
814
849
|
rootCause = `Capability ${top.dimension} dropped sharply`;
|
|
815
850
|
repairSuggestion = REPAIR_STRATEGY.PARAMETER_TUNE;
|
|
816
851
|
} else if (top.type === "catastrophic_forgetting") {
|
|
817
|
-
rootCause = "
|
|
852
|
+
rootCause = "Derived retention below threshold in recent metric records";
|
|
818
853
|
repairSuggestion = REPAIR_STRATEGY.MODEL_ROLLBACK;
|
|
819
854
|
}
|
|
820
855
|
}
|
|
@@ -1028,7 +1063,7 @@ export function getEvolutionStatsV2() {
|
|
|
1028
1063
|
}
|
|
1029
1064
|
return {
|
|
1030
1065
|
capabilityCount: _v2CapabilitiesByDim.size,
|
|
1031
|
-
|
|
1066
|
+
trainingMetricRecords: _v2TrainingMetricRecords.length,
|
|
1032
1067
|
diagnoses: { total: _v2DiagnosisById.size, bySeverity },
|
|
1033
1068
|
milestones: { total: _v2Milestones.length, byType: byMilestone },
|
|
1034
1069
|
};
|
|
@@ -1036,7 +1071,7 @@ export function getEvolutionStatsV2() {
|
|
|
1036
1071
|
|
|
1037
1072
|
export function _resetV2State() {
|
|
1038
1073
|
_v2CapabilitiesByDim.clear();
|
|
1039
|
-
|
|
1074
|
+
_v2TrainingMetricRecords.length = 0;
|
|
1040
1075
|
_v2DiagnosisById.clear();
|
|
1041
1076
|
_v2Milestones.length = 0;
|
|
1042
1077
|
_v2Config.enabled = true;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import crypto from "node:crypto";
|
|
13
|
+
import fs from "node:fs";
|
|
13
14
|
import path from "node:path";
|
|
14
15
|
import { getStatePath } from "./paths.js";
|
|
15
16
|
import {
|
|
@@ -454,8 +455,26 @@ export class McpLifecycleAuthority {
|
|
|
454
455
|
|
|
455
456
|
_read() {
|
|
456
457
|
if (!this.statePath) return validateStore(structuredClone(this._memory));
|
|
457
|
-
|
|
458
|
-
|
|
458
|
+
// A Windows replace can briefly make the destination path unobservable to
|
|
459
|
+
// an unlocked reader. Treating that ENOENT as an empty authority loses the
|
|
460
|
+
// server snapshot even though the replacement is about to become visible.
|
|
461
|
+
// Durable reads therefore share the exact strict lock used by mutations.
|
|
462
|
+
if (!fs.existsSync(path.dirname(this.statePath))) {
|
|
463
|
+
return validateStore({}, { missing: true });
|
|
464
|
+
}
|
|
465
|
+
return this._lock(
|
|
466
|
+
this.statePath,
|
|
467
|
+
() => {
|
|
468
|
+
const value = readSecurityStore(
|
|
469
|
+
this.statePath,
|
|
470
|
+
"MCP lifecycle authority",
|
|
471
|
+
);
|
|
472
|
+
return validateStore(value, {
|
|
473
|
+
missing: Object.keys(value).length === 0,
|
|
474
|
+
});
|
|
475
|
+
},
|
|
476
|
+
{ timeoutMs: 2000, staleMs: 30000, failIfUnavailable: true },
|
|
477
|
+
);
|
|
459
478
|
}
|
|
460
479
|
|
|
461
480
|
_mutate(mutator) {
|
|
@@ -53,6 +53,7 @@ import {
|
|
|
53
53
|
} from "./remote-control.js";
|
|
54
54
|
import { logger } from "./logger.js";
|
|
55
55
|
import { normalizeRemoteApprovalDecision } from "./remote-approval-decision.js";
|
|
56
|
+
import { captureStructuredMemoryPolicyReceiptWriter } from "./evolution/structured-memory-policy-receipt-writer.js";
|
|
56
57
|
|
|
57
58
|
const DEFAULT_DECISION_TIMEOUT_MS = 5 * 60 * 1000;
|
|
58
59
|
const REMOTE_LEASE_AUTHORIZATION_KIND =
|
|
@@ -102,6 +103,7 @@ export class RemoteApprovalBridge {
|
|
|
102
103
|
membershipHostAuthorityLockFile = null,
|
|
103
104
|
expectedCoordinatorPublicKeySha256 = null,
|
|
104
105
|
onSecurityError = null,
|
|
106
|
+
memoryPolicyReceiptWriter = null,
|
|
105
107
|
} = {}) {
|
|
106
108
|
if (!wsUrl) throw new Error("wsUrl is required");
|
|
107
109
|
if (!agentSessionId) throw new Error("agentSessionId is required");
|
|
@@ -122,6 +124,10 @@ export class RemoteApprovalBridge {
|
|
|
122
124
|
this._securityErrors = [];
|
|
123
125
|
this._onSecurityError =
|
|
124
126
|
typeof onSecurityError === "function" ? onSecurityError : null;
|
|
127
|
+
this._memoryPolicyReceiptWriter =
|
|
128
|
+
memoryPolicyReceiptWriter === null
|
|
129
|
+
? null
|
|
130
|
+
: captureStructuredMemoryPolicyReceiptWriter(memoryPolicyReceiptWriter);
|
|
125
131
|
this._membershipHostStore =
|
|
126
132
|
membershipHostStore === undefined
|
|
127
133
|
? () =>
|
|
@@ -1090,6 +1096,22 @@ export class RemoteApprovalBridge {
|
|
|
1090
1096
|
) {
|
|
1091
1097
|
throw new Error("Consumed Remote approval statement binding changed");
|
|
1092
1098
|
}
|
|
1099
|
+
if (this._memoryPolicyReceiptWriter !== null) {
|
|
1100
|
+
await this._memoryPolicyReceiptWriter.retainConsumedApproval({
|
|
1101
|
+
adopted,
|
|
1102
|
+
operation: {
|
|
1103
|
+
requestId: durableLease.requestId,
|
|
1104
|
+
fingerprint: durableLease.fingerprint,
|
|
1105
|
+
binding: durableLease.binding,
|
|
1106
|
+
toolName: descriptor.toolName,
|
|
1107
|
+
action: context.action ?? null,
|
|
1108
|
+
workspace: descriptor.workspace,
|
|
1109
|
+
session: descriptor.session,
|
|
1110
|
+
targetEnv: descriptor.targetEnv,
|
|
1111
|
+
policyVersion: descriptor.policyVersion,
|
|
1112
|
+
},
|
|
1113
|
+
});
|
|
1114
|
+
}
|
|
1093
1115
|
return true;
|
|
1094
1116
|
}
|
|
1095
1117
|
|
|
@@ -1310,6 +1332,7 @@ export async function startHeadlessRemoteApproval({
|
|
|
1310
1332
|
writeErr = () => {},
|
|
1311
1333
|
isText = false,
|
|
1312
1334
|
decisionTimeoutMs = undefined,
|
|
1335
|
+
memoryPolicyReceiptWriter = null,
|
|
1313
1336
|
deps = {},
|
|
1314
1337
|
} = {}) {
|
|
1315
1338
|
let effectiveConfig = config;
|
|
@@ -1374,6 +1397,7 @@ export async function startHeadlessRemoteApproval({
|
|
|
1374
1397
|
agentSessionId,
|
|
1375
1398
|
scopes: ["observe", "approve"],
|
|
1376
1399
|
decisionTimeoutMs,
|
|
1400
|
+
memoryPolicyReceiptWriter,
|
|
1377
1401
|
});
|
|
1378
1402
|
try {
|
|
1379
1403
|
await bridge.start();
|
|
@@ -37,6 +37,7 @@ const STORAGE_FAILURE_CODE_SET = new Set(STORAGE_FAILURE_CODES);
|
|
|
37
37
|
export const SCHEDULER_APPLICATION_ID = 0x4343534b; // "CCSK"
|
|
38
38
|
export const SCHEDULER_STORE_SCHEMA_VERSION = 6;
|
|
39
39
|
export const DEFAULT_BUSY_TIMEOUT_MS = 5_000;
|
|
40
|
+
const SQLITE_BUSY_TRANSACTION_ATTEMPTS = 3;
|
|
40
41
|
export const MAX_LEASE_MS = 24 * 60 * 60 * 1_000;
|
|
41
42
|
export const MIN_AUTHORITY_WINDOW_MS = 60_000;
|
|
42
43
|
export const MAX_AUTHORITY_WINDOW_MS = 31 * 24 * 60 * 60 * 1_000;
|
|
@@ -748,6 +749,26 @@ function findStorageFailureCode(error) {
|
|
|
748
749
|
return null;
|
|
749
750
|
}
|
|
750
751
|
|
|
752
|
+
function isSqliteBusy(error) {
|
|
753
|
+
const visited = new Set();
|
|
754
|
+
let current = error;
|
|
755
|
+
while (
|
|
756
|
+
current !== null &&
|
|
757
|
+
(typeof current === "object" || typeof current === "function") &&
|
|
758
|
+
!visited.has(current)
|
|
759
|
+
) {
|
|
760
|
+
visited.add(current);
|
|
761
|
+
if (
|
|
762
|
+
typeof current.code === "string" &&
|
|
763
|
+
current.code.trim().toUpperCase().startsWith("SQLITE_BUSY")
|
|
764
|
+
) {
|
|
765
|
+
return true;
|
|
766
|
+
}
|
|
767
|
+
current = current.cause;
|
|
768
|
+
}
|
|
769
|
+
return false;
|
|
770
|
+
}
|
|
771
|
+
|
|
751
772
|
function storageUnavailableError({ phase, storageCode, commitState }) {
|
|
752
773
|
return new SchedulerKernelError(
|
|
753
774
|
"SCHEDULER_STORAGE_UNAVAILABLE",
|
|
@@ -2316,20 +2337,7 @@ export class SchedulerStore {
|
|
|
2316
2337
|
this._assertOpen();
|
|
2317
2338
|
let bodyState = "not_started";
|
|
2318
2339
|
let bodyObservedTransaction = false;
|
|
2319
|
-
|
|
2320
|
-
const transaction = this.db.transaction((...args) => {
|
|
2321
|
-
bodyState = "running";
|
|
2322
|
-
try {
|
|
2323
|
-
bodyObservedTransaction = this.db.inTransaction === true;
|
|
2324
|
-
} catch {
|
|
2325
|
-
bodyObservedTransaction = false;
|
|
2326
|
-
}
|
|
2327
|
-
const result = callback(...args);
|
|
2328
|
-
bodyState = "returned";
|
|
2329
|
-
return result;
|
|
2330
|
-
});
|
|
2331
|
-
return transaction.immediate();
|
|
2332
|
-
} catch (cause) {
|
|
2340
|
+
const failWrite = (cause) => {
|
|
2333
2341
|
if (cause instanceof SchedulerKernelError) throw cause;
|
|
2334
2342
|
const storageCode = findStorageFailureCode(cause);
|
|
2335
2343
|
if (!storageCode) throw cause;
|
|
@@ -2353,7 +2361,47 @@ export class SchedulerStore {
|
|
|
2353
2361
|
? "not_committed"
|
|
2354
2362
|
: "unknown",
|
|
2355
2363
|
});
|
|
2364
|
+
};
|
|
2365
|
+
let transaction;
|
|
2366
|
+
try {
|
|
2367
|
+
transaction = this.db.transaction((...args) => {
|
|
2368
|
+
bodyState = "running";
|
|
2369
|
+
try {
|
|
2370
|
+
bodyObservedTransaction = this.db.inTransaction === true;
|
|
2371
|
+
} catch {
|
|
2372
|
+
bodyObservedTransaction = false;
|
|
2373
|
+
}
|
|
2374
|
+
const result = callback(...args);
|
|
2375
|
+
bodyState = "returned";
|
|
2376
|
+
return result;
|
|
2377
|
+
});
|
|
2378
|
+
} catch (cause) {
|
|
2379
|
+
return failWrite(cause);
|
|
2380
|
+
}
|
|
2381
|
+
for (
|
|
2382
|
+
let attempt = 1;
|
|
2383
|
+
attempt <= SQLITE_BUSY_TRANSACTION_ATTEMPTS;
|
|
2384
|
+
attempt += 1
|
|
2385
|
+
) {
|
|
2386
|
+
bodyState = "not_started";
|
|
2387
|
+
bodyObservedTransaction = false;
|
|
2388
|
+
try {
|
|
2389
|
+
return transaction.immediate();
|
|
2390
|
+
} catch (cause) {
|
|
2391
|
+
// BEGIN IMMEDIATE can lose a cross-process writer race even after the
|
|
2392
|
+
// native busy timeout. Retrying is safe only while the callback has
|
|
2393
|
+
// never started, so application writes and side effects cannot repeat.
|
|
2394
|
+
if (
|
|
2395
|
+
bodyState === "not_started" &&
|
|
2396
|
+
isSqliteBusy(cause) &&
|
|
2397
|
+
attempt < SQLITE_BUSY_TRANSACTION_ATTEMPTS
|
|
2398
|
+
) {
|
|
2399
|
+
continue;
|
|
2400
|
+
}
|
|
2401
|
+
return failWrite(cause);
|
|
2402
|
+
}
|
|
2356
2403
|
}
|
|
2404
|
+
throw new Error("unreachable Scheduler transaction retry state");
|
|
2357
2405
|
}
|
|
2358
2406
|
|
|
2359
2407
|
_appendEvent({
|
package/src/repl/agent-repl.js
CHANGED
|
@@ -171,6 +171,8 @@ import { resolveSlashMacro } from "./slash-macro.js";
|
|
|
171
171
|
import { expandMcpPrompt, renderMcpSurface } from "./mcp-prompt.js";
|
|
172
172
|
import { newCostStore, addUsage } from "./session-cost.js";
|
|
173
173
|
import { extractPluginUsageAttribution } from "../lib/plugin-usage-attribution.js";
|
|
174
|
+
import { captureStructuredMemoryAgentControlPlane } from "../lib/evolution/structured-memory-agent-control-plane.js";
|
|
175
|
+
import { captureAgentEvolutionIngress } from "../lib/evolution/agent-evolution-ingress.js";
|
|
174
176
|
import { formatManagedCheckpointEvent } from "../lib/managed-checkpoint-render.js";
|
|
175
177
|
import { parseThinkCommand, parseEffortCommand } from "./think-command.js";
|
|
176
178
|
import {
|
|
@@ -610,6 +612,10 @@ async function executeTool(name, args, context = {}) {
|
|
|
610
612
|
* unit-testable via the `options._coreLoop` injection seam.
|
|
611
613
|
*/
|
|
612
614
|
export async function agentLoop(messages, options) {
|
|
615
|
+
const evolutionIngress =
|
|
616
|
+
options.evolutionIngress == null
|
|
617
|
+
? null
|
|
618
|
+
: captureAgentEvolutionIngress(options.evolutionIngress);
|
|
613
619
|
const writeOut =
|
|
614
620
|
options.writeOut || ((text) => process.stdout.write(String(text)));
|
|
615
621
|
const waitForOutput = options.waitForOutput;
|
|
@@ -637,6 +643,13 @@ export async function agentLoop(messages, options) {
|
|
|
637
643
|
collapseValidatedPlainReplTailInPlace(messages);
|
|
638
644
|
}
|
|
639
645
|
const usageEvents = [];
|
|
646
|
+
const currentUserMessage = messages.at(-1);
|
|
647
|
+
if (evolutionIngress !== null && currentUserMessage?.role === "user") {
|
|
648
|
+
await evolutionIngress.ingestUserPrompt({
|
|
649
|
+
content: currentUserMessage.content,
|
|
650
|
+
sessionId: options.sessionId || null,
|
|
651
|
+
});
|
|
652
|
+
}
|
|
640
653
|
// Visible cross-vendor fallback notice: a silent switch from the configured
|
|
641
654
|
// provider onto another vendor (or a baseUrl relabel) is surfaced as a yellow
|
|
642
655
|
// line, so "configured X but it ran Y" never happens quietly. Callers may
|
|
@@ -757,6 +770,9 @@ export async function agentLoop(messages, options) {
|
|
|
757
770
|
onToolCallSettlement,
|
|
758
771
|
onProviderFallback,
|
|
759
772
|
})) {
|
|
773
|
+
if (evolutionIngress !== null) {
|
|
774
|
+
await evolutionIngress.ingestAgentEvent(event);
|
|
775
|
+
}
|
|
760
776
|
// P1 explicit turn→checkpoint binding — the REPL as PRODUCER: fold every
|
|
761
777
|
// loop event into the live table (checkpoint / tool / policy / child
|
|
762
778
|
// agent), mirroring the headless runner's feed. Advisory: a feeder failure
|
|
@@ -2909,10 +2925,38 @@ export function resolveReplPermanentMemoryStorage(
|
|
|
2909
2925
|
|
|
2910
2926
|
/** Start the agentic REPL with non-overridable production bindings. */
|
|
2911
2927
|
export async function startAgentRepl(options = {}) {
|
|
2928
|
+
const evolutionIngress =
|
|
2929
|
+
options.evolutionIngress == null
|
|
2930
|
+
? null
|
|
2931
|
+
: captureAgentEvolutionIngress(options.evolutionIngress);
|
|
2932
|
+
const structuredMemoryControlPlane =
|
|
2933
|
+
options.structuredMemoryControlPlane == null
|
|
2934
|
+
? null
|
|
2935
|
+
: captureStructuredMemoryAgentControlPlane(
|
|
2936
|
+
options.structuredMemoryControlPlane,
|
|
2937
|
+
);
|
|
2938
|
+
if (
|
|
2939
|
+
structuredMemoryControlPlane !== null &&
|
|
2940
|
+
options.memoryPolicyReceiptWriter != null &&
|
|
2941
|
+
options.memoryPolicyReceiptWriter !==
|
|
2942
|
+
structuredMemoryControlPlane.policyReceiptWriter
|
|
2943
|
+
) {
|
|
2944
|
+
throw new Error(
|
|
2945
|
+
"Agent REPL received conflicting structured memory policy capabilities",
|
|
2946
|
+
);
|
|
2947
|
+
}
|
|
2912
2948
|
const sessionHostLeaseScope = { lease: null };
|
|
2913
2949
|
const sessionBudgetRootScope = { root: null };
|
|
2914
2950
|
const runtimeOptions = {
|
|
2915
2951
|
...options,
|
|
2952
|
+
...(evolutionIngress === null ? {} : { evolutionIngress }),
|
|
2953
|
+
...(structuredMemoryControlPlane === null
|
|
2954
|
+
? {}
|
|
2955
|
+
: {
|
|
2956
|
+
structuredMemoryControlPlane,
|
|
2957
|
+
memoryPolicyReceiptWriter:
|
|
2958
|
+
structuredMemoryControlPlane.policyReceiptWriter,
|
|
2959
|
+
}),
|
|
2916
2960
|
_sessionHostLeaseScope: sessionHostLeaseScope,
|
|
2917
2961
|
_sessionBudgetRootScope: sessionBudgetRootScope,
|
|
2918
2962
|
};
|
|
@@ -3949,6 +3993,7 @@ async function startAgentReplInWorkspaceOwned(
|
|
|
3949
3993
|
isText: false, // the REPL prints its own pairing lines below
|
|
3950
3994
|
allowLan: options.remoteControlAllowLan === true,
|
|
3951
3995
|
env: process.env,
|
|
3996
|
+
memoryPolicyReceiptWriter: options.memoryPolicyReceiptWriter ?? null,
|
|
3952
3997
|
});
|
|
3953
3998
|
_remoteApproval = {
|
|
3954
3999
|
bridge: started.bridge,
|
|
@@ -31,6 +31,9 @@ import { loadConfig } from "../lib/config-manager.js";
|
|
|
31
31
|
import { collectWorkspacePluginBinSandboxPolicy } from "../lib/plugin-runtime/bin.js";
|
|
32
32
|
import { issueMcpStdioExecutionAuthority } from "../lib/mcp-stdio-execution-authority.js";
|
|
33
33
|
import { registerHostHooksV2Workspace } from "../lib/hooks-v2-workspace-context.js";
|
|
34
|
+
import { captureStructuredMemoryPolicyReceiptWriter } from "../lib/evolution/structured-memory-policy-receipt-writer.js";
|
|
35
|
+
import { captureStructuredMemoryAgentControlPlane } from "../lib/evolution/structured-memory-agent-control-plane.js";
|
|
36
|
+
import { captureAgentEvolutionIngress } from "../lib/evolution/agent-evolution-ingress.js";
|
|
34
37
|
|
|
35
38
|
const {
|
|
36
39
|
DEFAULT_ALLOWED_MCP_SERVER_NAMES,
|
|
@@ -62,6 +65,41 @@ export class AgentRuntime {
|
|
|
62
65
|
this.config = config;
|
|
63
66
|
this.context = createRuntimeContext({ kind, policy, config });
|
|
64
67
|
this.events = deps.events || new RuntimeEventEmitter();
|
|
68
|
+
this.evolutionIngress =
|
|
69
|
+
deps.evolutionIngress == null
|
|
70
|
+
? null
|
|
71
|
+
: captureAgentEvolutionIngress(deps.evolutionIngress);
|
|
72
|
+
this.structuredMemoryControlPlane =
|
|
73
|
+
deps.structuredMemoryControlPlane == null
|
|
74
|
+
? null
|
|
75
|
+
: captureStructuredMemoryAgentControlPlane(
|
|
76
|
+
deps.structuredMemoryControlPlane,
|
|
77
|
+
);
|
|
78
|
+
if (
|
|
79
|
+
this.structuredMemoryControlPlane !== null &&
|
|
80
|
+
deps.memoryPolicyReceiptWriter != null
|
|
81
|
+
) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
"structured memory control plane and standalone policy writer cannot both be configured",
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
this.memoryPolicyReceiptWriter =
|
|
87
|
+
this.structuredMemoryControlPlane?.policyReceiptWriter ??
|
|
88
|
+
(deps.memoryPolicyReceiptWriter == null
|
|
89
|
+
? null
|
|
90
|
+
: captureStructuredMemoryPolicyReceiptWriter(
|
|
91
|
+
deps.memoryPolicyReceiptWriter,
|
|
92
|
+
));
|
|
93
|
+
if (
|
|
94
|
+
this.evolutionIngress !== null &&
|
|
95
|
+
this.structuredMemoryControlPlane !== null &&
|
|
96
|
+
this.evolutionIngress.tenantId !==
|
|
97
|
+
this.structuredMemoryControlPlane.tenantId
|
|
98
|
+
) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
"Agent evolution ingress and structured memory must share one tenant",
|
|
101
|
+
);
|
|
102
|
+
}
|
|
65
103
|
this.deps = {
|
|
66
104
|
startAgentRepl: deps.startAgentRepl || startAgentRepl,
|
|
67
105
|
startChatRepl: deps.startChatRepl || startChatRepl,
|
|
@@ -88,8 +126,18 @@ export class AgentRuntime {
|
|
|
88
126
|
resolveAgentBundle: deps.resolveAgentBundle || null,
|
|
89
127
|
openBrowser: deps.openBrowser || openBrowser,
|
|
90
128
|
runTurn: deps.runTurn || null,
|
|
129
|
+
evolutionCompositionFactory:
|
|
130
|
+
deps.evolutionCompositionFactory == null
|
|
131
|
+
? null
|
|
132
|
+
: deps.evolutionCompositionFactory,
|
|
91
133
|
logger: deps.logger || logger,
|
|
92
134
|
};
|
|
135
|
+
if (
|
|
136
|
+
this.deps.evolutionCompositionFactory !== null &&
|
|
137
|
+
typeof this.deps.evolutionCompositionFactory !== "function"
|
|
138
|
+
) {
|
|
139
|
+
throw new TypeError("evolutionCompositionFactory must be a function");
|
|
140
|
+
}
|
|
93
141
|
}
|
|
94
142
|
|
|
95
143
|
on(eventName, listener) {
|
|
@@ -146,6 +194,14 @@ export class AgentRuntime {
|
|
|
146
194
|
}
|
|
147
195
|
|
|
148
196
|
const startedAt = Date.now();
|
|
197
|
+
if (this.evolutionIngress !== null) {
|
|
198
|
+
await this.evolutionIngress.ingestUserPrompt({
|
|
199
|
+
input,
|
|
200
|
+
meta,
|
|
201
|
+
sessionId: this.policy.sessionId || null,
|
|
202
|
+
startedAt,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
149
205
|
this.emit(
|
|
150
206
|
RUNTIME_EVENTS.TURN_START,
|
|
151
207
|
createAgentTurnRecord({
|
|
@@ -165,6 +221,16 @@ export class AgentRuntime {
|
|
|
165
221
|
context: this.context,
|
|
166
222
|
});
|
|
167
223
|
|
|
224
|
+
if (this.evolutionIngress !== null) {
|
|
225
|
+
await this.evolutionIngress.ingestAgentEvent({
|
|
226
|
+
type: "response-complete",
|
|
227
|
+
content: result,
|
|
228
|
+
sessionId: this.policy.sessionId || null,
|
|
229
|
+
startedAt,
|
|
230
|
+
endedAt: Date.now(),
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
168
234
|
this.emit(
|
|
169
235
|
RUNTIME_EVENTS.TURN_END,
|
|
170
236
|
createAgentTurnRecord({
|
|
@@ -181,7 +247,35 @@ export class AgentRuntime {
|
|
|
181
247
|
return result;
|
|
182
248
|
}
|
|
183
249
|
|
|
250
|
+
_requireStructuredMemoryControlPlane() {
|
|
251
|
+
if (this.kind !== "agent" || this.structuredMemoryControlPlane === null) {
|
|
252
|
+
throw new Error(
|
|
253
|
+
"structured memory Agent control plane is not configured",
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
return this.structuredMemoryControlPlane;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
async proposeSemanticMemory(input) {
|
|
260
|
+
return this._requireStructuredMemoryControlPlane().semantic.propose(input);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async reviewAndAcceptSemanticMemory(input) {
|
|
264
|
+
return this._requireStructuredMemoryControlPlane().semantic.reviewAndAccept(
|
|
265
|
+
input,
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
createEvolutionPromotionControlPlane(options) {
|
|
270
|
+
return this._requireStructuredMemoryControlPlane().createEvaluatedPromotionControlPlane(
|
|
271
|
+
options,
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
|
|
184
275
|
async startAgentSession() {
|
|
276
|
+
if (this.evolutionIngress !== null) {
|
|
277
|
+
await this.evolutionIngress.start();
|
|
278
|
+
}
|
|
185
279
|
this.emit(RUNTIME_EVENTS.RUNTIME_START, {
|
|
186
280
|
kind: this.kind,
|
|
187
281
|
policy: this.policy,
|
|
@@ -190,7 +284,24 @@ export class AgentRuntime {
|
|
|
190
284
|
kind: this.kind,
|
|
191
285
|
sessionId: this.policy.sessionId || null,
|
|
192
286
|
});
|
|
193
|
-
|
|
287
|
+
const result = await this.deps.startAgentRepl({
|
|
288
|
+
...this.policy,
|
|
289
|
+
...(this.memoryPolicyReceiptWriter === null
|
|
290
|
+
? {}
|
|
291
|
+
: { memoryPolicyReceiptWriter: this.memoryPolicyReceiptWriter }),
|
|
292
|
+
...(this.structuredMemoryControlPlane === null
|
|
293
|
+
? {}
|
|
294
|
+
: {
|
|
295
|
+
structuredMemoryControlPlane: this.structuredMemoryControlPlane,
|
|
296
|
+
}),
|
|
297
|
+
...(this.evolutionIngress === null
|
|
298
|
+
? {}
|
|
299
|
+
: { evolutionIngress: this.evolutionIngress }),
|
|
300
|
+
});
|
|
301
|
+
if (this.evolutionIngress !== null) {
|
|
302
|
+
await this.evolutionIngress.complete();
|
|
303
|
+
}
|
|
304
|
+
return result;
|
|
194
305
|
}
|
|
195
306
|
|
|
196
307
|
async startChatSession() {
|
|
@@ -356,6 +467,7 @@ export class AgentRuntime {
|
|
|
356
467
|
remoteSessionRelayUrl,
|
|
357
468
|
remoteSessionPeerId,
|
|
358
469
|
envelopeBus,
|
|
470
|
+
evolutionCompositionFactory: this.deps.evolutionCompositionFactory,
|
|
359
471
|
});
|
|
360
472
|
|
|
361
473
|
server.on("connection", ({ clientId, ip }) => {
|
|
@@ -529,6 +641,7 @@ export class AgentRuntime {
|
|
|
529
641
|
timeout: 60000,
|
|
530
642
|
sessionManager,
|
|
531
643
|
projectRoot: workspacePolicyCwd,
|
|
644
|
+
evolutionCompositionFactory: this.deps.evolutionCompositionFactory,
|
|
532
645
|
});
|
|
533
646
|
// ChainlessChainWSServer extends EventEmitter and emits "error"
|
|
534
647
|
// synchronously on bind failure (in addition to rejecting start()).
|