@symerian/symi 2.5.8 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{accounts-qtxJ-6em.js → accounts-3dCrO3oZ.js} +1 -1
- package/dist/{accounts-tNElYrCH.js → accounts-BRw8yhIW.js} +21 -21
- package/dist/{accounts-CWktKM8a.js → accounts-BuZxOb3B.js} +1 -1
- package/dist/{active-listener-C9r8ZB9m.js → active-listener-CfHHV2SU.js} +1 -1
- package/dist/{agent-scope-BxoUQqgM.js → agent-scope-CpEJ0B88.js} +3 -3
- package/dist/{agents-CXloh6n_.js → agents-DQIz-_on.js} +4 -4
- package/dist/{agents.config-BuTzBaXf.js → agents.config-CIJRaVWl.js} +1 -1
- package/dist/{agents.config-BhAJXAtA.js → agents.config-D8WPDf-m.js} +1 -1
- package/dist/{audio-preflight-O3ASWbaG.js → audio-preflight-BVaaZWkg.js} +34 -34
- package/dist/{audio-preflight-C40mKAp7.js → audio-preflight-CPBOQV4I.js} +4 -4
- package/dist/{auth-choice-DvaVrSwn.js → auth-choice-BqFbNDuP.js} +1 -1
- package/dist/{auth-choice-Br6zT8iS.js → auth-choice-DTDyJL1r.js} +1 -1
- package/dist/{model-auth-DK43VicI.js → auth-profiles-DdK1Hxaa.js} +412 -412
- package/dist/{banner-BtqKaQZr.js → banner-DYDCxnDL.js} +1 -1
- package/dist/{bindings-B7Ke6LJi.js → bindings-BsHoBLIE.js} +2 -2
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +60 -60
- package/dist/bundled/bootstrap-extra-files/handler.js +6 -6
- package/dist/bundled/command-logger/handler.js +3 -3
- package/dist/bundled/session-memory/handler.js +61 -61
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/{channel-activity-CsM_hJ_s.js → channel-activity-B6G1jnQT.js} +2 -2
- package/dist/{channel-options-CfLxsV76.js → channel-options-CvHSm_Kx.js} +1 -1
- package/dist/{channel-options-DFHEgad5.js → channel-options-vBCJhJB7.js} +1 -1
- package/dist/{channel-web-D-jDDmWN.js → channel-web-CM2LyWZW.js} +1 -1
- package/dist/{channels-cli-BEZORT4N.js → channels-cli-D5H3Wcho.js} +4 -4
- package/dist/{channels-cli-CT6wdGT8.js → channels-cli-DzOjNNFn.js} +4 -4
- package/dist/{chrome-BFekevcE.js → chrome-D2SKJnR7.js} +24 -24
- package/dist/{chrome-CDJYxX5a.js → chrome-DkaXoP36.js} +5 -5
- package/dist/{chunk-BW5f05BR.js → chunk-09egQapi.js} +1 -1
- package/dist/{cli-kxxM9xT0.js → cli-8hqssnRJ.js} +1 -1
- package/dist/{cli-CkxvN9Cb.js → cli-DNZwCDRe.js} +1 -1
- package/dist/{command-registry-DsqA8NDd.js → command-registry-CHtN2HeK.js} +9 -9
- package/dist/{commands-registry-D7CTCQPm.js → commands-registry-Bfc7Uz0o.js} +4 -4
- package/dist/{completion-cli-mZMiIG7C.js → completion-cli-C8y_J5KC.js} +1 -1
- package/dist/{completion-cli-QCrjurdu.js → completion-cli-Cov6N3BO.js} +2 -2
- package/dist/{config-DRbjHIwD.js → config-5SdHIcHU.js} +6 -6
- package/dist/{config-cli-CS_0o9LY.js → config-cli-B2REEd2l.js} +1 -1
- package/dist/{config-cli-DLsLPE4o.js → config-cli-BwO0xAbV.js} +1 -1
- package/dist/{configure-T9J4bw0H.js → configure-BWSYSi2-.js} +3 -3
- package/dist/{configure-BX4aNf3w.js → configure-C6yNe33U.js} +3 -3
- package/dist/{conversation-label-DXUkoKcB.js → conversation-label-Onz2hiJh.js} +1 -1
- package/dist/{deliver-BH0l3UKW.js → deliver-C-37cZUe.js} +1 -1
- package/dist/{deliver-CvCK5Mm9.js → deliver-C46-vyqg.js} +11 -11
- package/dist/{diagnostic-CI0kRQkt.js → diagnostic-rPhsBoZz.js} +2 -2
- package/dist/{doctor-completion-BKydQfCM.js → doctor-completion-BKKzstt6.js} +1 -1
- package/dist/{doctor-completion-CTodkFg2.js → doctor-completion-D7CDLFLg.js} +1 -1
- package/dist/entry.js +1 -1
- package/dist/{command-format-BaxDnULz.js → env-BDXYbTKj.js} +10 -10
- package/dist/{errors-BoQgnc8X.js → errors-XIsvXeC-.js} +1 -1
- package/dist/extensionAPI.js +6 -6
- package/dist/{frontmatter-C_bv_0P8.js → frontmatter-CTR5f_Ez.js} +2 -2
- package/dist/{gateway-cli-CZnyhTAu.js → gateway-cli-BhFM4Bkm.js} +20 -18
- package/dist/{gateway-cli-DEpU3Bg3.js → gateway-cli-Datohp3m.js} +20 -18
- package/dist/{gemini-auth-CdSPHuLl.js → gemini-auth-Dy12ZAH3.js} +2 -2
- package/dist/{github-copilot-token-C_qUP7p5.js → github-copilot-token-cCYzSU9h.js} +1 -1
- package/dist/{glass-ui-ws-KbKXJGb5.js → glass-ui-ws-BzqfD_wX.js} +7 -7
- package/dist/{glass-ui-ws-BdBSYcsf.js → glass-ui-ws-D9yvYULL.js} +7 -7
- package/dist/{health-DQmyj-7z.js → health-BjwDRAdd.js} +1 -1
- package/dist/{health-z-YCZRhf.js → health-C5XJPwpt.js} +1 -1
- package/dist/{hooks-cli-4d-QhgRs.js → hooks-cli-CafMq9Vr.js} +2 -2
- package/dist/{hooks-cli-BRehYEXJ.js → hooks-cli-U12oVyLH.js} +2 -2
- package/dist/{image-B0wGflxA.js → image-CuzFLQWC.js} +7 -7
- package/dist/{image-CHzdaNJ4.js → image-DcpMiprB.js} +1 -1
- package/dist/{image-ops-CvJzsyvE.js → image-ops-C7CauEK8.js} +99 -99
- package/dist/{inbound-context-BlHX0H3E.js → inbound-context-DSDTl6Kj.js} +2 -2
- package/dist/index.js +6 -6
- package/dist/{ir-DccrnjsE.js → ir-CTiz95Vb.js} +5 -5
- package/dist/llm-slug-generator.js +64 -84
- package/dist/{local-roots-DMwIh5cS.js → local-roots-DhZz0Ybs.js} +6 -6
- package/dist/{login-qr-Batf3PT5.js → login-qr-AP9agO-i.js} +13 -13
- package/dist/{login-CwCoxapk.js → login-ul8zaw_S.js} +7 -7
- package/dist/{manager-D_LwXbc6.js → manager-PprhCvO_.js} +25 -25
- package/dist/{manifest-registry-D0IQ3WuX.js → manifest-registry-yb7sAlu4.js} +2 -2
- package/dist/{markdown-tables-iMQQZu4Q.js → markdown-tables-C-BmIap8.js} +1 -1
- package/dist/{message-channel-Dz5lr5b0.js → message-channel-OlFBYAw8.js} +1 -1
- package/dist/{models-CPlSSoV0.js → models-Bo4iHJy-.js} +7 -8
- package/dist/{models-cli-BM2RWTmM.js → models-cli-6aNi3eN9.js} +7 -8
- package/dist/{models-cli-DDhpJuX3.js → models-cli-B5vh-XK8.js} +3 -3
- package/dist/{onboard-DpB21qno.js → onboard-Bm-pmstf.js} +2 -2
- package/dist/{onboard-channels-DjfS9mS6.js → onboard-channels-BRd1cXye.js} +1 -1
- package/dist/{onboard-channels-S0FbC25u.js → onboard-channels-CUl5U8kV.js} +1 -1
- package/dist/{onboard-BczLOUCW.js → onboard-f-GJ26Ix.js} +2 -2
- package/dist/{onboarding-CyPkawbg.js → onboarding-CvBDWlBJ.js} +3 -3
- package/dist/{onboarding--mrKZtpR.js → onboarding-DIVKvosg.js} +3 -3
- package/dist/{onboarding.finalize-0XoI3wLH.js → onboarding.finalize-DJX6mSLa.js} +6 -6
- package/dist/{onboarding.finalize-C0ijhYbg.js → onboarding.finalize-WSac-JKd.js} +5 -5
- package/dist/{outbound-D4fN_ZlE.js → outbound-CtMCmwxR.js} +7 -7
- package/dist/{outbound-attachment-DjNDa3zn.js → outbound-attachment-DJldbweZ.js} +2 -2
- package/dist/{paths-DLyHUt31.js → paths-CbQV9WEg.js} +2 -2
- package/dist/{pi-auth-json-0SYBFZTt.js → pi-auth-json-Bk8ERadJ.js} +10 -10
- package/dist/{pi-embedded-Cg70pjmm.js → pi-embedded-BmbbC1Sb.js} +20275 -20070
- package/dist/{pi-embedded-helpers-lgx_U5KS.js → pi-embedded-helpers-B8kqLWns.js} +4 -4
- package/dist/{pi-embedded-helpers-DLFjnVBb.js → pi-embedded-helpers-CfqDGQ9J.js} +81 -81
- package/dist/{plugin-registry-VhRGXCLQ.js → plugin-registry-2zUJMasm.js} +1 -1
- package/dist/{plugin-registry-Dxo1iUfJ.js → plugin-registry-5yf-hu_W.js} +1 -1
- package/dist/plugin-sdk/agents/model-token-filter.d.ts +10 -0
- package/dist/plugin-sdk/agents/pi-embedded-runner.d.ts +1 -1
- package/dist/plugin-sdk/agents/pi-tools.validate-wrapper.d.ts +23 -0
- package/dist/plugin-sdk/agents/pi-tools.validate.d.ts +26 -0
- package/dist/plugin-sdk/agents/tool-loop-detection.d.ts +3 -1
- package/dist/plugin-sdk/agents/unified-runner.d.ts +69 -1
- package/dist/plugin-sdk/auto-reply/reply/agent-runner-execution.d.ts +2 -2
- package/dist/plugin-sdk/{channel-web-DKo2tOO-.js → channel-web-DPyyTvFo.js} +1 -1
- package/dist/plugin-sdk/config/model-profiles.d.ts +2 -0
- package/dist/plugin-sdk/index.js +2 -2
- package/dist/plugin-sdk/infra/diagnostic-events.d.ts +1 -1
- package/dist/plugin-sdk/logging/diagnostic-session-state.d.ts +2 -0
- package/dist/plugin-sdk/logging/diagnostic.d.ts +1 -1
- package/dist/plugin-sdk/{reply-Ch4_18FZ.js → reply-QAcAd9ev.js} +536 -331
- package/dist/plugin-sdk/{tool-loop-detection-edmW8ZiF.js → tool-loop-detection-DU5sTIKg.js} +53 -3
- package/dist/plugin-sdk/{web-Dz2oyzw_.js → web-DaTTL9M0.js} +2 -2
- package/dist/{plugins-DQYI3Fr-.js → plugins-BzmbgY7s.js} +5 -5
- package/dist/{plugins-cli-zNr1ThAO.js → plugins-cli-D4eRESV2.js} +2 -2
- package/dist/{plugins-cli-DeDSnKlr.js → plugins-cli-DksVl33N.js} +2 -2
- package/dist/{program-COEKTv5u.js → program-BjORH7Cc.js} +7 -7
- package/dist/{program-context-CbM3x8lT.js → program-context-DaNGrTOm.js} +17 -17
- package/dist/{prompt-select-styled-d18_XWTb.js → prompt-select-styled-QaS2zul_.js} +4 -4
- package/dist/{prompt-select-styled-C6JLWNMU.js → prompt-select-styled-YOj4xigd.js} +4 -4
- package/dist/{provider-auth-helpers-BmH4oHwJ.js → provider-auth-helpers-BAGT_RXV.js} +1 -1
- package/dist/{provider-auth-helpers-C8cO9DLi.js → provider-auth-helpers-DCEbm2hz.js} +1 -1
- package/dist/{push-apns-CoqskfCc.js → push-apns-BECodU1i.js} +1 -1
- package/dist/{push-apns-CJtWrkQV.js → push-apns-Bek3ANJa.js} +1 -1
- package/dist/{pw-ai-De-KR9_s.js → pw-ai-1htA-NnS.js} +1 -1
- package/dist/{pw-ai-BnAKvSuw.js → pw-ai-m0mj2KWK.js} +16 -16
- package/dist/{qmd-manager-QHUP-_em.js → qmd-manager-iDLSiI4Z.js} +10 -10
- package/dist/{register.agent-C1Is84Q1.js → register.agent-B34lxx7F.js} +5 -5
- package/dist/{register.agent-fK3vOCU5.js → register.agent-DJHQo-Iq.js} +6 -6
- package/dist/{register.configure-CIwwqqt9.js → register.configure-BdhhIzb0.js} +6 -6
- package/dist/{register.configure-DFJeKFFK.js → register.configure-DC_-t5kj.js} +6 -6
- package/dist/{register.maintenance-BwTFd3Ax.js → register.maintenance-CITur3O_.js} +8 -8
- package/dist/{register.maintenance-DKDqruW6.js → register.maintenance-cs-A4kHF.js} +7 -7
- package/dist/{register.message-DYnXMP4c.js → register.message--RhtnEYn.js} +2 -2
- package/dist/{register.message-Ce57RPK8.js → register.message-PIaHm2pZ.js} +2 -2
- package/dist/{register.onboard-9glf-j43.js → register.onboard-CTJQoDcK.js} +4 -4
- package/dist/{register.onboard-Dj-_AJQr.js → register.onboard-DucZgrF7.js} +4 -4
- package/dist/{register.setup-C0CXUMFE.js → register.setup-2ZiUN7ui.js} +4 -4
- package/dist/{register.setup-Cp3DBI6D.js → register.setup-DD4Rgkt9.js} +4 -4
- package/dist/{register.status-health-sessions-DBXMyrNP.js → register.status-health-sessions-BqD7L8XL.js} +3 -3
- package/dist/{register.status-health-sessions-BncpB9Vw.js → register.status-health-sessions-sLgA92t7.js} +3 -3
- package/dist/{register.subclis-D6PmKJll.js → register.subclis-B2dGWFur.js} +9 -9
- package/dist/{registry-CK4e9hn8.js → registry-DYq1AYOv.js} +2 -2
- package/dist/{replies-BIX_isV7.js → replies-LSmuwOhA.js} +3 -3
- package/dist/{reply-BfZzgC9H.js → reply-DYnTEYoa.js} +537 -332
- package/dist/{reply-prefix-XlyuyChD.js → reply-prefix-DpqZu44Z.js} +1 -1
- package/dist/{resolve-route-CZ-1eqw0.js → resolve-route-C4_I4GFI.js} +5 -5
- package/dist/{retry-Cly39XZB.js → retry-BBVXkKBV.js} +1 -1
- package/dist/{run-main-wm3s04Xh.js → run-main-DWmu2b6D.js} +14 -14
- package/dist/{runner-DUBExAb5.js → runner-BcQ0sF9T.js} +1 -1
- package/dist/{runner-odEv83vv.js → runner-CU9l0uJh.js} +46 -46
- package/dist/{send-WyRqb4WD.js → send-CQAKg_12.js} +7 -7
- package/dist/{send-DeFniOjh.js → send-CVMyYPQw.js} +7 -7
- package/dist/{send-CiTGOvEc.js → send-CvhXrdgS.js} +12 -12
- package/dist/{send-DW96zgDL.js → send-DAN9hA5h.js} +6 -6
- package/dist/{send-B1u-LrcS.js → send-DYj_o4_F.js} +14 -14
- package/dist/{server-methods-D5zcFhng.js → server-methods-C8EWZt2g.js} +7 -7
- package/dist/{server-methods-xXv4ObXK.js → server-methods-vDGoM3xL.js} +7 -7
- package/dist/{server-node-events-BN7H6wBM.js → server-node-events-CKi12bol.js} +2 -2
- package/dist/{server-node-events-D4At7-pe.js → server-node-events-DFwGbkcO.js} +2 -2
- package/dist/{session-SM36BTsl.js → session-DSU1vxxi.js} +4 -4
- package/dist/{skill-commands-BJMb_psG.js → skill-commands-DcVwOafC.js} +17 -17
- package/dist/{skills-BFekKL7i.js → skills-Bs0AW1g3.js} +25 -25
- package/dist/{sqlite-DRbx2dhW.js → sqlite-D_mz1_-y.js} +17 -17
- package/dist/{status-XJTqV-CC.js → status--iNVOTMO.js} +2 -2
- package/dist/{status-PbQwO8SV.js → status-B1_iHrOg.js} +2 -2
- package/dist/{status-Nhvf_TEN.js → status-BQcdARV4.js} +1 -1
- package/dist/{status-C5rGEkur.js → status-DiX0DAtH.js} +1 -1
- package/dist/{store-C0wvOkae.js → store-01F_JM7O.js} +6 -6
- package/dist/{subagent-registry-DvCrN2PQ.js → subagent-registry-CXrOOgPW.js} +19438 -19233
- package/dist/{subsystem-Bs9YvKLa.js → subsystem-BjyjJF-d.js} +1 -1
- package/dist/{tables-DuZspiBu.js → tables-qMwbq29u.js} +1 -1
- package/dist/{target-errors-Be1SwYlW.js → target-errors-Bbr9rlzN.js} +2 -2
- package/dist/{thinking-CdlENGRW.js → thinking-BprCy23Z.js} +5 -5
- package/dist/{tokens-H1H1LiSQ.js → tokens-Bux9Y_xD.js} +1 -1
- package/dist/{tool-images-DXB7tqWi.js → tool-images-SqqWIT22.js} +2 -2
- package/dist/{tool-loop-detection-BgbtzUGc.js → tool-loop-detection-C7TCF2V2.js} +53 -3
- package/dist/{tool-loop-detection-BU3fbtCd.js → tool-loop-detection-D7qjFnRh.js} +53 -3
- package/dist/{tool-loop-detection-B6j1r-Wk.js → tool-loop-detection-DPVtQOfM.js} +53 -3
- package/dist/{tool-loop-detection-Cs8_HCsx.js → tool-loop-detection-DR_rrIA1.js} +56 -6
- package/dist/{pi-embedded-CTBkDXkV.js → unified-runner-CulJZMxc.js} +69924 -69719
- package/dist/{update-cli-BHxqriaA.js → update-cli-560gprSp.js} +7 -7
- package/dist/{update-cli-IqwjBYS0.js → update-cli-D1pLX3eo.js} +8 -8
- package/dist/{update-runner-BuoOzUcX.js → update-runner-BQxFFCGc.js} +1 -1
- package/dist/{update-runner-BFwirE1P.js → update-runner-CLKHrONW.js} +1 -1
- package/dist/{web-C4CDNJmR.js → web-Bqrgp43v.js} +1 -1
- package/dist/{web-OSVyyJa9.js → web-D4qJ9XKP.js} +6 -6
- package/dist/{web-Cr6E8Ych.js → web-Dr5cOn-1.js} +2 -2
- package/dist/{web-Dti17mxB.js → web-hHX9a9YO.js} +64 -64
- package/dist/{whatsapp-actions-D1RsnX7P.js → whatsapp-actions-BIeSWsCF.js} +25 -25
- package/dist/{workspace-wAaHI8-5.js → workspace-DscDraUb.js} +28 -28
- package/extensions/bluebubbles/node_modules/.bin/symi +0 -0
- package/extensions/copilot-proxy/node_modules/.bin/symi +0 -0
- package/extensions/diagnostics-otel/node_modules/.bin/acorn +0 -0
- package/extensions/diagnostics-otel/node_modules/.bin/symi +0 -0
- package/extensions/discord/node_modules/.bin/symi +0 -0
- package/extensions/feishu/node_modules/.bin/symi +0 -0
- package/extensions/google-antigravity-auth/node_modules/.bin/symi +0 -0
- package/extensions/google-gemini-cli-auth/node_modules/.bin/symi +0 -0
- package/extensions/googlechat/node_modules/.bin/symi +0 -0
- package/extensions/imessage/node_modules/.bin/symi +0 -0
- package/extensions/irc/node_modules/.bin/symi +0 -0
- package/extensions/learning-loop/node_modules/.bin/symi +0 -0
- package/extensions/line/node_modules/.bin/symi +0 -0
- package/extensions/matrix/node_modules/.bin/markdown-it +0 -0
- package/extensions/matrix/node_modules/.bin/symi +0 -0
- package/extensions/mattermost/node_modules/.bin/symi +0 -0
- package/extensions/memory-core/node_modules/.bin/symi +0 -0
- package/extensions/memory-lancedb/node_modules/.bin/arrow2csv +0 -0
- package/extensions/memory-lancedb/node_modules/.bin/openai +0 -0
- package/extensions/memory-lancedb/node_modules/.bin/symi +0 -0
- package/extensions/minimax-portal-auth/node_modules/.bin/symi +0 -0
- package/extensions/msteams/node_modules/.bin/symi +0 -0
- package/extensions/nextcloud-talk/node_modules/.bin/symi +0 -0
- package/extensions/nostr/node_modules/.bin/symi +0 -0
- package/extensions/nostr/node_modules/.bin/tsc +0 -0
- package/extensions/nostr/node_modules/.bin/tsserver +0 -0
- package/extensions/signal/node_modules/.bin/symi +0 -0
- package/extensions/slack/node_modules/.bin/symi +0 -0
- package/extensions/telegram/node_modules/.bin/symi +0 -0
- package/extensions/tlon/node_modules/.bin/symi +0 -0
- package/extensions/twitch/node_modules/.bin/symi +0 -0
- package/extensions/voice-call/node_modules/.bin/symi +0 -0
- package/extensions/whatsapp/node_modules/.bin/symi +0 -0
- package/extensions/zalo/node_modules/.bin/symi +0 -0
- package/extensions/zalouser/node_modules/.bin/symi +0 -0
- package/package.json +83 -113
- package/skills/nano-banana-pro/scripts/generate_image.py +0 -0
- package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +0 -0
- package/skills/tmux/scripts/find-sessions.sh +0 -0
- package/skills/tmux/scripts/wait-for-text.sh +0 -0
- package/dist/paths-Cce4PUkG.js +0 -212
- /package/dist/{boolean-B8-BqKGQ.js → boolean-CE7i9tBR.js} +0 -0
- /package/dist/{chat-type-C_KiWNAH.js → chat-type-3FRbbjbq.js} +0 -0
- /package/dist/{diagnostic-session-state-Bxo4UHOL.js → diagnostic-session-state-Zw87xFym.js} +0 -0
- /package/dist/{legacy-names-BHV4AoFT.js → legacy-names-CePMUvus.js} +0 -0
- /package/dist/{pi-model-discovery-DaNAekda.js → pi-model-discovery-Bv5YDJc8.js} +0 -0
- /package/dist/{redact-jSxx6Ep2.js → redact-BDMXB06K.js} +0 -0
- /package/dist/{ssrf-BTMDZjHT.js → ssrf-DpUUUgkK.js} +0 -0
- /package/dist/{targets-CFovdgJI.js → targets-DGkXkFPj.js} +0 -0
- /package/dist/{transcript-events-DDYvbmRV.js → transcript-events-BBh3Gsrx.js} +0 -0
|
@@ -1,177 +1,24 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
|
|
2
|
-
import { o as resolveOAuthPath, s as resolveStateDir } from "./paths-
|
|
2
|
+
import { o as resolveOAuthPath, s as resolveStateDir } from "./paths-CE7eVGHg.js";
|
|
3
3
|
import { t as DEFAULT_AGENT_ID } from "./session-key-BCzIW1Y2.js";
|
|
4
|
-
import { I as resolveUserPath } from "./registry-
|
|
5
|
-
import { a as resolveAgentModelPrimary, n as resolveAgentConfig } from "./agent-scope-
|
|
6
|
-
import { t as createSubsystemLogger } from "./subsystem-
|
|
7
|
-
import {
|
|
8
|
-
import { a as saveJsonFile, i as loadJsonFile, r as resolveCopilotApiToken, t as DEFAULT_COPILOT_API_BASE_URL } from "./github-copilot-token-
|
|
9
|
-
import fs from "node:fs/promises";
|
|
4
|
+
import { I as resolveUserPath } from "./registry-DYq1AYOv.js";
|
|
5
|
+
import { a as resolveAgentModelPrimary, n as resolveAgentConfig } from "./agent-scope-CpEJ0B88.js";
|
|
6
|
+
import { t as createSubsystemLogger } from "./subsystem-BjyjJF-d.js";
|
|
7
|
+
import { n as formatCliCommand, t as isTruthyEnvValue } from "./env-BDXYbTKj.js";
|
|
8
|
+
import { a as saveJsonFile, i as loadJsonFile, r as resolveCopilotApiToken, t as DEFAULT_COPILOT_API_BASE_URL } from "./github-copilot-token-cCYzSU9h.js";
|
|
10
9
|
import path from "node:path";
|
|
11
|
-
import fs
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
import fs$1 from "node:fs/promises";
|
|
12
12
|
import { execFileSync } from "node:child_process";
|
|
13
13
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
14
|
-
import { createAssistantMessageEventStream, getEnvApiKey, getOAuthApiKey, getOAuthProviders } from "@mariozechner/pi-ai";
|
|
15
14
|
import { BedrockClient, ListFoundationModelsCommand } from "@aws-sdk/client-bedrock";
|
|
15
|
+
import { createAssistantMessageEventStream, getEnvApiKey, getOAuthApiKey, getOAuthProviders } from "@mariozechner/pi-ai";
|
|
16
16
|
|
|
17
|
-
//#region src/
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function resolveTimeoutMs(timeoutMs) {
|
|
23
|
-
if (typeof timeoutMs !== "number" || !Number.isFinite(timeoutMs)) return DEFAULT_TIMEOUT_MS;
|
|
24
|
-
return Math.max(0, timeoutMs);
|
|
25
|
-
}
|
|
26
|
-
function resolveShell(env) {
|
|
27
|
-
const shell = env.SHELL?.trim();
|
|
28
|
-
return shell && shell.length > 0 ? shell : "/bin/sh";
|
|
29
|
-
}
|
|
30
|
-
function execLoginShellEnvZero(params) {
|
|
31
|
-
return params.exec(params.shell, [
|
|
32
|
-
"-l",
|
|
33
|
-
"-c",
|
|
34
|
-
"env -0"
|
|
35
|
-
], {
|
|
36
|
-
encoding: "buffer",
|
|
37
|
-
timeout: params.timeoutMs,
|
|
38
|
-
maxBuffer: DEFAULT_MAX_BUFFER_BYTES,
|
|
39
|
-
env: params.env,
|
|
40
|
-
stdio: [
|
|
41
|
-
"ignore",
|
|
42
|
-
"pipe",
|
|
43
|
-
"pipe"
|
|
44
|
-
]
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
function parseShellEnv(stdout) {
|
|
48
|
-
const shellEnv = /* @__PURE__ */ new Map();
|
|
49
|
-
const parts = stdout.toString("utf8").split("\0");
|
|
50
|
-
for (const part of parts) {
|
|
51
|
-
if (!part) continue;
|
|
52
|
-
const eq = part.indexOf("=");
|
|
53
|
-
if (eq <= 0) continue;
|
|
54
|
-
const key = part.slice(0, eq);
|
|
55
|
-
const value = part.slice(eq + 1);
|
|
56
|
-
if (!key) continue;
|
|
57
|
-
shellEnv.set(key, value);
|
|
58
|
-
}
|
|
59
|
-
return shellEnv;
|
|
60
|
-
}
|
|
61
|
-
function loadShellEnvFallback(opts) {
|
|
62
|
-
const logger = opts.logger ?? console;
|
|
63
|
-
const exec = opts.exec ?? execFileSync;
|
|
64
|
-
if (!opts.enabled) {
|
|
65
|
-
lastAppliedKeys = [];
|
|
66
|
-
return {
|
|
67
|
-
ok: true,
|
|
68
|
-
applied: [],
|
|
69
|
-
skippedReason: "disabled"
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
if (opts.expectedKeys.some((key) => Boolean(opts.env[key]?.trim()))) {
|
|
73
|
-
lastAppliedKeys = [];
|
|
74
|
-
return {
|
|
75
|
-
ok: true,
|
|
76
|
-
applied: [],
|
|
77
|
-
skippedReason: "already-has-keys"
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
const timeoutMs = resolveTimeoutMs(opts.timeoutMs);
|
|
81
|
-
const shell = resolveShell(opts.env);
|
|
82
|
-
let stdout;
|
|
83
|
-
try {
|
|
84
|
-
stdout = execLoginShellEnvZero({
|
|
85
|
-
shell,
|
|
86
|
-
env: opts.env,
|
|
87
|
-
exec,
|
|
88
|
-
timeoutMs
|
|
89
|
-
});
|
|
90
|
-
} catch (err) {
|
|
91
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
92
|
-
logger.warn(`[symi] shell env fallback failed: ${msg}`);
|
|
93
|
-
lastAppliedKeys = [];
|
|
94
|
-
return {
|
|
95
|
-
ok: false,
|
|
96
|
-
error: msg,
|
|
97
|
-
applied: []
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
const shellEnv = parseShellEnv(stdout);
|
|
101
|
-
const applied = [];
|
|
102
|
-
for (const key of opts.expectedKeys) {
|
|
103
|
-
if (opts.env[key]?.trim()) continue;
|
|
104
|
-
const value = shellEnv.get(key);
|
|
105
|
-
if (!value?.trim()) continue;
|
|
106
|
-
opts.env[key] = value;
|
|
107
|
-
applied.push(key);
|
|
108
|
-
}
|
|
109
|
-
lastAppliedKeys = applied;
|
|
110
|
-
return {
|
|
111
|
-
ok: true,
|
|
112
|
-
applied
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
function shouldEnableShellEnvFallback(env) {
|
|
116
|
-
return isTruthyEnvValue(env.SYMI_LOAD_SHELL_ENV);
|
|
117
|
-
}
|
|
118
|
-
function shouldDeferShellEnvFallback(env) {
|
|
119
|
-
return isTruthyEnvValue(env.SYMI_DEFER_SHELL_ENV_FALLBACK);
|
|
120
|
-
}
|
|
121
|
-
function resolveShellEnvFallbackTimeoutMs(env) {
|
|
122
|
-
const raw = env.SYMI_SHELL_ENV_TIMEOUT_MS?.trim();
|
|
123
|
-
if (!raw) return DEFAULT_TIMEOUT_MS;
|
|
124
|
-
const parsed = Number.parseInt(raw, 10);
|
|
125
|
-
if (!Number.isFinite(parsed)) return DEFAULT_TIMEOUT_MS;
|
|
126
|
-
return Math.max(0, parsed);
|
|
127
|
-
}
|
|
128
|
-
function getShellPathFromLoginShell(opts) {
|
|
129
|
-
if (cachedShellPath !== void 0) return cachedShellPath;
|
|
130
|
-
if ((opts.platform ?? process.platform) === "win32") {
|
|
131
|
-
cachedShellPath = null;
|
|
132
|
-
return cachedShellPath;
|
|
133
|
-
}
|
|
134
|
-
const exec = opts.exec ?? execFileSync;
|
|
135
|
-
const timeoutMs = resolveTimeoutMs(opts.timeoutMs);
|
|
136
|
-
const shell = resolveShell(opts.env);
|
|
137
|
-
let stdout;
|
|
138
|
-
try {
|
|
139
|
-
stdout = execLoginShellEnvZero({
|
|
140
|
-
shell,
|
|
141
|
-
env: opts.env,
|
|
142
|
-
exec,
|
|
143
|
-
timeoutMs
|
|
144
|
-
});
|
|
145
|
-
} catch {
|
|
146
|
-
cachedShellPath = null;
|
|
147
|
-
return cachedShellPath;
|
|
148
|
-
}
|
|
149
|
-
const shellPath = parseShellEnv(stdout).get("PATH")?.trim();
|
|
150
|
-
cachedShellPath = shellPath && shellPath.length > 0 ? shellPath : null;
|
|
151
|
-
return cachedShellPath;
|
|
152
|
-
}
|
|
153
|
-
function getShellEnvAppliedKeys() {
|
|
154
|
-
return [...lastAppliedKeys];
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
//#endregion
|
|
158
|
-
//#region src/utils/normalize-secret-input.ts
|
|
159
|
-
/**
|
|
160
|
-
* Secret normalization for copy/pasted credentials.
|
|
161
|
-
*
|
|
162
|
-
* Common footgun: line breaks (especially `\r`) embedded in API keys/tokens.
|
|
163
|
-
* We strip line breaks anywhere, then trim whitespace at the ends.
|
|
164
|
-
*
|
|
165
|
-
* Intentionally does NOT remove ordinary spaces inside the string to avoid
|
|
166
|
-
* silently altering "Bearer <token>" style values.
|
|
167
|
-
*/
|
|
168
|
-
function normalizeSecretInput(value) {
|
|
169
|
-
if (typeof value !== "string") return "";
|
|
170
|
-
return value.replace(/[\r\n\u2028\u2029]+/g, "").trim();
|
|
171
|
-
}
|
|
172
|
-
function normalizeOptionalSecretInput(value) {
|
|
173
|
-
const normalized = normalizeSecretInput(value);
|
|
174
|
-
return normalized ? normalized : void 0;
|
|
17
|
+
//#region src/agents/agent-paths.ts
|
|
18
|
+
function resolveSymiAgentDir() {
|
|
19
|
+
const override = process.env.SYMI_AGENT_DIR?.trim() || process.env.PI_CODING_AGENT_DIR?.trim();
|
|
20
|
+
if (override) return resolveUserPath(override);
|
|
21
|
+
return resolveUserPath(path.join(resolveStateDir(), "agents", DEFAULT_AGENT_ID, "agent"));
|
|
175
22
|
}
|
|
176
23
|
|
|
177
24
|
//#endregion
|
|
@@ -753,6 +600,394 @@ async function discoverHuggingfaceModels(apiKey) {
|
|
|
753
600
|
}
|
|
754
601
|
}
|
|
755
602
|
|
|
603
|
+
//#endregion
|
|
604
|
+
//#region src/infra/shell-env.ts
|
|
605
|
+
const DEFAULT_TIMEOUT_MS = 15e3;
|
|
606
|
+
const DEFAULT_MAX_BUFFER_BYTES = 2 * 1024 * 1024;
|
|
607
|
+
let lastAppliedKeys = [];
|
|
608
|
+
let cachedShellPath;
|
|
609
|
+
function resolveTimeoutMs(timeoutMs) {
|
|
610
|
+
if (typeof timeoutMs !== "number" || !Number.isFinite(timeoutMs)) return DEFAULT_TIMEOUT_MS;
|
|
611
|
+
return Math.max(0, timeoutMs);
|
|
612
|
+
}
|
|
613
|
+
function resolveShell(env) {
|
|
614
|
+
const shell = env.SHELL?.trim();
|
|
615
|
+
return shell && shell.length > 0 ? shell : "/bin/sh";
|
|
616
|
+
}
|
|
617
|
+
function execLoginShellEnvZero(params) {
|
|
618
|
+
return params.exec(params.shell, [
|
|
619
|
+
"-l",
|
|
620
|
+
"-c",
|
|
621
|
+
"env -0"
|
|
622
|
+
], {
|
|
623
|
+
encoding: "buffer",
|
|
624
|
+
timeout: params.timeoutMs,
|
|
625
|
+
maxBuffer: DEFAULT_MAX_BUFFER_BYTES,
|
|
626
|
+
env: params.env,
|
|
627
|
+
stdio: [
|
|
628
|
+
"ignore",
|
|
629
|
+
"pipe",
|
|
630
|
+
"pipe"
|
|
631
|
+
]
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
function parseShellEnv(stdout) {
|
|
635
|
+
const shellEnv = /* @__PURE__ */ new Map();
|
|
636
|
+
const parts = stdout.toString("utf8").split("\0");
|
|
637
|
+
for (const part of parts) {
|
|
638
|
+
if (!part) continue;
|
|
639
|
+
const eq = part.indexOf("=");
|
|
640
|
+
if (eq <= 0) continue;
|
|
641
|
+
const key = part.slice(0, eq);
|
|
642
|
+
const value = part.slice(eq + 1);
|
|
643
|
+
if (!key) continue;
|
|
644
|
+
shellEnv.set(key, value);
|
|
645
|
+
}
|
|
646
|
+
return shellEnv;
|
|
647
|
+
}
|
|
648
|
+
function loadShellEnvFallback(opts) {
|
|
649
|
+
const logger = opts.logger ?? console;
|
|
650
|
+
const exec = opts.exec ?? execFileSync;
|
|
651
|
+
if (!opts.enabled) {
|
|
652
|
+
lastAppliedKeys = [];
|
|
653
|
+
return {
|
|
654
|
+
ok: true,
|
|
655
|
+
applied: [],
|
|
656
|
+
skippedReason: "disabled"
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
if (opts.expectedKeys.some((key) => Boolean(opts.env[key]?.trim()))) {
|
|
660
|
+
lastAppliedKeys = [];
|
|
661
|
+
return {
|
|
662
|
+
ok: true,
|
|
663
|
+
applied: [],
|
|
664
|
+
skippedReason: "already-has-keys"
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
const timeoutMs = resolveTimeoutMs(opts.timeoutMs);
|
|
668
|
+
const shell = resolveShell(opts.env);
|
|
669
|
+
let stdout;
|
|
670
|
+
try {
|
|
671
|
+
stdout = execLoginShellEnvZero({
|
|
672
|
+
shell,
|
|
673
|
+
env: opts.env,
|
|
674
|
+
exec,
|
|
675
|
+
timeoutMs
|
|
676
|
+
});
|
|
677
|
+
} catch (err) {
|
|
678
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
679
|
+
logger.warn(`[symi] shell env fallback failed: ${msg}`);
|
|
680
|
+
lastAppliedKeys = [];
|
|
681
|
+
return {
|
|
682
|
+
ok: false,
|
|
683
|
+
error: msg,
|
|
684
|
+
applied: []
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
const shellEnv = parseShellEnv(stdout);
|
|
688
|
+
const applied = [];
|
|
689
|
+
for (const key of opts.expectedKeys) {
|
|
690
|
+
if (opts.env[key]?.trim()) continue;
|
|
691
|
+
const value = shellEnv.get(key);
|
|
692
|
+
if (!value?.trim()) continue;
|
|
693
|
+
opts.env[key] = value;
|
|
694
|
+
applied.push(key);
|
|
695
|
+
}
|
|
696
|
+
lastAppliedKeys = applied;
|
|
697
|
+
return {
|
|
698
|
+
ok: true,
|
|
699
|
+
applied
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
function shouldEnableShellEnvFallback(env) {
|
|
703
|
+
return isTruthyEnvValue(env.SYMI_LOAD_SHELL_ENV);
|
|
704
|
+
}
|
|
705
|
+
function shouldDeferShellEnvFallback(env) {
|
|
706
|
+
return isTruthyEnvValue(env.SYMI_DEFER_SHELL_ENV_FALLBACK);
|
|
707
|
+
}
|
|
708
|
+
function resolveShellEnvFallbackTimeoutMs(env) {
|
|
709
|
+
const raw = env.SYMI_SHELL_ENV_TIMEOUT_MS?.trim();
|
|
710
|
+
if (!raw) return DEFAULT_TIMEOUT_MS;
|
|
711
|
+
const parsed = Number.parseInt(raw, 10);
|
|
712
|
+
if (!Number.isFinite(parsed)) return DEFAULT_TIMEOUT_MS;
|
|
713
|
+
return Math.max(0, parsed);
|
|
714
|
+
}
|
|
715
|
+
function getShellPathFromLoginShell(opts) {
|
|
716
|
+
if (cachedShellPath !== void 0) return cachedShellPath;
|
|
717
|
+
if ((opts.platform ?? process.platform) === "win32") {
|
|
718
|
+
cachedShellPath = null;
|
|
719
|
+
return cachedShellPath;
|
|
720
|
+
}
|
|
721
|
+
const exec = opts.exec ?? execFileSync;
|
|
722
|
+
const timeoutMs = resolveTimeoutMs(opts.timeoutMs);
|
|
723
|
+
const shell = resolveShell(opts.env);
|
|
724
|
+
let stdout;
|
|
725
|
+
try {
|
|
726
|
+
stdout = execLoginShellEnvZero({
|
|
727
|
+
shell,
|
|
728
|
+
env: opts.env,
|
|
729
|
+
exec,
|
|
730
|
+
timeoutMs
|
|
731
|
+
});
|
|
732
|
+
} catch {
|
|
733
|
+
cachedShellPath = null;
|
|
734
|
+
return cachedShellPath;
|
|
735
|
+
}
|
|
736
|
+
const shellPath = parseShellEnv(stdout).get("PATH")?.trim();
|
|
737
|
+
cachedShellPath = shellPath && shellPath.length > 0 ? shellPath : null;
|
|
738
|
+
return cachedShellPath;
|
|
739
|
+
}
|
|
740
|
+
function getShellEnvAppliedKeys() {
|
|
741
|
+
return [...lastAppliedKeys];
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
//#endregion
|
|
745
|
+
//#region src/utils/normalize-secret-input.ts
|
|
746
|
+
/**
|
|
747
|
+
* Secret normalization for copy/pasted credentials.
|
|
748
|
+
*
|
|
749
|
+
* Common footgun: line breaks (especially `\r`) embedded in API keys/tokens.
|
|
750
|
+
* We strip line breaks anywhere, then trim whitespace at the ends.
|
|
751
|
+
*
|
|
752
|
+
* Intentionally does NOT remove ordinary spaces inside the string to avoid
|
|
753
|
+
* silently altering "Bearer <token>" style values.
|
|
754
|
+
*/
|
|
755
|
+
function normalizeSecretInput(value) {
|
|
756
|
+
if (typeof value !== "string") return "";
|
|
757
|
+
return value.replace(/[\r\n\u2028\u2029]+/g, "").trim();
|
|
758
|
+
}
|
|
759
|
+
function normalizeOptionalSecretInput(value) {
|
|
760
|
+
const normalized = normalizeSecretInput(value);
|
|
761
|
+
return normalized ? normalized : void 0;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
//#endregion
|
|
765
|
+
//#region src/agents/model-auth.ts
|
|
766
|
+
const AWS_BEARER_ENV = "AWS_BEARER_TOKEN_BEDROCK";
|
|
767
|
+
const AWS_ACCESS_KEY_ENV = "AWS_ACCESS_KEY_ID";
|
|
768
|
+
const AWS_SECRET_KEY_ENV = "AWS_SECRET_ACCESS_KEY";
|
|
769
|
+
const AWS_PROFILE_ENV = "AWS_PROFILE";
|
|
770
|
+
function resolveProviderConfig(cfg, provider) {
|
|
771
|
+
const providers = cfg?.models?.providers ?? {};
|
|
772
|
+
const direct = providers[provider];
|
|
773
|
+
if (direct) return direct;
|
|
774
|
+
const normalized = normalizeProviderId(provider);
|
|
775
|
+
if (normalized === provider) return Object.entries(providers).find(([key]) => normalizeProviderId(key) === normalized)?.[1];
|
|
776
|
+
return providers[normalized] ?? Object.entries(providers).find(([key]) => normalizeProviderId(key) === normalized)?.[1];
|
|
777
|
+
}
|
|
778
|
+
function getCustomProviderApiKey(cfg, provider) {
|
|
779
|
+
return normalizeOptionalSecretInput(resolveProviderConfig(cfg, provider)?.apiKey);
|
|
780
|
+
}
|
|
781
|
+
function resolveProviderAuthOverride(cfg, provider) {
|
|
782
|
+
const auth = resolveProviderConfig(cfg, provider)?.auth;
|
|
783
|
+
if (auth === "api-key" || auth === "aws-sdk" || auth === "oauth" || auth === "token") return auth;
|
|
784
|
+
}
|
|
785
|
+
function resolveEnvSourceLabel(params) {
|
|
786
|
+
return `${params.envVars.some((envVar) => params.applied.has(envVar)) ? "shell env: " : "env: "}${params.label}`;
|
|
787
|
+
}
|
|
788
|
+
function resolveAwsSdkEnvVarName(env = process.env) {
|
|
789
|
+
if (env[AWS_BEARER_ENV]?.trim()) return AWS_BEARER_ENV;
|
|
790
|
+
if (env[AWS_ACCESS_KEY_ENV]?.trim() && env[AWS_SECRET_KEY_ENV]?.trim()) return AWS_ACCESS_KEY_ENV;
|
|
791
|
+
if (env[AWS_PROFILE_ENV]?.trim()) return AWS_PROFILE_ENV;
|
|
792
|
+
}
|
|
793
|
+
function resolveAwsSdkAuthInfo() {
|
|
794
|
+
const applied = new Set(getShellEnvAppliedKeys());
|
|
795
|
+
if (process.env[AWS_BEARER_ENV]?.trim()) return {
|
|
796
|
+
mode: "aws-sdk",
|
|
797
|
+
source: resolveEnvSourceLabel({
|
|
798
|
+
applied,
|
|
799
|
+
envVars: [AWS_BEARER_ENV],
|
|
800
|
+
label: AWS_BEARER_ENV
|
|
801
|
+
})
|
|
802
|
+
};
|
|
803
|
+
if (process.env[AWS_ACCESS_KEY_ENV]?.trim() && process.env[AWS_SECRET_KEY_ENV]?.trim()) return {
|
|
804
|
+
mode: "aws-sdk",
|
|
805
|
+
source: resolveEnvSourceLabel({
|
|
806
|
+
applied,
|
|
807
|
+
envVars: [AWS_ACCESS_KEY_ENV, AWS_SECRET_KEY_ENV],
|
|
808
|
+
label: `${AWS_ACCESS_KEY_ENV} + ${AWS_SECRET_KEY_ENV}`
|
|
809
|
+
})
|
|
810
|
+
};
|
|
811
|
+
if (process.env[AWS_PROFILE_ENV]?.trim()) return {
|
|
812
|
+
mode: "aws-sdk",
|
|
813
|
+
source: resolveEnvSourceLabel({
|
|
814
|
+
applied,
|
|
815
|
+
envVars: [AWS_PROFILE_ENV],
|
|
816
|
+
label: AWS_PROFILE_ENV
|
|
817
|
+
})
|
|
818
|
+
};
|
|
819
|
+
return {
|
|
820
|
+
mode: "aws-sdk",
|
|
821
|
+
source: "aws-sdk default chain"
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
async function resolveApiKeyForProvider(params) {
|
|
825
|
+
const { provider, cfg, profileId, preferredProfile } = params;
|
|
826
|
+
const store = params.store ?? ensureAuthProfileStore(params.agentDir);
|
|
827
|
+
if (profileId) {
|
|
828
|
+
const resolved = await resolveApiKeyForProfile({
|
|
829
|
+
cfg,
|
|
830
|
+
store,
|
|
831
|
+
profileId,
|
|
832
|
+
agentDir: params.agentDir
|
|
833
|
+
});
|
|
834
|
+
if (!resolved) throw new Error(`No credentials found for profile "${profileId}".`);
|
|
835
|
+
const mode = store.profiles[profileId]?.type;
|
|
836
|
+
return {
|
|
837
|
+
apiKey: resolved.apiKey,
|
|
838
|
+
profileId,
|
|
839
|
+
source: `profile:${profileId}`,
|
|
840
|
+
mode: mode === "oauth" ? "oauth" : mode === "token" ? "token" : "api-key"
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
const authOverride = resolveProviderAuthOverride(cfg, provider);
|
|
844
|
+
if (authOverride === "aws-sdk") return resolveAwsSdkAuthInfo();
|
|
845
|
+
const order = resolveAuthProfileOrder({
|
|
846
|
+
cfg,
|
|
847
|
+
store,
|
|
848
|
+
provider,
|
|
849
|
+
preferredProfile
|
|
850
|
+
});
|
|
851
|
+
for (const candidate of order) try {
|
|
852
|
+
const resolved = await resolveApiKeyForProfile({
|
|
853
|
+
cfg,
|
|
854
|
+
store,
|
|
855
|
+
profileId: candidate,
|
|
856
|
+
agentDir: params.agentDir
|
|
857
|
+
});
|
|
858
|
+
if (resolved) {
|
|
859
|
+
const mode = store.profiles[candidate]?.type;
|
|
860
|
+
return {
|
|
861
|
+
apiKey: resolved.apiKey,
|
|
862
|
+
profileId: candidate,
|
|
863
|
+
source: `profile:${candidate}`,
|
|
864
|
+
mode: mode === "oauth" ? "oauth" : mode === "token" ? "token" : "api-key"
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
} catch {}
|
|
868
|
+
const envResolved = resolveEnvApiKey(provider);
|
|
869
|
+
if (envResolved) return {
|
|
870
|
+
apiKey: envResolved.apiKey,
|
|
871
|
+
source: envResolved.source,
|
|
872
|
+
mode: envResolved.source.includes("OAUTH_TOKEN") ? "oauth" : "api-key"
|
|
873
|
+
};
|
|
874
|
+
const customKey = getCustomProviderApiKey(cfg, provider);
|
|
875
|
+
if (customKey) return {
|
|
876
|
+
apiKey: customKey,
|
|
877
|
+
source: "models.json",
|
|
878
|
+
mode: "api-key"
|
|
879
|
+
};
|
|
880
|
+
const normalized = normalizeProviderId(provider);
|
|
881
|
+
if (authOverride === void 0 && normalized === "amazon-bedrock") return resolveAwsSdkAuthInfo();
|
|
882
|
+
if (provider === "openai") {
|
|
883
|
+
if (listProfilesForProvider(store, "openai-codex").length > 0) throw new Error("No API key found for provider \"openai\". You are authenticated with OpenAI Codex OAuth. Use openai-codex/gpt-5.3-codex (OAuth) or set OPENAI_API_KEY to use openai/gpt-5.1-codex.");
|
|
884
|
+
}
|
|
885
|
+
const authStorePath = resolveAuthStorePathForDisplay(params.agentDir);
|
|
886
|
+
const resolvedAgentDir = path.dirname(authStorePath);
|
|
887
|
+
throw new Error([
|
|
888
|
+
`No API key found for provider "${provider}".`,
|
|
889
|
+
`Auth store: ${authStorePath} (agentDir: ${resolvedAgentDir}).`,
|
|
890
|
+
`Configure auth for this agent (${formatCliCommand("symi agents add <id>")}) or copy auth-profiles.json from the main agentDir.`
|
|
891
|
+
].join(" "));
|
|
892
|
+
}
|
|
893
|
+
function resolveEnvApiKey(provider) {
|
|
894
|
+
const normalized = normalizeProviderId(provider);
|
|
895
|
+
const applied = new Set(getShellEnvAppliedKeys());
|
|
896
|
+
const pick = (envVar) => {
|
|
897
|
+
const value = normalizeOptionalSecretInput(process.env[envVar]);
|
|
898
|
+
if (!value) return null;
|
|
899
|
+
return {
|
|
900
|
+
apiKey: value,
|
|
901
|
+
source: applied.has(envVar) ? `shell env: ${envVar}` : `env: ${envVar}`
|
|
902
|
+
};
|
|
903
|
+
};
|
|
904
|
+
if (normalized === "github-copilot") return pick("COPILOT_GITHUB_TOKEN") ?? pick("GH_TOKEN") ?? pick("GITHUB_TOKEN");
|
|
905
|
+
if (normalized === "anthropic") return pick("ANTHROPIC_OAUTH_TOKEN") ?? pick("ANTHROPIC_API_KEY");
|
|
906
|
+
if (normalized === "chutes") return pick("CHUTES_OAUTH_TOKEN") ?? pick("CHUTES_API_KEY");
|
|
907
|
+
if (normalized === "zai") return pick("ZAI_API_KEY") ?? pick("Z_AI_API_KEY");
|
|
908
|
+
if (normalized === "google-vertex") {
|
|
909
|
+
const envKey = getEnvApiKey(normalized);
|
|
910
|
+
if (!envKey) return null;
|
|
911
|
+
return {
|
|
912
|
+
apiKey: envKey,
|
|
913
|
+
source: "gcloud adc"
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
if (normalized === "opencode") return pick("OPENCODE_API_KEY") ?? pick("OPENCODE_ZEN_API_KEY");
|
|
917
|
+
if (normalized === "qwen-portal") return pick("QWEN_OAUTH_TOKEN") ?? pick("QWEN_PORTAL_API_KEY");
|
|
918
|
+
if (normalized === "volcengine" || normalized === "volcengine-plan") return pick("VOLCANO_ENGINE_API_KEY");
|
|
919
|
+
if (normalized === "byteplus" || normalized === "byteplus-plan") return pick("BYTEPLUS_API_KEY");
|
|
920
|
+
if (normalized === "minimax-portal") return pick("MINIMAX_OAUTH_TOKEN") ?? pick("MINIMAX_API_KEY");
|
|
921
|
+
if (normalized === "kimi-coding") return pick("KIMI_API_KEY") ?? pick("KIMICODE_API_KEY");
|
|
922
|
+
if (normalized === "huggingface") return pick("HUGGINGFACE_HUB_TOKEN") ?? pick("HF_TOKEN");
|
|
923
|
+
const envVar = {
|
|
924
|
+
openai: "OPENAI_API_KEY",
|
|
925
|
+
google: "GEMINI_API_KEY",
|
|
926
|
+
voyage: "VOYAGE_API_KEY",
|
|
927
|
+
groq: "GROQ_API_KEY",
|
|
928
|
+
deepgram: "DEEPGRAM_API_KEY",
|
|
929
|
+
cerebras: "CEREBRAS_API_KEY",
|
|
930
|
+
xai: "XAI_API_KEY",
|
|
931
|
+
openrouter: "OPENROUTER_API_KEY",
|
|
932
|
+
litellm: "LITELLM_API_KEY",
|
|
933
|
+
"vercel-ai-gateway": "AI_GATEWAY_API_KEY",
|
|
934
|
+
"cloudflare-ai-gateway": "CLOUDFLARE_AI_GATEWAY_API_KEY",
|
|
935
|
+
moonshot: "MOONSHOT_API_KEY",
|
|
936
|
+
minimax: "MINIMAX_API_KEY",
|
|
937
|
+
nvidia: "NVIDIA_API_KEY",
|
|
938
|
+
xiaomi: "XIAOMI_API_KEY",
|
|
939
|
+
synthetic: "SYNTHETIC_API_KEY",
|
|
940
|
+
venice: "VENICE_API_KEY",
|
|
941
|
+
mistral: "MISTRAL_API_KEY",
|
|
942
|
+
opencode: "OPENCODE_API_KEY",
|
|
943
|
+
together: "TOGETHER_API_KEY",
|
|
944
|
+
qianfan: "QIANFAN_API_KEY",
|
|
945
|
+
ollama: "OLLAMA_API_KEY",
|
|
946
|
+
vllm: "VLLM_API_KEY"
|
|
947
|
+
}[normalized];
|
|
948
|
+
if (!envVar) return null;
|
|
949
|
+
return pick(envVar);
|
|
950
|
+
}
|
|
951
|
+
function resolveModelAuthMode(provider, cfg, store) {
|
|
952
|
+
const resolved = provider?.trim();
|
|
953
|
+
if (!resolved) return;
|
|
954
|
+
const authOverride = resolveProviderAuthOverride(cfg, resolved);
|
|
955
|
+
if (authOverride === "aws-sdk") return "aws-sdk";
|
|
956
|
+
const authStore = store ?? ensureAuthProfileStore();
|
|
957
|
+
const profiles = listProfilesForProvider(authStore, resolved);
|
|
958
|
+
if (profiles.length > 0) {
|
|
959
|
+
const modes = new Set(profiles.map((id) => authStore.profiles[id]?.type).filter((mode) => Boolean(mode)));
|
|
960
|
+
if ([
|
|
961
|
+
"oauth",
|
|
962
|
+
"token",
|
|
963
|
+
"api_key"
|
|
964
|
+
].filter((k) => modes.has(k)).length >= 2) return "mixed";
|
|
965
|
+
if (modes.has("oauth")) return "oauth";
|
|
966
|
+
if (modes.has("token")) return "token";
|
|
967
|
+
if (modes.has("api_key")) return "api-key";
|
|
968
|
+
}
|
|
969
|
+
if (authOverride === void 0 && normalizeProviderId(resolved) === "amazon-bedrock") return "aws-sdk";
|
|
970
|
+
const envKey = resolveEnvApiKey(resolved);
|
|
971
|
+
if (envKey?.apiKey) return envKey.source.includes("OAUTH_TOKEN") ? "oauth" : "api-key";
|
|
972
|
+
if (getCustomProviderApiKey(cfg, resolved)) return "api-key";
|
|
973
|
+
return "unknown";
|
|
974
|
+
}
|
|
975
|
+
async function getApiKeyForModel(params) {
|
|
976
|
+
return resolveApiKeyForProvider({
|
|
977
|
+
provider: params.model.provider,
|
|
978
|
+
cfg: params.cfg,
|
|
979
|
+
profileId: params.profileId,
|
|
980
|
+
preferredProfile: params.preferredProfile,
|
|
981
|
+
store: params.store,
|
|
982
|
+
agentDir: params.agentDir
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
function requireApiKey(auth, provider) {
|
|
986
|
+
const key = normalizeSecretInput(auth.apiKey);
|
|
987
|
+
if (key) return key;
|
|
988
|
+
throw new Error(`No API key resolved for provider "${provider}" (auth mode: ${auth.mode}).`);
|
|
989
|
+
}
|
|
990
|
+
|
|
756
991
|
//#endregion
|
|
757
992
|
//#region src/agents/ollama-stream.ts
|
|
758
993
|
const OLLAMA_NATIVE_BASE_URL = "http://127.0.0.1:11434";
|
|
@@ -2722,7 +2957,7 @@ function computeDelayMs(retries, attempt) {
|
|
|
2722
2957
|
}
|
|
2723
2958
|
async function readLockPayload(lockPath) {
|
|
2724
2959
|
try {
|
|
2725
|
-
const raw = await fs.readFile(lockPath, "utf8");
|
|
2960
|
+
const raw = await fs$1.readFile(lockPath, "utf8");
|
|
2726
2961
|
const parsed = JSON.parse(raw);
|
|
2727
2962
|
if (typeof parsed.pid !== "number" || typeof parsed.createdAt !== "string") return null;
|
|
2728
2963
|
return {
|
|
@@ -2736,9 +2971,9 @@ async function readLockPayload(lockPath) {
|
|
|
2736
2971
|
async function resolveNormalizedFilePath(filePath) {
|
|
2737
2972
|
const resolved = path.resolve(filePath);
|
|
2738
2973
|
const dir = path.dirname(resolved);
|
|
2739
|
-
await fs.mkdir(dir, { recursive: true });
|
|
2974
|
+
await fs$1.mkdir(dir, { recursive: true });
|
|
2740
2975
|
try {
|
|
2741
|
-
const realDir = await fs.realpath(dir);
|
|
2976
|
+
const realDir = await fs$1.realpath(dir);
|
|
2742
2977
|
return path.join(realDir, path.basename(resolved));
|
|
2743
2978
|
} catch {
|
|
2744
2979
|
return resolved;
|
|
@@ -2752,7 +2987,7 @@ async function isStaleLock(lockPath, staleMs) {
|
|
|
2752
2987
|
if (!Number.isFinite(createdAt) || Date.now() - createdAt > staleMs) return true;
|
|
2753
2988
|
}
|
|
2754
2989
|
try {
|
|
2755
|
-
const stat = await fs.stat(lockPath);
|
|
2990
|
+
const stat = await fs$1.stat(lockPath);
|
|
2756
2991
|
return Date.now() - stat.mtimeMs > staleMs;
|
|
2757
2992
|
} catch {
|
|
2758
2993
|
return true;
|
|
@@ -2765,7 +3000,7 @@ async function releaseHeldLock(normalizedFile) {
|
|
|
2765
3000
|
if (current.count > 0) return;
|
|
2766
3001
|
HELD_LOCKS.delete(normalizedFile);
|
|
2767
3002
|
await current.handle.close().catch(() => void 0);
|
|
2768
|
-
await fs.rm(current.lockPath, { force: true }).catch(() => void 0);
|
|
3003
|
+
await fs$1.rm(current.lockPath, { force: true }).catch(() => void 0);
|
|
2769
3004
|
}
|
|
2770
3005
|
async function acquireFileLock(filePath, options) {
|
|
2771
3006
|
const normalizedFile = await resolveNormalizedFilePath(filePath);
|
|
@@ -2780,7 +3015,7 @@ async function acquireFileLock(filePath, options) {
|
|
|
2780
3015
|
}
|
|
2781
3016
|
const attempts = Math.max(1, options.retries.retries + 1);
|
|
2782
3017
|
for (let attempt = 0; attempt < attempts; attempt += 1) try {
|
|
2783
|
-
const handle = await fs.open(lockPath, "wx");
|
|
3018
|
+
const handle = await fs$1.open(lockPath, "wx");
|
|
2784
3019
|
await handle.writeFile(JSON.stringify({
|
|
2785
3020
|
pid: process.pid,
|
|
2786
3021
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -2797,7 +3032,7 @@ async function acquireFileLock(filePath, options) {
|
|
|
2797
3032
|
} catch (err) {
|
|
2798
3033
|
if (err.code !== "EEXIST") throw err;
|
|
2799
3034
|
if (await isStaleLock(lockPath, options.stale)) {
|
|
2800
|
-
await fs.rm(lockPath, { force: true }).catch(() => void 0);
|
|
3035
|
+
await fs$1.rm(lockPath, { force: true }).catch(() => void 0);
|
|
2801
3036
|
continue;
|
|
2802
3037
|
}
|
|
2803
3038
|
if (attempt >= attempts - 1) break;
|
|
@@ -2936,14 +3171,6 @@ function syncExternalCliCredentials(store) {
|
|
|
2936
3171
|
return mutated;
|
|
2937
3172
|
}
|
|
2938
3173
|
|
|
2939
|
-
//#endregion
|
|
2940
|
-
//#region src/agents/agent-paths.ts
|
|
2941
|
-
function resolveSymiAgentDir() {
|
|
2942
|
-
const override = process.env.SYMI_AGENT_DIR?.trim() || process.env.PI_CODING_AGENT_DIR?.trim();
|
|
2943
|
-
if (override) return resolveUserPath(override);
|
|
2944
|
-
return resolveUserPath(path.join(resolveStateDir(), "agents", DEFAULT_AGENT_ID, "agent"));
|
|
2945
|
-
}
|
|
2946
|
-
|
|
2947
3174
|
//#endregion
|
|
2948
3175
|
//#region src/agents/auth-profiles/paths.ts
|
|
2949
3176
|
function resolveAuthStorePath(agentDir) {
|
|
@@ -2959,7 +3186,7 @@ function resolveAuthStorePathForDisplay(agentDir) {
|
|
|
2959
3186
|
return pathname.startsWith("~") ? pathname : resolveUserPath(pathname);
|
|
2960
3187
|
}
|
|
2961
3188
|
function ensureAuthStoreFile(pathname) {
|
|
2962
|
-
if (fs
|
|
3189
|
+
if (fs.existsSync(pathname)) return;
|
|
2963
3190
|
saveJsonFile(pathname, {
|
|
2964
3191
|
version: AUTH_STORE_VERSION,
|
|
2965
3192
|
profiles: {}
|
|
@@ -3128,7 +3355,7 @@ function loadAuthProfileStoreForAgent(agentDir, _options) {
|
|
|
3128
3355
|
if (shouldWrite && legacy !== null) {
|
|
3129
3356
|
const legacyPath = resolveLegacyAuthStorePath(agentDir);
|
|
3130
3357
|
try {
|
|
3131
|
-
fs
|
|
3358
|
+
fs.unlinkSync(legacyPath);
|
|
3132
3359
|
} catch (err) {
|
|
3133
3360
|
if (err?.code !== "ENOENT") log$1.warn("failed to delete legacy auth.json after migration", {
|
|
3134
3361
|
err,
|
|
@@ -3883,231 +4110,4 @@ function orderProfilesByMode(order, store) {
|
|
|
3883
4110
|
var auth_profiles_exports = /* @__PURE__ */ __exportAll({ ensureAuthProfileStore: () => ensureAuthProfileStore });
|
|
3884
4111
|
|
|
3885
4112
|
//#endregion
|
|
3886
|
-
|
|
3887
|
-
const AWS_BEARER_ENV = "AWS_BEARER_TOKEN_BEDROCK";
|
|
3888
|
-
const AWS_ACCESS_KEY_ENV = "AWS_ACCESS_KEY_ID";
|
|
3889
|
-
const AWS_SECRET_KEY_ENV = "AWS_SECRET_ACCESS_KEY";
|
|
3890
|
-
const AWS_PROFILE_ENV = "AWS_PROFILE";
|
|
3891
|
-
function resolveProviderConfig(cfg, provider) {
|
|
3892
|
-
const providers = cfg?.models?.providers ?? {};
|
|
3893
|
-
const direct = providers[provider];
|
|
3894
|
-
if (direct) return direct;
|
|
3895
|
-
const normalized = normalizeProviderId(provider);
|
|
3896
|
-
if (normalized === provider) return Object.entries(providers).find(([key]) => normalizeProviderId(key) === normalized)?.[1];
|
|
3897
|
-
return providers[normalized] ?? Object.entries(providers).find(([key]) => normalizeProviderId(key) === normalized)?.[1];
|
|
3898
|
-
}
|
|
3899
|
-
function getCustomProviderApiKey(cfg, provider) {
|
|
3900
|
-
return normalizeOptionalSecretInput(resolveProviderConfig(cfg, provider)?.apiKey);
|
|
3901
|
-
}
|
|
3902
|
-
function resolveProviderAuthOverride(cfg, provider) {
|
|
3903
|
-
const auth = resolveProviderConfig(cfg, provider)?.auth;
|
|
3904
|
-
if (auth === "api-key" || auth === "aws-sdk" || auth === "oauth" || auth === "token") return auth;
|
|
3905
|
-
}
|
|
3906
|
-
function resolveEnvSourceLabel(params) {
|
|
3907
|
-
return `${params.envVars.some((envVar) => params.applied.has(envVar)) ? "shell env: " : "env: "}${params.label}`;
|
|
3908
|
-
}
|
|
3909
|
-
function resolveAwsSdkEnvVarName(env = process.env) {
|
|
3910
|
-
if (env[AWS_BEARER_ENV]?.trim()) return AWS_BEARER_ENV;
|
|
3911
|
-
if (env[AWS_ACCESS_KEY_ENV]?.trim() && env[AWS_SECRET_KEY_ENV]?.trim()) return AWS_ACCESS_KEY_ENV;
|
|
3912
|
-
if (env[AWS_PROFILE_ENV]?.trim()) return AWS_PROFILE_ENV;
|
|
3913
|
-
}
|
|
3914
|
-
function resolveAwsSdkAuthInfo() {
|
|
3915
|
-
const applied = new Set(getShellEnvAppliedKeys());
|
|
3916
|
-
if (process.env[AWS_BEARER_ENV]?.trim()) return {
|
|
3917
|
-
mode: "aws-sdk",
|
|
3918
|
-
source: resolveEnvSourceLabel({
|
|
3919
|
-
applied,
|
|
3920
|
-
envVars: [AWS_BEARER_ENV],
|
|
3921
|
-
label: AWS_BEARER_ENV
|
|
3922
|
-
})
|
|
3923
|
-
};
|
|
3924
|
-
if (process.env[AWS_ACCESS_KEY_ENV]?.trim() && process.env[AWS_SECRET_KEY_ENV]?.trim()) return {
|
|
3925
|
-
mode: "aws-sdk",
|
|
3926
|
-
source: resolveEnvSourceLabel({
|
|
3927
|
-
applied,
|
|
3928
|
-
envVars: [AWS_ACCESS_KEY_ENV, AWS_SECRET_KEY_ENV],
|
|
3929
|
-
label: `${AWS_ACCESS_KEY_ENV} + ${AWS_SECRET_KEY_ENV}`
|
|
3930
|
-
})
|
|
3931
|
-
};
|
|
3932
|
-
if (process.env[AWS_PROFILE_ENV]?.trim()) return {
|
|
3933
|
-
mode: "aws-sdk",
|
|
3934
|
-
source: resolveEnvSourceLabel({
|
|
3935
|
-
applied,
|
|
3936
|
-
envVars: [AWS_PROFILE_ENV],
|
|
3937
|
-
label: AWS_PROFILE_ENV
|
|
3938
|
-
})
|
|
3939
|
-
};
|
|
3940
|
-
return {
|
|
3941
|
-
mode: "aws-sdk",
|
|
3942
|
-
source: "aws-sdk default chain"
|
|
3943
|
-
};
|
|
3944
|
-
}
|
|
3945
|
-
async function resolveApiKeyForProvider(params) {
|
|
3946
|
-
const { provider, cfg, profileId, preferredProfile } = params;
|
|
3947
|
-
const store = params.store ?? ensureAuthProfileStore(params.agentDir);
|
|
3948
|
-
if (profileId) {
|
|
3949
|
-
const resolved = await resolveApiKeyForProfile({
|
|
3950
|
-
cfg,
|
|
3951
|
-
store,
|
|
3952
|
-
profileId,
|
|
3953
|
-
agentDir: params.agentDir
|
|
3954
|
-
});
|
|
3955
|
-
if (!resolved) throw new Error(`No credentials found for profile "${profileId}".`);
|
|
3956
|
-
const mode = store.profiles[profileId]?.type;
|
|
3957
|
-
return {
|
|
3958
|
-
apiKey: resolved.apiKey,
|
|
3959
|
-
profileId,
|
|
3960
|
-
source: `profile:${profileId}`,
|
|
3961
|
-
mode: mode === "oauth" ? "oauth" : mode === "token" ? "token" : "api-key"
|
|
3962
|
-
};
|
|
3963
|
-
}
|
|
3964
|
-
const authOverride = resolveProviderAuthOverride(cfg, provider);
|
|
3965
|
-
if (authOverride === "aws-sdk") return resolveAwsSdkAuthInfo();
|
|
3966
|
-
const order = resolveAuthProfileOrder({
|
|
3967
|
-
cfg,
|
|
3968
|
-
store,
|
|
3969
|
-
provider,
|
|
3970
|
-
preferredProfile
|
|
3971
|
-
});
|
|
3972
|
-
for (const candidate of order) try {
|
|
3973
|
-
const resolved = await resolveApiKeyForProfile({
|
|
3974
|
-
cfg,
|
|
3975
|
-
store,
|
|
3976
|
-
profileId: candidate,
|
|
3977
|
-
agentDir: params.agentDir
|
|
3978
|
-
});
|
|
3979
|
-
if (resolved) {
|
|
3980
|
-
const mode = store.profiles[candidate]?.type;
|
|
3981
|
-
return {
|
|
3982
|
-
apiKey: resolved.apiKey,
|
|
3983
|
-
profileId: candidate,
|
|
3984
|
-
source: `profile:${candidate}`,
|
|
3985
|
-
mode: mode === "oauth" ? "oauth" : mode === "token" ? "token" : "api-key"
|
|
3986
|
-
};
|
|
3987
|
-
}
|
|
3988
|
-
} catch {}
|
|
3989
|
-
const envResolved = resolveEnvApiKey(provider);
|
|
3990
|
-
if (envResolved) return {
|
|
3991
|
-
apiKey: envResolved.apiKey,
|
|
3992
|
-
source: envResolved.source,
|
|
3993
|
-
mode: envResolved.source.includes("OAUTH_TOKEN") ? "oauth" : "api-key"
|
|
3994
|
-
};
|
|
3995
|
-
const customKey = getCustomProviderApiKey(cfg, provider);
|
|
3996
|
-
if (customKey) return {
|
|
3997
|
-
apiKey: customKey,
|
|
3998
|
-
source: "models.json",
|
|
3999
|
-
mode: "api-key"
|
|
4000
|
-
};
|
|
4001
|
-
const normalized = normalizeProviderId(provider);
|
|
4002
|
-
if (authOverride === void 0 && normalized === "amazon-bedrock") return resolveAwsSdkAuthInfo();
|
|
4003
|
-
if (provider === "openai") {
|
|
4004
|
-
if (listProfilesForProvider(store, "openai-codex").length > 0) throw new Error("No API key found for provider \"openai\". You are authenticated with OpenAI Codex OAuth. Use openai-codex/gpt-5.3-codex (OAuth) or set OPENAI_API_KEY to use openai/gpt-5.1-codex.");
|
|
4005
|
-
}
|
|
4006
|
-
const authStorePath = resolveAuthStorePathForDisplay(params.agentDir);
|
|
4007
|
-
const resolvedAgentDir = path.dirname(authStorePath);
|
|
4008
|
-
throw new Error([
|
|
4009
|
-
`No API key found for provider "${provider}".`,
|
|
4010
|
-
`Auth store: ${authStorePath} (agentDir: ${resolvedAgentDir}).`,
|
|
4011
|
-
`Configure auth for this agent (${formatCliCommand("symi agents add <id>")}) or copy auth-profiles.json from the main agentDir.`
|
|
4012
|
-
].join(" "));
|
|
4013
|
-
}
|
|
4014
|
-
function resolveEnvApiKey(provider) {
|
|
4015
|
-
const normalized = normalizeProviderId(provider);
|
|
4016
|
-
const applied = new Set(getShellEnvAppliedKeys());
|
|
4017
|
-
const pick = (envVar) => {
|
|
4018
|
-
const value = normalizeOptionalSecretInput(process.env[envVar]);
|
|
4019
|
-
if (!value) return null;
|
|
4020
|
-
return {
|
|
4021
|
-
apiKey: value,
|
|
4022
|
-
source: applied.has(envVar) ? `shell env: ${envVar}` : `env: ${envVar}`
|
|
4023
|
-
};
|
|
4024
|
-
};
|
|
4025
|
-
if (normalized === "github-copilot") return pick("COPILOT_GITHUB_TOKEN") ?? pick("GH_TOKEN") ?? pick("GITHUB_TOKEN");
|
|
4026
|
-
if (normalized === "anthropic") return pick("ANTHROPIC_OAUTH_TOKEN") ?? pick("ANTHROPIC_API_KEY");
|
|
4027
|
-
if (normalized === "chutes") return pick("CHUTES_OAUTH_TOKEN") ?? pick("CHUTES_API_KEY");
|
|
4028
|
-
if (normalized === "zai") return pick("ZAI_API_KEY") ?? pick("Z_AI_API_KEY");
|
|
4029
|
-
if (normalized === "google-vertex") {
|
|
4030
|
-
const envKey = getEnvApiKey(normalized);
|
|
4031
|
-
if (!envKey) return null;
|
|
4032
|
-
return {
|
|
4033
|
-
apiKey: envKey,
|
|
4034
|
-
source: "gcloud adc"
|
|
4035
|
-
};
|
|
4036
|
-
}
|
|
4037
|
-
if (normalized === "opencode") return pick("OPENCODE_API_KEY") ?? pick("OPENCODE_ZEN_API_KEY");
|
|
4038
|
-
if (normalized === "qwen-portal") return pick("QWEN_OAUTH_TOKEN") ?? pick("QWEN_PORTAL_API_KEY");
|
|
4039
|
-
if (normalized === "volcengine" || normalized === "volcengine-plan") return pick("VOLCANO_ENGINE_API_KEY");
|
|
4040
|
-
if (normalized === "byteplus" || normalized === "byteplus-plan") return pick("BYTEPLUS_API_KEY");
|
|
4041
|
-
if (normalized === "minimax-portal") return pick("MINIMAX_OAUTH_TOKEN") ?? pick("MINIMAX_API_KEY");
|
|
4042
|
-
if (normalized === "kimi-coding") return pick("KIMI_API_KEY") ?? pick("KIMICODE_API_KEY");
|
|
4043
|
-
if (normalized === "huggingface") return pick("HUGGINGFACE_HUB_TOKEN") ?? pick("HF_TOKEN");
|
|
4044
|
-
const envVar = {
|
|
4045
|
-
openai: "OPENAI_API_KEY",
|
|
4046
|
-
google: "GEMINI_API_KEY",
|
|
4047
|
-
voyage: "VOYAGE_API_KEY",
|
|
4048
|
-
groq: "GROQ_API_KEY",
|
|
4049
|
-
deepgram: "DEEPGRAM_API_KEY",
|
|
4050
|
-
cerebras: "CEREBRAS_API_KEY",
|
|
4051
|
-
xai: "XAI_API_KEY",
|
|
4052
|
-
openrouter: "OPENROUTER_API_KEY",
|
|
4053
|
-
litellm: "LITELLM_API_KEY",
|
|
4054
|
-
"vercel-ai-gateway": "AI_GATEWAY_API_KEY",
|
|
4055
|
-
"cloudflare-ai-gateway": "CLOUDFLARE_AI_GATEWAY_API_KEY",
|
|
4056
|
-
moonshot: "MOONSHOT_API_KEY",
|
|
4057
|
-
minimax: "MINIMAX_API_KEY",
|
|
4058
|
-
nvidia: "NVIDIA_API_KEY",
|
|
4059
|
-
xiaomi: "XIAOMI_API_KEY",
|
|
4060
|
-
synthetic: "SYNTHETIC_API_KEY",
|
|
4061
|
-
venice: "VENICE_API_KEY",
|
|
4062
|
-
mistral: "MISTRAL_API_KEY",
|
|
4063
|
-
opencode: "OPENCODE_API_KEY",
|
|
4064
|
-
together: "TOGETHER_API_KEY",
|
|
4065
|
-
qianfan: "QIANFAN_API_KEY",
|
|
4066
|
-
ollama: "OLLAMA_API_KEY",
|
|
4067
|
-
vllm: "VLLM_API_KEY"
|
|
4068
|
-
}[normalized];
|
|
4069
|
-
if (!envVar) return null;
|
|
4070
|
-
return pick(envVar);
|
|
4071
|
-
}
|
|
4072
|
-
function resolveModelAuthMode(provider, cfg, store) {
|
|
4073
|
-
const resolved = provider?.trim();
|
|
4074
|
-
if (!resolved) return;
|
|
4075
|
-
const authOverride = resolveProviderAuthOverride(cfg, resolved);
|
|
4076
|
-
if (authOverride === "aws-sdk") return "aws-sdk";
|
|
4077
|
-
const authStore = store ?? ensureAuthProfileStore();
|
|
4078
|
-
const profiles = listProfilesForProvider(authStore, resolved);
|
|
4079
|
-
if (profiles.length > 0) {
|
|
4080
|
-
const modes = new Set(profiles.map((id) => authStore.profiles[id]?.type).filter((mode) => Boolean(mode)));
|
|
4081
|
-
if ([
|
|
4082
|
-
"oauth",
|
|
4083
|
-
"token",
|
|
4084
|
-
"api_key"
|
|
4085
|
-
].filter((k) => modes.has(k)).length >= 2) return "mixed";
|
|
4086
|
-
if (modes.has("oauth")) return "oauth";
|
|
4087
|
-
if (modes.has("token")) return "token";
|
|
4088
|
-
if (modes.has("api_key")) return "api-key";
|
|
4089
|
-
}
|
|
4090
|
-
if (authOverride === void 0 && normalizeProviderId(resolved) === "amazon-bedrock") return "aws-sdk";
|
|
4091
|
-
const envKey = resolveEnvApiKey(resolved);
|
|
4092
|
-
if (envKey?.apiKey) return envKey.source.includes("OAUTH_TOKEN") ? "oauth" : "api-key";
|
|
4093
|
-
if (getCustomProviderApiKey(cfg, resolved)) return "api-key";
|
|
4094
|
-
return "unknown";
|
|
4095
|
-
}
|
|
4096
|
-
async function getApiKeyForModel(params) {
|
|
4097
|
-
return resolveApiKeyForProvider({
|
|
4098
|
-
provider: params.model.provider,
|
|
4099
|
-
cfg: params.cfg,
|
|
4100
|
-
profileId: params.profileId,
|
|
4101
|
-
preferredProfile: params.preferredProfile,
|
|
4102
|
-
store: params.store,
|
|
4103
|
-
agentDir: params.agentDir
|
|
4104
|
-
});
|
|
4105
|
-
}
|
|
4106
|
-
function requireApiKey(auth, provider) {
|
|
4107
|
-
const key = normalizeSecretInput(auth.apiKey);
|
|
4108
|
-
if (key) return key;
|
|
4109
|
-
throw new Error(`No API key resolved for provider "${provider}" (auth mode: ${auth.mode}).`);
|
|
4110
|
-
}
|
|
4111
|
-
|
|
4112
|
-
//#endregion
|
|
4113
|
-
export { shouldEnableShellEnvFallback as $, normalizeProviderId as A, resolveImplicitCopilotProvider as B, buildAllowedModelSet as C, isCliProvider as D, findNormalizedProviderValue as E, resolveSubagentSpawnModelSelection as F, DEFAULT_MODEL as G, OLLAMA_NATIVE_BASE_URL as H, resolveThinkingDefault as I, normalizeSecretInput as J, DEFAULT_PROVIDER as K, normalizeGoogleModelId as L, resolveConfiguredModelRef as M, resolveDefaultModelForAgent as N, modelKey as O, resolveModelRefFromString as P, shouldDeferShellEnvFallback as Q, normalizeProviders as R, isPidAlive as S, buildModelAliasIndex as T, createOllamaStreamFn as U, resolveImplicitProviders as V, DEFAULT_CONTEXT_TOKENS as W, loadShellEnvFallback as X, getShellPathFromLoginShell as Y, resolveShellEnvFallbackTimeoutMs as Z, ensureAuthProfileStore as _, resolveEnvApiKey as a, withFileLock as b, resolveAuthProfileOrder as c, markAuthProfileFailure as d, markAuthProfileUsed as f, markAuthProfileGood as g, listProfilesForProvider as h, resolveApiKeyForProvider as i, parseModelRef as j, normalizeModelRef as k, getSoonestCooldownExpiry as l, dedupeProfileIds as m, getCustomProviderApiKey as n, resolveModelAuthMode as o, resolveApiKeyForProfile as p, resolveAuthProfileDisplayLabel as q, requireApiKey as r, auth_profiles_exports as s, getApiKeyForModel as t, isProfileInCooldown as u, resolveAuthStorePathForDisplay as v, buildConfiguredAllowlistKeys as w, resolveProcessScopedMap as x, resolveSymiAgentDir as y, resolveImplicitBedrockProvider as z };
|
|
4113
|
+
export { resolveSymiAgentDir as $, normalizeGoogleModelId as A, resolveApiKeyForProvider as B, normalizeProviderId as C, resolveModelRefFromString as D, resolveDefaultModelForAgent as E, OLLAMA_NATIVE_BASE_URL as F, loadShellEnvFallback as G, resolveModelAuthMode as H, createOllamaStreamFn as I, shouldEnableShellEnvFallback as J, resolveShellEnvFallbackTimeoutMs as K, getApiKeyForModel as L, resolveImplicitBedrockProvider as M, resolveImplicitCopilotProvider as N, resolveSubagentSpawnModelSelection as O, resolveImplicitProviders as P, resolveAuthProfileDisplayLabel as Q, getCustomProviderApiKey as R, normalizeModelRef as S, resolveConfiguredModelRef as T, normalizeSecretInput as U, resolveEnvApiKey as V, getShellPathFromLoginShell as W, DEFAULT_MODEL as X, DEFAULT_CONTEXT_TOKENS as Y, DEFAULT_PROVIDER as Z, buildConfiguredAllowlistKeys as _, markAuthProfileFailure as a, isCliProvider as b, dedupeProfileIds as c, ensureAuthProfileStore as d, resolveAuthStorePathForDisplay as f, buildAllowedModelSet as g, isPidAlive as h, isProfileInCooldown as i, normalizeProviders as j, resolveThinkingDefault as k, listProfilesForProvider as l, resolveProcessScopedMap as m, resolveAuthProfileOrder as n, markAuthProfileUsed as o, withFileLock as p, shouldDeferShellEnvFallback as q, getSoonestCooldownExpiry as r, resolveApiKeyForProfile as s, auth_profiles_exports as t, markAuthProfileGood as u, buildModelAliasIndex as v, parseModelRef as w, modelKey as x, findNormalizedProviderValue as y, requireApiKey as z };
|