@makaio/framework 1.0.0-dev-1782130828143 → 1.0.0-dev-1782135086866

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.
Files changed (76) hide show
  1. package/dist/.makaio-build.json +2 -2
  2. package/dist/adapter-subsystem/index.mjs +1 -1
  3. package/dist/adapters/index.d.mts +1 -1
  4. package/dist/contracts/adapter/index.d.mts +1 -1
  5. package/dist/contracts/artifact/index.d.mts +1 -1
  6. package/dist/contracts/client/index.d.mts +1 -1
  7. package/dist/contracts/config/index.d.mts +6 -6
  8. package/dist/contracts/extension/index.d.mts +2 -2
  9. package/dist/contracts/facet/index.d.mts +1 -1
  10. package/dist/contracts/harness/index.d.mts +1 -1
  11. package/dist/contracts/index.d.mts +45 -45
  12. package/dist/contracts/materialization/index.d.mts +3 -3
  13. package/dist/contracts/provider/index.d.mts +1 -1
  14. package/dist/contracts/session/index.d.mts +2 -2
  15. package/dist/contracts/workflow/index.d.mts +2 -2
  16. package/dist/{definition-0EXM1tyu.d.mts → definition-DePb3ke-.d.mts} +1 -1
  17. package/dist/{extension-BJHRahFl.mjs → extension-DZqYHmhK.mjs} +1 -1
  18. package/dist/{index-DnLf0YKC.d.mts → index-2fK9iSHI.d.mts} +12 -12
  19. package/dist/{index-C3bheiJg.d.mts → index-5v0jVUGD.d.mts} +15 -15
  20. package/dist/{index-gKaw_TMU.d.mts → index-BAQ6QBcU.d.mts} +16 -16
  21. package/dist/{index-BW9kVuY2.d.mts → index-BMbmoarE.d.mts} +24 -24
  22. package/dist/{index-DBIqKoFm.d.mts → index-BvFjmhZj.d.mts} +61 -61
  23. package/dist/{index-Cx1Bm6WD.d.mts → index-BvjLe_w9.d.mts} +8 -8
  24. package/dist/{index-DBxYWBvw.d.mts → index-CUSOL0X_.d.mts} +3 -3
  25. package/dist/{index-BAnDvAk4.d.mts → index-CYHWOXUm.d.mts} +1 -1
  26. package/dist/{index-DImePakw.d.mts → index-CcAggMuC.d.mts} +20 -20
  27. package/dist/{index-CTEsbp9H.d.mts → index-D2WJ0Zpt.d.mts} +5 -5
  28. package/dist/{index-CG5h1g3H.d.mts → index-DIKiA3Sr.d.mts} +13 -1
  29. package/dist/{index-BjPtzjH6.d.mts → index-DvLCzle5.d.mts} +12 -12
  30. package/dist/{index-dZwlJDpU.d.mts → index-bRLjj6L4.d.mts} +92 -92
  31. package/dist/{index-DeVMGLbP.d.mts → index-pUYIAV_M.d.mts} +5 -5
  32. package/dist/{index-CfIW5biI.d.mts → index-wfSedMR9.d.mts} +1 -1
  33. package/dist/kernel/extension/index.d.mts +1 -1
  34. package/dist/kernel/extension/index.mjs +1 -1
  35. package/dist/kernel/index.d.mts +2 -2
  36. package/dist/kernel/index.mjs +1 -1
  37. package/dist/kernel/observability/index.d.mts +1 -1
  38. package/dist/{namespace-Dybz75l5.d.mts → namespace-B95uYmZB.d.mts} +26 -26
  39. package/dist/{namespace-DxyTww2j.d.mts → namespace-BMglTf9p.d.mts} +36 -36
  40. package/dist/{namespace-4xHw59K8.d.mts → namespace-Bm77p82L.d.mts} +1 -1
  41. package/dist/{namespace-KMxsPJwm.d.mts → namespace-Bv8B89uB.d.mts} +9 -9
  42. package/dist/{namespace-BLOld9Wa.d.mts → namespace-CfvtDD_U.d.mts} +2 -2
  43. package/dist/{namespace-DXWpFdQH2.d.mts → namespace-D8P8Sxce2.d.mts} +2 -2
  44. package/dist/package.json +1 -1
  45. package/dist/{schema-DqfR-im7.d.mts → schema-GFRQiPk0.d.mts} +2 -2
  46. package/dist/{schemas-CgX7mPkv.d.mts → schemas-CoFCV42v.d.mts} +2 -2
  47. package/dist/{schemas-DDaP5WkH.d.mts → schemas-D512XweP.d.mts} +4 -4
  48. package/dist/{schemas-CBt7Ld8G2.d.mts → schemas-TQPiRl642.d.mts} +9 -9
  49. package/dist/services/adapter-subsystem/index.d.mts +2 -2
  50. package/dist/services/adapter-subsystem/namespace.d.mts +1 -1
  51. package/dist/services/agent-runtime/index.d.mts +2 -2
  52. package/dist/services/agent-runtime/namespace.d.mts +1 -1
  53. package/dist/services/agent-runtime/schemas.d.mts +1 -1
  54. package/dist/services/context-rules/index.d.mts +3 -3
  55. package/dist/services/filesystem/namespace.d.mts +6 -6
  56. package/dist/services/filesystem/schemas.d.mts +3 -3
  57. package/dist/services/index.d.mts +38 -38
  58. package/dist/services/log-import/browser.d.mts +2 -2
  59. package/dist/services/log-import/index.d.mts +2 -2
  60. package/dist/services/log-import/log-import.d.mts +1 -1
  61. package/dist/services/log-import/namespace.d.mts +2 -2
  62. package/dist/services/log-import/schemas.d.mts +1 -1
  63. package/dist/services/session/index.d.mts +5 -5
  64. package/dist/services/session/messages/namespace.d.mts +1 -1
  65. package/dist/services/session/session-events/namespace.d.mts +1 -1
  66. package/dist/services/session/storage/namespace.d.mts +1 -1
  67. package/dist/services/session/storage/schema.d.mts +1 -1
  68. package/dist/services/settings/namespace.d.mts +6 -6
  69. package/dist/services/subagent-template/index.d.mts +2 -2
  70. package/dist/services/subagent-template/namespace.d.mts +1 -1
  71. package/dist/services/subagent-template/schemas.d.mts +1 -1
  72. package/dist/{transition-BBElJqQ8.d.mts → transition-Cufc_u3_.d.mts} +1 -1
  73. package/dist/{types-BLG7bl-Q.d.mts → types-CNIsRx86.d.mts} +38 -38
  74. package/dist/{types-BslClRkH.d.mts → types-InWSdi-V.d.mts} +1 -1
  75. package/dist/workflow-engine/index.d.mts +63 -63
  76. package/package.json +1 -1
