@agimon-ai/po-core 0.0.0-alpha.105 → 0.0.0-alpha.107

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.
@@ -20,6 +20,8 @@ interface PoServerBundleEntry {
20
20
  readonly origin?: 'po' | 'personal' | 'unknown';
21
21
  /** Validated additive client metadata, retained without importing browser code. */
22
22
  readonly webMetadata?: PoWebBrainMetadata;
23
+ /** The same descriptive metadata for the package's native half. */
24
+ readonly nativeMetadata?: PoWebBrainMetadata;
23
25
  /** Parsed at package load. Missing or malformed contracts cannot authorize federation. */
24
26
  readonly apiContract?: PoApiContract;
25
27
  /** The declared package-relative source entry, retained for attribution. */
@@ -68,6 +70,8 @@ interface BrainPackage {
68
70
  scope: BrainScope;
69
71
  owner: BrainOwner;
70
72
  web: PoWebBrainMetadata | null;
73
+ /** Installed native-half metadata; browser mount inventories omit it. */
74
+ native?: PoWebBrainMetadata | null;
71
75
  }
72
76
  interface BrainServicesSnapshot {
73
77
  scope: BrainScope;
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.d.mts","names":["_0","_0","_0","IoContext","_0","_$__hubChannel0.PoHubSessionUsage","_0","_$__protocolContracts0.ChordMethods"],"sources":["../src/schemas/serverBundle.ts","../src/schemas/brain.ts","../src/schemas/serverScope.ts","../src/schemas/approvalPrompt.ts","../src/schemas/approval.ts","../src/schemas/backgroundWork.ts","../src/schemas/platform.ts","../src/schemas/workflow.ts","../src/schemas/hubChannel.ts","../src/schemas/packageApi.ts","../src/schemas/apiContracts.ts","../src/services/apiContracts/index.ts","../src/schemas/builtinApiContracts.ts","../src/schemas/httpApiContracts.ts","../src/schemas/protocolContracts.ts","../src/schemas/sessionProtocol.ts","../src/schemas/sessionApiContracts.ts","../src/schemas/transportApiContracts.ts"],"mappings":";;;;;;;;;;;;UAKiB;WACN;WACA;;UAGM;WACN;;WAEA;;WAEA,cAAc;;WAEd,cAAc;;WAEd;;WAEA;WACA,iBAAiB;WACj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AA,KAAA,OAAA,KAAA,QAAA,KAAA,SAAA,KAAA,aAAA,KAAA,YAAA,KAAA,UAAA,KAAA,UAAA,KAAA,OAAA,KAAA,aAAA,KAAA,QAAA,KAAA,eAAA,KAAA,UAAA,KAAA,UAAA,KAAA,OAAA,KAAA,aAAA,KAAA,QAAA,KAAA,eAAA,KAAA,QAAA,KAAA,OAAA,KAAA,QAAA,KAAA,SAAA,KAAA,aAAA,KAAA,YAAA,KAAA,OAAA,KAAA,aAAA,KAAA,QAAA,KAAA,eAAA,KAAA,OAAA,KAAA,aAAA,KAAA,QAAA,KAAA,eAAA,KAAA,UAAA,KAAA,OAAA,KAAA,QAAA,KAAA,SAAA,KAAA;;qBAqCjB,wBAAsB,KAAA,QAAA,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAwBtB,wBAAsB,KAAA,QAAA,KAAA"}
1
+ {"version":3,"file":"apiContracts.d.mts","names":["_0","_0","_0","IoContext","_0","_$__hubChannel0.PoHubSessionUsage","_0","_$__protocolContracts0.ChordMethods"],"sources":["../src/schemas/serverBundle.ts","../src/schemas/brain.ts","../src/schemas/serverScope.ts","../src/schemas/approvalPrompt.ts","../src/schemas/approval.ts","../src/schemas/backgroundWork.ts","../src/schemas/platform.ts","../src/schemas/workflow.ts","../src/schemas/hubChannel.ts","../src/schemas/packageApi.ts","../src/schemas/apiContracts.ts","../src/services/apiContracts/index.ts","../src/schemas/builtinApiContracts.ts","../src/schemas/httpApiContracts.ts","../src/schemas/protocolContracts.ts","../src/schemas/sessionProtocol.ts","../src/schemas/sessionApiContracts.ts","../src/schemas/transportApiContracts.ts"],"mappings":";;;;;;;;;;;;UAKiB;WACN;WACA;;UAGM;WACN;;WAEA;;WAEA,cAAc;;WAEd,iBAAiB;;WAEjB,cAAc;;WAEd;;WAEA;WACA,iBAAiB;WACjB,iBAAiB;WACjB;;;;;UCtBM;EACf;EACA,OAAO;;UAGQ;EACf;EACA;EACA,QAAQ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AAA,KAAA,UAAA,KAAA,UAAA,KAAA,OAAA,KAAA,aAAA,KAAA,QAAA,KAAA,eAAA,KAAA,UAAA,KAAA,UAAA,KAAA,OAAA,KAAA,aAAA,KAAA,QAAA,KAAA,eAAA,KAAA,QAAA,KAAA,OAAA,KAAA,QAAA,KAAA,SAAA,KAAA,aAAA,KAAA,YAAA,KAAA,OAAA,KAAA,aAAA,KAAA,QAAA,KAAA,eAAA,KAAA,OAAA,KAAA,aAAA,KAAA,QAAA,KAAA,eAAA,KAAA,UAAA,KAAA,OAAA,KAAA,QAAA,KAAA,SAAA,KAAA;;qBAqCjB,wBAAsB,KAAA,QAAA,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAwBtB,wBAAsB,KAAA,QAAA,KAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"brain.cjs","names":[],"sources":["../../../src/schemas/brain.ts"],"sourcesContent":["import type { PoApiScope } from './packageApi';\nimport type { PoServerBundleEntry } from './serverBundle';\n\n/** Detached descriptions only. No service values, fibers, paths or callbacks cross this boundary. */\nexport interface BrainScope {\n id: string;\n level: PoApiScope;\n}\n\nexport interface BrainOwner {\n kind: 'host' | 'package' | 'unknown';\n packageName: string | null;\n origin: NonNullable<PoServerBundleEntry['origin']>;\n}\n\nexport interface BrainService {\n id: string;\n name: string;\n scope: BrainScope;\n visibleFrom: BrainScope;\n owner: BrainOwner;\n public: boolean;\n description: string | null;\n}\n\nexport interface BrainConsumer {\n id: string;\n name: string;\n scope: BrainScope;\n owner: BrainOwner;\n}\n\n/** Declared injections only, never inferred from ctx.get or requirePo helpers. */\nexport interface BrainEdge {\n consumer: string;\n service: string | null;\n name: string;\n status: 'resolved' | 'waiting';\n}\n\nexport interface BrainPackage {\n scope: BrainScope;\n owner: BrainOwner;\n web: PoWebBrainMetadata | null;\n}\n\nexport interface BrainServicesSnapshot {\n scope: BrainScope;\n scopes: BrainScope[];\n packages: BrainPackage[];\n /** Exact published browser mounts, when the host supplied every scope's inventory. */\n clientPackages?: BrainPackage[];\n services: BrainService[];\n consumers: BrainConsumer[];\n edges: BrainEdge[];\n diagnostics: string[];\n}\n\nexport interface BrainSlot {\n id: string;\n name: string;\n scope: BrainScope;\n owner: BrainOwner;\n description: string | null;\n parent: string | null;\n kind: 'data' | 'component';\n}\n\nexport interface BrainFill {\n id: string;\n slot: string | null;\n scope: BrainScope;\n owner: BrainOwner;\n /** Unverified identities are not evidence of placement or of a currently rendered component. */\n placement: 'verified' | 'unverified';\n}\n\nexport interface BrainSlotsSnapshot {\n scope: BrainScope;\n scopes: BrainScope[];\n slots: BrainSlot[];\n fills: BrainFill[];\n diagnostics: string[];\n}\n\n/** Additive manifest metadata. Older manifests omit this block rather than claiming no slots. */\nexport interface PoWebBrainMetadata {\n version: 1;\n slots: {\n name: string;\n scope: PoApiScope;\n description?: string;\n parent?: string;\n kind: 'data' | 'component';\n }[];\n fills: {\n id: string;\n slot: string | null;\n scope: PoApiScope;\n placement: 'verified' | 'unverified';\n }[];\n diagnostics: string[];\n}\n\n/** Host-owned data updated when a browser composition publishes, never by a remote request. */\nexport interface PoClientPluginInventory {\n available: boolean;\n packages: { owner: BrainOwner; web: PoWebBrainMetadata | null }[];\n}\n\n/** Bound and project untrusted descriptive manifests without carrying executable fields. */\nexport function parsePoWebBrainMetadata(value: unknown): PoWebBrainMetadata | undefined {\n const record = (input: unknown): input is Record<string, unknown> =>\n input !== null && typeof input === 'object' && !Array.isArray(input);\n const text = (input: unknown): input is string => typeof input === 'string' && input.length <= 16_384;\n const identity = (input: unknown): input is string => text(input) && input.trim().length > 0;\n const scope = (input: unknown): input is PoApiScope =>\n input === 'global' || input === 'workspace' || input === 'session';\n const list = (input: unknown): input is unknown[] => Array.isArray(input) && input.length <= 4096;\n if (!record(value) || value.version !== 1 || !list(value.slots) || !list(value.fills) || !list(value.diagnostics))\n return undefined;\n const slots: PoWebBrainMetadata['slots'] = [];\n const fills: PoWebBrainMetadata['fills'] = [];\n for (const slot of value.slots) {\n if (\n !record(slot) ||\n !identity(slot.name) ||\n !scope(slot.scope) ||\n (slot.kind !== 'data' && slot.kind !== 'component') ||\n (slot.description !== undefined && !text(slot.description)) ||\n (slot.parent !== undefined && !identity(slot.parent))\n )\n return undefined;\n slots.push({\n name: slot.name,\n scope: slot.scope,\n kind: slot.kind,\n ...(slot.description === undefined ? {} : { description: slot.description }),\n ...(slot.parent === undefined ? {} : { parent: slot.parent }),\n });\n }\n for (const fill of value.fills) {\n if (\n !record(fill) ||\n !identity(fill.id) ||\n !scope(fill.scope) ||\n (fill.slot !== null && !identity(fill.slot)) ||\n (fill.placement !== 'verified' && fill.placement !== 'unverified') ||\n (fill.placement === 'verified' && fill.slot === null)\n )\n return undefined;\n fills.push({ id: fill.id, scope: fill.scope, slot: fill.slot, placement: fill.placement });\n }\n if (!value.diagnostics.every(text)) return undefined;\n const metadata: PoWebBrainMetadata = { version: 1, slots, fills, diagnostics: [...value.diagnostics] };\n return new TextEncoder().encode(JSON.stringify(metadata)).byteLength <= 1024 * 1024 ? metadata : undefined;\n}\n"],"mappings":";;AA+GA,SAAgB,wBAAwB,OAAgD;CACtF,MAAM,UAAU,UACd,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;CACrE,MAAM,QAAQ,UAAoC,OAAO,UAAU,YAAY,MAAM,UAAU;CAC/F,MAAM,YAAY,UAAoC,KAAK,KAAK,KAAK,MAAM,KAAK,CAAC,CAAC,SAAS;CAC3F,MAAM,SAAS,UACb,UAAU,YAAY,UAAU,eAAe,UAAU;CAC3D,MAAM,QAAQ,UAAuC,MAAM,QAAQ,KAAK,KAAK,MAAM,UAAU;CAC7F,IAAI,CAAC,OAAO,KAAK,KAAK,MAAM,YAAY,KAAK,CAAC,KAAK,MAAM,KAAK,KAAK,CAAC,KAAK,MAAM,KAAK,KAAK,CAAC,KAAK,MAAM,WAAW,GAC9G,OAAO,KAAA;CACT,MAAM,QAAqC,CAAC;CAC5C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ain.ts"],"sourcesContent":["import type { PoApiScope } from './packageApi';\nimport type { PoServerBundleEntry } from './serverBundle';\n\n/** Detached descriptions only. No service values, fibers, paths or callbacks cross this boundary. */\nexport interface BrainScope {\n id: string;\n level: PoApiScope;\n}\n\nexport interface BrainOwner {\n kind: 'host' | 'package' | 'unknown';\n packageName: string | null;\n origin: NonNullable<PoServerBundleEntry['origin']>;\n}\n\nexport interface BrainService {\n id: string;\n name: string;\n scope: BrainScope;\n visibleFrom: BrainScope;\n owner: BrainOwner;\n public: boolean;\n description: string | null;\n}\n\nexport interface BrainConsumer {\n id: string;\n name: string;\n scope: BrainScope;\n owner: BrainOwner;\n}\n\n/** Declared injections only, never inferred from ctx.get or requirePo helpers. */\nexport interface BrainEdge {\n consumer: string;\n service: string | null;\n name: string;\n status: 'resolved' | 'waiting';\n}\n\nexport interface BrainPackage {\n scope: BrainScope;\n owner: BrainOwner;\n web: PoWebBrainMetadata | null;\n /** Installed native-half metadata; browser mount inventories omit it. */\n native?: PoWebBrainMetadata | null;\n}\n\nexport interface BrainServicesSnapshot {\n scope: BrainScope;\n scopes: BrainScope[];\n packages: BrainPackage[];\n /** Exact published browser mounts, when the host supplied every scope's inventory. */\n clientPackages?: BrainPackage[];\n services: BrainService[];\n consumers: BrainConsumer[];\n edges: BrainEdge[];\n diagnostics: string[];\n}\n\nexport interface BrainSlot {\n id: string;\n name: string;\n scope: BrainScope;\n owner: BrainOwner;\n description: string | null;\n parent: string | null;\n kind: 'data' | 'component';\n}\n\nexport interface BrainFill {\n id: string;\n slot: string | null;\n scope: BrainScope;\n owner: BrainOwner;\n /** Unverified identities are not evidence of placement or of a currently rendered component. */\n placement: 'verified' | 'unverified';\n}\n\nexport interface BrainSlotsSnapshot {\n scope: BrainScope;\n scopes: BrainScope[];\n slots: BrainSlot[];\n fills: BrainFill[];\n diagnostics: string[];\n}\n\n/** Additive manifest metadata. Older manifests omit this block rather than claiming no slots. */\nexport interface PoWebBrainMetadata {\n version: 1;\n slots: {\n name: string;\n scope: PoApiScope;\n description?: string;\n parent?: string;\n kind: 'data' | 'component';\n }[];\n fills: {\n id: string;\n slot: string | null;\n scope: PoApiScope;\n placement: 'verified' | 'unverified';\n }[];\n diagnostics: string[];\n}\n\n/** Host-owned data updated when a browser composition publishes, never by a remote request. */\nexport interface PoClientPluginInventory {\n available: boolean;\n packages: { owner: BrainOwner; web: PoWebBrainMetadata | null }[];\n}\n\n/** Bound and project untrusted descriptive manifests without carrying executable fields. */\nexport function parsePoWebBrainMetadata(value: unknown): PoWebBrainMetadata | undefined {\n const record = (input: unknown): input is Record<string, unknown> =>\n input !== null && typeof input === 'object' && !Array.isArray(input);\n const text = (input: unknown): input is string => typeof input === 'string' && input.length <= 16_384;\n const identity = (input: unknown): input is string => text(input) && input.trim().length > 0;\n const scope = (input: unknown): input is PoApiScope =>\n input === 'global' || input === 'workspace' || input === 'session';\n const list = (input: unknown): input is unknown[] => Array.isArray(input) && input.length <= 4096;\n if (!record(value) || value.version !== 1 || !list(value.slots) || !list(value.fills) || !list(value.diagnostics))\n return undefined;\n const slots: PoWebBrainMetadata['slots'] = [];\n const fills: PoWebBrainMetadata['fills'] = [];\n for (const slot of value.slots) {\n if (\n !record(slot) ||\n !identity(slot.name) ||\n !scope(slot.scope) ||\n (slot.kind !== 'data' && slot.kind !== 'component') ||\n (slot.description !== undefined && !text(slot.description)) ||\n (slot.parent !== undefined && !identity(slot.parent))\n )\n return undefined;\n slots.push({\n name: slot.name,\n scope: slot.scope,\n kind: slot.kind,\n ...(slot.description === undefined ? {} : { description: slot.description }),\n ...(slot.parent === undefined ? {} : { parent: slot.parent }),\n });\n }\n for (const fill of value.fills) {\n if (\n !record(fill) ||\n !identity(fill.id) ||\n !scope(fill.scope) ||\n (fill.slot !== null && !identity(fill.slot)) ||\n (fill.placement !== 'verified' && fill.placement !== 'unverified') ||\n (fill.placement === 'verified' && fill.slot === null)\n )\n return undefined;\n fills.push({ id: fill.id, scope: fill.scope, slot: fill.slot, placement: fill.placement });\n }\n if (!value.diagnostics.every(text)) return undefined;\n const metadata: PoWebBrainMetadata = { version: 1, slots, fills, diagnostics: [...value.diagnostics] };\n return new TextEncoder().encode(JSON.stringify(metadata)).byteLength <= 1024 * 1024 ? metadata : undefined;\n}\n"],"mappings":";;AAiHA,SAAgB,wBAAwB,OAAgD;CACtF,MAAM,UAAU,UACd,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;CACrE,MAAM,QAAQ,UAAoC,OAAO,UAAU,YAAY,MAAM,UAAU;CAC/F,MAAM,YAAY,UAAoC,KAAK,KAAK,KAAK,MAAM,KAAK,CAAC,CAAC,SAAS;CAC3F,MAAM,SAAS,UACb,UAAU,YAAY,UAAU,eAAe,UAAU;CAC3D,MAAM,QAAQ,UAAuC,MAAM,QAAQ,KAAK,KAAK,MAAM,UAAU;CAC7F,IAAI,CAAC,OAAO,KAAK,KAAK,MAAM,YAAY,KAAK,CAAC,KAAK,MAAM,KAAK,KAAK,CAAC,KAAK,MAAM,KAAK,KAAK,CAAC,KAAK,MAAM,WAAW,GAC9G,OAAO,KAAA;CACT,MAAM,QAAqC,CAAC;CAC5C,MAAM,QAAqC,CAAC;CAC5C,KAAK,MAAM,QAAQ,MAAM,OAAO;EAC9B,IACE,CAAC,OAAO,IAAI,KACZ,CAAC,SAAS,KAAK,IAAI,KACnB,CAAC,MAAM,KAAK,KAAK,KAChB,KAAK,SAAS,UAAU,KAAK,SAAS,eACtC,KAAK,gBAAgB,KAAA,KAAa,CAAC,KAAK,KAAK,WAAW,KACxD,KAAK,WAAW,KAAA,KAAa,CAAC,SAAS,KAAK,MAAM,GAEnD,OAAO,KAAA;EACT,MAAM,KAAK;GACT,MAAM,KAAK;GACX,OAAO,KAAK;GACZ,MAAM,KAAK;GACX,GAAI,KAAK,gBAAgB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa,KAAK,YAAY;GAC1E,GAAI,KAAK,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO;EAC7D,CAAC;CACH;CACA,KAAK,MAAM,QAAQ,MAAM,OAAO;EAC9B,IACE,CAAC,OAAO,IAAI,KACZ,CAAC,SAAS,KAAK,EAAE,KACjB,CAAC,MAAM,KAAK,KAAK,KAChB,KAAK,SAAS,QAAQ,CAAC,SAAS,KAAK,IAAI,KACzC,KAAK,cAAc,cAAc,KAAK,cAAc,gBACpD,KAAK,cAAc,cAAc,KAAK,SAAS,MAEhD,OAAO,KAAA;EACT,MAAM,KAAK;GAAE,IAAI,KAAK;GAAI,OAAO,KAAK;GAAO,MAAM,KAAK;GAAM,WAAW,KAAK;EAAU,CAAC;CAC3F;CACA,IAAI,CAAC,MAAM,YAAY,MAAM,IAAI,GAAG,OAAO,KAAA;CAC3C,MAAM,WAA+B;EAAE,SAAS;EAAG;EAAO;EAAO,aAAa,CAAC,GAAG,MAAM,WAAW;CAAE;CACrG,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK,UAAU,QAAQ,CAAC,CAAC,CAAC,cAAc,UAAc,WAAW,KAAA;AACnG"}
@@ -37,6 +37,8 @@ export interface BrainPackage {
37
37
  scope: BrainScope;
38
38
  owner: BrainOwner;
39
39
  web: PoWebBrainMetadata | null;
40
+ /** Installed native-half metadata; browser mount inventories omit it. */
41
+ native?: PoWebBrainMetadata | null;
40
42
  }
41
43
  export interface BrainServicesSnapshot {
42
44
  scope: BrainScope;
@@ -1 +1 @@
1
- {"version":3,"file":"brain.d.mts","names":[],"sources":["../../../src/schemas/brain.ts"],"mappings":";;;;iBAIiB;EACf;EACA,OAAO;;iBAGQ;EACf;EACA;EACA,QAAQ,YAAY;;iBAGL;EACf;EACA;EACA,OAAO;EACP,aAAa;EACb,OAAO;EACP;EACA;;iBAGe;EACf;EACA;EACA,OAAO;EACP,OAAO;;;iBAIQ;EACf;EACA;EACA;EACA;;iBAGe;EACf,OAAO;EACP,OAAO;EACP,KAAK;;iBAGU;EACf,OAAO;EACP,QAAQ;EACR,UAAU;;EAEV,iBAAiB;EACjB,UAAU;EACV,WAAW;EACX,OAAO;EACP;;iBAGe;EACf;EACA;EACA,OAAO;EACP,OAAO;EACP;EACA;EACA;;iBAGe;EACf;EACA;EACA,OAAO;EACP,OAAO;;EAEP;;iBAGe;EACf,OAAO;EACP,QAAQ;EACR,OAAO;EACP,OAAO;EACP;;;iBAIe;EACf;EACA;IACE;IACA,OAAO;IACP;IACA;IACA;;EAEF;IACE;IACA;IACA,OAAO;IACP;;EAEF;;;iBAIe;EACf;EACA;IAAY,OAAO;IAAY,KAAK;;;;wBAItB,wBAAwB,iBAAiB"}
1
+ {"version":3,"file":"brain.d.mts","names":[],"sources":["../../../src/schemas/brain.ts"],"mappings":";;;;iBAIiB;EACf;EACA,OAAO;;iBAGQ;EACf;EACA;EACA,QAAQ,YAAY;;iBAGL;EACf;EACA;EACA,OAAO;EACP,aAAa;EACb,OAAO;EACP;EACA;;iBAGe;EACf;EACA;EACA,OAAO;EACP,OAAO;;;iBAIQ;EACf;EACA;EACA;EACA;;iBAGe;EACf,OAAO;EACP,OAAO;EACP,KAAK;;EAEL,SAAS;;iBAGM;EACf,OAAO;EACP,QAAQ;EACR,UAAU;;EAEV,iBAAiB;EACjB,UAAU;EACV,WAAW;EACX,OAAO;EACP;;iBAGe;EACf;EACA;EACA,OAAO;EACP,OAAO;EACP;EACA;EACA;;iBAGe;EACf;EACA;EACA,OAAO;EACP,OAAO;;EAEP;;iBAGe;EACf,OAAO;EACP,QAAQ;EACR,OAAO;EACP,OAAO;EACP;;;iBAIe;EACf;EACA;IACE;IACA,OAAO;IACP;IACA;IACA;;EAEF;IACE;IACA;IACA,OAAO;IACP;;EAEF;;;iBAIe;EACf;EACA;IAAY,OAAO;IAAY,KAAK;;;;wBAItB,wBAAwB,iBAAiB"}
@@ -1 +1 @@
1
- {"version":3,"file":"brain.mjs","names":[],"sources":["../../../src/schemas/brain.ts"],"sourcesContent":["import type { PoApiScope } from './packageApi';\nimport type { PoServerBundleEntry } from './serverBundle';\n\n/** Detached descriptions only. No service values, fibers, paths or callbacks cross this boundary. */\nexport interface BrainScope {\n id: string;\n level: PoApiScope;\n}\n\nexport interface BrainOwner {\n kind: 'host' | 'package' | 'unknown';\n packageName: string | null;\n origin: NonNullable<PoServerBundleEntry['origin']>;\n}\n\nexport interface BrainService {\n id: string;\n name: string;\n scope: BrainScope;\n visibleFrom: BrainScope;\n owner: BrainOwner;\n public: boolean;\n description: string | null;\n}\n\nexport interface BrainConsumer {\n id: string;\n name: string;\n scope: BrainScope;\n owner: BrainOwner;\n}\n\n/** Declared injections only, never inferred from ctx.get or requirePo helpers. */\nexport interface BrainEdge {\n consumer: string;\n service: string | null;\n name: string;\n status: 'resolved' | 'waiting';\n}\n\nexport interface BrainPackage {\n scope: BrainScope;\n owner: BrainOwner;\n web: PoWebBrainMetadata | null;\n}\n\nexport interface BrainServicesSnapshot {\n scope: BrainScope;\n scopes: BrainScope[];\n packages: BrainPackage[];\n /** Exact published browser mounts, when the host supplied every scope's inventory. */\n clientPackages?: BrainPackage[];\n services: BrainService[];\n consumers: BrainConsumer[];\n edges: BrainEdge[];\n diagnostics: string[];\n}\n\nexport interface BrainSlot {\n id: string;\n name: string;\n scope: BrainScope;\n owner: BrainOwner;\n description: string | null;\n parent: string | null;\n kind: 'data' | 'component';\n}\n\nexport interface BrainFill {\n id: string;\n slot: string | null;\n scope: BrainScope;\n owner: BrainOwner;\n /** Unverified identities are not evidence of placement or of a currently rendered component. */\n placement: 'verified' | 'unverified';\n}\n\nexport interface BrainSlotsSnapshot {\n scope: BrainScope;\n scopes: BrainScope[];\n slots: BrainSlot[];\n fills: BrainFill[];\n diagnostics: string[];\n}\n\n/** Additive manifest metadata. Older manifests omit this block rather than claiming no slots. */\nexport interface PoWebBrainMetadata {\n version: 1;\n slots: {\n name: string;\n scope: PoApiScope;\n description?: string;\n parent?: string;\n kind: 'data' | 'component';\n }[];\n fills: {\n id: string;\n slot: string | null;\n scope: PoApiScope;\n placement: 'verified' | 'unverified';\n }[];\n diagnostics: string[];\n}\n\n/** Host-owned data updated when a browser composition publishes, never by a remote request. */\nexport interface PoClientPluginInventory {\n available: boolean;\n packages: { owner: BrainOwner; web: PoWebBrainMetadata | null }[];\n}\n\n/** Bound and project untrusted descriptive manifests without carrying executable fields. */\nexport function parsePoWebBrainMetadata(value: unknown): PoWebBrainMetadata | undefined {\n const record = (input: unknown): input is Record<string, unknown> =>\n input !== null && typeof input === 'object' && !Array.isArray(input);\n const text = (input: unknown): input is string => typeof input === 'string' && input.length <= 16_384;\n const identity = (input: unknown): input is string => text(input) && input.trim().length > 0;\n const scope = (input: unknown): input is PoApiScope =>\n input === 'global' || input === 'workspace' || input === 'session';\n const list = (input: unknown): input is unknown[] => Array.isArray(input) && input.length <= 4096;\n if (!record(value) || value.version !== 1 || !list(value.slots) || !list(value.fills) || !list(value.diagnostics))\n return undefined;\n const slots: PoWebBrainMetadata['slots'] = [];\n const fills: PoWebBrainMetadata['fills'] = [];\n for (const slot of value.slots) {\n if (\n !record(slot) ||\n !identity(slot.name) ||\n !scope(slot.scope) ||\n (slot.kind !== 'data' && slot.kind !== 'component') ||\n (slot.description !== undefined && !text(slot.description)) ||\n (slot.parent !== undefined && !identity(slot.parent))\n )\n return undefined;\n slots.push({\n name: slot.name,\n scope: slot.scope,\n kind: slot.kind,\n ...(slot.description === undefined ? {} : { description: slot.description }),\n ...(slot.parent === undefined ? {} : { parent: slot.parent }),\n });\n }\n for (const fill of value.fills) {\n if (\n !record(fill) ||\n !identity(fill.id) ||\n !scope(fill.scope) ||\n (fill.slot !== null && !identity(fill.slot)) ||\n (fill.placement !== 'verified' && fill.placement !== 'unverified') ||\n (fill.placement === 'verified' && fill.slot === null)\n )\n return undefined;\n fills.push({ id: fill.id, scope: fill.scope, slot: fill.slot, placement: fill.placement });\n }\n if (!value.diagnostics.every(text)) return undefined;\n const metadata: PoWebBrainMetadata = { version: 1, slots, fills, diagnostics: [...value.diagnostics] };\n return new TextEncoder().encode(JSON.stringify(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AS,KAAK,EAAE,KACjB,CAAC,MAAM,KAAK,KAAK,KAChB,KAAK,SAAS,QAAQ,CAAC,SAAS,KAAK,IAAI,KACzC,KAAK,cAAc,cAAc,KAAK,cAAc,gBACpD,KAAK,cAAc,cAAc,KAAK,SAAS,MAEhD,OAAO,KAAA;EACT,MAAM,KAAK;GAAE,IAAI,KAAK;GAAI,OAAO,KAAK;GAAO,MAAM,KAAK;GAAM,WAAW,KAAK;EAAU,CAAC;CAC3F;CACA,IAAI,CAAC,MAAM,YAAY,MAAM,IAAI,GAAG,OAAO,KAAA;CAC3C,MAAM,WAA+B;EAAE,SAAS;EAAG;EAAO;EAAO,aAAa,CAAC,GAAG,MAAM,WAAW;CAAE;CACrG,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK,UAAU,QAAQ,CAAC,CAAC,CAAC,cAAc,UAAc,WAAW,KAAA;AACnG"}
1
+ {"version":3,"file":"brain.mjs","names":[],"sources":["../../../src/schemas/brain.ts"],"sourcesContent":["import type { PoApiScope } from './packageApi';\nimport type { PoServerBundleEntry } from './serverBundle';\n\n/** Detached descriptions only. No service values, fibers, paths or callbacks cross this boundary. */\nexport interface BrainScope {\n id: string;\n level: PoApiScope;\n}\n\nexport interface BrainOwner {\n kind: 'host' | 'package' | 'unknown';\n packageName: string | null;\n origin: NonNullable<PoServerBundleEntry['origin']>;\n}\n\nexport interface BrainService {\n id: string;\n name: string;\n scope: BrainScope;\n visibleFrom: BrainScope;\n owner: BrainOwner;\n public: boolean;\n description: string | null;\n}\n\nexport interface BrainConsumer {\n id: string;\n name: string;\n scope: BrainScope;\n owner: BrainOwner;\n}\n\n/** Declared injections only, never inferred from ctx.get or requirePo helpers. */\nexport interface BrainEdge {\n consumer: string;\n service: string | null;\n name: string;\n status: 'resolved' | 'waiting';\n}\n\nexport interface BrainPackage {\n scope: BrainScope;\n owner: BrainOwner;\n web: PoWebBrainMetadata | null;\n /** Installed native-half metadata; browser mount inventories omit it. */\n native?: PoWebBrainMetadata | null;\n}\n\nexport interface BrainServicesSnapshot {\n scope: BrainScope;\n scopes: BrainScope[];\n packages: BrainPackage[];\n /** Exact published browser mounts, when the host supplied every scope's inventory. */\n clientPackages?: BrainPackage[];\n services: BrainService[];\n consumers: BrainConsumer[];\n edges: BrainEdge[];\n diagnostics: string[];\n}\n\nexport interface BrainSlot {\n id: string;\n name: string;\n scope: BrainScope;\n owner: BrainOwner;\n description: string | null;\n parent: string | null;\n kind: 'data' | 'component';\n}\n\nexport interface BrainFill {\n id: string;\n slot: string | null;\n scope: BrainScope;\n owner: BrainOwner;\n /** Unverified identities are not evidence of placement or of a currently rendered component. */\n placement: 'verified' | 'unverified';\n}\n\nexport interface BrainSlotsSnapshot {\n scope: BrainScope;\n scopes: BrainScope[];\n slots: BrainSlot[];\n fills: BrainFill[];\n diagnostics: string[];\n}\n\n/** Additive manifest metadata. Older manifests omit this block rather than claiming no slots. */\nexport interface PoWebBrainMetadata {\n version: 1;\n slots: {\n name: string;\n scope: PoApiScope;\n description?: string;\n parent?: string;\n kind: 'data' | 'component';\n }[];\n fills: {\n id: string;\n slot: string | null;\n scope: PoApiScope;\n placement: 'verified' | 'unverified';\n }[];\n diagnostics: string[];\n}\n\n/** Host-owned data updated when a browser composition publishes, never by a remote request. */\nexport interface PoClientPluginInventory {\n available: boolean;\n packages: { owner: BrainOwner; web: PoWebBrainMetadata | null }[];\n}\n\n/** Bound and project untrusted descriptive manifests without carrying executable fields. */\nexport function parsePoWebBrainMetadata(value: unknown): PoWebBrainMetadata | undefined {\n const record = (input: unknown): input is Record<string, unknown> =>\n input !== null && typeof input === 'object' && !Array.isArray(input);\n const text = (input: unknown): input is string => typeof input === 'string' && input.length <= 16_384;\n const identity = (input: unknown): input is string => text(input) && input.trim().length > 0;\n const scope = (input: unknown): input is PoApiScope =>\n input === 'global' || input === 'workspace' || input === 'session';\n const list = (input: unknown): input is unknown[] => Array.isArray(input) && input.length <= 4096;\n if (!record(value) || value.version !== 1 || !list(value.slots) || !list(value.fills) || !list(value.diagnostics))\n return undefined;\n const slots: PoWebBrainMetadata['slots'] = [];\n const fills: PoWebBrainMetadata['fills'] = [];\n for (const slot of value.slots) {\n if (\n !record(slot) ||\n !identity(slot.name) ||\n !scope(slot.scope) ||\n (slot.kind !== 'data' && slot.kind !== 'component') ||\n (slot.description !== undefined && !text(slot.description)) ||\n (slot.parent !== undefined && !identity(slot.parent))\n )\n return undefined;\n slots.push({\n name: slot.name,\n scope: slot.scope,\n kind: slot.kind,\n ...(slot.description === undefined ? {} : { description: slot.description }),\n ...(slot.parent === undefined ? {} : { parent: slot.parent }),\n });\n }\n for (const fill of value.fills) {\n if (\n !record(fill) ||\n !identity(fill.id) ||\n !scope(fill.scope) ||\n (fill.slot !== null && !identity(fill.slot)) ||\n (fill.placement !== 'verified' && fill.placement !== 'unverified') ||\n (fill.placement === 'verified' && fill.slot === null)\n )\n return undefined;\n fills.push({ id: fill.id, scope: fill.scope, slot: fill.slot, placement: fill.placement });\n }\n if (!value.diagnostics.every(text)) return undefined;\n const metadata: PoWebBrainMetadata = { version: 1, slots, fills, diagnostics: [...value.diagnostics] };\n return new TextEncoder().encode(JSON.stringify(metadata)).byteLength <= 1024 * 1024 ? metadata : undefined;\n}\n"],"mappings":";;AAiHA,SAAgB,wBAAwB,OAAgD;CACtF,MAAM,UAAU,UACd,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;CACrE,MAAM,QAAQ,UAAoC,OAAO,UAAU,YAAY,MAAM,UAAU;CAC/F,MAAM,YAAY,UAAoC,KAAK,KAAK,KAAK,MAAM,KAAK,CAAC,CAAC,SAAS;CAC3F,MAAM,SAAS,UACb,UAAU,YAAY,UAAU,eAAe,UAAU;CAC3D,MAAM,QAAQ,UAAuC,MAAM,QAAQ,KAAK,KAAK,MAAM,UAAU;CAC7F,IAAI,CAAC,OAAO,KAAK,KAAK,MAAM,YAAY,KAAK,CAAC,KAAK,MAAM,KAAK,KAAK,CAAC,KAAK,MAA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,CAAC,cAAc,UAAc,WAAW,KAAA;AACnG"}
@@ -13,6 +13,8 @@ export interface PoServerBundleEntry {
13
13
  readonly origin?: 'po' | 'personal' | 'unknown';
14
14
  /** Validated additive client metadata, retained without importing browser code. */
15
15
  readonly webMetadata?: PoWebBrainMetadata;
16
+ /** The same descriptive metadata for the package's native half. */
17
+ readonly nativeMetadata?: PoWebBrainMetadata;
16
18
  /** Parsed at package load. Missing or malformed contracts cannot authorize federation. */
17
19
  readonly apiContract?: PoApiContract;
18
20
  /** The declared package-relative source entry, retained for attribution. */
@@ -1 +1 @@
1
- {"version":3,"file":"serverBundle.d.mts","names":[],"sources":["../../../src/schemas/serverBundle.ts"],"mappings":";;;;;iBAKiB;WACN;WACA;;iBAGM;WACN;;WAEA;;WAEA,cAAc;;WAEd,cAAc;;WAEd;;WAEA;WACA,iBAAiB;WACjB,iBAAiB;WACjB"}
1
+ {"version":3,"file":"serverBundle.d.mts","names":[],"sources":["../../../src/schemas/serverBundle.ts"],"mappings":";;;;;iBAKiB;WACN;WACA;;iBAGM;WACN;;WAEA;;WAEA,cAAc;;WAEd,iBAAiB;;WAEjB,cAAc;;WAEd;;WAEA;WACA,iBAAiB;WACjB,iBAAiB;WACjB"}
@@ -389,7 +389,8 @@ var PoServerScope = class PoServerScope {
389
389
  result.packages.push({
390
390
  scope: describeScope(scope),
391
391
  owner,
392
- web: entry.declaration?.webMetadata ?? null
392
+ web: entry.declaration?.webMetadata ?? null,
393
+ native: entry.declaration?.nativeMetadata ?? null
393
394
  });
394
395
  const consumer = `${scope.label}:consumer:${name}`;
395
396
  result.consumers.push({
@@ -1 +1 @@
1
- {"version":3,"file":"serverScope.cjs","names":["PO_SERVER_SCOPE_LEVELS","Service","PO_GLOBAL_SERVICES_SERVICE","PO_SERVER_SCOPE_SERVICE","PO_SERVER_HOST_SERVICE","readPoHeadlessHost","PO_FS_SERVICE","PO_SHELL_SERVICE","PO_SQLITE_SERVICE","PO_SESSION_STORAGE_SERVICE","PO_ISOLATE_SERVICE","PO_NPM_SERVICE","PO_ELECTRON_SERVICE","PO_BROWSER_SERVICE","PO_PROVIDER_AUTH_SERVICE","PO_SESSION_FILES_SERVICE","BACKGROUND_CONTEXT","Context","PO_SESSION_TEMP_DIR","LIVE_FACTORY_TIMEOUT_MS","projectServiceBindingMetadata","parsePoWebBrainMetadata","PO_HOST_SERVICE_CONTRACTS","withTimeout","PO_HEADLESS_OWNER"],"sources":["../../../src/server/serverScope.ts"],"sourcesContent":["import { Context, type Events, type Fiber, Service } from '@deepseek-ai/cordis';\nimport { BACKGROUND_CONTEXT } from '@earendil-works/chord/context';\n\nimport {\n parsePoWebBrainMetadata,\n type BrainOwner,\n type BrainScope,\n type BrainServicesSnapshot,\n} from '../schemas/brain';\nimport { PO_GLOBAL_SERVICES_SERVICE, type PoGlobalServices } from '../schemas/globalServices';\nimport { PO_HEADLESS_OWNER, readPoHeadlessHost } from '../schemas/headless';\nimport { PO_HOST_SERVICE_CONTRACTS } from '../schemas/hostServiceContracts';\nimport type { PoApiHandler, PoApiScope } from '../schemas/packageApi';\nimport {\n PO_BROWSER_SERVICE,\n PO_ELECTRON_SERVICE,\n PO_FS_SERVICE,\n PO_ISOLATE_SERVICE,\n PO_NPM_SERVICE,\n PO_PROVIDER_AUTH_SERVICE,\n PO_SESSION_STORAGE_SERVICE,\n PO_SHELL_SERVICE,\n PO_SQLITE_SERVICE,\n type PoPlatform,\n} from '../schemas/platform';\nimport type { PoServerBundleEntry } from '../schemas/serverBundle';\nimport { PO_SERVER_HOST_SERVICE, type PoServerHostService, type PoServerPlugin } from '../schemas/serverPlugin';\nimport {\n PO_SERVER_SCOPE_LEVELS,\n projectServiceBindingMetadata,\n PO_SERVER_SCOPE_SERVICE,\n type PoServerPluginShare,\n type PoServerResourceKey,\n type PoServerResourceLease,\n type PoServerScopeService,\n type PoServiceContract,\n type PoServiceBindingMetadata,\n} from '../schemas/serverScope';\nimport { PO_SESSION_FILES_SERVICE, PO_SESSION_TEMP_DIR } from '../services/sessionFiles';\nimport { LIVE_FACTORY_TIMEOUT_MS, withTimeout } from './liveImport';\nimport type { LoadedServerPackage } from './serverPackages';\n\ninterface Binding {\n readonly name: string;\n readonly contract: PoServiceContract<unknown>;\n readonly metadata: PoServiceBindingMetadata;\n readonly value: unknown;\n /** The scope that bound it, named in logs. */\n readonly owner: PoServerScope;\n}\n\ninterface InstalledPackage {\n readonly plugin: PoServerPlugin;\n readonly declaration?: PoServerBundleEntry;\n readonly fiber: Fiber;\n}\n\n/** One shared value, how many levels hold it, and how its creator said to dispose it. */\ninterface SharedValue {\n readonly value: Promise<unknown>;\n holders: number;\n readonly disposeValue: ((value: unknown) => void | Promise<void>) | undefined;\n}\n\n/** What one plugin build shares in one tree: its keyed values, and what each scope running it holds. */\nclass PluginShare {\n readonly values = new Map<string, SharedValue>();\n readonly running = new Map<PoServerScope, unknown>();\n\n get idle(): boolean {\n return this.values.size === 0 && this.running.size === 0;\n }\n}\n\nconst resourceName = (key: PoServerResourceKey): string => JSON.stringify(typeof key === 'string' ? [key] : key);\n/** What a scope's owner publishes for the packages installed at its level. */\nexport interface PoServerScopeHost {\n /**\n * The level's mount table. A host that also routes requests (`createPoServerHost` does) answers\n * API requests for this level and every level below it that does not serve the API itself.\n */\n readonly host: PoServerHostService & { handlerFor?(basePath: string): PoApiHandler | undefined };\n /** Host capabilities published as `po/fs`, `po/shell`, `po/sqlite` and `po/session-storage`. */\n readonly platform: PoPlatform;\n}\n\nexport interface PoServerPackageSettledReport {\n readonly packageName: string;\n readonly durationMs: number;\n readonly outcome: 'installed' | 'failed' | 'timed_out';\n}\n\n/** A package whose build did not install, and what of it still runs. */\nexport interface PoServerPackageFailure {\n readonly packageName: string;\n readonly reason: string;\n /** `restored`: its previous build runs again; `lost`: that failed too; `none`: it had none. */\n readonly previous: 'restored' | 'lost' | 'none';\n}\n\nexport interface PoServerInstallOptions {\n readonly onNotice?: (message: string) => void;\n /** Bound on each package's `apply`; defaults to `LIVE_FACTORY_TIMEOUT_MS`. */\n readonly factoryTimeoutMs?: number;\n /** Reports how long each package's `apply` took and how it ended, for telemetry. */\n readonly onPackageSettled?: (report: PoServerPackageSettledReport) => void;\n /** Reports each package whose build did not install. */\n readonly onPackageFailed?: (failure: PoServerPackageFailure) => void;\n}\n\nconst depth = (level: PoApiScope): number => PO_SERVER_SCOPE_LEVELS.indexOf(level);\n\nconst describe = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\nconst PACKAGE_PROVENANCE = Symbol('package provenance');\n\nlet scopesOpened = 0;\nlet buildsSeen = 0;\nconst builds = new WeakMap<object, number>();\n/** A stable log label for one plugin build; a reload imports a new module, and so a new build. */\nfunction buildOf(owner: object): string {\n let build = builds.get(owner);\n if (build === undefined) builds.set(owner, (build = ++buildsSeen));\n return `build#${build}`;\n}\nconst nameOf = (owner: object): string | undefined => {\n const name = (owner as { name?: unknown }).name;\n return typeof name === 'string' ? name : undefined;\n};\n\n/** Publishes one binding as a native service of the root it is plugged into. */\nfunction bindingProvider(context: Context, { binding, scope }: { binding: Binding; scope: PoServerScope }): void {\n if (binding.name === PO_GLOBAL_SERVICES_SERVICE)\n new ScopedGlobalServices(context, binding.value as PoGlobalServices, scope);\n else context.provide(binding.name, binding.value);\n}\n\nclass ScopedGlobalServices extends Service<PoGlobalServices> implements PoGlobalServices {\n constructor(\n ctx: Context,\n private readonly registry: PoGlobalServices,\n private readonly scope: PoServerScope,\n ) {\n super(ctx, PO_GLOBAL_SERVICES_SERVICE);\n }\n\n register(\n owner: Parameters<PoGlobalServices['register']>[0],\n contribution: Parameters<PoGlobalServices['register']>[1],\n ) {\n return this.registry.register(owner, contribution, this.scope.provenance(this.ctx.fiber));\n }\n}\n\n/**\n * The scope service each root publishes.\n *\n * Cordis traceable services rebind `ctx` to the caller, so a binding made through\n * `provide` unwinds with the plugin that made it.\n */\nclass ScopeService extends Service<PoServerScopeService> implements PoServerScopeService {\n readonly level: PoApiScope;\n\n constructor(\n ctx: Context,\n private readonly scope: PoServerScope,\n ) {\n super(ctx, PO_SERVER_SCOPE_SERVICE);\n this.level = scope.level;\n }\n\n async provide<T>(contract: PoServiceContract<T>, value: T): Promise<() => Promise<void>> {\n return await this.ctx.effect(\n () => this.scope.bind(contract, value, this.scope.provenance(this.ctx.fiber)),\n `po scope provide ${contract.name}`,\n );\n }\n\n snapshot(): BrainServicesSnapshot {\n return this.scope.snapshot();\n }\n\n resolve<T>(contract: PoServiceContract<T>): T | undefined {\n return this.scope.resolve(contract);\n }\n\n emit<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void {\n this.scope.emit(name, ...args);\n }\n\n broadcast<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void {\n this.scope.broadcast(name, ...args);\n }\n\n plugin<TRoots>(owner: object): PoServerPluginShare<TRoots> {\n return this.scope.share<TRoots>(owner);\n }\n}\n\n/**\n * Binds registrations to the Cordis fiber that calls the host service.\n *\n * The host itself is shared by every package at its level, but Cordis traceable\n * services rebind `ctx` to the caller. That lets a package's registration unwind\n * even when `apply` throws before it can return its disposer.\n */\nclass ScopedPoServerHost extends Service<PoServerHostService> implements PoServerHostService {\n readonly scope: PoServerHostService['scope'];\n readonly context: PoServerHostService['context'];\n\n constructor(\n ctx: Context,\n private readonly host: PoServerHostService,\n ) {\n super(ctx, PO_SERVER_HOST_SERVICE);\n this.scope = host.scope;\n this.context = host.context;\n }\n\n registerApi(api: Parameters<PoServerHostService['registerApi']>[0]) {\n const headless = this.scope === 'session' ? readPoHeadlessHost(this.ctx) : undefined;\n if (headless) {\n const activity = headless.registerActivity({\n name: `api:${api.basePath}`,\n start: () => {\n const registration = this.host.registerApi(api);\n if (registration.mounted !== true) {\n registration.dispose();\n throw new Error(`package API '${api.basePath}' did not mount.`);\n }\n return () => {\n registration.dispose();\n };\n },\n });\n return {\n mounted: true,\n dispose: () => activity.dispose(),\n };\n }\n const registration = this.host.registerApi(api);\n if (registration.mounted !== true) {\n registration.dispose();\n throw new Error(`package API '${api.basePath}' did not mount.`);\n }\n this.ctx.effect(() => () => registration.dispose(), 'server package API registration');\n return registration;\n }\n\n registerChannel(channel: Parameters<PoServerHostService['registerChannel']>[0]) {\n const registration = this.host.registerChannel(channel);\n if (registration.mounted !== true) {\n registration.dispose();\n throw new Error(`hub channel '${channel.frameType}' did not mount.`);\n }\n this.ctx.effect(() => () => registration.dispose(), 'server package channel registration');\n return registration;\n }\n\n registerMethod: PoServerHostService['registerMethod'] = (definition, handler) => {\n const registration = this.host.registerMethod(definition, handler);\n if (registration.mounted !== true) {\n registration.dispose();\n throw new Error(`plugin method '${definition.service}.${definition.method}' did not mount.`);\n }\n this.ctx.effect(() => () => registration.dispose(), 'server package method registration');\n return registration;\n };\n\n mounted(): readonly string[] {\n return this.host.mounted();\n }\n\n mountedChannels(): readonly string[] {\n return this.host.mountedChannels();\n }\n}\n\n/** Publishes the host service from inside a root-level plugin, so it unwinds with the scope. */\nfunction serverHostProvider(context: Context, host: PoServerHostService): void {\n new ScopedPoServerHost(context, host);\n}\n\n/** Publishes the platform services from inside a root-level plugin, so they unwind with the scope. */\nfunction platformProvider(\n context: Context,\n input: { platform: PoPlatform; cwd: string; temporaryDirectory?: string },\n): void {\n const env = input.platform.env(input.cwd);\n context.provide(PO_FS_SERVICE, env);\n context.provide(PO_SHELL_SERVICE, env);\n context.provide(PO_SQLITE_SERVICE, input.platform.sqlite);\n context.provide(PO_SESSION_STORAGE_SERVICE, input.platform.sessions);\n if (input.platform.isolate !== undefined) context.provide(PO_ISOLATE_SERVICE, input.platform.isolate);\n if (input.platform.npm !== undefined) context.provide(PO_NPM_SERVICE, input.platform.npm);\n if (input.platform.electron !== undefined) context.provide(PO_ELECTRON_SERVICE, input.platform.electron);\n if (input.platform.browser !== undefined) context.provide(PO_BROWSER_SERVICE, input.platform.browser);\n if (input.platform.providerAuth !== undefined) context.provide(PO_PROVIDER_AUTH_SERVICE, input.platform.providerAuth);\n if (input.temporaryDirectory !== undefined)\n context.provide(PO_SESSION_FILES_SERVICE, { temporaryDirectory: input.temporaryDirectory });\n context.effect(() => () => env.cleanup(BACKGROUND_CONTEXT), 'platform execution env');\n}\n\n/**\n * One level of the server IoC tree: its own cordis root, a parent link, the contracts bound here,\n * and the packages installed here.\n *\n * Separate roots rather than one shared root, because cordis re-checks every fiber of a root on each\n * service change; a hundred sessions in one root would make every change scan all of them. A binding\n * is instead mirrored into each descendant root as a native service, so a plugin injects an outer\n * level's service exactly as it injects its own.\n */\nexport class PoServerScope {\n readonly root = new Context();\n private readonly children = new Set<PoServerScope>();\n private readonly bound = new Map<string, Binding>();\n private readonly mirrors = new Map<Binding, Fiber>();\n /** A binding waiting here for the farther one it shadows to leave, so a repeat mirror waits too. */\n private readonly replacing = new Map<Binding, Promise<void>>();\n private readonly hostFibers = new Set<Fiber>();\n private readonly installed = new Map<string, InstalledPackage>();\n private installs: Promise<void> = Promise.resolve();\n /** Set once a package's apply never settled, to the bound it overran; its fiber may never finish disposing. */\n private abandonedTimeoutMs: number | undefined;\n private notice: (message: string) => void = () => undefined;\n private disposing: Promise<void> | undefined;\n /** The served mount table, read when a request routes through this level. */\n private router: PoServerScopeHost['host'] | undefined;\n /** Kept by the outermost scope only: what each plugin build shares across the whole tree. */\n private readonly shares = new Map<object, PluginShare>();\n /** Names this scope in logs, as its level and the order it opened in. */\n readonly label: string;\n /** The last graph logged for a failing binding, by name, so a retry that fails the same way stays quiet. */\n private readonly reported = new Map<string, string>();\n\n private constructor(\n readonly level: PoApiScope,\n readonly parent: PoServerScope | undefined,\n ) {\n this.label = `${level}#${++scopesOpened}`;\n }\n\n /** Opens a scope below `parent`, with every binding visible from its ancestors already published. */\n static async open(level: PoApiScope, parent?: PoServerScope): Promise<PoServerScope> {\n if (parent?.disposing !== undefined) throw new Error(`The ${parent.level} scope is disposed.`);\n if (parent !== undefined && depth(level) <= depth(parent.level))\n throw new Error(`A ${level} scope cannot open below a ${parent.level} scope.`);\n const scope = new PoServerScope(level, parent);\n parent?.children.add(scope);\n try {\n await scope.root.plugin(ScopeService, scope);\n await Promise.all((parent?.visible() ?? []).map((binding) => scope.mirror(binding)));\n } catch (error) {\n await scope.dispose();\n throw error;\n }\n return scope;\n }\n\n get disposed(): boolean {\n return this.disposing !== undefined;\n }\n\n /**\n * Publishes what every package at this level reads: the owner's mount table as `po/server-host`,\n * and the platform services. They stay for the life of the scope; the owner still disposes the\n * mount table it handed in.\n */\n async serve(input: PoServerScopeHost): Promise<void> {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n if (input.host.scope !== this.level)\n throw new Error(`A ${input.host.scope} host cannot serve a ${this.level} scope.`);\n this.hostFibers.add(await this.root.plugin(serverHostProvider, input.host));\n this.router = input.host;\n // Published callers may hand a host without context (the packed authoring check does), so read it defensively.\n const hostContext = input.host.context as Partial<PoServerHostService['context']> | undefined;\n const cwd = hostContext?.cwd ?? hostContext?.workspaceRoot ?? input.platform.homeDirectory;\n this.hostFibers.add(\n await this.root.plugin(platformProvider, {\n platform: input.platform,\n cwd,\n temporaryDirectory: this.level === 'session' ? hostContext?.environment?.[PO_SESSION_TEMP_DIR] : undefined,\n }),\n );\n }\n\n /**\n * Installs packages at this level, each as its own fiber in this root, one at a time.\n *\n * Installation only adds. A package installed from the same build (the same plugin object) is\n * skipped. One whose build changed is disposed and the new build applied; when that fails, the\n * previous build is applied again. A package missing from `packages` stays installed, because\n * which packages a session runs is its own composition's choice. Installs into one scope run one\n * at a time. Resolves with every package installed here, in install order.\n */\n install(\n packages: readonly (PoServerPlugin | LoadedServerPackage)[],\n options: PoServerInstallOptions = {},\n ): Promise<readonly string[]> {\n const run = this.installs.then(() => this.installAll(packages, options));\n this.installs = run.then(\n () => undefined,\n () => undefined,\n );\n return run;\n }\n\n /**\n * Disposes the named packages installed here, in reverse install order, each bounded by the\n * cleanup time limit. Runs in order with installs. Resolves with every package still installed.\n */\n uninstall(names: readonly string[]): Promise<readonly string[]> {\n const run = this.installs.then(async () => {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n for (const [name, { fiber }] of [...this.installed].reverse()) {\n if (!names.includes(name)) continue;\n this.installed.delete(name);\n await this.disposeFiber(name, fiber, LIVE_FACTORY_TIMEOUT_MS);\n }\n return [...this.installed.keys()];\n });\n this.installs = run.then(\n () => undefined,\n () => undefined,\n );\n return run;\n }\n\n /**\n * Binds a contract owned by this level here and in every descendant, including ones opened later.\n * Settles once every descendant root publishes it, or a nearer binding of the same name shadows it\n * there. Hosts call this directly; plugins go through the scope service so the binding follows\n * their fiber.\n */\n async bind<T>(\n contract: PoServiceContract<T>,\n value: T,\n metadata: PoServiceBindingMetadata = {\n owner: { kind: 'host', packageName: null, origin: 'unknown' },\n contracts: [],\n },\n ): Promise<() => Promise<void>> {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n if (contract.scope !== this.level)\n throw new Error(\n `Contract '${contract.name}' belongs to the ${contract.scope} scope and cannot be provided from the ${this.level} scope.`,\n );\n if (this.bound.has(contract.name))\n throw new Error(`Contract '${contract.name}' is already provided in this ${this.level} scope.`);\n const binding: Binding = {\n name: contract.name,\n contract,\n metadata: projectServiceBindingMetadata(metadata),\n value,\n owner: this,\n };\n this.bound.set(contract.name, binding);\n const withdraw = async (): Promise<void> => {\n if (this.bound.get(contract.name) !== binding) return;\n this.bound.delete(contract.name);\n await Promise.all(\n [...this.subtree()].map(async (scope) => {\n await scope.unmirror(binding);\n // A farther binding this one shadowed shows through again.\n const outer = scope.nearest(contract.name);\n if (outer === undefined) return;\n await scope.mirror(outer).catch((error: unknown) => {\n this.notice(\n `binding '${contract.name}' from ${outer.owner.label} did not return to ${scope.label} (${describe(error)})`,\n );\n });\n }),\n );\n };\n try {\n await Promise.all([...this.subtree()].map((scope) => scope.mirror(binding)));\n } catch (error) {\n this.reportGraph(contract.name, error);\n await withdraw();\n throw error;\n }\n return withdraw;\n }\n\n /** Finds only the installed package that owns this fiber, including nested service fibers. */\n provenance(fiber: Fiber): PoServiceBindingMetadata {\n const declared = (fiber.ctx as Context & { [PACKAGE_PROVENANCE]?: PoServiceBindingMetadata })[PACKAGE_PROVENANCE];\n if (declared) return declared;\n for (;;) {\n for (const [name, entry] of this.installed) {\n if (entry.fiber.uid !== fiber.uid) continue;\n return {\n owner: { kind: 'package', packageName: name, origin: entry.declaration?.origin ?? 'unknown' },\n contracts: Object.values(entry.plugin.provides ?? {}).flat(),\n };\n }\n if (fiber.parent.fiber === fiber) break;\n fiber = fiber.parent.fiber;\n }\n return { owner: { kind: 'unknown', packageName: null, origin: 'unknown' }, contracts: [] };\n }\n\n snapshot(): BrainServicesSnapshot {\n const scopes = [...this.ancestry()];\n const describeScope = (scope: PoServerScope): BrainScope => ({ id: scope.label, level: scope.level });\n const result: BrainServicesSnapshot = {\n scope: describeScope(this),\n scopes: scopes.map(describeScope),\n packages: [],\n services: [],\n consumers: [],\n edges: [],\n diagnostics: [],\n };\n const clientInventories = scopes.map((scope) => scope.router?.context?.clientPlugins);\n if (clientInventories.every((inventory) => inventory?.available)) {\n result.clientPackages = clientInventories.flatMap((inventory, index) =>\n inventory!.packages.map((pkg) => ({\n scope: describeScope(scopes[index]!),\n owner: { kind: pkg.owner.kind, packageName: pkg.owner.packageName, origin: pkg.owner.origin },\n web: parsePoWebBrainMetadata(pkg.web) ?? null,\n })),\n );\n }\n for (const scope of scopes) {\n for (const [name, entry] of scope.installed) {\n const owner: BrainOwner = {\n kind: 'package',\n packageName: name,\n origin: entry.declaration?.origin ?? 'unknown',\n };\n result.packages.push({ scope: describeScope(scope), owner, web: entry.declaration?.webMetadata ?? null });\n const consumer = `${scope.label}:consumer:${name}`;\n result.consumers.push({ id: consumer, name, scope: describeScope(scope), owner });\n const injections = new Set([\n ...Object.keys(entry.fiber.inject),\n ...(entry.plugin.injects?.[scope.level] ?? []).map((contract) => contract.name),\n ]);\n for (const name of injections) result.edges.push({ consumer, name, service: null, status: 'waiting' });\n }\n for (const runtime of scope.root.registry.values()) {\n for (const fiber of runtime.fibers) {\n if ([...scope.installed.values()].some((entry) => entry.fiber.uid === fiber.uid)) continue;\n const names = Object.keys(fiber.inject);\n if (!names.length) continue;\n const consumer = `${scope.label}:consumer:fiber:${fiber.uid}`;\n result.consumers.push({\n id: consumer,\n name: `fiber#${fiber.uid}`,\n scope: describeScope(scope),\n owner: scope.provenance(fiber).owner,\n });\n for (const name of names) result.edges.push({ consumer, name, service: null, status: 'waiting' });\n }\n }\n for (const key of Reflect.ownKeys(scope.root.reflect.store)) {\n const impl = scope.root.reflect.store[key as symbol];\n const mirror = [...scope.mirrors].find(([, fiber]) => fiber.uid === impl.fiber.uid)?.[0];\n // Mirrors describe their original implementation once, at its owning scope.\n if (mirror && mirror.owner !== scope) continue;\n const metadata = mirror?.metadata ?? scope.provenance(impl.fiber);\n const host =\n (metadata.owner.kind === 'host' ||\n [...scope.hostFibers].some((fiber) => fiber.uid === impl.fiber.uid) ||\n impl.fiber === scope.root.fiber) &&\n PO_HOST_SERVICE_CONTRACTS.find((contract) => contract.name === impl.name);\n const contract = metadata.contracts.find(\n (contract) => contract.name === impl.name && contract.scope === scope.level,\n );\n result.services.push({\n id: `${scope.label}:service:${impl.name}`,\n name: impl.name,\n scope: describeScope(scope),\n visibleFrom: describeScope(scope),\n owner: host ? { kind: 'host', packageName: null, origin: 'unknown' } : metadata.owner,\n public: !!contract || !!host,\n description: contract?.description ?? mirror?.contract.description ?? (host ? host.description : null),\n });\n }\n }\n for (const service of result.services) {\n const ownerIndex = scopes.findIndex((scope) => scope.label === service.scope.id);\n const shadowIndex = scopes.findLastIndex(\n (scope, index) =>\n index < ownerIndex &&\n result.services.some((other) => other.scope.id === scope.label && other.name === service.name),\n );\n service.visibleFrom = describeScope(scopes[shadowIndex + 1]);\n }\n for (const edge of result.edges) {\n const consumer = result.consumers.find((consumer) => consumer.id === edge.consumer)!;\n const start = scopes.findIndex((scope) => scope.label === consumer.scope.id);\n const service = scopes\n .slice(start)\n .flatMap((scope) =>\n result.services.filter((service) => service.scope.id === scope.label && service.name === edge.name),\n )[0];\n if (service) {\n edge.service = service.id;\n edge.status = 'resolved';\n }\n }\n return structuredClone(result);\n }\n\n resolve<T>(contract: PoServiceContract<T>): T | undefined {\n if (depth(contract.scope) > depth(this.level))\n throw new Error(`A ${this.level} scope cannot see the ${contract.scope} contract '${contract.name}'.`);\n for (const scope of this.ancestry()) {\n if (scope.level === contract.scope) return scope.bound.get(contract.name)?.value as T | undefined;\n }\n return undefined;\n }\n\n /**\n * The handler for an API, from this level or the nearest one above it that serves it. An API\n * declared at a level reaches every level below it, and a level that runs a package from an outer\n * level leaves that level's root-bound APIs to it; a level that declares the API itself wins.\n */\n apiHandler(basePath: string): PoApiHandler | undefined {\n for (const scope of this.ancestry()) {\n const handler = scope.router?.handlerFor?.(basePath);\n if (handler !== undefined) return handler;\n }\n return undefined;\n }\n\n /** Resolve only the nearest mounted API's parsed contract, never a caller supplied operation. */\n apiOperation(basePath: string, method: string, path: string): string | undefined {\n for (const scope of this.ancestry()) {\n if (!scope.router?.handlerFor?.(basePath)) continue;\n for (const { declaration } of scope.installed.values()) {\n const route = declaration?.apiContract?.http.find(\n (route) =>\n route.scope === scope.level &&\n route.basePath === basePath &&\n route.method === method &&\n route.path.split('/').length === path.split('/').length &&\n route.path\n .split('/')\n .every((part, index) =>\n part.startsWith(':') ? !!path.split('/')[index] : part === path.split('/')[index],\n ),\n );\n if (route) return route.id;\n }\n return undefined;\n }\n return undefined;\n }\n\n emit<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void {\n deliver([...this.ancestry()], name, args);\n }\n\n broadcast<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void {\n deliver([...this.subtree()], name, args);\n }\n\n /**\n * Disposes descendants first, then the packages installed here in reverse install order, then\n * this root; a binding made here unwinds with its provider.\n */\n dispose(): Promise<void> {\n this.disposing ??= (async () => {\n await Promise.all([...this.children].map((child) => child.dispose()));\n this.parent?.children.delete(this);\n this.mirrors.clear();\n this.router = undefined;\n const packages = [...this.installed.values()].reverse();\n this.installed.clear();\n for (const { plugin, declaration, fiber } of packages)\n await this.disposeFiber(declaration?.packageName ?? plugin.name, fiber, LIVE_FACTORY_TIMEOUT_MS);\n const disposal = this.root.fiber.dispose();\n if (this.abandonedTimeoutMs === undefined) return await disposal;\n // An abandoned apply holds its fiber open, so teardown is bounded rather than left to hang.\n await withTimeout(disposal, this.abandonedTimeoutMs, `${this.level} scope dispose`).catch((error: unknown) =>\n this.notice(describe(error)),\n );\n })().finally(async () => {\n // What a level never released, such as a value an abandoned apply held, goes with the tree.\n if (this.parent === undefined) await this.disposeShares();\n });\n return this.disposing;\n }\n\n /**\n * What the plugin build `owner` shares in this tree, seen from this scope. The outermost scope keeps\n * one store per build, so every level of one hub sees the same values and no two hubs ever do.\n */\n share<TRoots>(owner: object): PoServerPluginShare<TRoots> {\n const top = this.outermost();\n const name = nameOf(owner);\n const build = buildOf(owner);\n for (const scope of this.parent?.ancestry() ?? [])\n for (const [other, store] of top.shares)\n if (other !== owner && name !== undefined && nameOf(other) === name && store.running.has(scope))\n this.notice(\n `${this.label} mounts ${build} of '${name}' while ${scope.label} runs ${buildOf(other)}, so it builds that build's roots itself.`,\n );\n const storeOf = (): PluginShare => {\n let store = top.shares.get(owner);\n if (store === undefined) {\n store = new PluginShare();\n top.shares.set(owner, store);\n }\n return store;\n };\n // An idle store is dropped, so builds a reload replaced do not accumulate.\n const settle = (store: PluginShare): void => {\n if (store.idle && top.shares.get(owner) === store) top.shares.delete(owner);\n };\n return {\n acquire: async <T>(\n key: PoServerResourceKey,\n create: () => T | Promise<T>,\n dispose?: (value: T) => void | Promise<void>,\n ): Promise<PoServerResourceLease<T>> => {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n const store = storeOf();\n const name = resourceName(key);\n let shared = store.values.get(name);\n if (shared === undefined) {\n const created: SharedValue = {\n value: Promise.resolve().then(create),\n holders: 0,\n disposeValue: dispose === undefined ? undefined : (value) => dispose(value as T),\n };\n store.values.set(name, created);\n // A value that could not be created is not kept, so the next acquire creates it again.\n created.value.catch(() => {\n if (store.values.get(name) === created) store.values.delete(name);\n settle(store);\n });\n shared = created;\n }\n const held = shared;\n held.holders += 1;\n let value: unknown;\n try {\n value = await held.value;\n } catch (error) {\n held.holders -= 1;\n throw error;\n }\n let released = false;\n return {\n value: value as T,\n release: async () => {\n if (released) return;\n released = true;\n held.holders -= 1;\n if (held.holders > 0 || store.values.get(name) !== held) return;\n store.values.delete(name);\n settle(store);\n await held.disposeValue?.(value);\n },\n };\n },\n run: (roots) => {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n const store = storeOf();\n store.running.set(this, roots);\n return () => {\n if (store.running.get(this) === roots) store.running.delete(this);\n settle(store);\n };\n },\n outer: (from) => {\n const store = top.shares.get(owner);\n if (store === undefined) return [];\n const held: TRoots[] = [];\n for (const scope of this.parent?.ancestry() ?? []) {\n if (depth(scope.level) >= depth(from) && store.running.has(scope))\n held.push(store.running.get(scope) as TRoots);\n }\n return held;\n },\n };\n }\n\n private async installAll(\n packages: readonly (PoServerPlugin | LoadedServerPackage)[],\n options: PoServerInstallOptions,\n ): Promise<readonly string[]> {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n const notice = options.onNotice ?? ((): void => {});\n this.notice = notice;\n if (\n packages.some((candidate) => 'retained' in candidate && candidate.retained === true) &&\n !readPoHeadlessHost(this.root)\n )\n throw new Error('Retained server candidates require a gated headless host');\n for (const candidate of packages) {\n const plugin = 'declaration' in candidate ? candidate.plugin : candidate;\n const declaration = 'declaration' in candidate ? candidate.declaration : undefined;\n const name = declaration?.packageName ?? plugin.name;\n const previous = this.installed.get(name);\n if (previous?.plugin === plugin) continue;\n if (previous !== undefined) {\n this.installed.delete(name);\n await this.disposeFiber(name, previous.fiber, options.factoryTimeoutMs ?? LIVE_FACTORY_TIMEOUT_MS);\n }\n try {\n const fiber = await this.apply(name, plugin, declaration, options);\n this.installed.set(name, { plugin, ...(declaration === undefined ? {} : { declaration }), fiber });\n } catch (error) {\n const message = `server package '${name}' did not install (${describe(error)})`;\n if (previous !== undefined) {\n const restored = await this.restore(name, previous, options, message);\n options.onPackageFailed?.({\n packageName: name,\n reason: describe(error),\n previous: restored ? 'restored' : 'lost',\n });\n continue;\n }\n options.onPackageFailed?.({ packageName: name, reason: describe(error), previous: 'none' });\n if (\n declaration?.required === true &&\n !('initiallyEligible' in candidate && candidate.initiallyEligible === false)\n )\n throw new Error(message, { cause: error });\n notice(message);\n }\n }\n // A level waiting for a contract that nothing at it or above it provides would never mount, silently.\n for (const candidate of packages) {\n const plugin = 'declaration' in candidate ? candidate.plugin : candidate;\n const name = ('declaration' in candidate ? candidate.declaration.packageName : undefined) ?? plugin.name;\n if (this.installed.get(name)?.plugin !== plugin) continue;\n for (const contract of plugin.injects?.[this.level] ?? []) {\n // An inner level's contract is never visible here; defineServerPlugin refuses one, a raw plugin may not.\n const missing = depth(contract.scope) > depth(this.level) || this.resolve(contract) === undefined;\n if (missing)\n notice(\n `server package '${name}' waits for contract '${contract.name}', which no ${contract.scope} package provides.`,\n );\n }\n }\n return [...this.installed.keys()];\n }\n\n /** Applies a replaced package's previous build again after its new build failed; true when it runs. */\n private async restore(\n name: string,\n previous: InstalledPackage,\n options: PoServerInstallOptions,\n message: string,\n ): Promise<boolean> {\n try {\n const fiber = await this.apply(name, previous.plugin, previous.declaration, options);\n this.installed.set(name, { ...previous, fiber });\n this.notice(`${message}; its previous build is restored.`);\n return true;\n } catch (rollbackError) {\n this.notice(`${message}; its previous build could not be restored (${describe(rollbackError)}).`);\n return false;\n }\n }\n\n /** Applies one package as its own fiber, bounded by the factory timeout, and reports how it settled. */\n private async apply(\n name: string,\n plugin: PoServerPlugin,\n declaration: PoServerBundleEntry | undefined,\n options: PoServerInstallOptions,\n ): Promise<Fiber> {\n const startedAt = Date.now();\n const timeoutMs = options.factoryTimeoutMs ?? LIVE_FACTORY_TIMEOUT_MS;\n const settled = (outcome: PoServerPackageSettledReport['outcome']): void =>\n options.onPackageSettled?.({ packageName: name, durationMs: Date.now() - startedAt, outcome });\n let fiber: Fiber | undefined;\n let applySettled = false;\n try {\n const metadata: PoServiceBindingMetadata = {\n owner: { kind: 'package', packageName: name, origin: declaration?.origin ?? 'unknown' },\n contracts: Object.values(plugin.provides ?? {}).flat(),\n };\n const owner = this.root.extend({\n [PACKAGE_PROVENANCE]: metadata,\n ...(declaration ? { [PO_HEADLESS_OWNER]: declaration } : {}),\n });\n fiber = owner.plugin(plugin);\n const applied = fiber.await();\n const markSettled = (): void => {\n applySettled = true;\n };\n applied.then(markSettled, markSettled);\n await withTimeout(applied, timeoutMs, `server package '${name}' apply`);\n settled('installed');\n return fiber;\n } catch (error) {\n settled(fiber && !applySettled ? 'timed_out' : 'failed');\n if (fiber && !applySettled) {\n this.abandonedTimeoutMs = Math.max(this.abandonedTimeoutMs ?? 0, timeoutMs);\n void fiber\n .dispose()\n .catch((disposeError: unknown) =>\n this.notice(`abandoned server package '${name}' did not dispose (${describe(disposeError)})`),\n );\n } else if (fiber) await this.disposeFiber(name, fiber, timeoutMs);\n throw error;\n }\n }\n\n /**\n * Disposes one package's fiber within `timeoutMs`. A package whose cleanup throws or never settles\n * is reported and left behind, so it cannot block the packages after it or the scope's teardown.\n */\n private async disposeFiber(name: string, fiber: Fiber, timeoutMs: number): Promise<void> {\n try {\n await withTimeout(fiber.dispose(), timeoutMs, `server package '${name}' dispose`);\n } catch (error) {\n this.abandonedTimeoutMs = Math.max(this.abandonedTimeoutMs ?? 0, timeoutMs);\n this.notice(`server package '${name}' did not dispose (${describe(error)})`);\n }\n }\n\n private visible(): Binding[] {\n return [...(this.parent?.visible() ?? []), ...this.bound.values()];\n }\n\n /**\n * Logs, once per distinct tree, which scopes bind `name`, whose binding each root mirrors, and\n * which Cordis fiber actually holds the service in that root.\n */\n private reportGraph(name: string, error: unknown): void {\n const top = this.outermost();\n const graph = [...top.subtree()]\n .map((scope) => {\n const context = scope.router?.context as Partial<PoServerHostService['context']> | undefined;\n const cwd = context?.cwd ?? context?.workspaceRoot;\n const holds = [...scope.mirrors.keys()]\n .filter((binding) => binding.name === name)\n .map(({ owner }) => owner.label);\n const impl = scope.root.reflect._getImpl(name, false);\n const mirrored = impl && [...scope.mirrors].find(([, fiber]) => fiber === impl.fiber)?.[0];\n const cordis =\n impl === undefined\n ? 'none'\n : `<${impl.fiber.name}#${impl.fiber.uid}> state=${impl.fiber.state}${mirrored ? ` from ${mirrored.owner.label}` : ''}`;\n return `${' '.repeat(depth(scope.level))}${scope.label}${cwd ? ` ${cwd}` : ''} binds=${scope.bound.has(name) ? 'yes' : 'no'} mirrors=[${holds.join(', ')}] cordis=${cordis}`;\n })\n .join('\\n');\n if (top.reported.get(name) === graph) return;\n top.reported.set(name, graph);\n this.notice(`binding '${name}' from ${this.label} failed (${describe(error)}); scope tree:\\n${graph}`);\n }\n\n /** This scope, then each parent out to the root. */\n private outermost(): PoServerScope {\n return this.parent === undefined ? this : this.parent.outermost();\n }\n\n /** Disposes every value the tree still holds, newest first; a failure is reported and the rest still go. */\n private async disposeShares(): Promise<void> {\n const values = [...this.shares.values()].flatMap((store) => [...store.values.values()]).reverse();\n this.shares.clear();\n for (const shared of values) {\n try {\n await shared.disposeValue?.(await shared.value);\n } catch (error) {\n this.notice(`a shared server value did not dispose (${describe(error)})`);\n }\n }\n }\n\n private *ancestry(): Generator<PoServerScope> {\n yield this;\n if (this.parent !== undefined) yield* this.parent.ancestry();\n }\n\n private *subtree(): Generator<PoServerScope> {\n if (this.disposed) return;\n yield this;\n for (const child of this.children) yield* child.subtree();\n }\n\n /** The binding of `name` this root publishes: the one bound nearest to it. */\n private nearest(name: string): Binding | undefined {\n for (const scope of this.ancestry()) {\n const binding = scope.bound.get(name);\n if (binding !== undefined) return binding;\n }\n return undefined;\n }\n\n /**\n * Publishes a binding into this root and settles once it is live. Idempotent per binding, since a\n * child opening mid-bind is reached by both `open` and `bind`. A nearer level binding the same\n * name wins, as a level declaring an API itself does; Cordis holds one service per name in a root,\n * so the farther binding leaves first.\n */\n private async mirror(binding: Binding): Promise<void> {\n if (this.disposed || this.nearest(binding.name) !== binding) return;\n const replacing = this.replacing.get(binding);\n if (replacing !== undefined) {\n await replacing;\n return await this.mirror(binding);\n }\n let fiber = this.mirrors.get(binding);\n if (fiber === undefined) {\n const shadowed = [...this.mirrors.keys()].filter((other) => other.name === binding.name);\n if (shadowed.length > 0) {\n const cleared = Promise.all(shadowed.map((other) => this.unmirror(other))).finally(() =>\n this.replacing.delete(binding),\n );\n this.replacing.set(\n binding,\n cleared.then(\n () => undefined,\n () => undefined,\n ),\n );\n await cleared;\n return await this.mirror(binding);\n }\n fiber = this.root.plugin(bindingProvider, { binding, scope: this });\n this.mirrors.set(binding, fiber);\n }\n try {\n await fiber.await();\n } catch (error) {\n throw new Error(`${describe(error)} when ${binding.owner.label} published it into ${this.label}`, {\n cause: error,\n });\n }\n }\n\n private async unmirror(binding: Binding): Promise<void> {\n const fiber = this.mirrors.get(binding);\n this.mirrors.delete(binding);\n // A disposing root unwinds its own mirrors.\n if (!this.disposed) await fiber?.dispose();\n }\n}\n\n/** Every scope receives the event even when an earlier one's listener throws. */\nfunction deliver(scopes: readonly PoServerScope[], name: keyof Events, args: readonly unknown[]): void {\n const errors: unknown[] = [];\n for (const scope of scopes) {\n if (scope.disposed) continue;\n try {\n scope.root.events.emit(name, ...args);\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length > 0) throw new AggregateError(errors, `${errors.length} scope listener(s) of '${name}' failed.`);\n}\n"],"mappings":";;;;;;;;;;;;;AAiEA,IAAM,cAAN,MAAkB;CAChB,yBAAkB,IAAI,IAAyB;CAC/C,0BAAmB,IAAI,IAA4B;CAEnD,IAAI,OAAgB;EAClB,OAAO,KAAK,OAAO,SAAS,KAAK,KAAK,QAAQ,SAAS;CACzD;AACF;AAEA,MAAM,gBAAgB,QAAqC,KAAK,UAAU,OAAO,QAAQ,WAAW,CAAC,GAAG,IAAI,GAAG;AAoC/G,MAAM,SAAS,UAA8BA,oBAAAA,uBAAuB,QAAQ,KAAK;AAEjF,MAAM,Y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B;IACA,KAAK,UAAU,IACb,SACA,QAAQ,WACA,KAAA,SACA,KAAA,CACR,CACF;IACA,MAAM;IACN,OAAO,MAAM,KAAK,OAAO,OAAO;GAClC;GACA,QAAQ,KAAK,KAAK,OAAO,iBAAiB;IAAE;IAAS,OAAO;GAAK,CAAC;GAClE,KAAK,QAAQ,IAAI,SAAS,KAAK;EACjC;EACA,IAAI;GACF,MAAM,MAAM,MAAM;EACpB,SAAS,OAAO;GACd,MAAM,IAAI,MAAM,GAAG,SAAS,KAAK,EAAE,QAAQ,QAAQ,MAAM,MAAM,qBAAqB,KAAK,SAAS,EAChG,OAAO,MACT,CAAC;EACH;CACF;CAEA,MAAc,SAAS,SAAiC;EACtD,MAAM,QAAQ,KAAK,QAAQ,IAAI,OAAO;EACtC,KAAK,QAAQ,OAAO,OAAO;EAE3B,IAAI,CAAC,KAAK,UAAU,MAAM,OAAO,QAAQ;CAC3C;AACF;;AAGA,SAAS,QAAQ,QAAkC,MAAoB,MAAgC;CACrG,MAAM,SAAoB,CAAC;CAC3B,KAAK,MAAM,SAAS,QAAQ;EAC1B,IAAI,MAAM,UAAU;EACpB,IAAI;GACF,MAAM,KAAK,OAAO,KAAK,MAAM,GAAG,IAAI;EACtC,SAAS,OAAO;GACd,OAAO,KAAK,KAAK;EACnB;CACF;CACA,IAAI,OAAO,SAAS,GAAG,MAAM,IAAI,eAAe,QAAQ,GAAG,OAAO,OAAO,yBAAyB,KAAK,UAAU;AACnH"}
1
+ {"version":3,"file":"serverScope.cjs","names":["PO_SERVER_SCOPE_LEVELS","Service","PO_GLOBAL_SERVICES_SERVICE","PO_SERVER_SCOPE_SERVICE","PO_SERVER_HOST_SERVICE","readPoHeadlessHost","PO_FS_SERVICE","PO_SHELL_SERVICE","PO_SQLITE_SERVICE","PO_SESSION_STORAGE_SERVICE","PO_ISOLATE_SERVICE","PO_NPM_SERVICE","PO_ELECTRON_SERVICE","PO_BROWSER_SERVICE","PO_PROVIDER_AUTH_SERVICE","PO_SESSION_FILES_SERVICE","BACKGROUND_CONTEXT","Context","PO_SESSION_TEMP_DIR","LIVE_FACTORY_TIMEOUT_MS","projectServiceBindingMetadata","parsePoWebBrainMetadata","PO_HOST_SERVICE_CONTRACTS","withTimeout","PO_HEADLESS_OWNER"],"sources":["../../../src/server/serverScope.ts"],"sourcesContent":["import { Context, type Events, type Fiber, Service } from '@deepseek-ai/cordis';\nimport { BACKGROUND_CONTEXT } from '@earendil-works/chord/context';\n\nimport {\n parsePoWebBrainMetadata,\n type BrainOwner,\n type BrainScope,\n type BrainServicesSnapshot,\n} from '../schemas/brain';\nimport { PO_GLOBAL_SERVICES_SERVICE, type PoGlobalServices } from '../schemas/globalServices';\nimport { PO_HEADLESS_OWNER, readPoHeadlessHost } from '../schemas/headless';\nimport { PO_HOST_SERVICE_CONTRACTS } from '../schemas/hostServiceContracts';\nimport type { PoApiHandler, PoApiScope } from '../schemas/packageApi';\nimport {\n PO_BROWSER_SERVICE,\n PO_ELECTRON_SERVICE,\n PO_FS_SERVICE,\n PO_ISOLATE_SERVICE,\n PO_NPM_SERVICE,\n PO_PROVIDER_AUTH_SERVICE,\n PO_SESSION_STORAGE_SERVICE,\n PO_SHELL_SERVICE,\n PO_SQLITE_SERVICE,\n type PoPlatform,\n} from '../schemas/platform';\nimport type { PoServerBundleEntry } from '../schemas/serverBundle';\nimport { PO_SERVER_HOST_SERVICE, type PoServerHostService, type PoServerPlugin } from '../schemas/serverPlugin';\nimport {\n PO_SERVER_SCOPE_LEVELS,\n projectServiceBindingMetadata,\n PO_SERVER_SCOPE_SERVICE,\n type PoServerPluginShare,\n type PoServerResourceKey,\n type PoServerResourceLease,\n type PoServerScopeService,\n type PoServiceContract,\n type PoServiceBindingMetadata,\n} from '../schemas/serverScope';\nimport { PO_SESSION_FILES_SERVICE, PO_SESSION_TEMP_DIR } from '../services/sessionFiles';\nimport { LIVE_FACTORY_TIMEOUT_MS, withTimeout } from './liveImport';\nimport type { LoadedServerPackage } from './serverPackages';\n\ninterface Binding {\n readonly name: string;\n readonly contract: PoServiceContract<unknown>;\n readonly metadata: PoServiceBindingMetadata;\n readonly value: unknown;\n /** The scope that bound it, named in logs. */\n readonly owner: PoServerScope;\n}\n\ninterface InstalledPackage {\n readonly plugin: PoServerPlugin;\n readonly declaration?: PoServerBundleEntry;\n readonly fiber: Fiber;\n}\n\n/** One shared value, how many levels hold it, and how its creator said to dispose it. */\ninterface SharedValue {\n readonly value: Promise<unknown>;\n holders: number;\n readonly disposeValue: ((value: unknown) => void | Promise<void>) | undefined;\n}\n\n/** What one plugin build shares in one tree: its keyed values, and what each scope running it holds. */\nclass PluginShare {\n readonly values = new Map<string, SharedValue>();\n readonly running = new Map<PoServerScope, unknown>();\n\n get idle(): boolean {\n return this.values.size === 0 && this.running.size === 0;\n }\n}\n\nconst resourceName = (key: PoServerResourceKey): string => JSON.stringify(typeof key === 'string' ? [key] : key);\n/** What a scope's owner publishes for the packages installed at its level. */\nexport interface PoServerScopeHost {\n /**\n * The level's mount table. A host that also routes requests (`createPoServerHost` does) answers\n * API requests for this level and every level below it that does not serve the API itself.\n */\n readonly host: PoServerHostService & { handlerFor?(basePath: string): PoApiHandler | undefined };\n /** Host capabilities published as `po/fs`, `po/shell`, `po/sqlite` and `po/session-storage`. */\n readonly platform: PoPlatform;\n}\n\nexport interface PoServerPackageSettledReport {\n readonly packageName: string;\n readonly durationMs: number;\n readonly outcome: 'installed' | 'failed' | 'timed_out';\n}\n\n/** A package whose build did not install, and what of it still runs. */\nexport interface PoServerPackageFailure {\n readonly packageName: string;\n readonly reason: string;\n /** `restored`: its previous build runs again; `lost`: that failed too; `none`: it had none. */\n readonly previous: 'restored' | 'lost' | 'none';\n}\n\nexport interface PoServerInstallOptions {\n readonly onNotice?: (message: string) => void;\n /** Bound on each package's `apply`; defaults to `LIVE_FACTORY_TIMEOUT_MS`. */\n readonly factoryTimeoutMs?: number;\n /** Reports how long each package's `apply` took and how it ended, for telemetry. */\n readonly onPackageSettled?: (report: PoServerPackageSettledReport) => void;\n /** Reports each package whose build did not install. */\n readonly onPackageFailed?: (failure: PoServerPackageFailure) => void;\n}\n\nconst depth = (level: PoApiScope): number => PO_SERVER_SCOPE_LEVELS.indexOf(level);\n\nconst describe = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\nconst PACKAGE_PROVENANCE = Symbol('package provenance');\n\nlet scopesOpened = 0;\nlet buildsSeen = 0;\nconst builds = new WeakMap<object, number>();\n/** A stable log label for one plugin build; a reload imports a new module, and so a new build. */\nfunction buildOf(owner: object): string {\n let build = builds.get(owner);\n if (build === undefined) builds.set(owner, (build = ++buildsSeen));\n return `build#${build}`;\n}\nconst nameOf = (owner: object): string | undefined => {\n const name = (owner as { name?: unknown }).name;\n return typeof name === 'string' ? name : undefined;\n};\n\n/** Publishes one binding as a native service of the root it is plugged into. */\nfunction bindingProvider(context: Context, { binding, scope }: { binding: Binding; scope: PoServerScope }): void {\n if (binding.name === PO_GLOBAL_SERVICES_SERVICE)\n new ScopedGlobalServices(context, binding.value as PoGlobalServices, scope);\n else context.provide(binding.name, binding.value);\n}\n\nclass ScopedGlobalServices extends Service<PoGlobalServices> implements PoGlobalServices {\n constructor(\n ctx: Context,\n private readonly registry: PoGlobalServices,\n private readonly scope: PoServerScope,\n ) {\n super(ctx, PO_GLOBAL_SERVICES_SERVICE);\n }\n\n register(\n owner: Parameters<PoGlobalServices['register']>[0],\n contribution: Parameters<PoGlobalServices['register']>[1],\n ) {\n return this.registry.register(owner, contribution, this.scope.provenance(this.ctx.fiber));\n }\n}\n\n/**\n * The scope service each root publishes.\n *\n * Cordis traceable services rebind `ctx` to the caller, so a binding made through\n * `provide` unwinds with the plugin that made it.\n */\nclass ScopeService extends Service<PoServerScopeService> implements PoServerScopeService {\n readonly level: PoApiScope;\n\n constructor(\n ctx: Context,\n private readonly scope: PoServerScope,\n ) {\n super(ctx, PO_SERVER_SCOPE_SERVICE);\n this.level = scope.level;\n }\n\n async provide<T>(contract: PoServiceContract<T>, value: T): Promise<() => Promise<void>> {\n return await this.ctx.effect(\n () => this.scope.bind(contract, value, this.scope.provenance(this.ctx.fiber)),\n `po scope provide ${contract.name}`,\n );\n }\n\n snapshot(): BrainServicesSnapshot {\n return this.scope.snapshot();\n }\n\n resolve<T>(contract: PoServiceContract<T>): T | undefined {\n return this.scope.resolve(contract);\n }\n\n emit<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void {\n this.scope.emit(name, ...args);\n }\n\n broadcast<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void {\n this.scope.broadcast(name, ...args);\n }\n\n plugin<TRoots>(owner: object): PoServerPluginShare<TRoots> {\n return this.scope.share<TRoots>(owner);\n }\n}\n\n/**\n * Binds registrations to the Cordis fiber that calls the host service.\n *\n * The host itself is shared by every package at its level, but Cordis traceable\n * services rebind `ctx` to the caller. That lets a package's registration unwind\n * even when `apply` throws before it can return its disposer.\n */\nclass ScopedPoServerHost extends Service<PoServerHostService> implements PoServerHostService {\n readonly scope: PoServerHostService['scope'];\n readonly context: PoServerHostService['context'];\n\n constructor(\n ctx: Context,\n private readonly host: PoServerHostService,\n ) {\n super(ctx, PO_SERVER_HOST_SERVICE);\n this.scope = host.scope;\n this.context = host.context;\n }\n\n registerApi(api: Parameters<PoServerHostService['registerApi']>[0]) {\n const headless = this.scope === 'session' ? readPoHeadlessHost(this.ctx) : undefined;\n if (headless) {\n const activity = headless.registerActivity({\n name: `api:${api.basePath}`,\n start: () => {\n const registration = this.host.registerApi(api);\n if (registration.mounted !== true) {\n registration.dispose();\n throw new Error(`package API '${api.basePath}' did not mount.`);\n }\n return () => {\n registration.dispose();\n };\n },\n });\n return {\n mounted: true,\n dispose: () => activity.dispose(),\n };\n }\n const registration = this.host.registerApi(api);\n if (registration.mounted !== true) {\n registration.dispose();\n throw new Error(`package API '${api.basePath}' did not mount.`);\n }\n this.ctx.effect(() => () => registration.dispose(), 'server package API registration');\n return registration;\n }\n\n registerChannel(channel: Parameters<PoServerHostService['registerChannel']>[0]) {\n const registration = this.host.registerChannel(channel);\n if (registration.mounted !== true) {\n registration.dispose();\n throw new Error(`hub channel '${channel.frameType}' did not mount.`);\n }\n this.ctx.effect(() => () => registration.dispose(), 'server package channel registration');\n return registration;\n }\n\n registerMethod: PoServerHostService['registerMethod'] = (definition, handler) => {\n const registration = this.host.registerMethod(definition, handler);\n if (registration.mounted !== true) {\n registration.dispose();\n throw new Error(`plugin method '${definition.service}.${definition.method}' did not mount.`);\n }\n this.ctx.effect(() => () => registration.dispose(), 'server package method registration');\n return registration;\n };\n\n mounted(): readonly string[] {\n return this.host.mounted();\n }\n\n mountedChannels(): readonly string[] {\n return this.host.mountedChannels();\n }\n}\n\n/** Publishes the host service from inside a root-level plugin, so it unwinds with the scope. */\nfunction serverHostProvider(context: Context, host: PoServerHostService): void {\n new ScopedPoServerHost(context, host);\n}\n\n/** Publishes the platform services from inside a root-level plugin, so they unwind with the scope. */\nfunction platformProvider(\n context: Context,\n input: { platform: PoPlatform; cwd: string; temporaryDirectory?: string },\n): void {\n const env = input.platform.env(input.cwd);\n context.provide(PO_FS_SERVICE, env);\n context.provide(PO_SHELL_SERVICE, env);\n context.provide(PO_SQLITE_SERVICE, input.platform.sqlite);\n context.provide(PO_SESSION_STORAGE_SERVICE, input.platform.sessions);\n if (input.platform.isolate !== undefined) context.provide(PO_ISOLATE_SERVICE, input.platform.isolate);\n if (input.platform.npm !== undefined) context.provide(PO_NPM_SERVICE, input.platform.npm);\n if (input.platform.electron !== undefined) context.provide(PO_ELECTRON_SERVICE, input.platform.electron);\n if (input.platform.browser !== undefined) context.provide(PO_BROWSER_SERVICE, input.platform.browser);\n if (input.platform.providerAuth !== undefined) context.provide(PO_PROVIDER_AUTH_SERVICE, input.platform.providerAuth);\n if (input.temporaryDirectory !== undefined)\n context.provide(PO_SESSION_FILES_SERVICE, { temporaryDirectory: input.temporaryDirectory });\n context.effect(() => () => env.cleanup(BACKGROUND_CONTEXT), 'platform execution env');\n}\n\n/**\n * One level of the server IoC tree: its own cordis root, a parent link, the contracts bound here,\n * and the packages installed here.\n *\n * Separate roots rather than one shared root, because cordis re-checks every fiber of a root on each\n * service change; a hundred sessions in one root would make every change scan all of them. A binding\n * is instead mirrored into each descendant root as a native service, so a plugin injects an outer\n * level's service exactly as it injects its own.\n */\nexport class PoServerScope {\n readonly root = new Context();\n private readonly children = new Set<PoServerScope>();\n private readonly bound = new Map<string, Binding>();\n private readonly mirrors = new Map<Binding, Fiber>();\n /** A binding waiting here for the farther one it shadows to leave, so a repeat mirror waits too. */\n private readonly replacing = new Map<Binding, Promise<void>>();\n private readonly hostFibers = new Set<Fiber>();\n private readonly installed = new Map<string, InstalledPackage>();\n private installs: Promise<void> = Promise.resolve();\n /** Set once a package's apply never settled, to the bound it overran; its fiber may never finish disposing. */\n private abandonedTimeoutMs: number | undefined;\n private notice: (message: string) => void = () => undefined;\n private disposing: Promise<void> | undefined;\n /** The served mount table, read when a request routes through this level. */\n private router: PoServerScopeHost['host'] | undefined;\n /** Kept by the outermost scope only: what each plugin build shares across the whole tree. */\n private readonly shares = new Map<object, PluginShare>();\n /** Names this scope in logs, as its level and the order it opened in. */\n readonly label: string;\n /** The last graph logged for a failing binding, by name, so a retry that fails the same way stays quiet. */\n private readonly reported = new Map<string, string>();\n\n private constructor(\n readonly level: PoApiScope,\n readonly parent: PoServerScope | undefined,\n ) {\n this.label = `${level}#${++scopesOpened}`;\n }\n\n /** Opens a scope below `parent`, with every binding visible from its ancestors already published. */\n static async open(level: PoApiScope, parent?: PoServerScope): Promise<PoServerScope> {\n if (parent?.disposing !== undefined) throw new Error(`The ${parent.level} scope is disposed.`);\n if (parent !== undefined && depth(level) <= depth(parent.level))\n throw new Error(`A ${level} scope cannot open below a ${parent.level} scope.`);\n const scope = new PoServerScope(level, parent);\n parent?.children.add(scope);\n try {\n await scope.root.plugin(ScopeService, scope);\n await Promise.all((parent?.visible() ?? []).map((binding) => scope.mirror(binding)));\n } catch (error) {\n await scope.dispose();\n throw error;\n }\n return scope;\n }\n\n get disposed(): boolean {\n return this.disposing !== undefined;\n }\n\n /**\n * Publishes what every package at this level reads: the owner's mount table as `po/server-host`,\n * and the platform services. They stay for the life of the scope; the owner still disposes the\n * mount table it handed in.\n */\n async serve(input: PoServerScopeHost): Promise<void> {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n if (input.host.scope !== this.level)\n throw new Error(`A ${input.host.scope} host cannot serve a ${this.level} scope.`);\n this.hostFibers.add(await this.root.plugin(serverHostProvider, input.host));\n this.router = input.host;\n // Published callers may hand a host without context (the packed authoring check does), so read it defensively.\n const hostContext = input.host.context as Partial<PoServerHostService['context']> | undefined;\n const cwd = hostContext?.cwd ?? hostContext?.workspaceRoot ?? input.platform.homeDirectory;\n this.hostFibers.add(\n await this.root.plugin(platformProvider, {\n platform: input.platform,\n cwd,\n temporaryDirectory: this.level === 'session' ? hostContext?.environment?.[PO_SESSION_TEMP_DIR] : undefined,\n }),\n );\n }\n\n /**\n * Installs packages at this level, each as its own fiber in this root, one at a time.\n *\n * Installation only adds. A package installed from the same build (the same plugin object) is\n * skipped. One whose build changed is disposed and the new build applied; when that fails, the\n * previous build is applied again. A package missing from `packages` stays installed, because\n * which packages a session runs is its own composition's choice. Installs into one scope run one\n * at a time. Resolves with every package installed here, in install order.\n */\n install(\n packages: readonly (PoServerPlugin | LoadedServerPackage)[],\n options: PoServerInstallOptions = {},\n ): Promise<readonly string[]> {\n const run = this.installs.then(() => this.installAll(packages, options));\n this.installs = run.then(\n () => undefined,\n () => undefined,\n );\n return run;\n }\n\n /**\n * Disposes the named packages installed here, in reverse install order, each bounded by the\n * cleanup time limit. Runs in order with installs. Resolves with every package still installed.\n */\n uninstall(names: readonly string[]): Promise<readonly string[]> {\n const run = this.installs.then(async () => {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n for (const [name, { fiber }] of [...this.installed].reverse()) {\n if (!names.includes(name)) continue;\n this.installed.delete(name);\n await this.disposeFiber(name, fiber, LIVE_FACTORY_TIMEOUT_MS);\n }\n return [...this.installed.keys()];\n });\n this.installs = run.then(\n () => undefined,\n () => undefined,\n );\n return run;\n }\n\n /**\n * Binds a contract owned by this level here and in every descendant, including ones opened later.\n * Settles once every descendant root publishes it, or a nearer binding of the same name shadows it\n * there. Hosts call this directly; plugins go through the scope service so the binding follows\n * their fiber.\n */\n async bind<T>(\n contract: PoServiceContract<T>,\n value: T,\n metadata: PoServiceBindingMetadata = {\n owner: { kind: 'host', packageName: null, origin: 'unknown' },\n contracts: [],\n },\n ): Promise<() => Promise<void>> {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n if (contract.scope !== this.level)\n throw new Error(\n `Contract '${contract.name}' belongs to the ${contract.scope} scope and cannot be provided from the ${this.level} scope.`,\n );\n if (this.bound.has(contract.name))\n throw new Error(`Contract '${contract.name}' is already provided in this ${this.level} scope.`);\n const binding: Binding = {\n name: contract.name,\n contract,\n metadata: projectServiceBindingMetadata(metadata),\n value,\n owner: this,\n };\n this.bound.set(contract.name, binding);\n const withdraw = async (): Promise<void> => {\n if (this.bound.get(contract.name) !== binding) return;\n this.bound.delete(contract.name);\n await Promise.all(\n [...this.subtree()].map(async (scope) => {\n await scope.unmirror(binding);\n // A farther binding this one shadowed shows through again.\n const outer = scope.nearest(contract.name);\n if (outer === undefined) return;\n await scope.mirror(outer).catch((error: unknown) => {\n this.notice(\n `binding '${contract.name}' from ${outer.owner.label} did not return to ${scope.label} (${describe(error)})`,\n );\n });\n }),\n );\n };\n try {\n await Promise.all([...this.subtree()].map((scope) => scope.mirror(binding)));\n } catch (error) {\n this.reportGraph(contract.name, error);\n await withdraw();\n throw error;\n }\n return withdraw;\n }\n\n /** Finds only the installed package that owns this fiber, including nested service fibers. */\n provenance(fiber: Fiber): PoServiceBindingMetadata {\n const declared = (fiber.ctx as Context & { [PACKAGE_PROVENANCE]?: PoServiceBindingMetadata })[PACKAGE_PROVENANCE];\n if (declared) return declared;\n for (;;) {\n for (const [name, entry] of this.installed) {\n if (entry.fiber.uid !== fiber.uid) continue;\n return {\n owner: { kind: 'package', packageName: name, origin: entry.declaration?.origin ?? 'unknown' },\n contracts: Object.values(entry.plugin.provides ?? {}).flat(),\n };\n }\n if (fiber.parent.fiber === fiber) break;\n fiber = fiber.parent.fiber;\n }\n return { owner: { kind: 'unknown', packageName: null, origin: 'unknown' }, contracts: [] };\n }\n\n snapshot(): BrainServicesSnapshot {\n const scopes = [...this.ancestry()];\n const describeScope = (scope: PoServerScope): BrainScope => ({ id: scope.label, level: scope.level });\n const result: BrainServicesSnapshot = {\n scope: describeScope(this),\n scopes: scopes.map(describeScope),\n packages: [],\n services: [],\n consumers: [],\n edges: [],\n diagnostics: [],\n };\n const clientInventories = scopes.map((scope) => scope.router?.context?.clientPlugins);\n if (clientInventories.every((inventory) => inventory?.available)) {\n result.clientPackages = clientInventories.flatMap((inventory, index) =>\n inventory!.packages.map((pkg) => ({\n scope: describeScope(scopes[index]!),\n owner: { kind: pkg.owner.kind, packageName: pkg.owner.packageName, origin: pkg.owner.origin },\n web: parsePoWebBrainMetadata(pkg.web) ?? null,\n })),\n );\n }\n for (const scope of scopes) {\n for (const [name, entry] of scope.installed) {\n const owner: BrainOwner = {\n kind: 'package',\n packageName: name,\n origin: entry.declaration?.origin ?? 'unknown',\n };\n result.packages.push({\n scope: describeScope(scope),\n owner,\n web: entry.declaration?.webMetadata ?? null,\n native: entry.declaration?.nativeMetadata ?? null,\n });\n const consumer = `${scope.label}:consumer:${name}`;\n result.consumers.push({ id: consumer, name, scope: describeScope(scope), owner });\n const injections = new Set([\n ...Object.keys(entry.fiber.inject),\n ...(entry.plugin.injects?.[scope.level] ?? []).map((contract) => contract.name),\n ]);\n for (const name of injections) result.edges.push({ consumer, name, service: null, status: 'waiting' });\n }\n for (const runtime of scope.root.registry.values()) {\n for (const fiber of runtime.fibers) {\n if ([...scope.installed.values()].some((entry) => entry.fiber.uid === fiber.uid)) continue;\n const names = Object.keys(fiber.inject);\n if (!names.length) continue;\n const consumer = `${scope.label}:consumer:fiber:${fiber.uid}`;\n result.consumers.push({\n id: consumer,\n name: `fiber#${fiber.uid}`,\n scope: describeScope(scope),\n owner: scope.provenance(fiber).owner,\n });\n for (const name of names) result.edges.push({ consumer, name, service: null, status: 'waiting' });\n }\n }\n for (const key of Reflect.ownKeys(scope.root.reflect.store)) {\n const impl = scope.root.reflect.store[key as symbol];\n const mirror = [...scope.mirrors].find(([, fiber]) => fiber.uid === impl.fiber.uid)?.[0];\n // Mirrors describe their original implementation once, at its owning scope.\n if (mirror && mirror.owner !== scope) continue;\n const metadata = mirror?.metadata ?? scope.provenance(impl.fiber);\n const host =\n (metadata.owner.kind === 'host' ||\n [...scope.hostFibers].some((fiber) => fiber.uid === impl.fiber.uid) ||\n impl.fiber === scope.root.fiber) &&\n PO_HOST_SERVICE_CONTRACTS.find((contract) => contract.name === impl.name);\n const contract = metadata.contracts.find(\n (contract) => contract.name === impl.name && contract.scope === scope.level,\n );\n result.services.push({\n id: `${scope.label}:service:${impl.name}`,\n name: impl.name,\n scope: describeScope(scope),\n visibleFrom: describeScope(scope),\n owner: host ? { kind: 'host', packageName: null, origin: 'unknown' } : metadata.owner,\n public: !!contract || !!host,\n description: contract?.description ?? mirror?.contract.description ?? (host ? host.description : null),\n });\n }\n }\n for (const service of result.services) {\n const ownerIndex = scopes.findIndex((scope) => scope.label === service.scope.id);\n const shadowIndex = scopes.findLastIndex(\n (scope, index) =>\n index < ownerIndex &&\n result.services.some((other) => other.scope.id === scope.label && other.name === service.name),\n );\n service.visibleFrom = describeScope(scopes[shadowIndex + 1]);\n }\n for (const edge of result.edges) {\n const consumer = result.consumers.find((consumer) => consumer.id === edge.consumer)!;\n const start = scopes.findIndex((scope) => scope.label === consumer.scope.id);\n const service = scopes\n .slice(start)\n .flatMap((scope) =>\n result.services.filter((service) => service.scope.id === scope.label && service.name === edge.name),\n )[0];\n if (service) {\n edge.service = service.id;\n edge.status = 'resolved';\n }\n }\n return structuredClone(result);\n }\n\n resolve<T>(contract: PoServiceContract<T>): T | undefined {\n if (depth(contract.scope) > depth(this.level))\n throw new Error(`A ${this.level} scope cannot see the ${contract.scope} contract '${contract.name}'.`);\n for (const scope of this.ancestry()) {\n if (scope.level === contract.scope) return scope.bound.get(contract.name)?.value as T | undefined;\n }\n return undefined;\n }\n\n /**\n * The handler for an API, from this level or the nearest one above it that serves it. An API\n * declared at a level reaches every level below it, and a level that runs a package from an outer\n * level leaves that level's root-bound APIs to it; a level that declares the API itself wins.\n */\n apiHandler(basePath: string): PoApiHandler | undefined {\n for (const scope of this.ancestry()) {\n const handler = scope.router?.handlerFor?.(basePath);\n if (handler !== undefined) return handler;\n }\n return undefined;\n }\n\n /** Resolve only the nearest mounted API's parsed contract, never a caller supplied operation. */\n apiOperation(basePath: string, method: string, path: string): string | undefined {\n for (const scope of this.ancestry()) {\n if (!scope.router?.handlerFor?.(basePath)) continue;\n for (const { declaration } of scope.installed.values()) {\n const route = declaration?.apiContract?.http.find(\n (route) =>\n route.scope === scope.level &&\n route.basePath === basePath &&\n route.method === method &&\n route.path.split('/').length === path.split('/').length &&\n route.path\n .split('/')\n .every((part, index) =>\n part.startsWith(':') ? !!path.split('/')[index] : part === path.split('/')[index],\n ),\n );\n if (route) return route.id;\n }\n return undefined;\n }\n return undefined;\n }\n\n emit<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void {\n deliver([...this.ancestry()], name, args);\n }\n\n broadcast<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void {\n deliver([...this.subtree()], name, args);\n }\n\n /**\n * Disposes descendants first, then the packages installed here in reverse install order, then\n * this root; a binding made here unwinds with its provider.\n */\n dispose(): Promise<void> {\n this.disposing ??= (async () => {\n await Promise.all([...this.children].map((child) => child.dispose()));\n this.parent?.children.delete(this);\n this.mirrors.clear();\n this.router = undefined;\n const packages = [...this.installed.values()].reverse();\n this.installed.clear();\n for (const { plugin, declaration, fiber } of packages)\n await this.disposeFiber(declaration?.packageName ?? plugin.name, fiber, LIVE_FACTORY_TIMEOUT_MS);\n const disposal = this.root.fiber.dispose();\n if (this.abandonedTimeoutMs === undefined) return await disposal;\n // An abandoned apply holds its fiber open, so teardown is bounded rather than left to hang.\n await withTimeout(disposal, this.abandonedTimeoutMs, `${this.level} scope dispose`).catch((error: unknown) =>\n this.notice(describe(error)),\n );\n })().finally(async () => {\n // What a level never released, such as a value an abandoned apply held, goes with the tree.\n if (this.parent === undefined) await this.disposeShares();\n });\n return this.disposing;\n }\n\n /**\n * What the plugin build `owner` shares in this tree, seen from this scope. The outermost scope keeps\n * one store per build, so every level of one hub sees the same values and no two hubs ever do.\n */\n share<TRoots>(owner: object): PoServerPluginShare<TRoots> {\n const top = this.outermost();\n const name = nameOf(owner);\n const build = buildOf(owner);\n for (const scope of this.parent?.ancestry() ?? [])\n for (const [other, store] of top.shares)\n if (other !== owner && name !== undefined && nameOf(other) === name && store.running.has(scope))\n this.notice(\n `${this.label} mounts ${build} of '${name}' while ${scope.label} runs ${buildOf(other)}, so it builds that build's roots itself.`,\n );\n const storeOf = (): PluginShare => {\n let store = top.shares.get(owner);\n if (store === undefined) {\n store = new PluginShare();\n top.shares.set(owner, store);\n }\n return store;\n };\n // An idle store is dropped, so builds a reload replaced do not accumulate.\n const settle = (store: PluginShare): void => {\n if (store.idle && top.shares.get(owner) === store) top.shares.delete(owner);\n };\n return {\n acquire: async <T>(\n key: PoServerResourceKey,\n create: () => T | Promise<T>,\n dispose?: (value: T) => void | Promise<void>,\n ): Promise<PoServerResourceLease<T>> => {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n const store = storeOf();\n const name = resourceName(key);\n let shared = store.values.get(name);\n if (shared === undefined) {\n const created: SharedValue = {\n value: Promise.resolve().then(create),\n holders: 0,\n disposeValue: dispose === undefined ? undefined : (value) => dispose(value as T),\n };\n store.values.set(name, created);\n // A value that could not be created is not kept, so the next acquire creates it again.\n created.value.catch(() => {\n if (store.values.get(name) === created) store.values.delete(name);\n settle(store);\n });\n shared = created;\n }\n const held = shared;\n held.holders += 1;\n let value: unknown;\n try {\n value = await held.value;\n } catch (error) {\n held.holders -= 1;\n throw error;\n }\n let released = false;\n return {\n value: value as T,\n release: async () => {\n if (released) return;\n released = true;\n held.holders -= 1;\n if (held.holders > 0 || store.values.get(name) !== held) return;\n store.values.delete(name);\n settle(store);\n await held.disposeValue?.(value);\n },\n };\n },\n run: (roots) => {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n const store = storeOf();\n store.running.set(this, roots);\n return () => {\n if (store.running.get(this) === roots) store.running.delete(this);\n settle(store);\n };\n },\n outer: (from) => {\n const store = top.shares.get(owner);\n if (store === undefined) return [];\n const held: TRoots[] = [];\n for (const scope of this.parent?.ancestry() ?? []) {\n if (depth(scope.level) >= depth(from) && store.running.has(scope))\n held.push(store.running.get(scope) as TRoots);\n }\n return held;\n },\n };\n }\n\n private async installAll(\n packages: readonly (PoServerPlugin | LoadedServerPackage)[],\n options: PoServerInstallOptions,\n ): Promise<readonly string[]> {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n const notice = options.onNotice ?? ((): void => {});\n this.notice = notice;\n if (\n packages.some((candidate) => 'retained' in candidate && candidate.retained === true) &&\n !readPoHeadlessHost(this.root)\n )\n throw new Error('Retained server candidates require a gated headless host');\n for (const candidate of packages) {\n const plugin = 'declaration' in candidate ? candidate.plugin : candidate;\n const declaration = 'declaration' in candidate ? candidate.declaration : undefined;\n const name = declaration?.packageName ?? plugin.name;\n const previous = this.installed.get(name);\n if (previous?.plugin === plugin) continue;\n if (previous !== undefined) {\n this.installed.delete(name);\n await this.disposeFiber(name, previous.fiber, options.factoryTimeoutMs ?? LIVE_FACTORY_TIMEOUT_MS);\n }\n try {\n const fiber = await this.apply(name, plugin, declaration, options);\n this.installed.set(name, { plugin, ...(declaration === undefined ? {} : { declaration }), fiber });\n } catch (error) {\n const message = `server package '${name}' did not install (${describe(error)})`;\n if (previous !== undefined) {\n const restored = await this.restore(name, previous, options, message);\n options.onPackageFailed?.({\n packageName: name,\n reason: describe(error),\n previous: restored ? 'restored' : 'lost',\n });\n continue;\n }\n options.onPackageFailed?.({ packageName: name, reason: describe(error), previous: 'none' });\n if (\n declaration?.required === true &&\n !('initiallyEligible' in candidate && candidate.initiallyEligible === false)\n )\n throw new Error(message, { cause: error });\n notice(message);\n }\n }\n // A level waiting for a contract that nothing at it or above it provides would never mount, silently.\n for (const candidate of packages) {\n const plugin = 'declaration' in candidate ? candidate.plugin : candidate;\n const name = ('declaration' in candidate ? candidate.declaration.packageName : undefined) ?? plugin.name;\n if (this.installed.get(name)?.plugin !== plugin) continue;\n for (const contract of plugin.injects?.[this.level] ?? []) {\n // An inner level's contract is never visible here; defineServerPlugin refuses one, a raw plugin may not.\n const missing = depth(contract.scope) > depth(this.level) || this.resolve(contract) === undefined;\n if (missing)\n notice(\n `server package '${name}' waits for contract '${contract.name}', which no ${contract.scope} package provides.`,\n );\n }\n }\n return [...this.installed.keys()];\n }\n\n /** Applies a replaced package's previous build again after its new build failed; true when it runs. */\n private async restore(\n name: string,\n previous: InstalledPackage,\n options: PoServerInstallOptions,\n message: string,\n ): Promise<boolean> {\n try {\n const fiber = await this.apply(name, previous.plugin, previous.declaration, options);\n this.installed.set(name, { ...previous, fiber });\n this.notice(`${message}; its previous build is restored.`);\n return true;\n } catch (rollbackError) {\n this.notice(`${message}; its previous build could not be restored (${describe(rollbackError)}).`);\n return false;\n }\n }\n\n /** Applies one package as its own fiber, bounded by the factory timeout, and reports how it settled. */\n private async apply(\n name: string,\n plugin: PoServerPlugin,\n declaration: PoServerBundleEntry | undefined,\n options: PoServerInstallOptions,\n ): Promise<Fiber> {\n const startedAt = Date.now();\n const timeoutMs = options.factoryTimeoutMs ?? LIVE_FACTORY_TIMEOUT_MS;\n const settled = (outcome: PoServerPackageSettledReport['outcome']): void =>\n options.onPackageSettled?.({ packageName: name, durationMs: Date.now() - startedAt, outcome });\n let fiber: Fiber | undefined;\n let applySettled = false;\n try {\n const metadata: PoServiceBindingMetadata = {\n owner: { kind: 'package', packageName: name, origin: declaration?.origin ?? 'unknown' },\n contracts: Object.values(plugin.provides ?? {}).flat(),\n };\n const owner = this.root.extend({\n [PACKAGE_PROVENANCE]: metadata,\n ...(declaration ? { [PO_HEADLESS_OWNER]: declaration } : {}),\n });\n fiber = owner.plugin(plugin);\n const applied = fiber.await();\n const markSettled = (): void => {\n applySettled = true;\n };\n applied.then(markSettled, markSettled);\n await withTimeout(applied, timeoutMs, `server package '${name}' apply`);\n settled('installed');\n return fiber;\n } catch (error) {\n settled(fiber && !applySettled ? 'timed_out' : 'failed');\n if (fiber && !applySettled) {\n this.abandonedTimeoutMs = Math.max(this.abandonedTimeoutMs ?? 0, timeoutMs);\n void fiber\n .dispose()\n .catch((disposeError: unknown) =>\n this.notice(`abandoned server package '${name}' did not dispose (${describe(disposeError)})`),\n );\n } else if (fiber) await this.disposeFiber(name, fiber, timeoutMs);\n throw error;\n }\n }\n\n /**\n * Disposes one package's fiber within `timeoutMs`. A package whose cleanup throws or never settles\n * is reported and left behind, so it cannot block the packages after it or the scope's teardown.\n */\n private async disposeFiber(name: string, fiber: Fiber, timeoutMs: number): Promise<void> {\n try {\n await withTimeout(fiber.dispose(), timeoutMs, `server package '${name}' dispose`);\n } catch (error) {\n this.abandonedTimeoutMs = Math.max(this.abandonedTimeoutMs ?? 0, timeoutMs);\n this.notice(`server package '${name}' did not dispose (${describe(error)})`);\n }\n }\n\n private visible(): Binding[] {\n return [...(this.parent?.visible() ?? []), ...this.bound.values()];\n }\n\n /**\n * Logs, once per distinct tree, which scopes bind `name`, whose binding each root mirrors, and\n * which Cordis fiber actually holds the service in that root.\n */\n private reportGraph(name: string, error: unknown): void {\n const top = this.outermost();\n const graph = [...top.subtree()]\n .map((scope) => {\n const context = scope.router?.context as Partial<PoServerHostService['context']> | undefined;\n const cwd = context?.cwd ?? context?.workspaceRoot;\n const holds = [...scope.mirrors.keys()]\n .filter((binding) => binding.name === name)\n .map(({ owner }) => owner.label);\n const impl = scope.root.reflect._getImpl(name, false);\n const mirrored = impl && [...scope.mirrors].find(([, fiber]) => fiber === impl.fiber)?.[0];\n const cordis =\n impl === undefined\n ? 'none'\n : `<${impl.fiber.name}#${impl.fiber.uid}> state=${impl.fiber.state}${mirrored ? ` from ${mirrored.owner.label}` : ''}`;\n return `${' '.repeat(depth(scope.level))}${scope.label}${cwd ? ` ${cwd}` : ''} binds=${scope.bound.has(name) ? 'yes' : 'no'} mirrors=[${holds.join(', ')}] cordis=${cordis}`;\n })\n .join('\\n');\n if (top.reported.get(name) === graph) return;\n top.reported.set(name, graph);\n this.notice(`binding '${name}' from ${this.label} failed (${describe(error)}); scope tree:\\n${graph}`);\n }\n\n /** This scope, then each parent out to the root. */\n private outermost(): PoServerScope {\n return this.parent === undefined ? this : this.parent.outermost();\n }\n\n /** Disposes every value the tree still holds, newest first; a failure is reported and the rest still go. */\n private async disposeShares(): Promise<void> {\n const values = [...this.shares.values()].flatMap((store) => [...store.values.values()]).reverse();\n this.shares.clear();\n for (const shared of values) {\n try {\n await shared.disposeValue?.(await shared.value);\n } catch (error) {\n this.notice(`a shared server value did not dispose (${describe(error)})`);\n }\n }\n }\n\n private *ancestry(): Generator<PoServerScope> {\n yield this;\n if (this.parent !== undefined) yield* this.parent.ancestry();\n }\n\n private *subtree(): Generator<PoServerScope> {\n if (this.disposed) return;\n yield this;\n for (const child of this.children) yield* child.subtree();\n }\n\n /** The binding of `name` this root publishes: the one bound nearest to it. */\n private nearest(name: string): Binding | undefined {\n for (const scope of this.ancestry()) {\n const binding = scope.bound.get(name);\n if (binding !== undefined) return binding;\n }\n return undefined;\n }\n\n /**\n * Publishes a binding into this root and settles once it is live. Idempotent per binding, since a\n * child opening mid-bind is reached by both `open` and `bind`. A nearer level binding the same\n * name wins, as a level declaring an API itself does; Cordis holds one service per name in a root,\n * so the farther binding leaves first.\n */\n private async mirror(binding: Binding): Promise<void> {\n if (this.disposed || this.nearest(binding.name) !== binding) return;\n const replacing = this.replacing.get(binding);\n if (replacing !== undefined) {\n await replacing;\n return await this.mirror(binding);\n }\n let fiber = this.mirrors.get(binding);\n if (fiber === undefined) {\n const shadowed = [...this.mirrors.keys()].filter((other) => other.name === binding.name);\n if (shadowed.length > 0) {\n const cleared = Promise.all(shadowed.map((other) => this.unmirror(other))).finally(() =>\n this.replacing.delete(binding),\n );\n this.replacing.set(\n binding,\n cleared.then(\n () => undefined,\n () => undefined,\n ),\n );\n await cleared;\n return await this.mirror(binding);\n }\n fiber = this.root.plugin(bindingProvider, { binding, scope: this });\n this.mirrors.set(binding, fiber);\n }\n try {\n await fiber.await();\n } catch (error) {\n throw new Error(`${describe(error)} when ${binding.owner.label} published it into ${this.label}`, {\n cause: error,\n });\n }\n }\n\n private async unmirror(binding: Binding): Promise<void> {\n const fiber = this.mirrors.get(binding);\n this.mirrors.delete(binding);\n // A disposing root unwinds its own mirrors.\n if (!this.disposed) await fiber?.dispose();\n }\n}\n\n/** Every scope receives the event even when an earlier one's listener throws. */\nfunction deliver(scopes: readonly PoServerScope[], name: keyof Events, args: readonly unknown[]): void {\n const errors: unknown[] = [];\n for (const scope of scopes) {\n if (scope.disposed) continue;\n try {\n scope.root.events.emit(name, ...args);\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length > 0) throw new AggregateError(errors, `${errors.length} scope listener(s) of '${name}' failed.`);\n}\n"],"mappings":";;;;;;;;;;;;;AAiEA,IAAM,cAAN,MAAkB;CAChB,yBAAkB,IAAI,IAAyB;CAC/C,0BAAmB,IAAI,IAA4B;CAEnD,IAAI,OAAgB;EAClB,OAAO,KAAK,OAAO,SAAS,KAAK,KAAK,QAAQ,SAAS;CACzD;AACF;AAEA,MAAM,gBAAgB,QAAqC,KAAK,UAAU,OAAO,QAAQ,WAAW,CAAC,GAAG,IAAI,GAAG;AAoC/G,MAAM,SAAS,UAA8BA,oBAAAA,uBAAuB,QAAQ,KAAK;AAEjF,MAAM,YAAY,UAA4B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAEnG,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AQ;MAgBlE;;;;;;EASE,MAAM,OAAO,oBAAoB;;;;;;;;;;EA2BvC,QACE,oBAAoB,iBAAiB,wBACrC,UAAS,yBACR;;;;;EAaH,UAAU,2BAA2B;;;;;;;EAuB/B,KAAK,GACT,UAAU,kBAAkB,IAC5B,OAAO,GACP,WAAU,2BAIT,cAAc;;EA4CjB,WAAW,OAAO,QAAQ;EAiB1B,YAAY;EA4GZ,QAAQ,GAAG,UAAU,kBAAkB,KAAK;;;;;;EAc5C,WAAW,mBAAmB;;EAS9B,aAAa,kBAAkB,gBAAgB;EAuB/C,KAAK,gBAAgB,QAAQ,MAAM,MAAM,MAAM,WAAW,OAAO;EAIjE,UAAU,gBAAgB,QAAQ,MAAM,MAAM,MAAM,WAAW,OAAO;;;;;EAQtE,WAAW;;;;;EA2BX,MAAM,QAAQ,gBAAgB,oBAAoB;UA2FpC;;UA+DA;;UAkBA;;;;;UAgDA;UASN;;;;;UAQA;;UAwBA;;UAKM;UAYL;UAKA;;UAOD;;;;;;;UAcM;UAoCA"}
@@ -389,7 +389,8 @@ var PoServerScope = class PoServerScope {
389
389
  result.packages.push({
390
390
  scope: describeScope(scope),
391
391
  owner,
392
- web: entry.declaration?.webMetadata ?? null
392
+ web: entry.declaration?.webMetadata ?? null,
393
+ native: entry.declaration?.nativeMetadata ?? null
393
394
  });
394
395
  const consumer = `${scope.label}:consumer:${name}`;
395
396
  result.consumers.push({
@@ -1 +1 @@
1
- {"version":3,"file":"serverScope.mjs","names":["Context"],"sources":["../../../src/server/serverScope.ts"],"sourcesContent":["import { Context, type Events, type Fiber, Service } from '@deepseek-ai/cordis';\nimport { BACKGROUND_CONTEXT } from '@earendil-works/chord/context';\n\nimport {\n parsePoWebBrainMetadata,\n type BrainOwner,\n type BrainScope,\n type BrainServicesSnapshot,\n} from '../schemas/brain';\nimport { PO_GLOBAL_SERVICES_SERVICE, type PoGlobalServices } from '../schemas/globalServices';\nimport { PO_HEADLESS_OWNER, readPoHeadlessHost } from '../schemas/headless';\nimport { PO_HOST_SERVICE_CONTRACTS } from '../schemas/hostServiceContracts';\nimport type { PoApiHandler, PoApiScope } from '../schemas/packageApi';\nimport {\n PO_BROWSER_SERVICE,\n PO_ELECTRON_SERVICE,\n PO_FS_SERVICE,\n PO_ISOLATE_SERVICE,\n PO_NPM_SERVICE,\n PO_PROVIDER_AUTH_SERVICE,\n PO_SESSION_STORAGE_SERVICE,\n PO_SHELL_SERVICE,\n PO_SQLITE_SERVICE,\n type PoPlatform,\n} from '../schemas/platform';\nimport type { PoServerBundleEntry } from '../schemas/serverBundle';\nimport { PO_SERVER_HOST_SERVICE, type PoServerHostService, type PoServerPlugin } from '../schemas/serverPlugin';\nimport {\n PO_SERVER_SCOPE_LEVELS,\n projectServiceBindingMetadata,\n PO_SERVER_SCOPE_SERVICE,\n type PoServerPluginShare,\n type PoServerResourceKey,\n type PoServerResourceLease,\n type PoServerScopeService,\n type PoServiceContract,\n type PoServiceBindingMetadata,\n} from '../schemas/serverScope';\nimport { PO_SESSION_FILES_SERVICE, PO_SESSION_TEMP_DIR } from '../services/sessionFiles';\nimport { LIVE_FACTORY_TIMEOUT_MS, withTimeout } from './liveImport';\nimport type { LoadedServerPackage } from './serverPackages';\n\ninterface Binding {\n readonly name: string;\n readonly contract: PoServiceContract<unknown>;\n readonly metadata: PoServiceBindingMetadata;\n readonly value: unknown;\n /** The scope that bound it, named in logs. */\n readonly owner: PoServerScope;\n}\n\ninterface InstalledPackage {\n readonly plugin: PoServerPlugin;\n readonly declaration?: PoServerBundleEntry;\n readonly fiber: Fiber;\n}\n\n/** One shared value, how many levels hold it, and how its creator said to dispose it. */\ninterface SharedValue {\n readonly value: Promise<unknown>;\n holders: number;\n readonly disposeValue: ((value: unknown) => void | Promise<void>) | undefined;\n}\n\n/** What one plugin build shares in one tree: its keyed values, and what each scope running it holds. */\nclass PluginShare {\n readonly values = new Map<string, SharedValue>();\n readonly running = new Map<PoServerScope, unknown>();\n\n get idle(): boolean {\n return this.values.size === 0 && this.running.size === 0;\n }\n}\n\nconst resourceName = (key: PoServerResourceKey): string => JSON.stringify(typeof key === 'string' ? [key] : key);\n/** What a scope's owner publishes for the packages installed at its level. */\nexport interface PoServerScopeHost {\n /**\n * The level's mount table. A host that also routes requests (`createPoServerHost` does) answers\n * API requests for this level and every level below it that does not serve the API itself.\n */\n readonly host: PoServerHostService & { handlerFor?(basePath: string): PoApiHandler | undefined };\n /** Host capabilities published as `po/fs`, `po/shell`, `po/sqlite` and `po/session-storage`. */\n readonly platform: PoPlatform;\n}\n\nexport interface PoServerPackageSettledReport {\n readonly packageName: string;\n readonly durationMs: number;\n readonly outcome: 'installed' | 'failed' | 'timed_out';\n}\n\n/** A package whose build did not install, and what of it still runs. */\nexport interface PoServerPackageFailure {\n readonly packageName: string;\n readonly reason: string;\n /** `restored`: its previous build runs again; `lost`: that failed too; `none`: it had none. */\n readonly previous: 'restored' | 'lost' | 'none';\n}\n\nexport interface PoServerInstallOptions {\n readonly onNotice?: (message: string) => void;\n /** Bound on each package's `apply`; defaults to `LIVE_FACTORY_TIMEOUT_MS`. */\n readonly factoryTimeoutMs?: number;\n /** Reports how long each package's `apply` took and how it ended, for telemetry. */\n readonly onPackageSettled?: (report: PoServerPackageSettledReport) => void;\n /** Reports each package whose build did not install. */\n readonly onPackageFailed?: (failure: PoServerPackageFailure) => void;\n}\n\nconst depth = (level: PoApiScope): number => PO_SERVER_SCOPE_LEVELS.indexOf(level);\n\nconst describe = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\nconst PACKAGE_PROVENANCE = Symbol('package provenance');\n\nlet scopesOpened = 0;\nlet buildsSeen = 0;\nconst builds = new WeakMap<object, number>();\n/** A stable log label for one plugin build; a reload imports a new module, and so a new build. */\nfunction buildOf(owner: object): string {\n let build = builds.get(owner);\n if (build === undefined) builds.set(owner, (build = ++buildsSeen));\n return `build#${build}`;\n}\nconst nameOf = (owner: object): string | undefined => {\n const name = (owner as { name?: unknown }).name;\n return typeof name === 'string' ? name : undefined;\n};\n\n/** Publishes one binding as a native service of the root it is plugged into. */\nfunction bindingProvider(context: Context, { binding, scope }: { binding: Binding; scope: PoServerScope }): void {\n if (binding.name === PO_GLOBAL_SERVICES_SERVICE)\n new ScopedGlobalServices(context, binding.value as PoGlobalServices, scope);\n else context.provide(binding.name, binding.value);\n}\n\nclass ScopedGlobalServices extends Service<PoGlobalServices> implements PoGlobalServices {\n constructor(\n ctx: Context,\n private readonly registry: PoGlobalServices,\n private readonly scope: PoServerScope,\n ) {\n super(ctx, PO_GLOBAL_SERVICES_SERVICE);\n }\n\n register(\n owner: Parameters<PoGlobalServices['register']>[0],\n contribution: Parameters<PoGlobalServices['register']>[1],\n ) {\n return this.registry.register(owner, contribution, this.scope.provenance(this.ctx.fiber));\n }\n}\n\n/**\n * The scope service each root publishes.\n *\n * Cordis traceable services rebind `ctx` to the caller, so a binding made through\n * `provide` unwinds with the plugin that made it.\n */\nclass ScopeService extends Service<PoServerScopeService> implements PoServerScopeService {\n readonly level: PoApiScope;\n\n constructor(\n ctx: Context,\n private readonly scope: PoServerScope,\n ) {\n super(ctx, PO_SERVER_SCOPE_SERVICE);\n this.level = scope.level;\n }\n\n async provide<T>(contract: PoServiceContract<T>, value: T): Promise<() => Promise<void>> {\n return await this.ctx.effect(\n () => this.scope.bind(contract, value, this.scope.provenance(this.ctx.fiber)),\n `po scope provide ${contract.name}`,\n );\n }\n\n snapshot(): BrainServicesSnapshot {\n return this.scope.snapshot();\n }\n\n resolve<T>(contract: PoServiceContract<T>): T | undefined {\n return this.scope.resolve(contract);\n }\n\n emit<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void {\n this.scope.emit(name, ...args);\n }\n\n broadcast<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void {\n this.scope.broadcast(name, ...args);\n }\n\n plugin<TRoots>(owner: object): PoServerPluginShare<TRoots> {\n return this.scope.share<TRoots>(owner);\n }\n}\n\n/**\n * Binds registrations to the Cordis fiber that calls the host service.\n *\n * The host itself is shared by every package at its level, but Cordis traceable\n * services rebind `ctx` to the caller. That lets a package's registration unwind\n * even when `apply` throws before it can return its disposer.\n */\nclass ScopedPoServerHost extends Service<PoServerHostService> implements PoServerHostService {\n readonly scope: PoServerHostService['scope'];\n readonly context: PoServerHostService['context'];\n\n constructor(\n ctx: Context,\n private readonly host: PoServerHostService,\n ) {\n super(ctx, PO_SERVER_HOST_SERVICE);\n this.scope = host.scope;\n this.context = host.context;\n }\n\n registerApi(api: Parameters<PoServerHostService['registerApi']>[0]) {\n const headless = this.scope === 'session' ? readPoHeadlessHost(this.ctx) : undefined;\n if (headless) {\n const activity = headless.registerActivity({\n name: `api:${api.basePath}`,\n start: () => {\n const registration = this.host.registerApi(api);\n if (registration.mounted !== true) {\n registration.dispose();\n throw new Error(`package API '${api.basePath}' did not mount.`);\n }\n return () => {\n registration.dispose();\n };\n },\n });\n return {\n mounted: true,\n dispose: () => activity.dispose(),\n };\n }\n const registration = this.host.registerApi(api);\n if (registration.mounted !== true) {\n registration.dispose();\n throw new Error(`package API '${api.basePath}' did not mount.`);\n }\n this.ctx.effect(() => () => registration.dispose(), 'server package API registration');\n return registration;\n }\n\n registerChannel(channel: Parameters<PoServerHostService['registerChannel']>[0]) {\n const registration = this.host.registerChannel(channel);\n if (registration.mounted !== true) {\n registration.dispose();\n throw new Error(`hub channel '${channel.frameType}' did not mount.`);\n }\n this.ctx.effect(() => () => registration.dispose(), 'server package channel registration');\n return registration;\n }\n\n registerMethod: PoServerHostService['registerMethod'] = (definition, handler) => {\n const registration = this.host.registerMethod(definition, handler);\n if (registration.mounted !== true) {\n registration.dispose();\n throw new Error(`plugin method '${definition.service}.${definition.method}' did not mount.`);\n }\n this.ctx.effect(() => () => registration.dispose(), 'server package method registration');\n return registration;\n };\n\n mounted(): readonly string[] {\n return this.host.mounted();\n }\n\n mountedChannels(): readonly string[] {\n return this.host.mountedChannels();\n }\n}\n\n/** Publishes the host service from inside a root-level plugin, so it unwinds with the scope. */\nfunction serverHostProvider(context: Context, host: PoServerHostService): void {\n new ScopedPoServerHost(context, host);\n}\n\n/** Publishes the platform services from inside a root-level plugin, so they unwind with the scope. */\nfunction platformProvider(\n context: Context,\n input: { platform: PoPlatform; cwd: string; temporaryDirectory?: string },\n): void {\n const env = input.platform.env(input.cwd);\n context.provide(PO_FS_SERVICE, env);\n context.provide(PO_SHELL_SERVICE, env);\n context.provide(PO_SQLITE_SERVICE, input.platform.sqlite);\n context.provide(PO_SESSION_STORAGE_SERVICE, input.platform.sessions);\n if (input.platform.isolate !== undefined) context.provide(PO_ISOLATE_SERVICE, input.platform.isolate);\n if (input.platform.npm !== undefined) context.provide(PO_NPM_SERVICE, input.platform.npm);\n if (input.platform.electron !== undefined) context.provide(PO_ELECTRON_SERVICE, input.platform.electron);\n if (input.platform.browser !== undefined) context.provide(PO_BROWSER_SERVICE, input.platform.browser);\n if (input.platform.providerAuth !== undefined) context.provide(PO_PROVIDER_AUTH_SERVICE, input.platform.providerAuth);\n if (input.temporaryDirectory !== undefined)\n context.provide(PO_SESSION_FILES_SERVICE, { temporaryDirectory: input.temporaryDirectory });\n context.effect(() => () => env.cleanup(BACKGROUND_CONTEXT), 'platform execution env');\n}\n\n/**\n * One level of the server IoC tree: its own cordis root, a parent link, the contracts bound here,\n * and the packages installed here.\n *\n * Separate roots rather than one shared root, because cordis re-checks every fiber of a root on each\n * service change; a hundred sessions in one root would make every change scan all of them. A binding\n * is instead mirrored into each descendant root as a native service, so a plugin injects an outer\n * level's service exactly as it injects its own.\n */\nexport class PoServerScope {\n readonly root = new Context();\n private readonly children = new Set<PoServerScope>();\n private readonly bound = new Map<string, Binding>();\n private readonly mirrors = new Map<Binding, Fiber>();\n /** A binding waiting here for the farther one it shadows to leave, so a repeat mirror waits too. */\n private readonly replacing = new Map<Binding, Promise<void>>();\n private readonly hostFibers = new Set<Fiber>();\n private readonly installed = new Map<string, InstalledPackage>();\n private installs: Promise<void> = Promise.resolve();\n /** Set once a package's apply never settled, to the bound it overran; its fiber may never finish disposing. */\n private abandonedTimeoutMs: number | undefined;\n private notice: (message: string) => void = () => undefined;\n private disposing: Promise<void> | undefined;\n /** The served mount table, read when a request routes through this level. */\n private router: PoServerScopeHost['host'] | undefined;\n /** Kept by the outermost scope only: what each plugin build shares across the whole tree. */\n private readonly shares = new Map<object, PluginShare>();\n /** Names this scope in logs, as its level and the order it opened in. */\n readonly label: string;\n /** The last graph logged for a failing binding, by name, so a retry that fails the same way stays quiet. */\n private readonly reported = new Map<string, string>();\n\n private constructor(\n readonly level: PoApiScope,\n readonly parent: PoServerScope | undefined,\n ) {\n this.label = `${level}#${++scopesOpened}`;\n }\n\n /** Opens a scope below `parent`, with every binding visible from its ancestors already published. */\n static async open(level: PoApiScope, parent?: PoServerScope): Promise<PoServerScope> {\n if (parent?.disposing !== undefined) throw new Error(`The ${parent.level} scope is disposed.`);\n if (parent !== undefined && depth(level) <= depth(parent.level))\n throw new Error(`A ${level} scope cannot open below a ${parent.level} scope.`);\n const scope = new PoServerScope(level, parent);\n parent?.children.add(scope);\n try {\n await scope.root.plugin(ScopeService, scope);\n await Promise.all((parent?.visible() ?? []).map((binding) => scope.mirror(binding)));\n } catch (error) {\n await scope.dispose();\n throw error;\n }\n return scope;\n }\n\n get disposed(): boolean {\n return this.disposing !== undefined;\n }\n\n /**\n * Publishes what every package at this level reads: the owner's mount table as `po/server-host`,\n * and the platform services. They stay for the life of the scope; the owner still disposes the\n * mount table it handed in.\n */\n async serve(input: PoServerScopeHost): Promise<void> {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n if (input.host.scope !== this.level)\n throw new Error(`A ${input.host.scope} host cannot serve a ${this.level} scope.`);\n this.hostFibers.add(await this.root.plugin(serverHostProvider, input.host));\n this.router = input.host;\n // Published callers may hand a host without context (the packed authoring check does), so read it defensively.\n const hostContext = input.host.context as Partial<PoServerHostService['context']> | undefined;\n const cwd = hostContext?.cwd ?? hostContext?.workspaceRoot ?? input.platform.homeDirectory;\n this.hostFibers.add(\n await this.root.plugin(platformProvider, {\n platform: input.platform,\n cwd,\n temporaryDirectory: this.level === 'session' ? hostContext?.environment?.[PO_SESSION_TEMP_DIR] : undefined,\n }),\n );\n }\n\n /**\n * Installs packages at this level, each as its own fiber in this root, one at a time.\n *\n * Installation only adds. A package installed from the same build (the same plugin object) is\n * skipped. One whose build changed is disposed and the new build applied; when that fails, the\n * previous build is applied again. A package missing from `packages` stays installed, because\n * which packages a session runs is its own composition's choice. Installs into one scope run one\n * at a time. Resolves with every package installed here, in install order.\n */\n install(\n packages: readonly (PoServerPlugin | LoadedServerPackage)[],\n options: PoServerInstallOptions = {},\n ): Promise<readonly string[]> {\n const run = this.installs.then(() => this.installAll(packages, options));\n this.installs = run.then(\n () => undefined,\n () => undefined,\n );\n return run;\n }\n\n /**\n * Disposes the named packages installed here, in reverse install order, each bounded by the\n * cleanup time limit. Runs in order with installs. Resolves with every package still installed.\n */\n uninstall(names: readonly string[]): Promise<readonly string[]> {\n const run = this.installs.then(async () => {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n for (const [name, { fiber }] of [...this.installed].reverse()) {\n if (!names.includes(name)) continue;\n this.installed.delete(name);\n await this.disposeFiber(name, fiber, LIVE_FACTORY_TIMEOUT_MS);\n }\n return [...this.installed.keys()];\n });\n this.installs = run.then(\n () => undefined,\n () => undefined,\n );\n return run;\n }\n\n /**\n * Binds a contract owned by this level here and in every descendant, including ones opened later.\n * Settles once every descendant root publishes it, or a nearer binding of the same name shadows it\n * there. Hosts call this directly; plugins go through the scope service so the binding follows\n * their fiber.\n */\n async bind<T>(\n contract: PoServiceContract<T>,\n value: T,\n metadata: PoServiceBindingMetadata = {\n owner: { kind: 'host', packageName: null, origin: 'unknown' },\n contracts: [],\n },\n ): Promise<() => Promise<void>> {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n if (contract.scope !== this.level)\n throw new Error(\n `Contract '${contract.name}' belongs to the ${contract.scope} scope and cannot be provided from the ${this.level} scope.`,\n );\n if (this.bound.has(contract.name))\n throw new Error(`Contract '${contract.name}' is already provided in this ${this.level} scope.`);\n const binding: Binding = {\n name: contract.name,\n contract,\n metadata: projectServiceBindingMetadata(metadata),\n value,\n owner: this,\n };\n this.bound.set(contract.name, binding);\n const withdraw = async (): Promise<void> => {\n if (this.bound.get(contract.name) !== binding) return;\n this.bound.delete(contract.name);\n await Promise.all(\n [...this.subtree()].map(async (scope) => {\n await scope.unmirror(binding);\n // A farther binding this one shadowed shows through again.\n const outer = scope.nearest(contract.name);\n if (outer === undefined) return;\n await scope.mirror(outer).catch((error: unknown) => {\n this.notice(\n `binding '${contract.name}' from ${outer.owner.label} did not return to ${scope.label} (${describe(error)})`,\n );\n });\n }),\n );\n };\n try {\n await Promise.all([...this.subtree()].map((scope) => scope.mirror(binding)));\n } catch (error) {\n this.reportGraph(contract.name, error);\n await withdraw();\n throw error;\n }\n return withdraw;\n }\n\n /** Finds only the installed package that owns this fiber, including nested service fibers. */\n provenance(fiber: Fiber): PoServiceBindingMetadata {\n const declared = (fiber.ctx as Context & { [PACKAGE_PROVENANCE]?: PoServiceBindingMetadata })[PACKAGE_PROVENANCE];\n if (declared) return declared;\n for (;;) {\n for (const [name, entry] of this.installed) {\n if (entry.fiber.uid !== fiber.uid) continue;\n return {\n owner: { kind: 'package', packageName: name, origin: entry.declaration?.origin ?? 'unknown' },\n contracts: Object.values(entry.plugin.provides ?? {}).flat(),\n };\n }\n if (fiber.parent.fiber === fiber) break;\n fiber = fiber.parent.fiber;\n }\n return { owner: { kind: 'unknown', packageName: null, origin: 'unknown' }, contracts: [] };\n }\n\n snapshot(): BrainServicesSnapshot {\n const scopes = [...this.ancestry()];\n const describeScope = (scope: PoServerScope): BrainScope => ({ id: scope.label, level: scope.level });\n const result: BrainServicesSnapshot = {\n scope: describeScope(this),\n scopes: scopes.map(describeScope),\n packages: [],\n services: [],\n consumers: [],\n edges: [],\n diagnostics: [],\n };\n const clientInventories = scopes.map((scope) => scope.router?.context?.clientPlugins);\n if (clientInventories.every((inventory) => inventory?.available)) {\n result.clientPackages = clientInventories.flatMap((inventory, index) =>\n inventory!.packages.map((pkg) => ({\n scope: describeScope(scopes[index]!),\n owner: { kind: pkg.owner.kind, packageName: pkg.owner.packageName, origin: pkg.owner.origin },\n web: parsePoWebBrainMetadata(pkg.web) ?? null,\n })),\n );\n }\n for (const scope of scopes) {\n for (const [name, entry] of scope.installed) {\n const owner: BrainOwner = {\n kind: 'package',\n packageName: name,\n origin: entry.declaration?.origin ?? 'unknown',\n };\n result.packages.push({ scope: describeScope(scope), owner, web: entry.declaration?.webMetadata ?? null });\n const consumer = `${scope.label}:consumer:${name}`;\n result.consumers.push({ id: consumer, name, scope: describeScope(scope), owner });\n const injections = new Set([\n ...Object.keys(entry.fiber.inject),\n ...(entry.plugin.injects?.[scope.level] ?? []).map((contract) => contract.name),\n ]);\n for (const name of injections) result.edges.push({ consumer, name, service: null, status: 'waiting' });\n }\n for (const runtime of scope.root.registry.values()) {\n for (const fiber of runtime.fibers) {\n if ([...scope.installed.values()].some((entry) => entry.fiber.uid === fiber.uid)) continue;\n const names = Object.keys(fiber.inject);\n if (!names.length) continue;\n const consumer = `${scope.label}:consumer:fiber:${fiber.uid}`;\n result.consumers.push({\n id: consumer,\n name: `fiber#${fiber.uid}`,\n scope: describeScope(scope),\n owner: scope.provenance(fiber).owner,\n });\n for (const name of names) result.edges.push({ consumer, name, service: null, status: 'waiting' });\n }\n }\n for (const key of Reflect.ownKeys(scope.root.reflect.store)) {\n const impl = scope.root.reflect.store[key as symbol];\n const mirror = [...scope.mirrors].find(([, fiber]) => fiber.uid === impl.fiber.uid)?.[0];\n // Mirrors describe their original implementation once, at its owning scope.\n if (mirror && mirror.owner !== scope) continue;\n const metadata = mirror?.metadata ?? scope.provenance(impl.fiber);\n const host =\n (metadata.owner.kind === 'host' ||\n [...scope.hostFibers].some((fiber) => fiber.uid === impl.fiber.uid) ||\n impl.fiber === scope.root.fiber) &&\n PO_HOST_SERVICE_CONTRACTS.find((contract) => contract.name === impl.name);\n const contract = metadata.contracts.find(\n (contract) => contract.name === impl.name && contract.scope === scope.level,\n );\n result.services.push({\n id: `${scope.label}:service:${impl.name}`,\n name: impl.name,\n scope: describeScope(scope),\n visibleFrom: describeScope(scope),\n owner: host ? { kind: 'host', packageName: null, origin: 'unknown' } : metadata.owner,\n public: !!contract || !!host,\n description: contract?.description ?? mirror?.contract.description ?? (host ? host.description : null),\n });\n }\n }\n for (const service of result.services) {\n const ownerIndex = scopes.findIndex((scope) => scope.label === service.scope.id);\n const shadowIndex = scopes.findLastIndex(\n (scope, index) =>\n index < ownerIndex &&\n result.services.some((other) => other.scope.id === scope.label && other.name === service.name),\n );\n service.visibleFrom = describeScope(scopes[shadowIndex + 1]);\n }\n for (const edge of result.edges) {\n const consumer = result.consumers.find((consumer) => consumer.id === edge.consumer)!;\n const start = scopes.findIndex((scope) => scope.label === consumer.scope.id);\n const service = scopes\n .slice(start)\n .flatMap((scope) =>\n result.services.filter((service) => service.scope.id === scope.label && service.name === edge.name),\n )[0];\n if (service) {\n edge.service = service.id;\n edge.status = 'resolved';\n }\n }\n return structuredClone(result);\n }\n\n resolve<T>(contract: PoServiceContract<T>): T | undefined {\n if (depth(contract.scope) > depth(this.level))\n throw new Error(`A ${this.level} scope cannot see the ${contract.scope} contract '${contract.name}'.`);\n for (const scope of this.ancestry()) {\n if (scope.level === contract.scope) return scope.bound.get(contract.name)?.value as T | undefined;\n }\n return undefined;\n }\n\n /**\n * The handler for an API, from this level or the nearest one above it that serves it. An API\n * declared at a level reaches every level below it, and a level that runs a package from an outer\n * level leaves that level's root-bound APIs to it; a level that declares the API itself wins.\n */\n apiHandler(basePath: string): PoApiHandler | undefined {\n for (const scope of this.ancestry()) {\n const handler = scope.router?.handlerFor?.(basePath);\n if (handler !== undefined) return handler;\n }\n return undefined;\n }\n\n /** Resolve only the nearest mounted API's parsed contract, never a caller supplied operation. */\n apiOperation(basePath: string, method: string, path: string): string | undefined {\n for (const scope of this.ancestry()) {\n if (!scope.router?.handlerFor?.(basePath)) continue;\n for (const { declaration } of scope.installed.values()) {\n const route = declaration?.apiContract?.http.find(\n (route) =>\n route.scope === scope.level &&\n route.basePath === basePath &&\n route.method === method &&\n route.path.split('/').length === path.split('/').length &&\n route.path\n .split('/')\n .every((part, index) =>\n part.startsWith(':') ? !!path.split('/')[index] : part === path.split('/')[index],\n ),\n );\n if (route) return route.id;\n }\n return undefined;\n }\n return undefined;\n }\n\n emit<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void {\n deliver([...this.ancestry()], name, args);\n }\n\n broadcast<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void {\n deliver([...this.subtree()], name, args);\n }\n\n /**\n * Disposes descendants first, then the packages installed here in reverse install order, then\n * this root; a binding made here unwinds with its provider.\n */\n dispose(): Promise<void> {\n this.disposing ??= (async () => {\n await Promise.all([...this.children].map((child) => child.dispose()));\n this.parent?.children.delete(this);\n this.mirrors.clear();\n this.router = undefined;\n const packages = [...this.installed.values()].reverse();\n this.installed.clear();\n for (const { plugin, declaration, fiber } of packages)\n await this.disposeFiber(declaration?.packageName ?? plugin.name, fiber, LIVE_FACTORY_TIMEOUT_MS);\n const disposal = this.root.fiber.dispose();\n if (this.abandonedTimeoutMs === undefined) return await disposal;\n // An abandoned apply holds its fiber open, so teardown is bounded rather than left to hang.\n await withTimeout(disposal, this.abandonedTimeoutMs, `${this.level} scope dispose`).catch((error: unknown) =>\n this.notice(describe(error)),\n );\n })().finally(async () => {\n // What a level never released, such as a value an abandoned apply held, goes with the tree.\n if (this.parent === undefined) await this.disposeShares();\n });\n return this.disposing;\n }\n\n /**\n * What the plugin build `owner` shares in this tree, seen from this scope. The outermost scope keeps\n * one store per build, so every level of one hub sees the same values and no two hubs ever do.\n */\n share<TRoots>(owner: object): PoServerPluginShare<TRoots> {\n const top = this.outermost();\n const name = nameOf(owner);\n const build = buildOf(owner);\n for (const scope of this.parent?.ancestry() ?? [])\n for (const [other, store] of top.shares)\n if (other !== owner && name !== undefined && nameOf(other) === name && store.running.has(scope))\n this.notice(\n `${this.label} mounts ${build} of '${name}' while ${scope.label} runs ${buildOf(other)}, so it builds that build's roots itself.`,\n );\n const storeOf = (): PluginShare => {\n let store = top.shares.get(owner);\n if (store === undefined) {\n store = new PluginShare();\n top.shares.set(owner, store);\n }\n return store;\n };\n // An idle store is dropped, so builds a reload replaced do not accumulate.\n const settle = (store: PluginShare): void => {\n if (store.idle && top.shares.get(owner) === store) top.shares.delete(owner);\n };\n return {\n acquire: async <T>(\n key: PoServerResourceKey,\n create: () => T | Promise<T>,\n dispose?: (value: T) => void | Promise<void>,\n ): Promise<PoServerResourceLease<T>> => {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n const store = storeOf();\n const name = resourceName(key);\n let shared = store.values.get(name);\n if (shared === undefined) {\n const created: SharedValue = {\n value: Promise.resolve().then(create),\n holders: 0,\n disposeValue: dispose === undefined ? undefined : (value) => dispose(value as T),\n };\n store.values.set(name, created);\n // A value that could not be created is not kept, so the next acquire creates it again.\n created.value.catch(() => {\n if (store.values.get(name) === created) store.values.delete(name);\n settle(store);\n });\n shared = created;\n }\n const held = shared;\n held.holders += 1;\n let value: unknown;\n try {\n value = await held.value;\n } catch (error) {\n held.holders -= 1;\n throw error;\n }\n let released = false;\n return {\n value: value as T,\n release: async () => {\n if (released) return;\n released = true;\n held.holders -= 1;\n if (held.holders > 0 || store.values.get(name) !== held) return;\n store.values.delete(name);\n settle(store);\n await held.disposeValue?.(value);\n },\n };\n },\n run: (roots) => {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n const store = storeOf();\n store.running.set(this, roots);\n return () => {\n if (store.running.get(this) === roots) store.running.delete(this);\n settle(store);\n };\n },\n outer: (from) => {\n const store = top.shares.get(owner);\n if (store === undefined) return [];\n const held: TRoots[] = [];\n for (const scope of this.parent?.ancestry() ?? []) {\n if (depth(scope.level) >= depth(from) && store.running.has(scope))\n held.push(store.running.get(scope) as TRoots);\n }\n return held;\n },\n };\n }\n\n private async installAll(\n packages: readonly (PoServerPlugin | LoadedServerPackage)[],\n options: PoServerInstallOptions,\n ): Promise<readonly string[]> {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n const notice = options.onNotice ?? ((): void => {});\n this.notice = notice;\n if (\n packages.some((candidate) => 'retained' in candidate && candidate.retained === true) &&\n !readPoHeadlessHost(this.root)\n )\n throw new Error('Retained server candidates require a gated headless host');\n for (const candidate of packages) {\n const plugin = 'declaration' in candidate ? candidate.plugin : candidate;\n const declaration = 'declaration' in candidate ? candidate.declaration : undefined;\n const name = declaration?.packageName ?? plugin.name;\n const previous = this.installed.get(name);\n if (previous?.plugin === plugin) continue;\n if (previous !== undefined) {\n this.installed.delete(name);\n await this.disposeFiber(name, previous.fiber, options.factoryTimeoutMs ?? LIVE_FACTORY_TIMEOUT_MS);\n }\n try {\n const fiber = await this.apply(name, plugin, declaration, options);\n this.installed.set(name, { plugin, ...(declaration === undefined ? {} : { declaration }), fiber });\n } catch (error) {\n const message = `server package '${name}' did not install (${describe(error)})`;\n if (previous !== undefined) {\n const restored = await this.restore(name, previous, options, message);\n options.onPackageFailed?.({\n packageName: name,\n reason: describe(error),\n previous: restored ? 'restored' : 'lost',\n });\n continue;\n }\n options.onPackageFailed?.({ packageName: name, reason: describe(error), previous: 'none' });\n if (\n declaration?.required === true &&\n !('initiallyEligible' in candidate && candidate.initiallyEligible === false)\n )\n throw new Error(message, { cause: error });\n notice(message);\n }\n }\n // A level waiting for a contract that nothing at it or above it provides would never mount, silently.\n for (const candidate of packages) {\n const plugin = 'declaration' in candidate ? candidate.plugin : candidate;\n const name = ('declaration' in candidate ? candidate.declaration.packageName : undefined) ?? plugin.name;\n if (this.installed.get(name)?.plugin !== plugin) continue;\n for (const contract of plugin.injects?.[this.level] ?? []) {\n // An inner level's contract is never visible here; defineServerPlugin refuses one, a raw plugin may not.\n const missing = depth(contract.scope) > depth(this.level) || this.resolve(contract) === undefined;\n if (missing)\n notice(\n `server package '${name}' waits for contract '${contract.name}', which no ${contract.scope} package provides.`,\n );\n }\n }\n return [...this.installed.keys()];\n }\n\n /** Applies a replaced package's previous build again after its new build failed; true when it runs. */\n private async restore(\n name: string,\n previous: InstalledPackage,\n options: PoServerInstallOptions,\n message: string,\n ): Promise<boolean> {\n try {\n const fiber = await this.apply(name, previous.plugin, previous.declaration, options);\n this.installed.set(name, { ...previous, fiber });\n this.notice(`${message}; its previous build is restored.`);\n return true;\n } catch (rollbackError) {\n this.notice(`${message}; its previous build could not be restored (${describe(rollbackError)}).`);\n return false;\n }\n }\n\n /** Applies one package as its own fiber, bounded by the factory timeout, and reports how it settled. */\n private async apply(\n name: string,\n plugin: PoServerPlugin,\n declaration: PoServerBundleEntry | undefined,\n options: PoServerInstallOptions,\n ): Promise<Fiber> {\n const startedAt = Date.now();\n const timeoutMs = options.factoryTimeoutMs ?? LIVE_FACTORY_TIMEOUT_MS;\n const settled = (outcome: PoServerPackageSettledReport['outcome']): void =>\n options.onPackageSettled?.({ packageName: name, durationMs: Date.now() - startedAt, outcome });\n let fiber: Fiber | undefined;\n let applySettled = false;\n try {\n const metadata: PoServiceBindingMetadata = {\n owner: { kind: 'package', packageName: name, origin: declaration?.origin ?? 'unknown' },\n contracts: Object.values(plugin.provides ?? {}).flat(),\n };\n const owner = this.root.extend({\n [PACKAGE_PROVENANCE]: metadata,\n ...(declaration ? { [PO_HEADLESS_OWNER]: declaration } : {}),\n });\n fiber = owner.plugin(plugin);\n const applied = fiber.await();\n const markSettled = (): void => {\n applySettled = true;\n };\n applied.then(markSettled, markSettled);\n await withTimeout(applied, timeoutMs, `server package '${name}' apply`);\n settled('installed');\n return fiber;\n } catch (error) {\n settled(fiber && !applySettled ? 'timed_out' : 'failed');\n if (fiber && !applySettled) {\n this.abandonedTimeoutMs = Math.max(this.abandonedTimeoutMs ?? 0, timeoutMs);\n void fiber\n .dispose()\n .catch((disposeError: unknown) =>\n this.notice(`abandoned server package '${name}' did not dispose (${describe(disposeError)})`),\n );\n } else if (fiber) await this.disposeFiber(name, fiber, timeoutMs);\n throw error;\n }\n }\n\n /**\n * Disposes one package's fiber within `timeoutMs`. A package whose cleanup throws or never settles\n * is reported and left behind, so it cannot block the packages after it or the scope's teardown.\n */\n private async disposeFiber(name: string, fiber: Fiber, timeoutMs: number): Promise<void> {\n try {\n await withTimeout(fiber.dispose(), timeoutMs, `server package '${name}' dispose`);\n } catch (error) {\n this.abandonedTimeoutMs = Math.max(this.abandonedTimeoutMs ?? 0, timeoutMs);\n this.notice(`server package '${name}' did not dispose (${describe(error)})`);\n }\n }\n\n private visible(): Binding[] {\n return [...(this.parent?.visible() ?? []), ...this.bound.values()];\n }\n\n /**\n * Logs, once per distinct tree, which scopes bind `name`, whose binding each root mirrors, and\n * which Cordis fiber actually holds the service in that root.\n */\n private reportGraph(name: string, error: unknown): void {\n const top = this.outermost();\n const graph = [...top.subtree()]\n .map((scope) => {\n const context = scope.router?.context as Partial<PoServerHostService['context']> | undefined;\n const cwd = context?.cwd ?? context?.workspaceRoot;\n const holds = [...scope.mirrors.keys()]\n .filter((binding) => binding.name === name)\n .map(({ owner }) => owner.label);\n const impl = scope.root.reflect._getImpl(name, false);\n const mirrored = impl && [...scope.mirrors].find(([, fiber]) => fiber === impl.fiber)?.[0];\n const cordis =\n impl === undefined\n ? 'none'\n : `<${impl.fiber.name}#${impl.fiber.uid}> state=${impl.fiber.state}${mirrored ? ` from ${mirrored.owner.label}` : ''}`;\n return `${' '.repeat(depth(scope.level))}${scope.label}${cwd ? ` ${cwd}` : ''} binds=${scope.bound.has(name) ? 'yes' : 'no'} mirrors=[${holds.join(', ')}] cordis=${cordis}`;\n })\n .join('\\n');\n if (top.reported.get(name) === graph) return;\n top.reported.set(name, graph);\n this.notice(`binding '${name}' from ${this.label} failed (${describe(error)}); scope tree:\\n${graph}`);\n }\n\n /** This scope, then each parent out to the root. */\n private outermost(): PoServerScope {\n return this.parent === undefined ? this : this.parent.outermost();\n }\n\n /** Disposes every value the tree still holds, newest first; a failure is reported and the rest still go. */\n private async disposeShares(): Promise<void> {\n const values = [...this.shares.values()].flatMap((store) => [...store.values.values()]).reverse();\n this.shares.clear();\n for (const shared of values) {\n try {\n await shared.disposeValue?.(await shared.value);\n } catch (error) {\n this.notice(`a shared server value did not dispose (${describe(error)})`);\n }\n }\n }\n\n private *ancestry(): Generator<PoServerScope> {\n yield this;\n if (this.parent !== undefined) yield* this.parent.ancestry();\n }\n\n private *subtree(): Generator<PoServerScope> {\n if (this.disposed) return;\n yield this;\n for (const child of this.children) yield* child.subtree();\n }\n\n /** The binding of `name` this root publishes: the one bound nearest to it. */\n private nearest(name: string): Binding | undefined {\n for (const scope of this.ancestry()) {\n const binding = scope.bound.get(name);\n if (binding !== undefined) return binding;\n }\n return undefined;\n }\n\n /**\n * Publishes a binding into this root and settles once it is live. Idempotent per binding, since a\n * child opening mid-bind is reached by both `open` and `bind`. A nearer level binding the same\n * name wins, as a level declaring an API itself does; Cordis holds one service per name in a root,\n * so the farther binding leaves first.\n */\n private async mirror(binding: Binding): Promise<void> {\n if (this.disposed || this.nearest(binding.name) !== binding) return;\n const replacing = this.replacing.get(binding);\n if (replacing !== undefined) {\n await replacing;\n return await this.mirror(binding);\n }\n let fiber = this.mirrors.get(binding);\n if (fiber === undefined) {\n const shadowed = [...this.mirrors.keys()].filter((other) => other.name === binding.name);\n if (shadowed.length > 0) {\n const cleared = Promise.all(shadowed.map((other) => this.unmirror(other))).finally(() =>\n this.replacing.delete(binding),\n );\n this.replacing.set(\n binding,\n cleared.then(\n () => undefined,\n () => undefined,\n ),\n );\n await cleared;\n return await this.mirror(binding);\n }\n fiber = this.root.plugin(bindingProvider, { binding, scope: this });\n this.mirrors.set(binding, fiber);\n }\n try {\n await fiber.await();\n } catch (error) {\n throw new Error(`${describe(error)} when ${binding.owner.label} published it into ${this.label}`, {\n cause: error,\n });\n }\n }\n\n private async unmirror(binding: Binding): Promise<void> {\n const fiber = this.mirrors.get(binding);\n this.mirrors.delete(binding);\n // A disposing root unwinds its own mirrors.\n if (!this.disposed) await fiber?.dispose();\n }\n}\n\n/** Every scope receives the event even when an earlier one's listener throws. */\nfunction deliver(scopes: readonly PoServerScope[], name: keyof Events, args: readonly unknown[]): void {\n const errors: unknown[] = [];\n for (const scope of scopes) {\n if (scope.disposed) continue;\n try {\n scope.root.events.emit(name, ...args);\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length > 0) throw new AggregateError(errors, `${errors.length} scope listener(s) of '${name}' failed.`);\n}\n"],"mappings":";;;;;;;;;;;;;AAiEA,IAAM,cAAN,MAAkB;CAChB,yBAAkB,IAAI,IAAyB;CAC/C,0BAAmB,IAAI,IAA4B;CAEnD,IAAI,OAAgB;EAClB,OAAO,KAAK,OAAO,SAAS,KAAK,KAAK,QAAQ,SAAS;CACzD;AACF;AAEA,MAAM,gBAAgB,QAAqC,KAAK,UAAU,OAAO,QAAQ,WAAW,CAAC,GAAG,IAAI,GAAG;AAoC/G,MAAM,SAAS,UAA8B,uBAAuB,QAAQ,KAAK;AAEjF,MAAM,YAAY,UAA4B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAEnG,MAAM,qBAAqB,OAAO,oBAAoB;AAEtD,IAAI,eAAe;AACnB,IAAI,aAAa;AACjB,MAAM,yBAAS,IAAI,QAAwB;;AAE3C,SAAS,QAAQ,OAAuB;CACtC,IAAI,QAAQ,OAAO,IAAI,KAAK;CAC5B,IAAI,UAAU,KAAA,GAAW,OAAO,IAAI,OAAQ,QAAQ,EAAE,UAAW;CACjE,OAAO,SAAS;AAClB;AACA,MAAM,UAAU,UAAsC;CACpD,MAAM,OAAQ,MAA6B;CAC3C,OAAO,OAAO,SAAS,WAAW,OAAO,KAAA;AAC3C;;AAGA,SAAS,gBAAgB,SAAkB,EAAE,SAAS,SAA2D;CAC/G,IAAI,QAAQ,SAAA,sBACV,IAAI,qBAAqB,SAAS,QAAQ,OAA2B,KAAK;MACvE,QAAQ,QAAQ,QAAQ,MAAM,QAAQ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Ae,QAAQ,GAAG,OAAO,OAAO,yBAAyB,KAAK,UAAU;AACnH"}
1
+ {"version":3,"file":"serverScope.mjs","names":["Context"],"sources":["../../../src/server/serverScope.ts"],"sourcesContent":["import { Context, type Events, type Fiber, Service } from '@deepseek-ai/cordis';\nimport { BACKGROUND_CONTEXT } from '@earendil-works/chord/context';\n\nimport {\n parsePoWebBrainMetadata,\n type BrainOwner,\n type BrainScope,\n type BrainServicesSnapshot,\n} from '../schemas/brain';\nimport { PO_GLOBAL_SERVICES_SERVICE, type PoGlobalServices } from '../schemas/globalServices';\nimport { PO_HEADLESS_OWNER, readPoHeadlessHost } from '../schemas/headless';\nimport { PO_HOST_SERVICE_CONTRACTS } from '../schemas/hostServiceContracts';\nimport type { PoApiHandler, PoApiScope } from '../schemas/packageApi';\nimport {\n PO_BROWSER_SERVICE,\n PO_ELECTRON_SERVICE,\n PO_FS_SERVICE,\n PO_ISOLATE_SERVICE,\n PO_NPM_SERVICE,\n PO_PROVIDER_AUTH_SERVICE,\n PO_SESSION_STORAGE_SERVICE,\n PO_SHELL_SERVICE,\n PO_SQLITE_SERVICE,\n type PoPlatform,\n} from '../schemas/platform';\nimport type { PoServerBundleEntry } from '../schemas/serverBundle';\nimport { PO_SERVER_HOST_SERVICE, type PoServerHostService, type PoServerPlugin } from '../schemas/serverPlugin';\nimport {\n PO_SERVER_SCOPE_LEVELS,\n projectServiceBindingMetadata,\n PO_SERVER_SCOPE_SERVICE,\n type PoServerPluginShare,\n type PoServerResourceKey,\n type PoServerResourceLease,\n type PoServerScopeService,\n type PoServiceContract,\n type PoServiceBindingMetadata,\n} from '../schemas/serverScope';\nimport { PO_SESSION_FILES_SERVICE, PO_SESSION_TEMP_DIR } from '../services/sessionFiles';\nimport { LIVE_FACTORY_TIMEOUT_MS, withTimeout } from './liveImport';\nimport type { LoadedServerPackage } from './serverPackages';\n\ninterface Binding {\n readonly name: string;\n readonly contract: PoServiceContract<unknown>;\n readonly metadata: PoServiceBindingMetadata;\n readonly value: unknown;\n /** The scope that bound it, named in logs. */\n readonly owner: PoServerScope;\n}\n\ninterface InstalledPackage {\n readonly plugin: PoServerPlugin;\n readonly declaration?: PoServerBundleEntry;\n readonly fiber: Fiber;\n}\n\n/** One shared value, how many levels hold it, and how its creator said to dispose it. */\ninterface SharedValue {\n readonly value: Promise<unknown>;\n holders: number;\n readonly disposeValue: ((value: unknown) => void | Promise<void>) | undefined;\n}\n\n/** What one plugin build shares in one tree: its keyed values, and what each scope running it holds. */\nclass PluginShare {\n readonly values = new Map<string, SharedValue>();\n readonly running = new Map<PoServerScope, unknown>();\n\n get idle(): boolean {\n return this.values.size === 0 && this.running.size === 0;\n }\n}\n\nconst resourceName = (key: PoServerResourceKey): string => JSON.stringify(typeof key === 'string' ? [key] : key);\n/** What a scope's owner publishes for the packages installed at its level. */\nexport interface PoServerScopeHost {\n /**\n * The level's mount table. A host that also routes requests (`createPoServerHost` does) answers\n * API requests for this level and every level below it that does not serve the API itself.\n */\n readonly host: PoServerHostService & { handlerFor?(basePath: string): PoApiHandler | undefined };\n /** Host capabilities published as `po/fs`, `po/shell`, `po/sqlite` and `po/session-storage`. */\n readonly platform: PoPlatform;\n}\n\nexport interface PoServerPackageSettledReport {\n readonly packageName: string;\n readonly durationMs: number;\n readonly outcome: 'installed' | 'failed' | 'timed_out';\n}\n\n/** A package whose build did not install, and what of it still runs. */\nexport interface PoServerPackageFailure {\n readonly packageName: string;\n readonly reason: string;\n /** `restored`: its previous build runs again; `lost`: that failed too; `none`: it had none. */\n readonly previous: 'restored' | 'lost' | 'none';\n}\n\nexport interface PoServerInstallOptions {\n readonly onNotice?: (message: string) => void;\n /** Bound on each package's `apply`; defaults to `LIVE_FACTORY_TIMEOUT_MS`. */\n readonly factoryTimeoutMs?: number;\n /** Reports how long each package's `apply` took and how it ended, for telemetry. */\n readonly onPackageSettled?: (report: PoServerPackageSettledReport) => void;\n /** Reports each package whose build did not install. */\n readonly onPackageFailed?: (failure: PoServerPackageFailure) => void;\n}\n\nconst depth = (level: PoApiScope): number => PO_SERVER_SCOPE_LEVELS.indexOf(level);\n\nconst describe = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\nconst PACKAGE_PROVENANCE = Symbol('package provenance');\n\nlet scopesOpened = 0;\nlet buildsSeen = 0;\nconst builds = new WeakMap<object, number>();\n/** A stable log label for one plugin build; a reload imports a new module, and so a new build. */\nfunction buildOf(owner: object): string {\n let build = builds.get(owner);\n if (build === undefined) builds.set(owner, (build = ++buildsSeen));\n return `build#${build}`;\n}\nconst nameOf = (owner: object): string | undefined => {\n const name = (owner as { name?: unknown }).name;\n return typeof name === 'string' ? name : undefined;\n};\n\n/** Publishes one binding as a native service of the root it is plugged into. */\nfunction bindingProvider(context: Context, { binding, scope }: { binding: Binding; scope: PoServerScope }): void {\n if (binding.name === PO_GLOBAL_SERVICES_SERVICE)\n new ScopedGlobalServices(context, binding.value as PoGlobalServices, scope);\n else context.provide(binding.name, binding.value);\n}\n\nclass ScopedGlobalServices extends Service<PoGlobalServices> implements PoGlobalServices {\n constructor(\n ctx: Context,\n private readonly registry: PoGlobalServices,\n private readonly scope: PoServerScope,\n ) {\n super(ctx, PO_GLOBAL_SERVICES_SERVICE);\n }\n\n register(\n owner: Parameters<PoGlobalServices['register']>[0],\n contribution: Parameters<PoGlobalServices['register']>[1],\n ) {\n return this.registry.register(owner, contribution, this.scope.provenance(this.ctx.fiber));\n }\n}\n\n/**\n * The scope service each root publishes.\n *\n * Cordis traceable services rebind `ctx` to the caller, so a binding made through\n * `provide` unwinds with the plugin that made it.\n */\nclass ScopeService extends Service<PoServerScopeService> implements PoServerScopeService {\n readonly level: PoApiScope;\n\n constructor(\n ctx: Context,\n private readonly scope: PoServerScope,\n ) {\n super(ctx, PO_SERVER_SCOPE_SERVICE);\n this.level = scope.level;\n }\n\n async provide<T>(contract: PoServiceContract<T>, value: T): Promise<() => Promise<void>> {\n return await this.ctx.effect(\n () => this.scope.bind(contract, value, this.scope.provenance(this.ctx.fiber)),\n `po scope provide ${contract.name}`,\n );\n }\n\n snapshot(): BrainServicesSnapshot {\n return this.scope.snapshot();\n }\n\n resolve<T>(contract: PoServiceContract<T>): T | undefined {\n return this.scope.resolve(contract);\n }\n\n emit<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void {\n this.scope.emit(name, ...args);\n }\n\n broadcast<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void {\n this.scope.broadcast(name, ...args);\n }\n\n plugin<TRoots>(owner: object): PoServerPluginShare<TRoots> {\n return this.scope.share<TRoots>(owner);\n }\n}\n\n/**\n * Binds registrations to the Cordis fiber that calls the host service.\n *\n * The host itself is shared by every package at its level, but Cordis traceable\n * services rebind `ctx` to the caller. That lets a package's registration unwind\n * even when `apply` throws before it can return its disposer.\n */\nclass ScopedPoServerHost extends Service<PoServerHostService> implements PoServerHostService {\n readonly scope: PoServerHostService['scope'];\n readonly context: PoServerHostService['context'];\n\n constructor(\n ctx: Context,\n private readonly host: PoServerHostService,\n ) {\n super(ctx, PO_SERVER_HOST_SERVICE);\n this.scope = host.scope;\n this.context = host.context;\n }\n\n registerApi(api: Parameters<PoServerHostService['registerApi']>[0]) {\n const headless = this.scope === 'session' ? readPoHeadlessHost(this.ctx) : undefined;\n if (headless) {\n const activity = headless.registerActivity({\n name: `api:${api.basePath}`,\n start: () => {\n const registration = this.host.registerApi(api);\n if (registration.mounted !== true) {\n registration.dispose();\n throw new Error(`package API '${api.basePath}' did not mount.`);\n }\n return () => {\n registration.dispose();\n };\n },\n });\n return {\n mounted: true,\n dispose: () => activity.dispose(),\n };\n }\n const registration = this.host.registerApi(api);\n if (registration.mounted !== true) {\n registration.dispose();\n throw new Error(`package API '${api.basePath}' did not mount.`);\n }\n this.ctx.effect(() => () => registration.dispose(), 'server package API registration');\n return registration;\n }\n\n registerChannel(channel: Parameters<PoServerHostService['registerChannel']>[0]) {\n const registration = this.host.registerChannel(channel);\n if (registration.mounted !== true) {\n registration.dispose();\n throw new Error(`hub channel '${channel.frameType}' did not mount.`);\n }\n this.ctx.effect(() => () => registration.dispose(), 'server package channel registration');\n return registration;\n }\n\n registerMethod: PoServerHostService['registerMethod'] = (definition, handler) => {\n const registration = this.host.registerMethod(definition, handler);\n if (registration.mounted !== true) {\n registration.dispose();\n throw new Error(`plugin method '${definition.service}.${definition.method}' did not mount.`);\n }\n this.ctx.effect(() => () => registration.dispose(), 'server package method registration');\n return registration;\n };\n\n mounted(): readonly string[] {\n return this.host.mounted();\n }\n\n mountedChannels(): readonly string[] {\n return this.host.mountedChannels();\n }\n}\n\n/** Publishes the host service from inside a root-level plugin, so it unwinds with the scope. */\nfunction serverHostProvider(context: Context, host: PoServerHostService): void {\n new ScopedPoServerHost(context, host);\n}\n\n/** Publishes the platform services from inside a root-level plugin, so they unwind with the scope. */\nfunction platformProvider(\n context: Context,\n input: { platform: PoPlatform; cwd: string; temporaryDirectory?: string },\n): void {\n const env = input.platform.env(input.cwd);\n context.provide(PO_FS_SERVICE, env);\n context.provide(PO_SHELL_SERVICE, env);\n context.provide(PO_SQLITE_SERVICE, input.platform.sqlite);\n context.provide(PO_SESSION_STORAGE_SERVICE, input.platform.sessions);\n if (input.platform.isolate !== undefined) context.provide(PO_ISOLATE_SERVICE, input.platform.isolate);\n if (input.platform.npm !== undefined) context.provide(PO_NPM_SERVICE, input.platform.npm);\n if (input.platform.electron !== undefined) context.provide(PO_ELECTRON_SERVICE, input.platform.electron);\n if (input.platform.browser !== undefined) context.provide(PO_BROWSER_SERVICE, input.platform.browser);\n if (input.platform.providerAuth !== undefined) context.provide(PO_PROVIDER_AUTH_SERVICE, input.platform.providerAuth);\n if (input.temporaryDirectory !== undefined)\n context.provide(PO_SESSION_FILES_SERVICE, { temporaryDirectory: input.temporaryDirectory });\n context.effect(() => () => env.cleanup(BACKGROUND_CONTEXT), 'platform execution env');\n}\n\n/**\n * One level of the server IoC tree: its own cordis root, a parent link, the contracts bound here,\n * and the packages installed here.\n *\n * Separate roots rather than one shared root, because cordis re-checks every fiber of a root on each\n * service change; a hundred sessions in one root would make every change scan all of them. A binding\n * is instead mirrored into each descendant root as a native service, so a plugin injects an outer\n * level's service exactly as it injects its own.\n */\nexport class PoServerScope {\n readonly root = new Context();\n private readonly children = new Set<PoServerScope>();\n private readonly bound = new Map<string, Binding>();\n private readonly mirrors = new Map<Binding, Fiber>();\n /** A binding waiting here for the farther one it shadows to leave, so a repeat mirror waits too. */\n private readonly replacing = new Map<Binding, Promise<void>>();\n private readonly hostFibers = new Set<Fiber>();\n private readonly installed = new Map<string, InstalledPackage>();\n private installs: Promise<void> = Promise.resolve();\n /** Set once a package's apply never settled, to the bound it overran; its fiber may never finish disposing. */\n private abandonedTimeoutMs: number | undefined;\n private notice: (message: string) => void = () => undefined;\n private disposing: Promise<void> | undefined;\n /** The served mount table, read when a request routes through this level. */\n private router: PoServerScopeHost['host'] | undefined;\n /** Kept by the outermost scope only: what each plugin build shares across the whole tree. */\n private readonly shares = new Map<object, PluginShare>();\n /** Names this scope in logs, as its level and the order it opened in. */\n readonly label: string;\n /** The last graph logged for a failing binding, by name, so a retry that fails the same way stays quiet. */\n private readonly reported = new Map<string, string>();\n\n private constructor(\n readonly level: PoApiScope,\n readonly parent: PoServerScope | undefined,\n ) {\n this.label = `${level}#${++scopesOpened}`;\n }\n\n /** Opens a scope below `parent`, with every binding visible from its ancestors already published. */\n static async open(level: PoApiScope, parent?: PoServerScope): Promise<PoServerScope> {\n if (parent?.disposing !== undefined) throw new Error(`The ${parent.level} scope is disposed.`);\n if (parent !== undefined && depth(level) <= depth(parent.level))\n throw new Error(`A ${level} scope cannot open below a ${parent.level} scope.`);\n const scope = new PoServerScope(level, parent);\n parent?.children.add(scope);\n try {\n await scope.root.plugin(ScopeService, scope);\n await Promise.all((parent?.visible() ?? []).map((binding) => scope.mirror(binding)));\n } catch (error) {\n await scope.dispose();\n throw error;\n }\n return scope;\n }\n\n get disposed(): boolean {\n return this.disposing !== undefined;\n }\n\n /**\n * Publishes what every package at this level reads: the owner's mount table as `po/server-host`,\n * and the platform services. They stay for the life of the scope; the owner still disposes the\n * mount table it handed in.\n */\n async serve(input: PoServerScopeHost): Promise<void> {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n if (input.host.scope !== this.level)\n throw new Error(`A ${input.host.scope} host cannot serve a ${this.level} scope.`);\n this.hostFibers.add(await this.root.plugin(serverHostProvider, input.host));\n this.router = input.host;\n // Published callers may hand a host without context (the packed authoring check does), so read it defensively.\n const hostContext = input.host.context as Partial<PoServerHostService['context']> | undefined;\n const cwd = hostContext?.cwd ?? hostContext?.workspaceRoot ?? input.platform.homeDirectory;\n this.hostFibers.add(\n await this.root.plugin(platformProvider, {\n platform: input.platform,\n cwd,\n temporaryDirectory: this.level === 'session' ? hostContext?.environment?.[PO_SESSION_TEMP_DIR] : undefined,\n }),\n );\n }\n\n /**\n * Installs packages at this level, each as its own fiber in this root, one at a time.\n *\n * Installation only adds. A package installed from the same build (the same plugin object) is\n * skipped. One whose build changed is disposed and the new build applied; when that fails, the\n * previous build is applied again. A package missing from `packages` stays installed, because\n * which packages a session runs is its own composition's choice. Installs into one scope run one\n * at a time. Resolves with every package installed here, in install order.\n */\n install(\n packages: readonly (PoServerPlugin | LoadedServerPackage)[],\n options: PoServerInstallOptions = {},\n ): Promise<readonly string[]> {\n const run = this.installs.then(() => this.installAll(packages, options));\n this.installs = run.then(\n () => undefined,\n () => undefined,\n );\n return run;\n }\n\n /**\n * Disposes the named packages installed here, in reverse install order, each bounded by the\n * cleanup time limit. Runs in order with installs. Resolves with every package still installed.\n */\n uninstall(names: readonly string[]): Promise<readonly string[]> {\n const run = this.installs.then(async () => {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n for (const [name, { fiber }] of [...this.installed].reverse()) {\n if (!names.includes(name)) continue;\n this.installed.delete(name);\n await this.disposeFiber(name, fiber, LIVE_FACTORY_TIMEOUT_MS);\n }\n return [...this.installed.keys()];\n });\n this.installs = run.then(\n () => undefined,\n () => undefined,\n );\n return run;\n }\n\n /**\n * Binds a contract owned by this level here and in every descendant, including ones opened later.\n * Settles once every descendant root publishes it, or a nearer binding of the same name shadows it\n * there. Hosts call this directly; plugins go through the scope service so the binding follows\n * their fiber.\n */\n async bind<T>(\n contract: PoServiceContract<T>,\n value: T,\n metadata: PoServiceBindingMetadata = {\n owner: { kind: 'host', packageName: null, origin: 'unknown' },\n contracts: [],\n },\n ): Promise<() => Promise<void>> {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n if (contract.scope !== this.level)\n throw new Error(\n `Contract '${contract.name}' belongs to the ${contract.scope} scope and cannot be provided from the ${this.level} scope.`,\n );\n if (this.bound.has(contract.name))\n throw new Error(`Contract '${contract.name}' is already provided in this ${this.level} scope.`);\n const binding: Binding = {\n name: contract.name,\n contract,\n metadata: projectServiceBindingMetadata(metadata),\n value,\n owner: this,\n };\n this.bound.set(contract.name, binding);\n const withdraw = async (): Promise<void> => {\n if (this.bound.get(contract.name) !== binding) return;\n this.bound.delete(contract.name);\n await Promise.all(\n [...this.subtree()].map(async (scope) => {\n await scope.unmirror(binding);\n // A farther binding this one shadowed shows through again.\n const outer = scope.nearest(contract.name);\n if (outer === undefined) return;\n await scope.mirror(outer).catch((error: unknown) => {\n this.notice(\n `binding '${contract.name}' from ${outer.owner.label} did not return to ${scope.label} (${describe(error)})`,\n );\n });\n }),\n );\n };\n try {\n await Promise.all([...this.subtree()].map((scope) => scope.mirror(binding)));\n } catch (error) {\n this.reportGraph(contract.name, error);\n await withdraw();\n throw error;\n }\n return withdraw;\n }\n\n /** Finds only the installed package that owns this fiber, including nested service fibers. */\n provenance(fiber: Fiber): PoServiceBindingMetadata {\n const declared = (fiber.ctx as Context & { [PACKAGE_PROVENANCE]?: PoServiceBindingMetadata })[PACKAGE_PROVENANCE];\n if (declared) return declared;\n for (;;) {\n for (const [name, entry] of this.installed) {\n if (entry.fiber.uid !== fiber.uid) continue;\n return {\n owner: { kind: 'package', packageName: name, origin: entry.declaration?.origin ?? 'unknown' },\n contracts: Object.values(entry.plugin.provides ?? {}).flat(),\n };\n }\n if (fiber.parent.fiber === fiber) break;\n fiber = fiber.parent.fiber;\n }\n return { owner: { kind: 'unknown', packageName: null, origin: 'unknown' }, contracts: [] };\n }\n\n snapshot(): BrainServicesSnapshot {\n const scopes = [...this.ancestry()];\n const describeScope = (scope: PoServerScope): BrainScope => ({ id: scope.label, level: scope.level });\n const result: BrainServicesSnapshot = {\n scope: describeScope(this),\n scopes: scopes.map(describeScope),\n packages: [],\n services: [],\n consumers: [],\n edges: [],\n diagnostics: [],\n };\n const clientInventories = scopes.map((scope) => scope.router?.context?.clientPlugins);\n if (clientInventories.every((inventory) => inventory?.available)) {\n result.clientPackages = clientInventories.flatMap((inventory, index) =>\n inventory!.packages.map((pkg) => ({\n scope: describeScope(scopes[index]!),\n owner: { kind: pkg.owner.kind, packageName: pkg.owner.packageName, origin: pkg.owner.origin },\n web: parsePoWebBrainMetadata(pkg.web) ?? null,\n })),\n );\n }\n for (const scope of scopes) {\n for (const [name, entry] of scope.installed) {\n const owner: BrainOwner = {\n kind: 'package',\n packageName: name,\n origin: entry.declaration?.origin ?? 'unknown',\n };\n result.packages.push({\n scope: describeScope(scope),\n owner,\n web: entry.declaration?.webMetadata ?? null,\n native: entry.declaration?.nativeMetadata ?? null,\n });\n const consumer = `${scope.label}:consumer:${name}`;\n result.consumers.push({ id: consumer, name, scope: describeScope(scope), owner });\n const injections = new Set([\n ...Object.keys(entry.fiber.inject),\n ...(entry.plugin.injects?.[scope.level] ?? []).map((contract) => contract.name),\n ]);\n for (const name of injections) result.edges.push({ consumer, name, service: null, status: 'waiting' });\n }\n for (const runtime of scope.root.registry.values()) {\n for (const fiber of runtime.fibers) {\n if ([...scope.installed.values()].some((entry) => entry.fiber.uid === fiber.uid)) continue;\n const names = Object.keys(fiber.inject);\n if (!names.length) continue;\n const consumer = `${scope.label}:consumer:fiber:${fiber.uid}`;\n result.consumers.push({\n id: consumer,\n name: `fiber#${fiber.uid}`,\n scope: describeScope(scope),\n owner: scope.provenance(fiber).owner,\n });\n for (const name of names) result.edges.push({ consumer, name, service: null, status: 'waiting' });\n }\n }\n for (const key of Reflect.ownKeys(scope.root.reflect.store)) {\n const impl = scope.root.reflect.store[key as symbol];\n const mirror = [...scope.mirrors].find(([, fiber]) => fiber.uid === impl.fiber.uid)?.[0];\n // Mirrors describe their original implementation once, at its owning scope.\n if (mirror && mirror.owner !== scope) continue;\n const metadata = mirror?.metadata ?? scope.provenance(impl.fiber);\n const host =\n (metadata.owner.kind === 'host' ||\n [...scope.hostFibers].some((fiber) => fiber.uid === impl.fiber.uid) ||\n impl.fiber === scope.root.fiber) &&\n PO_HOST_SERVICE_CONTRACTS.find((contract) => contract.name === impl.name);\n const contract = metadata.contracts.find(\n (contract) => contract.name === impl.name && contract.scope === scope.level,\n );\n result.services.push({\n id: `${scope.label}:service:${impl.name}`,\n name: impl.name,\n scope: describeScope(scope),\n visibleFrom: describeScope(scope),\n owner: host ? { kind: 'host', packageName: null, origin: 'unknown' } : metadata.owner,\n public: !!contract || !!host,\n description: contract?.description ?? mirror?.contract.description ?? (host ? host.description : null),\n });\n }\n }\n for (const service of result.services) {\n const ownerIndex = scopes.findIndex((scope) => scope.label === service.scope.id);\n const shadowIndex = scopes.findLastIndex(\n (scope, index) =>\n index < ownerIndex &&\n result.services.some((other) => other.scope.id === scope.label && other.name === service.name),\n );\n service.visibleFrom = describeScope(scopes[shadowIndex + 1]);\n }\n for (const edge of result.edges) {\n const consumer = result.consumers.find((consumer) => consumer.id === edge.consumer)!;\n const start = scopes.findIndex((scope) => scope.label === consumer.scope.id);\n const service = scopes\n .slice(start)\n .flatMap((scope) =>\n result.services.filter((service) => service.scope.id === scope.label && service.name === edge.name),\n )[0];\n if (service) {\n edge.service = service.id;\n edge.status = 'resolved';\n }\n }\n return structuredClone(result);\n }\n\n resolve<T>(contract: PoServiceContract<T>): T | undefined {\n if (depth(contract.scope) > depth(this.level))\n throw new Error(`A ${this.level} scope cannot see the ${contract.scope} contract '${contract.name}'.`);\n for (const scope of this.ancestry()) {\n if (scope.level === contract.scope) return scope.bound.get(contract.name)?.value as T | undefined;\n }\n return undefined;\n }\n\n /**\n * The handler for an API, from this level or the nearest one above it that serves it. An API\n * declared at a level reaches every level below it, and a level that runs a package from an outer\n * level leaves that level's root-bound APIs to it; a level that declares the API itself wins.\n */\n apiHandler(basePath: string): PoApiHandler | undefined {\n for (const scope of this.ancestry()) {\n const handler = scope.router?.handlerFor?.(basePath);\n if (handler !== undefined) return handler;\n }\n return undefined;\n }\n\n /** Resolve only the nearest mounted API's parsed contract, never a caller supplied operation. */\n apiOperation(basePath: string, method: string, path: string): string | undefined {\n for (const scope of this.ancestry()) {\n if (!scope.router?.handlerFor?.(basePath)) continue;\n for (const { declaration } of scope.installed.values()) {\n const route = declaration?.apiContract?.http.find(\n (route) =>\n route.scope === scope.level &&\n route.basePath === basePath &&\n route.method === method &&\n route.path.split('/').length === path.split('/').length &&\n route.path\n .split('/')\n .every((part, index) =>\n part.startsWith(':') ? !!path.split('/')[index] : part === path.split('/')[index],\n ),\n );\n if (route) return route.id;\n }\n return undefined;\n }\n return undefined;\n }\n\n emit<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void {\n deliver([...this.ancestry()], name, args);\n }\n\n broadcast<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void {\n deliver([...this.subtree()], name, args);\n }\n\n /**\n * Disposes descendants first, then the packages installed here in reverse install order, then\n * this root; a binding made here unwinds with its provider.\n */\n dispose(): Promise<void> {\n this.disposing ??= (async () => {\n await Promise.all([...this.children].map((child) => child.dispose()));\n this.parent?.children.delete(this);\n this.mirrors.clear();\n this.router = undefined;\n const packages = [...this.installed.values()].reverse();\n this.installed.clear();\n for (const { plugin, declaration, fiber } of packages)\n await this.disposeFiber(declaration?.packageName ?? plugin.name, fiber, LIVE_FACTORY_TIMEOUT_MS);\n const disposal = this.root.fiber.dispose();\n if (this.abandonedTimeoutMs === undefined) return await disposal;\n // An abandoned apply holds its fiber open, so teardown is bounded rather than left to hang.\n await withTimeout(disposal, this.abandonedTimeoutMs, `${this.level} scope dispose`).catch((error: unknown) =>\n this.notice(describe(error)),\n );\n })().finally(async () => {\n // What a level never released, such as a value an abandoned apply held, goes with the tree.\n if (this.parent === undefined) await this.disposeShares();\n });\n return this.disposing;\n }\n\n /**\n * What the plugin build `owner` shares in this tree, seen from this scope. The outermost scope keeps\n * one store per build, so every level of one hub sees the same values and no two hubs ever do.\n */\n share<TRoots>(owner: object): PoServerPluginShare<TRoots> {\n const top = this.outermost();\n const name = nameOf(owner);\n const build = buildOf(owner);\n for (const scope of this.parent?.ancestry() ?? [])\n for (const [other, store] of top.shares)\n if (other !== owner && name !== undefined && nameOf(other) === name && store.running.has(scope))\n this.notice(\n `${this.label} mounts ${build} of '${name}' while ${scope.label} runs ${buildOf(other)}, so it builds that build's roots itself.`,\n );\n const storeOf = (): PluginShare => {\n let store = top.shares.get(owner);\n if (store === undefined) {\n store = new PluginShare();\n top.shares.set(owner, store);\n }\n return store;\n };\n // An idle store is dropped, so builds a reload replaced do not accumulate.\n const settle = (store: PluginShare): void => {\n if (store.idle && top.shares.get(owner) === store) top.shares.delete(owner);\n };\n return {\n acquire: async <T>(\n key: PoServerResourceKey,\n create: () => T | Promise<T>,\n dispose?: (value: T) => void | Promise<void>,\n ): Promise<PoServerResourceLease<T>> => {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n const store = storeOf();\n const name = resourceName(key);\n let shared = store.values.get(name);\n if (shared === undefined) {\n const created: SharedValue = {\n value: Promise.resolve().then(create),\n holders: 0,\n disposeValue: dispose === undefined ? undefined : (value) => dispose(value as T),\n };\n store.values.set(name, created);\n // A value that could not be created is not kept, so the next acquire creates it again.\n created.value.catch(() => {\n if (store.values.get(name) === created) store.values.delete(name);\n settle(store);\n });\n shared = created;\n }\n const held = shared;\n held.holders += 1;\n let value: unknown;\n try {\n value = await held.value;\n } catch (error) {\n held.holders -= 1;\n throw error;\n }\n let released = false;\n return {\n value: value as T,\n release: async () => {\n if (released) return;\n released = true;\n held.holders -= 1;\n if (held.holders > 0 || store.values.get(name) !== held) return;\n store.values.delete(name);\n settle(store);\n await held.disposeValue?.(value);\n },\n };\n },\n run: (roots) => {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n const store = storeOf();\n store.running.set(this, roots);\n return () => {\n if (store.running.get(this) === roots) store.running.delete(this);\n settle(store);\n };\n },\n outer: (from) => {\n const store = top.shares.get(owner);\n if (store === undefined) return [];\n const held: TRoots[] = [];\n for (const scope of this.parent?.ancestry() ?? []) {\n if (depth(scope.level) >= depth(from) && store.running.has(scope))\n held.push(store.running.get(scope) as TRoots);\n }\n return held;\n },\n };\n }\n\n private async installAll(\n packages: readonly (PoServerPlugin | LoadedServerPackage)[],\n options: PoServerInstallOptions,\n ): Promise<readonly string[]> {\n if (this.disposed) throw new Error(`The ${this.level} scope is disposed.`);\n const notice = options.onNotice ?? ((): void => {});\n this.notice = notice;\n if (\n packages.some((candidate) => 'retained' in candidate && candidate.retained === true) &&\n !readPoHeadlessHost(this.root)\n )\n throw new Error('Retained server candidates require a gated headless host');\n for (const candidate of packages) {\n const plugin = 'declaration' in candidate ? candidate.plugin : candidate;\n const declaration = 'declaration' in candidate ? candidate.declaration : undefined;\n const name = declaration?.packageName ?? plugin.name;\n const previous = this.installed.get(name);\n if (previous?.plugin === plugin) continue;\n if (previous !== undefined) {\n this.installed.delete(name);\n await this.disposeFiber(name, previous.fiber, options.factoryTimeoutMs ?? LIVE_FACTORY_TIMEOUT_MS);\n }\n try {\n const fiber = await this.apply(name, plugin, declaration, options);\n this.installed.set(name, { plugin, ...(declaration === undefined ? {} : { declaration }), fiber });\n } catch (error) {\n const message = `server package '${name}' did not install (${describe(error)})`;\n if (previous !== undefined) {\n const restored = await this.restore(name, previous, options, message);\n options.onPackageFailed?.({\n packageName: name,\n reason: describe(error),\n previous: restored ? 'restored' : 'lost',\n });\n continue;\n }\n options.onPackageFailed?.({ packageName: name, reason: describe(error), previous: 'none' });\n if (\n declaration?.required === true &&\n !('initiallyEligible' in candidate && candidate.initiallyEligible === false)\n )\n throw new Error(message, { cause: error });\n notice(message);\n }\n }\n // A level waiting for a contract that nothing at it or above it provides would never mount, silently.\n for (const candidate of packages) {\n const plugin = 'declaration' in candidate ? candidate.plugin : candidate;\n const name = ('declaration' in candidate ? candidate.declaration.packageName : undefined) ?? plugin.name;\n if (this.installed.get(name)?.plugin !== plugin) continue;\n for (const contract of plugin.injects?.[this.level] ?? []) {\n // An inner level's contract is never visible here; defineServerPlugin refuses one, a raw plugin may not.\n const missing = depth(contract.scope) > depth(this.level) || this.resolve(contract) === undefined;\n if (missing)\n notice(\n `server package '${name}' waits for contract '${contract.name}', which no ${contract.scope} package provides.`,\n );\n }\n }\n return [...this.installed.keys()];\n }\n\n /** Applies a replaced package's previous build again after its new build failed; true when it runs. */\n private async restore(\n name: string,\n previous: InstalledPackage,\n options: PoServerInstallOptions,\n message: string,\n ): Promise<boolean> {\n try {\n const fiber = await this.apply(name, previous.plugin, previous.declaration, options);\n this.installed.set(name, { ...previous, fiber });\n this.notice(`${message}; its previous build is restored.`);\n return true;\n } catch (rollbackError) {\n this.notice(`${message}; its previous build could not be restored (${describe(rollbackError)}).`);\n return false;\n }\n }\n\n /** Applies one package as its own fiber, bounded by the factory timeout, and reports how it settled. */\n private async apply(\n name: string,\n plugin: PoServerPlugin,\n declaration: PoServerBundleEntry | undefined,\n options: PoServerInstallOptions,\n ): Promise<Fiber> {\n const startedAt = Date.now();\n const timeoutMs = options.factoryTimeoutMs ?? LIVE_FACTORY_TIMEOUT_MS;\n const settled = (outcome: PoServerPackageSettledReport['outcome']): void =>\n options.onPackageSettled?.({ packageName: name, durationMs: Date.now() - startedAt, outcome });\n let fiber: Fiber | undefined;\n let applySettled = false;\n try {\n const metadata: PoServiceBindingMetadata = {\n owner: { kind: 'package', packageName: name, origin: declaration?.origin ?? 'unknown' },\n contracts: Object.values(plugin.provides ?? {}).flat(),\n };\n const owner = this.root.extend({\n [PACKAGE_PROVENANCE]: metadata,\n ...(declaration ? { [PO_HEADLESS_OWNER]: declaration } : {}),\n });\n fiber = owner.plugin(plugin);\n const applied = fiber.await();\n const markSettled = (): void => {\n applySettled = true;\n };\n applied.then(markSettled, markSettled);\n await withTimeout(applied, timeoutMs, `server package '${name}' apply`);\n settled('installed');\n return fiber;\n } catch (error) {\n settled(fiber && !applySettled ? 'timed_out' : 'failed');\n if (fiber && !applySettled) {\n this.abandonedTimeoutMs = Math.max(this.abandonedTimeoutMs ?? 0, timeoutMs);\n void fiber\n .dispose()\n .catch((disposeError: unknown) =>\n this.notice(`abandoned server package '${name}' did not dispose (${describe(disposeError)})`),\n );\n } else if (fiber) await this.disposeFiber(name, fiber, timeoutMs);\n throw error;\n }\n }\n\n /**\n * Disposes one package's fiber within `timeoutMs`. A package whose cleanup throws or never settles\n * is reported and left behind, so it cannot block the packages after it or the scope's teardown.\n */\n private async disposeFiber(name: string, fiber: Fiber, timeoutMs: number): Promise<void> {\n try {\n await withTimeout(fiber.dispose(), timeoutMs, `server package '${name}' dispose`);\n } catch (error) {\n this.abandonedTimeoutMs = Math.max(this.abandonedTimeoutMs ?? 0, timeoutMs);\n this.notice(`server package '${name}' did not dispose (${describe(error)})`);\n }\n }\n\n private visible(): Binding[] {\n return [...(this.parent?.visible() ?? []), ...this.bound.values()];\n }\n\n /**\n * Logs, once per distinct tree, which scopes bind `name`, whose binding each root mirrors, and\n * which Cordis fiber actually holds the service in that root.\n */\n private reportGraph(name: string, error: unknown): void {\n const top = this.outermost();\n const graph = [...top.subtree()]\n .map((scope) => {\n const context = scope.router?.context as Partial<PoServerHostService['context']> | undefined;\n const cwd = context?.cwd ?? context?.workspaceRoot;\n const holds = [...scope.mirrors.keys()]\n .filter((binding) => binding.name === name)\n .map(({ owner }) => owner.label);\n const impl = scope.root.reflect._getImpl(name, false);\n const mirrored = impl && [...scope.mirrors].find(([, fiber]) => fiber === impl.fiber)?.[0];\n const cordis =\n impl === undefined\n ? 'none'\n : `<${impl.fiber.name}#${impl.fiber.uid}> state=${impl.fiber.state}${mirrored ? ` from ${mirrored.owner.label}` : ''}`;\n return `${' '.repeat(depth(scope.level))}${scope.label}${cwd ? ` ${cwd}` : ''} binds=${scope.bound.has(name) ? 'yes' : 'no'} mirrors=[${holds.join(', ')}] cordis=${cordis}`;\n })\n .join('\\n');\n if (top.reported.get(name) === graph) return;\n top.reported.set(name, graph);\n this.notice(`binding '${name}' from ${this.label} failed (${describe(error)}); scope tree:\\n${graph}`);\n }\n\n /** This scope, then each parent out to the root. */\n private outermost(): PoServerScope {\n return this.parent === undefined ? this : this.parent.outermost();\n }\n\n /** Disposes every value the tree still holds, newest first; a failure is reported and the rest still go. */\n private async disposeShares(): Promise<void> {\n const values = [...this.shares.values()].flatMap((store) => [...store.values.values()]).reverse();\n this.shares.clear();\n for (const shared of values) {\n try {\n await shared.disposeValue?.(await shared.value);\n } catch (error) {\n this.notice(`a shared server value did not dispose (${describe(error)})`);\n }\n }\n }\n\n private *ancestry(): Generator<PoServerScope> {\n yield this;\n if (this.parent !== undefined) yield* this.parent.ancestry();\n }\n\n private *subtree(): Generator<PoServerScope> {\n if (this.disposed) return;\n yield this;\n for (const child of this.children) yield* child.subtree();\n }\n\n /** The binding of `name` this root publishes: the one bound nearest to it. */\n private nearest(name: string): Binding | undefined {\n for (const scope of this.ancestry()) {\n const binding = scope.bound.get(name);\n if (binding !== undefined) return binding;\n }\n return undefined;\n }\n\n /**\n * Publishes a binding into this root and settles once it is live. Idempotent per binding, since a\n * child opening mid-bind is reached by both `open` and `bind`. A nearer level binding the same\n * name wins, as a level declaring an API itself does; Cordis holds one service per name in a root,\n * so the farther binding leaves first.\n */\n private async mirror(binding: Binding): Promise<void> {\n if (this.disposed || this.nearest(binding.name) !== binding) return;\n const replacing = this.replacing.get(binding);\n if (replacing !== undefined) {\n await replacing;\n return await this.mirror(binding);\n }\n let fiber = this.mirrors.get(binding);\n if (fiber === undefined) {\n const shadowed = [...this.mirrors.keys()].filter((other) => other.name === binding.name);\n if (shadowed.length > 0) {\n const cleared = Promise.all(shadowed.map((other) => this.unmirror(other))).finally(() =>\n this.replacing.delete(binding),\n );\n this.replacing.set(\n binding,\n cleared.then(\n () => undefined,\n () => undefined,\n ),\n );\n await cleared;\n return await this.mirror(binding);\n }\n fiber = this.root.plugin(bindingProvider, { binding, scope: this });\n this.mirrors.set(binding, fiber);\n }\n try {\n await fiber.await();\n } catch (error) {\n throw new Error(`${describe(error)} when ${binding.owner.label} published it into ${this.label}`, {\n cause: error,\n });\n }\n }\n\n private async unmirror(binding: Binding): Promise<void> {\n const fiber = this.mirrors.get(binding);\n this.mirrors.delete(binding);\n // A disposing root unwinds its own mirrors.\n if (!this.disposed) await fiber?.dispose();\n }\n}\n\n/** Every scope receives the event even when an earlier one's listener throws. */\nfunction deliver(scopes: readonly PoServerScope[], name: keyof Events, args: readonly unknown[]): void {\n const errors: unknown[] = [];\n for (const scope of scopes) {\n if (scope.disposed) continue;\n try {\n scope.root.events.emit(name, ...args);\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length > 0) throw new AggregateError(errors, `${errors.length} scope listener(s) of '${name}' failed.`);\n}\n"],"mappings":";;;;;;;;;;;;;AAiEA,IAAM,cAAN,MAAkB;CAChB,yBAAkB,IAAI,IAAyB;CAC/C,0BAAmB,IAAI,IAA4B;CAEnD,IAAI,OAAgB;EAClB,OAAO,KAAK,OAAO,SAAS,KAAK,KAAK,QAAQ,SAAS;CACzD;AACF;AAEA,MAAM,gBAAgB,QAAqC,KAAK,UAAU,OAAO,QAAQ,WAAW,CAAC,GAAG,IAAI,GAAG;AAoC/G,MAAM,SAAS,UAA8B,uBAAuB,QAAQ,KAAK;AAEjF,MAAM,YAAY,UAA4B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAEnG,MAAM,qBAAqB,OAAO,oBAAoB;AAEtD,IAAI,eAAe;AACnB,IAAI,aAAa;AACjB,MAAM,yBAA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G,OAAO,MACT,CAAC;EACH;CACF;CAEA,MAAc,SAAS,SAAiC;EACtD,MAAM,QAAQ,KAAK,QAAQ,IAAI,OAAO;EACtC,KAAK,QAAQ,OAAO,OAAO;EAE3B,IAAI,CAAC,KAAK,UAAU,MAAM,OAAO,QAAQ;CAC3C;AACF;;AAGA,SAAS,QAAQ,QAAkC,MAAoB,MAAgC;CACrG,MAAM,SAAoB,CAAC;CAC3B,KAAK,MAAM,SAAS,QAAQ;EAC1B,IAAI,MAAM,UAAU;EACpB,IAAI;GACF,MAAM,KAAK,OAAO,KAAK,MAAM,GAAG,IAAI;EACtC,SAAS,OAAO;GACd,OAAO,KAAK,KAAK;EACnB;CACF;CACA,IAAI,OAAO,SAAS,GAAG,MAAM,IAAI,eAAe,QAAQ,GAAG,OAAO,OAAO,yBAAyB,KAAK,UAAU;AACnH"}
@@ -57,6 +57,13 @@ const HOST_SLOT_METADATA = {
57
57
  description: "Session activity panels, with explicit child slots for activity groups.",
58
58
  kind: "component"
59
59
  },
60
+ activityPromo: {
61
+ slot: "activity-promo",
62
+ scope: "global",
63
+ description: "Compact actions inside the activity promo card, such as Explore.",
64
+ parent: "activity",
65
+ kind: "component"
66
+ },
60
67
  composerActions: {
61
68
  slot: "composer-actions",
62
69
  scope: "global",
@@ -1 +1 @@
1
- {"version":3,"file":"hostSlots.cjs","names":[],"sources":["../../../src/web/hostSlots.ts"],"sourcesContent":["import type { PoApiScope } from '../schemas/packageApi';\n\n/** Host-owned declarations are visible throughout the client scope tree. */\nexport const HOST_SLOT_METADATA = {\n home: { slot: 'home', scope: 'global', description: 'Typed Home content and launch contributions.', kind: 'data' },\n homeApps: {\n slot: 'home-apps',\n scope: 'global',\n description: 'Plugin cards on Home. Set data.column to side for the narrow column.',\n parent: 'home',\n kind: 'component',\n },\n dashboardTiles: {\n slot: 'dashboard-tiles',\n scope: 'global',\n description: 'Host-framed body-only tiles on Home and workspace dashboards.',\n kind: 'component',\n },\n homeAttention: {\n slot: 'home-attention',\n scope: 'global',\n description: 'Plugin-framed Home cards for things waiting on the person.',\n parent: 'home',\n kind: 'component',\n },\n overlay: {\n slot: 'overlay',\n scope: 'global',\n description: 'Overlays above the cockpit, such as a microphone dialog.',\n kind: 'component',\n },\n rail: { slot: 'rail', scope: 'global', description: 'Navigation items in the cockpit rail.', kind: 'component' },\n context: {\n slot: 'context',\n scope: 'global',\n description: 'Context panels beside the session conversation.',\n kind: 'component',\n },\n selectionBar: {\n slot: 'selection-bar',\n scope: 'global',\n description: 'Actions for the current text selection.',\n kind: 'component',\n },\n activity: {\n slot: 'activity',\n scope: 'global',\n description: 'Session activity panels, with explicit child slots for activity groups.',\n kind: 'component',\n },\n composerActions: {\n slot: 'composer-actions',\n scope: 'global',\n description: 'Action controls beside the session composer.',\n kind: 'component',\n },\n composerMenu: {\n slot: 'composer-menu',\n scope: 'global',\n description: 'Items in the session composer menu.',\n kind: 'component',\n },\n dialogPrompt: {\n slot: 'dialog-prompt',\n scope: 'global',\n description: 'Typed data fills that claim a dialog independently of a tool card.',\n kind: 'data',\n },\n sessionMenu: { slot: 'session-menu', scope: 'global', description: 'Items in the session menu.', kind: 'component' },\n newSession: {\n slot: 'new-session',\n scope: 'global',\n description: 'A workspace fill replacing the host new-session dialog.',\n kind: 'component',\n },\n page: {\n slot: 'page',\n scope: 'global',\n description: 'A full page at /page/<fill id> in the main area beside the sidebar.',\n kind: 'component',\n },\n} as const;\n\nexport const HOST_SLOTS = Object.fromEntries(\n Object.entries(HOST_SLOT_METADATA).map(([key, declaration]) => [key, declaration.slot]),\n) as { readonly [K in keyof typeof HOST_SLOT_METADATA]: (typeof HOST_SLOT_METADATA)[K]['slot'] };\n\n/** The keyed slot an activity group explicitly declares, not a dotted-name hierarchy inference. */\nexport function activityGroupSlot(name: string): string {\n return `${HOST_SLOTS.activity}.${name}`;\n}\n\nexport function activityGroupSlotMetadata(name: string, scope: PoApiScope) {\n return {\n slot: activityGroupSlot(name),\n description: `Activity sections in the ${name} group.`,\n parent: HOST_SLOTS.activity,\n kind: 'component' as const,\n scope,\n };\n}\n"],"mappings":";;AAGA,MAAa,qBAAqB;CAChC,MAAM;EAAE,MAAM;EAAQ,OAAO;EAAU,aAAa;EAAgD,MAAM;CAAO;CACjH,UAAU;EACR,MAAM;EACN,OAAO;EACP,aAAa;EACb,QAAQ;EACR,MAAM;CACR;CACA,gBAAgB;EACd,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,eAAe;EACb,MAAM;EACN,OAAO;EACP,aAAa;EACb,QAAQ;EACR,MAAM;CACR;CACA,SAAS;EACP,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,MAAM;EAAE,MAAM;EAAQ,OAAO;EAAU,aAAa;EAAyC,MAAM;CAAY;CAC/G,SAAS;EACP,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,cAAc;EACZ,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,UAAU;EACR,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,iBAAiB;EACf,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,cAAc;EACZ,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,cAAc;EACZ,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,aAAa;EAAE,MAAM;EAAgB,OAAO;EAAU,aAAa;EAA8B,MAAM;CAAY;CACnH,YAAY;EACV,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,MAAM;EACJ,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;AACF;AAEA,MAAa,aAAa,OAAO,YAC/B,OAAO,QAAQ,kBAAkB,CAAC,CAAC,KAAK,CAAC,KAAK,iBAAiB,CAAC,KAAK,YAAY,IAAI,CAAC,CACxF;;AAGA,SAAgB,kBAAkB,MAAsB;CACtD,OAAO,GAAG,WAAW,SAAS,GAAG;AACnC;AAEA,SAAgB,0BAA0B,MAAc,OAAmB;CACzE,OAAO;EACL,MAAM,kBAAkB,IAAI;EAC5B,aAAa,4BAA4B,KAAK;EAC9C,QAAQ,WAAW;EACnB,MAAM;EACN;CACF;AACF"}
1
+ {"version":3,"file":"hostSlots.cjs","names":[],"sources":["../../../src/web/hostSlots.ts"],"sourcesContent":["import type { PoApiScope } from '../schemas/packageApi';\n\n/** Host-owned declarations are visible throughout the client scope tree. */\nexport const HOST_SLOT_METADATA = {\n home: { slot: 'home', scope: 'global', description: 'Typed Home content and launch contributions.', kind: 'data' },\n homeApps: {\n slot: 'home-apps',\n scope: 'global',\n description: 'Plugin cards on Home. Set data.column to side for the narrow column.',\n parent: 'home',\n kind: 'component',\n },\n dashboardTiles: {\n slot: 'dashboard-tiles',\n scope: 'global',\n description: 'Host-framed body-only tiles on Home and workspace dashboards.',\n kind: 'component',\n },\n homeAttention: {\n slot: 'home-attention',\n scope: 'global',\n description: 'Plugin-framed Home cards for things waiting on the person.',\n parent: 'home',\n kind: 'component',\n },\n overlay: {\n slot: 'overlay',\n scope: 'global',\n description: 'Overlays above the cockpit, such as a microphone dialog.',\n kind: 'component',\n },\n rail: { slot: 'rail', scope: 'global', description: 'Navigation items in the cockpit rail.', kind: 'component' },\n context: {\n slot: 'context',\n scope: 'global',\n description: 'Context panels beside the session conversation.',\n kind: 'component',\n },\n selectionBar: {\n slot: 'selection-bar',\n scope: 'global',\n description: 'Actions for the current text selection.',\n kind: 'component',\n },\n activity: {\n slot: 'activity',\n scope: 'global',\n description: 'Session activity panels, with explicit child slots for activity groups.',\n kind: 'component',\n },\n activityPromo: {\n slot: 'activity-promo',\n scope: 'global',\n description: 'Compact actions inside the activity promo card, such as Explore.',\n parent: 'activity',\n kind: 'component',\n },\n composerActions: {\n slot: 'composer-actions',\n scope: 'global',\n description: 'Action controls beside the session composer.',\n kind: 'component',\n },\n composerMenu: {\n slot: 'composer-menu',\n scope: 'global',\n description: 'Items in the session composer menu.',\n kind: 'component',\n },\n dialogPrompt: {\n slot: 'dialog-prompt',\n scope: 'global',\n description: 'Typed data fills that claim a dialog independently of a tool card.',\n kind: 'data',\n },\n sessionMenu: { slot: 'session-menu', scope: 'global', description: 'Items in the session menu.', kind: 'component' },\n newSession: {\n slot: 'new-session',\n scope: 'global',\n description: 'A workspace fill replacing the host new-session dialog.',\n kind: 'component',\n },\n page: {\n slot: 'page',\n scope: 'global',\n description: 'A full page at /page/<fill id> in the main area beside the sidebar.',\n kind: 'component',\n },\n} as const;\n\nexport const HOST_SLOTS = Object.fromEntries(\n Object.entries(HOST_SLOT_METADATA).map(([key, declaration]) => [key, declaration.slot]),\n) as { readonly [K in keyof typeof HOST_SLOT_METADATA]: (typeof HOST_SLOT_METADATA)[K]['slot'] };\n\n/** The keyed slot an activity group explicitly declares, not a dotted-name hierarchy inference. */\nexport function activityGroupSlot(name: string): string {\n return `${HOST_SLOTS.activity}.${name}`;\n}\n\nexport function activityGroupSlotMetadata(name: string, scope: PoApiScope) {\n return {\n slot: activityGroupSlot(name),\n description: `Activity sections in the ${name} group.`,\n parent: HOST_SLOTS.activity,\n kind: 'component' as const,\n scope,\n };\n}\n"],"mappings":";;AAGA,MAAa,qBAAqB;CAChC,MAAM;EAAE,MAAM;EAAQ,OAAO;EAAU,aAAa;EAAgD,MAAM;CAAO;CACjH,UAAU;EACR,MAAM;EACN,OAAO;EACP,aAAa;EACb,QAAQ;EACR,MAAM;CACR;CACA,gBAAgB;EACd,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,eAAe;EACb,MAAM;EACN,OAAO;EACP,aAAa;EACb,QAAQ;EACR,MAAM;CACR;CACA,SAAS;EACP,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,MAAM;EAAE,MAAM;EAAQ,OAAO;EAAU,aAAa;EAAyC,MAAM;CAAY;CAC/G,SAAS;EACP,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,cAAc;EACZ,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,UAAU;EACR,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,eAAe;EACb,MAAM;EACN,OAAO;EACP,aAAa;EACb,QAAQ;EACR,MAAM;CACR;CACA,iBAAiB;EACf,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,cAAc;EACZ,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,cAAc;EACZ,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,aAAa;EAAE,MAAM;EAAgB,OAAO;EAAU,aAAa;EAA8B,MAAM;CAAY;CACnH,YAAY;EACV,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,MAAM;EACJ,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;AACF;AAEA,MAAa,aAAa,OAAO,YAC/B,OAAO,QAAQ,kBAAkB,CAAC,CAAC,KAAK,CAAC,KAAK,iBAAiB,CAAC,KAAK,YAAY,IAAI,CAAC,CACxF;;AAGA,SAAgB,kBAAkB,MAAsB;CACtD,OAAO,GAAG,WAAW,SAAS,GAAG;AACnC;AAEA,SAAgB,0BAA0B,MAAc,OAAmB;CACzE,OAAO;EACL,MAAM,kBAAkB,IAAI;EAC5B,aAAa,4BAA4B,KAAK;EAC9C,QAAQ,WAAW;EACnB,MAAM;EACN;CACF;AACF"}
@@ -58,6 +58,13 @@ export declare const HOST_SLOT_METADATA: {
58
58
  readonly description: 'Session activity panels, with explicit child slots for activity groups.';
59
59
  readonly kind: 'component';
60
60
  };
61
+ readonly activityPromo: {
62
+ readonly slot: 'activity-promo';
63
+ readonly scope: 'global';
64
+ readonly description: 'Compact actions inside the activity promo card, such as Explore.';
65
+ readonly parent: 'activity';
66
+ readonly kind: 'component';
67
+ };
61
68
  readonly composerActions: {
62
69
  readonly slot: 'composer-actions';
63
70
  readonly scope: 'global';
@@ -1 +1 @@
1
- {"version":3,"file":"hostSlots.d.mts","names":[],"sources":["../../../src/web/hostSlots.ts"],"mappings":";;;qBAGa;WACX;aAAQ;aAAc;aAAiB;aAA6D;;WACpG;aACE;aACA;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;;WAEF;aAAQ;aAAc;aAAiB;aAAsD;;WAC7F;aACE;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;;WAEF;aAAe;aAAsB;aAAiB;aAA2C;;WACjG;aACE;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;;;qBAIS,wBAEI,kBAAkB,6BAA6B,oBAAoB;;wBAGpE,kBAAkB;wBAIlB,0BAA0B,cAAc,OAAO;;;;EAKrD;SALqD"}
1
+ {"version":3,"file":"hostSlots.d.mts","names":[],"sources":["../../../src/web/hostSlots.ts"],"mappings":";;;qBAGa;WACX;aAAQ;aAAc;aAAiB;aAA6D;;WACpG;aACE;aACA;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;;WAEF;aAAQ;aAAc;aAAiB;aAAsD;;WAC7F;aACE;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;;WAEF;aAAe;aAAsB;aAAiB;aAA2C;;WACjG;aACE;aACA;aACA;aACA;;WAEF;aACE;aACA;aACA;aACA;;;qBAIS,wBAEI,kBAAkB,6BAA6B,oBAAoB;;wBAGpE,kBAAkB;wBAIlB,0BAA0B,cAAc,OAAO;;;;EAKrD;SALqD"}
@@ -57,6 +57,13 @@ const HOST_SLOT_METADATA = {
57
57
  description: "Session activity panels, with explicit child slots for activity groups.",
58
58
  kind: "component"
59
59
  },
60
+ activityPromo: {
61
+ slot: "activity-promo",
62
+ scope: "global",
63
+ description: "Compact actions inside the activity promo card, such as Explore.",
64
+ parent: "activity",
65
+ kind: "component"
66
+ },
60
67
  composerActions: {
61
68
  slot: "composer-actions",
62
69
  scope: "global",
@@ -1 +1 @@
1
- {"version":3,"file":"hostSlots.mjs","names":[],"sources":["../../../src/web/hostSlots.ts"],"sourcesContent":["import type { PoApiScope } from '../schemas/packageApi';\n\n/** Host-owned declarations are visible throughout the client scope tree. */\nexport const HOST_SLOT_METADATA = {\n home: { slot: 'home', scope: 'global', description: 'Typed Home content and launch contributions.', kind: 'data' },\n homeApps: {\n slot: 'home-apps',\n scope: 'global',\n description: 'Plugin cards on Home. Set data.column to side for the narrow column.',\n parent: 'home',\n kind: 'component',\n },\n dashboardTiles: {\n slot: 'dashboard-tiles',\n scope: 'global',\n description: 'Host-framed body-only tiles on Home and workspace dashboards.',\n kind: 'component',\n },\n homeAttention: {\n slot: 'home-attention',\n scope: 'global',\n description: 'Plugin-framed Home cards for things waiting on the person.',\n parent: 'home',\n kind: 'component',\n },\n overlay: {\n slot: 'overlay',\n scope: 'global',\n description: 'Overlays above the cockpit, such as a microphone dialog.',\n kind: 'component',\n },\n rail: { slot: 'rail', scope: 'global', description: 'Navigation items in the cockpit rail.', kind: 'component' },\n context: {\n slot: 'context',\n scope: 'global',\n description: 'Context panels beside the session conversation.',\n kind: 'component',\n },\n selectionBar: {\n slot: 'selection-bar',\n scope: 'global',\n description: 'Actions for the current text selection.',\n kind: 'component',\n },\n activity: {\n slot: 'activity',\n scope: 'global',\n description: 'Session activity panels, with explicit child slots for activity groups.',\n kind: 'component',\n },\n composerActions: {\n slot: 'composer-actions',\n scope: 'global',\n description: 'Action controls beside the session composer.',\n kind: 'component',\n },\n composerMenu: {\n slot: 'composer-menu',\n scope: 'global',\n description: 'Items in the session composer menu.',\n kind: 'component',\n },\n dialogPrompt: {\n slot: 'dialog-prompt',\n scope: 'global',\n description: 'Typed data fills that claim a dialog independently of a tool card.',\n kind: 'data',\n },\n sessionMenu: { slot: 'session-menu', scope: 'global', description: 'Items in the session menu.', kind: 'component' },\n newSession: {\n slot: 'new-session',\n scope: 'global',\n description: 'A workspace fill replacing the host new-session dialog.',\n kind: 'component',\n },\n page: {\n slot: 'page',\n scope: 'global',\n description: 'A full page at /page/<fill id> in the main area beside the sidebar.',\n kind: 'component',\n },\n} as const;\n\nexport const HOST_SLOTS = Object.fromEntries(\n Object.entries(HOST_SLOT_METADATA).map(([key, declaration]) => [key, declaration.slot]),\n) as { readonly [K in keyof typeof HOST_SLOT_METADATA]: (typeof HOST_SLOT_METADATA)[K]['slot'] };\n\n/** The keyed slot an activity group explicitly declares, not a dotted-name hierarchy inference. */\nexport function activityGroupSlot(name: string): string {\n return `${HOST_SLOTS.activity}.${name}`;\n}\n\nexport function activityGroupSlotMetadata(name: string, scope: PoApiScope) {\n return {\n slot: activityGroupSlot(name),\n description: `Activity sections in the ${name} group.`,\n parent: HOST_SLOTS.activity,\n kind: 'component' as const,\n scope,\n };\n}\n"],"mappings":";;AAGA,MAAa,qBAAqB;CAChC,MAAM;EAAE,MAAM;EAAQ,OAAO;EAAU,aAAa;EAAgD,MAAM;CAAO;CACjH,UAAU;EACR,MAAM;EACN,OAAO;EACP,aAAa;EACb,QAAQ;EACR,MAAM;CACR;CACA,gBAAgB;EACd,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,eAAe;EACb,MAAM;EACN,OAAO;EACP,aAAa;EACb,QAAQ;EACR,MAAM;CACR;CACA,SAAS;EACP,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,MAAM;EAAE,MAAM;EAAQ,OAAO;EAAU,aAAa;EAAyC,MAAM;CAAY;CAC/G,SAAS;EACP,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,cAAc;EACZ,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,UAAU;EACR,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,iBAAiB;EACf,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,cAAc;EACZ,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,cAAc;EACZ,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,aAAa;EAAE,MAAM;EAAgB,OAAO;EAAU,aAAa;EAA8B,MAAM;CAAY;CACnH,YAAY;EACV,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,MAAM;EACJ,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;AACF;AAEA,MAAa,aAAa,OAAO,YAC/B,OAAO,QAAQ,kBAAkB,CAAC,CAAC,KAAK,CAAC,KAAK,iBAAiB,CAAC,KAAK,YAAY,IAAI,CAAC,CACxF;;AAGA,SAAgB,kBAAkB,MAAsB;CACtD,OAAO,GAAG,WAAW,SAAS,GAAG;AACnC;AAEA,SAAgB,0BAA0B,MAAc,OAAmB;CACzE,OAAO;EACL,MAAM,kBAAkB,IAAI;EAC5B,aAAa,4BAA4B,KAAK;EAC9C,QAAQ,WAAW;EACnB,MAAM;EACN;CACF;AACF"}
1
+ {"version":3,"file":"hostSlots.mjs","names":[],"sources":["../../../src/web/hostSlots.ts"],"sourcesContent":["import type { PoApiScope } from '../schemas/packageApi';\n\n/** Host-owned declarations are visible throughout the client scope tree. */\nexport const HOST_SLOT_METADATA = {\n home: { slot: 'home', scope: 'global', description: 'Typed Home content and launch contributions.', kind: 'data' },\n homeApps: {\n slot: 'home-apps',\n scope: 'global',\n description: 'Plugin cards on Home. Set data.column to side for the narrow column.',\n parent: 'home',\n kind: 'component',\n },\n dashboardTiles: {\n slot: 'dashboard-tiles',\n scope: 'global',\n description: 'Host-framed body-only tiles on Home and workspace dashboards.',\n kind: 'component',\n },\n homeAttention: {\n slot: 'home-attention',\n scope: 'global',\n description: 'Plugin-framed Home cards for things waiting on the person.',\n parent: 'home',\n kind: 'component',\n },\n overlay: {\n slot: 'overlay',\n scope: 'global',\n description: 'Overlays above the cockpit, such as a microphone dialog.',\n kind: 'component',\n },\n rail: { slot: 'rail', scope: 'global', description: 'Navigation items in the cockpit rail.', kind: 'component' },\n context: {\n slot: 'context',\n scope: 'global',\n description: 'Context panels beside the session conversation.',\n kind: 'component',\n },\n selectionBar: {\n slot: 'selection-bar',\n scope: 'global',\n description: 'Actions for the current text selection.',\n kind: 'component',\n },\n activity: {\n slot: 'activity',\n scope: 'global',\n description: 'Session activity panels, with explicit child slots for activity groups.',\n kind: 'component',\n },\n activityPromo: {\n slot: 'activity-promo',\n scope: 'global',\n description: 'Compact actions inside the activity promo card, such as Explore.',\n parent: 'activity',\n kind: 'component',\n },\n composerActions: {\n slot: 'composer-actions',\n scope: 'global',\n description: 'Action controls beside the session composer.',\n kind: 'component',\n },\n composerMenu: {\n slot: 'composer-menu',\n scope: 'global',\n description: 'Items in the session composer menu.',\n kind: 'component',\n },\n dialogPrompt: {\n slot: 'dialog-prompt',\n scope: 'global',\n description: 'Typed data fills that claim a dialog independently of a tool card.',\n kind: 'data',\n },\n sessionMenu: { slot: 'session-menu', scope: 'global', description: 'Items in the session menu.', kind: 'component' },\n newSession: {\n slot: 'new-session',\n scope: 'global',\n description: 'A workspace fill replacing the host new-session dialog.',\n kind: 'component',\n },\n page: {\n slot: 'page',\n scope: 'global',\n description: 'A full page at /page/<fill id> in the main area beside the sidebar.',\n kind: 'component',\n },\n} as const;\n\nexport const HOST_SLOTS = Object.fromEntries(\n Object.entries(HOST_SLOT_METADATA).map(([key, declaration]) => [key, declaration.slot]),\n) as { readonly [K in keyof typeof HOST_SLOT_METADATA]: (typeof HOST_SLOT_METADATA)[K]['slot'] };\n\n/** The keyed slot an activity group explicitly declares, not a dotted-name hierarchy inference. */\nexport function activityGroupSlot(name: string): string {\n return `${HOST_SLOTS.activity}.${name}`;\n}\n\nexport function activityGroupSlotMetadata(name: string, scope: PoApiScope) {\n return {\n slot: activityGroupSlot(name),\n description: `Activity sections in the ${name} group.`,\n parent: HOST_SLOTS.activity,\n kind: 'component' as const,\n scope,\n };\n}\n"],"mappings":";;AAGA,MAAa,qBAAqB;CAChC,MAAM;EAAE,MAAM;EAAQ,OAAO;EAAU,aAAa;EAAgD,MAAM;CAAO;CACjH,UAAU;EACR,MAAM;EACN,OAAO;EACP,aAAa;EACb,QAAQ;EACR,MAAM;CACR;CACA,gBAAgB;EACd,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,eAAe;EACb,MAAM;EACN,OAAO;EACP,aAAa;EACb,QAAQ;EACR,MAAM;CACR;CACA,SAAS;EACP,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,MAAM;EAAE,MAAM;EAAQ,OAAO;EAAU,aAAa;EAAyC,MAAM;CAAY;CAC/G,SAAS;EACP,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,cAAc;EACZ,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,UAAU;EACR,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,eAAe;EACb,MAAM;EACN,OAAO;EACP,aAAa;EACb,QAAQ;EACR,MAAM;CACR;CACA,iBAAiB;EACf,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,cAAc;EACZ,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,cAAc;EACZ,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,aAAa;EAAE,MAAM;EAAgB,OAAO;EAAU,aAAa;EAA8B,MAAM;CAAY;CACnH,YAAY;EACV,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;CACA,MAAM;EACJ,MAAM;EACN,OAAO;EACP,aAAa;EACb,MAAM;CACR;AACF;AAEA,MAAa,aAAa,OAAO,YAC/B,OAAO,QAAQ,kBAAkB,CAAC,CAAC,KAAK,CAAC,KAAK,iBAAiB,CAAC,KAAK,YAAY,IAAI,CAAC,CACxF;;AAGA,SAAgB,kBAAkB,MAAsB;CACtD,OAAO,GAAG,WAAW,SAAS,GAAG;AACnC;AAEA,SAAgB,0BAA0B,MAAc,OAAmB;CACzE,OAAO;EACL,MAAM,kBAAkB,IAAI;EAC5B,aAAa,4BAA4B,KAAK;EAC9C,QAAQ,WAAW;EACnB,MAAM;EACN;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po-core",
3
- "version": "0.0.0-alpha.105",
3
+ "version": "0.0.0-alpha.107",
4
4
  "description": "Po runtime systems and reusable core services.",
5
5
  "keywords": [
6
6
  "ai",
@@ -579,8 +579,8 @@
579
579
  "registry": "https://registry.npmjs.org/"
580
580
  },
581
581
  "dependencies": {
582
- "@agimon-ai/po-logsink": "0.0.1-alpha.87",
583
- "@agimon-ai/po-web-security": "0.0.0-alpha.105",
582
+ "@agimon-ai/po-logsink": "0.0.1-alpha.89",
583
+ "@agimon-ai/po-web-security": "0.0.0-alpha.107",
584
584
  "@deepseek-ai/cordis": "4.0.5",
585
585
  "@earendil-works/chord": "1.5.0",
586
586
  "@earendil-works/pi-agent-core": "1.5.0",
@@ -605,7 +605,7 @@
605
605
  "yaml": "2.9.1"
606
606
  },
607
607
  "devDependencies": {
608
- "@agimon-ai/vibe-lint-plugin-po-core": "0.0.0-alpha.105",
608
+ "@agimon-ai/vibe-lint-plugin-po-core": "0.0.0-alpha.107",
609
609
  "@apidevtools/swagger-parser": "^13.1.0",
610
610
  "@asyncapi/parser": "^3.6.4",
611
611
  "@earendil-works/pi-ai": "1.5.0",