@humain/humain-code 0.8.2 → 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 +152 -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-PJXBU6CR.js → chunk-52642TYH.js} +394 -204
- 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-EFY2QPVP.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-U4EAJPMO.js → chunk-EVDQRT3I.js} +252 -371
- 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-G2QMON4O.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-H2B3WLIM.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-S2US54IU.js +37 -0
- package/dist/bundle/chunks/{chunk-H7UPU2SH.js → chunk-SOE25WIS.js} +1218 -1239
- 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-ELBUCH6U.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-NERIS6SW.js → dist-7PCCEUQF.js} +2 -2
- package/dist/bundle/chunks/{dist-QSYDYE3Y.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-SRYLSS5P.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-3P3BHQ7E.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-3PDJKE5F.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/adapter/delivery.d.ts +27 -0
- package/dist/coordination/adapter/delivery.d.ts.map +1 -1
- package/dist/coordination/adapter/delivery.js +164 -4
- package/dist/coordination/adapter/delivery.js.map +1 -1
- package/dist/coordination/adapter/index.d.ts.map +1 -1
- package/dist/coordination/adapter/index.js +31 -5
- package/dist/coordination/adapter/index.js.map +1 -1
- package/dist/coordination/adapter/presence.d.ts +5 -0
- package/dist/coordination/adapter/presence.d.ts.map +1 -1
- package/dist/coordination/adapter/presence.js +25 -3
- package/dist/coordination/adapter/presence.js.map +1 -1
- package/dist/coordination/adapter/question-routing.d.ts +7 -0
- package/dist/coordination/adapter/question-routing.d.ts.map +1 -0
- package/dist/coordination/adapter/question-routing.js +40 -0
- package/dist/coordination/adapter/question-routing.js.map +1 -0
- package/dist/coordination/adapter/receipts.d.ts +7 -0
- package/dist/coordination/adapter/receipts.d.ts.map +1 -1
- package/dist/coordination/adapter/receipts.js +25 -2
- package/dist/coordination/adapter/receipts.js.map +1 -1
- package/dist/coordination/adapter/tool.d.ts +19 -3
- package/dist/coordination/adapter/tool.d.ts.map +1 -1
- package/dist/coordination/adapter/tool.js +93 -19
- package/dist/coordination/adapter/tool.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/coordination/client/client.d.ts +2 -2
- package/dist/coordination/client/client.d.ts.map +1 -1
- package/dist/coordination/client/client.js +4 -0
- package/dist/coordination/client/client.js.map +1 -1
- package/dist/coordination/transport/protocol.d.ts.map +1 -1
- package/dist/coordination/transport/protocol.js +23 -0
- package/dist/coordination/transport/protocol.js.map +1 -1
- package/dist/coordination/transport/types.d.ts +11 -1
- package/dist/coordination/transport/types.d.ts.map +1 -1
- package/dist/coordination/transport/types.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 +20 -10
- 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/oauth-account-pool.d.ts +14 -0
- package/dist/core/oauth-account-pool.d.ts.map +1 -1
- package/dist/core/oauth-account-pool.js +166 -14
- package/dist/core/oauth-account-pool.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/run-outcome.d.ts +1 -1
- package/dist/core/run-outcome.d.ts.map +1 -1
- package/dist/core/run-outcome.js +2 -2
- package/dist/core/run-outcome.js.map +1 -1
- package/dist/core/run-preflight.d.ts.map +1 -1
- package/dist/core/run-preflight.js +15 -8
- package/dist/core/run-preflight.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 +38 -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 +45 -3
- package/docs/codemode.md +7 -3
- package/docs/compaction.md +1 -1
- package/docs/coordination.md +16 -4
- package/docs/development.md +6 -0
- package/docs/environment-variables.md +5 -3
- 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 +25 -3
- 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-3PJ7NPWN.js +0 -80
- package/dist/bundle/chunks/chunk-6JTCRCNF.js +0 -74
- 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-JQBZUFH7.js +0 -3580
- 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-UEW6TUSP.js +0 -36
- 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/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-SDUO5OLD.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-modules-IU5KWB2C.js +0 -28
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
2
|
+
import { t } from "../state/i18n-bridge.js";
|
|
3
|
+
import { NO_INPUT_PLACEHOLDER } from "../tool/format-answer.js";
|
|
4
|
+
import { prepareQuestionArguments } from "../tool/normalize-params.js";
|
|
5
|
+
import { isQuestionnaireResult, } from "../tool/types.js";
|
|
6
|
+
import { stripFenceMarkers } from "./components/preview/preview-box-renderer.js";
|
|
7
|
+
const INDENT = " ";
|
|
8
|
+
const COLUMN_GAP = " ";
|
|
9
|
+
const RECOMMENDED_SUFFIX = /\s*\(Recommended\)$/;
|
|
10
|
+
/**
|
|
11
|
+
* The questions as the session recorded them. Pi decodes a provider's double-encoded
|
|
12
|
+
* `questions` before the tool runs (#244), but a replayed session hands the renderers
|
|
13
|
+
* the raw recorded arguments, so they are decoded again here. A shape that is still
|
|
14
|
+
* not an array draws as no questions, and an element that is not a question keeps its
|
|
15
|
+
* slot (answers point at questions by index) with an empty header, so a malformed
|
|
16
|
+
* transcript cannot throw out of the render path.
|
|
17
|
+
*/
|
|
18
|
+
function recordedQuestions(args) {
|
|
19
|
+
const questions = prepareQuestionArguments(args ?? {})?.questions;
|
|
20
|
+
if (!Array.isArray(questions))
|
|
21
|
+
return [];
|
|
22
|
+
return questions.map((q) => {
|
|
23
|
+
const fields = typeof q === "object" && q !== null ? q : {};
|
|
24
|
+
return {
|
|
25
|
+
header: typeof fields.header === "string" ? fields.header : "",
|
|
26
|
+
question: typeof fields.question === "string" ? fields.question : undefined,
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Lines laid out at render time, so wrapping and truncation follow the terminal width.
|
|
32
|
+
* Every line is clamped to the width: Pi stops the whole TUI on a line wider than the
|
|
33
|
+
* terminal, so no receipt branch may hand it one.
|
|
34
|
+
*/
|
|
35
|
+
class WidthLines {
|
|
36
|
+
layout;
|
|
37
|
+
constructor(layout) {
|
|
38
|
+
this.layout = layout;
|
|
39
|
+
}
|
|
40
|
+
render(width) {
|
|
41
|
+
return this.layout(width).map((line) => truncateToWidth(line, width, "…"));
|
|
42
|
+
}
|
|
43
|
+
invalidate() { }
|
|
44
|
+
}
|
|
45
|
+
/** `Ask Format · Migration`: the headers name the questions. */
|
|
46
|
+
export function renderAskCall(args, theme) {
|
|
47
|
+
const headers = recordedQuestions(args)
|
|
48
|
+
.map((q) => q.header)
|
|
49
|
+
.filter(Boolean);
|
|
50
|
+
const title = theme.fg("toolTitle", theme.bold("Ask"));
|
|
51
|
+
const text = headers.length > 0 ? `${title} ${theme.fg("accent", headers.join(" · "))}` : title;
|
|
52
|
+
return new WidthLines(() => [text]);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The transcript receipt: one `✓ answer` line for a single question, an aligned
|
|
56
|
+
* header/answer table for several. A failure shows `✗` with the first line of the
|
|
57
|
+
* model-facing message; a declined questionnaire shows a dimmed `✗ no answer`.
|
|
58
|
+
*/
|
|
59
|
+
export function renderAskResult(result, args, theme, options) {
|
|
60
|
+
const details = isQuestionnaireResult(result.details) ? result.details : undefined;
|
|
61
|
+
if (options.isError || details?.error) {
|
|
62
|
+
return new WidthLines(() => [theme.fg("error", `✗ ${firstTextLine(result)}`)]);
|
|
63
|
+
}
|
|
64
|
+
if (!details)
|
|
65
|
+
return new WidthLines(() => [theme.fg("success", "✓")]);
|
|
66
|
+
if (details.cancelled) {
|
|
67
|
+
return new WidthLines(() => [theme.fg("dim", `✗ ${t("transcript.no_answer", "no answer")}`)]);
|
|
68
|
+
}
|
|
69
|
+
const questions = recordedQuestions(args);
|
|
70
|
+
return new WidthLines((width) => questions.length > 1
|
|
71
|
+
? tableLines(details, questions, theme, options.expanded, width)
|
|
72
|
+
: singleLines(details, questions[0]?.question, theme, options.expanded, width));
|
|
73
|
+
}
|
|
74
|
+
function singleLines(details, questionText, theme, expanded, width) {
|
|
75
|
+
const answer = details.answers[0];
|
|
76
|
+
const lines = hanging(`${theme.fg("success", "✓")} `, answerText(answer, theme), width);
|
|
77
|
+
lines.push(...detailLines(answer, expanded ? questionText : undefined, INDENT, theme, width));
|
|
78
|
+
return [...lines, ...globalNoteLines(details, theme, width)];
|
|
79
|
+
}
|
|
80
|
+
function tableLines(details, questions, theme, expanded, width) {
|
|
81
|
+
const headerWidth = Math.max(...questions.map((q) => visibleWidth(q.header)));
|
|
82
|
+
const answerIndent = " ".repeat(INDENT.length + headerWidth + COLUMN_GAP.length);
|
|
83
|
+
const lines = questions.flatMap((q, i) => {
|
|
84
|
+
const answer = details.answers.find((a) => a.questionIndex === i);
|
|
85
|
+
const header = q.header + " ".repeat(headerWidth - visibleWidth(q.header));
|
|
86
|
+
const row = hanging(`${INDENT}${theme.fg("muted", header)}${COLUMN_GAP}`, answerText(answer, theme), width);
|
|
87
|
+
return [...row, ...detailLines(answer, expanded ? q.question : undefined, answerIndent, theme, width)];
|
|
88
|
+
});
|
|
89
|
+
return [...lines, ...globalNoteLines(details, theme, width)];
|
|
90
|
+
}
|
|
91
|
+
/** Under an answer: the question text and chosen preview when expanded, then the answer's note. */
|
|
92
|
+
function detailLines(answer, questionText, indent, theme, width) {
|
|
93
|
+
const lines = [];
|
|
94
|
+
if (questionText)
|
|
95
|
+
lines.push(...hanging(indent, theme.fg("dim", questionText), width));
|
|
96
|
+
if (questionText && answer?.preview) {
|
|
97
|
+
for (const line of stripFenceMarkers(answer.preview.split("\n"))) {
|
|
98
|
+
lines.push(truncateToWidth(`${indent}${theme.fg("dim", `│ ${line}`)}`, width, "…"));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (answer?.notes)
|
|
102
|
+
lines.push(...hanging(indent, theme.fg("dim", `✎ ${answer.notes}`), width));
|
|
103
|
+
return lines;
|
|
104
|
+
}
|
|
105
|
+
function globalNoteLines(details, theme, width) {
|
|
106
|
+
return details.globalNote ? hanging(INDENT, theme.fg("dim", `✎ ${details.globalNote}`), width) : [];
|
|
107
|
+
}
|
|
108
|
+
function answerText(answer, theme) {
|
|
109
|
+
if (!answer)
|
|
110
|
+
return theme.fg("dim", t("transcript.not_answered", "not answered"));
|
|
111
|
+
const typed = answer.answer ? `"${answer.answer}"` : undefined;
|
|
112
|
+
const picks = answer.kind === "option"
|
|
113
|
+
? [label(answer.answer ?? "")]
|
|
114
|
+
: answer.kind === "custom"
|
|
115
|
+
? [typed]
|
|
116
|
+
: [...(answer.selected ?? []).map(label), typed];
|
|
117
|
+
return theme.fg("toolOutput", picks.filter(Boolean).join(", ") || NO_INPUT_PLACEHOLDER);
|
|
118
|
+
}
|
|
119
|
+
function label(text) {
|
|
120
|
+
return text.replace(RECOMMENDED_SUFFIX, "");
|
|
121
|
+
}
|
|
122
|
+
/** `prefix` then `text` wrapped to the width left after it; continuation lines align under the text. */
|
|
123
|
+
function hanging(prefix, text, width) {
|
|
124
|
+
const indent = visibleWidth(prefix);
|
|
125
|
+
return wrapTextWithAnsi(text, Math.max(1, width - indent)).map((line, i) => (i === 0 ? prefix : " ".repeat(indent)) + line);
|
|
126
|
+
}
|
|
127
|
+
function firstTextLine(result) {
|
|
128
|
+
const text = result.content.find((c) => c.type === "text")?.text ?? "";
|
|
129
|
+
return text.split("\n")[0] ?? "";
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=transcript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript.js","sourceRoot":"","sources":["../../../../../../src/humain/ask-user-question/vendor/ask/view/transcript.ts"],"names":[],"mappings":"AAA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AK,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAC7D,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAC3D,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,MAAsB;IAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,EAAE,IAAI,IAAI,EAAE,CAAC;IACvE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAClC,CAAC","sourcesContent":["import { type Component, truncateToWidth, visibleWidth, wrapTextWithAnsi } from \"@earendil-works/pi-tui\";\nimport type { Theme } from \"../../../../../modes/interactive/theme/theme.ts\";\nimport { t } from \"../state/i18n-bridge.ts\";\nimport { NO_INPUT_PLACEHOLDER } from \"../tool/format-answer.ts\";\nimport { prepareQuestionArguments } from \"../tool/normalize-params.ts\";\nimport {\n\tisQuestionnaireResult,\n\ttype QuestionAnswer,\n\ttype QuestionnaireResult,\n\ttype QuestionParams,\n} from \"../tool/types.ts\";\nimport { stripFenceMarkers } from \"./components/preview/preview-box-renderer.ts\";\n\nconst INDENT = \" \";\nconst COLUMN_GAP = \" \";\nconst RECOMMENDED_SUFFIX = /\\s*\\(Recommended\\)$/;\n\ntype ToolResultView = { content: ReadonlyArray<{ type: string; text?: string }>; details?: unknown };\n\n/** The part of a recorded question the transcript draws. */\ntype RecordedQuestion = { header: string; question: string | undefined };\n\n/**\n * The questions as the session recorded them. Pi decodes a provider's double-encoded\n * `questions` before the tool runs (#244), but a replayed session hands the renderers\n * the raw recorded arguments, so they are decoded again here. A shape that is still\n * not an array draws as no questions, and an element that is not a question keeps its\n * slot (answers point at questions by index) with an empty header, so a malformed\n * transcript cannot throw out of the render path.\n */\nfunction recordedQuestions(args: unknown): RecordedQuestion[] {\n\tconst questions: unknown = prepareQuestionArguments(args ?? {})?.questions;\n\tif (!Array.isArray(questions)) return [];\n\treturn questions.map((q) => {\n\t\tconst fields = typeof q === \"object\" && q !== null ? (q as Record<string, unknown>) : {};\n\t\treturn {\n\t\t\theader: typeof fields.header === \"string\" ? fields.header : \"\",\n\t\t\tquestion: typeof fields.question === \"string\" ? fields.question : undefined,\n\t\t};\n\t});\n}\n\n/**\n * Lines laid out at render time, so wrapping and truncation follow the terminal width.\n * Every line is clamped to the width: Pi stops the whole TUI on a line wider than the\n * terminal, so no receipt branch may hand it one.\n */\nclass WidthLines implements Component {\n\tprivate readonly layout: (width: number) => string[];\n\n\tconstructor(layout: (width: number) => string[]) {\n\t\tthis.layout = layout;\n\t}\n\trender(width: number): string[] {\n\t\treturn this.layout(width).map((line) => truncateToWidth(line, width, \"…\"));\n\t}\n\tinvalidate(): void {}\n}\n\n/** `Ask Format · Migration`: the headers name the questions. */\nexport function renderAskCall(args: QuestionParams | undefined, theme: Theme): Component {\n\tconst headers = recordedQuestions(args)\n\t\t.map((q) => q.header)\n\t\t.filter(Boolean);\n\tconst title = theme.fg(\"toolTitle\", theme.bold(\"Ask\"));\n\tconst text = headers.length > 0 ? `${title} ${theme.fg(\"accent\", headers.join(\" · \"))}` : title;\n\treturn new WidthLines(() => [text]);\n}\n\n/**\n * The transcript receipt: one `✓ answer` line for a single question, an aligned\n * header/answer table for several. A failure shows `✗` with the first line of the\n * model-facing message; a declined questionnaire shows a dimmed `✗ no answer`.\n */\nexport function renderAskResult(\n\tresult: ToolResultView,\n\targs: QuestionParams | undefined,\n\ttheme: Theme,\n\toptions: { expanded: boolean; isError: boolean },\n): Component {\n\tconst details = isQuestionnaireResult(result.details) ? result.details : undefined;\n\tif (options.isError || details?.error) {\n\t\treturn new WidthLines(() => [theme.fg(\"error\", `✗ ${firstTextLine(result)}`)]);\n\t}\n\tif (!details) return new WidthLines(() => [theme.fg(\"success\", \"✓\")]);\n\tif (details.cancelled) {\n\t\treturn new WidthLines(() => [theme.fg(\"dim\", `✗ ${t(\"transcript.no_answer\", \"no answer\")}`)]);\n\t}\n\tconst questions = recordedQuestions(args);\n\treturn new WidthLines((width) =>\n\t\tquestions.length > 1\n\t\t\t? tableLines(details, questions, theme, options.expanded, width)\n\t\t\t: singleLines(details, questions[0]?.question, theme, options.expanded, width),\n\t);\n}\n\nfunction singleLines(\n\tdetails: QuestionnaireResult,\n\tquestionText: string | undefined,\n\ttheme: Theme,\n\texpanded: boolean,\n\twidth: number,\n): string[] {\n\tconst answer = details.answers[0];\n\tconst lines = hanging(`${theme.fg(\"success\", \"✓\")} `, answerText(answer, theme), width);\n\tlines.push(...detailLines(answer, expanded ? questionText : undefined, INDENT, theme, width));\n\treturn [...lines, ...globalNoteLines(details, theme, width)];\n}\n\nfunction tableLines(\n\tdetails: QuestionnaireResult,\n\tquestions: readonly RecordedQuestion[],\n\ttheme: Theme,\n\texpanded: boolean,\n\twidth: number,\n): string[] {\n\tconst headerWidth = Math.max(...questions.map((q) => visibleWidth(q.header)));\n\tconst answerIndent = \" \".repeat(INDENT.length + headerWidth + COLUMN_GAP.length);\n\tconst lines = questions.flatMap((q, i) => {\n\t\tconst answer = details.answers.find((a) => a.questionIndex === i);\n\t\tconst header = q.header + \" \".repeat(headerWidth - visibleWidth(q.header));\n\t\tconst row = hanging(`${INDENT}${theme.fg(\"muted\", header)}${COLUMN_GAP}`, answerText(answer, theme), width);\n\t\treturn [...row, ...detailLines(answer, expanded ? q.question : undefined, answerIndent, theme, width)];\n\t});\n\treturn [...lines, ...globalNoteLines(details, theme, width)];\n}\n\n/** Under an answer: the question text and chosen preview when expanded, then the answer's note. */\nfunction detailLines(\n\tanswer: QuestionAnswer | undefined,\n\tquestionText: string | undefined,\n\tindent: string,\n\ttheme: Theme,\n\twidth: number,\n): string[] {\n\tconst lines: string[] = [];\n\tif (questionText) lines.push(...hanging(indent, theme.fg(\"dim\", questionText), width));\n\tif (questionText && answer?.preview) {\n\t\tfor (const line of stripFenceMarkers(answer.preview.split(\"\\n\"))) {\n\t\t\tlines.push(truncateToWidth(`${indent}${theme.fg(\"dim\", `│ ${line}`)}`, width, \"…\"));\n\t\t}\n\t}\n\tif (answer?.notes) lines.push(...hanging(indent, theme.fg(\"dim\", `✎ ${answer.notes}`), width));\n\treturn lines;\n}\n\nfunction globalNoteLines(details: QuestionnaireResult, theme: Theme, width: number): string[] {\n\treturn details.globalNote ? hanging(INDENT, theme.fg(\"dim\", `✎ ${details.globalNote}`), width) : [];\n}\n\nfunction answerText(answer: QuestionAnswer | undefined, theme: Theme): string {\n\tif (!answer) return theme.fg(\"dim\", t(\"transcript.not_answered\", \"not answered\"));\n\tconst typed = answer.answer ? `\"${answer.answer}\"` : undefined;\n\tconst picks =\n\t\tanswer.kind === \"option\"\n\t\t\t? [label(answer.answer ?? \"\")]\n\t\t\t: answer.kind === \"custom\"\n\t\t\t\t? [typed]\n\t\t\t\t: [...(answer.selected ?? []).map(label), typed];\n\treturn theme.fg(\"toolOutput\", picks.filter(Boolean).join(\", \") || NO_INPUT_PLACEHOLDER);\n}\n\nfunction label(text: string): string {\n\treturn text.replace(RECOMMENDED_SUFFIX, \"\");\n}\n\n/** `prefix` then `text` wrapped to the width left after it; continuation lines align under the text. */\nfunction hanging(prefix: string, text: string, width: number): string[] {\n\tconst indent = visibleWidth(prefix);\n\treturn wrapTextWithAnsi(text, Math.max(1, width - indent)).map(\n\t\t(line, i) => (i === 0 ? prefix : \" \".repeat(indent)) + line,\n\t);\n}\n\nfunction firstTextLine(result: ToolResultView): string {\n\tconst text = result.content.find((c) => c.type === \"text\")?.text ?? \"\";\n\treturn text.split(\"\\n\")[0] ?? \"\";\n}\n"]}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* rpiv-config — shared config I/O utilities for rpiv-mono sibling packages.
|
|
3
|
+
*
|
|
4
|
+
* Provides JSON config load/save with crash-resistant defaults, path resolution,
|
|
5
|
+
* guidance-field validation, env-var fallback, and TypeBox-driven schema validation.
|
|
6
|
+
* Stateless — no module-level singletons, no globalThis caches, no side effects.
|
|
7
|
+
*/
|
|
8
|
+
import { type Static, type TObject, Type } from "typebox";
|
|
9
|
+
/**
|
|
10
|
+
* Resolve a config file path under the XDG-aware config directory.
|
|
11
|
+
*
|
|
12
|
+
* `<resolveConfigDir()>/<name>/<file>` — defaults to `~/.config/<name>/config.json`
|
|
13
|
+
* when `XDG_CONFIG_HOME` is unset / empty / whitespace / relative.
|
|
14
|
+
*
|
|
15
|
+
* Boundary: `XDG_CONFIG_HOME` governs the rpiv-* sibling config layer only;
|
|
16
|
+
* Pi-native paths (`~/.pi/…`, via `PI_CODING_AGENT_DIR`) are orthogonal and
|
|
17
|
+
* not unified here.
|
|
18
|
+
*
|
|
19
|
+
* @param name — package directory name (e.g. "rpiv-todo")
|
|
20
|
+
* @param file — config filename (defaults to "config.json")
|
|
21
|
+
* @returns absolute path to the config file
|
|
22
|
+
*/
|
|
23
|
+
export declare function configPath(name: string, file?: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Load and parse a JSON config file.
|
|
26
|
+
*
|
|
27
|
+
* Returns `{}` for missing files, malformed JSON, or non-plain-object values.
|
|
28
|
+
* The typeof guard fixes a latent bug where valid non-object JSON
|
|
29
|
+
* (e.g. `"hello"`, `42`, `null`) passes through the cast. Arrays are also
|
|
30
|
+
* rejected — `typeof [] === "object"` in JavaScript, but config files are
|
|
31
|
+
* always plain objects.
|
|
32
|
+
*/
|
|
33
|
+
export declare function loadJsonConfig<T>(path: string): T;
|
|
34
|
+
/**
|
|
35
|
+
* Load a JSON config, preferring the XDG-resolved path and falling back to the
|
|
36
|
+
* legacy `~/.config/<name>/<file>` location only when the XDG path is missing.
|
|
37
|
+
*
|
|
38
|
+
* - XDG file present (valid or malformed) → its parse result wins. A malformed
|
|
39
|
+
* XDG file warns and returns `{}` but does NOT silently fall back to legacy —
|
|
40
|
+
* corruption is surfaced, not masked.
|
|
41
|
+
* - XDG file missing → read the legacy path (which returns `{}` if also missing,
|
|
42
|
+
* or warns + `{}` if malformed).
|
|
43
|
+
* - Both missing → `{}`.
|
|
44
|
+
*
|
|
45
|
+
* @param name — package directory name (e.g. "rpiv-todo")
|
|
46
|
+
* @param file — config filename (defaults to "config.json")
|
|
47
|
+
*/
|
|
48
|
+
export declare function loadJsonConfigWithLegacyFallback<T>(name: string, file?: string): T;
|
|
49
|
+
/**
|
|
50
|
+
* Persist a config object as formatted JSON. Returns `true` on successful
|
|
51
|
+
* mkdir+write, `false` on filesystem failure (disk full, EACCES, EROFS, …).
|
|
52
|
+
*
|
|
53
|
+
* Every current rpiv-* save call site is user-initiated and shows a
|
|
54
|
+
* "Saved …" notification — callers MUST guard the success notification on
|
|
55
|
+
* the boolean return so a silent disk failure can't make the success message
|
|
56
|
+
* lie on disk-full / EACCES.
|
|
57
|
+
*
|
|
58
|
+
* The chmod step is best-effort and never affects the return value: some
|
|
59
|
+
* filesystems (tmpfs, network mounts, Windows-style perms) silently ignore
|
|
60
|
+
* chmod and there is no portable way to enforce 0600 perms across platforms.
|
|
61
|
+
* Callers that genuinely don't care about persistence outcome can discard
|
|
62
|
+
* the return — TypeScript does not warn on ignored `boolean`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function saveJsonConfig(path: string, data: unknown): boolean;
|
|
65
|
+
export interface GuidanceFields {
|
|
66
|
+
promptSnippet?: string;
|
|
67
|
+
promptGuidelines?: string[];
|
|
68
|
+
description?: string;
|
|
69
|
+
}
|
|
70
|
+
export declare const GuidanceFieldsSchema: TObject<{
|
|
71
|
+
promptSnippet: Type.TOptional<Type.TString>;
|
|
72
|
+
promptGuidelines: Type.TOptional<Type.TArray<Type.TString>>;
|
|
73
|
+
description: Type.TOptional<Type.TString>;
|
|
74
|
+
}>;
|
|
75
|
+
/**
|
|
76
|
+
* Validate and extract guidance fields from an unknown value.
|
|
77
|
+
*
|
|
78
|
+
* Returns a clean `GuidanceFields` object with only valid entries.
|
|
79
|
+
* Byte-identical logic previously in rpiv-todo, rpiv-ask-user-question,
|
|
80
|
+
* rpiv-advisor, and rpiv-web-tools.
|
|
81
|
+
*/
|
|
82
|
+
export declare function validateGuidanceFields(fields: unknown): GuidanceFields;
|
|
83
|
+
/**
|
|
84
|
+
* Parse a model key string into its components.
|
|
85
|
+
*
|
|
86
|
+
* Accepts EITHER separator on read:
|
|
87
|
+
* - "provider/modelId" — canonical form (emitted by modelKey and persisted
|
|
88
|
+
* by post-slash-canonical-migration consumers).
|
|
89
|
+
* - "provider:modelId" — legacy form (persisted by released rpiv-advisor
|
|
90
|
+
* 1.16+ before the migration). Auto-rewritten on the next save by any
|
|
91
|
+
* consumer that re-serialises via modelKey.
|
|
92
|
+
*
|
|
93
|
+
* Slash is preferred when present — a key like "provider:foo/bar" splits on
|
|
94
|
+
* `/`, so the modelId is "bar" rather than re-introducing the legacy
|
|
95
|
+
* interpretation. No current model id contains a `/` so this asymmetry has
|
|
96
|
+
* no real-world ambiguity.
|
|
97
|
+
*/
|
|
98
|
+
export declare function parseModelKey(key: string): {
|
|
99
|
+
provider: string;
|
|
100
|
+
modelId: string;
|
|
101
|
+
} | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Compose the canonical "provider/modelId" string from provider and modelId
|
|
104
|
+
* components. Slash-only emission; paired with parseModelKey's tolerant read,
|
|
105
|
+
* legacy colon-form persisted values auto-migrate the next time any consumer
|
|
106
|
+
* re-serialises through this codec.
|
|
107
|
+
*/
|
|
108
|
+
export declare function modelKey(m: {
|
|
109
|
+
provider: string;
|
|
110
|
+
id: string;
|
|
111
|
+
}): string;
|
|
112
|
+
/**
|
|
113
|
+
* Read an environment variable with optional fallback.
|
|
114
|
+
*
|
|
115
|
+
* Trims whitespace from the env value. Returns `fallback` (or `undefined`)
|
|
116
|
+
* when the variable is unset or empty after trimming.
|
|
117
|
+
*/
|
|
118
|
+
export declare function readEnvVar(key: string, fallback?: string): string | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Validate and clean a config value against a TypeBox schema.
|
|
121
|
+
*
|
|
122
|
+
* 1. Guards against non-plain-object input (returns `{}` for primitives, arrays).
|
|
123
|
+
* 2. Clones the input (Value.Clean mutates).
|
|
124
|
+
* 3. Strips unknown properties via `Value.Clean`.
|
|
125
|
+
* 4. Applies schema defaults via `Value.Create` (spread merge: defaults
|
|
126
|
+
* provide base, cleaned value overrides).
|
|
127
|
+
* 5. Returns the validated, cleaned object typed as the schema's static type.
|
|
128
|
+
*
|
|
129
|
+
* Falls back to `{}` on any failure — same fail-soft contract as `loadJsonConfig`.
|
|
130
|
+
*/
|
|
131
|
+
export declare function validateConfig<T extends TObject>(schema: T, value: unknown): Static<T>;
|
|
132
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/humain/ask-user-question/vendor/config/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AA0D1D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAsB,GAAG,MAAM,CAE7E;AAMD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAejD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gCAAgC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAsB,GAAG,CAAC,CAMjG;AASD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAanE;AAMD,MAAM,WAAW,cAAc;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAUD,eAAO,MAAM,oBAAoB;;;;EAOhC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,cAAc,CAkBtE;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAM5F;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEpE;AAMD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE7E;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAWtF"}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* rpiv-config — shared config I/O utilities for rpiv-mono sibling packages.
|
|
3
|
+
*
|
|
4
|
+
* Provides JSON config load/save with crash-resistant defaults, path resolution,
|
|
5
|
+
* guidance-field validation, env-var fallback, and TypeBox-driven schema validation.
|
|
6
|
+
* Stateless — no module-level singletons, no globalThis caches, no side effects.
|
|
7
|
+
*/
|
|
8
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
9
|
+
import { homedir } from "node:os";
|
|
10
|
+
import { dirname, isAbsolute, join } from "node:path";
|
|
11
|
+
import { Type } from "typebox";
|
|
12
|
+
import { Value } from "typebox/value";
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Path resolution
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
/**
|
|
17
|
+
* Expand a leading `~` to the user's home directory. Mirrors Pi's
|
|
18
|
+
* `expandTildePath`. Uses `join` (not string concatenation) so the path
|
|
19
|
+
* separator is correct on every platform.
|
|
20
|
+
*
|
|
21
|
+
* Contract: only bare `~` and `~/…` expand. A `~user` form is returned
|
|
22
|
+
* unchanged (the XDG spec defines no `~user` expansion), so it fails the
|
|
23
|
+
* downstream `isAbsolute` check and routes to the default config dir.
|
|
24
|
+
*/
|
|
25
|
+
function expandTilde(p) {
|
|
26
|
+
if (p === "~")
|
|
27
|
+
return homedir();
|
|
28
|
+
if (p.startsWith("~/"))
|
|
29
|
+
return join(homedir(), p.slice(2));
|
|
30
|
+
return p;
|
|
31
|
+
}
|
|
32
|
+
/** Default config directory: `~/.config`. Single source of the `.config` literal. */
|
|
33
|
+
function defaultConfigDir() {
|
|
34
|
+
return join(homedir(), ".config");
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Resolve the config directory honoring `XDG_CONFIG_HOME`.
|
|
38
|
+
*
|
|
39
|
+
* Boundary: `XDG_CONFIG_HOME` governs the rpiv-* sibling config layer only.
|
|
40
|
+
* Pi-native paths (`~/.pi/…`, driven by `PI_CODING_AGENT_DIR`) are a separate,
|
|
41
|
+
* orthogonal concern and are intentionally NOT unified here.
|
|
42
|
+
*
|
|
43
|
+
* XDG spec compliance:
|
|
44
|
+
* - unset / empty-after-trim / whitespace-only → default (`~/.config`)
|
|
45
|
+
* - relative path → default (XDG mandates absolute)
|
|
46
|
+
* - `"~"` or `"~/…"` → expand the tilde, then require absolute
|
|
47
|
+
* - `"~user…"` → NOT expanded (XDG defines no `~user` form); silently
|
|
48
|
+
* routes to the default like any other relative path
|
|
49
|
+
* - absolute → used verbatim
|
|
50
|
+
*/
|
|
51
|
+
function resolveConfigDir() {
|
|
52
|
+
const xdg = readEnvVar("XDG_CONFIG_HOME");
|
|
53
|
+
if (!xdg)
|
|
54
|
+
return defaultConfigDir();
|
|
55
|
+
const expanded = expandTilde(xdg);
|
|
56
|
+
return isAbsolute(expanded) ? expanded : defaultConfigDir();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Always-legacy config path under `~/.config`. Used by the legacy-fallback
|
|
60
|
+
* reader so a pre-XDG config file is still discovered after an operator sets
|
|
61
|
+
* `XDG_CONFIG_HOME`. Ignores `XDG_CONFIG_HOME` by design.
|
|
62
|
+
*/
|
|
63
|
+
function legacyConfigPath(name, file = "config.json") {
|
|
64
|
+
return join(defaultConfigDir(), name, file);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Resolve a config file path under the XDG-aware config directory.
|
|
68
|
+
*
|
|
69
|
+
* `<resolveConfigDir()>/<name>/<file>` — defaults to `~/.config/<name>/config.json`
|
|
70
|
+
* when `XDG_CONFIG_HOME` is unset / empty / whitespace / relative.
|
|
71
|
+
*
|
|
72
|
+
* Boundary: `XDG_CONFIG_HOME` governs the rpiv-* sibling config layer only;
|
|
73
|
+
* Pi-native paths (`~/.pi/…`, via `PI_CODING_AGENT_DIR`) are orthogonal and
|
|
74
|
+
* not unified here.
|
|
75
|
+
*
|
|
76
|
+
* @param name — package directory name (e.g. "rpiv-todo")
|
|
77
|
+
* @param file — config filename (defaults to "config.json")
|
|
78
|
+
* @returns absolute path to the config file
|
|
79
|
+
*/
|
|
80
|
+
export function configPath(name, file = "config.json") {
|
|
81
|
+
return join(resolveConfigDir(), name, file);
|
|
82
|
+
}
|
|
83
|
+
// ---------------------------------------------------------------------------
|
|
84
|
+
// JSON config load — Variant A (with typeof guard) universally
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
/**
|
|
87
|
+
* Load and parse a JSON config file.
|
|
88
|
+
*
|
|
89
|
+
* Returns `{}` for missing files, malformed JSON, or non-plain-object values.
|
|
90
|
+
* The typeof guard fixes a latent bug where valid non-object JSON
|
|
91
|
+
* (e.g. `"hello"`, `42`, `null`) passes through the cast. Arrays are also
|
|
92
|
+
* rejected — `typeof [] === "object"` in JavaScript, but config files are
|
|
93
|
+
* always plain objects.
|
|
94
|
+
*/
|
|
95
|
+
export function loadJsonConfig(path) {
|
|
96
|
+
if (!existsSync(path))
|
|
97
|
+
return {};
|
|
98
|
+
try {
|
|
99
|
+
const parsed = JSON.parse(readFileSync(path, "utf-8"));
|
|
100
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
|
|
101
|
+
return {};
|
|
102
|
+
return parsed;
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
// Diagnostic for malformed-JSON path. Silent save + silent load otherwise
|
|
106
|
+
// produce identical user-visible symptoms (state reverts on next start)
|
|
107
|
+
// with zero diagnostic surface — the user cannot tell "never saved" from
|
|
108
|
+
// "saved-but-unreadable." Warning is owner-only since the file lives in
|
|
109
|
+
// the user's HOME.
|
|
110
|
+
console.warn(`rpiv-config: invalid JSON at ${path}, using default ({}) — ${err.message}`);
|
|
111
|
+
return {};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Load a JSON config, preferring the XDG-resolved path and falling back to the
|
|
116
|
+
* legacy `~/.config/<name>/<file>` location only when the XDG path is missing.
|
|
117
|
+
*
|
|
118
|
+
* - XDG file present (valid or malformed) → its parse result wins. A malformed
|
|
119
|
+
* XDG file warns and returns `{}` but does NOT silently fall back to legacy —
|
|
120
|
+
* corruption is surfaced, not masked.
|
|
121
|
+
* - XDG file missing → read the legacy path (which returns `{}` if also missing,
|
|
122
|
+
* or warns + `{}` if malformed).
|
|
123
|
+
* - Both missing → `{}`.
|
|
124
|
+
*
|
|
125
|
+
* @param name — package directory name (e.g. "rpiv-todo")
|
|
126
|
+
* @param file — config filename (defaults to "config.json")
|
|
127
|
+
*/
|
|
128
|
+
export function loadJsonConfigWithLegacyFallback(name, file = "config.json") {
|
|
129
|
+
const xdgPath = configPath(name, file);
|
|
130
|
+
if (existsSync(xdgPath)) {
|
|
131
|
+
return loadJsonConfig(xdgPath);
|
|
132
|
+
}
|
|
133
|
+
return loadJsonConfig(legacyConfigPath(name, file));
|
|
134
|
+
}
|
|
135
|
+
// ---------------------------------------------------------------------------
|
|
136
|
+
// JSON config save — best-effort void
|
|
137
|
+
// ---------------------------------------------------------------------------
|
|
138
|
+
/** File mode for config files (user read/write only). */
|
|
139
|
+
const CONFIG_FILE_MODE = 0o600;
|
|
140
|
+
/**
|
|
141
|
+
* Persist a config object as formatted JSON. Returns `true` on successful
|
|
142
|
+
* mkdir+write, `false` on filesystem failure (disk full, EACCES, EROFS, …).
|
|
143
|
+
*
|
|
144
|
+
* Every current rpiv-* save call site is user-initiated and shows a
|
|
145
|
+
* "Saved …" notification — callers MUST guard the success notification on
|
|
146
|
+
* the boolean return so a silent disk failure can't make the success message
|
|
147
|
+
* lie on disk-full / EACCES.
|
|
148
|
+
*
|
|
149
|
+
* The chmod step is best-effort and never affects the return value: some
|
|
150
|
+
* filesystems (tmpfs, network mounts, Windows-style perms) silently ignore
|
|
151
|
+
* chmod and there is no portable way to enforce 0600 perms across platforms.
|
|
152
|
+
* Callers that genuinely don't care about persistence outcome can discard
|
|
153
|
+
* the return — TypeScript does not warn on ignored `boolean`.
|
|
154
|
+
*/
|
|
155
|
+
export function saveJsonConfig(path, data) {
|
|
156
|
+
try {
|
|
157
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
158
|
+
writeFileSync(path, `${JSON.stringify(data, null, 2)}\n`, "utf-8");
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
chmodSync(path, CONFIG_FILE_MODE);
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
// chmod may fail on some filesystems — best effort only, never gates success
|
|
168
|
+
}
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
// TypeBox form of GuidanceFields. Mirrors the interface 1:1 — same fields,
|
|
172
|
+
// same optionality. `additionalProperties: true` lets consumers compose
|
|
173
|
+
// wrappers that may carry sibling-specific keys without those leaking back
|
|
174
|
+
// into rpiv-config. The runtime invariants (string fields must be non-empty,
|
|
175
|
+
// the array field must be non-empty and contain only non-empty strings) are
|
|
176
|
+
// still enforced by `validateGuidanceFields`; the schema is a structural
|
|
177
|
+
// type-narrowing aid for callers that bake guidance into a larger
|
|
178
|
+
// TypeBox-validated config object.
|
|
179
|
+
export const GuidanceFieldsSchema = Type.Object({
|
|
180
|
+
promptSnippet: Type.Optional(Type.String()),
|
|
181
|
+
promptGuidelines: Type.Optional(Type.Array(Type.String())),
|
|
182
|
+
description: Type.Optional(Type.String()),
|
|
183
|
+
}, { additionalProperties: true });
|
|
184
|
+
/**
|
|
185
|
+
* Validate and extract guidance fields from an unknown value.
|
|
186
|
+
*
|
|
187
|
+
* Returns a clean `GuidanceFields` object with only valid entries.
|
|
188
|
+
* Byte-identical logic previously in rpiv-todo, rpiv-ask-user-question,
|
|
189
|
+
* rpiv-advisor, and rpiv-web-tools.
|
|
190
|
+
*/
|
|
191
|
+
export function validateGuidanceFields(fields) {
|
|
192
|
+
if (!fields || typeof fields !== "object")
|
|
193
|
+
return {};
|
|
194
|
+
const g = fields;
|
|
195
|
+
const result = {};
|
|
196
|
+
if (typeof g.promptSnippet === "string" && g.promptSnippet.length > 0) {
|
|
197
|
+
result.promptSnippet = g.promptSnippet;
|
|
198
|
+
}
|
|
199
|
+
if (Array.isArray(g.promptGuidelines) &&
|
|
200
|
+
g.promptGuidelines.length > 0 &&
|
|
201
|
+
g.promptGuidelines.every((s) => typeof s === "string" && s.length > 0)) {
|
|
202
|
+
result.promptGuidelines = g.promptGuidelines;
|
|
203
|
+
}
|
|
204
|
+
if (typeof g.description === "string" && g.description.length > 0) {
|
|
205
|
+
result.description = g.description;
|
|
206
|
+
}
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
209
|
+
// ---------------------------------------------------------------------------
|
|
210
|
+
// Model key codec — provider:id string ↔ { provider, modelId } object.
|
|
211
|
+
// ---------------------------------------------------------------------------
|
|
212
|
+
/**
|
|
213
|
+
* Parse a model key string into its components.
|
|
214
|
+
*
|
|
215
|
+
* Accepts EITHER separator on read:
|
|
216
|
+
* - "provider/modelId" — canonical form (emitted by modelKey and persisted
|
|
217
|
+
* by post-slash-canonical-migration consumers).
|
|
218
|
+
* - "provider:modelId" — legacy form (persisted by released rpiv-advisor
|
|
219
|
+
* 1.16+ before the migration). Auto-rewritten on the next save by any
|
|
220
|
+
* consumer that re-serialises via modelKey.
|
|
221
|
+
*
|
|
222
|
+
* Slash is preferred when present — a key like "provider:foo/bar" splits on
|
|
223
|
+
* `/`, so the modelId is "bar" rather than re-introducing the legacy
|
|
224
|
+
* interpretation. No current model id contains a `/` so this asymmetry has
|
|
225
|
+
* no real-world ambiguity.
|
|
226
|
+
*/
|
|
227
|
+
export function parseModelKey(key) {
|
|
228
|
+
const slashIdx = key.indexOf("/");
|
|
229
|
+
if (slashIdx >= 1)
|
|
230
|
+
return { provider: key.slice(0, slashIdx), modelId: key.slice(slashIdx + 1) };
|
|
231
|
+
const colonIdx = key.indexOf(":");
|
|
232
|
+
if (colonIdx >= 1)
|
|
233
|
+
return { provider: key.slice(0, colonIdx), modelId: key.slice(colonIdx + 1) };
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Compose the canonical "provider/modelId" string from provider and modelId
|
|
238
|
+
* components. Slash-only emission; paired with parseModelKey's tolerant read,
|
|
239
|
+
* legacy colon-form persisted values auto-migrate the next time any consumer
|
|
240
|
+
* re-serialises through this codec.
|
|
241
|
+
*/
|
|
242
|
+
export function modelKey(m) {
|
|
243
|
+
return `${m.provider}/${m.id}`;
|
|
244
|
+
}
|
|
245
|
+
// ---------------------------------------------------------------------------
|
|
246
|
+
// Env-var fallback
|
|
247
|
+
// ---------------------------------------------------------------------------
|
|
248
|
+
/**
|
|
249
|
+
* Read an environment variable with optional fallback.
|
|
250
|
+
*
|
|
251
|
+
* Trims whitespace from the env value. Returns `fallback` (or `undefined`)
|
|
252
|
+
* when the variable is unset or empty after trimming.
|
|
253
|
+
*/
|
|
254
|
+
export function readEnvVar(key, fallback) {
|
|
255
|
+
return process.env[key]?.trim() || fallback;
|
|
256
|
+
}
|
|
257
|
+
// ---------------------------------------------------------------------------
|
|
258
|
+
// TypeBox-driven schema validation
|
|
259
|
+
// ---------------------------------------------------------------------------
|
|
260
|
+
/**
|
|
261
|
+
* Validate and clean a config value against a TypeBox schema.
|
|
262
|
+
*
|
|
263
|
+
* 1. Guards against non-plain-object input (returns `{}` for primitives, arrays).
|
|
264
|
+
* 2. Clones the input (Value.Clean mutates).
|
|
265
|
+
* 3. Strips unknown properties via `Value.Clean`.
|
|
266
|
+
* 4. Applies schema defaults via `Value.Create` (spread merge: defaults
|
|
267
|
+
* provide base, cleaned value overrides).
|
|
268
|
+
* 5. Returns the validated, cleaned object typed as the schema's static type.
|
|
269
|
+
*
|
|
270
|
+
* Falls back to `{}` on any failure — same fail-soft contract as `loadJsonConfig`.
|
|
271
|
+
*/
|
|
272
|
+
export function validateConfig(schema, value) {
|
|
273
|
+
try {
|
|
274
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
275
|
+
return {};
|
|
276
|
+
const cleaned = Value.Clean(schema, Value.Clone(value));
|
|
277
|
+
const defaults = Value.Create(schema);
|
|
278
|
+
// Merge: defaults as base, cleaned values override.
|
|
279
|
+
// Both are plain objects from TypeBox operations — safe spread via Record cast.
|
|
280
|
+
return { ...defaults, ...cleaned };
|
|
281
|
+
}
|
|
282
|
+
catch {
|
|
283
|
+
return {};
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../src/humain/ask-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C","sourcesContent":["/**\n * rpiv-config — shared config I/O utilities for rpiv-mono sibling packages.\n *\n * Provides JSON config load/save with crash-resistant defaults, path resolution,\n * guidance-field validation, env-var fallback, and TypeBox-driven schema validation.\n * Stateless — no module-level singletons, no globalThis caches, no side effects.\n */\n\nimport { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, isAbsolute, join } from \"node:path\";\nimport { type Static, type TObject, Type } from \"typebox\";\nimport { Value } from \"typebox/value\";\n\n// ---------------------------------------------------------------------------\n// Path resolution\n// ---------------------------------------------------------------------------\n\n/**\n * Expand a leading `~` to the user's home directory. Mirrors Pi's\n * `expandTildePath`. Uses `join` (not string concatenation) so the path\n * separator is correct on every platform.\n *\n * Contract: only bare `~` and `~/…` expand. A `~user` form is returned\n * unchanged (the XDG spec defines no `~user` expansion), so it fails the\n * downstream `isAbsolute` check and routes to the default config dir.\n */\nfunction expandTilde(p: string): string {\n\tif (p === \"~\") return homedir();\n\tif (p.startsWith(\"~/\")) return join(homedir(), p.slice(2));\n\treturn p;\n}\n\n/** Default config directory: `~/.config`. Single source of the `.config` literal. */\nfunction defaultConfigDir(): string {\n\treturn join(homedir(), \".config\");\n}\n\n/**\n * Resolve the config directory honoring `XDG_CONFIG_HOME`.\n *\n * Boundary: `XDG_CONFIG_HOME` governs the rpiv-* sibling config layer only.\n * Pi-native paths (`~/.pi/…`, driven by `PI_CODING_AGENT_DIR`) are a separate,\n * orthogonal concern and are intentionally NOT unified here.\n *\n * XDG spec compliance:\n * - unset / empty-after-trim / whitespace-only → default (`~/.config`)\n * - relative path → default (XDG mandates absolute)\n * - `\"~\"` or `\"~/…\"` → expand the tilde, then require absolute\n * - `\"~user…\"` → NOT expanded (XDG defines no `~user` form); silently\n * routes to the default like any other relative path\n * - absolute → used verbatim\n */\nfunction resolveConfigDir(): string {\n\tconst xdg = readEnvVar(\"XDG_CONFIG_HOME\");\n\tif (!xdg) return defaultConfigDir();\n\tconst expanded = expandTilde(xdg);\n\treturn isAbsolute(expanded) ? expanded : defaultConfigDir();\n}\n\n/**\n * Always-legacy config path under `~/.config`. Used by the legacy-fallback\n * reader so a pre-XDG config file is still discovered after an operator sets\n * `XDG_CONFIG_HOME`. Ignores `XDG_CONFIG_HOME` by design.\n */\nfunction legacyConfigPath(name: string, file: string = \"config.json\"): string {\n\treturn join(defaultConfigDir(), name, file);\n}\n\n/**\n * Resolve a config file path under the XDG-aware config directory.\n *\n * `<resolveConfigDir()>/<name>/<file>` — defaults to `~/.config/<name>/config.json`\n * when `XDG_CONFIG_HOME` is unset / empty / whitespace / relative.\n *\n * Boundary: `XDG_CONFIG_HOME` governs the rpiv-* sibling config layer only;\n * Pi-native paths (`~/.pi/…`, via `PI_CODING_AGENT_DIR`) are orthogonal and\n * not unified here.\n *\n * @param name — package directory name (e.g. \"rpiv-todo\")\n * @param file — config filename (defaults to \"config.json\")\n * @returns absolute path to the config file\n */\nexport function configPath(name: string, file: string = \"config.json\"): string {\n\treturn join(resolveConfigDir(), name, file);\n}\n\n// ---------------------------------------------------------------------------\n// JSON config load — Variant A (with typeof guard) universally\n// ---------------------------------------------------------------------------\n\n/**\n * Load and parse a JSON config file.\n *\n * Returns `{}` for missing files, malformed JSON, or non-plain-object values.\n * The typeof guard fixes a latent bug where valid non-object JSON\n * (e.g. `\"hello\"`, `42`, `null`) passes through the cast. Arrays are also\n * rejected — `typeof [] === \"object\"` in JavaScript, but config files are\n * always plain objects.\n */\nexport function loadJsonConfig<T>(path: string): T {\n\tif (!existsSync(path)) return {} as T;\n\ttry {\n\t\tconst parsed = JSON.parse(readFileSync(path, \"utf-8\")) as unknown;\n\t\tif (parsed === null || typeof parsed !== \"object\" || Array.isArray(parsed)) return {} as T;\n\t\treturn parsed as T;\n\t} catch (err) {\n\t\t// Diagnostic for malformed-JSON path. Silent save + silent load otherwise\n\t\t// produce identical user-visible symptoms (state reverts on next start)\n\t\t// with zero diagnostic surface — the user cannot tell \"never saved\" from\n\t\t// \"saved-but-unreadable.\" Warning is owner-only since the file lives in\n\t\t// the user's HOME.\n\t\tconsole.warn(`rpiv-config: invalid JSON at ${path}, using default ({}) — ${(err as Error).message}`);\n\t\treturn {} as T;\n\t}\n}\n\n/**\n * Load a JSON config, preferring the XDG-resolved path and falling back to the\n * legacy `~/.config/<name>/<file>` location only when the XDG path is missing.\n *\n * - XDG file present (valid or malformed) → its parse result wins. A malformed\n * XDG file warns and returns `{}` but does NOT silently fall back to legacy —\n * corruption is surfaced, not masked.\n * - XDG file missing → read the legacy path (which returns `{}` if also missing,\n * or warns + `{}` if malformed).\n * - Both missing → `{}`.\n *\n * @param name — package directory name (e.g. \"rpiv-todo\")\n * @param file — config filename (defaults to \"config.json\")\n */\nexport function loadJsonConfigWithLegacyFallback<T>(name: string, file: string = \"config.json\"): T {\n\tconst xdgPath = configPath(name, file);\n\tif (existsSync(xdgPath)) {\n\t\treturn loadJsonConfig<T>(xdgPath);\n\t}\n\treturn loadJsonConfig<T>(legacyConfigPath(name, file));\n}\n\n// ---------------------------------------------------------------------------\n// JSON config save — best-effort void\n// ---------------------------------------------------------------------------\n\n/** File mode for config files (user read/write only). */\nconst CONFIG_FILE_MODE = 0o600;\n\n/**\n * Persist a config object as formatted JSON. Returns `true` on successful\n * mkdir+write, `false` on filesystem failure (disk full, EACCES, EROFS, …).\n *\n * Every current rpiv-* save call site is user-initiated and shows a\n * \"Saved …\" notification — callers MUST guard the success notification on\n * the boolean return so a silent disk failure can't make the success message\n * lie on disk-full / EACCES.\n *\n * The chmod step is best-effort and never affects the return value: some\n * filesystems (tmpfs, network mounts, Windows-style perms) silently ignore\n * chmod and there is no portable way to enforce 0600 perms across platforms.\n * Callers that genuinely don't care about persistence outcome can discard\n * the return — TypeScript does not warn on ignored `boolean`.\n */\nexport function saveJsonConfig(path: string, data: unknown): boolean {\n\ttry {\n\t\tmkdirSync(dirname(path), { recursive: true });\n\t\twriteFileSync(path, `${JSON.stringify(data, null, 2)}\\n`, \"utf-8\");\n\t} catch {\n\t\treturn false;\n\t}\n\ttry {\n\t\tchmodSync(path, CONFIG_FILE_MODE);\n\t} catch {\n\t\t// chmod may fail on some filesystems — best effort only, never gates success\n\t}\n\treturn true;\n}\n\n// ---------------------------------------------------------------------------\n// GuidanceFields — extracted from 4 byte-identical copies\n// ---------------------------------------------------------------------------\n\nexport interface GuidanceFields {\n\tpromptSnippet?: string;\n\tpromptGuidelines?: string[];\n\tdescription?: string;\n}\n\n// TypeBox form of GuidanceFields. Mirrors the interface 1:1 — same fields,\n// same optionality. `additionalProperties: true` lets consumers compose\n// wrappers that may carry sibling-specific keys without those leaking back\n// into rpiv-config. The runtime invariants (string fields must be non-empty,\n// the array field must be non-empty and contain only non-empty strings) are\n// still enforced by `validateGuidanceFields`; the schema is a structural\n// type-narrowing aid for callers that bake guidance into a larger\n// TypeBox-validated config object.\nexport const GuidanceFieldsSchema = Type.Object(\n\t{\n\t\tpromptSnippet: Type.Optional(Type.String()),\n\t\tpromptGuidelines: Type.Optional(Type.Array(Type.String())),\n\t\tdescription: Type.Optional(Type.String()),\n\t},\n\t{ additionalProperties: true },\n);\n\n/**\n * Validate and extract guidance fields from an unknown value.\n *\n * Returns a clean `GuidanceFields` object with only valid entries.\n * Byte-identical logic previously in rpiv-todo, rpiv-ask-user-question,\n * rpiv-advisor, and rpiv-web-tools.\n */\nexport function validateGuidanceFields(fields: unknown): GuidanceFields {\n\tif (!fields || typeof fields !== \"object\") return {};\n\tconst g = fields as Record<string, unknown>;\n\tconst result: GuidanceFields = {};\n\tif (typeof g.promptSnippet === \"string\" && g.promptSnippet.length > 0) {\n\t\tresult.promptSnippet = g.promptSnippet;\n\t}\n\tif (\n\t\tArray.isArray(g.promptGuidelines) &&\n\t\tg.promptGuidelines.length > 0 &&\n\t\tg.promptGuidelines.every((s) => typeof s === \"string\" && s.length > 0)\n\t) {\n\t\tresult.promptGuidelines = g.promptGuidelines;\n\t}\n\tif (typeof g.description === \"string\" && g.description.length > 0) {\n\t\tresult.description = g.description;\n\t}\n\treturn result;\n}\n\n// ---------------------------------------------------------------------------\n// Model key codec — provider:id string ↔ { provider, modelId } object.\n// ---------------------------------------------------------------------------\n\n/**\n * Parse a model key string into its components.\n *\n * Accepts EITHER separator on read:\n * - \"provider/modelId\" — canonical form (emitted by modelKey and persisted\n * by post-slash-canonical-migration consumers).\n * - \"provider:modelId\" — legacy form (persisted by released rpiv-advisor\n * 1.16+ before the migration). Auto-rewritten on the next save by any\n * consumer that re-serialises via modelKey.\n *\n * Slash is preferred when present — a key like \"provider:foo/bar\" splits on\n * `/`, so the modelId is \"bar\" rather than re-introducing the legacy\n * interpretation. No current model id contains a `/` so this asymmetry has\n * no real-world ambiguity.\n */\nexport function parseModelKey(key: string): { provider: string; modelId: string } | undefined {\n\tconst slashIdx = key.indexOf(\"/\");\n\tif (slashIdx >= 1) return { provider: key.slice(0, slashIdx), modelId: key.slice(slashIdx + 1) };\n\tconst colonIdx = key.indexOf(\":\");\n\tif (colonIdx >= 1) return { provider: key.slice(0, colonIdx), modelId: key.slice(colonIdx + 1) };\n\treturn undefined;\n}\n\n/**\n * Compose the canonical \"provider/modelId\" string from provider and modelId\n * components. Slash-only emission; paired with parseModelKey's tolerant read,\n * legacy colon-form persisted values auto-migrate the next time any consumer\n * re-serialises through this codec.\n */\nexport function modelKey(m: { provider: string; id: string }): string {\n\treturn `${m.provider}/${m.id}`;\n}\n\n// ---------------------------------------------------------------------------\n// Env-var fallback\n// ---------------------------------------------------------------------------\n\n/**\n * Read an environment variable with optional fallback.\n *\n * Trims whitespace from the env value. Returns `fallback` (or `undefined`)\n * when the variable is unset or empty after trimming.\n */\nexport function readEnvVar(key: string, fallback?: string): string | undefined {\n\treturn process.env[key]?.trim() || fallback;\n}\n\n// ---------------------------------------------------------------------------\n// TypeBox-driven schema validation\n// ---------------------------------------------------------------------------\n\n/**\n * Validate and clean a config value against a TypeBox schema.\n *\n * 1. Guards against non-plain-object input (returns `{}` for primitives, arrays).\n * 2. Clones the input (Value.Clean mutates).\n * 3. Strips unknown properties via `Value.Clean`.\n * 4. Applies schema defaults via `Value.Create` (spread merge: defaults\n * provide base, cleaned value overrides).\n * 5. Returns the validated, cleaned object typed as the schema's static type.\n *\n * Falls back to `{}` on any failure — same fail-soft contract as `loadJsonConfig`.\n */\nexport function validateConfig<T extends TObject>(schema: T, value: unknown): Static<T> {\n\ttry {\n\t\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) return {} as Static<T>;\n\t\tconst cleaned = Value.Clean(schema, Value.Clone(value));\n\t\tconst defaults = Value.Create(schema);\n\t\t// Merge: defaults as base, cleaned values override.\n\t\t// Both are plain objects from TypeBox operations — safe spread via Record cast.\n\t\treturn { ...(defaults as Record<string, unknown>), ...(cleaned as Record<string, unknown>) } as Static<T>;\n\t} catch {\n\t\treturn {} as Static<T>;\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/humain/ask-user-question/vendor/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EACV,KAAK,cAAc,EACnB,oBAAoB,EACpB,cAAc,EACd,gCAAgC,EAChC,QAAQ,EACR,aAAa,EACb,UAAU,EACV,cAAc,EACd,cAAc,EACd,sBAAsB,GACtB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/humain/ask-user-question/vendor/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EAEV,oBAAoB,EACpB,cAAc,EACd,gCAAgC,EAChC,QAAQ,EACR,aAAa,EACb,UAAU,EACV,cAAc,EACd,cAAc,EACd,sBAAsB,GACtB,MAAM,aAAa,CAAC","sourcesContent":["export {\n\tconfigPath,\n\ttype GuidanceFields,\n\tGuidanceFieldsSchema,\n\tloadJsonConfig,\n\tloadJsonConfigWithLegacyFallback,\n\tmodelKey,\n\tparseModelKey,\n\treadEnvVar,\n\tsaveJsonConfig,\n\tvalidateConfig,\n\tvalidateGuidanceFields,\n} from \"./config.ts\";\n"]}
|