@@ -1 +1 @@
1
- import{n as e}from"./window-registry-PkrFIwX2.mjs";import{n as t}from"./namespace-DibbhCPP.mjs";import{n}from"./extension-namespace-v3K0qVry.mjs";import{t as r}from"./schema-introspection-B7xODt4I.mjs";import{z as i}from"zod";import a from"node:path";import{createBusNamespace as o}from"@makaio/framework/core";import{ProviderDefinitionSchema as s,primaryMigrationsPath as c,versionSatisfies as l}from"@makaio/framework/contracts";import{ToastSubjects as u}from"@makaio/framework/contracts/toast";import{ExtensionWarningSchema as d,getExtensionWarningActionLabel as f}from"@makaio/framework/contracts/extension";import{TrayMenuSubjects as p}from"@makaio/framework/services/tray-menu";const m=i.object({name:i.string(),displayName:i.string()}),h=o(`kernel:boot`,{getState:{request:i.object({}),response:i.object({complete:i.boolean(),completedCount:i.number(),totalCount:i.number(),currentService:i.string().optional(),failedServices:i.array(i.string()),skippedServices:i.array(i.string()).default([]),totalDurationMs:i.number().optional()})},"service.starting":m,"service.ready":m.extend({durationMs:i.number().int().nonnegative()}),"service.failed":m.extend({errorMessage:i.string()}),"service.skipped":m.extend({reason:i.string()}),progress:i.object({completedCount:i.number(),totalCount:i.number(),currentService:i.string().optional()}),complete:i.object({totalDurationMs:i.number(),failedServices:i.array(i.string())})}),g=h.subjects;var _=class extends Error{reason;constructor(e){super(e),this.name=`ServiceSkipError`,this.reason=e}};function v(e){return{name:e.name,displayName:e.displayName}}var y=class{bus;state;cleanup;constructor(e,t){this.bus=e,this.state={complete:!1,completedCount:0,totalCount:t,failedServices:[],skippedServices:[],startedAt:Date.now()},this.cleanup=this.bus.on(g.getState,e=>{e.setResult({complete:this.state.complete,completedCount:this.state.completedCount,totalCount:this.state.totalCount,...this.state.currentService===void 0?{}:{currentService:this.state.currentService},failedServices:[...this.state.failedServices],skippedServices:[...this.state.skippedServices],...this.state.totalDurationMs===void 0?{}:{totalDurationMs:this.state.totalDurationMs}})})}dispose(){this.cleanup()}starting(e){let t=v(e);this.state.currentService=t.displayName,this.state.currentServiceStartedAt=Date.now(),this.bus.emit(g.service.starting,t).catch(e=>{console.warn(`[ExtensionCoordinator] boot.service.starting emit failed for "${t.name}":`,e)})}ready(e){let t=v(e);this.state.completedCount+=1;let n=this.state.currentServiceStartedAt===void 0?0:Math.max(0,Date.now()-this.state.currentServiceStartedAt);this.bus.emit(g.service.ready,{...t,durationMs:n}).catch(e=>{console.warn(`[ExtensionCoordinator] boot.service.ready emit failed for "${t.name}":`,e)}),this.emitProgress()}failed(e,t){let n=v(e);this.state.completedCount+=1,this.state.failedServices.push(n.name),this.bus.emit(g.service.failed,{...n,errorMessage:t}).catch(e=>{console.warn(`[ExtensionCoordinator] boot.service.failed emit failed for "${n.name}":`,e)}),this.emitProgress()}skipped(e,t){let n=v(e);this.state.completedCount+=1,this.state.skippedServices.push(n.name),this.bus.emit(g.service.skipped,{...n,reason:t}).catch(e=>{console.warn(`[ExtensionCoordinator] boot.service.skipped emit failed for "${n.name}":`,e)}),this.emitProgress()}complete(){this.state.complete=!0,delete this.state.currentService,delete this.state.currentServiceStartedAt,this.state.totalDurationMs=Date.now()-this.state.startedAt,this.bus.emit(g.complete,{totalDurationMs:this.state.totalDurationMs,failedServices:[...this.state.failedServices]}).catch(e=>{console.warn(`[ExtensionCoordinator] boot.complete emit failed:`,e)})}emitProgress(){this.bus.emit(g.progress,{completedCount:this.state.completedCount,totalCount:this.state.totalCount,...this.state.currentService===void 0?{}:{currentService:this.state.currentService}}).catch(e=>{console.warn(`[ExtensionCoordinator] boot.progress emit failed:`,e)})}};function ee(e){return{subject:`wiring.apply`,$meta:{namespace:`client:${e}`,isRequest:!0,local:!1,channel:!1,payload:{request:{},response:{}}}}}const b=`action`;function x(e,t){return`${e}:${t}`}function te(e,t,n){return e.on(u.interacted,r=>{let{toastId:i,actionId:a}=r.payload,o=x(i,a),s=t.get(o);s&&S(e,s,i,n).catch(e=>{console.error(`[ExtensionCoordinator] Warning action dispatch failed for toast "${i}":`,e)})})}async function S(e,t,n,r){switch(t.kind){case`configure-integration`:await w(e,t.clientId,n,r);break;case`open-url`:console.info(`[ExtensionCoordinator] Toast "${n}" open-url action not routable from runtime layer: ${t.url}`);break;case`run-command`:console.info(`[ExtensionCoordinator] Toast "${n}" run-command action not routable from runtime layer: ${t.command}`);break;case`install-extension`:console.info(`[ExtensionCoordinator] Toast "${n}" install-extension action not routable from runtime layer: ${t.extensionName}`);break;default:C(t)}}function C(e){throw Error(`[ExtensionCoordinator] Unsupported warning action: ${JSON.stringify(e)}`)}async function w(e,t,n,r){let i=ee(t),a=await e.requestOptional(i,{scope:`user`,makaioCommand:r});if(!a.handled){console.warn(`[ExtensionCoordinator] Toast "${n}" configure-integration: no wiring handler for client "${t}". Is the client package loaded?`);return}let{applied:o,skipped:s}=a.data;console.info(`[ExtensionCoordinator] Toast "${n}" configure-integration: wired client "${t}" — ${o} applied, ${s} skipped.`)}function T(e){return e.map(e=>({name:e.name,description:e.description,hasInteractive:!!e.interactive,subcommands:e.subcommands.map(e=>({name:e.name,description:e.description,args:r(e.schema)}))}))}async function E(e,t,n){let{command:r,subcommand:i,args:a}=e,o=t.find(e=>e.name===r);if(!o)return{exitCode:1,stdout:[],stderr:[`Unknown command: ${r}`]};let s=o.subcommands.find(e=>e.name===i);if(!s)return{exitCode:1,stdout:[],stderr:[`Unknown subcommand: ${i}`]};let c=s.schema.safeParse(a??{});if(!c.success)return{exitCode:1,stdout:[],stderr:[`Validation failed:`,...c.error.issues.map(e=>` ${e.path.join(`.`)||`(root)`}: ${e.message}`)]};if(o.beforeRun)try{let e=await o.beforeRun({subcommandName:i,args:c.data??{},bus:n});if(!e.proceed)return{exitCode:e.exitCode??1,stdout:[],stderr:[e.message]}}catch(e){return{exitCode:1,stdout:[],stderr:[`beforeRun hook failed: ${e instanceof Error?e.message:String(e)}`]}}let l=[],u=[],d={write:e=>l.push(e),error:e=>u.push(e)},f=0,p=new AbortController().signal;try{await s.handler({args:c.data,bus:n,output:d,signal:p,setExitCode:e=>{f=e}})}catch(e){f===0&&(f=1),u.push(e instanceof Error?e.message:String(e))}return{exitCode:f,stdout:l,stderr:u}}function D(e){let{pkg:t,state:n,error:r,enabled:i}=e;return{name:t.name,displayName:t.displayName,state:n,...t.surface===void 0?{}:{surface:t.surface},enabled:i,...t.browser===void 0?{}:{browser:t.browser},...r===void 0?{}:{error:r}}}function O(e){let r=[];return r.push(e.bus.on(n.list,t=>{t.setResult({extensions:e.list()})})),r.push(e.bus.on(n.get,t=>{let n=e.entries.get(t.payload.name);t.setResult({extension:n?D(n):null})})),r.push(e.bus.on(n.setEnabled,async t=>{let n=await e.handleSetEnabled(t.payload.name,t.payload.enabled);t.setResult({success:n})})),r.push(e.bus.on(n.contributions.catalog,t=>{let n=[],r=[];for(let[t,i]of e.entries)if(i.state===`active`){for(let e of i.pkg.providers??[])n.push({packageName:t,definition:s.parse(e)});for(let e of i.pkg.clients??[])r.push({packageName:t,definition:e})}t.setResult({providers:n,clients:r})})),r.push(e.bus.on(t.listContributions,t=>{t.setResult({contributions:T(e.cliContributions)})})),r.push(e.bus.on(t.execute,async t=>{t.setResult(await E(t.payload,e.cliContributions,e.bus))})),r.push(e.bus.on(n.warnings.list,t=>{let{extensionName:n}=t.payload;if(n!==void 0){let r=e.entries.get(n),i=r&&r.warnings.length>0?[{extensionName:n,warnings:[...r.warnings]}]:[];t.setResult({entries:i});return}let r=[];for(let[t,n]of e.entries)n.warnings.length>0&&r.push({extensionName:t,warnings:[...n.warnings]});t.setResult({entries:r})})),r}async function ne(e){for(let[t,n]of e.entries)n.state===`active`&&await A(e,t,n)}function re(e){if(e&&k(e))return[{id:b,label:f(e)}]}function k(e){return e.kind===`configure-integration`}function ie(e,t){let n=`${t}:`;for(let t of e.keys())t.startsWith(n)&&e.delete(t)}async function A(e,t,n){ie(e.warningActionMap,t);let r=n.warnings.filter(e=>e.severity===`degraded`);if(r.length!==0)for(let i=0;i<r.length;i++){let a=r[i];console.warn(`[${t}] ⚠ ${a.title}: ${a.message}`);let o=`${t}:${a.title}:${i}`,s=re(a.action);try{await e.bus.emit(u.show,{level:`warning`,title:a.title,message:`${n.pkg.displayName}: ${a.message}`,toastId:o,durationMs:null,...s&&{actions:s}}),a.action&&k(a.action)&&e.warningActionMap.set(x(o,b),a.action)}catch(e){console.warn(`[${t}] toast emission failed for warning "${a.title}":`,e)}}}function ae(e){return Object.freeze({extensionName:e})}function oe(e,t,n,r){if(!t)return;let i={...n??{},...r??{}};try{return t.parse(i)}catch(n){console.warn(`[ExtensionCoordinator] Config parse failed for "${e}", starting with schema defaults:`,n instanceof Error?n.message:n);try{return t.parse({})}catch{console.warn(`[ExtensionCoordinator] Fallback config parse also failed for "${e}" — config will be absent`);return}}}function j(e,t,n){let r;if(n.pkg.configSchema)try{r=e.loadConfig?.(t)}catch(e){console.error(`[ExtensionCoordinator] loadConfig threw for "${t}":`,e)}return oe(t,n.pkg.configSchema,n.configDefaults,r)}function M(e,t,n){if(!e.extensionContextBase)throw Error(`ExtensionCoordinator: extensionContextBase is required to start extensions with a create factory. Provide it via the constructor.`);return{...e.extensionContextBase,bus:e.bus,identity:t.identity,dataDir:a.join(e.extensionContextBase.makaioHome,t.identity.extensionName),getService:t=>e.getExtensionService(t.name),signal:e.signal,hasExtension:e.hasActiveExtension,...n===void 0?{}:{config:n}}}function N(e){return{adapters:!!e.adapters?.length,tools:!!e.tools,triggers:!!e.triggers,providers:!!e.providers?.length,clients:!!e.clients?.length,ui:!!e.ui,storage:!!e.storage,sessionEventActions:!!e.sessionEventActions}}function P(e,t,r){let i=t.state;t.state=r,e.emit(n.stateChanged,{name:t.pkg.name,displayName:t.pkg.displayName,from:i,to:r,...t.error===void 0?{}:{error:t.error},contributes:N(t.pkg)}).catch(e=>{console.error(`[ExtensionCoordinator] stateChanged emit failed for "${t.pkg.name}":`,e)})}async function F(e,t,n,r,i){i===`activated`?await I(e,t,n,r):await L(e,n)}async function I(e,t,n,r){let i=[];try{for(let a of e){if(a.filter&&!a.filter(r.pkg))continue;let e=M(t,r,j(t,n,r));await a.processActivated(n,r.pkg,e),i.push(a)}}catch(e){for(let e of i.reverse())if(e.processStopped)try{await e.processStopped(n)}catch(e){console.error(`[ExtensionCoordinator] Contribution processor rollback error for "${n}":`,e)}throw e}}async function L(e,t){for(let n of[...e].reverse())if(n.processStopped)try{await n.processStopped(t)}catch(e){console.error(`[ExtensionCoordinator] Contribution processor error (stopped) for "${t}":`,e)}}async function R(e,t,r){let i=e.entries.get(t);if(!i)return!1;let a=r?await z(e,t,i):await B(e,t,i),o=i.enabled===r;return!a&&!o||(await e.persistEnabled?.(t,r),!a)?!1:(e.bus.emit(n.enabledChanged,{name:t,enabled:r}).catch(e=>{console.error(`[ExtensionCoordinator] enabledChanged emit failed for "${t}":`,e)}),!0)}async function z(e,t,n){if(n.state!==`stopped`&&n.state!==`failed`&&n.state!==`skipped`)return!1;let{pkg:r}=n,i,a=(r.dependencies??[]).filter(t=>{if(t.optional)return!1;let n=e.entries.get(t.name);return!n||n.state!==`active`});if(a.length>0)return n.error=`Required dependencies not active: ${a.map(e=>e.name).join(`, `)}`,console.error(`[ExtensionCoordinator] Cannot re-enable "${t}":`,n.error),P(e.bus,n,`failed`),!1;n.enabled=!0,n.error=void 0,P(e.bus,n,`initializing`);let o=j(e,t,n);if(r.storage?.registerHandlers&&e.db!==void 0)try{let t=M(e,n,o),a=r.storage.registerHandlers(e.bus,e.db,t);typeof a==`function`&&(i=a,n.storageCleanup=a)}catch(r){return n.error=r instanceof Error?r.message:String(r),console.error(`[ExtensionCoordinator] Extension "${t}" storage re-registration failed:`,r),P(e.bus,n,`failed`),!1}if(r.create){let a;try{let t=M(e,n,o);a=await r.create(t),await a.init?.(),n.service=a}catch(r){return await V(t,a,i,n),r instanceof _?n.pkg.critical?(n.error=`Critical extension cannot skip startup: ${r.reason}`,console.error(`[ExtensionCoordinator] Extension "${t}" failed to re-initialize:`,n.error),P(e.bus,n,`failed`),!1):(n.error=r.reason,P(e.bus,n,`skipped`),!1):(n.error=r instanceof Error?r.message:String(r),console.error(`[ExtensionCoordinator] Extension "${t}" failed to re-initialize:`,r),P(e.bus,n,`failed`),!1)}}try{await F(e.contributionProcessors,e,t,n,`activated`)}catch(r){return await V(t,n.service,i,n),n.service=void 0,n.error=r instanceof Error?r.message:String(r),console.error(`[ExtensionCoordinator] Extension "${t}" contribution processing failed:`,r),P(e.bus,n,`failed`),!1}return P(e.bus,n,`active`),await e.runHealthCheck(t),await e.emitWarningsForEntry(t,n),!0}async function B(e,t,r){if(r.state!==`active`)return!1;let i=Array.from(e.entries.entries()).filter(([e,n])=>e===t||n.state!==`active`?!1:n.pkg.dependencies?.some(e=>!e.optional&&e.name===t)??!1).map(([e])=>e);if(i.length>0)return r.error=`Cannot disable "${t}" while active dependents remain: ${i.join(`, `)}`,console.error(`[ExtensionCoordinator] ${r.error}`),!1;if(r.enabled=!1,r.error=void 0,await F(e.contributionProcessors,e,t,r,`stopped`),r.service)try{await r.service.destroy?.()}catch(e){console.error(`[ExtensionCoordinator] Error during disable destroy of "${t}":`,e)}finally{r.service=void 0}if(r.storageCleanup)try{r.storageCleanup()}catch(e){console.error(`[ExtensionCoordinator] Storage cleanup error during disable of "${t}":`,e)}finally{r.storageCleanup=void 0}P(e.bus,r,`stopped`),r.warnings=[];try{await e.bus.emit(n.warnings.changed,{extensionName:t,warnings:[]})}catch(e){console.error(`[ExtensionCoordinator] warnings.changed emit failed for "${t}":`,e)}return!0}async function V(e,t,n,r){try{await t?.destroy?.()}catch(t){console.error(`[ExtensionCoordinator] Service cleanup error after failed enable of "${e}":`,t)}try{n?.()}catch(t){console.error(`[ExtensionCoordinator] Storage cleanup error after failed enable of "${e}":`,t)}finally{r.storageCleanup=void 0}}function H(e){let t=new Map;for(let n of e)t.has(n.name)&&(console.info(`[ExtensionCoordinator] Extension "${n.name}" overrides an earlier registration`),t.delete(n.name)),t.set(n.name,n);return[...t.values()]}function U(e,t,n){let r=new Set(e.map(e=>e.name)),i=e.filter(e=>W(e,t,n)),a=new Map(i.map(e=>[e.name,e])),o=new Set(a.keys()),s=!0;for(;s;){s=!1;for(let e of o)(a.get(e).dependencies??[]).some(e=>!e.optional&&r.has(e.name)&&!o.has(e.name))&&(o.delete(e),s=!0)}return i.filter(e=>o.has(e.name))}function W(e,t,n){if(!K(e,t))return!1;let r=e.requires;return!r||r.length===0||!n?!0:r.every(e=>{switch(e.type){case`host`:return n.hosts.has(e.id);case`capability`:return n.capabilities.has(e.id)?e.version===void 0?!0:G(n,e.id,e.version):!1}})}function G(e,t,n){let r=e.capabilityVersions?.get(t);return r!==void 0&&l(r,n)}function K(e,t){return e.surface===void 0||e.surface===`any`||e.surface===t}function se(e){let t=ce(e);return le(e,t,new Map(e.map(e=>[e.name,e]))),fe(t,de(e,t))}function ce(e){let t=new Set;for(let n of e){if(t.has(n.name))throw Error(`ExtensionCoordinator: duplicate package name detected: "${n.name}"`);t.add(n.name)}return t}function le(e,t,n){for(let r of e)ue(r,t,n)}function ue(e,t,n){let r=e.dependencies??[],i=r.filter(e=>!e.optional&&!t.has(e.name));if(i.length>0)throw Error(`ExtensionCoordinator: package "${e.name}" declares missing dependencies: ${i.map(e=>e.name).join(`, `)}`);for(let t of r){let r=n.get(t.name);if(r===void 0)continue;let i=r.version;if(!l(i,t.version))throw Error(`ExtensionCoordinator: package "${e.name}" dependency "${t.name}" version ${i} does not satisfy ${t.version}`)}}function de(e,t){let n=new Map;for(let r of e){let e=(r.dependencies??[]).filter(e=>t.has(e.name)).map(e=>e.name);n.set(r.name,new Set(e))}return n}function fe(e,t){let n=[];for(let[e,r]of t)r.size===0&&n.push(e);let r=[],i=new Set;for(;n.length>0;){let e=n.shift();if(!i.has(e)){i.add(e),r.push(e);for(let[r,a]of t)a.has(e)&&(a.delete(e),a.size===0&&!i.has(r)&&n.push(r))}}if(r.length!==e.size){let t=[...e].filter(e=>!i.has(e));throw Error(`ExtensionCoordinator: circular dependency detected among: ${t.join(`, `)}`)}return r}async function pe(e){if(!e.runMigrations)return;let t=[];for(let n of e.loadOrder){let r=e.entries.get(n);if(!r)throw Error(`Extension "${n}" is in loadOrder but missing from entries`);let i=r.pkg.storage?.migrations;if(!i)continue;let a,o;if(typeof i==`string`)a=q(n,r.pkg,i);else{let e={};for(let[t,a]of Object.entries(i))a!==void 0&&(e[t]=q(n,r.pkg,a));let t=c(e);if(t===void 0)continue;a=t,o=e}t.push({name:n,migrationsPath:a,migrationSourceId:r.pkg.storage?.migrationSourceId??a,...o?{migrationsPathByDialect:o}:{}})}t.length!==0&&await e.runMigrations(t)}function q(e,t,n){if(a.isAbsolute(n))return n;let r=t.storage?.packageRoot;if(!r)throw Error(`Extension "${e}" declares relative storage.migrations "${n}" without storage.packageRoot`);let i=a.resolve(r),o=a.resolve(i,n),s=a.relative(i,o);if(s.startsWith(`..`)||a.isAbsolute(s))throw Error(`Extension "${e}" declares storage.migrations "${n}" outside storage.packageRoot`);return o}async function J(e,t){let r=e.entries.get(t);if(!r?.service||r.state!==`active`)return;let{checkHealth:i}=r.service;if(!i)return;let a;try{let e=await i.call(r.service),n=d.array().safeParse(e);n.success?a=n.data:(console.error(`[ExtensionCoordinator] checkHealth for "${t}" returned invalid data:`,n.error),a=[])}catch(e){console.error(`[ExtensionCoordinator] checkHealth threw for "${t}":`,e),a=[]}r.warnings=a;try{await e.bus.emit(n.warnings.changed,{extensionName:t,warnings:[...a]})}catch(e){console.error(`[ExtensionCoordinator] warnings.changed emit failed for "${t}":`,e)}}function me(e,t){if(t.windows)for(let n of t.windows)e.windowRegistry.register(t.name,t.displayName,n);if(t.tray&&e.trayEntries.push({...t.tray,packageName:t.name}),t.cli){let n=t.cli;`subcommands`in n&&e.cliContributions.push(n)}}function he(e){return Array.from(e.values()).filter(e=>e.enabled).map(e=>e.pkg).filter(e=>!!e.http)}async function ge(e){let t=[...e.loadOrder].reverse();for(let n of t){let t=e.entries.get(n);if(t){if(t.state===`active`&&await F(e.contributionProcessors,e.contextHost,n,t,`stopped`),t.service)try{await t.service.destroy?.()}catch(e){console.error(`[ExtensionCoordinator] Error during shutdown of "${n}":`,e)}finally{t.service=void 0}if(t.storageCleanup)try{t.storageCleanup()}catch(e){console.error(`[ExtensionCoordinator] Storage cleanup error for "${n}":`,e)}finally{t.storageCleanup=void 0}t.state===`active`&&P(e.contextHost.bus,t,`stopped`)}}}async function _e(e,t){if(!t.tray)return;let n=Y(t);await e.request(p.register,{entry:n})}function Y(e){let t=e.tray;if(!t)throw Error(`[tray-menu-entry-bridge] extension "${e.name}" does not declare a tray entry`);return{packageName:e.name,entryId:t.opensWindow??t.action??`default`,label:t.label,section:t.section??`views`,priority:50,enabled:!0,metadata:t.opensWindow?{registrationId:`${e.name}:${t.opensWindow}`}:t.action?{action:t.action}:void 0}}async function ve(e,t,n){if(!n.enabled){P(e.bus,n,`skipped`),e.bootProgress.skipped(n.pkg,`disabled`);return}let r=(n.pkg.dependencies??[]).filter(t=>t.optional?!1:e.entries.get(t.name)?.state!==`active`);if(r.length>0){let i=`Required dependencies not active: ${r.map(e=>e.name).join(`, `)}`;if(Q(e,t,n,i),n.pkg.critical)throw Error(`Critical package "${t}" failed: ${i}`);return}e.bootProgress.starting(n.pkg),P(e.bus,n,`initializing`);let i=j(e.contextHost,t,n);if(xe(e,t,n,i)){if(!n.pkg.create){await ye(e,t,n);return}await be(e,t,n,i)}}async function ye(e,t,n){try{await F(e.contributionProcessors,e.contextHost,t,n,`activated`)}catch(r){if(Z(t,n),X(e,t,n,r))return;if(Q(e,t,n,r instanceof Error?r.message:String(r)),n.pkg.critical)throw r;return}P(e.bus,n,`active`),e.bootProgress.ready(n.pkg),await $(e.bus,t,n)}async function be(e,t,n,r){let i;try{let a=M(e.contextHost,n,r);i=await n.pkg.create(a),await i.init?.(),n.service=i,await F(e.contributionProcessors,e.contextHost,t,n,`activated`),P(e.bus,n,`active`),e.bootProgress.ready(n.pkg),await $(e.bus,t,n)}catch(r){try{await i?.destroy?.()}catch(e){console.error(`[ExtensionCoordinator] Service cleanup error after failed start of "${t}":`,e)}if(n.service=void 0,Z(t,n),X(e,t,n,r))return;if(Q(e,t,n,r instanceof Error?r.message:String(r)),n.pkg.critical)throw r}}function X(e,t,n,r){if(!(r instanceof _))return!1;if(n.pkg.critical){let i=`Critical package cannot skip startup: ${r.reason}`;throw Q(e,t,n,i),Error(`Critical package "${t}" failed: ${i}`,{cause:r})}return n.error=r.reason,console.info(`[ExtensionCoordinator] Package "${t}" skipped: ${r.reason}`),P(e.bus,n,`skipped`),e.bootProgress.skipped(n.pkg,r.reason),!0}function xe(e,t,n,r){if(!n.pkg.storage?.registerHandlers||e.db===void 0)return!0;try{let t=M(e.contextHost,n,r),i=n.pkg.storage.registerHandlers(e.bus,e.db,t);return i&&(n.storageCleanup=i),!0}catch(r){let i=r instanceof Error?r.message:String(r);if(console.error(`[ExtensionCoordinator] Package "${t}" storage registration failed:`,r),Q(e,t,n,i),n.pkg.critical)throw r;return!1}}function Z(e,t){if(t.storageCleanup)try{t.storageCleanup()}catch(t){console.error(`[ExtensionCoordinator] Storage cleanup error after failed start of "${e}":`,t)}finally{t.storageCleanup=void 0}}function Q(e,t,n,r){n.error=r,console.error(`[ExtensionCoordinator] Package "${t}" failed:`,r),P(e.bus,n,`failed`),e.bootProgress.failed(n.pkg,r)}async function $(e,t,n){try{await _e(e,n.pkg)}catch(e){console.warn(`[ExtensionCoordinator] Failed to register tray entry for ${t}:`,e)}}var Se=class{bus;surface;db;extensionContextBase;runtimeEnvironment;shutdownController=new AbortController;entries=new Map;loadOrder=[];loaded=!1;started=!1;rpcCleanups=[];contributionProcessors=[];warningActionMap=new Map;windowRegistry=new e;_trayEntries=[];_cliContributions=[];persistEnabled;loadEnabled;loadConfig;runMigrations;constructor(e,t={}){this.bus=e,this.surface=t.surface??`headless`,this.db=t.db,this.extensionContextBase=t.extensionContextBase,this.runtimeEnvironment=t.runtimeEnvironment,this.persistEnabled=t.persistEnabled,this.loadEnabled=t.loadEnabled,this.loadConfig=t.loadConfig,this.runMigrations=t.runMigrations,this.rpcCleanups.push(te(this.bus,this.warningActionMap,t.launcherCommand??`makaio`))}get trayEntries(){return this._trayEntries.map(e=>({...e}))}get cliContributions(){return this._cliContributions}extensionsWithHttp(){return he(this.entries)}load(e,t){if(this.loaded)throw Error(`ExtensionCoordinator.load() called twice. The coordinator is single-use; create a new instance if needed.`);let n=H(U(e,this.surface,this.runtimeEnvironment));this.loadOrder=se(n);for(let e of this.loadOrder){let r=n.find(t=>t.name===e),i={pkg:r,identity:ae(r.name),state:`discovered`,enabled:this.loadEnabled?.(e)!==!1,warnings:[]};if(t){let n=t.get(e);n&&(i.configDefaults=n)}this.entries.set(e,i),r.namespaces&&this.bus.registerNamespaces(r.namespaces),me({windowRegistry:this.windowRegistry,trayEntries:this._trayEntries,cliContributions:this._cliContributions},r)}this.rpcCleanups.push(...O({bus:this.bus,entries:this.entries,cliContributions:this._cliContributions,list:()=>this.list(),handleSetEnabled:(e,t)=>this.handleSetEnabled(e,t)})),this.loaded=!0}async startAll(){if(!this.loaded)throw Error(`ExtensionCoordinator.startAll() called before load(). Call load() first.`);if(this.started)throw Error(`ExtensionCoordinator.startAll() called twice. The coordinator is single-use; create a new instance if needed.`);this.started=!0;let e=new y(this.bus,this.loadOrder.length);this.rpcCleanups.push(()=>e.dispose());try{await pe({loadOrder:this.loadOrder,entries:this.entries,runMigrations:this.runMigrations});for(let t of this.loadOrder){let n=this.entries.get(t);n&&await ve({bus:this.bus,db:this.db,entries:this.entries,contributionProcessors:this.contributionProcessors,contextHost:this.createExtensionContextHost(),bootProgress:e},t,n)}let t=this.createExtensionHealthHost();await Promise.all(this.loadOrder.map(e=>this.entries.get(e)?.state===`active`?J(t,e):void 0)),await ne({bus:this.bus,entries:this.entries,warningActionMap:this.warningActionMap})}finally{e.complete()}}async shutdown(){this.shutdownController.abort();for(let e of this.rpcCleanups)e();this.rpcCleanups=[],this.warningActionMap.clear(),await ge({entries:this.entries,loadOrder:this.loadOrder,contributionProcessors:this.contributionProcessors,contextHost:this.createExtensionContextHost()})}list(){return[...this.entries.values()].map(e=>D(e))}getExtensionService(e){let t=typeof e==`string`?e:e.name;return this.entries.get(t)?.service}getExtension(e){return this.entries.get(e)?.pkg}forEachActiveExtension(e){let t=this.createExtensionContextHost();for(let n of this.loadOrder){let r=this.entries.get(n);if(!r||r.state!==`active`)continue;let i=M(t,r,j(t,n,r));e(n,r.pkg,i)}}forExtension(e,t){let n=this.entries.get(e);if(!n||n.state!==`active`)return;let r=this.createExtensionContextHost(),i=M(r,n,j(r,e,n));t(e,n.pkg,i)}registerContributionProcessor(e){return this.contributionProcessors.push(e),()=>{let t=this.contributionProcessors.indexOf(e);t>=0&&this.contributionProcessors.splice(t,1)}}async handleSetEnabled(e,t){return R({bus:this.bus,db:this.db,entries:this.entries,extensionContextBase:this.extensionContextBase,loadConfig:this.loadConfig,signal:this.shutdownController.signal,hasActiveExtension:e=>this.hasActiveExtension(e),persistEnabled:this.persistEnabled,contributionProcessors:this.contributionProcessors,getExtensionService:e=>this.getExtensionService(e),runHealthCheck:e=>J(this.createExtensionHealthHost(),e),emitWarningsForEntry:(e,t)=>A({bus:this.bus,entries:this.entries,warningActionMap:this.warningActionMap},e,t)},e,t)}createExtensionContextHost(){return{bus:this.bus,extensionContextBase:this.extensionContextBase,loadConfig:this.loadConfig,signal:this.shutdownController.signal,hasActiveExtension:e=>this.hasActiveExtension(e),getExtensionService:e=>this.getExtensionService(e)}}createExtensionHealthHost(){return{bus:this.bus,entries:this.entries}}hasActiveExtension(e){return this.entries.get(e)?.state===`active`}};export{h as a,_ as i,H as n,g as o,U as r,Se as t};
1
+ import{n as e}from"./window-registry-PkrFIwX2.mjs";import{n as t}from"./namespace-DibbhCPP.mjs";import{n}from"./extension-namespace-v3K0qVry.mjs";import{t as r}from"./schema-introspection-B7xODt4I.mjs";import{z as i}from"zod";import a from"node:path";import{createBusNamespace as o}from"@makaio/framework/core";import{ProviderDefinitionSchema as s,primaryMigrationsPath as c,versionSatisfies as l}from"@makaio/framework/contracts";import{ToastSubjects as u}from"@makaio/framework/contracts/toast";import{ExtensionWarningSchema as d,getExtensionWarningActionLabel as f}from"@makaio/framework/contracts/extension";import{TrayMenuSubjects as p}from"@makaio/framework/services/tray-menu";const m=i.object({name:i.string(),displayName:i.string()}),h=o(`kernel:boot`,{getState:{request:i.object({}),response:i.object({complete:i.boolean(),completedCount:i.number(),totalCount:i.number(),currentService:i.string().optional(),failedServices:i.array(i.string()),skippedServices:i.array(i.string()).default([]),totalDurationMs:i.number().optional()})},"service.starting":m,"service.ready":m.extend({durationMs:i.number().int().nonnegative()}),"service.failed":m.extend({errorMessage:i.string()}),"service.skipped":m.extend({reason:i.string()}),progress:i.object({completedCount:i.number(),totalCount:i.number(),currentService:i.string().optional()}),complete:i.object({totalDurationMs:i.number(),failedServices:i.array(i.string())})}),g=h.subjects;var _=class extends Error{reason;constructor(e){super(e),this.name=`ServiceSkipError`,this.reason=e}};function v(e){return{name:e.name,displayName:e.displayName}}var y=class{bus;state;cleanup;constructor(e,t){this.bus=e,this.state={complete:!1,completedCount:0,totalCount:t,failedServices:[],skippedServices:[],startedAt:Date.now()},this.cleanup=this.bus.on(g.getState,e=>{e.setResult({complete:this.state.complete,completedCount:this.state.completedCount,totalCount:this.state.totalCount,...this.state.currentService===void 0?{}:{currentService:this.state.currentService},failedServices:[...this.state.failedServices],skippedServices:[...this.state.skippedServices],...this.state.totalDurationMs===void 0?{}:{totalDurationMs:this.state.totalDurationMs}})})}dispose(){this.cleanup()}starting(e){let t=v(e);this.state.currentService=t.displayName,this.state.currentServiceStartedAt=Date.now(),this.bus.emit(g.service.starting,t).catch(e=>{console.warn(`[ExtensionCoordinator] boot.service.starting emit failed for "${t.name}":`,e)})}ready(e){let t=v(e);this.state.completedCount+=1;let n=this.state.currentServiceStartedAt===void 0?0:Math.max(0,Date.now()-this.state.currentServiceStartedAt);this.bus.emit(g.service.ready,{...t,durationMs:n}).catch(e=>{console.warn(`[ExtensionCoordinator] boot.service.ready emit failed for "${t.name}":`,e)}),this.emitProgress()}failed(e,t){let n=v(e);this.state.completedCount+=1,this.state.failedServices.push(n.name),this.bus.emit(g.service.failed,{...n,errorMessage:t}).catch(e=>{console.warn(`[ExtensionCoordinator] boot.service.failed emit failed for "${n.name}":`,e)}),this.emitProgress()}skipped(e,t){let n=v(e);this.state.completedCount+=1,this.state.skippedServices.push(n.name),this.bus.emit(g.service.skipped,{...n,reason:t}).catch(e=>{console.warn(`[ExtensionCoordinator] boot.service.skipped emit failed for "${n.name}":`,e)}),this.emitProgress()}complete(){this.state.complete=!0,delete this.state.currentService,delete this.state.currentServiceStartedAt,this.state.totalDurationMs=Date.now()-this.state.startedAt,this.bus.emit(g.complete,{totalDurationMs:this.state.totalDurationMs,failedServices:[...this.state.failedServices]}).catch(e=>{console.warn(`[ExtensionCoordinator] boot.complete emit failed:`,e)})}emitProgress(){this.bus.emit(g.progress,{completedCount:this.state.completedCount,totalCount:this.state.totalCount,...this.state.currentService===void 0?{}:{currentService:this.state.currentService}}).catch(e=>{console.warn(`[ExtensionCoordinator] boot.progress emit failed:`,e)})}};function ee(e){return{subject:`wiring.apply`,$meta:{namespace:`client:${e}`,isRequest:!0,local:!1,channel:!1,payload:{request:{},response:{}}}}}const b=`action`;function x(e,t){return`${e}:${t}`}function te(e,t,n){return e.on(u.interacted,r=>{let{toastId:i,actionId:a}=r.payload,o=x(i,a),s=t.get(o);s&&S(e,s,i,n).catch(e=>{console.error(`[ExtensionCoordinator] Warning action dispatch failed for toast "${i}":`,e)})})}async function S(e,t,n,r){switch(t.kind){case`configure-integration`:await w(e,t.clientId,n,r);break;case`open-url`:console.info(`[ExtensionCoordinator] Toast "${n}" open-url action not routable from runtime layer: ${t.url}`);break;case`run-command`:console.info(`[ExtensionCoordinator] Toast "${n}" run-command action not routable from runtime layer: ${t.command}`);break;case`install-extension`:console.info(`[ExtensionCoordinator] Toast "${n}" install-extension action not routable from runtime layer: ${t.extensionName}`);break;default:C(t)}}function C(e){throw Error(`[ExtensionCoordinator] Unsupported warning action: ${JSON.stringify(e)}`)}async function w(e,t,n,r){let i=ee(t),a=await e.requestOptional(i,{scope:`user`,makaioCommand:r});if(!a.handled){console.warn(`[ExtensionCoordinator] Toast "${n}" configure-integration: no wiring handler for client "${t}". Is the client package loaded?`);return}let{applied:o,skipped:s}=a.data;console.info(`[ExtensionCoordinator] Toast "${n}" configure-integration: wired client "${t}" — ${o} applied, ${s} skipped.`)}function T(e){return e.map(e=>({name:e.name,description:e.description,hasInteractive:!!e.interactive,subcommands:e.subcommands.map(e=>({name:e.name,description:e.description,args:r(e.schema)}))}))}async function E(e,t,n){let{command:r,subcommand:i,args:a}=e,o=t.find(e=>e.name===r);if(!o)return{exitCode:1,stdout:[],stderr:[`Unknown command: ${r}`]};let s=o.subcommands.find(e=>e.name===i);if(!s)return{exitCode:1,stdout:[],stderr:[`Unknown subcommand: ${i}`]};let c=s.schema.safeParse(a??{});if(!c.success)return{exitCode:1,stdout:[],stderr:[`Validation failed:`,...c.error.issues.map(e=>` ${e.path.join(`.`)||`(root)`}: ${e.message}`)]};if(o.beforeRun)try{let e=await o.beforeRun({subcommandName:i,args:c.data??{},bus:n});if(!e.proceed)return{exitCode:e.exitCode??1,stdout:[],stderr:[e.message]}}catch(e){return{exitCode:1,stdout:[],stderr:[`beforeRun hook failed: ${e instanceof Error?e.message:String(e)}`]}}let l=[],u=[],d={write:e=>l.push(e),error:e=>u.push(e)},f=0,p=new AbortController().signal;try{await s.handler({args:c.data,bus:n,output:d,signal:p,setExitCode:e=>{f=e}})}catch(e){f===0&&(f=1),u.push(e instanceof Error?e.message:String(e))}return{exitCode:f,stdout:l,stderr:u}}function D(e){let{pkg:t,state:n,error:r,enabled:i}=e;return{name:t.name,displayName:t.displayName,state:n,...t.surface===void 0?{}:{surface:t.surface},enabled:i,...t.browser===void 0?{}:{browser:t.browser},...r===void 0?{}:{error:r}}}function O(e){let r=[];return r.push(e.bus.on(n.list,t=>{t.setResult({extensions:e.list()})})),r.push(e.bus.on(n.get,t=>{let n=e.entries.get(t.payload.name);t.setResult({extension:n?D(n):null})})),r.push(e.bus.on(n.setEnabled,async t=>{let n=await e.handleSetEnabled(t.payload.name,t.payload.enabled);t.setResult({success:n})})),r.push(e.bus.on(n.contributions.catalog,t=>{let n=[],r=[];for(let[t,i]of e.entries)if(i.state===`active`){for(let e of i.pkg.providers??[])n.push({packageName:t,definition:s.parse(e)});for(let e of i.pkg.clients??[])r.push({packageName:t,definition:e})}t.setResult({providers:n,clients:r})})),r.push(e.bus.on(t.listContributions,t=>{t.setResult({contributions:T(e.cliContributions)})})),r.push(e.bus.on(t.execute,async t=>{t.setResult(await E(t.payload,e.cliContributions,e.bus))})),r.push(e.bus.on(n.warnings.list,t=>{let{extensionName:n}=t.payload;if(n!==void 0){let r=e.entries.get(n),i=r&&r.warnings.length>0?[{extensionName:n,warnings:[...r.warnings]}]:[];t.setResult({entries:i});return}let r=[];for(let[t,n]of e.entries)n.warnings.length>0&&r.push({extensionName:t,warnings:[...n.warnings]});t.setResult({entries:r})})),r}async function ne(e){for(let[t,n]of e.entries)n.state===`active`&&await A(e,t,n)}function re(e){if(e&&k(e))return[{id:b,label:f(e)}]}function k(e){return e.kind===`configure-integration`}function ie(e,t){let n=`${t}:`;for(let t of e.keys())t.startsWith(n)&&e.delete(t)}async function A(e,t,n){ie(e.warningActionMap,t);let r=n.warnings.filter(e=>e.severity===`degraded`);if(r.length!==0)for(let i=0;i<r.length;i++){let a=r[i];console.warn(`[${t}] ⚠ ${a.title}: ${a.message}`);let o=`${t}:${a.title}:${i}`,s=re(a.action);try{await e.bus.emit(u.show,{level:`warning`,title:a.title,message:`${n.pkg.displayName}: ${a.message}`,toastId:o,durationMs:null,...s&&{actions:s}}),a.action&&k(a.action)&&e.warningActionMap.set(x(o,b),a.action)}catch(e){console.warn(`[${t}] toast emission failed for warning "${a.title}":`,e)}}}function ae(e){return Object.freeze({extensionName:e})}function oe(e,t,n,r){if(!t)return;let i={...n??{},...r??{}};try{return t.parse(i)}catch(n){console.warn(`[ExtensionCoordinator] Config parse failed for "${e}", starting with schema defaults:`,n instanceof Error?n.message:n);try{return t.parse({})}catch{console.warn(`[ExtensionCoordinator] Fallback config parse also failed for "${e}" — config will be absent`);return}}}function j(e,t,n){let r;if(n.pkg.configSchema)try{r=e.loadConfig?.(t)}catch(e){console.error(`[ExtensionCoordinator] loadConfig threw for "${t}":`,e)}return oe(t,n.pkg.configSchema,n.configDefaults,r)}function M(e,t,n){if(!e.extensionContextBase)throw Error(`ExtensionCoordinator: extensionContextBase is required to start extensions with a create factory. Provide it via the constructor.`);return{...e.extensionContextBase,bus:e.bus,identity:t.identity,dataDir:a.join(e.extensionContextBase.makaioHome,t.identity.extensionName),getService:t=>e.getExtensionService(t.name),signal:e.signal,hasExtension:e.hasActiveExtension,...n===void 0?{}:{config:n}}}function N(e){return{adapters:!!e.adapters?.length,tools:!!e.tools,triggers:!!e.triggers,providers:!!e.providers?.length,clients:!!e.clients?.length,ui:!!e.ui,storage:!!e.storage,sessionEventActions:!!e.sessionEventActions}}function P(e,t,r){let i=t.state;t.state=r,e.emit(n.stateChanged,{name:t.pkg.name,displayName:t.pkg.displayName,from:i,to:r,...t.error===void 0?{}:{error:t.error},contributes:N(t.pkg)}).catch(e=>{console.error(`[ExtensionCoordinator] stateChanged emit failed for "${t.pkg.name}":`,e)})}async function F(e,t,n,r,i){i===`activated`?await I(e,t,n,r):await L(e,n)}async function I(e,t,n,r){let i=[];try{for(let a of e){if(a.filter&&!a.filter(r.pkg))continue;let e=M(t,r,j(t,n,r));await a.processActivated(n,r.pkg,e),i.push(a)}}catch(e){for(let e of i.reverse())if(e.processStopped)try{await e.processStopped(n)}catch(e){console.error(`[ExtensionCoordinator] Contribution processor rollback error for "${n}":`,e)}throw e}}async function L(e,t){for(let n of[...e].reverse())if(n.processStopped)try{await n.processStopped(t)}catch(e){console.error(`[ExtensionCoordinator] Contribution processor error (stopped) for "${t}":`,e)}}async function R(e,t,r){let i=e.entries.get(t);if(!i)return!1;let a=r?await z(e,t,i):await B(e,t,i),o=i.enabled===r;return!a&&!o||(await e.persistEnabled?.(t,r),!a)?!1:(e.bus.emit(n.enabledChanged,{name:t,enabled:r}).catch(e=>{console.error(`[ExtensionCoordinator] enabledChanged emit failed for "${t}":`,e)}),!0)}async function z(e,t,n){if(n.state!==`stopped`&&n.state!==`failed`&&n.state!==`skipped`)return!1;let{pkg:r}=n,i,a=(r.dependencies??[]).filter(t=>{if(t.optional)return!1;let n=e.entries.get(t.name);return!n||n.state!==`active`});if(a.length>0)return n.error=`Required dependencies not active: ${a.map(e=>e.name).join(`, `)}`,console.error(`[ExtensionCoordinator] Cannot re-enable "${t}":`,n.error),P(e.bus,n,`failed`),!1;n.enabled=!0,n.error=void 0,P(e.bus,n,`initializing`);let o=j(e,t,n);if(r.storage?.registerHandlers&&e.db!==void 0)try{let t=M(e,n,o),a=r.storage.registerHandlers(e.bus,e.db,t);typeof a==`function`&&(i=a,n.storageCleanup=a)}catch(r){return n.error=r instanceof Error?r.message:String(r),console.error(`[ExtensionCoordinator] Extension "${t}" storage re-registration failed:`,r),P(e.bus,n,`failed`),!1}if(r.create){let a;try{let t=M(e,n,o);a=await r.create(t),await a.init?.(),n.service=a}catch(r){return await V(t,a,i,n),r instanceof _?n.pkg.critical?(n.error=`Critical extension cannot skip startup: ${r.reason}`,console.error(`[ExtensionCoordinator] Extension "${t}" failed to re-initialize:`,n.error),P(e.bus,n,`failed`),!1):(n.error=r.reason,P(e.bus,n,`skipped`),!1):(n.error=r instanceof Error?r.message:String(r),console.error(`[ExtensionCoordinator] Extension "${t}" failed to re-initialize:`,r),P(e.bus,n,`failed`),!1)}}try{await F(e.contributionProcessors,e,t,n,`activated`)}catch(r){return await V(t,n.service,i,n),n.service=void 0,n.error=r instanceof Error?r.message:String(r),console.error(`[ExtensionCoordinator] Extension "${t}" contribution processing failed:`,r),P(e.bus,n,`failed`),!1}return P(e.bus,n,`active`),await e.runHealthCheck(t),await e.emitWarningsForEntry(t,n),!0}async function B(e,t,r){if(r.state!==`active`)return!1;let i=Array.from(e.entries.entries()).filter(([e,n])=>e===t||n.state!==`active`?!1:n.pkg.dependencies?.some(e=>!e.optional&&e.name===t)??!1).map(([e])=>e);if(i.length>0)return r.error=`Cannot disable "${t}" while active dependents remain: ${i.join(`, `)}`,console.error(`[ExtensionCoordinator] ${r.error}`),!1;if(r.enabled=!1,r.error=void 0,await F(e.contributionProcessors,e,t,r,`stopped`),r.service)try{await r.service.destroy?.()}catch(e){console.error(`[ExtensionCoordinator] Error during disable destroy of "${t}":`,e)}finally{r.service=void 0}if(r.storageCleanup)try{r.storageCleanup()}catch(e){console.error(`[ExtensionCoordinator] Storage cleanup error during disable of "${t}":`,e)}finally{r.storageCleanup=void 0}P(e.bus,r,`stopped`),r.warnings=[];try{await e.bus.emit(n.warnings.changed,{extensionName:t,warnings:[]})}catch(e){console.error(`[ExtensionCoordinator] warnings.changed emit failed for "${t}":`,e)}return!0}async function V(e,t,n,r){try{await t?.destroy?.()}catch(t){console.error(`[ExtensionCoordinator] Service cleanup error after failed enable of "${e}":`,t)}try{n?.()}catch(t){console.error(`[ExtensionCoordinator] Storage cleanup error after failed enable of "${e}":`,t)}finally{r.storageCleanup=void 0}}function H(e){let t=new Map;for(let n of e)t.has(n.name)&&(console.info(`[ExtensionCoordinator] Extension "${n.name}" overrides an earlier registration`),t.delete(n.name)),t.set(n.name,n);return[...t.values()]}function U(e,t,n){let r=new Set(e.map(e=>e.name)),i=e.filter(e=>W(e,t,n)),a=new Map(i.map(e=>[e.name,e])),o=new Set(a.keys()),s=!0;for(;s;){s=!1;for(let e of o)(a.get(e).dependencies??[]).some(e=>!e.optional&&r.has(e.name)&&!o.has(e.name))&&(o.delete(e),s=!0)}return i.filter(e=>o.has(e.name))}function W(e,t,n){if(!K(e,t))return!1;let r=e.requires;return!r||r.length===0||!n?!0:r.every(e=>{switch(e.type){case`host`:return n.hosts.has(e.id);case`capability`:return n.capabilities.has(e.id)?e.version===void 0?!0:G(n,e.id,e.version):!1}})}function G(e,t,n){let r=e.capabilityVersions?.get(t);return r!==void 0&&l(r,n)}function K(e,t){return e.surface===void 0||e.surface===`any`||e.surface===t}function se(e){let t=ce(e);return le(e,t,new Map(e.map(e=>[e.name,e]))),fe(t,de(e,t))}function ce(e){let t=new Set;for(let n of e){if(t.has(n.name))throw Error(`ExtensionCoordinator: duplicate package name detected: "${n.name}"`);t.add(n.name)}return t}function le(e,t,n){for(let r of e)ue(r,t,n)}function ue(e,t,n){let r=e.dependencies??[],i=r.filter(e=>!e.optional&&!t.has(e.name));if(i.length>0)throw Error(`ExtensionCoordinator: package "${e.name}" declares missing dependencies: ${i.map(e=>e.name).join(`, `)}`);for(let t of r){let r=n.get(t.name);if(r===void 0)continue;let i=r.version;if(!l(i,t.version))throw Error(`ExtensionCoordinator: package "${e.name}" dependency "${t.name}" version ${i} does not satisfy ${t.version}`)}}function de(e,t){let n=new Map;for(let r of e){let e=(r.dependencies??[]).filter(e=>t.has(e.name)).map(e=>e.name);n.set(r.name,new Set(e))}return n}function fe(e,t){let n=[];for(let[e,r]of t)r.size===0&&n.push(e);let r=[],i=new Set;for(;n.length>0;){let e=n.shift();if(!i.has(e)){i.add(e),r.push(e);for(let[r,a]of t)a.has(e)&&(a.delete(e),a.size===0&&!i.has(r)&&n.push(r))}}if(r.length!==e.size){let t=[...e].filter(e=>!i.has(e));throw Error(`ExtensionCoordinator: circular dependency detected among: ${t.join(`, `)}`)}return r}async function pe(e){if(!e.runMigrations)return;let t=[];for(let n of e.loadOrder){let r=e.entries.get(n);if(!r)throw Error(`Extension "${n}" is in loadOrder but missing from entries`);let i=r.pkg.storage?.migrations;if(!i)continue;let a,o;if(typeof i==`string`)a=q(n,r.pkg,i);else{let e={};for(let[t,a]of Object.entries(i))a!==void 0&&(e[t]=q(n,r.pkg,a));let t=c(e);if(t===void 0)continue;a=t,o=e}t.push({name:n,migrationsPath:a,migrationSourceId:r.pkg.storage?.migrationSourceId??a,...o?{migrationsPathByDialect:o}:{}})}t.length!==0&&await e.runMigrations(t)}function q(e,t,n){if(a.isAbsolute(n))return n;let r=t.storage?.packageRoot;if(!r)throw Error(`Extension "${e}" declares relative storage.migrations "${n}" without storage.packageRoot`);let i=a.resolve(r),o=a.resolve(i,n),s=a.relative(i,o);if(s.startsWith(`..`)||a.isAbsolute(s))throw Error(`Extension "${e}" declares storage.migrations "${n}" outside storage.packageRoot`);return o}async function J(e,t){let r=e.entries.get(t);if(!r?.service||r.state!==`active`)return;let{checkHealth:i}=r.service;if(!i)return;let a;try{let e=await i.call(r.service),n=d.array().safeParse(e);n.success?a=n.data:(console.error(`[ExtensionCoordinator] checkHealth for "${t}" returned invalid data:`,n.error),a=[])}catch(e){console.error(`[ExtensionCoordinator] checkHealth threw for "${t}":`,e),a=[]}r.warnings=a;try{await e.bus.emit(n.warnings.changed,{extensionName:t,warnings:[...a]})}catch(e){console.error(`[ExtensionCoordinator] warnings.changed emit failed for "${t}":`,e)}}function me(e,t){if(t.windows)for(let n of t.windows)e.windowRegistry.register(t.name,t.displayName,n);if(t.tray&&e.trayEntries.push({...t.tray,packageName:t.name}),t.cli){let n=t.cli;`subcommands`in n&&e.cliContributions.push(n)}}function he(e){return Array.from(e.values()).filter(e=>e.enabled).map(e=>e.pkg).filter(e=>!!e.http)}async function ge(e){let t=[...e.loadOrder].reverse();for(let n of t){let t=e.entries.get(n);if(t){if(t.state===`active`&&await F(e.contributionProcessors,e.contextHost,n,t,`stopped`),t.service)try{await t.service.destroy?.()}catch(e){console.error(`[ExtensionCoordinator] Error during shutdown of "${n}":`,e)}finally{t.service=void 0}if(t.storageCleanup)try{t.storageCleanup()}catch(e){console.error(`[ExtensionCoordinator] Storage cleanup error for "${n}":`,e)}finally{t.storageCleanup=void 0}t.state===`active`&&P(e.contextHost.bus,t,`stopped`)}}}async function _e(e,t){if(!t.tray)return;let n=Y(t);await e.request(p.register,{entry:n})}function Y(e){let t=e.tray;if(!t)throw Error(`[tray-menu-entry-bridge] extension "${e.name}" does not declare a tray entry`);return{packageName:e.name,entryId:t.opensWindow??t.action??`default`,label:t.label,section:t.section??`views`,priority:50,enabled:!0,metadata:t.opensWindow?{registrationId:`${e.name}:${t.opensWindow}`}:t.action?{action:t.action}:void 0}}async function ve(e,t,n){if(!n.enabled){P(e.bus,n,`skipped`),e.bootProgress.skipped(n.pkg,`disabled`);return}let r=(n.pkg.dependencies??[]).filter(t=>t.optional?!1:e.entries.get(t.name)?.state!==`active`);if(r.length>0){let i=`Required dependencies not active: ${r.map(e=>e.name).join(`, `)}`;if(Q(e,t,n,i),n.pkg.critical)throw Error(`Critical package "${t}" failed: ${i}`);return}e.bootProgress.starting(n.pkg),P(e.bus,n,`initializing`);let i=j(e.contextHost,t,n);if(xe(e,t,n,i)){if(!n.pkg.create){await ye(e,t,n);return}await be(e,t,n,i)}}async function ye(e,t,n){try{await F(e.contributionProcessors,e.contextHost,t,n,`activated`)}catch(r){if(Z(t,n),X(e,t,n,r))return;if(Q(e,t,n,r instanceof Error?r.message:String(r)),n.pkg.critical)throw r;return}P(e.bus,n,`active`),e.bootProgress.ready(n.pkg),await $(e.bus,t,n)}async function be(e,t,n,r){let i;try{let a=M(e.contextHost,n,r);i=await n.pkg.create(a),await i.init?.(),n.service=i,await F(e.contributionProcessors,e.contextHost,t,n,`activated`),P(e.bus,n,`active`),e.bootProgress.ready(n.pkg),await $(e.bus,t,n)}catch(r){try{await i?.destroy?.()}catch(e){console.error(`[ExtensionCoordinator] Service cleanup error after failed start of "${t}":`,e)}if(n.service=void 0,Z(t,n),X(e,t,n,r))return;if(Q(e,t,n,r instanceof Error?r.message:String(r)),n.pkg.critical)throw r}}function X(e,t,n,r){if(!(r instanceof _))return!1;if(n.pkg.critical){let i=`Critical package cannot skip startup: ${r.reason}`;throw Q(e,t,n,i),Error(`Critical package "${t}" failed: ${i}`,{cause:r})}return n.error=r.reason,console.info(`[ExtensionCoordinator] Package "${t}" skipped: ${r.reason}`),P(e.bus,n,`skipped`),e.bootProgress.skipped(n.pkg,r.reason),!0}function xe(e,t,n,r){if(!n.pkg.storage?.registerHandlers||e.db===void 0)return!0;try{let t=M(e.contextHost,n,r),i=n.pkg.storage.registerHandlers(e.bus,e.db,t);return i&&(n.storageCleanup=i),!0}catch(r){let i=r instanceof Error?r.message:String(r);if(console.error(`[ExtensionCoordinator] Package "${t}" storage registration failed:`,r),Q(e,t,n,i),n.pkg.critical)throw r;return!1}}function Z(e,t){if(t.storageCleanup)try{t.storageCleanup()}catch(t){console.error(`[ExtensionCoordinator] Storage cleanup error after failed start of "${e}":`,t)}finally{t.storageCleanup=void 0}}function Q(e,t,n,r){n.error=r,console.error(`[ExtensionCoordinator] Package "${t}" failed:`,r),P(e.bus,n,`failed`),e.bootProgress.failed(n.pkg,r)}async function $(e,t,n){try{await _e(e,n.pkg)}catch(e){console.warn(`[ExtensionCoordinator] Failed to register tray entry for ${t}:`,e)}}var Se=class{bus;surface;db;extensionContextBase;runtimeEnvironment;shutdownController=new AbortController;entries=new Map;loadOrder=[];loaded=!1;started=!1;rpcCleanups=[];contributionProcessors=[];warningActionMap=new Map;windowRegistry=new e;_trayEntries=[];_cliContributions=[];persistEnabled;loadEnabled;loadConfig;runMigrations;constructor(e,t={}){this.bus=e,this.surface=t.surface??`headless`,this.db=t.db,this.extensionContextBase=t.extensionContextBase,this.runtimeEnvironment=t.runtimeEnvironment,this.persistEnabled=t.persistEnabled,this.loadEnabled=t.loadEnabled,this.loadConfig=t.loadConfig,this.runMigrations=t.runMigrations,this.rpcCleanups.push(te(this.bus,this.warningActionMap,t.launcherCommand??`makaio`))}get trayEntries(){return this._trayEntries.map(e=>({...e}))}get cliContributions(){return this._cliContributions}extensionsWithHttp(){return he(this.entries)}load(e,t){if(this.loaded)throw Error(`ExtensionCoordinator.load() called twice. The coordinator is single-use; create a new instance if needed.`);let n=H(U(e,this.surface,this.runtimeEnvironment));this.loadOrder=se(n);for(let e of this.loadOrder){let r=n.find(t=>t.name===e),i={pkg:r,identity:ae(r.name),state:`discovered`,enabled:this.loadEnabled?.(e)!==!1,warnings:[]};if(t){let n=t.get(e);n&&(i.configDefaults=n)}this.entries.set(e,i),r.namespaces&&this.bus.registerNamespaces(r.namespaces),me({windowRegistry:this.windowRegistry,trayEntries:this._trayEntries,cliContributions:this._cliContributions},r)}this.rpcCleanups.push(...O({bus:this.bus,entries:this.entries,cliContributions:this._cliContributions,list:()=>this.list(),handleSetEnabled:(e,t)=>this.handleSetEnabled(e,t)})),this.loaded=!0}async startAll(){if(!this.loaded)throw Error(`ExtensionCoordinator.startAll() called before load(). Call load() first.`);if(this.started)throw Error(`ExtensionCoordinator.startAll() called twice. The coordinator is single-use; create a new instance if needed.`);this.started=!0;let e=new y(this.bus,this.loadOrder.length);this.rpcCleanups.push(()=>e.dispose());try{await pe({loadOrder:this.loadOrder,entries:this.entries,runMigrations:this.runMigrations});for(let t of this.loadOrder){let n=this.entries.get(t);n&&await ve({bus:this.bus,db:this.db,entries:this.entries,contributionProcessors:this.contributionProcessors,contextHost:this.createExtensionContextHost(),bootProgress:e},t,n)}let t=this.createExtensionHealthHost();await Promise.all(this.loadOrder.map(e=>this.entries.get(e)?.state===`active`?J(t,e):void 0)),await ne({bus:this.bus,entries:this.entries,warningActionMap:this.warningActionMap})}finally{e.complete()}}async shutdown(){this.shutdownController.abort();for(let e of this.rpcCleanups)e();this.rpcCleanups=[],this.warningActionMap.clear(),await ge({entries:this.entries,loadOrder:this.loadOrder,contributionProcessors:this.contributionProcessors,contextHost:this.createExtensionContextHost()})}list(){return[...this.entries.values()].map(e=>D(e))}getExtensionService(e){let t=typeof e==`string`?e:e.name;return this.entries.get(t)?.service}getExtension(e){return this.entries.get(e)?.pkg}getLoadedProviderDefinitionIds(){let e=new Set;for(let t of this.entries.values())for(let n of t.pkg.providers??[])e.add(n.id);return e}forEachActiveExtension(e){let t=this.createExtensionContextHost();for(let n of this.loadOrder){let r=this.entries.get(n);if(!r||r.state!==`active`)continue;let i=M(t,r,j(t,n,r));e(n,r.pkg,i)}}forExtension(e,t){let n=this.entries.get(e);if(!n||n.state!==`active`)return;let r=this.createExtensionContextHost(),i=M(r,n,j(r,e,n));t(e,n.pkg,i)}registerContributionProcessor(e){return this.contributionProcessors.push(e),()=>{let t=this.contributionProcessors.indexOf(e);t>=0&&this.contributionProcessors.splice(t,1)}}async handleSetEnabled(e,t){return R({bus:this.bus,db:this.db,entries:this.entries,extensionContextBase:this.extensionContextBase,loadConfig:this.loadConfig,signal:this.shutdownController.signal,hasActiveExtension:e=>this.hasActiveExtension(e),persistEnabled:this.persistEnabled,contributionProcessors:this.contributionProcessors,getExtensionService:e=>this.getExtensionService(e),runHealthCheck:e=>J(this.createExtensionHealthHost(),e),emitWarningsForEntry:(e,t)=>A({bus:this.bus,entries:this.entries,warningActionMap:this.warningActionMap},e,t)},e,t)}createExtensionContextHost(){return{bus:this.bus,extensionContextBase:this.extensionContextBase,loadConfig:this.loadConfig,signal:this.shutdownController.signal,hasActiveExtension:e=>this.hasActiveExtension(e),getExtensionService:e=>this.getExtensionService(e)}}createExtensionHealthHost(){return{bus:this.bus,entries:this.entries}}hasActiveExtension(e){return this.entries.get(e)?.state===`active`}};export{h as a,_ as i,H as n,g as o,U as r,Se as t};
@@ -48,9 +48,9 @@ declare const MaterializationSchemas: {
48
48
  template: z.ZodString;
49
49
  }, z.core.$strip>], "kind">;
