@makaio/framework 1.0.0-dev-1779046984397
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/LICENSE +21 -0
- package/README.md +363 -0
- package/dist/account-identity-Ce1Bwrqi.mjs +1 -0
- package/dist/adapter-CbyjCE2d.mjs +1 -0
- package/dist/adapters/acp-client/index.d.mts +209 -0
- package/dist/adapters/acp-client/index.mjs +1 -0
- package/dist/adapters/config/index.d.mts +429 -0
- package/dist/adapters/config/index.mjs +1 -0
- package/dist/adapters/index.d.mts +4175 -0
- package/dist/adapters/index.mjs +11 -0
- package/dist/adapters/node.d.mts +263 -0
- package/dist/adapters/node.mjs +4 -0
- package/dist/adapters/stream-session/index.d.mts +1384 -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/base-orchestrator-9z8TuA5a.d.mts +772 -0
- package/dist/bus/index.d.mts +3331 -0
- package/dist/bus/index.mjs +1 -0
- package/dist/bus-B1seC4M_.mjs +2 -0
- package/dist/capability-service-tnpR_TaB.mjs +1 -0
- package/dist/chunk-Dc06z0qk.mjs +1 -0
- package/dist/chunk-cpUYaJdV.mjs +1 -0
- package/dist/cleanEnvForAdapter-DvcIGXTG.mjs +1 -0
- package/dist/client-Dh4x4GQN.mjs +1 -0
- package/dist/clients/index.d.mts +2786 -0
- package/dist/clients/index.mjs +1 -0
- package/dist/clients-namespace-B0xAPZ6J.d.mts +332 -0
- package/dist/config-namespace-DLSs83zr.d.mts +638 -0
- package/dist/config-namespace-MJT8P0Ud.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/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 +3 -0
- package/dist/contracts/extension/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 +12665 -0
- package/dist/contracts/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/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 +1001 -0
- package/dist/core/index.mjs +1 -0
- package/dist/credential-ref-DLCsoKVZ.mjs +1 -0
- package/dist/cursor-storage-DOQdvo9j.mjs +1 -0
- package/dist/definition-DkYy1PZz.mjs +1 -0
- package/dist/definition-DtUNiGom.d.mts +158 -0
- package/dist/definition-DxvZ9e22.d.mts +376 -0
- package/dist/drizzle-CWVVw7Er.mjs +1 -0
- package/dist/execution-target-BW_uiBVe.mjs +1 -0
- package/dist/extension-COqwS-2Q.mjs +1 -0
- package/dist/extension-Cbrl4YGX.mjs +1 -0
- package/dist/extension-namespace-zaGKi6Qj.mjs +1 -0
- package/dist/handlers-iGKUJ380.mjs +41 -0
- package/dist/harness-CEq1Zkf9.mjs +1 -0
- package/dist/hooks/index.d.mts +423 -0
- package/dist/hooks/index.mjs +1 -0
- package/dist/host-CXAUGGN0.mjs +1 -0
- package/dist/identity-B_A0mE63.mjs +1 -0
- package/dist/index-6lyShOoU.d.mts +225 -0
- package/dist/index-7sXlairn2.d.mts +43 -0
- package/dist/index-BAKM2GMH2.d.mts +535 -0
- package/dist/index-BB419vv-.d.mts +3897 -0
- package/dist/index-BJOfdtbw.d.mts +729 -0
- package/dist/index-BXP9GK5q.d.mts +1075 -0
- package/dist/index-BdPwu6c0.d.mts +1730 -0
- package/dist/index-BePI0ckL.d.mts +40 -0
- package/dist/index-Bigx81Kr.d.mts +37 -0
- package/dist/index-BnNqbx2I.d.mts +134 -0
- package/dist/index-Bv15sNLn.d.mts +389 -0
- package/dist/index-C-myW_aK.d.mts +412 -0
- package/dist/index-C9F3Fc1A.d.mts +2938 -0
- package/dist/index-CNxS4Tlu.d.mts +1 -0
- package/dist/index-CVA0m1g9.d.mts +995 -0
- package/dist/index-C_kS2aqV2.d.mts +438 -0
- package/dist/index-Ch3ph52M2.d.mts +40 -0
- package/dist/index-CnZOKNjU.d.mts +89 -0
- package/dist/index-D1T-PPqF.d.mts +67 -0
- package/dist/index-D7T8XCku.d.mts +341 -0
- package/dist/index-DBQtpFLE.d.mts +4843 -0
- package/dist/index-DEw90pa2.d.mts +183 -0
- package/dist/index-DQRsGXb5.d.mts +109 -0
- package/dist/index-Dd5s4MSm.d.mts +72 -0
- package/dist/index-DubqLGH8.d.mts +1002 -0
- package/dist/index-ESSDWIB7.d.mts +11 -0
- package/dist/index-N5K1NOYs.d.mts +184 -0
- package/dist/index-PdUSmPT2.d.mts +180 -0
- package/dist/index-SzSiyG61.d.mts +117 -0
- package/dist/index-T0471kWA.d.mts +6760 -0
- package/dist/index-WKjrpcA_.d.mts +218 -0
- package/dist/index-hapw9_En.d.mts +13592 -0
- package/dist/index-iID2R9G1.d.mts +1490 -0
- package/dist/kernel/cli/index.d.mts +141 -0
- package/dist/kernel/cli/index.mjs +1 -0
- package/dist/kernel/cli/schemas.d.mts +63 -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/model-registry-BNzpR6TU.mjs +1 -0
- package/dist/model-registry-CIscwC52.mjs +1 -0
- package/dist/namespace-0yuzAKlr.mjs +1 -0
- package/dist/namespace-8cNguvIp.mjs +1 -0
- package/dist/namespace-BK2erxpV.d.mts +921 -0
- package/dist/namespace-Bmc7AW4J2.mjs +1 -0
- package/dist/namespace-C2ufjgaQ.d.mts +767 -0
- package/dist/namespace-C54Oj025.d.mts +159 -0
- package/dist/namespace-CCDEOwmW.d.mts +1313 -0
- package/dist/namespace-CfEWMXBx.mjs +1 -0
- package/dist/namespace-CkLUtc0g.d.mts +580 -0
- package/dist/namespace-D5Wrt7YU.mjs +1 -0
- package/dist/namespace-DZcuLwEA.d.mts +51 -0
- package/dist/namespace-Db-p67Rg.mjs +1 -0
- package/dist/namespace-FWx6HxaW.d.mts +611 -0
- package/dist/namespace-GLGGcWPH.d.mts +43 -0
- package/dist/namespace-N0dfwSg6.mjs +1 -0
- package/dist/namespace-O5SNY-LV.d.mts +2226 -0
- package/dist/namespace-ZbthBQVt.d.mts +142 -0
- package/dist/namespace-bq4Prtzn.d.mts +2046 -0
- package/dist/namespace-pNcSglBS.mjs +1 -0
- package/dist/namespace-ptv-pw_g.d.mts +3019 -0
- package/dist/namespace-xkvVw3hf2.d.mts +189 -0
- package/dist/native-session-supervisor-L-UIaEfd.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 +1752 -0
- package/dist/node/transports/index.mjs +2 -0
- package/dist/orchestrator-shared-DrjtTXYh.d.mts +249 -0
- package/dist/orchestrator-shared-Wv1GI2mW.mjs +1 -0
- package/dist/platform-BbSLVg5b.mjs +1 -0
- package/dist/profile-4StaDQW0.mjs +1 -0
- package/dist/provider-context-CNRQ4d5m.mjs +1 -0
- package/dist/providers/index.d.mts +135 -0
- package/dist/providers/index.mjs +1 -0
- package/dist/providers-Cr4Za8a1.mjs +1 -0
- package/dist/providers-namespace-CDwxY_DV.d.mts +583 -0
- package/dist/schema-BwzXEtT2.d.mts +837 -0
- package/dist/schema-CAw_BqaG.mjs +1 -0
- package/dist/schema-introspection-D61TT_7b.mjs +1 -0
- package/dist/schema-uSGW-6oM.mjs +1 -0
- package/dist/schemas-BXstpWVp.mjs +1 -0
- package/dist/schemas-BdMU-gew.d.mts +160 -0
- package/dist/schemas-C40ZAJ33.mjs +1 -0
- package/dist/schemas-C5xtVqdb.d.mts +46 -0
- package/dist/schemas-CGZy_rU6.d.mts +13 -0
- package/dist/schemas-CLxtoKFy.mjs +1 -0
- package/dist/schemas-Co_sVhzz.mjs +1 -0
- package/dist/schemas-D9108Iv1.d.mts +182 -0
- package/dist/schemas-DENVYyds.d.mts +463 -0
- package/dist/schemas-DbWs_hj8.d.mts +174 -0
- package/dist/schemas-Di0XnnMX.d.mts +73 -0
- package/dist/schemas-KMA1efQg.d.mts +944 -0
- package/dist/schemas-qmn5SWPU.d.mts +312 -0
- package/dist/schemas-sshQEF3l.d.mts +237 -0
- package/dist/server-lifecycle-Cf_SZ27k.d.mts +160 -0
- package/dist/server-lifecycle-DbFwlrTW.mjs +1 -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/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/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 +5703 -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 +275 -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 +52 -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 +662 -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/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/services/worker/index.d.mts +3 -0
- package/dist/services/worker/index.mjs +1 -0
- package/dist/services/worker/namespace.d.mts +2 -0
- package/dist/services/worker/namespace.mjs +1 -0
- package/dist/services/worker/schemas.d.mts +2 -0
- package/dist/services/worker/schemas.mjs +1 -0
- package/dist/session-Do6lDZM4.mjs +123 -0
- package/dist/session-lineage-Eev4uo4I.d.mts +65 -0
- package/dist/session-piI1R5rP.mjs +1 -0
- package/dist/shared-DxHLl9UP.mjs +1 -0
- package/dist/shared-schemas-BgQv_tnu.mjs +1 -0
- package/dist/skill-CB5h-ZFQ.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 +98 -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-ADwyijoe.mjs +1 -0
- package/dist/storage-namespace-DAm8iWEj.d.mts +221 -0
- package/dist/storage-namespace-definition-CHu2k14q.mjs +1 -0
- package/dist/storage-namespace-definition-CJgqyXH1.d.mts +17 -0
- package/dist/style.css +3782 -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/tool-approval-service-BcBSUZCO.mjs +1 -0
- package/dist/tools/index.d.mts +825 -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-CDSgj0ee.mjs +1 -0
- package/dist/tray-menu-service-CTXC1Elg.mjs +1 -0
- package/dist/types-6WxLfoM3.d.mts +31 -0
- package/dist/types-BjToUrHp.d.mts +6619 -0
- package/dist/types-CD1LJwPc.d.mts +1009 -0
- package/dist/types-Cvrj2ogm.d.mts +305 -0
- package/dist/types-DYF5LxZY.d.mts +233 -0
- package/dist/types-t295YC6T.d.mts +262 -0
- package/dist/types-vNpkAe4Y.d.mts +128 -0
- package/dist/ui-components/index.d.mts +2342 -0
- package/dist/ui-components/index.mjs +8 -0
- package/dist/ui-config-CXmbsqZV.mjs +1 -0
- package/dist/ui-hooks/index.d.mts +1805 -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 +227 -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/resolve-package-root.d.mts +12 -0
- package/dist/utils/resolve-package-root.mjs +1 -0
- package/dist/utils/workspace-root.d.mts +27 -0
- package/dist/utils/workspace-root.mjs +2 -0
- package/dist/variant-D5kSrL3m.mjs +1 -0
- package/dist/version-CjS20oXi.mjs +1 -0
- package/dist/visibility-CZu8ooOA.mjs +1 -0
- package/dist/window-registry-CUftmDr3.mjs +1 -0
- package/dist/window-registry-C_IJmY8_.d.mts +130 -0
- package/package.json +346 -0
|
@@ -0,0 +1,1001 @@
|
|
|
1
|
+
import { ZodType, z } from "zod";
|
|
2
|
+
import { Paths, Simplify, UnknownRecord } from "type-fest";
|
|
3
|
+
|
|
4
|
+
//#region packages/makaio-core/src/types/config-storage.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Storage interface for config persistence.
|
|
7
|
+
*
|
|
8
|
+
* Generic interface allowing type-safe implementations with different
|
|
9
|
+
* config types. Simple file-based storage for bootstrap configuration.
|
|
10
|
+
* @typeParam TConfig - Type for configuration (defaults to unknown)
|
|
11
|
+
* @example Node.js file-based implementation
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import type { Config } from '@makaio/framework/contracts';
|
|
14
|
+
*
|
|
15
|
+
* class FileConfigStorage implements IConfigStorage<Config> {
|
|
16
|
+
* async getConfig(): Promise<Config> {
|
|
17
|
+
* const content = await fs.readFile('~/.makaio/config.json', 'utf-8');
|
|
18
|
+
* return ConfigSchema.parse(JSON.parse(content));
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* async saveConfig(config: Config): Promise<void> {
|
|
22
|
+
* await fs.writeFile('~/.makaio/config.json', JSON.stringify(config, null, 2));
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
* @example In-memory implementation for testing
|
|
27
|
+
* ```typescript
|
|
28
|
+
* class MemoryConfigStorage implements IConfigStorage<Config> {
|
|
29
|
+
* private config: Config = { mode: 'local', adapters: [] };
|
|
30
|
+
*
|
|
31
|
+
* async getConfig() { return this.config; }
|
|
32
|
+
* async saveConfig(config: Config) { this.config = config; }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
interface IConfigStorage<TConfig = unknown> {
|
|
37
|
+
/**
|
|
38
|
+
* Get the current config, or default if missing.
|
|
39
|
+
* @returns The config object
|
|
40
|
+
*/
|
|
41
|
+
getConfig(): Promise<TConfig>;
|
|
42
|
+
/**
|
|
43
|
+
* Save the config.
|
|
44
|
+
* @param config - The config object to save
|
|
45
|
+
*/
|
|
46
|
+
saveConfig(config: TConfig): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region packages/makaio-core/src/types/message.d.ts
|
|
50
|
+
/**
|
|
51
|
+
* Host-agnostic principal attached by a trusted local transport.
|
|
52
|
+
*
|
|
53
|
+
* The framework treats this as opaque metadata. Host code decides what
|
|
54
|
+
* principal kinds and claims mean.
|
|
55
|
+
*/
|
|
56
|
+
interface PrincipalContext {
|
|
57
|
+
/** Principal kind, such as `user`, `device`, `machine`, or host-defined values. */
|
|
58
|
+
readonly kind: string;
|
|
59
|
+
/** Optional stable principal identifier in the principal namespace. */
|
|
60
|
+
readonly id?: string;
|
|
61
|
+
/** Optional opaque claims supplied by the authenticating transport or host policy. */
|
|
62
|
+
readonly claims?: Readonly<Record<string, unknown>>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Authenticated peer metadata supplied by a transport connection.
|
|
66
|
+
*/
|
|
67
|
+
interface TransportPeerContext {
|
|
68
|
+
/** Peer kind, such as `browser`, `machine`, `worker`, or host-defined values. */
|
|
69
|
+
readonly kind: string;
|
|
70
|
+
/** Optional transport-level peer identifier. */
|
|
71
|
+
readonly id?: string;
|
|
72
|
+
/** Whether the receiving transport authenticated the peer. */
|
|
73
|
+
readonly authenticated?: boolean;
|
|
74
|
+
/** Whether the receiving transport established encrypted payload transport. */
|
|
75
|
+
readonly encrypted?: boolean;
|
|
76
|
+
/** Optional opaque peer claims. */
|
|
77
|
+
readonly claims?: Readonly<Record<string, unknown>>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Trusted context derived locally by the receiving transport.
|
|
81
|
+
*
|
|
82
|
+
* This context is never serialized into `BusMessage`; each receiving node must
|
|
83
|
+
* derive its own context from its own transport/session state.
|
|
84
|
+
*/
|
|
85
|
+
interface TransportReceiveContext {
|
|
86
|
+
/** Registered bus transport name that received the message. */
|
|
87
|
+
readonly transportName: string;
|
|
88
|
+
/** Optional connection/session identifier local to the transport. */
|
|
89
|
+
readonly connectionId?: string;
|
|
90
|
+
/** Optional authenticated transport peer. */
|
|
91
|
+
readonly peer?: TransportPeerContext;
|
|
92
|
+
/** Optional host-agnostic principal resolved for this connection. */
|
|
93
|
+
readonly principal?: PrincipalContext;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Base message context interface for both events and requests.
|
|
97
|
+
*
|
|
98
|
+
* Provides common metadata for tracking and correlation:
|
|
99
|
+
* - `messageId`: Unique identifier for this specific message
|
|
100
|
+
* - `correlationId`: Optional identifier linking related operations
|
|
101
|
+
*/
|
|
102
|
+
interface BaseMessageContext {
|
|
103
|
+
/**
|
|
104
|
+
* Unique identifier for this specific message.
|
|
105
|
+
* Auto-generated if not provided.
|
|
106
|
+
*
|
|
107
|
+
* Used for:
|
|
108
|
+
* - Message deduplication
|
|
109
|
+
* - Idempotency checks
|
|
110
|
+
* - Tracking individual messages in logs
|
|
111
|
+
*/
|
|
112
|
+
messageId: string;
|
|
113
|
+
/**
|
|
114
|
+
* Optional identifier linking related operations.
|
|
115
|
+
* Propagated through chains of requests/events.
|
|
116
|
+
*
|
|
117
|
+
* Used for:
|
|
118
|
+
* - Distributed tracing
|
|
119
|
+
* - Causality tracking
|
|
120
|
+
* - Following a workflow through the system
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* // Initial request generates correlationId
|
|
124
|
+
* const result = await request(
|
|
125
|
+
* UserSubjects.getUser,
|
|
126
|
+
* { userId: '42' },
|
|
127
|
+
* { correlationId: 'user-action-123' }
|
|
128
|
+
* );
|
|
129
|
+
*
|
|
130
|
+
* // Handler propagates correlationId to downstream operations
|
|
131
|
+
* await emit(
|
|
132
|
+
* UserSubjects.userLoaded,
|
|
133
|
+
* { user: result },
|
|
134
|
+
* { correlationId: context.correlationId }
|
|
135
|
+
* );
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
correlationId?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Trusted context supplied by the local receiving transport.
|
|
141
|
+
*
|
|
142
|
+
* Undefined for local calls and for transports that do not supply connection
|
|
143
|
+
* context. Never trust similarly named fields in payloads or wire messages.
|
|
144
|
+
*/
|
|
145
|
+
transport?: TransportReceiveContext;
|
|
146
|
+
isRequest: boolean;
|
|
147
|
+
}
|
|
148
|
+
type EventMessagePayload<Payload extends UnknownRecord = UnknownRecord> = Payload & {
|
|
149
|
+
request?: never;
|
|
150
|
+
response?: never;
|
|
151
|
+
};
|
|
152
|
+
type RequestMessagePayload<Request extends UnknownRecord = UnknownRecord, Response extends UnknownRecord = UnknownRecord> = {
|
|
153
|
+
request: Request;
|
|
154
|
+
response: Response;
|
|
155
|
+
};
|
|
156
|
+
type MessagePayload = RequestMessagePayload | EventMessagePayload;
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region packages/makaio-core/src/types/context.d.ts
|
|
159
|
+
/**
|
|
160
|
+
* Context object passed to event handlers when using wildcard patterns.
|
|
161
|
+
*
|
|
162
|
+
* Provides:
|
|
163
|
+
* - `isRequest`: Always false (discriminator for type narrowing)
|
|
164
|
+
* - `payload`: The event payload
|
|
165
|
+
* - Message tracking fields from BaseMessage (messageId, correlationId)
|
|
166
|
+
*/
|
|
167
|
+
interface EventContext<Payload> extends BaseMessageContext {
|
|
168
|
+
/** Discriminator - always false for events */
|
|
169
|
+
isRequest: false;
|
|
170
|
+
/** The event payload */
|
|
171
|
+
payload: Payload;
|
|
172
|
+
/** The event subject */
|
|
173
|
+
subject: string;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Context object passed to request handlers.
|
|
177
|
+
*
|
|
178
|
+
* Provides:
|
|
179
|
+
* - `isRequest`: Always true (discriminator for type narrowing)
|
|
180
|
+
* - `payload`: The request payload
|
|
181
|
+
* - `setResult`: Function to set the response value
|
|
182
|
+
* - `next`: Function to call the next handler in the middleware chain
|
|
183
|
+
* - `replacePayload`: Function to transform the payload for subsequent handlers
|
|
184
|
+
* - `identify`: Optional function to identify the handler for broadcast aggregation
|
|
185
|
+
* - Message tracking fields from BaseMessage (messageId, correlationId)
|
|
186
|
+
*/
|
|
187
|
+
interface RequestContext<Payload, Response> extends BaseMessageContext {
|
|
188
|
+
/** Discriminator - always true for requests */
|
|
189
|
+
isRequest: true;
|
|
190
|
+
/** The request payload */
|
|
191
|
+
payload: Payload;
|
|
192
|
+
/** Set the response value (ends the handler chain) */
|
|
193
|
+
setResult: (result: Response) => void;
|
|
194
|
+
/**
|
|
195
|
+
* Read the current result value.
|
|
196
|
+
*
|
|
197
|
+
* Returns the value set by `setResult()` in this handler or by a downstream
|
|
198
|
+
* handler after `await next()`. Undefined until a result has been set.
|
|
199
|
+
*/
|
|
200
|
+
readonly result: Response | undefined;
|
|
201
|
+
/**
|
|
202
|
+
* Shallow-merge additional fields into the current result.
|
|
203
|
+
*
|
|
204
|
+
* Only valid for object-typed responses. In the request path the operation
|
|
205
|
+
* uses spread (immutable); in broadcast mode it uses `Object.assign`
|
|
206
|
+
* (in-place mutation) so the already-pushed result reference stays current.
|
|
207
|
+
* If no result has been set yet, starts from an empty object.
|
|
208
|
+
* @param extension - Fields to merge into the current result
|
|
209
|
+
*/
|
|
210
|
+
extendResult: (extension: [Response] extends [Record<string, unknown>] ? Partial<Response> : never) => void;
|
|
211
|
+
/**
|
|
212
|
+
* Call the next handler in the middleware chain.
|
|
213
|
+
* If no more handlers exist, throws NoHandlerError.
|
|
214
|
+
*/
|
|
215
|
+
next: () => Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Replace the payload with a new value.
|
|
218
|
+
* Subsequent handlers in the middleware chain will receive the new payload.
|
|
219
|
+
* Useful for hooks that need to inject context before the main handler runs.
|
|
220
|
+
*/
|
|
221
|
+
replacePayload: (newPayload: Payload) => void;
|
|
222
|
+
/**
|
|
223
|
+
* Identify this handler for broadcast aggregation.
|
|
224
|
+
* Only present when called via broadcast() - call before setResult().
|
|
225
|
+
* @param nodeId - Unique identifier for this handler/node
|
|
226
|
+
*/
|
|
227
|
+
identify?: (nodeId: string) => void;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Unified context for wildcard handlers that can match both events and requests.
|
|
231
|
+
* Use the `isRequest` discriminator to narrow the type.
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* MakaioBus.on('adapter.*', (context) => {
|
|
235
|
+
* if (context.isRequest) {
|
|
236
|
+
* // TypeScript knows this is RequestContext
|
|
237
|
+
* context.setResult({ handled: true });
|
|
238
|
+
* } else {
|
|
239
|
+
* // TypeScript knows this is EventContext
|
|
240
|
+
* console.debug('Event:', context.payload);
|
|
241
|
+
* }
|
|
242
|
+
* });
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
type WildcardContext<Payload = unknown, Response = unknown> = EventContext<Payload> | RequestContext<Payload, Response>;
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region packages/makaio-core/src/types/filter.d.ts
|
|
248
|
+
type Primitive = string | number | boolean | null;
|
|
249
|
+
/**
|
|
250
|
+
* Filter operators for payload field matching.
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* // Equality (implicit)
|
|
254
|
+
* { agentId: 'agent-123' }
|
|
255
|
+
*
|
|
256
|
+
* // Membership
|
|
257
|
+
* { status: { $in: ['active', 'pending'] } }
|
|
258
|
+
*
|
|
259
|
+
* // Not equal
|
|
260
|
+
* { type: { $ne: 'internal' } }
|
|
261
|
+
*
|
|
262
|
+
* // Presence check
|
|
263
|
+
* { error: { $exists: false } }
|
|
264
|
+
*
|
|
265
|
+
* // String prefix/suffix matching
|
|
266
|
+
* { path: { $startsWith: '.git/' } }
|
|
267
|
+
* { file: { $endsWith: '.ts' } }
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
type FilterOperator<T extends Primitive = Primitive> = T | {
|
|
271
|
+
$in: T[];
|
|
272
|
+
} | {
|
|
273
|
+
$ne: T;
|
|
274
|
+
} | {
|
|
275
|
+
$exists: boolean;
|
|
276
|
+
} | {
|
|
277
|
+
$startsWith: string;
|
|
278
|
+
} | {
|
|
279
|
+
$endsWith: string;
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* Untyped payload filter - accepts any string keys.
|
|
283
|
+
* Use TypedPayloadFilter<T> for type-safe filters.
|
|
284
|
+
*/
|
|
285
|
+
type PayloadFilter = Record<string, FilterOperator>;
|
|
286
|
+
/**
|
|
287
|
+
* Type-safe payload filter constrained to valid paths of a payload type.
|
|
288
|
+
*
|
|
289
|
+
* Uses type-fest's `Paths` to support dotted path notation for nested fields.
|
|
290
|
+
* @example
|
|
291
|
+
* ```typescript
|
|
292
|
+
* interface McpPayload {
|
|
293
|
+
* agentId: string;
|
|
294
|
+
* raw: { msg: { type: string } };
|
|
295
|
+
* }
|
|
296
|
+
*
|
|
297
|
+
* // Type-safe - validates both top-level and nested paths
|
|
298
|
+
* const filter: TypedPayloadFilter<McpPayload> = {
|
|
299
|
+
* agentId: 'agent-123',
|
|
300
|
+
* 'raw.msg.type': 'session_configured', // ✅ valid path
|
|
301
|
+
* 'raw.msg.typo': 'x', // ❌ type error
|
|
302
|
+
* };
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
type TypedPayloadFilter<T> = { [K in Paths<T> & string]?: FilterOperator };
|
|
306
|
+
/**
|
|
307
|
+
* Type guard to check if a value is a filter operator object.
|
|
308
|
+
* @param value - The filter operator value to check
|
|
309
|
+
* @returns True if the value is a filter operator object with $in, $ne, $exists, $startsWith, or $endsWith
|
|
310
|
+
*/
|
|
311
|
+
declare function isOperatorObject(value: FilterOperator): value is {
|
|
312
|
+
$in: Primitive[];
|
|
313
|
+
} | {
|
|
314
|
+
$ne: Primitive;
|
|
315
|
+
} | {
|
|
316
|
+
$exists: boolean;
|
|
317
|
+
} | {
|
|
318
|
+
$startsWith: string;
|
|
319
|
+
} | {
|
|
320
|
+
$endsWith: string;
|
|
321
|
+
};
|
|
322
|
+
//#endregion
|
|
323
|
+
//#region packages/makaio-core/src/types/schema.d.ts
|
|
324
|
+
/**
|
|
325
|
+
* Schema definition for event subjects (fire-and-forget).
|
|
326
|
+
* Events have only a payload schema, no response.
|
|
327
|
+
* The payload is now separate from the context, so no restrictions needed.
|
|
328
|
+
*/
|
|
329
|
+
type EventSchema = z.ZodType;
|
|
330
|
+
/**
|
|
331
|
+
* Schema definition for request subjects (request-response).
|
|
332
|
+
* Requests have both a request payload schema and a response schema.
|
|
333
|
+
*/
|
|
334
|
+
type RequestSchema<Request extends ZodType = ZodType, Response extends ZodType = ZodType> = {
|
|
335
|
+
request: Request;
|
|
336
|
+
response: Response;
|
|
337
|
+
};
|
|
338
|
+
/**
|
|
339
|
+
* Wrapper to mark a subject as local-only (never sent to transports).
|
|
340
|
+
*
|
|
341
|
+
* Use `localSubject()` from `@makaio/bus-core` to create these.
|
|
342
|
+
* @example
|
|
343
|
+
* ```typescript
|
|
344
|
+
* import { localSubject } from '@makaio/framework/bus';
|
|
345
|
+
*
|
|
346
|
+
* const WidgetSchemas = {
|
|
347
|
+
* register: localSubject(widgetDefinitionSchema), // local event
|
|
348
|
+
* unregister: localSubject(z.object({ widgetId: z.string() })),
|
|
349
|
+
* };
|
|
350
|
+
* ```
|
|
351
|
+
*/
|
|
352
|
+
type LocalSubjectSchema<T extends EventSchema | RequestSchema = EventSchema | RequestSchema> = {
|
|
353
|
+
readonly __local: true;
|
|
354
|
+
readonly schema: T;
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* Wrapper to mark a subject as channel-only (encrypted point-to-point).
|
|
358
|
+
*
|
|
359
|
+
* Channel subjects are rejected by public bus methods and are only
|
|
360
|
+
* routable through the DirectChannel encrypted transport. Use
|
|
361
|
+
* `channelSubject()` from `@makaio/bus-core` to create these.
|
|
362
|
+
* @example
|
|
363
|
+
* ```typescript
|
|
364
|
+
* import { channelSubject } from '@makaio/framework/bus';
|
|
365
|
+
*
|
|
366
|
+
* const DirectSchemas = {
|
|
367
|
+
* message: channelSubject(z.object({ text: z.string() })),
|
|
368
|
+
* ping: channelSubject({
|
|
369
|
+
* request: z.object({ ts: z.number() }),
|
|
370
|
+
* response: z.object({ ts: z.number() }),
|
|
371
|
+
* }),
|
|
372
|
+
* };
|
|
373
|
+
* ```
|
|
374
|
+
*/
|
|
375
|
+
type ChannelSubjectSchema<T extends EventSchema | RequestSchema = EventSchema | RequestSchema> = {
|
|
376
|
+
readonly __channel: true;
|
|
377
|
+
readonly schema: T;
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* Base schema types (unwrapped).
|
|
381
|
+
*/
|
|
382
|
+
type BaseSubjectSchema = EventSchema | RequestSchema;
|
|
383
|
+
/**
|
|
384
|
+
* Union of all subject schema types (including local and channel wrappers).
|
|
385
|
+
*/
|
|
386
|
+
type SubjectSchema = BaseSubjectSchema | LocalSubjectSchema | ChannelSubjectSchema;
|
|
387
|
+
type SchemaRecord = Record<string, SubjectSchema>;
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region packages/makaio-core/src/types/type-helpers.d.ts
|
|
390
|
+
/**
|
|
391
|
+
* Unwrap LocalSubjectSchema or ChannelSubjectSchema wrappers if present.
|
|
392
|
+
* Returns the inner schema for wrapped subjects, or the schema as-is otherwise.
|
|
393
|
+
*/
|
|
394
|
+
type UnwrapSchema<S> = S extends {
|
|
395
|
+
readonly __local: true;
|
|
396
|
+
readonly schema: infer Inner;
|
|
397
|
+
} ? Inner : S extends {
|
|
398
|
+
readonly __channel: true;
|
|
399
|
+
readonly schema: infer Inner;
|
|
400
|
+
} ? Inner : S;
|
|
401
|
+
/**
|
|
402
|
+
* Infer payload type from schema (handles EventSchema, RequestSchema,
|
|
403
|
+
* LocalSubjectSchema, and ChannelSubjectSchema).
|
|
404
|
+
*
|
|
405
|
+
* For requests:
|
|
406
|
+
* - Uses z.input for request (what callers pass before validation/defaults)
|
|
407
|
+
* - Uses z.infer for response (what handlers return after processing)
|
|
408
|
+
*
|
|
409
|
+
* This allows schemas with .default() to have optional fields in the caller API
|
|
410
|
+
* while the response type reflects the validated output.
|
|
411
|
+
*
|
|
412
|
+
* LocalSubjectSchema and ChannelSubjectSchema wrappers are automatically
|
|
413
|
+
* unwrapped before inference.
|
|
414
|
+
*
|
|
415
|
+
* Idempotent: Returns already-inferred types as-is.
|
|
416
|
+
*/
|
|
417
|
+
type InferSchemaPayload<S extends SubjectSchema> = InferSchemaPayloadInner<UnwrapSchema<S>>;
|
|
418
|
+
type InferSchemaPayloadInner<S> = S extends {
|
|
419
|
+
request: infer Req extends z.ZodType;
|
|
420
|
+
response: infer Res extends z.ZodType;
|
|
421
|
+
} ? {
|
|
422
|
+
request: z.input<Req>;
|
|
423
|
+
response: z.infer<Res>;
|
|
424
|
+
} : S extends z.ZodType ? Simplify<z.infer<S>> : unknown;
|
|
425
|
+
/**
|
|
426
|
+
* Compute all subject meta from the original schema in one place.
|
|
427
|
+
*
|
|
428
|
+
* Resolves payload, locality, channel membership, request/event discriminator,
|
|
429
|
+
* and namespace from a raw SubjectSchema.
|
|
430
|
+
* @typeParam S - The subject schema type
|
|
431
|
+
* @typeParam Ns - The namespace string
|
|
432
|
+
*/
|
|
433
|
+
type InferSubjectMeta<S extends SubjectSchema, Ns extends string> = {
|
|
434
|
+
/** True when the subject is a request-response pair, false for events. */isRequest: UnwrapSchema<S> extends {
|
|
435
|
+
request: z.ZodType;
|
|
436
|
+
response: z.ZodType;
|
|
437
|
+
} ? true : false; /** True when the subject is wrapped with `localSubject()`. */
|
|
438
|
+
local: S extends LocalSubjectSchema ? true : false; /** True when the subject is wrapped with `channelSubject()`. */
|
|
439
|
+
channel: S extends ChannelSubjectSchema ? true : false; /** Inferred payload type (request/response pair or event payload). */
|
|
440
|
+
payload: InferSchemaPayload<S>; /** The namespace this subject belongs to. */
|
|
441
|
+
namespace: Ns;
|
|
442
|
+
};
|
|
443
|
+
//#endregion
|
|
444
|
+
//#region packages/makaio-core/src/types/subjects.d.ts
|
|
445
|
+
type SubjectRecord<SubjectKeys extends string = string, Payload extends MessagePayload = MessagePayload> = Record<SubjectKeys, Payload>;
|
|
446
|
+
type SubjectRecordFromSchemaRecord<SchemaRecord extends Record<string, SubjectSchema>> = { [K in keyof SchemaRecord & string]: Simplify<InferSchemaPayload<SchemaRecord[K]>> };
|
|
447
|
+
type SubjectDefinitionMeta<Subject extends SubjectRecord = SubjectRecord<'default'>, K extends keyof Subject = keyof Subject, Namespace extends string = string> = {
|
|
448
|
+
isRequest: Subject extends SubjectRecord<'default'> ? boolean : Subject[K] extends RequestMessagePayload ? true : false;
|
|
449
|
+
payload: K extends string ? Subject[K] : unknown;
|
|
450
|
+
namespace: Namespace;
|
|
451
|
+
/**
|
|
452
|
+
* If true, this subject is local-only and will never be sent to transports.
|
|
453
|
+
* Use for subjects whose payloads contain non-serializable data (e.g., React components).
|
|
454
|
+
*/
|
|
455
|
+
local: boolean;
|
|
456
|
+
/**
|
|
457
|
+
* If true, this subject is channel-only and is only routable through the
|
|
458
|
+
* DirectChannel encrypted point-to-point transport.
|
|
459
|
+
*/
|
|
460
|
+
channel: boolean;
|
|
461
|
+
};
|
|
462
|
+
type SubjectDefinition<Subject extends SubjectRecord = SubjectRecord, SubjectKey extends keyof Subject = keyof Subject, Namespace extends string = string> = {
|
|
463
|
+
$meta: SubjectDefinitionMeta<Subject, SubjectKey, Namespace>;
|
|
464
|
+
subject: SubjectKey;
|
|
465
|
+
};
|
|
466
|
+
/** Extract payload (event payload or request/response pair) */
|
|
467
|
+
type ExtractInternalSubjectPayload<T extends SubjectDefinition> = T['$meta']['payload'];
|
|
468
|
+
/** Extract subject payload */
|
|
469
|
+
type ExtractSubjectPayload<T extends SubjectDefinition> = ExtractInternalSubjectPayload<T> extends RequestMessagePayload ? ExtractInternalSubjectPayload<T>['request'] : ExtractInternalSubjectPayload<T>;
|
|
470
|
+
/** Extract response payload (request subjects only) */
|
|
471
|
+
type ExtractSubjectResponse<T extends SubjectDefinition> = ExtractInternalSubjectPayload<T> extends RequestMessagePayload ? ExtractInternalSubjectPayload<T>['response'] : never;
|
|
472
|
+
type ScopedSubjectDefinition<Namespace extends string = string> = SubjectDefinition<SubjectRecord, keyof SubjectRecord, Namespace>;
|
|
473
|
+
/**
|
|
474
|
+
* Extract the filterable payload from a MessagePayload.
|
|
475
|
+
* For requests, returns the request part (what we filter on).
|
|
476
|
+
* For events, returns the payload as-is.
|
|
477
|
+
*/
|
|
478
|
+
type FilterablePayload<P> = P extends RequestMessagePayload ? P['request'] : P;
|
|
479
|
+
/**
|
|
480
|
+
* Union of all filterable payloads from a SubjectRecord.
|
|
481
|
+
*/
|
|
482
|
+
type FilterablePayloadsUnion<Subjects extends SubjectRecord> = FilterablePayload<Subjects[keyof Subjects]>;
|
|
483
|
+
/**
|
|
484
|
+
* Extract keys from ANY member of a union type (distributive).
|
|
485
|
+
*
|
|
486
|
+
* For `{ a: 1, b: 2 } | { a: 1, c: 3 }`, returns `'a' | 'b' | 'c'`.
|
|
487
|
+
*/
|
|
488
|
+
type KeysOfUnion<T> = T extends unknown ? keyof T : never;
|
|
489
|
+
/**
|
|
490
|
+
* Extract value type for a key from union members that have it.
|
|
491
|
+
*/
|
|
492
|
+
type ValueOfKey<T, K extends PropertyKey> = T extends { [P in K]: infer V } ? V : never;
|
|
493
|
+
/**
|
|
494
|
+
* Build an object type with ALL keys from ANY union member.
|
|
495
|
+
*
|
|
496
|
+
* For `{ type: 'a', id: string } | { type: 'b', name: string }`:
|
|
497
|
+
* Result = `{ type: 'a' | 'b', id: string, name: string }`
|
|
498
|
+
*
|
|
499
|
+
* Allows filtering by any key that exists in any payload.
|
|
500
|
+
*/
|
|
501
|
+
type AllPropertiesOfUnion<T> = { [K in KeysOfUnion<T>]: ValueOfKey<T, K> };
|
|
502
|
+
/**
|
|
503
|
+
* Union of all filterable payload properties from a SubjectRecord.
|
|
504
|
+
*
|
|
505
|
+
* Collects ALL keys from ANY payload, allowing filtering by any field.
|
|
506
|
+
* Events without a filtered key simply won't match.
|
|
507
|
+
* @example
|
|
508
|
+
* ```typescript
|
|
509
|
+
* // Given subjects with payloads:
|
|
510
|
+
* // - 'event': { agentId: string, foo: number }
|
|
511
|
+
* // - 'request': { sessionId: string }
|
|
512
|
+
*
|
|
513
|
+
* // FilterablePayloadUnion = { agentId: string, foo: number, sessionId: string }
|
|
514
|
+
*
|
|
515
|
+
* // Filter can use any key from any payload
|
|
516
|
+
* bus.withFilter({ agentId: 'x' }); // ✅ matches events with agentId
|
|
517
|
+
* bus.withFilter({ sessionId: 'y' }); // ✅ matches requests with sessionId
|
|
518
|
+
* ```
|
|
519
|
+
*/
|
|
520
|
+
type FilterablePayloadIntersection<Subjects extends SubjectRecord> = Simplify<AllPropertiesOfUnion<FilterablePayloadsUnion<Subjects>>>;
|
|
521
|
+
/**
|
|
522
|
+
* Compute FilterPayload directly from a schema record.
|
|
523
|
+
*
|
|
524
|
+
* This bypasses SubjectRecordFromSchemaRecord and computes directly from schemas,
|
|
525
|
+
* which TypeScript can evaluate because Schemas is concrete at registration time.
|
|
526
|
+
*/
|
|
527
|
+
type FilterPayloadFromSchemas<Schemas extends Record<string, SubjectSchema>> = Simplify<AllPropertiesOfUnion<{ [K in keyof Schemas]: FilterablePayload<InferSchemaPayload<Schemas[K]>> }[keyof Schemas]>>;
|
|
528
|
+
//#endregion
|
|
529
|
+
//#region packages/makaio-core/src/types/wildcards.d.ts
|
|
530
|
+
type WildcardSubject = '*';
|
|
531
|
+
declare const WildcardSubjectKey = "*";
|
|
532
|
+
type WildcardSubjectDefinition<Namespace extends string = string> = SubjectDefinition<Record<'*', MessagePayload>, WildcardSubject, Namespace>;
|
|
533
|
+
//#endregion
|
|
534
|
+
//#region packages/makaio-core/src/types/handler-types.d.ts
|
|
535
|
+
type EventHandler<T> = (context: EventContext<T>) => void | Promise<void>;
|
|
536
|
+
type RequestHandler<Payload, Response> = (context: RequestContext<Payload, Response>) => void | Promise<void>;
|
|
537
|
+
/**
|
|
538
|
+
* Context provided to __onAny handlers for debugging/testing.
|
|
539
|
+
* Captures all message metadata regardless of type (event/request/broadcast).
|
|
540
|
+
*/
|
|
541
|
+
interface AnyMessageContext {
|
|
542
|
+
type: 'event' | 'request' | 'broadcast';
|
|
543
|
+
subject: string;
|
|
544
|
+
namespace: string;
|
|
545
|
+
payload: unknown;
|
|
546
|
+
messageId: string;
|
|
547
|
+
correlationId?: string;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Handler for __onAny - receives all messages (events and requests) across all namespaces.
|
|
551
|
+
* Used for debugging and testing only.
|
|
552
|
+
*/
|
|
553
|
+
type AnyHandler = (context: AnyMessageContext) => void | Promise<void>;
|
|
554
|
+
/**
|
|
555
|
+
* Special handler for wildcards that match both events and requests.
|
|
556
|
+
* @public
|
|
557
|
+
*/
|
|
558
|
+
type WildcardUnifiedHandler = (context: WildcardContext<unknown, unknown>) => void | Promise<void>;
|
|
559
|
+
/**
|
|
560
|
+
* Resolve the appropriate handler type for a subject pattern (exact or wildcard).
|
|
561
|
+
*
|
|
562
|
+
* Handles all subscription patterns:
|
|
563
|
+
* - Event wildcards (`adapter.*`) → `(payload: unknown) => void | Promise<void>`
|
|
564
|
+
* - Request wildcards (`adapter.*`) → `(context: RequestContext<unknown, unknown>) => void | Promise<void>`
|
|
565
|
+
* - Exact request subjects → `RequestHandler<TPayload, TReturnValue>`
|
|
566
|
+
* - Exact event subjects → `EventHandler<TPayload>`
|
|
567
|
+
*
|
|
568
|
+
* This is the primary type used by the `on()` method to resolve handler signatures.
|
|
569
|
+
* @example
|
|
570
|
+
* ```typescript
|
|
571
|
+
* // Event wildcard - unknown payload
|
|
572
|
+
* type Handler1 = HandlerForPattern<'adapter.*'>;
|
|
573
|
+
* // (payload: unknown) => void | Promise<void>
|
|
574
|
+
*
|
|
575
|
+
* // Exact event subject - typed payload
|
|
576
|
+
* type Handler2 = HandlerForPattern<'adapter.log'>;
|
|
577
|
+
* // EventHandler<{ message: string, level: string }>
|
|
578
|
+
*
|
|
579
|
+
* // Request wildcard - unknown context
|
|
580
|
+
* type Handler3 = HandlerForPattern<'adapter.*'>;
|
|
581
|
+
* // (context: RequestContext<unknown, unknown>) => void | Promise<void>
|
|
582
|
+
*
|
|
583
|
+
* // Exact request subject - typed context
|
|
584
|
+
* type Handler4 = HandlerForPattern<'adapter.getCapabilities'>;
|
|
585
|
+
* // RequestHandler<{ adapterName: string }, { capabilities: string[] }>
|
|
586
|
+
* ```
|
|
587
|
+
*/
|
|
588
|
+
/**
|
|
589
|
+
* Resolve the handler type for a SubjectDefinition.
|
|
590
|
+
*
|
|
591
|
+
* Uses indexed access (`T['$meta']['payload']`) instead of nested `extends` with `infer`
|
|
592
|
+
* to ensure proper type resolution when T is a generic type parameter.
|
|
593
|
+
*/
|
|
594
|
+
type HandlerForSubjectDefinition<T extends SubjectDefinition> = T['subject'] extends WildcardSubject ? WildcardUnifiedHandler : T['$meta']['payload'] extends RequestMessagePayload<infer Request, infer Response> ? RequestHandler<Request, Response> : T['$meta']['payload'] extends EventMessagePayload<infer Payload> ? EventHandler<Payload> : never;
|
|
595
|
+
/**
|
|
596
|
+
* Extract context type for once() promise return value.
|
|
597
|
+
*
|
|
598
|
+
* Uses the same pattern as HandlerForSubjectDefinition for consistency.
|
|
599
|
+
*/
|
|
600
|
+
type ContextForSubjectDefinition<T extends SubjectDefinition> = T['subject'] extends WildcardSubject ? WildcardContext<unknown, unknown> : T['$meta']['payload'] extends RequestMessagePayload<infer Request, infer Response> ? RequestContext<Request, Response> : T['$meta']['payload'] extends EventMessagePayload<infer Payload> ? EventContext<Payload> : never;
|
|
601
|
+
//#endregion
|
|
602
|
+
//#region packages/makaio-core/src/types/result.d.ts
|
|
603
|
+
/**
|
|
604
|
+
* Result types for optional request handling.
|
|
605
|
+
*
|
|
606
|
+
* Used by requestOptional to distinguish between "handler returned data"
|
|
607
|
+
* and "no handler was registered".
|
|
608
|
+
*/
|
|
609
|
+
/**
|
|
610
|
+
* Discriminated union for optional request results.
|
|
611
|
+
*
|
|
612
|
+
* - `handled: true` - A handler was found and returned data
|
|
613
|
+
* - `handled: false` - No handler was registered for the subject
|
|
614
|
+
* @example
|
|
615
|
+
* ```typescript
|
|
616
|
+
* const result = await bus.requestOptional(Subjects.getData, { id: '123' });
|
|
617
|
+
* if (result.handled) {
|
|
618
|
+
* console.debug('Got data:', result.data);
|
|
619
|
+
* } else {
|
|
620
|
+
* console.debug('No handler registered for getData');
|
|
621
|
+
* }
|
|
622
|
+
* ```
|
|
623
|
+
*/
|
|
624
|
+
type OptionalResult<T> = {
|
|
625
|
+
handled: true;
|
|
626
|
+
data: T;
|
|
627
|
+
} | {
|
|
628
|
+
handled: false;
|
|
629
|
+
};
|
|
630
|
+
//#endregion
|
|
631
|
+
//#region packages/makaio-core/src/types/bus-like.d.ts
|
|
632
|
+
type EventSubjectLike = SubjectDefinition & {
|
|
633
|
+
readonly $meta: {
|
|
634
|
+
readonly isRequest: false;
|
|
635
|
+
readonly channel: false;
|
|
636
|
+
};
|
|
637
|
+
};
|
|
638
|
+
type RequestSubjectLike = SubjectDefinition & {
|
|
639
|
+
readonly $meta: {
|
|
640
|
+
readonly isRequest: true;
|
|
641
|
+
readonly channel: false;
|
|
642
|
+
readonly payload: RequestMessagePayload;
|
|
643
|
+
};
|
|
644
|
+
};
|
|
645
|
+
/**
|
|
646
|
+
* Minimal structural bus seam for contracts-owned helpers.
|
|
647
|
+
*
|
|
648
|
+
* This deliberately does not re-model `@makaio/bus-core`'s generic overloads.
|
|
649
|
+
* Bus-core owns the full magic inference surface; this type only covers the
|
|
650
|
+
* event/request calls that contract helper APIs make without importing bus-core.
|
|
651
|
+
*/
|
|
652
|
+
interface MakaioBusLike {
|
|
653
|
+
/** Emit an event. */
|
|
654
|
+
emit<Subject extends EventSubjectLike>(subject: Subject, payload: Subject['$meta']['payload']): Promise<void>;
|
|
655
|
+
/** Send a request and await a response. */
|
|
656
|
+
request<Subject extends RequestSubjectLike>(subject: Subject, payload: Subject['$meta']['payload']['request']): Promise<Subject['$meta']['payload']['response']>;
|
|
657
|
+
}
|
|
658
|
+
//#endregion
|
|
659
|
+
//#region packages/makaio-core/src/subject-helpers/nest-subject-definitions.d.ts
|
|
660
|
+
/**
|
|
661
|
+
* Recursively nests a flat record of dotted keys into a hierarchical object type.
|
|
662
|
+
*
|
|
663
|
+
* ```
|
|
664
|
+
* { 'assistant.text': SubjectDef, 'agent.tool.started': SubjectDef }
|
|
665
|
+
* → { assistant: { text: SubjectDef }, agent: { tool: { started: SubjectDef } } }
|
|
666
|
+
* ```
|
|
667
|
+
*
|
|
668
|
+
* Used to expose registered subjects as a nested accessor tree (e.g.
|
|
669
|
+
* `BootSubjects.service.ready`) without requiring callers to deal with
|
|
670
|
+
* flat dotted-key strings at the type level.
|
|
671
|
+
*/
|
|
672
|
+
type NestedSubjectDefinitions<T extends Record<string, unknown> = Record<string, SubjectDefinition>> = { [K in ExtractPrefixes<keyof T & string>]: NestByPrefix<T, K> };
|
|
673
|
+
type ExtractPrefixes<Keys extends string> = Keys extends `${infer Prefix}.${string}` ? Prefix : Keys;
|
|
674
|
+
type StripPrefixMap<T, Prefix extends string> = { [K in keyof T as K extends `${Prefix}.${infer Rest}` ? Rest : never]: T[K] };
|
|
675
|
+
type NestByPrefix<T extends Record<string, unknown>, Prefix extends string> = Prefix extends keyof T ? T[Prefix] : NestedSubjectDefinitions<StripPrefixMap<T, Prefix>>;
|
|
676
|
+
/**
|
|
677
|
+
* Maps a flat schema record to a flat subject-definition record, attaching the
|
|
678
|
+
* correct `$meta` (namespace, isRequest, local, channel) and `subject` key for
|
|
679
|
+
* each entry.
|
|
680
|
+
*
|
|
681
|
+
* Intermediate type used by {@link nestSubjectDefinitions} before nesting.
|
|
682
|
+
* @typeParam Domain - Namespace domain string (e.g. `'boot'`)
|
|
683
|
+
* @typeParam Schemas - Flat record of raw Zod schemas keyed by dotted subject names
|
|
684
|
+
*/
|
|
685
|
+
type FlatSubjectDefinitions<Domain extends string, Schemas extends Record<string, SubjectSchema>> = { [K in keyof Schemas & string]: {
|
|
686
|
+
$meta: InferSubjectMeta<Schemas[K], Domain>;
|
|
687
|
+
subject: K;
|
|
688
|
+
} };
|
|
689
|
+
/**
|
|
690
|
+
* Fully-nested subject accessor tree returned by `registerNamespace`.
|
|
691
|
+
*
|
|
692
|
+
* Combines the {@link NestedSubjectDefinitions} hierarchy with a `$all`
|
|
693
|
+
* wildcard that matches every subject in the namespace. Consumers use this
|
|
694
|
+
* type to write `SomeNamespace.subjects.foo.bar` instead of raw strings.
|
|
695
|
+
* @typeParam RecordOfSubjectDefinitions - Flat record of subject definitions
|
|
696
|
+
* @typeParam Domain - Namespace domain string used for `$all` wildcard typing
|
|
697
|
+
*/
|
|
698
|
+
type BusSubjects<RecordOfSubjectDefinitions extends Record<string, unknown> = Record<string, SubjectDefinition>, Domain extends string = string> = NestedSubjectDefinitions<RecordOfSubjectDefinitions> & {
|
|
699
|
+
$all: WildcardSubjectDefinition<Domain>;
|
|
700
|
+
};
|
|
701
|
+
/**
|
|
702
|
+
* Nests flat dotted subject keys into a hierarchical structure.
|
|
703
|
+
* @param namespace - The domain/namespace for the subject definitions
|
|
704
|
+
* @param flat - Flat record of subject schemas with dotted keys
|
|
705
|
+
* @returns Nested subject definitions with hierarchical structure and a $all wildcard
|
|
706
|
+
*/
|
|
707
|
+
declare function nestSubjectDefinitions<Domain extends string, T extends Record<string, SubjectSchema>>(namespace: Domain, flat: T): NestedSubjectDefinitions<FlatSubjectDefinitions<Domain, T>> & {
|
|
708
|
+
$all: WildcardSubjectDefinition<Domain>;
|
|
709
|
+
};
|
|
710
|
+
/**
|
|
711
|
+
* Gets the fully qualified subject name in namespace.subject format.
|
|
712
|
+
* @param subject - The subject definition to format
|
|
713
|
+
* @returns The full subject string in the format "namespace.subject"
|
|
714
|
+
*/
|
|
715
|
+
declare function getFullSubjectForSubjectDefinition(subject: SubjectDefinition): string;
|
|
716
|
+
//#endregion
|
|
717
|
+
//#region packages/makaio-core/src/subject-helpers/is-request-schema.d.ts
|
|
718
|
+
/**
|
|
719
|
+
* Type guard to check if a schema is a request schema.
|
|
720
|
+
* @param schema - The schema to check
|
|
721
|
+
* @returns True if the schema is a RequestSchema, false otherwise
|
|
722
|
+
*/
|
|
723
|
+
declare function isRequestSchema(schema: SubjectSchema): schema is RequestSchema;
|
|
724
|
+
//#endregion
|
|
725
|
+
//#region packages/makaio-core/src/subject-helpers/is-local-schema.d.ts
|
|
726
|
+
/**
|
|
727
|
+
* Check if a schema is wrapped as a local subject.
|
|
728
|
+
* @param schema - The schema to check
|
|
729
|
+
* @returns True if the schema is a LocalSubjectSchema wrapper
|
|
730
|
+
*/
|
|
731
|
+
declare function isLocalSchema(schema: SubjectSchema): schema is LocalSubjectSchema;
|
|
732
|
+
/**
|
|
733
|
+
* Create a local-only subject schema wrapper.
|
|
734
|
+
*
|
|
735
|
+
* Local subjects are never sent to transports (SharedWorker, WebSocket, etc.).
|
|
736
|
+
* Use this for subjects whose payloads contain non-serializable data like
|
|
737
|
+
* React components or functions.
|
|
738
|
+
* @param schema - The event or request schema to mark as local
|
|
739
|
+
* @returns A LocalSubjectSchema wrapper
|
|
740
|
+
* @example
|
|
741
|
+
* ```typescript
|
|
742
|
+
* import { localSubject } from '@makaio/framework/core';
|
|
743
|
+
*
|
|
744
|
+
* const WidgetSchemas = {
|
|
745
|
+
* // Local event - contains React component, can't be serialized
|
|
746
|
+
* register: localSubject(widgetDefinitionSchema),
|
|
747
|
+
*
|
|
748
|
+
* // Local request - response contains functions
|
|
749
|
+
* getRenderer: localSubject({
|
|
750
|
+
* request: z.object({ widgetId: z.string() }),
|
|
751
|
+
* response: z.object({ render: z.function() }),
|
|
752
|
+
* }),
|
|
753
|
+
* };
|
|
754
|
+
* ```
|
|
755
|
+
*/
|
|
756
|
+
declare function localSubject<T extends EventSchema | RequestSchema>(schema: T): LocalSubjectSchema<T>;
|
|
757
|
+
//#endregion
|
|
758
|
+
//#region packages/makaio-core/src/subject-helpers/is-channel-schema.d.ts
|
|
759
|
+
/**
|
|
760
|
+
* Check if a schema is wrapped as a channel subject.
|
|
761
|
+
* @param schema - The schema to check
|
|
762
|
+
* @returns True if the schema is a ChannelSubjectSchema wrapper
|
|
763
|
+
*/
|
|
764
|
+
declare function isChannelSchema(schema: SubjectSchema): schema is ChannelSubjectSchema;
|
|
765
|
+
/**
|
|
766
|
+
* Create a channel-only subject schema wrapper.
|
|
767
|
+
*
|
|
768
|
+
* Channel subjects are rejected by public bus methods and are only
|
|
769
|
+
* routable through the DirectChannel encrypted point-to-point transport.
|
|
770
|
+
* Use this for subjects that must never travel over the public bus.
|
|
771
|
+
* @param schema - The event or request schema to mark as channel-only
|
|
772
|
+
* @returns A ChannelSubjectSchema wrapper
|
|
773
|
+
* @example
|
|
774
|
+
* ```typescript
|
|
775
|
+
* import { channelSubject } from '@makaio/framework/core';
|
|
776
|
+
*
|
|
777
|
+
* const DirectSchemas = {
|
|
778
|
+
* // Channel event - encrypted, point-to-point only
|
|
779
|
+
* message: channelSubject(z.object({ text: z.string() })),
|
|
780
|
+
*
|
|
781
|
+
* // Channel request - encrypted request-response pair
|
|
782
|
+
* ping: channelSubject({
|
|
783
|
+
* request: z.object({ ts: z.number() }),
|
|
784
|
+
* response: z.object({ ts: z.number() }),
|
|
785
|
+
* }),
|
|
786
|
+
* };
|
|
787
|
+
* ```
|
|
788
|
+
*/
|
|
789
|
+
declare function channelSubject<T extends EventSchema | RequestSchema>(schema: T): ChannelSubjectSchema<T>;
|
|
790
|
+
//#endregion
|
|
791
|
+
//#region packages/makaio-core/src/subject-helpers/unwrap-schema.d.ts
|
|
792
|
+
/**
|
|
793
|
+
* Unwrap any subject schema wrapper (local or channel) to get the inner schema.
|
|
794
|
+
* Returns the schema as-is if not wrapped.
|
|
795
|
+
* @param schema - The schema to unwrap
|
|
796
|
+
* @returns The inner EventSchema or RequestSchema
|
|
797
|
+
*/
|
|
798
|
+
declare function unwrapSchema(schema: SubjectSchema): EventSchema | RequestSchema;
|
|
799
|
+
//#endregion
|
|
800
|
+
//#region packages/makaio-core/src/bus-namespace-definition.d.ts
|
|
801
|
+
/**
|
|
802
|
+
* Report passed to the {@link NamespaceRegistrationOptions} `onSchemaViolation` callback
|
|
803
|
+
* when lenient validation detects a schema mismatch.
|
|
804
|
+
*
|
|
805
|
+
* Canonical owner: `@makaio/core`. `@makaio/bus-core` imports this type from core.
|
|
806
|
+
*/
|
|
807
|
+
interface SchemaViolationReport {
|
|
808
|
+
/** Fully-qualified subject key (e.g., `"adapter:claude-code.sdk.event"`) */
|
|
809
|
+
subject: string;
|
|
810
|
+
/** Raw payload that failed validation */
|
|
811
|
+
payload: unknown;
|
|
812
|
+
/** Individual Zod issues from the failed parse */
|
|
813
|
+
issues: unknown[];
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Options controlling runtime schema validation for a registered bus namespace.
|
|
817
|
+
*
|
|
818
|
+
* - `strict` (default) — throw `ValidationError` on schema mismatch
|
|
819
|
+
* - `lenient` — invoke `onSchemaViolation` callback, then deliver the event anyway
|
|
820
|
+
* - `skip` — no validation at all (for cross-Zod-version scenarios, e.g., SDK bundles Zod v3)
|
|
821
|
+
*
|
|
822
|
+
* Canonical owner: `@makaio/core`. `@makaio/bus-core` imports this type from core,
|
|
823
|
+
* not the other way around. Single source of truth — no mirroring.
|
|
824
|
+
*/
|
|
825
|
+
type NamespaceRegistrationOptions = {
|
|
826
|
+
busValidationMode?: 'strict';
|
|
827
|
+
} | {
|
|
828
|
+
busValidationMode: 'lenient';
|
|
829
|
+
onSchemaViolation: (report: SchemaViolationReport) => void;
|
|
830
|
+
} | {
|
|
831
|
+
busValidationMode: 'skip';
|
|
832
|
+
};
|
|
833
|
+
/**
|
|
834
|
+
* A declarative bus namespace definition.
|
|
835
|
+
*
|
|
836
|
+
* Created by {@link createBusNamespace}. Carries typed subject tokens for
|
|
837
|
+
* immediate use in bus operations, plus the original schemas for deferred
|
|
838
|
+
* registration at boot time via `MakaioBus.registerNamespace()`.
|
|
839
|
+
*
|
|
840
|
+
* Does not include `scopedBus()` — that method requires a bus instance and
|
|
841
|
+
* is available on the `BusNamespace` object returned by `registerNamespace()`.
|
|
842
|
+
* @typeParam Domain - Namespace domain string (e.g. `'adapter'`, `'session'`)
|
|
843
|
+
* @typeParam Schemas - Schema record mapping subject keys to Zod schemas
|
|
844
|
+
*/
|
|
845
|
+
interface BusNamespaceDefinition<Domain extends string = string, Schemas extends Record<string, SubjectSchema> = Record<string, SubjectSchema>> {
|
|
846
|
+
/** Namespace domain string (e.g., `'adapter'`, `'session'`) */
|
|
847
|
+
readonly name: Domain;
|
|
848
|
+
/**
|
|
849
|
+
* Typed subject tokens for bus operations — no registration needed to use
|
|
850
|
+
* these for `bus.on()`, `bus.emit()`, or `bus.request()`.
|
|
851
|
+
*/
|
|
852
|
+
readonly subjects: BusSubjects<FlatSubjectDefinitions<Domain, Schemas>, Domain>;
|
|
853
|
+
/** Original Zod schemas — carried for deferred registration */
|
|
854
|
+
readonly schemas: Schemas;
|
|
855
|
+
/** Registration options (validation mode, violation callback) */
|
|
856
|
+
readonly options?: NamespaceRegistrationOptions;
|
|
857
|
+
/**
|
|
858
|
+
* Phantom field for type inference of filterable payload shape.
|
|
859
|
+
*
|
|
860
|
+
* Never set at runtime. Exists solely so TypeScript can infer the
|
|
861
|
+
* `FilterPayload` type parameter from the schema record without an
|
|
862
|
+
* explicit annotation at every callsite.
|
|
863
|
+
* @internal
|
|
864
|
+
*/
|
|
865
|
+
readonly __filterPayload?: FilterablePayloadIntersection<SubjectRecordFromSchemaRecord<Schemas>>;
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Namespace definition shape required for runtime registration.
|
|
869
|
+
*
|
|
870
|
+
* Structurally derived from {@link BusNamespaceDefinition} with the typed
|
|
871
|
+
* subject tree erased to `unknown`. Composition-root catalogs and extension
|
|
872
|
+
* manifests only need the namespace name, schemas, options, and the runtime
|
|
873
|
+
* subject tokens; keeping this structural type separate lets those catalogs
|
|
874
|
+
* contain heterogeneous namespace definitions without widening every subject
|
|
875
|
+
* tree to an unsafe index signature.
|
|
876
|
+
*/
|
|
877
|
+
type RegistrableBusNamespaceDefinition = Omit<BusNamespaceDefinition, 'subjects' | '__filterPayload'> & {
|
|
878
|
+
/** Runtime subject token tree created by `createBusNamespace`. */readonly subjects: unknown;
|
|
879
|
+
};
|
|
880
|
+
/**
|
|
881
|
+
* Creates a bus namespace definition with typed subject tokens.
|
|
882
|
+
*
|
|
883
|
+
* Pure function — no side-effects, no bus singleton mutation. The returned
|
|
884
|
+
* definition can be used immediately for bus operations (`bus.on()`,
|
|
885
|
+
* `bus.emit()`, etc.) and registered later at boot time via
|
|
886
|
+
* `MakaioBus.registerNamespace(definition)`.
|
|
887
|
+
* @param name - Namespace domain string (e.g., `'adapter'`, `'session'`)
|
|
888
|
+
* @param schemas - Schema record mapping subject keys to Zod schemas
|
|
889
|
+
* @param options - Optional registration options (validation mode, violation callback)
|
|
890
|
+
* @returns Namespace definition with typed subject tokens and carried schemas
|
|
891
|
+
* @example
|
|
892
|
+
* ```typescript
|
|
893
|
+
* import { createBusNamespace } from '@makaio/framework/core';
|
|
894
|
+
* import { AdapterSchemas } from './schemas.js';
|
|
895
|
+
*
|
|
896
|
+
* export const AdapterNamespace = createBusNamespace('adapter', AdapterSchemas);
|
|
897
|
+
* export const AdapterSubjects = AdapterNamespace.subjects;
|
|
898
|
+
* ```
|
|
899
|
+
*/
|
|
900
|
+
declare function createBusNamespace<Domain extends string, Schemas extends Record<string, SubjectSchema>>(name: Domain, schemas: Schemas, options?: NamespaceRegistrationOptions): BusNamespaceDefinition<Domain, Schemas>;
|
|
901
|
+
//#endregion
|
|
902
|
+
//#region packages/makaio-core/src/context/index.d.ts
|
|
903
|
+
/**
|
|
904
|
+
* Platform identifier for tool execution context.
|
|
905
|
+
* Used to determine platform-specific behavior in tools.
|
|
906
|
+
*/
|
|
907
|
+
type Platform = 'posix' | 'windows';
|
|
908
|
+
/**
|
|
909
|
+
* Execution context passed to tool implementations.
|
|
910
|
+
*
|
|
911
|
+
* Provides tools with essential runtime information about the execution environment,
|
|
912
|
+
* including working directory, environment variables, platform, and cancellation support.
|
|
913
|
+
* @example
|
|
914
|
+
* ```typescript
|
|
915
|
+
* const result = await tool.execute(input, {
|
|
916
|
+
* cwd: '/path/to/project',
|
|
917
|
+
* env: { NODE_ENV: 'development' },
|
|
918
|
+
* platform: 'posix',
|
|
919
|
+
* signal: abortController.signal,
|
|
920
|
+
* });
|
|
921
|
+
* ```
|
|
922
|
+
*/
|
|
923
|
+
interface MakaioContext {
|
|
924
|
+
/** Working directory for tool execution */
|
|
925
|
+
cwd: string;
|
|
926
|
+
/** Read-only environment variables available to the tool */
|
|
927
|
+
env: Readonly<Record<string, string>>;
|
|
928
|
+
/** Platform identifier for cross-platform compatibility */
|
|
929
|
+
platform: Platform;
|
|
930
|
+
/** Optional abort signal for cancellation support */
|
|
931
|
+
signal?: AbortSignal;
|
|
932
|
+
/** Optional constraints that tools can check for specific behaviors */
|
|
933
|
+
constraints?: Record<string, unknown>;
|
|
934
|
+
/** Session ID for the current execution context */
|
|
935
|
+
sessionId?: string;
|
|
936
|
+
/** Subagent ID if running as a subagent */
|
|
937
|
+
subagentId?: string;
|
|
938
|
+
/** Current nesting depth in subagent hierarchy (0 = root) */
|
|
939
|
+
subagentDepth?: number;
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Creates a MakaioContext with sensible defaults and optional overrides.
|
|
943
|
+
*
|
|
944
|
+
* Default behavior:
|
|
945
|
+
* - `cwd`: Uses process.cwd() or '/' in non-Node environments
|
|
946
|
+
* - `env`: Sanitized process.env (filters undefined values)
|
|
947
|
+
* - `platform`: Auto-detected from process.platform
|
|
948
|
+
* @param overrides - Optional partial context to merge with defaults
|
|
949
|
+
* @returns Complete MakaioContext ready for tool execution
|
|
950
|
+
* @example
|
|
951
|
+
* ```typescript
|
|
952
|
+
* // Create context with all defaults
|
|
953
|
+
* const ctx = createMakaioContext();
|
|
954
|
+
*
|
|
955
|
+
* // Override specific values
|
|
956
|
+
* const ctx = createMakaioContext({
|
|
957
|
+
* cwd: '/custom/path',
|
|
958
|
+
* signal: abortController.signal,
|
|
959
|
+
* });
|
|
960
|
+
* ```
|
|
961
|
+
*/
|
|
962
|
+
declare function createMakaioContext(overrides?: Partial<MakaioContext>): MakaioContext;
|
|
963
|
+
//#endregion
|
|
964
|
+
//#region packages/makaio-core/src/errors/index.d.ts
|
|
965
|
+
/**
|
|
966
|
+
* Base error class for all Makaio-related errors.
|
|
967
|
+
*/
|
|
968
|
+
declare class MakaioError extends Error {
|
|
969
|
+
readonly subject?: string | undefined;
|
|
970
|
+
constructor(message: string, subject?: string | undefined);
|
|
971
|
+
}
|
|
972
|
+
declare class InvalidModelError extends MakaioError {
|
|
973
|
+
readonly subject?: string | undefined;
|
|
974
|
+
constructor(requestedModel: string, subject?: string | undefined);
|
|
975
|
+
}
|
|
976
|
+
declare class DirectoryNotFoundError extends MakaioError {
|
|
977
|
+
readonly subject?: string | undefined;
|
|
978
|
+
constructor(path: string, subject?: string | undefined);
|
|
979
|
+
}
|
|
980
|
+
declare class ConfigError extends MakaioError {
|
|
981
|
+
readonly subject?: string | undefined;
|
|
982
|
+
constructor(message: string, subject?: string | undefined);
|
|
983
|
+
}
|
|
984
|
+
/** Thrown when a provider rate-limits the request. */
|
|
985
|
+
declare class RateLimitError extends MakaioError {
|
|
986
|
+
readonly code: "rate_limit";
|
|
987
|
+
}
|
|
988
|
+
/** Thrown when authentication/authorization fails. */
|
|
989
|
+
declare class AuthenticationError extends MakaioError {
|
|
990
|
+
readonly code: "auth";
|
|
991
|
+
}
|
|
992
|
+
/** Thrown when the requested model is unavailable (deprecated, not found, etc.). */
|
|
993
|
+
declare class ModelUnavailableError extends MakaioError {
|
|
994
|
+
readonly code: "model_unavailable";
|
|
995
|
+
}
|
|
996
|
+
/** Thrown when a usage quota (tokens, requests) is exceeded. */
|
|
997
|
+
declare class QuotaExceededError extends MakaioError {
|
|
998
|
+
readonly code: "quota_exceeded";
|
|
999
|
+
}
|
|
1000
|
+
//#endregion
|
|
1001
|
+
export { type AnyHandler, type AnyMessageContext, AuthenticationError, type BaseSubjectSchema, type BusNamespaceDefinition, type BusSubjects, type ChannelSubjectSchema, ConfigError, type ContextForSubjectDefinition, DirectoryNotFoundError, type EventContext, type EventHandler, type EventMessagePayload, type EventSchema, type ExtractSubjectPayload, type ExtractSubjectResponse, type FilterOperator, type FilterPayloadFromSchemas, type FilterablePayloadIntersection, type FlatSubjectDefinitions, type HandlerForSubjectDefinition, type IConfigStorage, type InferSchemaPayload, type InferSubjectMeta, InvalidModelError, type LocalSubjectSchema, type MakaioBusLike, type MakaioContext, MakaioError, type MessagePayload, ModelUnavailableError, type NamespaceRegistrationOptions, type NestedSubjectDefinitions, type OptionalResult, type PayloadFilter, type PrincipalContext, QuotaExceededError, RateLimitError, type RegistrableBusNamespaceDefinition, type RequestContext, type RequestHandler, type RequestMessagePayload, type RequestSchema, type SchemaRecord, type SchemaViolationReport, type ScopedSubjectDefinition, type SubjectDefinition, type SubjectRecord, type SubjectRecordFromSchemaRecord, type SubjectSchema, type TransportPeerContext, type TransportReceiveContext, type TypedPayloadFilter, type WildcardContext, type WildcardSubject, type WildcardSubjectDefinition, WildcardSubjectKey, type WildcardUnifiedHandler, channelSubject, createBusNamespace, createMakaioContext, getFullSubjectForSubjectDefinition, isChannelSchema, isLocalSchema, isOperatorObject, isRequestSchema, localSubject, nestSubjectDefinitions, unwrapSchema };
|