@makaio/framework 1.0.0-dev-1781260968078 → 1.0.0-dev-1781354548379
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.makaio-build.json +2 -2
- package/dist/adapter-UpcpZDOv.mjs +1 -0
- package/dist/adapters/config/index.d.mts +1 -1
- package/dist/adapters/index.d.mts +11 -3
- package/dist/adapters/index.mjs +1 -1
- package/dist/bus/index.mjs +1 -1
- package/dist/clients/index.d.mts +4 -7
- package/dist/clients/index.mjs +1 -1
- 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/artifact/index.d.mts +1 -1
- package/dist/contracts/client/index.d.mts +1 -1
- package/dist/contracts/extension/index.d.mts +2 -2
- package/dist/contracts/facet/index.d.mts +1 -1
- package/dist/contracts/index.d.mts +219 -54
- package/dist/contracts/index.mjs +1 -1
- package/dist/contracts/materialization/index.d.mts +3 -3
- package/dist/contracts/session/index.d.mts +3 -3
- package/dist/contracts/session/index.mjs +1 -1
- package/dist/{definition-SiimP25_.d.mts → definition-DqJOg6Lv.d.mts} +1 -1
- package/dist/drizzle/0015_m_mqbh8q5b.sql +1 -0
- package/dist/drizzle/0016_m_mqbmq8h7.sql +1 -0
- package/dist/drizzle/0017_m_mqbnf924.sql +1 -0
- package/dist/drizzle/meta/0015_snapshot.json +2966 -0
- package/dist/drizzle/meta/0016_snapshot.json +2973 -0
- package/dist/drizzle/meta/0017_snapshot.json +2980 -0
- package/dist/drizzle/meta/_journal.json +21 -0
- package/dist/{handler-DSfSAlxx.mjs → handler-DqpiV9eA.mjs} +1 -1
- package/dist/handlers-BAB4fQNH.mjs +41 -0
- package/dist/{index-B2xbnMZe.d.mts → index-BCKRUuI2.d.mts} +1 -1
- package/dist/{index-CARxIllg.d.mts → index-BHAOu6Hs.d.mts} +20 -20
- package/dist/{index-Cb64d5c5.d.mts → index-BHzgDuRE.d.mts} +20 -3
- package/dist/{index-BtztOqaF.d.mts → index-BheaEhyI.d.mts} +6 -6
- package/dist/{index-CZ_TcT6J.d.mts → index-Bibt5jAX.d.mts} +8 -8
- package/dist/{index-D5CI1V5d.d.mts → index-C3zfJg6s.d.mts} +16 -16
- package/dist/{index-DTdqGAfH2.d.mts → index-CH5U3zSA2.d.mts} +1 -1
- package/dist/{index-CgjslA5-.d.mts → index-CTn_Xi-p.d.mts} +4 -4
- package/dist/{index-DDQkhhRo.d.mts → index-DPIdX6kb.d.mts} +363 -123
- package/dist/{index-BQiHs8EF.d.mts → index-Da4ABgRq.d.mts} +12 -12
- package/dist/{index-BvSyOgTY.d.mts → index-DrGLAuZc.d.mts} +98 -29
- package/dist/{index-BKKNWqkP2.d.mts → index-zgm2j9V92.d.mts} +44 -2
- package/dist/kernel/extension/index.d.mts +1 -1
- package/dist/kernel/index.d.mts +2 -2
- package/dist/kernel/observability/index.d.mts +1 -1
- package/dist/mcp-http-server/index.d.mts +132 -19
- package/dist/mcp-http-server/index.mjs +1 -1
- package/dist/{namespace-D1Iw_d1P.d.mts → namespace--s0d86h-.d.mts} +144 -0
- package/dist/{namespace-7tsuJhQ9.d.mts → namespace-Boe6l5n9.d.mts} +78 -42
- package/dist/{namespace-Ba4bxtHQ.d.mts → namespace-BxxBhcV_.d.mts} +9 -9
- package/dist/{namespace-DwE2g8Wm.mjs → namespace-Dfq6MDN9.mjs} +1 -1
- package/dist/{namespace-DDCjoQUj.d.mts → namespace-aJJfBJU5.d.mts} +170 -0
- package/dist/{orchestrator-shared-Dt4WDse7.mjs → orchestrator-shared-BKFXaKPL.mjs} +1 -1
- package/dist/{package-BSnp1zOR.d.mts → package--RZnpN2J.d.mts} +2 -3
- package/dist/package-BzJvtM5O.mjs +1 -0
- package/dist/package-DzN_jdqd.mjs +1 -0
- package/dist/package.json +1 -1
- package/dist/primitive-runtime-CNC_bSac.mjs +1 -0
- package/dist/runtime-node/bus/runtime/namespace.d.mts +8 -8
- package/dist/runtime-node/bus/runtime/schemas.d.mts +11 -4
- package/dist/runtime-node/bus/runtime/schemas.mjs +1 -1
- package/dist/runtime-node/index.d.mts +19 -1
- package/dist/runtime-node/index.mjs +1 -1
- package/dist/{schema-BerZmr2q.mjs → schema-C3TgjrsV.mjs} +1 -1
- package/dist/{schema-BrnYlDwZ.mjs → schema-CzhOc7TV.mjs} +1 -1
- package/dist/{schema-BNrM9LWb.d.mts → schema-DGMLvVoQ.d.mts} +23 -3
- package/dist/schemas-CuKayWhA.mjs +1 -0
- package/dist/{schemas-DAFYpgHk2.d.mts → schemas-kVcJMjjn2.d.mts} +8 -8
- package/dist/{schemas-CkOSG2eJ.d.mts → schemas-t1VR6_b_.d.mts} +3 -3
- package/dist/services/filesystem/namespace.d.mts +6 -6
- package/dist/services/filesystem/schemas.d.mts +3 -3
- package/dist/services/git/namespace.d.mts +2 -2
- package/dist/services/git/schemas.d.mts +2 -2
- package/dist/services/harness/index.d.mts +3 -4
- package/dist/services/harness/index.mjs +1 -1
- package/dist/services/index.d.mts +112 -15
- package/dist/services/index.mjs +1 -1
- package/dist/services/log-import/browser.d.mts +2 -2
- package/dist/services/log-import/index.d.mts +4 -5
- package/dist/services/log-import/index.mjs +1 -1
- package/dist/services/log-import/log-import.d.mts +1 -1
- package/dist/services/log-import/namespace.d.mts +2 -2
- package/dist/services/log-import/schemas.d.mts +1 -1
- package/dist/services/provider-context/index.mjs +1 -1
- package/dist/services/session/handlers/index.mjs +1 -1
- package/dist/services/session/index.d.mts +6 -6
- package/dist/services/session/index.mjs +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/storage/schema.mjs +1 -1
- package/dist/services/session/testing/index.mjs +5 -3
- 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/settings/index.mjs +1 -1
- package/dist/services/settings/namespace.d.mts +8 -8
- package/dist/services/settings/storage/clients-namespace.mjs +1 -1
- package/dist/services/settings/storage/index.mjs +1 -1
- package/dist/services/settings/storage/providers-namespace.mjs +1 -1
- package/dist/services/subagent/index.d.mts +1 -1
- package/dist/services/subagent/index.mjs +1 -1
- package/dist/services/subagent-template/index.d.mts +1 -1
- package/dist/services/subagent-template/schemas.d.mts +1 -1
- package/dist/services/tool-approval/index.mjs +1 -1
- package/dist/services/tools/index.mjs +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 +72 -0
- package/dist/services/turn/schemas.mjs +1 -1
- package/dist/{session-C1Cami7U.mjs → session-BwX5_k47.mjs} +1 -1
- package/dist/session-P4nX60Xx.mjs +39 -0
- package/dist/{session-lineage-CXzV_hAP.d.mts → session-lineage-CKg6mErA.d.mts} +1 -1
- package/dist/storage/drizzle/index.d.mts +1 -1
- package/dist/storage/drizzle/index.mjs +1 -1
- package/dist/{tool-approval-service-Cb2F1yT6.mjs → tool-approval-service-DNHV5x0M.mjs} +1 -1
- package/dist/{tools-D5DVHC-R.mjs → tools-CQImrHAp.mjs} +1 -1
- package/dist/{types-DLVitCZP.d.mts → types-BpuLMR2m.d.mts} +626 -443
- package/dist/{types-D5IMwOkJ.d.mts → types-D0fPFh-D.d.mts} +1 -1
- package/dist/{types-BMpIa4fx.d.mts → types-D6jnDjP2.d.mts} +18 -5
- package/dist/ui-components/index.d.mts +36 -37
- package/dist/ui-views/index.d.mts +2 -2
- package/dist/workflow-engine/index.d.mts +58 -25
- package/dist/workflow-engine/index.mjs +1 -1
- package/dist/workflow-engine/package.d.mts +1 -1
- package/dist/workflow-engine/package.mjs +1 -1
- package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
- package/package.json +10 -1
- package/dist/adapter-Dt2FDMs4.mjs +0 -1
- package/dist/handlers-C8EtpSqK.mjs +0 -41
- package/dist/package-Be2Ez4vv.mjs +0 -1
- package/dist/package-OE9dMQsq.mjs +0 -1
- package/dist/primitive-runtime-Xrc9xh6p.mjs +0 -1
- package/dist/schemas-CSUwpaNm.mjs +0 -1
- package/dist/session-KnewDVxt.mjs +0 -39
- /package/dist/{provider-context-lfG0BpqX.mjs → provider-context-wp4VSJFI.mjs} +0 -0
- /package/dist/{shared-schemas-CKe2uN4-.mjs → shared-schemas-DYL7a-No.mjs} +0 -0
|
@@ -524,10 +524,10 @@ declare const SessionEventStorageNamespace$1: {
|
|
|
524
524
|
childSessionId: _$zod.ZodString;
|
|
525
525
|
parentSessionId: _$zod.ZodString;
|
|
526
526
|
kind: _$zod.ZodEnum<{
|
|
527
|
-
branch: "branch";
|
|
528
527
|
fork: "fork";
|
|
529
528
|
subagent: "subagent";
|
|
530
529
|
compress: "compress";
|
|
530
|
+
branch: "branch";
|
|
531
531
|
rewrite: "rewrite";
|
|
532
532
|
coordinator: "coordinator";
|
|
533
533
|
aside: "aside";
|
|
@@ -842,10 +842,10 @@ declare const SessionEventStorageNamespace$1: {
|
|
|
842
842
|
childSessionId: _$zod.ZodString;
|
|
843
843
|
parentSessionId: _$zod.ZodString;
|
|
844
844
|
kind: _$zod.ZodEnum<{
|
|
845
|
-
branch: "branch";
|
|
846
845
|
fork: "fork";
|
|
847
846
|
subagent: "subagent";
|
|
848
847
|
compress: "compress";
|
|
848
|
+
branch: "branch";
|
|
849
849
|
rewrite: "rewrite";
|
|
850
850
|
coordinator: "coordinator";
|
|
851
851
|
aside: "aside";
|
|
@@ -1150,10 +1150,10 @@ declare const SessionEventStorageNamespace$1: {
|
|
|
1150
1150
|
childSessionId: _$zod.ZodString;
|
|
1151
1151
|
parentSessionId: _$zod.ZodString;
|
|
1152
1152
|
kind: _$zod.ZodEnum<{
|
|
1153
|
-
branch: "branch";
|
|
1154
1153
|
fork: "fork";
|
|
1155
1154
|
subagent: "subagent";
|
|
1156
1155
|
compress: "compress";
|
|
1156
|
+
branch: "branch";
|
|
1157
1157
|
rewrite: "rewrite";
|
|
1158
1158
|
coordinator: "coordinator";
|
|
1159
1159
|
aside: "aside";
|
|
@@ -1466,10 +1466,10 @@ declare const SessionEventStorageNamespace$1: {
|
|
|
1466
1466
|
childSessionId: _$zod.ZodString;
|
|
1467
1467
|
parentSessionId: _$zod.ZodString;
|
|
1468
1468
|
kind: _$zod.ZodEnum<{
|
|
1469
|
-
branch: "branch";
|
|
1470
1469
|
fork: "fork";
|
|
1471
1470
|
subagent: "subagent";
|
|
1472
1471
|
compress: "compress";
|
|
1472
|
+
branch: "branch";
|
|
1473
1473
|
rewrite: "rewrite";
|
|
1474
1474
|
coordinator: "coordinator";
|
|
1475
1475
|
aside: "aside";
|
|
@@ -1770,10 +1770,10 @@ declare const SessionEventStorageNamespace$1: {
|
|
|
1770
1770
|
childSessionId: _$zod.ZodString;
|
|
1771
1771
|
parentSessionId: _$zod.ZodString;
|
|
1772
1772
|
kind: _$zod.ZodEnum<{
|
|
1773
|
-
branch: "branch";
|
|
1774
1773
|
fork: "fork";
|
|
1775
1774
|
subagent: "subagent";
|
|
1776
1775
|
compress: "compress";
|
|
1776
|
+
branch: "branch";
|
|
1777
1777
|
rewrite: "rewrite";
|
|
1778
1778
|
coordinator: "coordinator";
|
|
1779
1779
|
aside: "aside";
|
|
@@ -2088,10 +2088,10 @@ declare const SessionEventStorageNamespace$1: {
|
|
|
2088
2088
|
childSessionId: _$zod.ZodString;
|
|
2089
2089
|
parentSessionId: _$zod.ZodString;
|
|
2090
2090
|
kind: _$zod.ZodEnum<{
|
|
2091
|
-
branch: "branch";
|
|
2092
2091
|
fork: "fork";
|
|
2093
2092
|
subagent: "subagent";
|
|
2094
2093
|
compress: "compress";
|
|
2094
|
+
branch: "branch";
|
|
2095
2095
|
rewrite: "rewrite";
|
|
2096
2096
|
coordinator: "coordinator";
|
|
2097
2097
|
aside: "aside";
|
|
@@ -2396,10 +2396,10 @@ declare const SessionEventStorageNamespace$1: {
|
|
|
2396
2396
|
childSessionId: _$zod.ZodString;
|
|
2397
2397
|
parentSessionId: _$zod.ZodString;
|
|
2398
2398
|
kind: _$zod.ZodEnum<{
|
|
2399
|
-
branch: "branch";
|
|
2400
2399
|
fork: "fork";
|
|
2401
2400
|
subagent: "subagent";
|
|
2402
2401
|
compress: "compress";
|
|
2402
|
+
branch: "branch";
|
|
2403
2403
|
rewrite: "rewrite";
|
|
2404
2404
|
coordinator: "coordinator";
|
|
2405
2405
|
aside: "aside";
|
|
@@ -2712,10 +2712,10 @@ declare const SessionEventStorageNamespace$1: {
|
|
|
2712
2712
|
childSessionId: _$zod.ZodString;
|
|
2713
2713
|
parentSessionId: _$zod.ZodString;
|
|
2714
2714
|
kind: _$zod.ZodEnum<{
|
|
2715
|
-
branch: "branch";
|
|
2716
2715
|
fork: "fork";
|
|
2717
2716
|
subagent: "subagent";
|
|
2718
2717
|
compress: "compress";
|
|
2718
|
+
branch: "branch";
|
|
2719
2719
|
rewrite: "rewrite";
|
|
2720
2720
|
coordinator: "coordinator";
|
|
2721
2721
|
aside: "aside";
|
|
@@ -2978,7 +2978,7 @@ declare const SessionEventStorageNamespace$1: {
|
|
|
2978
2978
|
payload: {
|
|
2979
2979
|
childSessionId: string;
|
|
2980
2980
|
parentSessionId: string;
|
|
2981
|
-
kind: "
|
|
2981
|
+
kind: "fork" | "subagent" | "compress" | "branch" | "rewrite" | "coordinator" | "aside";
|
|
2982
2982
|
forkPointMessageId?: string | undefined;
|
|
2983
2983
|
};
|
|
2984
2984
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sessionsDual as e}from"./services/session/storage/schema.mjs";import{n as t}from"./schema-
|
|
1
|
+
import{sessionsDual as e}from"./services/session/storage/schema.mjs";import{n as t}from"./schema-CzhOc7TV.mjs";import{t as n}from"./schema-C3TgjrsV.mjs";import{SessionEventStorageNamespace as r,SessionEventStorageSubjects as i}from"@makaio/framework/contracts";import{index as a}from"drizzle-orm/sqlite-core";import{customType as o,index as s,pgTable as c,text as l}from"drizzle-orm/pg-core";import{defineDialectSchema as u,defineDualTable as d}from"@makaio/framework/storage/drizzle";import{sql as f}from"drizzle-orm";import{epochMs as p}from"@makaio/framework/storage/drizzle/columns/postgres";const m=o({dataType(){return`tsvector`}}),h=c(`messages`,{messageId:l(`message_id`).primaryKey(),turnId:l(`turn_id`).references(()=>t.postgres.turnId,{onDelete:`cascade`}),sessionId:l(`session_id`).notNull().references(()=>e.postgres.sessionId,{onDelete:`cascade`}),role:l(`role`,{enum:[`user`,`assistant`]}).notNull(),contentText:l(`content_text`).notNull(),blocks:l(`blocks`).notNull().default(`[]`),agentId:l(`agent_id`),adapterSessionId:l(`adapter_session_id`),adapterMessageId:l(`adapter_message_id`),timestamp:p(`timestamp`).notNull(),editOf:l(`edit_of`).references(()=>h.messageId),origin:l(`origin`,{enum:[`voice`,`text`,`compact`]}),contentTsv:m(`content_tsv`).generatedAlwaysAs(f`to_tsvector('english', coalesce(content_text, ''))`)},e=>[s(`idx_messages_session`).on(e.sessionId,e.timestamp),s(`idx_messages_turn`).on(e.turnId,e.timestamp),s(`idx_messages_agent`).on(e.agentId,e.timestamp),s(`idx_messages_adapter_message_id`).on(e.adapterMessageId),s(`idx_messages_content_tsv`).using(`gin`,e.contentTsv)]),g=u({messages:n},{messages:h}),_=()=>({sqlite:n.messageId,postgres:h.messageId}),v=d(`session_events`,t=>({id:t.autoPk(`id`),sessionId:t.text(`session_id`).notNull().references(()=>e.columnPair(`sessionId`),{onDelete:`cascade`}),eventId:t.text(`event_id`).notNull().unique(),timestamp:t.epochMs(`timestamp`).notNull(),type:t.text(`type`).notNull(),agentId:t.text(`agent_id`),adapterId:t.text(`adapter_id`),originatingMessageId:t.text(`originating_message_id`),messageId:t.text(`message_id`).references(_,{onDelete:`cascade`}),turnId:t.text(`turn_id`),contentText:t.text(`content_text`),payload:t.text(`payload`).notNull()}),{sqlite:e=>[a(`idx_events_session_ts`).on(e.sessionId,e.timestamp),a(`idx_events_session_type`).on(e.sessionId,e.type),a(`idx_events_turn`).on(e.turnId),a(`idx_events_originating_message`).on(e.originatingMessageId)],postgres:e=>[s(`idx_events_session_ts`).on(e.sessionId,e.timestamp),s(`idx_events_session_type`).on(e.sessionId,e.type),s(`idx_events_turn`).on(e.turnId),s(`idx_events_originating_message`).on(e.originatingMessageId)]}),y=v.sqlite,b={...r,extensions:{drizzle:{sessionEvents:y}}};export{_ as a,v as i,i as n,g as o,y as r,b as t};
|
|
@@ -164,6 +164,25 @@ declare const TurnStorageNamespace: {
|
|
|
164
164
|
}, {}, {
|
|
165
165
|
length: number | undefined;
|
|
166
166
|
}>;
|
|
167
|
+
initiator: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
|
|
168
|
+
name: "initiator";
|
|
169
|
+
tableName: "turns";
|
|
170
|
+
dataType: "string";
|
|
171
|
+
columnType: "SQLiteText";
|
|
172
|
+
data: string;
|
|
173
|
+
driverParam: string;
|
|
174
|
+
notNull: false;
|
|
175
|
+
hasDefault: false;
|
|
176
|
+
isPrimaryKey: false;
|
|
177
|
+
isAutoincrement: false;
|
|
178
|
+
hasRuntimeDefault: false;
|
|
179
|
+
enumValues: [string, ...string[]];
|
|
180
|
+
baseColumn: never;
|
|
181
|
+
identity: undefined;
|
|
182
|
+
generated: undefined;
|
|
183
|
+
}, {}, {
|
|
184
|
+
length: number | undefined;
|
|
185
|
+
}>;
|
|
167
186
|
};
|
|
168
187
|
dialect: "sqlite";
|
|
169
188
|
}>;
|
|
@@ -176,6 +195,14 @@ declare const TurnStorageNamespace: {
|
|
|
176
195
|
request: _$zod.ZodObject<{
|
|
177
196
|
sessionId: _$zod.ZodString;
|
|
178
197
|
turnId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
198
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
199
|
+
source: _$zod.ZodEnum<{
|
|
200
|
+
user: "user";
|
|
201
|
+
system: "system";
|
|
202
|
+
extension: "extension";
|
|
203
|
+
}>;
|
|
204
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
205
|
+
}, _$zod_v4_core0.$strip>>;
|
|
179
206
|
}, _$zod_v4_core0.$strip>;
|
|
180
207
|
response: _$zod.ZodObject<{
|
|
181
208
|
turn: _$zod.ZodObject<{
|
|
@@ -202,6 +229,14 @@ declare const TurnStorageNamespace: {
|
|
|
202
229
|
cost: _$zod.ZodOptional<_$zod.ZodNumber>;
|
|
203
230
|
}, _$zod_v4_core0.$strip>>>;
|
|
204
231
|
}, _$zod_v4_core0.$strip>>;
|
|
232
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
233
|
+
source: _$zod.ZodEnum<{
|
|
234
|
+
user: "user";
|
|
235
|
+
system: "system";
|
|
236
|
+
extension: "extension";
|
|
237
|
+
}>;
|
|
238
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
239
|
+
}, _$zod_v4_core0.$strip>>;
|
|
205
240
|
}, _$zod_v4_core0.$strip>;
|
|
206
241
|
}, _$zod_v4_core0.$strip>;
|
|
207
242
|
};
|
|
@@ -256,6 +291,14 @@ declare const TurnStorageNamespace: {
|
|
|
256
291
|
cost: _$zod.ZodOptional<_$zod.ZodNumber>;
|
|
257
292
|
}, _$zod_v4_core0.$strip>>>;
|
|
258
293
|
}, _$zod_v4_core0.$strip>>;
|
|
294
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
295
|
+
source: _$zod.ZodEnum<{
|
|
296
|
+
user: "user";
|
|
297
|
+
system: "system";
|
|
298
|
+
extension: "extension";
|
|
299
|
+
}>;
|
|
300
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
301
|
+
}, _$zod_v4_core0.$strip>>;
|
|
259
302
|
}, _$zod_v4_core0.$strip>;
|
|
260
303
|
transitioned: _$zod.ZodBoolean;
|
|
261
304
|
}, _$zod_v4_core0.$strip>;
|
|
@@ -286,6 +329,14 @@ declare const TurnStorageNamespace: {
|
|
|
286
329
|
cost: _$zod.ZodOptional<_$zod.ZodNumber>;
|
|
287
330
|
}, _$zod_v4_core0.$strip>>>;
|
|
288
331
|
}, _$zod_v4_core0.$strip>>;
|
|
332
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
333
|
+
source: _$zod.ZodEnum<{
|
|
334
|
+
user: "user";
|
|
335
|
+
system: "system";
|
|
336
|
+
extension: "extension";
|
|
337
|
+
}>;
|
|
338
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
339
|
+
}, _$zod_v4_core0.$strip>>;
|
|
289
340
|
}, _$zod_v4_core0.$strip>;
|
|
290
341
|
}, _$zod_v4_core0.$strip>;
|
|
291
342
|
response: _$zod.ZodObject<{
|
|
@@ -313,6 +364,14 @@ declare const TurnStorageNamespace: {
|
|
|
313
364
|
cost: _$zod.ZodOptional<_$zod.ZodNumber>;
|
|
314
365
|
}, _$zod_v4_core0.$strip>>>;
|
|
315
366
|
}, _$zod_v4_core0.$strip>>;
|
|
367
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
368
|
+
source: _$zod.ZodEnum<{
|
|
369
|
+
user: "user";
|
|
370
|
+
system: "system";
|
|
371
|
+
extension: "extension";
|
|
372
|
+
}>;
|
|
373
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
374
|
+
}, _$zod_v4_core0.$strip>>;
|
|
316
375
|
}, _$zod_v4_core0.$strip>;
|
|
317
376
|
}, _$zod_v4_core0.$strip>;
|
|
318
377
|
};
|
|
@@ -345,6 +404,14 @@ declare const TurnStorageNamespace: {
|
|
|
345
404
|
cost: _$zod.ZodOptional<_$zod.ZodNumber>;
|
|
346
405
|
}, _$zod_v4_core0.$strip>>>;
|
|
347
406
|
}, _$zod_v4_core0.$strip>>;
|
|
407
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
408
|
+
source: _$zod.ZodEnum<{
|
|
409
|
+
user: "user";
|
|
410
|
+
system: "system";
|
|
411
|
+
extension: "extension";
|
|
412
|
+
}>;
|
|
413
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
414
|
+
}, _$zod_v4_core0.$strip>>;
|
|
348
415
|
}, _$zod_v4_core0.$strip>>;
|
|
349
416
|
}, _$zod_v4_core0.$strip>;
|
|
350
417
|
};
|
|
@@ -383,6 +450,14 @@ declare const TurnStorageNamespace: {
|
|
|
383
450
|
cost: _$zod.ZodOptional<_$zod.ZodNumber>;
|
|
384
451
|
}, _$zod_v4_core0.$strip>>>;
|
|
385
452
|
}, _$zod_v4_core0.$strip>>;
|
|
453
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
454
|
+
source: _$zod.ZodEnum<{
|
|
455
|
+
user: "user";
|
|
456
|
+
system: "system";
|
|
457
|
+
extension: "extension";
|
|
458
|
+
}>;
|
|
459
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
460
|
+
}, _$zod_v4_core0.$strip>>;
|
|
386
461
|
}, _$zod_v4_core0.$strip>>;
|
|
387
462
|
}, _$zod_v4_core0.$strip>;
|
|
388
463
|
};
|
|
@@ -415,6 +490,14 @@ declare const TurnStorageNamespace: {
|
|
|
415
490
|
cost: _$zod.ZodOptional<_$zod.ZodNumber>;
|
|
416
491
|
}, _$zod_v4_core0.$strip>>>;
|
|
417
492
|
}, _$zod_v4_core0.$strip>>;
|
|
493
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
494
|
+
source: _$zod.ZodEnum<{
|
|
495
|
+
user: "user";
|
|
496
|
+
system: "system";
|
|
497
|
+
extension: "extension";
|
|
498
|
+
}>;
|
|
499
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
500
|
+
}, _$zod_v4_core0.$strip>>;
|
|
418
501
|
}, _$zod_v4_core0.$strip>>;
|
|
419
502
|
}, _$zod_v4_core0.$strip>;
|
|
420
503
|
};
|
|
@@ -445,6 +528,14 @@ declare const TurnStorageNamespace: {
|
|
|
445
528
|
cost: _$zod.ZodOptional<_$zod.ZodNumber>;
|
|
446
529
|
}, _$zod_v4_core0.$strip>>>;
|
|
447
530
|
}, _$zod_v4_core0.$strip>>;
|
|
531
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
532
|
+
source: _$zod.ZodEnum<{
|
|
533
|
+
user: "user";
|
|
534
|
+
system: "system";
|
|
535
|
+
extension: "extension";
|
|
536
|
+
}>;
|
|
537
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
538
|
+
}, _$zod_v4_core0.$strip>>;
|
|
448
539
|
}, _$zod_v4_core0.$strip>>;
|
|
449
540
|
}, _$zod_v4_core0.$strip>;
|
|
450
541
|
};
|
|
@@ -454,6 +545,14 @@ declare const TurnStorageNamespace: {
|
|
|
454
545
|
request: _$zod.ZodObject<{
|
|
455
546
|
sessionId: _$zod.ZodString;
|
|
456
547
|
turnId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
548
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
549
|
+
source: _$zod.ZodEnum<{
|
|
550
|
+
user: "user";
|
|
551
|
+
system: "system";
|
|
552
|
+
extension: "extension";
|
|
553
|
+
}>;
|
|
554
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
555
|
+
}, _$zod_v4_core0.$strip>>;
|
|
457
556
|
}, _$zod_v4_core0.$strip>;
|
|
458
557
|
response: _$zod.ZodObject<{
|
|
459
558
|
turn: _$zod.ZodObject<{
|
|
@@ -480,6 +579,14 @@ declare const TurnStorageNamespace: {
|
|
|
480
579
|
cost: _$zod.ZodOptional<_$zod.ZodNumber>;
|
|
481
580
|
}, _$zod_v4_core0.$strip>>>;
|
|
482
581
|
}, _$zod_v4_core0.$strip>>;
|
|
582
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
583
|
+
source: _$zod.ZodEnum<{
|
|
584
|
+
user: "user";
|
|
585
|
+
system: "system";
|
|
586
|
+
extension: "extension";
|
|
587
|
+
}>;
|
|
588
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
589
|
+
}, _$zod_v4_core0.$strip>>;
|
|
483
590
|
}, _$zod_v4_core0.$strip>;
|
|
484
591
|
}, _$zod_v4_core0.$strip>;
|
|
485
592
|
};
|
|
@@ -534,6 +641,14 @@ declare const TurnStorageNamespace: {
|
|
|
534
641
|
cost: _$zod.ZodOptional<_$zod.ZodNumber>;
|
|
535
642
|
}, _$zod_v4_core0.$strip>>>;
|
|
536
643
|
}, _$zod_v4_core0.$strip>>;
|
|
644
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
645
|
+
source: _$zod.ZodEnum<{
|
|
646
|
+
user: "user";
|
|
647
|
+
system: "system";
|
|
648
|
+
extension: "extension";
|
|
649
|
+
}>;
|
|
650
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
651
|
+
}, _$zod_v4_core0.$strip>>;
|
|
537
652
|
}, _$zod_v4_core0.$strip>;
|
|
538
653
|
transitioned: _$zod.ZodBoolean;
|
|
539
654
|
}, _$zod_v4_core0.$strip>;
|
|
@@ -564,6 +679,14 @@ declare const TurnStorageNamespace: {
|
|
|
564
679
|
cost: _$zod.ZodOptional<_$zod.ZodNumber>;
|
|
565
680
|
}, _$zod_v4_core0.$strip>>>;
|
|
566
681
|
}, _$zod_v4_core0.$strip>>;
|
|
682
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
683
|
+
source: _$zod.ZodEnum<{
|
|
684
|
+
user: "user";
|
|
685
|
+
system: "system";
|
|
686
|
+
extension: "extension";
|
|
687
|
+
}>;
|
|
688
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
689
|
+
}, _$zod_v4_core0.$strip>>;
|
|
567
690
|
}, _$zod_v4_core0.$strip>;
|
|
568
691
|
}, _$zod_v4_core0.$strip>;
|
|
569
692
|
response: _$zod.ZodObject<{
|
|
@@ -591,6 +714,14 @@ declare const TurnStorageNamespace: {
|
|
|
591
714
|
cost: _$zod.ZodOptional<_$zod.ZodNumber>;
|
|
592
715
|
}, _$zod_v4_core0.$strip>>>;
|
|
593
716
|
}, _$zod_v4_core0.$strip>>;
|
|
717
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
718
|
+
source: _$zod.ZodEnum<{
|
|
719
|
+
user: "user";
|
|
720
|
+
system: "system";
|
|
721
|
+
extension: "extension";
|
|
722
|
+
}>;
|
|
723
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
724
|
+
}, _$zod_v4_core0.$strip>>;
|
|
594
725
|
}, _$zod_v4_core0.$strip>;
|
|
595
726
|
}, _$zod_v4_core0.$strip>;
|
|
596
727
|
};
|
|
@@ -623,6 +754,14 @@ declare const TurnStorageNamespace: {
|
|
|
623
754
|
cost: _$zod.ZodOptional<_$zod.ZodNumber>;
|
|
624
755
|
}, _$zod_v4_core0.$strip>>>;
|
|
625
756
|
}, _$zod_v4_core0.$strip>>;
|
|
757
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
758
|
+
source: _$zod.ZodEnum<{
|
|
759
|
+
user: "user";
|
|
760
|
+
system: "system";
|
|
761
|
+
extension: "extension";
|
|
762
|
+
}>;
|
|
763
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
764
|
+
}, _$zod_v4_core0.$strip>>;
|
|
626
765
|
}, _$zod_v4_core0.$strip>>;
|
|
627
766
|
}, _$zod_v4_core0.$strip>;
|
|
628
767
|
};
|
|
@@ -661,6 +800,14 @@ declare const TurnStorageNamespace: {
|
|
|
661
800
|
cost: _$zod.ZodOptional<_$zod.ZodNumber>;
|
|
662
801
|
}, _$zod_v4_core0.$strip>>>;
|
|
663
802
|
}, _$zod_v4_core0.$strip>>;
|
|
803
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
804
|
+
source: _$zod.ZodEnum<{
|
|
805
|
+
user: "user";
|
|
806
|
+
system: "system";
|
|
807
|
+
extension: "extension";
|
|
808
|
+
}>;
|
|
809
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
810
|
+
}, _$zod_v4_core0.$strip>>;
|
|
664
811
|
}, _$zod_v4_core0.$strip>>;
|
|
665
812
|
}, _$zod_v4_core0.$strip>;
|
|
666
813
|
};
|
|
@@ -693,6 +840,14 @@ declare const TurnStorageNamespace: {
|
|
|
693
840
|
cost: _$zod.ZodOptional<_$zod.ZodNumber>;
|
|
694
841
|
}, _$zod_v4_core0.$strip>>>;
|
|
695
842
|
}, _$zod_v4_core0.$strip>>;
|
|
843
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
844
|
+
source: _$zod.ZodEnum<{
|
|
845
|
+
user: "user";
|
|
846
|
+
system: "system";
|
|
847
|
+
extension: "extension";
|
|
848
|
+
}>;
|
|
849
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
850
|
+
}, _$zod_v4_core0.$strip>>;
|
|
696
851
|
}, _$zod_v4_core0.$strip>>;
|
|
697
852
|
}, _$zod_v4_core0.$strip>;
|
|
698
853
|
};
|
|
@@ -723,6 +878,14 @@ declare const TurnStorageNamespace: {
|
|
|
723
878
|
cost: _$zod.ZodOptional<_$zod.ZodNumber>;
|
|
724
879
|
}, _$zod_v4_core0.$strip>>>;
|
|
725
880
|
}, _$zod_v4_core0.$strip>>;
|
|
881
|
+
initiator: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
882
|
+
source: _$zod.ZodEnum<{
|
|
883
|
+
user: "user";
|
|
884
|
+
system: "system";
|
|
885
|
+
extension: "extension";
|
|
886
|
+
}>;
|
|
887
|
+
sourceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
888
|
+
}, _$zod_v4_core0.$strip>>;
|
|
726
889
|
}, _$zod_v4_core0.$strip>>;
|
|
727
890
|
}, _$zod_v4_core0.$strip>;
|
|
728
891
|
};
|
|
@@ -731,6 +894,9 @@ declare const TurnStorageNamespace: {
|
|
|
731
894
|
defaultTransports?: _$_makaio_core0.TransportRoutingDefault;
|
|
732
895
|
__filterPayload?: {
|
|
733
896
|
[x: string]: string | number | {
|
|
897
|
+
source: "user" | "system" | "extension";
|
|
898
|
+
sourceId?: string | undefined;
|
|
899
|
+
} | {
|
|
734
900
|
total: {
|
|
735
901
|
inputTokens: number;
|
|
736
902
|
outputTokens: number;
|
|
@@ -761,6 +927,10 @@ declare const TurnStorageNamespace: {
|
|
|
761
927
|
cost?: number | undefined;
|
|
762
928
|
}> | undefined;
|
|
763
929
|
} | undefined;
|
|
930
|
+
initiator?: {
|
|
931
|
+
source: "user" | "system" | "extension";
|
|
932
|
+
sourceId?: string | undefined;
|
|
933
|
+
} | undefined;
|
|
764
934
|
};
|
|
765
935
|
} | undefined;
|
|
766
936
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./namespace-
|
|
1
|
+
import{n as e}from"./namespace-Dfq6MDN9.mjs";import{MakaioBus as t}from"@makaio/framework/bus";import{AdapterSubjects as n,AgentSubjects as r,SessionSubjects as i}from"@makaio/framework/contracts";function a(){t.__resetHandlers?.()}function o(e=10){return new Promise(t=>setTimeout(t,e))}function s(e,t){let n=Date.now();return{agentId:e,adapterId:`adapter-${e}`,adapterName:`test-adapter`,sessionId:t?.sessionId??`test-session`,role:`member`,status:`idle`,createdAt:n,lastActivityAt:n,...t}}async function c(e,r=e){await t.emit(n.initialized,{adapterName:e,adapterId:r,capabilities:[]})}async function l(n){return(await t.request(e.getEvents,{sessionId:n})).events}function u(e,n,r){let i=[];return r.push(t.on(e,(e=>{let t=e.payload;i.push(n(t))}))),{received:i,clear:()=>{i.length=0}}}function d(e){return u(i.turn.started,e=>({sessionId:e.sessionId,turnId:e.turnId,messageId:e.messageId,agentIds:[...e.agentIds],initiator:e.initiator}),e)}function f(e){return u(i.turn.completed,e=>({sessionId:e.sessionId,turnId:e.turnId,success:e.success,error:e.error,initiator:e.initiator}),e)}function p(e){return u(i.user_message.sent,e=>({sessionId:e.sessionId,turnId:e.turnId,messageId:e.messageId,content:e.content,agentIds:[...e.agentIds],origin:e.origin}),e)}function m(e){return u(i.user_message.acknowledged,e=>({sessionId:e.sessionId,turnId:e.turnId,messageId:e.messageId,agentId:e.agentId}),e)}function h(e){return u(i.user_message.completed,e=>({sessionId:e.sessionId,turnId:e.turnId,messageId:e.messageId,agentId:e.agentId,outcome:e.outcome,error:e.error}),e)}const g=s;function _(e){let t=Date.now();return{sessionId:e.sessionId,createdAt:t,lastActivityAt:t,status:e.status??`active`,agents:e.agents??[],leadAgentId:e.leadAgentId,targetWorkingDirectory:e.targetWorkingDirectory}}function v(e){return t.on(i.create,t=>{let n=t.payload.sessionId??`session-${crypto.randomUUID().slice(0,8)}`;e.set(n,_({sessionId:n,agents:[]})),t.setResult({sessionId:n})})}function y(e){return t.on(i.agent.added,t=>{let n=e.get(t.payload.sessionId);if(!n)return;let r=n.agents.length===0,i=t.payload.role??(r?`lead`:`member`);r&&(n.adapterSessionId=t.payload.adapterSessionId,n.adapterName=t.payload.adapterName,n.adapterId=t.payload.adapterId);let a=Date.now();n.agents.push({agentId:t.payload.agentId,adapterId:t.payload.adapterId,adapterName:t.payload.adapterName,sessionId:t.payload.sessionId,role:i,status:`idle`,createdAt:a,lastActivityAt:a}),i===`lead`&&(n.leadAgentId=t.payload.agentId),n.lastActivityAt=Date.now()})}function b(e){return t.on(i.get,t=>{t.setResult({session:e.get(t.payload.sessionId)??null})})}function x(e){return t.on(n.getAgent,t=>{for(let n of e.values()){let e=n.agents.find(e=>e.agentId===t.payload.agentId);if(e){t.setResult({agent:{agentId:e.agentId,sessionId:n.sessionId,adapterSessionId:``}});return}}t.setResult({agent:null})})}function S(){return t.on(n.rehydrateAgent,e=>{e.setResult({})})}function C(e=`/previous/cwd`){return t.on(r.cwd.change,t=>{t.setResult({success:!0,previousCwd:e})})}function w(){return t.on(r.model.change,e=>{e.setResult({success:!0,swapped:!1})})}function T(e){return t.on(n.startAgent,t=>{let{adapterId:n,initialMessage:r}=t.payload,i=t.payload.sessionId??`session-${crypto.randomUUID().slice(0,8)}`,a=`agent-${crypto.randomUUID().slice(0,8)}`,o=r?`msg-${crypto.randomUUID().slice(0,8)}`:void 0,s=`adapter-session-${i}`;e?.({adapterId:n,sessionId:i,initialMessage:r}),t.setResult({success:!0,agentId:a,adapterId:n,adapterSessionId:s,sessionId:i,...o&&{messageId:o}}),j({sessionId:i,agentId:a,adapterId:n,adapterSessionId:s})})}function E(e){return t.on(n.startAgent,t=>{t.setResult({success:!1,message:e})})}function D(e){return t.on(r.sendMessage,t=>{let{agentId:n,adapterId:r,message:i,messageId:a,sessionContext:o,responseSchema:s}=t.payload,c=a??`msg-${crypto.randomUUID().slice(0,8)}`;e?.({agentId:n,adapterId:r,message:i,messageId:c,sessionContext:o,responseSchema:s}),t.setResult({messageId:c})})}function O(e,n){return t.on(r.sendMessage,t=>{if(e.has(t.payload.agentId))throw Error(n);t.setResult({messageId:t.payload.messageId??`generated-id`})})}async function k(e,n){await t.emit(r.complete,{agentId:e,adapterId:`adapter-${e}`,adapterName:`test-adapter`,adapterSessionId:`adapter-session-${e}`,messageId:n})}async function A(e,n){await t.emit(r.complete,{agentId:e,adapterId:`adapter-${e}`,adapterName:`test-adapter`,adapterSessionId:`adapter-session-${e}`,messageId:`msg-error-${e}`,outcome:`error`,error:n})}function j(e){setImmediate(()=>{t.emit(i.agent.added,{sessionId:e.sessionId,agentId:e.agentId,adapterId:e.adapterId,adapterName:e.adapterId,adapterSessionId:e.adapterSessionId,role:e.role})})}function M(e,r){let i=new Map,a=t.on(n.startAgent,t=>{r.payload=t.payload;let n=`agent-${crypto.randomUUID().slice(0,8)}`,a=t.payload.initialMessage?`msg-${crypto.randomUUID().slice(0,8)}`:void 0,o=`adapter-session-${e}`;i.set(n,{agentId:n,sessionId:e,adapterSessionId:o,adapterId:t.payload.adapterId}),t.setResult({success:!0,agentId:n,adapterId:t.payload.adapterId,adapterSessionId:o,sessionId:e,...a&&{messageId:a}}),j({sessionId:e,agentId:n,adapterId:t.payload.adapterId,adapterSessionId:o})}),o=t.on(n.getAgent,e=>{let t=i.get(e.payload.agentId);e.setResult({agent:t?{agentId:t.agentId,sessionId:t.sessionId,adapterSessionId:t.adapterSessionId}:null})});return()=>{a(),o()}}export{c as C,o as E,p as S,a as T,T as _,A as a,m as b,v as c,E as d,x as f,D as g,S as h,k as i,C as l,w as m,_ as n,y as o,b as p,j as r,M as s,g as t,O as u,f as v,l as w,h as x,d as y};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IMakaioBus } from "@makaio/framework/bus";
|
|
2
2
|
import * as _$_makaio_contracts0 from "@makaio/framework/contracts";
|
|
3
|
-
import {
|
|
3
|
+
import { IWorkflowRunner, IWorkflowTriggerTypeRegistry, MakaioNodeExtension, StationHandler, StepRunnerBusAuth, StepRunnerPlatformDefaults, WorkflowDefinition } from "@makaio/framework/contracts";
|
|
4
4
|
import { BaseService } from "@makaio/framework/service-base";
|
|
5
5
|
import { MakaioDatabase } from "@makaio/framework/storage/drizzle";
|
|
6
6
|
|
|
@@ -19,10 +19,9 @@ import { MakaioDatabase } from "@makaio/framework/storage/drizzle";
|
|
|
19
19
|
* - WorkLog projection: worklog.get, worklog.list, worklog.changed (event-driven)
|
|
20
20
|
* @param bus - MakaioBus instance for message handling
|
|
21
21
|
* @param db - Drizzle database instance
|
|
22
|
-
* @param _ctx - Extension context (unused; reserved for future use)
|
|
23
22
|
* @returns Cleanup function to unregister all handlers
|
|
24
23
|
*/
|
|
25
|
-
declare function registerDrizzleWorkflowStorage(bus: IMakaioBus, db: MakaioDatabase
|
|
24
|
+
declare function registerDrizzleWorkflowStorage(bus: IMakaioBus, db: MakaioDatabase): () => void;
|
|
26
25
|
//#endregion
|
|
27
26
|
//#region subsystems/workflow-engine/src/types.d.ts
|
|
28
27
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SessionStorageSubjects as e}from"./services/session/storage/namespace.mjs";import{ExecutionTargetSubjects as t}from"./services/execution-target/namespace.mjs";import{MakaioBus as n}from"@makaio/framework/bus";import{AdapterSubjects as r,AgentSubjects as i,DEFAULT_CONSTRAINTS as a,SessionSubjects as o,SpawnSubagentRpcRequestSchema as s,SubagentConfigSchema as c,SubagentError as l,SubagentErrorCode as u,SubagentSubjects as d,dep as f,extensionToken as p}from"@makaio/framework/contracts";import{BaseService as m}from"@makaio/framework/service-base";import{AdapterRuntimeSubjects as h}from"@makaio/framework/services/adapter-runtime";import{activateProviderContext as g,buildProviderContext as _}from"@makaio/framework/services/provider-context";function v(e,t){return`${e}:${t}`}function y(e,t){return e?.authenticated!==!0||!e.id?!1:e.kind===`workflow-execution`?!0:t.size===0?!1:t.has(v(e.kind,e.id))}var b=class{maxSize;items=[];constructor(e=50){this.maxSize=e}push(e){this.items.push(e),this.items.length>this.maxSize&&this.items.shift()}toArray(){return[...this.items]}get length(){return this.items.length}clear(){this.items=[]}};const x=[`completed`,`failed`,`cancelled`];function S(e){return x.includes(e)}var C=class{constraints;subagents=new Map;awaiters=new Map;constructor(e){this.constraints=e}track(e){let t=Date.now(),n={subagentId:e.subagentId,parentSessionId:e.parentSessionId,childSessionId:void 0,status:`spawning`,config:e.config,depth:e.depth,progressUpdates:new b(50),startTime:t,lastActivityAt:t};return this.subagents.set(e.subagentId,n),n}setChildSessionId(e,t){let n=this.subagents.get(e);n&&(n.childSessionId=t,n.lastActivityAt=Date.now(),n.status===`spawning`&&(n.status=`running`))}get(e){return this.subagents.get(e)}getAllNonTerminal(){let e=[];for(let t of this.subagents.values())S(t.status)||e.push(t);return e}countActiveBySession(e){let t=0;for(let n of this.subagents.values())n.parentSessionId===e&&!S(n.status)&&t++;return t}countTotalActive(){let e=0;for(let t of this.subagents.values())S(t.status)||e++;return e}updateStatus(e,t){let n=this.subagents.get(e);if(!n)return;let r=Date.now();n.status=t,n.lastActivityAt=r,S(t)&&(n.endTime=r)}addProgress(e,t){let n=this.subagents.get(e);n&&(n.progressUpdates.push(t),n.lastActivityAt=Date.now())}setPendingRequest(e,t){let n=this.subagents.get(e);if(!n)throw new l(u.NOT_FOUND,`Subagent ${e} not found`);if(n.pendingRequest)throw new l(u.REQUEST_PENDING,`Cannot call request_input while another request is pending`);n.pendingRequest=t,n.status=`waiting_input`,n.lastActivityAt=Date.now()}resolvePendingRequest(e,t){let n=this.subagents.get(e);n?.pendingRequest&&(n.pendingRequest.resolver(t),n.pendingRequest=void 0,n.lastActivityAt=Date.now(),n.status===`waiting_input`&&(n.status=`running`))}markCompleted(e,t,n,r){let i=this.subagents.get(e);if(!i)throw new l(u.NOT_FOUND,`Subagent ${e} not found`);if(S(i.status))throw new l(u.ALREADY_TERMINAL,`Subagent already in terminal state: ${i.status}`);let a=Date.now();i.status=`completed`,i.result=t,i.summary=n,i.completionSource=r,i.endTime=a,i.lastActivityAt=a,this.resolveAwaiters(e)}markFailed(e,t){let n=this.subagents.get(e);if(!n||S(n.status))return;let r=Date.now();n.status=`failed`,n.error=t,n.endTime=r,n.lastActivityAt=r,this.resolveAwaiters(e)}markCancelled(e){let t=this.subagents.get(e);if(!t||S(t.status))return!1;let n=Date.now();return t.status=`cancelled`,t.endTime=n,t.lastActivityAt=n,t.pendingRequest&&=(t.pendingRequest.resolver(null),void 0),this.resolveAwaiters(e),!0}addAwaiter(e,t){let n=this.awaiters.get(e)??[];n.push(t),this.awaiters.set(e,n)}removeAwaiter(e,t){let n=this.awaiters.get(e);if(!n)return!1;let r=n.indexOf(t);return r===-1?!1:(n.splice(r,1),n.length===0&&this.awaiters.delete(e),!0)}resolveAwaiters(e){let t=this.subagents.get(e),n=this.awaiters.get(e);if(!n||!t)return;let r={status:t.status,result:t.result,error:t.error,completionSource:t.completionSource};for(let e of n)e(r);this.awaiters.delete(e)}cleanup(){let e=Date.now(),t=0;for(let[n,r]of this.subagents)S(r.status)&&r.endTime&&e-r.endTime>this.constraints.stateRetentionMs&&(this.subagents.delete(n),t++);return t}sweepHung(e){if(e<=0)return 0;let t=Date.now(),n=0;for(let r of this.subagents.values())S(r.status)||r.status!==`waiting_input`&&r.status!==`hung`&&t-r.lastActivityAt>=e&&(r.status=`hung`,r.lastActivityAt=t,n++);return n}};async function w(e,t,n){let r=n?.trim();if(r)return r;let{session:i}=await e.request(o.get,{sessionId:t});return(i?.agents.find(e=>e.agentId===i.leadAgentId)??i?.agents[0])?.adapterName?.trim()}function T(e,t){let n=e.manager.get(t.subagentId);if(!n)throw Error(`Subagent not found: ${t.subagentId}`);return{status:n.status,childSessionId:n.childSessionId,pendingRequest:n.pendingRequest?{messageId:n.pendingRequest.messageId,question:n.pendingRequest.question,context:n.pendingRequest.context}:void 0,progress:n.progressUpdates.toArray(),result:n.result,summary:n.summary,error:n.error}}async function E(e,t){let{parentSessionId:n,config:r,depth:i,spawningToolCallId:a}=t,{constraints:o}=e.manager,s=Math.min(r.maxDepth??o.maxDepth,o.maxDepth);if(i>s)throw new l(u.DEPTH_EXCEEDED,`Maximum subagent depth (${s}) exceeded`);if(e.manager.countActiveBySession(n)>=o.maxConcurrentPerSession)throw new l(u.SESSION_LIMIT,`Maximum concurrent subagents per session (${o.maxConcurrentPerSession}) reached`);if(e.manager.countTotalActive()>=o.maxTotalActive)throw new l(u.GLOBAL_LIMIT,`Maximum total active subagents (${o.maxTotalActive}) reached`);let c=await w(e.bus,n,r.adapterName);if(!c)throw new l(u.ADAPTER_NOT_ALLOWED,`adapterName is required for subagent spawn when parent session has no inheritable adapter`);if(o.allowedAdapters.length>0&&!o.allowedAdapters.includes(c))throw new l(u.ADAPTER_NOT_ALLOWED,`Adapter '${c}' is not allowed`);if(r.model&&o.allowedModels.length>0&&!o.allowedModels.includes(r.model))throw new l(u.MODEL_NOT_ALLOWED,`Model '${r.model}' is not allowed`);let f={...r,adapterName:c},p=crypto.randomUUID();return e.manager.track({subagentId:p,parentSessionId:n,config:f,depth:i}),await e.bus.emit(d.spawned,{subagentId:p,parentSessionId:n,task:f.task,config:f,depth:i,...a!==void 0&&{spawningToolCallId:a}}),{subagentId:p,status:`spawning`}}async function D(e,t){let{subagentId:n,timeoutMs:r}=t,i=e.manager.get(n);if(!i)throw Error(`Subagent not found: ${n}`);if([`completed`,`failed`,`cancelled`].includes(i.status))return{status:i.status,result:i.result,error:i.error,completionSource:i.completionSource};if(i.status===`waiting_input`&&i.pendingRequest)return{status:`waiting_input`,pendingRequest:{messageId:i.pendingRequest.messageId,question:i.pendingRequest.question,context:i.pendingRequest.context}};let a=r??e.manager.constraints.defaultAwaitTimeoutMs;return new Promise(t=>{let r=!1,i,o=e=>{r||(r=!0,i&&clearTimeout(i),t({status:e.status,result:e.result,error:e.error,pendingRequest:e.pendingRequest,completionSource:e.completionSource}))};e.manager.addAwaiter(n,o),a>0&&(i=setTimeout(()=>{r||(r=!0,e.manager.removeAwaiter(n,o),t({status:`timeout`}))},a))})}async function O(e,t){let{subagentId:n,content:r,inResponseTo:i}=t,a=e.manager.get(n);if(!a)throw Error(`Subagent not found: ${n}`);let o=!1;return i&&a.pendingRequest?.messageId===i&&(e.manager.resolvePendingRequest(n,r),o=!0),await e.bus.emit(d.toChild,{subagentId:n,messageId:crypto.randomUUID(),content:r,inResponseTo:i}),{sent:!0,resolvedPending:o}}async function k(e,t){let{subagentId:n,reason:r}=t,i=e.manager.markCancelled(n);return i&&await e.bus.emit(d.cancelled,{subagentId:n,reason:r??`Killed by parent`}),{killed:i}}async function A(e,t){let{subagentId:n,update:r,percentComplete:i}=t;if(!e.manager.get(n))throw Error(`Subagent not found: ${n}`);let a=i===void 0?r:`[${i}%] ${r}`;return e.manager.addProgress(n,a),await e.bus.emit(d.toParent,{subagentId:n,messageId:crypto.randomUUID(),type:`progress`,content:a}),{reported:!0}}async function j(e,t){let{subagentId:n,question:r,context:i,timeoutMs:a}=t;if(!e.manager.get(n))throw Error(`Subagent not found: ${n}`);let o=crypto.randomUUID(),s=a??e.manager.constraints.defaultRequestTimeoutMs;return await e.bus.emit(d.toParent,{subagentId:n,messageId:o,type:`request_input`,content:r,context:i}),new Promise(t=>{let a=!1,c;e.manager.setPendingRequest(n,{messageId:o,question:r,context:i,resolver:e=>{a||(a=!0,c&&clearTimeout(c),t(e===null?{responded:!1,timedOut:!0}:{responded:!0,response:e,timedOut:!1}))}}),s>0&&(c=setTimeout(()=>{a||e.manager.resolvePendingRequest(n,null)},s))})}async function M(e,t){let{subagentId:n,result:r,summary:i}=t;return e.manager.markCompleted(n,r,i,`tool`),await e.bus.emit(d.completed,{subagentId:n,success:!0,result:i?`${i}\n\n${r}`:r}),{completed:!0}}function N(e,t){let{parentSessionId:n}=t;return{subagents:e.manager.getAllNonTerminal().filter(e=>e.parentSessionId===n).map(e=>({subagentId:e.subagentId,task:e.config.task,status:e.status}))}}const P={id:`system:local`,name:`Local`,description:`Default local process execution`,type:`local`,scope:`default`,enabled:!0,createdAt:Date.now(),updatedAt:Date.now()};var F=class extends m{machineId;delegationAllowSet;manager;pendingChildSessionClose=new Set;constructor(e=n,t=a,r,i=new Set){super(e),this.machineId=r,this.delegationAllowSet=i,this.manager=new C(t)}grantDelegation(e,t){this.delegationAllowSet.add(`${e}:${t}`)}revokeDelegation(e,t){this.delegationAllowSet.delete(`${e}:${t}`)}onInit(){this.registerHandler(d.spawned,async e=>{this.handleSpawned(e.payload).catch(e=>{console.error(`[SubagentService] handleSpawned error:`,e)})}),this.registerHandler(d.execute,async e=>{if(!this.isRemoteDelegationAllowed(e))return;let t=await this.handleExecute(e.payload);e.setResult(t)}),this.registerHandler(d.toChild,async e=>{await this.handleToChild(e.payload)}),this.registerHandler(d.completed,async e=>{await this.handleCompleted(e.payload.subagentId)}),this.registerHandler(d.cancelled,async e=>{await this.handleCancelled(e.payload.subagentId)}),this.registerHandler(r.session.closed,e=>{this.handleAdapterSessionClosed(e.payload.sessionId)}),this.registerHandler(i.complete,async e=>{await this.handleAgentComplete(e.payload)}),this.registerRpcHandlers(),this.wirePeriodicSweep()}wirePeriodicSweep(){let{inactivityTimeoutMs:e,sweepIntervalMs:t}=this.manager.constraints;if(t<=0)return;let n=setInterval(()=>{let t=this.manager.sweepHung(e);t>0&&console.warn(`[SubagentService] Swept ${t} hung subagent(s) due to inactivity`),this.manager.cleanup()},t);this.addCleanup(()=>clearInterval(n))}registerRpcHandlers(){let e={manager:this.manager,bus:this.bus};this.registerHandler(d.getStatus,t=>{let n=T(e,t.payload);t.setResult(n)}),this.registerHandler(d.spawn,async t=>{if(!this.isRemoteDelegationAllowed(t))return;let n=await E(e,s.parse(t.payload));t.setResult(n)}),this.registerHandler(d.await,async t=>{let n=await D(e,t.payload);t.setResult(n)}),this.registerHandler(d.send,async t=>{let n=await O(e,t.payload);t.setResult(n)}),this.registerHandler(d.kill,async t=>{let n=await k(e,t.payload);t.setResult(n)}),this.registerHandler(d.reportProgress,async t=>{let n=await A(e,t.payload);t.setResult(n)}),this.registerHandler(d.requestInput,async t=>{let n=await j(e,t.payload);t.setResult(n)}),this.registerHandler(d.completeTask,async t=>{let n=await M(e,t.payload);t.setResult(n)}),this.registerHandler(d.listBySession,t=>{let n=N(e,t.payload);t.setResult(n)})}onDestroy(){this.pendingChildSessionClose.clear()}async handleSpawned(e){let{subagentId:n,parentSessionId:r,task:i,spawningToolCallId:a}=e,o=c.parse({...e.config,task:i}),s=o.adapterName?.trim();if(!s)return this.failSpawn(n,r,`adapter_start`,`Subagent spawn requires a non-empty adapterName`);this.manager.get(n)||this.manager.track({subagentId:n,parentSessionId:r,config:o,depth:e.depth??1});let l,u;try{u=await this.buildExecutionTargetResolutionParams(r,o.executionTargetId);let e=await this.bus.requestOptional(t.resolve,u),i;if(e.handled)i=e.data.executionTarget;else if(u.executionTargetId!=null)throw Error(`Execution target resolver unavailable for explicit target '${u.executionTargetId}'`);else i=P;if(i.type!==`local`)return this.failSpawn(n,r,`adapter_start`,`Execution target type '${i.type}' is not yet supported for subagents`);l=u.executionTargetId??void 0}catch(e){return this.failSpawn(n,r,`adapter_start`,e)}let d;try{d=await this.createChildSessionForSpawn(n,r,o,l,u,a)}catch(e){return this.failSpawn(n,r,`session_create`,e)}let f=this.manager.get(n);if(!(f&&this.isTerminalSubagentStatus(f.status)))try{await this.startAdapterForSubagent(s,o,d,i)}catch(e){return this.failSpawn(n,r,`adapter_start`,e)}}async createChildSessionForSpawn(e,t,n,r,i,a){let{sessionId:s}=await this.bus.request(o.create,this.buildChildSessionCreatePayload(t,n,r,a));return this.manager.setChildSessionId(e,s),this.pendingChildSessionClose.has(e)&&await this.closeChildSession(e),s}async startAdapterForSubagent(e,t,n,i){let{adapterId:a}=await this.bus.request(h.resolveId,{adapterName:e,...this.machineId!==void 0&&{machineId:this.machineId}}),o=t.providerContext??(t.providerConfigId?await _(this.bus,t.providerConfigId):void 0);o!==void 0&&await g(this.bus,o);let s=await this.bus.request(r.startAgent,{adapterId:a,role:`lead`,...o!==void 0&&{providerContext:o},sessionId:n,initialMessage:i,model:t.model,reasoningEffort:t.reasoningEffort,systemPrompt:t.systemPrompt,responseSchema:t.responseSchema,allowedTools:t.tools,disallowedTools:t.disallowedTools,allowedDirectories:t.allowedDirectories,...t.harnessId!==void 0&&{harnessId:t.harnessId}});if(!s||s.success!==!0)throw Error(s?.message??`Adapter start failed`)}async failSpawn(e,t,n,r){let i=r instanceof Error?r.message:String(r);return this.manager.markFailed(e,i),await this.emitExecutionFailed(e,t,n,r),i}async buildExecutionTargetResolutionParams(t,n){if(n!==void 0)return{executionTargetId:n};let{session:r}=await this.bus.request(e.get,{sessionId:t});if(!r)throw Error(`Parent session not found: ${t}`);return{executionTargetId:r.executionTargetId}}buildChildSessionCreatePayload(e,t,n,r){return{branchKind:`subagent`,parentSessionId:e,contextInheritance:t.contextMode===`fork`?`parent-history`:`none`,...n!==void 0&&{executionTargetId:n},...r!==void 0&&{spawningToolCallId:r}}}async handleExecute(e){let t=c.parse({...e.config,task:e.task});this.manager.track({subagentId:e.subagentId,parentSessionId:e.parentSessionId,config:t,depth:e.depth});let n=await this.handleSpawned({subagentId:e.subagentId,parentSessionId:e.parentSessionId,task:e.task,config:t,depth:e.depth});return n?{success:!1,error:n}:{success:!0}}async handleToChild(e){let{subagentId:t,content:n}=e,r=this.manager.get(t);if(!r){console.warn(`[SubagentService] No subagent found: ${t}`);return}if(!r.childSessionId){console.warn(`[SubagentService] No child session for subagent: ${t}`);return}try{await this.bus.request(o.sendMessage,{sessionId:r.childSessionId,message:n,source:`system`})}catch(e){console.error(`[SubagentService] Failed to route message to child session:`,e)}}async handleCompleted(e){await this.closeChildSession(e)}async handleCancelled(e){await this.closeChildSession(e)}async closeChildSession(e){let t=this.manager.get(e);if(t){if(!t.childSessionId){this.pendingChildSessionClose.add(e);return}this.pendingChildSessionClose.delete(e);try{await this.bus.request(o.close,{sessionId:t.childSessionId})}catch(t){console.error(`[SubagentService] Failed to close child session for subagent ${e}:`,t)}}}isTerminalSubagentStatus(e){return e===`completed`||e===`failed`||e===`cancelled`}handleAdapterSessionClosed(e){for(let t of this.manager.getAllNonTerminal())if(t.childSessionId===e){console.warn(`[SubagentService] Adapter session closed for subagent ${t.subagentId}: ${e}`),this.manager.markFailed(t.subagentId,`adapter-session-closed`);return}}async handleAgentComplete(e){let{sessionId:t,outcome:n,message:r,error:i}=e;if(t)for(let e of this.manager.getAllNonTerminal()){if(e.childSessionId!==t)continue;if((e.config.completion??`tool`)!==`turn`||e.status===`waiting_input`)return;let a=n??`completed`;if(a===`completed`){try{this.manager.markCompleted(e.subagentId,r??``,void 0,`turn`)}catch{return}await this.bus.emit(d.completed,{subagentId:e.subagentId,success:!0,result:r??``})}else if(a===`error`){let t=i??`agent turn error`;this.manager.markFailed(e.subagentId,t),await this.bus.emit(d.completed,{subagentId:e.subagentId,success:!1,error:t})}return}}isRemoteDelegationAllowed(e){return e.origin.local||y(e.transport?.peer,this.delegationAllowSet)}async emitExecutionFailed(e,t,n,r){let i=r instanceof Error?r.message:String(r);await this.bus.emit(d.executionFailed,{subagentId:e,parentSessionId:t,phase:n,error:i}).catch(e=>{console.error(`[SubagentService] Failed to emit executionFailed:`,e)})}};const I=p(`subagent-service`),L={name:I.name,displayName:`Subagent Service`,version:`0.1.0`,critical:!0,surface:`headless`,dependencies:[f(`session`)],create:e=>new F(e.bus,a,e.machineId)};export{y as a,C as i,L as n,F as r,I as t};
|