50
50
  appliesTo: z.ZodArray<z.ZodEnum<{
51
- surface: "surface";
52
- workpiece: "workpiece";
53
51
  artifact: "artifact";
52
+ workpiece: "workpiece";
53
+ surface: "surface";
54
54
  }>>;
55
55
  valueMapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
56
56
  description: z.ZodOptional<z.ZodString>;
@@ -88,9 +88,9 @@ declare const MaterializationSchemas: {
88
88
  template: z.ZodString;
89
89
  }, z.core.$strip>], "kind">;
90
90
  appliesTo: z.ZodArray<z.ZodEnum<{
91
- surface: "surface";
92
- workpiece: "workpiece";
93
91
  artifact: "artifact";
92
+ workpiece: "workpiece";
93
+ surface: "surface";
94
94
  }>>;
95
95
  valueMapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
96
96
  description: z.ZodOptional<z.ZodString>;
@@ -153,9 +153,9 @@ declare const MaterializationNamespace: _$_makaio_core0.BusNamespaceDefinition<"
153
153
  template: z.ZodString;
154
154
  }, z.core.$strip>], "kind">;
155
155
  appliesTo: z.ZodArray<z.ZodEnum<{
156
- surface: "surface";
157
- workpiece: "workpiece";
158
156
  artifact: "artifact";
157
+ workpiece: "workpiece";
158
+ surface: "surface";
159
159
  }>>;
