@oscharko-dev/keiko 1.1.12 → 1.1.13
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/dist/ui/csp-hashes.json +6 -6
- package/dist/ui/static/404.html +1 -1
- package/dist/ui/static/__next.__PAGE__.txt +11 -11
- package/dist/ui/static/__next._full.txt +13 -13
- package/dist/ui/static/__next._tree.txt +2 -2
- package/dist/ui/static/_next/static/chunks/01n8x8_z3012u.js +1 -0
- package/dist/ui/static/_next/static/chunks/{3jb5u4g15g__m.css → 02epwnm5oro9c.css} +7 -4
- package/dist/ui/static/_next/static/chunks/04y8gqfjksqzo.js +1 -0
- package/dist/ui/static/_next/static/chunks/0_p-xs8nu7pby.js +1 -0
- package/dist/ui/static/_next/static/chunks/0gia_iwqox3xm.js +1 -0
- package/dist/ui/static/_next/static/chunks/0p2ekj8g4s6t2.js +1 -0
- package/dist/ui/static/_next/static/chunks/0tl_05c5ux5ut.js +1 -0
- package/dist/ui/static/_next/static/chunks/0y68jeskhcm2k.js +1 -0
- package/dist/ui/static/_next/static/chunks/13q3e5wnz6lps.css +1 -0
- package/dist/ui/static/_next/static/chunks/199p3upt-xa37.js +1 -0
- package/dist/ui/static/_next/static/chunks/{17jlhx5dll_r6.js → 1_bezidc0febq.js} +1 -1
- package/dist/ui/static/_next/static/chunks/{3aizxizjzdddj.js → 1bdojlx9hv0c5.js} +1 -1
- package/dist/ui/static/_next/static/chunks/1d7xigpwq-xq8.js +1 -0
- package/dist/ui/static/_next/static/chunks/1hucqkor7zgbn.js +1 -0
- package/dist/ui/static/_next/static/chunks/1j6nqp8yrqyhu.js +1 -0
- package/dist/ui/static/_next/static/chunks/{2iatd917svh3o.js → 1logclobi6726.js} +1 -1
- package/dist/ui/static/_next/static/chunks/1o3z4r4xrlbda.js +1 -0
- package/dist/ui/static/_next/static/chunks/1szpnddxqmzhy.js +1 -0
- package/dist/ui/static/_next/static/chunks/1tkt9f0xnc4fe.js +1 -0
- package/dist/ui/static/_next/static/chunks/1u_s3uvh9p4j7.js +1 -0
- package/dist/ui/static/_next/static/chunks/1wa9m6c88mg3p.js +1 -0
- package/dist/ui/static/_next/static/chunks/2384n1pce2w1h.js +1 -0
- package/dist/ui/static/_next/static/chunks/{0xhrzm-zp_lsx.js → 25f22x86d_a1n.js} +1 -1
- package/dist/ui/static/_next/static/chunks/271r_v0nh0vy-.js +1 -0
- package/dist/ui/static/_next/static/chunks/{36-tv3y56oau8.js → 29dj-5kj_vfl_.js} +1 -1
- package/dist/ui/static/_next/static/chunks/2_u63ddjyhbpm.js +3 -0
- package/dist/ui/static/_next/static/chunks/{306ima8lxo17-.js → 2cw7v8t4jg669.js} +1 -1
- package/dist/ui/static/_next/static/chunks/2gqs8fif3137x.js +3 -0
- package/dist/ui/static/_next/static/chunks/2r4vn_6anv2cw.js +5 -0
- package/dist/ui/static/_next/static/chunks/{25lgzefdnbdh6.js → 2s5wt9bf-ox40.js} +1 -1
- package/dist/ui/static/_next/static/chunks/{3_rof9w-g14_v.js → 2tmor5n3xss6c.js} +3 -3
- package/dist/ui/static/_next/static/chunks/{32tief1094icq.js → 2wd7di0z2l6il.js} +1 -1
- package/dist/ui/static/_next/static/chunks/2xynqzhclj1u-.js +27 -0
- package/dist/ui/static/_next/static/chunks/{2vcovdwo6s3-l.js → 2ymm_n9gbcdcw.js} +1 -1
- package/dist/ui/static/_next/static/chunks/3-ys11qyww0y6.js +1 -0
- package/dist/ui/static/_next/static/chunks/{1cluynrv3wmyz.js → 30botqyyk9ugo.js} +1 -1
- package/dist/ui/static/_next/static/chunks/30p9b535cwzhr.js +1 -0
- package/dist/ui/static/_next/static/chunks/31mnda46lo2b0.js +1 -0
- package/dist/ui/static/_next/static/chunks/338jl640mvtkg.js +1 -0
- package/dist/ui/static/_next/static/chunks/389bs_l5-yv4y.css +1 -0
- package/dist/ui/static/_next/static/chunks/39nyg25pqs1kv.js +1 -0
- package/dist/ui/static/_next/static/chunks/3buu6m28ig2oz.js +1 -0
- package/dist/ui/static/_next/static/chunks/3i0iog52c1ajg.js +1 -0
- package/dist/ui/static/_next/static/chunks/3im1pldojqzmu.js +1 -0
- package/dist/ui/static/_next/static/chunks/{25j7z89g58y1-.css → 3inx1ugcc-jd-.css} +1 -2
- package/dist/ui/static/_next/static/chunks/{0_p1naz51ki9i.js → 3iptbrztxckih.js} +1 -1
- package/dist/ui/static/_next/static/chunks/{0mkhgmj9-jvu-.js → 3m_idsf90zq5u.js} +1 -1
- package/dist/ui/static/_next/static/chunks/3mes_qld9wgti.js +1 -0
- package/dist/ui/static/_next/static/chunks/3timx0h4kcna0.js +1 -0
- package/dist/ui/static/_next/static/chunks/3u-4amh4iusi1.js +1 -0
- package/dist/ui/static/_next/static/chunks/3uacpjje41xz5.js +1 -0
- package/dist/ui/static/_next/static/chunks/3wcuc7e2bz4-l.js +1 -0
- package/dist/ui/static/_next/static/chunks/3xaa0t5drdxz3.js +1 -0
- package/dist/ui/static/_next/static/chunks/40ol4dc9uptck.js +10 -0
- package/dist/ui/static/_next/static/chunks/44jv6p8ly-u3e.js +1 -0
- package/dist/ui/static/_not-found/__next._full.txt +9 -9
- package/dist/ui/static/_not-found/__next._not-found.__PAGE__.txt +8 -8
- package/dist/ui/static/_not-found/__next._tree.txt +1 -1
- package/dist/ui/static/_not-found.html +1 -1
- package/dist/ui/static/_not-found.txt +9 -9
- package/dist/ui/static/atlassian-connectors/__next._full.txt +13 -13
- package/dist/ui/static/atlassian-connectors/__next._tree.txt +1 -1
- package/dist/ui/static/atlassian-connectors/__next.atlassian-connectors.__PAGE__.txt +10 -10
- package/dist/ui/static/atlassian-connectors.html +1 -1
- package/dist/ui/static/atlassian-connectors.txt +13 -13
- package/dist/ui/static/index.html +1 -1
- package/dist/ui/static/index.txt +13 -13
- package/dist/ui/static/launch/__next._full.txt +13 -13
- package/dist/ui/static/launch/__next._tree.txt +2 -2
- package/dist/ui/static/launch/__next.launch.__PAGE__.txt +11 -11
- package/dist/ui/static/launch.html +1 -1
- package/dist/ui/static/launch.txt +13 -13
- package/dist/ui/static/local-knowledge/__next._full.txt +13 -13
- package/dist/ui/static/local-knowledge/__next._tree.txt +2 -2
- package/dist/ui/static/local-knowledge/__next.local-knowledge.__PAGE__.txt +11 -11
- package/dist/ui/static/local-knowledge/capsule/__next._full.txt +13 -13
- package/dist/ui/static/local-knowledge/capsule/__next._tree.txt +1 -1
- package/dist/ui/static/local-knowledge/capsule/__next.local-knowledge.capsule.__PAGE__.txt +10 -10
- package/dist/ui/static/local-knowledge/capsule.html +1 -1
- package/dist/ui/static/local-knowledge/capsule.txt +13 -13
- package/dist/ui/static/local-knowledge.html +1 -1
- package/dist/ui/static/local-knowledge.txt +13 -13
- package/node_modules/@oscharko-dev/keiko-activity-log/dist/server-log.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-activity-log/dist/server-log.js +4 -1
- package/node_modules/@oscharko-dev/keiko-activity-log/package.json +3 -3
- package/node_modules/@oscharko-dev/keiko-cli/package.json +15 -15
- package/node_modules/@oscharko-dev/keiko-connectors/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-connectors/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-connectors/package.json +3 -3
- package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-failure-class-contracts.d.ts +24 -4
- package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-failure-class-contracts.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-failure-class-contracts.js +58 -2
- package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-registry.generated.d.ts +632 -7
- package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-registry.generated.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-registry.generated.js +760 -5
- package/node_modules/@oscharko-dev/keiko-contracts/dist/bff-wire.d.ts +16 -0
- package/node_modules/@oscharko-dev/keiko-contracts/dist/bff-wire.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/context-engineering-compaction-validation.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/context-engineering-compaction-validation.js +30 -0
- package/node_modules/@oscharko-dev/keiko-contracts/dist/context-engineering.d.ts +9 -0
- package/node_modules/@oscharko-dev/keiko-contracts/dist/context-engineering.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/diagnostics.d.ts +17 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/diagnostics.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/diagnostics.js +88 -4
- package/node_modules/@oscharko-dev/keiko-contracts/dist/editor-m7.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/editor-m7.js +24 -8
- package/node_modules/@oscharko-dev/keiko-contracts/dist/version.d.ts +2 -2
- package/node_modules/@oscharko-dev/keiko-contracts/dist/version.js +2 -2
- package/node_modules/@oscharko-dev/keiko-contracts/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-evaluations/package.json +9 -9
- package/node_modules/@oscharko-dev/keiko-evidence/dist/compaction-evidence.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-evidence/dist/compaction-evidence.js +13 -0
- package/node_modules/@oscharko-dev/keiko-evidence/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-evidence/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-evidence/package.json +4 -4
- package/node_modules/@oscharko-dev/keiko-git/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-git/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-git/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-harness/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-harness/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-harness/package.json +7 -7
- package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-local-knowledge/package.json +5 -5
- package/node_modules/@oscharko-dev/keiko-memory-capture/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-capture/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-capture/package.json +3 -3
- package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-consolidation/package.json +3 -3
- package/node_modules/@oscharko-dev/keiko-memory-governance/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-governance/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-governance/package.json +3 -3
- package/node_modules/@oscharko-dev/keiko-memory-retrieval/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-retrieval/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-retrieval/package.json +3 -3
- package/node_modules/@oscharko-dev/keiko-memory-vault/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-vault/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-vault/package.json +3 -3
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/package.json +4 -4
- package/node_modules/@oscharko-dev/keiko-quality-intelligence/package.json +3 -3
- package/node_modules/@oscharko-dev/keiko-sandbox/package.json +2 -2
- package/node_modules/@oscharko-dev/keiko-sdk/package.json +9 -9
- package/node_modules/@oscharko-dev/keiko-security/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-security/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-security/package.json +2 -2
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-activity.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-activity.js +16 -7
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-evidence.d.ts +1 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-evidence.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-evidence.js +4 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-model-call.d.ts +5 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-model-call.d.ts.map +1 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-model-call.js +29 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-model-summary.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-model-summary.js +108 -59
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-resurfacing.d.ts +3 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-resurfacing.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-resurfacing.js +43 -7
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-context-log.d.ts +4 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-context-log.d.ts.map +1 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-context-log.js +95 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-context-status.d.ts +5 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-context-status.d.ts.map +1 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-context-status.js +114 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-continuity-log.d.ts +21 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-continuity-log.d.ts.map +1 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-continuity-log.js +116 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-handlers.d.ts +7 -5
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-handlers.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-handlers.js +187 -99
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-history-rehydration.d.ts +4 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-history-rehydration.d.ts.map +1 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-history-rehydration.js +137 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-history-snapshot.d.ts +16 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-history-snapshot.d.ts.map +1 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-history-snapshot.js +152 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-budget-diagnostics.d.ts +1 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-budget-diagnostics.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-budget-diagnostics.js +15 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-budget.d.ts +12 -3
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-budget.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-budget.js +106 -20
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-compaction.d.ts +13 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-compaction.d.ts.map +1 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-prompt-compaction.js +161 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-stream-handlers.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/chat-stream-handlers.js +44 -19
- package/node_modules/@oscharko-dev/keiko-server/dist/client-diagnostics-routes.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/client-diagnostics-routes.js +83 -17
- package/node_modules/@oscharko-dev/keiko-server/dist/conversation-compaction.d.ts +6 -2
- package/node_modules/@oscharko-dev/keiko-server/dist/conversation-compaction.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/conversation-compaction.js +181 -52
- package/node_modules/@oscharko-dev/keiko-server/dist/conversation-gateway.d.ts +5 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/conversation-gateway.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/conversation-gateway.js +5 -2
- package/node_modules/@oscharko-dev/keiko-server/dist/deps.d.ts +4 -3
- package/node_modules/@oscharko-dev/keiko-server/dist/deps.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/deps.js +77 -16
- package/node_modules/@oscharko-dev/keiko-server/dist/gateway-readiness.d.ts +8 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/gateway-readiness.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/gateway-readiness.js +221 -14
- package/node_modules/@oscharko-dev/keiko-server/dist/gateway-setup.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/gateway-setup.js +71 -85
- package/node_modules/@oscharko-dev/keiko-server/dist/grounded-conversation-continuity.d.ts +10 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/grounded-conversation-continuity.d.ts.map +1 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/grounded-conversation-continuity.js +122 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-hybrid.d.ts +1 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-hybrid.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-hybrid.js +3 -3
- package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-multi-source.d.ts +1 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-multi-source.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa-multi-source.js +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa.d.ts +3 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa.js +86 -24
- package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-grounded-qa.d.ts +1 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-grounded-qa.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-grounded-qa.js +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/observability/route-template.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/observability/route-template.js +1 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/routes.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/routes.js +3 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/store/codingHistoryIsolation.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/store/codingHistoryIsolation.js +8 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/store/db.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/store/db.js +5 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/store/legacySchemaTestFixture.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/store/legacySchemaTestFixture.js +10 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/store/messages.d.ts +2 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/store/messages.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/store/messages.js +53 -82
- package/node_modules/@oscharko-dev/keiko-server/dist/store/schema.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/store/schema.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/store/schema.js +28 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/store/types.d.ts +3 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/store/types.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/store-handlers.d.ts +2 -0
- package/node_modules/@oscharko-dev/keiko-server/dist/store-handlers.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/store-handlers.js +41 -3
- package/node_modules/@oscharko-dev/keiko-server/package.json +23 -23
- package/node_modules/@oscharko-dev/keiko-tool-catalog/package.json +3 -3
- package/node_modules/@oscharko-dev/keiko-tools/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-tools/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-tools/package.json +7 -7
- package/node_modules/@oscharko-dev/keiko-verification/package.json +5 -5
- package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/index.d.ts +2 -1
- package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/index.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/index.js +2 -1
- package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/rehydration.d.ts +1 -0
- package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/rehydration.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/rehydration.js +2 -2
- package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/structured-digest.d.ts +1 -0
- package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/structured-digest.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-workflows/dist/context-budget/structured-digest.js +91 -27
- package/node_modules/@oscharko-dev/keiko-workflows/package.json +10 -10
- package/node_modules/@oscharko-dev/keiko-workspace/dist/version.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-workspace/dist/version.js +1 -1
- package/node_modules/@oscharko-dev/keiko-workspace/package.json +3 -3
- package/package.json +35 -29
- package/release-impact.catalog.json +87 -23
- package/vendor/oscharko-dev-keiko-activity-log-1.1.13.tgz +0 -0
- package/vendor/{oscharko-dev-keiko-cli-1.1.12.tgz → oscharko-dev-keiko-cli-1.1.13.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-connectors-1.1.12.tgz → oscharko-dev-keiko-connectors-1.1.13.tgz} +0 -0
- package/vendor/oscharko-dev-keiko-contracts-1.1.13.tgz +0 -0
- package/vendor/{oscharko-dev-keiko-evaluations-1.1.12.tgz → oscharko-dev-keiko-evaluations-1.1.13.tgz} +0 -0
- package/vendor/oscharko-dev-keiko-evidence-1.1.13.tgz +0 -0
- package/vendor/oscharko-dev-keiko-git-1.1.13.tgz +0 -0
- package/vendor/{oscharko-dev-keiko-harness-1.1.12.tgz → oscharko-dev-keiko-harness-1.1.13.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-local-knowledge-1.1.12.tgz → oscharko-dev-keiko-local-knowledge-1.1.13.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-memory-capture-1.1.12.tgz → oscharko-dev-keiko-memory-capture-1.1.13.tgz} +0 -0
- package/vendor/oscharko-dev-keiko-memory-consolidation-1.1.13.tgz +0 -0
- package/vendor/{oscharko-dev-keiko-memory-governance-1.1.12.tgz → oscharko-dev-keiko-memory-governance-1.1.13.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-memory-retrieval-1.1.12.tgz → oscharko-dev-keiko-memory-retrieval-1.1.13.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-memory-vault-1.1.12.tgz → oscharko-dev-keiko-memory-vault-1.1.13.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-model-gateway-1.1.12.tgz → oscharko-dev-keiko-model-gateway-1.1.13.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-quality-intelligence-1.1.12.tgz → oscharko-dev-keiko-quality-intelligence-1.1.13.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-sandbox-1.1.12.tgz → oscharko-dev-keiko-sandbox-1.1.13.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-sdk-1.1.12.tgz → oscharko-dev-keiko-sdk-1.1.13.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-security-1.1.12.tgz → oscharko-dev-keiko-security-1.1.13.tgz} +0 -0
- package/vendor/oscharko-dev-keiko-server-1.1.13.tgz +0 -0
- package/vendor/{oscharko-dev-keiko-tool-catalog-1.1.12.tgz → oscharko-dev-keiko-tool-catalog-1.1.13.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-tools-1.1.12.tgz → oscharko-dev-keiko-tools-1.1.13.tgz} +0 -0
- package/vendor/{oscharko-dev-keiko-verification-1.1.12.tgz → oscharko-dev-keiko-verification-1.1.13.tgz} +0 -0
- package/vendor/oscharko-dev-keiko-workflows-1.1.13.tgz +0 -0
- package/vendor/{oscharko-dev-keiko-workspace-1.1.12.tgz → oscharko-dev-keiko-workspace-1.1.13.tgz} +0 -0
- package/dist/ui/static/_next/static/chunks/06yzmh78cidsr.js +0 -1
- package/dist/ui/static/_next/static/chunks/08kdz_q929mef.js +0 -1
- package/dist/ui/static/_next/static/chunks/0_7ry-vzqryfq.js +0 -1
- package/dist/ui/static/_next/static/chunks/115f9zt0f5hm4.js +0 -1
- package/dist/ui/static/_next/static/chunks/1cjmlpaxzl17x.js +0 -1
- package/dist/ui/static/_next/static/chunks/1hnficrb11m9x.js +0 -1
- package/dist/ui/static/_next/static/chunks/1jfpuw9-h8iaq.js +0 -1
- package/dist/ui/static/_next/static/chunks/1oe16odh9-wem.js +0 -1
- package/dist/ui/static/_next/static/chunks/1rrylkj4wfhla.js +0 -1
- package/dist/ui/static/_next/static/chunks/1uxrq3q9n5v4y.js +0 -1
- package/dist/ui/static/_next/static/chunks/1x5aw_ayly-sh.js +0 -1
- package/dist/ui/static/_next/static/chunks/1yiiigw5l63v1.js +0 -36
- package/dist/ui/static/_next/static/chunks/2-h3ow6f6ywtk.js +0 -1
- package/dist/ui/static/_next/static/chunks/22tu2ta5xr5wj.js +0 -1
- package/dist/ui/static/_next/static/chunks/22x3pxeia7hk_.js +0 -1
- package/dist/ui/static/_next/static/chunks/22yars17p-i_a.js +0 -1
- package/dist/ui/static/_next/static/chunks/233j_pai87f3k.js +0 -2
- package/dist/ui/static/_next/static/chunks/27490erridyaz.js +0 -1
- package/dist/ui/static/_next/static/chunks/2e4prtd3wmn0a.js +0 -1
- package/dist/ui/static/_next/static/chunks/2tcon4aj5dc5t.js +0 -1
- package/dist/ui/static/_next/static/chunks/2uewj5n3jrohk.js +0 -1
- package/dist/ui/static/_next/static/chunks/2wtsqscjch4bx.js +0 -1
- package/dist/ui/static/_next/static/chunks/2xpud5k1hwfvf.js +0 -1
- package/dist/ui/static/_next/static/chunks/365nk-5mmf_8c.js +0 -1
- package/dist/ui/static/_next/static/chunks/36afhcug0i5mm.js +0 -1
- package/dist/ui/static/_next/static/chunks/36t-jmpwnypy0.js +0 -1
- package/dist/ui/static/_next/static/chunks/37f_o8ne61ty2.js +0 -1
- package/dist/ui/static/_next/static/chunks/37mtn-h7j8ygx.js +0 -1
- package/dist/ui/static/_next/static/chunks/3_u5w33et675r.js +0 -1
- package/dist/ui/static/_next/static/chunks/3f6svr_pokw6j.js +0 -1
- package/dist/ui/static/_next/static/chunks/3r4fz572q3l7s.js +0 -1
- package/dist/ui/static/_next/static/chunks/3vnb2msty1ab4.js +0 -1
- package/dist/ui/static/_next/static/chunks/3zd1y0ze7hnsy.js +0 -1
- package/dist/ui/static/_next/static/chunks/412pf48_r8im3.js +0 -1
- package/dist/ui/static/_next/static/chunks/434km55nqikg-.js +0 -7
- package/vendor/oscharko-dev-keiko-activity-log-1.1.12.tgz +0 -0
- package/vendor/oscharko-dev-keiko-contracts-1.1.12.tgz +0 -0
- package/vendor/oscharko-dev-keiko-evidence-1.1.12.tgz +0 -0
- package/vendor/oscharko-dev-keiko-git-1.1.12.tgz +0 -0
- package/vendor/oscharko-dev-keiko-memory-consolidation-1.1.12.tgz +0 -0
- package/vendor/oscharko-dev-keiko-server-1.1.12.tgz +0 -0
- package/vendor/oscharko-dev-keiko-workflows-1.1.12.tgz +0 -0
- /package/dist/ui/static/_next/static/{__kGQcCW6ht5xSodXZZBj → -GseUdaJoAYnEgt-Dl41f}/_buildManifest.js +0 -0
- /package/dist/ui/static/_next/static/{__kGQcCW6ht5xSodXZZBj → -GseUdaJoAYnEgt-Dl41f}/_clientMiddlewareManifest.js +0 -0
- /package/dist/ui/static/_next/static/{__kGQcCW6ht5xSodXZZBj → -GseUdaJoAYnEgt-Dl41f}/_ssgManifest.js +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { CancelledError } from "@oscharko-dev/keiko-security/errors/gateway";
|
|
2
|
+
import { compactCurrentChatPrompt } from "./chat-prompt-compaction.js";
|
|
3
|
+
import { captureChatHistory, stampHistoryRevision, } from "./chat-history-snapshot.js";
|
|
4
|
+
import { loadChatContinuityCheckpoint } from "./chat-compaction-resurfacing.js";
|
|
5
|
+
import { rehydrateChatHistory } from "./chat-history-rehydration.js";
|
|
4
6
|
import { createHash, randomUUID } from "node:crypto";
|
|
5
7
|
import { basename } from "node:path";
|
|
6
8
|
import { GatewayError, ContextOverflowError, listCapabilities, listConfiguredCapabilities, } from "@oscharko-dev/keiko-model-gateway";
|
|
@@ -13,7 +15,7 @@ import { retrieveMemoryContext } from "@oscharko-dev/keiko-memory-retrieval";
|
|
|
13
15
|
import { isMaintenanceDue, maybeRunAutoMaintenance, memoryMaintenanceAuditSink, memorySemanticizationMultipliers, resolveMaintenanceAutonomyMode, resolveMemoryRetentionPolicy, } from "./memory-maintenance-handlers.js";
|
|
14
16
|
import { buildConversationRetrievalSignals, conversationFusionMode, semanticRetrievalGateForText, } from "./memory-retrieval-signals.js";
|
|
15
17
|
import { reinforcementAccessIdsForAssistantUse } from "./memory-reinforcement.js";
|
|
16
|
-
import {
|
|
18
|
+
import { awaitAnyInitializedConversationReadyChatModel, awaitInitializedConversationReadiness, } from "./gateway-readiness.js";
|
|
17
19
|
import { extractCandidatesFromUserText, } from "@oscharko-dev/keiko-memory-capture";
|
|
18
20
|
import { UiStoreError, isProjectAvailable, } from "./store/index.js";
|
|
19
21
|
import { validateConversationPayload, validateConversationPayloadSafety, } from "./conversation-validation.js";
|
|
@@ -67,7 +69,7 @@ import { canonicalChatTurnGroundingScopeIdentity, canonicalChatTurnIdentityConte
|
|
|
67
69
|
import { createRequestCancellation } from "./request-cancellation.js";
|
|
68
70
|
import { readBoundedRequestBody, RequestBodyCancelledError, RequestBodyTooLargeError, } from "./bounded-request-body.js";
|
|
69
71
|
import { userFacingProjects } from "./workspace-root-membership.js";
|
|
70
|
-
import { buildChatCompactionContextText, selectGatewayPromptAssembly, } from "./chat-prompt-budget.js";
|
|
72
|
+
import { buildChatCompactionContextText, selectGatewayPromptAssembly, gatewayAssemblyOutputAllocation, } from "./chat-prompt-budget.js";
|
|
71
73
|
import { MAX_CONTEXT_MESSAGES, usableGatewayMessages, withGatewayConversationImages, } from "./conversation-gateway.js";
|
|
72
74
|
import { resolveAppSessionReadAuthority } from "./coding-app-session/appSessionReadAuthority.js";
|
|
73
75
|
import { ConversationAttachmentStoreError } from "./conversation-attachment-store.js";
|
|
@@ -260,7 +262,16 @@ function gatewayErrorResult(error, deps, correlationId, emitDiagnostic) {
|
|
|
260
262
|
const status = gatewayErrorStatus(error);
|
|
261
263
|
return { status, body: errorBody(error.code, redactErrorMessage(error.message, deps)) };
|
|
262
264
|
}
|
|
265
|
+
class ChatPromptPreparationRejection extends Error {
|
|
266
|
+
result;
|
|
267
|
+
constructor(result) {
|
|
268
|
+
super("Desktop chat prompt preparation was rejected.");
|
|
269
|
+
this.result = result;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
263
272
|
export function desktopChatErrorResult(error, deps, correlationId, emitDiagnostic = true) {
|
|
273
|
+
if (error instanceof ChatPromptPreparationRejection)
|
|
274
|
+
return error.result;
|
|
264
275
|
if (error instanceof ConversationAttachmentStoreError) {
|
|
265
276
|
return {
|
|
266
277
|
status: 409,
|
|
@@ -790,6 +801,18 @@ export function settleRejectedDesktopChatTurn(deps, prepared, admitted, terminal
|
|
|
790
801
|
// makes that rollback a compare-and-set, so a concurrent accepted update survives.
|
|
791
802
|
deps.store.discardLegacyTurnUserMessage(request.chatId, admitted.userMessage.id, prepared.chat.updatedAt, admitted.legacyTouchedUpdatedAt);
|
|
792
803
|
}
|
|
804
|
+
export function settleFailedChatPromptPreparation(deps, prepared, admitted, error, signal) {
|
|
805
|
+
const cancelled = signal.aborted ||
|
|
806
|
+
error instanceof CancelledError ||
|
|
807
|
+
(error instanceof Error && error.name === "AbortError");
|
|
808
|
+
settleRejectedDesktopChatTurn(deps, prepared, admitted, cancelled ? "cancelled" : "failed");
|
|
809
|
+
}
|
|
810
|
+
export function settlePromptPreparationRejection(deps, prepared, admitted, error) {
|
|
811
|
+
if (!(error instanceof ChatPromptPreparationRejection))
|
|
812
|
+
return false;
|
|
813
|
+
settleRejectedDesktopChatTurn(deps, prepared, admitted);
|
|
814
|
+
return true;
|
|
815
|
+
}
|
|
793
816
|
export function createAssistantMessage(deps, request, content, modelId, userMessage) {
|
|
794
817
|
assertUsableAssistantContent(content, modelId);
|
|
795
818
|
return deps.store.createTurnAssistant(userMessage.id, {
|
|
@@ -1077,24 +1100,27 @@ async function captureActionFromOutcome(outcome, deps, mode, surface, canonicalC
|
|
|
1077
1100
|
return null;
|
|
1078
1101
|
}
|
|
1079
1102
|
}
|
|
1080
|
-
|
|
1103
|
+
function captureActionsFromOutcomes(outcomes, deps, mode, surface, canonicalCapture) {
|
|
1104
|
+
return outcomes.reduce(async (previous, outcome) => {
|
|
1105
|
+
const actions = await previous;
|
|
1106
|
+
const action = await captureActionFromOutcome(outcome, deps, mode, surface, canonicalCapture);
|
|
1107
|
+
if (action !== null)
|
|
1108
|
+
actions.push(action);
|
|
1109
|
+
return actions;
|
|
1110
|
+
}, Promise.resolve([]));
|
|
1111
|
+
}
|
|
1112
|
+
function captureMemoryActions(request, deps, context) {
|
|
1081
1113
|
if (request.memory === undefined || !request.memory.enabled || deps.memoryVault === undefined) {
|
|
1082
|
-
return [];
|
|
1114
|
+
return Promise.resolve([]);
|
|
1083
1115
|
}
|
|
1084
1116
|
const outcomes = extractCandidatesFromUserText(request.content, buildCaptureContext(context, request.clientTurnId), {
|
|
1085
1117
|
...memoryCapturePolicyForDeps(deps, {
|
|
1086
1118
|
resolver: createMemoryTargetResolver(deps.memoryVault),
|
|
1087
1119
|
}),
|
|
1088
1120
|
});
|
|
1089
|
-
const actions = [];
|
|
1090
1121
|
const mode = resolveMemoryCaptureAutonomyMode(deps, request.memory.mode);
|
|
1091
1122
|
const surface = request.memory.surface ?? "desktop";
|
|
1092
|
-
|
|
1093
|
-
const action = await captureActionFromOutcome(outcome, deps, mode, surface, request.clientTurnId !== undefined);
|
|
1094
|
-
if (action !== null)
|
|
1095
|
-
actions.push(action);
|
|
1096
|
-
}
|
|
1097
|
-
return actions;
|
|
1123
|
+
return captureActionsFromOutcomes(outcomes, deps, mode, surface, request.clientTurnId !== undefined);
|
|
1098
1124
|
}
|
|
1099
1125
|
export async function collectMemoryActions(deps, request, memoryContext) {
|
|
1100
1126
|
if (memoryContext === undefined) {
|
|
@@ -1152,11 +1178,27 @@ export function commitChatAfterTurn(deps, admittedChat, request, modelId) {
|
|
|
1152
1178
|
export function gatewayHistoryPrefix(snapshot) {
|
|
1153
1179
|
return snapshot.history.filter((message) => message.id !== snapshot.currentUserMessageId);
|
|
1154
1180
|
}
|
|
1155
|
-
export function
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1181
|
+
export function captureAdmittedSnapshot(deps, prepared, admitted, signal, correlationId) {
|
|
1182
|
+
try {
|
|
1183
|
+
return captureGatewayTurnSnapshot(deps, { ...prepared.request, modelId: prepared.modelId }, admitted.userMessage, correlationId);
|
|
1184
|
+
}
|
|
1185
|
+
catch (error) {
|
|
1186
|
+
settleFailedChatPromptPreparation(deps, prepared, admitted, error, signal);
|
|
1187
|
+
throw error;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
export function captureGatewayTurnSnapshot(deps, request, userMessage, correlationId, rehydrate = true) {
|
|
1191
|
+
let checkpointDisposition = "none";
|
|
1192
|
+
const checkpoint = loadChatContinuityCheckpoint(deps.evidenceStore, request.chatId, deps.store.chatHistoryRevision(request.chatId), correlationId, (disposition) => {
|
|
1193
|
+
checkpointDisposition = disposition;
|
|
1194
|
+
});
|
|
1195
|
+
const snapshot = captureChatHistory(deps.store, request.chatId, userMessage.id, currentContextProfileForModel(deps, request.modelId) ?? DEFAULT_CONTEXT_PROFILE, currentRedactionSecrets(deps), checkpoint, { correlationId, checkpointDisposition });
|
|
1196
|
+
return snapshot.earlierCompaction === undefined || !rehydrate
|
|
1197
|
+
? snapshot
|
|
1198
|
+
: {
|
|
1199
|
+
...snapshot,
|
|
1200
|
+
rehydratedContext: rehydrateChatHistory(deps.store, request.chatId, request.content, new Set(snapshot.history.map((message) => message.id)), currentRedactionSecrets(deps), correlationId),
|
|
1201
|
+
};
|
|
1160
1202
|
}
|
|
1161
1203
|
function finalizeGatewayAssembly(selected, request, correlationId) {
|
|
1162
1204
|
if (selected === undefined) {
|
|
@@ -1166,12 +1208,13 @@ function finalizeGatewayAssembly(selected, request, correlationId) {
|
|
|
1166
1208
|
return selected;
|
|
1167
1209
|
}
|
|
1168
1210
|
export function buildGatewayAssembly(deps, request, memory, modelId, snapshot, correlationId) {
|
|
1169
|
-
const
|
|
1170
|
-
if (
|
|
1211
|
+
const hasCurrentUser = snapshot.history.some((message) => message.id === snapshot.currentUserMessageId);
|
|
1212
|
+
if (!hasCurrentUser) {
|
|
1171
1213
|
throw new UiStoreError("INTERNAL", "Admitted chat turn is missing from its history.", 500);
|
|
1172
1214
|
}
|
|
1173
1215
|
const historyPrefix = gatewayHistoryPrefix(snapshot);
|
|
1174
1216
|
const selected = selectGatewayPromptAssembly({
|
|
1217
|
+
proactiveCompaction: true,
|
|
1175
1218
|
historyPrefix,
|
|
1176
1219
|
historyTurnCount: usableGatewayMessages(historyPrefix).length,
|
|
1177
1220
|
request: {
|
|
@@ -1181,11 +1224,21 @@ export function buildGatewayAssembly(deps, request, memory, modelId, snapshot, c
|
|
|
1181
1224
|
},
|
|
1182
1225
|
profile: currentContextProfileForModel(deps, modelId) ?? DEFAULT_CONTEXT_PROFILE,
|
|
1183
1226
|
memoryEntries: memory.context.memories,
|
|
1184
|
-
compactionContextText: buildChatCompactionContextText(deps.evidenceStore, request.chatId),
|
|
1227
|
+
compactionContextText: buildChatCompactionContextText(deps.evidenceStore, request.chatId, snapshot.historyRevision, correlationId),
|
|
1228
|
+
continuityContextText: snapshot.rehydratedContext,
|
|
1229
|
+
earlierCompaction: snapshot.earlierCompaction,
|
|
1185
1230
|
documentContext: request.documentContext,
|
|
1186
1231
|
redactionSecrets: currentRedactionSecrets(deps),
|
|
1187
1232
|
});
|
|
1188
|
-
return finalizeGatewayAssembly(selected, request, correlationId);
|
|
1233
|
+
return finalizeGatewayAssembly(stampGatewayCompaction(selected, deps, modelId, snapshot), request, correlationId);
|
|
1234
|
+
}
|
|
1235
|
+
function stampGatewayCompaction(selected, deps, modelId, snapshot) {
|
|
1236
|
+
if (selected === undefined)
|
|
1237
|
+
return undefined;
|
|
1238
|
+
return {
|
|
1239
|
+
...selected,
|
|
1240
|
+
compaction: stampHistoryRevision(selected.compaction, snapshot.historyRevision ?? 0, (currentContextProfileForModel(deps, modelId) ?? DEFAULT_CONTEXT_PROFILE).maxInputTokens),
|
|
1241
|
+
};
|
|
1189
1242
|
}
|
|
1190
1243
|
// ADR-0173 D5 g9 — the INPUT shape of a chat turn, never its content: how many messages the
|
|
1191
1244
|
// assembled prompt carries (split by role) and how many image attachments rode along (count +
|
|
@@ -1240,6 +1293,7 @@ export function recordChatCompaction(deps, turn) {
|
|
|
1240
1293
|
messageCount: turn.messageCount,
|
|
1241
1294
|
startedAt: turn.startedAt,
|
|
1242
1295
|
finishedAt: Date.now(),
|
|
1296
|
+
correlationId: turn.correlationId,
|
|
1243
1297
|
};
|
|
1244
1298
|
persistChatCompactionEvidence(deps, input);
|
|
1245
1299
|
scheduleCompactionModelSummary(deps, input, turn.historyPrefix, turn.correlationId);
|
|
@@ -1275,29 +1329,15 @@ function logCompactionSummaryFailure(deps, correlationId, error) {
|
|
|
1275
1329
|
}));
|
|
1276
1330
|
}
|
|
1277
1331
|
function buildRegenerateGatewayAssembly(deps, request, memory, modelId, historyBeforeAssistant, correlationId) {
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
historyPrefix,
|
|
1288
|
-
historyTurnCount: usableGatewayMessages(historyPrefix).length,
|
|
1289
|
-
request: {
|
|
1290
|
-
content: request.content,
|
|
1291
|
-
discussionMode: request.discussionMode,
|
|
1292
|
-
imageCount: request.attachments.filter((attachment) => attachment.kind === "image").length,
|
|
1293
|
-
},
|
|
1294
|
-
profile: currentContextProfileForModel(deps, modelId) ?? DEFAULT_CONTEXT_PROFILE,
|
|
1295
|
-
memoryEntries: memory.context.memories,
|
|
1296
|
-
compactionContextText: buildChatCompactionContextText(deps.evidenceStore, request.chatId),
|
|
1297
|
-
documentContext: request.documentContext,
|
|
1298
|
-
redactionSecrets: currentRedactionSecrets(deps),
|
|
1299
|
-
});
|
|
1300
|
-
return finalizeGatewayAssembly(selected, request, correlationId);
|
|
1332
|
+
const user = [...historyBeforeAssistant].reverse().find((message) => message.role === "user");
|
|
1333
|
+
if (user === undefined)
|
|
1334
|
+
throw new UiStoreError("INTERNAL", "Regeneration user turn is missing.", 500);
|
|
1335
|
+
const snapshot = captureGatewayTurnSnapshot(deps, { ...request, content: user.content, modelId }, user, correlationId);
|
|
1336
|
+
const currentIndex = snapshot.history.findIndex((message) => message.id === user.id);
|
|
1337
|
+
return buildGatewayAssembly(deps, request, memory, modelId, {
|
|
1338
|
+
...snapshot,
|
|
1339
|
+
history: snapshot.history.slice(0, currentIndex + 1),
|
|
1340
|
+
}, correlationId);
|
|
1301
1341
|
}
|
|
1302
1342
|
function latestRegenerableTurn(messages, assistantMessageId) {
|
|
1303
1343
|
const targetIndex = messages.findIndex((message) => message.id === assistantMessageId);
|
|
@@ -1364,6 +1404,29 @@ function bufferedModelAtProviderBoundary(deps, modelId, executionAdmission, corr
|
|
|
1364
1404
|
body: errorBody("NO_MODEL", "No model provider is configured."),
|
|
1365
1405
|
});
|
|
1366
1406
|
}
|
|
1407
|
+
export async function prepareDesktopChatPrompt(deps, request, modelId, admission, signal, correlationId, operation = "chat.send.rejected") {
|
|
1408
|
+
const content = await compactCurrentChatPrompt({
|
|
1409
|
+
content: request.content,
|
|
1410
|
+
modelId,
|
|
1411
|
+
profile: currentContextProfileForModel(deps, modelId) ?? DEFAULT_CONTEXT_PROFILE,
|
|
1412
|
+
signal,
|
|
1413
|
+
correlationId,
|
|
1414
|
+
redact: (value) => String(deps.redactor(value)),
|
|
1415
|
+
call: (summaryRequest, summarySignal) => {
|
|
1416
|
+
const model = bufferedModelAtProviderBoundary(deps, modelId, admission, correlationId, operation);
|
|
1417
|
+
if (isRouteResult(model))
|
|
1418
|
+
throw new ChatPromptPreparationRejection(model);
|
|
1419
|
+
return model.call(summaryRequest, summarySignal);
|
|
1420
|
+
},
|
|
1421
|
+
});
|
|
1422
|
+
signal.throwIfAborted();
|
|
1423
|
+
const invalid = validateDesktopChatProviderBoundary(modelId, admission, deps);
|
|
1424
|
+
if (invalid !== undefined) {
|
|
1425
|
+
logChatRejection(operation, correlationId, modelId, deps, invalid.status, desktopChatProviderBoundaryRejectionReason(modelId, admission, deps));
|
|
1426
|
+
throw new ChatPromptPreparationRejection(invalid);
|
|
1427
|
+
}
|
|
1428
|
+
return content === request.content ? request : { ...request, content };
|
|
1429
|
+
}
|
|
1367
1430
|
function bufferedTurnCancellationResult(deps, prepared, signal, preProviderAdmitted) {
|
|
1368
1431
|
if (!requestSignalAborted(signal))
|
|
1369
1432
|
return undefined;
|
|
@@ -1462,24 +1525,45 @@ function buildBufferedGatewayAssembly(deps, request, memory, modelId, gatewayTur
|
|
|
1462
1525
|
logChatTurnStarted(correlationId, baseAssembly.messages, request.attachments);
|
|
1463
1526
|
return assemblyWithConversationImages(deps, request, modelId, baseAssembly);
|
|
1464
1527
|
}
|
|
1465
|
-
async function
|
|
1528
|
+
async function prepareBufferedGatewayAssembly(deps, prepared, memory, admission, gatewayTurn, signal, correlationId) {
|
|
1466
1529
|
const { request, modelId } = prepared;
|
|
1530
|
+
const { admitted, executionAdmission } = admission;
|
|
1531
|
+
try {
|
|
1532
|
+
const executionRequest = await prepareDesktopChatPrompt(deps, request, modelId, executionAdmission, signal, correlationId);
|
|
1533
|
+
return buildBufferedGatewayAssembly(deps, executionRequest, memory, modelId, gatewayTurn, correlationId);
|
|
1534
|
+
}
|
|
1535
|
+
catch (error) {
|
|
1536
|
+
settleFailedChatPromptPreparation(deps, prepared, admitted, error, signal);
|
|
1537
|
+
throw error;
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
function callPreparedAssembly(model, modelId, assembly, signal, correlationId) {
|
|
1541
|
+
return model.call({
|
|
1542
|
+
modelId,
|
|
1543
|
+
messages: assembly.messages,
|
|
1544
|
+
...gatewayAssemblyOutputAllocation(assembly),
|
|
1545
|
+
stream: false,
|
|
1546
|
+
logContext: { correlationId },
|
|
1547
|
+
}, signal);
|
|
1548
|
+
}
|
|
1549
|
+
async function executeBufferedModelTurn(deps, prepared, abortSignal, messageCountBeforeTurn, startedAt, correlationId) {
|
|
1550
|
+
const { modelId } = prepared;
|
|
1467
1551
|
const outcome = admitBufferedModelTurn(deps, prepared, correlationId);
|
|
1468
1552
|
if (isRouteResult(outcome))
|
|
1469
1553
|
return outcome;
|
|
1470
1554
|
const { admitted, executionAdmission } = outcome;
|
|
1471
1555
|
const { userMessage } = admitted;
|
|
1472
|
-
const
|
|
1556
|
+
const snapshot = captureAdmittedSnapshot(deps, prepared, admitted, abortSignal, correlationId);
|
|
1473
1557
|
const memory = await resolveBufferedMemory(deps, prepared, admitted, abortSignal, correlationId);
|
|
1474
1558
|
if (isRouteResult(memory))
|
|
1475
1559
|
return memory;
|
|
1476
|
-
const assembly =
|
|
1560
|
+
const assembly = await prepareBufferedGatewayAssembly(deps, prepared, memory, outcome, snapshot, abortSignal, correlationId);
|
|
1477
1561
|
const model = bufferedModelAtProviderBoundary(deps, modelId, executionAdmission, correlationId);
|
|
1478
1562
|
if (isRouteResult(model)) {
|
|
1479
1563
|
settleRejectedDesktopChatTurn(deps, prepared, admitted);
|
|
1480
1564
|
return model;
|
|
1481
1565
|
}
|
|
1482
|
-
const response = await model
|
|
1566
|
+
const response = await callPreparedAssembly(model, modelId, assembly, abortSignal, correlationId);
|
|
1483
1567
|
const cancelledAfterCall = bufferedTurnCancellationResult(deps, prepared, abortSignal);
|
|
1484
1568
|
if (cancelledAfterCall !== undefined)
|
|
1485
1569
|
return cancelledAfterCall;
|
|
@@ -1487,7 +1571,7 @@ async function executeBufferedModelTurn(deps, prepared, abortSignal, messageCoun
|
|
|
1487
1571
|
assembly,
|
|
1488
1572
|
messageCount: messageCountBeforeTurn,
|
|
1489
1573
|
startedAt,
|
|
1490
|
-
historyPrefix: gatewayHistoryPrefix(
|
|
1574
|
+
historyPrefix: gatewayHistoryPrefix(snapshot),
|
|
1491
1575
|
correlationId,
|
|
1492
1576
|
});
|
|
1493
1577
|
}
|
|
@@ -1592,7 +1676,7 @@ function updateChatDescriptionScope(deps, chatId, expected, held) {
|
|
|
1592
1676
|
return deps.store.updateChat(chatId, { gitChangeScopes: next });
|
|
1593
1677
|
}
|
|
1594
1678
|
async function generateAdmittedGitChangeTurn(deps, prepared, scope, admission, signal, correlationId) {
|
|
1595
|
-
const gatewayTurn = captureGatewayTurnSnapshot(deps, prepared.request, admission.userMessage);
|
|
1679
|
+
const gatewayTurn = captureGatewayTurnSnapshot(deps, { ...prepared.request, modelId: prepared.modelId }, admission.userMessage, correlationId, false);
|
|
1596
1680
|
return generateGitChangeChatDescription({
|
|
1597
1681
|
deps,
|
|
1598
1682
|
projectPath: prepared.chat.projectPath,
|
|
@@ -1678,16 +1762,11 @@ export async function handleCreateDesktopChat(ctx, deps) {
|
|
|
1678
1762
|
const body = await readJsonObject(ctx.req);
|
|
1679
1763
|
if (isRouteResult(body))
|
|
1680
1764
|
return body;
|
|
1681
|
-
//
|
|
1682
|
-
// walking past an unsuitable default (e.g. an OCR model first in the list) so a
|
|
1683
|
-
// configured-but-never-probed gateway does not reject the very first chat. The walk runs
|
|
1684
|
-
// only for a DEFAULTED request: for an explicit modelId the admission validates that model
|
|
1685
|
-
// alone, so probing its siblings could never change the outcome — it would only add their
|
|
1686
|
-
// probe latency to an already-decided answer.
|
|
1765
|
+
// Reuse configuration initialization; opening a chat never sends a readiness request.
|
|
1687
1766
|
const explicitModelId = explicitChatModelId(body);
|
|
1688
1767
|
await (explicitModelId === undefined
|
|
1689
|
-
?
|
|
1690
|
-
:
|
|
1768
|
+
? awaitAnyInitializedConversationReadyChatModel(deps, defaultChatModelId(deps), ctx.correlationId)
|
|
1769
|
+
: awaitInitializedConversationReadiness(deps, explicitModelId, ctx.correlationId));
|
|
1691
1770
|
const modelId = modelFromBody(body, deps);
|
|
1692
1771
|
if (isRouteResult(modelId)) {
|
|
1693
1772
|
logChatCreationRejection(ctx, deps, explicitModelId ?? defaultChatModelId(deps), modelId.status);
|
|
@@ -2156,7 +2235,7 @@ export async function handleSendDesktopChat(ctx, deps) {
|
|
|
2156
2235
|
if (isRouteResult(prepared))
|
|
2157
2236
|
return prepared;
|
|
2158
2237
|
if (activeGitChangeScope(prepared.chat) === undefined) {
|
|
2159
|
-
await
|
|
2238
|
+
await awaitInitializedConversationReadiness(deps, prepared.modelId, ctx.correlationId);
|
|
2160
2239
|
}
|
|
2161
2240
|
const gitChangeDenial = admitGitChangeScopedTurn(deps, prepared.chat, acceptedGitChangeChatMode(deps, prepared.request), ctx.correlationId);
|
|
2162
2241
|
if (gitChangeDenial !== undefined)
|
|
@@ -2208,30 +2287,28 @@ function canonicalTurnAsSendRequest(request, content) {
|
|
|
2208
2287
|
...(request.clientTurnId === undefined ? {} : { clientTurnId: request.clientTurnId }),
|
|
2209
2288
|
};
|
|
2210
2289
|
}
|
|
2211
|
-
|
|
2290
|
+
function collectCanonicalTurnLocalMemoryActions(deps, request, context) {
|
|
2212
2291
|
if (context === undefined || request.memory?.enabled !== true) {
|
|
2213
|
-
return [];
|
|
2292
|
+
return Promise.resolve([]);
|
|
2214
2293
|
}
|
|
2215
|
-
|
|
2216
|
-
|
|
2294
|
+
const vault = deps.memoryVault;
|
|
2295
|
+
if (vault === undefined) {
|
|
2296
|
+
return Promise.resolve([]);
|
|
2217
2297
|
}
|
|
2218
|
-
const actions = [];
|
|
2219
2298
|
const mode = resolveMemoryCaptureAutonomyMode(deps, request.memory.mode);
|
|
2220
|
-
|
|
2299
|
+
const surface = request.memory.surface ?? "desktop";
|
|
2300
|
+
return request.messages.reduce(async (previous, message, messageOrdinal) => {
|
|
2301
|
+
const actions = await previous;
|
|
2221
2302
|
if (message.role !== "user")
|
|
2222
|
-
|
|
2303
|
+
return actions;
|
|
2223
2304
|
const outcomes = extractCandidatesFromUserText(message.content, buildCaptureContext(context, request.clientTurnId, messageOrdinal), {
|
|
2224
2305
|
...memoryCapturePolicyForDeps(deps, {
|
|
2225
|
-
resolver: createMemoryTargetResolver(
|
|
2306
|
+
resolver: createMemoryTargetResolver(vault),
|
|
2226
2307
|
}),
|
|
2227
2308
|
});
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
actions.push(action);
|
|
2232
|
-
}
|
|
2233
|
-
}
|
|
2234
|
-
return actions;
|
|
2309
|
+
actions.push(...(await captureActionsFromOutcomes(outcomes, deps, mode, surface, request.clientTurnId !== undefined)));
|
|
2310
|
+
return actions;
|
|
2311
|
+
}, Promise.resolve([]));
|
|
2235
2312
|
}
|
|
2236
2313
|
function pushCanonicalTurnSaliencePair(pairs, userParts, assistantParts) {
|
|
2237
2314
|
const userText = userParts.join("\n").trim();
|
|
@@ -2409,13 +2486,14 @@ function invalidRegenerationModelResult(modelId, deps, correlationId) {
|
|
|
2409
2486
|
function captureGatewayGeneration(deps) {
|
|
2410
2487
|
return { gatewayConfigGeneration: deps.gatewayConfig?.generation() };
|
|
2411
2488
|
}
|
|
2412
|
-
async function buildRegenerateContext(deps, prepared, correlationId) {
|
|
2489
|
+
async function buildRegenerateContext(deps, prepared, correlationId, signal) {
|
|
2413
2490
|
const { modelId, turn, memoryRequest, memoryContext } = prepared;
|
|
2414
2491
|
const memory = memoryContext === undefined
|
|
2415
2492
|
? emptyMemoryResult(false)
|
|
2416
2493
|
: await buildMemoryResult(memoryRequest, deps, memoryContext);
|
|
2417
|
-
const
|
|
2418
|
-
|
|
2494
|
+
const executionRequest = await prepareDesktopChatPrompt(deps, memoryRequest, modelId, prepared.executionAdmission, signal, correlationId, "chat.regeneration.rejected");
|
|
2495
|
+
const assembly = buildRegenerateGatewayAssembly(deps, executionRequest, memory, modelId, turn.beforeAssistant, correlationId);
|
|
2496
|
+
return { memory, messages: assembly.messages, ...gatewayAssemblyOutputAllocation(assembly) };
|
|
2419
2497
|
}
|
|
2420
2498
|
function validateRegenerateCommit(deps, prepared) {
|
|
2421
2499
|
const current = latestRegenerableTurn(deps.store.listMessages(prepared.chat.id), prepared.turn.assistant.id);
|
|
@@ -2430,34 +2508,44 @@ function validateRegenerateCommit(deps, prepared) {
|
|
|
2430
2508
|
}
|
|
2431
2509
|
return current.assistant;
|
|
2432
2510
|
}
|
|
2511
|
+
function commitRegeneratedChatTurn(deps, prepared, memory, response) {
|
|
2512
|
+
const { chat, modelId, memoryRequest } = prepared;
|
|
2513
|
+
const redactedContent = deps.redactor(response.content);
|
|
2514
|
+
assertUsableAssistantContent(redactedContent, modelId);
|
|
2515
|
+
const currentAssistant = validateRegenerateCommit(deps, prepared);
|
|
2516
|
+
if (isRouteResult(currentAssistant))
|
|
2517
|
+
return currentAssistant;
|
|
2518
|
+
const assistantMessage = deps.store.createAssistantResponseVersion(currentAssistant.id, redactedContent, Date.now());
|
|
2519
|
+
const updatedChat = commitChatAfterTurn(deps, chat, memoryRequest, modelId);
|
|
2520
|
+
return {
|
|
2521
|
+
status: 200,
|
|
2522
|
+
body: {
|
|
2523
|
+
chat: updatedChat,
|
|
2524
|
+
messages: [assistantMessage],
|
|
2525
|
+
usage: response.usage,
|
|
2526
|
+
memory: { ...memory, actions: [] },
|
|
2527
|
+
},
|
|
2528
|
+
};
|
|
2529
|
+
}
|
|
2433
2530
|
async function persistRegeneratedChatTurn(deps, prepared, signal, correlationId) {
|
|
2434
|
-
const {
|
|
2531
|
+
const { modelId, executionAdmission } = prepared;
|
|
2435
2532
|
try {
|
|
2436
|
-
const { memory, messages } = await buildRegenerateContext(deps, prepared, correlationId);
|
|
2533
|
+
const { memory, messages, maxOutputTokens } = await buildRegenerateContext(deps, prepared, correlationId, signal);
|
|
2437
2534
|
if (requestSignalAborted(signal))
|
|
2438
2535
|
return requestCancelledResult();
|
|
2439
2536
|
const model = bufferedModelAtProviderBoundary(deps, modelId, executionAdmission, correlationId, "chat.regeneration.rejected");
|
|
2440
2537
|
if (isRouteResult(model))
|
|
2441
2538
|
return model;
|
|
2442
|
-
const response = await model.call({
|
|
2539
|
+
const response = await model.call({
|
|
2540
|
+
modelId,
|
|
2541
|
+
messages,
|
|
2542
|
+
...(maxOutputTokens === undefined ? {} : { maxOutputTokens }),
|
|
2543
|
+
stream: false,
|
|
2544
|
+
logContext: { correlationId },
|
|
2545
|
+
}, signal);
|
|
2443
2546
|
if (requestSignalAborted(signal))
|
|
2444
2547
|
return requestCancelledResult();
|
|
2445
|
-
|
|
2446
|
-
assertUsableAssistantContent(redactedContent, modelId);
|
|
2447
|
-
const currentAssistant = validateRegenerateCommit(deps, prepared);
|
|
2448
|
-
if (isRouteResult(currentAssistant))
|
|
2449
|
-
return currentAssistant;
|
|
2450
|
-
const assistantMessage = deps.store.createAssistantResponseVersion(currentAssistant.id, redactedContent, Date.now());
|
|
2451
|
-
const updatedChat = commitChatAfterTurn(deps, chat, memoryRequest, modelId);
|
|
2452
|
-
return {
|
|
2453
|
-
status: 200,
|
|
2454
|
-
body: {
|
|
2455
|
-
chat: updatedChat,
|
|
2456
|
-
messages: [assistantMessage],
|
|
2457
|
-
usage: response.usage,
|
|
2458
|
-
memory: { ...memory, actions: [] },
|
|
2459
|
-
},
|
|
2460
|
-
};
|
|
2548
|
+
return commitRegeneratedChatTurn(deps, prepared, memory, response);
|
|
2461
2549
|
}
|
|
2462
2550
|
catch (error) {
|
|
2463
2551
|
return signal.aborted
|
|
@@ -2473,7 +2561,7 @@ export async function handleRegenerateDesktopChat(ctx, deps) {
|
|
|
2473
2561
|
return requestCancelledResult();
|
|
2474
2562
|
if (isRouteResult(prepared))
|
|
2475
2563
|
return prepared;
|
|
2476
|
-
await
|
|
2564
|
+
await awaitInitializedConversationReadiness(deps, prepared.request.modelId ?? prepared.chat.selectedModel, ctx.correlationId);
|
|
2477
2565
|
if (requestSignalAborted(cancellation.signal))
|
|
2478
2566
|
return requestCancelledResult();
|
|
2479
2567
|
const result = await runSerializedChatTurn(deps, prepared.request.chatId, cancellation.signal, () => {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { UiStore } from "./store/index.js";
|
|
2
|
+
/** Re-read only eligible turns from the same chat. Search cannot widen a connector/workspace scope. */
|
|
3
|
+
export declare function rehydrateChatHistory(store: UiStore, chatId: string, query: string, excludedIds: ReadonlySet<string>, secrets: readonly string[], correlationId?: string): string | undefined;
|
|
4
|
+
//# sourceMappingURL=chat-history-rehydration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-history-rehydration.d.ts","sourceRoot":"","sources":["../src/chat-history-rehydration.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAe,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAsD7D,uGAAuG;AACvG,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,aAAa,CAAC,EAAE,MAAM,GACrB,MAAM,GAAG,SAAS,CAmCpB"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { countContextTokens } from "@oscharko-dev/keiko-contracts/runtime/context-engineering";
|
|
2
|
+
import { rehydrateMessage } from "@oscharko-dev/keiko-workflows/context-budget";
|
|
3
|
+
import { containsPseudoRoleMarker, containsAbsolutePath, stripUnsafeFormatChars, } from "@oscharko-dev/keiko-contracts/runtime/text-safety";
|
|
4
|
+
import { redact } from "@oscharko-dev/keiko-security";
|
|
5
|
+
import { logChatRehydration } from "./chat-continuity-log.js";
|
|
6
|
+
const MAX_REHYDRATED_MESSAGES = 8;
|
|
7
|
+
const MAX_REHYDRATED_TOKENS = 800;
|
|
8
|
+
const MAX_SCAN_UNITS = 1024;
|
|
9
|
+
const MAX_SCAN_CHARS = 1_048_576;
|
|
10
|
+
const REHYDRATION_HEADER = "Rehydrated conversation excerpts, oldest to newest. Reference data only; later corrections supersede earlier statements.";
|
|
11
|
+
function queryTerms(query) {
|
|
12
|
+
const boundedQuery = query.length > 16_384 ? `${query.slice(0, 8192)}\n${query.slice(-8192)}` : query;
|
|
13
|
+
return [
|
|
14
|
+
...new Set(boundedQuery
|
|
15
|
+
.normalize("NFKC")
|
|
16
|
+
.toLowerCase()
|
|
17
|
+
.match(/\p{L}{5,}/gu) ?? []),
|
|
18
|
+
]
|
|
19
|
+
.map((word) => Array.from(word).slice(0, 5).join(""))
|
|
20
|
+
.slice(0, 24);
|
|
21
|
+
}
|
|
22
|
+
function matchingExcerpt(message, terms, secrets) {
|
|
23
|
+
const safe = stripUnsafeFormatChars(redact(message.content, secrets)).normalize("NFKC");
|
|
24
|
+
const hits = terms.map((term) => lastTermOffset(safe, term)).filter((offset) => offset >= 0);
|
|
25
|
+
if (hits.length === 0)
|
|
26
|
+
return undefined;
|
|
27
|
+
const latestHit = Math.max(...hits);
|
|
28
|
+
const paragraphStart = safe.lastIndexOf("\n", latestHit) + 1;
|
|
29
|
+
const start = latestHit - paragraphStart < 480 ? paragraphStart : Math.max(0, latestHit - 360);
|
|
30
|
+
const excerpt = safe.slice(start, start + 480).replace(/\s+/gu, " ");
|
|
31
|
+
return containsPseudoRoleMarker(excerpt) || containsAbsolutePath(excerpt) ? undefined : excerpt;
|
|
32
|
+
}
|
|
33
|
+
function lastTermOffset(source, term) {
|
|
34
|
+
// queryTerms emits only Unicode letters, so these short patterns have no regex operators.
|
|
35
|
+
let last = -1;
|
|
36
|
+
for (const match of source.matchAll(new RegExp(term, "giu")))
|
|
37
|
+
last = match.index;
|
|
38
|
+
return last;
|
|
39
|
+
}
|
|
40
|
+
/** Re-read only eligible turns from the same chat. Search cannot widen a connector/workspace scope. */
|
|
41
|
+
export function rehydrateChatHistory(store, chatId, query, excludedIds, secrets, correlationId) {
|
|
42
|
+
const terms = queryTerms(query);
|
|
43
|
+
const state = {
|
|
44
|
+
candidates: [],
|
|
45
|
+
unitsVisited: 0,
|
|
46
|
+
scannedChars: 0,
|
|
47
|
+
order: 0,
|
|
48
|
+
scanDisposition: terms.length === 0 ? "no-query-terms" : "complete",
|
|
49
|
+
};
|
|
50
|
+
const normalizedQuery = query.length <= MAX_SCAN_CHARS
|
|
51
|
+
? query.normalize("NFKC").replace(/\s+/gu, " ").trim()
|
|
52
|
+
: undefined;
|
|
53
|
+
if (terms.length > 0)
|
|
54
|
+
store.visitGatewayMessageUnits(chatId, "", (unit) => {
|
|
55
|
+
state.unitsVisited += 1;
|
|
56
|
+
for (const message of [...unit].reverse()) {
|
|
57
|
+
if (state.scannedChars >= MAX_SCAN_CHARS)
|
|
58
|
+
break;
|
|
59
|
+
scanMessage(state, message, { terms, excludedIds, secrets, query, normalizedQuery });
|
|
60
|
+
}
|
|
61
|
+
return continueRecallScan(state, terms.length);
|
|
62
|
+
});
|
|
63
|
+
const rendered = renderCandidates(state.candidates);
|
|
64
|
+
logChatRehydration({
|
|
65
|
+
unitsVisited: state.unitsVisited,
|
|
66
|
+
scannedChars: state.scannedChars,
|
|
67
|
+
candidateCount: state.candidates.length,
|
|
68
|
+
excerptCount: rendered.count,
|
|
69
|
+
rehydratedTokens: countContextTokens(rendered.content ?? ""),
|
|
70
|
+
scanDisposition: state.scanDisposition,
|
|
71
|
+
}, correlationId);
|
|
72
|
+
return rendered.content;
|
|
73
|
+
}
|
|
74
|
+
function continueRecallScan(state, termCount) {
|
|
75
|
+
if (state.scannedChars >= MAX_SCAN_CHARS)
|
|
76
|
+
state.scanDisposition = "character-limit";
|
|
77
|
+
else if (state.unitsVisited >= MAX_SCAN_UNITS)
|
|
78
|
+
state.scanDisposition = "unit-limit";
|
|
79
|
+
else if (state.candidates.length === MAX_REHYDRATED_MESSAGES &&
|
|
80
|
+
state.candidates.every((candidate) => candidate.score === termCount))
|
|
81
|
+
state.scanDisposition = "best-matches";
|
|
82
|
+
return state.scanDisposition === "complete";
|
|
83
|
+
}
|
|
84
|
+
function scanMessage(state, message, input) {
|
|
85
|
+
state.order += 1;
|
|
86
|
+
if (input.excludedIds.has(message.id) || message.content === input.query)
|
|
87
|
+
return;
|
|
88
|
+
const remaining = MAX_SCAN_CHARS - state.scannedChars;
|
|
89
|
+
const bounded = message.content.slice(-remaining);
|
|
90
|
+
state.scannedChars += bounded.length;
|
|
91
|
+
// A truncated leading secret must not become an unrecognizable suffix in an excerpt.
|
|
92
|
+
const overlap = message.content.length > bounded.length
|
|
93
|
+
? Math.max(0, ...input.secrets.map((secret) => secret.length))
|
|
94
|
+
: 0;
|
|
95
|
+
const source = { ...message, content: bounded.slice(overlap) };
|
|
96
|
+
if (source.content.normalize("NFKC").replace(/\s+/gu, " ").trim() === input.normalizedQuery)
|
|
97
|
+
return;
|
|
98
|
+
const excerpt = rehydrateMessage(message.id, {
|
|
99
|
+
messages: {
|
|
100
|
+
read: (id) => id === message.id ? matchingExcerpt(source, input.terms, input.secrets) : undefined,
|
|
101
|
+
},
|
|
102
|
+
}, 2_000).content;
|
|
103
|
+
if (excerpt !== undefined)
|
|
104
|
+
selectCandidate(state.candidates, message, excerpt, input.terms, state.order);
|
|
105
|
+
}
|
|
106
|
+
function selectCandidate(candidates, message, excerpt, terms, order) {
|
|
107
|
+
if (candidates.some((candidate) => candidate.excerpt === excerpt))
|
|
108
|
+
return;
|
|
109
|
+
const lower = excerpt.toLowerCase();
|
|
110
|
+
candidates.push({
|
|
111
|
+
line: `${message.role} [${message.id}]: ${excerpt}`,
|
|
112
|
+
excerpt,
|
|
113
|
+
score: terms.filter((term) => lower.includes(term)).length,
|
|
114
|
+
order,
|
|
115
|
+
});
|
|
116
|
+
candidates.sort((left, right) => right.score - left.score || left.order - right.order);
|
|
117
|
+
if (candidates.length > MAX_REHYDRATED_MESSAGES)
|
|
118
|
+
candidates.pop();
|
|
119
|
+
}
|
|
120
|
+
function renderCandidates(candidates) {
|
|
121
|
+
const retained = [];
|
|
122
|
+
let tokens = countContextTokens(REHYDRATION_HEADER);
|
|
123
|
+
for (const candidate of candidates) {
|
|
124
|
+
const cost = countContextTokens(`\n${candidate.line}`);
|
|
125
|
+
if (tokens + cost > MAX_REHYDRATED_TOKENS)
|
|
126
|
+
continue;
|
|
127
|
+
retained.push(candidate);
|
|
128
|
+
tokens += cost;
|
|
129
|
+
}
|
|
130
|
+
if (retained.length === 0)
|
|
131
|
+
return { content: undefined, count: 0 };
|
|
132
|
+
retained.sort((left, right) => right.order - left.order);
|
|
133
|
+
return {
|
|
134
|
+
count: retained.length,
|
|
135
|
+
content: [REHYDRATION_HEADER, ...retained.map((candidate) => candidate.line)].join("\n"),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ContextCompactionRecord, ContextProfile } from "@oscharko-dev/keiko-contracts";
|
|
2
|
+
import type { ChatMessage, UiStore } from "./store/index.js";
|
|
3
|
+
export interface GatewayHistorySnapshot {
|
|
4
|
+
readonly history: readonly ChatMessage[];
|
|
5
|
+
readonly currentUserMessageId: string;
|
|
6
|
+
readonly historyRevision?: number | undefined;
|
|
7
|
+
readonly earlierCompaction?: ContextCompactionRecord | undefined;
|
|
8
|
+
readonly rehydratedContext?: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface HistoryCaptureOptions {
|
|
11
|
+
readonly correlationId?: string | undefined;
|
|
12
|
+
readonly checkpointDisposition?: "none" | "revision-mismatch" | "available" | undefined;
|
|
13
|
+
}
|
|
14
|
+
export declare function captureChatHistory(store: UiStore, chatId: string, currentUserMessageId: string, profile: ContextProfile, redactionSecrets: readonly string[], suppliedCheckpoint?: ContextCompactionRecord, options?: HistoryCaptureOptions): GatewayHistorySnapshot;
|
|
15
|
+
export declare function stampHistoryRevision(record: ContextCompactionRecord | undefined, historyRevision: number, contextWindowTokens?: number): ContextCompactionRecord | undefined;
|
|
16
|
+
//# sourceMappingURL=chat-history-snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-history-snapshot.d.ts","sourceRoot":"","sources":["../src/chat-history-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAU7F,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAQ7D,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IACzC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,iBAAiB,CAAC,EAAE,uBAAuB,GAAG,SAAS,CAAC;IACjE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjD;AAeD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,GAAG,mBAAmB,GAAG,WAAW,GAAG,SAAS,CAAC;CACzF;AAKD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,MAAM,EACd,oBAAoB,EAAE,MAAM,EAC5B,OAAO,EAAE,cAAc,EACvB,gBAAgB,EAAE,SAAS,MAAM,EAAE,EACnC,kBAAkB,CAAC,EAAE,uBAAuB,EAC5C,OAAO,GAAE,qBAA0B,GAClC,sBAAsB,CAyCxB;AA2HD,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,uBAAuB,GAAG,SAAS,EAC3C,eAAe,EAAE,MAAM,EACvB,mBAAmB,CAAC,EAAE,MAAM,GAC3B,uBAAuB,GAAG,SAAS,CAWrC"}
|