@agimon-ai/po-session 0.0.0-alpha.3 → 0.0.0-alpha.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.cjs","names":["Type","jsonApiResponses","defineApiContract"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type DoomHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\n/** The endpoint validates its own HMAC peer credential because tunnel device authentication is intentionally bypassed. */\nconst http: DoomHttpContract[] = [\n {\n id: 'peer-inbox',\n scope: 'global',\n basePath: 'session-peer',\n method: 'POST',\n path: '/inbox',\n authentication: 'none',\n description:\n 'Accept an HMAC-authenticated durable Session delivery envelope from an explicitly configured tunnel peer.',\n body: { contentType: 'application/json', required: true, schema: Type.Unknown() },\n responses: jsonApiResponses(Type.Object({ accepted: Type.Boolean(), state: Type.String() })),\n },\n];\n\nexport const apiContracts = defineApiContract({ version: 1, http, sockets: [], dynamic: [] });\nexport default apiContracts;\n"],"mappings":";;;;;;;;AAIA,MAAM,OAA2B,CAC/B;CACE,IAAI;CACJ,OAAO;CACP,UAAU;CACV,QAAQ;CACR,MAAM;CACN,gBAAgB;CAChB,aACE;CACF,MAAM;EAAE,aAAa;EAAoB,UAAU;EAAM,QAAQA,QAAAA,KAAK,QAAQ;CAAE;CAChF,YAAA,GAAWC,gCAAAA,iBAAAA,CAAiBD,QAAAA,KAAK,OAAO;EAAE,UAAUA,QAAAA,KAAK,QAAQ;EAAG,OAAOA,QAAAA,KAAK,OAAO;CAAE,CAAC,CAAC;AAC7F,CACF;AAEA,MAAa,gBAAA,GAAeE,gCAAAA,kBAAAA,CAAkB;CAAE,SAAS;CAAG;CAAM,SAAS,CAAC;CAAG,SAAS,CAAC;AAAE,CAAC"}
1
+ {"version":3,"file":"apiContracts.cjs","names":["Type","jsonApiResponses","defineApiContract"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\n/** The endpoint validates its own HMAC peer credential because tunnel device authentication is intentionally bypassed. */\nconst http: PoHttpContract[] = [\n {\n id: 'peer-inbox',\n scope: 'global',\n basePath: 'session-peer',\n method: 'POST',\n path: '/inbox',\n authentication: 'none',\n description:\n 'Accept an HMAC-authenticated durable Session delivery envelope from an explicitly configured tunnel peer.',\n body: { contentType: 'application/json', required: true, schema: Type.Unknown() },\n responses: jsonApiResponses(Type.Object({ accepted: Type.Boolean(), state: Type.String() })),\n },\n];\n\nexport const apiContracts = defineApiContract({ version: 1, http, sockets: [], dynamic: [] });\nexport default apiContracts;\n"],"mappings":";;;;;;;;AAIA,MAAM,OAAyB,CAC7B;CACE,IAAI;CACJ,OAAO;CACP,UAAU;CACV,QAAQ;CACR,MAAM;CACN,gBAAgB;CAChB,aACE;CACF,MAAM;EAAE,aAAa;EAAoB,UAAU;EAAM,QAAQA,QAAAA,KAAK,QAAQ;CAAE;CAChF,YAAA,GAAWC,gCAAAA,iBAAAA,CAAiBD,QAAAA,KAAK,OAAO;EAAE,UAAUA,QAAAA,KAAK,QAAQ;EAAG,OAAOA,QAAAA,KAAK,OAAO;CAAE,CAAC,CAAC;AAC7F,CACF;AAEA,MAAa,gBAAA,GAAeE,gCAAAA,kBAAAA,CAAkB;CAAE,SAAS;CAAG;CAAM,SAAS,CAAC;CAAG,SAAS,CAAC;AAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type DoomHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\n/** The endpoint validates its own HMAC peer credential because tunnel device authentication is intentionally bypassed. */\nconst http: DoomHttpContract[] = [\n {\n id: 'peer-inbox',\n scope: 'global',\n basePath: 'session-peer',\n method: 'POST',\n path: '/inbox',\n authentication: 'none',\n description:\n 'Accept an HMAC-authenticated durable Session delivery envelope from an explicitly configured tunnel peer.',\n body: { contentType: 'application/json', required: true, schema: Type.Unknown() },\n responses: jsonApiResponses(Type.Object({ accepted: Type.Boolean(), state: Type.String() })),\n },\n];\n\nexport const apiContracts = defineApiContract({ version: 1, http, sockets: [], dynamic: [] });\nexport default apiContracts;\n"],"mappings":";;;;AAIA,MAAM,OAA2B,CAC/B;CACE,IAAI;CACJ,OAAO;CACP,UAAU;CACV,QAAQ;CACR,MAAM;CACN,gBAAgB;CAChB,aACE;CACF,MAAM;EAAE,aAAa;EAAoB,UAAU;EAAM,QAAQ,KAAK,QAAQ;CAAE;CAChF,WAAW,iBAAiB,KAAK,OAAO;EAAE,UAAU,KAAK,QAAQ;EAAG,OAAO,KAAK,OAAO;CAAE,CAAC,CAAC;AAC7F,CACF;AAEA,MAAa,eAAe,kBAAkB;CAAE,SAAS;CAAG;CAAM,SAAS,CAAC;CAAG,SAAS,CAAC;AAAE,CAAC"}
1
+ {"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\n/** The endpoint validates its own HMAC peer credential because tunnel device authentication is intentionally bypassed. */\nconst http: PoHttpContract[] = [\n {\n id: 'peer-inbox',\n scope: 'global',\n basePath: 'session-peer',\n method: 'POST',\n path: '/inbox',\n authentication: 'none',\n description:\n 'Accept an HMAC-authenticated durable Session delivery envelope from an explicitly configured tunnel peer.',\n body: { contentType: 'application/json', required: true, schema: Type.Unknown() },\n responses: jsonApiResponses(Type.Object({ accepted: Type.Boolean(), state: Type.String() })),\n },\n];\n\nexport const apiContracts = defineApiContract({ version: 1, http, sockets: [], dynamic: [] });\nexport default apiContracts;\n"],"mappings":";;;;AAIA,MAAM,OAAyB,CAC7B;CACE,IAAI;CACJ,OAAO;CACP,UAAU;CACV,QAAQ;CACR,MAAM;CACN,gBAAgB;CAChB,aACE;CACF,MAAM;EAAE,aAAa;EAAoB,UAAU;EAAM,QAAQ,KAAK,QAAQ;CAAE;CAChF,WAAW,iBAAiB,KAAK,OAAO;EAAE,UAAU,KAAK,QAAQ;EAAG,OAAO,KAAK,OAAO;CAAE,CAAC,CAAC;AAC7F,CACF;AAEA,MAAa,eAAe,kBAAkB;CAAE,SAAS;CAAG;CAAM,SAAS,CAAC;CAAG,SAAS,CAAC;AAAE,CAAC"}
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_sessionDelivery = require("../sessionDelivery-CkKlRYAK.cjs");
5
+ const require_sessionDelivery = require("../sessionDelivery-D7PFBTSg.cjs");
6
6
  let node_path = require("node:path");
7
7
  node_path = require_sessionDelivery.__toESM(node_path, 1);
8
8
  let _agimon_ai_po_core_platform = require("@agimon-ai/po-core/platform");
@@ -37,8 +37,8 @@ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)((plug
37
37
  const homeDirectory = pluginContext.host.context.homeDirectory;
38
38
  const sessionService = pluginContext.host.context.sessionService;
39
39
  if (!agent || !session?.admitPrompt || !communication || !homeDirectory || !sessionService?.canCommunicate) throw new Error("Session delivery requires the headless agent, authenticated session communication, host home directory, and communication policy.");
40
- const fs = (0, _agimon_ai_po_core_platform.requireDoomFs)(pluginContext.context);
41
- const sqlite = (0, _agimon_ai_po_core_platform.requireDoomSqlite)(pluginContext.context);
40
+ const fs = (0, _agimon_ai_po_core_platform.requirePoFs)(pluginContext.context);
41
+ const sqlite = (0, _agimon_ai_po_core_platform.requirePoSqlite)(pluginContext.context);
42
42
  const io = _agimon_ai_po_core_platform.BACKGROUND_CONTEXT;
43
43
  const sessionDirectory = node_path.default.join((0, _agimon_ai_po_core_piSettings.poHomeDirectory)(homeDirectory), "session");
44
44
  const deliveryDirectory = node_path.default.join(sessionDirectory, "delivery");
@@ -99,7 +99,7 @@ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)((plug
99
99
  readiness: "unknown"
100
100
  }
101
101
  });
