theokit 0.43.12 → 0.44.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/{actions-virtual-module-RSFRPJQZ.js → actions-virtual-module-67K4POQ2.js} +20 -20
- package/dist/actions-virtual-module-67K4POQ2.js.map +1 -0
- package/dist/{actions-virtual-module-HG66SZ7T.js → actions-virtual-module-IK2SDIZ3.js} +4 -3
- package/dist/{actions-virtual-module-HG66SZ7T.js.map → actions-virtual-module-IK2SDIZ3.js.map} +1 -1
- package/dist/adapters/web-shim.js +1 -1
- package/dist/adapters/web-shim.js.map +1 -1
- package/dist/adapters/ws-shim.js +1 -1
- package/dist/adapters/ws-shim.js.map +1 -1
- package/dist/{agent-OXRRKB55.js → agent-OCCL5RUY.js} +2 -2
- package/dist/{agents-typed-client-ZP7BKJB3.js → agents-typed-client-TNHCUU7Q.js} +2 -2
- package/dist/agents-typed-client-TNHCUU7Q.js.map +1 -0
- package/dist/{app-typed-client-GDF2OMJ2.js → app-typed-client-4OH3JREB.js} +47 -8
- package/dist/app-typed-client-4OH3JREB.js.map +1 -0
- package/dist/{app-typed-client-USLAMN7X.js → app-typed-client-N5WUE2CP.js} +62 -24
- package/dist/app-typed-client-N5WUE2CP.js.map +1 -0
- package/dist/{body-parser-web-NNEJGX6Y.js → body-parser-web-4Z2QTPDU.js} +2 -2
- package/dist/body-parser-web-4Z2QTPDU.js.map +1 -0
- package/dist/boot/index.js +4 -4
- package/dist/boot/index.js.map +1 -1
- package/dist/{broadcast-4SX7R5XE.js → broadcast-H64DJRBE.js} +3 -3
- package/dist/broadcast-H64DJRBE.js.map +1 -0
- package/dist/{build-MQHIJROR.js → build-25RSFP22.js} +13 -4
- package/dist/build-25RSFP22.js.map +1 -0
- package/dist/{build-request-body-preview-FVBQ7LCE.js → build-request-body-preview-CKWWBF2M.js} +2 -2
- package/dist/build-request-body-preview-CKWWBF2M.js.map +1 -0
- package/dist/{chunk-26ECIX74.js → chunk-2ADKT37V.js} +5 -5
- package/dist/chunk-2ADKT37V.js.map +1 -0
- package/dist/{chunk-JIL74SFK.js → chunk-37ZO643S.js} +9 -9
- package/dist/chunk-37ZO643S.js.map +1 -0
- package/dist/{chunk-ESC54TAK.js → chunk-3DGIANAN.js} +1 -1
- package/dist/chunk-3DGIANAN.js.map +1 -0
- package/dist/{chunk-6FK7FKY6.js → chunk-47FFT43U.js} +1 -1
- package/dist/chunk-47FFT43U.js.map +1 -0
- package/dist/{chunk-ZJQ4O76G.js → chunk-4FWBKX6G.js} +1 -1
- package/dist/chunk-4FWBKX6G.js.map +1 -0
- package/dist/{chunk-NM4WF3XD.js → chunk-4PBJ266F.js} +1 -1
- package/dist/chunk-4PBJ266F.js.map +1 -0
- package/dist/{chunk-7MQOHNHE.js → chunk-52PDWL5S.js} +1 -1
- package/dist/chunk-52PDWL5S.js.map +1 -0
- package/dist/{chunk-JQJN6LFK.js → chunk-62EU2BVZ.js} +2 -2
- package/dist/chunk-62EU2BVZ.js.map +1 -0
- package/dist/{chunk-SJIRP73B.js → chunk-646CA6RV.js} +2 -2
- package/dist/chunk-646CA6RV.js.map +1 -0
- package/dist/{chunk-ASDXVRJD.js → chunk-6KDXP472.js} +4 -4
- package/dist/chunk-6KDXP472.js.map +1 -0
- package/dist/chunk-6LNIGF5P.js +46 -0
- package/dist/chunk-6LNIGF5P.js.map +1 -0
- package/dist/chunk-7IHWXDJJ.js +1 -0
- package/dist/chunk-7IHWXDJJ.js.map +1 -0
- package/dist/{chunk-JQSKBMXP.js → chunk-7LVM22VG.js} +1 -1
- package/dist/chunk-7LVM22VG.js.map +1 -0
- package/dist/{chunk-UVXB2ER7.js → chunk-7SABX4DJ.js} +1 -1
- package/dist/chunk-7SABX4DJ.js.map +1 -0
- package/dist/{chunk-X32XEJXR.js → chunk-ACKBVBUI.js} +1 -1
- package/dist/chunk-ACKBVBUI.js.map +1 -0
- package/dist/{chunk-UUFYP2UM.js → chunk-AM3QABW5.js} +3 -3
- package/dist/chunk-AM3QABW5.js.map +1 -0
- package/dist/{chunk-FH3DYBAN.js → chunk-ANS4ELRH.js} +1 -1
- package/dist/chunk-ANS4ELRH.js.map +1 -0
- package/dist/{chunk-UD3LFGDL.js → chunk-AVQU5CQF.js} +1 -1
- package/dist/chunk-AVQU5CQF.js.map +1 -0
- package/dist/{chunk-CJNMJUHE.js → chunk-B7ONQ4QJ.js} +2 -2
- package/dist/{chunk-WSJKACWB.js → chunk-C34PMLSN.js} +1 -1
- package/dist/chunk-C34PMLSN.js.map +1 -0
- package/dist/{chunk-2WH6SD3C.js → chunk-DSOBIXXR.js} +4 -4
- package/dist/{chunk-DJFMAWH5.js → chunk-EIRQM55C.js} +6 -5
- package/dist/chunk-EIRQM55C.js.map +1 -0
- package/dist/{chunk-ZEGYW52B.js → chunk-FB2HBNIC.js} +1 -1
- package/dist/chunk-FB2HBNIC.js.map +1 -0
- package/dist/chunk-FXZZS7YW.js +605 -0
- package/dist/chunk-FXZZS7YW.js.map +1 -0
- package/dist/{chunk-HGUZWG2C.js → chunk-FZG3JYB3.js} +8 -47
- package/dist/chunk-FZG3JYB3.js.map +1 -0
- package/dist/{chunk-V3LJN2GS.js → chunk-GAPBPRPP.js} +1 -1
- package/dist/chunk-GAPBPRPP.js.map +1 -0
- package/dist/chunk-GUBN5UTT.js +1 -0
- package/dist/chunk-GUBN5UTT.js.map +1 -0
- package/dist/{chunk-6OXCZMW3.js → chunk-HEK4SET7.js} +5 -5
- package/dist/chunk-HEK4SET7.js.map +1 -0
- package/dist/{chunk-N2D5AVRR.js → chunk-HRCNHWLP.js} +7 -109
- package/dist/chunk-HRCNHWLP.js.map +1 -0
- package/dist/{chunk-C3ZZ56YZ.js → chunk-JA2ZAT5Q.js} +1 -1
- package/dist/chunk-JA2ZAT5Q.js.map +1 -0
- package/dist/{chunk-L2S2R3TI.js → chunk-KBGGQK4I.js} +25 -8
- package/dist/chunk-KBGGQK4I.js.map +1 -0
- package/dist/{chunk-VPISAMXU.js → chunk-KD5G3YXI.js} +4 -4
- package/dist/chunk-KD5G3YXI.js.map +1 -0
- package/dist/{chunk-VMEWD57H.js → chunk-KPKLIUUL.js} +1 -1
- package/dist/chunk-KPKLIUUL.js.map +1 -0
- package/dist/{chunk-4HAU7AJM.js → chunk-L4Y6RJ4E.js} +3 -3
- package/dist/chunk-L4Y6RJ4E.js.map +1 -0
- package/dist/{chunk-OVHW23YC.js → chunk-L5Z6IY5U.js} +5 -5
- package/dist/chunk-L5Z6IY5U.js.map +1 -0
- package/dist/{chunk-JBCHWRKF.js → chunk-MTEWLGVY.js} +2 -2
- package/dist/chunk-MTEWLGVY.js.map +1 -0
- package/dist/{chunk-XZ6B2Y2R.js → chunk-MWP4YXWJ.js} +1 -1
- package/dist/chunk-MWP4YXWJ.js.map +1 -0
- package/dist/{chunk-575PAX5L.js → chunk-NGEBYCOZ.js} +62 -38
- package/dist/chunk-NGEBYCOZ.js.map +1 -0
- package/dist/{chunk-5QW7IQQU.js → chunk-NTDN54XO.js} +1 -1
- package/dist/chunk-NTDN54XO.js.map +1 -0
- package/dist/{chunk-7BIM27LV.js → chunk-OIGJOYX6.js} +1 -1
- package/dist/chunk-OIGJOYX6.js.map +1 -0
- package/dist/{chunk-TSLSIRBR.js → chunk-OLGPYOLO.js} +2 -2
- package/dist/chunk-OLGPYOLO.js.map +1 -0
- package/dist/{chunk-IE6C4KZX.js → chunk-Q5OT7LZG.js} +11 -496
- package/dist/chunk-Q5OT7LZG.js.map +1 -0
- package/dist/{chunk-6NEXVBPY.js → chunk-RWNSW4FM.js} +1 -1
- package/dist/chunk-RWNSW4FM.js.map +1 -0
- package/dist/{chunk-E25FBYJP.js → chunk-SAFGDIPQ.js} +1 -1
- package/dist/chunk-SAFGDIPQ.js.map +1 -0
- package/dist/{chunk-OP7QCTR5.js → chunk-SEELKQUM.js} +2 -2
- package/dist/chunk-SEELKQUM.js.map +1 -0
- package/dist/{chunk-4B2ZMX45.js → chunk-SSYDEKWF.js} +1 -1
- package/dist/chunk-SSYDEKWF.js.map +1 -0
- package/dist/{chunk-DQVBL2G4.js → chunk-SZU6BOMV.js} +75 -53
- package/dist/chunk-SZU6BOMV.js.map +1 -0
- package/dist/{chunk-65EFIUDD.js → chunk-U267AOWS.js} +1 -1
- package/dist/chunk-U267AOWS.js.map +1 -0
- package/dist/{chunk-FX72VHAE.js → chunk-U3H53IIN.js} +6 -6
- package/dist/chunk-U3H53IIN.js.map +1 -0
- package/dist/{chunk-OPLICDUB.js → chunk-UW2TEAGR.js} +1 -1
- package/dist/chunk-UW2TEAGR.js.map +1 -0
- package/dist/{chunk-IAJ2JVEH.js → chunk-VSLTKX5L.js} +1 -1
- package/dist/chunk-VSLTKX5L.js.map +1 -0
- package/dist/{chunk-YB5DJJ4U.js → chunk-VZTYCAO6.js} +1 -1
- package/dist/chunk-VZTYCAO6.js.map +1 -0
- package/dist/chunk-WDGYCBNI.js +65 -0
- package/dist/chunk-WDGYCBNI.js.map +1 -0
- package/dist/chunk-WPJOTQA5.js +1 -0
- package/dist/chunk-WPJOTQA5.js.map +1 -0
- package/dist/{chunk-DGUM43GV.js → chunk-XTHN6JBX.js} +1 -1
- package/dist/chunk-XTHN6JBX.js.map +1 -0
- package/dist/{chunk-HZ6USUHC.js → chunk-YOIVCCZT.js} +1 -1
- package/dist/chunk-YOIVCCZT.js.map +1 -0
- package/dist/{chunk-OI6DK6ZJ.js → chunk-ZC2UESE4.js} +6 -4
- package/dist/{chunk-OI6DK6ZJ.js.map → chunk-ZC2UESE4.js.map} +1 -1
- package/dist/cli/index.js +8 -8
- package/dist/client/core.d.ts +4 -258
- package/dist/client/core.js +13 -9
- package/dist/client/core.js.map +1 -1
- package/dist/client/index.d.ts +7 -96
- package/dist/client/index.js +19 -67
- package/dist/client/index.js.map +1 -1
- package/dist/{controller-swc-transform-JJRMTSDY.js → controller-swc-transform-T7ZTD55V.js} +2 -2
- package/dist/controller-swc-transform-T7ZTD55V.js.map +1 -0
- package/dist/{cookies-MJKMGJ7N.js → cookies-SOXUQJXG.js} +3 -3
- package/dist/cookies-SOXUQJXG.js.map +1 -0
- package/dist/{dev-WQ4LWCAW.js → dev-V6UBM2OL.js} +8 -7
- package/dist/{dev-WQ4LWCAW.js.map → dev-V6UBM2OL.js.map} +1 -1
- package/dist/{dev-emit-HLGJK3PP.js → dev-emit-F54Y5TIU.js} +5 -5
- package/dist/dev-emit-F54Y5TIU.js.map +1 -0
- package/dist/devtools/entry.js +61 -53
- package/dist/devtools/entry.js.map +1 -1
- package/dist/dispatcher-MXKF3CRH.js +8 -0
- package/dist/dispatcher-MXKF3CRH.js.map +1 -0
- package/dist/index.js +25 -25
- package/dist/index.js.map +1 -1
- package/dist/{info-75U6GCMD.js → info-ICDTPJDC.js} +3 -3
- package/dist/{internal-api-JFORKYLR.js → internal-api-ALXVBL56.js} +10 -8
- package/dist/{internal-api-DV3H5NNV.js → internal-api-S7WK2WCY.js} +20 -20
- package/dist/internal-api-S7WK2WCY.js.map +1 -0
- package/dist/{load-config-XP7NSSA7.js → load-config-ICCNMO74.js} +3 -3
- package/dist/{mcp-FF3NTCHB.js → mcp-4JFODA5U.js} +3 -3
- package/dist/{openapi-ZPXYRAM2.js → openapi-NIYA2VBG.js} +3 -3
- package/dist/react-query/index.js +2 -2
- package/dist/react-query/index.js.map +1 -1
- package/dist/{routes-ZVDKABXZ.js → routes-2RD4S5PZ.js} +3 -3
- package/dist/{schema-FBOTN46F.js → schema-S553QCAU.js} +2 -2
- package/dist/server/agent/index.d.ts +3 -72
- package/dist/server/agent/index.js +4 -4
- package/dist/server/agent/index.js.map +1 -1
- package/dist/server/auth/index.js +4 -4
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cost/index.js +2 -2
- package/dist/server/cost/index.js.map +1 -1
- package/dist/server/cron/index.js +6 -6
- package/dist/server/cron/index.js.map +1 -1
- package/dist/server/define/index.js +4 -4
- package/dist/server/define/index.js.map +1 -1
- package/dist/server/http/index.js +11 -11
- package/dist/server/http/index.js.map +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +41 -41
- package/dist/server/index.js.map +1 -1
- package/dist/server/jobs/index.js +7 -7
- package/dist/server/jobs/index.js.map +1 -1
- package/dist/server/observability/index.d.ts +8 -1
- package/dist/server/observability/index.js +5 -5
- package/dist/server/observability/index.js.map +1 -1
- package/dist/server/plugins/index.js +3 -3
- package/dist/server/plugins/index.js.map +1 -1
- package/dist/server/rate-limit/index.js +4 -4
- package/dist/server/rate-limit/index.js.map +1 -1
- package/dist/server/realtime/index.js +2 -2
- package/dist/server/realtime/index.js.map +1 -1
- package/dist/server/scan/index.js +7 -7
- package/dist/server/scan/index.js.map +1 -1
- package/dist/server/security/index.js +5 -5
- package/dist/server/security/index.js.map +1 -1
- package/dist/server/storage/index.js +2 -2
- package/dist/server/storage/index.js.map +1 -1
- package/dist/server/webhook/index.js +3 -3
- package/dist/server/webhook/index.js.map +1 -1
- package/dist/server-error-to-envelope-UM7DEVM4.js +8 -0
- package/dist/server-error-to-envelope-UM7DEVM4.js.map +1 -0
- package/dist/{server-routes-hmr-RI7SYNT2.js → server-routes-hmr-6CRNSEWF.js} +2 -2
- package/dist/server-routes-hmr-6CRNSEWF.js.map +1 -0
- package/dist/{services-typed-client-AU6DKXAO.js → services-typed-client-IXNOPVZA.js} +3 -3
- package/dist/services-typed-client-IXNOPVZA.js.map +1 -0
- package/dist/{start-2U3FUCJX.js → start-2LNPPG74.js} +35 -11
- package/dist/start-2LNPPG74.js.map +1 -0
- package/dist/vite-plugin/index.js +25 -25
- package/dist/vite-plugin/index.js.map +1 -1
- package/dist/{vite-plugin-D2NTPZNC.js → vite-plugin-X6YO3OUH.js} +8 -7
- package/package.json +9 -5
- package/dist/actions-virtual-module-RSFRPJQZ.js.map +0 -1
- package/dist/agents-typed-client-ZP7BKJB3.js.map +0 -1
- package/dist/app-typed-client-GDF2OMJ2.js.map +0 -1
- package/dist/app-typed-client-USLAMN7X.js.map +0 -1
- package/dist/body-parser-web-NNEJGX6Y.js.map +0 -1
- package/dist/build-MQHIJROR.js.map +0 -1
- package/dist/build-request-body-preview-FVBQ7LCE.js.map +0 -1
- package/dist/chunk-26ECIX74.js.map +0 -1
- package/dist/chunk-4B2ZMX45.js.map +0 -1
- package/dist/chunk-4HAU7AJM.js.map +0 -1
- package/dist/chunk-575PAX5L.js.map +0 -1
- package/dist/chunk-5QW7IQQU.js.map +0 -1
- package/dist/chunk-65EFIUDD.js.map +0 -1
- package/dist/chunk-6FK7FKY6.js.map +0 -1
- package/dist/chunk-6NEXVBPY.js.map +0 -1
- package/dist/chunk-6OXCZMW3.js.map +0 -1
- package/dist/chunk-7BIM27LV.js.map +0 -1
- package/dist/chunk-7MQOHNHE.js.map +0 -1
- package/dist/chunk-ASDXVRJD.js.map +0 -1
- package/dist/chunk-C3ZZ56YZ.js.map +0 -1
- package/dist/chunk-DJFMAWH5.js.map +0 -1
- package/dist/chunk-DQVBL2G4.js.map +0 -1
- package/dist/chunk-E25FBYJP.js.map +0 -1
- package/dist/chunk-E3JH6YUM.js +0 -1
- package/dist/chunk-ESC54TAK.js.map +0 -1
- package/dist/chunk-FH3DYBAN.js.map +0 -1
- package/dist/chunk-FX72VHAE.js.map +0 -1
- package/dist/chunk-HGUZWG2C.js.map +0 -1
- package/dist/chunk-HZ6USUHC.js.map +0 -1
- package/dist/chunk-IAJ2JVEH.js.map +0 -1
- package/dist/chunk-IE6C4KZX.js.map +0 -1
- package/dist/chunk-JBCHWRKF.js.map +0 -1
- package/dist/chunk-JHEAWR3L.js +0 -1
- package/dist/chunk-JIL74SFK.js.map +0 -1
- package/dist/chunk-JQJN6LFK.js.map +0 -1
- package/dist/chunk-JQSKBMXP.js.map +0 -1
- package/dist/chunk-KPRJS3II.js +0 -505
- package/dist/chunk-KPRJS3II.js.map +0 -1
- package/dist/chunk-L2S2R3TI.js.map +0 -1
- package/dist/chunk-N2D5AVRR.js.map +0 -1
- package/dist/chunk-NM4WF3XD.js.map +0 -1
- package/dist/chunk-NPMCKOX4.js +0 -1
- package/dist/chunk-NPMCKOX4.js.map +0 -1
- package/dist/chunk-OP7QCTR5.js.map +0 -1
- package/dist/chunk-OPLICDUB.js.map +0 -1
- package/dist/chunk-OVHW23YC.js.map +0 -1
- package/dist/chunk-SJIRP73B.js.map +0 -1
- package/dist/chunk-TSLSIRBR.js.map +0 -1
- package/dist/chunk-UD3LFGDL.js.map +0 -1
- package/dist/chunk-UUFYP2UM.js.map +0 -1
- package/dist/chunk-UVXB2ER7.js.map +0 -1
- package/dist/chunk-V3LJN2GS.js.map +0 -1
- package/dist/chunk-VMEWD57H.js.map +0 -1
- package/dist/chunk-VPISAMXU.js.map +0 -1
- package/dist/chunk-WSJKACWB.js.map +0 -1
- package/dist/chunk-X32XEJXR.js.map +0 -1
- package/dist/chunk-XZ6B2Y2R.js.map +0 -1
- package/dist/chunk-YB5DJJ4U.js.map +0 -1
- package/dist/chunk-ZEGYW52B.js.map +0 -1
- package/dist/chunk-ZJQ4O76G.js.map +0 -1
- package/dist/controller-swc-transform-JJRMTSDY.js.map +0 -1
- package/dist/cookies-MJKMGJ7N.js.map +0 -1
- package/dist/dev-emit-HLGJK3PP.js.map +0 -1
- package/dist/dispatcher-DLKIXYNO.js +0 -8
- package/dist/dispatcher-DLKIXYNO.js.map +0 -1
- package/dist/internal-api-DV3H5NNV.js.map +0 -1
- package/dist/internal-api-JFORKYLR.js.map +0 -1
- package/dist/load-config-XP7NSSA7.js.map +0 -1
- package/dist/schema-FBOTN46F.js.map +0 -1
- package/dist/server-error-to-envelope-EOFUIUNB.js +0 -8
- package/dist/server-error-to-envelope-EOFUIUNB.js.map +0 -1
- package/dist/server-routes-hmr-RI7SYNT2.js.map +0 -1
- package/dist/services-typed-client-AU6DKXAO.js.map +0 -1
- package/dist/start-2U3FUCJX.js.map +0 -1
- package/dist/vite-plugin-D2NTPZNC.js.map +0 -1
- /package/dist/{agent-OXRRKB55.js.map → agent-OCCL5RUY.js.map} +0 -0
- /package/dist/{chunk-CJNMJUHE.js.map → chunk-B7ONQ4QJ.js.map} +0 -0
- /package/dist/{chunk-2WH6SD3C.js.map → chunk-DSOBIXXR.js.map} +0 -0
- /package/dist/{info-75U6GCMD.js.map → info-ICDTPJDC.js.map} +0 -0
- /package/dist/{broadcast-4SX7R5XE.js.map → internal-api-ALXVBL56.js.map} +0 -0
- /package/dist/{chunk-DGUM43GV.js.map → load-config-ICCNMO74.js.map} +0 -0
- /package/dist/{mcp-FF3NTCHB.js.map → mcp-4JFODA5U.js.map} +0 -0
- /package/dist/{openapi-ZPXYRAM2.js.map → openapi-NIYA2VBG.js.map} +0 -0
- /package/dist/{routes-ZVDKABXZ.js.map → routes-2RD4S5PZ.js.map} +0 -0
- /package/dist/{chunk-E3JH6YUM.js.map → schema-S553QCAU.js.map} +0 -0
- /package/dist/{chunk-JHEAWR3L.js.map → vite-plugin-X6YO3OUH.js.map} +0 -0
package/dist/client/core.d.ts
CHANGED
|
@@ -1,89 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* M41 (ADR-0050 D2) — a HITL approval decision sent to settle a paused gated-tool call. Mirrors the
|
|
5
|
-
* `POST /api/agents/<name>/approve/<id>` wire body (`approve-agent.ts` `parseApprovalBody`). Defined
|
|
6
|
-
* on the client side (not imported from `server/`) as the client's view of the boundary contract.
|
|
7
|
-
*/
|
|
8
|
-
interface ApprovalDecision {
|
|
9
|
-
/** Whether the paused gated tool may proceed. */
|
|
10
|
-
approved: boolean;
|
|
11
|
-
/** Optional reason surfaced to the model on denial. */
|
|
12
|
-
reason?: string;
|
|
13
|
-
/** Optional small structured note (edited args, a reviewer comment) — capped server-side at 16 KiB. */
|
|
14
|
-
payload?: unknown;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* M43 (ADR-0052) — per-request context attached uniformly across every transport.
|
|
18
|
-
*
|
|
19
|
-
* `headers` is the serializable, HTTP-native half (an auth token → request headers on `HttpTransport`);
|
|
20
|
-
* `metadata` is the structured, same-process half forwarded to the in-process runner
|
|
21
|
-
* (`InProcessTransport`) / the Tauri `invoke` (`ChannelTransport`). Threaded through the seam's existing
|
|
22
|
-
* `ChatRequestOptions` — NOT a new channel. The turn input stays the request `body`.
|
|
23
|
-
*/
|
|
24
|
-
interface RequestContext {
|
|
25
|
-
/** Per-request headers (e.g. auth). HTTP-native; mapped to request headers by `HttpTransport`. */
|
|
26
|
-
headers?: Record<string, string>;
|
|
27
|
-
/** Structured per-request context (tenant, provider, …) forwarded to in-process / channel runners. */
|
|
28
|
-
metadata?: unknown;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* M41 (ADR-0050 D1/D2) — the client transport seam.
|
|
32
|
-
*
|
|
33
|
-
* It IS `ai`'s `ChatTransport<UIMessage>` (the adopted SOTA interface — we do NOT invent a parallel
|
|
34
|
-
* one) plus ONE optional method, `approve`, for TheoKit's OUT-OF-BAND HITL (the server pauses the run;
|
|
35
|
-
* the client settles it via a separate call). `ai`'s `ChatTransport` has no `approve` because its HITL
|
|
36
|
-
* is in-band (a re-sent message part); ours is out-of-band, and the settle route differs per transport
|
|
37
|
-
* (HTTP `POST /approve/<id>` vs an inline callback), so it belongs on the transport. `approve` is
|
|
38
|
-
* optional — agents without gated tools never settle an approval.
|
|
39
|
-
*
|
|
40
|
-
* `HttpTransport` (web) and `InProcessTransport` (TUI/desktop) implement this; `useAgent` drives it.
|
|
41
|
-
*/
|
|
42
|
-
type AgentTransport = ChatTransport<UIMessage> & {
|
|
43
|
-
approve?(approvalId: string, decision: ApprovalDecision): Promise<void>;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
type UseAgentStatus = 'idle' | 'streaming' | 'done' | 'error';
|
|
47
|
-
/** The observable state the store exposes (stable reference between emits — `useSyncExternalStore` contract). */
|
|
48
|
-
interface AgentClientState {
|
|
49
|
-
/** The CURRENT turn's assistant messages (per-turn; reset each `send`). Back-compat — unchanged since M41. */
|
|
50
|
-
messages: UIMessage[];
|
|
51
|
-
/**
|
|
52
|
-
* M46 — the full conversation: committed turns + the current turn's user message + in-flight assistant.
|
|
53
|
-
* Accumulated across sends (never reset except by `reset()`), with stable ids committed exactly once.
|
|
54
|
-
* Render this instead of hand-rolling a transcript from `messages`.
|
|
55
|
-
*/
|
|
56
|
-
thread: UIMessage[];
|
|
57
|
-
status: UseAgentStatus;
|
|
58
|
-
error: Error | undefined;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* M41 (ADR-0050 D6) — the framework-agnostic agent client store.
|
|
62
|
-
*
|
|
63
|
-
* Holds `messages`/`status`/`error`, drives an {@link AgentTransport}, and notifies subscribers on
|
|
64
|
-
* change. It is the SINGLE consolidation point: web (`HttpTransport`) and terminal/desktop
|
|
65
|
-
* (`InProcessTransport`) run the SAME store. `useAgent` is a thin React binding over it via
|
|
66
|
-
* `useSyncExternalStore`; a standalone (no-React) client (M44) can subscribe directly. Being
|
|
67
|
-
* framework-agnostic, it is unit-tested without a DOM.
|
|
68
|
-
*/
|
|
69
|
-
declare class AgentClient<TInput = unknown> {
|
|
70
|
-
#private;
|
|
71
|
-
constructor(transport: AgentTransport, contextResolver?: () => RequestContext | undefined);
|
|
72
|
-
/** Subscribe to state changes; returns an unsubscribe fn. */
|
|
73
|
-
subscribe: (listener: () => void) => (() => void);
|
|
74
|
-
/** The current immutable snapshot (stable reference until the next emit). */
|
|
75
|
-
getSnapshot: () => AgentClientState;
|
|
76
|
-
/** Send a typed input; opens a fresh stream (replaces prior messages). */
|
|
77
|
-
send: (input: TInput) => void;
|
|
78
|
-
/** Resume an interrupted stream via the transport's `reconnectToStream` (no-op when unavailable). */
|
|
79
|
-
reconnect: () => void;
|
|
80
|
-
/** Abort an in-flight stream (not an error — leaves messages as-is). */
|
|
81
|
-
abort: () => void;
|
|
82
|
-
/** Clear messages + error, back to idle. */
|
|
83
|
-
reset: () => void;
|
|
84
|
-
/** Settle a paused HITL approval via the transport's HITL path (HTTP POST or inline callback). */
|
|
85
|
-
approve: (approvalId: string, decision: ApprovalDecision) => Promise<void>;
|
|
86
|
-
}
|
|
1
|
+
import { ApprovalDecision, AgentClientState, RequestContext, AgentTransport } from '@theokit/agents/client';
|
|
2
|
+
export { AgentClient, AgentClientState, AgentTransport, ApprovalDecision, ChannelPushSource, ChannelTransport, ChannelTransportOptions, ChannelTurnHandlers, HeadersResolver, HttpTransport, HttpTransportOptions, InProcessApprovalRequestLike, InProcessAwaitApproval, InProcessRunInput, InProcessRunner, InProcessTransport, InProcessTransportOptions, RequestContext, UseAgentStatus, consumeChunkStream, consumeUIMessageStream, responseToChunkStream } from '@theokit/agents/client';
|
|
3
|
+
import { UIMessage } from 'ai';
|
|
87
4
|
|
|
88
5
|
interface CreateAgentClientOptions {
|
|
89
6
|
/**
|
|
@@ -131,175 +48,4 @@ interface AgentClientHandle<TInput = unknown> {
|
|
|
131
48
|
*/
|
|
132
49
|
declare function createAgentClient<TInput = unknown>(transport: AgentTransport, options?: CreateAgentClientOptions): AgentClientHandle<TInput>;
|
|
133
50
|
|
|
134
|
-
|
|
135
|
-
type HeadersResolver = Record<string, string> | (() => Record<string, string> | undefined);
|
|
136
|
-
interface HttpTransportOptions {
|
|
137
|
-
/** Agent endpoint path or URL, e.g. `/api/agents/support`. */
|
|
138
|
-
api: string;
|
|
139
|
-
/**
|
|
140
|
-
* Extra request headers (e.g. auth). Static record OR a resolver evaluated on EVERY request — pass a
|
|
141
|
-
* resolver when the value is dynamic (a rotating JWT), so a stale header is never sent. Merged UNDER
|
|
142
|
-
* per-request headers.
|
|
143
|
-
*/
|
|
144
|
-
headers?: HeadersResolver;
|
|
145
|
-
/** Override fetch (primarily for tests / non-browser hosts) — static; resolved once at construction. */
|
|
146
|
-
fetch?: typeof fetch;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* M41 (ADR-0050 D3) — `ChatTransport` over the web agent path.
|
|
150
|
-
*
|
|
151
|
-
* - `sendMessages`: `POST <api>` with the UIMessageStream `accept` + the `X-Theo-Action` CSRF header
|
|
152
|
-
* (HTTP method + headers are identical to the pre-M41 `useAgent` fetch; the body shape is a superset —
|
|
153
|
-
* `{ ...input, messages: [UIMessage] }` — which the server's dual-path parser accepts, so no
|
|
154
|
-
* regression), captures the server-minted `x-theokit-run-id`, and returns `ReadableStream<UIMessageChunk>`
|
|
155
|
-
* via `ai`'s own SSE parser (`responseToChunkStream`).
|
|
156
|
-
* - `reconnectToStream`: `GET <api>/runs/<runId>/stream` (M37 durable transport); 404 → `null` (the run
|
|
157
|
-
* completed / was evicted). A caller may pass a `Last-Event-ID` header to resume only the tail; by
|
|
158
|
-
* default the server replays the run from the start and the client upserts by message id (idempotent).
|
|
159
|
-
* - `approve`: `POST <api>/approve/<id>` (out-of-band HITL settle).
|
|
160
|
-
*
|
|
161
|
-
* Implemented directly (not by subclassing `DefaultChatTransport`) because reconnect keys on our
|
|
162
|
-
* server-minted `runId` captured from a response header, which the base class does not expose — see
|
|
163
|
-
* ADR-0050 D3.
|
|
164
|
-
*/
|
|
165
|
-
declare class HttpTransport implements AgentTransport {
|
|
166
|
-
#private;
|
|
167
|
-
constructor(options: HttpTransportOptions);
|
|
168
|
-
sendMessages(options: Parameters<ChatTransport<UIMessage>['sendMessages']>[0]): Promise<ReadableStream<UIMessageChunk>>;
|
|
169
|
-
reconnectToStream(options: Parameters<ChatTransport<UIMessage>['reconnectToStream']>[0]): Promise<ReadableStream<UIMessageChunk> | null>;
|
|
170
|
-
approve(approvalId: string, decision: ApprovalDecision): Promise<void>;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/** An inline approval request handed to the transport's resolver (structural — no server import). */
|
|
174
|
-
interface InProcessApprovalRequestLike {
|
|
175
|
-
approvalId: string;
|
|
176
|
-
toolName: string;
|
|
177
|
-
opts: unknown;
|
|
178
|
-
}
|
|
179
|
-
/** Resolve one gated-tool approval inline (mirrors the SDK's `boolean | HitlDecision` return). */
|
|
180
|
-
type InProcessAwaitApproval = (req: InProcessApprovalRequestLike) => Promise<boolean | ApprovalDecision>;
|
|
181
|
-
/** The input the injected runner receives (structurally compatible with `StreamAgentTurnInProcessInput`). */
|
|
182
|
-
interface InProcessRunInput {
|
|
183
|
-
message: string;
|
|
184
|
-
sessionId?: string;
|
|
185
|
-
signal?: AbortSignal;
|
|
186
|
-
awaitApproval?: InProcessAwaitApproval;
|
|
187
|
-
/** M43 — per-request context (from `sendMessages`'s `metadata`) — tenant / provider / auth for the runner. */
|
|
188
|
-
context?: unknown;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* The in-process turn runner. The consumer binds `streamAgentTurnInProcess(mod, apiKey, …)`:
|
|
192
|
-
* `new InProcessTransport({ run: (input) => streamAgentTurnInProcess(mod, apiKey, input) })`.
|
|
193
|
-
* Injecting it keeps this client module decoupled from `server/` and makes the transport testable.
|
|
194
|
-
*/
|
|
195
|
-
type InProcessRunner = (input: InProcessRunInput) => AsyncGenerator<UIMessageChunk>;
|
|
196
|
-
interface InProcessTransportOptions {
|
|
197
|
-
run: InProcessRunner;
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* M41 (ADR-0050 D4) — `ChatTransport` over the in-process seam (`streamAgentTurnInProcess`), for the
|
|
201
|
-
* terminal/desktop surfaces that run client + server in ONE process (no HTTP loopback).
|
|
202
|
-
*
|
|
203
|
-
* - `sendMessages`: bridge the injected runner's `AsyncGenerator<UIMessageChunk>` into a
|
|
204
|
-
* `ReadableStream<UIMessageChunk>` (honoring `abortSignal`, which the runner forwards to the SDK).
|
|
205
|
-
* - `reconnectToStream`: always `null` — a single process has no dropped server-side stream to resume
|
|
206
|
-
* (mirrors `ai`'s `DirectChatTransport`).
|
|
207
|
-
* - `approve`: resolve the pending inline approval by id (the run parks on `awaitApproval`). An unknown
|
|
208
|
-
* id rejects (fail-fast, Rule 8 — never a silent resolve).
|
|
209
|
-
*
|
|
210
|
-
* Error asymmetry vs `HttpTransport` (by design, matching the `ChatTransport` contract): a runner that
|
|
211
|
-
* throws SYNCHRONOUSLY surfaces the error when the stream is READ (via `controller.error`), not from the
|
|
212
|
-
* `sendMessages` promise — whereas `HttpTransport` throws from `sendMessages` on a non-2xx response.
|
|
213
|
-
*/
|
|
214
|
-
declare class InProcessTransport implements AgentTransport {
|
|
215
|
-
#private;
|
|
216
|
-
constructor(options: InProcessTransportOptions);
|
|
217
|
-
sendMessages(options: Parameters<ChatTransport<UIMessage>['sendMessages']>[0]): Promise<ReadableStream<UIMessageChunk>>;
|
|
218
|
-
reconnectToStream(): Promise<ReadableStream<UIMessageChunk> | null>;
|
|
219
|
-
approve(approvalId: string, decision: ApprovalDecision): Promise<void>;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/** Handlers the transport hands to the injected push source for one turn. */
|
|
223
|
-
interface ChannelTurnHandlers {
|
|
224
|
-
/** One pushed JSONL line (a serialized `UIMessageChunk`). */
|
|
225
|
-
onLine: (line: string) => void;
|
|
226
|
-
/** The turn ended — no more lines. */
|
|
227
|
-
onClose: () => void;
|
|
228
|
-
/** The push source failed. */
|
|
229
|
-
onError?: (err: unknown) => void;
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* The injected push source — a Tauri `Channel`/`invoke` bridge, kept STRUCTURAL so core adds no
|
|
233
|
-
* `@tauri-apps/*` dependency and the transport is testable with a fake (ADR-0051 D2). The Tauri app
|
|
234
|
-
* wires it: `new Channel()`, `channel.onmessage = onLine`, `invoke('run_agent', { message, channel })`,
|
|
235
|
-
* returning a teardown that aborts the sidecar turn.
|
|
236
|
-
*/
|
|
237
|
-
interface ChannelPushSource {
|
|
238
|
-
/**
|
|
239
|
-
* Start a turn; deliver each JSONL `UIMessageChunk` line to `onLine`, then `onClose`. Return a teardown.
|
|
240
|
-
* `turn.context` (M43) is the per-request context (from the seam's `metadata`) — the Tauri `invoke`
|
|
241
|
-
* forwards it to the sidecar. When no context is set it is present as `context: undefined` (the key is
|
|
242
|
-
* NOT absent) — a sidecar that checks `'context' in turn` should treat `undefined` as "no context".
|
|
243
|
-
*/
|
|
244
|
-
start(turn: {
|
|
245
|
-
message: string;
|
|
246
|
-
context?: unknown;
|
|
247
|
-
}, handlers: ChannelTurnHandlers): () => void;
|
|
248
|
-
/** Optional HITL settle (another Tauri `invoke`). */
|
|
249
|
-
settle?(approvalId: string, decision: ApprovalDecision): Promise<void>;
|
|
250
|
-
}
|
|
251
|
-
interface ChannelTransportOptions {
|
|
252
|
-
source: ChannelPushSource;
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* M42 (ADR-0051) — `ChatTransport` over a Tauri-`Channel`-shaped push source, for the desktop webview.
|
|
256
|
-
*
|
|
257
|
-
* - `sendMessages`: start the turn via the injected source and bridge its pushed JSONL frames into a
|
|
258
|
-
* `ReadableStream<UIMessageChunk>` (built in `start` — a Channel is push, so the stream's queue buffers
|
|
259
|
-
* frames; ADR-0051 D3). A malformed JSONL line is SKIPPED, never fatal (ADR-0051 D4, Rule 8). `abortSignal`
|
|
260
|
-
* tears down the source and closes the stream.
|
|
261
|
-
* - `reconnectToStream`: always `null` — the M36 sidecar runs the turn directly (no durable server stream);
|
|
262
|
-
* this is the honest parity for a single-process push surface (ADR-0051 D5; mirrors `InProcessTransport`).
|
|
263
|
-
* - `approve`: routes to the injected `settle` (another Tauri `invoke`); absent `settle` → a typed error.
|
|
264
|
-
*
|
|
265
|
-
* The push source is INJECTED — core stays Tauri-agnostic and this transport is unit-tested with a fake.
|
|
266
|
-
*/
|
|
267
|
-
declare class ChannelTransport implements AgentTransport {
|
|
268
|
-
#private;
|
|
269
|
-
constructor(options: ChannelTransportOptions);
|
|
270
|
-
sendMessages(options: Parameters<ChatTransport<UIMessage>['sendMessages']>[0]): Promise<ReadableStream<UIMessageChunk>>;
|
|
271
|
-
reconnectToStream(): Promise<ReadableStream<UIMessageChunk> | null>;
|
|
272
|
-
approve(approvalId: string, decision: ApprovalDecision): Promise<void>;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* M2 (theokit-ai-first) — read a TheoKit agent endpoint's `UIMessageStream` SSE `Response`
|
|
277
|
-
* into reconstructed assistant `UIMessage`s, reusing the `ai` package's own consumer
|
|
278
|
-
* primitives (`parseJsonEventStream` + `readUIMessageStream`) — the exact path
|
|
279
|
-
* `@ai-sdk/react`'s `useChat` runs internally. No reinvented wire parser (Rule 9).
|
|
280
|
-
*
|
|
281
|
-
* `ai` is an OPTIONAL peer dependency, so it is imported dynamically: an app that never
|
|
282
|
-
* calls an agent never pays for it, and importing `theokit/client` does not hard-require
|
|
283
|
-
* `ai` (mirrors how the agent runtime dynamically imports `@theokit/sdk`). An agent app
|
|
284
|
-
* always has `ai` installed (it is the UIMessageStream consumer).
|
|
285
|
-
*
|
|
286
|
-
* `onMessage` is invoked on every reconstruction step with the latest snapshot of the
|
|
287
|
-
* assistant message, so a caller (the `useAgent` hook) can render streaming updates.
|
|
288
|
-
*/
|
|
289
|
-
declare function consumeUIMessageStream(response: Response, onMessage: (message: UIMessage) => void): Promise<void>;
|
|
290
|
-
/**
|
|
291
|
-
* M41 (ADR-0050 D3) — the reusable middle piece: a UIMessageStream SSE `Response` →
|
|
292
|
-
* `ReadableStream<UIMessageChunk>`, reusing `ai`'s own `parseJsonEventStream` (the exact primitive
|
|
293
|
-
* `useChat` runs). This is precisely what a `ChatTransport.sendMessages` returns, so `HttpTransport`
|
|
294
|
-
* builds on it directly (no reinvented wire parser — Rule 9). A body-less response yields an empty stream.
|
|
295
|
-
*/
|
|
296
|
-
declare function responseToChunkStream(response: Response): Promise<ReadableStream<UIMessageChunk>>;
|
|
297
|
-
/**
|
|
298
|
-
* M41 (ADR-0050 D6) — read a `ReadableStream<UIMessageChunk>` into reconstructed assistant
|
|
299
|
-
* `UIMessage`s via `ai`'s `readUIMessageStream`. Shared by `consumeUIMessageStream` (Response path)
|
|
300
|
-
* and the framework-agnostic `AgentClient` store (transport path). `onMessage` fires on every
|
|
301
|
-
* reconstruction step so a caller can render streaming updates.
|
|
302
|
-
*/
|
|
303
|
-
declare function consumeChunkStream(stream: ReadableStream<UIMessageChunk>, onMessage: (message: UIMessage) => void): Promise<void>;
|
|
304
|
-
|
|
305
|
-
export { AgentClient, type AgentClientHandle, type AgentClientState, type AgentTransport, type ApprovalDecision, type ChannelPushSource, ChannelTransport, type ChannelTransportOptions, type ChannelTurnHandlers, type CreateAgentClientOptions, type HeadersResolver, HttpTransport, type HttpTransportOptions, type InProcessApprovalRequestLike, type InProcessAwaitApproval, type InProcessRunInput, type InProcessRunner, InProcessTransport, type InProcessTransportOptions, type RequestContext, type UseAgentStatus, consumeChunkStream, consumeUIMessageStream, createAgentClient, responseToChunkStream };
|
|
51
|
+
export { type AgentClientHandle, type CreateAgentClientOptions, createAgentClient };
|
package/dist/client/core.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
createAgentClient
|
|
3
|
+
} from "../chunk-WDGYCBNI.js";
|
|
4
|
+
import "../chunk-XTHN6JBX.js";
|
|
5
|
+
|
|
6
|
+
// src/client/core.ts
|
|
7
|
+
import { AgentClient } from "@theokit/agents/client";
|
|
8
|
+
import { HttpTransport } from "@theokit/agents/client";
|
|
9
|
+
import { InProcessTransport } from "@theokit/agents/client";
|
|
10
|
+
import { ChannelTransport } from "@theokit/agents/client";
|
|
11
|
+
import {
|
|
7
12
|
consumeUIMessageStream,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "
|
|
11
|
-
import "../chunk-DGUM43GV.js";
|
|
13
|
+
responseToChunkStream,
|
|
14
|
+
consumeChunkStream
|
|
15
|
+
} from "@theokit/agents/client";
|
|
12
16
|
export {
|
|
13
17
|
AgentClient,
|
|
14
18
|
ChannelTransport,
|
package/dist/client/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":["../../src/client/core.ts"],"mappings":";;;;;;AAYA,SAAS,mBAAmB;AAK5B,SAAS,qBAAqB;AAE9B,SAAS,0BAA0B;AAQnC,SAAS,wBAAwB;AAQjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { T as TheoErrorEnvelope } from '../error-envelope-BsNzzAV5.js';
|
|
3
3
|
export { FetchOptionsLike, Fetcher, QueryKey, UseTheoQueryConfig, buildUseTheoQueryConfig, stableQueryKey } from '../react-query/index.js';
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
|
|
4
|
+
export { AgentClient, AgentClientState, AgentHandle, AgentTransport, ApprovalDecision, ChannelPushSource, ChannelTransport, ChannelTransportOptions, ChannelTurnHandlers, HttpTransport, HttpTransportOptions, InProcessApprovalRequestLike, InProcessAwaitApproval, InProcessRunInput, InProcessRunner, InProcessTransport, InProcessTransportOptions, RequestContext, agentHandle, consumeChunkStream, consumeUIMessageStream, isAgentHandle, responseToChunkStream } from '@theokit/agents/client';
|
|
5
|
+
export { UseAgentOptions, UseAgentReturn, UseAgentStatus, useAgent } from '@theokit/agents/client/react';
|
|
6
|
+
export { AgentClientHandle, CreateAgentClientOptions, createAgentClient } from './core.js';
|
|
7
7
|
import * as react from 'react';
|
|
8
8
|
import { LinkProps as LinkProps$1 } from 'react-router';
|
|
9
|
+
import 'ai';
|
|
9
10
|
|
|
10
11
|
/** Infer the response type from a route's handler return */
|
|
11
12
|
type InferResponse<T> = T extends {
|
|
@@ -117,96 +118,6 @@ interface Batcher {
|
|
|
117
118
|
}
|
|
118
119
|
declare function createBatcher(options: BatcherOptions): Batcher;
|
|
119
120
|
|
|
120
|
-
/**
|
|
121
|
-
* M47 (ADR-M47-2) — a typed, client-safe handle for an exposed agent.
|
|
122
|
-
*
|
|
123
|
-
* It carries ONLY the HTTP `path` at runtime plus phantom `input`/`toolNames` types (never populated) — so
|
|
124
|
-
* `useAgent(chat)` / `createAgentClient(chat…)` bind with NO magic string (the path is generated from the
|
|
125
|
-
* `@Expose` exposure, not hand-typed) and NO duplicated input type (the input type flows through the phantom
|
|
126
|
-
* generic, inferred from the agent's `.input()`). This mirrors tRPC/Hono's type-only handle: the client
|
|
127
|
-
* pulls the agent's TYPE via `import type`, never its server runtime. The generated `@theo/agents` module
|
|
128
|
-
* emits one `export const <name> = agentHandle('/api/agents/<name>')` per agent, typed with the phantoms.
|
|
129
|
-
*/
|
|
130
|
-
interface AgentHandle<TInput = unknown, TToolNames extends string = string> {
|
|
131
|
-
/** The agent's HTTP endpoint path (e.g. `/api/agents/chat`). The only serializable/runtime-bearing field. */
|
|
132
|
-
readonly path: string;
|
|
133
|
-
/**
|
|
134
|
-
* M47 — bind this agent in-process (TUI / single-process): wraps the app's runner in an
|
|
135
|
-
* {@link InProcessTransport}. `useAgent(chat.inProcess(run))` drives the SAME agent without HTTP.
|
|
136
|
-
*/
|
|
137
|
-
inProcess(run: InProcessRunner): InProcessTransport;
|
|
138
|
-
/**
|
|
139
|
-
* M47 — bind this agent over a push channel (Tauri desktop webview): wraps the source in a
|
|
140
|
-
* {@link ChannelTransport}. `createAgentClient(chat.channel(source))` drives the SAME agent.
|
|
141
|
-
*/
|
|
142
|
-
channel(source: ChannelPushSource): ChannelTransport;
|
|
143
|
-
/** Phantom — the agent's `input` type, carried for `useAgent(handle).send` inference. Never populated. */
|
|
144
|
-
readonly __input?: TInput;
|
|
145
|
-
/** Phantom — the agent's tool-name union, carried end-to-end. Never populated. */
|
|
146
|
-
readonly __toolNames?: TToolNames;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Build an {@link AgentHandle} from an agent's HTTP path. Types are supplied by the caller/codegen. The
|
|
150
|
-
* `inProcess`/`channel` binders are methods (dropped by `JSON.stringify`, so the `{ path }` core stays
|
|
151
|
-
* serializable + client-safe) that produce the M41 transports for the non-web surfaces.
|
|
152
|
-
*/
|
|
153
|
-
declare function agentHandle<TInput = unknown, TToolNames extends string = string>(path: string): AgentHandle<TInput, TToolNames>;
|
|
154
|
-
/** Narrow an unknown binding to an {@link AgentHandle} (has a string `path`, is not a transport). */
|
|
155
|
-
declare function isAgentHandle(value: unknown): value is AgentHandle;
|
|
156
|
-
|
|
157
|
-
interface UseAgentReturn<TInput = unknown, TToolNames extends string = string> {
|
|
158
|
-
/** The CURRENT turn's assistant messages (per-turn; reset each `send`). Back-compat since M41. */
|
|
159
|
-
messages: UIMessage[];
|
|
160
|
-
/**
|
|
161
|
-
* M46 — the full conversation to render: committed turns + the current turn's user + in-flight
|
|
162
|
-
* assistant, accumulated across sends with stable ids. Prefer this over hand-rolling a transcript
|
|
163
|
-
* from `messages`. Same shape on every surface (web/desktop/TUI) — it lives in the core store.
|
|
164
|
-
*/
|
|
165
|
-
thread: UIMessage[];
|
|
166
|
-
status: UseAgentStatus;
|
|
167
|
-
/** The last error, or `undefined`. */
|
|
168
|
-
error: Error | undefined;
|
|
169
|
-
/** Send a request; opens a new stream. Typed to the agent's `input` schema. */
|
|
170
|
-
send: (input: TInput) => void;
|
|
171
|
-
/** Abort an in-flight stream. */
|
|
172
|
-
abort: () => void;
|
|
173
|
-
/** Clear messages + error, back to idle. */
|
|
174
|
-
reset: () => void;
|
|
175
|
-
/** Settle a paused HITL approval (HTTP `POST /approve/<id>` for web; the inline callback in-process). */
|
|
176
|
-
approve: (approvalId: string, decision: ApprovalDecision) => Promise<void>;
|
|
177
|
-
/** Resume an interrupted stream (M37 durable transport for web; a no-op in-process). */
|
|
178
|
-
reconnect: () => void;
|
|
179
|
-
/**
|
|
180
|
-
* The union of tool names this agent can emit (M8), carried end-to-end from the `agent()` builder's
|
|
181
|
-
* accumulated tool-name type through the generated `@theo/agents` client. Type-only witness (never
|
|
182
|
-
* populated at runtime). Resolves to the literal union for builder agents, `string` otherwise.
|
|
183
|
-
*/
|
|
184
|
-
readonly __toolNames?: TToolNames;
|
|
185
|
-
}
|
|
186
|
-
interface UseAgentOptions {
|
|
187
|
-
/**
|
|
188
|
-
* Extra request headers (e.g., auth) — applied when a string path builds an `HttpTransport`. Read on
|
|
189
|
-
* EVERY request, so a value that changes across renders (a rotating JWT) is never sent stale.
|
|
190
|
-
*/
|
|
191
|
-
headers?: Record<string, string>;
|
|
192
|
-
/** Override fetch (primarily for tests) — captured when a string path builds an `HttpTransport`. */
|
|
193
|
-
fetch?: typeof fetch;
|
|
194
|
-
/**
|
|
195
|
-
* M43 — per-request context attached uniformly to EVERY transport (`headers` → HTTP request headers;
|
|
196
|
-
* `metadata` → the in-process runner / Tauri invoke). A value OR a resolver evaluated on every
|
|
197
|
-
* send/reconnect, so a rotating token/tenant is never stale.
|
|
198
|
-
*/
|
|
199
|
-
context?: RequestContext | (() => RequestContext | undefined);
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Bind to an agent by endpoint path (`/api/agents/<name>`), by a typed {@link AgentHandle} (M47 — the
|
|
203
|
-
* generated `chat` handle; kills the magic string + duplicated input type), or by an explicit
|
|
204
|
-
* {@link AgentTransport}. Prefer the generated `useAgent` from `@theo/agents` (typed by agent name or
|
|
205
|
-
* handle); this base accepts all three. The store is created once per binding identity — memoize a
|
|
206
|
-
* transport before passing it.
|
|
207
|
-
*/
|
|
208
|
-
declare function useAgent<TInput = unknown>(binding: string | AgentHandle<TInput> | AgentTransport, options?: UseAgentOptions): UseAgentReturn<TInput>;
|
|
209
|
-
|
|
210
121
|
type PrefetchBehavior = 'none' | 'intent' | 'viewport';
|
|
211
122
|
interface LinkProps extends LinkProps$1 {
|
|
212
123
|
/** Prefetch strategy. Default: 'intent' (on hover + focus). */
|
|
@@ -264,7 +175,7 @@ interface MetadataProps {
|
|
|
264
175
|
/** Custom meta tags rendered as children */
|
|
265
176
|
children?: React.ReactNode;
|
|
266
177
|
}
|
|
267
|
-
declare function Metadata(props: MetadataProps): react.JSX.Element;
|
|
178
|
+
declare function Metadata(props: Readonly<MetadataProps>): react.JSX.Element;
|
|
268
179
|
|
|
269
180
|
/**
|
|
270
181
|
* <Image> — optimized image component with lazy loading.
|
|
@@ -302,7 +213,7 @@ interface ImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
|
|
|
302
213
|
/** If true, loading="eager" — use for above-the-fold images. */
|
|
303
214
|
priority?: boolean;
|
|
304
215
|
}
|
|
305
|
-
declare function Image({ priority, loading, decoding, ...props }: ImageProps): react.JSX.Element;
|
|
216
|
+
declare function Image({ priority, loading, decoding, ...props }: Readonly<ImageProps>): react.JSX.Element;
|
|
306
217
|
|
|
307
218
|
/**
|
|
308
219
|
* M30 (ADR-0041) — client host for MCP App `ui://` resources.
|
|
@@ -354,4 +265,4 @@ declare function mountMcpApp(container: HTMLElement, resource: {
|
|
|
354
265
|
html: string;
|
|
355
266
|
}, opts: McpAppHostOptions): McpAppHandle;
|
|
356
267
|
|
|
357
|
-
export { type
|
|
268
|
+
export { type BatchRequest, type BatchResponse, type BatchTransport, type Batcher, type BatcherOptions, type CreateAppClientOptions, type GuestMessage, Image, type ImageProps, type InferBody, type InferQuery, type InferResponse, Link, type LinkProps, MCP_APP_SANDBOX, type McpAppHandle, type McpAppHostOptions, Metadata, type MetadataProps, type PrefetchBehavior, TheoFetchError, type TheoFetchOptions, createAppClient, createBatcher, createGuestMessageHandler, mountMcpApp, theoFetch };
|
package/dist/client/index.js
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
HttpTransport,
|
|
5
|
-
InProcessTransport,
|
|
6
|
-
consumeChunkStream,
|
|
7
|
-
consumeUIMessageStream,
|
|
8
|
-
createAgentClient,
|
|
9
|
-
responseToChunkStream
|
|
10
|
-
} from "../chunk-KPRJS3II.js";
|
|
2
|
+
createAgentClient
|
|
3
|
+
} from "../chunk-WDGYCBNI.js";
|
|
11
4
|
import {
|
|
12
5
|
buildUseTheoQueryConfig,
|
|
13
6
|
stableQueryKey
|
|
14
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-ANS4ELRH.js";
|
|
15
8
|
import {
|
|
16
9
|
HTTP_METHOD_LOWERCASE
|
|
17
|
-
} from "../chunk-
|
|
18
|
-
import "../chunk-
|
|
10
|
+
} from "../chunk-C34PMLSN.js";
|
|
11
|
+
import "../chunk-XTHN6JBX.js";
|
|
19
12
|
|
|
20
13
|
// src/client/theo-fetch.ts
|
|
21
14
|
import superjson from "superjson";
|
|
@@ -394,62 +387,21 @@ function createAppClient(baseUrlOrOptions, legacyFetchImpl) {
|
|
|
394
387
|
return makeProxy({ segments: [], baseUrl, fetchImpl });
|
|
395
388
|
}
|
|
396
389
|
|
|
397
|
-
// src/client/
|
|
398
|
-
import {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
return typeof value === "object" && value !== null && typeof value.path === "string" && typeof value.sendMessages !== "function";
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// src/client/use-agent.ts
|
|
413
|
-
function useAgent(binding, options = {}) {
|
|
414
|
-
const optionsRef = useRef(options);
|
|
415
|
-
optionsRef.current = options;
|
|
416
|
-
let api;
|
|
417
|
-
if (typeof binding === "string") api = binding;
|
|
418
|
-
else if (isAgentHandle(binding)) api = binding.path;
|
|
419
|
-
const bindingIdentity = api ?? binding;
|
|
420
|
-
const client = useMemo(
|
|
421
|
-
() => new AgentClient(
|
|
422
|
-
api !== void 0 ? new HttpTransport({
|
|
423
|
-
api,
|
|
424
|
-
headers: () => optionsRef.current.headers,
|
|
425
|
-
fetch: optionsRef.current.fetch
|
|
426
|
-
}) : binding,
|
|
427
|
-
// M43 — resolve context live from the ref each send/reconnect (never stale). A value or a resolver.
|
|
428
|
-
() => {
|
|
429
|
-
const ctx = optionsRef.current.context;
|
|
430
|
-
return typeof ctx === "function" ? ctx() : ctx;
|
|
431
|
-
}
|
|
432
|
-
),
|
|
433
|
-
// bindingIdentity captures api/binding; options resolve live via optionsRef (rebuild would drop messages).
|
|
434
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
435
|
-
[bindingIdentity]
|
|
436
|
-
);
|
|
437
|
-
const state = useSyncExternalStore(client.subscribe, client.getSnapshot, client.getSnapshot);
|
|
438
|
-
return {
|
|
439
|
-
messages: state.messages,
|
|
440
|
-
thread: state.thread,
|
|
441
|
-
status: state.status,
|
|
442
|
-
error: state.error,
|
|
443
|
-
send: client.send,
|
|
444
|
-
abort: client.abort,
|
|
445
|
-
reset: client.reset,
|
|
446
|
-
approve: client.approve,
|
|
447
|
-
reconnect: client.reconnect
|
|
448
|
-
};
|
|
449
|
-
}
|
|
390
|
+
// src/client/index.ts
|
|
391
|
+
import {
|
|
392
|
+
consumeUIMessageStream,
|
|
393
|
+
responseToChunkStream,
|
|
394
|
+
consumeChunkStream
|
|
395
|
+
} from "@theokit/agents/client";
|
|
396
|
+
import { useAgent } from "@theokit/agents/client/react";
|
|
397
|
+
import { agentHandle, isAgentHandle } from "@theokit/agents/client";
|
|
398
|
+
import { HttpTransport } from "@theokit/agents/client";
|
|
399
|
+
import { InProcessTransport } from "@theokit/agents/client";
|
|
400
|
+
import { ChannelTransport } from "@theokit/agents/client";
|
|
401
|
+
import { AgentClient } from "@theokit/agents/client";
|
|
450
402
|
|
|
451
403
|
// src/client/link.tsx
|
|
452
|
-
import { useRef
|
|
404
|
+
import { useRef, useCallback, useEffect } from "react";
|
|
453
405
|
import { Link as RouterLink } from "react-router";
|
|
454
406
|
import { jsx } from "react/jsx-runtime";
|
|
455
407
|
var prefetched = /* @__PURE__ */ new Set();
|
|
@@ -473,7 +425,7 @@ function Link({
|
|
|
473
425
|
onFocus,
|
|
474
426
|
...rest
|
|
475
427
|
}) {
|
|
476
|
-
const ref =
|
|
428
|
+
const ref = useRef(null);
|
|
477
429
|
const handleIntent = useCallback(
|
|
478
430
|
(event) => {
|
|
479
431
|
if (prefetch === "intent") {
|