@humain/humain-code 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +141 -0
- package/dist/bundle/agent-monitor.js +1 -1
- package/dist/bundle/chunks/anthropic-messages-42CGJCSR.js +82 -0
- package/dist/bundle/chunks/ask-VH7GNX75.js +97 -0
- package/dist/bundle/chunks/azure-openai-responses-DOKKMBUN.js +15 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +200 -179
- package/dist/bundle/chunks/bowser-UX7KDMIY.js +92 -0
- package/dist/bundle/chunks/{chunk-46C6D7UC.js → chunk-2CYGUEQO.js} +1 -1
- package/dist/bundle/chunks/chunk-3RXT35Y3.js +3 -0
- package/dist/bundle/chunks/chunk-4BNDLR6C.js +177 -0
- package/dist/bundle/chunks/{chunk-MPRAQ6ZI.js → chunk-4LGBXPUD.js} +1 -1
- package/dist/bundle/chunks/chunk-4SL6URR3.js +90 -0
- package/dist/bundle/chunks/{chunk-7LSTTCSC.js → chunk-52642TYH.js} +316 -148
- package/dist/bundle/chunks/{chunk-LSRXA7OS.js → chunk-5C5K4EVJ.js} +3 -3
- package/dist/bundle/chunks/{chunk-2JNJJ6SZ.js → chunk-5KUCY54O.js} +3 -3
- package/dist/bundle/chunks/{chunk-4TDNOR36.js → chunk-625QJSFJ.js} +1 -1
- package/dist/bundle/chunks/chunk-73YX5XGR.js +2461 -0
- package/dist/bundle/chunks/chunk-7DIRHF4H.js +17 -0
- package/dist/bundle/chunks/{chunk-QJB5YI3I.js → chunk-7PAXKU7M.js} +1 -1
- package/dist/bundle/chunks/{chunk-R2KD2HFT.js → chunk-7YB3HRRN.js} +83 -196
- package/dist/bundle/chunks/{chunk-DCXHRP6C.js → chunk-A2UZYK23.js} +13 -13
- package/dist/bundle/chunks/chunk-A5ZMBTTM.js +12 -0
- package/dist/bundle/chunks/{chunk-JKX5EGOT.js → chunk-AER66CNP.js} +13 -13
- package/dist/bundle/chunks/chunk-ARTF7ZMQ.js +5 -0
- package/dist/bundle/chunks/chunk-B3FT6L6S.js +131 -0
- package/dist/bundle/chunks/chunk-BIC5BSNX.js +13 -0
- package/dist/bundle/chunks/{chunk-JSHKS7VH.js → chunk-BNZZJ4LO.js} +1 -1
- package/dist/bundle/chunks/{chunk-4MKATHT2.js → chunk-CG43CMFH.js} +1 -1
- package/dist/bundle/chunks/{chunk-2XD7TLKB.js → chunk-CIAXW64K.js} +16 -16
- package/dist/bundle/chunks/{chunk-VFLVWPLZ.js → chunk-CKFLQGJN.js} +20 -16
- package/dist/bundle/chunks/chunk-D4UCXXDP.js +115 -0
- package/dist/bundle/chunks/{chunk-HQMUDHC3.js → chunk-D6ZWWDW5.js} +6 -5
- package/dist/bundle/chunks/{chunk-4GB7A76U.js → chunk-EVDQRT3I.js} +225 -348
- package/dist/bundle/chunks/{chunk-FJIISX5W.js → chunk-F74XLJPC.js} +195 -192
- package/dist/bundle/chunks/chunk-FDRBTGFJ.js +4 -0
- package/dist/bundle/chunks/{chunk-E4VUW4RI.js → chunk-FLWO3H5J.js} +12 -12
- package/dist/bundle/chunks/{chunk-KLSRGGOH.js → chunk-G2PFPQX7.js} +2 -2
- package/dist/bundle/chunks/chunk-GMPJWLZS.js +57 -0
- package/dist/bundle/chunks/{chunk-M5TVWJ5T.js → chunk-H35P7ROY.js} +462 -441
- package/dist/bundle/chunks/chunk-HCHCYBNK.js +2 -0
- package/dist/bundle/chunks/{chunk-7WE77IE3.js → chunk-HRNYDRL7.js} +1 -1
- package/dist/bundle/chunks/chunk-HWFAAGYK.js +23 -0
- package/dist/bundle/chunks/{chunk-VSXVZVBE.js → chunk-HWXQCJDP.js} +408 -392
- package/dist/bundle/chunks/{chunk-PVNXN2TC.js → chunk-II5C7G67.js} +1 -1
- package/dist/bundle/chunks/{chunk-F2H47FRF.js → chunk-IMRZP5SC.js} +182 -137
- package/dist/bundle/chunks/{chunk-AW24RHGJ.js → chunk-J5YFXMTM.js} +4 -4
- package/dist/bundle/chunks/chunk-J64VNQ6D.js +13 -0
- package/dist/bundle/chunks/{chunk-65FLSKDA.js → chunk-K5EFEIFP.js} +5 -4
- package/dist/bundle/chunks/{chunk-KI7CHPWC.js → chunk-KJ3QRSSY.js} +46 -43
- package/dist/bundle/chunks/{cli-6DJO467D.js → chunk-KSEO2LRK.js} +12 -10
- package/dist/bundle/chunks/{chunk-HHWVVNGG.js → chunk-MA2WCMSN.js} +2 -2
- package/dist/bundle/chunks/{chunk-L4J7SMJB.js → chunk-MAEKQSFU.js} +1 -1
- package/dist/bundle/chunks/chunk-MHQNLTZR.js +8 -0
- package/dist/bundle/chunks/chunk-MLOUZAVZ.js +122 -0
- package/dist/bundle/chunks/chunk-MQYR4Q6X.js +5 -0
- package/dist/bundle/chunks/chunk-MXF3KYLZ.js +4 -0
- package/dist/bundle/chunks/{chunk-GY663MNP.js → chunk-MZRTVX7F.js} +1 -1
- package/dist/bundle/chunks/chunk-MZYHSWHX.js +59 -0
- package/dist/bundle/chunks/{chunk-6HTHDVJC.js → chunk-NPVRWPGX.js} +1 -1
- package/dist/bundle/chunks/{chunk-BRSLXHED.js → chunk-O44A4E4K.js} +1 -1
- package/dist/bundle/chunks/{chunk-T2ZGMEMV.js → chunk-OADQOW67.js} +175 -260
- package/dist/bundle/chunks/chunk-OTVHRZ67.js +17 -0
- package/dist/bundle/chunks/{chunk-J4GII2EE.js → chunk-P7SLTLSZ.js} +51 -46
- package/dist/bundle/chunks/{chunk-7OZNMWAJ.js → chunk-PPGSQZZF.js} +1 -1
- package/dist/bundle/chunks/chunk-PYX6ZCC7.js +29 -0
- package/dist/bundle/chunks/chunk-PZ7NYBHJ.js +8 -0
- package/dist/bundle/chunks/{chunk-VCMXBP5S.js → chunk-QESIDBMW.js} +1 -7
- package/dist/bundle/chunks/chunk-QUWVILLB.js +3 -0
- package/dist/bundle/chunks/chunk-QZWUXGY7.js +99 -0
- package/dist/bundle/chunks/{chunk-MIAXMK5F.js → chunk-QZXLTW7V.js} +8 -7
- package/dist/bundle/chunks/chunk-RP6MWUAP.js +4 -0
- package/dist/bundle/chunks/{chunk-MUN4ZZZP.js → chunk-SOE25WIS.js} +1143 -1167
- package/dist/bundle/chunks/{chunk-JSZBTGI6.js → chunk-SZZ5PNP6.js} +2 -2
- package/dist/bundle/chunks/chunk-T5WECB2D.js +7 -0
- package/dist/bundle/chunks/{chunk-2NVGOSBN.js → chunk-T7F2TEIS.js} +37 -13
- package/dist/bundle/chunks/{chunk-ZSWU5KKA.js → chunk-UOSJTMCL.js} +7 -3
- package/dist/bundle/chunks/{chunk-6P6MMQUH.js → chunk-UTRUALFN.js} +3 -3
- package/dist/bundle/chunks/{chunk-PWFM6AQQ.js → chunk-V2HTCZRF.js} +70 -67
- package/dist/bundle/chunks/{chunk-JX6YIPNK.js → chunk-WCKS2DPT.js} +1 -1
- package/dist/bundle/chunks/chunk-XGOJCV6Z.js +2 -0
- package/dist/bundle/chunks/chunk-XGSJX23G.js +1151 -0
- package/dist/bundle/chunks/{chunk-7WETECIB.js → chunk-Z7BWHPJ2.js} +1 -1
- package/dist/bundle/chunks/chunk-ZFFDBTG3.js +17 -0
- package/dist/bundle/chunks/cli-NJLV3XDZ.js +3 -0
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-JEZVYITT.js → cloudflare-workers-ai-system-one-ZAZW4M4B.js} +1 -1
- package/dist/bundle/chunks/{compat-4ILE5BEC.js → compat-7UJJAO4E.js} +12 -12
- package/dist/bundle/chunks/{curator-server-QB4GITGS.js → curator-server-MW645JI3.js} +2 -2
- package/dist/bundle/chunks/{dist-NXHRL2KY.js → dist-7PCCEUQF.js} +2 -2
- package/dist/bundle/chunks/{dist-I6CI3CG5.js → dist-I53JI67E.js} +9 -9
- package/dist/bundle/chunks/{dist-35STTNYA.js → dist-NI2PTSLH.js} +1 -1
- package/dist/bundle/chunks/{dist-CBODG4CA.js → dist-VXQT3DQY.js} +6 -6
- package/dist/bundle/chunks/{dist-cjs-EROMDUKS.js → dist-cjs-4JQA6W3S.js} +31 -31
- package/dist/bundle/chunks/doctor-KJVAYG3F.js +83 -0
- package/dist/bundle/chunks/{easter-egg-3d-VZC5WOYV.js → easter-egg-3d-Z24JLXD4.js} +1 -1
- package/dist/bundle/chunks/entry-3EL6GOWK.js +2 -0
- package/dist/bundle/chunks/{entry-6XDR2IDE.js → entry-4IMREZBD.js} +80 -79
- package/dist/bundle/chunks/{execute-6MEJJF2T.js → execute-C4BZQRPQ.js} +23 -22
- package/dist/bundle/chunks/{extract-L373D6O7.js → extract-XVQCIS7D.js} +5 -5
- package/dist/bundle/chunks/{flow-implementer-XOP4MG5X.js → flow-implementer-GE2ARQKR.js} +5 -5
- package/dist/bundle/chunks/github-copilot.js +57 -56
- package/dist/bundle/chunks/google-generative-ai-P2P45MYP.js +22 -0
- package/dist/bundle/chunks/google-vertex-SHY4IS5F.js +26 -0
- package/dist/bundle/chunks/{host-WOLZCWQQ.js → host-YESS2VAB.js} +1 -1
- package/dist/bundle/chunks/{index.bundle-HONF3PUD.js → index.bundle-TZT64KLH.js} +102 -89
- package/dist/bundle/chunks/{inprocess-MBKFGDM2.js → inprocess-MGMVI6HN.js} +6 -6
- package/dist/bundle/chunks/interactive-mode-HHWOE4FD.js +5 -0
- package/dist/bundle/chunks/{llama-cpp-classify-KYZT532X.js → llama-cpp-classify-RSRH4KV2.js} +5 -5
- package/dist/bundle/chunks/mistral-conversations-YTMJKHHI.js +42 -0
- package/dist/bundle/chunks/{node-N7TPBUJB.js → node-FF6QQQLH.js} +1 -1
- package/dist/bundle/chunks/openai-codex-responses-NUCJOJSZ.js +97 -0
- package/dist/bundle/chunks/openai-completions-E5NRJUHA.js +91 -0
- package/dist/bundle/chunks/{openai-decisions-JMSDGR7K.js → openai-decisions-342J5ZYG.js} +1 -1
- package/dist/bundle/chunks/openai-responses-BN5Z4HFI.js +26 -0
- package/dist/bundle/chunks/openrouter-images-7RNG3JVF.js +12 -0
- package/dist/bundle/chunks/{pdfjs-FE3L72A6.js → pdfjs-LSTLRXQW.js} +1415 -1416
- package/dist/bundle/chunks/pi-messages-2L7FV5OK.js +22 -0
- package/dist/bundle/chunks/questionnaire-session-XEVAK7JS.js +123 -0
- package/dist/bundle/chunks/runtime-2FSZRUG5.js +2 -0
- package/dist/bundle/chunks/session-picker-666KJIVM.js +4 -0
- package/dist/bundle/chunks/startup-ui-INEVSNGK.js +3 -0
- package/dist/bundle/chunks/{trace-command-VM7FBWPE.js → trace-command-BCVMZ5ZD.js} +4 -4
- package/dist/bundle/chunks/typesafe-system-one-UJUNSZG4.js +3 -0
- package/dist/bundle/chunks/{undici-WVNE45GY.js → undici-7IGAYA4S.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-UXSSFNV5.js +29 -0
- package/dist/bundle/cli-runtime.js +5 -5
- package/dist/bundle/flow/package.json +3 -3
- package/dist/bundle/index.js +13 -13
- package/dist/bundle/orchestrate/package.json +1 -1
- package/dist/bundle/rpc-entry.js +5 -4
- package/dist/cli/agent-dir-arg.d.ts +12 -0
- package/dist/cli/agent-dir-arg.d.ts.map +1 -0
- package/dist/cli/agent-dir-arg.js +15 -0
- package/dist/cli/agent-dir-arg.js.map +1 -0
- package/dist/cli/args.d.ts +9 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +19 -5
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth-check.d.ts +1 -1
- package/dist/cli/auth-check.d.ts.map +1 -1
- package/dist/cli/auth-check.js +4 -2
- package/dist/cli/auth-check.js.map +1 -1
- package/dist/cli/doctor-config.d.ts +14 -0
- package/dist/cli/doctor-config.d.ts.map +1 -0
- package/dist/cli/doctor-config.js +92 -0
- package/dist/cli/doctor-config.js.map +1 -0
- package/dist/cli/doctor-system.d.ts +12 -0
- package/dist/cli/doctor-system.d.ts.map +1 -0
- package/dist/cli/doctor-system.js +109 -0
- package/dist/cli/doctor-system.js.map +1 -0
- package/dist/cli/doctor.d.ts +11 -0
- package/dist/cli/doctor.d.ts.map +1 -0
- package/dist/cli/doctor.js +323 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/doctor.lazy.d.ts +3 -0
- package/dist/cli/doctor.lazy.d.ts.map +1 -0
- package/dist/cli/doctor.lazy.js +3 -0
- package/dist/cli/doctor.lazy.js.map +1 -0
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +0 -4
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/project-trust.d.ts.map +1 -1
- package/dist/cli/project-trust.js +6 -6
- package/dist/cli/project-trust.js.map +1 -1
- package/dist/cli/startup-ui.d.ts +3 -2
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +23 -10
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/config.d.ts +5 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +13 -3
- package/dist/config.js.map +1 -1
- package/dist/coordination/broker/broker.d.ts +3 -3
- package/dist/coordination/broker/broker.d.ts.map +1 -1
- package/dist/coordination/broker/broker.js +15 -7
- package/dist/coordination/broker/broker.js.map +1 -1
- package/dist/core/acceptance-command.d.ts +6 -3
- package/dist/core/acceptance-command.d.ts.map +1 -1
- package/dist/core/acceptance-command.js +43 -12
- package/dist/core/acceptance-command.js.map +1 -1
- package/dist/core/acceptance-ledger.d.ts +2 -0
- package/dist/core/acceptance-ledger.d.ts.map +1 -1
- package/dist/core/acceptance-ledger.js +14 -3
- package/dist/core/acceptance-ledger.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +11 -4
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +13 -4
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +6 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +19 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +131 -36
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +7 -1
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts +3 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +18 -8
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +2 -2
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +9 -15
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +3 -0
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +12 -10
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template.js +23 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +13 -2
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +9 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +2 -4
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts +5 -2
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +6 -3
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/keybindings.d.ts +20 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +4 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/mcp-servers.d.ts +29 -0
- package/dist/core/mcp-servers.d.ts.map +1 -1
- package/dist/core/mcp-servers.js +63 -17
- package/dist/core/mcp-servers.js.map +1 -1
- package/dist/core/messages.d.ts +4 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +10 -2
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +36 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +6 -2
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/nested-tool-calls.d.ts +6 -5
- package/dist/core/nested-tool-calls.d.ts.map +1 -1
- package/dist/core/nested-tool-calls.js +1 -3
- package/dist/core/nested-tool-calls.js.map +1 -1
- package/dist/core/os-secret-store.js +1 -1
- package/dist/core/os-secret-store.js.map +1 -1
- package/dist/core/package-manager.d.ts +3 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +25 -4
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-ai-schemas.d.ts +4 -0
- package/dist/core/pi-ai-schemas.d.ts.map +1 -1
- package/dist/core/project-trust.d.ts.map +1 -1
- package/dist/core/project-trust.js +1 -1
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/provider-composer.d.ts +1 -0
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +1 -0
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts +4 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +14 -3
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +40 -2
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +11 -7
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +8 -4
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +22 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +227 -37
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-defaults.d.ts +10 -1
- package/dist/core/settings-defaults.d.ts.map +1 -1
- package/dist/core/settings-defaults.js +7 -1
- package/dist/core/settings-defaults.js.map +1 -1
- package/dist/core/settings-manager.d.ts +14 -4
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +48 -15
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +20 -2
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +27 -4
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/bash-jobs.js +2 -2
- package/dist/core/tools/bash-jobs.js.map +1 -1
- package/dist/core/tools/bash.d.ts +3 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +78 -46
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +7 -1
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +139 -75
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +4 -1
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +21 -6
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +90 -76
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +7 -2
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +14 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts.map +1 -1
- package/dist/core/tools/renderers/bash.js +9 -3
- package/dist/core/tools/renderers/bash.js.map +1 -1
- package/dist/core/tools/truncate.d.ts +1 -1
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +16 -7
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +2 -0
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts +2 -0
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +5 -4
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +3 -0
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +64 -20
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/renderer.d.ts.map +1 -1
- package/dist/extensions/codemode/renderer.js +8 -3
- package/dist/extensions/codemode/renderer.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +5 -0
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +3 -13
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/ui.d.ts.map +1 -1
- package/dist/extensions/llama/ui.js +2 -1
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/extensions/mcp/cli.d.ts +7 -0
- package/dist/extensions/mcp/cli.d.ts.map +1 -1
- package/dist/extensions/mcp/cli.js +35 -8
- package/dist/extensions/mcp/cli.js.map +1 -1
- package/dist/extensions/mcp/config.d.ts +33 -0
- package/dist/extensions/mcp/config.d.ts.map +1 -1
- package/dist/extensions/mcp/config.js +11 -2
- package/dist/extensions/mcp/config.js.map +1 -1
- package/dist/extensions/mcp/index.d.ts +8 -0
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +16 -0
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/resources.d.ts +1 -1
- package/dist/extensions/mcp/resources.d.ts.map +1 -1
- package/dist/extensions/mcp/resources.js +4 -3
- package/dist/extensions/mcp/resources.js.map +1 -1
- package/dist/extensions/mcp/runtime.d.ts +1 -1
- package/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/dist/extensions/mcp/runtime.js +15 -14
- package/dist/extensions/mcp/runtime.js.map +1 -1
- package/dist/extensions/mcp/tools.d.ts +1 -24
- package/dist/extensions/mcp/tools.d.ts.map +1 -1
- package/dist/extensions/mcp/tools.js +10 -163
- package/dist/extensions/mcp/tools.js.map +1 -1
- package/dist/humain/ask-user-question/index.d.ts +4 -0
- package/dist/humain/ask-user-question/index.d.ts.map +1 -0
- package/dist/humain/ask-user-question/index.js +18 -0
- package/dist/humain/ask-user-question/index.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/answer-channel.d.ts +38 -0
- package/dist/humain/ask-user-question/vendor/ask/answer-channel.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/answer-channel.js +97 -0
- package/dist/humain/ask-user-question/vendor/ask/answer-channel.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/ask-user-question.d.ts +41 -0
- package/dist/humain/ask-user-question/vendor/ask/ask-user-question.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/ask-user-question.js +441 -0
- package/dist/humain/ask-user-question/vendor/ask/ask-user-question.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/config.d.ts +39 -0
- package/dist/humain/ask-user-question/vendor/ask/config.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/config.js +95 -0
- package/dist/humain/ask-user-question/vendor/ask/config.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/events.d.ts +132 -0
- package/dist/humain/ask-user-question/vendor/ask/events.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/events.js +50 -0
- package/dist/humain/ask-user-question/vendor/ask/events.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/index.d.ts +5 -0
- package/dist/humain/ask-user-question/vendor/ask/index.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/index.js +15 -0
- package/dist/humain/ask-user-question/vendor/ask/index.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/presentation.d.ts +81 -0
- package/dist/humain/ask-user-question/vendor/ask/presentation.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/presentation.js +105 -0
- package/dist/humain/ask-user-question/vendor/ask/presentation.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/reconcile.d.ts +28 -0
- package/dist/humain/ask-user-question/vendor/ask/reconcile.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/reconcile.js +45 -0
- package/dist/humain/ask-user-question/vendor/ask/reconcile.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/rpc-fallback.d.ts +41 -0
- package/dist/humain/ask-user-question/vendor/ask/rpc-fallback.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/rpc-fallback.js +166 -0
- package/dist/humain/ask-user-question/vendor/ask/rpc-fallback.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/build-questionnaire.d.ts +46 -0
- package/dist/humain/ask-user-question/vendor/ask/state/build-questionnaire.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/build-questionnaire.js +247 -0
- package/dist/humain/ask-user-question/vendor/ask/state/build-questionnaire.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/external-editor.d.ts +11 -0
- package/dist/humain/ask-user-question/vendor/ask/state/external-editor.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/external-editor.js +56 -0
- package/dist/humain/ask-user-question/vendor/ask/state/external-editor.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/i18n-bridge.d.ts +6 -0
- package/dist/humain/ask-user-question/vendor/ask/state/i18n-bridge.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/i18n-bridge.js +10 -0
- package/dist/humain/ask-user-question/vendor/ask/state/i18n-bridge.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/key-router.d.ts +57 -0
- package/dist/humain/ask-user-question/vendor/ask/state/key-router.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/key-router.js +357 -0
- package/dist/humain/ask-user-question/vendor/ask/state/key-router.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/questionnaire-session.d.ts +112 -0
- package/dist/humain/ask-user-question/vendor/ask/state/questionnaire-session.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/questionnaire-session.js +240 -0
- package/dist/humain/ask-user-question/vendor/ask/state/questionnaire-session.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/row-intent.d.ts +87 -0
- package/dist/humain/ask-user-question/vendor/ask/state/row-intent.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/row-intent.js +79 -0
- package/dist/humain/ask-user-question/vendor/ask/state/row-intent.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/selectors/contract.d.ts +22 -0
- package/dist/humain/ask-user-question/vendor/ask/state/selectors/contract.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/selectors/contract.js +2 -0
- package/dist/humain/ask-user-question/vendor/ask/state/selectors/contract.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/selectors/derivations.d.ts +27 -0
- package/dist/humain/ask-user-question/vendor/ask/state/selectors/derivations.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/selectors/derivations.js +48 -0
- package/dist/humain/ask-user-question/vendor/ask/state/selectors/derivations.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/selectors/focus.d.ts +13 -0
- package/dist/humain/ask-user-question/vendor/ask/state/selectors/focus.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/selectors/focus.js +15 -0
- package/dist/humain/ask-user-question/vendor/ask/state/selectors/focus.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/selectors/projections.d.ts +14 -0
- package/dist/humain/ask-user-question/vendor/ask/state/selectors/projections.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/selectors/projections.js +96 -0
- package/dist/humain/ask-user-question/vendor/ask/state/selectors/projections.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/state-reducer.d.ts +58 -0
- package/dist/humain/ask-user-question/vendor/ask/state/state-reducer.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/state-reducer.js +310 -0
- package/dist/humain/ask-user-question/vendor/ask/state/state-reducer.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/state.d.ts +68 -0
- package/dist/humain/ask-user-question/vendor/ask/state/state.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/state/state.js +2 -0
- package/dist/humain/ask-user-question/vendor/ask/state/state.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/external-answer.d.ts +24 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/external-answer.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/external-answer.js +114 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/external-answer.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/format-answer.d.ts +18 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/format-answer.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/format-answer.js +29 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/format-answer.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/normalize-params.d.ts +41 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/normalize-params.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/normalize-params.js +99 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/normalize-params.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/response-envelope.d.ts +37 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/response-envelope.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/response-envelope.js +70 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/response-envelope.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/types.d.ts +129 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/types.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/types.js +76 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/types.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/validate-questionnaire.d.ts +21 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/validate-questionnaire.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/validate-questionnaire.js +49 -0
- package/dist/humain/ask-user-question/vendor/ask/tool/validate-questionnaire.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/component-binding.d.ts +23 -0
- package/dist/humain/ask-user-question/vendor/ask/view/component-binding.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/component-binding.js +16 -0
- package/dist/humain/ask-user-question/vendor/ask/view/component-binding.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/inline-input.d.ts +21 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/inline-input.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/inline-input.js +49 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/inline-input.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/multi-select-view.d.ts +43 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/multi-select-view.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/multi-select-view.js +130 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/multi-select-view.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/option-list-view.d.ts +45 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/option-list-view.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/option-list-view.js +39 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/option-list-view.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/markdown-content-cache.d.ts +36 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/markdown-content-cache.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/markdown-content-cache.js +72 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/markdown-content-cache.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-block-renderer.d.ts +61 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-block-renderer.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-block-renderer.js +108 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-block-renderer.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-box-renderer.d.ts +39 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-box-renderer.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-box-renderer.js +76 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-box-renderer.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-layout-decider.d.ts +123 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-layout-decider.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-layout-decider.js +180 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-layout-decider.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-pane.d.ts +108 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-pane.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-pane.js +235 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/preview/preview-pane.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/submit-picker.d.ts +37 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/submit-picker.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/submit-picker.js +47 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/submit-picker.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/tab-bar.d.ts +31 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/tab-bar.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/tab-bar.js +35 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/tab-bar.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/wrapping-select.d.ts +124 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/wrapping-select.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/wrapping-select.js +205 -0
- package/dist/humain/ask-user-question/vendor/ask/view/components/wrapping-select.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/dialog-builder.d.ts +83 -0
- package/dist/humain/ask-user-question/vendor/ask/view/dialog-builder.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/dialog-builder.js +186 -0
- package/dist/humain/ask-user-question/vendor/ask/view/dialog-builder.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/dialog-copy.d.ts +47 -0
- package/dist/humain/ask-user-question/vendor/ask/view/dialog-copy.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/dialog-copy.js +48 -0
- package/dist/humain/ask-user-question/vendor/ask/view/dialog-copy.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/props-adapter.d.ts +58 -0
- package/dist/humain/ask-user-question/vendor/ask/view/props-adapter.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/props-adapter.js +84 -0
- package/dist/humain/ask-user-question/vendor/ask/view/props-adapter.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/scroll-window.d.ts +20 -0
- package/dist/humain/ask-user-question/vendor/ask/view/scroll-window.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/scroll-window.js +55 -0
- package/dist/humain/ask-user-question/vendor/ask/view/scroll-window.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/stateful-view.d.ts +23 -0
- package/dist/humain/ask-user-question/vendor/ask/view/stateful-view.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/stateful-view.js +2 -0
- package/dist/humain/ask-user-question/vendor/ask/view/stateful-view.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/tab-components.d.ts +15 -0
- package/dist/humain/ask-user-question/vendor/ask/view/tab-components.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/tab-components.js +2 -0
- package/dist/humain/ask-user-question/vendor/ask/view/tab-components.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/tab-content-strategy.d.ts +98 -0
- package/dist/humain/ask-user-question/vendor/ask/view/tab-content-strategy.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/tab-content-strategy.js +248 -0
- package/dist/humain/ask-user-question/vendor/ask/view/tab-content-strategy.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/transcript.d.ts +23 -0
- package/dist/humain/ask-user-question/vendor/ask/view/transcript.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/ask/view/transcript.js +131 -0
- package/dist/humain/ask-user-question/vendor/ask/view/transcript.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/config/config.d.ts +132 -0
- package/dist/humain/ask-user-question/vendor/config/config.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/config/config.js +286 -0
- package/dist/humain/ask-user-question/vendor/config/config.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/config/index.d.ts +2 -0
- package/dist/humain/ask-user-question/vendor/config/index.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/config/index.js +2 -0
- package/dist/humain/ask-user-question/vendor/config/index.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/i18n/i18n.d.ts +64 -0
- package/dist/humain/ask-user-question/vendor/i18n/i18n.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/i18n/i18n.js +185 -0
- package/dist/humain/ask-user-question/vendor/i18n/i18n.js.map +1 -0
- package/dist/humain/ask-user-question/vendor/i18n/loader.d.ts +44 -0
- package/dist/humain/ask-user-question/vendor/i18n/loader.d.ts.map +1 -0
- package/dist/humain/ask-user-question/vendor/i18n/loader.js +55 -0
- package/dist/humain/ask-user-question/vendor/i18n/loader.js.map +1 -0
- package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +26 -16
- package/dist/humain/brand-logo.d.ts +2 -0
- package/dist/humain/brand-logo.d.ts.map +1 -1
- package/dist/humain/brand-logo.js +4 -0
- package/dist/humain/brand-logo.js.map +1 -1
- package/dist/humain/bundled-extension-names.d.ts +1 -0
- package/dist/humain/bundled-extension-names.d.ts.map +1 -1
- package/dist/humain/bundled-extension-names.js +1 -0
- package/dist/humain/bundled-extension-names.js.map +1 -1
- package/dist/humain/checklist/footer-progress.d.ts +7 -0
- package/dist/humain/checklist/footer-progress.d.ts.map +1 -0
- package/dist/humain/checklist/footer-progress.js +15 -0
- package/dist/humain/checklist/footer-progress.js.map +1 -0
- package/dist/humain/checklist/glyphs.d.ts +7 -0
- package/dist/humain/checklist/glyphs.d.ts.map +1 -0
- package/dist/humain/checklist/glyphs.js +8 -0
- package/dist/humain/checklist/glyphs.js.map +1 -0
- package/dist/humain/checklist/index.d.ts +6 -0
- package/dist/humain/checklist/index.d.ts.map +1 -0
- package/dist/humain/checklist/index.js +37 -0
- package/dist/humain/checklist/index.js.map +1 -0
- package/dist/humain/checklist/progress.d.ts +37 -0
- package/dist/humain/checklist/progress.d.ts.map +1 -0
- package/dist/humain/checklist/progress.js +234 -0
- package/dist/humain/checklist/progress.js.map +1 -0
- package/dist/humain/checklist/projector.d.ts +53 -0
- package/dist/humain/checklist/projector.d.ts.map +1 -0
- package/dist/humain/checklist/projector.js +198 -0
- package/dist/humain/checklist/projector.js.map +1 -0
- package/dist/humain/checklist/sidebar.d.ts +18 -0
- package/dist/humain/checklist/sidebar.d.ts.map +1 -0
- package/dist/humain/checklist/sidebar.js +38 -0
- package/dist/humain/checklist/sidebar.js.map +1 -0
- package/dist/humain/checklist/status-segment.d.ts +19 -0
- package/dist/humain/checklist/status-segment.d.ts.map +1 -0
- package/dist/humain/checklist/status-segment.js +59 -0
- package/dist/humain/checklist/status-segment.js.map +1 -0
- package/dist/humain/checklist/vendor/add-task-dialog.d.ts +54 -0
- package/dist/humain/checklist/vendor/add-task-dialog.d.ts.map +1 -0
- package/dist/humain/checklist/vendor/add-task-dialog.js +238 -0
- package/dist/humain/checklist/vendor/add-task-dialog.js.map +1 -0
- package/dist/humain/checklist/vendor/commands.d.ts +38 -0
- package/dist/humain/checklist/vendor/commands.d.ts.map +1 -0
- package/dist/humain/checklist/vendor/commands.js +193 -0
- package/dist/humain/checklist/vendor/commands.js.map +1 -0
- package/dist/humain/checklist/vendor/index.d.ts +3 -0
- package/dist/humain/checklist/vendor/index.d.ts.map +1 -0
- package/dist/humain/checklist/vendor/index.js +276 -0
- package/dist/humain/checklist/vendor/index.js.map +1 -0
- package/dist/humain/checklist/vendor/render.d.ts +97 -0
- package/dist/humain/checklist/vendor/render.d.ts.map +1 -0
- package/dist/humain/checklist/vendor/render.js +354 -0
- package/dist/humain/checklist/vendor/render.js.map +1 -0
- package/dist/humain/checklist/vendor/settings.d.ts +11 -0
- package/dist/humain/checklist/vendor/settings.d.ts.map +1 -0
- package/dist/humain/checklist/vendor/settings.js +8 -0
- package/dist/humain/checklist/vendor/settings.js.map +1 -0
- package/dist/humain/checklist/vendor/store.d.ts +120 -0
- package/dist/humain/checklist/vendor/store.d.ts.map +1 -0
- package/dist/humain/checklist/vendor/store.js +990 -0
- package/dist/humain/checklist/vendor/store.js.map +1 -0
- package/dist/humain/checklist/vendor/tools.d.ts +21 -0
- package/dist/humain/checklist/vendor/tools.d.ts.map +1 -0
- package/dist/humain/checklist/vendor/tools.js +162 -0
- package/dist/humain/checklist/vendor/tools.js.map +1 -0
- package/dist/humain/checklist/vendor/types.d.ts +188 -0
- package/dist/humain/checklist/vendor/types.d.ts.map +1 -0
- package/dist/humain/checklist/vendor/types.js +32 -0
- package/dist/humain/checklist/vendor/types.js.map +1 -0
- package/dist/humain/gateway/catalog.d.ts +1 -0
- package/dist/humain/gateway/catalog.d.ts.map +1 -1
- package/dist/humain/gateway/catalog.js +1 -0
- package/dist/humain/gateway/catalog.js.map +1 -1
- package/dist/humain/gateway/client.d.ts +1 -0
- package/dist/humain/gateway/client.d.ts.map +1 -1
- package/dist/humain/gateway/client.js +8 -1
- package/dist/humain/gateway/client.js.map +1 -1
- package/dist/humain/gateway/http.d.ts.map +1 -1
- package/dist/humain/gateway/http.js +11 -3
- package/dist/humain/gateway/http.js.map +1 -1
- package/dist/humain/gateway/images.d.ts +3 -0
- package/dist/humain/gateway/images.d.ts.map +1 -0
- package/dist/humain/gateway/images.js +73 -0
- package/dist/humain/gateway/images.js.map +1 -0
- package/dist/humain/gateway/provider.js +1 -1
- package/dist/humain/gateway/provider.js.map +1 -1
- package/dist/humain/hcode/account-store.d.ts.map +1 -1
- package/dist/humain/hcode/account-store.js +3 -1
- package/dist/humain/hcode/account-store.js.map +1 -1
- package/dist/humain/hcode/account.d.ts.map +1 -1
- package/dist/humain/hcode/account.js +23 -13
- package/dist/humain/hcode/account.js.map +1 -1
- package/dist/humain/hcode/images.d.ts.map +1 -1
- package/dist/humain/hcode/images.js +19 -13
- package/dist/humain/hcode/images.js.map +1 -1
- package/dist/humain/hcode/login-failure.d.ts +1 -0
- package/dist/humain/hcode/login-failure.d.ts.map +1 -1
- package/dist/humain/hcode/login-failure.js +1 -0
- package/dist/humain/hcode/login-failure.js.map +1 -1
- package/dist/humain/hcode/provider.d.ts.map +1 -1
- package/dist/humain/hcode/provider.js +2 -1
- package/dist/humain/hcode/provider.js.map +1 -1
- package/dist/humain/hcode/run-credential.d.ts +1 -0
- package/dist/humain/hcode/run-credential.d.ts.map +1 -1
- package/dist/humain/hcode/run-credential.js +12 -4
- package/dist/humain/hcode/run-credential.js.map +1 -1
- package/dist/humain/index.d.ts.map +1 -1
- package/dist/humain/index.js +4 -0
- package/dist/humain/index.js.map +1 -1
- package/dist/humain/node-provider.d.ts.map +1 -1
- package/dist/humain/node-provider.js +37 -8
- package/dist/humain/node-provider.js.map +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +36 -26
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/chat-viewport.js +1 -1
- package/dist/modes/interactive/chat-viewport.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +2 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +7 -4
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +1 -1
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +2 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +20 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +1 -1
- package/dist/modes/interactive/components/extension-editor.js +2 -2
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +7 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +74 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
- package/dist/modes/interactive/components/mermaid.js +11 -4
- package/dist/modes/interactive/components/mermaid.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +2 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +56 -8
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +13 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +10 -9
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +3 -3
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +4 -3
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +83 -37
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.js +3 -3
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +18 -7
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +70 -24
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/status-line.d.ts +16 -0
- package/dist/modes/interactive/components/status-line.d.ts.map +1 -0
- package/dist/modes/interactive/components/status-line.js +51 -0
- package/dist/modes/interactive/components/status-line.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +5 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +8 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js +11 -3
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +13 -3
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +17 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +232 -108
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/program-status-reporter.d.ts +2 -0
- package/dist/modes/interactive/program-status-reporter.d.ts.map +1 -1
- package/dist/modes/interactive/program-status-reporter.js +4 -0
- package/dist/modes/interactive/program-status-reporter.js.map +1 -1
- package/dist/modes/interactive/session-share.d.ts.map +1 -1
- package/dist/modes/interactive/session-share.js +9 -1
- package/dist/modes/interactive/session-share.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +34 -7
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/jsonl.js +6 -5
- package/dist/modes/rpc/jsonl.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +2 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +9 -2
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +2 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +113 -13
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +22 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/modes/uncaught-errors.d.ts +20 -0
- package/dist/modes/uncaught-errors.d.ts.map +1 -0
- package/dist/modes/uncaught-errors.js +56 -0
- package/dist/modes/uncaught-errors.js.map +1 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +10 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/clipboard-image.js +1 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.js +2 -2
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/image-process.d.ts +5 -0
- package/dist/utils/image-process.d.ts.map +1 -1
- package/dist/utils/image-process.js +22 -4
- package/dist/utils/image-process.js.map +1 -1
- package/dist/utils/output-files.d.ts +44 -7
- package/dist/utils/output-files.d.ts.map +1 -1
- package/dist/utils/output-files.js +206 -12
- package/dist/utils/output-files.js.map +1 -1
- package/dist/utils/piped-stdin.d.ts +21 -0
- package/dist/utils/piped-stdin.d.ts.map +1 -0
- package/dist/utils/piped-stdin.js +60 -0
- package/dist/utils/piped-stdin.js.map +1 -0
- package/dist/utils/shell.d.ts +5 -2
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +77 -8
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +33 -2
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +77 -10
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +1 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +9 -8
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/wsl.d.ts +8 -2
- package/dist/utils/wsl.d.ts.map +1 -1
- package/dist/utils/wsl.js +12 -3
- package/dist/utils/wsl.js.map +1 -1
- package/docs/cli.md +39 -3
- package/docs/codemode.md +7 -3
- package/docs/compaction.md +1 -1
- package/docs/development.md +6 -0
- package/docs/environment-variables.md +3 -2
- package/docs/extensions.md +19 -5
- package/docs/keybindings.md +2 -0
- package/docs/llama-cpp.md +2 -2
- package/docs/message-types.md +1 -0
- package/docs/models-configuration.md +14 -3
- package/docs/models.md +29 -7
- package/docs/providers.md +20 -2
- package/docs/rpc-commands.md +25 -2
- package/docs/rpc.md +20 -0
- package/docs/run-preflight.md +2 -2
- package/docs/session-format.md +9 -0
- package/docs/settings.md +35 -5
- package/docs/shell-aliases.md +1 -1
- package/docs/slash-commands.md +3 -1
- package/docs/terminal-setup.md +25 -0
- package/docs/windows.md +2 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +4 -4
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/rpc-extension-ui.ts +8 -7
- package/npm-shrinkwrap.json +209 -180
- package/package.json +26 -20
- package/schemas/keybindings.schema.json +12 -0
- package/schemas/models.schema.json +20 -7
- package/schemas/settings.schema.json +43 -5
- package/src/coordination/UPSTREAM.md +27 -1
- package/src/coordination/upstream.json +3 -3
- package/src/humain/ask-user-question/UPSTREAM.md +31 -0
- package/src/humain/ask-user-question/upstream.json +258 -0
- package/src/humain/ask-user-question/vendor/ask/LICENSE +21 -0
- package/src/humain/ask-user-question/vendor/ask/locales/de.json +38 -0
- package/src/humain/ask-user-question/vendor/ask/locales/en.json +41 -0
- package/src/humain/ask-user-question/vendor/ask/locales/es.json +38 -0
- package/src/humain/ask-user-question/vendor/ask/locales/fr.json +38 -0
- package/src/humain/ask-user-question/vendor/ask/locales/pt-BR.json +38 -0
- package/src/humain/ask-user-question/vendor/ask/locales/pt.json +38 -0
- package/src/humain/ask-user-question/vendor/ask/locales/ru.json +38 -0
- package/src/humain/ask-user-question/vendor/ask/locales/uk.json +38 -0
- package/src/humain/ask-user-question/vendor/ask/locales/zh.json +40 -0
- package/src/humain/ask-user-question/vendor/config/LICENSE +21 -0
- package/src/humain/ask-user-question/vendor/i18n/LICENSE +21 -0
- package/src/humain/caveman/UPSTREAM.md +44 -11
- package/src/humain/caveman/upstream.json +3 -3
- package/src/humain/caveman/vendor/NOTICE +4 -0
- package/dist/bundle/chunks/anthropic-messages-XFCDMGD6.js +0 -77
- package/dist/bundle/chunks/azure-openai-responses-F4KQM3NK.js +0 -15
- package/dist/bundle/chunks/bowser-DXKSTXFQ.js +0 -89
- package/dist/bundle/chunks/chunk-3E37CJCE.js +0 -34
- package/dist/bundle/chunks/chunk-3HVHETMU.js +0 -18
- package/dist/bundle/chunks/chunk-6JTCRCNF.js +0 -74
- package/dist/bundle/chunks/chunk-B3ZLWVDA.js +0 -80
- package/dist/bundle/chunks/chunk-F77J5EQZ.js +0 -3
- package/dist/bundle/chunks/chunk-GPLWWO5Q.js +0 -121
- package/dist/bundle/chunks/chunk-GV5OVRKK.js +0 -4
- package/dist/bundle/chunks/chunk-JBSWWCT5.js +0 -12
- package/dist/bundle/chunks/chunk-JWOPWHVH.js +0 -51
- package/dist/bundle/chunks/chunk-KRBELWQH.js +0 -7
- package/dist/bundle/chunks/chunk-PFBAIRCY.js +0 -56
- package/dist/bundle/chunks/chunk-Q5RKNQ2T.js +0 -73
- package/dist/bundle/chunks/chunk-QFDZEUFU.js +0 -12
- package/dist/bundle/chunks/chunk-SKCJ25SX.js +0 -24
- package/dist/bundle/chunks/chunk-UZOIHLNU.js +0 -23
- package/dist/bundle/chunks/chunk-YSWDFV2L.js +0 -11
- package/dist/bundle/chunks/chunk-YZMQXAJM.js +0 -8
- package/dist/bundle/chunks/chunk-ZAHVC5V2.js +0 -3591
- package/dist/bundle/chunks/entry-2GZ3PTWQ.js +0 -2
- package/dist/bundle/chunks/google-generative-ai-WIASMWS3.js +0 -22
- package/dist/bundle/chunks/google-vertex-WSPHRZIZ.js +0 -25
- package/dist/bundle/chunks/interactive-mode-3322RQEH.js +0 -5
- package/dist/bundle/chunks/mistral-conversations-7JYDDRUT.js +0 -43
- package/dist/bundle/chunks/openai-codex-responses-7PAML4NF.js +0 -102
- package/dist/bundle/chunks/openai-completions-UJDAIGTK.js +0 -87
- package/dist/bundle/chunks/openai-responses-2WNCE6AY.js +0 -26
- package/dist/bundle/chunks/openrouter-images-V3UCCO6X.js +0 -8
- package/dist/bundle/chunks/pi-messages-TQ7LJUNQ.js +0 -28
- package/dist/bundle/chunks/runtime-H7LYNKCZ.js +0 -2
- package/dist/bundle/chunks/session-picker-EYKCMFQR.js +0 -4
- package/dist/bundle/chunks/startup-ui-7ODOR34R.js +0 -3
- package/dist/bundle/chunks/typesafe-system-one-YP7GGN4C.js +0 -3
- package/dist/bundle/chunks/virtual-mod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,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC;AAC5E,CAAC;AACD,SAAS,iBAAiB,CAAC,KAAc;IACxC,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;QAC7D,aAAa;QACb,cAAc;QACd,WAAW;QACX,qBAAqB;KACrB,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACjC,oGAAoG;IACpG,OAAO,mBAAmB,KAAK,SAAS;QACvC,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,mBAAmB,EAAE,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC,EAAE,CAAC;AAC/E,CAAC;AACD,SAAS,SAAS,CAAC,KAAc;IAChC,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC7E,CAAC","sourcesContent":["// Encrypted, generation-fenced native grants. No token is written to generic auth storage.\nimport { createCipheriv, createDecipheriv, randomBytes, randomUUID } from \"node:crypto\";\nimport {\n\tcloseSync,\n\tconstants,\n\texistsSync,\n\tfstatSync,\n\tfsyncSync,\n\tlstatSync,\n\tmkdirSync,\n\topenSync,\n\treaddirSync,\n\treadFileSync,\n\trenameSync,\n\tunlinkSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport { dirname, isAbsolute, join, relative, resolve, sep } from \"node:path\";\nimport { setTimeout as delay } from \"node:timers/promises\";\nimport lockfile from \"proper-lockfile\";\nimport { getAgentDir } from \"../../config.ts\";\nimport { createOsSecretStore, type OsSecretStore } from \"../../core/os-secret-store.ts\";\nimport { assertPrivateWindowsPath } from \"../../core/private-windows-path.ts\";\nimport { type CommandRunner, spawnCommand } from \"../../core/trace-client/credential-store.ts\";\nimport { type HcodeEnvironment, type HcodeEnvironmentName, resolveHcodeEnvironment } from \"./environment.ts\";\nimport type { HcodeAccountRef } from \"./ports.ts\";\nimport * as wire from \"./wire.ts\";\n\nexport interface HcodeGrant {\n\taccessToken: string;\n\trefreshToken: string;\n\texpiresAt: number;\n}\nexport interface HcodeBinding {\n\tenvironmentId: string;\n\tissuer: string;\n\tclientId: string;\n}\ninterface StoredAccount extends HcodeBinding {\n\treference: HcodeAccountRef;\n}\ninterface State {\n\tversion: 1;\n\tcurrent: StoredAccount | null;\n\tintents: string[];\n\t// A refresh was dispatched or is about to be. Without a staged grant, the old token must not be replayed.\n\trotation: string | null;\n}\n/** A refresh can persist rotated tokens before the account has been checked. */\nexport interface HcodeRefreshGrant extends HcodeGrant {\n\tpendingVerification?: true;\n}\n/** Refresh outcome: the saved grant can be used, or the account was rejected. */\nexport type HcodeRefreshOutcome = \"rotated\" | \"rejected\";\n/** Rotates or revalidates a grant. Throwing keeps the last saved grant; only \"rejected\" removes the account. */\nexport type HcodeRefresh = (\n\tgrant: HcodeRefreshGrant,\n\tsave: (next: HcodeRefreshGrant) => void,\n\tmarkRotation: (inFlight: boolean) => void,\n) => Promise<HcodeRefreshOutcome>;\n/** The replacement envelope definitely never became visible; its token may be retired. */\nexport class HcodeUncommittedRotationError extends Error {}\n/** A refresh may have consumed the retained token; the user must replace the grant rather than retry it. */\nexport class HcodeUncertainRotationError extends Error {\n\tconstructor() {\n\t\tsuper(\"HUMAIN Code sign-in renewal could not be confirmed. Sign in again.\");\n\t}\n}\n/** Trusted host publication and bounded, issuer-fenced retirement, used only under the account lock. */\nexport interface HcodeAccountPublication {\n\tread(signal?: AbortSignal): Promise<HcodeAccountRef | null>;\n\tclear(expected: HcodeAccountRef | null, signal?: AbortSignal): Promise<void>;\n\tretire?(binding: HcodeBinding, grant: HcodeGrant): Promise<void>;\n}\ninterface Replacement {\n\tprevious: StoredAccount | null;\n\tcandidate: StoredAccount;\n}\nexport interface HcodeAccountStoreOptions {\n\tenvironment?: HcodeEnvironmentName;\n\tagentDir?: string;\n\tsecrets?: OsSecretStore;\n\tpublication?: HcodeAccountPublication;\n\tplatform?: NodeJS.Platform;\n\trun?: CommandRunner;\n}\nconst UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;\nconst MAX_GRANT = 1048576;\nconst MAX_ENVELOPE = 1400000;\nconst STORAGE_ERROR = \"HUMAIN Code secure storage failed. Sign in again after checking private storage access.\";\n\n/** Owns encrypted grants and cross-process serialization for one built-in environment. */\nexport class HcodeAccountStore {\n\tprivate readonly dir: string;\n\tprivate readonly environment: HcodeEnvironment;\n\tprivate readonly platform: NodeJS.Platform;\n\tprivate readonly runner: CommandRunner;\n\tprivate secrets: OsSecretStore | undefined;\n\tprivate publication: HcodeAccountPublication | undefined;\n\tprivate readonly createdDirectories = new Set<string>();\n\tcleanupIncomplete = false;\n\tconstructor(options: HcodeAccountStoreOptions = {}) {\n\t\tthis.environment = resolveHcodeEnvironment(options.environment);\n\t\tconst agentDir = resolve(options.agentDir ?? getAgentDir());\n\t\t// Config is global, never a project-controlled credential destination.\n\t\tfor (let path = agentDir; ; path = dirname(path)) {\n\t\t\tif (existsSync(join(path, \".git\"))) throw new Error(STORAGE_ERROR);\n\t\t\tif (dirname(path) === path) break;\n\t\t}\n\t\tconst fromCwd = relative(process.cwd(), agentDir);\n\t\tif (!fromCwd || (!fromCwd.startsWith(`..${sep}`) && !isAbsolute(fromCwd))) throw new Error(STORAGE_ERROR);\n\t\tthis.dir = join(agentDir, \"hcode\", \"accounts\", this.environment.id);\n\t\tthis.platform = options.platform ?? process.platform;\n\t\tthis.runner = options.run ?? spawnCommand;\n\t\tthis.secrets = options.secrets;\n\t\tthis.publication = options.publication;\n\t}\n\n\t/** Attaches the owning host's generic store without reading secrets or recovering at construction. */\n\tconfigurePublication(publication: HcodeAccountPublication | undefined): void {\n\t\tthis.publication = publication;\n\t}\n\n\t/** Checks only local replacement evidence, without creating files or touching OS secrets. */\n\thasPendingReplacement(): boolean {\n\t\tthis.guardParents(false, true);\n\t\treturn this.read(\"replacement.json\", 16384) !== undefined;\n\t}\n\n\t/** Recovers only an existing replacement; signed-out startup never creates storage or probes keys. */\n\tasync recoverPendingReplacement(signal?: AbortSignal): Promise<boolean> {\n\t\tsignal?.throwIfAborted();\n\t\tif (!this.hasPendingReplacement()) return false;\n\t\tawait this.locked(async () => {}, \"logout\", signal);\n\t\treturn true;\n\t}\n\n\t/** Reads only non-secret local metadata. Never creates files, probes a keyring or sends HTTP. */\n\tstatus(environmentId: string): HcodeAccountRef | null {\n\t\tif (environmentId !== this.environment.id) return null;\n\t\ttry {\n\t\t\tthis.guardParents(false);\n\t\t\tconst state = this.readState();\n\t\t\tconst ref = state.current?.reference;\n\t\t\treturn ref?.environmentId === environmentId && !this.tombstoned(ref) ? ref : null;\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/** Compares logout's observed generation independently of its durable logout marker. */\n\tisCurrent(expected: HcodeAccountRef): boolean {\n\t\tif (expected.environmentId !== this.environment.id) return false;\n\t\ttry {\n\t\t\tthis.guardParents(false);\n\t\t\treturn sameReference(this.readState().current?.reference, expected);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/** Checks existing private state and purpose-key availability without creating or recovering account files. */\n\tasync prepare(signal: AbortSignal): Promise<void> {\n\t\tsignal.throwIfAborted();\n\t\tthis.guardParents(false, true);\n\t\tconst state = this.readState();\n\t\tif (existsSync(this.dir)) {\n\t\t\tfor (const name of readdirSync(this.dir)) {\n\t\t\t\tawait this.acl(join(this.dir, name), signal);\n\t\t\t\tconst text = this.read(name, MAX_ENVELOPE);\n\t\t\t\tif (name.endsWith(\".enc\") || name.endsWith(\".rotation\")) {\n\t\t\t\t\tconst envelope = wire.object(JSON.parse(text!), [\"version\", \"keyId\", \"nonce\", \"ciphertext\", \"tag\"]);\n\t\t\t\t\twire.literal(envelope.version, 1);\n\t\t\t\t\tuuid(envelope.keyId);\n\t\t\t\t\tbase64(envelope.nonce, 12);\n\t\t\t\t\tbase64(envelope.tag, 16);\n\t\t\t\t\tbase64(envelope.ciphertext);\n\t\t\t\t} else if (name === \"replacement.json\") {\n\t\t\t\t\tthis.parseReplacement(text!);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const path of [dirname(dirname(this.dir)), dirname(this.dir), this.dir])\n\t\t\tif (existsSync(path)) await this.acl(path, signal);\n\t\tawait this.keyStore().probe(signal);\n\t\tif (state.current) await this.decrypt(state.current, undefined, signal);\n\t\tsignal.throwIfAborted();\n\t}\n\n\t/** Recovers durable intents, replacements and logout markers under the same lock used by every mutation. */\n\tasync recover(signal?: AbortSignal, retire?: HcodeAccountPublication[\"retire\"]): Promise<void> {\n\t\tawait this.locked(async () => {}, \"recover\", signal, retire);\n\t}\n\n\t/**\n\t * Probes the purpose-key store, obtains a grant without holding the account lock, then stores it under the lock\n\t * only if the account observed before `obtain` is still current. A failed replacement leaves the old grant intact.\n\t */\n\tasync replace(\n\t\tbinding: HcodeBinding,\n\t\tobtain: () => Promise<{ accountId: string; grant: HcodeGrant }>,\n\t\tretire?: (grant: HcodeGrant | null) => Promise<void>,\n\t\tpublish?: (reference: HcodeAccountRef) => Promise<void>,\n\t): Promise<HcodeAccountRef> {\n\t\tthis.assertEnvironment(binding.environmentId);\n\t\tawait this.keyStore().probe();\n\t\tconst observed = this.status(this.environment.id);\n\t\t// A device sign-in can wait minutes; other windows keep using the saved account meanwhile.\n\t\tconst result = await obtain();\n\t\tlet entered = false;\n\t\ttry {\n\t\t\treturn await this.locked(async (state, assertLock) => {\n\t\t\t\tentered = true;\n\t\t\t\treturn this.commit(binding, result, observed, state, assertLock, retire, publish);\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (!entered && retire) {\n\t\t\t\ttry {\n\t\t\t\t\tawait retire(result.grant);\n\t\t\t\t} catch {\n\t\t\t\t\t/* The lock failure is the reported error. */\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/** Stores an obtained grant as the new current account; runs under the account lock. */\n\tprivate async commit(\n\t\tbinding: HcodeBinding,\n\t\tresult: { accountId: string; grant: HcodeGrant },\n\t\tobserved: HcodeAccountRef | null,\n\t\tstate: State,\n\t\tassertLock: () => void,\n\t\tretire?: (grant: HcodeGrant | null) => Promise<void>,\n\t\tpublish?: (reference: HcodeAccountRef) => Promise<void>,\n\t): Promise<HcodeAccountRef> {\n\t\tconst generation = randomUUID();\n\t\tlet key: Buffer | undefined;\n\t\tlet journaled = false;\n\t\tconst retireBound = async (issued: HcodeBinding, grant: HcodeGrant) => {\n\t\t\tif (retire) await retire(sameBinding(issued, binding) ? grant : null);\n\t\t};\n\t\ttry {\n\t\t\tstate.intents.push(generation);\n\t\t\tthis.saveState(state);\n\t\t\tkey = randomBytes(32);\n\t\t\tawait this.keyStore().set(`${this.environment.id}:${generation}`, key.toString(\"base64\"));\n\t\t\tif ((await this.keyStore().get(`${this.environment.id}:${generation}`)) !== key.toString(\"base64\"))\n\t\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t\tconst reference = {\n\t\t\t\tenvironmentId: wire.string(binding.environmentId),\n\t\t\t\taccountId: wire.string(result.accountId),\n\t\t\t\tgeneration,\n\t\t\t};\n\t\t\tconst next: StoredAccount = {\n\t\t\t\tenvironmentId: binding.environmentId,\n\t\t\t\tissuer: binding.issuer,\n\t\t\t\tclientId: binding.clientId,\n\t\t\t\treference,\n\t\t\t};\n\t\t\tconst old = state.current;\n\t\t\t// Another window replaced or removed the observed account, or logged it out, while this grant was obtained.\n\t\t\tif (\n\t\t\t\t(old !== null || observed !== null) &&\n\t\t\t\t(!sameReference(old?.reference, observed) || this.tombstoned(old!.reference))\n\t\t\t)\n\t\t\t\tthrow new Error(\"HUMAIN Code account changed. Sign in again.\");\n\t\t\tassertLock();\n\t\t\tthis.atomic(`${generation}.enc`, this.encrypt(next, parseGrant(result.grant), key));\n\t\t\tthis.atomic(\"replacement.json\", JSON.stringify({ previous: old, candidate: next }), () => {\n\t\t\t\tjournaled = true;\n\t\t\t});\n\t\t\tconst published: State = {\n\t\t\t\t...state,\n\t\t\t\tcurrent: next,\n\t\t\t\tintents: state.intents.filter((id) => id !== generation),\n\t\t\t};\n\t\t\tthis.saveState(published);\n\t\t\t// Publication is the decision; its journal survives until retirement also finishes.\n\t\t\tawait publish?.(reference);\n\t\t\tObject.assign(state, published);\n\t\t\ttry {\n\t\t\t\tawait this.finishReplacement(state, assertLock, undefined, retireBound);\n\t\t\t} catch {\n\t\t\t\t// Never revoke or roll back a published candidate because later cleanup failed.\n\t\t\t\tthis.cleanupIncomplete = true;\n\t\t\t}\n\t\t\tif (!sameReference(state.current?.reference, reference))\n\t\t\t\tthrow new Error(\"HUMAIN Code account reference changed. Sign in again.\");\n\t\t\treturn reference;\n\t\t} catch (error) {\n\t\t\tif (journaled) {\n\t\t\t\tawait this.finishReplacement(state, assertLock, undefined, retireBound);\n\t\t\t\t// A write-then-reject publisher whose CAS compensation failed may still have committed.\n\t\t\t\tif (state.current?.reference.generation === generation) return state.current.reference;\n\t\t\t} else {\n\t\t\t\tif (retire) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait retire(result.grant);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t/* Local cleanup must still run. */\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait this.cleanup(state);\n\t\t\t}\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tkey?.fill(0);\n\t\t}\n\t}\n\n\t/**\n\t * Uses a grant only while its captured binding/generation remains current. An uncertain rotation retains the\n\t * grant for retirement or replacement, but fences refresh replay across windows and restarts.\n\t */\n\tasync use<T>(\n\t\texpected: HcodeAccountRef,\n\t\tbinding: HcodeBinding,\n\t\tsend: (grant: HcodeGrant) => Promise<T>,\n\t\trefresh?: HcodeRefresh,\n\t\tsignal?: AbortSignal,\n\t): Promise<T> {\n\t\tthis.validateReference(expected);\n\t\tthis.assertEnvironment(binding.environmentId);\n\t\tconst dispatched = await this.locked(\n\t\t\tasync (state, assertLock) => {\n\t\t\t\tconst current = this.requireCurrent(state, expected, binding);\n\t\t\t\tlet grant = await this.decrypt(current, undefined, signal);\n\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\tassertLock();\n\t\t\t\tif (refresh && (grant.pendingVerification || grant.expiresAt <= Date.now() + 30000)) {\n\t\t\t\t\t// Resolve cancellable OS work before the refresh request; the request itself is never cancelled here.\n\t\t\t\t\tconst key = await this.key(current.reference.generation, signal);\n\t\t\t\t\tlet outcome: HcodeRefreshOutcome;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\t\t\tassertLock();\n\t\t\t\t\t\tthis.requireCurrent(state, expected, binding);\n\t\t\t\t\t\toutcome = await refresh(\n\t\t\t\t\t\t\tgrant,\n\t\t\t\t\t\t\t(next) => {\n\t\t\t\t\t\t\t\tconst rotating = state.rotation === expected.generation;\n\t\t\t\t\t\t\t\tlet staged = false;\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tassertLock();\n\t\t\t\t\t\t\t\t\tconst parsed = parseRefreshGrant(next);\n\t\t\t\t\t\t\t\t\tconst envelope = this.encrypt(current, parsed, key);\n\t\t\t\t\t\t\t\t\tif (rotating)\n\t\t\t\t\t\t\t\t\t\tthis.atomic(`${expected.generation}.rotation`, envelope, () => {\n\t\t\t\t\t\t\t\t\t\t\tstaged = true;\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tthis.atomic(`${expected.generation}.enc`, envelope);\n\t\t\t\t\t\t\t\t\tif (rotating) {\n\t\t\t\t\t\t\t\t\t\tstate.rotation = null;\n\t\t\t\t\t\t\t\t\t\tthis.saveState(state);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tgrant = parsed;\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\tif (rotating && !staged) throw new HcodeUncommittedRotationError(STORAGE_ERROR);\n\t\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(inFlight) => {\n\t\t\t\t\t\t\t\tassertLock();\n\t\t\t\t\t\t\t\tif (inFlight && state.rotation !== null) throw new HcodeUncertainRotationError();\n\t\t\t\t\t\t\t\tstate.rotation = inFlight ? expected.generation : null;\n\t\t\t\t\t\t\t\tthis.saveState(state);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tkey.fill(0);\n\t\t\t\t\t}\n\t\t\t\t\tif (outcome === \"rejected\") {\n\t\t\t\t\t\tassertLock();\n\t\t\t\t\t\tstate.current = null;\n\t\t\t\t\t\tstate.rotation = null;\n\t\t\t\t\t\tthis.saveState(state);\n\t\t\t\t\t\tawait this.cleanup(state);\n\t\t\t\t\t\tthrow new Error(\"HUMAIN Code sign-in expired. Sign in again.\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (grant.pendingVerification) throw new Error(\"HUMAIN Code account verification is pending.\");\n\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\tassertLock();\n\t\t\t\tthis.requireCurrent(state, expected, binding);\n\t\t\t\tconst response = send(grant);\n\t\t\t\t// Rejection can precede asynchronous lock release; await the response only after release.\n\t\t\t\tvoid response.catch(() => {});\n\t\t\t\treturn { response };\n\t\t\t},\n\t\t\t\"use\",\n\t\t\tsignal,\n\t\t);\n\t\treturn dispatched.response;\n\t}\n\n\t/** Persists logout before waiting for a refresh lock; stale logout affects only its observed generation. */\n\ttombstone(expected: HcodeAccountRef): void {\n\t\tthis.validateReference(expected);\n\t\tthis.guardParents(false);\n\t\t// Exclusive empty markers need no temporary file that a concurrent recovery could collect.\n\t\tconst name = `${expected.generation}.logout`;\n\t\tlet fd: number;\n\t\ttry {\n\t\t\tfd = openSync(join(this.dir, name), constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL, 0o600);\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && \"code\" in error && error.code === \"EEXIST\") {\n\t\t\t\tthis.read(name, 64);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t}\n\t\ttry {\n\t\t\tfsyncSync(fd);\n\t\t} finally {\n\t\t\tcloseSync(fd);\n\t\t}\n\t\tthis.syncDirectory();\n\t}\n\n\t/** Removes local state offline even when revocation fails. The callback must not retain the grant. */\n\tasync remove(\n\t\texpected: HcodeAccountRef,\n\t\tbinding: HcodeBinding | undefined,\n\t\trevoke: (grant: HcodeGrant) => Promise<void>,\n\t): Promise<void> {\n\t\tif (binding) this.assertEnvironment(binding.environmentId);\n\t\tthis.tombstone(expected);\n\t\tawait this.locked(async (state, assertLock) => {\n\t\t\tif (sameReference(state.current?.reference, expected)) {\n\t\t\t\tconst current = state.current!;\n\t\t\t\ttry {\n\t\t\t\t\tif (binding && sameBinding(current, binding))\n\t\t\t\t\t\tawait revoke(await this.grantForRetirement(state, current));\n\t\t\t\t} catch {\n\t\t\t\t\t/* Removal is independent of remote availability. */\n\t\t\t\t}\n\t\t\t\tassertLock();\n\t\t\t\tstate.current = null;\n\t\t\t\tstate.rotation = null;\n\t\t\t\tthis.saveState(state);\n\t\t\t}\n\t\t\tawait this.cleanup(state);\n\t\t}, \"logout\");\n\t}\n\n\tprivate grantForRetirement(state: State, account: StoredAccount, signal?: AbortSignal): Promise<HcodeGrant> {\n\t\tconst generation = account.reference.generation;\n\t\tconst staged = `${generation}.rotation`;\n\t\treturn this.decrypt(\n\t\t\taccount,\n\t\t\tstate.rotation === generation && this.read(staged, MAX_ENVELOPE) !== undefined ? staged : undefined,\n\t\t\tsignal,\n\t\t);\n\t}\n\n\tprivate requireCurrent(state: State, expected: HcodeAccountRef, binding: HcodeBinding): StoredAccount {\n\t\tthis.validateReference(expected);\n\t\tconst current = state.current;\n\t\tif (\n\t\t\t!current ||\n\t\t\t!sameReference(current.reference, expected) ||\n\t\t\t!sameBinding(current, binding) ||\n\t\t\tthis.tombstoned(expected)\n\t\t)\n\t\t\tthrow new Error(\"HUMAIN Code account changed. Sign in again.\");\n\t\treturn current;\n\t}\n\tprivate assertEnvironment(environmentId: string): void {\n\t\t// Private storage input must never select another environment namespace.\n\t\tif (environmentId !== this.environment.id) throw new Error(\"HUMAIN Code account environment changed.\");\n\t}\n\tprivate validateReference(ref: HcodeAccountRef): void {\n\t\tthis.assertEnvironment(ref.environmentId);\n\t\twire.string(ref.environmentId);\n\t\twire.string(ref.accountId);\n\t\tuuid(ref.generation);\n\t}\n\tprivate tombstoned(ref: HcodeAccountRef): boolean {\n\t\treturn this.read(`${uuid(ref.generation)}.logout`, 64) !== undefined;\n\t}\n\tprivate keyStore(): OsSecretStore {\n\t\tthis.secrets ??= createOsSecretStore({ service: \"humain-code-account-keys\", label: \"HUMAIN Code account keys\" });\n\t\treturn this.secrets;\n\t}\n\tprivate async key(generation: string, signal?: AbortSignal): Promise<Buffer> {\n\t\tsignal?.throwIfAborted();\n\t\tconst value = await this.keyStore().get(`${this.environment.id}:${uuid(generation)}`, signal);\n\t\tsignal?.throwIfAborted();\n\t\tif (!value || !/^[A-Za-z0-9+/]{43}=$/.test(value)) throw new Error(STORAGE_ERROR);\n\t\tconst bytes = Buffer.from(value, \"base64\");\n\t\tif (bytes.length !== 32 || bytes.toString(\"base64\") !== value) throw new Error(STORAGE_ERROR);\n\t\treturn bytes;\n\t}\n\tprivate aad(account: StoredAccount): Buffer {\n\t\treturn Buffer.from(\n\t\t\tJSON.stringify([\n\t\t\t\t1,\n\t\t\t\taccount.environmentId,\n\t\t\t\taccount.issuer,\n\t\t\t\taccount.clientId,\n\t\t\t\taccount.reference.accountId,\n\t\t\t\taccount.reference.generation,\n\t\t\t]),\n\t\t);\n\t}\n\tprivate encrypt(account: StoredAccount, grant: HcodeRefreshGrant, key: Buffer): string {\n\t\tconst nonce = randomBytes(12);\n\t\tconst cipher = createCipheriv(\"aes-256-gcm\", key, nonce);\n\t\tcipher.setAAD(this.aad(account));\n\t\tconst ciphertext = Buffer.concat([cipher.update(JSON.stringify(grant)), cipher.final()]);\n\t\treturn JSON.stringify({\n\t\t\tversion: 1,\n\t\t\tkeyId: account.reference.generation,\n\t\t\tnonce: nonce.toString(\"base64\"),\n\t\t\tciphertext: ciphertext.toString(\"base64\"),\n\t\t\ttag: cipher.getAuthTag().toString(\"base64\"),\n\t\t});\n\t}\n\tprivate async decrypt(\n\t\taccount: StoredAccount,\n\t\tfile = `${account.reference.generation}.enc`,\n\t\tsignal?: AbortSignal,\n\t): Promise<HcodeRefreshGrant> {\n\t\ttry {\n\t\t\tconst envelope = wire.object(JSON.parse(this.read(file, MAX_ENVELOPE) ?? \"null\"), [\n\t\t\t\t\"version\",\n\t\t\t\t\"keyId\",\n\t\t\t\t\"nonce\",\n\t\t\t\t\"ciphertext\",\n\t\t\t\t\"tag\",\n\t\t\t]);\n\t\t\twire.literal(envelope.version, 1);\n\t\t\twire.literal(envelope.keyId, account.reference.generation);\n\t\t\tconst nonce = base64(envelope.nonce, 12),\n\t\t\t\ttag = base64(envelope.tag, 16),\n\t\t\t\tciphertext = base64(envelope.ciphertext);\n\t\t\tconst key = await this.key(account.reference.generation, signal);\n\t\t\ttry {\n\t\t\t\tconst decipher = createDecipheriv(\"aes-256-gcm\", key, nonce);\n\t\t\t\tdecipher.setAAD(this.aad(account));\n\t\t\t\tdecipher.setAuthTag(tag);\n\t\t\t\treturn parseRefreshGrant(\n\t\t\t\t\tJSON.parse(Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString(\"utf8\")),\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\tkey.fill(0);\n\t\t\t}\n\t\t} catch {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t}\n\t}\n\tprivate readState(): State {\n\t\tconst text = this.read(\"state.json\", 16384);\n\t\tif (text === undefined) return { version: 1, current: null, intents: [], rotation: null };\n\t\tconst v = wire.object(JSON.parse(text), [\"version\", \"current\", \"intents\", \"rotation\"]);\n\t\tconst current = v.current === null ? null : this.parseStored(v.current);\n\t\treturn {\n\t\t\tversion: wire.literal(v.version, 1),\n\t\t\tcurrent,\n\t\t\tintents: wire.array(v.intents, uuid, 16),\n\t\t\trotation: v.rotation === null ? null : uuid(v.rotation),\n\t\t};\n\t}\n\tprivate parseStored(value: unknown): StoredAccount {\n\t\tconst account = parseStored(value);\n\t\tthis.assertEnvironment(account.environmentId);\n\t\treturn account;\n\t}\n\tprivate saveState(state: State): void {\n\t\tthis.atomic(\"state.json\", JSON.stringify(state));\n\t}\n\tprivate async locked<T>(\n\t\toperation: (state: State, assertLock: () => void) => Promise<T>,\n\t\tintent: \"use\" | \"logout\" | \"recover\" = \"use\",\n\t\tsignal?: AbortSignal,\n\t\tretire = this.publication?.retire,\n\t): Promise<T> {\n\t\tsignal?.throwIfAborted();\n\t\tthis.guardParents(true);\n\t\tfor (const path of [dirname(dirname(this.dir)), dirname(this.dir), this.dir]) await this.acl(path, signal);\n\t\tfor (const name of readdirSync(this.dir)) await this.acl(join(this.dir, name), signal);\n\t\tlet compromised = false;\n\t\tlet release: () => Promise<void>;\n\t\t// About 30 s: another window's refresh holds the lock for up to two 10 s requests plus revocation.\n\t\tconst attempts = 300;\n\t\tfor (let attempt = 0; ; attempt++) {\n\t\t\tsignal?.throwIfAborted();\n\t\t\ttry {\n\t\t\t\trelease = await lockfile.lock(this.dir, {\n\t\t\t\t\trealpath: true,\n\t\t\t\t\t// proper-lockfile's internal retry timers have no cancellation API.\n\t\t\t\t\tretries: signal ? 0 : { retries: attempts, minTimeout: 20, maxTimeout: 100 },\n\t\t\t\t\tonCompromised: () => {\n\t\t\t\t\t\tcompromised = true;\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t} catch (error) {\n\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\tif (!signal || attempt >= attempts) throw error;\n\t\t\t\tawait delay(Math.min(20 * 2 ** attempt, 100), undefined, { signal });\n\t\t\t}\n\t\t}\n\t\tconst assertLock = () => {\n\t\t\tif (compromised) throw new Error(STORAGE_ERROR);\n\t\t\tthis.guardParents(false);\n\t\t};\n\t\ttry {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tassertLock();\n\t\t\tconst state = this.readState();\n\t\t\tawait this.finishReplacement(state, assertLock, signal);\n\t\t\tconst current = state.current;\n\t\t\tif (current && this.tombstoned(current.reference)) {\n\t\t\t\t// Normal readers must leave revocable material for serialized logout, not perform crash collection.\n\t\t\t\tif (intent === \"use\") throw new Error(\"HUMAIN Code account changed. Sign in again.\");\n\t\t\t\tif (intent === \"recover\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Recovery may acquire the lock ahead of the window that wrote the tombstone.\n\t\t\t\t\t\tif (retire) await retire(current, await this.grantForRetirement(state, current));\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t/* Logout remains effective offline. */\n\t\t\t\t\t}\n\t\t\t\t\tassertLock();\n\t\t\t\t\tstate.current = null;\n\t\t\t\t\tstate.rotation = null;\n\t\t\t\t\tthis.saveState(state);\n\t\t\t\t}\n\t\t\t} else if (state.rotation !== null) {\n\t\t\t\tconst staged = `${state.rotation}.rotation`;\n\t\t\t\tconst envelope =\n\t\t\t\t\tcurrent?.reference.generation === state.rotation ? this.read(staged, MAX_ENVELOPE) : undefined;\n\t\t\t\tif (envelope !== undefined && current) {\n\t\t\t\t\tawait this.decrypt(current, staged, signal);\n\t\t\t\t\tassertLock();\n\t\t\t\t\tthis.atomic(`${state.rotation}.enc`, envelope);\n\t\t\t\t}\n\t\t\t\tif (envelope !== undefined || current?.reference.generation !== state.rotation) {\n\t\t\t\t\tstate.rotation = null;\n\t\t\t\t\tthis.saveState(state);\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait this.cleanup(state, signal);\n\t\t\tsignal?.throwIfAborted();\n\t\t\tassertLock();\n\t\t\treturn await operation(state, assertLock);\n\t\t} finally {\n\t\t\tawait release();\n\t\t}\n\t}\n\tprivate parseReplacement(text: string): Replacement {\n\t\tconst journal = wire.object(JSON.parse(text), [\"previous\", \"candidate\"]);\n\t\tconst previous = journal.previous === null ? null : this.parseStored(journal.previous);\n\t\tconst candidate = this.parseStored(journal.candidate);\n\t\t// Private journal input cannot retire the same generation it selects as survivor.\n\t\tif (previous?.reference.generation === candidate.reference.generation) return wire.invalid();\n\t\treturn { previous, candidate };\n\t}\n\tprivate async finishReplacement(\n\t\tstate: State,\n\t\tassertLock: () => void,\n\t\tsignal?: AbortSignal,\n\t\tretire = this.publication?.retire,\n\t): Promise<void> {\n\t\tconst text = this.read(\"replacement.json\", 16384);\n\t\tif (text === undefined) return;\n\t\tconst { previous, candidate } = this.parseReplacement(text);\n\t\tconst published = this.publication ? await this.publication.read(signal) : (state.current?.reference ?? null);\n\t\tsignal?.throwIfAborted();\n\t\tassertLock();\n\t\tconst forward = sameReference(published, candidate.reference);\n\t\tlet current = forward ? candidate : previous;\n\t\tif (\n\t\t\t!forward &&\n\t\t\tcurrent &&\n\t\t\t(this.read(`${current.reference.generation}.enc`, MAX_ENVELOPE) === undefined ||\n\t\t\t\t(await this.keyStore().get(`${this.environment.id}:${current.reference.generation}`, signal)) === undefined)\n\t\t) {\n\t\t\tcurrent = null;\n\t\t}\n\t\tstate.current = current;\n\t\tthis.saveState(state);\n\t\tif (!forward && previous !== null && current === null) await this.publication?.clear(published, signal);\n\t\tconst discarded = forward ? previous : candidate;\n\t\tif (discarded && retire) {\n\t\t\ttry {\n\t\t\t\tawait retire(discarded, await this.grantForRetirement(state, discarded, signal));\n\t\t\t} catch {\n\t\t\t\t/* Missing retired material or unavailable revocation must not prevent local cleanup. */\n\t\t\t}\n\t\t}\n\t\tsignal?.throwIfAborted();\n\t\tassertLock();\n\t\tif (state.rotation !== null && state.rotation !== current?.reference.generation) {\n\t\t\tstate.rotation = null;\n\t\t\tthis.saveState(state);\n\t\t}\n\t\tawait this.cleanup(state, signal);\n\t\tassertLock();\n\t\tthis.removeFile(\"replacement.json\");\n\t}\n\tprivate async cleanup(state: State, signal?: AbortSignal): Promise<void> {\n\t\tsignal?.throwIfAborted();\n\t\tconst current = state.current?.reference.generation;\n\t\tconst orphans = new Set(state.intents.filter((id) => id !== current));\n\t\tfor (const file of readdirSync(this.dir)) {\n\t\t\tconst match = /^([0-9a-f-]+)\\.(enc|rotation|logout)$/.exec(file);\n\t\t\tif (match && UUID.test(match[1]!) && match[1] !== current) orphans.add(match[1]!);\n\t\t\tif (/^[0-9a-f-]+\\.tmp$/.test(file)) this.removeFile(file);\n\t\t}\n\t\tfor (const id of orphans) {\n\t\t\tawait this.keyStore().delete(`${this.environment.id}:${id}`, signal);\n\t\t\tsignal?.throwIfAborted();\n\t\t\tfor (const suffix of [\"enc\", \"rotation\", \"logout\"]) this.removeFile(`${id}.${suffix}`);\n\t\t}\n\t\tif (state.intents.length) {\n\t\t\tstate.intents = [];\n\t\t\tthis.saveState(state);\n\t\t}\n\t\t// A staged envelope is needed only until the matching rotation marker has cleared.\n\t\tif (current && current !== state.rotation) this.removeFile(`${current}.rotation`);\n\t}\n\tprivate guardParents(create: boolean, allowMissing = false): void {\n\t\tconst paths: string[] = [];\n\t\tfor (let path = this.dir; ; path = dirname(path)) {\n\t\t\tpaths.unshift(path);\n\t\t\tif (dirname(path) === path) break;\n\t\t}\n\t\tfor (const path of paths) {\n\t\t\tif (!existsSync(path) && allowMissing) {\n\t\t\t\ttry {\n\t\t\t\t\tlstatSync(path);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (isMissing(error)) return;\n\t\t\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!existsSync(path) && create) {\n\t\t\t\tmkdirSync(path, { mode: 0o700 });\n\t\t\t\tthis.syncDirectory(dirname(path));\n\t\t\t\tthis.createdDirectories.add(path);\n\t\t\t}\n\t\t\tlet stat: ReturnType<typeof lstatSync>;\n\t\t\ttry {\n\t\t\t\tstat = lstatSync(path);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t\t}\n\t\t\tif (!stat.isDirectory() || stat.isSymbolicLink()) throw new Error(STORAGE_ERROR);\n\t\t\tif (\n\t\t\t\t(path === this.dir || path === dirname(this.dir) || path === dirname(dirname(this.dir))) &&\n\t\t\t\tthis.platform !== \"win32\" &&\n\t\t\t\t((stat.mode & 0o777) !== 0o700 || stat.uid !== process.getuid?.())\n\t\t\t)\n\t\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t}\n\t}\n\tprivate read(name: string, max: number): string | undefined {\n\t\tconst path = join(this.dir, name);\n\t\ttry {\n\t\t\tif (lstatSync(path).isSymbolicLink()) throw new Error(STORAGE_ERROR);\n\t\t} catch (error) {\n\t\t\tif (isMissing(error)) return undefined;\n\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t}\n\t\tlet fd: number;\n\t\ttry {\n\t\t\tfd = openSync(\n\t\t\t\tjoin(this.dir, name),\n\t\t\t\tconstants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tif (isMissing(error)) return undefined;\n\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t}\n\t\ttry {\n\t\t\tconst stat = fstatSync(fd);\n\t\t\tif (\n\t\t\t\t!stat.isFile() ||\n\t\t\t\tstat.nlink !== 1 ||\n\t\t\t\tstat.size > max ||\n\t\t\t\t(this.platform !== \"win32\" && ((stat.mode & 0o777) !== 0o600 || stat.uid !== process.getuid?.()))\n\t\t\t)\n\t\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t\treturn readFileSync(fd, \"utf8\");\n\t\t} finally {\n\t\t\tcloseSync(fd);\n\t\t}\n\t}\n\tprivate atomic(name: string, text: string, renamed?: () => void): void {\n\t\tthis.guardParents(false);\n\t\t// Validate an existing destination rather than following or replacing a hostile link.\n\t\tthis.read(name, MAX_ENVELOPE);\n\t\tconst temp = join(this.dir, `${randomUUID()}.tmp`);\n\t\tconst fd = openSync(temp, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL, 0o600);\n\t\ttry {\n\t\t\twriteFileSync(fd, text);\n\t\t\tfsyncSync(fd);\n\t\t} finally {\n\t\t\tcloseSync(fd);\n\t\t}\n\t\trenameSync(temp, join(this.dir, name));\n\t\trenamed?.();\n\t\tthis.syncDirectory();\n\t}\n\tprivate removeFile(name: string): void {\n\t\tthis.read(name, MAX_ENVELOPE);\n\t\ttry {\n\t\t\tunlinkSync(join(this.dir, name));\n\t\t} catch (error) {\n\t\t\tif (!isMissing(error)) throw new Error(STORAGE_ERROR);\n\t\t}\n\t\tthis.syncDirectory();\n\t}\n\tprivate syncDirectory(path = this.dir): void {\n\t\tif (this.platform === \"win32\") return;\n\t\tconst fd = openSync(path, constants.O_RDONLY);\n\t\ttry {\n\t\t\tfsyncSync(fd);\n\t\t} finally {\n\t\t\tcloseSync(fd);\n\t\t}\n\t}\n\tprivate async acl(path: string, signal?: AbortSignal): Promise<void> {\n\t\tsignal?.throwIfAborted();\n\t\tif (this.platform !== \"win32\") return;\n\t\t// Windows filesystem input: protected DACL, owner and every allow ACE must be this user only.\n\t\ttry {\n\t\t\tawait assertPrivateWindowsPath(\n\t\t\t\tpath,\n\t\t\t\tthis.createdDirectories.has(path) ? \"create\" : \"verify\",\n\t\t\t\tthis.runner,\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tthis.createdDirectories.delete(path);\n\t\t} catch {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t}\n\t}\n}\n\n/** Compares non-secret references without adopting another environment, account or generation. */\nexport function sameReference(a: HcodeAccountRef | null | undefined, b: HcodeAccountRef | null | undefined): boolean {\n\treturn (\n\t\t!!a && !!b && a.environmentId === b.environmentId && a.accountId === b.accountId && a.generation === b.generation\n\t);\n}\nfunction sameBinding(a: HcodeBinding, b: HcodeBinding): boolean {\n\treturn a.environmentId === b.environmentId && a.issuer === b.issuer && a.clientId === b.clientId;\n}\nfunction uuid(value: unknown): string {\n\tconst text = wire.string(value, 36);\n\tif (!UUID.test(text)) return wire.invalid();\n\treturn text;\n}\nfunction base64(value: unknown, size?: number): Buffer {\n\tconst text = wire.string(value, MAX_ENVELOPE);\n\tconst bytes = Buffer.from(text, \"base64\");\n\tif (bytes.toString(\"base64\") !== text || (size !== undefined && bytes.length !== size) || bytes.length > MAX_GRANT)\n\t\treturn wire.invalid();\n\treturn bytes;\n}\nfunction parseStored(value: unknown): StoredAccount {\n\tconst v = wire.object(value, [\"environmentId\", \"issuer\", \"clientId\", \"reference\"]),\n\t\tref = wire.object(v.reference, [\"environmentId\", \"accountId\", \"generation\"]);\n\tconst environmentId = wire.string(v.environmentId);\n\tif (ref.environmentId !== environmentId) return wire.invalid();\n\treturn {\n\t\tenvironmentId,\n\t\tissuer: wire.https(v.issuer),\n\t\tclientId: wire.string(v.clientId),\n\t\treference: { environmentId, accountId: wire.string(ref.accountId), generation: uuid(ref.generation) },\n\t};\n}\n/** Validates untrusted token data before encryption or private send. */\nexport function parseGrant(value: unknown): HcodeGrant {\n\tif (wire.jsonBytes(value) > MAX_GRANT) return wire.invalid();\n\tconst v = wire.object(value, [\"accessToken\", \"refreshToken\", \"expiresAt\"]);\n\tconst accessToken = wire.string(v.accessToken, MAX_GRANT),\n\t\trefreshToken = wire.string(v.refreshToken, MAX_GRANT);\n\tif (/[^\\x21-\\x7e]/.test(accessToken) || /[\\p{Cc}]/u.test(refreshToken)) return wire.invalid();\n\treturn { accessToken, refreshToken, expiresAt: wire.integer(v.expiresAt) };\n}\nfunction parseRefreshGrant(value: unknown): HcodeRefreshGrant {\n\tconst { pendingVerification, ...tokens } = wire.object(value, [\n\t\t\"accessToken\",\n\t\t\"refreshToken\",\n\t\t\"expiresAt\",\n\t\t\"pendingVerification\",\n\t]);\n\tconst grant = parseGrant(tokens);\n\t// Keep the flag in the authenticated envelope so a crash cannot separate it from the rotated grant.\n\treturn pendingVerification === undefined\n\t\t? grant\n\t\t: { ...grant, pendingVerification: wire.literal(pendingVerification, true) };\n}\nfunction isMissing(error: unknown): boolean {\n\treturn error instanceof Error && \"code\" in error && error.code === \"ENOENT\";\n}\n"]}
|
|
1
|
+
{"version":3,"file":"account-store.js","sourceRoot":"","sources":["../../../src/humain/hcode/account-store.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EACN,SAAS,EACT,SAAS,EACT,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,UAAU,EACV,UAAU,EACV,aAAa,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAsB,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAsB,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC/F,OAAO,EAAoD,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC7G,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAkClC,0FAA0F;AAC1F,MAAM,OAAO,6BAA8B,SAAQ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CAAC,CAAC,CAAC,WAAW,EAAE,SAAS,CAAC,EACxD,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IACvD,IAAI,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC;QAAE,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IAC9F,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC;AAC5E,CAAC;AACD,SAAS,iBAAiB,CAAC,KAAc;IACxC,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;QAC7D,aAAa;QACb,cAAc;QACd,WAAW;QACX,qBAAqB;KACrB,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACjC,oGAAoG;IACpG,OAAO,mBAAmB,KAAK,SAAS;QACvC,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,mBAAmB,EAAE,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC,EAAE,CAAC;AAC/E,CAAC;AACD,SAAS,SAAS,CAAC,KAAc;IAChC,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC7E,CAAC","sourcesContent":["// Encrypted, generation-fenced native grants. No token is written to generic auth storage.\nimport { createCipheriv, createDecipheriv, randomBytes, randomUUID } from \"node:crypto\";\nimport {\n\tcloseSync,\n\tconstants,\n\texistsSync,\n\tfstatSync,\n\tfsyncSync,\n\tlstatSync,\n\tmkdirSync,\n\topenSync,\n\treaddirSync,\n\treadFileSync,\n\trenameSync,\n\tunlinkSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport { dirname, isAbsolute, join, relative, resolve, sep } from \"node:path\";\nimport { setTimeout as delay } from \"node:timers/promises\";\nimport lockfile from \"proper-lockfile\";\nimport { getAgentDir } from \"../../config.ts\";\nimport { createOsSecretStore, type OsSecretStore } from \"../../core/os-secret-store.ts\";\nimport { assertPrivateWindowsPath } from \"../../core/private-windows-path.ts\";\nimport { SafeCredentialError } from \"../../core/safe-credential-error.ts\";\nimport { type CommandRunner, spawnCommand } from \"../../core/trace-client/credential-store.ts\";\nimport { type HcodeEnvironment, type HcodeEnvironmentName, resolveHcodeEnvironment } from \"./environment.ts\";\nimport { HCODE_LOGIN_FAILURES } from \"./login-failure.ts\";\nimport type { HcodeAccountRef } from \"./ports.ts\";\nimport * as wire from \"./wire.ts\";\n\nexport interface HcodeGrant {\n\taccessToken: string;\n\trefreshToken: string;\n\texpiresAt: number;\n}\nexport interface HcodeBinding {\n\tenvironmentId: string;\n\tissuer: string;\n\tclientId: string;\n}\ninterface StoredAccount extends HcodeBinding {\n\treference: HcodeAccountRef;\n}\ninterface State {\n\tversion: 1;\n\tcurrent: StoredAccount | null;\n\tintents: string[];\n\t// A refresh was dispatched or is about to be. Without a staged grant, the old token must not be replayed.\n\trotation: string | null;\n}\n/** A refresh can persist rotated tokens before the account has been checked. */\nexport interface HcodeRefreshGrant extends HcodeGrant {\n\tpendingVerification?: true;\n}\n/** Refresh outcome: the saved grant can be used, or the account was rejected. */\nexport type HcodeRefreshOutcome = \"rotated\" | \"rejected\";\n/** Rotates or revalidates a grant. Throwing keeps the last saved grant; only \"rejected\" removes the account. */\nexport type HcodeRefresh = (\n\tgrant: HcodeRefreshGrant,\n\tsave: (next: HcodeRefreshGrant) => void,\n\tmarkRotation: (inFlight: boolean) => void,\n) => Promise<HcodeRefreshOutcome>;\n/** The replacement envelope definitely never became visible; its token may be retired. */\nexport class HcodeUncommittedRotationError extends Error {}\n/** A refresh may have consumed the retained token; the user must replace the grant rather than retry it. */\nexport class HcodeUncertainRotationError extends Error {\n\tconstructor() {\n\t\tsuper(\"HUMAIN Code sign-in renewal could not be confirmed. Sign in again.\");\n\t}\n}\n/** Trusted host publication and bounded, issuer-fenced retirement, used only under the account lock. */\nexport interface HcodeAccountPublication {\n\tread(signal?: AbortSignal): Promise<HcodeAccountRef | null>;\n\tclear(expected: HcodeAccountRef | null, signal?: AbortSignal): Promise<void>;\n\tretire?(binding: HcodeBinding, grant: HcodeGrant): Promise<void>;\n}\ninterface Replacement {\n\tprevious: StoredAccount | null;\n\tcandidate: StoredAccount;\n}\nexport interface HcodeAccountStoreOptions {\n\tenvironment?: HcodeEnvironmentName;\n\tagentDir?: string;\n\tsecrets?: OsSecretStore;\n\tpublication?: HcodeAccountPublication;\n\tplatform?: NodeJS.Platform;\n\trun?: CommandRunner;\n}\nconst UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;\nconst MAX_GRANT = 1048576;\nconst MAX_ENVELOPE = 1400000;\nconst STORAGE_ERROR = \"HUMAIN Code secure storage failed. Sign in again after checking private storage access.\";\n\n/** Owns encrypted grants and cross-process serialization for one built-in environment. */\nexport class HcodeAccountStore {\n\tprivate readonly dir: string;\n\tprivate readonly environment: HcodeEnvironment;\n\tprivate readonly platform: NodeJS.Platform;\n\tprivate readonly runner: CommandRunner;\n\tprivate secrets: OsSecretStore | undefined;\n\tprivate publication: HcodeAccountPublication | undefined;\n\tprivate readonly createdDirectories = new Set<string>();\n\tcleanupIncomplete = false;\n\tconstructor(options: HcodeAccountStoreOptions = {}) {\n\t\tthis.environment = resolveHcodeEnvironment(options.environment);\n\t\tconst agentDir = resolve(options.agentDir ?? getAgentDir());\n\t\t// Config is global, never a project-controlled credential destination.\n\t\tfor (let path = agentDir; ; path = dirname(path)) {\n\t\t\tif (existsSync(join(path, \".git\"))) throw new SafeCredentialError(HCODE_LOGIN_FAILURES.gitStorage);\n\t\t\tif (dirname(path) === path) break;\n\t\t}\n\t\tconst fromCwd = relative(process.cwd(), agentDir);\n\t\tif (!fromCwd || (!fromCwd.startsWith(`..${sep}`) && !isAbsolute(fromCwd))) throw new Error(STORAGE_ERROR);\n\t\tthis.dir = join(agentDir, \"hcode\", \"accounts\", this.environment.id);\n\t\tthis.platform = options.platform ?? process.platform;\n\t\tthis.runner = options.run ?? spawnCommand;\n\t\tthis.secrets = options.secrets;\n\t\tthis.publication = options.publication;\n\t}\n\n\t/** Attaches the owning host's generic store without reading secrets or recovering at construction. */\n\tconfigurePublication(publication: HcodeAccountPublication | undefined): void {\n\t\tthis.publication = publication;\n\t}\n\n\t/** Checks only local replacement evidence, without creating files or touching OS secrets. */\n\thasPendingReplacement(): boolean {\n\t\tthis.guardParents(false, true);\n\t\treturn this.read(\"replacement.json\", 16384) !== undefined;\n\t}\n\n\t/** Recovers only an existing replacement; signed-out startup never creates storage or probes keys. */\n\tasync recoverPendingReplacement(signal?: AbortSignal): Promise<boolean> {\n\t\tsignal?.throwIfAborted();\n\t\tif (!this.hasPendingReplacement()) return false;\n\t\tawait this.locked(async () => {}, \"logout\", signal);\n\t\treturn true;\n\t}\n\n\t/** Reads only non-secret local metadata. Never creates files, probes a keyring or sends HTTP. */\n\tstatus(environmentId: string): HcodeAccountRef | null {\n\t\tif (environmentId !== this.environment.id) return null;\n\t\ttry {\n\t\t\tthis.guardParents(false);\n\t\t\tconst state = this.readState();\n\t\t\tconst ref = state.current?.reference;\n\t\t\treturn ref?.environmentId === environmentId && !this.tombstoned(ref) ? ref : null;\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/** Compares logout's observed generation independently of its durable logout marker. */\n\tisCurrent(expected: HcodeAccountRef): boolean {\n\t\tif (expected.environmentId !== this.environment.id) return false;\n\t\ttry {\n\t\t\tthis.guardParents(false);\n\t\t\treturn sameReference(this.readState().current?.reference, expected);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/** Checks existing private state and purpose-key availability without creating or recovering account files. */\n\tasync prepare(signal: AbortSignal): Promise<void> {\n\t\tsignal.throwIfAborted();\n\t\tthis.guardParents(false, true);\n\t\tconst state = this.readState();\n\t\tif (existsSync(this.dir)) {\n\t\t\tfor (const name of readdirSync(this.dir)) {\n\t\t\t\tawait this.acl(join(this.dir, name), signal);\n\t\t\t\tconst text = this.read(name, MAX_ENVELOPE);\n\t\t\t\tif (name.endsWith(\".enc\") || name.endsWith(\".rotation\")) {\n\t\t\t\t\tconst envelope = wire.object(JSON.parse(text!), [\"version\", \"keyId\", \"nonce\", \"ciphertext\", \"tag\"]);\n\t\t\t\t\twire.literal(envelope.version, 1);\n\t\t\t\t\tuuid(envelope.keyId);\n\t\t\t\t\tbase64(envelope.nonce, 12);\n\t\t\t\t\tbase64(envelope.tag, 16);\n\t\t\t\t\tbase64(envelope.ciphertext);\n\t\t\t\t} else if (name === \"replacement.json\") {\n\t\t\t\t\tthis.parseReplacement(text!);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const path of [dirname(dirname(this.dir)), dirname(this.dir), this.dir])\n\t\t\tif (existsSync(path)) await this.acl(path, signal);\n\t\tawait this.keyStore().probe(signal);\n\t\tif (state.current) await this.decrypt(state.current, undefined, signal);\n\t\tsignal.throwIfAborted();\n\t}\n\n\t/** Recovers durable intents, replacements and logout markers under the same lock used by every mutation. */\n\tasync recover(signal?: AbortSignal, retire?: HcodeAccountPublication[\"retire\"]): Promise<void> {\n\t\tawait this.locked(async () => {}, \"recover\", signal, retire);\n\t}\n\n\t/**\n\t * Probes the purpose-key store, obtains a grant without holding the account lock, then stores it under the lock\n\t * only if the account observed before `obtain` is still current. A failed replacement leaves the old grant intact.\n\t */\n\tasync replace(\n\t\tbinding: HcodeBinding,\n\t\tobtain: () => Promise<{ accountId: string; grant: HcodeGrant }>,\n\t\tretire?: (grant: HcodeGrant | null) => Promise<void>,\n\t\tpublish?: (reference: HcodeAccountRef) => Promise<void>,\n\t): Promise<HcodeAccountRef> {\n\t\tthis.assertEnvironment(binding.environmentId);\n\t\tawait this.keyStore().probe();\n\t\tconst observed = this.status(this.environment.id);\n\t\t// A device sign-in can wait minutes; other windows keep using the saved account meanwhile.\n\t\tconst result = await obtain();\n\t\tlet entered = false;\n\t\ttry {\n\t\t\treturn await this.locked(async (state, assertLock) => {\n\t\t\t\tentered = true;\n\t\t\t\treturn this.commit(binding, result, observed, state, assertLock, retire, publish);\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (!entered && retire) {\n\t\t\t\ttry {\n\t\t\t\t\tawait retire(result.grant);\n\t\t\t\t} catch {\n\t\t\t\t\t/* The lock failure is the reported error. */\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/** Stores an obtained grant as the new current account; runs under the account lock. */\n\tprivate async commit(\n\t\tbinding: HcodeBinding,\n\t\tresult: { accountId: string; grant: HcodeGrant },\n\t\tobserved: HcodeAccountRef | null,\n\t\tstate: State,\n\t\tassertLock: () => void,\n\t\tretire?: (grant: HcodeGrant | null) => Promise<void>,\n\t\tpublish?: (reference: HcodeAccountRef) => Promise<void>,\n\t): Promise<HcodeAccountRef> {\n\t\tconst generation = randomUUID();\n\t\tlet key: Buffer | undefined;\n\t\tlet journaled = false;\n\t\tconst retireBound = async (issued: HcodeBinding, grant: HcodeGrant) => {\n\t\t\tif (retire) await retire(sameBinding(issued, binding) ? grant : null);\n\t\t};\n\t\ttry {\n\t\t\tstate.intents.push(generation);\n\t\t\tthis.saveState(state);\n\t\t\tkey = randomBytes(32);\n\t\t\tawait this.keyStore().set(`${this.environment.id}:${generation}`, key.toString(\"base64\"));\n\t\t\tif ((await this.keyStore().get(`${this.environment.id}:${generation}`)) !== key.toString(\"base64\"))\n\t\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t\tconst reference = {\n\t\t\t\tenvironmentId: wire.string(binding.environmentId),\n\t\t\t\taccountId: wire.string(result.accountId),\n\t\t\t\tgeneration,\n\t\t\t};\n\t\t\tconst next: StoredAccount = {\n\t\t\t\tenvironmentId: binding.environmentId,\n\t\t\t\tissuer: binding.issuer,\n\t\t\t\tclientId: binding.clientId,\n\t\t\t\treference,\n\t\t\t};\n\t\t\tconst old = state.current;\n\t\t\t// Another window replaced or removed the observed account, or logged it out, while this grant was obtained.\n\t\t\tif (\n\t\t\t\t(old !== null || observed !== null) &&\n\t\t\t\t(!sameReference(old?.reference, observed) || this.tombstoned(old!.reference))\n\t\t\t)\n\t\t\t\tthrow new Error(\"HUMAIN Code account changed. Sign in again.\");\n\t\t\tassertLock();\n\t\t\tthis.atomic(`${generation}.enc`, this.encrypt(next, parseGrant(result.grant), key));\n\t\t\tthis.atomic(\"replacement.json\", JSON.stringify({ previous: old, candidate: next }), () => {\n\t\t\t\tjournaled = true;\n\t\t\t});\n\t\t\tconst published: State = {\n\t\t\t\t...state,\n\t\t\t\tcurrent: next,\n\t\t\t\tintents: state.intents.filter((id) => id !== generation),\n\t\t\t};\n\t\t\tthis.saveState(published);\n\t\t\t// Publication is the decision; its journal survives until retirement also finishes.\n\t\t\tawait publish?.(reference);\n\t\t\tObject.assign(state, published);\n\t\t\ttry {\n\t\t\t\tawait this.finishReplacement(state, assertLock, undefined, retireBound);\n\t\t\t} catch {\n\t\t\t\t// Never revoke or roll back a published candidate because later cleanup failed.\n\t\t\t\tthis.cleanupIncomplete = true;\n\t\t\t}\n\t\t\tif (!sameReference(state.current?.reference, reference))\n\t\t\t\tthrow new Error(\"HUMAIN Code account reference changed. Sign in again.\");\n\t\t\treturn reference;\n\t\t} catch (error) {\n\t\t\tif (journaled) {\n\t\t\t\tawait this.finishReplacement(state, assertLock, undefined, retireBound);\n\t\t\t\t// A write-then-reject publisher whose CAS compensation failed may still have committed.\n\t\t\t\tif (state.current?.reference.generation === generation) return state.current.reference;\n\t\t\t} else {\n\t\t\t\tif (retire) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait retire(result.grant);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t/* Local cleanup must still run. */\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait this.cleanup(state);\n\t\t\t}\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tkey?.fill(0);\n\t\t}\n\t}\n\n\t/**\n\t * Uses a grant only while its captured binding/generation remains current. An uncertain rotation retains the\n\t * grant for retirement or replacement, but fences refresh replay across windows and restarts.\n\t */\n\tasync use<T>(\n\t\texpected: HcodeAccountRef,\n\t\tbinding: HcodeBinding,\n\t\tsend: (grant: HcodeGrant) => Promise<T>,\n\t\trefresh?: HcodeRefresh,\n\t\tsignal?: AbortSignal,\n\t): Promise<T> {\n\t\tthis.validateReference(expected);\n\t\tthis.assertEnvironment(binding.environmentId);\n\t\tconst dispatched = await this.locked(\n\t\t\tasync (state, assertLock) => {\n\t\t\t\tconst current = this.requireCurrent(state, expected, binding);\n\t\t\t\tlet grant = await this.decrypt(current, undefined, signal);\n\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\tassertLock();\n\t\t\t\tif (refresh && (grant.pendingVerification || grant.expiresAt <= Date.now() + 30000)) {\n\t\t\t\t\t// Resolve cancellable OS work before the refresh request; the request itself is never cancelled here.\n\t\t\t\t\tconst key = await this.key(current.reference.generation, signal);\n\t\t\t\t\tlet outcome: HcodeRefreshOutcome;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\t\t\tassertLock();\n\t\t\t\t\t\tthis.requireCurrent(state, expected, binding);\n\t\t\t\t\t\toutcome = await refresh(\n\t\t\t\t\t\t\tgrant,\n\t\t\t\t\t\t\t(next) => {\n\t\t\t\t\t\t\t\tconst rotating = state.rotation === expected.generation;\n\t\t\t\t\t\t\t\tlet staged = false;\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tassertLock();\n\t\t\t\t\t\t\t\t\tconst parsed = parseRefreshGrant(next);\n\t\t\t\t\t\t\t\t\tconst envelope = this.encrypt(current, parsed, key);\n\t\t\t\t\t\t\t\t\tif (rotating)\n\t\t\t\t\t\t\t\t\t\tthis.atomic(`${expected.generation}.rotation`, envelope, () => {\n\t\t\t\t\t\t\t\t\t\t\tstaged = true;\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tthis.atomic(`${expected.generation}.enc`, envelope);\n\t\t\t\t\t\t\t\t\tif (rotating) {\n\t\t\t\t\t\t\t\t\t\tstate.rotation = null;\n\t\t\t\t\t\t\t\t\t\tthis.saveState(state);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tgrant = parsed;\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\tif (rotating && !staged) throw new HcodeUncommittedRotationError(STORAGE_ERROR);\n\t\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(inFlight) => {\n\t\t\t\t\t\t\t\tassertLock();\n\t\t\t\t\t\t\t\tif (inFlight && state.rotation !== null) throw new HcodeUncertainRotationError();\n\t\t\t\t\t\t\t\tstate.rotation = inFlight ? expected.generation : null;\n\t\t\t\t\t\t\t\tthis.saveState(state);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tkey.fill(0);\n\t\t\t\t\t}\n\t\t\t\t\tif (outcome === \"rejected\") {\n\t\t\t\t\t\tassertLock();\n\t\t\t\t\t\tstate.current = null;\n\t\t\t\t\t\tstate.rotation = null;\n\t\t\t\t\t\tthis.saveState(state);\n\t\t\t\t\t\tawait this.cleanup(state);\n\t\t\t\t\t\tthrow new Error(\"HUMAIN Code sign-in expired. Sign in again.\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (grant.pendingVerification) throw new Error(\"HUMAIN Code account verification is pending.\");\n\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\tassertLock();\n\t\t\t\tthis.requireCurrent(state, expected, binding);\n\t\t\t\tconst response = send(grant);\n\t\t\t\t// Rejection can precede asynchronous lock release; await the response only after release.\n\t\t\t\tvoid response.catch(() => {});\n\t\t\t\treturn { response };\n\t\t\t},\n\t\t\t\"use\",\n\t\t\tsignal,\n\t\t);\n\t\treturn dispatched.response;\n\t}\n\n\t/** Persists logout before waiting for a refresh lock; stale logout affects only its observed generation. */\n\ttombstone(expected: HcodeAccountRef): void {\n\t\tthis.validateReference(expected);\n\t\tthis.guardParents(false);\n\t\t// Exclusive empty markers need no temporary file that a concurrent recovery could collect.\n\t\tconst name = `${expected.generation}.logout`;\n\t\tlet fd: number;\n\t\ttry {\n\t\t\tfd = openSync(join(this.dir, name), constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL, 0o600);\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && \"code\" in error && error.code === \"EEXIST\") {\n\t\t\t\tthis.read(name, 64);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t}\n\t\ttry {\n\t\t\tfsyncSync(fd);\n\t\t} finally {\n\t\t\tcloseSync(fd);\n\t\t}\n\t\tthis.syncDirectory();\n\t}\n\n\t/** Removes local state offline even when revocation fails. The callback must not retain the grant. */\n\tasync remove(\n\t\texpected: HcodeAccountRef,\n\t\tbinding: HcodeBinding | undefined,\n\t\trevoke: (grant: HcodeGrant) => Promise<void>,\n\t): Promise<void> {\n\t\tif (binding) this.assertEnvironment(binding.environmentId);\n\t\tthis.tombstone(expected);\n\t\tawait this.locked(async (state, assertLock) => {\n\t\t\tif (sameReference(state.current?.reference, expected)) {\n\t\t\t\tconst current = state.current!;\n\t\t\t\ttry {\n\t\t\t\t\tif (binding && sameBinding(current, binding))\n\t\t\t\t\t\tawait revoke(await this.grantForRetirement(state, current));\n\t\t\t\t} catch {\n\t\t\t\t\t/* Removal is independent of remote availability. */\n\t\t\t\t}\n\t\t\t\tassertLock();\n\t\t\t\tstate.current = null;\n\t\t\t\tstate.rotation = null;\n\t\t\t\tthis.saveState(state);\n\t\t\t}\n\t\t\tawait this.cleanup(state);\n\t\t}, \"logout\");\n\t}\n\n\tprivate grantForRetirement(state: State, account: StoredAccount, signal?: AbortSignal): Promise<HcodeGrant> {\n\t\tconst generation = account.reference.generation;\n\t\tconst staged = `${generation}.rotation`;\n\t\treturn this.decrypt(\n\t\t\taccount,\n\t\t\tstate.rotation === generation && this.read(staged, MAX_ENVELOPE) !== undefined ? staged : undefined,\n\t\t\tsignal,\n\t\t);\n\t}\n\n\tprivate requireCurrent(state: State, expected: HcodeAccountRef, binding: HcodeBinding): StoredAccount {\n\t\tthis.validateReference(expected);\n\t\tconst current = state.current;\n\t\tif (\n\t\t\t!current ||\n\t\t\t!sameReference(current.reference, expected) ||\n\t\t\t!sameBinding(current, binding) ||\n\t\t\tthis.tombstoned(expected)\n\t\t)\n\t\t\tthrow new Error(\"HUMAIN Code account changed. Sign in again.\");\n\t\treturn current;\n\t}\n\tprivate assertEnvironment(environmentId: string): void {\n\t\t// Private storage input must never select another environment namespace.\n\t\tif (environmentId !== this.environment.id) throw new Error(\"HUMAIN Code account environment changed.\");\n\t}\n\tprivate validateReference(ref: HcodeAccountRef): void {\n\t\tthis.assertEnvironment(ref.environmentId);\n\t\twire.string(ref.environmentId);\n\t\twire.string(ref.accountId);\n\t\tuuid(ref.generation);\n\t}\n\tprivate tombstoned(ref: HcodeAccountRef): boolean {\n\t\treturn this.read(`${uuid(ref.generation)}.logout`, 64) !== undefined;\n\t}\n\tprivate keyStore(): OsSecretStore {\n\t\tthis.secrets ??= createOsSecretStore({ service: \"humain-code-account-keys\", label: \"HUMAIN Code account keys\" });\n\t\treturn this.secrets;\n\t}\n\tprivate async key(generation: string, signal?: AbortSignal): Promise<Buffer> {\n\t\tsignal?.throwIfAborted();\n\t\tconst value = await this.keyStore().get(`${this.environment.id}:${uuid(generation)}`, signal);\n\t\tsignal?.throwIfAborted();\n\t\tif (!value || !/^[A-Za-z0-9+/]{43}=$/.test(value)) throw new Error(STORAGE_ERROR);\n\t\tconst bytes = Buffer.from(value, \"base64\");\n\t\tif (bytes.length !== 32 || bytes.toString(\"base64\") !== value) throw new Error(STORAGE_ERROR);\n\t\treturn bytes;\n\t}\n\tprivate aad(account: StoredAccount): Buffer {\n\t\treturn Buffer.from(\n\t\t\tJSON.stringify([\n\t\t\t\t1,\n\t\t\t\taccount.environmentId,\n\t\t\t\taccount.issuer,\n\t\t\t\taccount.clientId,\n\t\t\t\taccount.reference.accountId,\n\t\t\t\taccount.reference.generation,\n\t\t\t]),\n\t\t);\n\t}\n\tprivate encrypt(account: StoredAccount, grant: HcodeRefreshGrant, key: Buffer): string {\n\t\tconst nonce = randomBytes(12);\n\t\tconst cipher = createCipheriv(\"aes-256-gcm\", key, nonce);\n\t\tcipher.setAAD(this.aad(account));\n\t\tconst ciphertext = Buffer.concat([cipher.update(JSON.stringify(grant)), cipher.final()]);\n\t\treturn JSON.stringify({\n\t\t\tversion: 1,\n\t\t\tkeyId: account.reference.generation,\n\t\t\tnonce: nonce.toString(\"base64\"),\n\t\t\tciphertext: ciphertext.toString(\"base64\"),\n\t\t\ttag: cipher.getAuthTag().toString(\"base64\"),\n\t\t});\n\t}\n\tprivate async decrypt(\n\t\taccount: StoredAccount,\n\t\tfile = `${account.reference.generation}.enc`,\n\t\tsignal?: AbortSignal,\n\t): Promise<HcodeRefreshGrant> {\n\t\ttry {\n\t\t\tconst envelope = wire.object(JSON.parse(this.read(file, MAX_ENVELOPE) ?? \"null\"), [\n\t\t\t\t\"version\",\n\t\t\t\t\"keyId\",\n\t\t\t\t\"nonce\",\n\t\t\t\t\"ciphertext\",\n\t\t\t\t\"tag\",\n\t\t\t]);\n\t\t\twire.literal(envelope.version, 1);\n\t\t\twire.literal(envelope.keyId, account.reference.generation);\n\t\t\tconst nonce = base64(envelope.nonce, 12),\n\t\t\t\ttag = base64(envelope.tag, 16),\n\t\t\t\tciphertext = base64(envelope.ciphertext);\n\t\t\tconst key = await this.key(account.reference.generation, signal);\n\t\t\ttry {\n\t\t\t\tconst decipher = createDecipheriv(\"aes-256-gcm\", key, nonce);\n\t\t\t\tdecipher.setAAD(this.aad(account));\n\t\t\t\tdecipher.setAuthTag(tag);\n\t\t\t\treturn parseRefreshGrant(\n\t\t\t\t\tJSON.parse(Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString(\"utf8\")),\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\tkey.fill(0);\n\t\t\t}\n\t\t} catch {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t}\n\t}\n\tprivate readState(): State {\n\t\tconst text = this.read(\"state.json\", 16384);\n\t\tif (text === undefined) return { version: 1, current: null, intents: [], rotation: null };\n\t\tconst v = wire.object(JSON.parse(text), [\"version\", \"current\", \"intents\", \"rotation\"]);\n\t\tconst current = v.current === null ? null : this.parseStored(v.current);\n\t\treturn {\n\t\t\tversion: wire.literal(v.version, 1),\n\t\t\tcurrent,\n\t\t\tintents: wire.array(v.intents, uuid, 16),\n\t\t\trotation: v.rotation === null ? null : uuid(v.rotation),\n\t\t};\n\t}\n\tprivate parseStored(value: unknown): StoredAccount {\n\t\tconst account = parseStored(value);\n\t\tthis.assertEnvironment(account.environmentId);\n\t\treturn account;\n\t}\n\tprivate saveState(state: State): void {\n\t\tthis.atomic(\"state.json\", JSON.stringify(state));\n\t}\n\tprivate async locked<T>(\n\t\toperation: (state: State, assertLock: () => void) => Promise<T>,\n\t\tintent: \"use\" | \"logout\" | \"recover\" = \"use\",\n\t\tsignal?: AbortSignal,\n\t\tretire = this.publication?.retire,\n\t): Promise<T> {\n\t\tsignal?.throwIfAborted();\n\t\tthis.guardParents(true);\n\t\tfor (const path of [dirname(dirname(this.dir)), dirname(this.dir), this.dir]) await this.acl(path, signal);\n\t\tfor (const name of readdirSync(this.dir)) await this.acl(join(this.dir, name), signal);\n\t\tlet compromised = false;\n\t\tlet release: () => Promise<void>;\n\t\t// About 30 s: another window's refresh holds the lock for up to two 10 s requests plus revocation.\n\t\tconst attempts = 300;\n\t\tfor (let attempt = 0; ; attempt++) {\n\t\t\tsignal?.throwIfAborted();\n\t\t\ttry {\n\t\t\t\trelease = await lockfile.lock(this.dir, {\n\t\t\t\t\trealpath: true,\n\t\t\t\t\t// proper-lockfile's internal retry timers have no cancellation API.\n\t\t\t\t\tretries: signal ? 0 : { retries: attempts, minTimeout: 20, maxTimeout: 100 },\n\t\t\t\t\tonCompromised: () => {\n\t\t\t\t\t\tcompromised = true;\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t} catch (error) {\n\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\tif (!signal || attempt >= attempts) throw error;\n\t\t\t\tawait delay(Math.min(20 * 2 ** attempt, 100), undefined, { signal });\n\t\t\t}\n\t\t}\n\t\tconst assertLock = () => {\n\t\t\tif (compromised) throw new Error(STORAGE_ERROR);\n\t\t\tthis.guardParents(false);\n\t\t};\n\t\ttry {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tassertLock();\n\t\t\tconst state = this.readState();\n\t\t\tawait this.finishReplacement(state, assertLock, signal);\n\t\t\tconst current = state.current;\n\t\t\tif (current && this.tombstoned(current.reference)) {\n\t\t\t\t// Normal readers must leave revocable material for serialized logout, not perform crash collection.\n\t\t\t\tif (intent === \"use\") throw new Error(\"HUMAIN Code account changed. Sign in again.\");\n\t\t\t\tif (intent === \"recover\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Recovery may acquire the lock ahead of the window that wrote the tombstone.\n\t\t\t\t\t\tif (retire) await retire(current, await this.grantForRetirement(state, current));\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t/* Logout remains effective offline. */\n\t\t\t\t\t}\n\t\t\t\t\tassertLock();\n\t\t\t\t\tstate.current = null;\n\t\t\t\t\tstate.rotation = null;\n\t\t\t\t\tthis.saveState(state);\n\t\t\t\t}\n\t\t\t} else if (state.rotation !== null) {\n\t\t\t\tconst staged = `${state.rotation}.rotation`;\n\t\t\t\tconst envelope =\n\t\t\t\t\tcurrent?.reference.generation === state.rotation ? this.read(staged, MAX_ENVELOPE) : undefined;\n\t\t\t\tif (envelope !== undefined && current) {\n\t\t\t\t\tawait this.decrypt(current, staged, signal);\n\t\t\t\t\tassertLock();\n\t\t\t\t\tthis.atomic(`${state.rotation}.enc`, envelope);\n\t\t\t\t}\n\t\t\t\tif (envelope !== undefined || current?.reference.generation !== state.rotation) {\n\t\t\t\t\tstate.rotation = null;\n\t\t\t\t\tthis.saveState(state);\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait this.cleanup(state, signal);\n\t\t\tsignal?.throwIfAborted();\n\t\t\tassertLock();\n\t\t\treturn await operation(state, assertLock);\n\t\t} finally {\n\t\t\tawait release();\n\t\t}\n\t}\n\tprivate parseReplacement(text: string): Replacement {\n\t\tconst journal = wire.object(JSON.parse(text), [\"previous\", \"candidate\"]);\n\t\tconst previous = journal.previous === null ? null : this.parseStored(journal.previous);\n\t\tconst candidate = this.parseStored(journal.candidate);\n\t\t// Private journal input cannot retire the same generation it selects as survivor.\n\t\tif (previous?.reference.generation === candidate.reference.generation) return wire.invalid();\n\t\treturn { previous, candidate };\n\t}\n\tprivate async finishReplacement(\n\t\tstate: State,\n\t\tassertLock: () => void,\n\t\tsignal?: AbortSignal,\n\t\tretire = this.publication?.retire,\n\t): Promise<void> {\n\t\tconst text = this.read(\"replacement.json\", 16384);\n\t\tif (text === undefined) return;\n\t\tconst { previous, candidate } = this.parseReplacement(text);\n\t\tconst published = this.publication ? await this.publication.read(signal) : (state.current?.reference ?? null);\n\t\tsignal?.throwIfAborted();\n\t\tassertLock();\n\t\tconst forward = sameReference(published, candidate.reference);\n\t\tlet current = forward ? candidate : previous;\n\t\tif (\n\t\t\t!forward &&\n\t\t\tcurrent &&\n\t\t\t(this.read(`${current.reference.generation}.enc`, MAX_ENVELOPE) === undefined ||\n\t\t\t\t(await this.keyStore().get(`${this.environment.id}:${current.reference.generation}`, signal)) === undefined)\n\t\t) {\n\t\t\tcurrent = null;\n\t\t}\n\t\tstate.current = current;\n\t\tthis.saveState(state);\n\t\tif (!forward && previous !== null && current === null) await this.publication?.clear(published, signal);\n\t\tconst discarded = forward ? previous : candidate;\n\t\tif (discarded && retire) {\n\t\t\ttry {\n\t\t\t\tawait retire(discarded, await this.grantForRetirement(state, discarded, signal));\n\t\t\t} catch {\n\t\t\t\t/* Missing retired material or unavailable revocation must not prevent local cleanup. */\n\t\t\t}\n\t\t}\n\t\tsignal?.throwIfAborted();\n\t\tassertLock();\n\t\tif (state.rotation !== null && state.rotation !== current?.reference.generation) {\n\t\t\tstate.rotation = null;\n\t\t\tthis.saveState(state);\n\t\t}\n\t\tawait this.cleanup(state, signal);\n\t\tassertLock();\n\t\tthis.removeFile(\"replacement.json\");\n\t}\n\tprivate async cleanup(state: State, signal?: AbortSignal): Promise<void> {\n\t\tsignal?.throwIfAborted();\n\t\tconst current = state.current?.reference.generation;\n\t\tconst orphans = new Set(state.intents.filter((id) => id !== current));\n\t\tfor (const file of readdirSync(this.dir)) {\n\t\t\tconst match = /^([0-9a-f-]+)\\.(enc|rotation|logout)$/.exec(file);\n\t\t\tif (match && UUID.test(match[1]!) && match[1] !== current) orphans.add(match[1]!);\n\t\t\tif (/^[0-9a-f-]+\\.tmp$/.test(file)) this.removeFile(file);\n\t\t}\n\t\tfor (const id of orphans) {\n\t\t\tawait this.keyStore().delete(`${this.environment.id}:${id}`, signal);\n\t\t\tsignal?.throwIfAborted();\n\t\t\tfor (const suffix of [\"enc\", \"rotation\", \"logout\"]) this.removeFile(`${id}.${suffix}`);\n\t\t}\n\t\tif (state.intents.length) {\n\t\t\tstate.intents = [];\n\t\t\tthis.saveState(state);\n\t\t}\n\t\t// A staged envelope is needed only until the matching rotation marker has cleared.\n\t\tif (current && current !== state.rotation) this.removeFile(`${current}.rotation`);\n\t}\n\tprivate guardParents(create: boolean, allowMissing = false): void {\n\t\tconst paths: string[] = [];\n\t\tfor (let path = this.dir; ; path = dirname(path)) {\n\t\t\tpaths.unshift(path);\n\t\t\tif (dirname(path) === path) break;\n\t\t}\n\t\tfor (const path of paths) {\n\t\t\tif (!existsSync(path) && allowMissing) {\n\t\t\t\ttry {\n\t\t\t\t\tlstatSync(path);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (isMissing(error)) return;\n\t\t\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!existsSync(path) && create) {\n\t\t\t\tmkdirSync(path, { mode: 0o700 });\n\t\t\t\tthis.syncDirectory(dirname(path));\n\t\t\t\tthis.createdDirectories.add(path);\n\t\t\t}\n\t\t\tlet stat: ReturnType<typeof lstatSync>;\n\t\t\ttry {\n\t\t\t\tstat = lstatSync(path);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t\t}\n\t\t\tif (!stat.isDirectory() || stat.isSymbolicLink()) throw new Error(STORAGE_ERROR);\n\t\t\tif (\n\t\t\t\t(path === this.dir || path === dirname(this.dir) || path === dirname(dirname(this.dir))) &&\n\t\t\t\tthis.platform !== \"win32\" &&\n\t\t\t\t((stat.mode & 0o777) !== 0o700 || stat.uid !== process.getuid?.())\n\t\t\t)\n\t\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t}\n\t}\n\tprivate read(name: string, max: number): string | undefined {\n\t\tconst path = join(this.dir, name);\n\t\ttry {\n\t\t\tif (lstatSync(path).isSymbolicLink()) throw new Error(STORAGE_ERROR);\n\t\t} catch (error) {\n\t\t\tif (isMissing(error)) return undefined;\n\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t}\n\t\tlet fd: number;\n\t\ttry {\n\t\t\tfd = openSync(\n\t\t\t\tjoin(this.dir, name),\n\t\t\t\tconstants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tif (isMissing(error)) return undefined;\n\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t}\n\t\ttry {\n\t\t\tconst stat = fstatSync(fd);\n\t\t\tif (\n\t\t\t\t!stat.isFile() ||\n\t\t\t\tstat.nlink !== 1 ||\n\t\t\t\tstat.size > max ||\n\t\t\t\t(this.platform !== \"win32\" && ((stat.mode & 0o777) !== 0o600 || stat.uid !== process.getuid?.()))\n\t\t\t)\n\t\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t\treturn readFileSync(fd, \"utf8\");\n\t\t} finally {\n\t\t\tcloseSync(fd);\n\t\t}\n\t}\n\tprivate atomic(name: string, text: string, renamed?: () => void): void {\n\t\tthis.guardParents(false);\n\t\t// Validate an existing destination rather than following or replacing a hostile link.\n\t\tthis.read(name, MAX_ENVELOPE);\n\t\tconst temp = join(this.dir, `${randomUUID()}.tmp`);\n\t\tconst fd = openSync(temp, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL, 0o600);\n\t\ttry {\n\t\t\twriteFileSync(fd, text);\n\t\t\tfsyncSync(fd);\n\t\t} finally {\n\t\t\tcloseSync(fd);\n\t\t}\n\t\trenameSync(temp, join(this.dir, name));\n\t\trenamed?.();\n\t\tthis.syncDirectory();\n\t}\n\tprivate removeFile(name: string): void {\n\t\tthis.read(name, MAX_ENVELOPE);\n\t\ttry {\n\t\t\tunlinkSync(join(this.dir, name));\n\t\t} catch (error) {\n\t\t\tif (!isMissing(error)) throw new Error(STORAGE_ERROR);\n\t\t}\n\t\tthis.syncDirectory();\n\t}\n\tprivate syncDirectory(path = this.dir): void {\n\t\tif (this.platform === \"win32\") return;\n\t\tconst fd = openSync(path, constants.O_RDONLY);\n\t\ttry {\n\t\t\tfsyncSync(fd);\n\t\t} finally {\n\t\t\tcloseSync(fd);\n\t\t}\n\t}\n\tprivate async acl(path: string, signal?: AbortSignal): Promise<void> {\n\t\tsignal?.throwIfAborted();\n\t\tif (this.platform !== \"win32\") return;\n\t\t// Windows filesystem input: protected DACL, owner and every allow ACE must be this user only.\n\t\ttry {\n\t\t\tawait assertPrivateWindowsPath(\n\t\t\t\tpath,\n\t\t\t\tthis.createdDirectories.has(path) ? \"create\" : \"verify\",\n\t\t\t\tthis.runner,\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tthis.createdDirectories.delete(path);\n\t\t} catch {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tthrow new Error(STORAGE_ERROR);\n\t\t}\n\t}\n}\n\n/** Compares non-secret references without adopting another environment, account or generation. */\nexport function sameReference(a: HcodeAccountRef | null | undefined, b: HcodeAccountRef | null | undefined): boolean {\n\treturn (\n\t\t!!a && !!b && a.environmentId === b.environmentId && a.accountId === b.accountId && a.generation === b.generation\n\t);\n}\nfunction sameBinding(a: HcodeBinding, b: HcodeBinding): boolean {\n\treturn a.environmentId === b.environmentId && a.issuer === b.issuer && a.clientId === b.clientId;\n}\nfunction uuid(value: unknown): string {\n\tconst text = wire.string(value, 36);\n\tif (!UUID.test(text)) return wire.invalid();\n\treturn text;\n}\nfunction base64(value: unknown, size?: number): Buffer {\n\tconst text = wire.string(value, MAX_ENVELOPE);\n\tconst bytes = Buffer.from(text, \"base64\");\n\tif (bytes.toString(\"base64\") !== text || (size !== undefined && bytes.length !== size) || bytes.length > MAX_GRANT)\n\t\treturn wire.invalid();\n\treturn bytes;\n}\nfunction parseStored(value: unknown): StoredAccount {\n\tconst v = wire.object(value, [\"environmentId\", \"issuer\", \"clientId\", \"reference\"]),\n\t\tref = wire.object(v.reference, [\"environmentId\", \"accountId\", \"generation\"]);\n\tconst environmentId = wire.string(v.environmentId);\n\tif (ref.environmentId !== environmentId) return wire.invalid();\n\treturn {\n\t\tenvironmentId,\n\t\tissuer: wire.https(v.issuer),\n\t\tclientId: wire.string(v.clientId),\n\t\treference: { environmentId, accountId: wire.string(ref.accountId), generation: uuid(ref.generation) },\n\t};\n}\n/** Validates untrusted token data before encryption or private send. */\nexport function parseGrant(value: unknown): HcodeGrant {\n\tif (wire.jsonBytes(value) > MAX_GRANT) return wire.invalid();\n\tconst v = wire.object(value, [\"accessToken\", \"refreshToken\", \"expiresAt\"]);\n\tconst accessToken = wire.string(v.accessToken, MAX_GRANT),\n\t\trefreshToken = wire.string(v.refreshToken, MAX_GRANT);\n\tif (/[^\\x21-\\x7e]/.test(accessToken) || /[\\p{Cc}]/u.test(refreshToken)) return wire.invalid();\n\treturn { accessToken, refreshToken, expiresAt: wire.integer(v.expiresAt) };\n}\nfunction parseRefreshGrant(value: unknown): HcodeRefreshGrant {\n\tconst { pendingVerification, ...tokens } = wire.object(value, [\n\t\t\"accessToken\",\n\t\t\"refreshToken\",\n\t\t\"expiresAt\",\n\t\t\"pendingVerification\",\n\t]);\n\tconst grant = parseGrant(tokens);\n\t// Keep the flag in the authenticated envelope so a crash cannot separate it from the rotated grant.\n\treturn pendingVerification === undefined\n\t\t? grant\n\t\t: { ...grant, pendingVerification: wire.literal(pendingVerification, true) };\n}\nfunction isMissing(error: unknown): boolean {\n\treturn error instanceof Error && \"code\" in error && error.code === \"ENOENT\";\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../src/humain/hcode/account.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAM7D,OAAO,EACN,KAAK,uBAAuB,EAC5B,iBAAiB,EASjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAyB,KAAK,oBAAoB,EAA2B,MAAM,kBAAkB,CAAC;AAG7G,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGpE,yFAAyF;AACzF,eAAO,MAAM,yBAAyB,yLACiJ,CAAC;AAExL,8GAA8G;AAC9G,MAAM,WAAW,kBAAkB;IAClC,aAAa,EAAE,+BAA+B,CAAC;IAC/C,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,qBAAqB,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,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,GACrD,OAAO,CAAC,eAAe,CAAC,CAAC;IAC5B,uGAAuG;IACvG,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACpD,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC;IAC7E,mFAAmF;IACnF,qBAAqB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC;IACtD,yFAAyF;IACzF,KAAK,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAAC;IACrD,OAAO,IAAI,IAAI,CAAC;CAChB;AAED,4GAA4G;AAC5G,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,iBAAiB,CAklBvF;AAiCD,mFAAmF;AACnF,wBAAsB,iBAAiB,CACtC,CAAC,EAAE,kBAAkB,EACrB,OAAO,EAAE,OAAO,KAAK,EACrB,MAAM,EAAE,WAAW,GACjB,OAAO,CAAC,IAAI,CAAC,CAmBf"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Native device authorization and private, final-send bearer resolution. No ambient auth sources.
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { pollOAuthDeviceCodeFlow } from "@earendil-works/pi-ai/oauth";
|
|
3
|
+
import { generatePKCE, pollOAuthDeviceCodeFlow } from "@earendil-works/pi-ai/oauth";
|
|
4
4
|
import { OsSecretStoreError } from "../../core/os-secret-store.js";
|
|
5
5
|
import { SafeCredentialError } from "../../core/safe-credential-error.js";
|
|
6
6
|
import { raceWithAbortSignal } from "../../utils/abort.js";
|
|
@@ -214,17 +214,23 @@ export function createHcodeAccount(options = {}) {
|
|
|
214
214
|
let email = null;
|
|
215
215
|
try {
|
|
216
216
|
const authorizeDevice = async () => {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
217
|
+
// A lost reply abandons a device code; its replacement must have its own PKCE pair.
|
|
218
|
+
const { response, verifier } = await retryOnce(signal, async () => {
|
|
219
|
+
const { verifier, challenge } = await generatePKCE();
|
|
220
|
+
const response = await hcodeJson(fetcher, p.deviceAuthorizationEndpoint, {
|
|
221
|
+
method: "POST",
|
|
222
|
+
body: new URLSearchParams({
|
|
223
|
+
client_id: p.clientId,
|
|
224
|
+
scope: p.scopes.join(" "),
|
|
225
|
+
audience: p.audience,
|
|
226
|
+
code_challenge: challenge,
|
|
227
|
+
code_challenge_method: "S256",
|
|
228
|
+
}),
|
|
229
|
+
signal,
|
|
230
|
+
});
|
|
231
|
+
return { response, verifier };
|
|
232
|
+
});
|
|
233
|
+
const device = wire.fields(response, [
|
|
228
234
|
"device_code",
|
|
229
235
|
"user_code",
|
|
230
236
|
"verification_uri",
|
|
@@ -255,7 +261,11 @@ export function createHcodeAccount(options = {}) {
|
|
|
255
261
|
poll: async () => {
|
|
256
262
|
let response;
|
|
257
263
|
try {
|
|
258
|
-
response = await tokenRequest(p, fetcher, {
|
|
264
|
+
response = await tokenRequest(p, fetcher, {
|
|
265
|
+
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
266
|
+
device_code: code,
|
|
267
|
+
code_verifier: verifier,
|
|
268
|
+
}, signal, (refreshToken) => {
|
|
259
269
|
uncommitted = refreshToken;
|
|
260
270
|
});
|
|
261
271
|
}
|