@iowarp/clio-coder 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +4 -4
- package/CHANGELOG.md +35 -0
- package/CONTRIBUTING.md +9 -0
- package/README.md +12 -9
- package/ROADMAP.md +30 -5
- package/dist/{acp-KS7ARGV6.js → acp-F6PGOFZ4.js} +2 -2
- package/dist/{agents-YOGJ2YEJ.js → agents-ZHP4R6EX.js} +22 -21
- package/dist/assets/codewiki.json +1 -1
- package/dist/{auth-CEDCO6O6.js → auth-N75U2H3Z.js} +4 -4
- package/dist/{chunk-D3KWFOUT.js → chunk-23UIXH6Z.js} +3 -3
- package/dist/{chunk-ZR5YA6ZF.js → chunk-36XVK5P5.js} +5 -5
- package/dist/{chunk-AVSR2HKI.js → chunk-3DZ4LPLS.js} +6 -6
- package/dist/{chunk-LYJJ6546.js → chunk-3GSPCWFX.js} +12 -12
- package/dist/{chunk-CRHPCPZP.js → chunk-4KC4CHKJ.js} +2 -2
- package/dist/{chunk-4VDHLCF5.js → chunk-4WJBWKMI.js} +2 -2
- package/dist/{chunk-KBUTSJSR.js → chunk-4XBYHXGK.js} +2 -2
- package/dist/{chunk-6W75D37F.js → chunk-53P775GE.js} +6 -3
- package/dist/{chunk-XZWSP67B.js → chunk-5APYAXCB.js} +2 -2
- package/dist/{chunk-D65E25JG.js → chunk-67HPYNTJ.js} +2 -2
- package/dist/{chunk-5JQR5B4D.js → chunk-6KV4KCQZ.js} +4 -4
- package/dist/{chunk-V4XJWDHR.js → chunk-6UKFRTXI.js} +2 -1
- package/dist/{chunk-NDPF2N2L.js → chunk-7DW7CJW2.js} +2 -2
- package/dist/{chunk-5KQEUIWM.js → chunk-7LUEQODV.js} +4 -4
- package/dist/{chunk-LNOXCGN2.js → chunk-7UFDIOBT.js} +3 -3
- package/dist/{chunk-DXSETN72.js → chunk-7WUGNN43.js} +2 -2
- package/dist/{chunk-V35KZDUZ.js → chunk-AA3GRZWS.js} +2 -2
- package/dist/{chunk-X4CEFOSG.js → chunk-ADO3OQIC.js} +4 -4
- package/dist/{chunk-UX2L5CUD.js → chunk-AI36V3ON.js} +3 -3
- package/dist/{chunk-B7GY6QER.js → chunk-B26OUMJW.js} +2 -2
- package/dist/{chunk-LAR7DX5E.js → chunk-B5TASTCK.js} +153 -62
- package/dist/{chunk-TGWZXJ7L.js → chunk-BEMQK5Q7.js} +92 -84
- package/dist/{chunk-RNDCROSG.js → chunk-CNXU7TR2.js} +3 -3
- package/dist/{chunk-3JLTRPN7.js → chunk-CVMUXT64.js} +35 -66
- package/dist/{chunk-733ZBT5P.js → chunk-E74MJF6G.js} +4 -4
- package/dist/{chunk-T2MDZES3.js → chunk-EBMTBE76.js} +3 -3
- package/dist/{chunk-OZ76TLGU.js → chunk-EEITU7S6.js} +2 -2
- package/dist/{chunk-GRHOXDKB.js → chunk-ELDJWJKM.js} +97 -14
- package/dist/{chunk-GCQFN7YI.js → chunk-EMYEQLWO.js} +2 -2
- package/dist/{chunk-LTWH2ACR.js → chunk-EQPFEDFV.js} +222 -127
- package/dist/{chunk-TDGYTWM6.js → chunk-F4I3H56H.js} +2 -2
- package/dist/chunk-F6KCJO3U.js +523 -0
- package/dist/{chunk-FGSQHUCK.js → chunk-F6VKWTTY.js} +5 -5
- package/dist/{chunk-UJD5MPP6.js → chunk-FLNXQQ5B.js} +2 -2
- package/dist/{chunk-EX57VVWW.js → chunk-FOSRJ2VZ.js} +4 -4
- package/dist/{chunk-ZARZ4POR.js → chunk-G5ZDQQE3.js} +3 -3
- package/dist/{chunk-HQVN7G4F.js → chunk-G62JBPXN.js} +7 -7
- package/dist/{chunk-ZJPORZTC.js → chunk-GIAI7A2K.js} +2 -2
- package/dist/chunk-GPTR6OTU.js +2551 -0
- package/dist/{chunk-EZD2BXGP.js → chunk-GUFQPTQK.js} +2 -2
- package/dist/{chunk-OPD7GL6F.js → chunk-H6FQVNZC.js} +8 -7
- package/dist/chunk-H7REJ7L5.js +80 -0
- package/dist/{chunk-EYTLV3W3.js → chunk-HTWTORF7.js} +2 -2
- package/dist/{chunk-DF6PI6GN.js → chunk-I6UKQPGS.js} +3 -3
- package/dist/{chunk-ISHUS7HC.js → chunk-JRW236JT.js} +3 -3
- package/dist/{chunk-DE2LU267.js → chunk-KKAJGT3B.js} +3 -2
- package/dist/{chunk-OV62D6KO.js → chunk-KQMYL5GR.js} +3 -3
- package/dist/{chunk-QDUUOZ3S.js → chunk-KWMFC7FN.js} +3 -3
- package/dist/{chunk-R7FGRZNF.js → chunk-LXYHCCIZ.js} +9 -9
- package/dist/{chunk-NFSK2VNU.js → chunk-LZMTVVN4.js} +2 -2
- package/dist/{chunk-62UK7AGW.js → chunk-M5PMRZSR.js} +397 -44
- package/dist/chunk-MMZMM6SW.js +131 -0
- package/dist/{chunk-FFYTC2KQ.js → chunk-MNABNEBX.js} +2 -2
- package/dist/{chunk-XMDBTYCH.js → chunk-N3CWOGVF.js} +3 -3
- package/dist/{chunk-VYRQHORQ.js → chunk-NMQSO6Z6.js} +4 -3
- package/dist/{chunk-R2UUNSNQ.js → chunk-O3ZAF7UY.js} +18 -5
- package/dist/{chunk-4SYHGVDE.js → chunk-OQNCLZI4.js} +4 -4
- package/dist/{chunk-EG4ARXPC.js → chunk-OX6QTA4N.js} +3 -3
- package/dist/{chunk-P4GNZPXO.js → chunk-OYUS3UZP.js} +2 -2
- package/dist/{chunk-OQ2EOAHA.js → chunk-PF36KOGI.js} +291 -112
- package/dist/{chunk-55RMDDFM.js → chunk-PGQG7ZMW.js} +2 -2
- package/dist/{chunk-CBAQPTDU.js → chunk-PIU6BXXW.js} +2 -2
- package/dist/{chunk-EKV4UBCM.js → chunk-PZBQUJ2F.js} +2 -2
- package/dist/{chunk-7RET77VB.js → chunk-Q2HKY32Y.js} +2 -2
- package/dist/{chunk-U6YTUVOX.js → chunk-Q4RMNWMZ.js} +4 -4
- package/dist/chunk-Q6FRR3AQ.js +48 -0
- package/dist/{chunk-6RJMYYIE.js → chunk-QJSIAJBY.js} +3 -3
- package/dist/{chunk-DOUISWEE.js → chunk-QOJ4ERMU.js} +5 -5
- package/dist/{chunk-IFPDAD7R.js → chunk-RWSRKXLT.js} +3 -3
- package/dist/{chunk-T33IYTZM.js → chunk-SAASVMIY.js} +3 -3
- package/dist/{chunk-2DTIWSAW.js → chunk-SEQDH6JC.js} +3 -3
- package/dist/{chunk-BRCOSE7O.js → chunk-SZUO5BSE.js} +2 -2
- package/dist/{chunk-HOEDA42N.js → chunk-T7HZ7KJF.js} +2 -2
- package/dist/{chunk-OJXOA6YU.js → chunk-TL6LNERH.js} +2 -2
- package/dist/{chunk-UCINIRHW.js → chunk-TPCZXWLT.js} +3 -3
- package/dist/{chunk-ZUKUCZYZ.js → chunk-TQ2KTH4A.js} +2 -2
- package/dist/{chunk-4WOOTKFD.js → chunk-U3FETNQB.js} +341 -20
- package/dist/{chunk-5B3RTYAK.js → chunk-UGDSB4AN.js} +2 -2
- package/dist/{chunk-VKHLUZNO.js → chunk-UZ7YBL43.js} +3 -3
- package/dist/{chunk-QNUQ7K7D.js → chunk-VKMSEO7Y.js} +4 -4
- package/dist/{chunk-IN7DGBVS.js → chunk-VLX5VZ35.js} +5 -5
- package/dist/{chunk-SJGS3GDI.js → chunk-WAGBMMNX.js} +5 -5
- package/dist/{chunk-BFOSV5EZ.js → chunk-WX2YCH7F.js} +2 -2
- package/dist/{chunk-3LT34CAM.js → chunk-XBIGUILU.js} +32 -17
- package/dist/{chunk-XDHUDE5K.js → chunk-XKYBFRWR.js} +5 -5
- package/dist/{chunk-U5QU5ZOD.js → chunk-XYPWFSU5.js} +3 -3
- package/dist/{chunk-YBUECLAF.js → chunk-YEJQDODA.js} +2 -2
- package/dist/{chunk-YQ6XEFVK.js → chunk-Z74OGONW.js} +39 -7
- package/dist/{chunk-I4ELN5BX.js → chunk-ZTNOEJRI.js} +2 -2
- package/dist/cli/index.js +26 -26
- package/dist/{clio-K2PBVCEM.js → clio-4IKFE25F.js} +2 -2
- package/dist/{clio-context-tools-GR4OHFSO.js → clio-context-tools-OHJXYX4R.js} +25 -23
- package/dist/{code-nav-4X3OI6DK.js → code-nav-XPM3MY5I.js} +7 -7
- package/dist/{config-Q5J7UBAB.js → config-343YS25T.js} +43 -41
- package/dist/{config-graph-P3555574.js → config-graph-WI263KDX.js} +43 -41
- package/dist/{configure-KIJ32ZO6.js → configure-GZDG4HER.js} +21 -21
- package/dist/{context-LFBQOSXT.js → context-4OFO7N7Y.js} +12 -12
- package/dist/{context-WBH3KSVR.js → context-JLK2RLOG.js} +42 -40
- package/dist/{context-NNLBES2Y.js → context-O6DIWCF6.js} +23 -21
- package/dist/{context-clear-YOHMQ6SQ.js → context-clear-MR7KOGQI.js} +42 -40
- package/dist/{context-working-set-MRAEVDNV.js → context-working-set-YZAD3KWO.js} +14 -13
- package/dist/{data-tool-JJPBGMQJ.js → data-tool-EKD7DFHG.js} +7 -7
- package/dist/{detail-RHJOTGN4.js → detail-YZPHFEVJ.js} +43 -41
- package/dist/{dispatch-runner-NC7PYNIO.js → dispatch-runner-VKVXVTWJ.js} +44 -42
- package/dist/{doctor-S5KZ2GTN.js → doctor-53AVQXAO.js} +17 -16
- package/dist/{doctor-deep-2EJQSHIZ.js → doctor-deep-BLRB2NCG.js} +5 -5
- package/dist/{eval-3D6M36N7.js → eval-P3BQSLQE.js} +21 -20
- package/dist/{evidence-XNVPPLVK.js → evidence-6LLI6SZH.js} +44 -42
- package/dist/{evidence-6IYN52ET.js → evidence-HTN3JLUO.js} +42 -40
- package/dist/{evidence-JVECPI3F.js → evidence-NJRE3R5H.js} +42 -40
- package/dist/{evolve-TLPUDJDM.js → evolve-WWZHJVJP.js} +42 -40
- package/dist/{fleet-WKVBF5SZ.js → fleet-GGZ4BVJE.js} +64 -62
- package/dist/{fleet-6RJWIOEO.js → fleet-QG3IIWWM.js} +44 -42
- package/dist/{fleet-commands-L6WFT7KZ.js → fleet-commands-J2ZIKISQ.js} +7 -7
- package/dist/{fleet-decisions-BTQMWU5A.js → fleet-decisions-Y2Q7375Q.js} +8 -8
- package/dist/{fleet-graph-553DZ67Q.js → fleet-graph-TCBCCCBP.js} +11 -11
- package/dist/{fleet-inspect-236FZPRB.js → fleet-inspect-KOLKBC56.js} +44 -42
- package/dist/{fleet-preflight-NZQHABWO.js → fleet-preflight-44UNCC4Y.js} +27 -25
- package/dist/{fleet-validate-7NLAE26R.js → fleet-validate-K2FXRZVA.js} +13 -13
- package/dist/{fleet-verify-E3RO6A5W.js → fleet-verify-AS444WDW.js} +42 -40
- package/dist/{fleet-view-KMZQY7YJ.js → fleet-view-X4JU4J6O.js} +43 -41
- package/dist/gui/ops-worker.js +9 -9
- package/dist/gui/reads-worker.js +9 -8
- package/dist/{init-DV5B6HQG.js → init-VSOWFHVL.js} +54 -52
- package/dist/{interactive-OXGYZYAS.js → interactive-JRCBENLZ.js} +1733 -577
- package/dist/{interop-J7UOBOSF.js → interop-JR6BCY7R.js} +10 -10
- package/dist/{inventory-OEGIL6PY.js → inventory-3JUGLVJI.js} +43 -41
- package/dist/{library-ROZAMUIL.js → library-7BOH3Y7N.js} +15 -15
- package/dist/{library-B3UPGY4V.js → library-7PFONXUI.js} +9 -9
- package/dist/{library-MXQA5DLT.js → library-TUYZMFIA.js} +7 -7
- package/dist/{library-import-2LTWOVBD.js → library-import-TJVXKLDK.js} +10 -10
- package/dist/{library-inventory-LJ3XHLWO.js → library-inventory-MD3AYTP4.js} +9 -9
- package/dist/{library-validation-DARHHUNW.js → library-validation-ZDLITEA3.js} +7 -7
- package/dist/{mcp-2GSPYQ54.js → mcp-EFCWUPUR.js} +3 -3
- package/dist/{memory-J3STUUIK.js → memory-Q2YVOKK5.js} +42 -40
- package/dist/{models-Y3GMFJ2V.js → models-M7BOCW7F.js} +17 -16
- package/dist/{monitor-LHNH577J.js → monitor-2HD3MC67.js} +47 -45
- package/dist/{orchestrator-DTAPXULA.js → orchestrator-OUW3ZN6Y.js} +1894 -226
- package/dist/{panes-A743ONZ5.js → panes-TTPPSYCL.js} +3 -3
- package/dist/{preload-OJBMAIXF.js → preload-A47C2NUF.js} +42 -40
- package/dist/{providers-CMETPZNS.js → providers-T43W7EL4.js} +4 -4
- package/dist/{resources-FY6XYFN2.js → resources-TP6X2V6W.js} +20 -11
- package/dist/{run-H64MEVTA.js → run-LDSBPMCS.js} +61 -59
- package/dist/{share-CAFMMQLM.js → share-URHKKMHR.js} +9 -9
- package/dist/{skills-ERKQUC7L.js → skills-E477MOOO.js} +13 -11
- package/dist/{skills-eval-CQ23MYQK.js → skills-eval-AIBR2L7H.js} +583 -93
- package/dist/{skills-inventory-TVUYJDVN.js → skills-inventory-HLMKY3R5.js} +13 -11
- package/dist/{slash-commands-ROG3KIFJ.js → slash-commands-LIIZKA5Y.js} +28 -26
- package/dist/{startup-background-KDWCQMWT.js → startup-background-JR2KDK6R.js} +43 -41
- package/dist/{steer-KKYXJSH4.js → steer-D7RTAPCM.js} +3 -3
- package/dist/{system-ZDW44ZGX.js → system-X2P5N4IY.js} +14 -13
- package/dist/{targets-AJWA6E7Z.js → targets-VFFAKUFM.js} +25 -24
- package/dist/{tasks-6L2JJRC5.js → tasks-ERAWZA22.js} +6 -6
- package/dist/{terminal-lease-YFUSDPAD.js → terminal-lease-V2N2BIKQ.js} +2 -2
- package/dist/{trace-LA5MVR4Y.js → trace-MA5BT7XY.js} +3 -3
- package/dist/{usage-XSILDHKF.js → usage-WYFY2L6M.js} +50 -48
- package/dist/{verifiers-ECA5GIHL.js → verifiers-TYIW2XKF.js} +7 -7
- package/dist/{verify-R6QQCCEB.js → verify-242UFYTP.js} +6 -6
- package/dist/{web-fetch-PVZNMBOB.js → web-fetch-LRAGYU6Y.js} +3 -3
- package/dist/{wiki-generate-RP22WP5K.js → wiki-generate-OFKOX2T6.js} +53 -51
- package/dist/worker/entry.js +31 -29
- package/docs/architecture/architecture.md +1 -0
- package/docs/architecture/context-engine.md +4 -2
- package/docs/architecture/observability.md +6 -4
- package/docs/architecture/prompt-envelope-and-tools.md +1 -1
- package/docs/architecture/session-lifecycle.md +1 -1
- package/docs/architecture/tui-design.md +12 -9
- package/docs/gui/parity/02-slash-and-surfaces.md +1 -1
- package/docs/guide/commands-and-modes.md +91 -5
- package/docs/guide/configuration-and-targets.md +2 -2
- package/docs/guide/context-continuity.md +49 -0
- package/docs/guide/proactive-memory.md +6 -3
- package/library/registry.yaml +292 -32
- package/library/skills/README.md +27 -2
- package/library/skills/context/context-handoff/SKILL.md +10 -4
- package/library/skills/meta/clio-coder-dev/SKILL.md +92 -88
- package/library/skills/meta/clio-coder-dev/evals.md +51 -46
- package/library/skills/meta/clio-coder-dev/plugin.json +2 -2
- package/library/skills/meta/clio-coder-dev/references/change-map.md +49 -0
- package/library/skills/meta/clio-coder-test/SKILL.md +89 -142
- package/library/skills/meta/clio-coder-test/evals.md +58 -62
- package/library/skills/meta/clio-coder-test/plugin.json +2 -2
- package/library/skills/meta/clio-coder-test/references/harness.md +3 -3
- package/library/skills/meta/clio-coder-test/references/lifecycle-validation.md +30 -0
- package/library/skills/meta/clio-coder-test/references/test-map.md +60 -89
- package/library/skills/registry.yaml +5 -5
- package/library/skills/skill-marketplace.json +12 -14
- package/package.json +1 -1
- package/src/cli/skills-eval.ts +1064 -54
- package/src/cli/usage.ts +2 -2
- package/src/core/clio-repo.ts +3 -0
- package/src/core/tool-names.ts +1 -0
- package/src/domains/context/budget/inspection.ts +9 -0
- package/src/domains/context/budget/live-view.ts +418 -0
- package/src/domains/context/budget/pressure.ts +393 -0
- package/src/domains/context/budget/request-fit.ts +15 -0
- package/src/domains/evidence/build.ts +24 -0
- package/src/domains/gateway/mcp/client.ts +1 -1
- package/src/domains/memory/commit-state.ts +160 -0
- package/src/domains/memory/operations.ts +18 -10
- package/src/domains/memory/prompt-cache.ts +95 -0
- package/src/domains/memory/prompt-section.ts +50 -7
- package/src/domains/memory/relevance.ts +93 -0
- package/src/domains/memory/restoration.ts +78 -0
- package/src/domains/memory/store.ts +39 -1
- package/src/domains/middleware/memory-intervention.ts +116 -24
- package/src/domains/observability/background-memory-usage.ts +1 -1
- package/src/domains/observability/cost.ts +3 -3
- package/src/domains/observability/extension.ts +1 -1
- package/src/domains/observability/metrics.ts +1 -1
- package/src/domains/prompts/compiler.ts +1 -1
- package/src/domains/prompts/extension.ts +38 -1
- package/src/domains/quota/anthropic-max-provider.ts +134 -0
- package/src/domains/quota/anthropic-usage.ts +220 -0
- package/src/domains/quota/antigravity-provider.ts +339 -0
- package/src/domains/quota/cache.ts +87 -0
- package/src/domains/quota/claude-code-provider.ts +169 -0
- package/src/domains/quota/codex-provider.ts +237 -0
- package/src/domains/quota/presentation.ts +240 -0
- package/src/domains/quota/registry.ts +23 -0
- package/src/domains/quota/service.ts +93 -0
- package/src/domains/quota/summary-feed.ts +86 -0
- package/src/domains/quota/types.ts +84 -0
- package/src/domains/resources/index.ts +11 -0
- package/src/domains/resources/skills/catalog-view.ts +571 -0
- package/src/domains/resources/skills/lexical-match.ts +136 -0
- package/src/domains/resources/skills/loader.ts +38 -0
- package/src/domains/resources/skills/promotion.ts +1 -55
- package/src/domains/resources/skills/provenance-pin.ts +50 -20
- package/src/domains/safety/action-classifier.ts +1 -0
- package/src/domains/session/compaction/branch-summary.ts +4 -1
- package/src/domains/session/compaction/compact.ts +18 -2
- package/src/domains/session/compaction/cut-point.ts +20 -1
- package/src/domains/session/compaction/tokens.ts +48 -3
- package/src/domains/session/context-accounting.ts +8 -1
- package/src/domains/session/continuity/carry.ts +59 -0
- package/src/domains/session/continuity/contract.ts +592 -0
- package/src/domains/session/continuity/evidence.ts +290 -0
- package/src/domains/session/continuity/fold.ts +1075 -0
- package/src/domains/session/continuity/note.ts +79 -0
- package/src/domains/session/continuity/operator-request.ts +104 -0
- package/src/domains/session/continuity/persistence.ts +408 -0
- package/src/domains/session/continuity/ports.ts +231 -0
- package/src/domains/session/continuity/projection.ts +538 -0
- package/src/domains/session/continuity/validate.ts +352 -0
- package/src/domains/session/entries.ts +50 -3
- package/src/domains/session/index.ts +48 -0
- package/src/domains/session/migrations/index.ts +7 -3
- package/src/domains/session/tree/fork.ts +15 -1
- package/src/domains/session/usage.ts +2 -2
- package/src/engine/acp/commands.ts +1 -1
- package/src/engine/agent.ts +133 -9
- package/src/engine/session.ts +13 -6
- package/src/entry/orchestrator.ts +116 -33
- package/src/interactive/chat-loop-messages.ts +2 -2
- package/src/interactive/chat-loop.ts +219 -63
- package/src/interactive/chat-renderer.ts +99 -8
- package/src/interactive/context-overlay.ts +24 -3
- package/src/interactive/continuity-controller.ts +526 -0
- package/src/interactive/dispatch-board.ts +21 -3
- package/src/interactive/footer/dashboard.ts +25 -1
- package/src/interactive/footer/key-hints.ts +2 -2
- package/src/interactive/footer/pages.ts +70 -27
- package/src/interactive/footer/widgets.ts +32 -7
- package/src/interactive/footer-panel.ts +1 -1
- package/src/interactive/interactive-application.ts +7 -2
- package/src/interactive/interactive-input-runtime.ts +2 -2
- package/src/interactive/interactive-presentation.ts +15 -0
- package/src/interactive/interactive-slash-runtime.ts +45 -8
- package/src/interactive/interactive-tickers.ts +7 -1
- package/src/interactive/model-session-replay.ts +130 -3
- package/src/interactive/output-reserve.ts +35 -0
- package/src/interactive/overlay-general-openers.ts +12 -8
- package/src/interactive/overlay-key-routing.ts +6 -9
- package/src/interactive/overlay-lifecycle.ts +10 -6
- package/src/interactive/overlay-session-lifecycle.ts +21 -14
- package/src/interactive/quota-view.ts +229 -0
- package/src/interactive/session-last-turn.ts +1 -1
- package/src/interactive/session-transcript.ts +2 -1
- package/src/interactive/session-usage-reseed.ts +2 -2
- package/src/interactive/side-question.ts +2 -2
- package/src/interactive/slash-commands.ts +28 -9
- package/src/interactive/turn-context.ts +686 -63
- package/src/interactive/turn-middleware.ts +39 -6
- package/src/interactive/turn-persistence.ts +15 -2
- package/src/interactive/turn-prewarm.ts +1 -1
- package/src/interactive/turn-runtime.ts +48 -5
- package/src/interactive/{cost-overlay.ts → usage-overlay.ts} +121 -33
- package/src/interactive/welcome-dashboard.ts +26 -3
- package/src/tools/agent-tools.ts +3 -1
- package/src/tools/bootstrap.ts +6 -0
- package/src/tools/builtin-tool-catalog.ts +9 -0
- package/src/tools/context/index.ts +148 -113
- package/src/tools/context/surface.ts +11 -7
- package/src/tools/core-bootstrap.ts +4 -0
- package/src/tools/observation.ts +8 -2
- package/src/tools/policy.ts +3 -0
- package/src/tools/self-compact.ts +31 -0
- package/src/tools/surface.ts +1 -0
- package/src/tools/tasks.ts +1 -1
- package/dist/chunk-CTFPFW3H.js +0 -44
- package/dist/chunk-EOJPDNUP.js +0 -1325
- package/dist/chunk-I4Y4WKZR.js +0 -386
package/src/cli/usage.ts
CHANGED
|
@@ -114,7 +114,7 @@ function addResponseModelIdObservation(counts: ResponseModelIdObservationCounts,
|
|
|
114
114
|
* session pre-warm, and a proactive-memory step are real spend and belong in
|
|
115
115
|
* the token and cost totals, but none of them is a turn: they never entered
|
|
116
116
|
* the session. `turns` therefore subtracts them from the folded row count,
|
|
117
|
-
* which is exactly what the `/
|
|
117
|
+
* which is exactly what the `/usage` overlay does.
|
|
118
118
|
*/
|
|
119
119
|
interface CallOrigins {
|
|
120
120
|
rows: number;
|
|
@@ -435,7 +435,7 @@ export async function runUsageCommand(argv: ReadonlyArray<string>): Promise<numb
|
|
|
435
435
|
}
|
|
436
436
|
}
|
|
437
437
|
|
|
438
|
-
// Token and cost facts fold the same per-call usage the `/
|
|
438
|
+
// Token and cost facts fold the same per-call usage the `/usage` overlay
|
|
439
439
|
// reseeds from, through the same session-domain function, so the report and
|
|
440
440
|
// the overlay cannot disagree about what a session spent.
|
|
441
441
|
// Keyed by the model id accounting attributes the call to. A reported LM
|
package/src/core/clio-repo.ts
CHANGED
|
@@ -13,6 +13,9 @@ interface PackageJsonShape {
|
|
|
13
13
|
|
|
14
14
|
const CLIO_PACKAGE_NAME = "@iowarp/clio-coder";
|
|
15
15
|
|
|
16
|
+
/** Only these authoring skills become native discovery in Clio's own checkout. */
|
|
17
|
+
export const CLIO_SELF_DEVELOPMENT_SKILLS = ["clio-coder-dev", "clio-coder-test"] as const;
|
|
18
|
+
|
|
16
19
|
const SOURCE_MARKERS = [
|
|
17
20
|
"src/entry/orchestrator.ts",
|
|
18
21
|
"src/worker/entry.ts",
|
package/src/core/tool-names.ts
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LiveBudgetView } from "./live-view.js";
|
|
2
|
+
|
|
3
|
+
/** A native-session accounting port, never inherited by a dispatched worker. */
|
|
4
|
+
export type BudgetInspection =
|
|
5
|
+
| { status: "available"; capability: "native"; view: LiveBudgetView }
|
|
6
|
+
| { status: "unavailable" | "unsupported"; reason: string };
|
|
7
|
+
|
|
8
|
+
/** Refreshes accounting only: no runtime initialization, model calls or I/O. */
|
|
9
|
+
export type BudgetProvider = () => BudgetInspection;
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The live budget view: one immutable projection of what the next provider
|
|
3
|
+
* request will cost, plus the single opaque revision every consumer quotes.
|
|
4
|
+
*
|
|
5
|
+
* `ContextSnapshot` keeps its existing job, a capture written to the diagnostic
|
|
6
|
+
* ledger. It can lag the live agent state by a whole tool batch, so it is not
|
|
7
|
+
* the authority a tool, the footer, or an admission check should budget
|
|
8
|
+
* against. The producer here owns that authority: the interactive adapter
|
|
9
|
+
* refreshes it at the seams that actually change the next request, and every
|
|
10
|
+
* consumer reads the published view instead of repricing the conversation.
|
|
11
|
+
*
|
|
12
|
+
* This module is pure policy plus a publication cache. It performs no I/O,
|
|
13
|
+
* issues no model call, and triggers no reduction. The adapter supplies every
|
|
14
|
+
* fact, including the real output reserve it will ask the provider for and a
|
|
15
|
+
* fingerprint of the exact material it measured, because only the adapter can
|
|
16
|
+
* see the live agent state.
|
|
17
|
+
*
|
|
18
|
+
* Revisions are monotonic rather than a bare content hash. A conversation that
|
|
19
|
+
* returns to an earlier byte-identical state is still a later observation, and
|
|
20
|
+
* an initial capture, a reconciliation, and tool growth must never alias onto
|
|
21
|
+
* one revision. A publish whose material inputs did not move keeps its
|
|
22
|
+
* revision, so repeated reads are stable.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { createHash } from "node:crypto";
|
|
26
|
+
import {
|
|
27
|
+
type AdvisoryDecision,
|
|
28
|
+
type AdvisoryMemory,
|
|
29
|
+
DEFAULT_REDUCE_THRESHOLD,
|
|
30
|
+
DEFAULT_WORKING_SET_TARGET,
|
|
31
|
+
evaluatePressure,
|
|
32
|
+
INITIAL_ADVISORY_MEMORY,
|
|
33
|
+
type PolicyRejection,
|
|
34
|
+
type PressureDecision,
|
|
35
|
+
type PressureFacts,
|
|
36
|
+
type PressurePhase,
|
|
37
|
+
type ReductionAvailability,
|
|
38
|
+
type RequestAdmission,
|
|
39
|
+
type ResolvedPressurePolicy,
|
|
40
|
+
resolvePressurePolicy,
|
|
41
|
+
} from "./pressure.js";
|
|
42
|
+
|
|
43
|
+
/** Structural split of the prompt side, in the terms the estimator produces. */
|
|
44
|
+
export interface LiveBudgetBreakdown {
|
|
45
|
+
systemPromptTokens: number;
|
|
46
|
+
messageTokens: number;
|
|
47
|
+
pendingUserTokens: number;
|
|
48
|
+
toolSchemaTokens: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Where `inputTokens` came from.
|
|
53
|
+
*
|
|
54
|
+
* `anchored-plus-estimated-tail` is deliberately not called exact: it is a
|
|
55
|
+
* provider count for the messages one attested call covered plus a chars/4
|
|
56
|
+
* estimate of everything appended since. `historical` is a persisted
|
|
57
|
+
* measurement read before this process built a runtime; it describes the
|
|
58
|
+
* conversation the previous process measured, not the next request.
|
|
59
|
+
*/
|
|
60
|
+
export type LiveBudgetInputSource = "estimated" | "anchored-plus-estimated-tail" | "historical" | "unknown";
|
|
61
|
+
|
|
62
|
+
/** Whether the structural split was recomputed live or read off a capture. */
|
|
63
|
+
export type LiveBudgetBreakdownSource = "live" | "captured";
|
|
64
|
+
|
|
65
|
+
/** The last reduction this session performed, as the producer was told about it. */
|
|
66
|
+
export interface LiveBudgetReductionProjection {
|
|
67
|
+
stage: string;
|
|
68
|
+
tokensBefore: number;
|
|
69
|
+
tokensAfter: number;
|
|
70
|
+
trigger: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Optional continuity projections. Packet 02 owns the durable records these
|
|
75
|
+
* describe; the producer only carries whatever an injected reader hands it, so
|
|
76
|
+
* this slice implements no persistence and requires no packet 02 record shape.
|
|
77
|
+
*/
|
|
78
|
+
export interface LiveBudgetHandoffProjection {
|
|
79
|
+
id: string;
|
|
80
|
+
preparedAt: string | null;
|
|
81
|
+
/** The live revision the note was prepared against, when one was recorded. */
|
|
82
|
+
sourceRevision: string | null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface LiveBudgetOutcomeProjection {
|
|
86
|
+
outcome: string;
|
|
87
|
+
at: string | null;
|
|
88
|
+
detail: string | null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface LiveBudgetView {
|
|
92
|
+
/** Opaque and monotonic. Compare for equality; never parse. */
|
|
93
|
+
revision: string;
|
|
94
|
+
/** Diagnostic cross-reference to the persisted capture, never the live authority. */
|
|
95
|
+
capturedSnapshotId: string | null;
|
|
96
|
+
sessionId: string | null;
|
|
97
|
+
/**
|
|
98
|
+
* Advisory branch identity. Stable while a branch's leaf advances through
|
|
99
|
+
* ordinary appends; it moves only on real branch navigation, so an advisory
|
|
100
|
+
* announced once is not announced again after every tool batch.
|
|
101
|
+
*/
|
|
102
|
+
branchAnchorTurnId: string | null;
|
|
103
|
+
/** Ledger leaf the next append parents under. Diagnostic; never the advisory anchor. */
|
|
104
|
+
activeLeafTurnId: string | null;
|
|
105
|
+
activeUserTurnId: string | null;
|
|
106
|
+
targetId: string | null;
|
|
107
|
+
runtimeId: string | null;
|
|
108
|
+
modelId: string | null;
|
|
109
|
+
modelApi: string | null;
|
|
110
|
+
effectiveWindow: number | null;
|
|
111
|
+
windowSource: string | null;
|
|
112
|
+
/** Structural chars/4 projection of the next request's prompt side. */
|
|
113
|
+
estimatedInputTokens: number | null;
|
|
114
|
+
/** Provider-attested prefix plus an estimated tail, or null when no anchor holds. */
|
|
115
|
+
anchoredInputTokens: number | null;
|
|
116
|
+
/** The figure to budget against: the higher of the two above. */
|
|
117
|
+
inputTokens: number | null;
|
|
118
|
+
inputSource: LiveBudgetInputSource;
|
|
119
|
+
/** True when the figures describe a persisted capture rather than a live runtime. */
|
|
120
|
+
historical: boolean;
|
|
121
|
+
breakdown: LiveBudgetBreakdown | null;
|
|
122
|
+
breakdownSource: LiveBudgetBreakdownSource | null;
|
|
123
|
+
/** Preflight output reservation for the next request; null when unresolvable. */
|
|
124
|
+
outputReserveTokens: number | null;
|
|
125
|
+
/**
|
|
126
|
+
* Compaction-threshold headroom recorded by the capture. It is not the output
|
|
127
|
+
* reserve and must never be presented as one.
|
|
128
|
+
*/
|
|
129
|
+
thresholdReserveTokens: number | null;
|
|
130
|
+
headroomTokens: number | null;
|
|
131
|
+
pressure: number | null;
|
|
132
|
+
phase: PressurePhase;
|
|
133
|
+
admission: RequestAdmission;
|
|
134
|
+
advisory: AdvisoryDecision;
|
|
135
|
+
/** The policy actually in force for this view. */
|
|
136
|
+
policy: ResolvedPressurePolicy;
|
|
137
|
+
/**
|
|
138
|
+
* Why the configured threshold/target pair was refused, or null when
|
|
139
|
+
* `policy` is the configured one. Non-null means the defaults are running
|
|
140
|
+
* and the operator's configuration is not.
|
|
141
|
+
*/
|
|
142
|
+
policyRejection: PolicyRejection | null;
|
|
143
|
+
reduction: ReductionAvailability;
|
|
144
|
+
lastReduction: LiveBudgetReductionProjection | null;
|
|
145
|
+
pendingHandoff: LiveBudgetHandoffProjection | null;
|
|
146
|
+
lastOutcome: LiveBudgetOutcomeProjection | null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Everything the producer needs for one publication.
|
|
151
|
+
*
|
|
152
|
+
* `reductionBasisKey` is the adapter's exact identity for the request a
|
|
153
|
+
* reduction would be asked about. It is computed after the live estimate and
|
|
154
|
+
* the output reservation are resolved, so it covers the measured content, the
|
|
155
|
+
* route and its resolved output cap, the reconciled accounting, and the
|
|
156
|
+
* settings that decide reduction eligibility. It deliberately excludes the
|
|
157
|
+
* `reduction` verdict itself, which would otherwise change its own key. It is
|
|
158
|
+
* not the advisory identity: an advisory re-arms on a different budget basis,
|
|
159
|
+
* while a refusal survives only for one byte-identical request.
|
|
160
|
+
*/
|
|
161
|
+
export interface LiveBudgetInput {
|
|
162
|
+
sessionId: string | null;
|
|
163
|
+
branchAnchorTurnId: string | null;
|
|
164
|
+
activeLeafTurnId: string | null;
|
|
165
|
+
activeUserTurnId: string | null;
|
|
166
|
+
capturedSnapshotId: string | null;
|
|
167
|
+
targetId: string | null;
|
|
168
|
+
runtimeId: string | null;
|
|
169
|
+
modelId: string | null;
|
|
170
|
+
modelApi: string | null;
|
|
171
|
+
effectiveWindow: number | null;
|
|
172
|
+
windowSource: string | null;
|
|
173
|
+
estimatedInputTokens: number | null;
|
|
174
|
+
anchoredInputTokens: number | null;
|
|
175
|
+
inputTokens: number | null;
|
|
176
|
+
inputSource: LiveBudgetInputSource;
|
|
177
|
+
historical: boolean;
|
|
178
|
+
breakdown: LiveBudgetBreakdown | null;
|
|
179
|
+
breakdownSource: LiveBudgetBreakdownSource | null;
|
|
180
|
+
outputReserveTokens: number | null;
|
|
181
|
+
thresholdReserveTokens: number | null;
|
|
182
|
+
policy: ResolvedPressurePolicy;
|
|
183
|
+
policyRejection: PolicyRejection | null;
|
|
184
|
+
reduction: ReductionAvailability;
|
|
185
|
+
/** Post-accounting request identity; see the interface comment. */
|
|
186
|
+
reductionBasisKey: string;
|
|
187
|
+
/** System-prompt identity for advisory re-arming. */
|
|
188
|
+
promptFingerprint: string | null;
|
|
189
|
+
/** Tool-surface identity for advisory re-arming. */
|
|
190
|
+
toolSignature: string | null;
|
|
191
|
+
/** Incremented by real branch navigation only, never by an ordinary append. */
|
|
192
|
+
navigationEpoch: number;
|
|
193
|
+
lastReduction: LiveBudgetReductionProjection | null;
|
|
194
|
+
pendingHandoff: LiveBudgetHandoffProjection | null;
|
|
195
|
+
lastOutcome: LiveBudgetOutcomeProjection | null;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export interface LiveBudgetProducer {
|
|
199
|
+
/**
|
|
200
|
+
* Recompute and cache the view. The only thing this mutates is that cache.
|
|
201
|
+
* Republishing unchanged facts keeps the revision and the advisory verdict
|
|
202
|
+
* that revision was given, so a refresh can never consume a crossing.
|
|
203
|
+
*/
|
|
204
|
+
publish(input: LiveBudgetInput): LiveBudgetView;
|
|
205
|
+
/** Last published view, or null before the first publication. Pure. */
|
|
206
|
+
current(): LiveBudgetView | null;
|
|
207
|
+
/** Drop the cache and the advisory memory on a session switch. */
|
|
208
|
+
reset(): void;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export interface LiveBudgetPolicyResolution {
|
|
212
|
+
policy: ResolvedPressurePolicy;
|
|
213
|
+
/**
|
|
214
|
+
* Why the configured pair was refused, or null when it is the policy in
|
|
215
|
+
* force. A refusal is reported, never repaired into a fabricated setting the
|
|
216
|
+
* operator never wrote: the defaults take over and say so.
|
|
217
|
+
*/
|
|
218
|
+
rejection: PolicyRejection | null;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Resolve the pressure policy from the two existing, independent settings:
|
|
223
|
+
* `context.compaction.threshold` is the reduce point and
|
|
224
|
+
* `context.workingSet.target` is the working-set target an applied eviction
|
|
225
|
+
* batches down to. The target is not derived from the threshold; a session
|
|
226
|
+
* configured at 0.9 / 0.6 publishes exactly 0.9 and 0.6.
|
|
227
|
+
*
|
|
228
|
+
* Either value left unset falls through to the product default. A pair
|
|
229
|
+
* `resolvePressurePolicy` refuses (out of range, or a target at or above its own
|
|
230
|
+
* reduce point) yields the default policy plus the refusal reason, so the view
|
|
231
|
+
* can state that the configured policy is not the one in force.
|
|
232
|
+
*/
|
|
233
|
+
export function resolveLiveBudgetPolicy(
|
|
234
|
+
reduceThreshold: number | null | undefined,
|
|
235
|
+
workingSetTarget: number | null | undefined,
|
|
236
|
+
): LiveBudgetPolicyResolution {
|
|
237
|
+
const configured = resolvePressurePolicy({
|
|
238
|
+
...(typeof reduceThreshold === "number" ? { reduceThreshold } : {}),
|
|
239
|
+
...(typeof workingSetTarget === "number" ? { workingSetTarget } : {}),
|
|
240
|
+
});
|
|
241
|
+
if (configured.ok) return { policy: configured.policy, rejection: null };
|
|
242
|
+
const fallback = resolvePressurePolicy({
|
|
243
|
+
reduceThreshold: DEFAULT_REDUCE_THRESHOLD,
|
|
244
|
+
workingSetTarget: DEFAULT_WORKING_SET_TARGET,
|
|
245
|
+
});
|
|
246
|
+
/* c8 ignore next */
|
|
247
|
+
if (!fallback.ok) throw new Error(`default pressure policy is unresolvable: ${fallback.reason}`);
|
|
248
|
+
return { policy: fallback.policy, rejection: configured.reason };
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Everything whose change makes this a different published view, the optional
|
|
253
|
+
* projections included: a consumer quoting a revision must not find different
|
|
254
|
+
* continuity values under it later. Deliberately excludes `capturedSnapshotId`
|
|
255
|
+
* (a diagnostic id that moves on every capture) and the advancing ledger leaf,
|
|
256
|
+
* so the revision tracks the request rather than the bookkeeping around it.
|
|
257
|
+
*/
|
|
258
|
+
function materialFingerprint(input: LiveBudgetInput): string {
|
|
259
|
+
return createHash("sha256")
|
|
260
|
+
.update(
|
|
261
|
+
JSON.stringify([
|
|
262
|
+
"live-budget/1",
|
|
263
|
+
input.sessionId,
|
|
264
|
+
input.branchAnchorTurnId,
|
|
265
|
+
input.navigationEpoch,
|
|
266
|
+
input.targetId,
|
|
267
|
+
input.runtimeId,
|
|
268
|
+
input.modelId,
|
|
269
|
+
input.modelApi,
|
|
270
|
+
input.effectiveWindow,
|
|
271
|
+
input.windowSource,
|
|
272
|
+
input.estimatedInputTokens,
|
|
273
|
+
input.anchoredInputTokens,
|
|
274
|
+
input.inputTokens,
|
|
275
|
+
input.inputSource,
|
|
276
|
+
input.historical,
|
|
277
|
+
input.breakdown,
|
|
278
|
+
input.breakdownSource,
|
|
279
|
+
input.outputReserveTokens,
|
|
280
|
+
input.thresholdReserveTokens,
|
|
281
|
+
input.policy.notice,
|
|
282
|
+
input.policy.prepare,
|
|
283
|
+
input.policy.reduce,
|
|
284
|
+
input.policy.target,
|
|
285
|
+
input.policyRejection,
|
|
286
|
+
input.reduction,
|
|
287
|
+
input.reductionBasisKey,
|
|
288
|
+
input.promptFingerprint,
|
|
289
|
+
input.toolSignature,
|
|
290
|
+
input.lastReduction,
|
|
291
|
+
input.pendingHandoff,
|
|
292
|
+
input.lastOutcome,
|
|
293
|
+
]),
|
|
294
|
+
)
|
|
295
|
+
.digest("hex");
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* A reserve the adapter could not resolve is unknown, not zero. `evaluatePressure`
|
|
300
|
+
* reports any non-finite measurement as unknown rather than admitting a request
|
|
301
|
+
* it never priced, which is exactly the verdict a view without a runtime
|
|
302
|
+
* deserves. The policy labels that case `input-unknown`; the view says which
|
|
303
|
+
* measurement was missing by leaving that field null.
|
|
304
|
+
*/
|
|
305
|
+
function pressureFacts(input: LiveBudgetInput): PressureFacts {
|
|
306
|
+
return {
|
|
307
|
+
revision: {
|
|
308
|
+
sessionId: input.sessionId ?? "",
|
|
309
|
+
branchAnchorTurnId: input.branchAnchorTurnId,
|
|
310
|
+
// The policy reuses a no-cut refusal only for this exact identity, so
|
|
311
|
+
// it has to be the post-accounting one: a recalibrated anchor or a
|
|
312
|
+
// different resolved output cap is a request the reducer never saw.
|
|
313
|
+
revisionId: input.reductionBasisKey,
|
|
314
|
+
},
|
|
315
|
+
inputTokens: input.inputTokens,
|
|
316
|
+
inputSource: input.inputSource === "anchored-plus-estimated-tail" ? "trusted" : "estimated",
|
|
317
|
+
effectiveContextWindow: input.effectiveWindow,
|
|
318
|
+
outputReserveTokens: input.outputReserveTokens ?? Number.NaN,
|
|
319
|
+
// The live estimate already prices pending text, tool schemas, and every
|
|
320
|
+
// injected block, so there is nothing left for the caller to add once.
|
|
321
|
+
pendingRequestOverheadTokens: 0,
|
|
322
|
+
reduction: input.reduction,
|
|
323
|
+
contextIdentity: {
|
|
324
|
+
targetId: input.targetId,
|
|
325
|
+
modelId: input.modelId,
|
|
326
|
+
promptFingerprint: input.promptFingerprint,
|
|
327
|
+
toolSignature: input.toolSignature,
|
|
328
|
+
epoch: input.navigationEpoch,
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** Copy and freeze a flat value object so a publication cannot be edited behind a quoted revision. */
|
|
334
|
+
function frozenCopy<T extends object>(value: T | null): T | null {
|
|
335
|
+
return value === null ? null : Object.freeze({ ...value });
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export function createLiveBudgetProducer(): LiveBudgetProducer {
|
|
339
|
+
let view: LiveBudgetView | null = null;
|
|
340
|
+
let fingerprint: string | null = null;
|
|
341
|
+
let sequence = 0;
|
|
342
|
+
let memory: AdvisoryMemory = INITIAL_ADVISORY_MEMORY;
|
|
343
|
+
let decision: PressureDecision | null = null;
|
|
344
|
+
|
|
345
|
+
return {
|
|
346
|
+
publish(input: LiveBudgetInput): LiveBudgetView {
|
|
347
|
+
const next = materialFingerprint(input);
|
|
348
|
+
const transitioned = next !== fingerprint;
|
|
349
|
+
if (transitioned) {
|
|
350
|
+
fingerprint = next;
|
|
351
|
+
sequence += 1;
|
|
352
|
+
}
|
|
353
|
+
const revision = `lb-${sequence}-${next.slice(0, 16)}`;
|
|
354
|
+
// The advisory is evaluated once per material transition and then held.
|
|
355
|
+
// A refresh that changes nothing must not consume a crossing: republishing
|
|
356
|
+
// identical facts would otherwise turn `emit` from true to false under a
|
|
357
|
+
// revision a consumer has not read yet. One-time delivery deduplicates on
|
|
358
|
+
// `revision`; nothing here treats a cache refresh as acknowledgement.
|
|
359
|
+
//
|
|
360
|
+
// An unmeasured decision already reports null pressure and headroom and
|
|
361
|
+
// carries the prior advisory memory through untouched, so nothing here
|
|
362
|
+
// has to special-case a view without a runtime.
|
|
363
|
+
if (transitioned || decision === null) {
|
|
364
|
+
decision = evaluatePressure(pressureFacts(input), input.policy, memory);
|
|
365
|
+
memory = decision.memory;
|
|
366
|
+
}
|
|
367
|
+
view = Object.freeze({
|
|
368
|
+
revision,
|
|
369
|
+
capturedSnapshotId: input.capturedSnapshotId,
|
|
370
|
+
sessionId: input.sessionId,
|
|
371
|
+
branchAnchorTurnId: input.branchAnchorTurnId,
|
|
372
|
+
activeLeafTurnId: input.activeLeafTurnId,
|
|
373
|
+
activeUserTurnId: input.activeUserTurnId,
|
|
374
|
+
targetId: input.targetId,
|
|
375
|
+
runtimeId: input.runtimeId,
|
|
376
|
+
modelId: input.modelId,
|
|
377
|
+
modelApi: input.modelApi,
|
|
378
|
+
effectiveWindow: input.effectiveWindow,
|
|
379
|
+
windowSource: input.windowSource,
|
|
380
|
+
estimatedInputTokens: input.estimatedInputTokens,
|
|
381
|
+
anchoredInputTokens: input.anchoredInputTokens,
|
|
382
|
+
inputTokens: input.inputTokens,
|
|
383
|
+
inputSource: input.inputSource,
|
|
384
|
+
historical: input.historical,
|
|
385
|
+
breakdown: frozenCopy(input.breakdown),
|
|
386
|
+
breakdownSource: input.breakdownSource,
|
|
387
|
+
outputReserveTokens: input.outputReserveTokens,
|
|
388
|
+
thresholdReserveTokens: input.thresholdReserveTokens,
|
|
389
|
+
headroomTokens: decision.headroomTokens,
|
|
390
|
+
pressure: decision.pressure,
|
|
391
|
+
phase: decision.phase,
|
|
392
|
+
admission: decision.admission,
|
|
393
|
+
advisory: decision.advisory,
|
|
394
|
+
policy: Object.freeze({ ...input.policy }),
|
|
395
|
+
policyRejection: input.policyRejection,
|
|
396
|
+
reduction: input.reduction,
|
|
397
|
+
// Copied and frozen at this boundary. An injected reader owns the
|
|
398
|
+
// object it returns and may reuse or mutate it; a published view is
|
|
399
|
+
// the thing a revision names, and it does not change underneath one.
|
|
400
|
+
lastReduction: frozenCopy(input.lastReduction),
|
|
401
|
+
pendingHandoff: frozenCopy(input.pendingHandoff),
|
|
402
|
+
lastOutcome: frozenCopy(input.lastOutcome),
|
|
403
|
+
});
|
|
404
|
+
return view;
|
|
405
|
+
},
|
|
406
|
+
|
|
407
|
+
current(): LiveBudgetView | null {
|
|
408
|
+
return view;
|
|
409
|
+
},
|
|
410
|
+
|
|
411
|
+
reset(): void {
|
|
412
|
+
view = null;
|
|
413
|
+
fingerprint = null;
|
|
414
|
+
decision = null;
|
|
415
|
+
memory = INITIAL_ADVISORY_MEMORY;
|
|
416
|
+
},
|
|
417
|
+
};
|
|
418
|
+
}
|