160
160
  valueMapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
161
161
  description: z.ZodOptional<z.ZodString>;
@@ -193,9 +193,9 @@ declare const MaterializationNamespace: _$_makaio_core0.BusNamespaceDefinition<"
193
193
  template: z.ZodString;
194
194
  }, z.core.$strip>], "kind">;
195
195
  appliesTo: z.ZodArray<z.ZodEnum<{
196
- surface: "surface";
197
- workpiece: "workpiece";
198
196
  artifact: "artifact";
197
+ workpiece: "workpiece";
198
+ surface: "surface";
199
199
  }>>;
200
200
  valueMapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
201
201
  description: z.ZodOptional<z.ZodString>;
@@ -268,9 +268,9 @@ declare const MaterializationSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
268
268
  template: z.ZodString;
269
269
  }, z.core.$strip>], "kind">;
270
270
  appliesTo: z.ZodArray<z.ZodEnum<{
271
- surface: "surface";
272
- workpiece: "workpiece";
273
271
  artifact: "artifact";
272
+ workpiece: "workpiece";
273
+ surface: "surface";
274
274
  }>>;
275
275
  valueMapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
276
276
  description: z.ZodOptional<z.ZodString>;
@@ -308,9 +308,9 @@ declare const MaterializationSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
308
308
  template: z.ZodString;
