@makaio/framework 1.0.0-dev-1779046984397 → 1.0.0-dev-1779051654000
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/README.md +32 -315
- package/dist/{account-identity-Ce1Bwrqi.mjs → account-identity-Bg_vKkcs.mjs} +1 -1
- package/dist/{adapter-CbyjCE2d.mjs → adapter-CpF2aK_-.mjs} +1 -1
- package/dist/adapters/config/index.d.mts +1 -1
- package/dist/adapters/config/index.mjs +1 -1
- package/dist/adapters/index.d.mts +2 -2
- package/dist/adapters/index.mjs +1 -1
- package/dist/adapters/node.d.mts +1 -1
- package/dist/adapters/node.mjs +1 -1
- package/dist/client-DMWXCWhM.mjs +1 -0
- package/dist/clients/index.d.mts +122 -347
- package/dist/clients/index.mjs +2 -1
- package/dist/{clients-namespace-B0xAPZ6J.d.mts → clients-namespace-UHj5wt-l.d.mts} +7 -7
- package/dist/contracts/adapter/index.d.mts +2 -2
- package/dist/contracts/adapter/index.mjs +1 -1
- package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
- package/dist/contracts/client/index.d.mts +3 -3
- package/dist/contracts/client/index.mjs +1 -1
- package/dist/contracts/common/index.d.mts +1 -1
- package/dist/contracts/config/index.d.mts +6 -6
- package/dist/contracts/config/index.mjs +1 -1
- package/dist/contracts/extension/index.d.mts +2 -2
- package/dist/contracts/extension/index.mjs +1 -1
- package/dist/contracts/harness/index.d.mts +1 -1
- package/dist/contracts/harness/index.mjs +1 -1
- package/dist/contracts/host/index.mjs +1 -1
- package/dist/contracts/index.d.mts +64 -63
- package/dist/contracts/index.mjs +1 -1
- package/dist/contracts/model-registry/index.mjs +1 -1
- package/dist/contracts/native-session-supervisor/index.mjs +1 -1
- package/dist/contracts/platform/index.mjs +1 -1
- package/dist/contracts/session/index.d.mts +2 -2
- package/dist/contracts/session/index.mjs +1 -1
- package/dist/contracts/shared/index.d.mts +1 -1
- package/dist/contracts/shared/index.mjs +1 -1
- package/dist/contracts/skill/index.mjs +1 -1
- package/dist/contracts/timeout/index.d.mts +2 -0
- package/dist/contracts/timeout/index.mjs +1 -0
- package/dist/contracts/toast/index.mjs +1 -1
- package/dist/contracts/variant/index.mjs +1 -1
- package/dist/{definition-DxvZ9e22.d.mts → definition-DB7bbFSa.d.mts} +84 -91
- package/dist/{extension-COqwS-2Q.mjs → extension-53GerdGg.mjs} +1 -1
- package/dist/extension-fJmv8Yri.mjs +1 -0
- package/dist/{handlers-iGKUJ380.mjs → handlers-DR_4_rAT.mjs} +1 -1
- package/dist/{harness-CEq1Zkf9.mjs → harness-B6lGP9rm.mjs} +1 -1
- package/dist/{index-DBQtpFLE.d.mts → index-BnSQE7z7.d.mts} +3 -3
- package/dist/{index-CVA0m1g9.d.mts → index-CnmPtjnA.d.mts} +4 -4
- package/dist/{index-hapw9_En.d.mts → index-Cq8B7cwK.d.mts} +67 -67
- package/dist/{index-BJOfdtbw.d.mts → index-DGTFJB_8.d.mts} +3 -3
- package/dist/{index-DubqLGH8.d.mts → index-DaEp4UWW.d.mts} +56 -62
- package/dist/{index-C9F3Fc1A.d.mts → index-DwCA1HWa.d.mts} +133 -79
- package/dist/index-E8d_RwaF.d.mts +28 -0
- package/dist/{index-BB419vv-.d.mts → index-e5C62_M3.d.mts} +31 -11
- package/dist/{index-Bv15sNLn.d.mts → index-sBob9D25.d.mts} +1 -1
- package/dist/{index-BAKM2GMH2.d.mts → index-tKvu34DJ2.d.mts} +6 -6
- package/dist/{index-BdPwu6c0.d.mts → index-yvN8UcEH.d.mts} +110 -110
- package/dist/kernel/cli/index.mjs +1 -1
- package/dist/kernel/cli/schemas.mjs +1 -1
- package/dist/kernel/extension/index.d.mts +1 -1
- package/dist/kernel/extension/index.mjs +1 -1
- package/dist/kernel/index.d.mts +2 -2
- package/dist/kernel/index.mjs +1 -1
- package/dist/kernel/namespace/index.mjs +1 -1
- package/dist/kernel/observability/index.d.mts +1 -1
- package/dist/kernel/observability/index.mjs +1 -1
- package/dist/kernel/providers/index.mjs +1 -1
- package/dist/kernel/window/index.mjs +1 -1
- package/dist/{namespace-CkLUtc0g.d.mts → namespace-B1E57soL.d.mts} +22 -22
- package/dist/{namespace-bq4Prtzn.d.mts → namespace-B5ZCshBw.d.mts} +75 -75
- package/dist/{namespace-CCDEOwmW.d.mts → namespace-BCRNwPnw.d.mts} +6 -6
- package/dist/{namespace-ptv-pw_g.d.mts → namespace-BKrV_2gZ.d.mts} +9 -9
- package/dist/{namespace-O5SNY-LV.d.mts → namespace-BpIE-jQW.d.mts} +14 -14
- package/dist/{namespace-8cNguvIp.mjs → namespace-DGMO2E8f.mjs} +1 -1
- package/dist/{namespace-FWx6HxaW.d.mts → namespace-DXnMk3U8.d.mts} +14 -14
- package/dist/{namespace-xkvVw3hf2.d.mts → namespace-DwCyOaZn2.d.mts} +2 -2
- package/dist/{namespace-C2ufjgaQ.d.mts → namespace-Ysg1N6rR.d.mts} +24 -24
- package/dist/{native-session-supervisor-L-UIaEfd.mjs → native-session-supervisor-zPt624Tp.mjs} +1 -1
- package/dist/node/bus-server/index.d.mts +1 -1
- package/dist/node/bus-server/index.mjs +1 -1
- package/dist/node/bus-server/server-lifecycle.d.mts +1 -1
- package/dist/node/bus-server/server-lifecycle.mjs +1 -1
- package/dist/{orchestrator-shared-Wv1GI2mW.mjs → orchestrator-shared-D2txLAUs.mjs} +1 -1
- package/dist/profile-Cq4A7kQa.mjs +1 -0
- package/dist/{provider-context-CNRQ4d5m.mjs → provider-context-BB4eD8ON.mjs} +1 -1
- package/dist/{schema-BwzXEtT2.d.mts → schema-B295yplx.d.mts} +1 -1
- package/dist/{schema-CAw_BqaG.mjs → schema-C4iznV0q.mjs} +1 -1
- package/dist/{schema-introspection-D61TT_7b.mjs → schema-introspection-DCYC47_d.mjs} +1 -1
- package/dist/{schemas-BdMU-gew.d.mts → schemas-BWvuaL0w.d.mts} +4 -4
- package/dist/{schemas-D9108Iv1.d.mts → schemas-BfMZAwff.d.mts} +7 -7
- package/dist/{schemas-BXstpWVp.mjs → schemas-Bn8aqDIE.mjs} +1 -1
- package/dist/{schemas-qmn5SWPU.d.mts → schemas-C31qbb0s.d.mts} +4 -4
- package/dist/{schemas-DbWs_hj8.d.mts → schemas-DYqKRNju.d.mts} +3 -3
- package/dist/{schemas-DENVYyds.d.mts → schemas-Ra8pz5M-.d.mts} +14 -14
- package/dist/services/adapter-runtime/index.mjs +1 -1
- package/dist/services/adapter-subsystem/index.d.mts +2 -2
- package/dist/services/adapter-subsystem/index.mjs +1 -1
- package/dist/services/adapter-subsystem/namespace.d.mts +1 -1
- package/dist/services/adapter-subsystem/namespace.mjs +1 -1
- package/dist/services/capability/index.mjs +1 -1
- package/dist/services/context-rules/index.mjs +1 -1
- package/dist/services/execution-target/index.d.mts +3 -3
- package/dist/services/execution-target/index.mjs +1 -1
- package/dist/services/execution-target/namespace.d.mts +1 -1
- package/dist/services/execution-target/schemas.d.mts +1 -1
- package/dist/services/filesystem/namespace.d.mts +6 -6
- package/dist/services/filesystem/schemas.d.mts +3 -3
- package/dist/services/harness/index.d.mts +34 -34
- package/dist/services/harness/index.mjs +1 -1
- package/dist/services/harness/storage/schema.d.mts +4 -4
- package/dist/services/index.d.mts +70 -71
- package/dist/services/index.mjs +1 -1
- package/dist/services/log-import/log-import.mjs +1 -1
- package/dist/services/log-import/namespace.mjs +1 -1
- package/dist/services/log-import/schemas.mjs +1 -1
- package/dist/services/model-registry/index.mjs +1 -1
- package/dist/services/preferences/index.d.mts +2 -2
- package/dist/services/preferences/schemas.d.mts +1 -1
- package/dist/services/preferences/storage-namespace.d.mts +2 -2
- package/dist/services/provider-context/index.mjs +1 -1
- package/dist/services/provider-runtime/index.mjs +1 -1
- package/dist/services/session/handlers/index.mjs +1 -1
- package/dist/services/session/index.d.mts +7 -7
- package/dist/services/session/index.mjs +1 -1
- package/dist/services/session/messages/namespace.d.mts +1 -1
- package/dist/services/session/messages/namespace.mjs +1 -1
- package/dist/services/session/orchestrator-testing/index.mjs +1 -1
- package/dist/services/session/session-events/namespace.d.mts +1 -1
- package/dist/services/session/session-events/namespace.mjs +1 -1
- package/dist/services/session/storage/namespace.d.mts +1 -1
- package/dist/services/session/storage/schema.d.mts +1 -1
- package/dist/services/session/testing/index.mjs +1 -1
- package/dist/services/session/testing/orchestrator-shared.mjs +1 -1
- package/dist/services/session/turns/namespace.d.mts +1 -1
- package/dist/services/session/turns/namespace.mjs +1 -1
- package/dist/services/session-editor/index.mjs +1 -1
- package/dist/services/settings/index.d.mts +1 -1
- package/dist/services/settings/index.mjs +1 -1
- package/dist/services/settings/namespace.d.mts +9 -9
- package/dist/services/settings/namespace.mjs +1 -1
- package/dist/services/settings/storage/clients-namespace.d.mts +1 -1
- package/dist/services/settings/storage/clients-namespace.mjs +1 -1
- package/dist/services/settings/storage/extension-configs/namespace.d.mts +3 -3
- package/dist/services/settings/storage/index.d.mts +1 -1
- package/dist/services/settings/storage/index.mjs +1 -1
- package/dist/services/settings/storage/providers-namespace.mjs +1 -1
- package/dist/services/tool-approval/index.mjs +1 -1
- package/dist/services/tools/index.mjs +1 -1
- package/dist/services/tray-menu/index.d.mts +2 -2
- package/dist/services/tray-menu/index.mjs +1 -1
- package/dist/services/tray-menu/namespace.d.mts +1 -1
- package/dist/services/tray-menu/schemas.d.mts +1 -1
- package/dist/services/turn/index.d.mts +1 -1
- package/dist/services/turn/namespace.d.mts +1 -1
- package/dist/services/turn/schemas.d.mts +11 -11
- package/dist/services/worker/index.d.mts +1 -1
- package/dist/services/worker/schemas.d.mts +1 -1
- package/dist/{session-piI1R5rP.mjs → session-BCSf-Fgj.mjs} +1 -1
- package/dist/{session-Do6lDZM4.mjs → session-BNo_cIiz.mjs} +1 -1
- package/dist/{shared-DxHLl9UP.mjs → shared-BhuSHZXH.mjs} +1 -1
- package/dist/{skill-CB5h-ZFQ.mjs → skill-20_SBXaI.mjs} +1 -1
- package/dist/storage/handlers/drizzle/index.mjs +1 -1
- package/dist/storage/handlers/index.mjs +1 -1
- package/dist/{storage-namespace-DAm8iWEj.d.mts → storage-namespace-DoH-Wkjp.d.mts} +10 -10
- package/dist/timeout-D33CUZ0M.mjs +1 -0
- package/dist/{tool-approval-service-BcBSUZCO.mjs → tool-approval-service-CZCPfvVy.mjs} +1 -1
- package/dist/{tools-CDSgj0ee.mjs → tools-Cid9D99F.mjs} +1 -1
- package/dist/{types-BjToUrHp.d.mts → types--nrtGZ1V.d.mts} +24 -24
- package/dist/ui-kernel/index.d.mts +4 -4
- package/dist/ui-kernel/pages/namespace.d.mts +4 -4
- package/dist/ui-kernel/pages/schemas.d.mts +1 -1
- package/package.json +5 -1
- package/dist/client-Dh4x4GQN.mjs +0 -1
- package/dist/extension-Cbrl4YGX.mjs +0 -1
- package/dist/index-CNxS4Tlu.d.mts +0 -1
- package/dist/profile-4StaDQW0.mjs +0 -1
- package/dist/schemas-CGZy_rU6.d.mts +0 -13
- /package/dist/{base-orchestrator-9z8TuA5a.d.mts → base-orchestrator-BOAPgqF7.d.mts} +0 -0
- /package/dist/{capability-service-tnpR_TaB.mjs → capability-service-DV32ecwR.mjs} +0 -0
- /package/dist/{cleanEnvForAdapter-DvcIGXTG.mjs → cleanEnvForAdapter-hTPNvPU5.mjs} +0 -0
- /package/dist/{config-namespace-DLSs83zr.d.mts → config-namespace-ChZOpi1W.d.mts} +0 -0
- /package/dist/{config-namespace-MJT8P0Ud.mjs → config-namespace-wJ2CakDB.mjs} +0 -0
- /package/dist/{cursor-storage-DOQdvo9j.mjs → cursor-storage-BoNI7OAR.mjs} +0 -0
- /package/dist/{drizzle-CWVVw7Er.mjs → drizzle-Bn2GtW8c.mjs} +0 -0
- /package/dist/{execution-target-BW_uiBVe.mjs → execution-target-D6MgthYs.mjs} +0 -0
- /package/dist/{extension-namespace-zaGKi6Qj.mjs → extension-namespace-CTd9kOtt.mjs} +0 -0
- /package/dist/{host-CXAUGGN0.mjs → host-CvEht5RT.mjs} +0 -0
- /package/dist/{identity-B_A0mE63.mjs → identity-DBST3-XO.mjs} +0 -0
- /package/dist/{index-PdUSmPT2.d.mts → index-D2jejYlV.d.mts} +0 -0
- /package/dist/{index-T0471kWA.d.mts → index-DQWMu5fS.d.mts} +0 -0
- /package/dist/{model-registry-CIscwC52.mjs → model-registry-Dzpssh9j.mjs} +0 -0
- /package/dist/{model-registry-BNzpR6TU.mjs → model-registry-xINyxQUT.mjs} +0 -0
- /package/dist/{namespace-Bmc7AW4J2.mjs → namespace-C_h7scWx2.mjs} +0 -0
- /package/dist/{namespace-N0dfwSg6.mjs → namespace-DBw9BYr8.mjs} +0 -0
- /package/dist/{namespace-pNcSglBS.mjs → namespace-DUVgMfTR.mjs} +0 -0
- /package/dist/{namespace-0yuzAKlr.mjs → namespace-OwAf1Brw.mjs} +0 -0
- /package/dist/{namespace-CfEWMXBx.mjs → namespace-Zb8HAbyF.mjs} +0 -0
- /package/dist/{namespace-Db-p67Rg.mjs → namespace-aALq9tnE.mjs} +0 -0
- /package/dist/{namespace-D5Wrt7YU.mjs → namespace-yxIxUsjo.mjs} +0 -0
- /package/dist/{platform-BbSLVg5b.mjs → platform-BMFUpmTA.mjs} +0 -0
- /package/dist/{providers-Cr4Za8a1.mjs → providers-DhiW_fx4.mjs} +0 -0
- /package/dist/{schema-uSGW-6oM.mjs → schema-D3ZG13h9.mjs} +0 -0
- /package/dist/{schemas-C40ZAJ33.mjs → schemas-CEBe89yE.mjs} +0 -0
- /package/dist/{schemas-Co_sVhzz.mjs → schemas-COnLJnt_.mjs} +0 -0
- /package/dist/{schemas-CLxtoKFy.mjs → schemas-CrnlCRep.mjs} +0 -0
- /package/dist/{server-lifecycle-Cf_SZ27k.d.mts → server-lifecycle-BC6FRn86.d.mts} +0 -0
- /package/dist/{server-lifecycle-DbFwlrTW.mjs → server-lifecycle-Dx5WgfoS.mjs} +0 -0
- /package/dist/{session-lineage-Eev4uo4I.d.mts → session-lineage-B0cpHfuc.d.mts} +0 -0
- /package/dist/{shared-schemas-BgQv_tnu.mjs → shared-schemas-Byah36lG.mjs} +0 -0
- /package/dist/{storage-namespace-ADwyijoe.mjs → storage-namespace-BIDs9LPb.mjs} +0 -0
- /package/dist/{storage-namespace-definition-CHu2k14q.mjs → storage-namespace-definition-BjK9nZAN.mjs} +0 -0
- /package/dist/{tray-menu-service-CTXC1Elg.mjs → tray-menu-service-BAYtLdAg.mjs} +0 -0
- /package/dist/{types-CD1LJwPc.d.mts → types-C11LvekX.d.mts} +0 -0
- /package/dist/{ui-config-CXmbsqZV.mjs → ui-config-zawaoEfB.mjs} +0 -0
- /package/dist/{variant-D5kSrL3m.mjs → variant-BZWfmS0q.mjs} +0 -0
- /package/dist/{version-CjS20oXi.mjs → version-D8S4O22A.mjs} +0 -0
- /package/dist/{window-registry-CUftmDr3.mjs → window-registry-B_-hBEcV.mjs} +0 -0
package/README.md
CHANGED
|
@@ -1,125 +1,31 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<img src="
|
|
3
|
-
<h1
|
|
2
|
+
<img src="https://raw.githubusercontent.com/makaio-ai/makaio-framework/main/docs/assets/logo.svg" alt="Makaio Logo" width="120" />
|
|
3
|
+
<h1>@makaio/framework</h1>
|
|
4
4
|
<p><strong>A typed, bus-centric runtime for orchestrating AI agents, tools, and sessions across providers.</strong></p>
|
|
5
5
|
|
|
6
|
-
[](
|
|
6
|
+
[](https://github.com/makaio-ai/makaio-framework/blob/main/LICENSE)
|
|
7
7
|
[](https://github.com/makaio-ai/makaio-framework/actions/workflows/ci.yml)
|
|
8
|
-
|
|
9
|
-
[Website](https://makaio.ai) · [Getting Started](https://makaio.ai/guides/getting-started/) · [Why Makaio](https://makaio.ai/why/)
|
|
10
8
|
</div>
|
|
11
9
|
|
|
12
10
|
---
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
> **Give your AI agent full context.** Point it at [`makaio.ai/llms.txt`](https://makaio.ai/llms.txt) — everything it needs to answer questions, write extensions, or explore the architecture with you.
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Most AI tooling today solves one layer: call an LLM, stream a response, maybe loop on tool calls. That works until you need multiple providers in one system, agents that communicate across processes, storage you can swap without rewriting services, or extensions that load at runtime without forking the host.
|
|
21
|
-
|
|
22
|
-
Makaio Framework is a typed runtime for building and hosting AI agent systems. It gives you a bus-centric architecture where agents, services, tools, and storage communicate through typed events and RPC — across threads, processes, or machines.
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
### Connect your AI tools
|
|
27
|
-
|
|
28
|
-
> [!NOTE]
|
|
29
|
-
> Makaio normalizes the infrastructure beneath your AI tools — adapters, credentials, streaming, storage. Build a usage tracker, session viewer, or approval workflow once, and it works across Claude Code, Codex, Gemini, and more. Already built something for one provider? Move it to Makaio and it works with all of them.
|
|
30
|
-
>
|
|
31
|
-
> → [Connect your tooling](../../docs/connect.md) · [Shipped extensions](../../extensions/index.md)
|
|
12
|
+
## What is this?
|
|
32
13
|
|
|
33
|
-
|
|
14
|
+
Makaio Framework is runtime infrastructure for AI agent systems. It provides a typed event bus where agents, services, tools, and storage communicate through events and RPC — across threads, processes, or machines.
|
|
34
15
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
### Compose, intercept, extend
|
|
41
|
-
|
|
42
|
-
> [!NOTE]
|
|
43
|
-
> Everything flows through a typed bus — tool calls, agent events, storage requests. Intercept tool inputs for redaction, route sensitive analysis to local models, chain handlers with priority middleware. Build sophisticated automations without forking the framework.
|
|
44
|
-
>
|
|
45
|
-
> → [Bus architecture](../../docs/architecture/bus/index.md) · [Writing an adapter](../../docs/creating-adapters.md)
|
|
46
|
-
|
|
47
|
-
### Evaluating agent frameworks?
|
|
48
|
-
|
|
49
|
-
> [!NOTE]
|
|
50
|
-
> Makaio is not another LangChain wrapper. It's runtime infrastructure: a typed event bus with cross-process transports, a 3-layer adapter contract with conformance tests, and an extension system where capabilities load at runtime. Compare it to the orchestration layer beneath your agents, not the agents themselves.
|
|
51
|
-
>
|
|
52
|
-
> → [How this differs](#how-this-differs) · [Architecture](#architecture)
|
|
53
|
-
|
|
54
|
-
---
|
|
16
|
+
- **8 provider adapters** (Anthropic, OpenAI, Gemini, Codex, Qwen, GitHub Copilot, and more)
|
|
17
|
+
- **Typed event bus** with pub/sub, RPC, namespaces, and cross-process transports
|
|
18
|
+
- **Extension system** — capabilities load at runtime, not compile time
|
|
19
|
+
- **Bus-mediated storage** — swap backends without touching service code
|
|
20
|
+
- **Conformance-tested** — every adapter passes a shared test suite
|
|
55
21
|
|
|
56
22
|
## Install
|
|
57
23
|
|
|
58
|
-
Makaio Framework is currently source-first. From a source checkout:
|
|
59
|
-
|
|
60
24
|
```bash
|
|
61
|
-
|
|
62
|
-
yarn dev
|
|
25
|
+
npm install @makaio/framework
|
|
63
26
|
```
|
|
64
27
|
|
|
65
|
-
|
|
66
|
-
CLI directly from source:
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
yarn tsx apps/cli/src/cli-entry.ts --help
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## Quick Start
|
|
73
|
-
|
|
74
|
-
Start the runtime and manage extensions — no code required:
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
# Start the Makaio runtime (bus + services + adapters)
|
|
78
|
-
makaio serve
|
|
79
|
-
|
|
80
|
-
# In another terminal — install extensions
|
|
81
|
-
makaio extension install ./extensions/account-manager # Local source checkout
|
|
82
|
-
makaio extension install ./my-local-extension # Your local extension
|
|
83
|
-
|
|
84
|
-
# See what's installed
|
|
85
|
-
makaio extension list
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Extensions contribute CLI commands, background services, tools, UI surfaces, and more — all discovered at runtime via `descriptor.json`. During the pre-release phase, framework-shipped extensions are installed from local paths; published npm package names will be documented once those packages are public.
|
|
89
|
-
|
|
90
|
-
The [account-manager](../../extensions/account-manager/README.md) extension adds credential management across AI tools. The [prompt](../../extensions/prompt/README.md) extension adds `makaio prompt send` — a provider-agnostic CLI for sending prompts, useful as a drop-in replacement for `claude -p` in scripts and CI pipelines.
|
|
91
|
-
|
|
92
|
-
## Why a Shared Framework
|
|
93
|
-
|
|
94
|
-
Everyone building AI-powered applications ends up writing the same infrastructure: provider adapters that break every SDK update, streaming pipelines, tool execution loops, session management, storage layers. Then the model landscape shifts — a new provider launches, an API version bumps, a protocol like ACP emerges — and every project maintains its own copy of the same adapter fixes.
|
|
95
|
-
|
|
96
|
-
This is that shared copy. One set of adapters with conformance tests, one extension model, one typed bus. You build your application, workflow, or agent system on top. When Anthropic ships a new API version or OpenAI changes their streaming format, the fix lands here once — not in every project independently.
|
|
97
|
-
|
|
98
|
-
## How This Differs
|
|
99
|
-
|
|
100
|
-
Existing solutions occupy specific layers:
|
|
101
|
-
|
|
102
|
-
| Layer | Examples | What they solve |
|
|
103
|
-
|-------|----------|-----------------|
|
|
104
|
-
| Provider abstraction | Vercel AI SDK, LiteLLM | Unified interface to call any LLM |
|
|
105
|
-
| Agent orchestration | LangGraph, AutoGen, CrewAI | Build and run multi-agent workflows |
|
|
106
|
-
| Coding assistants | Claude Code, Cursor, Copilot | AI-powered development in a single tool |
|
|
107
|
-
|
|
108
|
-
Makaio Framework operates below and across these layers. It provides the runtime infrastructure that agent systems need regardless of which provider, orchestration pattern, or host surface they use:
|
|
109
|
-
|
|
110
|
-
- A **typed event bus** with pub/sub, RPC, namespaces, and cross-process transports
|
|
111
|
-
- A **3-layer adapter contract** (Adapter → Agent → Connector) with conformance tests
|
|
112
|
-
- An **extension system** where capabilities load at runtime, not compile time
|
|
113
|
-
- **Bus-mediated storage** so backends are swappable without touching service code
|
|
114
|
-
- **Host composition** — CLI and desktop share the same boot pipeline
|
|
115
|
-
|
|
116
|
-
The bus isn't a notification layer added to a procedural core. It's the architectural backbone: services subscribe, adapters publish, storage handlers respond to requests, and transports bridge it all across process boundaries.
|
|
117
|
-
|
|
118
|
-
## Build on Makaio
|
|
119
|
-
|
|
120
|
-
Start any provider's agent with a bus request. Control tool access. React to events. All typed, all provider-agnostic:
|
|
121
|
-
|
|
122
|
-
> `@makaio/framework` is the intended public aggregate package. Until that package is published, these imports describe the release surface rather than an installable npm package.
|
|
28
|
+
## Usage
|
|
123
29
|
|
|
124
30
|
```ts
|
|
125
31
|
import { MakaioBus } from '@makaio/framework/bus';
|
|
@@ -127,237 +33,48 @@ import { AgentSubjects, SessionSubjects } from '@makaio/framework/contracts';
|
|
|
127
33
|
|
|
128
34
|
const sessionId = crypto.randomUUID();
|
|
129
35
|
|
|
130
|
-
// Start a session-backed turn — same shape regardless of provider
|
|
131
36
|
const { messageId } = await MakaioBus.request(SessionSubjects.sendMessage, {
|
|
132
37
|
sessionId,
|
|
133
38
|
agent: {
|
|
134
39
|
kind: 'adapter',
|
|
135
|
-
adapterName: 'anthropic-sdk', //
|
|
40
|
+
adapterName: 'anthropic-sdk', // or 'openai-node', 'gemini-sdk', etc.
|
|
136
41
|
systemPrompt: 'You are a security reviewer. Be concise.',
|
|
137
|
-
// Omit model to use the provider default, or pass an adapter-specific ID from the model registry.
|
|
138
42
|
},
|
|
139
43
|
message: 'Review the changes in src/ for security issues',
|
|
140
44
|
});
|
|
141
45
|
|
|
142
|
-
// Control what the agent can do — approve, deny, or abort
|
|
143
|
-
const unsub = MakaioBus.on(
|
|
144
|
-
AgentSubjects.toolApprove,
|
|
145
|
-
(ctx) => {
|
|
146
|
-
if (ctx.payload.toolName === 'write_file') {
|
|
147
|
-
ctx.setResult({ action: 'deny', message: 'Read-only review.', shouldAbort: false });
|
|
148
|
-
} else {
|
|
149
|
-
ctx.setResult({ action: 'allow' });
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
{ filter: { sessionId } },
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
// Wait for completion — typed result
|
|
156
46
|
const completed = await MakaioBus.once(AgentSubjects.complete, {
|
|
157
47
|
filter: { sessionId, messageId },
|
|
158
48
|
timeoutMs: 120_000,
|
|
159
49
|
});
|
|
160
50
|
|
|
161
51
|
console.info(completed.payload.message);
|
|
162
|
-
unsub();
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
Switch `adapterName` and the same session orchestration code runs against Claude, Codex, Gemini, or Qwen. Keep `model` omitted for provider defaults unless you have resolved a concrete adapter-specific model ID from the model registry. The [adapter conformance test suite](../../adapters/implementations/__tests__/) guarantees consistent behavior across all of them.
|
|
166
|
-
|
|
167
|
-
### Architecture
|
|
168
|
-
|
|
169
|
-
```text
|
|
170
|
-
┌─────────────────────────────────────────────────────────┐
|
|
171
|
-
│ Your Application / Host │
|
|
172
|
-
│ CLI, Electron, or custom host │
|
|
173
|
-
└────────────────────────┬────────────────────────────────┘
|
|
174
|
-
│
|
|
175
|
-
┌────────────────────────▼────────────────────────────────┐
|
|
176
|
-
│ Runtime + Extension Coordinator │
|
|
177
|
-
│ Dependency ordering · Lifecycle · Surfaces │
|
|
178
|
-
└────────────────────────┬────────────────────────────────┘
|
|
179
|
-
│
|
|
180
|
-
┌────────────────────────▼────────────────────────────────┐
|
|
181
|
-
│ Makaio Bus │
|
|
182
|
-
│ Typed pub/sub + RPC · Namespaces · Scoped/Filtered │
|
|
183
|
-
│ Transport registry (WebSocket, loopback, custom) │
|
|
184
|
-
└───────┬────────────────┼───────────────────┬────────────┘
|
|
185
|
-
│ │ │
|
|
186
|
-
┌───────▼──────┐ ┌──────▼───────┐ ┌────────▼─────────┐
|
|
187
|
-
│ Services │ │ Storage │ │ Tools │
|
|
188
|
-
│ Session, │ │ Bus-backed │ │ Typed schemas, │
|
|
189
|
-
│ Orchestrator│ │ handlers │ │ registry, │
|
|
190
|
-
│ Registry │ │ (swappable) │ │ approval flow │
|
|
191
|
-
└──────────────┘ └──────────────┘ └──────────────────┘
|
|
192
|
-
│
|
|
193
|
-
┌───────▼─────────────────────────────────────────────────┐
|
|
194
|
-
│ Adapter Layer (3-part) │
|
|
195
|
-
│ AIAdapter → lifecycle, session management │
|
|
196
|
-
│ AIAgent → turn execution, tool orchestration │
|
|
197
|
-
│ AIAgentConnector → provider SDK / CLI / ACP bridge │
|
|
198
|
-
└─────────────────────────────────────────────────────────┘
|
|
199
52
|
```
|
|
200
53
|
|
|
201
|
-
|
|
54
|
+
Switch `adapterName` and the same code runs against any supported provider.
|
|
202
55
|
|
|
203
|
-
|
|
56
|
+
## Subpath Exports
|
|
204
57
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
|
208
|
-
|
|
209
|
-
| `
|
|
210
|
-
| `
|
|
211
|
-
| `
|
|
212
|
-
| `
|
|
213
|
-
| `
|
|
214
|
-
| `
|
|
215
|
-
| `
|
|
216
|
-
| `github-copilot-sdk` | GitHub (Copilot) | API SDK | [ABANDONED](https://github.blog/news-insights/company-news/github-copilot-is-moving-to-usage-based-billing/) |
|
|
217
|
-
|
|
218
|
-
**Status definitions:**
|
|
219
|
-
|
|
220
|
-
- **Stable** — Actively maintained, conformance tests pass, used in production
|
|
221
|
-
- **Experimental** — Working implementation, API surface may change
|
|
222
|
-
- **Community** — Maintained by contributors, not the core team
|
|
223
|
-
|
|
224
|
-
Writing a new adapter means implementing `AIAgentConnector` (the provider bridge), wrapping it in an `AIAgent` and `AIAdapter`, and running the conformance suite. See [Creating Adapters](../../docs/creating-adapters.md).
|
|
225
|
-
|
|
226
|
-
### SDKs
|
|
227
|
-
|
|
228
|
-
The bus protocol is language-neutral. SDKs let any process participate — subscribe to events, handle requests, emit — without importing the TypeScript framework:
|
|
229
|
-
|
|
230
|
-
| SDK | Language | Transport | Status |
|
|
231
|
-
|-----|----------|-----------|--------|
|
|
232
|
-
| [`@makaio/sdk`](../../sdks/typescript/) | TypeScript | Framework-native facade | Pre-release, unpublished package |
|
|
233
|
-
| [`makaio-sdk`](../../sdks/python/) | Python | WebSocket + stdio (asyncio) | Pre-release, unpublished package |
|
|
234
|
-
| [`makaio-sdk`](../../sdks/rust/) | Rust | WebSocket + stdio (tokio) | Unpublished crate (`publish = false`) |
|
|
235
|
-
|
|
236
|
-
All SDKs expose the same logical surface:
|
|
237
|
-
|
|
238
|
-
```
|
|
239
|
-
connect(url, options?) // WebSocket connection with optional HMAC auth and dispatch mode
|
|
240
|
-
subscribe(subject, handler) // event subscription (local + remote dispatch)
|
|
241
|
-
onRequest/on_request(...) // request handler with middleware chaining (TypeScript uses onRequest; Python/Rust use on_request)
|
|
242
|
-
request(subject, payload) // typed RPC (local-first dispatch by default)
|
|
243
|
-
emit(subject, payload) // fire-and-forget (dispatches to local + remote subscribers)
|
|
244
|
-
close() // clean shutdown
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
All three SDKs support HMAC authentication (auto-probed from `/health`), local-first request dispatch with middleware chaining via `RequestContext.next()`, typed subject descriptors generated from the protocol manifest, and WebSocket transport. Python and Rust additionally support stdio transport for detached extension processes.
|
|
248
|
-
|
|
249
|
-
Subscription cleanup is language-shaped: TypeScript returns unsubscribe functions, Python subscription handles expose `close()`, and Rust uses `unsubscribe()` for event subscriptions and `unregister()` for request handlers.
|
|
250
|
-
|
|
251
|
-
Cross-language SDKs are generated from a [shared protocol manifest](../../sdks/manifest/) derived from `@makaio/contracts`, validated against a [shared conformance suite](../../sdks/conformance/). The TypeScript SDK is a thin facade over the framework's bus packages.
|
|
58
|
+
| Import | Description |
|
|
59
|
+
|--------|-------------|
|
|
60
|
+
| `@makaio/framework/bus` | Typed event bus — pub/sub, RPC, namespaces |
|
|
61
|
+
| `@makaio/framework/contracts` | Zod schemas, subject taxonomy, wire format |
|
|
62
|
+
| `@makaio/framework/core` | Foundational types, errors, OptionalResult |
|
|
63
|
+
| `@makaio/framework/kernel` | Extension coordinator, service lifecycle |
|
|
64
|
+
| `@makaio/framework/services` | Session, orchestrator, tool registry, model registry |
|
|
65
|
+
| `@makaio/framework/adapters` | Adapter layer — lifecycle, session management |
|
|
66
|
+
| `@makaio/framework/storage` | Bus-mediated storage contracts and handlers |
|
|
67
|
+
| `@makaio/framework/tools` | Tool contract, defineTool(), defineToolset() |
|
|
68
|
+
| `@makaio/framework/testing` | Test helpers, bus fixtures, SQLite harness |
|
|
252
69
|
|
|
253
70
|
## Documentation
|
|
254
71
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
| CLI reference | [apps/cli/README.md](../../apps/cli/README.md) |
|
|
261
|
-
| Configuration | [docs/configuration.md](../../docs/configuration.md) |
|
|
262
|
-
|
|
263
|
-
**Build on Makaio:**
|
|
264
|
-
|
|
265
|
-
| Topic | Link |
|
|
266
|
-
|-------|------|
|
|
267
|
-
| Writing an extension | [docs/creating-extensions.md](../../docs/creating-extensions.md) |
|
|
268
|
-
| Writing an adapter | [docs/creating-adapters.md](../../docs/creating-adapters.md) |
|
|
269
|
-
| Extension model | [docs/architecture/extensions/index.md](../../docs/architecture/extensions/index.md) |
|
|
270
|
-
| Bus architecture | [docs/architecture/bus/](../../docs/architecture/bus/index.md) |
|
|
271
|
-
| Transport (WebSocket, cross-process) | [docs/architecture/transport.md](../../docs/architecture/transport.md) |
|
|
272
|
-
|
|
273
|
-
**Host and deploy:**
|
|
274
|
-
|
|
275
|
-
| Topic | Link |
|
|
276
|
-
|-------|------|
|
|
277
|
-
| Host applications | [docs/architecture/apps.md](../../docs/architecture/apps.md) |
|
|
278
|
-
|
|
279
|
-
## Repository Layout
|
|
280
|
-
|
|
281
|
-
Representative high-level tree for the framework distribution. It lists the main workspace groups and notable packages; individual provider, extension, and test packages may change as the framework evolves.
|
|
282
|
-
|
|
283
|
-
```text
|
|
284
|
-
├── adapters/
|
|
285
|
-
│ ├── core/ Adapter contracts, conformance test suite
|
|
286
|
-
│ ├── shared/ Shared ACP, Claude, and stream-session helpers
|
|
287
|
-
│ └── implementations/ One directory per provider adapter
|
|
288
|
-
├── apps/
|
|
289
|
-
│ ├── cli/ Headless CLI server + bus client
|
|
290
|
-
│ ├── electron/ Electron desktop host
|
|
291
|
-
│ ├── electrobun/ Electrobun desktop host (experimental)
|
|
292
|
-
│ ├── host-shared/ Shared desktop host boot/rendering logic
|
|
293
|
-
│ └── mcp-server/ MCP server bridge
|
|
294
|
-
├── build-tooling/ Shared Vite/tsdown configs for packages and extensions
|
|
295
|
-
├── clients/ External tool client integrations (Claude Code, Codex, Gemini, Copilot, Qwen)
|
|
296
|
-
├── docs/ Framework documentation
|
|
297
|
-
├── extensions/ Framework-shipped extensions
|
|
298
|
-
├── packages/
|
|
299
|
-
│ ├── adapter-subsystem/ Adapter contribution loading, runtime registry, identity
|
|
300
|
-
│ ├── bus-core/ Typed event bus — pub/sub, RPC, namespaces, scoped/filtered buses
|
|
301
|
-
│ ├── bus-server/ HTTP + WebSocket server lifecycle
|
|
302
|
-
│ ├── bus-server-vite/ Vite dev-server bus integration
|
|
303
|
-
│ ├── clients-core/ Managed client/runtime/binary services
|
|
304
|
-
│ ├── contracts/ Zod schemas, subject taxonomy, wire format
|
|
305
|
-
│ ├── expression/ Expression evaluator over contracts
|
|
306
|
-
│ ├── file-watcher/ File watching abstraction
|
|
307
|
-
│ ├── hooks/ Bus-event hook system
|
|
308
|
-
│ ├── machine-identity/ Stable machine ID (keypair)
|
|
309
|
-
│ ├── makaio-core/ Foundational types, errors, OptionalResult
|
|
310
|
-
│ ├── mcp-http-server/ MCP-over-HTTP bridge
|
|
311
|
-
│ ├── native-session-supervisor/ Native client session observation
|
|
312
|
-
│ ├── kernel/ ExtensionCoordinator, service lifecycle, boot observability
|
|
313
|
-
│ ├── services/base/ BaseService lifecycle primitive
|
|
314
|
-
│ ├── services/core/ Core services: session, orchestrator, tool registry, model registry
|
|
315
|
-
│ ├── services/log-import/ Session log import service
|
|
316
|
-
│ ├── services/package-manager/ Package discovery and management service
|
|
317
|
-
│ ├── storage/core/ Storage namespace contracts
|
|
318
|
-
│ ├── storage/drizzle/ Drizzle/SQLite client helpers, FTS, transactions
|
|
319
|
-
│ ├── storage/handlers/ Bus-backed CRUD + list handler factories
|
|
320
|
-
│ ├── storage-migrations/ Migration runner + schema discovery
|
|
321
|
-
│ ├── preferences/ User preferences storage
|
|
322
|
-
│ ├── providers/ Config/provider runtime helpers
|
|
323
|
-
│ ├── rules/ Runtime rule helpers
|
|
324
|
-
│ ├── test-utils/ Test helpers, bus fixtures, SQLite test harness
|
|
325
|
-
│ └── utils/ Shared utilities
|
|
326
|
-
├── providers/ Provider metadata packages (model catalogs, capability tags)
|
|
327
|
-
├── runtimes/
|
|
328
|
-
│ ├── bun/ Bun host assembly helpers
|
|
329
|
-
│ └── node/ Node host assembly: bootMakaioRuntime(), discovery, DB init
|
|
330
|
-
├── sdks/
|
|
331
|
-
│ ├── typescript/ @makaio/sdk — TypeScript facade
|
|
332
|
-
│ ├── python/ Python SDK (asyncio, WebSocket + stdio)
|
|
333
|
-
│ ├── rust/ Rust SDK (tokio, WebSocket + stdio)
|
|
334
|
-
│ ├── manifest/ Language-neutral protocol definition (generated)
|
|
335
|
-
│ └── conformance/ Shared wire-level conformance fixtures
|
|
336
|
-
├── tools/
|
|
337
|
-
│ ├── core/ Tool contract, defineTool(), defineToolset(), executor
|
|
338
|
-
│ ├── filesystem/ File read/write/search tools
|
|
339
|
-
│ ├── shell/ Shell execution tool
|
|
340
|
-
│ └── subagent/ Sub-agent spawning tool
|
|
341
|
-
├── transports/
|
|
342
|
-
│ ├── ws/ WebSocket transport (HMAC auth, E2E encryption, relay)
|
|
343
|
-
│ └── message-channel/ MessageChannel transport (SharedWorker, iframe)
|
|
344
|
-
└── ui/
|
|
345
|
-
├── kernel/ UI contracts, registries (widgets, pages, navigation)
|
|
346
|
-
├── theme/ SCSS design system: tokens, themes, mixins
|
|
347
|
-
├── components/ Pure UI components (no hooks, no bus)
|
|
348
|
-
├── hooks/ React hooks, stores, providers (BusProvider, useBus)
|
|
349
|
-
└── views/ Composed views and shell components
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
## Contributing
|
|
353
|
-
|
|
354
|
-
We welcome contributions — adapters, extensions, tools, bug fixes, and documentation. See [CONTRIBUTING.md](../../CONTRIBUTING.md) for development setup, contribution surfaces, and PR guidelines.
|
|
355
|
-
|
|
356
|
-
## Community
|
|
357
|
-
|
|
358
|
-
- [Code of Conduct](../../CODE_OF_CONDUCT.md)
|
|
359
|
-
- [Security Policy](../../SECURITY.md)
|
|
72
|
+
- [Getting Started](https://github.com/makaio-ai/makaio-framework/blob/main/docs/getting-started.md)
|
|
73
|
+
- [Writing an Extension](https://github.com/makaio-ai/makaio-framework/blob/main/docs/creating-extensions.md)
|
|
74
|
+
- [Writing an Adapter](https://github.com/makaio-ai/makaio-framework/blob/main/docs/creating-adapters.md)
|
|
75
|
+
- [Bus Architecture](https://github.com/makaio-ai/makaio-framework/blob/main/docs/architecture/bus/index.md)
|
|
76
|
+
- [Full README](https://github.com/makaio-ai/makaio-framework)
|
|
360
77
|
|
|
361
78
|
## License
|
|
362
79
|
|
|
363
|
-
[MIT](
|
|
80
|
+
[MIT](https://github.com/makaio-ai/makaio-framework/blob/main/LICENSE)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as e}from"./shared-
|
|
1
|
+
import{m as e}from"./shared-BhuSHZXH.mjs";import{g as t,h as n}from"./profile-Cq4A7kQa.mjs";import{n as r}from"./version-D8S4O22A.mjs";import{z as i}from"zod";const a=i.enum([`strong`,`alias`]),o=i.object({scheme:t,value:t,strength:a}),s=i.object({key:t,label:i.string(),usedPercentage:i.number().finite().min(0).max(100),resetsAt:n.optional()}),c=i.object({windows:i.array(s)}),l=i.record(i.string(),i.unknown()).optional(),u=i.object({clientId:t,found:i.boolean(),version:i.string().optional(),warningMessage:i.string().optional()}),d=i.object({clientId:t,binaryName:t,supportedVersions:r.optional()}),f=i.object({clientAccountId:t,clientId:t,observedAt:n,source:t,displayLabel:i.string().optional(),usage:c,metadata:l}),p=i.discriminatedUnion(`kind`,[i.object({kind:i.literal(`session`),sessionId:t}),i.object({kind:i.literal(`adapter-session`),adapterSessionId:t}),i.object({kind:i.literal(`both`),sessionId:t,adapterSessionId:t})]),m=i.object({clientId:i.string(),source:i.string(),kind:i.string(),observedAt:n,payload:e}),h={request:i.object({clientId:t,observedAt:n.optional(),displayLabel:i.string().optional(),identifiers:i.array(o).min(1),metadata:l}),response:i.object({clientAccountId:t,displayLabel:i.string().optional()})},g={request:m.extend({locator:p}),response:i.object({handled:i.boolean(),sessionId:t.nullable(),clientAccountId:t.nullable(),changed:i.boolean()})},_={request:i.object({clientId:t,observedAt:n,source:t,account:i.object({displayLabel:i.string().optional(),identifiers:i.array(o).min(1)}),usage:c,metadata:l}),response:i.object({clientAccountId:t,snapshot:f})};export{l as a,g as c,f as d,s as f,m as i,p as l,h as n,u as o,c as p,a as r,d as s,o as t,_ as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,b as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,ot as u,p as d,r as f,s as p,t as m,u as h,v as g,x as _,y as v}from"./schemas-
|
|
1
|
+
import{_ as e,b as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,ot as u,p as d,r as f,s as p,t as m,u as h,v as g,x as _,y as v}from"./schemas-Bn8aqDIE.mjs";import"./contracts/adapter/schemas/session-lineage.mjs";import{createBusNamespace as y}from"@makaio/framework/core";const b={getCapabilities:u,startAgent:_,infer:t,listAgents:v,getAgent:g,stopAgent:e,rehydrateAgent:a,getConfigSchema:o,"agent.created":l,"session.created":d,"session.discovered":s,"session.linked":f,"session.statusChanged":m,"session.usage":i,"session.closed":r,log:h,error:c,initialized:n,quota:p},x=y(`adapter`,b),S=x.subjects;export{S as n,b as r,x as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as BaseAgentConnectorConfig } from "../../types-
|
|
1
|
+
import { g as BaseAgentConnectorConfig } from "../../types-C11LvekX.mjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { IMakaioBus, MakaioBusContext } from "@makaio/framework/bus";
|
|
4
4
|
import { AIModelSchema, ProtocolId, ProviderContext } from "@makaio/framework/contracts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../../cleanEnvForAdapter-
|
|
1
|
+
import{t as e}from"../../cleanEnvForAdapter-hTPNvPU5.mjs";import{z as t}from"zod";import{createBusInstance as n,openChannel as r}from"@makaio/framework/bus";import{AIModelSchema as i,CredentialSubjects as a}from"@makaio/framework/contracts";import{BaseAdapterConfigSchema as o,ProviderConfigSchema as s,ProviderDefaultsSchema as c}from"@makaio/framework/contracts/config";import l from"node:fs/promises";import{ProviderStorageSubjects as u}from"@makaio/framework/services/settings/storage";import{resolveTimeouts as d}from"@makaio/framework/utils";import{AdapterSubsystemSubjects as f}from"@makaio/framework/services/adapter-subsystem";import{resolveClientBinary as p}from"@makaio/framework/clients";async function m(e,t={}){if(e.startsWith(`env:`)){let n=e.slice(4);if(!n)throw Error(`Credential reference is missing environment variable name`);return(t.readEnv??(e=>process.env[e]))(n)||null}if(e.startsWith(`file:`)){let n=e.slice(5);if(!n)throw Error(`Credential reference is missing file path`);return(await(t.readFile??(async e=>await l.readFile(e,`utf-8`)))(n)).trim()||null}if(e.startsWith(`keychain:`)){let[n,...r]=e.slice(9).split(`:`);if(!n||r.length===0)throw Error(`Credential reference is missing keychain service or account`);if(!t.resolveKeychain)throw Error(`Keychain credential resolution is not configured`);return t.resolveKeychain(n,r.join(`:`))}return e||null}function h(e,t){let n=e.find(e=>e.id===t);if(!n)throw Error(`Provider definition not found: '${t}'`);if(!g(n))throw Error(`Provider definition '${t}' is missing a defaultModel`);return n}function g(e){return typeof e.defaultModel==`string`&&e.defaultModel.length>0}const _=t.record(t.string(),t.unknown());function v(e){return{getDefaults:()=>e().adapterDefaults,getConfig:async t=>{let{adapterName:n,adapterDefaults:r,adapterDefinition:i,protocol:a}=e(),{providerContext:o}=t,s=o.endpointOverrides?.[a]??null,c=d([{layer:`adapter`,source:n,config:i.defaultTimeouts},{layer:`runtime`,source:`config.ts`,config:t.runtimeTimeouts}]),l={...r.providerConfig,...t.providerConfig,baseUrl:s??t.providerConfig?.baseUrl??r.providerConfig?.baseUrl},u=t.model??r.model;if(!u)throw Error(`No model resolved for adapter "${n}" (agentId: ${t.agentId}). Provide a model explicitly or configure adapterDefaults.model.`);return{...r,...t,adapterName:t.adapterName,model:u,cwd:t.cwd??r.cwd??process.cwd(),timeouts:c,providerConfig:l}}}}async function y(e,t){let i=Object.entries(t);if(i.length===0)return{};let o={},s=e.getContext(),{token:c}=await n({context:s}).request(a.getChannelToken,{}),l=await r(s,`credentials`,{token:c,transports:[]});try{let e=await Promise.allSettled(i.map(([,e])=>l.request(a.resolve,{ref:e})));for(let t=0;t<i.length;t++){let[n,r]=i[t],a=e[t];if(a.status===`fulfilled`)if(a.value.value!==null)o[n]=a.value.value;else if(a.value.error){let e=JSON.stringify(r);console.warn(`[resolveConnectorCredentials] Failed to resolve field '${n}' (ref ${e}):`,a.value.error)}else{let e=JSON.stringify(r);console.info(`[resolveConnectorCredentials] Credential unavailable for field '${n}' (ref ${e}); omitting it from the resolved connector credentials.`)}else{let e=JSON.stringify(r);console.warn(`[resolveConnectorCredentials] Failed to resolve field '${n}' (ref ${e}):`,a.reason)}}}finally{l.close()}return o}async function b(e,t,n){let{config:r}=await e.request(f.getProviderConfig,{id:t});if(!r)throw Error(`ProviderConfig '${t}' not found`);let{context:i}=await e.request(f.buildProviderContext,{providerConfigId:t});if(!i)throw Error(`ProviderConfig '${t}' not found`);if(i.definitionId!==r.definitionId)throw Error(`ProviderConfig '${t}' changed during resolution; retry`);let{provider:a}=await e.request(u.get,{id:i.definitionId});if(!a)throw Error(`ProviderDefinition '${r.definitionId}' not found for config '${t}'`);return{config:r,definition:a,baseUrl:i.endpointOverrides?.[n]??a.endpoints?.[n]??null,credentials:await y(e,i.credentialRefs)}}async function x(e,t,n){let{baseUrl:r,credentials:i}=await b(e,t,n);if(!r)throw Error(`Could not resolve baseUrl for ProviderConfig '${t}' with protocol '${n}'. Ensure the provider definition or config override declares an endpoint for this protocol.`);let a=i.apiKey;if(!a)throw Error(`Could not resolve apiKey for ProviderConfig '${t}'. Store credentials via settings before using this provider.`);return{baseUrl:r,apiKey:a}}function S(e,t){if(!t)return{};let n={};for(let[r,i]of Object.entries(t)){let t=e[r];t!==void 0&&(n[i]=t)}return n}async function C(t){let{bus:n,providerContext:r,clientId:i,baseEnv:a={}}=t,o=await y(n,r?.credentialRefs??{}),s=S(o,r?.credentialEnvVars),c=await p(i);return{credentials:o,credEnv:s,resolvedBinary:c,spawnEnv:{...e(a,{omitEnvVars:r?.ambientCredentialEnvVars}),...s,...c?.env??{}}}}export{i as AIModelSchema,o as BaseAdapterConfigSchema,_ as BaseProviderConfigSchema,s as ProviderConfigSchema,c as ProviderDefaultsSchema,S as buildCredentialEnv,v as createAdapterConfigFactory,h as getDefinitionOrThrow,y as resolveConnectorCredentials,m as resolveCredentialRef,x as resolveProviderEndpoint,b as resolveProviderResolution,C as resolveSessionEnvironment};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as MessageHandle, B as ISessionToolLedger, C as SendMessageRequestPayload, D as IAdapterConfigFactory, E as ConfigFactoryInput, F as ProcessingState, H as SessionToolLedger, I as SendMessageOptions, L as AIModel, M as normalizeMessageInput, N as MessageResult, O as AIAgentConnector, P as MessageState, R as AIReasoningLevel, S as NormalizedCallUsage, T as StartAgentOptions, U as ToolLedgerEntry, V as LedgerSessionContext, _ as ConnectorSendMessageOptions, a as AgentCwdChangeRequestPayload, b as ExecutionContext, c as AgentInterruptRequestPayload, d as AgentMcpServersSetResponsePayload, f as AgentModelChangeRequestPayload, g as BaseAgentConnectorConfig, h as AgentStartResult, i as AgentCredentialChangeResponsePayload, j as NormalizedMessageInput, k as MessageDeliveryMode, l as AgentInterruptResponsePayload, m as AgentSendMessageOptions, n as AgentContext, o as AgentCwdChangeResponsePayload, p as AgentModelChangeResponsePayload, r as AgentCredentialChangeRequestPayload, s as AgentIdentity, t as AIAgentConfig, u as AgentMcpServersSetRequestPayload, v as ConnectorStartOptions, w as SendMessageResponsePayload, x as GetCapabilitiesResponsePayload, y as ContextWindowInput, z as ReasoningLevelMap } from "../types-
|
|
2
|
-
import { _ as LogImporterConfig, a as CompactionMetadata, b as StorageMessagePayload, c as ExternalToolIdentifiers, d as ImportMetadata, f as ImportSegment, g as LogImporter, h as LogImportTestConfig, l as ExternalToolMeta, m as LogImportSessionContext, n as LogOrchestratorConfig, o as DiscoveryMetadata, p as ImportSegmentLineage, r as ParseFileResult, s as ExternalToolIdentifier, u as ImportCursorPosition, v as NormalizedEvent, x as toImportSegment, y as ProcessLogFileResult } from "../base-orchestrator-
|
|
1
|
+
import { A as MessageHandle, B as ISessionToolLedger, C as SendMessageRequestPayload, D as IAdapterConfigFactory, E as ConfigFactoryInput, F as ProcessingState, H as SessionToolLedger, I as SendMessageOptions, L as AIModel, M as normalizeMessageInput, N as MessageResult, O as AIAgentConnector, P as MessageState, R as AIReasoningLevel, S as NormalizedCallUsage, T as StartAgentOptions, U as ToolLedgerEntry, V as LedgerSessionContext, _ as ConnectorSendMessageOptions, a as AgentCwdChangeRequestPayload, b as ExecutionContext, c as AgentInterruptRequestPayload, d as AgentMcpServersSetResponsePayload, f as AgentModelChangeRequestPayload, g as BaseAgentConnectorConfig, h as AgentStartResult, i as AgentCredentialChangeResponsePayload, j as NormalizedMessageInput, k as MessageDeliveryMode, l as AgentInterruptResponsePayload, m as AgentSendMessageOptions, n as AgentContext, o as AgentCwdChangeResponsePayload, p as AgentModelChangeResponsePayload, r as AgentCredentialChangeRequestPayload, s as AgentIdentity, t as AIAgentConfig, u as AgentMcpServersSetRequestPayload, v as ConnectorStartOptions, w as SendMessageResponsePayload, x as GetCapabilitiesResponsePayload, y as ContextWindowInput, z as ReasoningLevelMap } from "../types-C11LvekX.mjs";
|
|
2
|
+
import { _ as LogImporterConfig, a as CompactionMetadata, b as StorageMessagePayload, c as ExternalToolIdentifiers, d as ImportMetadata, f as ImportSegment, g as LogImporter, h as LogImportTestConfig, l as ExternalToolMeta, m as LogImportSessionContext, n as LogOrchestratorConfig, o as DiscoveryMetadata, p as ImportSegmentLineage, r as ParseFileResult, s as ExternalToolIdentifier, u as ImportCursorPosition, v as NormalizedEvent, x as toImportSegment, y as ProcessLogFileResult } from "../base-orchestrator-BOAPgqF7.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import * as _$_makaio_core0 from "@makaio/framework/core";
|
|
5
5
|
import { ExtractSubjectPayload, FilterablePayloadIntersection, HandlerForSubjectDefinition, RequestContext, SchemaRecord, ScopedSubjectDefinition, SubjectDefinition, SubjectRecordFromSchemaRecord } from "@makaio/framework/core";
|
package/dist/adapters/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"../cleanEnvForAdapter-
|
|
1
|
+
import{t as e}from"../cleanEnvForAdapter-hTPNvPU5.mjs";import{n as t,r as n,t as r}from"../cursor-storage-BoNI7OAR.mjs";import{z as i}from"zod";import*as a from"node:fs";import{AuthenticationError as o,DirectoryNotFoundError as s,ModelUnavailableError as c,QuotaExceededError as l,RateLimitError as u,createBusNamespace as d}from"@makaio/framework/core";import{MakaioBus as f,NoHandlerError as p,RequestError as m}from"@makaio/framework/bus";import{AdapterSubjects as h,AgentSubjects as g,AgentToolApproveSchema as _,HarnessSubjects as v,MCP_CALL_TOOL_NAME as ee,McpSubjects as y,SessionContextSchema as b,SessionSubjects as x}from"@makaio/framework/contracts";import{TurnStorageSubjects as te}from"@makaio/framework/services/turn";import{CredentialRefSchema as ne}from"@makaio/framework/contracts/config";import{runPostUserMessageHooks as re,runPreUserMessageHooks as ie}from"@makaio/framework/hooks";import{activateProviderContextStrict as ae,buildProviderContext as S}from"@makaio/framework/services/provider-context";import oe from"node:os";import{AgentStorageSubjects as C}from"@makaio/framework/services/session";import{DeferredPromise as w,resolveTimeouts as se}from"@makaio/framework/utils";import ce from"emittery";import*as le from"node:process";function ue(e,t,n){return f.registerNamespace(d(e,t,n))}function T(e){let t=[];try{return JSON.stringify(e,function(e,n){if(typeof n==`bigint`)return n.toString();if(typeof n==`object`&&n){for(;t.length>0&&t[t.length-1]!==this;)t.pop();if(t.includes(n))return`[Circular]`;t.push(n)}return n},2)??`[Non-serializable value]`}catch{try{return String(e)}catch{return`[Non-serializable value]`}}}function de(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`'`,`'`)}function fe(e){let t=e.replace(/[^a-zA-Z0-9_-]/g,`_`);return t.length===0?`context`:/^[A-Za-z_]/.test(t)?t:`context_${t}`}function E(e,t){let n=fe(e);return`<${n}>\n${de(t)}\n</${n}>`}function pe(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.name==`string`&&typeof t.description==`string`&&(t.compatibility===void 0||typeof t.compatibility==`string`)}function me(e){if(typeof e!=`object`||!e)return!1;let t=e,n=t.metadata,r=n;return typeof t.name==`string`&&typeof t.content==`string`&&(t.license===void 0||typeof t.license==`string`)&&(t.compatibility===void 0||typeof t.compatibility==`string`)&&(t.allowedTools===void 0||typeof t.allowedTools==`string`)&&(n===void 0||typeof n==`object`&&!!n&&Object.values(r??{}).every(e=>typeof e==`string`))}function he(e){if(!Array.isArray(e))return;let t=e.filter(pe).sort((e,t)=>e.name.localeCompare(t.name)).map(e=>e.compatibility?`- ${e.name}: ${e.description} Compatibility: ${e.compatibility}`:`- ${e.name}: ${e.description}`);return t.length>0?t.join(`
|
|
2
2
|
`):void 0}function ge(e){if(!Array.isArray(e))return;let t=e.filter(me).sort((e,t)=>e.name.localeCompare(t.name)).map(e=>{let t=[`## ${e.name}`];return e.compatibility&&t.push(`Compatibility: ${e.compatibility}`),t.push(e.content),t.join(`
|
|
3
3
|
`)});return t.length>0?t.join(`
|
|
4
4
|
|
package/dist/adapters/node.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as LogImporter, i as LogFileChangeEvent, n as LogOrchestratorConfig, t as BaseLogOrchestrator } from "../base-orchestrator-
|
|
1
|
+
import { g as LogImporter, i as LogFileChangeEvent, n as LogOrchestratorConfig, t as BaseLogOrchestrator } from "../base-orchestrator-BOAPgqF7.mjs";
|
|
2
2
|
|
|
3
3
|
//#region adapters/core/src/log-importer/jsonl-parser.d.ts
|
|
4
4
|
/**
|
package/dist/adapters/node.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"../cursor-storage-
|
|
1
|
+
import{r as e}from"../cursor-storage-BoNI7OAR.mjs";import*as t from"node:path";import{MakaioBus as n}from"@makaio/framework/bus";import{AdapterSubjects as r,SessionSubjects as i}from"@makaio/framework/contracts";import*as a from"node:fs/promises";import{AdapterSessionStorageSubjects as o}from"@makaio/framework/services/session";import s from"emittery";import c from"p-queue";import{globby as l}from"globby";const u=65536;async function d(e){let{filePath:t,startOffset:n=0}=e,r=[],i=[],o=n,s;try{s=await a.open(t,`r`);let e=await s.stat();if(n>=e.size)return{records:r,bytesRead:n,errors:i};let c=Buffer.alloc(u),l=``,d=n,f=0;for(n>0&&(f=await g(s,n));d<e.size;){let{bytesRead:e}=await s.read(c,0,u,d);if(e===0)break;l+=c.toString(`utf8`,0,e),d+=e;let t=l.split(`
|
|
2
2
|
`),n=t.pop();for(let e of t){if(f++,e.trim()===``){o+=Buffer.byteLength(e,`utf8`)+1;continue}let t=m(e,f);t.success?r.push(t.record):i.push(t.error),o+=Buffer.byteLength(e,`utf8`)+1}l=n??``}return{records:r,bytesRead:o,errors:i}}finally{s&&await s.close()}}async function f(e,t){let n=[],r;try{r=await a.open(e,`r`);let i=Buffer.alloc(u),o=``,s=0;for(;n.length<t;){let{bytesRead:e}=await r.read(i,0,u,s);if(e===0)break;o+=i.toString(`utf8`,0,e),s+=e;let a=o.split(`
|
|
3
3
|
`);o=a.pop()??``;for(let e of a){if(n.length>=t)break;let r=e.trim();if(r!==``)try{n.push(JSON.parse(r))}catch{}}}return n}finally{r&&await r.close()}}async function p(e,t){let n;try{n=await a.open(e,`r`);let r=Buffer.alloc(u),i=``,o=0;for(;;){let{bytesRead:e}=await n.read(r,0,u,o);if(e===0)break;i+=r.toString(`utf8`,0,e),o+=e;let a=i.split(`
|
|
4
4
|
`);i=a.pop()??``;for(let e of a){let n=e.trim();if(n!==``)try{if(t(JSON.parse(n)))return!0}catch{}}}return!1}finally{n&&await n.close()}}function m(e,t){try{return{success:!0,record:JSON.parse(e)}}catch(n){return{success:!1,error:{line:t,error:n instanceof Error?n.message:String(n),content:h(e)}}}}function h(e){return e.length<=200?e:e.slice(0,200)+`...`}async function g(e,t){let n=0,r=Buffer.alloc(u),i=0;for(;i<t;){let a=Math.min(u,t-i),{bytesRead:o}=await e.read(r,0,a,i);if(o===0)break;for(let e=0;e<o;e++)r[e]===10&&n++;i+=o}return n}var _=class{eventQueue;cursorQueue;onEventEmitted;constructor(e){this.onEventEmitted=e.onEventEmitted,this.eventQueue=new c({concurrency:1,interval:1e3,intervalCap:e.eventsPerSecond}),this.cursorQueue=new c({concurrency:1})}queueEvent(e){return this.eventQueue.add(async()=>{await n.emit(e.subject,e.payload),this.onEventEmitted()})}queueAfterEvents(e,t=[]){let n=Promise.all(t);return n.catch(()=>void 0),this.cursorQueue.add(async()=>{await n,await e()})}async drain(){await Promise.all([this.eventQueue.onIdle(),this.cursorQueue.onIdle()])}async onIdle(){await this.drain()}},v=class{options;emittery=new s;trackedFiles=new Map;pollTimer;isPolling=!1;isDisposed=!1;inFlightChecks=new Map;constructor(e){if(!t.isAbsolute(e.directory))throw Error(`Directory must be an absolute path: ${e.directory}`);this.options={directory:e.directory,pattern:e.pattern,pollIntervalMs:e.pollIntervalMs??1e4}}on(e,t){return this.emittery.on(e,t)}once(e,t){return this.emittery.once(e,t)}async start(){this.isDisposed||this.pollTimer===void 0&&(await this.poll(),this.pollTimer=setInterval(()=>{this.poll()},this.options.pollIntervalMs))}stop(){this.pollTimer!==void 0&&(clearInterval(this.pollTimer),this.pollTimer=void 0)}dispose(){this.isDisposed=!0,this.stop(),this.emittery.clearListeners(),this.trackedFiles.clear(),this.inFlightChecks.clear()}isRunning(){return this.pollTimer!==void 0}getTrackedFiles(){return this.trackedFiles}seedFromCursors(e){for(let t of e)this.trackedFiles.set(t.filePath,{size:t.bytesRead,mtimeMs:new Date(t.lastModified).getTime()})}async poll(){if(!this.isDisposed&&!this.isPolling){this.isPolling=!0;try{let e=await this.discoverFiles(),t=new Set(e);for(let e of this.trackedFiles.keys())if(!t.has(e)){if(this.isDisposed)return;this.trackedFiles.delete(e),await this.emittery.emit(`deleted`,{filePath:e})}for(let t of e)try{await this.runFileCheck(t)}catch(e){await this.emitWatcherError(e,t)}if(this.isDisposed)return;await this.emittery.emit(`polled`,{trackedFilePaths:new Set(this.trackedFiles.keys())})}catch(e){await this.emitWatcherError(e)}finally{this.isPolling=!1}}}async discoverFiles(){return l(this.options.pattern,{cwd:this.options.directory,absolute:!0,onlyFiles:!0})}async checkFile(e){if(this.isDisposed)return;let t=await a.stat(e);if(this.isDisposed)return;let n={size:t.size,mtimeMs:t.mtimeMs},r=this.trackedFiles.get(e);if(!r){if(this.trackedFiles.set(e,n),this.isDisposed){this.trackedFiles.delete(e);return}await this.emittery.emit(`change`,{filePath:e,stat:{size:t.size,mtime:t.mtime},changeType:`created`});return}if(n.mtimeMs!==r.mtimeMs){let i=n.size<r.size?`rotated`:`modified`;if(this.trackedFiles.set(e,n),this.isDisposed)return;await this.emittery.emit(`change`,{filePath:e,stat:{size:t.size,mtime:t.mtime},changeType:i})}}clearTrackedFile(e){return this.trackedFiles.delete(e)}clearAllTrackedFiles(){this.trackedFiles.clear()}triggerImmediatePoll(e){this.runFileCheck(e).catch(t=>{this.emitWatcherError(t,e)})}async runFileCheck(e){if(this.isDisposed)return;let t=this.inFlightChecks.get(e);if(t){await t;return}let n=(async()=>{try{await this.checkFile(e)}finally{this.inFlightChecks.delete(e)}})();this.inFlightChecks.set(e,n),await n}async emitWatcherError(e,t){let n=e instanceof Error?e:Error(String(e));try{await this.emittery.emit(`error`,{error:n,filePath:t})}catch(e){console.error(`[LogFileWatcher] Error listener failed:`,e instanceof Error?e.message:String(e))}}},y=class{watcher;constructor(e){this.watcher=new v(e)}isRunning(){return this.watcher.isRunning()}async start(){await this.watcher.start()}stop(){this.watcher.stop()}dispose(){this.watcher.dispose()}onChange(e){return this.watcher.on(`change`,e)}onError(e){return this.watcher.on(`error`,e)}onDeleted(e){return this.watcher.on(`deleted`,e)}onPolled(e){return this.watcher.on(`polled`,({trackedFilePaths:t})=>e(t))}getTrackedFileMtimeMs(e){return this.watcher.getTrackedFiles().get(e)?.mtimeMs}triggerImmediatePoll(e){this.watcher.triggerImmediatePoll(e)}seedFromCursors(e){this.watcher.seedFromCursors(e)}},b=class{filesProcessed=0;eventsEmitted=0;sessionsImported=new Set;sessionsSkipped=new Set;lastLoggedEventCount=0;lastLoggedSnapshot=``;reset(){this.filesProcessed=0,this.eventsEmitted=0,this.sessionsImported.clear(),this.sessionsSkipped.clear(),this.lastLoggedEventCount=0,this.lastLoggedSnapshot=``}recordFileProcessed(){this.filesProcessed++}recordEventEmitted(e){this.eventsEmitted++,!(this.eventsEmitted-this.lastLoggedEventCount<1e3)&&(console.info(`${e} Imported ${this.eventsEmitted} events (${this.sessionsImported.size} sessions)...`),this.lastLoggedEventCount=this.eventsEmitted)}recordSessionImported(e){this.sessionsImported.add(e)}recordSessionSkipped(e){this.sessionsSkipped.add(e)}hasActivity(){return this.eventsEmitted>0||this.filesProcessed>0}stoppedMessage(e){return`${e} Stopped - ${this.eventsEmitted} events from ${this.sessionsImported.size} sessions (${this.sessionsSkipped.size} skipped)`}logProgress(e){if(!this.hasActivity())return;let t=JSON.stringify({eventsEmitted:this.eventsEmitted,filesProcessed:this.filesProcessed,sessionsImported:this.sessionsImported.size,sessionsSkipped:this.sessionsSkipped.size});t!==this.lastLoggedSnapshot&&(this.lastLoggedSnapshot=t,console.info(`${e} Progress: ${this.eventsEmitted} events, ${this.sessionsImported.size} sessions, ${this.filesProcessed} files, ${this.sessionsSkipped.size} skipped`))}};function x(){return async e=>{try{let t=await n.request(i.getByAdapterSessionId,{adapterSessionId:e});return t.session!==null&&!t.session.isImported}catch{return!1}}}var S=class{checkedSessions=new Map;inFlight=new Map;async isSkipped(e,t,n){let r=this.checkedSessions.get(e);if(r!==void 0)return r;let i=this.inFlight.get(e);return i||(i=t(e).then(t=>(this.checkedSessions.set(e,t),t&&n(e),t)).finally(()=>{this.inFlight.delete(e)}),this.inFlight.set(e,i)),i}clear(){this.checkedSessions.clear(),this.inFlight.clear()}};function C(e,t,n,r){return!n||!e||r===`rotated`?!1:new Date(e)>=t}function w(e,t,n){for(let r of n??[]){let n=r.line===void 0?``:` at line ${r.line}`;console.warn(`${e} Parse error in ${t}${n}: ${r.error}`)}}async function T(t,r,i,a){let{cursor:o}=await n.request(e.get,{filePath:t});return o&&o.bytesRead>0&&!o.sessionContext&&!r?(await n.request(e.delete,{filePath:t}).catch(()=>{}),a(i),`retry`):o}async function E(e,t,n,r,i,a){let o=await a.parseFile(e,0);w(i,e,o.errors);let s=a.validateRecords(o.records);s.length>0&&await a.handleFirstRead(e,s,o.bytesRead??0,t,n,0,r)}function D(e,t,n,r,i){let a=[];n&&(a.push(i(t.sessionEvent)),a.push(i(t.startedEvent)));let o=r(e,t);for(let e of o)a.push(i(e));return a}function O(e,t){let n=[];for(let r of e)n.push(t(r));return n}function k(e){return typeof e==`object`&&!!e&&`compactionDetected`in e&&e.compactionDetected===!0}function A(e,t,n){return{...e,state:n(t)}}var j=class{tasks=new Set;track(e){this.tasks.add(e),e.finally(()=>{this.tasks.delete(e)})}async drain(){for(;this.tasks.size>0;)await Promise.allSettled([...this.tasks])}},M=class{config;watcher;eventQueue;importer;managedSessionCache=new S;unsubscribeChange;unsubscribeError;unsubscribeDeleted;stats=new b;watcherTasks=new j;progressTimer;constructor(e,t){this.importer=t;let n=e.directory??t.getLogDirectory();this.config={enabled:e.enabled,directory:e.directory,pollIntervalMs:e.pollIntervalMs??1e4,eventsPerSecond:e.eventsPerSecond??100,adapterId:e.adapterId,adapterName:e.adapterName,checkMakaioManaged:e.checkMakaioManaged},this.watcher=new y({directory:n,pattern:this.getLogFilePattern(),pollIntervalMs:this.config.pollIntervalMs}),this.eventQueue=new _({eventsPerSecond:this.config.eventsPerSecond,onEventEmitted:()=>{this.stats.recordEventEmitted(this.logPrefix)}})}shouldSkipFile(e){return!1}validateRecords(e){return e}getMaxRecords(){}buildCursorSessionContext(e){let{adapterSessionId:t,sessionEvent:n,startedEvent:r,state:i,...a}=e;return{...a,adapterSessionId:t,sessionEvent:n,startedEvent:r,state:this.importer.serializeState(i)}}usesJsonFormat(){let e=this.getLogFilePattern();return e.includes(`.json`)&&!e.includes(`.jsonl`)}isEnabled(){return this.config.enabled}isRunning(){return this.watcher.isRunning()}async start(){if(!this.config.enabled||this.isRunning())return;let t=this.config.directory??this.importer.getLogDirectory();console.info(`${this.logPrefix} Starting - watching ${t}`),this.stats.reset(),this.managedSessionCache.clear(),this.progressTimer=setInterval(()=>this.stats.logProgress(this.logPrefix),1e4),this.unsubscribeChange=this.watcher.onChange(e=>{this.trackFileChange(e)}),this.unsubscribeError=this.watcher.onError(({error:e,filePath:t})=>{console.warn(`${this.logPrefix} Error${t?` for ${t}`:``}: ${e.message}`)}),this.unsubscribeDeleted=this.watcher.onDeleted(({filePath:t})=>{this.watcherTasks.track(n.request(e.delete,{filePath:t}).then(()=>void 0).catch(()=>{}))}),await this.watcher.start()}async stop(){this.progressTimer&&=(clearInterval(this.progressTimer),void 0),this.unsubscribeChange?.(),this.unsubscribeError?.(),this.unsubscribeDeleted?.(),this.unsubscribeChange=void 0,this.unsubscribeError=void 0,this.unsubscribeDeleted=void 0,this.watcher.stop(),await this.watcherTasks.drain(),await this.eventQueue.drain(),this.stats.hasActivity()&&console.info(this.stats.stoppedMessage(this.logPrefix))}async dispose(){await this.stop(),this.watcher.dispose(),this.managedSessionCache.clear()}static createDefaultCheckMakaioManaged(){return x()}async updateCursor(t,r,i,a){await n.request(e.set,{filePath:t,bytesRead:r,lastModified:i.toISOString(),sessionContext:a})}async handleFileChange(t){let{filePath:r,changeType:i,stat:a}=t;if(this.shouldSkipFile(r))return;let o=this.usesJsonFormat();i===`rotated`&&await n.request(e.delete,{filePath:r}).catch(()=>{});let s=await T(r,o,t,e=>this.trackFileChange(e));if(s===`retry`)return;let c=s?.sessionContext!==void 0,l=c?s?.bytesRead??0:0;if(C(s?.lastModified,a.mtime,o,i))return;let u=await this.parseFile(r,o?0:l,this.getMaxRecords());w(this.logPrefix,r,u.errors),this.stats.recordFileProcessed();let d=this.validateRecords(u.records),f=u.bytesRead??0;if(d.length===0){await this.maybeUpdateCursor(r,f,l,a.mtime,o,s?.sessionContext);return}c&&s?.sessionContext?await this.handleIncrementalRead(r,d,s.sessionContext,f,a.mtime,o,l):await this.handleFirstRead(r,d,f,a.mtime,o,l)}trackFileChange(e){let t=this.handleFileChange(e).catch(e=>{console.error(`${this.logPrefix} Error handling file change:`,e instanceof Error?e.message:String(e))});this.watcherTasks.track(t)}async handleFirstRead(e,t,n,r,i,a,o=!0){let s=this.importer.extractSessionContext(t);if(await this.isSessionSkipped(s.adapterSessionId)){await this.maybeUpdateCursor(e,n,a,r,i,this.buildCursorSessionContext(s));return}let c=D(t,s,o,(e,t)=>this.importer.processRecords(e,t),e=>this.queueEvent(e));this.trackImportedSession(s.adapterSessionId),await this.queueCursorUpdate(e,n,a,r,i,this.buildCursorSessionContext(s),c)}trackImportedSession(e){this.stats.recordSessionImported(e)}async handleIncrementalRead(t,r,i,a,o,s,c){if(await this.isSessionSkipped(i.adapterSessionId)){await this.maybeUpdateCursor(t,a,c,o,s,i);return}let l;try{l=this.importer.deserializeState(i.state)}catch(r){console.warn(`${this.logPrefix} Corrupted cursor state for ${t}, deleting cursor and re-importing.`,r instanceof Error?r.message:String(r)),await n.request(e.delete,{filePath:t}).catch(e=>{console.warn(`${this.logPrefix} Failed to delete corrupted cursor for ${t}.`,e instanceof Error?e.message:String(e))}),await E(t,o,s,!0,this.logPrefix,{parseFile:(e,t)=>this.parseFile(e,t),validateRecords:e=>this.validateRecords(e),handleFirstRead:(e,t,n,r,i,a,o)=>this.handleFirstRead(e,t,n,r,i,a,o)});return}let u={adapterSessionId:i.adapterSessionId,model:i.model,cwd:i.cwd,sessionEvent:i.sessionEvent,startedEvent:i.startedEvent,state:l},d=this.importer.processRecords(r,u);if(k(u.state)){await E(t,o,s,!1,this.logPrefix,{parseFile:(e,t)=>this.parseFile(e,t),validateRecords:e=>this.validateRecords(e),handleFirstRead:(e,t,n,r,i,a,o)=>this.handleFirstRead(e,t,n,r,i,a,o)});return}let f=O(d,e=>this.queueEvent(e)),p=A(i,u.state,e=>this.importer.serializeState(e));await this.queueCursorUpdate(t,a,c,o,s,p,f)}async maybeUpdateCursor(e,t,n,r,i,a){(t>n||i)&&await this.updateCursor(e,t,r,a)}async isSessionSkipped(e){return this.managedSessionCache.isSkipped(e,e=>this.importer.isMakaioManaged(e),e=>this.stats.recordSessionSkipped(e))}queueEvent(e){return this.eventQueue.queueEvent(e)}queueCursorUpdate(e,t,n,r,i,a,o=[]){return this.eventQueue.queueAfterEvents(()=>this.maybeUpdateCursor(e,t,n,r,i,a),o)}},N=class extends M{trackingFilePaths=new Set;trackingInactiveCount=new Map;lastSeenMtimeMs=new Map;unsubscribePolled;constructor(e,t){super(e,t)}clearTrackingState(e){this.trackingFilePaths.delete(e),this.trackingInactiveCount.delete(e),this.lastSeenMtimeMs.delete(e)}async persistImportedStatus(e){let{session:t}=await n.request(o.getByLogFilePath,{logFilePath:e});return!t||t.status!==`tracking`||(await n.request(o.updateStatus,{adapterSessionId:t.adapterSessionId,status:`imported`})).success?!0:(console.warn(`${this.logPrefix} Failed to persist imported status for ${e}`),!1)}async start(){!this.isEnabled()||this.isRunning()||(await super.start(),this.unsubscribePolled=this.watcher.onPolled(e=>{this.onPollCycle(e).catch(e=>{console.error(`${this.logPrefix} Error handling poll cycle:`,e instanceof Error?e.message:String(e))})}),await this.restorePersistedTrackingState())}async stop(){this.unsubscribePolled?.(),this.unsubscribePolled=void 0,await super.stop()}async dispose(){this.trackingFilePaths.clear(),this.trackingInactiveCount.clear(),this.lastSeenMtimeMs.clear(),await super.dispose()}async handleFileChange(t){let{filePath:r,changeType:i,stat:a}=t;if(this.shouldSkipFile(r))return;let{cursor:o}=await n.request(e.get,{filePath:r});if(!o){await this.discoverNewFile(t);return}i===`modified`&&await this.handleModifiedImportedFile(r,t,a.mtime)}async restorePersistedTrackingState(){this.trackingFilePaths.clear(),this.trackingInactiveCount.clear(),this.lastSeenMtimeMs.clear();try{let{sessions:e}=await n.request(o.list,{});for(let t of e){if(t.status!==`tracking`||!t.logFilePath)continue;let e=this.watcher.getTrackedFileMtimeMs(t.logFilePath);e!==void 0&&(this.trackingFilePaths.add(t.logFilePath),this.trackingInactiveCount.set(t.logFilePath,0),this.lastSeenMtimeMs.set(t.logFilePath,e))}}catch(e){console.warn(`[DiscoveryOrchestrator] Failed to restore persisted tracking state:`,e instanceof Error?e.message:String(e))}}async discoverNewFile(e){let{filePath:t,stat:n}=e,i=await this.importer.extractDiscoveryMetadata(t);if(!(i.hasMessages??!1)){await this.updateCursor(t,0,n.mtime);return}if(await this.isSessionSkipped(i.adapterSessionId)){await this.updateCursor(t,0,n.mtime);return}let a=this.queueEvent({subject:r.session.discovered,payload:{adapterId:this.config.adapterId,adapterName:this.config.adapterName,adapterSessionId:i.adapterSessionId,model:i.model??null,cwd:i.cwd??null,title:i.title,parentAdapterSessionId:i.parentAdapterSessionId??null,forkPointMessageId:i.forkPointMessageId??null,kind:i.kind??`root`,startedAt:i.startedAt,logFilePath:t}});await this.eventQueue.queueAfterEvents(()=>this.updateCursor(t,0,n.mtime),[a])}async handleModifiedImportedFile(e,t,r){let{session:i}=await n.request(o.getByLogFilePath,{logFilePath:e});if(!i){await this.discoverNewFile(t);return}if(!(i.status!==`imported`&&i.status!==`tracking`)){if(await super.handleFileChange(t),i.status===`imported`&&!(await n.request(o.updateStatus,{adapterSessionId:i.adapterSessionId,status:`tracking`})).success){console.warn(`${this.logPrefix} Failed to persist tracking status for ${e}`);return}this.trackingFilePaths.add(e),this.lastSeenMtimeMs.set(e,r.getTime()),this.trackingInactiveCount.delete(e),this.watcher.triggerImmediatePoll(e)}}async onPollCycle(e){for(let t of[...this.trackingFilePaths]){if(!e.has(t)){await this.persistImportedStatus(t)&&this.clearTrackingState(t);continue}let n=this.watcher.getTrackedFileMtimeMs(t),r=this.lastSeenMtimeMs.get(t);if(!(n===void 0||r===void 0))try{if(n===r){let e=(this.trackingInactiveCount.get(t)??0)+1;e>=3?await this.persistImportedStatus(t)&&this.clearTrackingState(t):this.trackingInactiveCount.set(t,e)}else this.lastSeenMtimeMs.set(t,n),this.trackingInactiveCount.delete(t)}catch(e){console.warn(`${this.logPrefix} Failed to process tracked file ${t}:`,e instanceof Error?e.message:String(e))}}}};export{M as BaseLogOrchestrator,N as DiscoveryOrchestrator,d as parseJsonlFile,f as readFirstJsonlRecords,p as someJsonlRecord};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./schemas-COnLJnt_.mjs";import{_ as t,a as n,g as r,h as i,m as a,n as ee,o as te}from"./profile-Cq4A7kQa.mjs";import{n as ne,t as o}from"./version-D8S4O22A.mjs";import{c as re,d as ie,n as ae,o as oe,s as se,t as s,u as c}from"./account-identity-Bg_vKkcs.mjs";import{z as l}from"zod";import{createBusNamespace as ce}from"@makaio/framework/core";const u=l.object({tag:l.string(),description:l.string().optional()}),d=l.object({name:l.string(),friendlyName:l.string(),description:l.string().optional(),category:l.string().optional(),capabilities:l.array(u).default([])}),f=l.object({id:l.string(),name:l.string(),description:l.string().optional(),glob:l.string().optional()}),p=l.object({name:l.string().min(1),frameworkSubject:l.string().min(1).optional()}),m=l.object({envVar:r.regex(/^[A-Za-z_][A-Za-z0-9_]*$/,{message:`envVar must be a valid environment variable name (letters, digits, underscores)`}),defaultPath:r.refine(e=>e===`~`||e.startsWith(`~/`)||t(e),{message:`defaultPath must be absolute, '~', or start with '~/'`}),pathKind:l.enum([`directory`,`file`]).default(`directory`)});function le(e){if(!e.startsWith(`@`))return!e.includes(`@`);let t=e.indexOf(`/`);return t>1&&!e.slice(t+1).includes(`@`)}const h=l.object({type:l.literal(`npm`),package:l.string().min(1).refine(le,{message:"package must not include an inline `@version` suffix; use the version field instead"}),version:o}),g=l.object({type:l.literal(`signed-binary-bucket`),version:o,config:l.object({baseUrl:l.string().url(),manifestPathTemplate:l.string().min(1),manifestSignaturePathTemplate:l.string().min(1),publicKeyUrl:l.string().url(),publicKeyFingerprint:l.string().min(1),binaryPathTemplate:l.string().min(1),platforms:l.record(l.string().min(1),l.string().min(1))})}),_=l.discriminatedUnion(`type`,[h,g]),v=l.object({executable:l.union([l.string().min(1),l.object({default:l.string().min(1),darwin:l.string().min(1).optional(),linux:l.string().min(1).optional(),win32:l.string().min(1).optional()}).strict()]),args:l.array(l.string()).default([])}).strict(),y=l.object({kind:l.string().min(1),payload:l.record(l.string(),l.unknown()).optional()}),b=l.object({supportsHooks:l.boolean().default(!1),supportsStatusline:l.boolean().default(!1),supportsSupervisorLaunch:l.boolean().default(!1),supportsManagedBinary:l.boolean().default(!1),hookEvents:l.array(p).default([])}).refine(e=>e.supportsHooks||e.hookEvents.length===0,{message:`hookEvents must be empty when supportsHooks is false`,path:[`hookEvents`]}),x=l.object({name:l.string().min(1),supportedVersions:ne}).strict(),S=l.object({id:l.string(),name:l.string(),version:o,description:l.string().optional(),binary:x.optional(),nativeTools:l.array(d).default([]),defaultApprovalPolicy:e,logSources:l.array(f).optional(),defaultProviderId:l.string().optional(),runtimeCapabilities:b.optional().transform(e=>b.parse(e??{})),managedInstall:_.optional(),versionCommand:v.optional(),postInstall:y.optional(),configIsolation:m.optional()}).strict().refine(e=>!e.runtimeCapabilities.supportsManagedBinary||e.managedInstall!==void 0,{message:`managedInstall is required when runtimeCapabilities.supportsManagedBinary is true`,path:[`managedInstall`]}).refine(e=>e.managedInstall===void 0||e.runtimeCapabilities.supportsManagedBinary,{message:`runtimeCapabilities.supportsManagedBinary must be true when managedInstall is provided`,path:[`runtimeCapabilities`,`supportsManagedBinary`]}).refine(e=>e.managedInstall===void 0||e.versionCommand!==void 0,{message:`versionCommand is required when managedInstall is provided`,path:[`versionCommand`]}).superRefine((e,t)=>{if(e.managedInstall===void 0||e.versionCommand===void 0)return;let{executable:n}=e.versionCommand,r=typeof n==`string`?[{path:n,issuePath:[`versionCommand`,`executable`]}]:[{path:n.default,issuePath:[`versionCommand`,`executable`,`default`]},...n.darwin===void 0?[]:[{path:n.darwin,issuePath:[`versionCommand`,`executable`,`darwin`]}],...n.linux===void 0?[]:[{path:n.linux,issuePath:[`versionCommand`,`executable`,`linux`]}],...n.win32===void 0?[]:[{path:n.win32,issuePath:[`versionCommand`,`executable`,`win32`]}]];for(let{path:e,issuePath:n}of r){let r=e.startsWith(`/`),i=/^[A-Za-z]:/.test(e),a=e.startsWith(`\\`);if(r||i||a){t.addIssue({code:l.ZodIssueCode.custom,path:n,message:`${n.join(`.`)} must be a relative path within the install directory`});continue}e.split(/[/\\]/).some(e=>e===`..`)&&t.addIssue({code:l.ZodIssueCode.custom,path:n,message:`${n.join(`.`)} must be a relative path within the install directory`})}}),C=l.object({binaryPath:a.nullable(),env:l.record(l.string(),l.string()),configDir:a.nullable(),source:l.enum([`managed`,`global`]),version:r.nullable()}),w={request:l.object({clientId:r,sessionId:r.optional(),projectDir:a.optional(),preferSource:l.enum([`managed`,`global`]).optional(),harnessId:r.optional()}),response:C},T=l.enum([`npm`,`signed-binary-bucket`]),E=l.object({version:r,installPath:a,installedAt:i,isActive:l.boolean()}),D=l.object({clientId:r,installedVersions:l.array(E),activeVersion:r.nullable(),pinnedVersion:o,updateAvailable:l.boolean()}).strict(),O={request:l.object({forceRefresh:l.boolean().optional()}),response:l.object({clients:l.array(D)})},k={request:l.object({clientId:r,version:o.optional()}),response:l.object({jobId:r,requestedVersion:o.nullable(),resolvedVersion:o.nullable()})},A={request:l.object({clientId:r,version:r}),response:l.object({clientId:r,removedVersion:r,activeVersion:r.nullable()})},j={request:l.object({clientId:r}),response:l.object({jobId:r,resolvedVersion:o.nullable()})},M={request:l.object({clientId:r,version:r}),response:l.object({clientId:r,activeVersion:r})},N=l.enum([`resolving`,`downloading`,`verifying`,`extracting`,`installing`,`post-install`,`activating`]),P=l.object({jobId:r,clientId:r,version:r.optional(),strategy:T,stage:N,progress:l.number().min(0).max(100).nullable(),installPath:a.optional(),activeAfterCompletion:l.boolean().optional(),metadata:l.record(l.string(),l.unknown()).optional()}),F=l.object({message:l.string(),code:l.string().optional()}),I=l.object({jobId:r,clientId:r,version:r.optional(),strategy:T,status:l.enum([`success`,`error`]),installPath:a.optional(),activeVersion:r.nullable(),error:F.optional(),metadata:l.record(l.string(),l.unknown()).optional()}),L=l.object({clientId:r,previousActiveVersion:r.nullable(),activeVersion:r.nullable(),reason:l.enum([`install`,`update`,`set-active`,`uninstall`])}),R=l.enum([`supervisor`,`adapter`,`client-hook`,`statusline`,`cli-wrapper`]),z=l.object({layer:R,producer:r}),B=l.object({supervisorSessionId:r.optional(),pid:l.number().int().positive().optional(),parentPid:l.number().int().positive().optional(),adapterSessionId:r.optional(),sessionId:r.optional(),cwd:l.string().optional(),argv:l.array(l.string()).optional(),metadata:l.record(l.string(),l.unknown()).optional()}),V={request:l.object({clientId:r,source:z,observedAt:i}).merge(B).refine(e=>e.supervisorSessionId!==void 0||e.pid!==void 0||e.adapterSessionId!==void 0,{message:`At least one hard-evidence field is required (supervisorSessionId, pid, or adapterSessionId)`}),response:l.object({clientRuntimeId:r,created:l.boolean(),promoted:l.boolean()})},H=B.extend({clientRuntimeId:r,clientId:r,status:l.enum([`observed`,`started`]),source:z,observedAt:i}),U=l.object({clientId:r,source:r,observedAt:i,sessionId:l.string().optional(),adapterSessionId:l.string().optional(),metadata:l.record(l.string(),l.unknown()).optional()}),W=U.extend({}),G=U.extend({prompt:r.optional()}),K=U.extend({}),q=U.extend({}),J=U.extend({toolName:r.optional(),toolCallId:r.optional()}),Y=U.extend({toolName:r.optional(),toolCallId:r.optional(),success:l.boolean().optional()}),X=l.object({group:r,name:r,installed:l.boolean(),command:r}),Z={"runtime.observe":V,"runtime.started":H,scan:{request:l.object({targets:l.array(se).optional()}),response:l.object({results:l.array(oe)})},"session.account.observe":re,"account.observe":ae,"account.activate":{request:l.object({clientId:r,clientAccountId:r,identifiers:l.array(s).min(1),displayLabel:l.string().optional()}),response:l.object({accepted:l.boolean()})},"account.getActive":{request:l.object({clientId:r}),response:l.object({identity:l.object({clientAccountId:r,identifiers:l.array(s).min(1),displayLabel:l.string().optional()}).nullable()})},"usage.ingest":c,"usage.snapshot":ie,"session.started":W,"session.userPrompt.submitted":G,"session.turn.started":K,"session.turn.completed":q,"session.tool.pre":J,"session.tool.post":Y,"wiring.list":{request:l.object({clientId:r.optional(),projectDir:a.optional(),makaioCommand:r}),response:l.object({results:l.array(l.object({clientId:r,entries:l.array(X)}))})},list:O,install:k,uninstall:A,update:j,setActive:M,"installJob.progress":P,"installJob.completed":I,"version.changed":L,resolveBinary:w,...n,...te,"config.prime":ee},Q=ce(`client`,Z),ue=Q.subjects;function $(e){if(Array.isArray(e)){for(let t of e)$(t);return Object.freeze(e)}if(e&&typeof e==`object`){for(let t of Object.values(e))$(t);return Object.freeze(e)}return e}function de(e){return $(S.parse(e))}export{T as A,f as B,M as C,F as D,L as E,p as F,v as G,h as H,b as I,u as L,w as M,x as N,N as O,S as P,d as R,O as S,j as T,y as U,_ as V,g as W,H as _,U as a,P as b,J as c,G as d,X as f,z as g,R as h,Z as i,C as j,E as k,q as l,V as m,Q as n,W as o,B as p,ue as r,Y as s,de as t,K as u,D as v,A as w,k as x,I as y,m as z};
|