@makaio/framework 1.0.0-dev-1783282710723 → 1.0.0-dev-1783439621927
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-Lx6K7yQS.mjs +1 -0
- package/dist/adapter-subsystem/index.mjs +1 -1
- package/dist/adapters/config/index.d.mts +1 -1
- package/dist/adapters/index.d.mts +229 -41
- package/dist/adapters/index.mjs +6 -6
- package/dist/adapters/node.d.mts +1 -1
- package/dist/adapters/node.mjs +1 -1
- package/dist/{base-orchestrator-Cw0vpNgB.d.mts → base-orchestrator-ODRyDBzu.d.mts} +79 -3
- package/dist/bus/index.mjs +1 -1
- package/dist/client-n0OJiTt1.mjs +1 -0
- 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/adapter/schemas/session-lineage.mjs +1 -1
- package/dist/contracts/artifact/index.d.mts +1 -1
- package/dist/contracts/client/index.d.mts +2 -2
- package/dist/contracts/client/index.mjs +1 -1
- package/dist/contracts/config/index.d.mts +6 -6
- package/dist/contracts/extension/index.d.mts +2 -2
- package/dist/contracts/facet/index.d.mts +1 -1
- package/dist/contracts/harness/index.d.mts +1 -1
- package/dist/contracts/index.d.mts +375 -197
- package/dist/contracts/index.mjs +1 -1
- package/dist/contracts/materialization/index.d.mts +3 -3
- package/dist/contracts/provider/index.d.mts +1 -1
- package/dist/contracts/session/index.d.mts +3 -3
- package/dist/contracts/session/index.mjs +1 -1
- package/dist/contracts/variant/index.d.mts +1 -1
- package/dist/contracts/workflow/index.d.mts +2 -2
- package/dist/contracts/workflow/index.mjs +1 -1
- package/dist/{definition-DFcxkf2i.d.mts → definition-DpkfJi8v.d.mts} +1 -1
- package/dist/drizzle/0021_m_mr8e1j84.sql +3 -0
- package/dist/drizzle/0022_m_mr8i4ky3.sql +43 -0
- package/dist/drizzle/0023_m_mr9gc37m.sql +1 -0
- package/dist/drizzle/meta/_journal.json +21 -0
- package/dist/{handler-2bPhRn0u.mjs → handler-BFNvtv5t.mjs} +1 -1
- package/dist/handlers-B74FvKlA.mjs +57 -0
- package/dist/hooks/index.d.mts +27 -2
- package/dist/hooks/index.mjs +1 -1
- package/dist/{identity-BarL3JYI.mjs → identity-DC3Pk0ps.mjs} +1 -1
- package/dist/{index-4eP9DRL_.d.mts → index-B3fjN5HX.d.mts} +7 -7
- package/dist/{index-Bh6lHiW4.d.mts → index-B5Uczo3R.d.mts} +40 -40
- package/dist/{index-CL2T6LVv.d.mts → index-BIZeIA5k.d.mts} +8 -8
- package/dist/{index-gAFwNiJT.d.mts → index-BvTd61i5.d.mts} +212 -26
- package/dist/{index-Y2r0Zvcm.d.mts → index-BvjLe_w9.d.mts} +12 -12
- package/dist/{index-2fK9iSHI.d.mts → index-BwGfdbI0.d.mts} +9 -9
- package/dist/{index-CaOWqztb.d.mts → index-C8k2f_E0.d.mts} +1 -1
- package/dist/{index-DEzdNQum.d.mts → index-CYHWOXUm.d.mts} +1 -1
- package/dist/{index-9b2_jXxq.d.mts → index-CwHP8Jxs.d.mts} +514 -96
- package/dist/{index-D6aAzr32.d.mts → index-Cyi7y_aG.d.mts} +20 -20
- package/dist/{index-DdBRlm7m.d.mts → index-D7Fu3375.d.mts} +401 -21
- package/dist/{index-CfIW5biI.d.mts → index-D7rWAEY0.d.mts} +1 -0
- package/dist/{index-CTEsbp9H.d.mts → index-DFK3tpEY.d.mts} +83 -5
- package/dist/{index-Dg-y1mrq.d.mts → index-DS6kxiFl.d.mts} +28 -28
- package/dist/{index-BMbmoarE.d.mts → index-DTBQOCar.d.mts} +16 -16
- package/dist/{index-GD-i3DW7.d.mts → index-DmJ-OpTD.d.mts} +1275 -224
- package/dist/{index-DLy-tc0L.d.mts → index-Dtb2cVJz.d.mts} +260 -47
- package/dist/{index-D9-vOJvZ.d.mts → index-h5go5Dtd.d.mts} +1 -1
- 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/{lib-Ba55od_d.mjs → lib-BOmKyjWD.mjs} +1 -1
- package/dist/{lib-CM_BUxN8.mjs → lib-DLZYp5z3.mjs} +1 -1
- package/dist/{loop-gate-handlers-BLoGCWMQ.mjs → loop-gate-handlers-Bjmat-K3.mjs} +1 -1
- package/dist/{namespace-D8P8Sxce2.d.mts → namespace-6sIu5nBI2.d.mts} +2 -2
- package/dist/{namespace-CfvtDD_U.d.mts → namespace-BLER-Qom.d.mts} +2 -2
- package/dist/{namespace-B3ol3pc-.d.mts → namespace-BigVYQyx.d.mts} +12 -0
- package/dist/{namespace-j7vFsmYL.d.mts → namespace-C74bbsdZ.d.mts} +2 -2
- package/dist/{namespace-B4cV_pk3.d.mts → namespace-CGxFYDlK.d.mts} +32 -32
- package/dist/{namespace-LUNf8zo5.d.mts → namespace-D1_9WVCo.d.mts} +157 -0
- package/dist/{namespace-KMxsPJwm.d.mts → namespace-D4Uf5Mw_.d.mts} +432 -18
- package/dist/{namespace-BsYKEMd8.d.mts → namespace-DAj_riOn.d.mts} +138 -0
- package/dist/{namespace-DXW-voCe.d.mts → namespace-DRXQyBe0.d.mts} +204 -24
- package/dist/{namespace-DGAWYjbO.d.mts → namespace-JFzrlNs4.d.mts} +27 -27
- package/dist/namespace-dFBD2ZmS.mjs +1 -0
- package/dist/node/transports/index.mjs +1 -1
- package/dist/orchestrator-shared-ChygCvR1.mjs +1 -0
- package/dist/{orchestrator-shared-ChOdIgh6.d.mts → orchestrator-shared-DFLb1otg.d.mts} +9 -3
- package/dist/{package-MmQvNJ3u.d.mts → package-B6mEMD8r.d.mts} +5 -0
- package/dist/package-BQn_RTo7.mjs +1 -0
- package/dist/package.json +1 -1
- package/dist/runtime-node/index.mjs +1 -1
- package/dist/schema-7aKBGB7S.mjs +1 -0
- package/dist/{schema-D1HrnvT7.d.mts → schema-B9goOieO.d.mts} +50 -1
- package/dist/{schema-DHlTAy0N.mjs → schema-CHp6I33k.mjs} +1 -1
- package/dist/{schemas-D-9zNyAM2.d.mts → schemas-9S9Y9PHT2.d.mts} +7 -7
- package/dist/{schemas-CoFCV42v.d.mts → schemas-B_t6oOK-.d.mts} +2 -2
- package/dist/{schemas-lnE9YoG7.d.mts → schemas-CW6YsPT4.d.mts} +3 -3
- package/dist/schemas-CkOigLAT.mjs +1 -0
- package/dist/{schemas-BemsLc_V.d.mts → schemas-CurUbHy4.d.mts} +4 -4
- package/dist/{schemas-DMCGXlKa.d.mts → schemas-DXeGCbJ9.d.mts} +4 -4
- package/dist/schemas-DZGnr9Tl.mjs +1 -0
- package/dist/{schemas-DWfo0wp4.d.mts → schemas-DnmbwE_V.d.mts} +7 -7
- package/dist/{schemas-DmGRSeIq.d.mts → schemas-t6h9oSct.d.mts} +28 -1
- package/dist/services/adapter-runtime/index.d.mts +4 -4
- package/dist/services/adapter-runtime/index.mjs +1 -1
- package/dist/services/adapter-runtime/namespace.d.mts +1 -1
- package/dist/services/adapter-runtime/schemas.d.mts +2 -2
- package/dist/services/adapter-runtime/schemas.mjs +1 -1
- package/dist/services/adapter-subsystem/index.d.mts +2 -2
- package/dist/services/adapter-subsystem/namespace.d.mts +1 -1
- package/dist/services/agent-runtime/index.d.mts +2 -2
- package/dist/services/agent-runtime/namespace.d.mts +1 -1
- package/dist/services/agent-runtime/schemas.d.mts +1 -1
- package/dist/services/context-rules/index.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 +4 -4
- package/dist/services/harness/index.mjs +1 -1
- package/dist/services/index.d.mts +129 -53
- 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 +86 -6
- package/dist/services/log-import/index.mjs +2 -2
- package/dist/services/log-import/log-import.d.mts +1 -1
- package/dist/services/log-import/log-import.mjs +1 -1
- package/dist/services/log-import/namespace.d.mts +54 -0
- package/dist/services/log-import/namespace.mjs +1 -1
- package/dist/services/log-import/schemas.d.mts +44 -0
- package/dist/services/log-import/schemas.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/session/handlers/index.d.mts +1 -1
- package/dist/services/session/handlers/index.mjs +1 -1
- package/dist/services/session/index.d.mts +9 -9
- 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.d.mts +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 +10 -4
- package/dist/services/session/testing/orchestrator-shared.d.mts +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.d.mts +1 -1
- package/dist/services/settings/namespace.d.mts +7 -7
- package/dist/services/subagent-template/index.d.mts +2 -2
- package/dist/services/subagent-template/namespace.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/tray-menu/index.d.mts +2 -2
- 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 +89 -0
- package/dist/services/turn/schemas.mjs +1 -1
- package/dist/session-CZUrp7gC.mjs +69 -0
- package/dist/session-Dp7z5N1d.mjs +1 -0
- package/dist/{session-lineage-DR-9DU-U.d.mts → session-lineage-C1M7-O3C.d.mts} +3 -3
- package/dist/storage/drizzle/index.d.mts +1 -1
- package/dist/storage/drizzle/index.mjs +1 -1
- package/dist/{storage-namespace-Di1A3DMm.d.mts → storage-namespace-BvRF22by.d.mts} +10 -10
- package/dist/{tool-approval-service-DEQiipxj.mjs → tool-approval-service-BIbUSuqg.mjs} +1 -1
- package/dist/tools-Yz8XyiwA.mjs +1 -0
- package/dist/{transition-DnXibkhX.d.mts → transition-DYorNHZu.d.mts} +1 -1
- package/dist/{types-Dur8EtpR.d.mts → types-9XCB1aPK.d.mts} +562 -107
- package/dist/{types-BMS6yfLS.d.mts → types-BNW5n6qm.d.mts} +1 -1
- package/dist/{types-BslClRkH.d.mts → types-BWduCvRU.d.mts} +22 -1
- package/dist/{types-Cse8s_cD.d.mts → types-N_BOtTqt.d.mts} +29 -18
- package/dist/ui-components/index.mjs +1 -1
- 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/dist/{workflow-BqH6ar-D.mjs → workflow-C1z7I5CI.mjs} +1 -1
- package/dist/workflow-engine/index.d.mts +45 -45
- 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 +1 -1
- package/dist/adapter-DaQqmKOJ.mjs +0 -1
- package/dist/client-BcfR-LJC.mjs +0 -1
- package/dist/handlers-BAycjV02.mjs +0 -41
- package/dist/namespace-C-piH3w4.mjs +0 -1
- package/dist/orchestrator-shared-Cxk3x8Vs.mjs +0 -1
- package/dist/package-B1AXe-oz.mjs +0 -1
- package/dist/schema-D6WAI8OL.mjs +0 -1
- package/dist/schemas-ArqQTC0Q.mjs +0 -1
- package/dist/schemas-uID59wR8.mjs +0 -1
- package/dist/session-0nWT4st6.mjs +0 -39
- package/dist/session-DH-ja8Ka.mjs +0 -1
- package/dist/tools-DFOsOboy.mjs +0 -1
package/dist/services/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{TurnStorageNamespace as e,TurnStorageSubjects as t}from"./turn/namespace.mjs";import{agents as n,sessions as r}from"./session/storage/schema.mjs";import{n as i,t as a}from"../schema-DHlTAy0N.mjs";import{t as o}from"../schema-D6WAI8OL.mjs";import{i as s,n as c,r as l,t as u}from"../namespace-C-piH3w4.mjs";import{SessionStorageNamespace as d,SessionStorageSubjects as f}from"./session/storage/namespace.mjs";import{A as p,C as m,D as h,E as ee,F as g,M as te,N as ne,O as re,P as _,S as ie,T as ae,_ as oe,a as se,b as ce,c as le,d as ue,f as de,g as fe,h as pe,i as me,j as he,k as ge,l as _e,m as ve,n as ye,o as be,p as xe,r as Se,s as Ce,t as we,u as Te,v as Ee,w as v,x as y,y as b}from"../handlers-BAycjV02.mjs";import{A as x,B as S,C,E as w,F as T,G as E,H as D,I as De,J as Oe,K as ke,L as Ae,M as je,N as Me,O as Ne,P as Pe,R as Fe,S as Ie,T as Le,U as Re,V as ze,W as Be,X as Ve,Y as He,_ as Ue,a as We,b as Ge,c as Ke,d as qe,g as Je,h as Ye,i as Xe,j as Ze,k as Qe,l as $e,m as et,o as tt,p as nt,q as rt,r as it,s as at,t as ot,u as st,v as ct,w as lt,x as ut,y as dt,z as ft}from"../session-0nWT4st6.mjs";import{t as pt}from"../namespace-DBHwyhME.mjs";import{n as mt,r as ht,t as gt}from"../provider-context-DC_eq7es.mjs";import{AdapterRuntimeSchemas as _t,ResolveIdRequestSchema as vt,ResolveIdResponseSchema as yt,ResolveNameRequestSchema as bt,ResolveNameResponseSchema as xt}from"./adapter-runtime/schemas.mjs";import{AdapterRuntimeNamespace as O,AdapterRuntimeSubjects as St}from"./adapter-runtime/namespace.mjs";import{ProviderStorageNamespace as Ct}from"./settings/storage/providers-namespace.mjs";import{ContainerIsolatedExecutionTargetSchema as wt,ContainerLocalExecutionTargetSchema as Tt,ExecutionTargetInputSchema as Et,ExecutionTargetListQuerySchema as Dt,ExecutionTargetResolveRequestSchema as Ot,ExecutionTargetSchema as kt,ExecutionTargetSchemas as At,ExecutionTargetTypeSchema as jt,LocalExecutionTargetSchema as Mt}from"./execution-target/schemas.mjs";import{ExecutionTargetNamespace as k,ExecutionTargetSubjects as Nt}from"./execution-target/namespace.mjs";import{MessageStorageNamespace as Pt,MessageStorageSubjects as Ft}from"./session/messages/namespace.mjs";import{TurnStorageNamespace as It}from"./session/turns/namespace.mjs";import{BugEntrySchema as Lt,CompressRequestSchema as Rt,CompressResponseSchema as zt,CompressionEventSchema as Bt,CompressionSchemas as Vt,ExtractedContextSchema as Ht,TechnicalDetailsSchema as Ut,TodoEntrySchema as Wt}from"./compression/schemas.mjs";import{PreferenceItemSchema as Gt,PreferenceKeySchema as Kt,PreferenceValueSchema as qt,PreferencesSchemas as Jt}from"./preferences/schemas.mjs";import{PreferencesNamespace as A,PreferencesSubjects as Yt}from"./preferences/storage-namespace.mjs";import{t as Xt}from"../namespace-wke7juzy.mjs";import{A as Zt,B as Qt,C as $t,D as en,E as tn,F as nn,G as rn,H as an,I as on,J as sn,K as cn,L as ln,M as un,N as dn,O as fn,P as pn,R as mn,S as hn,T as gn,U as _n,V as vn,W as yn,Y as bn,_ as xn,a as j,b as Sn,c as Cn,d as wn,f as M,g as N,h as Tn,i as P,j as En,k as Dn,l as On,m as kn,o as An,p as F,q as jn,r as Mn,s as I,u as Nn,v as L,w as Pn,x as Fn,y as In,z as Ln}from"../tools-DFOsOboy.mjs";import{t as Rn}from"../capability-service-XlymTzz1.mjs";import{a as zn,c as Bn,i as Vn,l as Hn,n as Un,o as R,r as Wn,s as Gn,t as Kn,u as qn}from"../model-registry-rYICIwyR.mjs";import{t as Jn}from"../tool-approval-service-DEQiipxj.mjs";import{TrayMenuEntrySchema as Yn,TrayMenuGroupEntrySchema as Xn,TrayMenuGroupSchema as Zn,TrayMenuItemClickedSchema as Qn,TrayMenuListEntrySchema as $n,TrayMenuMetadataSchema as er,TrayMenuSchemas as tr,TrayMenuSectionSchema as nr}from"./tray-menu/schemas.mjs";import{TrayMenuNamespace as z,TrayMenuSubjects as rr}from"./tray-menu/namespace.mjs";import{t as ir}from"../tray-menu-service-B2AxiQqL.mjs";import{n as ar}from"../handler-2bPhRn0u.mjs";import{i as or,n as sr,r as cr,t as lr}from"../package-CF_Zm2v4.mjs";import{FsNamespace as ur}from"./filesystem/namespace.mjs";import"./capability/index.mjs";import"./tool-approval/index.mjs";import"./tray-menu/index.mjs";import"./subagent/index.mjs";import{AgentInstanceStatusSchema as dr,AgentRuntimeSchemas as fr,AgentRuntimeSelectionSchema as pr}from"./agent-runtime/schemas.mjs";import{AgentRuntimeNamespace as B,AgentRuntimeSubjects as mr}from"./agent-runtime/namespace.mjs";import{CodebaseChangedEventSchema as hr,CodebaseSchemas as gr}from"./codebase/schemas.mjs";import{CodebaseNamespace as V,CodebaseSubjects as _r}from"./codebase/namespace.mjs";import{CompressionNamespace as H,CompressionSubjects as vr}from"./compression/namespace.mjs";import{r as yr,t as br}from"../storage-namespace-D5q9CrBp.mjs";import{DefinitionNamespace as xr}from"./definition/namespace.mjs";import{DialogNamespace as Sr}from"./dialog/namespace.mjs";import{_ as Cr,c as wr,d as Tr,f as Er,g as Dr,h as Or,i as kr,l as Ar,m as jr,n as Mr,o as Nr,p as Pr,r as U,s as Fr,t as Ir,u as Lr,v as Rr,y as zr}from"../execution-target-BR8bLkCR.mjs";import{CLIDetectionNamespace as Br}from"./cli-detection/namespace.mjs";import{LocalNotificationNamespace as Vr}from"./local-notification/namespace.mjs";import{t as Hr}from"../namespace-CVMZVqB5.mjs";import{ExtensionConfigStorageNamespace as Ur}from"./settings/storage/extension-configs/namespace.mjs";import{ClientStorageNamespace as Wr}from"./settings/storage/clients-namespace.mjs";import{SubagentTemplateCompletedEventSchema as Gr,SubagentTemplateCreateSchema as Kr,SubagentTemplateInstanceSchema as qr,SubagentTemplateInstanceStatusSchema as Jr,SubagentTemplateKernelSchemas as Yr,SubagentTemplateSchema as Xr,SubagentTemplateSettingsSchemas as Zr,SubagentTemplateSpawnRequestSchema as Qr,SubagentTemplateSpawnedEventSchema as $r,SubagentTemplateSummarySchema as ei,SubagentTemplateUpdateSchema as ti}from"./subagent-template/schemas.mjs";import{r as ni,t as ri}from"../namespace-BO3tODGC.mjs";import{SubagentTemplateKernelNamespace as W,SubagentTemplateSubjects as ii}from"./subagent-template/namespace.mjs";import{i as ai,n as oi,r as si,t as ci}from"../identity-BarL3JYI.mjs";import"./adapter-runtime/index.mjs";import"./agent-runtime/index.mjs";import"./codebase/index.mjs";import"./compression/index.mjs";import"./preferences/index.mjs";import"./subagent-template/index.mjs";import{ArtifactSubjects as li}from"@makaio/framework/contracts";import{ImportCursorStorageNamespace as ui}from"@makaio/framework/adapters";import{ModelRegistryPublicNamespace as di}from"@makaio/framework/contracts/model-registry";function fi(e){return{source:`extension`,ownerKey:`extension:${e}`}}function pi(e,t){for(let n of e.values())if(n.registry===t)for(let e of n.registrations)t.registerKind(e,n.owner)}function mi(){let e=new Map,t=t=>{let n=e.get(t);if(n){e.delete(t);for(let e=n.registrations.length-1;e>=0;--e){let t=n.registrations[e];n.registry.deregisterKind(t.kind,t.schemaVersion,n.owner)}pi(e,n.registry)}};return{filter:e=>(e.artifactKinds?.kinds?.length??0)>0,async processActivated(n,r,i){let a=i.getService(j);if(!a)throw Error(`ArtifactSchemaRegistry is not available — ensure artifact-schema-registry is started before extensions with artifactKinds.`);let o=(r.artifactKinds?.kinds??[]).map(e=>e.toRegistration()),s=fi(n);t(n);for(let e of o)a.registerKind(e,s);e.set(n,{registry:a,owner:s,registrations:o})},async processStopped(e){try{t(e)}catch(t){console.error(`[ArtifactContributionProcessor] Deregister error for "${e}":`,t)}}}}function hi(e,t,n){return{...n,filter:{...n.filter,kind:e,schemaVersion:t}}}function gi(){let e=new Map,t=t=>{let n=e.get(t);n&&(e.delete(t),n.cleanup())};return{filter:e=>{let t=e.artifactLifecycleHooks!=null,n=(e.artifactKinds?.kinds??[]).some(e=>(e.hooks?.hooks.length??0)>0);return t||n},async processActivated(n,r,i){let a=i.getService(P);if(!a)throw Error(`ArtifactLifecycleHookRegistry is not available — ensure artifact-lifecycle-hook-registry is started before extensions with artifact lifecycle hooks.`);let o=r.artifactLifecycleHooks?[...await r.artifactLifecycleHooks.createHooks({bus:i.bus,extensionName:n})]:[],s=[];for(let e of r.artifactKinds?.kinds??[])if(e.hooks)for(let t of e.hooks.hooks)s.push(hi(e.kind,e.schemaVersion,t));let c=[...o,...s];t(n);let l=a.registerHooks(n,c);e.set(n,{cleanup:l})},async processStopped(e){try{t(e)}catch(t){console.error(`[ArtifactLifecycleHookContributionProcessor] Deregister error for "${e}":`,t)}}}}async function _i(e){let t=e.maxDepth??5,n={bus:e.bus,kindRegistry:e.kindRegistry,maxDepth:t,resolvedByKey:new Map,kindDefaultsCache:new Map,walkedByKey:new Set,refIndexByKey:new Map,resolved:[],refs:[]},r=await K(n,e.ref);if(!r)throw Error(`artifact.resolveContext: root artifact '${e.ref.kind}:${e.ref.id}:${e.ref.revision}' not found`);return n.resolved.push(r),await G(n,r,J(await q(n,r),e.selectors),0,new Set([Z(e.ref)])),{rootRef:e.ref,refs:n.refs,resolved:n.resolved}}async function G(e,t,n,r,i){let a=wi(t,n,r,i);if(e.walkedByKey.has(a))return;e.walkedByKey.add(a);let o=xi(t);for(let a of t.relations)await vi(e,o,a,n,r,i)}async function vi(e,t,n,r,i,a){let o=r?.[n.type];if(o?.hint===`omit`)return;let s=o?.hint??`link`;if(!yi(o,n.target)){X(e,Y(t,n,s,`not-selected`));return}if(n.target.refClass!==`artifact`){X(e,Y(t,n,s,`unsupported-ref-class`));return}let c=Z(n.target),l=a.has(c);if(i>=e.maxDepth&&!l){X(e,Y(t,n,s,`depth-exceeded`));return}let u=e.resolvedByKey.has(c),d=await K(e,n.target);if(!d){X(e,Y(t,n,s,`not-found`));return}if(X(e,{sourceRef:t,target:n.target,relationType:n.type,hint:s,status:`resolved`}),u||e.resolved.push(d),l)return;let f=(o.depth??1)-1,p=f>0?{[n.type]:{...o,depth:f}}:void 0,m=J(J(await q(e,d),p),o.nested),h=new Set(a);h.add(c),await G(e,d,m,i+1,h)}async function K(e,t){let n=Z(t);if(e.resolvedByKey.has(n))return e.resolvedByKey.get(n)??null;let{artifact:r}=await e.bus.request(li.resolve,{ref:t});return e.resolvedByKey.set(n,r),r}async function q(e,t){let n=JSON.stringify([t.kind,t.schemaVersion]);if(e.kindDefaultsCache.has(n))return e.kindDefaultsCache.get(n);let r=(await e.kindRegistry.getKind(t.kind,t.schemaVersion))?.defaultContext;return e.kindDefaultsCache.set(n,r),r}function J(e,t){if(!t)return e;if(!e)return t;let n={...e};for(let[e,r]of Object.entries(t))n[e]=r;return n}function yi(e,t){return e?e.kinds?e.kinds.includes(bi(t)):!0:!1}function bi(e){return e.refClass===`local`?e.artifact.kind:e.kind}function Y(e,t,n,r){return{sourceRef:e,target:t.target,relationType:t.type,hint:n,status:`unresolved`,reason:r}}function X(e,t){let n=Si(t),r=e.refIndexByKey.get(n);if(r===void 0){e.refIndexByKey.set(n,e.refs.length),e.refs.push(t);return}t.status===`resolved`&&e.refs[r]?.status===`unresolved`&&(e.refs[r]=t)}function xi(e){return{refClass:`artifact`,kind:e.kind,id:e.id,revision:e.revision}}function Z(e){return JSON.stringify([e.kind,e.id,e.revision])}function Si(e){return JSON.stringify([Z(e.sourceRef),e.relationType,Ci(e.target)])}function Ci(e){return e.refClass===`artifact`?JSON.stringify([`artifact`,e.kind,e.id,e.revision]):e.refClass===`local`?JSON.stringify([`local`,Z(e.artifact),e.localId]):JSON.stringify([`evidence`,e.kind,e.id,e.revision??null,e.locator??null])}function wi(e,t,n,r){return JSON.stringify([e.kind,e.id,e.revision,n,t??null,[...r].sort()])}function Q(e,t){for(let n of e.values())if(n.registry===t)for(let e of n.registrations)t.registerNamespace(e)}function Ti(){let e=new Map,t=(t,n)=>{if(n){for(let e of n.registrations)n.registry.registerNamespace(e);e.set(t,n)}},n=t=>{let n=e.get(t);if(n){e.delete(t);for(let e=n.registrations.length-1;e>=0;--e){let t=n.registrations[e];n.registry.deregisterNamespace(t.namespace)}Q(e,n.registry)}};return{filter:e=>(e.facetNamespaces?.namespaces?.length??0)>0,async processActivated(r,i,a){let o=a.getService(I);if(!o)throw Error(`FacetNamespaceRegistry is not available — ensure facet-namespace-registry is started before extensions with facetNamespaces.`);let s=(i.facetNamespaces?.namespaces??[]).map(e=>e.toRegistration()),c=e.get(r);n(r);let l=[];try{for(let e of s)o.registerNamespace(e),l.push(e)}catch(n){for(let e=l.length-1;e>=0;--e)o.deregisterNamespace(l[e].namespace);throw Q(e,o),t(r,c),n}e.set(r,{registry:o,registrations:s})},async processStopped(e){try{n(e)}catch(t){console.error(`[FacetNamespaceContributionProcessor] Deregister error for "${e}":`,t)}}}}function $(e,t){for(let n of e.values())if(n.registry===t)for(let e of n.registrations)t.registerBinding(e)}function Ei(){let e=new Map,t=(t,n)=>{if(n){for(let e of n.registrations)n.registry.registerBinding(e);e.set(t,n)}},n=t=>{let n=e.get(t);if(n){e.delete(t);for(let e=n.registrations.length-1;e>=0;--e){let t=n.registrations[e];n.registry.deregisterBinding(t.id)}$(e,n.registry)}};return{filter:e=>(e.surfaceBindings?.bindings?.length??0)>0,async processActivated(r,i,a){let o=a.getService(F);if(!o)throw Error(`SurfaceBindingRegistry is not available — ensure surface-binding-registry is started before extensions with surfaceBindings.`);let s=(i.surfaceBindings?.bindings??[]).map(e=>e.toRegistration()),c=e.get(r);n(r);let l=[];try{for(let e of s)o.registerBinding(e),l.push(e)}catch(n){for(let e=l.length-1;e>=0;--e)o.deregisterBinding(l[e].id);throw $(e,o),t(r,c),n}e.set(r,{registry:o,registrations:s})},async processStopped(e){try{n(e)}catch(t){console.error(`[SurfaceBindingContributionProcessor] Deregister error for "${e}":`,t)}}}}function Di(){let e=new Map;return{filter:e=>!!e.workflowBlocks?.blocks,async processActivated(t,n,r){let i=r.getService(L);if(!i)throw Error(`WorkflowBlockRegistry is not available — ensure workflow-block-registry is started before extensions with workflowBlocks.`);await i.register(t,n.workflowBlocks.blocks),e.set(t,()=>i.deregister(t))},async processStopped(t){let n=e.get(t);if(n){try{await n()}catch(e){console.error(`[WorkflowBlockContributionProcessor] Deregister error for "${t}":`,e)}e.delete(t)}}}}function Oi(){let e=new Map;return{filter:e=>!!(e.transitionRules?.rules?.length||e.transitionActions?.actions),async processActivated(t,n,r){let i=r.getService(N);if(!i)throw Error(`TransitionContributionProcessor: TransitionPipelineService is not available — ensure '${N.name}' is started before extensions with transitionRules or transitionActions.`);let a=n.transitionRules?.rules??[],o=n.transitionActions?.actions,s=a.length>0,c=o!==void 0;s&&ki(t,a),c&&Ai(t,o);let l=!1,u=!1;try{s&&(i.ruleRegistry.register(t,a),l=!0),c&&(i.actionRegistry.register(t,o),u=!0)}catch(e){throw l&&i.ruleRegistry.deregister(t),u&&i.actionRegistry.deregister(t),e}e.set(t,()=>{s&&i.ruleRegistry.deregister(t),c&&i.actionRegistry.deregister(t)})},async processStopped(t){let n=e.get(t);if(n){try{n()}catch(e){console.error(`[TransitionContributionProcessor] Deregister error for "${t}":`,e)}e.delete(t)}}}}function ki(e,t){let n=`${e}.`;for(let e of t)if(!e.id.startsWith(n))throw Error(`TransitionContributionProcessor: rule '${e.id}' must be namespaced by extension '${n}'`)}function Ai(e,t){let n=`${e}.`;for(let e of Object.keys(t))if(!e.startsWith(n))throw Error(`TransitionContributionProcessor: action type '${e}' must be namespaced by extension '${n}'`)}const ji=[O,pt,B,_,Br,Wr,V,H,yr,br,xr,Sr,U,k,Ur,ur,ar,ui,Vr,S,R,di,A,Hr,Ct,Xt,ri,z,e,W,ni];export{ci as AdapterIdentityRegistry,Oe as AdapterRegistry,O as AdapterRuntimeNamespace,_t as AdapterRuntimeSchemas,St as AdapterRuntimeSubjects,dr as AgentInstanceStatusSchema,B as AgentRuntimeNamespace,fr as AgentRuntimeSchemas,pr as AgentRuntimeSelectionSchema,mr as AgentRuntimeSubjects,_ as AgentStorageNamespace,g as AgentStorageSubjects,jn as ArtifactLifecycleHookRegistry,P as ArtifactLifecycleHookRegistryToken,sn as ArtifactLifecycleHookRejectedError,bn as ArtifactSchemaRegistry,j as ArtifactSchemaRegistryToken,Lt as BugEntrySchema,je as CONNECTOR_SWAP_DEFAULT_PIPELINE,Kn as CachedRegistryFetcher,yn as CanonicalModelResolutionError,_n as CanonicalModelResolver,an as CanonicalModelService,Rn as CapabilityService,An as CapabilityToken,hr as CodebaseChangedEventSchema,V as CodebaseNamespace,gr as CodebaseSchemas,_r as CodebaseSubjects,Rt as CompressRequestSchema,zt as CompressResponseSchema,Bt as CompressionEventSchema,H as CompressionNamespace,Vt as CompressionSchemas,vr as CompressionSubjects,Nr as ContainerCreatedSchema,Fr as ContainerDestroyedSchema,wt as ContainerIsolatedExecutionTargetSchema,wr as ContainerIsolatedSpawnRequestSchema,Tt as ContainerLocalExecutionTargetSchema,Ar as ContainerLocalSpawnRequestSchema,Lr as ContainerRuntimeSchema,Ir as ContainerSpawnNamespace,Mr as ContainerSpawnSubjects,Tr as ContainerStartedSchema,Er as ContainerStateSchema,Pr as ContainerStoppedSchema,ot as ContextWindowTracker,U as DockerNamespace,kr as DockerSubjects,at as EmbeddingIndexManager,Et as ExecutionTargetInputSchema,Dt as ExecutionTargetListQuerySchema,k as ExecutionTargetNamespace,Ot as ExecutionTargetResolveRequestSchema,kt as ExecutionTargetSchema,At as ExecutionTargetSchemas,Nt as ExecutionTargetSubjects,jt as ExecutionTargetTypeSchema,Ht as ExtractedContextSchema,cn as FacetNamespaceRegistry,I as FacetNamespaceRegistryToken,Un as FallbackRegistryFetcher,ji as FrameworkServicesCoreNamespaces,Mt as LocalExecutionTargetSchema,tt as MakaioSession,He as MakaioSessionService,S as MessageRoutingNamespace,ze as MessageRoutingSubjects,Pt as MessageStorageNamespace,Ft as MessageStorageSubjects,R as ModelRegistryNamespace,Wn as ModelRegistryProviderNotFoundError,Bn as ModelRegistrySchema,Hn as ModelRegistrySchemas,Vn as ModelRegistryService,Gn as ModelRegistrySubjects,Cn as ModelRegistryToken,Gt as PreferenceItemSchema,Kt as PreferenceKeySchema,qt as PreferenceValueSchema,A as PreferencesNamespace,Jt as PreferencesSchemas,Yt as PreferencesSubjects,qn as ProviderModelOverrideSchema,vt as ResolveIdRequestSchema,yt as ResolveIdResponseSchema,bt as ResolveNameRequestSchema,xt as ResolveNameResponseSchema,x as SessionBridge,On as SessionBridgeToken,u as SessionEventStorageNamespace,c as SessionEventStorageSubjects,Ne as SessionExtensionContextImpl,qe as SessionLogger,Ae as SessionOrchestrator,Nn as SessionOrchestratorToken,d as SessionStorageNamespace,f as SessionStorageSubjects,wn as SessionStorageToken,M as SessionToken,Fe as SessionTurnManager,jr as SpawnRequestSchema,Or as SpawnResponseSchema,Dr as StatusRequestSchema,Cr as StatusResponseSchema,Rr as StopRequestSchema,zr as StopResponseSchema,or as SubagentManager,cr as SubagentService,lr as SubagentServiceToken,Gr as SubagentTemplateCompletedEventSchema,Kr as SubagentTemplateCreateSchema,qr as SubagentTemplateInstanceSchema,Jr as SubagentTemplateInstanceStatusSchema,W as SubagentTemplateKernelNamespace,Yr as SubagentTemplateKernelSchemas,Xr as SubagentTemplateSchema,Zr as SubagentTemplateSettingsSchemas,Qr as SubagentTemplateSpawnRequestSchema,$r as SubagentTemplateSpawnedEventSchema,ii as SubagentTemplateSubjects,ei as SubagentTemplateSummarySchema,ti as SubagentTemplateUpdateSchema,rn as SurfaceBindingRegistry,F as SurfaceBindingRegistryToken,Ut as TechnicalDetailsSchema,Wt as TodoEntrySchema,Jn as ToolApprovalService,kn as ToolApprovalToken,Qt as ToolRegistry,Tn as ToolRegistryToken,ln as TransitionActionRegistry,nn as TransitionPipelineService,N as TransitionPipelineToken,on as TransitionRuleRegistry,Yn as TrayMenuEntrySchema,Xn as TrayMenuGroupEntrySchema,Zn as TrayMenuGroupSchema,Qn as TrayMenuItemClickedSchema,$n as TrayMenuListEntrySchema,er as TrayMenuMetadataSchema,z as TrayMenuNamespace,tr as TrayMenuSchemas,nr as TrayMenuSectionSchema,ir as TrayMenuService,rr as TrayMenuSubjects,xn as TrayMenuToken,b as Turn,De as TurnContextEnricher,It as TurnStorageNamespace,t as TurnStorageSubjects,mn as WORKFLOW_START_ACTION_TYPE,Ln as WorkflowBlockRegistry,L as WorkflowBlockRegistryToken,ge as actionRegistry,gt as activateProviderContext,mt as activateProviderContextStrict,n as agents,In as artifactLifecycleHookRegistryPackage,Sn as artifactSchemaRegistryPackage,ye as assembleForkContext,oi as buildDeterministicAdapterId,ht as buildProviderContext,h as buildRecoveryContext,ie as buildRecoveryContextWithPipeline,p as buildSessionContext,xe as buildTurnInitiator,vn as canonicalModelPackage,Fn as capabilityPackage,mi as createArtifactKindContributionProcessor,gi as createArtifactLifecycleHookContributionProcessor,Ti as createFacetNamespaceContributionProcessor,hn as createModelRegistryPackage,Qe as createSessionExtensionContext,Ei as createSurfaceBindingContributionProcessor,Mn as createToolContributionProcessor,Oi as createTransitionContributionProcessor,Di as createWorkflowBlockContributionProcessor,m as ensureAgentCwd,v as ensureAgentModel,oe as extractTextContent,$t as facetNamespaceRegistryPackage,et as fetchAgentsBySession,Ye as fetchMessageCountsBySession,Je as fetchPreviewBySession,ut as fetchSessionPreviewMaps,ve as findTurnByAgent,Pn as frameworkCorePackages,re as getFullConversation,pe as getOrCreateSession,$e as importCursors,st as importCursorsDual,w as kindToBranchKind,Ie as mapAgentsBySession,Ue as mapRowToSession,C as mapToSession,zn as mergeModelMetadata,D as messageRouting,Re as messageRoutingDual,o as messages,ue as normalizeSelectionString,Ee as normalizeToBlocks,ct as parseForkTransforms,Ze as pickFallbackRuntimeOptions,ae as recoverAgent,le as registerAbandonHandler,si as registerAdapterRuntimeIdentityHandlers,Te as registerAttachHandler,be as registerBuiltInActions,se as registerCompressHandler,Xe as registerCompressLineageResolver,Ve as registerCoreSessionServiceHandlers,lt as registerDrizzleAgentStorage,Ke as registerDrizzleImportCursorStorage,ft as registerDrizzleMessageRoutingStorage,E as registerDrizzleMessageStorage,ke as registerDrizzleSessionEventStorage,Ge as registerDrizzleSessionStorage,y as registerDrizzleTurnStorage,me as registerForkHandler,nt as registerFtsSearchHandler,Pe as registerGetStatusCountsHandler,Me as registerListActionsHandler,dt as registerMemoryAgentStorage,Be as registerMemoryMessageStorage,rt as registerMemorySessionEventStorage,Le as registerMemorySessionStorage,ce as registerMemoryTurnStorage,Se as registerMergeHandler,We as registerParentResolver,T as registerResumeHandler,it as registerSpawningToolCallResolver,Ce as resetBuiltInActionsRegistration,he as resolveAdapterId,de as resolveAdapterNameById,_i as resolveArtifactContext,ai as resolveDeterministicAdapterId,te as resolveExecutionTarget,ne as resolveModelCapabilities,fe as resolveTargetAgents,we as routeToAgents,_e as routeToAgentsCore,gn as sessionBridgePackage,l as sessionEvents,s as sessionEventsDual,tn as sessionOrchestratorPackage,en as sessionPackage,fn as sessionStoragePackage,r as sessions,sr as subagentServicePackage,Dn as surfaceBindingRegistryPackage,Zt as toolApprovalPackage,En as toolRegistryPackage,un as transitionPipelinePackage,dn as trayMenuPackage,a as turns,i as turnsDual,ee as verifyAndRecoverAgents,pn as workflowBlockRegistryPackage};
|
|
1
|
+
import{agents as e,sessions as t}from"./session/storage/schema.mjs";import{n,t as r}from"../schema-CHp6I33k.mjs";import{t as i}from"../schema-7aKBGB7S.mjs";import{i as a,n as o,r as s,t as c}from"../namespace-dFBD2ZmS.mjs";import{A as l,B as u,C as d,D as f,E as p,F as m,I as h,M as ee,N as te,O as ne,P as re,T as ie,V as ae,_ as oe,a as se,b as ce,c as le,d as ue,f as de,g as fe,h as pe,i as me,j as he,k as ge,l as _e,m as ve,n as ye,o as be,p as xe,r as Se,s as Ce,t as we,u as Te,v as Ee,w as De,x as Oe,y as ke}from"../handlers-B74FvKlA.mjs";import{TurnStorageNamespace as Ae,TurnStorageSubjects as je}from"./turn/namespace.mjs";import{SessionStorageNamespace as Me,SessionStorageSubjects as Ne}from"./session/storage/namespace.mjs";import{$ as g,A as _,B as v,C as y,D as b,E as Pe,F as Fe,G as Ie,H as Le,I as Re,J as ze,K as x,L as Be,M as Ve,O as He,P as Ue,Q as We,R as Ge,S as Ke,T as qe,U as Je,V as Ye,W as Xe,X as Ze,Y as Qe,Z as $e,a as et,b as tt,c as nt,et as rt,i as it,j as at,k as ot,l as st,o as ct,q as lt,r as ut,s as dt,t as ft,u as pt,w as mt,x as ht,y as gt,z as _t}from"../session-CZUrp7gC.mjs";import{t as vt}from"../namespace-DBHwyhME.mjs";import{n as yt,r as bt,t as xt}from"../provider-context-DC_eq7es.mjs";import{AdapterRuntimeSchemas as St,ResolveIdRequestSchema as Ct,ResolveIdResponseSchema as wt,ResolveNameRequestSchema as Tt,ResolveNameResponseSchema as Et}from"./adapter-runtime/schemas.mjs";import{AdapterRuntimeNamespace as S,AdapterRuntimeSubjects as Dt}from"./adapter-runtime/namespace.mjs";import{ProviderStorageNamespace as Ot}from"./settings/storage/providers-namespace.mjs";import{ContainerIsolatedExecutionTargetSchema as kt,ContainerLocalExecutionTargetSchema as At,ExecutionTargetInputSchema as jt,ExecutionTargetListQuerySchema as Mt,ExecutionTargetResolveRequestSchema as Nt,ExecutionTargetSchema as Pt,ExecutionTargetSchemas as Ft,ExecutionTargetTypeSchema as It,LocalExecutionTargetSchema as Lt}from"./execution-target/schemas.mjs";import{ExecutionTargetNamespace as C,ExecutionTargetSubjects as Rt}from"./execution-target/namespace.mjs";import{MessageStorageNamespace as zt,MessageStorageSubjects as Bt}from"./session/messages/namespace.mjs";import{TurnStorageNamespace as Vt}from"./session/turns/namespace.mjs";import{BugEntrySchema as Ht,CompressRequestSchema as Ut,CompressResponseSchema as Wt,CompressionEventSchema as Gt,CompressionSchemas as Kt,ExtractedContextSchema as qt,TechnicalDetailsSchema as Jt,TodoEntrySchema as Yt}from"./compression/schemas.mjs";import{PreferenceItemSchema as Xt,PreferenceKeySchema as Zt,PreferenceValueSchema as Qt,PreferencesSchemas as $t}from"./preferences/schemas.mjs";import{PreferencesNamespace as w,PreferencesSubjects as en}from"./preferences/storage-namespace.mjs";import{t as tn}from"../namespace-wke7juzy.mjs";import{A as nn,B as rn,C as an,D as on,E as sn,F as cn,G as ln,H as un,I as dn,J as fn,K as pn,L as mn,M as hn,N as gn,O as _n,P as vn,R as yn,S as bn,T as xn,U as Sn,V as Cn,W as wn,Y as Tn,_ as En,a as T,b as Dn,c as On,d as kn,f as An,g as E,h as jn,i as D,j as Mn,k as O,l as Nn,m as Pn,o as Fn,p as k,q as In,r as Ln,s as A,u as Rn,v as j,w as zn,x as Bn,y as Vn,z as Hn}from"../tools-Yz8XyiwA.mjs";import{t as Un}from"../capability-service-XlymTzz1.mjs";import{a as Wn,c as Gn,i as Kn,l as qn,n as Jn,o as M,r as Yn,s as Xn,t as Zn,u as Qn}from"../model-registry-rYICIwyR.mjs";import{t as $n}from"../tool-approval-service-BIbUSuqg.mjs";import{TrayMenuEntrySchema as er,TrayMenuGroupEntrySchema as tr,TrayMenuGroupSchema as nr,TrayMenuItemClickedSchema as rr,TrayMenuListEntrySchema as ir,TrayMenuMetadataSchema as ar,TrayMenuSchemas as or,TrayMenuSectionSchema as sr}from"./tray-menu/schemas.mjs";import{TrayMenuNamespace as N,TrayMenuSubjects as cr}from"./tray-menu/namespace.mjs";import{t as lr}from"../tray-menu-service-B2AxiQqL.mjs";import{n as ur}from"../handler-BFNvtv5t.mjs";import{i as dr,n as fr,r as pr,t as mr}from"../package-CF_Zm2v4.mjs";import{FsNamespace as hr}from"./filesystem/namespace.mjs";import"./capability/index.mjs";import"./tool-approval/index.mjs";import"./tray-menu/index.mjs";import"./subagent/index.mjs";import{AgentInstanceStatusSchema as gr,AgentRuntimeSchemas as _r,AgentRuntimeSelectionSchema as vr}from"./agent-runtime/schemas.mjs";import{AgentRuntimeNamespace as P,AgentRuntimeSubjects as yr}from"./agent-runtime/namespace.mjs";import{CodebaseChangedEventSchema as br,CodebaseSchemas as xr}from"./codebase/schemas.mjs";import{CodebaseNamespace as F,CodebaseSubjects as Sr}from"./codebase/namespace.mjs";import{CompressionNamespace as I,CompressionSubjects as Cr}from"./compression/namespace.mjs";import{r as wr,t as Tr}from"../storage-namespace-D5q9CrBp.mjs";import{DefinitionNamespace as Er}from"./definition/namespace.mjs";import{DialogNamespace as Dr}from"./dialog/namespace.mjs";import{_ as Or,c as kr,d as Ar,f as jr,g as Mr,h as Nr,i as Pr,l as Fr,m as Ir,n as Lr,o as Rr,p as zr,r as L,s as Br,t as Vr,u as Hr,v as Ur,y as Wr}from"../execution-target-BR8bLkCR.mjs";import{CLIDetectionNamespace as Gr}from"./cli-detection/namespace.mjs";import{LocalNotificationNamespace as Kr}from"./local-notification/namespace.mjs";import{t as qr}from"../namespace-CVMZVqB5.mjs";import{ExtensionConfigStorageNamespace as Jr}from"./settings/storage/extension-configs/namespace.mjs";import{ClientStorageNamespace as Yr}from"./settings/storage/clients-namespace.mjs";import{SubagentTemplateCompletedEventSchema as Xr,SubagentTemplateCreateSchema as Zr,SubagentTemplateInstanceSchema as Qr,SubagentTemplateInstanceStatusSchema as $r,SubagentTemplateKernelSchemas as ei,SubagentTemplateSchema as ti,SubagentTemplateSettingsSchemas as ni,SubagentTemplateSpawnRequestSchema as ri,SubagentTemplateSpawnedEventSchema as ii,SubagentTemplateSummarySchema as ai,SubagentTemplateUpdateSchema as oi}from"./subagent-template/schemas.mjs";import{r as si,t as ci}from"../namespace-BO3tODGC.mjs";import{SubagentTemplateKernelNamespace as R,SubagentTemplateSubjects as li}from"./subagent-template/namespace.mjs";import{i as ui,n as di,r as fi,t as pi}from"../identity-DC3Pk0ps.mjs";import"./adapter-runtime/index.mjs";import"./agent-runtime/index.mjs";import"./codebase/index.mjs";import"./compression/index.mjs";import"./preferences/index.mjs";import"./subagent-template/index.mjs";import{ArtifactSubjects as mi}from"@makaio/framework/contracts";import{ImportCursorStorageNamespace as hi}from"@makaio/framework/adapters";import{ModelRegistryPublicNamespace as gi}from"@makaio/framework/contracts/model-registry";function _i(e){return{source:`extension`,ownerKey:`extension:${e}`}}function vi(e,t){for(let n of e.values())if(n.registry===t)for(let e of n.registrations)t.registerKind(e,n.owner)}function yi(){let e=new Map,t=t=>{let n=e.get(t);if(n){e.delete(t);for(let e=n.registrations.length-1;e>=0;--e){let t=n.registrations[e];n.registry.deregisterKind(t.kind,t.schemaVersion,n.owner)}vi(e,n.registry)}};return{filter:e=>(e.artifactKinds?.kinds?.length??0)>0,async processActivated(n,r,i){let a=i.getService(T);if(!a)throw Error(`ArtifactSchemaRegistry is not available — ensure artifact-schema-registry is started before extensions with artifactKinds.`);let o=(r.artifactKinds?.kinds??[]).map(e=>e.toRegistration()),s=_i(n);t(n);for(let e of o)a.registerKind(e,s);e.set(n,{registry:a,owner:s,registrations:o})},async processStopped(e){try{t(e)}catch(t){console.error(`[ArtifactContributionProcessor] Deregister error for "${e}":`,t)}}}}function bi(e,t,n){return{...n,filter:{...n.filter,kind:e,schemaVersion:t}}}function xi(){let e=new Map,t=t=>{let n=e.get(t);n&&(e.delete(t),n.cleanup())};return{filter:e=>{let t=e.artifactLifecycleHooks!=null,n=(e.artifactKinds?.kinds??[]).some(e=>(e.hooks?.hooks.length??0)>0);return t||n},async processActivated(n,r,i){let a=i.getService(D);if(!a)throw Error(`ArtifactLifecycleHookRegistry is not available — ensure artifact-lifecycle-hook-registry is started before extensions with artifact lifecycle hooks.`);let o=r.artifactLifecycleHooks?[...await r.artifactLifecycleHooks.createHooks({bus:i.bus,extensionName:n})]:[],s=[];for(let e of r.artifactKinds?.kinds??[])if(e.hooks)for(let t of e.hooks.hooks)s.push(bi(e.kind,e.schemaVersion,t));let c=[...o,...s];t(n);let l=a.registerHooks(n,c);e.set(n,{cleanup:l})},async processStopped(e){try{t(e)}catch(t){console.error(`[ArtifactLifecycleHookContributionProcessor] Deregister error for "${e}":`,t)}}}}async function Si(e){let t=e.maxDepth??5,n={bus:e.bus,kindRegistry:e.kindRegistry,maxDepth:t,resolvedByKey:new Map,kindDefaultsCache:new Map,walkedByKey:new Set,refIndexByKey:new Map,refMetadataByKey:new Map,resolved:[],refs:[]},r=await B(n,e.ref);if(!r)throw Error(`artifact.resolveContext: root artifact '${e.ref.kind}:${e.ref.id}:${e.ref.revision}' not found`);return n.resolved.push(r),await z(n,r,H(await V(n,r),e.selectors),0,new Set([Z(e.ref)])),{rootRef:e.ref,refs:n.refs,resolved:n.resolved}}async function z(e,t,n,r,i){let a=Mi(t,n,r,i);if(e.walkedByKey.has(a))return;e.walkedByKey.add(a);let o=ki(t);for(let a of t.relations)await Ci(e,o,a,n,r,i)}async function Ci(e,t,n,r,i,a){let o=r?.[n.type];if(o?.hint===`omit`)return;let s=o?.hint??`link`;if(!wi(o,n.target)){W(e,U(t,n,s,`not-selected`));return}if(n.target.refClass!==`artifact`){W(e,U(t,n,s,`unsupported-ref-class`));return}let c=Z(n.target),l=a.has(c);if(i>=e.maxDepth&&!l){W(e,U(t,n,s,`depth-exceeded`));return}let u=e.resolvedByKey.has(c),d=await B(e,n.target);if(!d){W(e,U(t,n,s,`not-found`));return}if(W(e,{sourceRef:t,target:n.target,relationType:n.type,hint:s,status:`resolved`},{resolvedViaBackEdge:l}),u||e.resolved.push(d),l)return;let f=(o.depth??1)-1,p=f>0?{[n.type]:{...o,depth:f}}:void 0,m=H(H(await V(e,d),p),o.nested),h=new Set(a);h.add(c),await z(e,d,m,i+1,h)}async function B(e,t){let n=Z(t);if(e.resolvedByKey.has(n))return e.resolvedByKey.get(n)??null;let{artifact:r}=await e.bus.request(mi.resolve,{ref:t});return e.resolvedByKey.set(n,r),r}async function V(e,t){let n=JSON.stringify([t.kind,t.schemaVersion]);if(e.kindDefaultsCache.has(n))return e.kindDefaultsCache.get(n);let r=(await e.kindRegistry.getKind(t.kind,t.schemaVersion))?.defaultContext;return e.kindDefaultsCache.set(n,r),r}function H(e,t){if(!t)return e;if(!e)return t;let n={...e};for(let[e,r]of Object.entries(t))n[e]=r;return n}function wi(e,t){return e?e.kinds?e.kinds.includes(Ti(t)):!0:!1}function Ti(e){return e.refClass===`local`?e.artifact.kind:e.kind}function U(e,t,n,r){return{sourceRef:e,target:t.target,relationType:t.type,hint:n,status:`unresolved`,reason:r}}function W(e,t,n){let r=Ai(t),i=e.refIndexByKey.get(r);if(i===void 0){e.refIndexByKey.set(r,e.refs.length),J(e,r,t,n),e.refs.push(t);return}let a=e.refs[i];if(a){if(t.status===`unresolved`&&t.reason===`depth-exceeded`){if(!Ei(a,Oi(e,r)))return;q(e,i,r,t,n);return}if(a.status===`unresolved`&&a.reason===`depth-exceeded`){if(t.status===`resolved`&&X(n)||t.status===`unresolved`&&!G(t.reason,a.reason))return;q(e,i,r,t,n);return}if(t.status===`unresolved`&&a.status===`unresolved`){G(t.reason,a.reason)&&q(e,i,r,t,n);return}if(t.status===`resolved`&&a.status===`unresolved`){q(e,i,r,t,n);return}t.status===`resolved`&&!X(n)&&Y(e,r,n)}}function Ei(e,t){return e.status===`resolved`?t:G(`depth-exceeded`,e.reason)}function G(e,t){return K(e)>K(t)}function K(e){return e===`not-selected`?0:e===`depth-exceeded`?1:2}function q(e,t,n,r,i){J(e,n,r,i),e.refs[t]=r}function J(e,t,n,r){if(n.status===`resolved`){Y(e,t,r);return}Di(e,t)}function Y(e,t,n){e.refMetadataByKey.set(t,n??{resolvedViaBackEdge:!1})}function Di(e,t){e.refMetadataByKey.delete(t)}function Oi(e,t){return X(e.refMetadataByKey.get(t))}function X(e){return e?.resolvedViaBackEdge===!0}function ki(e){return{refClass:`artifact`,kind:e.kind,id:e.id,revision:e.revision}}function Z(e){return JSON.stringify([e.kind,e.id,e.revision])}function Ai(e){return JSON.stringify([Z(e.sourceRef),e.relationType,ji(e.target)])}function ji(e){return e.refClass===`artifact`?JSON.stringify([`artifact`,e.kind,e.id,e.revision]):e.refClass===`local`?JSON.stringify([`local`,Z(e.artifact),e.localId]):JSON.stringify([`evidence`,e.kind,e.id,e.revision??null,e.locator??null])}function Mi(e,t,n,r){return JSON.stringify([e.kind,e.id,e.revision,n,t??null,[...r].sort()])}function Q(e,t){for(let n of e.values())if(n.registry===t)for(let e of n.registrations)t.registerNamespace(e)}function Ni(){let e=new Map,t=(t,n)=>{if(n){for(let e of n.registrations)n.registry.registerNamespace(e);e.set(t,n)}},n=t=>{let n=e.get(t);if(n){e.delete(t);for(let e=n.registrations.length-1;e>=0;--e){let t=n.registrations[e];n.registry.deregisterNamespace(t.namespace)}Q(e,n.registry)}};return{filter:e=>(e.facetNamespaces?.namespaces?.length??0)>0,async processActivated(r,i,a){let o=a.getService(A);if(!o)throw Error(`FacetNamespaceRegistry is not available — ensure facet-namespace-registry is started before extensions with facetNamespaces.`);let s=(i.facetNamespaces?.namespaces??[]).map(e=>e.toRegistration()),c=e.get(r);n(r);let l=[];try{for(let e of s)o.registerNamespace(e),l.push(e)}catch(n){for(let e=l.length-1;e>=0;--e)o.deregisterNamespace(l[e].namespace);throw Q(e,o),t(r,c),n}e.set(r,{registry:o,registrations:s})},async processStopped(e){try{n(e)}catch(t){console.error(`[FacetNamespaceContributionProcessor] Deregister error for "${e}":`,t)}}}}function $(e,t){for(let n of e.values())if(n.registry===t)for(let e of n.registrations)t.registerBinding(e)}function Pi(){let e=new Map,t=(t,n)=>{if(n){for(let e of n.registrations)n.registry.registerBinding(e);e.set(t,n)}},n=t=>{let n=e.get(t);if(n){e.delete(t);for(let e=n.registrations.length-1;e>=0;--e){let t=n.registrations[e];n.registry.deregisterBinding(t.id)}$(e,n.registry)}};return{filter:e=>(e.surfaceBindings?.bindings?.length??0)>0,async processActivated(r,i,a){let o=a.getService(k);if(!o)throw Error(`SurfaceBindingRegistry is not available — ensure surface-binding-registry is started before extensions with surfaceBindings.`);let s=(i.surfaceBindings?.bindings??[]).map(e=>e.toRegistration()),c=e.get(r);n(r);let l=[];try{for(let e of s)o.registerBinding(e),l.push(e)}catch(n){for(let e=l.length-1;e>=0;--e)o.deregisterBinding(l[e].id);throw $(e,o),t(r,c),n}e.set(r,{registry:o,registrations:s})},async processStopped(e){try{n(e)}catch(t){console.error(`[SurfaceBindingContributionProcessor] Deregister error for "${e}":`,t)}}}}function Fi(){let e=new Map;return{filter:e=>!!e.workflowBlocks?.blocks,async processActivated(t,n,r){let i=r.getService(j);if(!i)throw Error(`WorkflowBlockRegistry is not available — ensure workflow-block-registry is started before extensions with workflowBlocks.`);await i.register(t,n.workflowBlocks.blocks),e.set(t,()=>i.deregister(t))},async processStopped(t){let n=e.get(t);if(n){try{await n()}catch(e){console.error(`[WorkflowBlockContributionProcessor] Deregister error for "${t}":`,e)}e.delete(t)}}}}function Ii(){let e=new Map;return{filter:e=>!!(e.transitionRules?.rules?.length||e.transitionActions?.actions),async processActivated(t,n,r){let i=r.getService(E);if(!i)throw Error(`TransitionContributionProcessor: TransitionPipelineService is not available — ensure '${E.name}' is started before extensions with transitionRules or transitionActions.`);let a=n.transitionRules?.rules??[],o=n.transitionActions?.actions,s=a.length>0,c=o!==void 0;s&&Li(t,a),c&&Ri(t,o);let l=!1,u=!1;try{s&&(i.ruleRegistry.register(t,a),l=!0),c&&(i.actionRegistry.register(t,o),u=!0)}catch(e){throw l&&i.ruleRegistry.deregister(t),u&&i.actionRegistry.deregister(t),e}e.set(t,()=>{s&&i.ruleRegistry.deregister(t),c&&i.actionRegistry.deregister(t)})},async processStopped(t){let n=e.get(t);if(n){try{n()}catch(e){console.error(`[TransitionContributionProcessor] Deregister error for "${t}":`,e)}e.delete(t)}}}}function Li(e,t){let n=`${e}.`;for(let e of t)if(!e.id.startsWith(n))throw Error(`TransitionContributionProcessor: rule '${e.id}' must be namespaced by extension '${n}'`)}function Ri(e,t){let n=`${e}.`;for(let e of Object.keys(t))if(!e.startsWith(n))throw Error(`TransitionContributionProcessor: action type '${e}' must be namespaced by extension '${n}'`)}const zi=[S,vt,P,m,Gr,Yr,F,I,wr,Tr,Er,Dr,L,C,Jr,hr,ur,hi,Kr,x,M,gi,w,qr,Ot,tn,ci,N,Ae,R,si];export{pi as AdapterIdentityRegistry,We as AdapterRegistry,S as AdapterRuntimeNamespace,St as AdapterRuntimeSchemas,Dt as AdapterRuntimeSubjects,gr as AgentInstanceStatusSchema,P as AgentRuntimeNamespace,_r as AgentRuntimeSchemas,vr as AgentRuntimeSelectionSchema,yr as AgentRuntimeSubjects,m as AgentStorageNamespace,h as AgentStorageSubjects,In as ArtifactLifecycleHookRegistry,D as ArtifactLifecycleHookRegistryToken,fn as ArtifactLifecycleHookRejectedError,Tn as ArtifactSchemaRegistry,T as ArtifactSchemaRegistryToken,Ht as BugEntrySchema,Ge as CONNECTOR_SWAP_DEFAULT_PIPELINE,Zn as CachedRegistryFetcher,wn as CanonicalModelResolutionError,Sn as CanonicalModelResolver,un as CanonicalModelService,Un as CapabilityService,Fn as CapabilityToken,br as CodebaseChangedEventSchema,F as CodebaseNamespace,xr as CodebaseSchemas,Sr as CodebaseSubjects,Ut as CompressRequestSchema,Wt as CompressResponseSchema,Gt as CompressionEventSchema,I as CompressionNamespace,Kt as CompressionSchemas,Cr as CompressionSubjects,Rr as ContainerCreatedSchema,Br as ContainerDestroyedSchema,kt as ContainerIsolatedExecutionTargetSchema,kr as ContainerIsolatedSpawnRequestSchema,At as ContainerLocalExecutionTargetSchema,Fr as ContainerLocalSpawnRequestSchema,Hr as ContainerRuntimeSchema,Vr as ContainerSpawnNamespace,Lr as ContainerSpawnSubjects,Ar as ContainerStartedSchema,jr as ContainerStateSchema,zr as ContainerStoppedSchema,ft as ContextWindowTracker,L as DockerNamespace,Pr as DockerSubjects,dt as EmbeddingIndexManager,jt as ExecutionTargetInputSchema,Mt as ExecutionTargetListQuerySchema,C as ExecutionTargetNamespace,Nt as ExecutionTargetResolveRequestSchema,Pt as ExecutionTargetSchema,Ft as ExecutionTargetSchemas,Rt as ExecutionTargetSubjects,It as ExecutionTargetTypeSchema,qt as ExtractedContextSchema,pn as FacetNamespaceRegistry,A as FacetNamespaceRegistryToken,Jn as FallbackRegistryFetcher,zi as FrameworkServicesCoreNamespaces,Lt as LocalExecutionTargetSchema,ct as MakaioSession,g as MakaioSessionService,x as MessageRoutingNamespace,lt as MessageRoutingSubjects,zt as MessageStorageNamespace,Bt as MessageStorageSubjects,M as ModelRegistryNamespace,Yn as ModelRegistryProviderNotFoundError,Gn as ModelRegistrySchema,qn as ModelRegistrySchemas,Kn as ModelRegistryService,Xn as ModelRegistrySubjects,On as ModelRegistryToken,Xt as PreferenceItemSchema,Zt as PreferenceKeySchema,Qt as PreferenceValueSchema,w as PreferencesNamespace,$t as PreferencesSchemas,en as PreferencesSubjects,Qn as ProviderModelOverrideSchema,Ct as ResolveIdRequestSchema,wt as ResolveIdResponseSchema,Tt as ResolveNameRequestSchema,Et as ResolveNameResponseSchema,Re as SessionBridge,Nn as SessionBridgeToken,c as SessionEventStorageNamespace,o as SessionEventStorageSubjects,Ue as SessionExtensionContextImpl,Je as SessionOrchestrator,Rn as SessionOrchestratorToken,Me as SessionStorageNamespace,Ne as SessionStorageSubjects,kn as SessionStorageToken,An as SessionToken,Xe as SessionTurnManager,Ir as SpawnRequestSchema,Nr as SpawnResponseSchema,Mr as StatusRequestSchema,Or as StatusResponseSchema,Ur as StopRequestSchema,Wr as StopResponseSchema,dr as SubagentManager,pr as SubagentService,mr as SubagentServiceToken,Xr as SubagentTemplateCompletedEventSchema,Zr as SubagentTemplateCreateSchema,Qr as SubagentTemplateInstanceSchema,$r as SubagentTemplateInstanceStatusSchema,R as SubagentTemplateKernelNamespace,ei as SubagentTemplateKernelSchemas,ti as SubagentTemplateSchema,ni as SubagentTemplateSettingsSchemas,ri as SubagentTemplateSpawnRequestSchema,ii as SubagentTemplateSpawnedEventSchema,li as SubagentTemplateSubjects,ai as SubagentTemplateSummarySchema,oi as SubagentTemplateUpdateSchema,ln as SurfaceBindingRegistry,k as SurfaceBindingRegistryToken,Jt as TechnicalDetailsSchema,Yt as TodoEntrySchema,$n as ToolApprovalService,Pn as ToolApprovalToken,rn as ToolRegistry,jn as ToolRegistryToken,mn as TransitionActionRegistry,cn as TransitionPipelineService,E as TransitionPipelineToken,dn as TransitionRuleRegistry,er as TrayMenuEntrySchema,tr as TrayMenuGroupEntrySchema,nr as TrayMenuGroupSchema,rr as TrayMenuItemClickedSchema,ir as TrayMenuListEntrySchema,ar as TrayMenuMetadataSchema,N as TrayMenuNamespace,or as TrayMenuSchemas,sr as TrayMenuSectionSchema,lr as TrayMenuService,cr as TrayMenuSubjects,En as TrayMenuToken,ke as Turn,Le as TurnContextEnricher,Vt as TurnStorageNamespace,je as TurnStorageSubjects,yn as WORKFLOW_START_ACTION_TYPE,Hn as WorkflowBlockRegistry,j as WorkflowBlockRegistryToken,l as actionRegistry,xt as activateProviderContext,yt as activateProviderContextStrict,e as agents,Vn as artifactLifecycleHookRegistryPackage,Dn as artifactSchemaRegistryPackage,ye as assembleForkContext,di as buildDeterministicAdapterId,bt as buildProviderContext,ne as buildRecoveryContext,d as buildRecoveryContextWithPipeline,he as buildSessionContext,xe as buildTurnInitiator,Cn as canonicalModelPackage,Bn as capabilityPackage,yi as createArtifactKindContributionProcessor,xi as createArtifactLifecycleHookContributionProcessor,Ni as createFacetNamespaceContributionProcessor,bn as createModelRegistryPackage,Fe as createSessionExtensionContext,Pi as createSurfaceBindingContributionProcessor,Ln as createToolContributionProcessor,Ii as createTransitionContributionProcessor,Fi as createWorkflowBlockContributionProcessor,De as ensureAgentCwd,ie as ensureAgentModel,oe as extractTextContent,an as facetNamespaceRegistryPackage,tt as fetchAgentsBySession,ht as fetchMessageCountsBySession,Ke as fetchPreviewBySession,b as fetchSessionPreviewMaps,ve as findTurnByAgent,zn as frameworkCorePackages,ge as getFullConversation,pe as getOrCreateSession,st as importCursors,pt as importCursorsDual,Ve as kindToBranchKind,He as mapAgentsBySession,y as mapRowToSession,ot as mapToSession,Wn as mergeModelMetadata,ze as messageRouting,Qe as messageRoutingDual,i as messages,ue as normalizeSelectionString,Ee as normalizeToBlocks,mt as parseForkTransforms,Be as pickFallbackRuntimeOptions,p as recoverAgent,le as registerAbandonHandler,fi as registerAdapterRuntimeIdentityHandlers,Te as registerAttachHandler,be as registerBuiltInActions,se as registerCompressHandler,it as registerCompressLineageResolver,rt as registerCoreSessionServiceHandlers,_ as registerDrizzleAgentStorage,nt as registerDrizzleImportCursorStorage,Ie as registerDrizzleMessageRoutingStorage,$e as registerDrizzleMessageStorage,u as registerDrizzleSessionEventStorage,Pe as registerDrizzleSessionStorage,Oe as registerDrizzleTurnStorage,me as registerForkHandler,gt as registerFtsSearchHandler,v as registerGetStatusCountsHandler,_t as registerListActionsHandler,qe as registerMemoryAgentStorage,Ze as registerMemoryMessageStorage,ae as registerMemorySessionEventStorage,at as registerMemorySessionStorage,ce as registerMemoryTurnStorage,Se as registerMergeHandler,et as registerParentResolver,Ye as registerResumeHandler,ut as registerSpawningToolCallResolver,Ce as resetBuiltInActionsRegistration,ee as resolveAdapterId,de as resolveAdapterNameById,Si as resolveArtifactContext,ui as resolveDeterministicAdapterId,te as resolveExecutionTarget,re as resolveModelCapabilities,fe as resolveTargetAgents,we as routeToAgents,_e as routeToAgentsCore,xn as sessionBridgePackage,s as sessionEvents,a as sessionEventsDual,sn as sessionOrchestratorPackage,on as sessionPackage,_n as sessionStoragePackage,t as sessions,fr as subagentServicePackage,O as surfaceBindingRegistryPackage,nn as toolApprovalPackage,Mn as toolRegistryPackage,hn as transitionPipelinePackage,gn as trayMenuPackage,r as turns,n as turnsDual,f as verifyAndRecoverAgents,vn as workflowBlockRegistryPackage};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as LogImporterInfo } from "../../index-
|
|
2
|
-
import { a as OrchestratorFactory, i as OrchestratorEntry, r as LogImporterRegistration, t as LogImportRegistryOptions } from "../../types-
|
|
1
|
+
import { t as LogImporterInfo } from "../../index-D7rWAEY0.mjs";
|
|
2
|
+
import { a as OrchestratorFactory, i as OrchestratorEntry, r as LogImporterRegistration, t as LogImportRegistryOptions } from "../../types-BWduCvRU.mjs";
|
|
3
3
|
export { type LogImportRegistryOptions, type LogImporterInfo, type LogImporterRegistration, type OrchestratorEntry, type OrchestratorFactory };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { i as LogImportSettings, t as LogImporterInfo } from "../../index-
|
|
2
|
-
import { a as OrchestratorFactory, i as OrchestratorEntry, n as LogImportServiceInstance, o as LogImportRegistry, r as LogImporterRegistration, t as LogImportRegistryOptions } from "../../types-
|
|
1
|
+
import { i as LogImportSettings, t as LogImporterInfo } from "../../index-D7rWAEY0.mjs";
|
|
2
|
+
import { a as OrchestratorFactory, i as OrchestratorEntry, n as LogImportServiceInstance, o as LogImportRegistry, r as LogImporterRegistration, t as LogImportRegistryOptions } from "../../types-BWduCvRU.mjs";
|
|
3
3
|
import { LogImportNamespace, LogImportSubjects } from "./namespace.mjs";
|
|
4
4
|
import { IMakaioBus } from "@makaio/framework/bus";
|
|
5
5
|
import * as _$_makaio_contracts0 from "@makaio/framework/contracts";
|
|
6
|
-
import { MakaioNodeExtension } from "@makaio/framework/contracts";
|
|
6
|
+
import { MakaioNodeExtension, TurnIngestionMarker } from "@makaio/framework/contracts";
|
|
7
7
|
import * as _$drizzle_orm_sqlite_core0 from "drizzle-orm/sqlite-core";
|
|
8
8
|
import { MakaioDatabase } from "@makaio/framework/storage/drizzle";
|
|
9
9
|
import { LogImporter, ProcessLogFileResult } from "@makaio/framework/adapters";
|
|
@@ -60,12 +60,29 @@ interface SessionCompactedEventInput {
|
|
|
60
60
|
declare function appendSessionCompactedEvent(bus: IMakaioBus, event: SessionCompactedEventInput): Promise<void>;
|
|
61
61
|
//#endregion
|
|
62
62
|
//#region services/log-import/src/import-types.d.ts
|
|
63
|
+
/** Result of a file import operation. */
|
|
64
|
+
interface ImportFromFileContentResult {
|
|
65
|
+
/** Makaio session ID that was populated. */
|
|
66
|
+
sessionId: string;
|
|
67
|
+
/** Number of messages written (created + already-present). */
|
|
68
|
+
messageCount: number;
|
|
69
|
+
/**
|
|
70
|
+
* Number of NEWLY created turns across the segment tree in this call.
|
|
71
|
+
* Re-imported turns (anchor already present) do not count.
|
|
72
|
+
*/
|
|
73
|
+
turnCount: number;
|
|
74
|
+
}
|
|
63
75
|
/** Result returned after persisting an imported segment subtree. */
|
|
64
76
|
interface ImportSegmentTreeResult {
|
|
65
77
|
/** Makaio session ID created or reused for the imported segment. */
|
|
66
78
|
sessionId: string;
|
|
67
79
|
/** Total messages persisted across the segment subtree. */
|
|
68
80
|
messageCount: number;
|
|
81
|
+
/**
|
|
82
|
+
* Number of NEWLY created turns across the segment subtree in this call.
|
|
83
|
+
* Re-imported turns (anchor already present) do not count.
|
|
84
|
+
*/
|
|
85
|
+
turnCount: number;
|
|
69
86
|
}
|
|
70
87
|
/** Minimal caller context required to persist a processed import result tree. */
|
|
71
88
|
interface PersistImportResultContext {
|
|
@@ -75,6 +92,19 @@ interface PersistImportResultContext {
|
|
|
75
92
|
adapterName: string;
|
|
76
93
|
/** Log file path on disk; only the root segment owns it. */
|
|
77
94
|
logFilePath?: string | null;
|
|
95
|
+
/**
|
|
96
|
+
* Machine identifier of the machine that owns the imported sessions.
|
|
97
|
+
* Always caller-supplied; never derived inside import handlers.
|
|
98
|
+
* Pass `undefined` to omit (leaves stored value untouched).
|
|
99
|
+
* Pass `null` to explicitly store NULL.
|
|
100
|
+
*/
|
|
101
|
+
machineId?: string | null;
|
|
102
|
+
/**
|
|
103
|
+
* Marker stamped on the `session.turn.*` events emitted for ingested turns.
|
|
104
|
+
* Defaults to `'backfill'` (historical/watcher imports); hook-triggered
|
|
105
|
+
* live ingestion passes `'live'`.
|
|
106
|
+
*/
|
|
107
|
+
ingestionMarker?: TurnIngestionMarker;
|
|
78
108
|
}
|
|
79
109
|
//#endregion
|
|
80
110
|
//#region services/log-import/src/generic-import-handlers.d.ts
|
|
@@ -85,10 +115,60 @@ interface PersistImportResultContext {
|
|
|
85
115
|
* session creation, message persistence, compaction events, and status finalization.
|
|
86
116
|
* @param bus - Bus instance
|
|
87
117
|
* @param result - Fully processed importer result for one log file
|
|
88
|
-
* @param ctx - Adapter identity
|
|
89
|
-
* @returns Makaio session ID
|
|
118
|
+
* @param ctx - Adapter identity, optional root log file path, and optional ingestion marker
|
|
119
|
+
* @returns Makaio session ID, total persisted message count, and newly created turn count
|
|
90
120
|
*/
|
|
91
121
|
declare function persistImportResultTree(bus: IMakaioBus, result: ProcessLogFileResult, ctx: PersistImportResultContext): Promise<ImportSegmentTreeResult>;
|
|
122
|
+
/**
|
|
123
|
+
* Parse, extract, and store all messages from log file content.
|
|
124
|
+
*
|
|
125
|
+
* Core reusable import logic shared by the upload and lazy-load handlers.
|
|
126
|
+
* This function marks the session import status as `'imported'` after subtree persistence succeeds.
|
|
127
|
+
*
|
|
128
|
+
* When the importer produces `compressChildren` (from compaction boundary
|
|
129
|
+
* detection), each child is processed in order after the parent. Children
|
|
130
|
+
* use `logFilePath: null` — only the parent session owns the file reference.
|
|
131
|
+
* @param params - Import parameters
|
|
132
|
+
* @returns The Makaio session ID and total message count
|
|
133
|
+
* @throws Error if no valid records are found in the content
|
|
134
|
+
*/
|
|
135
|
+
declare function importFromFileContent(params: {
|
|
136
|
+
bus: IMakaioBus;
|
|
137
|
+
importer: LogImporter<unknown>;
|
|
138
|
+
content: string;
|
|
139
|
+
isJsonl: boolean;
|
|
140
|
+
adapterName: string;
|
|
141
|
+
adapterId: string;
|
|
142
|
+
sourceFilePath?: string;
|
|
143
|
+
persistedLogFilePath?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Machine identifier of the machine that owns the imported sessions.
|
|
146
|
+
* Always caller-supplied; never derived here. Pass `undefined` to omit
|
|
147
|
+
* (leaves stored value untouched), `null` to explicitly store NULL.
|
|
148
|
+
*/
|
|
149
|
+
machineId?: string | null;
|
|
150
|
+
/**
|
|
151
|
+
* Marker stamped on `session.turn.*` events emitted for ingested turns.
|
|
152
|
+
* Defaults to `'backfill'` (applied at the {@link importSegmentTree} boundary).
|
|
153
|
+
*/
|
|
154
|
+
ingestionMarker?: TurnIngestionMarker;
|
|
155
|
+
}): Promise<ImportFromFileContentResult>;
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region services/log-import/src/import-file-handler.d.ts
|
|
158
|
+
/**
|
|
159
|
+
* Register the importFile handler.
|
|
160
|
+
*
|
|
161
|
+
* Responds to `log-import.importFile` by parsing the given transcript file
|
|
162
|
+
* with the registered importer for `adapterName` and persisting the resulting
|
|
163
|
+
* segment tree (sessions, messages, turns). Per the subject's
|
|
164
|
+
* graceful-absence contract, a missing importer registration or a missing
|
|
165
|
+
* file yields a `skipped` result instead of an error; genuine importer or
|
|
166
|
+
* storage failures propagate.
|
|
167
|
+
* @param bus - Bus instance for communication
|
|
168
|
+
* @param getRegistration - Function to look up a registration by adapter name
|
|
169
|
+
* @returns Cleanup function to unsubscribe the handler
|
|
170
|
+
*/
|
|
171
|
+
declare function registerImportFileHandler(bus: IMakaioBus, getRegistration: (adapterName: string) => LogImporterRegistration | undefined): () => void;
|
|
92
172
|
//#endregion
|
|
93
173
|
//#region services/log-import/src/import-phase.d.ts
|
|
94
174
|
/**
|
|
@@ -265,4 +345,4 @@ declare function rowToSettings(row: SelectLogImportSettings): LogImportSettings;
|
|
|
265
345
|
*/
|
|
266
346
|
declare function registerDrizzleLogImportStorage(bus: IMakaioBus, db: MakaioDatabase): () => void;
|
|
267
347
|
//#endregion
|
|
268
|
-
export { ImportPhase, type ImportPhaseValue, LogImportNamespace, LogImportRegistry, type LogImportRegistryOptions, LogImportRegistryToken, type LogImportServiceInstance, LogImportSubjects, type LogImporterInfo, type LogImporterRegistration, type OrchestratorEntry, type OrchestratorFactory, type PersistImportResultContext, type SessionCompactedEventInput, appendSessionCompactedEvent, createLogImportContributionProcessor, logImportRegistryPackage, persistImportResultTree, registerDrizzleLogImportStorage, rowToSettings };
|
|
348
|
+
export { ImportPhase, type ImportPhaseValue, LogImportNamespace, LogImportRegistry, type LogImportRegistryOptions, LogImportRegistryToken, type LogImportServiceInstance, LogImportSubjects, type LogImporterInfo, type LogImporterRegistration, type OrchestratorEntry, type OrchestratorFactory, type PersistImportResultContext, type SessionCompactedEventInput, appendSessionCompactedEvent, createLogImportContributionProcessor, importFromFileContent, logImportRegistryPackage, persistImportResultTree, registerDrizzleLogImportStorage, registerImportFileHandler, rowToSettings };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LogImportNamespace as e,LogImportSubjects as t}from"./namespace.mjs";import{z as n}from"zod";import*as r from"node:fs/promises";import{basename as i,dirname as a,isAbsolute as o,join as s,relative as c,resolve as l,sep as u}from"node:path";import{MakaioBus as d}from"@makaio/framework/bus";import{COMPRESS_SESSION_LINEAGE_KIND as f,CapabilitySubjects as p,FORK_SESSION_LINEAGE_KIND as m,ROOT_SESSION_LINEAGE_KIND as
|
|
2
|
-
`).filter(e=>e.trim());for(let e of n){let n=t.parseRecord(e,r);n&&i.push(n)}}else{let n=t.parseRecord(e,r);n&&i.push(n)}return i}function N(e,n){return e.on(t.scan,async t=>{let{adapterName:i}=t.payload,a=n(i);if(!a){t.setResult({adapterName:i,sessionsFound:0,newSessions:0});return}let{importer:o,logFilePattern:s,adapterName:c}=a,l=o.getLogDirectory();try{await r.access(l)}catch{t.setResult({adapterName:i,sessionsFound:0,newSessions:0});return}let u=s.endsWith(`.jsonl`),d=await j(l,s),f=0,p=0;for(let t of d)try{let n=M(await r.readFile(t,`utf8`),o,u,t);if(n.length===0)continue;let i=C(o.extractSessionContext(n).sessionEvent);f++;let{created:a}=await e.request(b.importUpsert,w(i,c,i.cwd,t,i.startedAt));a&&p++}catch(e){console.warn(`[LogImportRegistry] Failed to process ${t}:`,e instanceof Error?e.message:e)}t.setResult({adapterName:i,sessionsFound:f,newSessions:p})})}async function P(e,t,n,i,a,o){try{let a=await r.stat(i),s=t.extractSessionContext(n),c={adapterSessionId:o,model:s.model,cwd:s.cwd,sessionEvent:s.sessionEvent,startedEvent:s.startedEvent,state:t.serializeState(s.state)};await e.request(re.set,{filePath:i,bytesRead:a.size,lastModified:a.mtime.toISOString(),sessionContext:c})}catch(e){console.warn(`[importFromFileContent] Failed to persist import cursor`,{adapterName:a,adapterSessionId:o,filePath:i,error:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0})}}async function F(e,t,n,r,i){let a=i.find(e=>e.origin===`compact`),o=a?.contentText??null,s=r.timestamp??a?.timestamp??Date.now();await T(e,{sessionId:t,eventId:`session-compacted:${t}:${n}`,timestamp:s,trigger:r.trigger,preTokens:r.preTokens,summary:o,compressChildSessionId:n})}async function I(e,t,n){for(let r of n)await e.request(ae.upsertByAdapterMessageId,{sessionId:t,turnId:null,adapterMessageId:r.adapterMessageId,role:r.role,contentText:r.contentText,blocks:r.blocks,agentId:r.agentId,adapterSessionId:r.adapterSessionId,timestamp:r.timestamp,...r.origin!==void 0&&{origin:r.origin}})}async function L(e,t,n,r){let i=oe(t,n.model,n.cwd),a=t.messages.length>0?t.messages.reduce((e,t)=>Math.min(e,t.timestamp),1/0):void 0,{sessionId:o}=await e.request(b.importUpsert,w(i,n.adapterName,n.cwd,n.logFilePath,a,n.adapterId));await I(e,o,t.messages),r!==void 0&&t.compaction!==void 0&&await F(e,r,o,t.compaction,t.messages);let s=t.messages.length,c={adapterId:n.adapterId,adapterName:n.adapterName,model:n.model,cwd:n.cwd,logFilePath:null};for(let n of t.children??[]){let t=await L(e,n,c,o);s+=t.messageCount}return await e.request(b.updateImportStatus,{sessionId:o,importStatus:`imported`}),{sessionId:o,messageCount:s}}async function R(e,t,n){let r=C(t.sessionEvent);return L(e,ie(t),{adapterId:n.adapterId,adapterName:n.adapterName,model:r.model,cwd:r.cwd,logFilePath:n.logFilePath})}async function z(e){let{bus:t,importer:n,content:r,isJsonl:i,adapterName:a,adapterId:o,sourceFilePath:s,persistedLogFilePath:c}=e,l=M(r,n,i,s);if(l.length===0)throw Error(`No valid records found`);let u=n.processLogFile(l),d=ce(c,s,C(u.sessionEvent).cwd),{sessionId:f,messageCount:p}=await R(t,u,{adapterId:o,adapterName:a,logFilePath:d});return d!==void 0&&await P(t,n,l,d,a,u.adapterSessionId),{sessionId:f,messageCount:p}}function B(e,n){return e.on(t.uploadFiles,async t=>{let{adapterName:r,files:i}=t.payload,a=n(r);if(!a){t.setResult({adapterName:r,filesProcessed:i.length,sessionsImported:0,errors:i.map(e=>({filename:e.filename,error:`No importer registered for this adapter`}))});return}let{importer:o,logFilePattern:s,adapterName:c,id:l}=a,u=s.endsWith(`.jsonl`),d=0,f=[];for(let t of i)try{await z({bus:e,importer:o,content:Buffer.from(t.contentBase64,`base64`).toString(`utf8`),isJsonl:u,adapterName:c,adapterId:l,sourceFilePath:t.filename}),d++}catch(e){f.push({filename:t.filename,error:e instanceof Error?e.message:String(e)})}t.setResult({adapterName:r,filesProcessed:i.length,sessionsImported:d,errors:f})})}function V(e,n){return e.on(t.importSession,async t=>{let{adapterSessionId:i,adapterName:a}=t.payload,{session:o}=await e.request(b.getByAdapterSessionId,{adapterSessionId:i,source:a});if(!o)throw Error(`Session not found for external ID: ${i}`);if(o.source!==a)throw Error(`Session '${i}' belongs to adapter '${o.source}', not '${a}'`);if(!o.logFilePath)throw Error(`No log file path recorded for session with external ID '${i}'. Re-run a discovery scan to populate the file path.`);let s=n(a);if(!s)throw Error(`No importer registered for adapter '${a}'`);let{importer:c,logFilePattern:l,adapterName:u,id:d}=s,f=l.endsWith(`.jsonl`),{sessionId:p,messageCount:m}=await z({bus:e,importer:c,content:await r.readFile(o.logFilePath,`utf8`),isJsonl:f,adapterName:u,adapterId:d,sourceFilePath:o.logFilePath,persistedLogFilePath:o.logFilePath});t.setResult({sessionId:p,messageCount:m})})}function H(e){return e.hasAdapterContribution?`adapter`:`extension`}function U(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t.registration;return typeof t.id==`string`&&typeof t.displayName==`string`&&typeof t.adapterName==`string`&&!!n&&typeof n==`object`&&typeof n.LogImporterClass==`function`&&typeof n.logFilePattern==`string`&&(n.LogOrchestratorClass===void 0||typeof n.LogOrchestratorClass==`function`)&&(n.LogDiscoveryOrchestratorClass===void 0||typeof n.LogDiscoveryOrchestratorClass==`function`)}function W(e,t,n){return{enabled:n?.enabled??!0,pollIntervalMs:n?.pollIntervalMs,eventsPerSecond:n?.eventsPerSecond,adapterId:e,adapterName:t,checkMakaioManaged:n?.checkMakaioManaged}}function G(e,t,n,r,i){if(!r&&!i)return null;let a=W(e,t,n);return e=>a.enabled?e===`discover`&&i?new i(a):e===`import`&&r?new r(a):null:null}async function le(e,n,r,i){try{let a=await r.requestOptional(t.getMode,{adapterName:n});if(!a.handled)return;let{mode:o}=a.data;if(o===`disabled`)return;await i(e,o)}catch(e){console.warn(`[LogImport] Failed to restore persisted mode for '${n}':`,e)}}async function K(e,t,n){if(!U(e)||n.getImporter(e.id)!==void 0)return;await n.register({id:e.id,adapterName:e.adapterName,displayName:e.displayName,source:H({hasAdapterContribution:!0}),importer:new e.registration.LogImporterClass({adapterId:e.id,adapterName:e.adapterName}),logFilePattern:e.registration.logFilePattern});let r=G(e.id,e.adapterName,e.logImportConfig,e.registration.LogOrchestratorClass,e.registration.LogDiscoveryOrchestratorClass);r&&n.setOrchestratorFactory(e.id,r),await le(e.id,e.adapterName,t,(e,t)=>n.switchMode(e,t))}async function ue(e,t,n){let r=e.on(p.register,async t=>{await K(t.payload.provider,e,n)},{filter:{capabilityId:`log-import`}});for(let r of t?.getProviders(`log-import`)??[])await K(r,e,n);return r}async function q(e,t){let n=e.get(t);if(n)try{n.orchestrator.isRunning()&&await n.orchestrator.stop()}finally{try{await n.orchestrator.dispose()}finally{e.delete(t)}}}async function de(e,t){try{await e.start()}catch(n){try{try{e.isRunning()&&await e.stop()}finally{await e.dispose()}}catch(e){console.warn(`[LogImportRegistry] Failed to clean up orchestrator after start failure for '${t}'.`,e instanceof Error?e.message:String(e))}throw n}}var J=class{bus;capabilityService;registrations=new Map;orchestrators=new Map;cleanupHandlers=[];initialized=!1;constructor(e){this.bus=e?.bus??d,this.capabilityService=e?.capabilityService}async init(){if(this.initialized)return;let e=this.bus.on(t.listImporters,e=>{let t=this.listImporters();e.setResult({importers:t})});this.cleanupHandlers.push(e);let n=N(this.bus,e=>this.getImporterByAdapterName(e));this.cleanupHandlers.push(n);let r=B(this.bus,e=>this.getImporterByAdapterName(e));this.cleanupHandlers.push(r);let i=V(this.bus,e=>this.getImporterByAdapterName(e));this.cleanupHandlers.push(i);let a=await ue(this.bus,this.capabilityService,this);this.cleanupHandlers.push(a),this.initialized=!0}async register(e){if(this.registrations.has(e.id))throw Error(`Log importer '${e.id}' is already registered`);this.registrations.set(e.id,e)}async unregister(e){if(!this.registrations.has(e))throw Error(`Log importer '${e}' is not registered`);await q(this.orchestrators,e),this.registrations.delete(e)}async startImporter(e){if(!this.registrations.get(e))throw Error(`Log importer '${e}' is not registered`);let t=this.orchestrators.get(e);if(!t)throw Error(`No orchestrator available for '${e}'. Orchestrators must be created and provided by the adapter or extension before starting.`);t.orchestrator.isRunning()||(await t.orchestrator.start(),t.isManaged=!0)}async stopImporter(e){let t=this.orchestrators.get(e);t&&(t.orchestrator.isRunning()&&await t.orchestrator.stop(),t.isManaged=!1)}async switchMode(e,t){let n=this.registrations.get(e);if(!n)throw Error(`Log importer '${e}' is not registered`);if(await q(this.orchestrators,e),t===`disabled`||!n.orchestratorFactory)return;let r=n.orchestratorFactory(t);r&&(await de(r,e),this.orchestrators.set(e,{orchestrator:r,isManaged:!0}))}async startDiscovery(e){return this.switchMode(e,`discover`)}setOrchestratorFactory(e,t){let n=this.registrations.get(e);if(!n)throw Error(`Cannot set orchestrator factory for unregistered importer '${e}'`);this.registrations.set(e,{...n,orchestratorFactory:t})}listImporters(){let e=[];for(let[,t]of this.registrations){let n=this.orchestrators.get(t.id)?.orchestrator.isRunning()??!1;e.push({id:t.id,adapterName:t.adapterName,displayName:t.displayName,source:t.source,logFilePattern:t.logFilePattern,isRunning:n,supportsManualImport:t.supportsManualImport??!0})}return e}getImporter(e){let t=this.registrations.get(e);return t?{...t}:void 0}getImporterByAdapterName(e){for(let t of this.registrations.values())if(t.adapterName===e)return{...t}}detectImporter(e){let t,n=0;for(let r of this.registrations.values()){let i=r.importer.canHandle(e);if(i===!1)continue;let a=i===!0?1:i.confidence;a>n&&(n=a,t=r)}return t}async registerOrchestrator(e,t){if(!this.registrations.has(e))throw Error(`Cannot register orchestrator for unregistered importer '${e}'`);await q(this.orchestrators,e),this.orchestrators.set(e,{orchestrator:t,isManaged:!1})}async destroy(){if(!(!this.initialized&&this.orchestrators.size===0&&this.cleanupHandlers.length===0)){for(let[e]of this.orchestrators)await q(this.orchestrators,e);for(let e of this.cleanupHandlers)e();this.cleanupHandlers.length=0,this.initialized=!1}}};const Y=g(`log-import-registry`),fe={name:Y.name,displayName:`Log Import Registry`,version:`0.1.0`,critical:!0,namespaces:[e],create:e=>new J({bus:e.bus})};function pe(e,t,n){return{enabled:n?.enabled??!0,pollIntervalMs:n?.pollIntervalMs,eventsPerSecond:n?.eventsPerSecond,adapterId:e,adapterName:t,checkMakaioManaged:n?.checkMakaioManaged}}function me(e,t,n){if(!n.LogOrchestratorClass&&!n.LogDiscoveryOrchestratorClass)return null;let r=pe(e,t,n.logImportConfig);return e=>r.enabled?e===`discover`&&n.LogDiscoveryOrchestratorClass?new n.LogDiscoveryOrchestratorClass(r):e===`import`&&n.LogOrchestratorClass?new n.LogOrchestratorClass(r):null:null}function X(){let e=new Map;return{filter:e=>!!e.logImport,processActivated:async(t,n,r)=>{let{logImport:i}=n;if(!i)return;let a=r.getService(Y);if(!a)throw Error(`[LogImportContributionProcessor] LogImportRegistry is not available. Ensure '${Y.name}' is listed as a dependency before activating '${t}'.`);let{adapterName:o,displayName:s,config:c}=i,l=c,u=`package:${t}`,d=H({hasAdapterContribution:!!n.adapters?.length}),f=new l.LogImporterClass({adapterId:u,adapterName:o});await a.register({id:u,adapterName:o,displayName:s,source:d,importer:f,logFilePattern:l.logFilePattern??``,supportsManualImport:l.supportsManualImport});try{let e=me(u,o,l);e&&a.setOrchestratorFactory(u,e)}catch(e){try{await a.unregister(u)}catch(e){console.error(`[LogImportContributionProcessor] Rollback of log importer '${u}' failed:`,e)}throw e}console.info(`[LogImportContributionProcessor] Registered log importer '${o}' from package: ${t}`),e.set(u,async()=>{try{await a.unregister(u)}catch(e){console.error(`[LogImportContributionProcessor] Failed to unregister log importer '${u}' during cleanup:`,e)}})},processStopped:async t=>{let n=`package:${t}`,r=e.get(n);r&&(e.delete(n),await r())}}}const he={linked:`linked`,persisted:`persisted`,finalized:`finalized`},Z=te(`log_import_settings`,e=>({adapterName:e.text(`adapter_name`).primaryKey(),mode:e.textEnum(`mode`,{enum:[`disabled`,`discover`,`import`]}).notNull().default(`disabled`),createdAt:e.epochMs(`created_at`).notNull(),updatedAt:e.epochMs(`updated_at`).notNull()})),ge=Z.sqlite,_e=Z.postgres,Q=_({logImportSettings:ge},{logImportSettings:_e});function $(e){return{adapterName:e.adapterName,mode:e.mode,createdAt:e.createdAt,updatedAt:e.updatedAt}}function ve(e){let{bus:n,db:r}=e,{logImportSettings:i}=v(r,Q);return n.on(t.getMode,async e=>{let{adapterName:t}=e.payload,[n]=await r.select().from(i).where(ne(i.adapterName,t)).limit(1);e.setResult({mode:n?.mode??`disabled`})})}function ye(e){let{bus:n,db:r}=e,{logImportSettings:i}=v(r,Q);return n.on(t.setMode,async e=>{let{adapterName:t,mode:n}=e.payload,a=Date.now();await r.insert(i).values({adapterName:t,mode:n,createdAt:a,updatedAt:a}).onConflictDoUpdate({target:i.adapterName,set:{mode:n,updatedAt:a}}),e.setResult({success:!0})})}function be(e){let{bus:n,db:r}=e,{logImportSettings:i}=v(r,Q);return n.on(t.listSettings,async e=>{let t=await r.select().from(i);e.setResult({settings:t.map($)})})}function xe(e,t){let n={bus:e,db:t},r=[ve(n),ye(n),be(n)];return()=>r.forEach(e=>e())}export{he as ImportPhase,e as LogImportNamespace,J as LogImportRegistry,Y as LogImportRegistryToken,t as LogImportSubjects,T as appendSessionCompactedEvent,X as createLogImportContributionProcessor,fe as logImportRegistryPackage,R as persistImportResultTree,xe as registerDrizzleLogImportStorage,$ as rowToSettings};
|
|
1
|
+
import{LogImportNamespace as e,LogImportSubjects as t}from"./namespace.mjs";import{z as n}from"zod";import*as r from"node:fs/promises";import{basename as i,dirname as a,isAbsolute as o,join as s,relative as c,resolve as l,sep as u}from"node:path";import{MakaioBus as d}from"@makaio/framework/bus";import{COMPRESS_SESSION_LINEAGE_KIND as f,CapabilitySubjects as p,FORK_SESSION_LINEAGE_KIND as m,ROOT_SESSION_LINEAGE_KIND as h,SUBAGENT_SESSION_LINEAGE_KIND as ee,extensionToken as te}from"@makaio/framework/contracts";import{defineDialectSchema as ne,defineDualTable as g,resolveSchema as _}from"@makaio/framework/storage/drizzle";import{eq as re}from"drizzle-orm";import{ImportCursorStorageSubjects as v,toImportSegment as ie}from"@makaio/framework/adapters";import{MessageStorageSubjects as ae,SessionEventStorageSubjects as y,SessionStorageSubjects as b,ingestCompletedTurn as oe,isPolicyDiscoveredObservedSession as se,toSessionLineage as x}from"@makaio/framework/services/session";function S(e,t){return t===void 0?{}:{[e]:t}}const ce=n.discriminatedUnion(`kind`,[n.object({adapterSessionId:n.string(),kind:n.literal(h),parentAdapterSessionId:n.null().default(null),forkPointMessageId:n.null().default(null),model:n.string().nullable().default(null),cwd:n.string().nullable().default(null),startedAt:n.number().finite().optional()}),n.object({adapterSessionId:n.string(),kind:n.literal(m),parentAdapterSessionId:n.string(),forkPointMessageId:n.string(),model:n.string().nullable().default(null),cwd:n.string().nullable().default(null),startedAt:n.number().finite().optional()}),n.object({adapterSessionId:n.string(),kind:n.literal(ee),parentAdapterSessionId:n.string(),forkPointMessageId:n.null().default(null),model:n.string().nullable().default(null),cwd:n.string().nullable().default(null),startedAt:n.number().finite().optional()}),n.object({adapterSessionId:n.string(),kind:n.literal(f),parentAdapterSessionId:n.string(),forkPointMessageId:n.null().default(null),model:n.string().nullable().default(null),cwd:n.string().nullable().default(null),startedAt:n.number().finite().optional()})]);function C(e){return ce.parse(e.payload)}function w(e){let{metadata:t,source:n,cwd:r,logFilePath:i,startedAt:a,adapterId:o,clientId:s,isSidechain:c,machineId:l}=e,u=x(t);return{externalSessionId:t.adapterSessionId,source:n,cwd:r,...S(`logFilePath`,i),...S(`startedAt`,a),...S(`adapterId`,o),...S(`clientId`,s),...S(`isSidechain`,c),...S(`machineId`,l),...u}}function T(e,t,n){let r={adapterSessionId:e.adapterSessionId,model:t,cwd:n};switch(e.lineage.kind){case`root`:return{...r,kind:`root`,parentAdapterSessionId:null,forkPointMessageId:null};case`fork`:if(e.lineage.parentAdapterSessionId==null)throw Error(`Fork segment ${e.adapterSessionId} missing parentAdapterSessionId`);if(e.lineage.forkPointMessageId==null)throw Error(`Fork segment ${e.adapterSessionId} missing forkPointMessageId`);return{...r,kind:`fork`,parentAdapterSessionId:e.lineage.parentAdapterSessionId,forkPointMessageId:e.lineage.forkPointMessageId};case`subagent`:if(e.lineage.parentAdapterSessionId==null)throw Error(`Subagent segment ${e.adapterSessionId} missing parentAdapterSessionId`);return{...r,kind:`subagent`,parentAdapterSessionId:e.lineage.parentAdapterSessionId,forkPointMessageId:null};case`compress`:if(e.lineage.parentAdapterSessionId==null)throw Error(`Compress segment ${e.adapterSessionId} missing parentAdapterSessionId`);return{...r,kind:`compress`,parentAdapterSessionId:e.lineage.parentAdapterSessionId,forkPointMessageId:null};default:{let t=e.lineage.kind;throw Error(`Unknown lineage kind: ${String(t)}`)}}}async function E(e,t){let{events:n}=await e.request(y.getByIds,{sessionId:t.sessionId,eventIds:[t.eventId]});if(!(n.length>0))try{await e.request(y.append,{event:{sessionId:t.sessionId,eventId:t.eventId,timestamp:t.timestamp,type:`session.compacted`,payload:{trigger:t.trigger,preTokens:t.preTokens,summary:t.summary,compressChildSessionId:t.compressChildSessionId}}})}catch(n){let{events:r}=await e.request(y.getByIds,{sessionId:t.sessionId,eventIds:[t.eventId]});if(r.length>0)return;throw n}}const D=new Map,O=`MAKAIO_GLOBSTAR_DIR`,k=`MAKAIO_GLOBSTAR`,A=`MAKAIO_STAR`;function j(e){return e.replace(/[\\/]+/g,`/`).replace(/^\.\/+/,``)}function le(e,t){let n=j(e),r=j(t),a=r.includes(`/`)?n:i(n);if(r.length>200)return!1;if(!r.includes(`*`))return a===r;let o=0;for(let e of r)if(e===`*`&&(o+=1,o>64))return!1;let s=D.get(r);if(s)return D.delete(r),D.set(r,s),s.test(a);let c=r.replace(/\*\*\//g,O).replace(/\*\*/g,k).replace(/\*/g,A).replace(/[.+^${}()|[\]\\]/g,`\\$&`).replaceAll(O,`(?:.*/)?`).replaceAll(k,`.*`).replaceAll(A,`[^/]*`),l=RegExp(`^${c}$`);if(D.size>=512){let e=D.keys().next();e.done||D.delete(e.value)}return D.set(r,l),l.test(a)}async function M(e,t,n=e){let i=[];try{let a=await r.readdir(e,{withFileTypes:!0});for(let r of a){let a=s(e,r.name);if(r.isDirectory()){let e=await M(a,t,n);i.push(...e)}else if(r.isFile()){if(!le(c(n,a).split(u).join(`/`),t))continue;i.push(a)}}}catch{}return i}function ue(e,t,n){if(e!==void 0){if(o(e))return e;if(t&&o(t))return l(a(t),e);if(n&&o(n))return l(n,e)}}function N(e,t,n=!0,r){let i=[];if(n){let n=e.split(`
|
|
2
|
+
`).filter(e=>e.trim());for(let e of n){let n=t.parseRecord(e,r);n&&i.push(n)}}else{let n=t.parseRecord(e,r);n&&i.push(n)}return i}function de(e,n){return e.on(t.scan,async t=>{let{adapterName:i}=t.payload,a=n(i);if(!a){t.setResult({adapterName:i,sessionsFound:0,newSessions:0});return}let{importer:o,logFilePattern:s,adapterName:c,machineId:l}=a,u=o.getLogDirectory();try{await r.access(u)}catch{t.setResult({adapterName:i,sessionsFound:0,newSessions:0});return}let d=s.endsWith(`.jsonl`),f=await M(u,s),p=0,m=0;for(let t of f)try{let n=N(await r.readFile(t,`utf8`),o,d,t);if(n.length===0)continue;let i=C(o.extractSessionContext(n).sessionEvent);p++;let{created:a}=await e.request(b.importUpsert,w({metadata:i,source:c,cwd:i.cwd,logFilePath:t,startedAt:i.startedAt,machineId:l}));a&&m++}catch(e){console.warn(`[LogImportRegistry] Failed to process ${t}:`,e instanceof Error?e.message:e)}t.setResult({adapterName:i,sessionsFound:p,newSessions:m})})}async function P(e,t,n,i,a,o,s){try{let o=await r.stat(a),c=o.size===i,l=t.extractSessionContext(n);t.processRecords(n,l);let u={adapterSessionId:s,model:l.model,cwd:l.cwd,sessionEvent:l.sessionEvent,startedEvent:l.startedEvent,state:t.serializeState(l.state)};await e.request(v.set,{filePath:a,bytesRead:i,lastModified:c?o.mtime.toISOString():new Date(0).toISOString(),sessionContext:u})}catch(e){console.warn(`[importFromFileContent] Failed to persist import cursor`,{adapterName:o,adapterSessionId:s,filePath:a,error:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0})}}async function F(e,t,n,r,i){let a=i.find(e=>e.origin===`compact`),o=a?.contentText??null,s=r.timestamp??a?.timestamp??Date.now();await E(e,{sessionId:t,eventId:`session-compacted:${t}:${n}`,timestamp:s,trigger:r.trigger,preTokens:r.preTokens,summary:o,compressChildSessionId:n})}async function I(e,t,n){for(let r of n)await e.request(ae.upsertByAdapterMessageId,{sessionId:t,turnId:null,adapterMessageId:r.adapterMessageId,role:r.role,contentText:r.contentText,blocks:r.blocks,agentId:r.agentId,adapterSessionId:r.adapterSessionId,timestamp:r.timestamp,...r.origin!==void 0&&{origin:r.origin}})}function L(e){return{adapterMessageId:e.adapterMessageId,role:e.role,contentText:e.contentText,blocks:e.blocks,agentId:e.agentId,adapterSessionId:e.adapterSessionId,timestamp:e.timestamp,...e.origin!==void 0&&{origin:e.origin}}}async function R(e,t,n,r,i){let a=new Map(n.messages.map(e=>[e.adapterMessageId,e])),o=new Set,s=0;for(let[n,c]of r.entries()){let l=[],u=new Set;for(let e of c.adapterMessageIds){let t=a.get(e);if(t===void 0){console.warn(`[importSegmentTree] Turn ${n+1}/${r.length} references an unknown member; skipping it`);continue}u.add(e),l.push(L(t))}if(!u.has(c.turnAnchorId)){console.warn(`[importSegmentTree] Turn ${n+1}/${r.length} is missing its anchor; skipping turn`);continue}(await oe(e,{sessionId:t,turnAnchorId:c.turnAnchorId,startedAt:c.startedAt,completedAt:c.completedAt,status:c.status??`completed`,ingestionMarker:i,messages:l})).created&&(s+=1);for(let e of u)o.add(e)}return{turnMemberIds:o,createdTurnCount:s}}async function z(e,t,n,r){let i=n.ingestionMarker??`backfill`,a=T(t,n.model,n.cwd),o=t.messages.length>0?t.messages.reduce((e,t)=>Math.min(e,t.timestamp),1/0):void 0,s=await e.requestOptional(b.getByAdapterSessionId,{adapterSessionId:a.adapterSessionId,source:n.adapterName});if(s.handled&&s.data.session!==null){let e=s.data.session;if(se(e))return{sessionId:e.sessionId,messageCount:0,turnCount:0}}let{sessionId:c}=await e.request(b.importUpsert,w({metadata:a,source:n.adapterName,cwd:n.cwd,logFilePath:n.logFilePath,startedAt:o,adapterId:n.adapterId,isSidechain:t.isSidechain,machineId:n.machineId})),l=0;if(t.turns!==void 0&&t.turns.length>0){let{turnMemberIds:n,createdTurnCount:r}=await R(e,c,t,t.turns,i);l+=r,await I(e,c,t.messages.filter(e=>!n.has(e.adapterMessageId)))}else await I(e,c,t.messages);r!==void 0&&t.compaction!==void 0&&await F(e,r,c,t.compaction,t.messages);let u=t.messages.length,d={adapterId:n.adapterId,adapterName:n.adapterName,model:n.model,cwd:n.cwd,logFilePath:null,machineId:n.machineId,ingestionMarker:i};for(let n of t.children??[]){let t=await z(e,n,d,c);u+=t.messageCount,l+=t.turnCount}return await e.request(b.updateImportStatus,{sessionId:c,importStatus:`imported`}),{sessionId:c,messageCount:u,turnCount:l}}async function B(e,t,n){let r=C(t.sessionEvent);return z(e,ie(t),{adapterId:n.adapterId,adapterName:n.adapterName,model:r.model,cwd:r.cwd,logFilePath:n.logFilePath,machineId:n.machineId,ingestionMarker:n.ingestionMarker})}async function V(e){let{bus:t,importer:n,content:r,isJsonl:i,adapterName:a,adapterId:o,sourceFilePath:s,persistedLogFilePath:c}=e,l=N(r,n,i,s);if(l.length===0)throw Error(`No valid records found`);let u=n.processLogFile(l),d=ue(c,s,C(u.sessionEvent).cwd),{sessionId:f,messageCount:p,turnCount:m}=await B(t,u,{adapterId:o,adapterName:a,logFilePath:d,machineId:e.machineId,ingestionMarker:e.ingestionMarker});return d!==void 0&&await P(t,n,l,Buffer.byteLength(r,`utf8`),d,a,u.adapterSessionId),{sessionId:f,messageCount:p,turnCount:m}}function H(e,n){return e.on(t.uploadFiles,async t=>{let{adapterName:r,files:i}=t.payload,a=n(r);if(!a){t.setResult({adapterName:r,filesProcessed:i.length,sessionsImported:0,errors:i.map(e=>({filename:e.filename,error:`No importer registered for this adapter`}))});return}let{importer:o,logFilePattern:s,adapterName:c,id:l}=a,u=s.endsWith(`.jsonl`),d=0,f=[];for(let t of i)try{await V({bus:e,importer:o,content:Buffer.from(t.contentBase64,`base64`).toString(`utf8`),isJsonl:u,adapterName:c,adapterId:l,sourceFilePath:t.filename}),d++}catch(e){f.push({filename:t.filename,error:e instanceof Error?e.message:String(e)})}t.setResult({adapterName:r,filesProcessed:i.length,sessionsImported:d,errors:f})})}function U(e,n){return e.on(t.importSession,async t=>{let{adapterSessionId:i,adapterName:a,ingestionMarker:o}=t.payload,{session:s}=await e.request(b.getByAdapterSessionId,{adapterSessionId:i,source:a});if(!s)throw Error(`Session not found for external ID: ${i}`);if(s.source!==a)throw Error(`Session '${i}' belongs to adapter '${s.source}', not '${a}'`);if(!s.logFilePath)throw Error(`No log file path recorded for session with external ID '${i}'. Re-run a discovery scan to populate the file path.`);let c=n(a);if(!c)throw Error(`No importer registered for adapter '${a}'`);let{importer:l,logFilePattern:u,adapterName:d,id:f}=c,p=u.endsWith(`.jsonl`),{sessionId:m,messageCount:h}=await V({bus:e,importer:l,content:await r.readFile(s.logFilePath,`utf8`),isJsonl:p,adapterName:d,adapterId:f,machineId:c.machineId,sourceFilePath:s.logFilePath,persistedLogFilePath:s.logFilePath,ingestionMarker:o??`backfill`});t.setResult({sessionId:m,messageCount:h})})}const W=new Map;async function fe(e,t,n){let{filePath:i,adapterName:a}=n,o=t(a);if(o===void 0)return{status:`skipped`,reason:`no-importer`};try{await r.stat(i)}catch{return{status:`skipped`,reason:`file-missing`}}let s=await r.readFile(i,`utf8`),c=o.logFilePattern.endsWith(`.jsonl`),{sessionId:l,messageCount:u,turnCount:d}=await V({bus:e,importer:o.importer,content:s,isJsonl:c,adapterName:o.adapterName,adapterId:o.id,machineId:o.machineId,sourceFilePath:i,persistedLogFilePath:i,ingestionMarker:n.ingestionMarker??`live`});return{status:`imported`,sessionId:l,messageCount:u,turnCount:d}}function G(e,n){return e.on(t.importFile,async t=>{let{filePath:r}=t.payload,i=(W.get(r)??Promise.resolve()).then(()=>fe(e,n,t.payload)),a=i.then(()=>void 0,()=>void 0);W.set(r,a),a.then(()=>{W.get(r)===a&&W.delete(r)}),t.setResult(await i)})}function K(e){return e.hasAdapterContribution?`adapter`:`extension`}function pe(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t.registration;return typeof t.id==`string`&&typeof t.displayName==`string`&&typeof t.adapterName==`string`&&!!n&&typeof n==`object`&&typeof n.LogImporterClass==`function`&&typeof n.logFilePattern==`string`&&(n.LogOrchestratorClass===void 0||typeof n.LogOrchestratorClass==`function`)&&(n.LogDiscoveryOrchestratorClass===void 0||typeof n.LogDiscoveryOrchestratorClass==`function`)}function me(e,t,n,r){return{enabled:n?.enabled??!0,pollIntervalMs:n?.pollIntervalMs,eventsPerSecond:n?.eventsPerSecond,adapterId:e,adapterName:t,checkMakaioManaged:n?.checkMakaioManaged,machineId:r}}function he(e,t,n,r,i,a){if(!r&&!i)return null;let o=me(e,t,n,a);return e=>o.enabled?e===`discover`&&i?new i(o):e===`import`&&r?new r(o):null:null}async function ge(e,n,r,i){try{let a=await r.requestOptional(t.getMode,{adapterName:n});if(!a.handled)return;let{mode:o}=a.data;if(o===`disabled`)return;await i(e,o)}catch(e){console.warn(`[LogImport] Failed to restore persisted mode for '${n}':`,e)}}async function q(e,t,n){if(!pe(e)||n.getImporter(e.id)!==void 0)return;await n.register({id:e.id,adapterName:e.adapterName,displayName:e.displayName,source:K({hasAdapterContribution:!0}),importer:new e.registration.LogImporterClass({adapterId:e.id,adapterName:e.adapterName}),logFilePattern:e.registration.logFilePattern,clientId:e.registration.clientId,machineId:e.machineId});let r=he(e.id,e.adapterName,e.logImportConfig,e.registration.LogOrchestratorClass,e.registration.LogDiscoveryOrchestratorClass,e.machineId);r&&n.setOrchestratorFactory(e.id,r),await ge(e.id,e.adapterName,t,(e,t)=>n.switchMode(e,t))}async function _e(e,t,n){let r=e.on(p.register,async t=>{await q(t.payload.provider,e,n)},{filter:{capabilityId:`log-import`}});for(let r of t?.getProviders(`log-import`)??[])await q(r,e,n);return r}async function J(e,t){let n=e.get(t);if(n)try{n.orchestrator.isRunning()&&await n.orchestrator.stop()}finally{try{await n.orchestrator.dispose()}finally{e.delete(t)}}}async function ve(e,t){try{await e.start()}catch(n){try{try{e.isRunning()&&await e.stop()}finally{await e.dispose()}}catch(e){console.warn(`[LogImportRegistry] Failed to clean up orchestrator after start failure for '${t}'.`,e instanceof Error?e.message:String(e))}throw n}}var Y=class{bus;capabilityService;registrations=new Map;orchestrators=new Map;cleanupHandlers=[];initialized=!1;constructor(e){this.bus=e?.bus??d,this.capabilityService=e?.capabilityService}async init(){if(this.initialized)return;let e=this.bus.on(t.listImporters,e=>{let t=this.listImporters();e.setResult({importers:t})});this.cleanupHandlers.push(e);let n=de(this.bus,e=>this.getImporterByAdapterName(e));this.cleanupHandlers.push(n);let r=H(this.bus,e=>this.getImporterByAdapterName(e));this.cleanupHandlers.push(r);let i=U(this.bus,e=>this.getImporterByAdapterName(e));this.cleanupHandlers.push(i);let a=G(this.bus,e=>this.getImporterByAdapterName(e));this.cleanupHandlers.push(a);let o=await _e(this.bus,this.capabilityService,this);this.cleanupHandlers.push(o),this.initialized=!0}async register(e){if(this.registrations.has(e.id))throw Error(`Log importer '${e.id}' is already registered`);this.registrations.set(e.id,e)}async unregister(e){if(!this.registrations.has(e))throw Error(`Log importer '${e}' is not registered`);await J(this.orchestrators,e),this.registrations.delete(e)}async startImporter(e){if(!this.registrations.get(e))throw Error(`Log importer '${e}' is not registered`);let t=this.orchestrators.get(e);if(!t)throw Error(`No orchestrator available for '${e}'. Orchestrators must be created and provided by the adapter or extension before starting.`);t.orchestrator.isRunning()||(await t.orchestrator.start(),t.isManaged=!0)}async stopImporter(e){let t=this.orchestrators.get(e);t&&(t.orchestrator.isRunning()&&await t.orchestrator.stop(),t.isManaged=!1)}async switchMode(e,t){let n=this.registrations.get(e);if(!n)throw Error(`Log importer '${e}' is not registered`);if(await J(this.orchestrators,e),t===`disabled`||!n.orchestratorFactory)return;let r=n.orchestratorFactory(t);r&&(await ve(r,e),this.orchestrators.set(e,{orchestrator:r,isManaged:!0}))}async startDiscovery(e){return this.switchMode(e,`discover`)}setOrchestratorFactory(e,t){let n=this.registrations.get(e);if(!n)throw Error(`Cannot set orchestrator factory for unregistered importer '${e}'`);this.registrations.set(e,{...n,orchestratorFactory:t})}listImporters(){let e=[];for(let[,t]of this.registrations){let n=this.orchestrators.get(t.id)?.orchestrator.isRunning()??!1;e.push({id:t.id,adapterName:t.adapterName,displayName:t.displayName,source:t.source,logFilePattern:t.logFilePattern,isRunning:n,supportsManualImport:t.supportsManualImport??!0,...t.clientId!==void 0&&{clientId:t.clientId}})}return e}getImporter(e){let t=this.registrations.get(e);return t?{...t}:void 0}getImporterByAdapterName(e){for(let t of this.registrations.values())if(t.adapterName===e)return{...t}}detectImporter(e){let t,n=0;for(let r of this.registrations.values()){let i=r.importer.canHandle(e);if(i===!1)continue;let a=i===!0?1:i.confidence;a>n&&(n=a,t=r)}return t}async registerOrchestrator(e,t){if(!this.registrations.has(e))throw Error(`Cannot register orchestrator for unregistered importer '${e}'`);await J(this.orchestrators,e),this.orchestrators.set(e,{orchestrator:t,isManaged:!1})}async destroy(){if(!(!this.initialized&&this.orchestrators.size===0&&this.cleanupHandlers.length===0)){for(let[e]of this.orchestrators)await J(this.orchestrators,e);for(let e of this.cleanupHandlers)e();this.cleanupHandlers.length=0,this.initialized=!1}}};const X=te(`log-import-registry`),ye={name:X.name,displayName:`Log Import Registry`,version:`0.1.0`,critical:!0,namespaces:[e],create:e=>new Y({bus:e.bus})};function be(e,t,n,r){return{enabled:n?.enabled??!0,pollIntervalMs:n?.pollIntervalMs,eventsPerSecond:n?.eventsPerSecond,adapterId:e,adapterName:t,checkMakaioManaged:n?.checkMakaioManaged,machineId:r}}function xe(e,t,n,r){if(!n.LogOrchestratorClass&&!n.LogDiscoveryOrchestratorClass)return null;let i=be(e,t,n.logImportConfig,r);return e=>i.enabled?e===`discover`&&n.LogDiscoveryOrchestratorClass?new n.LogDiscoveryOrchestratorClass(i):e===`import`&&n.LogOrchestratorClass?new n.LogOrchestratorClass(i):null:null}function Se(){let e=new Map;return{filter:e=>!!e.logImport,processActivated:async(t,n,r)=>{let{logImport:i}=n;if(!i)return;let a=r.getService(X);if(!a)throw Error(`[LogImportContributionProcessor] LogImportRegistry is not available. Ensure '${X.name}' is listed as a dependency before activating '${t}'.`);let{adapterName:o,displayName:s,config:c}=i,l=c,u=`package:${t}`,d=K({hasAdapterContribution:!!n.adapters?.length}),f=new l.LogImporterClass({adapterId:u,adapterName:o});await a.register({id:u,adapterName:o,displayName:s,source:d,importer:f,logFilePattern:l.logFilePattern??``,clientId:l.clientId,supportsManualImport:l.supportsManualImport,machineId:r.machineId});try{let e=xe(u,o,l,r.machineId);e&&a.setOrchestratorFactory(u,e)}catch(e){try{await a.unregister(u)}catch(e){console.error(`[LogImportContributionProcessor] Rollback of log importer '${u}' failed:`,e)}throw e}console.info(`[LogImportContributionProcessor] Registered log importer '${o}' from package: ${t}`),e.set(u,async()=>{try{await a.unregister(u)}catch(e){console.error(`[LogImportContributionProcessor] Failed to unregister log importer '${u}' during cleanup:`,e)}})},processStopped:async t=>{let n=`package:${t}`,r=e.get(n);r&&(e.delete(n),await r())}}}const Ce={linked:`linked`,persisted:`persisted`,finalized:`finalized`},Z=g(`log_import_settings`,e=>({adapterName:e.text(`adapter_name`).primaryKey(),mode:e.textEnum(`mode`,{enum:[`disabled`,`discover`,`import`]}).notNull().default(`disabled`),createdAt:e.epochMs(`created_at`).notNull(),updatedAt:e.epochMs(`updated_at`).notNull()})),we=Z.sqlite,Te=Z.postgres,Q=ne({logImportSettings:we},{logImportSettings:Te});function $(e){return{adapterName:e.adapterName,mode:e.mode,createdAt:e.createdAt,updatedAt:e.updatedAt}}function Ee(e){let{bus:n,db:r}=e,{logImportSettings:i}=_(r,Q);return n.on(t.getMode,async e=>{let{adapterName:t}=e.payload,[n]=await r.select().from(i).where(re(i.adapterName,t)).limit(1);e.setResult({mode:n?.mode??`disabled`})})}function De(e){let{bus:n,db:r}=e,{logImportSettings:i}=_(r,Q);return n.on(t.setMode,async e=>{let{adapterName:t,mode:n}=e.payload,a=Date.now();await r.insert(i).values({adapterName:t,mode:n,createdAt:a,updatedAt:a}).onConflictDoUpdate({target:i.adapterName,set:{mode:n,updatedAt:a}}),e.setResult({success:!0})})}function Oe(e){let{bus:n,db:r}=e,{logImportSettings:i}=_(r,Q);return n.on(t.listSettings,async e=>{let t=await r.select().from(i);e.setResult({settings:t.map($)})})}function ke(e,t){let n={bus:e,db:t},r=[Ee(n),De(n),Oe(n)];return()=>r.forEach(e=>e())}export{Ce as ImportPhase,e as LogImportNamespace,Y as LogImportRegistry,X as LogImportRegistryToken,t as LogImportSubjects,E as appendSessionCompactedEvent,Se as createLogImportContributionProcessor,V as importFromFileContent,ye as logImportRegistryPackage,B as persistImportResultTree,ke as registerDrizzleLogImportStorage,G as registerImportFileHandler,$ as rowToSettings};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as IMPORT_LAST_SCAN_CATEGORY, r as LogImportMode, t as LogImporterInfo } from "../../index-
|
|
1
|
+
import { n as IMPORT_LAST_SCAN_CATEGORY, r as LogImportMode, t as LogImporterInfo } from "../../index-D7rWAEY0.mjs";
|
|
2
2
|
import { LogImportSubjects } from "./namespace.mjs";
|
|
3
3
|
export { IMPORT_LAST_SCAN_CATEGORY, type LogImportMode, LogImportSubjects, type LogImporterInfo };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"../../schemas-
|
|
1
|
+
import{n as e}from"../../schemas-DZGnr9Tl.mjs";import{LogImportSubjects as t}from"./namespace.mjs";export{e as IMPORT_LAST_SCAN_CATEGORY,t as LogImportSubjects};
|
|
@@ -80,6 +80,7 @@ declare const LogImportNamespace: _$_makaio_core0.BusNamespaceDefinition<"log-im
|
|
|
80
80
|
logFilePattern: _$zod.ZodString;
|
|
81
81
|
isRunning: _$zod.ZodBoolean;
|
|
82
82
|
supportsManualImport: _$zod.ZodDefault<_$zod.ZodBoolean>;
|
|
83
|
+
clientId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
83
84
|
}, _$zod_v4_core0.$strip>>;
|
|
84
85
|
}, _$zod_v4_core0.$strip>;
|
|
85
86
|
};
|
|
@@ -116,12 +117,38 @@ declare const LogImportNamespace: _$_makaio_core0.BusNamespaceDefinition<"log-im
|
|
|
116
117
|
request: _$zod.ZodObject<{
|
|
117
118
|
adapterSessionId: _$zod.ZodString;
|
|
118
119
|
adapterName: _$zod.ZodString;
|
|
120
|
+
ingestionMarker: _$zod.ZodOptional<_$zod.ZodEnum<{
|
|
121
|
+
live: "live";
|
|
122
|
+
backfill: "backfill";
|
|
123
|
+
}>>;
|
|
119
124
|
}, _$zod_v4_core0.$strip>;
|
|
120
125
|
response: _$zod.ZodObject<{
|
|
121
126
|
sessionId: _$zod.ZodString;
|
|
122
127
|
messageCount: _$zod.ZodNumber;
|
|
123
128
|
}, _$zod_v4_core0.$strip>;
|
|
124
129
|
};
|
|
130
|
+
importFile: {
|
|
131
|
+
request: _$zod.ZodObject<{
|
|
132
|
+
filePath: _$zod.ZodString;
|
|
133
|
+
adapterName: _$zod.ZodString;
|
|
134
|
+
ingestionMarker: _$zod.ZodOptional<_$zod.ZodEnum<{
|
|
135
|
+
live: "live";
|
|
136
|
+
backfill: "backfill";
|
|
137
|
+
}>>;
|
|
138
|
+
}, _$zod_v4_core0.$strip>;
|
|
139
|
+
response: _$zod.ZodDiscriminatedUnion<[_$zod.ZodObject<{
|
|
140
|
+
status: _$zod.ZodLiteral<"imported">;
|
|
141
|
+
sessionId: _$zod.ZodString;
|
|
142
|
+
messageCount: _$zod.ZodNumber;
|
|
143
|
+
turnCount: _$zod.ZodNumber;
|
|
144
|
+
}, _$zod_v4_core0.$strip>, _$zod.ZodObject<{
|
|
145
|
+
status: _$zod.ZodLiteral<"skipped">;
|
|
146
|
+
reason: _$zod.ZodEnum<{
|
|
147
|
+
"no-importer": "no-importer";
|
|
148
|
+
"file-missing": "file-missing";
|
|
149
|
+
}>;
|
|
150
|
+
}, _$zod_v4_core0.$strip>], "status">;
|
|
151
|
+
};
|
|
125
152
|
getMode: {
|
|
126
153
|
request: _$zod.ZodObject<{
|
|
127
154
|
adapterName: _$zod.ZodString;
|
|
@@ -240,6 +267,7 @@ declare const LogImportSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.Fla
|
|
|
240
267
|
logFilePattern: _$zod.ZodString;
|
|
241
268
|
isRunning: _$zod.ZodBoolean;
|
|
242
269
|
supportsManualImport: _$zod.ZodDefault<_$zod.ZodBoolean>;
|
|
270
|
+
clientId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
243
271
|
}, _$zod_v4_core0.$strip>>;
|
|
244
272
|
}, _$zod_v4_core0.$strip>;
|
|
245
273
|
};
|
|
@@ -276,12 +304,38 @@ declare const LogImportSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.Fla
|
|
|
276
304
|
request: _$zod.ZodObject<{
|
|
277
305
|
adapterSessionId: _$zod.ZodString;
|
|
278
306
|
adapterName: _$zod.ZodString;
|
|
307
|
+
ingestionMarker: _$zod.ZodOptional<_$zod.ZodEnum<{
|
|
308
|
+
live: "live";
|
|
309
|
+
backfill: "backfill";
|
|
310
|
+
}>>;
|
|
279
311
|
}, _$zod_v4_core0.$strip>;
|
|
280
312
|
response: _$zod.ZodObject<{
|
|
281
313
|
sessionId: _$zod.ZodString;
|
|
282
314
|
messageCount: _$zod.ZodNumber;
|
|
283
315
|
}, _$zod_v4_core0.$strip>;
|
|
284
316
|
};
|
|
317
|
+
importFile: {
|
|
318
|
+
request: _$zod.ZodObject<{
|
|
319
|
+
filePath: _$zod.ZodString;
|
|
320
|
+
adapterName: _$zod.ZodString;
|
|
321
|
+
ingestionMarker: _$zod.ZodOptional<_$zod.ZodEnum<{
|
|
322
|
+
live: "live";
|
|
323
|
+
backfill: "backfill";
|
|
324
|
+
}>>;
|
|
325
|
+
}, _$zod_v4_core0.$strip>;
|
|
326
|
+
response: _$zod.ZodDiscriminatedUnion<[_$zod.ZodObject<{
|
|
327
|
+
status: _$zod.ZodLiteral<"imported">;
|
|
328
|
+
sessionId: _$zod.ZodString;
|
|
329
|
+
messageCount: _$zod.ZodNumber;
|
|
330
|
+
turnCount: _$zod.ZodNumber;
|
|
331
|
+
}, _$zod_v4_core0.$strip>, _$zod.ZodObject<{
|
|
332
|
+
status: _$zod.ZodLiteral<"skipped">;
|
|
333
|
+
reason: _$zod.ZodEnum<{
|
|
334
|
+
"no-importer": "no-importer";
|
|
335
|
+
"file-missing": "file-missing";
|
|
336
|
+
}>;
|
|
337
|
+
}, _$zod_v4_core0.$strip>], "status">;
|
|
338
|
+
};
|
|
285
339
|
getMode: {
|
|
286
340
|
request: _$zod.ZodObject<{
|
|
287
341
|
adapterName: _$zod.ZodString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../../schemas-
|
|
1
|
+
import{t as e}from"../../schemas-DZGnr9Tl.mjs";import{createBusNamespace as t}from"@makaio/framework/core";const n=t(`log-import`,e),r=n.subjects;export{n as LogImportNamespace,r as LogImportSubjects};
|
|
@@ -96,6 +96,7 @@ declare const LogImportSchemas: {
|
|
|
96
96
|
logFilePattern: z.ZodString;
|
|
97
97
|
isRunning: z.ZodBoolean;
|
|
98
98
|
supportsManualImport: z.ZodDefault<z.ZodBoolean>;
|
|
99
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
99
100
|
}, z.core.$strip>>;
|
|
100
101
|
}, z.core.$strip>;
|
|
101
102
|
};
|
|
@@ -139,12 +140,55 @@ declare const LogImportSchemas: {
|
|
|
139
140
|
request: z.ZodObject<{
|
|
140
141
|
adapterSessionId: z.ZodString;
|
|
141
142
|
adapterName: z.ZodString;
|
|
143
|
+
ingestionMarker: z.ZodOptional<z.ZodEnum<{
|
|
144
|
+
live: "live";
|
|
145
|
+
backfill: "backfill";
|
|
146
|
+
}>>;
|
|
142
147
|
}, z.core.$strip>;
|
|
143
148
|
response: z.ZodObject<{
|
|
144
149
|
sessionId: z.ZodString;
|
|
145
150
|
messageCount: z.ZodNumber;
|
|
146
151
|
}, z.core.$strip>;
|
|
147
152
|
};
|
|
153
|
+
/**
|
|
154
|
+
* Import a transcript file by path, addressable without prior discovery.
|
|
155
|
+
*
|
|
156
|
+
* Subject: `log-import.importFile`
|
|
157
|
+
* Type: Request (RPC)
|
|
158
|
+
* Purpose: Parses the given transcript file with the named importer and
|
|
159
|
+
* persists the resulting segment tree (messages + turns).
|
|
160
|
+
*
|
|
161
|
+
* **Graceful-absence contract:** unlike `importSession`, this subject NEVER
|
|
162
|
+
* throws for a missing importer registration — framework-only hosts (no
|
|
163
|
+
* product importers contributed) receive a `skipped` status with reason
|
|
164
|
+
* `no-importer`. It is addressable by file path directly (no prior
|
|
165
|
+
* discovery stub required) and performs a full re-parse from byte 0,
|
|
166
|
+
* relying on message/turn idempotency (import cursors do not persist parser
|
|
167
|
+
* state across restarts). Concurrent calls for the same `filePath` are
|
|
168
|
+
* serialized by the handler.
|
|
169
|
+
*/
|
|
170
|
+
importFile: {
|
|
171
|
+
request: z.ZodObject<{
|
|
172
|
+
filePath: z.ZodString;
|
|
173
|
+
adapterName: z.ZodString;
|
|
174
|
+
ingestionMarker: z.ZodOptional<z.ZodEnum<{
|
|
175
|
+
live: "live";
|
|
176
|
+
backfill: "backfill";
|
|
177
|
+
}>>;
|
|
178
|
+
}, z.core.$strip>;
|
|
179
|
+
response: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
180
|
+
status: z.ZodLiteral<"imported">;
|
|
181
|
+
sessionId: z.ZodString;
|
|
182
|
+
messageCount: z.ZodNumber;
|
|
183
|
+
turnCount: z.ZodNumber;
|
|
184
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
185
|
+
status: z.ZodLiteral<"skipped">;
|
|
186
|
+
reason: z.ZodEnum<{
|
|
187
|
+
"no-importer": "no-importer";
|
|
188
|
+
"file-missing": "file-missing";
|
|
189
|
+
}>;
|
|
190
|
+
}, z.core.$strip>], "status">;
|
|
191
|
+
};
|
|
148
192
|
/**
|
|
149
193
|
* Resolve the effective global import mode for a given adapter.
|
|
150
194
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../../schemas-
|
|
1
|
+
import{t as e}from"../../schemas-DZGnr9Tl.mjs";export{e as LogImportSchemas};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as PreferenceValueSchema, i as PreferenceKeySchema, n as PreferenceItemSchema, o as PreferencesSchemas, r as PreferenceKey, t as PreferenceItem } from "../../schemas-
|
|
2
|
-
import { n as PreferencesSubjects, t as PreferencesNamespace } from "../../storage-namespace-
|
|
1
|
+
import { a as PreferenceValueSchema, i as PreferenceKeySchema, n as PreferenceItemSchema, o as PreferencesSchemas, r as PreferenceKey, t as PreferenceItem } from "../../schemas-DnmbwE_V.mjs";
|
|
2
|
+
import { n as PreferencesSubjects, t as PreferencesNamespace } from "../../storage-namespace-BvRF22by.mjs";
|
|
3
3
|
export { type PreferenceItem, PreferenceItemSchema, type PreferenceKey, PreferenceKeySchema, PreferenceValueSchema, PreferencesNamespace, PreferencesSchemas, PreferencesSubjects };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as PreferenceValueSchema, i as PreferenceKeySchema, n as PreferenceItemSchema, o as PreferencesSchemas, r as PreferenceKey, t as PreferenceItem } from "../../schemas-
|
|
1
|
+
import { a as PreferenceValueSchema, i as PreferenceKeySchema, n as PreferenceItemSchema, o as PreferencesSchemas, r as PreferenceKey, t as PreferenceItem } from "../../schemas-DnmbwE_V.mjs";
|
|
2
2
|
export { PreferenceItem, PreferenceItemSchema, PreferenceKey, PreferenceKeySchema, PreferenceValueSchema, PreferencesSchemas };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as PreferenceValueSchema, i as PreferenceKeySchema, n as PreferenceItemSchema, o as PreferencesSchemas, r as PreferenceKey, t as PreferenceItem } from "../../schemas-
|
|
2
|
-
import { n as PreferencesSubjects, t as PreferencesNamespace } from "../../storage-namespace-
|
|
1
|
+
import { a as PreferenceValueSchema, i as PreferenceKeySchema, n as PreferenceItemSchema, o as PreferencesSchemas, r as PreferenceKey, t as PreferenceItem } from "../../schemas-DnmbwE_V.mjs";
|
|
2
|
+
import { n as PreferencesSubjects, t as PreferencesNamespace } from "../../storage-namespace-BvRF22by.mjs";
|
|
3
3
|
export { PreferenceItem, PreferenceItemSchema, PreferenceKey, PreferenceKeySchema, PreferenceValueSchema, PreferencesNamespace, PreferencesSchemas, PreferencesSubjects };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as registerCompressHandler, i as registerForkHandler, n as routeToAgents, o as registerAttachHandler, r as registerMergeHandler, s as registerAbandonHandler, t as routeToAgentsCore } from "../../../index-
|
|
1
|
+
import { a as registerCompressHandler, i as registerForkHandler, n as routeToAgents, o as registerAttachHandler, r as registerMergeHandler, s as registerAbandonHandler, t as routeToAgentsCore } from "../../../index-BvTd61i5.mjs";
|
|
2
2
|
export { registerAbandonHandler, registerAttachHandler, registerCompressHandler, registerForkHandler, registerMergeHandler, routeToAgents, routeToAgentsCore };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,i as n,l as r,r as i,t as a,u as o}from"../../../handlers-
|
|
1
|
+
import{a as e,c as t,i as n,l as r,r as i,t as a,u as o}from"../../../handlers-B74FvKlA.mjs";export{t as registerAbandonHandler,o as registerAttachHandler,e as registerCompressHandler,n as registerForkHandler,i as registerMergeHandler,a as routeToAgents,r as routeToAgentsCore};
|