309
309
  }, z.core.$strip>], "kind">;
310
310
  appliesTo: z.ZodArray<z.ZodEnum<{
311
- surface: "surface";
312
- workpiece: "workpiece";
313
311
  artifact: "artifact";
312
+ workpiece: "workpiece";
313
+ surface: "surface";
314
314
  }>>;
315
315
  valueMapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
316
316
  description: z.ZodOptional<z.ZodString>;
@@ -946,8 +946,8 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
946
946
  member: "member";
947
947
  }>;
948
948
  status: z.ZodEnum<{
949
- active: "active";
950
949
  idle: "idle";
950
+ active: "active";
951
951
  dead: "dead";
952
952
  disposed: "disposed";
953
953
  }>;
@@ -989,8 +989,8 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
989
989
  member: "member";
990
990
  }>;
991
991
  status: z.ZodEnum<{
992
- active: "active";
993
992
  idle: "idle";
993
+ active: "active";
994
994
  dead: "dead";
995
995
  disposed: "disposed";
996
996
  }>;
@@ -1027,8 +1027,8 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1027
1027
  adapterName: z.ZodString;
1028
1028
  status: z.ZodOptional<z.ZodEnum<{
1029
1029
  all: "all";
1030
- active: "active";
1031
1030
  idle: "idle";
1031
+ active: "active";
1032
1032
  dead: "dead";
1033
1033
  disposed: "disposed";
1034
1034
  }>>;