102
- unprovide.push(context.provide(require_sessionDelivery.DOOM_SESSION_INTERCOM_SERVICE, require_sessionDelivery.createSessionIntercom({
102
+ unprovide.push(context.provide(require_sessionDelivery.PO_SESSION_INTERCOM_SERVICE, require_sessionDelivery.createSessionIntercom({
103
103
  selfReference,
104
104
  directory,
105
105
  groups,
@@ -118,7 +118,7 @@ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)((plug
118
118
  //#endregion
119
119
  //#region src/services/peerInboxApi/index.ts
120
120
  const MAX_BODY_BYTES = 65536;
121
- const DELIVERY_TYPES = /* @__PURE__ */ new Set(["doom/session-delivery/envelope", "doom/session-delivery/ack"]);
121
+ const DELIVERY_TYPES = /* @__PURE__ */ new Set(["po/session-delivery/envelope", "po/session-delivery/ack"]);
122
122
  function response(status, error) {
123
123
  return Response.json({ error }, { status });
124
124
  }
@@ -182,8 +182,8 @@ function createPeerInboxApi(platform) {
182
182
  //#endregion
183
183
  //#region src/extensions/(backend)/api/session-peer/route.server.ts
184
184
  var route_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoute)(({ context }) => createPeerInboxApi({
185
- fs: (0, _agimon_ai_po_core_platform.requireDoomFs)(context),
186
- sqlite: (0, _agimon_ai_po_core_platform.requireDoomSqlite)(context)
185
+ fs: (0, _agimon_ai_po_core_platform.requirePoFs)(context),
186
+ sqlite: (0, _agimon_ai_po_core_platform.requirePoSqlite)(context)
187
187
  }));
188
188
  //#endregion
189
189
  //#region generated/server.ts
@@ -1 +1 @@
1
- {"version":3,"file":"server.cjs","names":["defineRoot","provideBackgroundWorkService","requireDoomFs","requireDoomSqlite","BACKGROUND_CONTEXT","path","poHomeDirectory","ensurePrivateDirectory","readSessionPeerConfigAsync","createPeerCommunication","parseRemoteSessionReference","createSessionGroupStore","peerSessionReference","createSessionGroupDeliveryAuthorizer","provideSessionDeliveryService","createSessionDirectory","DOOM_SESSION_INTERCOM_SERVICE","createSessionIntercom","readSessionPeerConfigAsync","BACKGROUND_CONTEXT","path","sessionPeerConfigPath","PEER_REPLAY_DATABASE_FILE","ensurePrivateDirectory","createPeerReplayGuardAsync","verifyPeerRequest","parseSessionPeerEnvelope","peerSessionReference","defineRoute","requireDoomFs","requireDoomSqlite","defineServerPlugin","composeServerProviderOverrides","rootSession","apiRoute","composeRootHooks"],"sources":["../../src/services/peerInbox/index.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/services/peerInboxApi/index.ts","../../src/extensions/(backend)/api/session-peer/route.server.ts","../../generated/server.ts"],"sourcesContent":["import type { DoomSessionDeliveryInboxState } from '../sessionDelivery';\n\nexport type SessionPeerInbox = (\n sourceKey: string,\n type: string,\n payload: unknown,\n) => Promise<DoomSessionDeliveryInboxState | undefined> | undefined;\n\nconst inboxes = new Map<string, SessionPeerInbox>();\n\n/**\n * Registers one live session-owned peer inbox. This registry is reachable only by the Session route.\n * The newest registration wins: a Durable Object evicted without disposal leaves its entry in the\n * isolate's module state, and the restarted session must replace it. The hub still rejects two live\n * sessions with one id, and an older unregister cannot remove a newer inbox.\n */\nexport function registerSessionPeerInbox(sessionId: string, inbox: SessionPeerInbox): () => void {\n inboxes.set(sessionId, inbox);\n return () => {\n if (inboxes.get(sessionId) === inbox) inboxes.delete(sessionId);\n };\n}\n\nexport async function deliverSessionPeerEnvelope(\n targetSessionId: string,\n sourceKey: string,\n type: string,\n payload: unknown,\n): Promise<DoomSessionDeliveryInboxState | undefined> {\n return inboxes.get(targetSessionId)?.(sourceKey, type, payload);\n}\n","import path from 'node:path';\n\nimport { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport { poHomeDirectory } from '@agimon-ai/po-core/piSettings';\nimport { BACKGROUND_CONTEXT, requireDoomFs, requireDoomSqlite } from '@agimon-ai/po-core/platform';\nimport type { DoomServerPluginContext } from '@agimon-ai/po-core/serverFacet';\n\nimport { provideBackgroundWorkService } from '../../../../services/backgroundWorkService';\nimport { registerSessionPeerInbox } from '../../../../services/peerInbox';\nimport {\n createPeerCommunication,\n ensurePrivateDirectory,\n parseRemoteSessionReference,\n peerSessionReference,\n readSessionPeerConfigAsync,\n} from '../../../../services/peerTransport';\nimport { provideSessionDeliveryService } from '../../../../services/sessionDelivery';\nimport { createSessionDirectory } from '../../../../services/sessionDirectory';\nimport { createSessionGroupStore } from '../../../../services/sessionGroups';\nimport {\n DOOM_SESSION_INTERCOM_SERVICE,\n createSessionGroupDeliveryAuthorizer,\n createSessionIntercom,\n} from '../../../../services/sessionIntercom';\n\nexport default defineRoot((pluginContext: DoomServerPluginContext) => ({\n value: undefined,\n services: [\n provideBackgroundWorkService,\n async (context) => {\n const agent = pluginContext.agent;\n const session = agent?.context.session;\n const communication = pluginContext.host.context.sessionCommunication;\n const homeDirectory = pluginContext.host.context.homeDirectory;\n const sessionService = pluginContext.host.context.sessionService;\n if (!agent || !session?.admitPrompt || !communication || !homeDirectory || !sessionService?.canCommunicate) {\n throw new Error(\n 'Session delivery requires the headless agent, authenticated session communication, host home directory, and communication policy.',\n );\n }\n const fs = requireDoomFs(pluginContext.context);\n const sqlite = requireDoomSqlite(pluginContext.context);\n const io = BACKGROUND_CONTEXT;\n const sessionDirectory = path.join(poHomeDirectory(homeDirectory), 'session');\n const deliveryDirectory = path.join(sessionDirectory, 'delivery');\n await ensurePrivateDirectory(fs, deliveryDirectory, io);\n const peerConfig = await readSessionPeerConfigAsync(fs, homeDirectory, io);\n const peerCommunication = createPeerCommunication({ local: communication, config: peerConfig });\n const remotePeerIsGranted = (peerKey: string): boolean => {\n const peer = parseRemoteSessionReference(peerKey);\n return (\n peer !== undefined &&\n peerConfig?.peers.some(\n (candidate) =>\n candidate.hostId === peer.hostId && candidate.allowedSessionIds.includes(agent.context.sessionId),\n ) === true\n );\n };\n const fallbackAuthorization = (peerKey: string): boolean =>\n sessionService.canCommunicate?.(agent.context.sessionId, peerKey) === true || remotePeerIsGranted(peerKey);\n const groups = peerConfig\n ? await createSessionGroupStore({\n database: await sqlite.open(path.join(sessionDirectory, 'groups.sqlite'), io),\n })\n : undefined;\n const localHostId = peerConfig?.hostId;\n const selfReference = localHostId ? peerSessionReference(localHostId, agent.context.sessionId) : undefined;\n const groupAuthorization =\n groups && selfReference && localHostId\n ? createSessionGroupDeliveryAuthorizer({\n selfReference,\n groups,\n peerReference: (peerKey) =>\n parseRemoteSessionReference(peerKey) === undefined\n ? peerSessionReference(localHostId, peerKey)\n : peerKey,\n fallback: fallbackAuthorization,\n })\n : undefined;\n let delivery: Awaited<ReturnType<typeof provideSessionDeliveryService>>;\n try {\n delivery = await provideSessionDeliveryService(context, {\n database: await sqlite.open(path.join(deliveryDirectory, `${agent.context.sessionId}.sqlite`), io),\n recipientKey: agent.context.sessionId,\n communication: peerCommunication,\n authorizePeer: (peerKey, metadata) =>\n groupAuthorization ? groupAuthorization(peerKey, metadata) : fallbackAuthorization(peerKey),\n admitPrompt: (prompt, admission) => session.admitPrompt!(prompt, admission),\n });\n } catch (error) {\n await groups?.close();\n throw error;\n }\n const { service, close: closeDelivery } = delivery;\n const unprovide: (() => void)[] = [];\n if (groups && selfReference && peerConfig) {\n const directory = createSessionDirectory({\n authorizeDiscovery: async (caller, subject) => {\n const reference = peerSessionReference(subject.hostId, subject.sessionId);\n const permitted = (await groups.groupsFor(caller)).some((group) => group.members.includes(reference));\n return permitted ? { capabilities: ['message'] } : undefined;\n },\n });\n for (const peer of peerConfig.peers)\n for (const sessionId of peer.allowedSessionIds)\n directory.observe({\n hostId: peer.hostId,\n sessionId,\n hostIncarnation: 'unknown',\n sessionIncarnation: 'unknown',\n sequence: 0,\n observedAt: 0,\n staleAfterMs: 0,\n deliveryTarget: peerSessionReference(peer.hostId, sessionId),\n reachability: 'unknown',\n runtime: 'unknown',\n activity: 'unknown',\n voice: { eligible: 'unknown', readiness: 'unknown' },\n });\n unprovide.push(\n context.provide(\n DOOM_SESSION_INTERCOM_SERVICE,\n createSessionIntercom({ selfReference, directory, groups, delivery: service }),\n ),\n );\n }\n const unregister = registerSessionPeerInbox(agent.context.sessionId, (sourceKey, kind, payload) =>\n service.receive?.(sourceKey, kind, payload),\n );\n return async () => {\n unregister();\n for (const release of unprovide.reverse()) release();\n await closeDelivery();\n await groups?.close();\n };\n },\n ],\n}));\n","import path from 'node:path';\n\nimport type { DoomApi, DoomApiHandler } from '@agimon-ai/po-core/packageApi';\nimport { BACKGROUND_CONTEXT, type DoomSqliteService, type FileSystem } from '@agimon-ai/po-core/platform';\n\nimport { deliverSessionPeerEnvelope } from '../peerInbox';\nimport {\n PEER_REPLAY_DATABASE_FILE,\n createPeerReplayGuardAsync,\n ensurePrivateDirectory,\n parseSessionPeerEnvelope,\n peerSessionReference,\n readSessionPeerConfigAsync,\n sessionPeerConfigPath,\n verifyPeerRequest,\n type SessionPeerConfig,\n type SessionPeerReplayGuardAsync,\n} from '../peerTransport';\n\nconst MAX_BODY_BYTES = 64 * 1024;\nconst DELIVERY_TYPES = new Set(['doom/session-delivery/envelope', 'doom/session-delivery/ack']);\n\nfunction response(status: number, error: string): Response {\n return Response.json({ error }, { status });\n}\n\ninterface PeerInboxState {\n readonly config: SessionPeerConfig | undefined;\n readonly replay: SessionPeerReplayGuardAsync | undefined;\n}\n\n/** Narrow HMAC-authenticated endpoint that a trusted tunnel may forward without device authentication. */\nexport function createPeerInboxApi(platform: { readonly fs: FileSystem; readonly sqlite: DoomSqliteService }): DoomApi {\n return {\n basePath: 'session-peer',\n start(context): DoomApiHandler {\n const homeDirectory = context.homeDirectory;\n // Opened once on first use: the handler starts synchronously, the platform services are async.\n let opened: Promise<PeerInboxState> | undefined;\n const open = (): Promise<PeerInboxState> =>\n (opened ??= (async () => {\n if (homeDirectory === undefined) return { config: undefined, replay: undefined };\n const config = await readSessionPeerConfigAsync(platform.fs, homeDirectory, BACKGROUND_CONTEXT);\n const file = path.join(path.dirname(sessionPeerConfigPath(homeDirectory)), PEER_REPLAY_DATABASE_FILE);\n await ensurePrivateDirectory(platform.fs, path.dirname(file), BACKGROUND_CONTEXT);\n const replay = await createPeerReplayGuardAsync(await platform.sqlite.open(file, BACKGROUND_CONTEXT));\n return { config, replay };\n })().catch((error: unknown) => {\n // A failed open is retried by the next request rather than cached.\n opened = undefined;\n throw error;\n }));\n return {\n async fetch(request) {\n if (request.method !== 'POST' || new URL(request.url).pathname !== '/inbox')\n return response(404, 'Not found.');\n const { config, replay } = await open();\n if (!config) return response(503, 'Paired Session delivery is not configured.');\n const length = request.headers.get('content-length');\n if (length !== null && (!/^\\d+$/u.test(length) || Number(length) > MAX_BODY_BYTES))\n return response(413, 'Request body is too large.');\n const body = await request.text();\n if (Buffer.byteLength(body) > MAX_BODY_BYTES) return response(413, 'Request body is too large.');\n const peer = verifyPeerRequest(config, request, body);\n if (!peer) return response(401, 'Paired Session request is unauthorized.');\n if (!(await replay?.admit(request))) return response(409, 'Paired Session request was already received.');\n let parsed: unknown;\n try {\n parsed = JSON.parse(body) as unknown;\n } catch {\n return response(400, 'Paired Session request is malformed.');\n }\n const envelope = parseSessionPeerEnvelope(parsed);\n if (!envelope || !DELIVERY_TYPES.has(envelope.type))\n return response(400, 'Paired Session envelope is invalid.');\n if (!peer.allowedSessionIds.includes(envelope.targetSessionId))\n return response(403, 'Peer is not granted this session.');\n const state = await deliverSessionPeerEnvelope(\n envelope.targetSessionId,\n peerSessionReference(peer.hostId, envelope.sourceSessionId),\n envelope.type,\n envelope.payload,\n );\n return state === undefined\n ? response(404, 'Target Session is unavailable.')\n : Response.json({ accepted: true, state }, { status: 202 });\n },\n async close() {\n const state = await opened?.catch(() => undefined);\n await state?.replay?.close();\n },\n };\n },\n };\n}\n","import { defineRoute } from '@agimon-ai/po-core/extensionFile';\nimport { requireDoomFs, requireDoomSqlite } from '@agimon-ai/po-core/platform';\nimport type { DoomServerPluginContext } from '@agimon-ai/po-core/serverFacet';\n\nimport { createPeerInboxApi } from '../../../../services/peerInboxApi';\n\nexport default defineRoute(({ context }: DoomServerPluginContext) =>\n createPeerInboxApi({ fs: requireDoomFs(context), sqlite: requireDoomSqlite(context) }),\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverFacet';\nimport { composeRootHooks } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport apiRoute from '../src/extensions/(backend)/api/session-peer/route.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\n\nexport const facet = defineServerPlugin({\n name: '@agimon-ai/po-session',\n providerOverrides: composeServerProviderOverrides(rootSession),\n global: (context) => ({\n get api(): DoomServerSessionPlugin['api'] { return [at(apiRoute, context)]; },\n }),\n workspace: (context) => ({\n get api(): DoomServerSessionPlugin['api'] { return [at(apiRoute, context)]; },\n }),\n session: async (context) => {\n const scopeSession = await rootSession(context);\n return {\n ...composeRootHooks(scopeSession),\n get api(): DoomServerSessionPlugin['api'] { return [at(apiRoute, context)]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): DoomServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default facet;\n"],"mappings":";;;;;;;;;;;;AAQA,MAAM,0BAAU,IAAI,IAA8B;;;;;;;AAQlD,SAAgB,yBAAyB,WAAmB,OAAqC;CAC/F,QAAQ,IAAI,WAAW,KAAK;CAC5B,aAAa;EACX,IAAI,QAAQ,IAAI,SAAS,MAAM,OAAO,QAAQ,OAAO,SAAS;CAChE;AACF;AAEA,eAAsB,2BACpB,iBACA,WACA,MACA,SACoD;CACpD,OAAO,QAAQ,IAAI,eAAe,CAAC,GAAG,WAAW,MAAM,OAAO;AAChE;;;ACLA,IAAA,uBAAA,GAAeA,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,IAAI,aAAoD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACzG;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"server.cjs","names":["defineRoot","provideBackgroundWorkService","requirePoFs","requirePoSqlite","BACKGROUND_CONTEXT","path","poHomeDirectory","ensurePrivateDirectory","readSessionPeerConfigAsync","createPeerCommunication","parseRemoteSessionReference","createSessionGroupStore","peerSessionReference","createSessionGroupDeliveryAuthorizer","provideSessionDeliveryService","createSessionDirectory","PO_SESSION_INTERCOM_SERVICE","createSessionIntercom","readSessionPeerConfigAsync","BACKGROUND_CONTEXT","path","sessionPeerConfigPath","PEER_REPLAY_DATABASE_FILE","ensurePrivateDirectory","createPeerReplayGuardAsync","verifyPeerRequest","parseSessionPeerEnvelope","peerSessionReference","defineRoute","requirePoFs","requirePoSqlite","defineServerPlugin","composeServerProviderOverrides","rootSession","apiRoute","composeRootHooks"],"sources":["../../src/services/peerInbox/index.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/services/peerInboxApi/index.ts","../../src/extensions/(backend)/api/session-peer/route.server.ts","../../generated/server.ts"],"sourcesContent":["import type { PoSessionDeliveryInboxState } from '../sessionDelivery';\n\nexport type SessionPeerInbox = (\n sourceKey: string,\n type: string,\n payload: unknown,\n) => Promise<PoSessionDeliveryInboxState | undefined> | undefined;\n\nconst inboxes = new Map<string, SessionPeerInbox>();\n\n/**\n * Registers one live session-owned peer inbox. This registry is reachable only by the Session route.\n * The newest registration wins: a Durable Object evicted without disposal leaves its entry in the\n * isolate's module state, and the restarted session must replace it. The hub still rejects two live\n * sessions with one id, and an older unregister cannot remove a newer inbox.\n */\nexport function registerSessionPeerInbox(sessionId: string, inbox: SessionPeerInbox): () => void {\n inboxes.set(sessionId, inbox);\n return () => {\n if (inboxes.get(sessionId) === inbox) inboxes.delete(sessionId);\n };\n}\n\nexport async function deliverSessionPeerEnvelope(\n targetSessionId: string,\n sourceKey: string,\n type: string,\n payload: unknown,\n): Promise<PoSessionDeliveryInboxState | undefined> {\n return inboxes.get(targetSessionId)?.(sourceKey, type, payload);\n}\n","import path from 'node:path';\n\nimport { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport { poHomeDirectory } from '@agimon-ai/po-core/piSettings';\nimport { BACKGROUND_CONTEXT, requirePoFs, requirePoSqlite } from '@agimon-ai/po-core/platform';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverFacet';\n\nimport { provideBackgroundWorkService } from '../../../../services/backgroundWorkService';\nimport { registerSessionPeerInbox } from '../../../../services/peerInbox';\nimport {\n createPeerCommunication,\n ensurePrivateDirectory,\n parseRemoteSessionReference,\n peerSessionReference,\n readSessionPeerConfigAsync,\n} from '../../../../services/peerTransport';\nimport { provideSessionDeliveryService } from '../../../../services/sessionDelivery';\nimport { createSessionDirectory } from '../../../../services/sessionDirectory';\nimport { createSessionGroupStore } from '../../../../services/sessionGroups';\nimport {\n PO_SESSION_INTERCOM_SERVICE,\n createSessionGroupDeliveryAuthorizer,\n createSessionIntercom,\n} from '../../../../services/sessionIntercom';\n\nexport default defineRoot((pluginContext: PoServerPluginContext) => ({\n value: undefined,\n services: [\n provideBackgroundWorkService,\n async (context) => {\n const agent = pluginContext.agent;\n const session = agent?.context.session;\n const communication = pluginContext.host.context.sessionCommunication;\n const homeDirectory = pluginContext.host.context.homeDirectory;\n const sessionService = pluginContext.host.context.sessionService;\n if (!agent || !session?.admitPrompt || !communication || !homeDirectory || !sessionService?.canCommunicate) {\n throw new Error(\n 'Session delivery requires the headless agent, authenticated session communication, host home directory, and communication policy.',\n );\n }\n const fs = requirePoFs(pluginContext.context);\n const sqlite = requirePoSqlite(pluginContext.context);\n const io = BACKGROUND_CONTEXT;\n const sessionDirectory = path.join(poHomeDirectory(homeDirectory), 'session');\n const deliveryDirectory = path.join(sessionDirectory, 'delivery');\n await ensurePrivateDirectory(fs, deliveryDirectory, io);\n const peerConfig = await readSessionPeerConfigAsync(fs, homeDirectory, io);\n const peerCommunication = createPeerCommunication({ local: communication, config: peerConfig });\n const remotePeerIsGranted = (peerKey: string): boolean => {\n const peer = parseRemoteSessionReference(peerKey);\n return (\n peer !== undefined &&\n peerConfig?.peers.some(\n (candidate) =>\n candidate.hostId === peer.hostId && candidate.allowedSessionIds.includes(agent.context.sessionId),\n ) === true\n );\n };\n const fallbackAuthorization = (peerKey: string): boolean =>\n sessionService.canCommunicate?.(agent.context.sessionId, peerKey) === true || remotePeerIsGranted(peerKey);\n const groups = peerConfig\n ? await createSessionGroupStore({\n database: await sqlite.open(path.join(sessionDirectory, 'groups.sqlite'), io),\n })\n : undefined;\n const localHostId = peerConfig?.hostId;\n const selfReference = localHostId ? peerSessionReference(localHostId, agent.context.sessionId) : undefined;\n const groupAuthorization =\n groups && selfReference && localHostId\n ? createSessionGroupDeliveryAuthorizer({\n selfReference,\n groups,\n peerReference: (peerKey) =>\n parseRemoteSessionReference(peerKey) === undefined\n ? peerSessionReference(localHostId, peerKey)\n : peerKey,\n fallback: fallbackAuthorization,\n })\n : undefined;\n let delivery: Awaited<ReturnType<typeof provideSessionDeliveryService>>;\n try {\n delivery = await provideSessionDeliveryService(context, {\n database: await sqlite.open(path.join(deliveryDirectory, `${agent.context.sessionId}.sqlite`), io),\n recipientKey: agent.context.sessionId,\n communication: peerCommunication,\n authorizePeer: (peerKey, metadata) =>\n groupAuthorization ? groupAuthorization(peerKey, metadata) : fallbackAuthorization(peerKey),\n admitPrompt: (prompt, admission) => session.admitPrompt!(prompt, admission),\n });\n } catch (error) {\n await groups?.close();\n throw error;\n }\n const { service, close: closeDelivery } = delivery;\n const unprovide: (() => void)[] = [];\n if (groups && selfReference && peerConfig) {\n const directory = createSessionDirectory({\n authorizeDiscovery: async (caller, subject) => {\n const reference = peerSessionReference(subject.hostId, subject.sessionId);\n const permitted = (await groups.groupsFor(caller)).some((group) => group.members.includes(reference));\n return permitted ? { capabilities: ['message'] } : undefined;\n },\n });\n for (const peer of peerConfig.peers)\n for (const sessionId of peer.allowedSessionIds)\n directory.observe({\n hostId: peer.hostId,\n sessionId,\n hostIncarnation: 'unknown',\n sessionIncarnation: 'unknown',\n sequence: 0,\n observedAt: 0,\n staleAfterMs: 0,\n deliveryTarget: peerSessionReference(peer.hostId, sessionId),\n reachability: 'unknown',\n runtime: 'unknown',\n activity: 'unknown',\n voice: { eligible: 'unknown', readiness: 'unknown' },\n });\n unprovide.push(\n context.provide(\n PO_SESSION_INTERCOM_SERVICE,\n createSessionIntercom({ selfReference, directory, groups, delivery: service }),\n ),\n );\n }\n const unregister = registerSessionPeerInbox(agent.context.sessionId, (sourceKey, kind, payload) =>\n service.receive?.(sourceKey, kind, payload),\n );\n return async () => {\n unregister();\n for (const release of unprovide.reverse()) release();\n await closeDelivery();\n await groups?.close();\n };\n },\n ],\n}));\n","import path from 'node:path';\n\nimport type { PoApi, PoApiHandler } from '@agimon-ai/po-core/packageApi';\nimport { BACKGROUND_CONTEXT, type PoSqliteService, type FileSystem } from '@agimon-ai/po-core/platform';\n\nimport { deliverSessionPeerEnvelope } from '../peerInbox';\nimport {\n PEER_REPLAY_DATABASE_FILE,\n createPeerReplayGuardAsync,\n ensurePrivateDirectory,\n parseSessionPeerEnvelope,\n peerSessionReference,\n readSessionPeerConfigAsync,\n sessionPeerConfigPath,\n verifyPeerRequest,\n type SessionPeerConfig,\n type SessionPeerReplayGuardAsync,\n} from '../peerTransport';\n\nconst MAX_BODY_BYTES = 64 * 1024;\nconst DELIVERY_TYPES = new Set(['po/session-delivery/envelope', 'po/session-delivery/ack']);\n\nfunction response(status: number, error: string): Response {\n return Response.json({ error }, { status });\n}\n\ninterface PeerInboxState {\n readonly config: SessionPeerConfig | undefined;\n readonly replay: SessionPeerReplayGuardAsync | undefined;\n}\n\n/** Narrow HMAC-authenticated endpoint that a trusted tunnel may forward without device authentication. */\nexport function createPeerInboxApi(platform: { readonly fs: FileSystem; readonly sqlite: PoSqliteService }): PoApi {\n return {\n basePath: 'session-peer',\n start(context): PoApiHandler {\n const homeDirectory = context.homeDirectory;\n // Opened once on first use: the handler starts synchronously, the platform services are async.\n let opened: Promise<PeerInboxState> | undefined;\n const open = (): Promise<PeerInboxState> =>\n (opened ??= (async () => {\n if (homeDirectory === undefined) return { config: undefined, replay: undefined };\n const config = await readSessionPeerConfigAsync(platform.fs, homeDirectory, BACKGROUND_CONTEXT);\n const file = path.join(path.dirname(sessionPeerConfigPath(homeDirectory)), PEER_REPLAY_DATABASE_FILE);\n await ensurePrivateDirectory(platform.fs, path.dirname(file), BACKGROUND_CONTEXT);\n const replay = await createPeerReplayGuardAsync(await platform.sqlite.open(file, BACKGROUND_CONTEXT));\n return { config, replay };\n })().catch((error: unknown) => {\n // A failed open is retried by the next request rather than cached.\n opened = undefined;\n throw error;\n }));\n return {\n async fetch(request) {\n if (request.method !== 'POST' || new URL(request.url).pathname !== '/inbox')\n return response(404, 'Not found.');\n const { config, replay } = await open();\n if (!config) return response(503, 'Paired Session delivery is not configured.');\n const length = request.headers.get('content-length');\n if (length !== null && (!/^\\d+$/u.test(length) || Number(length) > MAX_BODY_BYTES))\n return response(413, 'Request body is too large.');\n const body = await request.text();\n if (Buffer.byteLength(body) > MAX_BODY_BYTES) return response(413, 'Request body is too large.');\n const peer = verifyPeerRequest(config, request, body);\n if (!peer) return response(401, 'Paired Session request is unauthorized.');\n if (!(await replay?.admit(request))) return response(409, 'Paired Session request was already received.');\n let parsed: unknown;\n try {\n parsed = JSON.parse(body) as unknown;\n } catch {\n return response(400, 'Paired Session request is malformed.');\n }\n const envelope = parseSessionPeerEnvelope(parsed);\n if (!envelope || !DELIVERY_TYPES.has(envelope.type))\n return response(400, 'Paired Session envelope is invalid.');\n if (!peer.allowedSessionIds.includes(envelope.targetSessionId))\n return response(403, 'Peer is not granted this session.');\n const state = await deliverSessionPeerEnvelope(\n envelope.targetSessionId,\n peerSessionReference(peer.hostId, envelope.sourceSessionId),\n envelope.type,\n envelope.payload,\n );\n return state === undefined\n ? response(404, 'Target Session is unavailable.')\n : Response.json({ accepted: true, state }, { status: 202 });\n },\n async close() {\n const state = await opened?.catch(() => undefined);\n await state?.replay?.close();\n },\n };\n },\n };\n}\n","import { defineRoute } from '@agimon-ai/po-core/extensionFile';\nimport { requirePoFs, requirePoSqlite } from '@agimon-ai/po-core/platform';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverFacet';\n\nimport { createPeerInboxApi } from '../../../../services/peerInboxApi';\n\nexport default defineRoute(({ context }: PoServerPluginContext) =>\n createPeerInboxApi({ fs: requirePoFs(context), sqlite: requirePoSqlite(context) }),\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverFacet';\nimport { composeRootHooks } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport apiRoute from '../src/extensions/(backend)/api/session-peer/route.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\n\nexport const facet = defineServerPlugin({\n name: '@agimon-ai/po-session',\n providerOverrides: composeServerProviderOverrides(rootSession),\n global: (context) => ({\n get api(): PoServerSessionPlugin['api'] { return [at(apiRoute, context)]; },\n }),\n workspace: (context) => ({\n get api(): PoServerSessionPlugin['api'] { return [at(apiRoute, context)]; },\n }),\n session: async (context) => {\n const scopeSession = await rootSession(context);\n return {\n ...composeRootHooks(scopeSession),\n get api(): PoServerSessionPlugin['api'] { return [at(apiRoute, context)]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default facet;\n"],"mappings":";;;;;;;;;;;;AAQA,MAAM,0BAAU,IAAI,IAA8B;;;;;;;AAQlD,SAAgB,yBAAyB,WAAmB,OAAqC;CAC/F,QAAQ,IAAI,WA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,YAAY;EAC1B,MAAM,eAAe,MAAMD,oBAAY,OAAO;EAC9C,OAAO;GACL,IAAA,GAAGE,iCAAAA,iBAAAA,CAAiB,YAAY;GAChC,IAAI,MAAoC;IAAE,OAAO,CAAC,GAAGD,sBAAU,OAAO,CAAC;GAAG;GAC1E,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
@@ -1,5 +1,5 @@
1
1
  //#region generated/server.d.ts
2
- export declare const facet: import("@agimon-ai/po-core/serverFacet").DoomServerFacet;
2
+ export declare const facet: import("@agimon-ai/po-core/serverFacet").PoServerFacet;
3
3
  //#endregion
4
4
  export { facet as default };
5
5
  //# sourceMappingURL=server.d.mts.map
@@ -1,6 +1,6 @@
1
- import { D as provideBackgroundWorkService, T as sessionPeerConfigPath, _ as parseSessionPeerEnvelope, a as createSessionGroupDeliveryAuthorizer, b as readSessionPeerConfigAsync, f as createSessionDirectory, g as parseRemoteSessionReference, h as ensurePrivateDirectory, m as createPeerReplayGuardAsync, n as provideSessionDeliveryService, o as createSessionIntercom, p as createPeerCommunication, s as DOOM_SESSION_INTERCOM_SERVICE, u as createSessionGroupStore, w as PEER_REPLAY_DATABASE_FILE, x as verifyPeerRequest, y as peerSessionReference } from "../sessionDelivery-BzPl0sCk.mjs";
1
+ import { D as provideBackgroundWorkService, T as sessionPeerConfigPath, _ as parseSessionPeerEnvelope, a as createSessionGroupDeliveryAuthorizer, b as readSessionPeerConfigAsync, f as createSessionDirectory, g as parseRemoteSessionReference, h as ensurePrivateDirectory, m as createPeerReplayGuardAsync, n as provideSessionDeliveryService, o as createSessionIntercom, p as createPeerCommunication, s as PO_SESSION_INTERCOM_SERVICE, u as createSessionGroupStore, w as PEER_REPLAY_DATABASE_FILE, x as verifyPeerRequest, y as peerSessionReference } from "../sessionDelivery-CROSMn_N.mjs";
2
2
  import path from "node:path";
3
- import { BACKGROUND_CONTEXT, requireDoomFs, requireDoomSqlite } from "@agimon-ai/po-core/platform";
3
+ import { BACKGROUND_CONTEXT, requirePoFs, requirePoSqlite } from "@agimon-ai/po-core/platform";
4
4
  import { poHomeDirectory } from "@agimon-ai/po-core/piSettings";
5
5
  import { composeServerProviderOverrides, defineServerPlugin } from "@agimon-ai/po-core/serverFacet";
6
6
  import { composeRootHooks, defineRoot, defineRoute } from "@agimon-ai/po-core/extensionFile";
@@ -32,8 +32,8 @@ var root_server_default = defineRoot((pluginContext) => ({
32
32
  const homeDirectory = pluginContext.host.context.homeDirectory;
33
33
  const sessionService = pluginContext.host.context.sessionService;
34
34
  if (!agent || !session?.admitPrompt || !communication || !homeDirectory || !sessionService?.canCommunicate) throw new Error("Session delivery requires the headless agent, authenticated session communication, host home directory, and communication policy.");
35
- const fs = requireDoomFs(pluginContext.context);
36
- const sqlite = requireDoomSqlite(pluginContext.context);
35
+ const fs = requirePoFs(pluginContext.context);
36
+ const sqlite = requirePoSqlite(pluginContext.context);
37
37
  const io = BACKGROUND_CONTEXT;
38
38
  const sessionDirectory = path.join(poHomeDirectory(homeDirectory), "session");
39
39
  const deliveryDirectory = path.join(sessionDirectory, "delivery");
@@ -94,7 +94,7 @@ var root_server_default = defineRoot((pluginContext) => ({
94
94
  readiness: "unknown"
95
95
  }
96
96
  });
97
- unprovide.push(context.provide(DOOM_SESSION_INTERCOM_SERVICE, createSessionIntercom({
97
+ unprovide.push(context.provide(PO_SESSION_INTERCOM_SERVICE, createSessionIntercom({
98
98
  selfReference,
99
99
  directory,
100
100
  groups,
@@ -113,7 +113,7 @@ var root_server_default = defineRoot((pluginContext) => ({
113
113
  //#endregion
114
114
  //#region src/services/peerInboxApi/index.ts
115
115
  const MAX_BODY_BYTES = 65536;
116
- const DELIVERY_TYPES = /* @__PURE__ */ new Set(["doom/session-delivery/envelope", "doom/session-delivery/ack"]);
116
+ const DELIVERY_TYPES = /* @__PURE__ */ new Set(["po/session-delivery/envelope", "po/session-delivery/ack"]);
117
117
  function response(status, error) {
118
118
  return Response.json({ error }, { status });
119
119
  }
@@ -177,8 +177,8 @@ function createPeerInboxApi(platform) {
177
177
  //#endregion
178
178
  //#region src/extensions/(backend)/api/session-peer/route.server.ts
179
179
  var route_server_default = defineRoute(({ context }) => createPeerInboxApi({
180
- fs: requireDoomFs(context),
181
- sqlite: requireDoomSqlite(context)
180
+ fs: requirePoFs(context),
181
+ sqlite: requirePoSqlite(context)
182
182
  }));
183
183
  //#endregion
184
184
  //#region generated/server.ts
@@ -1 +1 @@
1
- {"version":3,"file":"server.mjs","names":["rootSession","apiRoute"],"sources":["../../src/services/peerInbox/index.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/services/peerInboxApi/index.ts","../../src/extensions/(backend)/api/session-peer/route.server.ts","../../generated/server.ts"],"sourcesContent":["import type { DoomSessionDeliveryInboxState } from '../sessionDelivery';\n\nexport type SessionPeerInbox = (\n sourceKey: string,\n type: string,\n payload: unknown,\n) => Promise<DoomSessionDeliveryInboxState | undefined> | undefined;\n\nconst inboxes = new Map<string, SessionPeerInbox>();\n\n/**\n * Registers one live session-owned peer inbox. This registry is reachable only by the Session route.\n * The newest registration wins: a Durable Object evicted without disposal leaves its entry in the\n * isolate's module state, and the restarted session must replace it. The hub still rejects two live\n * sessions with one id, and an older unregister cannot remove a newer inbox.\n */\nexport function registerSessionPeerInbox(sessionId: string, inbox: SessionPeerInbox): () => void {\n inboxes.set(sessionId, inbox);\n return () => {\n if (inboxes.get(sessionId) === inbox) inboxes.delete(sessionId);\n };\n}\n\nexport async function deliverSessionPeerEnvelope(\n targetSessionId: string,\n sourceKey: string,\n type: string,\n payload: unknown,\n): Promise<DoomSessionDeliveryInboxState | undefined> {\n return inboxes.get(targetSessionId)?.(sourceKey, type, payload);\n}\n","import path from 'node:path';\n\nimport { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport { poHomeDirectory } from '@agimon-ai/po-core/piSettings';\nimport { BACKGROUND_CONTEXT, requireDoomFs, requireDoomSqlite } from '@agimon-ai/po-core/platform';\nimport type { DoomServerPluginContext } from '@agimon-ai/po-core/serverFacet';\n\nimport { provideBackgroundWorkService } from '../../../../services/backgroundWorkService';\nimport { registerSessionPeerInbox } from '../../../../services/peerInbox';\nimport {\n createPeerCommunication,\n ensurePrivateDirectory,\n parseRemoteSessionReference,\n peerSessionReference,\n readSessionPeerConfigAsync,\n} from '../../../../services/peerTransport';\nimport { provideSessionDeliveryService } from '../../../../services/sessionDelivery';\nimport { createSessionDirectory } from '../../../../services/sessionDirectory';\nimport { createSessionGroupStore } from '../../../../services/sessionGroups';\nimport {\n DOOM_SESSION_INTERCOM_SERVICE,\n createSessionGroupDeliveryAuthorizer,\n createSessionIntercom,\n} from '../../../../services/sessionIntercom';\n\nexport default defineRoot((pluginContext: DoomServerPluginContext) => ({\n value: undefined,\n services: [\n provideBackgroundWorkService,\n async (context) => {\n const agent = pluginContext.agent;\n const session = agent?.context.session;\n const communication = pluginContext.host.context.sessionCommunication;\n const homeDirectory = pluginContext.host.context.homeDirectory;\n const sessionService = pluginContext.host.context.sessionService;\n if (!agent || !session?.admitPrompt || !communication || !homeDirectory || !sessionService?.canCommunicate) {\n throw new Error(\n 'Session delivery requires the headless agent, authenticated session communication, host home directory, and communication policy.',\n );\n }\n const fs = requireDoomFs(pluginContext.context);\n const sqlite = requireDoomSqlite(pluginContext.context);\n const io = BACKGROUND_CONTEXT;\n const sessionDirectory = path.join(poHomeDirectory(homeDirectory), 'session');\n const deliveryDirectory = path.join(sessionDirectory, 'delivery');\n await ensurePrivateDirectory(fs, deliveryDirectory, io);\n const peerConfig = await readSessionPeerConfigAsync(fs, homeDirectory, io);\n const peerCommunication = createPeerCommunication({ local: communication, config: peerConfig });\n const remotePeerIsGranted = (peerKey: string): boolean => {\n const peer = parseRemoteSessionReference(peerKey);\n return (\n peer !== undefined &&\n peerConfig?.peers.some(\n (candidate) =>\n candidate.hostId === peer.hostId && candidate.allowedSessionIds.includes(agent.context.sessionId),\n ) === true\n );\n };\n const fallbackAuthorization = (peerKey: string): boolean =>\n sessionService.canCommunicate?.(agent.context.sessionId, peerKey) === true || remotePeerIsGranted(peerKey);\n const groups = peerConfig\n ? await createSessionGroupStore({\n database: await sqlite.open(path.join(sessionDirectory, 'groups.sqlite'), io),\n })\n : undefined;\n const localHostId = peerConfig?.hostId;\n const selfReference = localHostId ? peerSessionReference(localHostId, agent.context.sessionId) : undefined;\n const groupAuthorization =\n groups && selfReference && localHostId\n ? createSessionGroupDeliveryAuthorizer({\n selfReference,\n groups,\n peerReference: (peerKey) =>\n parseRemoteSessionReference(peerKey) === undefined\n ? peerSessionReference(localHostId, peerKey)\n : peerKey,\n fallback: fallbackAuthorization,\n })\n : undefined;\n let delivery: Awaited<ReturnType<typeof provideSessionDeliveryService>>;\n try {\n delivery = await provideSessionDeliveryService(context, {\n database: await sqlite.open(path.join(deliveryDirectory, `${agent.context.sessionId}.sqlite`), io),\n recipientKey: agent.context.sessionId,\n communication: peerCommunication,\n authorizePeer: (peerKey, metadata) =>\n groupAuthorization ? groupAuthorization(peerKey, metadata) : fallbackAuthorization(peerKey),\n admitPrompt: (prompt, admission) => session.admitPrompt!(prompt, admission),\n });\n } catch (error) {\n await groups?.close();\n throw error;\n }\n const { service, close: closeDelivery } = delivery;\n const unprovide: (() => void)[] = [];\n if (groups && selfReference && peerConfig) {\n const directory = createSessionDirectory({\n authorizeDiscovery: async (caller, subject) => {\n const reference = peerSessionReference(subject.hostId, subject.sessionId);\n const permitted = (await groups.groupsFor(caller)).some((group) => group.members.includes(reference));\n return permitted ? { capabilities: ['message'] } : undefined;\n },\n });\n for (const peer of peerConfig.peers)\n for (const sessionId of peer.allowedSessionIds)\n directory.observe({\n hostId: peer.hostId,\n sessionId,\n hostIncarnation: 'unknown',\n sessionIncarnation: 'unknown',\n sequence: 0,\n observedAt: 0,\n staleAfterMs: 0,\n deliveryTarget: peerSessionReference(peer.hostId, sessionId),\n reachability: 'unknown',\n runtime: 'unknown',\n activity: 'unknown',\n voice: { eligible: 'unknown', readiness: 'unknown' },\n });\n unprovide.push(\n context.provide(\n DOOM_SESSION_INTERCOM_SERVICE,\n createSessionIntercom({ selfReference, directory, groups, delivery: service }),\n ),\n );\n }\n const unregister = registerSessionPeerInbox(agent.context.sessionId, (sourceKey, kind, payload) =>\n service.receive?.(sourceKey, kind, payload),\n );\n return async () => {\n unregister();\n for (const release of unprovide.reverse()) release();\n await closeDelivery();\n await groups?.close();\n };\n },\n ],\n}));\n","import path from 'node:path';\n\nimport type { DoomApi, DoomApiHandler } from '@agimon-ai/po-core/packageApi';\nimport { BACKGROUND_CONTEXT, type DoomSqliteService, type FileSystem } from '@agimon-ai/po-core/platform';\n\nimport { deliverSessionPeerEnvelope } from '../peerInbox';\nimport {\n PEER_REPLAY_DATABASE_FILE,\n createPeerReplayGuardAsync,\n ensurePrivateDirectory,\n parseSessionPeerEnvelope,\n peerSessionReference,\n readSessionPeerConfigAsync,\n sessionPeerConfigPath,\n verifyPeerRequest,\n type SessionPeerConfig,\n type SessionPeerReplayGuardAsync,\n} from '../peerTransport';\n\nconst MAX_BODY_BYTES = 64 * 1024;\nconst DELIVERY_TYPES = new Set(['doom/session-delivery/envelope', 'doom/session-delivery/ack']);\n\nfunction response(status: number, error: string): Response {\n return Response.json({ error }, { status });\n}\n\ninterface PeerInboxState {\n readonly config: SessionPeerConfig | undefined;\n readonly replay: SessionPeerReplayGuardAsync | undefined;\n}\n\n/** Narrow HMAC-authenticated endpoint that a trusted tunnel may forward without device authentication. */\nexport function createPeerInboxApi(platform: { readonly fs: FileSystem; readonly sqlite: DoomSqliteService }): DoomApi {\n return {\n basePath: 'session-peer',\n start(context): DoomApiHandler {\n const homeDirectory = context.homeDirectory;\n // Opened once on first use: the handler starts synchronously, the platform services are async.\n let opened: Promise<PeerInboxState> | undefined;\n const open = (): Promise<PeerInboxState> =>\n (opened ??= (async () => {\n if (homeDirectory === undefined) return { config: undefined, replay: undefined };\n const config = await readSessionPeerConfigAsync(platform.fs, homeDirectory, BACKGROUND_CONTEXT);\n const file = path.join(path.dirname(sessionPeerConfigPath(homeDirectory)), PEER_REPLAY_DATABASE_FILE);\n await ensurePrivateDirectory(platform.fs, path.dirname(file), BACKGROUND_CONTEXT);\n const replay = await createPeerReplayGuardAsync(await platform.sqlite.open(file, BACKGROUND_CONTEXT));\n return { config, replay };\n })().catch((error: unknown) => {\n // A failed open is retried by the next request rather than cached.\n opened = undefined;\n throw error;\n }));\n return {\n async fetch(request) {\n if (request.method !== 'POST' || new URL(request.url).pathname !== '/inbox')\n return response(404, 'Not found.');\n const { config, replay } = await open();\n if (!config) return response(503, 'Paired Session delivery is not configured.');\n const length = request.headers.get('content-length');\n if (length !== null && (!/^\\d+$/u.test(length) || Number(length) > MAX_BODY_BYTES))\n return response(413, 'Request body is too large.');\n const body = await request.text();\n if (Buffer.byteLength(body) > MAX_BODY_BYTES) return response(413, 'Request body is too large.');\n const peer = verifyPeerRequest(config, request, body);\n if (!peer) return response(401, 'Paired Session request is unauthorized.');\n if (!(await replay?.admit(request))) return response(409, 'Paired Session request was already received.');\n let parsed: unknown;\n try {\n parsed = JSON.parse(body) as unknown;\n } catch {\n return response(400, 'Paired Session request is malformed.');\n }\n const envelope = parseSessionPeerEnvelope(parsed);\n if (!envelope || !DELIVERY_TYPES.has(envelope.type))\n return response(400, 'Paired Session envelope is invalid.');\n if (!peer.allowedSessionIds.includes(envelope.targetSessionId))\n return response(403, 'Peer is not granted this session.');\n const state = await deliverSessionPeerEnvelope(\n envelope.targetSessionId,\n peerSessionReference(peer.hostId, envelope.sourceSessionId),\n envelope.type,\n envelope.payload,\n );\n return state === undefined\n ? response(404, 'Target Session is unavailable.')\n : Response.json({ accepted: true, state }, { status: 202 });\n },\n async close() {\n const state = await opened?.catch(() => undefined);\n await state?.replay?.close();\n },\n };\n },\n };\n}\n","import { defineRoute } from '@agimon-ai/po-core/extensionFile';\nimport { requireDoomFs, requireDoomSqlite } from '@agimon-ai/po-core/platform';\nimport type { DoomServerPluginContext } from '@agimon-ai/po-core/serverFacet';\n\nimport { createPeerInboxApi } from '../../../../services/peerInboxApi';\n\nexport default defineRoute(({ context }: DoomServerPluginContext) =>\n createPeerInboxApi({ fs: requireDoomFs(context), sqlite: requireDoomSqlite(context) }),\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverFacet';\nimport { composeRootHooks } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport apiRoute from '../src/extensions/(backend)/api/session-peer/route.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\n\nexport const facet = defineServerPlugin({\n name: '@agimon-ai/po-session',\n providerOverrides: composeServerProviderOverrides(rootSession),\n global: (context) => ({\n get api(): DoomServerSessionPlugin['api'] { return [at(apiRoute, context)]; },\n }),\n workspace: (context) => ({\n get api(): DoomServerSessionPlugin['api'] { return [at(apiRoute, context)]; },\n }),\n session: async (context) => {\n const scopeSession = await rootSession(context);\n return {\n ...composeRootHooks(scopeSession),\n get api(): DoomServerSessionPlugin['api'] { return [at(apiRoute, context)]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): DoomServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default facet;\n"],"mappings":";;;;;;;AAQA,MAAM,0BAAU,IAAI,IAA8B;;;;;;;AAQlD,SAAgB,yBAAyB,WAAmB,OAAqC;CAC/F,QAAQ,IAAI,WAAW,KAAK;CAC5B,aAAa;EACX,IAAI,QAAQ,IAAI,SAAS,MAAM,OAAO,QAAQ,OAAO,SAAS;CAChE;AACF;AAEA,eAAsB,2BACpB,iBACA,WACA,MACA,SACoD;CACpD,OAA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,OAAM,MADc,QAAQ,YAAY,KAAA,CAAS,EAAA,EACpC,QAAQ,MAAM;IAC7B;GACF;EACF;CACF;AACF;;;ACxFA,IAAA,uBAAe,aAAa,EAAE,cAC5B,mBAAmB;CAAE,IAAI,cAAc,OAAO;CAAG,QAAQ,kBAAkB,OAAO;AAAE,CAAC,CACvF;;;ACCA,MAAM,MAAY,OAA0B,YAC1C,OAAO,UAAU,aAAc,MAAwB,OAAO,IAAI;AAEpE,MAAa,QAAQ,mBAAmB;CACtC,MAAM;CACN,mBAAmB,+BAA+BA,mBAAW;CAC7D,SAAS,aAAa,EACpB,IAAI,MAAsC;EAAE,OAAO,CAAC,GAAGC,sBAAU,OAAO,CAAC;CAAG,EAC9E;CACA,YAAY,aAAa,EACvB,IAAI,MAAsC;EAAE,OAAO,CAAC,GAAGA,sBAAU,OAAO,CAAC;CAAG,EAC9E;CACA,SAAS,OAAO,YAAY;EAC1B,MAAM,eAAe,MAAMD,oBAAY,OAAO;EAC9C,OAAO;GACL,GAAG,iBAAiB,YAAY;GAChC,IAAI,MAAsC;IAAE,OAAO,CAAC,GAAGC,sBAAU,OAAO,CAAC;GAAG;GAC5E,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAoD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACzG;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"server.mjs","names":["rootSession","apiRoute"],"sources":["../../src/services/peerInbox/index.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/services/peerInboxApi/index.ts","../../src/extensions/(backend)/api/session-peer/route.server.ts","../../generated/server.ts"],"sourcesContent":["import type { PoSessionDeliveryInboxState } from '../sessionDelivery';\n\nexport type SessionPeerInbox = (\n sourceKey: string,\n type: string,\n payload: unknown,\n) => Promise<PoSessionDeliveryInboxState | undefined> | undefined;\n\nconst inboxes = new Map<string, SessionPeerInbox>();\n\n/**\n * Registers one live session-owned peer inbox. This registry is reachable only by the Session route.\n * The newest registration wins: a Durable Object evicted without disposal leaves its entry in the\n * isolate's module state, and the restarted session must replace it. The hub still rejects two live\n * sessions with one id, and an older unregister cannot remove a newer inbox.\n */\nexport function registerSessionPeerInbox(sessionId: string, inbox: SessionPeerInbox): () => void {\n inboxes.set(sessionId, inbox);\n return () => {\n if (inboxes.get(sessionId) === inbox) inboxes.delete(sessionId);\n };\n}\n\nexport async function deliverSessionPeerEnvelope(\n targetSessionId: string,\n sourceKey: string,\n type: string,\n payload: unknown,\n): Promise<PoSessionDeliveryInboxState | undefined> {\n return inboxes.get(targetSessionId)?.(sourceKey, type, payload);\n}\n","import path from 'node:path';\n\nimport { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport { poHomeDirectory } from '@agimon-ai/po-core/piSettings';\nimport { BACKGROUND_CONTEXT, requirePoFs, requirePoSqlite } from '@agimon-ai/po-core/platform';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverFacet';\n\nimport { provideBackgroundWorkService } from '../../../../services/backgroundWorkService';\nimport { registerSessionPeerInbox } from '../../../../services/peerInbox';\nimport {\n createPeerCommunication,\n ensurePrivateDirectory,\n parseRemoteSessionReference,\n peerSessionReference,\n readSessionPeerConfigAsync,\n} from '../../../../services/peerTransport';\nimport { provideSessionDeliveryService } from '../../../../services/sessionDelivery';\nimport { createSessionDirectory } from '../../../../services/sessionDirectory';\nimport { createSessionGroupStore } from '../../../../services/sessionGroups';\nimport {\n PO_SESSION_INTERCOM_SERVICE,\n createSessionGroupDeliveryAuthorizer,\n createSessionIntercom,\n} from '../../../../services/sessionIntercom';\n\nexport default defineRoot((pluginContext: PoServerPluginContext) => ({\n value: undefined,\n services: [\n provideBackgroundWorkService,\n async (context) => {\n const agent = pluginContext.agent;\n const session = agent?.context.session;\n const communication = pluginContext.host.context.sessionCommunication;\n const homeDirectory = pluginContext.host.context.homeDirectory;\n const sessionService = pluginContext.host.context.sessionService;\n if (!agent || !session?.admitPrompt || !communication || !homeDirectory || !sessionService?.canCommunicate) {\n throw new Error(\n 'Session delivery requires the headless agent, authenticated session communication, host home directory, and communication policy.',\n );\n }\n const fs = requirePoFs(pluginContext.context);\n const sqlite = requirePoSqlite(pluginContext.context);\n const io = BACKGROUND_CONTEXT;\n const sessionDirectory = path.join(poHomeDirectory(homeDirectory), 'session');\n const deliveryDirectory = path.join(sessionDirectory, 'delivery');\n await ensurePrivateDirectory(fs, deliveryDirectory, io);\n const peerConfig = await readSessionPeerConfigAsync(fs, homeDirectory, io);\n const peerCommunication = createPeerCommunication({ local: communication, config: peerConfig });\n const remotePeerIsGranted = (peerKey: string): boolean => {\n const peer = parseRemoteSessionReference(peerKey);\n return (\n peer !== undefined &&\n peerConfig?.peers.some(\n (candidate) =>\n candidate.hostId === peer.hostId && candidate.allowedSessionIds.includes(agent.context.sessionId),\n ) === true\n );\n };\n const fallbackAuthorization = (peerKey: string): boolean =>\n sessionService.canCommunicate?.(agent.context.sessionId, peerKey) === true || remotePeerIsGranted(peerKey);\n const groups = peerConfig\n ? await createSessionGroupStore({\n database: await sqlite.open(path.join(sessionDirectory, 'groups.sqlite'), io),\n })\n : undefined;\n const localHostId = peerConfig?.hostId;\n const selfReference = localHostId ? peerSessionReference(localHostId, agent.context.sessionId) : undefined;\n const groupAuthorization =\n groups && selfReference && localHostId\n ? createSessionGroupDeliveryAuthorizer({\n selfReference,\n groups,\n peerReference: (peerKey) =>\n parseRemoteSessionReference(peerKey) === undefined\n ? peerSessionReference(localHostId, peerKey)\n : peerKey,\n fallback: fallbackAuthorization,\n })\n : undefined;\n let delivery: Awaited<ReturnType<typeof provideSessionDeliveryService>>;\n try {\n delivery = await provideSessionDeliveryService(context, {\n database: await sqlite.open(path.join(deliveryDirectory, `${agent.context.sessionId}.sqlite`), io),\n recipientKey: agent.context.sessionId,\n communication: peerCommunication,\n authorizePeer: (peerKey, metadata) =>\n groupAuthorization ? groupAuthorization(peerKey, metadata) : fallbackAuthorization(peerKey),\n admitPrompt: (prompt, admission) => session.admitPrompt!(prompt, admission),\n });\n } catch (error) {\n await groups?.close();\n throw error;\n }\n const { service, close: closeDelivery } = delivery;\n const unprovide: (() => void)[] = [];\n if (groups && selfReference && peerConfig) {\n const directory = createSessionDirectory({\n authorizeDiscovery: async (caller, subject) => {\n const reference = peerSessionReference(subject.hostId, subject.sessionId);\n const permitted = (await groups.groupsFor(caller)).some((group) => group.members.includes(reference));\n return permitted ? { capabilities: ['message'] } : undefined;\n },\n });\n for (const peer of peerConfig.peers)\n for (const sessionId of peer.allowedSessionIds)\n directory.observe({\n hostId: peer.hostId,\n sessionId,\n hostIncarnation: 'unknown',\n sessionIncarnation: 'unknown',\n sequence: 0,\n observedAt: 0,\n staleAfterMs: 0,\n deliveryTarget: peerSessionReference(peer.hostId, sessionId),\n reachability: 'unknown',\n runtime: 'unknown',\n activity: 'unknown',\n voice: { eligible: 'unknown', readiness: 'unknown' },\n });\n unprovide.push(\n context.provide(\n PO_SESSION_INTERCOM_SERVICE,\n createSessionIntercom({ selfReference, directory, groups, delivery: service }),\n ),\n );\n }\n const unregister = registerSessionPeerInbox(agent.context.sessionId, (sourceKey, kind, payload) =>\n service.receive?.(sourceKey, kind, payload),\n );\n return async () => {\n unregister();\n for (const release of unprovide.reverse()) release();\n await closeDelivery();\n await groups?.close();\n };\n },\n ],\n}));\n","import path from 'node:path';\n\nimport type { PoApi, PoApiHandler } from '@agimon-ai/po-core/packageApi';\nimport { BACKGROUND_CONTEXT, type PoSqliteService, type FileSystem } from '@agimon-ai/po-core/platform';\n\nimport { deliverSessionPeerEnvelope } from '../peerInbox';\nimport {\n PEER_REPLAY_DATABASE_FILE,\n createPeerReplayGuardAsync,\n ensurePrivateDirectory,\n parseSessionPeerEnvelope,\n peerSessionReference,\n readSessionPeerConfigAsync,\n sessionPeerConfigPath,\n verifyPeerRequest,\n type SessionPeerConfig,\n type SessionPeerReplayGuardAsync,\n} from '../peerTransport';\n\nconst MAX_BODY_BYTES = 64 * 1024;\nconst DELIVERY_TYPES = new Set(['po/session-delivery/envelope', 'po/session-delivery/ack']);\n\nfunction response(status: number, error: string): Response {\n return Response.json({ error }, { status });\n}\n\ninterface PeerInboxState {\n readonly config: SessionPeerConfig | undefined;\n readonly replay: SessionPeerReplayGuardAsync | undefined;\n}\n\n/** Narrow HMAC-authenticated endpoint that a trusted tunnel may forward without device authentication. */\nexport function createPeerInboxApi(platform: { readonly fs: FileSystem; readonly sqlite: PoSqliteService }): PoApi {\n return {\n basePath: 'session-peer',\n start(context): PoApiHandler {\n const homeDirectory = context.homeDirectory;\n // Opened once on first use: the handler starts synchronously, the platform services are async.\n let opened: Promise<PeerInboxState> | undefined;\n const open = (): Promise<PeerInboxState> =>\n (opened ??= (async () => {\n if (homeDirectory === undefined) return { config: undefined, replay: undefined };\n const config = await readSessionPeerConfigAsync(platform.fs, homeDirectory, BACKGROUND_CONTEXT);\n const file = path.join(path.dirname(sessionPeerConfigPath(homeDirectory)), PEER_REPLAY_DATABASE_FILE);\n await ensurePrivateDirectory(platform.fs, path.dirname(file), BACKGROUND_CONTEXT);\n const replay = await createPeerReplayGuardAsync(await platform.sqlite.open(file, BACKGROUND_CONTEXT));\n return { config, replay };\n })().catch((error: unknown) => {\n // A failed open is retried by the next request rather than cached.\n opened = undefined;\n throw error;\n }));\n return {\n async fetch(request) {\n if (request.method !== 'POST' || new URL(request.url).pathname !== '/inbox')\n return response(404, 'Not found.');\n const { config, replay } = await open();\n if (!config) return response(503, 'Paired Session delivery is not configured.');\n const length = request.headers.get('content-length');\n if (length !== null && (!/^\\d+$/u.test(length) || Number(length) > MAX_BODY_BYTES))\n return response(413, 'Request body is too large.');\n const body = await request.text();\n if (Buffer.byteLength(body) > MAX_BODY_BYTES) return response(413, 'Request body is too large.');\n const peer = verifyPeerRequest(config, request, body);\n if (!peer) return response(401, 'Paired Session request is unauthorized.');\n if (!(await replay?.admit(request))) return response(409, 'Paired Session request was already received.');\n let parsed: unknown;\n try {\n parsed = JSON.parse(body) as unknown;\n } catch {\n return response(400, 'Paired Session request is malformed.');\n }\n const envelope = parseSessionPeerEnvelope(parsed);\n if (!envelope || !DELIVERY_TYPES.has(envelope.type))\n return response(400, 'Paired Session envelope is invalid.');\n if (!peer.allowedSessionIds.includes(envelope.targetSessionId))\n return response(403, 'Peer is not granted this session.');\n const state = await deliverSessionPeerEnvelope(\n envelope.targetSessionId,\n peerSessionReference(peer.hostId, envelope.sourceSessionId),\n envelope.type,\n envelope.payload,\n );\n return state === undefined\n ? response(404, 'Target Session is unavailable.')\n : Response.json({ accepted: true, state }, { status: 202 });\n },\n async close() {\n const state = await opened?.catch(() => undefined);\n await state?.replay?.close();\n },\n };\n },\n };\n}\n","import { defineRoute } from '@agimon-ai/po-core/extensionFile';\nimport { requirePoFs, requirePoSqlite } from '@agimon-ai/po-core/platform';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverFacet';\n\nimport { createPeerInboxApi } from '../../../../services/peerInboxApi';\n\nexport default defineRoute(({ context }: PoServerPluginContext) =>\n createPeerInboxApi({ fs: requirePoFs(context), sqlite: requirePoSqlite(context) }),\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverFacet';\nimport { composeRootHooks } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport apiRoute from '../src/extensions/(backend)/api/session-peer/route.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\n\nexport const facet = defineServerPlugin({\n name: '@agimon-ai/po-session',\n providerOverrides: composeServerProviderOverrides(rootSession),\n global: (context) => ({\n get api(): PoServerSessionPlugin['api'] { return [at(apiRoute, context)]; },\n }),\n workspace: (context) => ({\n get api(): PoServerSessionPlugin['api'] { return [at(apiRoute, context)]; },\n }),\n session: async (context) => {\n const scopeSession = await rootSession(context);\n return {\n ...composeRootHooks(scopeSession),\n get api(): PoServerSessionPlugin['api'] { return [at(apiRoute, context)]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default facet;\n"],"mappings":";;;;;;;AAQA,MAAM,0BAAU,IAAI,IAA8B;;;;;;;AAQlD,SAAgB,yBAAyB,WAAmB,OAAqC;CAC/F,QAAQ,IAAI,WAAW,KAAK;CAC5B,aAAa;EACX,IAAI,QAAQ,IAAI,SAAS,MAAM,OAAO,QAAQ,OAAO,SAAS;CAChE;AACF;AAEA,eAAsB,2BACpB,iBACA,WACA,MACA,SACkD;CAClD,OAAO,QAAQ,IAAI,eAAe,CAAC,GAAG,WAAW,MAAM,OAAO;AAChE;;;ACLA,IAAA,sBAAe,YAAY,mBAA0C;CACnE,OAAO,KAAA;CACP,UAAU,CACR,8BACA,OAAO,YAAY;EACjB,MAAM,QAAQ,cAAc;EAC5B,MAAM,UAAU,OAAO,QAAQ;EAC/B,MAAM,gBAAgB,cAAc,KAAK,QAAQ;EACjD,MAAM,gBAAgB,cAAc,KAAK,QAAQ;EACjD,MAAM,iBAAiB,cAAc,KAAK,QAAQ;EAClD,IAAI,CAAC,SAAS,CAAC,SAAS,eAAe,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,gBAAgB,gBAC1F,MAAM,IAAI,MACR,mIACF;EAEF,MAAM,KAAK,YAAY,cAAc,OAAO;EAC5C,MAAM,SAAS,gBAAgB,cAAc,OAAO;EACpD,MAAM,KAAK;EACX,MAAM,mBAAmB,KAAK,KAAK,gBAAgB,aAAa,GAAG,SAAS;EAC5E,MAAM,oBAAoB,KAAK,KAAK,kBAAkB,UAAU;EAChE,MAAM,uBAAuB,IAAI,mBAAmB,EAAE;EACtD,MAAM,aAAa,MAAM,2BAA2B,IAAI,eAAe,EAAE;EACzE,MAAM,oBAAoB,wBAAwB;GA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;GAC3C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sessionDelivery = require("./sessionDelivery-CkKlRYAK.cjs");
3
- exports.DOOM_SESSION_DELIVERY_SERVICE = require_sessionDelivery.DOOM_SESSION_DELIVERY_SERVICE;
4
- exports.DOOM_SESSION_INTERCOM_SERVICE = require_sessionDelivery.DOOM_SESSION_INTERCOM_SERVICE;
2
+ const require_sessionDelivery = require("./sessionDelivery-D7PFBTSg.cjs");
3
+ exports.PO_SESSION_DELIVERY_SERVICE = require_sessionDelivery.PO_SESSION_DELIVERY_SERVICE;
4
+ exports.PO_SESSION_INTERCOM_SERVICE = require_sessionDelivery.PO_SESSION_INTERCOM_SERVICE;
5
5
  exports.SessionGroupRevisionError = require_sessionDelivery.SessionGroupRevisionError;
6
6
  exports.createBackgroundWorkService = require_sessionDelivery.createBackgroundWorkService;
7
7
  exports.createPeerCommunication = require_sessionDelivery.createPeerCommunication;
@@ -17,7 +17,7 @@ exports.peerRequestHeaders = require_sessionDelivery.peerRequestHeaders;
17
17
  exports.peerSessionReference = require_sessionDelivery.peerSessionReference;
18
18
  exports.provideBackgroundWorkService = require_sessionDelivery.provideBackgroundWorkService;
19
19
  exports.provideSessionDeliveryService = require_sessionDelivery.provideSessionDeliveryService;
20
- exports.readDoomSessionDelivery = require_sessionDelivery.readDoomSessionDelivery;
20
+ exports.readPoSessionDelivery = require_sessionDelivery.readPoSessionDelivery;
21
21
  exports.readSessionIntercom = require_sessionDelivery.readSessionIntercom;
22
22
  exports.readSessionPeerConfig = require_sessionDelivery.readSessionPeerConfig;
23
23
  exports.readSessionPeerConfigAsync = require_sessionDelivery.readSessionPeerConfigAsync;
package/dist/index.d.mts CHANGED
@@ -1,16 +1,16 @@
1
- import { DoomBackgroundWorkService } from "@agimon-ai/po-core/backgroundWork";
2
- import { DoomSqliteService, FileSystem } from "@agimon-ai/po-core/platform";
1
+ import { PoBackgroundWorkService } from "@agimon-ai/po-core/backgroundWork";
2
+ import { FileSystem, PoSqliteService } from "@agimon-ai/po-core/platform";
3
3
  import { Context } from "@deepseek-ai/cordis";
4
- import { DoomSessionCommunicationEndpoint } from "@agimon-ai/po-core/hubChannel";
4
+ import { PoSessionCommunicationEndpoint } from "@agimon-ai/po-core/hubChannel";
5
5
  //#region src/services/backgroundWorkService/index.d.ts
6
6
  /** Creates the generation-bound, pull-based coordinator shared by session extensions. */
7
- export declare function createBackgroundWorkService(ctx: Context): DoomBackgroundWorkService;
7
+ export declare function createBackgroundWorkService(ctx: Context): PoBackgroundWorkService;
8
8
  /** Installs one coordinator in the current session service context. */
9
9
  export declare function provideBackgroundWorkService(context: Context): void;
10
10
  //#endregion
11
11
  //#region src/services/sessionGroups/type.d.ts
12
12
  /** pi-durable `SqliteDatabase`, reached through po-core so this package needs no direct dependency. */
13
- type SessionSqliteDatabase = Awaited<ReturnType<DoomSqliteService['open']>>;
13
+ type SessionSqliteDatabase = Awaited<ReturnType<PoSqliteService['open']>>;
14
14
  interface SessionCommunicationGroup {
15
15
  readonly id: string;
16
16
  readonly ownerAuthority: string;
@@ -112,11 +112,11 @@ export declare function createPeerReplayGuardAsync(database: SessionSqliteDataba
112
112
  export declare function verifyPeerRequest(config: SessionPeerConfig, request: Request, body: string, now?: number): SessionPeer | undefined;
113
113
  /** Adds asynchronous tunnel publication to a host-bound local communication endpoint. */
114
114
  export declare function createPeerCommunication(options: {
115
- readonly local: DoomSessionCommunicationEndpoint;
115
+ readonly local: PoSessionCommunicationEndpoint;
116
116
  /** Read once by the caller, for example with readSessionPeerConfigAsync. */
117
117
  readonly config: SessionPeerConfig | undefined;
118
118
  readonly fetch?: typeof fetch;
119
- }): DoomSessionCommunicationEndpoint;
119
+ }): PoSessionCommunicationEndpoint;
120
120
  //#endregion
121
121
  //#region src/services/sessionDirectory/type.d.ts
122
122
  type SessionHostReachability = 'reachable' | 'unreachable' | 'unknown';
@@ -180,57 +180,57 @@ export declare function createSessionDirectory(options: SessionDirectoryOptions)
180
180
  export declare function createSessionGroupStore(options: SessionGroupStoreOptions): Promise<SessionGroupStore>;
181
181
  //#endregion
182
182
  //#region src/services/sessionDelivery/type.d.ts
183
- export declare const DOOM_SESSION_DELIVERY_SERVICE = "doom/session-delivery";
184
- type DoomSessionDeliveryInboxState = 'accepted' | 'admitting' | 'admitted' | 'recovery_required';
185
- type DoomSessionDeliveryMode = 'prompt' | 'steer' | 'followUp';
186
- interface DoomSessionDeliveryMetadata extends Readonly<Record<string, string | undefined>> {
183
+ export declare const PO_SESSION_DELIVERY_SERVICE = "po/session-delivery";
184
+ type PoSessionDeliveryInboxState = 'accepted' | 'admitting' | 'admitted' | 'recovery_required';
185
+ type PoSessionDeliveryMode = 'prompt' | 'steer' | 'followUp';
186
+ interface PoSessionDeliveryMetadata extends Readonly<Record<string, string | undefined>> {
187
187
  readonly worktreeId?: string;
188
188
  readonly fromRole?: string;
189
189
  }
190
- interface DoomSessionDeliveryRequest {
190
+ interface PoSessionDeliveryRequest {
191
191
  readonly deliveryId?: string;
192
192
  readonly recipientKey: string;
193
193
  readonly kind: string;
194
194
  readonly prompt: string;
195
- readonly delivery?: DoomSessionDeliveryMode;
196
- readonly metadata?: DoomSessionDeliveryMetadata;
195
+ readonly delivery?: PoSessionDeliveryMode;
196
+ readonly metadata?: PoSessionDeliveryMetadata;
197
197
  }
198
- interface DoomSessionInboxQuery {
198
+ interface PoSessionInboxQuery {
199
199
  readonly kind?: string;
200
- readonly metadata?: DoomSessionDeliveryMetadata;
201
- readonly state?: DoomSessionDeliveryInboxState;
200
+ readonly metadata?: PoSessionDeliveryMetadata;
201
+ readonly state?: PoSessionDeliveryInboxState;
202
202
  readonly consumed?: boolean;
203
203
  }
204
- interface DoomSessionInboxEntry {
204
+ interface PoSessionInboxEntry {
205
205
  readonly deliveryId: string;
206
206
  readonly senderKey: string;
207
207
  readonly recipientKey: string;
208
208
  readonly kind: string;
209
209
  readonly prompt: string;
210
- readonly delivery: DoomSessionDeliveryMode;
211
- readonly metadata: DoomSessionDeliveryMetadata;
212
- readonly state: DoomSessionDeliveryInboxState;
210
+ readonly delivery: PoSessionDeliveryMode;
211
+ readonly metadata: PoSessionDeliveryMetadata;
212
+ readonly state: PoSessionDeliveryInboxState;
213
213
  readonly consumed: boolean;
214
214
  }
215
- interface DoomSessionOutboxEntry {
215
+ interface PoSessionOutboxEntry {
216
216
  readonly deliveryId: string;
217
217
  readonly recipientKey: string;
218
218
  readonly kind: string;
219
- readonly metadata: DoomSessionDeliveryMetadata;
219
+ readonly metadata: PoSessionDeliveryMetadata;
220
220
  readonly state: 'queued' | 'acknowledged';
221
- readonly recipientState?: DoomSessionDeliveryInboxState;
221
+ readonly recipientState?: PoSessionDeliveryInboxState;
222
222
  }
223
- interface DoomSessionDeliveryService {
223
+ interface PoSessionDeliveryService {
224
224
  readonly recipientKey: string;
225
- deliver(request: DoomSessionDeliveryRequest): Promise<{
225
+ deliver(request: PoSessionDeliveryRequest): Promise<{
226
226
  deliveryId: string;
227
227
  }>;
228
- waitForAdmission(deliveryId: string, timeoutMs?: number): Promise<DoomSessionDeliveryInboxState | undefined>;
229
- inbox(query?: DoomSessionInboxQuery): Promise<readonly DoomSessionInboxEntry[]>;
228
+ waitForAdmission(deliveryId: string, timeoutMs?: number): Promise<PoSessionDeliveryInboxState | undefined>;
229
+ inbox(query?: PoSessionInboxQuery): Promise<readonly PoSessionInboxEntry[]>;
230
230
  /** Optional host-routed peer envelope admission. Local-only consumers need no transport receiver. */
231
- receive?(senderKey: string, kind: string, payload: unknown): Promise<DoomSessionDeliveryInboxState | undefined>;
231
+ receive?(senderKey: string, kind: string, payload: unknown): Promise<PoSessionDeliveryInboxState | undefined>;
232
232
  consume(deliveryId: string): Promise<boolean>;
233
- outbox(deliveryId: string): Promise<DoomSessionOutboxEntry | undefined>;
233
+ outbox(deliveryId: string): Promise<PoSessionOutboxEntry | undefined>;
234
234
  close(): Promise<void>;
235
235
  }
236
236
  interface SessionDeliveryServiceOptions {
@@ -240,22 +240,22 @@ interface SessionDeliveryServiceOptions {
240
240
  */
241
241
  readonly database: SessionSqliteDatabase;
242
242
  readonly recipientKey: string;
243
- readonly communication: DoomSessionCommunicationEndpoint;
243
+ readonly communication: PoSessionCommunicationEndpoint;
244
244
  /** Host-owned relationship check applied before sends, retries, and recipient acceptance. */
245
- readonly authorizePeer: (peerKey: string, metadata?: DoomSessionDeliveryMetadata) => boolean | Promise<boolean>;
246
- readonly admitPrompt: (prompt: string, delivery?: DoomSessionDeliveryMode) => Promise<void>;
245
+ readonly authorizePeer: (peerKey: string, metadata?: PoSessionDeliveryMetadata) => boolean | Promise<boolean>;
246
+ readonly admitPrompt: (prompt: string, delivery?: PoSessionDeliveryMode) => Promise<void>;
247
247
  }
248
248
  declare module '@deepseek-ai/cordis' {
249
249
  interface Context {
250
- 'doom/session-delivery': DoomSessionDeliveryService;
250
+ 'po/session-delivery': PoSessionDeliveryService;
251
251
  }
252
252
  }
253
253
  /** Reads the currently active provider each time, without retaining a stale binding. */
254
- export declare function readDoomSessionDelivery(context: Context): DoomSessionDeliveryService | undefined;
254
+ export declare function readPoSessionDelivery(context: Context): PoSessionDeliveryService | undefined;
255
255
  //#endregion
256
256
  //#region src/services/sessionDelivery/index.d.ts
257
257
  /** Opens and starts one durable delivery endpoint. */
258
- export declare function createSessionDeliveryService(options: SessionDeliveryServiceOptions): Promise<DoomSessionDeliveryService>;
258
+ export declare function createSessionDeliveryService(options: SessionDeliveryServiceOptions): Promise<PoSessionDeliveryService>;
259
259
  /**
260
260
  * Installs a provider-owned endpoint in the current Cordis context.
261
261
  *
@@ -264,12 +264,12 @@ export declare function createSessionDeliveryService(options: SessionDeliverySer
264
264
  * LOADING, which is the whole of that fiber's own callback.
265
265
  */
266
266
  export declare function provideSessionDeliveryService(context: Context, options: SessionDeliveryServiceOptions): Promise<{
267
- readonly service: DoomSessionDeliveryService;
267
+ readonly service: PoSessionDeliveryService;
268
268
  readonly close: () => Promise<void>;
269
269
  }>;
270
270
  //#endregion
271
271
  //#region src/services/sessionIntercom/type.d.ts
272
- export declare const DOOM_SESSION_INTERCOM_SERVICE = "doom/session-intercom";
272
+ export declare const PO_SESSION_INTERCOM_SERVICE = "po/session-intercom";
273
273
  type SessionReportStatus = 'done' | 'blocked' | 'failed';
274
274
  interface SessionIntercomMessage {
275
275
  readonly deliveryId: string;
@@ -279,7 +279,7 @@ interface SessionIntercomMessage {
279
279
  readonly correlationId?: string;
280
280
  readonly text: string;
281
281
  readonly reportStatus?: SessionReportStatus;
282
- readonly state: DoomSessionInboxEntry['state'];
282
+ readonly state: PoSessionInboxEntry['state'];
283
283
  readonly consumed: boolean;
284
284
  }
285
285
  interface SessionIntercomSendRequest {
@@ -293,7 +293,7 @@ interface SessionIntercomOptions {
293
293
  readonly selfReference: string;
294
294
  readonly directory: SessionDirectory;
295
295
  readonly groups: SessionGroupStore;
296
- readonly delivery: DoomSessionDeliveryService;
296
+ readonly delivery: PoSessionDeliveryService;
297
297
  }
298
298
  interface SessionIntercom {
299
299
  discover(): Promise<readonly DiscoveredSession[]>;
@@ -306,17 +306,17 @@ interface SessionIntercom {
306
306
  deliveryId: string;
307
307
  }>;
308
308
  messages(): Promise<readonly SessionIntercomMessage[]>;
309
- delivery(deliveryId: string): Promise<DoomSessionOutboxEntry | undefined>;
309
+ delivery(deliveryId: string): Promise<PoSessionOutboxEntry | undefined>;
310
310
  }
311
311
  interface SessionGroupDeliveryAuthorizationOptions {
312
312
  readonly selfReference: string;
313
313
  readonly groups: SessionGroupStore;
314
314
  readonly peerReference: (peerKey: string) => string | undefined;
315
- readonly fallback?: (peerKey: string, metadata: DoomSessionDeliveryMetadata | undefined) => boolean | Promise<boolean>;
315
+ readonly fallback?: (peerKey: string, metadata: PoSessionDeliveryMetadata | undefined) => boolean | Promise<boolean>;
316
316
  }
317
317
  declare module '@deepseek-ai/cordis' {
318
318
  interface Context {
319
- 'doom/session-intercom': SessionIntercom;
319
+ 'po/session-intercom': SessionIntercom;
320
320
  }
321
321
  }
322
322
  export declare function readSessionIntercom(context: Context): SessionIntercom | undefined;
@@ -326,7 +326,7 @@ export declare function requireSessionIntercom(context: Context): SessionInterco
326
326
  /** Agent-facing intercom operations. A composition may acquire this service without gaining session controls. */
327
327
  export declare function createSessionIntercom(options: SessionIntercomOptions): SessionIntercom;
328
328
  /** Builds the dynamic delivery check used before every send, retry, and recipient acceptance. */
329
- export declare function createSessionGroupDeliveryAuthorizer(options: SessionGroupDeliveryAuthorizationOptions): (peerKey: string, metadata: DoomSessionDeliveryMetadata | undefined) => Promise<boolean>;
329
+ export declare function createSessionGroupDeliveryAuthorizer(options: SessionGroupDeliveryAuthorizationOptions): (peerKey: string, metadata: PoSessionDeliveryMetadata | undefined) => Promise<boolean>;
330
330
  //#endregion
331
- export type { DiscoveredSession, DoomSessionDeliveryInboxState, DoomSessionDeliveryMetadata, DoomSessionDeliveryMode, DoomSessionDeliveryRequest, DoomSessionDeliveryService, DoomSessionInboxEntry, DoomSessionInboxQuery, DoomSessionOutboxEntry, RemoteSessionReference, SessionActivityState, SessionCommunicationGroup, SessionDeliveryServiceOptions, SessionDirectory, SessionDirectoryOptions, SessionDiscoveryGrant, SessionGroupDeliveryAuthorizationOptions, SessionGroupMutation, SessionGroupStore, SessionGroupStoreOptions, SessionHostReachability, SessionIntercom, SessionIntercomMessage, SessionIntercomOptions, SessionIntercomSendRequest, SessionPeer, SessionPeerConfig, SessionPeerEnvelope, SessionPeerReplayGuard, SessionPeerReplayGuardAsync, SessionPresenceFacts, SessionPresenceObservation, SessionReportStatus, SessionRuntimeState, SessionVoiceReadiness };
331
+ export type { DiscoveredSession, PoSessionDeliveryInboxState, PoSessionDeliveryMetadata, PoSessionDeliveryMode, PoSessionDeliveryRequest, PoSessionDeliveryService, PoSessionInboxEntry, PoSessionInboxQuery, PoSessionOutboxEntry, RemoteSessionReference, SessionActivityState, SessionCommunicationGroup, SessionDeliveryServiceOptions, SessionDirectory, SessionDirectoryOptions, SessionDiscoveryGrant, SessionGroupDeliveryAuthorizationOptions, SessionGroupMutation, SessionGroupStore, SessionGroupStoreOptions, SessionHostReachability, SessionIntercom, SessionIntercomMessage, SessionIntercomOptions, SessionIntercomSendRequest, SessionPeer, SessionPeerConfig, SessionPeerEnvelope, SessionPeerReplayGuard, SessionPeerReplayGuardAsync, SessionPresenceFacts, SessionPresenceObservation, SessionReportStatus, SessionRuntimeState, SessionVoiceReadiness };
332
332
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":["_0"],"sources":["../src/services/backgroundWorkService/index.ts","../src/services/sessionGroups/type.ts","../src/services/peerTransport/config.ts","../src/services/peerTransport/sync.ts","../src/services/peerTransport/index.ts","../src/services/sessionDirectory/type.ts","../src/services/sessionDirectory/index.ts","../src/services/sessionGroups/index.ts","../src/services/sessionDelivery/type.ts","../src/services/sessionDelivery/index.ts","../src/services/sessionIntercom/type.ts","../src/services/sessionIntercom/index.ts"],"mappings":";;;;;;wBAmBgB,4BAA4B,KAAK,UAAU;;wBAoE3C,6BAA6B,SAAS;;;;KCpF1C,wBAAwB,QAAQ,WAAW;UAEtC;WACN;WACA;WACA;WACA;;UAGM;WACN;WACA;WACA;WACA;WACA;;UAGM;;;;;WAKN,UAAU;WACV,uBAAuB,mBAAmB,OAAO;WACjD,sBAAsB,iBAAiB;;UAGjC;EACf,OAAO,iBAAiB,wBAAwB,6BAA6B,QAAQ;EACrF,OAAO,UAAU,uBAAuB,QAAQ;EAChD,IAAI,kBAAkB,QAAQ;EAC9B,UAAU,0BAA0B,iBAAiB;EACrD,WAAW,iBAAiB,yBAAyB,0BAA0B;EAC/E,SAAS;;qBAGE,kCAAkC;EAC7C,YAAY,iBAAiB,kBAAkB;;;;cCpCpC;UAWI;WACN;WACA;WACA;;WAEA;;WAEA;;UAGM;WACN,gBA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mts","names":["_0"],"sources":["../src/services/backgroundWorkService/index.ts","../src/services/sessionGroups/type.ts","../src/services/peerTransport/config.ts","../src/services/peerTransport/sync.ts","../src/services/peerTransport/index.ts","../src/services/sessionDirectory/type.ts","../src/services/sessionDirectory/index.ts","../src/services/sessionGroups/index.ts","../src/services/sessionDelivery/type.ts","../src/services/sessionDelivery/index.ts","../src/services/sessionIntercom/type.ts","../src/services/sessionIntercom/index.ts"],"mappings":";;;;;;wBAmBgB,4BAA4B,KAAK,UAAU;;wBAoE3C,6BAA6B,SAAS;;;;KCpF1C,wBAAwB,QAAQ,WAAW;UAEtC;WACN;WACA;WACA;WACA;;UAGM;WACN;WACA;WACA;WACA;WACA;;UAGM;;;;;WAKN,UAAU;WACV,uBAAuB,mBAAmB,OAAO;WACjD,sBAAsB,iBAAiB;;UAGjC;EACf,OAAO,iBAAiB,wBAAwB,6BAA6B,QAAQ;EACrF,OAAO,UAAU,uBAAuB,QAAQ;EAChD,IAAI,kBAAkB,QAAQ;EAC9B,UAAU,0BAA0B,iBAAiB;EACrD,WAAW,iBAAiB,yBAAyB,0BAA0B;EAC/E,SAAS;;qBAGE,kCAAkC;EAC7C,YAAY,iBAAiB,kBAAkB;;;;cCpCpC;UAWI;WACN;WACA;WACA;;WAEA;;WAEA;;UAGM;WACN,gBAAgB;WAChB;WACA,gBAAgB;;UAGV;EACf,MAAM,SAAS,SAAS;EACxB;;UAGe;EACf,MAAM,SAAS,SAAS,eAAe;EACvC,SAAS;;wBAqCK,sBAAsB;;;;;;;;wBCrDtB,sBAAsB,wBAAwB;;;;;;wBAiB9C,sBAAsB,wBAAwB;;;;KCZzD,YAAY,WAAW;UAEX;WACN;WACA;;UAGM;WACN;WACA;WACA;WACA;;;wBAIW,2BACpB,IAAI,YACJ,uBACA,SAAS,YACR,QAAQ;;wBA+BK,4BAA4B,gBAAgB;wBAK5C,qBAAqB,gBAAgB;wBAWrC,mBACd,sBACA,MAAM,aACN,gBACA,kBACA,cACA,eACC;;;;;w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f,gBAAgB,iBAAiB,WAAW,wCAAwC;WACpF,cAAc,gBAAgB,WAAW,0BAA0B;;;YAIlE;IACR,uBAAuB;;;;wBAKX,sBAAsB,SAAS,UAAU;;;;wBC+EnC,6BACpB,SAAS,gCACR,QAAQ;;;;;;;;wBAuWW,8BACpB,SAAS,SACT,SAAS,gCACR;WAAmB,SAAS;WAAmC,aAAa;;;;qBCpgBlE;KAED;UAEK;WACN;WACA;WACA;WACA;WACA;WACA;WACA,eAAe;WACf,OAAO;WACP;;UAGM;WACN;WACA;WACA;WACA;WACA;;UAGM;WACN;WACA,WAAW;WACX,QAAQ;WACR,UAAU;;UAGJ;EACf,YAAY,iBAAiB;EAC7B,KAAK,SAAS,6BAA6B;IAAU;;EACrD,OACE,SAAS;aAAwC,QAAQ;MACxD;IAAU;;EACb,YAAY,iBAAiB;EAC7B,SAAS,qBAAqB,QAAQ;;UAGvB;WACN;WACA,QAAQ;WACR,gBAAgB;WAChB,YAAY,iBAAiB,UAAU,oDAAoD;;;YAI1F;IACR,uBAAuB;;;wBAIX,oBAAoB,SAAS,UAAU;wBAIvC,uBAAuB,SAAS,UAAU;;;;wBCxB1C,sBAAsB,SAAS,yBAAyB;;wBA6ExD,qCACd,SAAS,4CACP,iBAAiB,UAAU,0CAA0C"}
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { r as DOOM_SESSION_DELIVERY_SERVICE, s as DOOM_SESSION_INTERCOM_SERVICE, d as SessionGroupRevisionError, E as createBackgroundWorkService, p as createPeerCommunication, S as createPeerReplayGuard, m as createPeerReplayGuardAsync, t as createSessionDeliveryService, f as createSessionDirectory, a as createSessionGroupDeliveryAuthorizer, u as createSessionGroupStore, o as createSessionIntercom, g as parseRemoteSessionReference, v as peerRequestHeaders, y as peerSessionReference, D as provideBackgroundWorkService, n as provideSessionDeliveryService, i as readDoomSessionDelivery, c as readSessionIntercom, C as readSessionPeerConfig, b as readSessionPeerConfigAsync, l as requireSessionIntercom, T as sessionPeerConfigPath, x as verifyPeerRequest } from "./sessionDelivery-BzPl0sCk.mjs";
1
+ export { r as PO_SESSION_DELIVERY_SERVICE, s as PO_SESSION_INTERCOM_SERVICE, d as SessionGroupRevisionError, E as createBackgroundWorkService, p as createPeerCommunication, S as createPeerReplayGuard, m as createPeerReplayGuardAsync, t as createSessionDeliveryService, f as createSessionDirectory, a as createSessionGroupDeliveryAuthorizer, u as createSessionGroupStore, o as createSessionIntercom, g as parseRemoteSessionReference, v as peerRequestHeaders, y as peerSessionReference, D as provideBackgroundWorkService, n as provideSessionDeliveryService, i as readPoSessionDelivery, c as readSessionIntercom, C as readSessionPeerConfig, b as readSessionPeerConfigAsync, l as requireSessionIntercom, T as sessionPeerConfigPath, x as verifyPeerRequest } from "./sessionDelivery-CROSMn_N.mjs";