@makaio/framework 1.0.0-dev-1781022866275 → 1.0.0-dev-1781023871421
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/.makaio-build.json +5 -0
- package/dist/account-identity-DT5NOtFi.mjs +1 -0
- package/dist/adapter-C1eI-fGV.mjs +1 -0
- package/dist/adapters/acp-client/index.d.mts +6208 -0
- package/dist/adapters/acp-client/index.mjs +3 -0
- package/dist/adapters/config/index.d.mts +429 -0
- package/dist/adapters/config/index.mjs +1 -0
- package/dist/adapters/index.d.mts +4202 -0
- package/dist/adapters/index.mjs +18 -0
- package/dist/adapters/node.d.mts +263 -0
- package/dist/adapters/node.mjs +4 -0
- package/dist/adapters/stream-session/index.d.mts +1414 -0
- package/dist/adapters/stream-session/index.mjs +1 -0
- package/dist/adapters/stream-session/testing/index.d.mts +29 -0
- package/dist/adapters/stream-session/testing/index.mjs +1 -0
- package/dist/artifact-B3npq1cy.mjs +1 -0
- package/dist/base-orchestrator-wyumsn3b.d.mts +772 -0
- package/dist/bus/index.d.mts +3994 -0
- package/dist/bus/index.mjs +1 -0
- package/dist/bus-Caz3Jpbc.mjs +1 -0
- package/dist/bus-Hb-LGzgb.mjs +2 -0
- package/dist/capability-service-CJbmhfv9.mjs +1 -0
- package/dist/chunk-DTipWd-i.mjs +1 -0
- package/dist/chunk-cpUYaJdV.mjs +1 -0
- package/dist/cleanEnvForAdapter-KkYzQa1f.mjs +1 -0
- package/dist/client-bx74gm4R.mjs +1 -0
- package/dist/clients/index.d.mts +2639 -0
- package/dist/clients/index.mjs +2 -0
- package/dist/clients-namespace-GmSJpBUV.d.mts +332 -0
- package/dist/config-namespace-CPY9YsR8.d.mts +638 -0
- package/dist/config-namespace-ncYg2ct_.mjs +1 -0
- package/dist/contracts/adapter/index.d.mts +3 -0
- package/dist/contracts/adapter/index.mjs +1 -0
- package/dist/contracts/adapter/schemas/session-lineage.d.mts +2 -0
- package/dist/contracts/adapter/schemas/session-lineage.mjs +1 -0
- package/dist/contracts/artifact/index.d.mts +2 -0
- package/dist/contracts/artifact/index.mjs +1 -0
- package/dist/contracts/client/index.d.mts +3 -0
- package/dist/contracts/client/index.mjs +1 -0
- package/dist/contracts/common/index.d.mts +2 -0
- package/dist/contracts/common/index.mjs +1 -0
- package/dist/contracts/config/index.d.mts +455 -0
- package/dist/contracts/config/index.mjs +1 -0
- package/dist/contracts/extension/index.d.mts +4 -0
- package/dist/contracts/extension/index.mjs +1 -0
- package/dist/contracts/facet/index.d.mts +2 -0
- package/dist/contracts/facet/index.mjs +1 -0
- package/dist/contracts/harness/index.d.mts +2 -0
- package/dist/contracts/harness/index.mjs +1 -0
- package/dist/contracts/host/index.d.mts +2 -0
- package/dist/contracts/host/index.mjs +1 -0
- package/dist/contracts/index.d.mts +23046 -0
- package/dist/contracts/index.mjs +1 -0
- package/dist/contracts/materialization/index.d.mts +4 -0
- package/dist/contracts/materialization/index.mjs +1 -0
- package/dist/contracts/model-registry/index.d.mts +2 -0
- package/dist/contracts/model-registry/index.mjs +1 -0
- package/dist/contracts/native-session-supervisor/index.d.mts +2 -0
- package/dist/contracts/native-session-supervisor/index.mjs +1 -0
- package/dist/contracts/platform/index.d.mts +2 -0
- package/dist/contracts/platform/index.mjs +1 -0
- package/dist/contracts/provider/index.d.mts +3 -0
- package/dist/contracts/provider/index.mjs +1 -0
- package/dist/contracts/session/index.d.mts +3 -0
- package/dist/contracts/session/index.mjs +1 -0
- package/dist/contracts/shared/index.d.mts +2 -0
- package/dist/contracts/shared/index.mjs +1 -0
- package/dist/contracts/skill/index.d.mts +2 -0
- package/dist/contracts/skill/index.mjs +1 -0
- package/dist/contracts/telemetry/index.d.mts +2 -0
- package/dist/contracts/telemetry/index.mjs +1 -0
- package/dist/contracts/timeout/index.d.mts +2 -0
- package/dist/contracts/timeout/index.mjs +1 -0
- package/dist/contracts/toast/index.d.mts +198 -0
- package/dist/contracts/toast/index.mjs +1 -0
- package/dist/contracts/variant/index.d.mts +2 -0
- package/dist/contracts/variant/index.mjs +1 -0
- package/dist/core/index.d.mts +1263 -0
- package/dist/core/index.mjs +1 -0
- package/dist/credential-ref-YWQQENEo.mjs +1 -0
- package/dist/cursor-storage-CtVJ3JzB.mjs +1 -0
- package/dist/definition-BLCdXGzh.d.mts +383 -0
- package/dist/definition-CrgHIpTK.d.mts +60 -0
- package/dist/definition-DZMXOnjX.mjs +1 -0
- package/dist/definition-pkJ6szUl.d.mts +158 -0
- package/dist/drizzle-Eq8W1EbD.mjs +1 -0
- package/dist/event-Ca2yUf5i.mjs +1 -0
- package/dist/execution-target-CRPTfZlc.mjs +1 -0
- package/dist/extension-C-4BHMRI.mjs +1 -0
- package/dist/extension-CpIUgBKI.mjs +1 -0
- package/dist/extension-namespace-cMh_mMiL.mjs +1 -0
- package/dist/facet-BuwhrThl.mjs +1 -0
- package/dist/filesystem-service-B8rhBRgB.mjs +1 -0
- package/dist/filesystem-service-p_iJVHd4.d.mts +66 -0
- package/dist/git/index.d.mts +210 -0
- package/dist/git/index.mjs +18 -0
- package/dist/globby-rtWVaFHv.mjs +41 -0
- package/dist/handlers-CkTsQLra.mjs +41 -0
- package/dist/harness-BRCMcvQN.mjs +1 -0
- package/dist/hooks/index.d.mts +423 -0
- package/dist/hooks/index.mjs +1 -0
- package/dist/host-Br9VuOyr.mjs +1 -0
- package/dist/identity-Cz2IeEtm.mjs +1 -0
- package/dist/index-472sOmsW.d.mts +218 -0
- package/dist/index-8SZkg7s6.d.mts +353 -0
- package/dist/index-B3PK4FIn.d.mts +5116 -0
- package/dist/index-B80L4YqA.d.mts +180 -0
- package/dist/index-BFg9BUpx.d.mts +355 -0
- package/dist/index-BGfWS6GE.d.mts +483 -0
- package/dist/index-BVgfS-AJ.d.mts +109 -0
- package/dist/index-B_zQC98V.d.mts +995 -0
- package/dist/index-Bh_Ne7LF.d.mts +1008 -0
- package/dist/index-Bvb2mMH6.d.mts +1730 -0
- package/dist/index-CCGVh9BF2.d.mts +749 -0
- package/dist/index-CGmcS0Ma.d.mts +412 -0
- package/dist/index-CHQ1SqT0.d.mts +117 -0
- package/dist/index-CLpjm52M.d.mts +183 -0
- package/dist/index-Caig6TeF.d.mts +6746 -0
- package/dist/index-CelJCBjk.d.mts +2992 -0
- package/dist/index-ChunCFu4.d.mts +11 -0
- package/dist/index-Cm0dUkWL.d.mts +4651 -0
- package/dist/index-CokQYGVP.d.mts +184 -0
- package/dist/index-Cs0kZXIz2.d.mts +37 -0
- package/dist/index-D5d5HeWI2.d.mts +259 -0
- package/dist/index-D90OmGmV.d.mts +389 -0
- package/dist/index-D9MwJ2Q8.d.mts +67 -0
- package/dist/index-DANINzMu.d.mts +40 -0
- package/dist/index-DBw-89vC2.d.mts +3640 -0
- package/dist/index-DGBu6bHi2.d.mts +438 -0
- package/dist/index-DKC62dY5.d.mts +146 -0
- package/dist/index-DKia0MX1.d.mts +43 -0
- package/dist/index-DMKnON5s.d.mts +28 -0
- package/dist/index-DUaw0Dw8.d.mts +14747 -0
- package/dist/index-De3kPhlN.d.mts +72 -0
- package/dist/index-L4GjJDKb.d.mts +822 -0
- package/dist/index-U-A8eyGT.d.mts +1490 -0
- package/dist/index-eemAKwsB.d.mts +362 -0
- package/dist/index-mNec7V-9.d.mts +1075 -0
- package/dist/index-soFznFCy2.d.mts +89 -0
- package/dist/index-vtXJuwrz.d.mts +40 -0
- package/dist/index-x_lVDp_J.d.mts +134 -0
- package/dist/json-value-CmhSGMLv.mjs +1 -0
- package/dist/kernel/cli/index.d.mts +143 -0
- package/dist/kernel/cli/index.mjs +1 -0
- package/dist/kernel/cli/schemas.d.mts +64 -0
- package/dist/kernel/cli/schemas.mjs +1 -0
- package/dist/kernel/extension/index.d.mts +2 -0
- package/dist/kernel/extension/index.mjs +1 -0
- package/dist/kernel/index.d.mts +296 -0
- package/dist/kernel/index.mjs +1 -0
- package/dist/kernel/namespace/index.d.mts +2 -0
- package/dist/kernel/namespace/index.mjs +1 -0
- package/dist/kernel/observability/index.d.mts +2 -0
- package/dist/kernel/observability/index.mjs +1 -0
- package/dist/kernel/providers/index.d.mts +2 -0
- package/dist/kernel/providers/index.mjs +1 -0
- package/dist/kernel/window/index.d.mts +2 -0
- package/dist/kernel/window/index.mjs +1 -0
- package/dist/materialization-CuUBu4XI.mjs +1 -0
- package/dist/model-registry-CfXytvzx.mjs +1 -0
- package/dist/model-registry-Scn_MC2d.mjs +1 -0
- package/dist/namespace-5QQqbF-B.d.mts +3133 -0
- package/dist/namespace-BM7Djng9.d.mts +189 -0
- package/dist/namespace-BoD94mrN.mjs +1 -0
- package/dist/namespace-BwzZJqTV.mjs +1 -0
- package/dist/namespace-CFLAmQfh.mjs +1 -0
- package/dist/namespace-CTm3nEvh.d.mts +51 -0
- package/dist/namespace-CaaNnKcR.d.mts +921 -0
- package/dist/namespace-CaoZ3S78.d.mts +43 -0
- package/dist/namespace-CxhsoFUP.d.mts +607 -0
- package/dist/namespace-DD8Oiqo7.d.mts +580 -0
- package/dist/namespace-DLovh2Ws.d.mts +1313 -0
- package/dist/namespace-DgqkaOVu.d.mts +768 -0
- package/dist/namespace-DkRgbZYn.mjs +1 -0
- package/dist/namespace-Dr8K0MCp.d.mts +2047 -0
- package/dist/namespace-DuXK5AYN.mjs +1 -0
- package/dist/namespace-EQniz-Aw.d.mts +142 -0
- package/dist/namespace-IV1QK__V.d.mts +159 -0
- package/dist/namespace-LViZ-EQk.mjs +1 -0
- package/dist/namespace-TyiTsLFv.d.mts +3020 -0
- package/dist/namespace-Yna5-Pws.mjs +1 -0
- package/dist/namespace-xcmbQlxh.mjs +1 -0
- package/dist/native-session-supervisor-B1TnaPUF.mjs +1 -0
- package/dist/node/bus-server/index.d.mts +178 -0
- package/dist/node/bus-server/index.mjs +1 -0
- package/dist/node/bus-server/server-lifecycle.d.mts +2 -0
- package/dist/node/bus-server/server-lifecycle.mjs +1 -0
- package/dist/node/machine-identity/index.d.mts +85 -0
- package/dist/node/machine-identity/index.mjs +3 -0
- package/dist/node/transports/index.d.mts +1945 -0
- package/dist/node/transports/index.mjs +2 -0
- package/dist/orchestrator-shared-CIDiFJMD.mjs +1 -0
- package/dist/orchestrator-shared-Dfa7FMyw.d.mts +249 -0
- package/dist/package-DKVlsMP3.mjs +1 -0
- package/dist/platform-DZ7z-wXD.mjs +1 -0
- package/dist/profile-6ynCD5k3.mjs +1 -0
- package/dist/provider-context-CK6B4X_8.mjs +1 -0
- package/dist/providers/index.d.mts +135 -0
- package/dist/providers/index.mjs +1 -0
- package/dist/providers-namespace-DSEpli4A.d.mts +583 -0
- package/dist/providers-u8i15co9.mjs +1 -0
- package/dist/schema-CoyE6mPt.mjs +1 -0
- package/dist/schema-M5YTvSAG.d.mts +949 -0
- package/dist/schema-e0wU_lcV.mjs +1 -0
- package/dist/schema-introspection-Dn1jWQs1.mjs +1 -0
- package/dist/schemas-Bd0OjRQf.d.mts +46 -0
- package/dist/schemas-C46QfKzv.d.mts +459 -0
- package/dist/schemas-CDBSjg7o.d.mts +237 -0
- package/dist/schemas-CR1Rripy.mjs +1 -0
- package/dist/schemas-CVvwIfG4.mjs +1 -0
- package/dist/schemas-CaLhkkLn.mjs +1 -0
- package/dist/schemas-ClOOT1W6.d.mts +174 -0
- package/dist/schemas-DATniTHb.d.mts +182 -0
- package/dist/schemas-DE-GNmSD.mjs +1 -0
- package/dist/schemas-DVF1A4DF.d.mts +160 -0
- package/dist/schemas-DaRSfYLf.d.mts +73 -0
- package/dist/schemas-DiYVzG6e.d.mts +315 -0
- package/dist/schemas-hSrzflwZ.mjs +1 -0
- package/dist/schemas-j7ivZ2HI.d.mts +944 -0
- package/dist/schemas-jFe1AuI-.mjs +1 -0
- package/dist/schemas-wg_6PAdV.d.mts +153 -0
- package/dist/scoped-bus-04pwo1uM.mjs +1 -0
- package/dist/server-lifecycle-FXTPW39-.mjs +1 -0
- package/dist/server-lifecycle-YoSGFGnU.d.mts +160 -0
- package/dist/service-base/index.d.mts +98 -0
- package/dist/service-base/index.mjs +1 -0
- package/dist/services/adapter-runtime/index.d.mts +4 -0
- package/dist/services/adapter-runtime/index.mjs +1 -0
- package/dist/services/adapter-runtime/namespace.d.mts +2 -0
- package/dist/services/adapter-runtime/namespace.mjs +1 -0
- package/dist/services/adapter-runtime/schemas.d.mts +2 -0
- package/dist/services/adapter-runtime/schemas.mjs +1 -0
- package/dist/services/adapter-subsystem/index.d.mts +3 -0
- package/dist/services/adapter-subsystem/index.mjs +1 -0
- package/dist/services/adapter-subsystem/namespace.d.mts +2 -0
- package/dist/services/adapter-subsystem/namespace.mjs +1 -0
- package/dist/services/agent-runtime/index.d.mts +3 -0
- package/dist/services/agent-runtime/index.mjs +1 -0
- package/dist/services/agent-runtime/namespace.d.mts +2 -0
- package/dist/services/agent-runtime/namespace.mjs +1 -0
- package/dist/services/agent-runtime/schemas.d.mts +2 -0
- package/dist/services/agent-runtime/schemas.mjs +1 -0
- package/dist/services/capability/index.d.mts +2 -0
- package/dist/services/capability/index.mjs +1 -0
- package/dist/services/cli-detection/namespace.d.mts +56 -0
- package/dist/services/cli-detection/namespace.mjs +1 -0
- package/dist/services/codebase/index.d.mts +3 -0
- package/dist/services/codebase/index.mjs +1 -0
- package/dist/services/codebase/namespace.d.mts +2 -0
- package/dist/services/codebase/namespace.mjs +1 -0
- package/dist/services/codebase/schemas.d.mts +2 -0
- package/dist/services/codebase/schemas.mjs +1 -0
- package/dist/services/compression/index.d.mts +3 -0
- package/dist/services/compression/index.mjs +1 -0
- package/dist/services/compression/namespace.d.mts +2 -0
- package/dist/services/compression/namespace.mjs +1 -0
- package/dist/services/compression/schemas.d.mts +2 -0
- package/dist/services/compression/schemas.mjs +1 -0
- package/dist/services/context-rules/index.d.mts +412 -0
- package/dist/services/context-rules/index.mjs +1 -0
- package/dist/services/credential-change/index.d.mts +17 -0
- package/dist/services/credential-change/index.mjs +1 -0
- package/dist/services/definition/index.d.mts +2 -0
- package/dist/services/definition/index.mjs +1 -0
- package/dist/services/definition/namespace.d.mts +71 -0
- package/dist/services/definition/namespace.mjs +1 -0
- package/dist/services/definition/schemas.d.mts +38 -0
- package/dist/services/definition/schemas.mjs +1 -0
- package/dist/services/dialog/namespace.d.mts +105 -0
- package/dist/services/dialog/namespace.mjs +1 -0
- package/dist/services/dialog/schemas.d.mts +109 -0
- package/dist/services/dialog/schemas.mjs +1 -0
- package/dist/services/execution-target/index.d.mts +4 -0
- package/dist/services/execution-target/index.mjs +1 -0
- package/dist/services/execution-target/namespace.d.mts +2 -0
- package/dist/services/execution-target/namespace.mjs +1 -0
- package/dist/services/execution-target/schemas.d.mts +2 -0
- package/dist/services/execution-target/schemas.mjs +1 -0
- package/dist/services/filesystem/index.d.mts +3 -0
- package/dist/services/filesystem/index.mjs +1 -0
- package/dist/services/filesystem/namespace.d.mts +432 -0
- package/dist/services/filesystem/namespace.mjs +1 -0
- package/dist/services/filesystem/schemas.d.mts +240 -0
- package/dist/services/filesystem/schemas.mjs +1 -0
- package/dist/services/git/namespace.d.mts +1163 -0
- package/dist/services/git/namespace.mjs +1 -0
- package/dist/services/git/schemas.d.mts +932 -0
- package/dist/services/git/schemas.mjs +1 -0
- package/dist/services/harness/index.d.mts +861 -0
- package/dist/services/harness/index.mjs +1 -0
- package/dist/services/harness/storage/schema.d.mts +424 -0
- package/dist/services/harness/storage/schema.mjs +1 -0
- package/dist/services/index.d.mts +6185 -0
- package/dist/services/index.mjs +1 -0
- package/dist/services/local-notification/index.d.mts +25 -0
- package/dist/services/local-notification/index.mjs +1 -0
- package/dist/services/local-notification/namespace.d.mts +73 -0
- package/dist/services/local-notification/namespace.mjs +1 -0
- package/dist/services/local-notification/schemas.d.mts +88 -0
- package/dist/services/local-notification/schemas.mjs +1 -0
- package/dist/services/log-import/browser.d.mts +3 -0
- package/dist/services/log-import/browser.mjs +1 -0
- package/dist/services/log-import/index.d.mts +274 -0
- package/dist/services/log-import/index.mjs +2 -0
- package/dist/services/log-import/log-import.d.mts +3 -0
- package/dist/services/log-import/log-import.mjs +1 -0
- package/dist/services/log-import/namespace.d.mts +327 -0
- package/dist/services/log-import/namespace.mjs +1 -0
- package/dist/services/log-import/schemas.d.mts +217 -0
- package/dist/services/log-import/schemas.mjs +1 -0
- package/dist/services/model-registry/index.d.mts +2 -0
- package/dist/services/model-registry/index.mjs +1 -0
- package/dist/services/preferences/index.d.mts +3 -0
- package/dist/services/preferences/index.mjs +1 -0
- package/dist/services/preferences/schemas.d.mts +2 -0
- package/dist/services/preferences/schemas.mjs +1 -0
- package/dist/services/preferences/storage-namespace.d.mts +3 -0
- package/dist/services/preferences/storage-namespace.mjs +1 -0
- package/dist/services/provider-context/index.d.mts +2 -0
- package/dist/services/provider-context/index.mjs +1 -0
- package/dist/services/provider-runtime/index.d.mts +136 -0
- package/dist/services/provider-runtime/index.mjs +1 -0
- package/dist/services/session/handlers/index.d.mts +2 -0
- package/dist/services/session/handlers/index.mjs +1 -0
- package/dist/services/session/index.d.mts +10 -0
- package/dist/services/session/index.mjs +1 -0
- package/dist/services/session/messages/namespace.d.mts +2 -0
- package/dist/services/session/messages/namespace.mjs +1 -0
- package/dist/services/session/orchestrator-testing/index.d.mts +2 -0
- package/dist/services/session/orchestrator-testing/index.mjs +1 -0
- package/dist/services/session/session-events/namespace.d.mts +2 -0
- package/dist/services/session/session-events/namespace.mjs +1 -0
- package/dist/services/session/storage/namespace.d.mts +2 -0
- package/dist/services/session/storage/namespace.mjs +1 -0
- package/dist/services/session/storage/schema.d.mts +2 -0
- package/dist/services/session/storage/schema.mjs +1 -0
- package/dist/services/session/testing/index.d.mts +35 -0
- package/dist/services/session/testing/index.mjs +65 -0
- package/dist/services/session/testing/orchestrator-shared.d.mts +2 -0
- package/dist/services/session/testing/orchestrator-shared.mjs +1 -0
- package/dist/services/session/turns/namespace.d.mts +2 -0
- package/dist/services/session/turns/namespace.mjs +1 -0
- package/dist/services/session-editor/index.d.mts +119 -0
- package/dist/services/session-editor/index.mjs +1 -0
- package/dist/services/settings/index.d.mts +47 -0
- package/dist/services/settings/index.mjs +1 -0
- package/dist/services/settings/namespace.d.mts +663 -0
- package/dist/services/settings/namespace.mjs +1 -0
- package/dist/services/settings/storage/clients-namespace.d.mts +2 -0
- package/dist/services/settings/storage/clients-namespace.mjs +1 -0
- package/dist/services/settings/storage/extension-configs/namespace.d.mts +184 -0
- package/dist/services/settings/storage/extension-configs/namespace.mjs +1 -0
- package/dist/services/settings/storage/index.d.mts +4 -0
- package/dist/services/settings/storage/index.mjs +1 -0
- package/dist/services/settings/storage/providers-namespace.d.mts +2 -0
- package/dist/services/settings/storage/providers-namespace.mjs +1 -0
- package/dist/services/subagent/index.d.mts +2 -0
- package/dist/services/subagent/index.mjs +1 -0
- package/dist/services/subagent-template/index.d.mts +3 -0
- package/dist/services/subagent-template/index.mjs +1 -0
- package/dist/services/subagent-template/namespace.d.mts +2 -0
- package/dist/services/subagent-template/namespace.mjs +1 -0
- package/dist/services/subagent-template/schemas.d.mts +2 -0
- package/dist/services/subagent-template/schemas.mjs +1 -0
- package/dist/services/tool-approval/index.d.mts +2 -0
- package/dist/services/tool-approval/index.mjs +1 -0
- package/dist/services/tools/index.d.mts +2 -0
- package/dist/services/tools/index.mjs +1 -0
- package/dist/services/tray-menu/index.d.mts +4 -0
- package/dist/services/tray-menu/index.mjs +1 -0
- package/dist/services/tray-menu/namespace.d.mts +2 -0
- package/dist/services/tray-menu/namespace.mjs +1 -0
- package/dist/services/tray-menu/schemas.d.mts +2 -0
- package/dist/services/tray-menu/schemas.mjs +1 -0
- package/dist/services/turn/index.d.mts +2 -0
- package/dist/services/turn/index.mjs +1 -0
- package/dist/services/turn/namespace.d.mts +2 -0
- package/dist/services/turn/namespace.mjs +1 -0
- package/dist/services/turn/schemas.d.mts +335 -0
- package/dist/services/turn/schemas.mjs +1 -0
- package/dist/session-BoldSdNZ2.mjs +134 -0
- package/dist/session-DuVOYctZ.mjs +1 -0
- package/dist/session-lineage-CRsc9g1x.d.mts +65 -0
- package/dist/shared-DpOEfD8F.mjs +1 -0
- package/dist/shared-schemas-CPShiLNp.mjs +1 -0
- package/dist/skill-CQO4mDqK.mjs +1 -0
- package/dist/storage/drizzle/client.d.mts +78 -0
- package/dist/storage/drizzle/client.mjs +1 -0
- package/dist/storage/drizzle/index.d.mts +137 -0
- package/dist/storage/drizzle/index.mjs +1 -0
- package/dist/storage/handlers/drizzle/index.d.mts +2 -0
- package/dist/storage/handlers/drizzle/index.mjs +1 -0
- package/dist/storage/handlers/index.d.mts +33 -0
- package/dist/storage/handlers/index.mjs +1 -0
- package/dist/storage/index.d.mts +192 -0
- package/dist/storage/index.mjs +1 -0
- package/dist/storage-namespace-BXkoh5Sy.d.mts +221 -0
- package/dist/storage-namespace-DWsYLAXa.mjs +1 -0
- package/dist/storage-namespace-definition-Bkx5rSto.d.mts +17 -0
- package/dist/storage-namespace-definition-CqSdsuCC.mjs +1 -0
- package/dist/style.css +3782 -0
- package/dist/telemetry-CvdLBWuk.mjs +1 -0
- package/dist/testing/drizzle-harness.d.mts +130 -0
- package/dist/testing/drizzle-harness.mjs +1 -0
- package/dist/testing/index.d.mts +106 -0
- package/dist/testing/index.mjs +1 -0
- package/dist/timeout-XsYIOKrc.mjs +1 -0
- package/dist/tool-approval-service-BvZWhYZp.mjs +1 -0
- package/dist/tools/index.d.mts +835 -0
- package/dist/tools/index.mjs +1 -0
- package/dist/tools/testing/index.d.mts +53 -0
- package/dist/tools/testing/index.mjs +1 -0
- package/dist/tools-D-luYcDw.mjs +1431 -0
- package/dist/tray-menu-service-DuXq5k22.mjs +1 -0
- package/dist/types-BCMUtBj1.d.mts +1106 -0
- package/dist/types-C2Ob9zz_.d.mts +128 -0
- package/dist/types-CCdqjeuH.d.mts +262 -0
- package/dist/types-DZHvOc_Q.d.mts +305 -0
- package/dist/types-Dy3YTcTF.d.mts +6777 -0
- package/dist/types-MfJZ67e9.d.mts +315 -0
- package/dist/types-dyP-bXXE.d.mts +31 -0
- package/dist/ui-components/index.d.mts +2342 -0
- package/dist/ui-components/index.mjs +8 -0
- package/dist/ui-config-9bDRwFZr.mjs +1 -0
- package/dist/ui-hooks/index.d.mts +1915 -0
- package/dist/ui-hooks/index.mjs +1 -0
- package/dist/ui-kernel/index.d.mts +2793 -0
- package/dist/ui-kernel/index.mjs +1 -0
- package/dist/ui-kernel/pages/namespace.d.mts +88 -0
- package/dist/ui-kernel/pages/namespace.mjs +1 -0
- package/dist/ui-kernel/pages/schemas.d.mts +2 -0
- package/dist/ui-kernel/pages/schemas.mjs +1 -0
- package/dist/ui-views/index.d.mts +487 -0
- package/dist/ui-views/index.mjs +30 -0
- package/dist/utils/health-probe.d.mts +26 -0
- package/dist/utils/health-probe.mjs +1 -0
- package/dist/utils/index.d.mts +262 -0
- package/dist/utils/index.mjs +2 -0
- package/dist/utils/keychain.d.mts +31 -0
- package/dist/utils/keychain.mjs +1 -0
- package/dist/utils/project-manifest.d.mts +130 -0
- package/dist/utils/project-manifest.mjs +1 -0
- package/dist/utils/resolve-package-root.d.mts +12 -0
- package/dist/utils/resolve-package-root.mjs +1 -0
- package/dist/utils/scope-paths.d.mts +33 -0
- package/dist/utils/scope-paths.mjs +1 -0
- package/dist/utils/workspace-packages.d.mts +59 -0
- package/dist/utils/workspace-packages.mjs +1 -0
- package/dist/utils/workspace-root.d.mts +24 -0
- package/dist/utils/workspace-root.mjs +2 -0
- package/dist/variant-CT6XBP6T.mjs +1 -0
- package/dist/version-BeT3ASEe.mjs +1 -0
- package/dist/visibility-Cb62p9bv.mjs +1 -0
- package/dist/window-registry-CBcrGTv4.d.mts +130 -0
- package/dist/window-registry-DW-dKRjQ.mjs +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1414 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { EventMessagePayload, ScopedSubjectDefinition } from "@makaio/framework/core";
|
|
3
|
+
import { ScopedBus } from "@makaio/framework/bus";
|
|
4
|
+
import { AgentToolApproveRequest, AgentToolApproveResponse, McpSessionContext, SessionMessageBlock, ToolExecuteResult, ToolExecutionContextOverrides, ToolListItem } from "@makaio/framework/contracts";
|
|
5
|
+
import { AIAgent, AIAgentConnector, AIReasoningLevel as AIReasoningLevel$1, AgentCompleteEvent, AgentCompleteEventSchema, AgentStartedEvent, AgentStartedEvent as AgentStartedEvent$1, AgentStartedEventSchema, BaseAgentConnectorConfig, BaseConnectorSession, ConnectorSendMessageOptions, ErrorEvent, ErrorEvent as ErrorEvent$1, ErrorEventSchema, LedgerSessionContext, MessageHandle, MessageResult, NormalizedCallUsage, NormalizedMessageInput, ProceduralAgentConnector, ProceduralConnectorSession, ProceduralConnectorTurn, ToolApprovalContext, ToolCompletedEvent, ToolCompletedEvent as ToolCompletedEvent$1, ToolCompletedEventSchema, ToolStartedEvent, ToolStartedEvent as ToolStartedEvent$1, ToolStartedEventSchema, UserMessageQueue, WireSessionConfig, WireSessionSubjects } from "@makaio/framework/adapters";
|
|
6
|
+
|
|
7
|
+
//#region adapters/shared/stream-session/src/tool-handling/tool-result.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Shared tool result types and content bounding utility.
|
|
10
|
+
*
|
|
11
|
+
* These types and functions are identical across all stream-based adapter
|
|
12
|
+
* implementations and are extracted here to avoid duplication.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Tool-specific fields extracted from a normalized tool call.
|
|
16
|
+
*
|
|
17
|
+
* Identity context (agentId, adapterId, etc.) is intentionally excluded —
|
|
18
|
+
* the connector injects those when forwarding to the global bus.
|
|
19
|
+
*/
|
|
20
|
+
interface ToolCallPayload {
|
|
21
|
+
/** Name of the tool to call */
|
|
22
|
+
toolName: string;
|
|
23
|
+
/** Parsed arguments for the tool */
|
|
24
|
+
args: Record<string, unknown>;
|
|
25
|
+
/** Unique identifier for this tool call */
|
|
26
|
+
toolCallId: string;
|
|
27
|
+
}
|
|
28
|
+
declare const MAX_TOOL_RESULT_CONTENT_CHARS = 8000;
|
|
29
|
+
/**
|
|
30
|
+
* Bound tool result content before injecting it back into model context.
|
|
31
|
+
*
|
|
32
|
+
* Tool outputs (filesystem, grep, etc.) can be very large and cause
|
|
33
|
+
* context-window overflows in recursive tool-call turns. Keep full payload
|
|
34
|
+
* on emitted events, but cap what is sent back to the model.
|
|
35
|
+
* @param content - Serialized tool result payload
|
|
36
|
+
* @returns Content truncated to context-safe size
|
|
37
|
+
*/
|
|
38
|
+
declare function boundToolResultContent(content: string): string;
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region adapters/shared/stream-session/src/namespaces/schemas/tool-calls.d.ts
|
|
41
|
+
/**
|
|
42
|
+
* Public contract for a single tool-call function payload.
|
|
43
|
+
*
|
|
44
|
+
* Matches both the Anthropic ToolUseBlock.input structure and the
|
|
45
|
+
* OpenAI ChatCompletionMessageToolCall.Function structure.
|
|
46
|
+
*/
|
|
47
|
+
interface ToolCallFunction {
|
|
48
|
+
/** Name of the function to call. */
|
|
49
|
+
name: string;
|
|
50
|
+
/** JSON-encoded arguments for the function. */
|
|
51
|
+
arguments: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Public contract for a single tool call.
|
|
55
|
+
*
|
|
56
|
+
* Contains only the fields common to both Anthropic and OpenAI adapters.
|
|
57
|
+
* The Anthropic adapter extends this with `blockIndex`.
|
|
58
|
+
*/
|
|
59
|
+
interface ToolCall {
|
|
60
|
+
/** Unique identifier for this tool call. */
|
|
61
|
+
id: string;
|
|
62
|
+
/** Type of tool (always 'function' for now). */
|
|
63
|
+
type: 'function';
|
|
64
|
+
/** Function call details. */
|
|
65
|
+
function: ToolCallFunction;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Public contract for a tool-calls event.
|
|
69
|
+
*
|
|
70
|
+
* Emitted when the model requests tool / function execution.
|
|
71
|
+
*/
|
|
72
|
+
interface ToolCallsEvent {
|
|
73
|
+
/** Discriminator for tool call events. */
|
|
74
|
+
eventType: 'tool_calls';
|
|
75
|
+
/** Array of requested tool calls. */
|
|
76
|
+
toolCalls: ToolCall[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Schema for a single tool call function.
|
|
80
|
+
*
|
|
81
|
+
* Matches both the Anthropic ToolUseBlock.input structure and the
|
|
82
|
+
* OpenAI ChatCompletionMessageToolCall.Function structure.
|
|
83
|
+
*/
|
|
84
|
+
declare const ToolCallFunctionSchema: z.ZodObject<{
|
|
85
|
+
name: z.ZodString;
|
|
86
|
+
arguments: z.ZodString;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
/**
|
|
89
|
+
* Schema for a single tool call.
|
|
90
|
+
*
|
|
91
|
+
* Contains only the fields common to both Anthropic and OpenAI adapters.
|
|
92
|
+
* The Anthropic adapter extends this with `blockIndex` via `.extend()`.
|
|
93
|
+
*
|
|
94
|
+
* Adapter-specific schemas may extend this via `.extend()`.
|
|
95
|
+
*/
|
|
96
|
+
declare const ToolCallSchema: z.ZodObject<{
|
|
97
|
+
id: z.ZodString;
|
|
98
|
+
type: z.ZodLiteral<"function">;
|
|
99
|
+
function: z.ZodObject<{
|
|
100
|
+
name: z.ZodString;
|
|
101
|
+
arguments: z.ZodString;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
}, z.core.$strip>;
|
|
104
|
+
/**
|
|
105
|
+
* Schema for a tool calls event.
|
|
106
|
+
*
|
|
107
|
+
* Emitted when the model requests tool / function execution.
|
|
108
|
+
* Both adapters emit this event with the same structure, except the
|
|
109
|
+
* Anthropic adapter's individual `ToolCall` entries also carry `blockIndex`.
|
|
110
|
+
*/
|
|
111
|
+
declare const ToolCallsEventSchema: z.ZodObject<{
|
|
112
|
+
eventType: z.ZodLiteral<"tool_calls">;
|
|
113
|
+
toolCalls: z.ZodArray<z.ZodObject<{
|
|
114
|
+
id: z.ZodString;
|
|
115
|
+
type: z.ZodLiteral<"function">;
|
|
116
|
+
function: z.ZodObject<{
|
|
117
|
+
name: z.ZodString;
|
|
118
|
+
arguments: z.ZodString;
|
|
119
|
+
}, z.core.$strip>;
|
|
120
|
+
}, z.core.$strip>>;
|
|
121
|
+
}, z.core.$strip>;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region adapters/shared/stream-session/src/tool-handling/tool-approval.d.ts
|
|
124
|
+
/**
|
|
125
|
+
* Extract tool-specific fields from a normalized tool call.
|
|
126
|
+
*
|
|
127
|
+
* The `function.arguments` field is a JSON string assembled from streaming
|
|
128
|
+
* delta fragments. This function parses it to recover the structured args.
|
|
129
|
+
* @param toolCall - Normalized tool call from the stream-bridge tool_calls event
|
|
130
|
+
* @param adapterLabel - Short label used in error logs (e.g. 'AnthropicSdkAgent'). Defaults to 'Adapter'.
|
|
131
|
+
* @returns Tool-specific payload without identity context
|
|
132
|
+
*/
|
|
133
|
+
declare function extractToolCallPayload(toolCall: ToolCall, adapterLabel?: string): ToolCallPayload;
|
|
134
|
+
/**
|
|
135
|
+
* Transform a normalized tool call into an AgentToolApproveRequest.
|
|
136
|
+
*
|
|
137
|
+
* Combines the extracted tool payload with full adapter identity context.
|
|
138
|
+
* @param toolCall - Normalized tool call from the stream-bridge tool_calls event
|
|
139
|
+
* @param context - Adapter context providing identity fields
|
|
140
|
+
* @param adapterLabel - Short label used in error logs (e.g. 'AnthropicSdkAgent'). Defaults to 'Adapter'.
|
|
141
|
+
* @returns Global tool approval request ready for AgentSubjects.toolApprove
|
|
142
|
+
*/
|
|
143
|
+
declare function toGlobalToolApproval(toolCall: ToolCall, context: ToolApprovalContext, adapterLabel?: string): AgentToolApproveRequest;
|
|
144
|
+
/**
|
|
145
|
+
* Apply approved argument overrides directly to the tool call payload.
|
|
146
|
+
*
|
|
147
|
+
* Approval handlers can transform tool input via `updatedInput`. When present,
|
|
148
|
+
* the modified args must replace the original JSON string before execution.
|
|
149
|
+
* @param toolCall - Tool call object to update in place
|
|
150
|
+
* @param approval - Allow-branch approval response from AgentSubjects.toolApprove
|
|
151
|
+
*/
|
|
152
|
+
declare function applyApprovedArgs(toolCall: ToolCall, approval: Extract<AgentToolApproveResponse, {
|
|
153
|
+
action: 'allow';
|
|
154
|
+
}>): void;
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region adapters/shared/stream-session/src/tool-handling/tool-registry.d.ts
|
|
157
|
+
/**
|
|
158
|
+
* Load tools from ToolRegistry via MakaioBus.
|
|
159
|
+
*
|
|
160
|
+
* Fetches available tools from the central ToolRegistry.
|
|
161
|
+
* Returns raw ToolListItem[] for maximum flexibility so each adapter can
|
|
162
|
+
* convert to its own SDK-specific format.
|
|
163
|
+
*
|
|
164
|
+
* Does not throw on failure — an agent can still operate without tools,
|
|
165
|
+
* so errors are logged and an empty array is returned.
|
|
166
|
+
* @param adapterId - Adapter instance ID for logging/routing
|
|
167
|
+
* @param adapterName - Adapter type name
|
|
168
|
+
* @returns List of available tools, or empty array if fetch fails
|
|
169
|
+
*/
|
|
170
|
+
declare function loadToolsFromRegistry(adapterId: string, adapterName: string): Promise<ToolListItem[]>;
|
|
171
|
+
/**
|
|
172
|
+
* Filter tools to only those with an inputSchema defined.
|
|
173
|
+
*
|
|
174
|
+
* Most LLM SDKs require a JSON Schema for function calling parameters.
|
|
175
|
+
* Tools without inputSchema cannot be used with native function calling.
|
|
176
|
+
* @param tools - Tools from the registry
|
|
177
|
+
* @returns Tools that have a defined inputSchema
|
|
178
|
+
*/
|
|
179
|
+
declare function filterToolsWithSchema(tools: ToolListItem[]): (ToolListItem & {
|
|
180
|
+
inputSchema: Record<string, unknown>;
|
|
181
|
+
})[];
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region adapters/shared/stream-session/src/tool-handling/tool-execution.d.ts
|
|
184
|
+
/**
|
|
185
|
+
* Minimal SDK event emitter interface for tool lifecycle events.
|
|
186
|
+
*
|
|
187
|
+
* Both adapter SdkEventMessage discriminated unions include ToolStartedEvent
|
|
188
|
+
* and ToolCompletedEvent. Using a structural union here avoids the shared
|
|
189
|
+
* package depending on adapter-specific namespaces.
|
|
190
|
+
*/
|
|
191
|
+
type ToolLifecycleEmitter = (event: ToolStartedEvent$1 | ToolCompletedEvent$1) => Promise<void>;
|
|
192
|
+
/**
|
|
193
|
+
* Execute a tool via Bus RPC.
|
|
194
|
+
*
|
|
195
|
+
* Routes tool execution through the ToolRegistry via MakaioBus.
|
|
196
|
+
* Emits tool_started before execution and tool_completed after (on both
|
|
197
|
+
* success and failure paths). On bus error the error is re-thrown after
|
|
198
|
+
* the tool_completed failure event is emitted.
|
|
199
|
+
* @param toolCall - The normalized tool call to execute
|
|
200
|
+
* @param emitSdkEvent - Callback to emit SDK lifecycle events
|
|
201
|
+
* @param contextOverrides - Execution context (cwd, env, sessionId, agentId, turnId)
|
|
202
|
+
* @returns Tool execution result
|
|
203
|
+
*/
|
|
204
|
+
declare function executeTool(toolCall: ToolCall, emitSdkEvent: ToolLifecycleEmitter, contextOverrides: ToolExecutionContextOverrides): Promise<ToolExecuteResult>;
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region adapters/shared/stream-session/src/tool-handling/handle-tool-calls.d.ts
|
|
207
|
+
/**
|
|
208
|
+
* Callbacks needed by {@link handleToolCalls}. Adapter-agnostic.
|
|
209
|
+
*/
|
|
210
|
+
type HandleToolCallsCallbacks = {
|
|
211
|
+
/** Emit SDK lifecycle events (tool_started, tool_completed). */emitSdkEvent: ToolLifecycleEmitter;
|
|
212
|
+
/**
|
|
213
|
+
* Request tool approval via the scoped bus routed to the global bus.
|
|
214
|
+
* @param payload - Tool call payload enriched with optional reasoning
|
|
215
|
+
* @returns Global approval response
|
|
216
|
+
*/
|
|
217
|
+
requestToolApproval: (payload: ToolCallPayload & {
|
|
218
|
+
reasoning?: string;
|
|
219
|
+
}) => Promise<AgentToolApproveResponse>;
|
|
220
|
+
/**
|
|
221
|
+
* Record an mcp_call invocation in the session tool ledger.
|
|
222
|
+
*
|
|
223
|
+
* Optional. When present, called after each successful mcp_call execution
|
|
224
|
+
* with the resolved target tool name. The connector binds this callback to
|
|
225
|
+
* its ledger and captures the current turn number in the closure, so it
|
|
226
|
+
* always reflects the turn in progress when the call is recorded.
|
|
227
|
+
* @param toolFullName - Namespaced target tool name extracted from mcp_call args
|
|
228
|
+
*/
|
|
229
|
+
recordMcpCall?: (toolFullName: string) => void;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Adapter-specific result formatter for tool call outcomes.
|
|
233
|
+
* @param toolCallId - The tool call ID for correlation
|
|
234
|
+
* @param content - Serialized result content (already bounded)
|
|
235
|
+
* @param isError - Whether the result represents an error
|
|
236
|
+
* @returns SDK-specific result value
|
|
237
|
+
*/
|
|
238
|
+
type ToolResultBuilder<TResult> = (toolCallId: string, content: string, isError: boolean) => TResult;
|
|
239
|
+
/**
|
|
240
|
+
* Process tool calls from a model response: approve, execute, and format results.
|
|
241
|
+
*
|
|
242
|
+
* Shared orchestration across all stream-based adapters. Each adapter provides
|
|
243
|
+
* a `buildResult` factory to format results in its SDK-specific type.
|
|
244
|
+
*
|
|
245
|
+
* **Mutation:** When approval modifies tool arguments, entries in `toolCalls`
|
|
246
|
+
* are mutated in place via {@link applyApprovedArgs}.
|
|
247
|
+
* @param toolCalls - Tool calls from the model (entries may be mutated when approval modifies args)
|
|
248
|
+
* @param callbacks - Approval and lifecycle event callbacks
|
|
249
|
+
* @param contextOverrides - Execution context (session, agent, turn)
|
|
250
|
+
* @param buildResult - Adapter-specific result formatter
|
|
251
|
+
* @param adapterLabel - Adapter name for logging
|
|
252
|
+
* @returns Formatted tool results for injection back into the conversation
|
|
253
|
+
*/
|
|
254
|
+
declare function handleToolCalls<TResult>(toolCalls: ToolCall[], callbacks: HandleToolCallsCallbacks, contextOverrides: ToolExecutionContextOverrides, buildResult: ToolResultBuilder<TResult>, adapterLabel: string): Promise<TResult[]>;
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region adapters/shared/stream-session/src/namespaces/schemas/turn-state.d.ts
|
|
257
|
+
/**
|
|
258
|
+
* Public turn-state contract for stream-session adapters.
|
|
259
|
+
*
|
|
260
|
+
* Both Anthropic SDK and OpenAI Node adapters share these states.
|
|
261
|
+
* Neither uses a 'paused' state — they abort and restart instead.
|
|
262
|
+
*/
|
|
263
|
+
type StreamSessionTurnState = 'idle' | 'turn_started' | 'step_started' | 'step_finished' | 'turn_finished';
|
|
264
|
+
/**
|
|
265
|
+
* Public payload contract for turn-state transitions.
|
|
266
|
+
*/
|
|
267
|
+
interface TurnStateChanged {
|
|
268
|
+
/** The adapter instance identifier. */
|
|
269
|
+
adapterId: string;
|
|
270
|
+
/** The agent this turn belongs to. */
|
|
271
|
+
agentId: string;
|
|
272
|
+
/** The state being left. */
|
|
273
|
+
oldState: StreamSessionTurnState;
|
|
274
|
+
/** The state being entered. */
|
|
275
|
+
newState: StreamSessionTurnState;
|
|
276
|
+
/** Unix timestamp (ms) when the transition occurred. */
|
|
277
|
+
timestamp: number;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Shared turn state schema for stream-session adapters.
|
|
281
|
+
*/
|
|
282
|
+
declare const StreamSessionTurnStateSchema: z.ZodEnum<{
|
|
283
|
+
idle: "idle";
|
|
284
|
+
turn_started: "turn_started";
|
|
285
|
+
step_started: "step_started";
|
|
286
|
+
step_finished: "step_finished";
|
|
287
|
+
turn_finished: "turn_finished";
|
|
288
|
+
}>;
|
|
289
|
+
/**
|
|
290
|
+
* Schema for a turn state change event.
|
|
291
|
+
* Emitted by adapters whenever the turn state machine transitions.
|
|
292
|
+
* @param adapterId - The adapter instance identifier.
|
|
293
|
+
* @param agentId - The agent this turn belongs to.
|
|
294
|
+
* @param oldState - The state being left.
|
|
295
|
+
* @param newState - The state being entered.
|
|
296
|
+
* @param timestamp - Unix timestamp (ms) when the transition occurred.
|
|
297
|
+
*/
|
|
298
|
+
declare const TurnStateChangedSchema: z.ZodObject<{
|
|
299
|
+
adapterId: z.ZodString;
|
|
300
|
+
agentId: z.ZodString;
|
|
301
|
+
oldState: z.ZodEnum<{
|
|
302
|
+
idle: "idle";
|
|
303
|
+
turn_started: "turn_started";
|
|
304
|
+
step_started: "step_started";
|
|
305
|
+
step_finished: "step_finished";
|
|
306
|
+
turn_finished: "turn_finished";
|
|
307
|
+
}>;
|
|
308
|
+
newState: z.ZodEnum<{
|
|
309
|
+
idle: "idle";
|
|
310
|
+
turn_started: "turn_started";
|
|
311
|
+
step_started: "step_started";
|
|
312
|
+
step_finished: "step_finished";
|
|
313
|
+
turn_finished: "turn_finished";
|
|
314
|
+
}>;
|
|
315
|
+
timestamp: z.ZodNumber;
|
|
316
|
+
}, z.core.$strip>;
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region adapters/shared/stream-session/src/namespaces/schemas/reasoning.d.ts
|
|
319
|
+
/**
|
|
320
|
+
* Base schema for a reasoning delta event.
|
|
321
|
+
*
|
|
322
|
+
* Emitted during streaming when the model outputs incremental reasoning /
|
|
323
|
+
* thinking content. Both Anthropic (extended thinking) and OpenAI-compatible
|
|
324
|
+
* reasoning models emit this event.
|
|
325
|
+
*
|
|
326
|
+
* Adapter-specific schemas may extend this via `.extend()`.
|
|
327
|
+
*/
|
|
328
|
+
declare const ReasoningDeltaEventSchema: z.ZodObject<{
|
|
329
|
+
eventType: z.ZodLiteral<"reasoning_delta">;
|
|
330
|
+
content: z.ZodString;
|
|
331
|
+
}, z.core.$strip>;
|
|
332
|
+
/** Inferred reasoning delta event type. */
|
|
333
|
+
type ReasoningDeltaEvent = z.infer<typeof ReasoningDeltaEventSchema>;
|
|
334
|
+
/**
|
|
335
|
+
* Base schema for a reasoning complete event.
|
|
336
|
+
*
|
|
337
|
+
* Emitted when the full reasoning / thinking content has been assembled from
|
|
338
|
+
* all streaming deltas. Does NOT include the Anthropic-specific `signature`
|
|
339
|
+
* field — the Anthropic adapter extends this schema with `.extend()`.
|
|
340
|
+
*
|
|
341
|
+
* Adapter-specific schemas may extend this via `.extend()`.
|
|
342
|
+
*/
|
|
343
|
+
declare const ReasoningCompleteEventSchema: z.ZodObject<{
|
|
344
|
+
eventType: z.ZodLiteral<"reasoning_complete">;
|
|
345
|
+
content: z.ZodString;
|
|
346
|
+
}, z.core.$strip>;
|
|
347
|
+
/** Inferred reasoning complete event type. */
|
|
348
|
+
type ReasoningCompleteEvent = z.infer<typeof ReasoningCompleteEventSchema>;
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region adapters/shared/stream-session/src/namespaces/schemas/message.d.ts
|
|
351
|
+
/**
|
|
352
|
+
* Base schema for a tool call embedded in a message complete event.
|
|
353
|
+
*
|
|
354
|
+
* Contains only the fields common to both Anthropic and OpenAI adapters.
|
|
355
|
+
* The Anthropic adapter's version additionally carries `blockIndex`.
|
|
356
|
+
*/
|
|
357
|
+
declare const MessageToolCallSchema: z.ZodObject<{
|
|
358
|
+
id: z.ZodString;
|
|
359
|
+
type: z.ZodLiteral<"function">;
|
|
360
|
+
function: z.ZodObject<{
|
|
361
|
+
name: z.ZodString;
|
|
362
|
+
arguments: z.ZodString;
|
|
363
|
+
}, z.core.$strip>;
|
|
364
|
+
}, z.core.$strip>;
|
|
365
|
+
/** Inferred base message tool call type. */
|
|
366
|
+
type MessageToolCall = z.infer<typeof MessageToolCallSchema>;
|
|
367
|
+
/**
|
|
368
|
+
* Base schema for a message complete event.
|
|
369
|
+
*
|
|
370
|
+
* Emitted when a full assistant message has been assembled from streaming
|
|
371
|
+
* chunks. The `finish_reason` and `tool_calls` fields are left open for
|
|
372
|
+
* each adapter to specialise via `.extend()`, since the allowed values
|
|
373
|
+
* differ between providers.
|
|
374
|
+
*
|
|
375
|
+
* Adapter-specific schemas MUST extend this schema and narrow:
|
|
376
|
+
* - `finish_reason` to their provider-specific enum
|
|
377
|
+
* - `tool_calls` to their adapter-specific tool-call schema (if needed)
|
|
378
|
+
*/
|
|
379
|
+
declare const MessageCompleteEventSchema: z.ZodObject<{
|
|
380
|
+
eventType: z.ZodLiteral<"message_complete">;
|
|
381
|
+
content: z.ZodNullable<z.ZodString>;
|
|
382
|
+
reasoning: z.ZodOptional<z.ZodString>;
|
|
383
|
+
tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
384
|
+
id: z.ZodString;
|
|
385
|
+
type: z.ZodLiteral<"function">;
|
|
386
|
+
function: z.ZodObject<{
|
|
387
|
+
name: z.ZodString;
|
|
388
|
+
arguments: z.ZodString;
|
|
389
|
+
}, z.core.$strip>;
|
|
390
|
+
}, z.core.$strip>>>;
|
|
391
|
+
finish_reason: z.ZodNullable<z.ZodString>;
|
|
392
|
+
}, z.core.$strip>;
|
|
393
|
+
/** Inferred base message complete event type. */
|
|
394
|
+
type MessageCompleteEvent = z.infer<typeof MessageCompleteEventSchema>;
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region adapters/shared/stream-session/src/session/types.d.ts
|
|
397
|
+
/**
|
|
398
|
+
* Union of SDK event types emitted directly by the base stream session.
|
|
399
|
+
*
|
|
400
|
+
* Adapter configs use a broader union (`SdkEventMessage`) that includes all
|
|
401
|
+
* adapter-specific events. Since `AgentStartedEvent` and `ErrorEvent` are
|
|
402
|
+
* members of every adapter's `SdkEventMessage` union, a function accepting
|
|
403
|
+
* the broader union satisfies this narrower parameter type via contravariance.
|
|
404
|
+
*/
|
|
405
|
+
type BaseSessionEmitEvent = AgentStartedEvent$1 | ErrorEvent$1;
|
|
406
|
+
/**
|
|
407
|
+
* Minimal typed envelope for the `message_complete` SDK event returned
|
|
408
|
+
* from `bus.once()` inside the base stream session.
|
|
409
|
+
*
|
|
410
|
+
* Both adapter namespaces wrap their SDK events in an envelope with the same
|
|
411
|
+
* shape (event, agentId?, adapterId?, ...). The base session only
|
|
412
|
+
* needs `event.eventType` for dispatch and passes the full payload to
|
|
413
|
+
* `applyMessageComplete` which is implemented by each adapter subclass.
|
|
414
|
+
*/
|
|
415
|
+
interface StreamSdkEventEnvelope {
|
|
416
|
+
/** Inner SDK event discriminated by `eventType`. */
|
|
417
|
+
event: {
|
|
418
|
+
eventType: string;
|
|
419
|
+
} & Record<string, unknown>;
|
|
420
|
+
/** Agent ID from the envelope for bus filter matching. */
|
|
421
|
+
agentId?: string;
|
|
422
|
+
/** Adapter ID from the envelope for bus filter matching. */
|
|
423
|
+
adapterId?: string;
|
|
424
|
+
/** Adapter name from the envelope. */
|
|
425
|
+
adapterName?: string;
|
|
426
|
+
/** Session ID from the envelope. */
|
|
427
|
+
sessionId?: string;
|
|
428
|
+
/** Adapter-local session ID from the envelope for turn correlation. */
|
|
429
|
+
adapterSessionId?: string;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Shared configuration interface for stream-based connector sessions.
|
|
433
|
+
*
|
|
434
|
+
* Contains all fields common to the Anthropic SDK and OpenAI Node session
|
|
435
|
+
* configurations. SDK-specific fields (`client`, tool-list types) remain
|
|
436
|
+
* in each adapter's own config type which extends this interface.
|
|
437
|
+
* @typeParam TBus - Scoped bus type for the adapter namespace
|
|
438
|
+
*/
|
|
439
|
+
interface StreamSessionConfig<TBus extends ScopedBus<string> = ScopedBus<string>> {
|
|
440
|
+
/** Scoped bus for the adapter namespace. */
|
|
441
|
+
bus: TBus;
|
|
442
|
+
/** Stable adapter instance identifier. */
|
|
443
|
+
adapterId: string;
|
|
444
|
+
/** Human-readable adapter name used in log messages and bus events. */
|
|
445
|
+
adapterName: string;
|
|
446
|
+
/** Agent ID for tool execution attribution and bus subject filtering. */
|
|
447
|
+
agentId: string;
|
|
448
|
+
/** Makaio session ID for tool execution context. Stable across turns. */
|
|
449
|
+
sessionId?: string;
|
|
450
|
+
/** Working directory for tool execution context. */
|
|
451
|
+
cwd: string;
|
|
452
|
+
/** Initial model identifier; mutable per turn via `updateModel()`. */
|
|
453
|
+
model: string;
|
|
454
|
+
/** Reasoning effort level for reasoning-capable models. */
|
|
455
|
+
reasoningEffort?: AIReasoningLevel$1;
|
|
456
|
+
/**
|
|
457
|
+
* Timeout in milliseconds before the streaming API call is considered
|
|
458
|
+
* failed. A single retry is attempted before the error propagates.
|
|
459
|
+
*/
|
|
460
|
+
streamStartTimeoutMs?: number;
|
|
461
|
+
/** Environment variables forwarded to tool execution. */
|
|
462
|
+
env: Record<string, string>;
|
|
463
|
+
/** Resolved system prompt string prepended to the message array. */
|
|
464
|
+
systemPrompt?: string;
|
|
465
|
+
/**
|
|
466
|
+
* Emit a typed SDK lifecycle event to the connector bus.
|
|
467
|
+
* Adapter configs narrow this to their full `SdkEventMessage` union.
|
|
468
|
+
* The base session only emits `agent_started` and `error` events,
|
|
469
|
+
* both of which are members of every adapter's `SdkEventMessage` union.
|
|
470
|
+
*/
|
|
471
|
+
emitSdkEvent: (event: BaseSessionEmitEvent) => Promise<void>;
|
|
472
|
+
/** Handle a connector-level error. */
|
|
473
|
+
handleError: (error: Error, rethrow: boolean) => void;
|
|
474
|
+
/** Called synchronously when a new turn is about to start. */
|
|
475
|
+
onTurnStart?: (handle: MessageHandle) => void;
|
|
476
|
+
/** Called when a turn reaches a terminal state (completed or error). */
|
|
477
|
+
onTurnComplete?: (handle: MessageHandle, result: MessageResult) => void;
|
|
478
|
+
/** Optional low-level event logger for adapter observability. */
|
|
479
|
+
logLowLevelEvent?: (event: unknown) => void;
|
|
480
|
+
/**
|
|
481
|
+
* Directory restrictions for file-system tool execution.
|
|
482
|
+
* Forwarded as `constraints.allowedDirectories` in every tool call.
|
|
483
|
+
* - `undefined`: no directory restriction
|
|
484
|
+
* - `[]`: deny all filesystem paths
|
|
485
|
+
* - non-empty array: allow-list to these directories
|
|
486
|
+
*/
|
|
487
|
+
allowedDirectories?: string[];
|
|
488
|
+
/**
|
|
489
|
+
* Record one mcp_call invocation in the session tool ledger.
|
|
490
|
+
*
|
|
491
|
+
* When present, the session forwards this to `HandleToolCallsCallbacks` so
|
|
492
|
+
* the shared `handleToolCalls` function can record mcp_call invocations.
|
|
493
|
+
* The connector binds it as a closure over its ledger and current turn number,
|
|
494
|
+
* so no turn-number threading is needed at the session level.
|
|
495
|
+
* @param toolFullName - The namespaced target tool name from the mcp_call args
|
|
496
|
+
*/
|
|
497
|
+
recordMcpCall?: (toolFullName: string) => void;
|
|
498
|
+
}
|
|
499
|
+
//#endregion
|
|
500
|
+
//#region adapters/shared/stream-session/src/session/base-stream-session.d.ts
|
|
501
|
+
/**
|
|
502
|
+
* Turn contract required by `BaseStreamSession`.
|
|
503
|
+
*
|
|
504
|
+
* Stream sessions depend on the core procedural turn lifecycle plus an abort
|
|
505
|
+
* signal accessor used by `runTurnIteration`.
|
|
506
|
+
*/
|
|
507
|
+
interface StreamSessionTurn extends ProceduralConnectorTurn {
|
|
508
|
+
/**
|
|
509
|
+
* Get the current abort signal for this turn.
|
|
510
|
+
* @returns AbortSignal for stream cancellation
|
|
511
|
+
*/
|
|
512
|
+
getAbortSignal(): AbortSignal;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Abstract base class for stream-based AI connector sessions.
|
|
516
|
+
*
|
|
517
|
+
* Captures the shared session lifecycle logic between the Anthropic SDK and
|
|
518
|
+
* OpenAI Node adapters. Both adapters use an identical queue-based turn model:
|
|
519
|
+
*
|
|
520
|
+
* 1. `processQueue` — dequeues messages and dispatches to `startNewTurn`
|
|
521
|
+
* 2. `startNewTurn` — initialises a new turn, wires the finally-cleanup, and
|
|
522
|
+
* fires the async `queueMicrotask` loop
|
|
523
|
+
* 3. `runTurn` → `runTurnIteration` — the agentic loop; executes streaming
|
|
524
|
+
* API calls and recurses when tool calls are returned
|
|
525
|
+
* 4. `executeStreamingStep` — the stream-start-timeout wrapper; delegates the
|
|
526
|
+
* actual API call to the abstract `executeApiCall` hook
|
|
527
|
+
* 5. `applyMessageComplete` — abstract; each adapter appends the assistant
|
|
528
|
+
* response in its own wire format and handles tool recursion
|
|
529
|
+
*
|
|
530
|
+
* ## Generic type parameters
|
|
531
|
+
* @typeParam TConfig - Adapter session config extending `StreamSessionConfig`
|
|
532
|
+
* @typeParam TTurn - Adapter turn type extending `ProceduralConnectorTurn`
|
|
533
|
+
* @typeParam TMessageCompleteEvent - Adapter-specific `MessageCompleteEvent`
|
|
534
|
+
* extension; defaults to the shared base schema type
|
|
535
|
+
*/
|
|
536
|
+
declare abstract class BaseStreamSession<TConfig extends StreamSessionConfig<ScopedBus<string>>, TTurn extends StreamSessionTurn, TMessageCompleteEvent extends MessageCompleteEvent = MessageCompleteEvent> extends BaseConnectorSession<TConfig> {
|
|
537
|
+
/**
|
|
538
|
+
* Maximum number of tool-call recursion steps per turn.
|
|
539
|
+
* Subclasses reference this in `applyMessageComplete`.
|
|
540
|
+
*/
|
|
541
|
+
protected static readonly MAX_TOOL_CALL_ITERATIONS = 8;
|
|
542
|
+
/** Active turn reference; overwritten on each new turn. */
|
|
543
|
+
protected currentTurn: TTurn | undefined;
|
|
544
|
+
/** Assembled last assistant message content; reset on each new turn. */
|
|
545
|
+
protected lastAssistantMessage: string | undefined;
|
|
546
|
+
/** Runtime model used for subsequent API calls; set from config.model. */
|
|
547
|
+
protected currentModel: string;
|
|
548
|
+
/** Runtime working directory for tool execution; set from config.cwd. */
|
|
549
|
+
protected currentCwd: string;
|
|
550
|
+
/** Pending public-turn history compactions waiting for canonical completion. */
|
|
551
|
+
private readonly pendingAssistantHistoryCompactions;
|
|
552
|
+
/**
|
|
553
|
+
* Initialize a stream session with connector runtime config.
|
|
554
|
+
* @param config - Session configuration (bus identity, model/cwd defaults, and adapter hooks).
|
|
555
|
+
*/
|
|
556
|
+
constructor(config: TConfig);
|
|
557
|
+
/**
|
|
558
|
+
* Create the adapter-specific turn instance for `handle`.
|
|
559
|
+
* @param handle - The message handle this turn will process
|
|
560
|
+
* @returns A new turn instance
|
|
561
|
+
*/
|
|
562
|
+
protected abstract createTurn(handle: MessageHandle): TTurn;
|
|
563
|
+
/**
|
|
564
|
+
* Build (or rebuild) the adapter-specific messages array from the message
|
|
565
|
+
* handle's history and optional merged content from superseded messages.
|
|
566
|
+
* @param handle - The message handle containing history and current message
|
|
567
|
+
* @param mergedContent - Text content from superseded/merged messages
|
|
568
|
+
*/
|
|
569
|
+
protected abstract buildMessages(handle: MessageHandle, mergedContent?: string[]): void;
|
|
570
|
+
/**
|
|
571
|
+
* Return the current adapter-specific conversation history length.
|
|
572
|
+
*
|
|
573
|
+
* Used to checkpoint the boundary immediately after a user turn has been
|
|
574
|
+
* materialized, so structured-output retries can later compact provisional
|
|
575
|
+
* assistant/retry blocks back to the canonical public completion.
|
|
576
|
+
* @returns Number of provider-native messages currently in history
|
|
577
|
+
*/
|
|
578
|
+
protected abstract getConversationHistoryLength(): number;
|
|
579
|
+
/**
|
|
580
|
+
* Replace all assistant-side history for a turn with the canonical assistant
|
|
581
|
+
* message emitted by the `MessageHandle`.
|
|
582
|
+
* @param startIndex - History index immediately after the user turn input
|
|
583
|
+
* @param endIndex - Exclusive history boundary for provisional assistant/retry blocks
|
|
584
|
+
* @param assistantMessage - Canonical assistant message for that turn
|
|
585
|
+
*/
|
|
586
|
+
protected abstract replaceAssistantTurnHistory(startIndex: number, endIndex: number, assistantMessage: string): void;
|
|
587
|
+
/**
|
|
588
|
+
* Execute the adapter-specific streaming API call.
|
|
589
|
+
*
|
|
590
|
+
* Called inside `executeStreamingStep` after the stream-start timeout is
|
|
591
|
+
* armed. Implementors must operate on the provided turn instance rather than
|
|
592
|
+
* reading `this.currentTurn` directly so superseded turns cannot mutate the
|
|
593
|
+
* active turn state.
|
|
594
|
+
* @param turn - Captured turn instance for this run loop
|
|
595
|
+
* @param abortSignal - Combined abort signal (turn abort + stream timeout)
|
|
596
|
+
* @param adapterSessionId - Turn-scoped adapter session ID for event correlation
|
|
597
|
+
*/
|
|
598
|
+
protected abstract executeApiCall(turn: TTurn, abortSignal: AbortSignal, adapterSessionId: string): Promise<void>;
|
|
599
|
+
/**
|
|
600
|
+
* Return the bus subject to `once()` on for the `message_complete` event.
|
|
601
|
+
*
|
|
602
|
+
* Each adapter listens on its own namespace subject (e.g.
|
|
603
|
+
* `AnthropicSdkConnectorSubjects.sdk.event`).
|
|
604
|
+
* @returns The bus subject for the adapter's SDK event stream
|
|
605
|
+
*/
|
|
606
|
+
protected abstract getSdkEventSubject(): ScopedSubjectDefinition<string>;
|
|
607
|
+
/**
|
|
608
|
+
* Apply a `message_complete` event to the messages array and recurse for
|
|
609
|
+
* tool calls.
|
|
610
|
+
*
|
|
611
|
+
* Called in `runTurnIteration` after `message_complete` is received from
|
|
612
|
+
* the bus. Implementations append the assistant message in the adapter's
|
|
613
|
+
* wire format, check the tool-call finish reason, and call
|
|
614
|
+
* `runTurnIteration` again when tools need executing.
|
|
615
|
+
* @param result - The parsed `message_complete` event payload
|
|
616
|
+
* @param currentHandle - The active message handle
|
|
617
|
+
* @param toolCallIteration - Current recursion depth (for iteration guard)
|
|
618
|
+
* @param turn - Captured turn instance for this run loop
|
|
619
|
+
*/
|
|
620
|
+
protected abstract applyMessageComplete(result: TMessageCompleteEvent, currentHandle: MessageHandle, toolCallIteration: number, turn: TTurn): Promise<void>;
|
|
621
|
+
/**
|
|
622
|
+
* Classify an SDK-level error into the appropriate error type.
|
|
623
|
+
*
|
|
624
|
+
* The base class re-throws whatever this returns; adapters map SDK-specific
|
|
625
|
+
* error shapes (e.g. Anthropic's `APIError`, OpenAI's `APIError`) to
|
|
626
|
+
* normalised error instances.
|
|
627
|
+
* @param error - The raw error caught from the API call or stream
|
|
628
|
+
* @returns A normalised `Error` instance
|
|
629
|
+
*/
|
|
630
|
+
protected abstract classifyError(error: unknown): Error;
|
|
631
|
+
/**
|
|
632
|
+
* Process messages from the queue.
|
|
633
|
+
*
|
|
634
|
+
* Creates a new turn or handles immediate injection via abort+restart.
|
|
635
|
+
* @param queue - The user message queue to drain
|
|
636
|
+
*/
|
|
637
|
+
processQueue(queue: UserMessageQueue): Promise<void>;
|
|
638
|
+
/**
|
|
639
|
+
* Start a new turn for the given message handle.
|
|
640
|
+
*
|
|
641
|
+
* Orchestrates the full turn setup: session ID rotation, message building,
|
|
642
|
+
* turn creation, acknowledgment, and the async `queueMicrotask` loop.
|
|
643
|
+
* Turn finalisation is always in the `finally` block so the connector state
|
|
644
|
+
* machine always reaches a terminal state.
|
|
645
|
+
* @param handle - The message handle to process
|
|
646
|
+
* @param mergedContent - Optional content from superseded/merged messages
|
|
647
|
+
*/
|
|
648
|
+
protected startNewTurn(handle: MessageHandle, mergedContent?: string[]): Promise<void>;
|
|
649
|
+
/**
|
|
650
|
+
* Handle a turn-level error from the `queueMicrotask` body.
|
|
651
|
+
*
|
|
652
|
+
* Branches on whether the turn was paused (immediate-mode abort or
|
|
653
|
+
* shutdown) and either returns silently, completes the handle with an
|
|
654
|
+
* error result, or delegates to the connector error handler.
|
|
655
|
+
* @param error - The caught error
|
|
656
|
+
* @param turn - The captured turn reference for pause-state checks
|
|
657
|
+
* @param handle - The message handle to finalise on non-abort errors
|
|
658
|
+
*/
|
|
659
|
+
private handleTurnError;
|
|
660
|
+
/**
|
|
661
|
+
* Run a turn — the agentic loop entry point.
|
|
662
|
+
* @param turn - Captured turn instance for this run loop
|
|
663
|
+
* @param currentHandle - The handle to track supersedence
|
|
664
|
+
*/
|
|
665
|
+
protected runTurn(turn: TTurn, currentHandle: MessageHandle): Promise<void>;
|
|
666
|
+
/**
|
|
667
|
+
* Wait for the SDK `message_complete` event emitted by stream processing.
|
|
668
|
+
*
|
|
669
|
+
* Uses `bus.once` with AbortSignal support to avoid dangling listeners on
|
|
670
|
+
* abort. Namespace-scoped buses are shared across connector instances, so
|
|
671
|
+
* the filter includes both the event type and adapter identity to prevent
|
|
672
|
+
* concurrent agents from satisfying each other's waiter.
|
|
673
|
+
* @param abortSignal - Abort signal for the current turn
|
|
674
|
+
* @param adapterSessionId - Adapter-local session ID bound to the turn
|
|
675
|
+
* @returns Promise resolving to the SDK event envelope
|
|
676
|
+
*/
|
|
677
|
+
protected createMessageCompletePromise(abortSignal: AbortSignal, adapterSessionId: string): Promise<{
|
|
678
|
+
payload: StreamSdkEventEnvelope;
|
|
679
|
+
}>;
|
|
680
|
+
/**
|
|
681
|
+
* Execute one streaming API step with stream-start-timeout protection.
|
|
682
|
+
*
|
|
683
|
+
* Arms a timeout that aborts the stream connection attempt if no bytes
|
|
684
|
+
* arrive within `streamStartTimeoutMs` (default: 30 s). On timeout a
|
|
685
|
+
* single retry is attempted by `runTurnIteration`. Delegates the actual
|
|
686
|
+
* API call to the abstract `executeApiCall` hook.
|
|
687
|
+
* @param turn - Captured turn instance for this run loop
|
|
688
|
+
* @param abortSignal - Turn-level abort signal
|
|
689
|
+
* @param adapterSessionId - Turn-scoped adapter session ID for event correlation
|
|
690
|
+
*/
|
|
691
|
+
protected executeStreamingStep(turn: TTurn, abortSignal: AbortSignal, adapterSessionId: string): Promise<void>;
|
|
692
|
+
/**
|
|
693
|
+
* Run one iteration of the agentic loop.
|
|
694
|
+
*
|
|
695
|
+
* Fires the streaming step, waits for the `message_complete` event, then
|
|
696
|
+
* delegates to `applyMessageComplete`. Handles abort signals, stream-start
|
|
697
|
+
* timeouts (with a single retry), and SDK-level errors uniformly.
|
|
698
|
+
* @param turn - Captured turn instance for this run loop
|
|
699
|
+
* @param currentHandle - The handle to track supersedence
|
|
700
|
+
* @param toolCallIteration - Current tool recursion depth (default: 0)
|
|
701
|
+
*/
|
|
702
|
+
protected runTurnIteration(turn: TTurn, currentHandle: MessageHandle, toolCallIteration?: number): Promise<void>;
|
|
703
|
+
/**
|
|
704
|
+
* Build the tool execution constraints object from session config.
|
|
705
|
+
*
|
|
706
|
+
* Returns `{ allowedDirectories }` when `config.allowedDirectories` is set,
|
|
707
|
+
* or `undefined` when no directory restrictions are configured. Both
|
|
708
|
+
* concrete adapter sessions call this in `applyMessageComplete` to avoid
|
|
709
|
+
* duplicating the conditional spread.
|
|
710
|
+
* @returns Typed constraints for `ToolExecutionContextOverrides`, or `undefined`
|
|
711
|
+
*/
|
|
712
|
+
protected buildToolConstraints(): {
|
|
713
|
+
allowedDirectories: string[];
|
|
714
|
+
} | undefined;
|
|
715
|
+
/**
|
|
716
|
+
* Update the model used for subsequent API calls.
|
|
717
|
+
*
|
|
718
|
+
* Called by the connector's `changeModelInPlace()` to sync the session
|
|
719
|
+
* with the connector-level model without requiring a full session swap.
|
|
720
|
+
* @param model - New model identifier
|
|
721
|
+
*/
|
|
722
|
+
updateModel(model: string): void;
|
|
723
|
+
/**
|
|
724
|
+
* Update the working directory used for subsequent tool executions.
|
|
725
|
+
*
|
|
726
|
+
* Called by the connector's `changeCwdInPlace()` to sync the session
|
|
727
|
+
* with the connector-level cwd without requiring a full session swap.
|
|
728
|
+
* @param cwd - New working directory path
|
|
729
|
+
*/
|
|
730
|
+
updateCwd(cwd: string): void;
|
|
731
|
+
/**
|
|
732
|
+
* Get the current turn for state inspection.
|
|
733
|
+
* @returns The current turn or `undefined` if no turn is active
|
|
734
|
+
*/
|
|
735
|
+
getCurrentTurn(): TTurn | undefined;
|
|
736
|
+
/**
|
|
737
|
+
* Returns true when a newer turn has replaced the captured turn.
|
|
738
|
+
* @param turn - Captured turn reference
|
|
739
|
+
* @returns Whether this turn has been superseded
|
|
740
|
+
*/
|
|
741
|
+
protected isTurnSuperseded(turn: TTurn): boolean;
|
|
742
|
+
/**
|
|
743
|
+
* Unified early-exit guard for stale turns and superseded handles.
|
|
744
|
+
* @param turn - Captured turn reference
|
|
745
|
+
* @param currentHandle - Active message handle
|
|
746
|
+
* @returns True when iteration must stop
|
|
747
|
+
*/
|
|
748
|
+
protected shouldAbortTurnProcessing(turn: TTurn, currentHandle: MessageHandle): boolean;
|
|
749
|
+
/**
|
|
750
|
+
* Close any unresolved public-turn history compactions before a new public
|
|
751
|
+
* turn appends its user message.
|
|
752
|
+
* @param endIndex - Exclusive boundary before the new public turn starts
|
|
753
|
+
*/
|
|
754
|
+
private closePendingAssistantHistoryCompactions;
|
|
755
|
+
/**
|
|
756
|
+
* Remove a completed history compaction from the pending set.
|
|
757
|
+
* @param compaction - Pending compaction handle to remove
|
|
758
|
+
*/
|
|
759
|
+
private removePendingAssistantHistoryCompaction;
|
|
760
|
+
}
|
|
761
|
+
//#endregion
|
|
762
|
+
//#region adapters/shared/stream-session/src/connector/base-stream-connector.d.ts
|
|
763
|
+
/**
|
|
764
|
+
* Minimal session contract required by BaseStreamConnector.
|
|
765
|
+
*
|
|
766
|
+
* Extends `ProceduralConnectorSession` with the lifecycle methods that the
|
|
767
|
+
* connector delegates to: `abort` (used by interrupt/close), `updateModel` and
|
|
768
|
+
* `updateCwd` for in-place mutation without a full session swap.
|
|
769
|
+
*/
|
|
770
|
+
interface StreamConnectorSession extends ProceduralConnectorSession {
|
|
771
|
+
/** Abort the active turn, cancelling any in-flight API call. */
|
|
772
|
+
abort(): Promise<void>;
|
|
773
|
+
/**
|
|
774
|
+
* Update the model used for subsequent API calls.
|
|
775
|
+
* @param model - New model identifier
|
|
776
|
+
*/
|
|
777
|
+
updateModel(model: string): void;
|
|
778
|
+
/**
|
|
779
|
+
* Update the working directory used for subsequent tool executions.
|
|
780
|
+
* @param cwd - New working directory path
|
|
781
|
+
*/
|
|
782
|
+
updateCwd(cwd: string): void;
|
|
783
|
+
/**
|
|
784
|
+
* Update the session's tool set for the next API call.
|
|
785
|
+
* Optional — not all adapters support mid-session tool updates.
|
|
786
|
+
* @param tools - New tool list in generic `ToolListItem` format; session converts internally
|
|
787
|
+
*/
|
|
788
|
+
updateTools?(tools: ToolListItem[]): void;
|
|
789
|
+
/**
|
|
790
|
+
* Update the reasoning effort level used for subsequent API calls.
|
|
791
|
+
* Optional — only adapters that pass reasoning per-request implement this seam.
|
|
792
|
+
* @param level - New reasoning effort level
|
|
793
|
+
*/
|
|
794
|
+
updateReasoning?(level: AIReasoningLevel$1): void;
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* Config shape required by `BaseStreamConnector`.
|
|
798
|
+
*
|
|
799
|
+
* Extends `BaseAgentConnectorConfig` and widens `mcpSessionContext` to include
|
|
800
|
+
* the full {@link McpSessionContext} shape so the stream connector can
|
|
801
|
+
* re-resolve the session via the bus (which requires `sessionId`, `profileId`,
|
|
802
|
+
* and `projectId`). The orchestrator always supplies a full `McpSessionContext`;
|
|
803
|
+
* `LedgerSessionContext` is retained in the union for standalone/test connectors
|
|
804
|
+
* that do not need bus re-resolve.
|
|
805
|
+
* @typeParam TBus - Scoped bus type for the adapter namespace
|
|
806
|
+
* @typeParam TProviderConfig - Provider-specific config object
|
|
807
|
+
*/
|
|
808
|
+
type BaseStreamConnectorConfig<TBus extends ScopedBus<string> = ScopedBus<string>, TProviderConfig extends object = object> = Omit<BaseAgentConnectorConfig<TBus, TProviderConfig>, 'mcpSessionContext'> & {
|
|
809
|
+
/**
|
|
810
|
+
* MCP session context resolved by the orchestrator.
|
|
811
|
+
* May be the full {@link McpSessionContext} (with `sessionId`/`servers` for
|
|
812
|
+
* bus re-resolve) or a bare `LedgerSessionContext` for standalone connectors.
|
|
813
|
+
* The connector discriminates at runtime via `'sessionId' in ctx`.
|
|
814
|
+
*/
|
|
815
|
+
mcpSessionContext?: McpSessionContext | LedgerSessionContext;
|
|
816
|
+
};
|
|
817
|
+
/**
|
|
818
|
+
* Abstract base class for stream-based AI adapter connectors.
|
|
819
|
+
*
|
|
820
|
+
* Captures the shared connector lifecycle logic between the Anthropic SDK and
|
|
821
|
+
* OpenAI Node adapters. Both connectors follow an identical pattern:
|
|
822
|
+
*
|
|
823
|
+
* - Lazy single-session initialisation via `ensureSession` / `initializeSession`
|
|
824
|
+
* - Tool fetching on first turn (delegated to the abstract `fetchTools` hook)
|
|
825
|
+
* - `sendMessage` → `processUserMessages` delegation to `ProceduralAgentConnector`
|
|
826
|
+
* - In-place model and cwd mutation via `changeModelInPlace` / `changeCwdInPlace`
|
|
827
|
+
*
|
|
828
|
+
* Concrete subclasses must implement the following abstract hooks:
|
|
829
|
+
* - `fetchTools()` — fetch adapter-specific tools and cache them internally
|
|
830
|
+
* - `createSession()` — construct the concrete session instance
|
|
831
|
+
* - `getTurnSubjects()` — return adapter-specific turn lifecycle subjects
|
|
832
|
+
*
|
|
833
|
+
* Subclasses may override `afterSessionCreated()` for extra post-creation wiring
|
|
834
|
+
* (e.g. Anthropic sets tools on the session after construction).
|
|
835
|
+
* @typeParam TBus - Scoped bus type for the adapter namespace
|
|
836
|
+
* @typeParam TSession - Concrete session type; must satisfy `StreamConnectorSession`
|
|
837
|
+
* @typeParam TConfig - Connector config type extending `BaseStreamConnectorConfig<TBus>`
|
|
838
|
+
*/
|
|
839
|
+
declare abstract class BaseStreamConnector<TBus extends ScopedBus<string>, TSession extends StreamConnectorSession, TConfig extends BaseStreamConnectorConfig<TBus>> extends ProceduralAgentConnector<TBus, TConfig> {
|
|
840
|
+
/** Session manages Turn lifecycle. Initialised lazily on first message. */
|
|
841
|
+
private session?;
|
|
842
|
+
/** Message queue for serialising async send operations. */
|
|
843
|
+
private readonly userMessageQueue;
|
|
844
|
+
/** MCP tools resolved for direct injection into the session. */
|
|
845
|
+
protected mcpDirectTools: ToolListItem[];
|
|
846
|
+
/**
|
|
847
|
+
* Fresh MCP session context fetched via bus during `refreshTools()`.
|
|
848
|
+
*
|
|
849
|
+
* When set, `prepareMcpDirectTools()` reads from this cache instead of the
|
|
850
|
+
* startup snapshot in `config.mcpSessionContext`, ensuring that mid-session
|
|
851
|
+
* tool refreshes reflect the current registry state rather than the state
|
|
852
|
+
* at connector construction time.
|
|
853
|
+
*/
|
|
854
|
+
private mcpSessionContextCache?;
|
|
855
|
+
/**
|
|
856
|
+
* Flag set via `markToolRefreshPending()` by the AIAgent layer on MCP bus events.
|
|
857
|
+
* Checked at turn boundaries to trigger `refreshTools()`.
|
|
858
|
+
*
|
|
859
|
+
* Refreshing mid-turn would mutate the tool set while the LLM is actively
|
|
860
|
+
* generating tool calls against the current set, risking inconsistent state.
|
|
861
|
+
* Instead, the refresh is deferred to the next turn boundary:
|
|
862
|
+
*
|
|
863
|
+
* - Consumed in `onTurnStarted` (primary) so the next turn uses updated tools
|
|
864
|
+
* immediately, before the API call is made.
|
|
865
|
+
* - Consumed in `onTurnFinished` (safety net) for updates that arrive
|
|
866
|
+
* mid-turn, ensuring the turn after that also picks up the updated tools.
|
|
867
|
+
*/
|
|
868
|
+
protected hasPendingToolRefresh: boolean;
|
|
869
|
+
/**
|
|
870
|
+
* Set to `true` by `refreshTools()` when MCP direct-inject tools have been
|
|
871
|
+
* re-prepared but the canonical turn number for the next turn is not yet known.
|
|
872
|
+
*
|
|
873
|
+
* Flushed to the tool ledger in `onTurnStarted`, after `consumeTurnNumber()`
|
|
874
|
+
* has committed the real canonical value, ensuring `recordInjection` is always
|
|
875
|
+
* called with the correct turn number rather than a speculative `currentTurnNumber + 1`.
|
|
876
|
+
*/
|
|
877
|
+
private hasPendingLedgerInjection;
|
|
878
|
+
/**
|
|
879
|
+
* Marks that MCP tools have changed and should be refreshed at the next turn boundary.
|
|
880
|
+
*
|
|
881
|
+
* Called by the AIAgent layer when receiving MCP bus events (`mcp.tools.updated`,
|
|
882
|
+
* `mcp.tools.enabled`). The connector will call `refreshTools()` before processing
|
|
883
|
+
* the next queued message.
|
|
884
|
+
*/
|
|
885
|
+
markToolRefreshPending(): void;
|
|
886
|
+
/**
|
|
887
|
+
* Fetch adapter-specific tools from the bus and cache them internally.
|
|
888
|
+
*
|
|
889
|
+
* Called once before the first session is created. Implementations store
|
|
890
|
+
* the result in their own typed field (e.g. `this.anthropicTools`) which is
|
|
891
|
+
* then passed to `createSession()`.
|
|
892
|
+
*/
|
|
893
|
+
protected abstract fetchTools(): Promise<void>;
|
|
894
|
+
/**
|
|
895
|
+
* Construct and return the concrete session instance.
|
|
896
|
+
*
|
|
897
|
+
* Called by `initializeSession` after tools have been fetched. The session
|
|
898
|
+
* config should be fully populated from `this.config`, `this.cwd`,
|
|
899
|
+
* `this.model`, and the previously fetched tools.
|
|
900
|
+
* @returns The initialised adapter-specific session
|
|
901
|
+
*/
|
|
902
|
+
protected abstract createSession(): TSession;
|
|
903
|
+
/**
|
|
904
|
+
* Perform any adapter-specific post-creation wiring on the session.
|
|
905
|
+
*
|
|
906
|
+
* Called immediately after `createSession()` and before `wireSessionEvents()`.
|
|
907
|
+
* The default implementation is a no-op — override only when the adapter
|
|
908
|
+
* needs extra wiring beyond what `createSession()` already handles.
|
|
909
|
+
* @param _session - The freshly created session instance
|
|
910
|
+
*/
|
|
911
|
+
protected afterSessionCreated(_session: TSession): void;
|
|
912
|
+
/**
|
|
913
|
+
* Return the adapter's namespace-specific turn subjects for `wireSessionEvents`.
|
|
914
|
+
*
|
|
915
|
+
* Forwarded to `ProceduralAgentConnector.wireSessionEvents` which subscribes
|
|
916
|
+
* to turn lifecycle events and updates connector processing state.
|
|
917
|
+
* @returns Turn subject definitions for this adapter's namespace
|
|
918
|
+
*/
|
|
919
|
+
protected abstract getTurnSubjects(): WireSessionSubjects<TBus['namespace']>;
|
|
920
|
+
/**
|
|
921
|
+
* Get the active session instance.
|
|
922
|
+
* @returns The session or `undefined` if not yet initialised
|
|
923
|
+
*/
|
|
924
|
+
protected getSession(): TSession | undefined;
|
|
925
|
+
/**
|
|
926
|
+
* Ensure the session is initialised and return it.
|
|
927
|
+
*
|
|
928
|
+
* No-op if the session already exists (idempotent). Creates and wires the
|
|
929
|
+
* session on first call by delegating to `initializeSession`.
|
|
930
|
+
* @returns The initialised session as `ProceduralConnectorSession`
|
|
931
|
+
*/
|
|
932
|
+
protected ensureSession(): Promise<ProceduralConnectorSession>;
|
|
933
|
+
/**
|
|
934
|
+
* Get the user message queue for this connector.
|
|
935
|
+
* @returns The `UserMessageQueue` instance shared across all turns
|
|
936
|
+
*/
|
|
937
|
+
protected getSessionQueue(): UserMessageQueue;
|
|
938
|
+
/**
|
|
939
|
+
* Initialise the session for SDK lifecycle management.
|
|
940
|
+
*
|
|
941
|
+
* Fetches tools (once via `fetchToolsViaBus`), prepares MCP direct-inject
|
|
942
|
+
* tools, constructs the concrete session via `createSession`, runs optional
|
|
943
|
+
* adapter-specific post-creation wiring via `afterSessionCreated`, wires turn
|
|
944
|
+
* events to the connector state machine via `wireSessionEvents`, pushes any
|
|
945
|
+
* MCP direct-inject tools into the session via `updateTools`, then records
|
|
946
|
+
* the initial injection set in the tool ledger at the correct turn number
|
|
947
|
+
* (1 for fresh sessions; the staged canonical turn for connector swaps).
|
|
948
|
+
*/
|
|
949
|
+
private initializeSession;
|
|
950
|
+
/**
|
|
951
|
+
* Convert MCP direct-inject tools from the session context to the generic
|
|
952
|
+
* `ToolListItem` format and cache in `this.mcpDirectTools`.
|
|
953
|
+
*
|
|
954
|
+
* Called during `initializeSession()` after `fetchToolsViaBus()`, and again
|
|
955
|
+
* by `refreshTools()` when the tool set may have changed. Reads from
|
|
956
|
+
* `mcpSessionContextCache` when available (populated by a bus re-resolve),
|
|
957
|
+
* falling back to the startup snapshot in `config.mcpSessionContext`.
|
|
958
|
+
* No-op when neither source is present.
|
|
959
|
+
*/
|
|
960
|
+
protected prepareMcpDirectTools(): void;
|
|
961
|
+
/**
|
|
962
|
+
* Fetch tools from the bus if not already loaded.
|
|
963
|
+
*
|
|
964
|
+
* Guards with a `this.session` check so tools are only fetched once per
|
|
965
|
+
* connector lifetime. Delegates to the abstract `fetchTools` hook which each
|
|
966
|
+
* adapter implements to populate its own typed tools field.
|
|
967
|
+
*/
|
|
968
|
+
protected fetchToolsViaBus(): Promise<void>;
|
|
969
|
+
/**
|
|
970
|
+
* Re-prepare MCP direct-inject tools for the next turn.
|
|
971
|
+
*
|
|
972
|
+
* Called at turn boundary when `hasPendingToolRefresh` is true (set via
|
|
973
|
+
* `markToolRefreshPending()`). When a full `McpSessionContext` (with
|
|
974
|
+
* `sessionId`) is available, issues a `McpSubjects['session.resolve']` bus
|
|
975
|
+
* call to fetch the latest tool state from the registry, updating
|
|
976
|
+
* `mcpSessionContextCache` so `prepareMcpDirectTools()` reads fresh data.
|
|
977
|
+
* If the bus call fails, logs a warning and falls back to the previous cache
|
|
978
|
+
* (or the startup snapshot) so the connector remains operational.
|
|
979
|
+
*
|
|
980
|
+
* Subclasses that manage native adapter-format tools (e.g. Anthropic, OpenAI)
|
|
981
|
+
* override this to: (1) re-fetch their native tools, (2) call
|
|
982
|
+
* `super.refreshTools()` to re-prepare `mcpDirectTools` and arm the ledger
|
|
983
|
+
* flag, then (3) push the updated tool list to the active session via
|
|
984
|
+
* `this.getSession()?.updateTools?.(this.mcpDirectTools)`.
|
|
985
|
+
*
|
|
986
|
+
* Unlike `fetchTools()` which runs once before session creation,
|
|
987
|
+
* `refreshTools()` operates on a live session and may be called multiple
|
|
988
|
+
* times during a connector's lifetime.
|
|
989
|
+
*/
|
|
990
|
+
protected refreshTools(): Promise<void>;
|
|
991
|
+
/**
|
|
992
|
+
* Re-resolve the MCP session context from the bus and update the cache.
|
|
993
|
+
*
|
|
994
|
+
* Only fires when the startup config holds a full `McpSessionContext` (i.e.
|
|
995
|
+
* it has a `sessionId`). Standalone connectors created without a session skip
|
|
996
|
+
* this and continue to use the existing cache or startup snapshot.
|
|
997
|
+
* On bus failure the warning is logged and the cache is left unchanged so
|
|
998
|
+
* the connector can continue with the last known good tool set.
|
|
999
|
+
*/
|
|
1000
|
+
private resolveAndCacheMcpContext;
|
|
1001
|
+
/**
|
|
1002
|
+
* Wire turn-boundary hooks into the session lifecycle.
|
|
1003
|
+
*
|
|
1004
|
+
* - `onTurnStarted`: commit the canonical turn number via `consumeTurnNumber`,
|
|
1005
|
+
* refresh tools if a pending update arrived while idle or during the previous
|
|
1006
|
+
* turn (primary refresh path), then flush any pending ledger injection so
|
|
1007
|
+
* `recordInjection` is always called with the real turn number. The order
|
|
1008
|
+
* matters: consumeTurnNumber → refreshTools → recordInjection, because
|
|
1009
|
+
* `refreshTools` sets `hasPendingLedgerInjection`.
|
|
1010
|
+
* - `onTurnFinished`: safety-net refresh for updates that arrive mid-turn,
|
|
1011
|
+
* before draining the queue so the following turn uses the updated tool set.
|
|
1012
|
+
* @returns Wire session configuration with the turn hooks
|
|
1013
|
+
*/
|
|
1014
|
+
protected getWireSessionConfig(): WireSessionConfig;
|
|
1015
|
+
/**
|
|
1016
|
+
* Resolve the runtime system prompt to a plain string for the SDK API.
|
|
1017
|
+
*
|
|
1018
|
+
* - `string` mode: use as-is
|
|
1019
|
+
* - Append mode: use `content` directly (stream-based adapters have no base
|
|
1020
|
+
* prompt to append to)
|
|
1021
|
+
* @returns Resolved prompt string, or `undefined` if no prompt is set
|
|
1022
|
+
*/
|
|
1023
|
+
protected resolveSystemPrompt(): string | undefined;
|
|
1024
|
+
/**
|
|
1025
|
+
* Send a message to the agent.
|
|
1026
|
+
* @param message - The normalised message to send
|
|
1027
|
+
* @param options - Optional send message options
|
|
1028
|
+
* @returns A handle for tracking the message
|
|
1029
|
+
*/
|
|
1030
|
+
sendMessage(message: NormalizedMessageInput, options?: ConnectorSendMessageOptions): Promise<MessageHandle>;
|
|
1031
|
+
/**
|
|
1032
|
+
* Abort the agent and clean up resources.
|
|
1033
|
+
*
|
|
1034
|
+
* Note: Session-closed event emission is handled by the adapter's AIAgent
|
|
1035
|
+
* layer, not by the connector.
|
|
1036
|
+
*/
|
|
1037
|
+
abort(): void;
|
|
1038
|
+
/**
|
|
1039
|
+
* Gracefully close the session.
|
|
1040
|
+
*/
|
|
1041
|
+
close(): Promise<void>;
|
|
1042
|
+
/**
|
|
1043
|
+
* Perform an in-place model update without swapping the connector.
|
|
1044
|
+
*
|
|
1045
|
+
* Stream-based adapters are stateless — the session caches `config.model` at
|
|
1046
|
+
* construction but must be synced here so the next turn uses the new model.
|
|
1047
|
+
*
|
|
1048
|
+
* **Mutation contract:** Implementations MUST NOT mutate `this.model`.
|
|
1049
|
+
* The caller owns the connector-level `model` field update after this returns.
|
|
1050
|
+
* @param newModel - The model identifier to switch to
|
|
1051
|
+
* @returns Always `true` — stateless APIs never require a full connector swap
|
|
1052
|
+
*/
|
|
1053
|
+
changeModelInPlace(newModel: string): Promise<boolean>;
|
|
1054
|
+
/**
|
|
1055
|
+
* Perform an in-place working-directory update without swapping the connector.
|
|
1056
|
+
*
|
|
1057
|
+
* Stream-based adapters are stateless — cwd is only used for tool execution
|
|
1058
|
+
* context, not for persistent session state.
|
|
1059
|
+
*
|
|
1060
|
+
* **Mutation contract:** Implementations MUST NOT mutate `this.cwd`.
|
|
1061
|
+
* The caller owns the connector-level `cwd` field update after this returns.
|
|
1062
|
+
* @param newCwd - The working directory path to switch to
|
|
1063
|
+
* @returns Always `true` — stateless APIs never require a full connector swap
|
|
1064
|
+
*/
|
|
1065
|
+
changeCwdInPlace(newCwd: string): Promise<boolean>;
|
|
1066
|
+
/**
|
|
1067
|
+
* Perform an in-place reasoning effort update without swapping the connector.
|
|
1068
|
+
*
|
|
1069
|
+
* Stream-based adapters pass `reasoning_effort` (or equivalent) per-request.
|
|
1070
|
+
* The session's `currentReasoningEffort` field is updated so the next API
|
|
1071
|
+
* call uses the new level without requiring a full connector swap.
|
|
1072
|
+
*
|
|
1073
|
+
* **Mutation contract:** Implementations MUST NOT mutate `this.currentReasoningEffort`.
|
|
1074
|
+
* The caller owns the connector-level field update after this returns `true`.
|
|
1075
|
+
* @param newLevel - The new reasoning effort level to apply
|
|
1076
|
+
* @returns Always `true` — stateless APIs never require a full connector swap
|
|
1077
|
+
*/
|
|
1078
|
+
changeReasoningInPlace(newLevel: AIReasoningLevel$1): Promise<boolean>;
|
|
1079
|
+
/**
|
|
1080
|
+
* Interrupt the current turn by aborting the active API request.
|
|
1081
|
+
*/
|
|
1082
|
+
interrupt(): Promise<void>;
|
|
1083
|
+
/**
|
|
1084
|
+
* Get the adapter session ID.
|
|
1085
|
+
*
|
|
1086
|
+
* Stream-based adapters use a locally-generated UUID (stateless APIs provide
|
|
1087
|
+
* no server-side session identity).
|
|
1088
|
+
* @returns The local session UUID
|
|
1089
|
+
*/
|
|
1090
|
+
getAdapterSessionId(): Promise<string>;
|
|
1091
|
+
/**
|
|
1092
|
+
* Initialise `adapterSessionId` from config or generate a fresh UUID.
|
|
1093
|
+
*
|
|
1094
|
+
* Call this at the end of each concrete constructor after `super()`. The
|
|
1095
|
+
* nullish-assignment guard ensures the swap case (where the base constructor
|
|
1096
|
+
* already populated `adapterSessionId` from config) is preserved.
|
|
1097
|
+
*/
|
|
1098
|
+
protected initAdapterSessionId(): void;
|
|
1099
|
+
}
|
|
1100
|
+
//#endregion
|
|
1101
|
+
//#region adapters/shared/stream-session/src/agent/base-stream-agent.d.ts
|
|
1102
|
+
/**
|
|
1103
|
+
* Extract the bus namespace from a connector via the same conditional type used by
|
|
1104
|
+
* `AIAgent.subscribeConnector` and `AIAgent.createConnectorEventMapping`.
|
|
1105
|
+
*
|
|
1106
|
+
* Using the identical conditional type expression ensures TypeScript resolves the
|
|
1107
|
+
* constraint at call sites without a namespace mismatch error.
|
|
1108
|
+
* @typeParam TConnector - Connector type extending `AIAgentConnector<ScopedBus<string>>`
|
|
1109
|
+
*/
|
|
1110
|
+
type ConnectorNamespace<TConnector extends AIAgentConnector<ScopedBus<string>>> = TConnector extends AIAgentConnector<infer TBus> ? TBus['namespace'] : never;
|
|
1111
|
+
type ToolCallArgs = Record<string, unknown>;
|
|
1112
|
+
/**
|
|
1113
|
+
* A manually typed subject definition for event (non-request) subjects.
|
|
1114
|
+
*
|
|
1115
|
+
* Uses a structural interface rather than `SubjectDefinition<SubjectRecord, ...>` to
|
|
1116
|
+
* avoid the incompatibility that arises when the full namespace `SubjectRecord` contains
|
|
1117
|
+
* a mix of event and request subjects (e.g., `tool_approval` is a request). By defining
|
|
1118
|
+
* only the `$meta` fields we care about, concrete subjects that extend `ScopedSubjectDefinition`
|
|
1119
|
+
* are still assignable here as long as they carry event payloads.
|
|
1120
|
+
*
|
|
1121
|
+
* `HandlerForSubjectDefinition<EventSubjectDef<N>>` resolves to
|
|
1122
|
+
* `EventHandler<Record<string, unknown>>` — a concrete, non-`never` handler type —
|
|
1123
|
+
* enabling the base class wire methods to use typed handler parameters.
|
|
1124
|
+
* @typeParam TNamespace - The adapter bus namespace string
|
|
1125
|
+
*/
|
|
1126
|
+
type EventSubjectDef<TNamespace extends string> = {
|
|
1127
|
+
readonly $meta: {
|
|
1128
|
+
readonly payload: EventMessagePayload<Record<string, unknown>>;
|
|
1129
|
+
readonly namespace: TNamespace;
|
|
1130
|
+
readonly isRequest: false;
|
|
1131
|
+
readonly local: boolean;
|
|
1132
|
+
readonly channel: boolean;
|
|
1133
|
+
};
|
|
1134
|
+
readonly subject: string;
|
|
1135
|
+
};
|
|
1136
|
+
/**
|
|
1137
|
+
* Adapter-specific subjects for stream-based agent wiring.
|
|
1138
|
+
*
|
|
1139
|
+
* Groups all connector scoped subjects used during event wiring into a single spec
|
|
1140
|
+
* type parameter. Subjects whose payloads differ between adapters (chunk, usage,
|
|
1141
|
+
* toolCalls, reasoningComplete) carry a generic `EventSubjectDef`. Concrete adapters
|
|
1142
|
+
* supply fully typed subjects when implementing `getConnectorSubjects()` — the typed
|
|
1143
|
+
* subjects extend `EventSubjectDef` so TypeScript can resolve handler signatures.
|
|
1144
|
+
* @typeParam TNamespace - The adapter bus namespace string literal
|
|
1145
|
+
*/
|
|
1146
|
+
interface StreamAdapterSubjectSpec<TNamespace extends string> {
|
|
1147
|
+
/**
|
|
1148
|
+
* Streaming chunk subject. Payload differs per adapter:
|
|
1149
|
+
* - Anthropic: `{ eventType, index, delta }` (delta.text for text_delta)
|
|
1150
|
+
* - OpenAI: `{ eventType, id, choices }` (choices[0].delta.content)
|
|
1151
|
+
*/
|
|
1152
|
+
readonly chunk: EventSubjectDef<TNamespace>;
|
|
1153
|
+
/**
|
|
1154
|
+
* Token usage subject. Payload differs per adapter:
|
|
1155
|
+
* - Anthropic: has `cache_read_input_tokens` / `cache_creation_input_tokens`
|
|
1156
|
+
* - OpenAI: has `prompt_tokens_details` / `completion_tokens_details`
|
|
1157
|
+
*/
|
|
1158
|
+
readonly usage: EventSubjectDef<TNamespace>;
|
|
1159
|
+
/**
|
|
1160
|
+
* Tool calls subject. Payload differs per adapter:
|
|
1161
|
+
* - Anthropic: each tool call entry carries a provider `blockIndex`
|
|
1162
|
+
* - OpenAI: base ToolCall without blockIndex
|
|
1163
|
+
*/
|
|
1164
|
+
readonly toolCalls: EventSubjectDef<TNamespace>;
|
|
1165
|
+
/**
|
|
1166
|
+
* Reasoning complete subject. Payload differs per adapter:
|
|
1167
|
+
* - Anthropic: base + `signature` field (for native history round-trip)
|
|
1168
|
+
* - OpenAI: base only
|
|
1169
|
+
*/
|
|
1170
|
+
readonly reasoningComplete: EventSubjectDef<TNamespace>;
|
|
1171
|
+
/** Assembled message complete event — `content` field is shared across adapters. */
|
|
1172
|
+
readonly messageComplete: EventSubjectDef<TNamespace>;
|
|
1173
|
+
/** Incremental reasoning content delta — payload is shared across adapters. */
|
|
1174
|
+
readonly reasoningDelta: EventSubjectDef<TNamespace>;
|
|
1175
|
+
/** Tool execution started lifecycle event — payload is shared across adapters. */
|
|
1176
|
+
readonly toolStarted: EventSubjectDef<TNamespace>;
|
|
1177
|
+
/** Tool execution completed lifecycle event — payload is shared across adapters. */
|
|
1178
|
+
readonly toolCompleted: EventSubjectDef<TNamespace>;
|
|
1179
|
+
/** Agent turn started lifecycle event — payload is shared across adapters. */
|
|
1180
|
+
readonly agentStarted: EventSubjectDef<TNamespace>;
|
|
1181
|
+
/** Agent turn completed lifecycle event — payload is shared across adapters. */
|
|
1182
|
+
readonly agentComplete: EventSubjectDef<TNamespace>;
|
|
1183
|
+
/** Connector-level error event — payload is shared across adapters. */
|
|
1184
|
+
readonly error: EventSubjectDef<TNamespace>;
|
|
1185
|
+
}
|
|
1186
|
+
/**
|
|
1187
|
+
* Abstract base class for stream-based AI adapter agents.
|
|
1188
|
+
*
|
|
1189
|
+
* Captures the shared event-wiring logic between the Anthropic SDK and
|
|
1190
|
+
* OpenAI Node agent implementations. Both agents follow an identical two-tier
|
|
1191
|
+
* fan-out pattern:
|
|
1192
|
+
*
|
|
1193
|
+
* 1. `wireSdkEvents()` routes the sdk.event catch-all to typed semantic subjects
|
|
1194
|
+
* (adapter-specific — kept abstract to avoid complex generics with `createConnectorEventMapping`).
|
|
1195
|
+
* 2. `wireSemanticEvents()` wires semantic subjects to global `agent.*` subjects
|
|
1196
|
+
* (shared — implemented here; delegates adapter-specific parts to abstract hooks).
|
|
1197
|
+
*
|
|
1198
|
+
* Abstract hooks that subclasses must implement:
|
|
1199
|
+
* - `wireSdkEvents()` — routes sdk.event to semantic subjects (adapter-specific).
|
|
1200
|
+
* - `getConnectorSubjects()` — returns the semantic subject spec for this adapter.
|
|
1201
|
+
* - `extractChunkText(payload)` — extracts text from adapter-specific chunk events.
|
|
1202
|
+
* - `extractUsagePayload(payload)` — maps adapter-specific usage to `NormalizedCallUsage`.
|
|
1203
|
+
* - `emitUsageContextWindowUpdate(payload)` — emits context window status after usage tracking.
|
|
1204
|
+
* - `reserveToolCallBlockIndex(tc)` — assigns block index for a tool call.
|
|
1205
|
+
* - `afterToolCallStepEmitted(blockIndex)` — post-emission book-keeping for tool_calls.
|
|
1206
|
+
* - `getFallbackToolCompletedBlockIndex()` — fallback index when map lookup misses.
|
|
1207
|
+
* - `afterToolCompletedStepEmitted(resolvedBlockIndex)` — post-emission book-keeping for tool_completed.
|
|
1208
|
+
* - `buildReasoningBlock(payload)` — constructs the reasoning `SessionMessageBlock`.
|
|
1209
|
+
* - `wireToolApprovalRpc(connector)` — wires the adapter's tool_approval RPC to the global bus.
|
|
1210
|
+
* @typeParam TBus - Scoped bus for the adapter namespace
|
|
1211
|
+
* @typeParam TConnector - Concrete connector type extending `AIAgentConnector<TBus>`
|
|
1212
|
+
* @typeParam TSpec - Subject spec whose namespace matches `ConnectorNamespace<TConnector>`
|
|
1213
|
+
*/
|
|
1214
|
+
declare abstract class BaseStreamAgent<TBus extends ScopedBus<string>, TConnector extends AIAgentConnector<TBus>, TSpec extends StreamAdapterSubjectSpec<ConnectorNamespace<TConnector>>> extends AIAgent<TBus, TConnector> {
|
|
1215
|
+
/**
|
|
1216
|
+
* Track toolCallId → blockIndex for correlation between step.started and step.finished.
|
|
1217
|
+
*
|
|
1218
|
+
* Both adapters emit parallel tool calls (all at once in the tool_calls event),
|
|
1219
|
+
* but results arrive asynchronously in separate tool_completed events, potentially
|
|
1220
|
+
* out of order. This map ensures each tool's step.finished uses the same blockIndex
|
|
1221
|
+
* as its step.started, maintaining correlation regardless of arrival order.
|
|
1222
|
+
*
|
|
1223
|
+
* Pattern:
|
|
1224
|
+
* 1. tool_calls event: reserve blockIndex per toolCallId, store in map
|
|
1225
|
+
* 2. tool_completed event: lookup stored blockIndex, emit step.finished, delete from map
|
|
1226
|
+
*/
|
|
1227
|
+
protected toolBlockIndexMap: Map<string, number>;
|
|
1228
|
+
/**
|
|
1229
|
+
* Track tool call IDs whose completion already arrived.
|
|
1230
|
+
*
|
|
1231
|
+
* Some providers can deliver `tool_completed` before `tool_calls` under
|
|
1232
|
+
* race conditions. Mark completed IDs so late `tool_calls` can be ignored
|
|
1233
|
+
* instead of emitting out-of-order step.started/tool.use events.
|
|
1234
|
+
*/
|
|
1235
|
+
protected completedToolIds: Set<string>;
|
|
1236
|
+
/**
|
|
1237
|
+
* Stash tool call args keyed by toolCallId.
|
|
1238
|
+
*
|
|
1239
|
+
* Args are available when `tool_calls` fires (parsed from function arguments)
|
|
1240
|
+
* but must be forwarded to `tool_completed` which arrives separately.
|
|
1241
|
+
* Entries are removed after emission to prevent unbounded growth.
|
|
1242
|
+
*/
|
|
1243
|
+
protected toolCallArgsMap: Map<string, ToolCallArgs>;
|
|
1244
|
+
private resetPerTurnToolTracking;
|
|
1245
|
+
/**
|
|
1246
|
+
* Tier 1: Route sdk.event catch-all to typed semantic subjects.
|
|
1247
|
+
*
|
|
1248
|
+
* Implement by calling `this.createConnectorEventMapping(connectorSubjects.sdk.event, 'eventType', { ... }, 'event')`
|
|
1249
|
+
* using the adapter's own typed connector subjects. This is kept adapter-specific to avoid
|
|
1250
|
+
* complex generic type constraints when calling `createConnectorEventMapping` from a generic context.
|
|
1251
|
+
*/
|
|
1252
|
+
protected abstract wireSdkEvents(): void;
|
|
1253
|
+
/**
|
|
1254
|
+
* Return the semantic subject spec for this adapter's connector namespace.
|
|
1255
|
+
*
|
|
1256
|
+
* Called once during `wireEvents()`. The returned subjects are used to subscribe
|
|
1257
|
+
* to connector events and emit to global `agent.*` subjects.
|
|
1258
|
+
* @returns Subject spec for this adapter's connector namespace
|
|
1259
|
+
*/
|
|
1260
|
+
protected abstract getConnectorSubjects(): TSpec;
|
|
1261
|
+
/**
|
|
1262
|
+
* Extract plain text from an adapter-specific chunk event payload.
|
|
1263
|
+
*
|
|
1264
|
+
* - Anthropic: checks `delta.type === 'text_delta'` and returns `delta.text`
|
|
1265
|
+
* - OpenAI: returns `choices[0]?.delta?.content ?? ''`
|
|
1266
|
+
* @param payload - Raw chunk event payload (cast from the connector's chunk event type)
|
|
1267
|
+
* @returns Plain text string, or empty string when the chunk carries no text content
|
|
1268
|
+
*/
|
|
1269
|
+
protected abstract extractChunkText(payload: Record<string, unknown>): string;
|
|
1270
|
+
/**
|
|
1271
|
+
* Map an adapter-specific usage event payload to the shared `NormalizedCallUsage` format.
|
|
1272
|
+
*
|
|
1273
|
+
* - Anthropic: reads `cache_read_input_tokens`, `cache_creation_input_tokens`
|
|
1274
|
+
* - OpenAI: reads `prompt_tokens_details.cached_tokens`, `completion_tokens_details.reasoning_tokens`
|
|
1275
|
+
* @param payload - Raw usage event payload (cast from the connector's usage event type)
|
|
1276
|
+
* @returns Normalized usage metrics ready for `trackUsage()`
|
|
1277
|
+
*/
|
|
1278
|
+
protected abstract extractUsagePayload(payload: Record<string, unknown>): NormalizedCallUsage;
|
|
1279
|
+
/**
|
|
1280
|
+
* Emit the context window update after processing a usage event.
|
|
1281
|
+
*
|
|
1282
|
+
* Adapters differ in which fields provide the cached token count and the default
|
|
1283
|
+
* max context window size. Called from `wireUsageEvents` after `trackUsage()`.
|
|
1284
|
+
* @param payload - Raw usage event payload (same object passed to `extractUsagePayload`)
|
|
1285
|
+
*/
|
|
1286
|
+
protected abstract emitUsageContextWindowUpdate(payload: Record<string, unknown>): Promise<void>;
|
|
1287
|
+
/**
|
|
1288
|
+
* Reserve a block index for a tool call from the tool_calls event.
|
|
1289
|
+
*
|
|
1290
|
+
* - Anthropic: returns `(tc as AnthropicToolCall).blockIndex` (provider-native; no counter mutation).
|
|
1291
|
+
* - OpenAI: returns `this.getBlockIndex()` and increments the internal counter.
|
|
1292
|
+
*
|
|
1293
|
+
* Called once per tool call in `wireToolEvents` before emitting step.started.
|
|
1294
|
+
* @param tc - The tool call entry from the tool_calls event payload
|
|
1295
|
+
* @returns The block index to use for this tool call's step.started / step.finished pair
|
|
1296
|
+
*/
|
|
1297
|
+
protected abstract reserveToolCallBlockIndex(tc: ToolCall): number;
|
|
1298
|
+
/**
|
|
1299
|
+
* Perform adapter-specific book-keeping after a tool call's step.started has been emitted.
|
|
1300
|
+
*
|
|
1301
|
+
* - Anthropic: calls `reconcileInternalBlockIndex(blockIndex)` to keep the internal
|
|
1302
|
+
* block index counter in sync with provider-native indices.
|
|
1303
|
+
* - OpenAI: no-op (the counter was already incremented inside `reserveToolCallBlockIndex`).
|
|
1304
|
+
* @param blockIndex - The block index that was just emitted for this tool call
|
|
1305
|
+
*/
|
|
1306
|
+
protected abstract afterToolCallStepEmitted(blockIndex: number): void;
|
|
1307
|
+
/**
|
|
1308
|
+
* Return the fallback block index when `toolBlockIndexMap` has no entry for a toolCallId.
|
|
1309
|
+
*
|
|
1310
|
+
* Used only when a tool_completed event arrives without a matching tool_calls entry
|
|
1311
|
+
* (out-of-order delivery or state mismatch).
|
|
1312
|
+
*
|
|
1313
|
+
* - Anthropic: `this.getBlockIndex()` (also increments the internal counter for monotonicity)
|
|
1314
|
+
* - OpenAI: `-1` (sentinel indicating unknown index)
|
|
1315
|
+
* @returns Fallback block index for unresolvable toolCallId map lookups
|
|
1316
|
+
*/
|
|
1317
|
+
protected abstract getFallbackToolCompletedBlockIndex(): number;
|
|
1318
|
+
/**
|
|
1319
|
+
* Perform adapter-specific book-keeping after a tool_completed step.finished has been emitted.
|
|
1320
|
+
*
|
|
1321
|
+
* - Anthropic: calls `reconcileInternalBlockIndex(resolvedBlockIndex)`.
|
|
1322
|
+
* - OpenAI: no-op.
|
|
1323
|
+
* @param resolvedBlockIndex - The block index used for this tool's step.finished
|
|
1324
|
+
*/
|
|
1325
|
+
protected abstract afterToolCompletedStepEmitted(resolvedBlockIndex: number): void;
|
|
1326
|
+
/**
|
|
1327
|
+
* Build the `SessionMessageBlock` for a reasoning step from the reasoning_complete payload.
|
|
1328
|
+
*
|
|
1329
|
+
* - Anthropic: `{ type: 'reasoning', content, metadata: { signature } }` when `signature` is set
|
|
1330
|
+
* - OpenAI: `{ type: 'reasoning', content }` (no metadata)
|
|
1331
|
+
* @param payload - Raw reasoning complete event payload (cast from the connector's event type)
|
|
1332
|
+
* @returns A reasoning block suitable for `emitStepFinished`
|
|
1333
|
+
*/
|
|
1334
|
+
protected abstract buildReasoningBlock(payload: Record<string, unknown>): SessionMessageBlock;
|
|
1335
|
+
/**
|
|
1336
|
+
* Register the tool approval RPC handler for this adapter's connector.
|
|
1337
|
+
*
|
|
1338
|
+
* Wires the adapter-scoped `tool_approval` subject to the global
|
|
1339
|
+
* `AgentSubjects.toolApprove` via the adapter-specific `registerToolApprovalHandler`
|
|
1340
|
+
* factory (generated by `createToolApprovalHandler`). Called during `wireEvents()`.
|
|
1341
|
+
* @param connector - The adapter connector to register the tool approval handler on
|
|
1342
|
+
*/
|
|
1343
|
+
protected abstract wireToolApprovalRpc(connector: TConnector): void;
|
|
1344
|
+
/**
|
|
1345
|
+
* Wire connector events to global agent.* subjects.
|
|
1346
|
+
*
|
|
1347
|
+
* Entry point called by `AIAgent.init()` after connector creation.
|
|
1348
|
+
* Follows a two-tier fan-out pattern:
|
|
1349
|
+
* 1. `wireSdkEvents()` — abstract, routes sdk.event to typed semantic subjects.
|
|
1350
|
+
* 2. `wireSemanticEvents()` — shared, wires semantic subjects to global agent.* subjects.
|
|
1351
|
+
* @param connector - The adapter connector to wire events from
|
|
1352
|
+
*/
|
|
1353
|
+
protected wireEvents(connector: TConnector): void;
|
|
1354
|
+
/**
|
|
1355
|
+
* Wire semantic subjects to global agent.* subjects.
|
|
1356
|
+
*
|
|
1357
|
+
* Delegates to individual wire methods grouped by event category.
|
|
1358
|
+
* @param connector - The adapter connector to subscribe on
|
|
1359
|
+
* @param subjects - The adapter's connector subjects from `getConnectorSubjects()`
|
|
1360
|
+
*/
|
|
1361
|
+
private wireSemanticEvents;
|
|
1362
|
+
/**
|
|
1363
|
+
* Wire message streaming and completion events.
|
|
1364
|
+
*
|
|
1365
|
+
* - `chunk` → `agent.message_delta` (adapter-specific text via `extractChunkText`)
|
|
1366
|
+
* - `message_complete` → `agent.message` + step.started/step.finished for text content
|
|
1367
|
+
* @param connector - The adapter connector to subscribe on
|
|
1368
|
+
* @param subjects - The adapter's connector subjects
|
|
1369
|
+
*/
|
|
1370
|
+
private wireMessageEvents;
|
|
1371
|
+
/**
|
|
1372
|
+
* Wire token usage tracking events.
|
|
1373
|
+
*
|
|
1374
|
+
* Delegates payload parsing to `extractUsagePayload` and context window emission
|
|
1375
|
+
* to `emitUsageContextWindowUpdate` (both adapter-specific).
|
|
1376
|
+
* @param connector - The adapter connector to subscribe on
|
|
1377
|
+
* @param subjects - The adapter's connector subjects
|
|
1378
|
+
*/
|
|
1379
|
+
private wireUsageEvents;
|
|
1380
|
+
/**
|
|
1381
|
+
* Wire tool lifecycle events (tool_calls, tool_started, tool_completed).
|
|
1382
|
+
*
|
|
1383
|
+
* - `tool_calls` → per-tool `agent.step.started` + `agent.tool.use`
|
|
1384
|
+
* - `tool_started` → `agent.tool.started`
|
|
1385
|
+
* - `tool_completed` → `agent.step.finished` + `agent.tool.completed`
|
|
1386
|
+
* @param connector - The adapter connector to subscribe on
|
|
1387
|
+
* @param subjects - The adapter's connector subjects
|
|
1388
|
+
*/
|
|
1389
|
+
private wireToolEvents;
|
|
1390
|
+
/**
|
|
1391
|
+
* Wire reasoning streaming and completion events.
|
|
1392
|
+
*
|
|
1393
|
+
* - `reasoning_delta` → `agent.reasoning_delta`
|
|
1394
|
+
* - `reasoning_complete` → `agent.reasoning` + step.started/step.finished
|
|
1395
|
+
* @param connector - The adapter connector to subscribe on
|
|
1396
|
+
* @param subjects - The adapter's connector subjects
|
|
1397
|
+
*/
|
|
1398
|
+
private wireReasoningEvents;
|
|
1399
|
+
/**
|
|
1400
|
+
* Wire agent lifecycle events (agent_started, agent_complete, error).
|
|
1401
|
+
*
|
|
1402
|
+
* - `agent_started` → clears per-turn tool tracking and calls `emitStart()`
|
|
1403
|
+
* - `agent_complete` → clears per-turn tool tracking
|
|
1404
|
+
* - `error` → calls `emitError()` to stash error metadata for next `emitCompletion`
|
|
1405
|
+
*
|
|
1406
|
+
* Note: `agent_complete` emission is handled by `AIAgent` via `onMessageHandle()`
|
|
1407
|
+
* when the connector calls `markCompleted()`. We subscribe only for state reset.
|
|
1408
|
+
* @param connector - The adapter connector to subscribe on
|
|
1409
|
+
* @param subjects - The adapter's connector subjects
|
|
1410
|
+
*/
|
|
1411
|
+
private wireLifecycleEvents;
|
|
1412
|
+
}
|
|
1413
|
+
//#endregion
|
|
1414
|
+
export { type AgentCompleteEvent, AgentCompleteEventSchema, type AgentStartedEvent, AgentStartedEventSchema, type BaseSessionEmitEvent, BaseStreamAgent, BaseStreamConnector, type BaseStreamConnectorConfig, BaseStreamSession, type ErrorEvent, ErrorEventSchema, type HandleToolCallsCallbacks, MAX_TOOL_RESULT_CONTENT_CHARS, type MessageCompleteEvent, MessageCompleteEventSchema, type MessageToolCall, MessageToolCallSchema, type ReasoningCompleteEvent, ReasoningCompleteEventSchema, type ReasoningDeltaEvent, ReasoningDeltaEventSchema, type StreamAdapterSubjectSpec, type StreamConnectorSession, type StreamSdkEventEnvelope, type StreamSessionConfig, type StreamSessionTurnState, StreamSessionTurnStateSchema, type ToolCall, type ToolCallFunction, ToolCallFunctionSchema, type ToolCallPayload, ToolCallSchema, type ToolCallsEvent, ToolCallsEventSchema, type ToolCompletedEvent, ToolCompletedEventSchema, type ToolExecutionContextOverrides, type ToolLifecycleEmitter, type ToolResultBuilder, type ToolStartedEvent, ToolStartedEventSchema, type TurnStateChanged, TurnStateChangedSchema, applyApprovedArgs, boundToolResultContent, executeTool, extractToolCallPayload, filterToolsWithSchema, handleToolCalls, loadToolsFromRegistry, toGlobalToolApproval };
|