@@ -1058,8 +1058,8 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1058
1058
  member: "member";
1059
1059
  }>;
1060
1060
  status: z.ZodEnum<{
1061
- active: "active";
1062
1061
  idle: "idle";
1062
+ active: "active";
1063
1063
  dead: "dead";
1064
1064
  disposed: "disposed";
1065
1065
  }>;
@@ -1103,8 +1103,8 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1103
1103
  member: "member";
1104
1104
  }>;
1105
1105
  status: z.ZodEnum<{
1106
- active: "active";
1107
1106
  idle: "idle";
1107
+ active: "active";
1108
1108
  dead: "dead";
1109
1109
  disposed: "disposed";
1110
1110
  }>;
@@ -1123,8 +1123,8 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1123
1123
  request: z.ZodObject<{
1124
1124
  agentId: z.ZodString;
1125
1125
  status: z.ZodEnum<{
1126
- active: "active";
1127
1126
  idle: "idle";
1127
+ active: "active";
1128
1128
  dead: "dead";
1129
1129
  disposed: "disposed";
1130
1130
  }>;
@@ -1463,7 +1463,7 @@ declare const AgentStorageNamespace: _$_makaio_storage_core0.StorageNamespaceDef
1463
1463
  tableName: "agents";
1464
1464
  dataType: "string";
1465
1465
  columnType: "SQLiteText";
1466
- data: "active" | "idle" | "dead" | "disposed";
1466
+ data: "idle" | "active" | "dead" | "disposed";
1467
1467
  driverParam: string;
1468
1468
  notNull: true;
1469
1469
  hasDefault: false;
@@ -1555,8 +1555,8 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1555
1555
  member: "member";
1556
1556
  }>;
