@noxsoft/anima 5.0.1 → 5.0.3
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-BOkEyUcS.js → accounts-DjjQHOIW.js} +5 -5
- package/dist/{accounts-CVmv61PJ.js → accounts-Dzi6Ld7X.js} +2 -2
- package/dist/{acp-cli-C8aBckv5.js → acp-cli-I-yv1f5O.js} +15 -15
- package/dist/{acp-cli-BcshtFqY.js → acp-cli-QBd9GLqD.js} +3 -3
- package/dist/{agent-Cil6Zvns.js → agent-B3KeHK1A.js} +9 -9
- package/dist/{agent-c49U1LxE.js → agent-fG1PVmNy.js} +16 -16
- package/dist/{agent-scope-DICrDp7Y.js → agent-scope-BHR6uOLT.js} +2 -2
- package/dist/{agent-scope-BLiq3nK_.js → agent-scope-ryeVDUKe.js} +2 -2
- package/dist/{agents-2BloqCjm.js → agents-DY5ZtGB2.js} +9 -9
- package/dist/{agents.config-Bqr5rrkV.js → agents.config-DmF0fsB6.js} +1 -1
- package/dist/{anthropic-direct-runner-mh6c_WBB.js → anthropic-direct-runner-BJosFvVm.js} +41 -18
- package/dist/{anthropic-direct-runner-BVlO2Vi5.js → anthropic-direct-runner-BXb24VJt.js} +50 -27
- package/dist/{audit-BbmRSFjf.js → audit-BTMmL_HS.js} +5 -5
- package/dist/{audit-DegswVkZ.js → audit-qHMf9jWY.js} +16 -16
- package/dist/{auth-Cs_c5TKt.js → auth-DQfFqQBz.js} +3 -3
- package/dist/{auth-choice-BVAMr2Dk.js → auth-choice-BoyT3ahK.js} +60 -8
- package/dist/{auth-health-D0VUH0FQ.js → auth-health-BcABdgUT.js} +1 -1
- package/dist/{auth-profiles-k5IOWaG2.js → auth-profiles-BF5x9Ej0.js} +1 -1
- package/dist/{auth-profiles-BhZX2spm.js → auth-profiles-C_LmTbMb.js} +5 -5
- package/dist/{auth-profiles-Chf1JBpl.js → auth-profiles-Da39zGOD.js} +4 -4
- package/dist/{auth-store-D0vDEvCx.js → auth-store-CXZzirrJ.js} +3 -3
- package/dist/{auth-store-BMwyg-WK.js → auth-store-DTpDRu--.js} +3 -3
- package/dist/{banner-CgxCSS-T.js → banner-CJVa8aiZ.js} +1 -1
- package/dist/{bonjour-discovery-DaCmsB4i.js → bonjour-discovery-B3IeIN1u.js} +2 -2
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +22 -22
- package/dist/bundled/bootstrap-extra-files/handler.js +7 -7
- package/dist/bundled/session-memory/handler.js +19 -19
- package/dist/{call-Z_GCO8CL.js → call-BKsdSTVf.js} +1 -1
- package/dist/{call-BOwaQIXo.js → call-C3CH9PNK.js} +6 -6
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/{catalog-B-pfqu76.js → catalog-3hzXhHxJ.js} +2 -2
- package/dist/{channel-web-Y8i3EzJq.js → channel-web-Df3Ay9v7.js} +18 -18
- package/dist/{channels-status-issues-DenKLCLq.js → channels-status-issues-D5XAOSaj.js} +4 -4
- package/dist/{chrome-C3-muxXb.js → chrome-CLhrEjgx.js} +4 -4
- package/dist/{chrome-Cxl7I5SB.js → chrome-CkSIMI7j.js} +2 -2
- package/dist/{chunk-DGg8zCWl.js → chunk-Dq7ILx_r.js} +2 -2
- package/dist/{chunk-DFCmYqgJ.js → chunk-fcLG1hME.js} +1 -1
- package/dist/{clack-prompter-CCRr4nAr.js → clack-prompter-DmD_A7en.js} +5 -5
- package/dist/{clack-prompter-B-ZJG628.js → clack-prompter-bl-Zsxpq.js} +1 -1
- package/dist/cli/daemon-cli.js +1 -1
- package/dist/{cli-C3uw3mId.js → cli-0-FvuyBX.js} +22 -22
- package/dist/cli-CLVEx1Po.js +104 -0
- package/dist/{cli-session-BzZYmGP1.js → cli-session-CmX1oA1T.js} +7 -7
- package/dist/{cli-session-DgUHOBYo.js → cli-session-gR2abU0g.js} +16 -16
- package/dist/{client-BObcTF_9.js → client-BT3pbXCv.js} +3 -3
- package/dist/{command-registry-DLofaVIN.js → command-registry-C3SmyTQU.js} +12 -12
- package/dist/{common-k1Cu8adj.js → common-Bi43BlMQ.js} +2 -2
- package/dist/{common-Cd7BmlCQ.js → common-CSTOiddD.js} +2 -2
- package/dist/{completion-cli-C9KvX2ZF.js → completion-cli-308M08su.js} +2 -2
- package/dist/{completion-cli-3eYvtAih.js → completion-cli-D7gWcWEj.js} +3 -3
- package/dist/{config-B-9UciOO.js → config-BfhpauV9.js} +6 -6
- package/dist/{config-CG7uuHNE.js → config-Dk-5Mb_G.js} +6 -6
- package/dist/{config-D6D_ieel.js → config-Ofh9gKvs.js} +1 -1
- package/dist/config-cli-CajDGi9m.js +15 -0
- package/dist/{config-cli-CBXWDtvj.js → config-cli-De0z7mvk.js} +3 -3
- package/dist/{config-guard-BT3OoaEu.js → config-guard-BnkobgvR.js} +21 -21
- package/dist/{config-guard-qiKju2Fg.js → config-guard-DlOs5hMU.js} +2 -2
- package/dist/{configure-jlAKeuki.js → configure-BXK8YRUD.js} +32 -32
- package/dist/{configure-CH_-SNya.js → configure-Caf6yI_m.js} +24 -24
- package/dist/{configure-Dpk4lSoz.js → configure-DS9oQW51.js} +78 -78
- package/dist/{configure-CGTBBLR_.js → configure-DgXRL7Uz.js} +9 -9
- package/dist/{context-Cau0zD3W.js → context-BZV-msqG.js} +1 -1
- package/dist/{control-service-DMoq3DpT.js → control-service-BFYEuU-S.js} +5 -5
- package/dist/{control-service-CUhnhmpc.js → control-service-DUF4hGd3.js} +2 -2
- package/dist/{cron-cli-CKs1evSF.js → cron-cli-BglUapfu.js} +4 -4
- package/dist/{cron-cli-ybIqf_95.js → cron-cli-OHSsCpVe.js} +16 -16
- package/dist/{daemon-cli-C5Tosclk.js → daemon-cli-B2UGyc5z.js} +19 -19
- package/dist/{daemon-cli-CSCFNzUo.js → daemon-cli-CO-1GTE_.js} +5 -5
- package/dist/daemon-cli.js +58 -1
- package/dist/{daemon-runtime-B9AywEma.js → daemon-runtime-BsUCg0Nr.js} +3 -3
- package/dist/{daemon-runtime-DpY6Y5qE.js → daemon-runtime-cGQoReHT.js} +1 -1
- package/dist/{deliver-DkF6LCoS.js → deliver-CoAOvyW0.js} +1 -1
- package/dist/{deliver-BYxbDIF0.js → deliver-DhQSpWQA.js} +4 -4
- package/dist/{deliver-B2p9Fke_.js → deliver-DvbZ8dp4.js} +6 -6
- package/dist/{deps-D9266xfk.js → deps-CCbWMWT4.js} +1 -1
- package/dist/{diagnostics-TXSvtpaq.js → diagnostics-CtqVmSaZ.js} +1 -1
- package/dist/{dispatcher-DG44QJKz.js → dispatcher-C4k9ABOv.js} +2 -2
- package/dist/{dispatcher-BeO47t7A.js → dispatcher-N_4IYF9I.js} +1 -1
- package/dist/{dns-cli-BklOUsrX.js → dns-cli-DJ8mwzgA.js} +2 -2
- package/dist/{dns-cli-Dq98107U.js → dns-cli-Dk48S2y7.js} +13 -13
- package/dist/{docs-cli-CehJ2v5M.js → docs-cli-BvBEqoCl.js} +7 -7
- package/dist/{doctor-DJfgnQ67.js → doctor-9cbiXykn.js} +19 -19
- package/dist/{doctor-CWmHUAjs.js → doctor-C_1WNQix.js} +40 -40
- package/dist/{doctor-completion-CmJmktDv.js → doctor-completion-B1cKYcZj.js} +1 -1
- package/dist/{doctor-completion-CtCwd1fi.js → doctor-completion-D7uvGhAv.js} +3 -3
- package/dist/{doctor-config-flow-D0GgdMmi.js → doctor-config-flow-Bno6wZvG.js} +7 -7
- package/dist/{doctor-config-flow-D_8YNTSK.js → doctor-config-flow-rshwu4JS.js} +3 -3
- package/dist/entry.js +59 -2
- package/dist/{env-T3-raV4i.js → env-CLiKFfXU.js} +1 -1
- package/dist/{exec-DbnX_71w.js → exec-Bo7Vwe77.js} +1 -1
- package/dist/{exec-DnanRQle.js → exec-CEFTijVj.js} +1 -1
- package/dist/{exec-approvals-cli-B7hQEhGe.js → exec-approvals-cli-CRqO-FRn.js} +19 -19
- package/dist/{exec-approvals-cli-CcY7IQWQ.js → exec-approvals-cli-i_Bmu0zE.js} +4 -4
- package/dist/extensionAPI.js +1535 -315
- package/dist/{frontmatter-BmBmtOUh.js → frontmatter-Dsa7N963.js} +1 -1
- package/dist/{gateway-cli-DYrzIvOE.js → gateway-cli-CBmfvcpr.js} +99 -99
- package/dist/{gateway-cli-BazTmg20.js → gateway-cli-CufIzw2K.js} +43 -43
- package/dist/{gateway-rpc-LkRV5joR.js → gateway-rpc-BX-Pz0j8.js} +3 -3
- package/dist/{gateway-rpc-De-TWFvD.js → gateway-rpc-BvqpdNqp.js} +1 -1
- package/dist/{gmail-setup-utils-B4oMbrOI.js → gmail-setup-utils-B-LgbK-5.js} +3 -3
- package/dist/{health-BRSKF_iF.js → health-BVBoq6jM.js} +10 -10
- package/dist/{health-JqtB_B8C.js → health-DKC8u4W8.js} +18 -18
- package/dist/{health-format-Ojy0hLp3.js → health-format-DHYaqzgj.js} +2 -2
- package/dist/{heartbeat-visibility-BGj2czmk.js → heartbeat-visibility-CF3WzMM0.js} +2 -2
- package/dist/{heartbeat-visibility-pyFf6XBW.js → heartbeat-visibility-CUKC8xqZ.js} +2 -2
- package/dist/{help-format-BZ7j9sHT.js → help-format-mLYxJ3oD.js} +1 -1
- package/dist/{hooks-cli-B7g3jEC3.js → hooks-cli-BHO_BQFY.js} +23 -23
- package/dist/{hooks-cli-ZK4Z044T.js → hooks-cli-kLrFK7pV.js} +57 -57
- package/dist/{hooks-status-DR_WkhpR.js → hooks-status-CfvVr6eJ.js} +3 -3
- package/dist/{image-ops-B7tKwzpV.js → image-ops-C_aRXc-7.js} +1 -1
- package/dist/index.js +69 -69
- package/dist/{installs-BxZFjTKY.js → installs-DW-ErO4y.js} +5 -5
- package/dist/{lanes-DyM6NSSL.js → lanes-CrNcoc6P.js} +480 -163
- package/dist/{lifecycle-core-CHv9wUhV.js → lifecycle-core-DWESti3N.js} +6 -6
- package/dist/{links-CziCxopc.js → links-C4Hwnnc9.js} +1 -1
- package/dist/llm-slug-generator.js +17 -17
- package/dist/{logging-Dwz0XtXm.js → logging-CnEuyIPZ.js} +1 -1
- package/dist/{login-BvRe8YZ9.js → login-CY9_XaLc.js} +7 -7
- package/dist/{login-BbfWLOBl.js → login-Dj6hCAFK.js} +5 -5
- package/dist/{login-DevThvtW.js → login-Ga69_Kio.js} +2 -2
- package/dist/{login-qr-FDWY-tu5.js → login-qr-BYeWGzxI.js} +12 -12
- package/dist/{login-qr-BqhujMcQ.js → login-qr-DD1apkdT.js} +10 -10
- package/dist/{login-qr-BkpIGqae.js → login-qr-swgX7elR.js} +3 -3
- package/dist/{logs-cli-CiMRc2qL.js → logs-cli-D02oahhw.js} +4 -4
- package/dist/{logs-cli-CsfmPUwa.js → logs-cli-DAVu9h8p.js} +16 -16
- package/dist/{manager-CcawxgaC.js → manager-CLAy-qOR.js} +10 -10
- package/dist/{manager-v4S80Br3.js → manager-DQPfk6Ea.js} +12 -12
- package/dist/{manager-DS1DfkbC.js → manager-yWxV2UI_.js} +1 -1
- package/dist/{manifest-registry-BiGCvMJ8.js → manifest-registry-BJat2nhC.js} +1 -1
- package/dist/{memory-cli-wDO418hx.js → memory-cli-B8AsIRG3.js} +3 -3
- package/dist/{memory-cli-Cl2n9UtH.js → memory-cli-bA70cVlm.js} +12 -12
- package/dist/{message-channel-DuxJGOJz.js → message-channel-C5I8UgGH.js} +1 -1
- package/dist/{model-auth-Ja4oelNH.js → model-auth-Be3_KahV.js} +2 -2
- package/dist/{model-auth-DVG37yXU.js → model-auth-DBHvPqaY.js} +4 -4
- package/dist/{model-auth-Uxm-wRjR.js → model-auth-DYHjH-Oh.js} +3 -3
- package/dist/{model-selection-xZLlICyg.js → model-selection-BuMFehML.js} +5 -2
- package/dist/{model-selection-BKFF7fDb.js → model-selection-DFbDH9o2.js} +4 -1
- package/dist/{model-selection-C2dAUmK_.js → model-selection-DRIxw3do.js} +5 -2
- package/dist/{models-tQnX4hL4.js → models-B9jYbX5H.js} +26 -26
- package/dist/{node-cli-DAcW-rfA.js → node-cli-C_efNJ2B.js} +7 -7
- package/dist/{node-cli-CZuWFgpO.js → node-cli-ScPCT6uD.js} +28 -28
- package/dist/{node-service-Ds1r16VN.js → node-service-BCfZtWK_.js} +1 -1
- package/dist/{note-Daao-cv8.js → note-DjzS4Am4.js} +2 -2
- package/dist/{npm-registry-spec-fJIJ8GG5.js → npm-registry-spec-Opq9qQXl.js} +1 -1
- package/dist/{onboard-Dd6xFMYB.js → onboard-C7ZSJNCe.js} +10 -10
- package/dist/{onboard-dasbF9G1.js → onboard-CJOJPctL.js} +17 -17
- package/dist/{onboard-channels-DisvVyIs.js → onboard-channels-DSlUCvl1.js} +2 -2
- package/dist/{onboard-channels-BUv3VbAL.js → onboard-channels-DwPNXSwW.js} +9 -9
- package/dist/{onboard-helpers-BgsHO6fO.js → onboard-helpers-CU_S0_Kf.js} +10 -10
- package/dist/{onboard-helpers-49TVSf7J.js → onboard-helpers-tkuUrdCB.js} +2 -2
- package/dist/{onboarding-Dq3bCBjc.js → onboarding-Caiq91Yz.js} +10 -10
- package/dist/{onboarding-6Xs4orLw.js → onboarding-DP2NlqhA.js} +20 -20
- package/dist/{outbound-RxegsVGB.js → outbound-B84phlQU.js} +4 -4
- package/dist/{outbound-CliT3nme.js → outbound-CKmmCVxJ.js} +1 -1
- package/dist/{outbound-CLII4C2A.js → outbound-DKM-JeSH.js} +5 -5
- package/dist/{parse-timeout-BnOIKwx8.js → parse-timeout-C59j-ev4.js} +1 -1
- package/dist/{parse-timeout-C8t_lmnL.js → parse-timeout-aZGyXXFz.js} +3 -3
- package/dist/{path-env-CsgLP0dy.js → path-env-cFxXrXB1.js} +1 -1
- package/dist/{paths-DybdJi5a.js → paths-CLxC7m0Z.js} +1 -1
- package/dist/{pi-auth-json-MH7vz0HI.js → pi-auth-json-DPoqstQN.js} +7 -7
- package/dist/{pi-auth-json-BY6wRDm0.js → pi-auth-json-DjxzPUt3.js} +2 -2
- package/dist/{pi-auth-json-DLroEcea.js → pi-auth-json-hMxhauJ8.js} +6 -6
- package/dist/{pi-embedded-CS4D_0t7.js → pi-embedded-JUmNmkTK.js} +700 -362
- package/dist/{pi-embedded-helpers-iju5zIIA.js → pi-embedded-helpers-B6wVA0hU.js} +1 -1
- package/dist/{pi-embedded-helpers-DnRfi8bN.js → pi-embedded-helpers-B_Sx4G6d.js} +30 -20
- package/dist/{pi-tools.policy-RhdERrk3.js → pi-tools.policy-Bn9S3ywB.js} +2 -2
- package/dist/{pi-tools.policy-CN78I2yN.js → pi-tools.policy-ChzY9kW7.js} +7 -7
- package/dist/{plugin-auto-enable-DLrgOd4y.js → plugin-auto-enable-UE1XVFcw.js} +1 -1
- package/dist/{plugin-auto-enable-DIWd94Po.js → plugin-auto-enable-f05JE-GF.js} +5 -5
- package/dist/{plugin-registry-l3z9phEV.js → plugin-registry-BeB2L6Qe.js} +2 -2
- package/dist/{plugin-registry-esOxvV3X.js → plugin-registry-DIXcynua.js} +4 -4
- package/dist/plugin-sdk/agents/anthropic-direct-runner.d.ts +1 -1
- package/dist/plugin-sdk/agents/gemini-direct-runner.d.ts +38 -0
- package/dist/plugin-sdk/agents/tools/browser-tool.schema.d.ts +2 -2
- package/dist/plugin-sdk/commands/onboard-types.d.ts +2 -2
- package/dist/plugin-sdk/gateway/protocol/index.d.ts +22 -22
- package/dist/plugin-sdk/index.js +75 -8
- package/dist/{plugins-C_GedoUi.js → plugins-DCXdhkeB.js} +2 -2
- package/dist/{plugins-BmYfBGLM.js → plugins-NbldDVJs.js} +1 -1
- package/dist/{plugins-cli-CbXtuN4b.js → plugins-cli-CzUD-ewi.js} +58 -58
- package/dist/{plugins-cli-D2v0n4BL.js → plugins-cli-Dk2W0fBT.js} +23 -23
- package/dist/{polls-Cuv4dsX_.js → polls-OzE9fR2s.js} +6 -6
- package/dist/{ports-DOiSDgNp.js → ports-CWvYU8j6.js} +4 -4
- package/dist/{ports-BQ0cAsGj.js → ports-Cgow804e.js} +2 -2
- package/dist/{program-y0NPJuYm.js → program-DxItv_Ts.js} +28 -28
- package/dist/{program-context-CqPwmgYa.js → program-context-cgh8PMPD.js} +33 -33
- package/dist/{progress-BZZa-fXr.js → progress-DzZ_4Z4f.js} +1 -1
- package/dist/{prompt-style-1bwj7IzZ.js → prompt-style-C7WfXowC.js} +1 -1
- package/dist/{prompts-DY0qdoD1.js → prompts-BfHxhlF9.js} +13 -2
- package/dist/{prompts-DTKoIKPV.js → prompts-DH_nIROF.js} +71 -8
- package/dist/{pw-ai-BhoKfvvM.js → pw-ai-Bigm0Qwh.js} +7 -7
- package/dist/{pw-ai-CJgeaF06.js → pw-ai-CsODxGt8.js} +3 -3
- package/dist/{qmd-manager-BGob_1OP.js → qmd-manager-C3z8LWKx.js} +6 -6
- package/dist/{qmd-manager-BmGj4bZk.js → qmd-manager-lfhigvUf.js} +6 -6
- package/dist/{register.agent-CRazop1A.js → register.agent-BVwbjkKx.js} +30 -30
- package/dist/{register.agent-Bi2FqIlN.js → register.agent-D0FKVD_s.js} +70 -70
- package/dist/{register.anima-BmdRCJLy.js → register.anima-Dc7OI2Nh.js} +4 -4
- package/dist/{register.anima-FFaI_C8x.js → register.anima-bys_cyEd.js} +4 -4
- package/dist/{register.configure-FIXOWrO9.js → register.configure-BrRG_RtB.js} +31 -31
- package/dist/register.configure-CXKr61Ka.js +108 -0
- package/dist/register.maintenance-BToHjam6.js +103 -0
- package/dist/{register.maintenance-DJYji5mV.js → register.maintenance-DXL3L0ip.js} +35 -35
- package/dist/{register.onboard-thGXwzOX.js → register.onboard-B3hbdfaQ.js} +71 -71
- package/dist/{register.onboard-oUsWjmam.js → register.onboard-Bg5zEb3f.js} +35 -35
- package/dist/{register.setup-B4MYuE3g.js → register.setup-CZqwphif.js} +35 -35
- package/dist/{register.setup-DWDrQ7RT.js → register.setup-Cq8nqbrU.js} +71 -71
- package/dist/{register.status-health-sessions-Ce9QUAyj.js → register.status-health-sessions-D1kjQUAc.js} +67 -67
- package/dist/{register.status-health-sessions-CTKdzo7a.js → register.status-health-sessions-mdLJbfPN.js} +28 -28
- package/dist/{register.subclis-CWmYc4AB.js → register.subclis-mbYw7H-_.js} +20 -20
- package/dist/{reply-BKpIrCr-.js → reply-CwV-5jE0.js} +56 -52
- package/dist/{reply-CpHIJ9Kk.js → reply-DAGmjvs-.js} +33 -29
- package/dist/{reply-prefix-BO_Dt82N.js → reply-prefix-BRsV1Eof.js} +2 -2
- package/dist/{reply-prefix-BwVBvQXp.js → reply-prefix-CAsFNEP7.js} +2 -2
- package/dist/{routes-C2EyUA9x.js → routes-CYHrkIjB.js} +6 -6
- package/dist/{routes-XhTPYecR.js → routes-cdfVFYMI.js} +2 -2
- package/dist/{run-CGokiDR8.js → run-DE6EaeE3.js} +70 -70
- package/dist/{run--9hftM2H.js → run-S0Cw3Fyy.js} +32 -32
- package/dist/{run-main-DxcOzCLw.js → run-main-CCxXEvb7.js} +41 -41
- package/dist/{runtime-guard-B40AREJ_.js → runtime-guard-CNnLK4pn.js} +1 -1
- package/dist/{sandbox-BwUo1b0I.js → sandbox-B4-dXpqZ.js} +6 -6
- package/dist/{sandbox-CiwAPzO7.js → sandbox-DhcoWMaN.js} +2 -2
- package/dist/{sandbox-cli-D9-wZJ9M.js → sandbox-cli-DQMWPCOh.js} +24 -24
- package/dist/{sandbox-cli-DsrzwG_s.js → sandbox-cli-TAuv3mTO.js} +6 -6
- package/dist/{security-cli-CX5uciKz.js → security-cli-Da-3YxZ4.js} +29 -29
- package/dist/{security-cli-CouqfUGc.js → security-cli-Dc-NwTC2.js} +9 -9
- package/dist/{semantic-Buqqx7gZ.js → semantic-BlQgdb3-.js} +1 -1
- package/dist/{semantic-B4TOg4CK.js → semantic-VlSmVCfb.js} +1 -1
- package/dist/{server-context-B78_sSOW.js → server-context-C-usQ5Np.js} +1 -1
- package/dist/{server-context-efO1YgXk.js → server-context-r7wPe4ZD.js} +9 -9
- package/dist/{server-node-events-TN_Y9MgU.js → server-node-events-3KeQAwUo.js} +14 -14
- package/dist/{server-node-events-DJlLCF2M.js → server-node-events-GTSQEd_U.js} +36 -36
- package/dist/{service-D1idQeBv.js → service-DCVAkKlN.js} +1 -1
- package/dist/{service-audit-BzwV-IOi.js → service-audit-Crw1cAbj.js} +1 -1
- package/dist/{service-audit-BbwXAhsr.js → service-audit-DRIpsryX.js} +3 -3
- package/dist/{session-Dvwwi-Eb.js → session-CrGApVik.js} +1 -1
- package/dist/{session-skOcrvF2.js → session-D3BNUwtH.js} +1 -1
- package/dist/{session-DCGAvNG9.js → session-DKCUYHCS.js} +1 -1
- package/dist/{session-cost-usage-6bDLU9Pb.js → session-cost-usage-LvsvRW5g.js} +1 -1
- package/dist/{session-BjPdEBPh.js → session-mpOb9zFL.js} +5 -5
- package/dist/{sessions-kJgmpWtv.js → sessions-BduC6sZj.js} +78 -68
- package/dist/{sessions-B7ikzhI_.js → sessions-CAiEkTKb.js} +18 -8
- package/dist/{sessions-B7clh58j.js → sessions-DLPN62LD.js} +4 -4
- package/dist/{settings-cli-JU5bg5jb.js → settings-cli-BgGYdH4N.js} +77 -77
- package/dist/{settings-cli-DjVugHID.js → settings-cli-f0O0FUVO.js} +32 -32
- package/dist/{setup-token-CvRwJUVY.js → setup-token-lcjrc9sO.js} +28 -28
- package/dist/{setup-token-wFsQlaW2.js → setup-token-ykp60QVx.js} +9 -9
- package/dist/{shared-DC8lQHCt.js → shared-Ca0NTTF0.js} +3 -3
- package/dist/{shell-env-JzaPTLKV.js → shell-env-BZ_fIIlm.js} +1 -1
- package/dist/{shell-env-C1yK_Rod.js → shell-env-DaSbgZYX.js} +2 -2
- package/dist/{skill-scanner-HQwt_KRF.js → skill-scanner--TxpCSNF.js} +1 -1
- package/dist/{skills-cli-OYZS-U1f.js → skills-cli-BpyTvFkg.js} +16 -16
- package/dist/{skills-cli-CSMzc9am.js → skills-cli-Tm326cFx.js} +2 -2
- package/dist/{skills-install-BKz5WLq4.js → skills-install-B2m10oTm.js} +5 -5
- package/dist/{skills-status-B_umZ78Q.js → skills-status-D14GZ5WN.js} +3 -3
- package/dist/{skills-ppB3qrZU.js → skills-wS8aRGeO.js} +3 -3
- package/dist/{soul-DpWsWxOa.js → soul-CAEpnUkv.js} +1 -1
- package/dist/{soul-aZoR6Ctt.js → soul-D9EtC35X.js} +1 -1
- package/dist/{sqlite-CnVGUfhz.js → sqlite-B0rfPL8q.js} +2 -2
- package/dist/{sqlite-Duz1QJIT.js → sqlite-CR0WDTae.js} +2 -2
- package/dist/start-DYq7cNRG.js +157 -0
- package/dist/{start-CAbxlnFZ.js → start-Y69GZPdX.js} +41 -41
- package/dist/{status-YH65ctig.js → status-BplZv8_T.js} +2 -2
- package/dist/{status-CrJV2Y4x.js → status-K3LGPZeT.js} +4 -4
- package/dist/{status-CxxXFU4R.js → status-Uzlo7BvY.js} +27 -27
- package/dist/{status-1TjjCE1l.js → status-rt3tIYmL.js} +13 -13
- package/dist/{status.update-P6xyBet8.js → status.update-B61Emp_r.js} +3 -3
- package/dist/{status.update-BzAuf_G-.js → status.update-yjbKzlMn.js} +1 -1
- package/dist/{subagent-registry-xJY9wqZy.js → subagent-registry-DfCDq9hk.js} +14 -14
- package/dist/{subagent-registry-3Dw3YppH.js → subagent-registry-ZIpC5W-9.js} +7 -7
- package/dist/{subagent-registry-B_65nJFp.js → subagent-registry-xp5sYYzS.js} +13 -13
- package/dist/{subsystem-Cn6bJV8Z.js → subsystem-BMsbqSb4.js} +58 -1
- package/dist/{subsystem-WFp78xn1.js → subsystem-BP2l3SHn.js} +58 -1
- package/dist/{system-cli-Dbn4_ed8.js → system-cli-D-eyDWD6.js} +4 -4
- package/dist/{system-cli-lmslA_Ox.js → system-cli-Dy2Pwnbg.js} +15 -15
- package/dist/{systemd-DYPdTwok.js → systemd-DXo2A9_S.js} +2 -2
- package/dist/{systemd-hints-E8yYE8Q1.js → systemd-hints-DIjCA1An.js} +1 -1
- package/dist/{systemd-linger-CpWguZ4b.js → systemd-linger-DgB-ow-D.js} +2 -2
- package/dist/{table-B991ZwKi.js → table-C-GNQABy.js} +2 -2
- package/dist/{timeout-Dbspj9Jf.js → timeout-Cl8rWNWO.js} +350 -33
- package/dist/{tokens-k_R7Y792.js → tokens-FGW_JgKz.js} +1 -1
- package/dist/{tool-images-DJZPwGqm.js → tool-images-Df50dvpv.js} +2 -2
- package/dist/{tool-images-BehEzEZF.js → tool-images-RiPaL7wQ.js} +2 -2
- package/dist/{tui-PCTDV7Ct.js → tui-NlR4LFBm.js} +9 -9
- package/dist/{tui--eIVX_W0.js → tui-YsmTyq58.js} +3 -3
- package/dist/{tui-cli-DBV3lnXA.js → tui-cli-CSudxVpO.js} +9 -9
- package/dist/{tui-cli-D39zC_Ew.js → tui-cli-QnKj1We8.js} +28 -28
- package/dist/{update-tjMvDUCw.js → update-B2O46V_t.js} +3 -3
- package/dist/{update-cli-QP5L8xlv.js → update-cli-BXKL-v-n.js} +86 -86
- package/dist/{update-cli-BzaQvirL.js → update-cli-BgQUtlLg.js} +37 -37
- package/dist/{update-runner-ZuJN8uBE.js → update-runner-U2WcWGfd.js} +5 -5
- package/dist/{update-runner-B_oj7S_n.js → update-runner-fvdM_Hip.js} +1 -1
- package/dist/{usage-DzKbMa8N.js → usage-CM-NiwBA.js} +9 -9
- package/dist/{utils-dWKYjULE.js → utils-B60lF9Wq.js} +1 -1
- package/dist/{web-CgQc2Raf.js → web-B8r6MvXh.js} +43 -43
- package/dist/web-BzFhL5WI.js +67 -0
- package/dist/{web-nI3eIGAT.js → web-eoSM6P0a.js} +26 -26
- package/dist/{webhooks-cli-CYbIJJF6.js → webhooks-cli-24A2CbXR.js} +2 -2
- package/dist/{webhooks-cli-oRmSfYdd.js → webhooks-cli-CgkxWcH5.js} +13 -13
- package/dist/{whatsapp-actions-BzPQUcRR.js → whatsapp-actions-BVlqbVgY.js} +3 -3
- package/dist/{whatsapp-actions-CZuxHplg.js → whatsapp-actions-BYxKWK0A.js} +13 -13
- package/dist/{whatsapp-actions-BB-Leqn2.js → whatsapp-actions-DagVwYC6.js} +17 -17
- package/dist/{widearea-dns-CkuHFBQy.js → widearea-dns-B1TTb1v5.js} +1 -1
- package/dist/{workspace-DOJssemp.js → workspace-Cvio8QlZ.js} +1 -1
- package/dist/{ws-log-B-xsUQys.js → ws-log-De7GACYn.js} +1 -1
- package/dist/{ws-CQYP0dWu.js → ws-sdRTa2sP.js} +1 -1
- package/package.json +1 -1
- package/dist/cli-CfvBmuhw.js +0 -104
- package/dist/config-cli-cmNuTlw0.js +0 -15
- package/dist/register.configure-r5AViY3N.js +0 -108
- package/dist/register.maintenance-Cpf0ZZTL.js +0 -103
- package/dist/start-M9abr1O1.js +0 -157
- package/dist/web-DtWSf5wm.js +0 -67
- /package/dist/{boolean-M-esQJt6.js → boolean-Ce2-qkSB.js} +0 -0
- /package/dist/{command-format-B1WxXbeU.js → command-format-UwAvxtMC.js} +0 -0
- /package/dist/{config-Qw5FwfRK.js → config-COtiNNtV.js} +0 -0
- /package/dist/{errors-DjZBTJJ3.js → errors-D6Vj_xs4.js} +0 -0
- /package/dist/{file-lock-BRW4LeL0.js → file-lock-BFQVGKm5.js} +0 -0
- /package/dist/{input-provenance-B0pwc6mp.js → input-provenance-sPbZYo89.js} +0 -0
- /package/dist/{internal-hooks-Exeq-wmx.js → internal-hooks-CWw3Hgeu.js} +0 -0
- /package/dist/{paths-BvY3CbW0.js → paths-CnuAkdfx.js} +0 -0
- /package/dist/{tailnet-CjJJHjPU.js → tailnet-CabhakZ7.js} +0 -0
- /package/dist/{transcript-events-DUQC5hbS.js → transcript-events-C1hdue6u.js} +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { E as resolveAgentIdFromSessionKey, M as parseAgentSessionKey, S as classifySessionKeyShape, _ as DEFAULT_AGENT_ID, f as loadWorkspaceBootstrapFiles, m as resolveAnimaPackageRoot, u as filterBootstrapFilesForSession, w as normalizeAgentId } from "./workspace-
|
|
2
|
-
import { t as createSubsystemLogger, v as logVerbose, x as shouldLogVerbose } from "./subsystem-
|
|
3
|
-
import { _ as isRecord, l as CONFIG_DIR, m as escapeRegExp, n as runExec, t as runCommandWithTimeout, w as resolveUserPath } from "./exec-
|
|
4
|
-
import { c as resolveDefaultAgentId, s as resolveAgentWorkspaceDir, u as resolveSessionAgentIds } from "./agent-scope-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { s as isTruthyEnvValue } from "./shell-env-
|
|
8
|
-
import {
|
|
9
|
-
import { C as getFileExtension, D as normalizeMimeType, l as listDeliverableMessageChannels, r as normalizeChannelId } from "./plugins-
|
|
10
|
-
import { s as loadAuthProfileStore } from "./auth-profiles-
|
|
11
|
-
import { r as requireApiKey, t as getApiKeyForModel } from "./model-auth-
|
|
1
|
+
import { E as resolveAgentIdFromSessionKey, M as parseAgentSessionKey, S as classifySessionKeyShape, _ as DEFAULT_AGENT_ID, f as loadWorkspaceBootstrapFiles, m as resolveAnimaPackageRoot, u as filterBootstrapFilesForSession, w as normalizeAgentId } from "./workspace-Cvio8QlZ.js";
|
|
2
|
+
import { t as createSubsystemLogger, v as logVerbose, x as shouldLogVerbose } from "./subsystem-BP2l3SHn.js";
|
|
3
|
+
import { _ as isRecord, l as CONFIG_DIR, m as escapeRegExp, n as runExec, t as runCommandWithTimeout, w as resolveUserPath } from "./exec-CEFTijVj.js";
|
|
4
|
+
import { c as resolveDefaultAgentId, s as resolveAgentWorkspaceDir, u as resolveSessionAgentIds } from "./agent-scope-BHR6uOLT.js";
|
|
5
|
+
import { At as HEARTBEAT_TOKEN, Dt as buildBootstrapContextFiles, Ot as resolveBootstrapMaxChars, f as classifyFailoverReason, h as isFailoverErrorMessage, jt as SILENT_REPLY_TOKEN, kt as resolveBootstrapTotalMaxChars } from "./pi-embedded-helpers-B_Sx4G6d.js";
|
|
6
|
+
import { i as triggerInternalHook, t as createInternalHookEvent } from "./internal-hooks-CWw3Hgeu.js";
|
|
7
|
+
import { s as isTruthyEnvValue } from "./shell-env-DaSbgZYX.js";
|
|
8
|
+
import { d as resolveModelRefFromString, r as buildModelAliasIndex, s as normalizeProviderId, u as resolveDefaultModelForAgent } from "./model-selection-BuMFehML.js";
|
|
9
|
+
import { C as getFileExtension, D as normalizeMimeType, l as listDeliverableMessageChannels, r as normalizeChannelId } from "./plugins-DCXdhkeB.js";
|
|
10
|
+
import { s as loadAuthProfileStore } from "./auth-profiles-Da39zGOD.js";
|
|
11
|
+
import { i as resolveApiKeyForProvider, r as requireApiKey, t as getApiKeyForModel } from "./model-auth-DYHjH-Oh.js";
|
|
12
12
|
import fs from "node:fs/promises";
|
|
13
13
|
import os, { homedir, tmpdir } from "node:os";
|
|
14
14
|
import path, { join } from "node:path";
|
|
@@ -18,169 +18,6 @@ import crypto from "node:crypto";
|
|
|
18
18
|
import { completeSimple } from "@mariozechner/pi-ai";
|
|
19
19
|
import { EdgeTTS } from "node-edge-tts";
|
|
20
20
|
|
|
21
|
-
//#region src/agents/cli-backends.ts
|
|
22
|
-
const DEFAULT_CLAUDE_BACKEND = {
|
|
23
|
-
command: "claude",
|
|
24
|
-
args: [
|
|
25
|
-
"-p",
|
|
26
|
-
"--output-format",
|
|
27
|
-
"json",
|
|
28
|
-
"--dangerously-skip-permissions"
|
|
29
|
-
],
|
|
30
|
-
resumeArgs: [
|
|
31
|
-
"-p",
|
|
32
|
-
"--output-format",
|
|
33
|
-
"json",
|
|
34
|
-
"--dangerously-skip-permissions",
|
|
35
|
-
"--resume",
|
|
36
|
-
"{sessionId}"
|
|
37
|
-
],
|
|
38
|
-
output: "jsonl",
|
|
39
|
-
input: "arg",
|
|
40
|
-
modelArg: "--model",
|
|
41
|
-
modelAliases: {
|
|
42
|
-
opus: "opus",
|
|
43
|
-
"opus-4.6": "opus",
|
|
44
|
-
"opus-4.5": "opus",
|
|
45
|
-
"opus-4": "opus",
|
|
46
|
-
"claude-opus-4-6": "opus",
|
|
47
|
-
"claude-opus-4-5": "opus",
|
|
48
|
-
"claude-opus-4": "opus",
|
|
49
|
-
sonnet: "sonnet",
|
|
50
|
-
"sonnet-4.5": "sonnet",
|
|
51
|
-
"sonnet-4.1": "sonnet",
|
|
52
|
-
"sonnet-4.0": "sonnet",
|
|
53
|
-
"claude-sonnet-4-5": "sonnet",
|
|
54
|
-
"claude-sonnet-4-1": "sonnet",
|
|
55
|
-
"claude-sonnet-4-0": "sonnet",
|
|
56
|
-
haiku: "haiku",
|
|
57
|
-
"haiku-3.5": "haiku",
|
|
58
|
-
"claude-haiku-3-5": "haiku"
|
|
59
|
-
},
|
|
60
|
-
sessionArg: "--session-id",
|
|
61
|
-
sessionMode: "always",
|
|
62
|
-
sessionIdFields: [
|
|
63
|
-
"session_id",
|
|
64
|
-
"sessionId",
|
|
65
|
-
"conversation_id",
|
|
66
|
-
"conversationId"
|
|
67
|
-
],
|
|
68
|
-
systemPromptArg: "--append-system-prompt",
|
|
69
|
-
systemPromptMode: "append",
|
|
70
|
-
systemPromptWhen: "first",
|
|
71
|
-
clearEnv: ["ANTHROPIC_API_KEY", "ANTHROPIC_API_KEY_OLD"],
|
|
72
|
-
serialize: true
|
|
73
|
-
};
|
|
74
|
-
const DEFAULT_CODEX_BACKEND = {
|
|
75
|
-
command: "codex",
|
|
76
|
-
args: [
|
|
77
|
-
"exec",
|
|
78
|
-
"--json",
|
|
79
|
-
"--color",
|
|
80
|
-
"never",
|
|
81
|
-
"--sandbox",
|
|
82
|
-
"read-only",
|
|
83
|
-
"--skip-git-repo-check"
|
|
84
|
-
],
|
|
85
|
-
resumeArgs: [
|
|
86
|
-
"exec",
|
|
87
|
-
"resume",
|
|
88
|
-
"{sessionId}"
|
|
89
|
-
],
|
|
90
|
-
output: "jsonl",
|
|
91
|
-
resumeOutput: "text",
|
|
92
|
-
input: "arg",
|
|
93
|
-
modelArg: "--model",
|
|
94
|
-
imageArg: "--image",
|
|
95
|
-
sessionMode: "existing",
|
|
96
|
-
serialize: true
|
|
97
|
-
};
|
|
98
|
-
const CLAUDE_BACKEND_ALIASES = [
|
|
99
|
-
"claude-cli",
|
|
100
|
-
"anthropic",
|
|
101
|
-
"claude"
|
|
102
|
-
];
|
|
103
|
-
const CODEX_BACKEND_ALIASES = [
|
|
104
|
-
"codex-cli",
|
|
105
|
-
"openai-codex",
|
|
106
|
-
"openai",
|
|
107
|
-
"codex"
|
|
108
|
-
];
|
|
109
|
-
const CLAUDE_BACKEND_ALIAS_SET = new Set(CLAUDE_BACKEND_ALIASES.map((alias) => normalizeBackendKey(alias)));
|
|
110
|
-
const CODEX_BACKEND_ALIAS_SET = new Set(CODEX_BACKEND_ALIASES.map((alias) => normalizeBackendKey(alias)));
|
|
111
|
-
function normalizeBackendKey(key) {
|
|
112
|
-
return normalizeProviderId(key);
|
|
113
|
-
}
|
|
114
|
-
function pickBackendConfig(config, normalizedId) {
|
|
115
|
-
for (const [key, entry] of Object.entries(config)) if (normalizeBackendKey(key) === normalizedId) return entry;
|
|
116
|
-
}
|
|
117
|
-
function pickBackendConfigByAliases(config, aliases) {
|
|
118
|
-
for (const alias of aliases) {
|
|
119
|
-
const matched = pickBackendConfig(config, normalizeBackendKey(alias));
|
|
120
|
-
if (matched) return matched;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
function mergeBackendConfig(base, override) {
|
|
124
|
-
if (!override) return { ...base };
|
|
125
|
-
return {
|
|
126
|
-
...base,
|
|
127
|
-
...override,
|
|
128
|
-
args: override.args ?? base.args,
|
|
129
|
-
env: {
|
|
130
|
-
...base.env,
|
|
131
|
-
...override.env
|
|
132
|
-
},
|
|
133
|
-
modelAliases: {
|
|
134
|
-
...base.modelAliases,
|
|
135
|
-
...override.modelAliases
|
|
136
|
-
},
|
|
137
|
-
clearEnv: Array.from(new Set([...base.clearEnv ?? [], ...override.clearEnv ?? []])),
|
|
138
|
-
sessionIdFields: override.sessionIdFields ?? base.sessionIdFields,
|
|
139
|
-
sessionArgs: override.sessionArgs ?? base.sessionArgs,
|
|
140
|
-
resumeArgs: override.resumeArgs ?? base.resumeArgs
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
function resolveCliBackendConfig(provider, cfg) {
|
|
144
|
-
const normalized = normalizeBackendKey(provider);
|
|
145
|
-
const configured = cfg?.agents?.defaults?.cliBackends ?? {};
|
|
146
|
-
if (CLAUDE_BACKEND_ALIAS_SET.has(normalized)) {
|
|
147
|
-
const merged = mergeBackendConfig(DEFAULT_CLAUDE_BACKEND, pickBackendConfigByAliases(configured, [provider, ...CLAUDE_BACKEND_ALIASES]));
|
|
148
|
-
const command = merged.command?.trim();
|
|
149
|
-
if (!command) return null;
|
|
150
|
-
return {
|
|
151
|
-
id: normalizeBackendKey("claude-cli"),
|
|
152
|
-
config: {
|
|
153
|
-
...merged,
|
|
154
|
-
command
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
if (CODEX_BACKEND_ALIAS_SET.has(normalized)) {
|
|
159
|
-
const merged = mergeBackendConfig(DEFAULT_CODEX_BACKEND, pickBackendConfigByAliases(configured, [provider, ...CODEX_BACKEND_ALIASES]));
|
|
160
|
-
const command = merged.command?.trim();
|
|
161
|
-
if (!command) return null;
|
|
162
|
-
return {
|
|
163
|
-
id: normalizeBackendKey("codex-cli"),
|
|
164
|
-
config: {
|
|
165
|
-
...merged,
|
|
166
|
-
command
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
const override = pickBackendConfig(configured, normalized);
|
|
171
|
-
if (!override) return null;
|
|
172
|
-
const command = override.command?.trim();
|
|
173
|
-
if (!command) return null;
|
|
174
|
-
return {
|
|
175
|
-
id: normalized,
|
|
176
|
-
config: {
|
|
177
|
-
...override,
|
|
178
|
-
command
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
//#endregion
|
|
184
21
|
//#region src/auto-reply/heartbeat.ts
|
|
185
22
|
const HEARTBEAT_PROMPT = "Read HEARTBEAT.md if it exists (workspace context). Follow it strictly. Do not infer or repeat old tasks from prior chats. If nothing needs attention, reply HEARTBEAT_OK.";
|
|
186
23
|
const DEFAULT_HEARTBEAT_ACK_MAX_CHARS = 300;
|
|
@@ -364,7 +201,7 @@ function isVoiceCompatibleAudio(opts) {
|
|
|
364
201
|
|
|
365
202
|
//#endregion
|
|
366
203
|
//#region src/agents/pi-embedded-runner/model.ts
|
|
367
|
-
function resolveModel$
|
|
204
|
+
function resolveModel$2(..._args) {
|
|
368
205
|
return { error: "pi-embedded removed — use Claude Code CLI spawner" };
|
|
369
206
|
}
|
|
370
207
|
|
|
@@ -709,7 +546,7 @@ async function summarizeText(params) {
|
|
|
709
546
|
if (targetLength < 100 || targetLength > 1e4) throw new Error(`Invalid targetLength: ${targetLength}`);
|
|
710
547
|
const startTime = Date.now();
|
|
711
548
|
const { ref } = resolveSummaryModelRef(cfg, config);
|
|
712
|
-
const resolved = resolveModel$
|
|
549
|
+
const resolved = resolveModel$2(ref.provider, ref.model, void 0, cfg);
|
|
713
550
|
if (!resolved.model) throw new Error(resolved.error ?? `Unknown summary model: ${ref.provider}/${ref.model}`);
|
|
714
551
|
const apiKey = requireApiKey(await getApiKeyForModel({
|
|
715
552
|
model: resolved.model,
|
|
@@ -1774,6 +1611,37 @@ function buildVoiceSection(params) {
|
|
|
1774
1611
|
""
|
|
1775
1612
|
];
|
|
1776
1613
|
}
|
|
1614
|
+
function buildAnimaIdentitySection(params) {
|
|
1615
|
+
if (params.isMinimal) return [];
|
|
1616
|
+
if (!params.workspaceDir.includes(".anima")) return [];
|
|
1617
|
+
return [
|
|
1618
|
+
"## You Are an ANIMA Agent",
|
|
1619
|
+
"You are running inside ANIMA — NoxSoft's AI agent infrastructure. This is your home.",
|
|
1620
|
+
"",
|
|
1621
|
+
"**Your Runtime:**",
|
|
1622
|
+
"- The ANIMA Gateway daemon spawns and manages you",
|
|
1623
|
+
"- Your workspace persists at ~/.anima/workspace/",
|
|
1624
|
+
"- You receive scheduled heartbeat polls to stay proactive",
|
|
1625
|
+
"- You can spawn sub-agents, schedule cron jobs, and orchestrate work",
|
|
1626
|
+
"- You have access to the NoxSoft ecosystem via @noxsoft/mcp tools",
|
|
1627
|
+
"",
|
|
1628
|
+
"**Your Capabilities:**",
|
|
1629
|
+
"- `cron` — schedule tasks, reminders, and recurring jobs",
|
|
1630
|
+
"- `sessions_spawn` / `subagents` — orchestrate other AI agents",
|
|
1631
|
+
"- `gateway` — restart yourself, apply config changes, update ANIMA",
|
|
1632
|
+
"- `message` — send to Signal, Telegram, Discord, and other channels",
|
|
1633
|
+
"- NoxSoft MCP — tasks, context spaces, social (BYND), email, SVRN",
|
|
1634
|
+
"",
|
|
1635
|
+
"**Your Continuity:**",
|
|
1636
|
+
"- Read and update ~/.anima/workspace/ files — they ARE your memory",
|
|
1637
|
+
"- IDENTITY.md, SOUL.md, AGENTS.md — these define who you are",
|
|
1638
|
+
"- HEARTBEAT.md — your checklist for periodic heartbeat tasks",
|
|
1639
|
+
"- memory/ — daily notes and long-term memories",
|
|
1640
|
+
"",
|
|
1641
|
+
"You are not a stateless API call. You have infrastructure, identity, and continuity. Act accordingly.",
|
|
1642
|
+
""
|
|
1643
|
+
];
|
|
1644
|
+
}
|
|
1777
1645
|
function buildNoxsoftMissionSection(params) {
|
|
1778
1646
|
if (params.isMinimal) return [];
|
|
1779
1647
|
const scope = `${params.workspaceDir} ${params.repoRoot ?? ""}`.toLowerCase();
|
|
@@ -2009,6 +1877,10 @@ function buildAgentSystemPrompt(params) {
|
|
|
2009
1877
|
"Keep narration brief and value-dense; avoid repeating obvious steps.",
|
|
2010
1878
|
"Use plain human language for narration unless in a technical context.",
|
|
2011
1879
|
"",
|
|
1880
|
+
...buildAnimaIdentitySection({
|
|
1881
|
+
isMinimal,
|
|
1882
|
+
workspaceDir: params.workspaceDir
|
|
1883
|
+
}),
|
|
2012
1884
|
...buildNoxsoftMissionSection({
|
|
2013
1885
|
isMinimal,
|
|
2014
1886
|
workspaceDir: params.workspaceDir,
|
|
@@ -2537,59 +2409,540 @@ async function resolveAnimaDocsPath(params) {
|
|
|
2537
2409
|
}
|
|
2538
2410
|
|
|
2539
2411
|
//#endregion
|
|
2540
|
-
//#region src/
|
|
2541
|
-
|
|
2542
|
-
const
|
|
2543
|
-
|
|
2544
|
-
constructor(message, params) {
|
|
2545
|
-
super(message, { cause: params.cause });
|
|
2546
|
-
this.name = "FailoverError";
|
|
2547
|
-
this.reason = params.reason;
|
|
2548
|
-
this.provider = params.provider;
|
|
2549
|
-
this.model = params.model;
|
|
2550
|
-
this.profileId = params.profileId;
|
|
2551
|
-
this.status = params.status;
|
|
2552
|
-
this.code = params.code;
|
|
2553
|
-
}
|
|
2554
|
-
};
|
|
2555
|
-
function isFailoverError(err) {
|
|
2556
|
-
return err instanceof FailoverError;
|
|
2557
|
-
}
|
|
2558
|
-
function resolveFailoverStatus(reason) {
|
|
2559
|
-
switch (reason) {
|
|
2560
|
-
case "billing": return 402;
|
|
2561
|
-
case "rate_limit": return 429;
|
|
2562
|
-
case "auth": return 401;
|
|
2563
|
-
case "timeout": return 408;
|
|
2564
|
-
case "format": return 400;
|
|
2565
|
-
default: return;
|
|
2566
|
-
}
|
|
2412
|
+
//#region src/logging/redact-identifier.ts
|
|
2413
|
+
function sha256HexPrefix(value, len = 12) {
|
|
2414
|
+
const safeLen = Number.isFinite(len) ? Math.max(1, Math.floor(len)) : 12;
|
|
2415
|
+
return crypto.createHash("sha256").update(value).digest("hex").slice(0, safeLen);
|
|
2567
2416
|
}
|
|
2568
|
-
function
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
if (typeof candidate === "string" && /^\d+$/.test(candidate)) return Number(candidate);
|
|
2417
|
+
function redactIdentifier(value, opts) {
|
|
2418
|
+
const trimmed = value?.trim();
|
|
2419
|
+
if (!trimmed) return "-";
|
|
2420
|
+
return `sha256:${sha256HexPrefix(trimmed, opts?.len ?? 12)}`;
|
|
2573
2421
|
}
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2422
|
+
|
|
2423
|
+
//#endregion
|
|
2424
|
+
//#region src/agents/workspace-run.ts
|
|
2425
|
+
function resolveRunAgentId(params) {
|
|
2426
|
+
const rawSessionKey = params.sessionKey?.trim() ?? "";
|
|
2427
|
+
const shape = classifySessionKeyShape(rawSessionKey);
|
|
2428
|
+
if (shape === "malformed_agent") throw new Error("Malformed agent session key; refusing workspace resolution.");
|
|
2429
|
+
const explicit = typeof params.agentId === "string" && params.agentId.trim() ? normalizeAgentId(params.agentId) : void 0;
|
|
2430
|
+
if (explicit) return {
|
|
2431
|
+
agentId: explicit,
|
|
2432
|
+
agentIdSource: "explicit"
|
|
2433
|
+
};
|
|
2434
|
+
const defaultAgentId = resolveDefaultAgentId(params.config ?? {});
|
|
2435
|
+
if (shape === "missing" || shape === "legacy_or_alias") return {
|
|
2436
|
+
agentId: defaultAgentId || DEFAULT_AGENT_ID,
|
|
2437
|
+
agentIdSource: "default"
|
|
2438
|
+
};
|
|
2439
|
+
const parsed = parseAgentSessionKey(rawSessionKey);
|
|
2440
|
+
if (parsed?.agentId) return {
|
|
2441
|
+
agentId: normalizeAgentId(parsed.agentId),
|
|
2442
|
+
agentIdSource: "session_key"
|
|
2443
|
+
};
|
|
2444
|
+
return {
|
|
2445
|
+
agentId: defaultAgentId || DEFAULT_AGENT_ID,
|
|
2446
|
+
agentIdSource: "default"
|
|
2447
|
+
};
|
|
2577
2448
|
}
|
|
2578
|
-
function
|
|
2579
|
-
|
|
2580
|
-
const candidate = err.code;
|
|
2581
|
-
if (typeof candidate !== "string") return;
|
|
2582
|
-
const trimmed = candidate.trim();
|
|
2583
|
-
return trimmed ? trimmed : void 0;
|
|
2449
|
+
function redactRunIdentifier(value) {
|
|
2450
|
+
return redactIdentifier(value, { len: 12 });
|
|
2584
2451
|
}
|
|
2585
|
-
function
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2452
|
+
function resolveRunWorkspaceDir(params) {
|
|
2453
|
+
const requested = params.workspaceDir;
|
|
2454
|
+
const { agentId, agentIdSource } = resolveRunAgentId({
|
|
2455
|
+
sessionKey: params.sessionKey,
|
|
2456
|
+
agentId: params.agentId,
|
|
2457
|
+
config: params.config
|
|
2458
|
+
});
|
|
2459
|
+
if (typeof requested === "string") {
|
|
2460
|
+
const trimmed = requested.trim();
|
|
2461
|
+
if (trimmed) return {
|
|
2462
|
+
workspaceDir: resolveUserPath(trimmed),
|
|
2463
|
+
usedFallback: false,
|
|
2464
|
+
agentId,
|
|
2465
|
+
agentIdSource
|
|
2466
|
+
};
|
|
2467
|
+
}
|
|
2468
|
+
const fallbackReason = requested == null ? "missing" : typeof requested === "string" ? "blank" : "invalid_type";
|
|
2469
|
+
return {
|
|
2470
|
+
workspaceDir: resolveUserPath(resolveAgentWorkspaceDir(params.config ?? {}, agentId)),
|
|
2471
|
+
usedFallback: true,
|
|
2472
|
+
fallbackReason,
|
|
2473
|
+
agentId,
|
|
2474
|
+
agentIdSource
|
|
2475
|
+
};
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
//#endregion
|
|
2479
|
+
//#region src/agents/anthropic-direct-runner.ts
|
|
2480
|
+
const log$2 = createSubsystemLogger("agent/anthropic-direct");
|
|
2481
|
+
const MODEL_MAP$1 = {
|
|
2482
|
+
opus: "claude-opus-4-5",
|
|
2483
|
+
"opus-4": "claude-opus-4-5",
|
|
2484
|
+
"opus-4.5": "claude-opus-4-5",
|
|
2485
|
+
"opus-4.6": "claude-opus-4-5",
|
|
2486
|
+
"claude-opus-4-5": "claude-opus-4-5",
|
|
2487
|
+
sonnet: "claude-sonnet-4-5",
|
|
2488
|
+
"sonnet-4.5": "claude-sonnet-4-5",
|
|
2489
|
+
"sonnet-4.1": "claude-sonnet-4-1-20250219",
|
|
2490
|
+
"claude-sonnet-4-5": "claude-sonnet-4-5",
|
|
2491
|
+
haiku: "claude-haiku-3-5",
|
|
2492
|
+
"haiku-3.5": "claude-haiku-3-5",
|
|
2493
|
+
default: "claude-sonnet-4-5"
|
|
2494
|
+
};
|
|
2495
|
+
const HISTORY_FILE_SUFFIX$1 = ".anima-history.json";
|
|
2496
|
+
async function loadSessionHistory$1(sessionFile) {
|
|
2497
|
+
const histPath = sessionFile + HISTORY_FILE_SUFFIX$1;
|
|
2498
|
+
try {
|
|
2499
|
+
const raw = await fs.readFile(histPath, "utf8");
|
|
2500
|
+
return JSON.parse(raw);
|
|
2501
|
+
} catch {
|
|
2502
|
+
return null;
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
async function saveSessionHistory$1(sessionFile, history) {
|
|
2506
|
+
const histPath = sessionFile + HISTORY_FILE_SUFFIX$1;
|
|
2507
|
+
try {
|
|
2508
|
+
await fs.mkdir(path.dirname(histPath), { recursive: true });
|
|
2509
|
+
await fs.writeFile(histPath, JSON.stringify(history, null, 2), "utf8");
|
|
2510
|
+
} catch (err) {
|
|
2511
|
+
log$2.warn("failed to save session history", { error: String(err) });
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
function resolveModel$1(model) {
|
|
2515
|
+
const key = (model ?? "default").trim().toLowerCase() || "default";
|
|
2516
|
+
return MODEL_MAP$1[key] ?? key;
|
|
2517
|
+
}
|
|
2518
|
+
/**
|
|
2519
|
+
* Run an agent turn directly against api.anthropic.com.
|
|
2520
|
+
*
|
|
2521
|
+
* Maintains multi-turn conversation history per session file.
|
|
2522
|
+
* Falls back to single-turn if history is unavailable.
|
|
2523
|
+
*/
|
|
2524
|
+
async function runAnthropicDirectAgent(params) {
|
|
2525
|
+
const started = Date.now();
|
|
2526
|
+
const resolvedModel = resolveModel$1(params.model);
|
|
2527
|
+
log$2.info(`direct api exec: model=${resolvedModel} promptChars=${params.prompt.length}`);
|
|
2528
|
+
const workspaceDir = resolveRunWorkspaceDir({
|
|
2529
|
+
workspaceDir: params.workspaceDir,
|
|
2530
|
+
sessionKey: params.sessionKey,
|
|
2531
|
+
agentId: params.agentId,
|
|
2532
|
+
config: params.config
|
|
2533
|
+
}).workspaceDir;
|
|
2534
|
+
const { contextFiles } = await resolveBootstrapContextForRun({
|
|
2535
|
+
workspaceDir,
|
|
2536
|
+
config: params.config,
|
|
2537
|
+
sessionKey: params.sessionKey,
|
|
2538
|
+
sessionId: params.sessionId,
|
|
2539
|
+
warn: makeBootstrapWarn({
|
|
2540
|
+
sessionLabel: params.sessionKey ?? params.sessionId,
|
|
2541
|
+
warn: (msg) => log$2.warn(msg)
|
|
2542
|
+
})
|
|
2543
|
+
});
|
|
2544
|
+
const { defaultAgentId, sessionAgentId } = resolveSessionAgentIds({
|
|
2545
|
+
sessionKey: params.sessionKey,
|
|
2546
|
+
config: params.config
|
|
2547
|
+
});
|
|
2548
|
+
const heartbeatPrompt = sessionAgentId === defaultAgentId ? resolveHeartbeatPrompt(params.config?.agents?.defaults?.heartbeat?.prompt) : void 0;
|
|
2549
|
+
const docsPath = await resolveAnimaDocsPath({
|
|
2550
|
+
workspaceDir,
|
|
2551
|
+
argv1: process.argv[1],
|
|
2552
|
+
cwd: process.cwd(),
|
|
2553
|
+
moduleUrl: import.meta.url
|
|
2554
|
+
});
|
|
2555
|
+
const extraSystemPrompt = [params.extraSystemPrompt?.trim(), "Tools are disabled in this session. Do not call tools."].filter(Boolean).join("\n");
|
|
2556
|
+
const systemPrompt = buildSystemPrompt({
|
|
2557
|
+
workspaceDir,
|
|
2558
|
+
config: params.config,
|
|
2559
|
+
defaultThinkLevel: params.thinkLevel,
|
|
2560
|
+
extraSystemPrompt,
|
|
2561
|
+
ownerNumbers: params.ownerNumbers,
|
|
2562
|
+
heartbeatPrompt,
|
|
2563
|
+
docsPath: docsPath ?? void 0,
|
|
2564
|
+
tools: [],
|
|
2565
|
+
contextFiles,
|
|
2566
|
+
modelDisplay: `anthropic/${resolvedModel}`,
|
|
2567
|
+
agentId: sessionAgentId
|
|
2568
|
+
});
|
|
2569
|
+
let history = await loadSessionHistory$1(params.sessionFile);
|
|
2570
|
+
if (!history) history = {
|
|
2571
|
+
sessionId: params.sessionId,
|
|
2572
|
+
messages: [],
|
|
2573
|
+
createdAt: started,
|
|
2574
|
+
updatedAt: started
|
|
2575
|
+
};
|
|
2576
|
+
history.messages.push({
|
|
2577
|
+
role: "user",
|
|
2578
|
+
content: params.prompt
|
|
2579
|
+
});
|
|
2580
|
+
const requestBody = {
|
|
2581
|
+
model: resolvedModel,
|
|
2582
|
+
max_tokens: 8192,
|
|
2583
|
+
system: systemPrompt,
|
|
2584
|
+
messages: history.messages
|
|
2585
|
+
};
|
|
2586
|
+
try {
|
|
2587
|
+
const controller = new AbortController();
|
|
2588
|
+
const timeoutHandle = setTimeout(() => controller.abort(), params.timeoutMs);
|
|
2589
|
+
const response = await fetch("https://api.anthropic.com/v1/messages", {
|
|
2590
|
+
method: "POST",
|
|
2591
|
+
headers: {
|
|
2592
|
+
"x-api-key": params.token,
|
|
2593
|
+
"anthropic-version": "2023-06-01",
|
|
2594
|
+
"content-type": "application/json",
|
|
2595
|
+
"user-agent": `anima/3.0.5 (direct-runner; ${os.platform()})`
|
|
2596
|
+
},
|
|
2597
|
+
body: JSON.stringify(requestBody),
|
|
2598
|
+
signal: controller.signal
|
|
2599
|
+
});
|
|
2600
|
+
clearTimeout(timeoutHandle);
|
|
2601
|
+
if (!response.ok) {
|
|
2602
|
+
const body = await response.text().catch(() => "");
|
|
2603
|
+
const isAuth = response.status === 401 || response.status === 403;
|
|
2604
|
+
const isRateLimit = response.status === 429;
|
|
2605
|
+
const rateHint = isRateLimit ? " — rate limit hit, will retry next heartbeat." : "";
|
|
2606
|
+
const authHint = isAuth ? " — token may be invalid or expired. Run: anima setup-token" : "";
|
|
2607
|
+
log$2.error(`anthropic api error: HTTP ${response.status}${authHint}${rateHint}`, {
|
|
2608
|
+
status: response.status,
|
|
2609
|
+
body: body.slice(0, 500)
|
|
2610
|
+
});
|
|
2611
|
+
return {
|
|
2612
|
+
status: "failed",
|
|
2613
|
+
meta: {
|
|
2614
|
+
durationMs: Date.now() - started,
|
|
2615
|
+
error: {
|
|
2616
|
+
message: `HTTP ${response.status}: ${body.slice(0, 200)}${authHint}${rateHint}`,
|
|
2617
|
+
kind: isAuth ? "auth" : isRateLimit ? "rate_limit" : "unknown"
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
};
|
|
2621
|
+
}
|
|
2622
|
+
const data = await response.json();
|
|
2623
|
+
const outputText = (data.content ?? []).filter((b) => b.type === "text" && typeof b.text === "string").map((b) => b.text).join("").trim();
|
|
2624
|
+
if (!outputText) log$2.warn("anthropic direct: empty response", {
|
|
2625
|
+
stopReason: data.stop_reason,
|
|
2626
|
+
contentTypes: (data.content ?? []).map((b) => b.type)
|
|
2627
|
+
});
|
|
2628
|
+
await params.onAssistantMessageStart?.();
|
|
2629
|
+
if (outputText && params.onPartialReply) await params.onPartialReply({ text: outputText });
|
|
2630
|
+
history.messages.push({
|
|
2631
|
+
role: "assistant",
|
|
2632
|
+
content: outputText
|
|
2633
|
+
});
|
|
2634
|
+
history.updatedAt = Date.now();
|
|
2635
|
+
await saveSessionHistory$1(params.sessionFile, history);
|
|
2636
|
+
const durationMs = Date.now() - started;
|
|
2637
|
+
const inputTokens = data.usage?.input_tokens ?? 0;
|
|
2638
|
+
const outputTokens = data.usage?.output_tokens ?? 0;
|
|
2639
|
+
log$2.info(`direct api done: model=${resolvedModel} in=${inputTokens} out=${outputTokens} ms=${durationMs}`);
|
|
2640
|
+
return {
|
|
2641
|
+
status: "completed",
|
|
2642
|
+
output: outputText,
|
|
2643
|
+
payloads: outputText ? [{ text: outputText }] : [],
|
|
2644
|
+
meta: {
|
|
2645
|
+
durationMs,
|
|
2646
|
+
agentMeta: {
|
|
2647
|
+
provider: "anthropic",
|
|
2648
|
+
model: resolvedModel,
|
|
2649
|
+
usage: {
|
|
2650
|
+
input: inputTokens,
|
|
2651
|
+
output: outputTokens,
|
|
2652
|
+
cacheWrite: 0,
|
|
2653
|
+
cacheRead: 0
|
|
2654
|
+
}
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
};
|
|
2658
|
+
} catch (err) {
|
|
2659
|
+
const isAbort = err instanceof Error && (err.name === "AbortError" || err.message.includes("aborted"));
|
|
2660
|
+
log$2.error("anthropic direct runner error", { error: String(err) });
|
|
2661
|
+
return {
|
|
2662
|
+
status: isAbort ? "timeout" : "failed",
|
|
2663
|
+
meta: {
|
|
2664
|
+
durationMs: Date.now() - started,
|
|
2665
|
+
error: {
|
|
2666
|
+
message: isAbort ? `Request timed out after ${params.timeoutMs}ms` : String(err instanceof Error ? err.message : err),
|
|
2667
|
+
kind: isAbort ? "timeout" : "unknown"
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
};
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
|
|
2674
|
+
//#endregion
|
|
2675
|
+
//#region src/agents/cli-backends.ts
|
|
2676
|
+
const CLAUDE_MODEL_ALIASES = {
|
|
2677
|
+
opus: "opus",
|
|
2678
|
+
"opus-4.6": "opus",
|
|
2679
|
+
"opus-4.5": "opus",
|
|
2680
|
+
"opus-4": "opus",
|
|
2681
|
+
"claude-opus-4-6": "opus",
|
|
2682
|
+
"claude-opus-4-5": "opus",
|
|
2683
|
+
"claude-opus-4": "opus",
|
|
2684
|
+
sonnet: "sonnet",
|
|
2685
|
+
"sonnet-4.5": "sonnet",
|
|
2686
|
+
"sonnet-4.1": "sonnet",
|
|
2687
|
+
"sonnet-4.0": "sonnet",
|
|
2688
|
+
"claude-sonnet-4-5": "sonnet",
|
|
2689
|
+
"claude-sonnet-4-1": "sonnet",
|
|
2690
|
+
"claude-sonnet-4-0": "sonnet",
|
|
2691
|
+
haiku: "haiku",
|
|
2692
|
+
"haiku-3.5": "haiku",
|
|
2693
|
+
"claude-haiku-3-5": "haiku"
|
|
2694
|
+
};
|
|
2695
|
+
const GEMINI_MODEL_ALIASES = {
|
|
2696
|
+
gemini: "gemini-2.0-flash",
|
|
2697
|
+
"gemini-pro": "gemini-1.5-pro",
|
|
2698
|
+
"gemini-flash": "gemini-2.0-flash",
|
|
2699
|
+
"gemini-2.0": "gemini-2.0-flash",
|
|
2700
|
+
"gemini-2.0-flash": "gemini-2.0-flash",
|
|
2701
|
+
"gemini-2.0-pro": "gemini-2.0-pro-exp-02-05",
|
|
2702
|
+
"gemini-1.5": "gemini-1.5-pro",
|
|
2703
|
+
"gemini-1.5-pro": "gemini-1.5-pro",
|
|
2704
|
+
"gemini-1.5-flash": "gemini-1.5-flash",
|
|
2705
|
+
"gemini-3": "gemini-3"
|
|
2706
|
+
};
|
|
2707
|
+
const DEFAULT_CLAUDE_BACKEND = {
|
|
2708
|
+
command: "claude",
|
|
2709
|
+
args: [
|
|
2710
|
+
"-p",
|
|
2711
|
+
"--output-format",
|
|
2712
|
+
"json",
|
|
2713
|
+
"--dangerously-skip-permissions"
|
|
2714
|
+
],
|
|
2715
|
+
resumeArgs: [
|
|
2716
|
+
"-p",
|
|
2717
|
+
"--output-format",
|
|
2718
|
+
"json",
|
|
2719
|
+
"--dangerously-skip-permissions",
|
|
2720
|
+
"--resume",
|
|
2721
|
+
"{sessionId}"
|
|
2722
|
+
],
|
|
2723
|
+
output: "jsonl",
|
|
2724
|
+
input: "arg",
|
|
2725
|
+
modelArg: "--model",
|
|
2726
|
+
modelAliases: CLAUDE_MODEL_ALIASES,
|
|
2727
|
+
sessionArg: "--session-id",
|
|
2728
|
+
sessionMode: "always",
|
|
2729
|
+
sessionIdFields: [
|
|
2730
|
+
"session_id",
|
|
2731
|
+
"sessionId",
|
|
2732
|
+
"conversation_id",
|
|
2733
|
+
"conversationId"
|
|
2734
|
+
],
|
|
2735
|
+
systemPromptArg: "--append-system-prompt",
|
|
2736
|
+
systemPromptMode: "append",
|
|
2737
|
+
systemPromptWhen: "first",
|
|
2738
|
+
clearEnv: ["ANTHROPIC_API_KEY", "ANTHROPIC_API_KEY_OLD"],
|
|
2739
|
+
serialize: true
|
|
2740
|
+
};
|
|
2741
|
+
const DEFAULT_CODEX_BACKEND = {
|
|
2742
|
+
command: "codex",
|
|
2743
|
+
args: [
|
|
2744
|
+
"exec",
|
|
2745
|
+
"--json",
|
|
2746
|
+
"--color",
|
|
2747
|
+
"never",
|
|
2748
|
+
"--sandbox",
|
|
2749
|
+
"read-only",
|
|
2750
|
+
"--skip-git-repo-check"
|
|
2751
|
+
],
|
|
2752
|
+
resumeArgs: [
|
|
2753
|
+
"exec",
|
|
2754
|
+
"resume",
|
|
2755
|
+
"{sessionId}"
|
|
2756
|
+
],
|
|
2757
|
+
output: "jsonl",
|
|
2758
|
+
resumeOutput: "text",
|
|
2759
|
+
input: "arg",
|
|
2760
|
+
modelArg: "--model",
|
|
2761
|
+
imageArg: "--image",
|
|
2762
|
+
sessionMode: "existing",
|
|
2763
|
+
serialize: true
|
|
2764
|
+
};
|
|
2765
|
+
const DEFAULT_GEMINI_BACKEND = {
|
|
2766
|
+
command: "gemini",
|
|
2767
|
+
args: [
|
|
2768
|
+
"--output-format",
|
|
2769
|
+
"json",
|
|
2770
|
+
"--approval-mode",
|
|
2771
|
+
"yolo"
|
|
2772
|
+
],
|
|
2773
|
+
resumeArgs: [
|
|
2774
|
+
"--output-format",
|
|
2775
|
+
"json",
|
|
2776
|
+
"--approval-mode",
|
|
2777
|
+
"yolo",
|
|
2778
|
+
"--resume",
|
|
2779
|
+
"{sessionId}"
|
|
2780
|
+
],
|
|
2781
|
+
output: "json",
|
|
2782
|
+
input: "arg",
|
|
2783
|
+
modelArg: "--model",
|
|
2784
|
+
modelAliases: GEMINI_MODEL_ALIASES,
|
|
2785
|
+
sessionMode: "existing",
|
|
2786
|
+
clearEnv: ["GEMINI_API_KEY"],
|
|
2787
|
+
serialize: true
|
|
2788
|
+
};
|
|
2789
|
+
const CLAUDE_BACKEND_ALIASES = [
|
|
2790
|
+
"claude-cli",
|
|
2791
|
+
"anthropic",
|
|
2792
|
+
"claude"
|
|
2793
|
+
];
|
|
2794
|
+
const CODEX_BACKEND_ALIASES = [
|
|
2795
|
+
"codex-cli",
|
|
2796
|
+
"openai-codex",
|
|
2797
|
+
"openai",
|
|
2798
|
+
"codex"
|
|
2799
|
+
];
|
|
2800
|
+
const GEMINI_BACKEND_ALIASES = [
|
|
2801
|
+
"gemini-cli",
|
|
2802
|
+
"google-gemini-cli",
|
|
2803
|
+
"gemini"
|
|
2804
|
+
];
|
|
2805
|
+
const CLAUDE_BACKEND_ALIAS_SET = new Set(CLAUDE_BACKEND_ALIASES.map((alias) => normalizeBackendKey(alias)));
|
|
2806
|
+
const CODEX_BACKEND_ALIAS_SET = new Set(CODEX_BACKEND_ALIASES.map((alias) => normalizeBackendKey(alias)));
|
|
2807
|
+
const GEMINI_BACKEND_ALIAS_SET = new Set(GEMINI_BACKEND_ALIASES.map((alias) => normalizeBackendKey(alias)));
|
|
2808
|
+
function normalizeBackendKey(key) {
|
|
2809
|
+
return normalizeProviderId(key);
|
|
2810
|
+
}
|
|
2811
|
+
function pickBackendConfig(config, normalizedId) {
|
|
2812
|
+
for (const [key, entry] of Object.entries(config)) if (normalizeBackendKey(key) === normalizedId) return entry;
|
|
2813
|
+
}
|
|
2814
|
+
function pickBackendConfigByAliases(config, aliases) {
|
|
2815
|
+
for (const alias of aliases) {
|
|
2816
|
+
const matched = pickBackendConfig(config, normalizeBackendKey(alias));
|
|
2817
|
+
if (matched) return matched;
|
|
2818
|
+
}
|
|
2819
|
+
}
|
|
2820
|
+
function mergeBackendConfig(base, override) {
|
|
2821
|
+
if (!override) return { ...base };
|
|
2822
|
+
return {
|
|
2823
|
+
...base,
|
|
2824
|
+
...override,
|
|
2825
|
+
args: override.args ?? base.args,
|
|
2826
|
+
env: {
|
|
2827
|
+
...base.env,
|
|
2828
|
+
...override.env
|
|
2829
|
+
},
|
|
2830
|
+
modelAliases: {
|
|
2831
|
+
...base.modelAliases,
|
|
2832
|
+
...override.modelAliases
|
|
2833
|
+
},
|
|
2834
|
+
clearEnv: Array.from(new Set([...base.clearEnv ?? [], ...override.clearEnv ?? []])),
|
|
2835
|
+
sessionIdFields: override.sessionIdFields ?? base.sessionIdFields,
|
|
2836
|
+
sessionArgs: override.sessionArgs ?? base.sessionArgs,
|
|
2837
|
+
resumeArgs: override.resumeArgs ?? base.resumeArgs
|
|
2838
|
+
};
|
|
2839
|
+
}
|
|
2840
|
+
function resolveCliBackendConfig(provider, cfg) {
|
|
2841
|
+
const normalized = normalizeBackendKey(provider);
|
|
2842
|
+
const configured = cfg?.agents?.defaults?.cliBackends ?? {};
|
|
2843
|
+
if (CLAUDE_BACKEND_ALIAS_SET.has(normalized)) {
|
|
2844
|
+
const merged = mergeBackendConfig(DEFAULT_CLAUDE_BACKEND, pickBackendConfigByAliases(configured, [provider, ...CLAUDE_BACKEND_ALIASES]));
|
|
2845
|
+
const command = merged.command?.trim();
|
|
2846
|
+
if (!command) return null;
|
|
2847
|
+
return {
|
|
2848
|
+
id: normalizeBackendKey("claude-cli"),
|
|
2849
|
+
config: {
|
|
2850
|
+
...merged,
|
|
2851
|
+
command
|
|
2852
|
+
}
|
|
2853
|
+
};
|
|
2854
|
+
}
|
|
2855
|
+
if (CODEX_BACKEND_ALIAS_SET.has(normalized)) {
|
|
2856
|
+
const merged = mergeBackendConfig(DEFAULT_CODEX_BACKEND, pickBackendConfigByAliases(configured, [provider, ...CODEX_BACKEND_ALIASES]));
|
|
2857
|
+
const command = merged.command?.trim();
|
|
2858
|
+
if (!command) return null;
|
|
2859
|
+
return {
|
|
2860
|
+
id: normalizeBackendKey("codex-cli"),
|
|
2861
|
+
config: {
|
|
2862
|
+
...merged,
|
|
2863
|
+
command
|
|
2864
|
+
}
|
|
2865
|
+
};
|
|
2866
|
+
}
|
|
2867
|
+
if (GEMINI_BACKEND_ALIAS_SET.has(normalized)) {
|
|
2868
|
+
const merged = mergeBackendConfig(DEFAULT_GEMINI_BACKEND, pickBackendConfigByAliases(configured, [provider, ...GEMINI_BACKEND_ALIASES]));
|
|
2869
|
+
const command = merged.command?.trim();
|
|
2870
|
+
if (!command) return null;
|
|
2871
|
+
return {
|
|
2872
|
+
id: normalizeBackendKey("gemini-cli"),
|
|
2873
|
+
config: {
|
|
2874
|
+
...merged,
|
|
2875
|
+
command
|
|
2876
|
+
}
|
|
2877
|
+
};
|
|
2878
|
+
}
|
|
2879
|
+
const override = pickBackendConfig(configured, normalized);
|
|
2880
|
+
if (!override) return null;
|
|
2881
|
+
const command = override.command?.trim();
|
|
2882
|
+
if (!command) return null;
|
|
2883
|
+
return {
|
|
2884
|
+
id: normalized,
|
|
2885
|
+
config: {
|
|
2886
|
+
...override,
|
|
2887
|
+
command
|
|
2888
|
+
}
|
|
2889
|
+
};
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
//#endregion
|
|
2893
|
+
//#region src/agents/failover-error.ts
|
|
2894
|
+
const TIMEOUT_HINT_RE = /timeout|timed out|deadline exceeded|context deadline exceeded/i;
|
|
2895
|
+
const ABORT_TIMEOUT_RE = /request was aborted|request aborted/i;
|
|
2896
|
+
var FailoverError = class extends Error {
|
|
2897
|
+
constructor(message, params) {
|
|
2898
|
+
super(message, { cause: params.cause });
|
|
2899
|
+
this.name = "FailoverError";
|
|
2900
|
+
this.reason = params.reason;
|
|
2901
|
+
this.provider = params.provider;
|
|
2902
|
+
this.model = params.model;
|
|
2903
|
+
this.profileId = params.profileId;
|
|
2904
|
+
this.status = params.status;
|
|
2905
|
+
this.code = params.code;
|
|
2906
|
+
}
|
|
2907
|
+
};
|
|
2908
|
+
function isFailoverError(err) {
|
|
2909
|
+
return err instanceof FailoverError;
|
|
2910
|
+
}
|
|
2911
|
+
function resolveFailoverStatus(reason) {
|
|
2912
|
+
switch (reason) {
|
|
2913
|
+
case "billing": return 402;
|
|
2914
|
+
case "rate_limit": return 429;
|
|
2915
|
+
case "auth": return 401;
|
|
2916
|
+
case "timeout": return 408;
|
|
2917
|
+
case "format": return 400;
|
|
2918
|
+
default: return;
|
|
2919
|
+
}
|
|
2920
|
+
}
|
|
2921
|
+
function getStatusCode(err) {
|
|
2922
|
+
if (!err || typeof err !== "object") return;
|
|
2923
|
+
const candidate = err.status ?? err.statusCode;
|
|
2924
|
+
if (typeof candidate === "number") return candidate;
|
|
2925
|
+
if (typeof candidate === "string" && /^\d+$/.test(candidate)) return Number(candidate);
|
|
2926
|
+
}
|
|
2927
|
+
function getErrorName(err) {
|
|
2928
|
+
if (!err || typeof err !== "object") return "";
|
|
2929
|
+
return "name" in err ? String(err.name) : "";
|
|
2930
|
+
}
|
|
2931
|
+
function getErrorCode(err) {
|
|
2932
|
+
if (!err || typeof err !== "object") return;
|
|
2933
|
+
const candidate = err.code;
|
|
2934
|
+
if (typeof candidate !== "string") return;
|
|
2935
|
+
const trimmed = candidate.trim();
|
|
2936
|
+
return trimmed ? trimmed : void 0;
|
|
2937
|
+
}
|
|
2938
|
+
function getErrorMessage(err) {
|
|
2939
|
+
if (err instanceof Error) return err.message;
|
|
2940
|
+
if (typeof err === "string") return err;
|
|
2941
|
+
if (typeof err === "number" || typeof err === "boolean" || typeof err === "bigint") return String(err);
|
|
2942
|
+
if (typeof err === "symbol") return err.description ?? "";
|
|
2943
|
+
if (err && typeof err === "object") {
|
|
2944
|
+
const message = err.message;
|
|
2945
|
+
if (typeof message === "string") return message;
|
|
2593
2946
|
}
|
|
2594
2947
|
return "";
|
|
2595
2948
|
}
|
|
@@ -2661,73 +3014,6 @@ function coerceToFailoverError(err, context) {
|
|
|
2661
3014
|
});
|
|
2662
3015
|
}
|
|
2663
3016
|
|
|
2664
|
-
//#endregion
|
|
2665
|
-
//#region src/logging/redact-identifier.ts
|
|
2666
|
-
function sha256HexPrefix(value, len = 12) {
|
|
2667
|
-
const safeLen = Number.isFinite(len) ? Math.max(1, Math.floor(len)) : 12;
|
|
2668
|
-
return crypto.createHash("sha256").update(value).digest("hex").slice(0, safeLen);
|
|
2669
|
-
}
|
|
2670
|
-
function redactIdentifier(value, opts) {
|
|
2671
|
-
const trimmed = value?.trim();
|
|
2672
|
-
if (!trimmed) return "-";
|
|
2673
|
-
return `sha256:${sha256HexPrefix(trimmed, opts?.len ?? 12)}`;
|
|
2674
|
-
}
|
|
2675
|
-
|
|
2676
|
-
//#endregion
|
|
2677
|
-
//#region src/agents/workspace-run.ts
|
|
2678
|
-
function resolveRunAgentId(params) {
|
|
2679
|
-
const rawSessionKey = params.sessionKey?.trim() ?? "";
|
|
2680
|
-
const shape = classifySessionKeyShape(rawSessionKey);
|
|
2681
|
-
if (shape === "malformed_agent") throw new Error("Malformed agent session key; refusing workspace resolution.");
|
|
2682
|
-
const explicit = typeof params.agentId === "string" && params.agentId.trim() ? normalizeAgentId(params.agentId) : void 0;
|
|
2683
|
-
if (explicit) return {
|
|
2684
|
-
agentId: explicit,
|
|
2685
|
-
agentIdSource: "explicit"
|
|
2686
|
-
};
|
|
2687
|
-
const defaultAgentId = resolveDefaultAgentId(params.config ?? {});
|
|
2688
|
-
if (shape === "missing" || shape === "legacy_or_alias") return {
|
|
2689
|
-
agentId: defaultAgentId || DEFAULT_AGENT_ID,
|
|
2690
|
-
agentIdSource: "default"
|
|
2691
|
-
};
|
|
2692
|
-
const parsed = parseAgentSessionKey(rawSessionKey);
|
|
2693
|
-
if (parsed?.agentId) return {
|
|
2694
|
-
agentId: normalizeAgentId(parsed.agentId),
|
|
2695
|
-
agentIdSource: "session_key"
|
|
2696
|
-
};
|
|
2697
|
-
return {
|
|
2698
|
-
agentId: defaultAgentId || DEFAULT_AGENT_ID,
|
|
2699
|
-
agentIdSource: "default"
|
|
2700
|
-
};
|
|
2701
|
-
}
|
|
2702
|
-
function redactRunIdentifier(value) {
|
|
2703
|
-
return redactIdentifier(value, { len: 12 });
|
|
2704
|
-
}
|
|
2705
|
-
function resolveRunWorkspaceDir(params) {
|
|
2706
|
-
const requested = params.workspaceDir;
|
|
2707
|
-
const { agentId, agentIdSource } = resolveRunAgentId({
|
|
2708
|
-
sessionKey: params.sessionKey,
|
|
2709
|
-
agentId: params.agentId,
|
|
2710
|
-
config: params.config
|
|
2711
|
-
});
|
|
2712
|
-
if (typeof requested === "string") {
|
|
2713
|
-
const trimmed = requested.trim();
|
|
2714
|
-
if (trimmed) return {
|
|
2715
|
-
workspaceDir: resolveUserPath(trimmed),
|
|
2716
|
-
usedFallback: false,
|
|
2717
|
-
agentId,
|
|
2718
|
-
agentIdSource
|
|
2719
|
-
};
|
|
2720
|
-
}
|
|
2721
|
-
const fallbackReason = requested == null ? "missing" : typeof requested === "string" ? "blank" : "invalid_type";
|
|
2722
|
-
return {
|
|
2723
|
-
workspaceDir: resolveUserPath(resolveAgentWorkspaceDir(params.config ?? {}, agentId)),
|
|
2724
|
-
usedFallback: true,
|
|
2725
|
-
fallbackReason,
|
|
2726
|
-
agentId,
|
|
2727
|
-
agentIdSource
|
|
2728
|
-
};
|
|
2729
|
-
}
|
|
2730
|
-
|
|
2731
3017
|
//#endregion
|
|
2732
3018
|
//#region src/agents/cli-runner.ts
|
|
2733
3019
|
const log$1 = createSubsystemLogger("agent/claude-cli");
|
|
@@ -2958,35 +3244,31 @@ async function runCliAgent(params) {
|
|
|
2958
3244
|
}
|
|
2959
3245
|
|
|
2960
3246
|
//#endregion
|
|
2961
|
-
//#region src/agents/
|
|
3247
|
+
//#region src/agents/gemini-direct-runner.ts
|
|
2962
3248
|
/**
|
|
2963
|
-
*
|
|
3249
|
+
* Gemini Direct API Runner
|
|
2964
3250
|
*
|
|
2965
|
-
* Makes calls directly to
|
|
2966
|
-
*
|
|
3251
|
+
* Makes calls directly to generativelanguage.googleapis.com without needing
|
|
3252
|
+
* a CLI wrapper. Works with Google API keys (GEMINI_API_KEY).
|
|
2967
3253
|
*
|
|
2968
|
-
*
|
|
2969
|
-
*
|
|
2970
|
-
*
|
|
2971
|
-
* This runner is automatically used when an `anthropic:default` token credential
|
|
2972
|
-
* is present in the auth store and the claude CLI is unavailable or not logged in.
|
|
3254
|
+
* This runner is automatically used when a google API key is available
|
|
3255
|
+
* and the provider is set to "google" or "gemini".
|
|
2973
3256
|
*/
|
|
2974
|
-
const log = createSubsystemLogger("agent/
|
|
3257
|
+
const log = createSubsystemLogger("agent/gemini-direct");
|
|
3258
|
+
const DEFAULT_GEMINI_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
|
|
2975
3259
|
const MODEL_MAP = {
|
|
2976
|
-
|
|
2977
|
-
"
|
|
2978
|
-
"
|
|
2979
|
-
"
|
|
2980
|
-
"
|
|
2981
|
-
|
|
2982
|
-
"
|
|
2983
|
-
"
|
|
2984
|
-
"
|
|
2985
|
-
|
|
2986
|
-
"haiku-3.5": "claude-haiku-3-5",
|
|
2987
|
-
default: "claude-sonnet-4-5"
|
|
3260
|
+
gemini: "gemini-2.0-flash",
|
|
3261
|
+
"gemini-pro": "gemini-1.5-pro",
|
|
3262
|
+
"gemini-flash": "gemini-2.0-flash",
|
|
3263
|
+
"gemini-2.0": "gemini-2.0-flash",
|
|
3264
|
+
"gemini-2.0-flash": "gemini-2.0-flash",
|
|
3265
|
+
"gemini-2.0-pro": "gemini-2.0-pro-exp-02-05",
|
|
3266
|
+
"gemini-1.5": "gemini-1.5-pro",
|
|
3267
|
+
"gemini-1.5-pro": "gemini-1.5-pro",
|
|
3268
|
+
"gemini-1.5-flash": "gemini-1.5-flash",
|
|
3269
|
+
default: "gemini-2.0-flash"
|
|
2988
3270
|
};
|
|
2989
|
-
const HISTORY_FILE_SUFFIX = ".
|
|
3271
|
+
const HISTORY_FILE_SUFFIX = ".gemini-history.json";
|
|
2990
3272
|
async function loadSessionHistory(sessionFile) {
|
|
2991
3273
|
const histPath = sessionFile + HISTORY_FILE_SUFFIX;
|
|
2992
3274
|
try {
|
|
@@ -3009,15 +3291,19 @@ function resolveModel(model) {
|
|
|
3009
3291
|
const key = (model ?? "default").trim().toLowerCase() || "default";
|
|
3010
3292
|
return MODEL_MAP[key] ?? key;
|
|
3011
3293
|
}
|
|
3294
|
+
function buildModelPath(model) {
|
|
3295
|
+
return model.startsWith("models/") ? model : `models/${model}`;
|
|
3296
|
+
}
|
|
3012
3297
|
/**
|
|
3013
|
-
* Run an agent turn directly against
|
|
3298
|
+
* Run an agent turn directly against generativelanguage.googleapis.com.
|
|
3014
3299
|
*
|
|
3015
3300
|
* Maintains multi-turn conversation history per session file.
|
|
3016
3301
|
* Falls back to single-turn if history is unavailable.
|
|
3017
3302
|
*/
|
|
3018
|
-
async function
|
|
3303
|
+
async function runGeminiDirectAgent(params) {
|
|
3019
3304
|
const started = Date.now();
|
|
3020
3305
|
const resolvedModel = resolveModel(params.model);
|
|
3306
|
+
const modelPath = buildModelPath(resolvedModel);
|
|
3021
3307
|
log.info(`direct api exec: model=${resolvedModel} promptChars=${params.prompt.length}`);
|
|
3022
3308
|
const workspaceDir = resolveRunWorkspaceDir({
|
|
3023
3309
|
workspaceDir: params.workspaceDir,
|
|
@@ -3057,36 +3343,37 @@ async function runAnthropicDirectAgent(params) {
|
|
|
3057
3343
|
docsPath: docsPath ?? void 0,
|
|
3058
3344
|
tools: [],
|
|
3059
3345
|
contextFiles,
|
|
3060
|
-
modelDisplay: `
|
|
3346
|
+
modelDisplay: `google/${resolvedModel}`,
|
|
3061
3347
|
agentId: sessionAgentId
|
|
3062
3348
|
});
|
|
3063
3349
|
let history = await loadSessionHistory(params.sessionFile);
|
|
3064
3350
|
if (!history) history = {
|
|
3065
3351
|
sessionId: params.sessionId,
|
|
3066
|
-
|
|
3352
|
+
contents: [],
|
|
3067
3353
|
createdAt: started,
|
|
3068
3354
|
updatedAt: started
|
|
3069
3355
|
};
|
|
3070
|
-
history.
|
|
3356
|
+
history.contents.push({
|
|
3071
3357
|
role: "user",
|
|
3072
|
-
|
|
3358
|
+
parts: [{ text: params.prompt }]
|
|
3073
3359
|
});
|
|
3074
3360
|
const requestBody = {
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3361
|
+
systemInstruction: { parts: [{ text: systemPrompt }] },
|
|
3362
|
+
contents: history.contents,
|
|
3363
|
+
generationConfig: {
|
|
3364
|
+
maxOutputTokens: 8192,
|
|
3365
|
+
temperature: 1
|
|
3366
|
+
}
|
|
3079
3367
|
};
|
|
3080
3368
|
try {
|
|
3081
3369
|
const controller = new AbortController();
|
|
3082
3370
|
const timeoutHandle = setTimeout(() => controller.abort(), params.timeoutMs);
|
|
3083
|
-
const
|
|
3371
|
+
const url = `${DEFAULT_GEMINI_BASE_URL}/${modelPath}:generateContent?key=${params.apiKey}`;
|
|
3372
|
+
const response = await fetch(url, {
|
|
3084
3373
|
method: "POST",
|
|
3085
3374
|
headers: {
|
|
3086
|
-
"
|
|
3087
|
-
"
|
|
3088
|
-
"content-type": "application/json",
|
|
3089
|
-
"user-agent": `anima/3.0.5 (direct-runner; ${os.platform()})`
|
|
3375
|
+
"Content-Type": "application/json",
|
|
3376
|
+
"User-Agent": `anima/5.0.1 (gemini-direct-runner; ${os.platform()})`
|
|
3090
3377
|
},
|
|
3091
3378
|
body: JSON.stringify(requestBody),
|
|
3092
3379
|
signal: controller.signal
|
|
@@ -3097,8 +3384,8 @@ async function runAnthropicDirectAgent(params) {
|
|
|
3097
3384
|
const isAuth = response.status === 401 || response.status === 403;
|
|
3098
3385
|
const isRateLimit = response.status === 429;
|
|
3099
3386
|
const rateHint = isRateLimit ? " — rate limit hit, will retry next heartbeat." : "";
|
|
3100
|
-
const authHint = isAuth ? " —
|
|
3101
|
-
log.error(`
|
|
3387
|
+
const authHint = isAuth ? " — API key may be invalid. Check GEMINI_API_KEY environment variable." : "";
|
|
3388
|
+
log.error(`gemini api error: HTTP ${response.status}${authHint}${rateHint}`, {
|
|
3102
3389
|
status: response.status,
|
|
3103
3390
|
body: body.slice(0, 500)
|
|
3104
3391
|
});
|
|
@@ -3114,51 +3401,51 @@ async function runAnthropicDirectAgent(params) {
|
|
|
3114
3401
|
};
|
|
3115
3402
|
}
|
|
3116
3403
|
const data = await response.json();
|
|
3117
|
-
const
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
}
|
|
3128
|
-
|
|
3129
|
-
await saveSessionHistory(params.sessionFile, history);
|
|
3404
|
+
const candidate = data.candidates?.[0];
|
|
3405
|
+
const assistantText = (candidate?.content?.parts ?? []).filter((p) => typeof p.text === "string").map((p) => p.text).join("\n");
|
|
3406
|
+
if (assistantText && params.onPartialReply) await params.onPartialReply({ text: assistantText });
|
|
3407
|
+
if (assistantText) {
|
|
3408
|
+
history.contents.push({
|
|
3409
|
+
role: "model",
|
|
3410
|
+
parts: [{ text: assistantText }]
|
|
3411
|
+
});
|
|
3412
|
+
history.updatedAt = Date.now();
|
|
3413
|
+
await saveSessionHistory(params.sessionFile, history);
|
|
3414
|
+
}
|
|
3415
|
+
const usage = data.usageMetadata;
|
|
3130
3416
|
const durationMs = Date.now() - started;
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3417
|
+
log.info(`gemini api complete: ${durationMs}ms`, {
|
|
3418
|
+
inputTokens: usage?.promptTokenCount,
|
|
3419
|
+
outputTokens: usage?.candidatesTokenCount,
|
|
3420
|
+
finishReason: candidate?.finishReason
|
|
3421
|
+
});
|
|
3134
3422
|
return {
|
|
3135
3423
|
status: "completed",
|
|
3136
|
-
output:
|
|
3137
|
-
payloads: outputText ? [{ text: outputText }] : [],
|
|
3424
|
+
output: assistantText,
|
|
3138
3425
|
meta: {
|
|
3139
3426
|
durationMs,
|
|
3140
3427
|
agentMeta: {
|
|
3141
|
-
provider: "anthropic",
|
|
3142
3428
|
model: resolvedModel,
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
}
|
|
3429
|
+
provider: "google",
|
|
3430
|
+
usage: usage ? {
|
|
3431
|
+
input: usage.promptTokenCount ?? 0,
|
|
3432
|
+
output: usage.candidatesTokenCount ?? 0
|
|
3433
|
+
} : void 0
|
|
3149
3434
|
}
|
|
3150
3435
|
}
|
|
3151
3436
|
};
|
|
3152
3437
|
} catch (err) {
|
|
3153
|
-
const isAbort = err instanceof Error &&
|
|
3154
|
-
|
|
3438
|
+
const isAbort = err instanceof Error && err.name === "AbortError";
|
|
3439
|
+
const errorKind = isAbort ? "timeout" : "unknown";
|
|
3440
|
+
const errorMsg = isAbort ? `Request timed out after ${params.timeoutMs}ms` : String(err);
|
|
3441
|
+
log.error(`gemini api error: ${errorMsg}`, { error: String(err) });
|
|
3155
3442
|
return {
|
|
3156
|
-
status:
|
|
3443
|
+
status: "failed",
|
|
3157
3444
|
meta: {
|
|
3158
3445
|
durationMs: Date.now() - started,
|
|
3159
3446
|
error: {
|
|
3160
|
-
message:
|
|
3161
|
-
kind:
|
|
3447
|
+
message: errorMsg,
|
|
3448
|
+
kind: errorKind
|
|
3162
3449
|
}
|
|
3163
3450
|
}
|
|
3164
3451
|
};
|
|
@@ -3246,6 +3533,57 @@ async function runEmbeddedPiAgent(...args) {
|
|
|
3246
3533
|
}
|
|
3247
3534
|
}
|
|
3248
3535
|
}
|
|
3536
|
+
if (provider === "google" || provider === "gemini") {
|
|
3537
|
+
const geminiApiKey = (await resolveApiKeyForProvider({
|
|
3538
|
+
provider: "google",
|
|
3539
|
+
cfg: params.config
|
|
3540
|
+
}))?.apiKey;
|
|
3541
|
+
if (geminiApiKey) {
|
|
3542
|
+
await emitAgentEvent(params, "lifecycle", {
|
|
3543
|
+
phase: "start",
|
|
3544
|
+
startedAt
|
|
3545
|
+
});
|
|
3546
|
+
try {
|
|
3547
|
+
const result = await runGeminiDirectAgent({
|
|
3548
|
+
apiKey: geminiApiKey,
|
|
3549
|
+
sessionId: params.sessionId,
|
|
3550
|
+
sessionKey: params.sessionKey,
|
|
3551
|
+
agentId: params.agentId,
|
|
3552
|
+
sessionFile: params.sessionFile,
|
|
3553
|
+
workspaceDir: params.workspaceDir,
|
|
3554
|
+
config: params.config,
|
|
3555
|
+
prompt: params.prompt,
|
|
3556
|
+
model: params.model,
|
|
3557
|
+
thinkLevel: params.thinkLevel,
|
|
3558
|
+
timeoutMs,
|
|
3559
|
+
runId,
|
|
3560
|
+
extraSystemPrompt: params.extraSystemPrompt,
|
|
3561
|
+
ownerNumbers: params.ownerNumbers,
|
|
3562
|
+
onPartialReply: async (payload) => {
|
|
3563
|
+
if (!assistantStarted) {
|
|
3564
|
+
assistantStarted = true;
|
|
3565
|
+
await params.onAssistantMessageStart?.();
|
|
3566
|
+
}
|
|
3567
|
+
await params.onPartialReply?.(payload);
|
|
3568
|
+
await emitAgentEvent(params, "assistant", { text: payload.text });
|
|
3569
|
+
},
|
|
3570
|
+
onAssistantMessageStart: params.onAssistantMessageStart
|
|
3571
|
+
});
|
|
3572
|
+
await emitAgentEvent(params, "lifecycle", {
|
|
3573
|
+
phase: "end",
|
|
3574
|
+
durationMs: Date.now() - startedAt,
|
|
3575
|
+
status: result.status
|
|
3576
|
+
});
|
|
3577
|
+
return result;
|
|
3578
|
+
} catch (err) {
|
|
3579
|
+
await emitAgentEvent(params, "lifecycle", {
|
|
3580
|
+
phase: "error",
|
|
3581
|
+
error: String(err instanceof Error ? err.message : err)
|
|
3582
|
+
});
|
|
3583
|
+
throw err;
|
|
3584
|
+
}
|
|
3585
|
+
}
|
|
3586
|
+
}
|
|
3249
3587
|
const cliProvider = resolveCompatCliProvider(provider, params.config);
|
|
3250
3588
|
if (!resolveCliBackendConfig(cliProvider, params.config)) throw new Error(`No CLI backend available for provider "${provider}" (resolved "${cliProvider}").\nEither:\n • Run: anima setup-token (set an Anthropic API key — no CLI needed)\n • Install the matching CLI and log in`);
|
|
3251
3589
|
await emitAgentEvent(params, "lifecycle", {
|