@agimon-ai/po-core 0.0.0-alpha.20 → 0.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +149 -21
- package/NOTICE +41 -0
- package/dist/apiContracts.d.mts +54 -1
- package/dist/apiContracts.d.mts.map +1 -1
- package/dist/headlessHub.cjs +4 -0
- package/dist/headlessHub.cjs.map +1 -1
- package/dist/headlessHub.mjs +4 -0
- package/dist/headlessHub.mjs.map +1 -1
- package/dist/headlessServer.cjs +7 -2
- package/dist/headlessServer.cjs.map +1 -1
- package/dist/headlessServer.d.mts +2 -0
- package/dist/headlessServer.d.mts.map +1 -1
- package/dist/headlessServer.mjs +7 -2
- package/dist/headlessServer.mjs.map +1 -1
- package/dist/moduleResolution.cjs +24 -2
- package/dist/moduleResolution.cjs.map +1 -1
- package/dist/moduleResolution.d.mts +6 -0
- package/dist/moduleResolution.d.mts.map +1 -1
- package/dist/moduleResolution.mjs +24 -3
- package/dist/moduleResolution.mjs.map +1 -1
- package/dist/native.cjs +1 -0
- package/dist/native.d.mts +3 -3
- package/dist/native.mjs +2 -2
- package/dist/nodePlatform.cjs +1 -0
- package/dist/nodePlatform.cjs.map +1 -1
- package/dist/nodePlatform.d.mts +2 -0
- package/dist/nodePlatform.d.mts.map +1 -1
- package/dist/nodePlatform.mjs +1 -0
- package/dist/nodePlatform.mjs.map +1 -1
- package/dist/packageApiServer.cjs +11 -5
- package/dist/packageApiServer.cjs.map +1 -1
- package/dist/packageApiServer.d.mts.map +1 -1
- package/dist/packageApiServer.mjs +7 -1
- package/dist/packageApiServer.mjs.map +1 -1
- package/dist/platform.cjs +6 -0
- package/dist/platform.d.mts +2 -1
- package/dist/platform.mjs +2 -1
- package/dist/src/schemas/hubChannel.cjs.map +1 -1
- package/dist/src/schemas/hubChannel.d.mts +4 -0
- package/dist/src/schemas/hubChannel.d.mts.map +1 -1
- package/dist/src/schemas/hubChannel.mjs.map +1 -1
- package/dist/src/schemas/packageApi.cjs.map +1 -1
- package/dist/src/schemas/packageApi.d.mts +3 -0
- package/dist/src/schemas/packageApi.d.mts.map +1 -1
- package/dist/src/schemas/packageApi.mjs.map +1 -1
- package/dist/src/schemas/platform.cjs.map +1 -1
- package/dist/src/schemas/platform.d.mts +5 -0
- package/dist/src/schemas/platform.d.mts.map +1 -1
- package/dist/src/schemas/platform.mjs.map +1 -1
- package/dist/src/server/serverScope.cjs +4 -1
- package/dist/src/server/serverScope.cjs.map +1 -1
- package/dist/src/server/serverScope.d.mts.map +1 -1
- package/dist/src/server/serverScope.mjs +4 -1
- package/dist/src/server/serverScope.mjs.map +1 -1
- package/dist/src/services/sessionFiles/index.cjs +96 -0
- package/dist/src/services/sessionFiles/index.cjs.map +1 -0
- package/dist/src/services/sessionFiles/index.d.mts +33 -0
- package/dist/src/services/sessionFiles/index.d.mts.map +1 -0
- package/dist/src/services/sessionFiles/index.mjs +89 -0
- package/dist/src/services/sessionFiles/index.mjs.map +1 -0
- package/dist/src/services/sessionFiles/sessionDirectory.cjs +66 -0
- package/dist/src/services/sessionFiles/sessionDirectory.cjs.map +1 -0
- package/dist/src/services/sessionFiles/sessionDirectory.mjs +62 -0
- package/dist/src/services/sessionFiles/sessionDirectory.mjs.map +1 -0
- package/dist/src/systems/main/adapters/headlessSessionHost.cjs +18 -6
- package/dist/src/systems/main/adapters/headlessSessionHost.cjs.map +1 -1
- package/dist/src/systems/main/adapters/headlessSessionHost.d.mts.map +1 -1
- package/dist/src/systems/main/adapters/headlessSessionHost.mjs +16 -4
- package/dist/src/systems/main/adapters/headlessSessionHost.mjs.map +1 -1
- package/dist/src/web/types/nativeTemplate.d.mts +1 -1
- package/dist/src/web/types/nativeTemplate.d.mts.map +1 -1
- package/licenses/Codex-Apache-2.0.txt +201 -0
- package/package.json +8 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageApi.d.mts","names":[],"sources":["../../../src/schemas/packageApi.ts"],"mappings":"
|
|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AEA;WACA;;iBAGM;WACN,OAAO;;WAEP;WACA;;;;;;YAOC,uBAAuB,YAAY,YAAY;;qBAG9C;;;;;iBAOI;;EAEf;EACA;EACA;EACA;;EAEA;EACA;;EAEA;;;iBAIe;EACf,OAAO;;EAEP;;;;;EAKA;;EAEA,iBAAiB;;EAEjB;;EAEA;;EAEA;;EAEA,cAAc,SAAS;;EAEvB;;EAEA;;;;;EAKA,mBAAmB;;EAEnB,oBACE,uBACC,QAAQ,oCAAoC;;EAE/C;IAA4B;IAAY;IAAc;IAAc;;;EAEpE;;;;;EAKA,kBAAkB;;EAElB,iBAAiB;;EAEjB,iBAAiB;;EAEjB,uBAAuB;;EAEvB,eAAe;;;;;EAKf,iBAAiB,UAAU;;EAE3B,YAAY,OAAO,YAAY,kBAAkB,SAAS,UAAU,QAAQ;;EAE5E,cAAc;;EAEd,gBAAgB,mBAAmB,mBAAmB,kBAAkB;;EAExE,kBAAkB;;EAElB,mBAAmB;;EAEnB,kBAAkB;;EAElB,eAAe;;EAEf,aAAa;;EAEb;IAAkB,MAAM,SAAS,UAAU,QAAQ;;;;;;;EAMnD,WAAW,cAAc,gBAAgB,QAAQ;EACjD,SAAS;;;;;;;iBAQM;EACf,MAAM,SAAS,UAAU,WAAW,QAAQ;EAC5C;;iBAGe;;EAEf;EACA,MAAM,SAAS,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageApi.mjs","names":[],"sources":["../../../src/schemas/packageApi.ts"],"sourcesContent":["/**\n * The HTTP surface a package offers its host.\n *\n * A server plugin registers one with its host. The host mounts it under the API\n * route prefix, and the package writes routes relative to that mount.\n *\n * The handler is a plain fetch callback so no host and no package is committed\n * to one HTTP framework; a Hono app satisfies it through `app.fetch`.\n */\n\nimport type {\n PoComputerUseSessionAccess,\n PoDirectEventBus,\n PoHubSessionService,\n PoSessionCommunicationEndpoint,\n PoSessionActivity,\n PoSessionContext,\n} from './hubChannel';\nimport type { PoMcpProjection } from './mcpProjection';\n/** The host-owned sync view a repository-scoped package API may inspect. */\nexport interface PoRepositorySyncView {\n fresh: boolean;\n reasons: string[];\n /** True while a background sync that may prepare what `reasons` names is running. */\n syncing?: boolean;\n mcpProjection?: PoMcpProjection;\n}\n\n/** Where an API runs: inside one session's server, or in the machine-wide hub. */\nexport type PoApiScope = 'global' | 'workspace' | 'session';\n\nexport const PO_API_SCOPES: readonly PoApiScope[] = ['global', 'workspace', 'session'];\n\n/** Identity of an independently mounted plugin host. */\nexport type PoApiMount =\n | { scope: 'global' }\n | { scope: 'workspace'; workspaceId: string }\n | { scope: 'session'; sessionId: string };\n\n/** Immutable browser contribution generation paired with a server mount. */\nexport interface PoWebComposition {\n id: string;\n scope: PoApiScope;\n revision: number;\n manifestUrl: string;\n rawAssetBaseUrl: string;\n verifiedAssetBaseUrl: string;\n /** `[slot, entry]` for each of this mount's plugin copies, the entry an absolute path below the asset prefixes. */\n pluginEntries: [string, string][];\n /** Every signed file this mount's slots can load, absolute below the asset prefixes. */\n assetPaths: string[];\n /** Per-plugin stylesheets of this mount's plugins only, so other mounts' classes never apply here. */\n stylePaths: string[];\n channels: string[];\n /** The slots resolved for this mount; the shared build may hold more. */\n plugins: string[];\n}\n\n/**\n * Immutable native contribution generation paired with a server mount. One signed CommonJS module at\n * `entryPath`, served through the same immutable plugin routes as web compositions.\n */\nexport interface PoNativeComposition {\n id: string;\n scope: PoApiScope;\n revision: number;\n manifestUrl: string;\n rawAssetBaseUrl: string;\n /** Always `/composition.js`. */\n entryPath: string;\n channels: string[];\n /** The `poNative.pluginId` values resolved for this mount; the shell installs only these. */\n plugins: string[];\n}\n\n/** Canonical public prefix. Scope selection never falls through to a parent. */\nexport function poApiMountPath(mount: PoApiMount & { workspaceId?: string }): string {\n if (mount.scope === 'global') return '/api/plugins';\n if (mount.scope === 'workspace') return `/api/workspaces/${encodeURIComponent(mount.workspaceId)}/plugins`;\n if (!mount.workspaceId) throw new Error('A session API path requires its workspace identity.');\n return `/api/workspaces/${encodeURIComponent(mount.workspaceId)}/sessions/${encodeURIComponent(mount.sessionId)}/plugins`;\n}\n\n/** Scope addressed by a public WebSocket upgrade. */\nexport type PoSocketMount =\n | { scope: 'global' }\n | { scope: 'workspace'; workspaceId: string }\n | { scope: 'session'; workspaceId: string; sessionId: string };\n\n/** Only canonical resource paths may select a protocol listener. */\nexport function parsePoSocketPath(pathname: string): PoSocketMount | undefined {\n if (pathname === '/api/ws') return { scope: 'global' };\n const match = /^\\/api\\/workspaces\\/([^/]+)(?:\\/sessions\\/([^/]+))?\\/ws$/u.exec(pathname);\n if (!match) return undefined;\n try {\n const workspaceId = decodeURIComponent(match[1]);\n return match[2] === undefined\n ? { scope: 'workspace', workspaceId }\n : { scope: 'session', workspaceId, sessionId: decodeURIComponent(match[2]) };\n } catch {\n return undefined;\n }\n}\n\n/** The segment an API is mounted under, below this prefix. */\nexport const PO_API_ROUTE_PREFIX = '/api/plugins';\n/** Selects the hub API bundle that owns the named cockpit session. */\nexport const PO_HUB_API_SESSION_QUERY_PARAM = 'hubSession';\n\n/** Trusted caller headers written only by the cockpit-to-session proxy. */\nexport const PO_API_CALLER_LOCALITY_HEADER = 'x-po-api-caller-locality';\nexport const PO_API_CALLER_DEVICE_ID_HEADER = 'x-po-api-caller-device-id';\nexport const PO_API_CALLER_STEP_UP_HEADER = 'x-po-api-caller-step-up';\nexport const PO_API_CALLER_HEADERS = [\n PO_API_CALLER_LOCALITY_HEADER,\n PO_API_CALLER_DEVICE_ID_HEADER,\n PO_API_CALLER_STEP_UP_HEADER,\n] as const;\n\nexport type PoApiCallerStepUp = 'not-required' | 'verified' | 'unavailable';\nexport type PoApiCaller =\n | { locality: 'local'; stepUp: 'not-required' }\n | { locality: 'remote'; deviceId: string; stepUp: PoApiCallerStepUp };\n\n/** Reads the proxy-authenticated caller identity, rejecting partial or contradictory stamps. */\nexport function poApiCallerFrom(headers: Headers): PoApiCaller | undefined {\n const locality = headers.get(PO_API_CALLER_LOCALITY_HEADER);\n const deviceId = headers.get(PO_API_CALLER_DEVICE_ID_HEADER);\n const stepUp = headers.get(PO_API_CALLER_STEP_UP_HEADER);\n if (locality === 'local') {\n return deviceId === null && stepUp === 'not-required' ? { locality, stepUp } : undefined;\n }\n if (\n locality === 'remote' &&\n deviceId !== null &&\n deviceId !== '' &&\n (stepUp === 'not-required' || stepUp === 'verified' || stepUp === 'unavailable')\n ) {\n return { locality, deviceId, stepUp };\n }\n return undefined;\n}\n/**\n * A browser-reachable OAuth redirect the host serves on its own listener.\n *\n * A package brokering third-party OAuth cannot use a loopback redirect when the\n * operator's browser is on another machine: `127.0.0.1` resolves to whichever\n * machine the browser runs on. The host owns a listener that is reachable from\n * wherever the cockpit is being used, so it lends that instead of the package\n * opening a port of its own.\n */\nexport interface PoOAuthRedirect {\n /** Absolute URL to register as the redirect target, already origin-correct. */\n readonly redirectUri: string;\n /**\n * Accept redirects carrying this state. Must complete before the\n * authorization URL is surfaced, or the redirect races its own reservation.\n */\n reserve(state: string, timeoutMs?: number): Promise<void>;\n /** Resolves once the redirect carrying this state arrives. */\n wait(state: string, timeoutMs?: number): Promise<{ code: string; state: string }>;\n /** Drops a reservation whose flow ended without a redirect. */\n cancel(state: string): void;\n}\n\n/** An exact, host-owned receipt address. Provider IDs are not event cursor positions. */\nexport interface PoRequestReceiptKey {\n namespace: string;\n activationId: string;\n requestId: string;\n}\n\nexport interface PoRequestReceipt extends PoRequestReceiptKey {\n fingerprint: string;\n destination: string;\n transactionId: string;\n outcome: 'reserved' | 'admitted' | 'rejected' | 'uncertain';\n}\n\nexport interface PoRequestReceiptReservation extends PoRequestReceiptKey {\n /** Lowercase SHA-256 of the authoritative request text, never the full transcript. */\n fingerprint: string;\n destination: string;\n transactionId: string;\n}\n\nexport type PoRequestReceiptReserveResult =\n | { kind: 'reserved'; token: string }\n | { kind: 'existing'; receipt: PoRequestReceipt }\n | { kind: 'conflict'; receipt: PoRequestReceipt };\n\n/** A global-only receipt capability. A reservation is not an execution receipt. */\nexport interface PoRequestReceipts {\n reserve(request: PoRequestReceiptReservation): Promise<PoRequestReceiptReserveResult>;\n lookup(key: PoRequestReceiptKey): Promise<PoRequestReceipt | undefined>;\n finish(\n request: PoRequestReceiptKey & { token: string; outcome: 'admitted' | 'rejected' | 'uncertain' },\n ): Promise<PoRequestReceipt>;\n}\n\n/** Permit returned for expensive local work. Calling it releases the slot. */\nexport interface PoHostExecutionPermit {\n (): void;\n attachProcess?(pid: number): Promise<void>;\n}\n\n/** Host-wide admission for expensive local work. Release only after the owned process exits. */\nexport interface PoHostExecutionBudget {\n acquire(signal?: AbortSignal): Promise<PoHostExecutionPermit>;\n getSnapshot(): Readonly<{ running: number; queued: number; limit: number }>;\n}\n\n/** Synchronous host-owned exclusion across media APIs mounted at different scopes. */\nexport interface PoHostMediaArbitration {\n register(busy: () => boolean): () => void;\n available(busy: () => boolean): boolean;\n}\n\n/** One host's paired agent registrations, shared across its global and session mounts. */\nexport interface PoPeerAgentRegistry {\n register(sessionId: string, agent: { fetch(request: Request): Promise<Response> }, hubToken: string): () => void;\n get(sessionId: string): { fetch(request: Request): Promise<Response>; hubToken: string } | undefined;\n}\n\n/** One agent that edits files: a hub session or an in-process child run. */\nexport interface PoEditPresenceAgent {\n /** `session:<id>` or `run:<runId>`. Unique across the host. */\n readonly key: string;\n /** Read when a note is rendered, so a name registered after the edit still shows. */\n readonly label: () => string;\n /** Hub session id other agents can reach with intercom. */\n readonly contact: string;\n readonly isLive: () => boolean;\n}\n\nexport interface PoEditPresenceEntry {\n readonly agent: PoEditPresenceAgent;\n /** `@file` tag of the bytes this agent's last successful edit or write left behind. */\n readonly tag: string;\n readonly at: number;\n}\n\n/**\n * Host-wide record of the last edit each live agent made to a file, keyed by realpath then agent key.\n * Owners delete their entries when they dispose, so no callback outlives its session or run.\n */\nexport type PoEditPresenceLedger = Map<string, Map<string, PoEditPresenceEntry>>;\n\n/** Why shareFile rejects while the host has no public tunnel origin. */\nexport const PO_SHARE_FILE_REMOTE_OFF_MESSAGE =\n 'Remote access is off, so Po cannot share files with remote MCP servers. Turn it on and retry.';\n\n/**\n * A file published at a short-lived public tunnel URL: 10 minutes, 3 downloads, and gone\n * when the tunnel revision changes. Call revoke as soon as the consumer is done with it.\n */\nexport interface PoSharedFile {\n /** Bearer link; never log or persist it. */\n url: string;\n fileName: string;\n mimeType: string;\n size: number;\n /** Expiry as epoch milliseconds. */\n expiresAt: number;\n maxDownloads: number;\n /** Idempotent. */\n revoke(): void;\n}\n\n/** What the host tells an API about itself when it starts. */\nexport interface PoApiContext {\n scope: PoApiScope;\n /** Stable, opaque workspace id, shared by every session and member checkout of the workspace. */\n workspaceId?: string;\n /**\n * The admitted workspace root for a workspace mount. For a session mount it is the checkout\n * the session runs in; read sessionContext for both roots. Absent from global mounts.\n */\n workspaceRoot?: string;\n /** The session's baseline context; present on session mounts whose host knows its workspace. */\n sessionContext?: PoSessionContext;\n /** Explicit host home, never selected by a remote request. */\n homeDirectory?: string;\n /** The session this host serves; absent for a hub-scoped API. */\n sessionId?: string;\n /** The session's working directory; absent for a hub-scoped API. */\n cwd?: string;\n /** Session environment admitted by the server, never supplied by remote clients. */\n environment?: Readonly<Record<string, string | undefined>>;\n /** Shared only with child processes in this session, never with remote API clients. */\n internalToken?: string;\n /** Shared only with the cockpit hub for privileged cross-session coordination. */\n hubToken?: string;\n /**\n * Resolves a hub-issued opaque repository id to an admitted canonical root.\n * Hub APIs must never accept a browser-supplied filesystem path instead.\n */\n resolveRepository?(repositoryId: string): string | undefined;\n /** Reads the admitted repository's sync projection without exposing its state path. */\n readRepositorySync?(\n repositoryId: string,\n ): Promise<PoRepositorySyncView | undefined> | PoRepositorySyncView | undefined;\n /** Admitted workspaces available to this mount. */\n repositories?(): readonly { id: string; name: string; path: string; active: boolean }[];\n /** Publish a successful config write to the owning mount's refresh lifecycle. */\n configurationChanged?(): void;\n /**\n * Borrows the hub's OAuth redirect surface. Undefined when the hub cannot\n * currently serve one, in which case the package keeps its own behaviour.\n */\n oauthRedirect?(): PoOAuthRedirect | undefined;\n /** Canonical in-process lifecycle for sessions created by this host. */\n sessionService?: PoHubSessionService;\n /** Host-bound, authenticated inter-session event endpoint for this session. */\n sessionCommunication?: PoSessionCommunicationEndpoint;\n /** Same-process events shared by session APIs and hub channels. */\n directEvents?: PoDirectEventBus;\n /**\n * Publishes this session's activity line to every page's rail; undefined clears it.\n * Session mounts only. The last publisher wins.\n */\n publishActivity?(activity: PoSessionActivity | undefined): void;\n /** Trusted in-process dispatch to an explicitly selected mounted API. No browser authentication is performed here. */\n requestApi?(mount: PoApiMount, basePath: string, request: Request): Promise<Response>;\n /** Present only on a session mounted by an authenticated Desktop host. */\n computerUse?: PoComputerUseSessionAccess;\n /** Deliver a typed method to the channel serving a session this mount reaches, retaining the caller's connection identity. */\n receiveChannel?(sessionId: string, frameType: string, payload: unknown, connectionId: string): boolean;\n /** Host-owned replay evidence, supplied only on the global mount. Never exposed to browsers or agents. */\n requestReceipts?: PoRequestReceipts;\n /** One host's exclusive media activity, shared across global and session scopes. */\n mediaArbitration?: PoHostMediaArbitration;\n /** One host-wide heavy-job budget, not a separate budget for every session. */\n executionBudget?: PoHostExecutionBudget;\n /** One host-wide edit presence ledger, shared by every session mount. */\n editPresence?: PoEditPresenceLedger;\n /** Paired agents belonging to this host only. */\n peerAgents?: PoPeerAgentRegistry;\n /** Machine-owned Remote Control service, mounted only by Po's own global server plugin. */\n remoteControl?: { fetch(request: Request): Promise<Response> };\n /**\n * Publishes a file from this session's cwd or attachments at a short-lived tunnel URL.\n * Session mounts only; rejects with PO_SHARE_FILE_REMOTE_OFF_MESSAGE while remote access is off.\n * The host asks no consent: the caller must obtain it before passing the URL on.\n */\n shareFile?(path: string, label: string): Promise<PoSharedFile>;\n onNotice(message: string): void;\n}\n\n/**\n * One running surface. The host strips the mount prefix before calling, so\n * routes are declared relative ('/runners/:id/log') and a package never\n * repeats where it was mounted.\n */\nexport interface PoApiHandler {\n fetch(request: Request): Response | Promise<Response>;\n close(): void;\n}\n\nexport interface PoApi {\n /** Segment under /api/plugins/; globally unique across loaded packages. */\n basePath: string;\n start(context: PoApiContext): PoApiHandler;\n}\n"],"mappings":";AA+BA,MAAa,gBAAuC;CAAC;CAAU;CAAa;AAAS;;AA6CrF,SAAgB,eAAe,OAAsD;CACnF,IAAI,MAAM,UAAU,UAAU,OAAO;CACrC,IAAI,MAAM,UAAU,aAAa,OAAO,mBAAmB,mBAAmB,MAAM,WAAW,EAAE;CACjG,IAAI,CAAC,MAAM,aAAa,MAAM,IAAI,MAAM,qDAAqD;CAC7F,OAAO,mBAAmB,mBAAmB,MAAM,WAAW,EAAE,YAAY,mBAAmB,MAAM,SAAS,EAAE;AAClH;;AASA,SAAgB,kBAAkB,UAA6C;CAC7E,IAAI,aAAa,WAAW,OAAO,EAAE,OAAO,SAAS;CACrD,MAAM,QAAQ,4DAA4D,KAAK,QAAQ;CACvF,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,IAAI;EACF,MAAM,cAAc,mBAAmB,MAAM,EAAE;EAC/C,OAAO,MAAM,OAAO,KAAA,IAChB;GAAE,OAAO;GAAa;EAAY,IAClC;GAAE,OAAO;GAAW;GAAa,WAAW,mBAAmB,MAAM,EAAE;EAAE;CAC/E,QAAQ;EACN;CACF;AACF;;AAGA,MAAa,sBAAsB;;AAEnC,MAAa,iCAAiC;;AAG9C,MAAa,gCAAgC;AAC7C,MAAa,iCAAiC;AAC9C,MAAa,+BAA+B;AAC5C,MAAa,wBAAwB;CACnC;CACA;CACA;AACF;;AAQA,SAAgB,gBAAgB,SAA2C;CACzE,MAAM,WAAW,QAAQ,IAAI,6BAA6B;CAC1D,MAAM,WAAW,QAAQ,IAAI,8BAA8B;CAC3D,MAAM,SAAS,QAAQ,IAAI,4BAA4B;CACvD,IAAI,aAAa,SACf,OAAO,aAAa,QAAQ,WAAW,iBAAiB;EAAE;EAAU;CAAO,IAAI,KAAA;CAEjF,IACE,aAAa,YACb,aAAa,QACb,aAAa,OACZ,WAAW,kBAAkB,WAAW,cAAc,WAAW,gBAElE,OAAO;EAAE;EAAU;EAAU;CAAO;AAGxC;;AA4GA,MAAa,mCACX"}
|
|
1
|
+
{"version":3,"file":"packageApi.mjs","names":[],"sources":["../../../src/schemas/packageApi.ts"],"sourcesContent":["/**\n * The HTTP surface a package offers its host.\n *\n * A server plugin registers one with its host. The host mounts it under the API\n * route prefix, and the package writes routes relative to that mount.\n *\n * The handler is a plain fetch callback so no host and no package is committed\n * to one HTTP framework; a Hono app satisfies it through `app.fetch`.\n */\n\nimport type {\n PoComputerUseSessionAccess,\n PoDirectEventBus,\n PoHubSessionService,\n PoSessionCommunicationEndpoint,\n PoSessionActivity,\n PoSessionContext,\n} from './hubChannel';\nimport type { PoMcpProjection } from './mcpProjection';\nimport type { PoSessionStorageService } from './platform';\n/** The host-owned sync view a repository-scoped package API may inspect. */\nexport interface PoRepositorySyncView {\n fresh: boolean;\n reasons: string[];\n /** True while a background sync that may prepare what `reasons` names is running. */\n syncing?: boolean;\n mcpProjection?: PoMcpProjection;\n}\n\n/** Where an API runs: inside one session's server, or in the machine-wide hub. */\nexport type PoApiScope = 'global' | 'workspace' | 'session';\n\nexport const PO_API_SCOPES: readonly PoApiScope[] = ['global', 'workspace', 'session'];\n\n/** Identity of an independently mounted plugin host. */\nexport type PoApiMount =\n | { scope: 'global' }\n | { scope: 'workspace'; workspaceId: string }\n | { scope: 'session'; sessionId: string };\n\n/** Immutable browser contribution generation paired with a server mount. */\nexport interface PoWebComposition {\n id: string;\n scope: PoApiScope;\n revision: number;\n manifestUrl: string;\n rawAssetBaseUrl: string;\n verifiedAssetBaseUrl: string;\n /** `[slot, entry]` for each of this mount's plugin copies, the entry an absolute path below the asset prefixes. */\n pluginEntries: [string, string][];\n /** Every signed file this mount's slots can load, absolute below the asset prefixes. */\n assetPaths: string[];\n /** Per-plugin stylesheets of this mount's plugins only, so other mounts' classes never apply here. */\n stylePaths: string[];\n channels: string[];\n /** The slots resolved for this mount; the shared build may hold more. */\n plugins: string[];\n}\n\n/**\n * Immutable native contribution generation paired with a server mount. One signed CommonJS module at\n * `entryPath`, served through the same immutable plugin routes as web compositions.\n */\nexport interface PoNativeComposition {\n id: string;\n scope: PoApiScope;\n revision: number;\n manifestUrl: string;\n rawAssetBaseUrl: string;\n /** Always `/composition.js`. */\n entryPath: string;\n channels: string[];\n /** The `poNative.pluginId` values resolved for this mount; the shell installs only these. */\n plugins: string[];\n}\n\n/** Canonical public prefix. Scope selection never falls through to a parent. */\nexport function poApiMountPath(mount: PoApiMount & { workspaceId?: string }): string {\n if (mount.scope === 'global') return '/api/plugins';\n if (mount.scope === 'workspace') return `/api/workspaces/${encodeURIComponent(mount.workspaceId)}/plugins`;\n if (!mount.workspaceId) throw new Error('A session API path requires its workspace identity.');\n return `/api/workspaces/${encodeURIComponent(mount.workspaceId)}/sessions/${encodeURIComponent(mount.sessionId)}/plugins`;\n}\n\n/** Scope addressed by a public WebSocket upgrade. */\nexport type PoSocketMount =\n | { scope: 'global' }\n | { scope: 'workspace'; workspaceId: string }\n | { scope: 'session'; workspaceId: string; sessionId: string };\n\n/** Only canonical resource paths may select a protocol listener. */\nexport function parsePoSocketPath(pathname: string): PoSocketMount | undefined {\n if (pathname === '/api/ws') return { scope: 'global' };\n const match = /^\\/api\\/workspaces\\/([^/]+)(?:\\/sessions\\/([^/]+))?\\/ws$/u.exec(pathname);\n if (!match) return undefined;\n try {\n const workspaceId = decodeURIComponent(match[1]);\n return match[2] === undefined\n ? { scope: 'workspace', workspaceId }\n : { scope: 'session', workspaceId, sessionId: decodeURIComponent(match[2]) };\n } catch {\n return undefined;\n }\n}\n\n/** The segment an API is mounted under, below this prefix. */\nexport const PO_API_ROUTE_PREFIX = '/api/plugins';\n/** Selects the hub API bundle that owns the named cockpit session. */\nexport const PO_HUB_API_SESSION_QUERY_PARAM = 'hubSession';\n\n/** Trusted caller headers written only by the cockpit-to-session proxy. */\nexport const PO_API_CALLER_LOCALITY_HEADER = 'x-po-api-caller-locality';\nexport const PO_API_CALLER_DEVICE_ID_HEADER = 'x-po-api-caller-device-id';\nexport const PO_API_CALLER_STEP_UP_HEADER = 'x-po-api-caller-step-up';\nexport const PO_API_CALLER_HEADERS = [\n PO_API_CALLER_LOCALITY_HEADER,\n PO_API_CALLER_DEVICE_ID_HEADER,\n PO_API_CALLER_STEP_UP_HEADER,\n] as const;\n\nexport type PoApiCallerStepUp = 'not-required' | 'verified' | 'unavailable';\nexport type PoApiCaller =\n | { locality: 'local'; stepUp: 'not-required' }\n | { locality: 'remote'; deviceId: string; stepUp: PoApiCallerStepUp };\n\n/** Reads the proxy-authenticated caller identity, rejecting partial or contradictory stamps. */\nexport function poApiCallerFrom(headers: Headers): PoApiCaller | undefined {\n const locality = headers.get(PO_API_CALLER_LOCALITY_HEADER);\n const deviceId = headers.get(PO_API_CALLER_DEVICE_ID_HEADER);\n const stepUp = headers.get(PO_API_CALLER_STEP_UP_HEADER);\n if (locality === 'local') {\n return deviceId === null && stepUp === 'not-required' ? { locality, stepUp } : undefined;\n }\n if (\n locality === 'remote' &&\n deviceId !== null &&\n deviceId !== '' &&\n (stepUp === 'not-required' || stepUp === 'verified' || stepUp === 'unavailable')\n ) {\n return { locality, deviceId, stepUp };\n }\n return undefined;\n}\n/**\n * A browser-reachable OAuth redirect the host serves on its own listener.\n *\n * A package brokering third-party OAuth cannot use a loopback redirect when the\n * operator's browser is on another machine: `127.0.0.1` resolves to whichever\n * machine the browser runs on. The host owns a listener that is reachable from\n * wherever the cockpit is being used, so it lends that instead of the package\n * opening a port of its own.\n */\nexport interface PoOAuthRedirect {\n /** Absolute URL to register as the redirect target, already origin-correct. */\n readonly redirectUri: string;\n /**\n * Accept redirects carrying this state. Must complete before the\n * authorization URL is surfaced, or the redirect races its own reservation.\n */\n reserve(state: string, timeoutMs?: number): Promise<void>;\n /** Resolves once the redirect carrying this state arrives. */\n wait(state: string, timeoutMs?: number): Promise<{ code: string; state: string }>;\n /** Drops a reservation whose flow ended without a redirect. */\n cancel(state: string): void;\n}\n\n/** An exact, host-owned receipt address. Provider IDs are not event cursor positions. */\nexport interface PoRequestReceiptKey {\n namespace: string;\n activationId: string;\n requestId: string;\n}\n\nexport interface PoRequestReceipt extends PoRequestReceiptKey {\n fingerprint: string;\n destination: string;\n transactionId: string;\n outcome: 'reserved' | 'admitted' | 'rejected' | 'uncertain';\n}\n\nexport interface PoRequestReceiptReservation extends PoRequestReceiptKey {\n /** Lowercase SHA-256 of the authoritative request text, never the full transcript. */\n fingerprint: string;\n destination: string;\n transactionId: string;\n}\n\nexport type PoRequestReceiptReserveResult =\n | { kind: 'reserved'; token: string }\n | { kind: 'existing'; receipt: PoRequestReceipt }\n | { kind: 'conflict'; receipt: PoRequestReceipt };\n\n/** A global-only receipt capability. A reservation is not an execution receipt. */\nexport interface PoRequestReceipts {\n reserve(request: PoRequestReceiptReservation): Promise<PoRequestReceiptReserveResult>;\n lookup(key: PoRequestReceiptKey): Promise<PoRequestReceipt | undefined>;\n finish(\n request: PoRequestReceiptKey & { token: string; outcome: 'admitted' | 'rejected' | 'uncertain' },\n ): Promise<PoRequestReceipt>;\n}\n\n/** Permit returned for expensive local work. Calling it releases the slot. */\nexport interface PoHostExecutionPermit {\n (): void;\n attachProcess?(pid: number): Promise<void>;\n}\n\n/** Host-wide admission for expensive local work. Release only after the owned process exits. */\nexport interface PoHostExecutionBudget {\n acquire(signal?: AbortSignal): Promise<PoHostExecutionPermit>;\n getSnapshot(): Readonly<{ running: number; queued: number; limit: number }>;\n}\n\n/** Synchronous host-owned exclusion across media APIs mounted at different scopes. */\nexport interface PoHostMediaArbitration {\n register(busy: () => boolean): () => void;\n available(busy: () => boolean): boolean;\n}\n\n/** One host's paired agent registrations, shared across its global and session mounts. */\nexport interface PoPeerAgentRegistry {\n register(sessionId: string, agent: { fetch(request: Request): Promise<Response> }, hubToken: string): () => void;\n get(sessionId: string): { fetch(request: Request): Promise<Response>; hubToken: string } | undefined;\n}\n\n/** One agent that edits files: a hub session or an in-process child run. */\nexport interface PoEditPresenceAgent {\n /** `session:<id>` or `run:<runId>`. Unique across the host. */\n readonly key: string;\n /** Read when a note is rendered, so a name registered after the edit still shows. */\n readonly label: () => string;\n /** Hub session id other agents can reach with intercom. */\n readonly contact: string;\n readonly isLive: () => boolean;\n}\n\nexport interface PoEditPresenceEntry {\n readonly agent: PoEditPresenceAgent;\n /** `@file` tag of the bytes this agent's last successful edit or write left behind. */\n readonly tag: string;\n readonly at: number;\n}\n\n/**\n * Host-wide record of the last edit each live agent made to a file, keyed by realpath then agent key.\n * Owners delete their entries when they dispose, so no callback outlives its session or run.\n */\nexport type PoEditPresenceLedger = Map<string, Map<string, PoEditPresenceEntry>>;\n\n/** Why shareFile rejects while the host has no public tunnel origin. */\nexport const PO_SHARE_FILE_REMOTE_OFF_MESSAGE =\n 'Remote access is off, so Po cannot share files with remote MCP servers. Turn it on and retry.';\n\n/**\n * A file published at a short-lived public tunnel URL: 10 minutes, 3 downloads, and gone\n * when the tunnel revision changes. Call revoke as soon as the consumer is done with it.\n */\nexport interface PoSharedFile {\n /** Bearer link; never log or persist it. */\n url: string;\n fileName: string;\n mimeType: string;\n size: number;\n /** Expiry as epoch milliseconds. */\n expiresAt: number;\n maxDownloads: number;\n /** Idempotent. */\n revoke(): void;\n}\n\n/** What the host tells an API about itself when it starts. */\nexport interface PoApiContext {\n scope: PoApiScope;\n /** Stable, opaque workspace id, shared by every session and member checkout of the workspace. */\n workspaceId?: string;\n /**\n * The admitted workspace root for a workspace mount. For a session mount it is the checkout\n * the session runs in; read sessionContext for both roots. Absent from global mounts.\n */\n workspaceRoot?: string;\n /** The session's baseline context; present on session mounts whose host knows its workspace. */\n sessionContext?: PoSessionContext;\n /** Explicit host home, never selected by a remote request. */\n homeDirectory?: string;\n /** The session this host serves; absent for a hub-scoped API. */\n sessionId?: string;\n /** The session's working directory; absent for a hub-scoped API. */\n cwd?: string;\n /** Session environment admitted by the server, never supplied by remote clients. */\n environment?: Readonly<Record<string, string | undefined>>;\n /** Shared only with child processes in this session, never with remote API clients. */\n internalToken?: string;\n /** Shared only with the cockpit hub for privileged cross-session coordination. */\n hubToken?: string;\n /**\n * Resolves a hub-issued opaque repository id to an admitted canonical root.\n * Hub APIs must never accept a browser-supplied filesystem path instead.\n */\n resolveRepository?(repositoryId: string): string | undefined;\n /** Reads the admitted repository's sync projection without exposing its state path. */\n readRepositorySync?(\n repositoryId: string,\n ): Promise<PoRepositorySyncView | undefined> | PoRepositorySyncView | undefined;\n /** Admitted workspaces available to this mount. */\n repositories?(): readonly { id: string; name: string; path: string; active: boolean }[];\n /** Publish a successful config write to the owning mount's refresh lifecycle. */\n configurationChanged?(): void;\n /**\n * Borrows the hub's OAuth redirect surface. Undefined when the hub cannot\n * currently serve one, in which case the package keeps its own behaviour.\n */\n oauthRedirect?(): PoOAuthRedirect | undefined;\n /** Canonical in-process lifecycle for sessions created by this host. */\n sessionService?: PoHubSessionService;\n /** Trusted in-process storage capability. APIs must retain their mount's session authorization. */\n sessionStorage?: PoSessionStorageService;\n /** Host-bound, authenticated inter-session event endpoint for this session. */\n sessionCommunication?: PoSessionCommunicationEndpoint;\n /** Same-process events shared by session APIs and hub channels. */\n directEvents?: PoDirectEventBus;\n /**\n * Publishes this session's activity line to every page's rail; undefined clears it.\n * Session mounts only. The last publisher wins.\n */\n publishActivity?(activity: PoSessionActivity | undefined): void;\n /** Trusted in-process dispatch to an explicitly selected mounted API. No browser authentication is performed here. */\n requestApi?(mount: PoApiMount, basePath: string, request: Request): Promise<Response>;\n /** Present only on a session mounted by an authenticated Desktop host. */\n computerUse?: PoComputerUseSessionAccess;\n /** Deliver a typed method to the channel serving a session this mount reaches, retaining the caller's connection identity. */\n receiveChannel?(sessionId: string, frameType: string, payload: unknown, connectionId: string): boolean;\n /** Host-owned replay evidence, supplied only on the global mount. Never exposed to browsers or agents. */\n requestReceipts?: PoRequestReceipts;\n /** One host's exclusive media activity, shared across global and session scopes. */\n mediaArbitration?: PoHostMediaArbitration;\n /** One host-wide heavy-job budget, not a separate budget for every session. */\n executionBudget?: PoHostExecutionBudget;\n /** One host-wide edit presence ledger, shared by every session mount. */\n editPresence?: PoEditPresenceLedger;\n /** Paired agents belonging to this host only. */\n peerAgents?: PoPeerAgentRegistry;\n /** Machine-owned Remote Control service, mounted only by Po's own global server plugin. */\n remoteControl?: { fetch(request: Request): Promise<Response> };\n /**\n * Publishes a file from this session's cwd or attachments at a short-lived tunnel URL.\n * Session mounts only; rejects with PO_SHARE_FILE_REMOTE_OFF_MESSAGE while remote access is off.\n * The host asks no consent: the caller must obtain it before passing the URL on.\n */\n shareFile?(path: string, label: string): Promise<PoSharedFile>;\n onNotice(message: string): void;\n}\n\n/**\n * One running surface. The host strips the mount prefix before calling, so\n * routes are declared relative ('/runners/:id/log') and a package never\n * repeats where it was mounted.\n */\nexport interface PoApiHandler {\n fetch(request: Request): Response | Promise<Response>;\n close(): void;\n}\n\nexport interface PoApi {\n /** Segment under /api/plugins/; globally unique across loaded packages. */\n basePath: string;\n start(context: PoApiContext): PoApiHandler;\n}\n"],"mappings":";AAgCA,MAAa,gBAAuC;CAAC;CAAU;CAAa;AAAS;;AA6CrF,SAAgB,eAAe,OAAsD;CACnF,IAAI,MAAM,UAAU,UAAU,OAAO;CACrC,IAAI,MAAM,UAAU,aAAa,OAAO,mBAAmB,mBAAmB,MAAM,WAAW,EAAE;CACjG,IAAI,CAAC,MAAM,aAAa,MAAM,IAAI,MAAM,qDAAqD;CAC7F,OAAO,mBAAmB,mBAAmB,MAAM,WAAW,EAAE,YAAY,mBAAmB,MAAM,SAAS,EAAE;AAClH;;AASA,SAAgB,kBAAkB,UAA6C;CAC7E,IAAI,aAAa,WAAW,OAAO,EAAE,OAAO,SAAS;CACrD,MAAM,QAAQ,4DAA4D,KAAK,QAAQ;CACvF,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,IAAI;EACF,MAAM,cAAc,mBAAmB,MAAM,EAAE;EAC/C,OAAO,MAAM,OAAO,KAAA,IAChB;GAAE,OAAO;GAAa;EAAY,IAClC;GAAE,OAAO;GAAW;GAAa,WAAW,mBAAmB,MAAM,EAAE;EAAE;CAC/E,QAAQ;EACN;CACF;AACF;;AAGA,MAAa,sBAAsB;;AAEnC,MAAa,iCAAiC;;AAG9C,MAAa,gCAAgC;AAC7C,MAAa,iCAAiC;AAC9C,MAAa,+BAA+B;AAC5C,MAAa,wBAAwB;CACnC;CACA;CACA;AACF;;AAQA,SAAgB,gBAAgB,SAA2C;CACzE,MAAM,WAAW,QAAQ,IAAI,6BAA6B;CAC1D,MAAM,WAAW,QAAQ,IAAI,8BAA8B;CAC3D,MAAM,SAAS,QAAQ,IAAI,4BAA4B;CACvD,IAAI,aAAa,SACf,OAAO,aAAa,QAAQ,WAAW,iBAAiB;EAAE;EAAU;CAAO,IAAI,KAAA;CAEjF,IACE,aAAa,YACb,aAAa,QACb,aAAa,OACZ,WAAW,kBAAkB,WAAW,cAAc,WAAW,gBAElE,OAAO;EAAE;EAAU;EAAU;CAAO;AAGxC;;AA4GA,MAAa,mCACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.cjs","names":[],"sources":["../../../src/schemas/platform.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis';\nimport type { Context as IoContext } from '@earendil-works/chord';\nimport type { Storage } from '@earendil-works/pi-durable';\nimport type { ExecutionEnv, FileSystem, Shell } from '@earendil-works/pi-durable/env';\nimport type { SqliteDatabase } from '@earendil-works/pi-durable/storage/sqlite';\n\nexport const PO_FS_SERVICE = 'po/fs';\nexport const PO_SHELL_SERVICE = 'po/shell';\nexport const PO_SQLITE_SERVICE = 'po/sqlite';\nexport const PO_SESSION_STORAGE_SERVICE = 'po/session-storage';\n\nexport interface PoSqliteService {\n readonly abiVersion: 1;\n /** Node: the database file at this path. Edge: the owning Durable Object's single database. */\n open(file: string, context: IoContext): Promise<SqliteDatabase>;\n}\n\n/** One agent session's storage, held by a single writer until released. */\nexport interface PoSessionStorage {\n readonly storage: Storage;\n /** Throws once another writer may own the session; checked before every write. */\n assertWritable(): void | Promise<void>;\n /** Closes `storage` and gives the session up, after its harness closed. */\n release(context: IoContext): Promise<void>;\n}\n\nexport interface PoSessionStorageRequest {\n /** Omitted for a new session, which gets a fresh id. */\n readonly sessionId?: string;\n /** Recorded on a new session. */\n readonly parentSessionId?: string;\n /** Resume only: refuse to create a session that was never stored. */\n readonly existing?: boolean;\n}\n\nexport interface PoStoredSession {\n readonly sessionId: string;\n /** Epoch milliseconds of the session's last write. */\n readonly updatedAt: number;\n}\n\n/**\n * Where agent sessions live, keyed by session id: one SQLite file per session on Node, the\n * Durable Object's own SQLite on the edge. Callers never see a file, a path or a database.\n */\nexport interface PoSessionStorageService {\n readonly abiVersion: 1;\n open(request: PoSessionStorageRequest, context: IoContext): Promise<PoSessionStorage>;\n /** A stored session without taking ownership or migrating it. The caller closes the storage. */\n openReadOnly(sessionId: string, context: IoContext): Promise<Storage>;\n list(context: IoContext): Promise<readonly PoStoredSession[]>;\n}\n\n/** Host capabilities one composition root runs on: Node in the CLI, a Durable Object on the edge. */\nexport interface PoPlatform {\n readonly abiVersion: 1;\n readonly homeDirectory: string;\n /** Files and shell rooted at `cwd`; pi-durable `FileSystem` and `Shell`. */\n env(cwd: string): ExecutionEnv;\n readonly sqlite: PoSqliteService;\n readonly sessions: PoSessionStorageService;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'po/fs': FileSystem;\n 'po/shell': Shell;\n 'po/sqlite': PoSqliteService;\n 'po/session-storage': PoSessionStorageService;\n }\n}\n\nexport function readPoFs(context: Context): FileSystem | undefined {\n return context.get(PO_FS_SERVICE) as FileSystem | undefined;\n}\n\nexport function requirePoFs(context: Context): FileSystem {\n const service = readPoFs(context);\n if (!service) throw new Error(`The '${PO_FS_SERVICE}' service is unavailable. Start a Po server first.`);\n return service;\n}\n\nexport function requirePoShell(context: Context): Shell {\n const service = context.get(PO_SHELL_SERVICE) as Shell | undefined;\n if (!service) throw new Error(`The '${PO_SHELL_SERVICE}' service is unavailable. Start a Po server first.`);\n return service;\n}\n\nexport function requirePoSqlite(context: Context): PoSqliteService {\n const service = context.get(PO_SQLITE_SERVICE) as PoSqliteService | undefined;\n if (!service) throw new Error(`The '${PO_SQLITE_SERVICE}' service is unavailable. Start a Po server first.`);\n return service;\n}\n"],"mappings":";AAMA,MAAa,gBAAgB;AAC7B,MAAa,mBAAmB;AAChC,MAAa,oBAAoB;AACjC,MAAa,6BAA6B;
|
|
1
|
+
{"version":3,"file":"platform.cjs","names":[],"sources":["../../../src/schemas/platform.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis';\nimport type { Context as IoContext } from '@earendil-works/chord';\nimport type { Storage } from '@earendil-works/pi-durable';\nimport type { ExecutionEnv, FileSystem, Shell } from '@earendil-works/pi-durable/env';\nimport type { SqliteDatabase } from '@earendil-works/pi-durable/storage/sqlite';\n\nexport const PO_FS_SERVICE = 'po/fs';\nexport const PO_SHELL_SERVICE = 'po/shell';\nexport const PO_SQLITE_SERVICE = 'po/sqlite';\nexport const PO_SESSION_STORAGE_SERVICE = 'po/session-storage';\n\nexport interface PoSqliteService {\n readonly abiVersion: 1;\n /** Node: the database file at this path. Edge: the owning Durable Object's single database. */\n open(file: string, context: IoContext): Promise<SqliteDatabase>;\n}\n\n/** One agent session's storage, held by a single writer until released. */\nexport interface PoSessionStorage {\n readonly storage: Storage;\n /** Throws once another writer may own the session; checked before every write. */\n assertWritable(): void | Promise<void>;\n /** Closes `storage` and gives the session up, after its harness closed. */\n release(context: IoContext): Promise<void>;\n}\n\nexport interface PoSessionStorageRequest {\n /** Omitted for a new session, which gets a fresh id. */\n readonly sessionId?: string;\n /** Recorded on a new session. */\n readonly parentSessionId?: string;\n /** Resume only: refuse to create a session that was never stored. */\n readonly existing?: boolean;\n}\n\nexport interface PoStoredSession {\n readonly sessionId: string;\n /** Epoch milliseconds of the session's last write. */\n readonly updatedAt: number;\n}\n\n/**\n * Where agent sessions live, keyed by session id: one SQLite file per session on Node, the\n * Durable Object's own SQLite on the edge. Callers never see a file, a path or a database.\n */\nexport interface PoSessionStorageService {\n readonly abiVersion: 1;\n open(request: PoSessionStorageRequest, context: IoContext): Promise<PoSessionStorage>;\n /** A stored session without taking ownership or migrating it. The caller closes the storage. */\n openReadOnly(sessionId: string, context: IoContext): Promise<Storage>;\n list(context: IoContext): Promise<readonly PoStoredSession[]>;\n}\n\n/** Host capabilities one composition root runs on: Node in the CLI, a Durable Object on the edge. */\nexport interface PoPlatform {\n readonly abiVersion: 1;\n readonly homeDirectory: string;\n /** Host-selected base for session output; absent on older embedding platforms. */\n readonly temporaryDirectory?: string;\n /** Files and shell rooted at `cwd`; pi-durable `FileSystem` and `Shell`. */\n env(cwd: string): ExecutionEnv;\n readonly sqlite: PoSqliteService;\n readonly sessions: PoSessionStorageService;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'po/fs': FileSystem;\n 'po/shell': Shell;\n 'po/sqlite': PoSqliteService;\n 'po/session-storage': PoSessionStorageService;\n 'po/session-files': { readonly temporaryDirectory: string };\n }\n}\n\nexport function readPoFs(context: Context): FileSystem | undefined {\n return context.get(PO_FS_SERVICE) as FileSystem | undefined;\n}\n\nexport function requirePoFs(context: Context): FileSystem {\n const service = readPoFs(context);\n if (!service) throw new Error(`The '${PO_FS_SERVICE}' service is unavailable. Start a Po server first.`);\n return service;\n}\n\nexport function requirePoShell(context: Context): Shell {\n const service = context.get(PO_SHELL_SERVICE) as Shell | undefined;\n if (!service) throw new Error(`The '${PO_SHELL_SERVICE}' service is unavailable. Start a Po server first.`);\n return service;\n}\n\nexport function requirePoSqlite(context: Context): PoSqliteService {\n const service = context.get(PO_SQLITE_SERVICE) as PoSqliteService | undefined;\n if (!service) throw new Error(`The '${PO_SQLITE_SERVICE}' service is unavailable. Start a Po server first.`);\n return service;\n}\n"],"mappings":";AAMA,MAAa,gBAAgB;AAC7B,MAAa,mBAAmB;AAChC,MAAa,oBAAoB;AACjC,MAAa,6BAA6B;AAkE1C,SAAgB,SAAS,SAA0C;CACjE,OAAO,QAAQ,IAAI,aAAa;AAClC;AAEA,SAAgB,YAAY,SAA8B;CACxD,MAAM,UAAU,SAAS,OAAO;CAChC,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,QAAQ,cAAc,mDAAmD;CACvG,OAAO;AACT;AAEA,SAAgB,eAAe,SAAyB;CACtD,MAAM,UAAU,QAAQ,IAAI,gBAAgB;CAC5C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,QAAQ,iBAAiB,mDAAmD;CAC1G,OAAO;AACT;AAEA,SAAgB,gBAAgB,SAAmC;CACjE,MAAM,UAAU,QAAQ,IAAI,iBAAiB;CAC7C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,QAAQ,kBAAkB,mDAAmD;CAC3G,OAAO;AACT"}
|
|
@@ -49,6 +49,8 @@ export interface PoSessionStorageService {
|
|
|
49
49
|
export interface PoPlatform {
|
|
50
50
|
readonly abiVersion: 1;
|
|
51
51
|
readonly homeDirectory: string;
|
|
52
|
+
/** Host-selected base for session output; absent on older embedding platforms. */
|
|
53
|
+
readonly temporaryDirectory?: string;
|
|
52
54
|
/** Files and shell rooted at `cwd`; pi-durable `FileSystem` and `Shell`. */
|
|
53
55
|
env(cwd: string): ExecutionEnv;
|
|
54
56
|
readonly sqlite: PoSqliteService;
|
|
@@ -60,6 +62,9 @@ declare module '@deepseek-ai/cordis' {
|
|
|
60
62
|
'po/shell': Shell;
|
|
61
63
|
'po/sqlite': PoSqliteService;
|
|
62
64
|
'po/session-storage': PoSessionStorageService;
|
|
65
|
+
'po/session-files': {
|
|
66
|
+
readonly temporaryDirectory: string;
|
|
67
|
+
};
|
|
63
68
|
}
|
|
64
69
|
}
|
|
65
70
|
export declare function readPoFs(context: Context): FileSystem | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.mts","names":["IoContext"],"sources":["../../../src/schemas/platform.ts"],"mappings":";;;;;;qBAMa;qBACA;qBACA;qBACA;iBAEI;WACN;;EAET,KAAK,cAAc,SAASA,YAAY,QAAQ;;;iBAIjC;WACN,SAAS;;EAElB,yBAAyB;;EAEzB,QAAQ,SAASA,YAAY;;iBAGd;;WAEN;;WAEA;;WAEA;;iBAGM;WACN;;WAEA;;;;;;iBAOM;WACN;EACT,KAAK,SAAS,yBAAyB,SAASA,YAAY,QAAQ;;EAEpE,aAAa,mBAAmB,SAASA,YAAY,QAAQ;EAC7D,KAAK,SAASA,YAAY,iBAAiB;;;iBAI5B;WACN;WACA;;EAET,IAAI,cAAc;WACT,QAAQ;WACR,UAAU;;;YAIT;IACR,SAAS;IACT,YAAY;IACZ,aAAa;IACb,sBAAsB
|
|
1
|
+
{"version":3,"file":"platform.d.mts","names":["IoContext"],"sources":["../../../src/schemas/platform.ts"],"mappings":";;;;;;qBAMa;qBACA;qBACA;qBACA;iBAEI;WACN;;EAET,KAAK,cAAc,SAASA,YAAY,QAAQ;;;iBAIjC;WACN,SAAS;;EAElB,yBAAyB;;EAEzB,QAAQ,SAASA,YAAY;;iBAGd;;WAEN;;WAEA;;WAEA;;iBAGM;WACN;;WAEA;;;;;;iBAOM;WACN;EACT,KAAK,SAAS,yBAAyB,SAASA,YAAY,QAAQ;;EAEpE,aAAa,mBAAmB,SAASA,YAAY,QAAQ;EAC7D,KAAK,SAASA,YAAY,iBAAiB;;;iBAI5B;WACN;WACA;;WAEA;;EAET,IAAI,cAAc;WACT,QAAQ;WACR,UAAU;;;YAIT;IACR,SAAS;IACT,YAAY;IACZ,aAAa;IACb,sBAAsB;IACtB;eAA+B;;;;wBAInB,SAAS,SAAS,UAAU;wBAI5B,YAAY,SAAS,UAAU;wBAM/B,eAAe,SAAS,UAAU;wBAMlC,gBAAgB,SAAS,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.mjs","names":[],"sources":["../../../src/schemas/platform.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis';\nimport type { Context as IoContext } from '@earendil-works/chord';\nimport type { Storage } from '@earendil-works/pi-durable';\nimport type { ExecutionEnv, FileSystem, Shell } from '@earendil-works/pi-durable/env';\nimport type { SqliteDatabase } from '@earendil-works/pi-durable/storage/sqlite';\n\nexport const PO_FS_SERVICE = 'po/fs';\nexport const PO_SHELL_SERVICE = 'po/shell';\nexport const PO_SQLITE_SERVICE = 'po/sqlite';\nexport const PO_SESSION_STORAGE_SERVICE = 'po/session-storage';\n\nexport interface PoSqliteService {\n readonly abiVersion: 1;\n /** Node: the database file at this path. Edge: the owning Durable Object's single database. */\n open(file: string, context: IoContext): Promise<SqliteDatabase>;\n}\n\n/** One agent session's storage, held by a single writer until released. */\nexport interface PoSessionStorage {\n readonly storage: Storage;\n /** Throws once another writer may own the session; checked before every write. */\n assertWritable(): void | Promise<void>;\n /** Closes `storage` and gives the session up, after its harness closed. */\n release(context: IoContext): Promise<void>;\n}\n\nexport interface PoSessionStorageRequest {\n /** Omitted for a new session, which gets a fresh id. */\n readonly sessionId?: string;\n /** Recorded on a new session. */\n readonly parentSessionId?: string;\n /** Resume only: refuse to create a session that was never stored. */\n readonly existing?: boolean;\n}\n\nexport interface PoStoredSession {\n readonly sessionId: string;\n /** Epoch milliseconds of the session's last write. */\n readonly updatedAt: number;\n}\n\n/**\n * Where agent sessions live, keyed by session id: one SQLite file per session on Node, the\n * Durable Object's own SQLite on the edge. Callers never see a file, a path or a database.\n */\nexport interface PoSessionStorageService {\n readonly abiVersion: 1;\n open(request: PoSessionStorageRequest, context: IoContext): Promise<PoSessionStorage>;\n /** A stored session without taking ownership or migrating it. The caller closes the storage. */\n openReadOnly(sessionId: string, context: IoContext): Promise<Storage>;\n list(context: IoContext): Promise<readonly PoStoredSession[]>;\n}\n\n/** Host capabilities one composition root runs on: Node in the CLI, a Durable Object on the edge. */\nexport interface PoPlatform {\n readonly abiVersion: 1;\n readonly homeDirectory: string;\n /** Files and shell rooted at `cwd`; pi-durable `FileSystem` and `Shell`. */\n env(cwd: string): ExecutionEnv;\n readonly sqlite: PoSqliteService;\n readonly sessions: PoSessionStorageService;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'po/fs': FileSystem;\n 'po/shell': Shell;\n 'po/sqlite': PoSqliteService;\n 'po/session-storage': PoSessionStorageService;\n }\n}\n\nexport function readPoFs(context: Context): FileSystem | undefined {\n return context.get(PO_FS_SERVICE) as FileSystem | undefined;\n}\n\nexport function requirePoFs(context: Context): FileSystem {\n const service = readPoFs(context);\n if (!service) throw new Error(`The '${PO_FS_SERVICE}' service is unavailable. Start a Po server first.`);\n return service;\n}\n\nexport function requirePoShell(context: Context): Shell {\n const service = context.get(PO_SHELL_SERVICE) as Shell | undefined;\n if (!service) throw new Error(`The '${PO_SHELL_SERVICE}' service is unavailable. Start a Po server first.`);\n return service;\n}\n\nexport function requirePoSqlite(context: Context): PoSqliteService {\n const service = context.get(PO_SQLITE_SERVICE) as PoSqliteService | undefined;\n if (!service) throw new Error(`The '${PO_SQLITE_SERVICE}' service is unavailable. Start a Po server first.`);\n return service;\n}\n"],"mappings":";AAMA,MAAa,gBAAgB;AAC7B,MAAa,mBAAmB;AAChC,MAAa,oBAAoB;AACjC,MAAa,6BAA6B;
|
|
1
|
+
{"version":3,"file":"platform.mjs","names":[],"sources":["../../../src/schemas/platform.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis';\nimport type { Context as IoContext } from '@earendil-works/chord';\nimport type { Storage } from '@earendil-works/pi-durable';\nimport type { ExecutionEnv, FileSystem, Shell } from '@earendil-works/pi-durable/env';\nimport type { SqliteDatabase } from '@earendil-works/pi-durable/storage/sqlite';\n\nexport const PO_FS_SERVICE = 'po/fs';\nexport const PO_SHELL_SERVICE = 'po/shell';\nexport const PO_SQLITE_SERVICE = 'po/sqlite';\nexport const PO_SESSION_STORAGE_SERVICE = 'po/session-storage';\n\nexport interface PoSqliteService {\n readonly abiVersion: 1;\n /** Node: the database file at this path. Edge: the owning Durable Object's single database. */\n open(file: string, context: IoContext): Promise<SqliteDatabase>;\n}\n\n/** One agent session's storage, held by a single writer until released. */\nexport interface PoSessionStorage {\n readonly storage: Storage;\n /** Throws once another writer may own the session; checked before every write. */\n assertWritable(): void | Promise<void>;\n /** Closes `storage` and gives the session up, after its harness closed. */\n release(context: IoContext): Promise<void>;\n}\n\nexport interface PoSessionStorageRequest {\n /** Omitted for a new session, which gets a fresh id. */\n readonly sessionId?: string;\n /** Recorded on a new session. */\n readonly parentSessionId?: string;\n /** Resume only: refuse to create a session that was never stored. */\n readonly existing?: boolean;\n}\n\nexport interface PoStoredSession {\n readonly sessionId: string;\n /** Epoch milliseconds of the session's last write. */\n readonly updatedAt: number;\n}\n\n/**\n * Where agent sessions live, keyed by session id: one SQLite file per session on Node, the\n * Durable Object's own SQLite on the edge. Callers never see a file, a path or a database.\n */\nexport interface PoSessionStorageService {\n readonly abiVersion: 1;\n open(request: PoSessionStorageRequest, context: IoContext): Promise<PoSessionStorage>;\n /** A stored session without taking ownership or migrating it. The caller closes the storage. */\n openReadOnly(sessionId: string, context: IoContext): Promise<Storage>;\n list(context: IoContext): Promise<readonly PoStoredSession[]>;\n}\n\n/** Host capabilities one composition root runs on: Node in the CLI, a Durable Object on the edge. */\nexport interface PoPlatform {\n readonly abiVersion: 1;\n readonly homeDirectory: string;\n /** Host-selected base for session output; absent on older embedding platforms. */\n readonly temporaryDirectory?: string;\n /** Files and shell rooted at `cwd`; pi-durable `FileSystem` and `Shell`. */\n env(cwd: string): ExecutionEnv;\n readonly sqlite: PoSqliteService;\n readonly sessions: PoSessionStorageService;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'po/fs': FileSystem;\n 'po/shell': Shell;\n 'po/sqlite': PoSqliteService;\n 'po/session-storage': PoSessionStorageService;\n 'po/session-files': { readonly temporaryDirectory: string };\n }\n}\n\nexport function readPoFs(context: Context): FileSystem | undefined {\n return context.get(PO_FS_SERVICE) as FileSystem | undefined;\n}\n\nexport function requirePoFs(context: Context): FileSystem {\n const service = readPoFs(context);\n if (!service) throw new Error(`The '${PO_FS_SERVICE}' service is unavailable. Start a Po server first.`);\n return service;\n}\n\nexport function requirePoShell(context: Context): Shell {\n const service = context.get(PO_SHELL_SERVICE) as Shell | undefined;\n if (!service) throw new Error(`The '${PO_SHELL_SERVICE}' service is unavailable. Start a Po server first.`);\n return service;\n}\n\nexport function requirePoSqlite(context: Context): PoSqliteService {\n const service = context.get(PO_SQLITE_SERVICE) as PoSqliteService | undefined;\n if (!service) throw new Error(`The '${PO_SQLITE_SERVICE}' service is unavailable. Start a Po server first.`);\n return service;\n}\n"],"mappings":";AAMA,MAAa,gBAAgB;AAC7B,MAAa,mBAAmB;AAChC,MAAa,oBAAoB;AACjC,MAAa,6BAA6B;AAkE1C,SAAgB,SAAS,SAA0C;CACjE,OAAO,QAAQ,IAAI,aAAa;AAClC;AAEA,SAAgB,YAAY,SAA8B;CACxD,MAAM,UAAU,SAAS,OAAO;CAChC,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,QAAQ,cAAc,mDAAmD;CACvG,OAAO;AACT;AAEA,SAAgB,eAAe,SAAyB;CACtD,MAAM,UAAU,QAAQ,IAAI,gBAAgB;CAC5C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,QAAQ,iBAAiB,mDAAmD;CAC1G,OAAO;AACT;AAEA,SAAgB,gBAAgB,SAAmC;CACjE,MAAM,UAAU,QAAQ,IAAI,iBAAiB;CAC7C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,QAAQ,kBAAkB,mDAAmD;CAC3G,OAAO;AACT"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_serverScope = require("../schemas/serverScope.cjs");
|
|
2
2
|
const require_headless = require("../schemas/headless.cjs");
|
|
3
|
+
const require_index = require("../services/sessionFiles/index.cjs");
|
|
3
4
|
const require_liveImport = require("./liveImport.cjs");
|
|
4
5
|
const require_platform = require("../schemas/platform.cjs");
|
|
5
6
|
const require_serverPlugin = require("../schemas/serverPlugin.cjs");
|
|
@@ -133,6 +134,7 @@ function platformProvider(context, input) {
|
|
|
133
134
|
context.provide(require_platform.PO_SHELL_SERVICE, env);
|
|
134
135
|
context.provide(require_platform.PO_SQLITE_SERVICE, input.platform.sqlite);
|
|
135
136
|
context.provide(require_platform.PO_SESSION_STORAGE_SERVICE, input.platform.sessions);
|
|
137
|
+
if (input.temporaryDirectory !== void 0) context.provide(require_index.PO_SESSION_FILES_SERVICE, { temporaryDirectory: input.temporaryDirectory });
|
|
136
138
|
context.effect(() => () => env.cleanup(dist_interop_chordContext_mjs.BACKGROUND_CONTEXT), "platform execution env");
|
|
137
139
|
}
|
|
138
140
|
/**
|
|
@@ -197,7 +199,8 @@ var PoServerScope = class PoServerScope {
|
|
|
197
199
|
const cwd = hostContext?.cwd ?? hostContext?.workspaceRoot ?? input.platform.homeDirectory;
|
|
198
200
|
await this.root.plugin(platformProvider, {
|
|
199
201
|
platform: input.platform,
|
|
200
|
-
cwd
|
|
202
|
+
cwd,
|
|
203
|
+
temporaryDirectory: this.level === "session" ? hostContext?.environment?.[require_index.PO_SESSION_TEMP_DIR] : void 0
|
|
201
204
|
});
|
|
202
205
|
}
|
|
203
206
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverScope.cjs","names":["PO_SERVER_SCOPE_LEVELS","Service","PO_SERVER_SCOPE_SERVICE","PO_SERVER_HOST_SERVICE","readPoHeadlessHost","PO_FS_SERVICE","PO_SHELL_SERVICE","PO_SQLITE_SERVICE","PO_SESSION_STORAGE_SERVICE","BACKGROUND_CONTEXT","Context","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 { PO_HEADLESS_OWNER, readPoHeadlessHost } from '../schemas/headless';\nimport type { PoApiHandler, PoApiScope } from '../schemas/packageApi';\nimport {\n PO_FS_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 PO_SERVER_SCOPE_SERVICE,\n type PoServerPluginShare,\n type PoServerResourceKey,\n type PoServerResourceLease,\n type PoServerScopeService,\n type PoServiceContract,\n} from '../schemas/serverScope';\nimport { LIVE_FACTORY_TIMEOUT_MS, withTimeout } from './liveImport';\nimport type { LoadedServerPackage } from './serverPackages';\n\ninterface Binding {\n readonly name: string;\n readonly value: unknown;\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\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}\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\n/** Publishes one binding as a native service of the root it is plugged into. */\nfunction bindingProvider(context: Context, binding: Binding): void {\n context.provide(binding.name, binding.value);\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(() => this.scope.bind(contract, value), `po scope provide ${contract.name}`);\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(context: Context, input: { platform: PoPlatform; cwd: string }): 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 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 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\n private constructor(\n readonly level: PoApiScope,\n readonly parent: PoServerScope | undefined,\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 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 await this.root.plugin(platformProvider, { platform: input.platform, cwd });\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 * Binds a contract owned by this level here and in every descendant, including ones opened later.\n * Settles once every descendant root publishes it. Hosts call this directly; plugins go through\n * the scope service so the binding follows their fiber.\n */\n async bind<T>(contract: PoServiceContract<T>, value: T): 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 = { name: contract.name, value };\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([...this.subtree()].map((scope) => scope.unmirror(binding)));\n };\n try {\n await Promise.all([...this.subtree()].map((scope) => scope.mirror(binding)));\n } catch (error) {\n await withdraw();\n throw error;\n }\n return withdraw;\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 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 { fiber } of packages) await fiber.dispose();\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 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 previous.fiber.dispose();\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 await this.restore(name, previous, options, message);\n continue;\n }\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. */\n private async restore(\n name: string,\n previous: InstalledPackage,\n options: PoServerInstallOptions,\n message: string,\n ): Promise<void> {\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 } catch (rollbackError) {\n this.notice(`${message}; its previous build could not be restored (${describe(rollbackError)}).`);\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 owner = declaration ? this.root.extend({ [PO_HEADLESS_OWNER]: declaration }) : this.root;\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 await fiber?.dispose();\n throw error;\n }\n }\n\n private visible(): Binding[] {\n return [...(this.parent?.visible() ?? []), ...this.bound.values()];\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 /**\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`.\n */\n private async mirror(binding: Binding): Promise<void> {\n if (this.disposed) return;\n let fiber = this.mirrors.get(binding);\n if (fiber === undefined) {\n fiber = this.root.plugin(bindingProvider, binding);\n this.mirrors.set(binding, fiber);\n }\n await fiber.await();\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":";;;;;;;;;AA6CA,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;AA0B/G,MAAM,SAAS,UAA8BA,oBAAAA,uBAAuB,QAAQ,KAAK;AAEjF,MAAM,YAAY,UAA4B,iBAAiB,Q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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_SERVER_SCOPE_SERVICE","PO_SERVER_HOST_SERVICE","readPoHeadlessHost","PO_FS_SERVICE","PO_SHELL_SERVICE","PO_SQLITE_SERVICE","PO_SESSION_STORAGE_SERVICE","PO_SESSION_FILES_SERVICE","BACKGROUND_CONTEXT","Context","PO_SESSION_TEMP_DIR","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 { PO_HEADLESS_OWNER, readPoHeadlessHost } from '../schemas/headless';\nimport type { PoApiHandler, PoApiScope } from '../schemas/packageApi';\nimport {\n PO_FS_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 PO_SERVER_SCOPE_SERVICE,\n type PoServerPluginShare,\n type PoServerResourceKey,\n type PoServerResourceLease,\n type PoServerScopeService,\n type PoServiceContract,\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 value: unknown;\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\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}\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\n/** Publishes one binding as a native service of the root it is plugged into. */\nfunction bindingProvider(context: Context, binding: Binding): void {\n context.provide(binding.name, binding.value);\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(() => this.scope.bind(contract, value), `po scope provide ${contract.name}`);\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.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 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\n private constructor(\n readonly level: PoApiScope,\n readonly parent: PoServerScope | undefined,\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 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 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 * 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 * Binds a contract owned by this level here and in every descendant, including ones opened later.\n * Settles once every descendant root publishes it. Hosts call this directly; plugins go through\n * the scope service so the binding follows their fiber.\n */\n async bind<T>(contract: PoServiceContract<T>, value: T): 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 = { name: contract.name, value };\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([...this.subtree()].map((scope) => scope.unmirror(binding)));\n };\n try {\n await Promise.all([...this.subtree()].map((scope) => scope.mirror(binding)));\n } catch (error) {\n await withdraw();\n throw error;\n }\n return withdraw;\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 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 { fiber } of packages) await fiber.dispose();\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 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 previous.fiber.dispose();\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 await this.restore(name, previous, options, message);\n continue;\n }\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. */\n private async restore(\n name: string,\n previous: InstalledPackage,\n options: PoServerInstallOptions,\n message: string,\n ): Promise<void> {\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 } catch (rollbackError) {\n this.notice(`${message}; its previous build could not be restored (${describe(rollbackError)}).`);\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 owner = declaration ? this.root.extend({ [PO_HEADLESS_OWNER]: declaration }) : this.root;\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 await fiber?.dispose();\n throw error;\n }\n }\n\n private visible(): Binding[] {\n return [...(this.parent?.visible() ?? []), ...this.bound.values()];\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 /**\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`.\n */\n private async mirror(binding: Binding): Promise<void> {\n if (this.disposed) return;\n let fiber = this.mirrors.get(binding);\n if (fiber === undefined) {\n fiber = this.root.plugin(bindingProvider, binding);\n this.mirrors.set(binding, fiber);\n }\n await fiber.await();\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":";;;;;;;;;;AA8CA,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;AA0B/G,MAAM,SAAS,UAA8BA,oBAAAA,uBAAuB,QAAQ,KAAK;AAEjF,MAAM,YAAY,UAA4B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;;AAGnG,SAAS,gB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AAM,MAAM;CACpB;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverScope.d.mts","names":[],"sources":["../../../src/server/serverScope.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"serverScope.d.mts","names":[],"sources":["../../../src/server/serverScope.ts"],"mappings":";;;;;;;;iBAyDiB;;;;;WAKN,MAAM;IAAwB,YAAY,mBAAmB;;;WAE7D,UAAU;;iBAGJ;WACN;WACA;WACA;;iBAGM;WACN,YAAY;;WAEZ;;WAEA,oBAAoB,QAAQ;;;;;;;;;;;qBA8J1B;WAiBA,OAAO;WACP,QAAQ;WAjBV,MAAI;mBACI;mBACA;mBACA;mBACA;UACT;;UAEA;UACA;UACA;;UAEA;;mBAES;UAEV;;SAMM,KAAK,OAAO,YAAY,SAAS,gBAAgB,QAAQ;MAgBlE;;;;;;EASE,MAAM,OAAO,oBAAoB;;;;;;;;;;EAyBvC,QACE,oBAAoB,iBAAiB,wBACrC,UAAS,yBACR;;;;;;EAcG,KAAK,GAAG,UAAU,kBAAkB,IAAI,OAAO,IAAI,cAAc;EAwBvE,QAAQ,GAAG,UAAU,kBAAkB,KAAK;;;;;;EAc5C,WAAW,mBAAmB;EAQ9B,KAAK,gBAAgB,QAAQ,MAAM,MAAM,MAAM,WAAW,OAAO;EAIjE,UAAU,gBAAgB,QAAQ,MAAM,MAAM,MAAM,WAAW,OAAO;;;;;EAQtE,WAAW;;;;;EA0BX,MAAM,QAAQ,gBAAgB,oBAAoB;UAmFpC;;UAyDA;;UAgBA;UAqCN;;UAKA;;UAKM;UAYL;UAKA;;;;;UAUK;UAUA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PO_SERVER_SCOPE_LEVELS, PO_SERVER_SCOPE_SERVICE } from "../schemas/serverScope.mjs";
|
|
2
2
|
import { PO_HEADLESS_OWNER, readPoHeadlessHost } from "../schemas/headless.mjs";
|
|
3
|
+
import { PO_SESSION_FILES_SERVICE, PO_SESSION_TEMP_DIR } from "../services/sessionFiles/index.mjs";
|
|
3
4
|
import { withTimeout } from "./liveImport.mjs";
|
|
4
5
|
import { PO_FS_SERVICE, PO_SESSION_STORAGE_SERVICE, PO_SHELL_SERVICE, PO_SQLITE_SERVICE } from "../schemas/platform.mjs";
|
|
5
6
|
import { PO_SERVER_HOST_SERVICE } from "../schemas/serverPlugin.mjs";
|
|
@@ -133,6 +134,7 @@ function platformProvider(context, input) {
|
|
|
133
134
|
context.provide(PO_SHELL_SERVICE, env);
|
|
134
135
|
context.provide(PO_SQLITE_SERVICE, input.platform.sqlite);
|
|
135
136
|
context.provide(PO_SESSION_STORAGE_SERVICE, input.platform.sessions);
|
|
137
|
+
if (input.temporaryDirectory !== void 0) context.provide(PO_SESSION_FILES_SERVICE, { temporaryDirectory: input.temporaryDirectory });
|
|
136
138
|
context.effect(() => () => env.cleanup(BACKGROUND_CONTEXT), "platform execution env");
|
|
137
139
|
}
|
|
138
140
|
/**
|
|
@@ -197,7 +199,8 @@ var PoServerScope = class PoServerScope {
|
|
|
197
199
|
const cwd = hostContext?.cwd ?? hostContext?.workspaceRoot ?? input.platform.homeDirectory;
|
|
198
200
|
await this.root.plugin(platformProvider, {
|
|
199
201
|
platform: input.platform,
|
|
200
|
-
cwd
|
|
202
|
+
cwd,
|
|
203
|
+
temporaryDirectory: this.level === "session" ? hostContext?.environment?.[PO_SESSION_TEMP_DIR] : void 0
|
|
201
204
|
});
|
|
202
205
|
}
|
|
203
206
|
/**
|