1557
1557
  status: z.ZodEnum<{
1558
- active: "active";
1559
1558
  idle: "idle";
1559
+ active: "active";
1560
1560
  dead: "dead";
1561
1561
  disposed: "disposed";
1562
1562
  }>;
@@ -1598,8 +1598,8 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1598
1598
  member: "member";
1599
1599
  }>;
1600
1600
  status: z.ZodEnum<{
1601
- active: "active";
1602
1601
  idle: "idle";
1602
+ active: "active";
1603
1603
  dead: "dead";
1604
1604
  disposed: "disposed";
1605
1605
  }>;
@@ -1636,8 +1636,8 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1636
1636
  adapterName: z.ZodString;
1637
1637
  status: z.ZodOptional<z.ZodEnum<{
1638
1638
  all: "all";
1639
- active: "active";
1640
1639
  idle: "idle";
1640
+ active: "active";
1641
1641
  dead: "dead";
1642
1642
  disposed: "disposed";
1643
1643
  }>>;
@@ -1667,8 +1667,8 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1667
1667
  member: "member";
1668
1668
  }>;
1669
1669
  status: z.ZodEnum<{
1670
- active: "active";
1671
1670
  idle: "idle";
1671
+ active: "active";
1672
1672
  dead: "dead";
1673
1673
  disposed: "disposed";
1674
1674
  }>;
@@ -1712,8 +1712,8 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1712
1712
  member: "member";
1713
1713
  }>;
1714
1714
  status: z.ZodEnum<{
1715
- active: "active";
1716
1715
  idle: "idle";
1716
+ active: "active";
1717
1717
  dead: "dead";
1718
1718
  disposed: "disposed";
1719
1719
  }>;
@@ -1732,8 +1732,8 @@ declare const AgentStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.
1732
1732
  request: z.ZodObject<{
1733
1733
  agentId: z.ZodString;
1734
1734
  status: z.ZodEnum<{
1735
- active: "active";
1736
1735
  idle: "idle";
1736
+ active: "active";
1737
1737
  dead: "dead";
1738
1738
  disposed: "disposed";
1739
1739
  }>;
@@ -2019,7 +2019,7 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2019
2019
  tableName: "sessions";
2020
2020
  dataType: "string";
2021
2021
  columnType: "SQLiteText";
2022
- data: "fork" | "subagent" | "compress" | "branch" | "rewrite" | "coordinator" | "aside";
2022
+ data: "fork" | "branch" | "subagent" | "compress" | "rewrite" | "coordinator" | "aside";
2023
2023
  driverParam: string;
2024
2024
  notNull: false;
2025
2025
  hasDefault: false;
@@ -2740,7 +2740,7 @@ declare const sessionStorageSchema: _$_makaio_storage_drizzle0.DialectSchema<{
2740
2740
  tableName: "agents";
2741
2741
  dataType: "string";
2742
2742
  columnType: "SQLiteText";
2743
- data: "active" | "idle" | "dead" | "disposed";
2743
+ data: "idle" | "active" | "dead" | "disposed";
2744
2744
  driverParam: string;
2745
2745
  notNull: true;
2746
2746
  hasDefault: false;
@@ -15,8 +15,8 @@ declare const ProviderConfigFileRecordSchema: z.ZodObject<{
15
15
  endpointOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
16
16
  modelVisibility: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
17
17
  enabled: "enabled";
18
- visible: "visible";
19
18
  disabled: "disabled";
19
+ visible: "visible";
20
20
  }>>>;
21
21
  modelFilterMode: z.ZodEnum<{
22
22
  allowlist: "allowlist";
@@ -188,8 +188,8 @@ declare const AdapterSubsystemSchemas: {
188
188
  endpointOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
189
189
  modelVisibility: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
190
190
  enabled: "enabled";
191
- visible: "visible";
192
191
  disabled: "disabled";
192
+ visible: "visible";
193
193
  }>>>;
194
194
  modelFilterMode: z.ZodEnum<{
195
195
  allowlist: "allowlist";
@@ -218,8 +218,8 @@ declare const AdapterSubsystemSchemas: {
218
218
  endpointOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
219
219
  modelVisibility: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
220
220
  enabled: "enabled";
221
- visible: "visible";
222
221
  disabled: "disabled";
222
+ visible: "visible";
223
223
  }>>>;
224
224
  modelFilterMode: z.ZodEnum<{
225
225
  allowlist: "allowlist";
@@ -248,8 +248,8 @@ declare const AdapterSubsystemSchemas: {
248
248
  endpointOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
249
249
  modelVisibility: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
250
250
  enabled: "enabled";
251
- visible: "visible";
252
251
  disabled: "disabled";
252
+ visible: "visible";
253
253
  }>>>;
254
254
  modelFilterMode: z.ZodEnum<{
255
255
  allowlist: "allowlist";
@@ -324,8 +324,8 @@ declare const AdapterSubsystemSchemas: {
324
324
  endpointOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
325
325
  modelVisibility: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
326
326
  enabled: "enabled";
327
- visible: "visible";
328
327
  disabled: "disabled";
328
+ visible: "visible";
329
329
  }>>>;
330
330
  modelFilterMode: z.ZodEnum<{
331
331
  allowlist: "allowlist";
@@ -488,8 +488,8 @@ declare const AdapterSubsystemSchemas: {
488
488
  }, z.core.$strip>>;
489
489
  modelVisibility: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
490
490
  enabled: "enabled";
491
- visible: "visible";
492
491
  disabled: "disabled";
492
+ visible: "visible";
493
493
  }>>>;
494
494
  modelFilterMode: z.ZodOptional<z.ZodEnum<{
495
495
  allowlist: "allowlist";
@@ -505,8 +505,8 @@ declare const AdapterSubsystemSchemas: {
505
505
  endpointOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
506
506
  modelVisibility: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
507
507
  enabled: "enabled";
508
- visible: "visible";
509
508
  disabled: "disabled";
509
+ visible: "visible";
510
510
  }>>>;
511
511
  modelFilterMode: z.ZodEnum<{
512
512
  allowlist: "allowlist";
@@ -534,8 +534,8 @@ declare const AdapterSubsystemSchemas: {
534
534
  }, z.core.$strip>>>;
535
535
  modelVisibility: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
536
536
  enabled: "enabled";
537
- visible: "visible";
538
537
  disabled: "disabled";
538
+ visible: "visible";
539
539
  }>>>;
540
540
  enabled: z.ZodOptional<z.ZodBoolean>;
541
541
  }, z.core.$strict>;
@@ -548,8 +548,8 @@ declare const AdapterSubsystemSchemas: {
548
548
  endpointOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
549
549
  modelVisibility: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
550
550
  enabled: "enabled";
551
- visible: "visible";
552
551
  disabled: "disabled";
552
+ visible: "visible";
553
553
  }>>>;
554
554
  modelFilterMode: z.ZodEnum<{
555
555
  allowlist: "allowlist";
@@ -579,8 +579,8 @@ declare const AdapterSubsystemSchemas: {
579
579
  endpointOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
580
580
  modelVisibility: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
581
581
  enabled: "enabled";
582
- visible: "visible";
583
582
  disabled: "disabled";
583
+ visible: "visible";
584
584
  }>>>;
585
585
  modelFilterMode: z.ZodEnum<{
586
586
  allowlist: "allowlist";
@@ -620,8 +620,8 @@ declare const AdapterSubsystemSchemas: {
620
620
  endpointOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
621
621
  modelVisibility: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
622
622
  enabled: "enabled";
623
- visible: "visible";
624
623
  disabled: "disabled";
624
+ visible: "visible";
625
625
  }>>>;
626
626
  modelFilterMode: z.ZodEnum<{
627
627
  allowlist: "allowlist";
@@ -655,8 +655,8 @@ declare const AdapterSubsystemSchemas: {
655
655
  endpointOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
656
656
  modelVisibility: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
657
657
  enabled: "enabled";
658
- visible: "visible";
659
658
  disabled: "disabled";
659
+ visible: "visible";
660
660
  }>>>;
661
661
  modelFilterMode: z.ZodEnum<{
662
662
  allowlist: "allowlist";
@@ -781,8 +781,8 @@ declare const AdapterSubsystemSchemas: {
781
781
  endpointOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
782
782
  modelVisibility: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
783
783
  enabled: "enabled";
784
- visible: "visible";
785
784
  disabled: "disabled";
785
+ visible: "visible";
786
786
  }>>>;
787
787
  modelFilterMode: z.ZodEnum<{
788
788
  allowlist: "allowlist";
@@ -801,8 +801,8 @@ declare const AdapterSubsystemSchemas: {
801
801
  endpointOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
802
802
  modelVisibility: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
803
803
  enabled: "enabled";
804
- visible: "visible";
805
804
  disabled: "disabled";
805
+ visible: "visible";
806
806
  }>>>;
807
807
  modelFilterMode: z.ZodEnum<{
808
808
  allowlist: "allowlist";
@@ -937,8 +937,8 @@ declare const CreateCanonicalProviderConfigInputSchema: z.ZodObject<{
937
937
  }, z.core.$strip>>;
938
938
  modelVisibility: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
939
939
  enabled: "enabled";
940
- visible: "visible";
941
940
  disabled: "disabled";
941
+ visible: "visible";
942
942
  }>>>;
943
943
  modelFilterMode: z.ZodOptional<z.ZodEnum<{
944
944
  allowlist: "allowlist";
@@ -960,8 +960,8 @@ declare const CanonicalProviderConfigPatchSchema: z.ZodObject<{
960
960
  }, z.core.$strip>>>;
961
961
  modelVisibility: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
962
962
  enabled: "enabled";
963
- visible: "visible";
964
963
  disabled: "disabled";
964
+ visible: "visible";
965
965
  }>>>;
966
966
  enabled: z.ZodOptional<z.ZodBoolean>;
967
967
  }, z.core.$strict>;
@@ -11,8 +11,8 @@ import * as _$_makaio_core0 from "@makaio/framework/core";
11
11
  */
12
12
  declare const FacetAuthoritySchema: z.ZodEnum<{
13
13
  system: "system";
14
- human: "human";
15
14
  agent: "agent";
15
+ human: "human";
16
16
  }>;
17
17
  /**
18
18
  * Cardinality of values a facet namespace permits per target.
@@ -32,9 +32,9 @@ declare const FacetCardinalitySchema: z.ZodEnum<{
32
32
  * - `'surface'` — a UI surface or layout area
33
33
  */
34
34
  declare const FacetAppliesToSchema: z.ZodEnum<{
35
- surface: "surface";
36
- workpiece: "workpiece";
37
35
  artifact: "artifact";
36
+ workpiece: "workpiece";
37
+ surface: "surface";
38
38
  }>;
39
39
  /**
40
40
  * Serializable registration record for a named facet namespace.
@@ -53,13 +53,13 @@ declare const FacetNamespaceRegistrationSchema: z.ZodObject<{
53
53
  values: z.ZodUnion<readonly [z.ZodLiteral<"open">, z.ZodReadonly<z.ZodArray<z.ZodString>>]>;
54
54
  authority: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
55
55
  system: "system";
56
- human: "human";
57
56
  agent: "agent";
57
+ human: "human";
58
58
  }>>>;
59
59
  appliesTo: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
60
- surface: "surface";
61
- workpiece: "workpiece";
62
60
  artifact: "artifact";
61
+ workpiece: "workpiece";
62
+ surface: "surface";
63
63
  }>>>;
64
64
  description: z.ZodOptional<z.ZodString>;
65
65
  }, z.core.$strip>;
@@ -157,13 +157,13 @@ declare const FacetSchemas: {
157
157
  values: z.ZodUnion<readonly [z.ZodLiteral<"open">, z.ZodReadonly<z.ZodArray<z.ZodString>>]>;
158
158
  authority: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
159
159
  system: "system";
160
- human: "human";
161
160
  agent: "agent";
161
+ human: "human";
162
162
  }>>>;
163
163
  appliesTo: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
164
- surface: "surface";
165
- workpiece: "workpiece";
166
164
  artifact: "artifact";
165
+ workpiece: "workpiece";
166
+ surface: "surface";
167
167
  }>>>;
168
168
  description: z.ZodOptional<z.ZodString>;
169
169
  }, z.core.$strip>;
@@ -185,13 +185,13 @@ declare const FacetSchemas: {
185
185
  values: z.ZodUnion<readonly [z.ZodLiteral<"open">, z.ZodReadonly<z.ZodArray<z.ZodString>>]>;
186
186
  authority: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
187
187
  system: "system";
188
- human: "human";
189
188
  agent: "agent";
189
+ human: "human";
190
190
  }>>>;
191
191
  appliesTo: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
192
- surface: "surface";
193
- workpiece: "workpiece";
194
192
  artifact: "artifact";
193
+ workpiece: "workpiece";
194
+ surface: "surface";
195
195
  }>>>;
196
196
  description: z.ZodOptional<z.ZodString>;
197
197
  }, z.core.$strip>>;
@@ -223,13 +223,13 @@ declare const FacetNamespace: _$_makaio_core0.BusNamespaceDefinition<"facet", {
223
223
  values: z.ZodUnion<readonly [z.ZodLiteral<"open">, z.ZodReadonly<z.ZodArray<z.ZodString>>]>;
224
224
  authority: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
225
225
  system: "system";
226
- human: "human";
227
226
  agent: "agent";
227
+ human: "human";
228
228
  }>>>;
229
229
  appliesTo: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
230
- surface: "surface";
231
- workpiece: "workpiece";
232
230
  artifact: "artifact";
231
+ workpiece: "workpiece";
232
+ surface: "surface";
233
233
  }>>>;
234
234
  description: z.ZodOptional<z.ZodString>;
235
235
  }, z.core.$strip>;
@@ -251,13 +251,13 @@ declare const FacetNamespace: _$_makaio_core0.BusNamespaceDefinition<"facet", {
251
251
  values: z.ZodUnion<readonly [z.ZodLiteral<"open">, z.ZodReadonly<z.ZodArray<z.ZodString>>]>;
252
252
  authority: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
253
253
  system: "system";
254
- human: "human";
255
254
  agent: "agent";
255
+ human: "human";
256
256
  }>>>;
257
257
  appliesTo: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
258
- surface: "surface";
259
- workpiece: "workpiece";
260
258
  artifact: "artifact";
259
+ workpiece: "workpiece";
260
+ surface: "surface";
261
261
  }>>>;
262
262
  description: z.ZodOptional<z.ZodString>;
263
263
  }, z.core.$strip>>;
@@ -295,13 +295,13 @@ declare const FacetSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.FlatSub
295
295
  values: z.ZodUnion<readonly [z.ZodLiteral<"open">, z.ZodReadonly<z.ZodArray<z.ZodString>>]>;
296
296
  authority: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
297
297
  system: "system";
298
- human: "human";
299
298
  agent: "agent";
299
+ human: "human";
300
300
  }>>>;
301
301
  appliesTo: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
302
- surface: "surface";
303
- workpiece: "workpiece";
304
302
  artifact: "artifact";
303
+ workpiece: "workpiece";
304
+ surface: "surface";
305
305
  }>>>;
306
306
  description: z.ZodOptional<z.ZodString>;
307
307
  }, z.core.$strip>;
@@ -323,13 +323,13 @@ declare const FacetSubjects: _$_makaio_core0.BusSubjects<_$_makaio_core0.FlatSub
323
323
  values: z.ZodUnion<readonly [z.ZodLiteral<"open">, z.ZodReadonly<z.ZodArray<z.ZodString>>]>;
324
324
  authority: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
325
325
  system: "system";
326
- human: "human";
327
326
  agent: "agent";
327
+ human: "human";
328
328
  }>>>;
329
329
  appliesTo: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
330
- surface: "surface";
331
- workpiece: "workpiece";
332
330
  artifact: "artifact";
331
+ workpiece: "workpiece";
332
+ surface: "surface";
333
333
  }>>>;
334
334
  description: z.ZodOptional<z.ZodString>;
335
335
  }, z.core.$strip>>;