@agimon-ai/po-session 0.0.0-alpha.125 → 0.0.0-alpha.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +34 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +9 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +34 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -128,14 +128,6 @@ function createCoordinatorService(options) {
|
|
|
128
128
|
const home = general === void 0 ? void 0 : oldestCoordinator(general.id);
|
|
129
129
|
return home === void 0 ? void 0 : options.records().find((record) => record.sessionId === home.sessionId)?.coordinator;
|
|
130
130
|
};
|
|
131
|
-
const defaultPersona = (root) => {
|
|
132
|
-
const profile = options.defaultProfile(root);
|
|
133
|
-
if (profile === void 0) throw new Error("Choose a default profile before adding a coordinator.");
|
|
134
|
-
return {
|
|
135
|
-
profile,
|
|
136
|
-
name: profile
|
|
137
|
-
};
|
|
138
|
-
};
|
|
139
131
|
const recordPersona = (sessionId, coordinator) => {
|
|
140
132
|
const record = options.records().find((entry) => entry.sessionId === sessionId);
|
|
141
133
|
if (record === void 0) return;
|
|
@@ -201,12 +193,40 @@ function createCoordinatorService(options) {
|
|
|
201
193
|
}
|
|
202
194
|
return { sessionId };
|
|
203
195
|
},
|
|
204
|
-
async add(workspaceId) {
|
|
205
|
-
if (
|
|
206
|
-
const workspace = options.workspaces().find((entry) => entry.id === workspaceId);
|
|
207
|
-
if (
|
|
208
|
-
|
|
209
|
-
|
|
196
|
+
async add(workspaceId, profile) {
|
|
197
|
+
if (profile !== void 0 && (typeof profile !== "string" || profile.trim() === "")) throw new Error("A coordinator profile must be non-empty text.");
|
|
198
|
+
const workspace = workspaceId === void 0 ? homeWorkspace() : options.workspaces().find((entry) => entry.id === workspaceId);
|
|
199
|
+
if (workspaceId !== void 0) {
|
|
200
|
+
if (workspace === void 0) throw new Error(`Workspace '${workspaceId}' not found.`);
|
|
201
|
+
if (!coordinated(workspace)) throw new Error("This workspace cannot have a coordinator.");
|
|
202
|
+
}
|
|
203
|
+
const existing = workspace === void 0 ? void 0 : oldestCoordinator(workspace.id);
|
|
204
|
+
const inherited = homePersona();
|
|
205
|
+
const selected = profile?.trim() ?? inherited?.profile ?? options.defaultProfile(workspaceId === void 0 ? void 0 : workspace?.root);
|
|
206
|
+
if (selected === void 0 && existing === void 0) return {
|
|
207
|
+
profileRequired: true,
|
|
208
|
+
error: "Choose a profile before adding a coordinator."
|
|
209
|
+
};
|
|
210
|
+
if (selected === void 0 && existing !== void 0) {
|
|
211
|
+
if (!existing.live) {
|
|
212
|
+
const record = options.records().find((entry) => entry.sessionId === existing.sessionId);
|
|
213
|
+
if (record === void 0) throw new Error("The coordinator record disappeared while reviving it.");
|
|
214
|
+
await options.revive(record);
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
sessionId: existing.sessionId,
|
|
218
|
+
created: false
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
const settings = profile !== void 0 ? {
|
|
222
|
+
profile: selected,
|
|
223
|
+
name: selected
|
|
224
|
+
} : inherited ?? {
|
|
225
|
+
profile: selected ?? "",
|
|
226
|
+
name: selected ?? ""
|
|
227
|
+
};
|
|
228
|
+
if (profile !== void 0 && existing === void 0) await options.validateProfile?.(selected, workspaceId === void 0 ? void 0 : workspace);
|
|
229
|
+
return workspaceId === void 0 ? ensureHome(settings) : ensureCoordinator(workspaceId, workspaceSettings(workspace, settings));
|
|
210
230
|
},
|
|
211
231
|
async setRole(sessionId, coordinator) {
|
|
212
232
|
let live = options.liveSessions().find((session) => session.id === sessionId);
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["REMOTE_CONVERSATION_SESSION_PROVENANCE","COORDINATOR_SESSION_PROVENANCE","COORDINATOR_SESSION_PROVENANCE","verifyEnvelope","createClientHandshake","createHostHandshake"],"sources":["../src/services/sessionCoordination/policy.ts","../src/services/sessionCoordination/index.ts","../src/services/peerLink/roster.ts"],"sourcesContent":["import {\n COORDINATOR_SESSION_PROVENANCE,\n REMOTE_CONVERSATION_SESSION_PROVENANCE,\n type PoSessionCommunicationPolicy,\n type PoSessionCommunicationSubject,\n} from '@agimon-ai/po-core/hubChannel';\n\n/** ponytail: a fixed per-coordinator budget; add configuration only when another number is needed. */\nexport const COORDINATOR_STARTS_PER_HOUR = 5;\nexport const COORDINATOR_START_WINDOW_MS = 60 * 60 * 1000;\n\nexport function assertCoordinatorStartBudget(count: number): void {\n if (count >= COORDINATOR_STARTS_PER_HOUR)\n throw new Error(`A coordinator can start at most ${COORDINATOR_STARTS_PER_HOUR} sessions an hour.`);\n}\n\nexport function assertCoordinatorStartScope(\n callerWorkspaceId: string | undefined,\n homeWorkspaceId: string | undefined,\n workspace: { id: string; kind?: 'session'; available?: boolean; sandbox?: string } | undefined,\n hasCoordinator: boolean,\n): void {\n if (workspace === undefined || workspace.available === false || workspace.sandbox !== undefined)\n throw new Error('The target workspace is unavailable.');\n if (workspace.id === callerWorkspaceId) return;\n if (callerWorkspaceId === undefined || callerWorkspaceId !== homeWorkspaceId || workspace.kind === 'session')\n throw new Error('Only the home coordinator can target another workspace.');\n if (hasCoordinator) throw new Error('This workspace has a coordinator. Ask it to start the session.');\n}\n\n/** Communication is symmetric. A message grant never grants lifecycle authority. */\nexport const canSessionsCommunicate: PoSessionCommunicationPolicy = (input) => {\n const { source, target } = input;\n if (source.id === target.id) return false;\n if (source.parentSessionId === target.id || target.parentSessionId === source.id) return true;\n if (\n source.sessionProvenance === REMOTE_CONVERSATION_SESSION_PROVENANCE ||\n target.sessionProvenance === REMOTE_CONVERSATION_SESSION_PROVENANCE\n )\n return false;\n const coordinates = (session: PoSessionCommunicationSubject): boolean =>\n session.sessionProvenance === COORDINATOR_SESSION_PROVENANCE;\n const home = (session: PoSessionCommunicationSubject): boolean =>\n coordinates(session) &&\n session.workspaceId !== undefined &&\n input.workspaces.some((workspace) => workspace.id === session.workspaceId && workspace.kind === 'session');\n const homeFallback = (coordinator: PoSessionCommunicationSubject, peer: PoSessionCommunicationSubject): boolean => {\n if (!home(coordinator) || peer.workspaceId === undefined) return false;\n const workspace = input.workspaces.find((entry) => entry.id === peer.workspaceId);\n if (!workspace || workspace.kind === 'session' || workspace.sandbox !== undefined || workspace.available === false)\n return false;\n return (\n !input.sessions.some((session) => session.workspaceId === workspace.id && coordinates(session)) &&\n !input.dormantSessions.some(\n (record) =>\n record.workspaceId === workspace.id &&\n record.sessionProvenance === COORDINATOR_SESSION_PROVENANCE &&\n !input.sessions.some((session) => session.id === record.sessionId),\n )\n );\n };\n if (\n (coordinates(source) || coordinates(target)) &&\n source.workspaceId !== undefined &&\n source.workspaceId === target.workspaceId\n )\n return true;\n if (coordinates(source) && coordinates(target) && (home(source) || home(target))) return true;\n if (homeFallback(source, target) || homeFallback(target, source)) return true;\n if (source.workspaceId !== undefined && source.workspaceId === target.workspaceId && input.filesOverlap) return true;\n return (source.groups ?? []).some((group) => target.groups?.includes(group) === true);\n};\n","import { COORDINATOR_SESSION_PROVENANCE } from '@agimon-ai/po-core/hubChannel';\n\nimport { assertCoordinatorStartBudget, assertCoordinatorStartScope, COORDINATOR_START_WINDOW_MS } from './policy';\nimport type {\n CoordinatorSettings,\n CoordinatorResult,\n CoordinatorWorkspace,\n CoordinatorCreateRequest,\n CoordinatorServiceOptions,\n CoordinatorService,\n} from './type';\n\nexport { COORDINATOR_STARTS_PER_HOUR } from './policy';\nconst FALLBACK_SLUG = 'workspace';\n\nexport type {\n CoordinatorSettings,\n CoordinatorResult,\n CoordinatorCreateRequest,\n CoordinatorServiceOptions,\n CoordinatorService,\n} from './type';\n\n/** Kebab-case from the workspace name, else its folder name. */\nexport function workspaceSlug(workspace: { readonly name?: string; readonly root: string }): string {\n const source = workspace.name?.trim() || workspace.root.split(/[\\\\/]/u).filter(Boolean).pop() || '';\n const slug = source\n .toLowerCase()\n .replace(/[^a-z0-9]+/gu, '-')\n .replace(/^-+|-+$/gu, '');\n return slug || FALLBACK_SLUG;\n}\n\nexport function createCoordinatorService(options: CoordinatorServiceOptions): CoordinatorService {\n const opening = new Map<string, Promise<CoordinatorResult>>();\n const starts = new Map<string, number[]>();\n const now = (): number => options.now?.() ?? Date.now();\n\n const homeWorkspace = (): CoordinatorWorkspace | undefined =>\n options.workspaces().find((workspace) => workspace.kind === 'session');\n\n /** Live sessions first, so a live coordinator's record is never mistaken for a dormant one. Oldest wins. */\n const coordinatorsIn = (workspaceId: string): { sessionId: string; createdAt: string; live: boolean }[] => {\n const liveSessions = options.liveSessions();\n const live = liveSessions\n .filter(\n (session) =>\n session.sessionProvenance === COORDINATOR_SESSION_PROVENANCE && session.workspaceId === workspaceId,\n )\n .map((session) => ({ sessionId: session.id, createdAt: session.createdAt, live: true }));\n const dormant = options\n .records()\n .filter(\n (record) =>\n record.sessionProvenance === COORDINATOR_SESSION_PROVENANCE &&\n record.workspaceId === workspaceId &&\n !liveSessions.some((session) => session.id === record.sessionId),\n )\n .map((record) => ({ sessionId: record.sessionId, createdAt: record.createdAt, live: false }));\n return [...live, ...dormant].sort((a, b) => a.createdAt.localeCompare(b.createdAt));\n };\n\n const oldestCoordinator = (workspaceId: string) => {\n const found = coordinatorsIn(workspaceId);\n if (found.length > 1)\n options.notice(\n `Workspace '${workspaceId}' has ${found.length} coordinators; using the oldest, '${found[0]?.sessionId}'.`,\n );\n return found[0];\n };\n\n const open = async (target: string, settings: CoordinatorSettings): Promise<CoordinatorResult> => {\n const workspace = target === 'home' ? homeWorkspace() : options.workspaces().find((entry) => entry.id === target);\n if (target !== 'home') {\n if (workspace === undefined) throw new Error(`Workspace '${target}' not found.`);\n if (workspace.kind === 'session') throw new Error('The home workspace takes the home coordinator.');\n if (!coordinated(workspace)) throw new Error('This workspace cannot have a coordinator.');\n }\n if (workspace?.sandbox !== undefined) throw new Error('This workspace cannot have a coordinator.');\n const existing = workspace === undefined ? undefined : oldestCoordinator(workspace.id);\n if (existing !== undefined) {\n if (!existing.live) {\n const record = options.records().find((entry) => entry.sessionId === existing.sessionId);\n if (record === undefined) throw new Error('The coordinator record disappeared while reviving it.');\n await options.revive(record);\n }\n return { sessionId: existing.sessionId, created: false };\n }\n const request: CoordinatorCreateRequest = {\n name: settings.name,\n sessionProvenance: COORDINATOR_SESSION_PROVENANCE,\n selection: { profile: settings.profile },\n ...(settings.model === undefined ? {} : { model: settings.model }),\n };\n const { sessionId } =\n workspace === undefined || target === 'home'\n ? await options.createGeneral(request)\n : await options.createInWorkspace(workspace, request);\n // The persona rides on the record, so the admit path still knows it after a restart.\n const record = options.records().find((entry) => entry.sessionId === sessionId);\n const coordinator = {\n profile: settings.profile,\n name: settings.name,\n ...(settings.model === undefined ? {} : { model: settings.model }),\n };\n if (record === undefined || !options.saveRecord({ ...record, coordinator }))\n options.notice(`Coordinator '${sessionId}' persona could not be recorded.`);\n return { sessionId, created: true };\n };\n\n const ensureCoordinator = (target: string, settings: CoordinatorSettings): Promise<CoordinatorResult> => {\n const pending = opening.get(target);\n if (pending !== undefined) return pending;\n const run = open(target, settings).finally(() => opening.delete(target));\n opening.set(target, run);\n return run;\n };\n\n const workspaceSettings = (workspace: CoordinatorWorkspace, home: CoordinatorSettings): CoordinatorSettings => ({\n profile: home.profile,\n name: `${home.name}-${workspaceSlug(workspace)}`,\n ...(home.model === undefined ? {} : { model: home.model }),\n });\n\n // Sandboxed workspaces get no coordinator; their sessions live in the sandbox's own records.\n const coordinated = (workspace: CoordinatorWorkspace): boolean =>\n workspace.kind !== 'session' && workspace.available !== false && workspace.sandbox === undefined;\n\n const homePersona = (): CoordinatorSettings | undefined => {\n const general = homeWorkspace();\n const home = general === undefined ? undefined : oldestCoordinator(general.id);\n return home === undefined\n ? undefined\n : options.records().find((record) => record.sessionId === home.sessionId)?.coordinator;\n };\n\n const defaultPersona = (root?: string): CoordinatorSettings => {\n const profile = options.defaultProfile(root);\n if (profile === undefined) throw new Error('Choose a default profile before adding a coordinator.');\n return { profile, name: profile };\n };\n\n const recordPersona = (sessionId: string, coordinator: CoordinatorSettings | undefined): void => {\n const record = options.records().find((entry) => entry.sessionId === sessionId);\n if (record === undefined) return;\n const { coordinator: _dropped, ...rest } = record;\n if (!options.saveRecord(coordinator === undefined ? rest : { ...rest, coordinator }))\n options.notice(`Coordinator '${sessionId}' persona could not be recorded.`);\n };\n\n const demote = async (sessionId: string): Promise<void> => {\n if (options.liveSessions().some((session) => session.id === sessionId)) await options.reopen(sessionId, {});\n else {\n const record = options.records().find((entry) => entry.sessionId === sessionId);\n if (record === undefined) return;\n const { sessionProvenance: _dropped, ...rest } = record;\n if (!options.saveRecord(rest)) throw new Error(`Session '${sessionId}' could not be made regular.`);\n }\n recordPersona(sessionId, undefined);\n };\n\n const ensureHome = async (settings: CoordinatorSettings): Promise<CoordinatorResult> => {\n const home = await ensureCoordinator('home', settings);\n const outcomes = await Promise.allSettled(\n options\n .workspaces()\n .filter(coordinated)\n .map((workspace) => ensureCoordinator(workspace.id, workspaceSettings(workspace, settings))),\n );\n for (const outcome of outcomes)\n if (outcome.status === 'rejected')\n options.notice(`A workspace coordinator could not be opened: ${String(outcome.reason)}`);\n return home;\n };\n\n return {\n ensureCoordinator,\n ensureHome,\n async workspaceAdmitted(workspaceId) {\n const workspace = options.workspaces().find((entry) => entry.id === workspaceId);\n const general = homeWorkspace();\n if (workspace === undefined || general === undefined || !coordinated(workspace)) return;\n const home = oldestCoordinator(general.id);\n if (home === undefined) return;\n const persona = options.records().find((record) => record.sessionId === home.sessionId)?.coordinator;\n if (persona === undefined) {\n options.notice(\n `Home coordinator '${home.sessionId}' has no recorded persona; workspace '${workspaceId}' gets none.`,\n );\n return;\n }\n await ensureCoordinator(workspaceId, workspaceSettings(workspace, persona));\n },\n async startSession(coordinatorSessionId, request) {\n const caller = options.liveSessions().find((session) => session.id === coordinatorSessionId);\n if (caller?.sessionProvenance !== COORDINATOR_SESSION_PROVENANCE)\n throw new Error('Only a coordinator can start sessions.');\n const name = request.name.trim();\n const brief = request.brief.trim();\n if (name === '' || brief === '') throw new Error('A started session needs a name and a brief.');\n if (\n request.workspaceId !== undefined &&\n (typeof request.workspaceId !== 'string' || request.workspaceId.trim() === '')\n )\n throw new Error('A target workspace ID must be non-empty text.');\n const workspace = options.workspaces().find((entry) => entry.id === (request.workspaceId ?? caller.workspaceId));\n assertCoordinatorStartScope(\n caller.workspaceId,\n homeWorkspace()?.id,\n workspace,\n workspace !== undefined && oldestCoordinator(workspace.id) !== undefined,\n );\n const at = now();\n const recent = (starts.get(coordinatorSessionId) ?? []).filter((time) => at - time < COORDINATOR_START_WINDOW_MS);\n assertCoordinatorStartBudget(recent.length);\n starts.set(coordinatorSessionId, [...recent, at]);\n // No parent link: a parent may close its children, and a coordinator never stops sessions.\n const { sessionId } =\n workspace!.kind === 'session'\n ? await options.createGeneral({ name })\n : await options.createInWorkspace(workspace!, { name });\n try {\n await options.prompt(sessionId, brief);\n } catch (error) {\n // Creation committed and spent its quota. Report the id so callers do not blindly retry.\n return { sessionId, promptError: error instanceof Error ? error.message : String(error) };\n }\n return { sessionId };\n },\n async add(workspaceId) {\n if (workspaceId === undefined) return ensureHome(homePersona() ?? defaultPersona());\n const workspace = options.workspaces().find((entry) => entry.id === workspaceId);\n if (workspace === undefined) throw new Error(`Workspace '${workspaceId}' not found.`);\n if (!coordinated(workspace)) throw new Error('This workspace cannot have a coordinator.');\n return ensureCoordinator(\n workspaceId,\n workspaceSettings(workspace, homePersona() ?? defaultPersona(workspace.root)),\n );\n },\n async setRole(sessionId, coordinator) {\n let live = options.liveSessions().find((session) => session.id === sessionId);\n const record = options.records().find((entry) => entry.sessionId === sessionId);\n const current = live ?? (record === undefined ? undefined : { ...record, id: record.sessionId });\n if (current?.workspaceId === undefined) throw new Error('Session not found.');\n if ((current.sessionProvenance === COORDINATOR_SESSION_PROVENANCE) === coordinator) return;\n if (!coordinator) return demote(sessionId);\n if (current.parentSessionId !== undefined) throw new Error('A nested session cannot become a coordinator.');\n // A worktree, workflow or voice session keeps the role its provenance gives it.\n if (current.sessionProvenance !== undefined)\n throw new Error(`A ${current.sessionProvenance} session cannot become a coordinator.`);\n const workspace = options.workspaces().find((entry) => entry.id === current.workspaceId);\n if (\n workspace === undefined ||\n workspace.sandbox !== undefined ||\n (workspace.kind !== 'session' && !coordinated(workspace))\n )\n throw new Error('This workspace cannot have a coordinator.');\n for (const other of coordinatorsIn(workspace.id)) await demote(other.sessionId);\n if (live === undefined) {\n await options.revive(record!);\n live = options.liveSessions().find((session) => session.id === sessionId);\n }\n // The session keeps its own persona; one without gets the default.\n const profile = live?.profile?.name ?? options.defaultProfile(workspace.root);\n await options.reopen(sessionId, {\n sessionProvenance: COORDINATOR_SESSION_PROVENANCE,\n ...(live?.profile === undefined && profile !== undefined ? { profile } : {}),\n });\n if (profile !== undefined) recordPersona(sessionId, { profile, name: current.name ?? profile });\n else options.notice(`Coordinator '${sessionId}' has no profile; new workspaces will not copy its persona.`);\n },\n };\n}\n","import { verifyEnvelope } from '@agimon-ai/po-web-security/deviceProof';\nimport {\n createClientHandshake,\n createHostHandshake,\n type SealedChannel,\n} from '@agimon-ai/po-web-security/nodeSealedChannel';\n\nimport type {\n RosterLinkProof,\n RosterPeerChannel,\n RosterPeerLinkPorts,\n RosterPeerLinks,\n SignedRosterLinkProof,\n} from './type';\n\nconst LINK_TTL = 60_000;\n\n/** Account links are separate from legacy session-peer secrets and permissions.\n * A fresh signed ephemeral exchange uses the host key in the verified C6 roster.\n * Coordinator availability is irrelevant. Roster removal or rotation fences all\n * existing channel uses; applications must sync and persist C6 before exposing it.\n */\nexport function createRosterPeerLink(ports: RosterPeerLinkPorts): RosterPeerLinks {\n const consumed = new Map<string, number>();\n function check(proof: SignedRosterLinkProof): RosterLinkProof {\n const snapshot = ports.roster();\n const payload = proof.payload;\n const host = snapshot.hosts.find((h) => h.hostId === payload.hostId);\n if (\n !host ||\n payload.hostId === ports.hostId ||\n payload.destinationHostId !== ports.hostId ||\n payload.networkId !== snapshot.networkId ||\n payload.epoch !== snapshot.epoch ||\n !payload.publicKey ||\n !payload.challenge ||\n typeof payload.echo !== 'string' ||\n payload.expiresAt - payload.issuedAt > LINK_TTL ||\n !verifyEnvelope(host.publicKey, 'po/host-request/v1', proof, ports.now())\n )\n throw new Error('Roster link refused');\n return payload;\n }\n function wrap(channel: SealedChannel, hostId: string, epoch: number): RosterPeerChannel {\n const snapshot = ports.roster();\n const remote = snapshot.hosts.find((h) => h.hostId === hostId)?.publicKey;\n const local = snapshot.hosts.find((h) => h.hostId === ports.hostId)?.publicKey;\n const valid = () => {\n const current = ports.roster();\n return (\n !!remote &&\n !!local &&\n current.networkId === snapshot.networkId &&\n current.epoch === epoch &&\n current.hosts.some((h) => h.hostId === hostId && h.publicKey === remote) &&\n current.hosts.some((h) => h.hostId === ports.hostId && h.publicKey === local)\n );\n };\n return {\n seal(plaintext) {\n if (!valid()) return { ok: false, failure: 'auth' };\n return channel.seal(plaintext);\n },\n async open(envelope) {\n if (!valid()) return undefined;\n const opened = channel.open(envelope);\n if (!opened.ok || !(await ports.verifyRequest(opened.plaintext, hostId)) || !valid()) return undefined;\n return opened.plaintext;\n },\n };\n }\n return {\n async connect(hostId, token, exchange) {\n const snapshot = ports.roster();\n if (!snapshot.hosts.some((h) => h.hostId === ports.hostId) || !snapshot.hosts.some((h) => h.hostId === hostId))\n throw new Error('Host is not in roster');\n const handshake = createClientHandshake();\n const payload: RosterLinkProof = {\n networkId: snapshot.networkId,\n epoch: snapshot.epoch,\n hostId: ports.hostId,\n destinationHostId: hostId,\n publicKey: handshake.publicKey,\n challenge: crypto.randomUUID(),\n echo: '',\n issuedAt: ports.now(),\n expiresAt: ports.now() + LINK_TTL,\n };\n const reply = check(await exchange(ports.sign(payload), token));\n if (\n reply.hostId !== hostId ||\n reply.challenge !== payload.challenge ||\n reply.echo !== payload.publicKey ||\n reply.epoch !== payload.epoch\n )\n throw new Error('Roster link response mismatch');\n const channel = handshake.accept(reply.publicKey);\n if (!channel) throw new Error('Invalid roster channel');\n return wrap(channel, hostId, payload.epoch);\n },\n async accept(proof, token) {\n const payload = check(proof);\n if (payload.echo !== '' || !(await ports.authorize(token, payload.hostId, payload.networkId)))\n throw new Error('Roster link denied');\n // Authorization may await a roster sync. Recheck before committing the link.\n check(proof);\n for (const [id, expiry] of consumed) if (expiry <= ports.now()) consumed.delete(id);\n const id = JSON.stringify([payload.hostId, payload.challenge]);\n if (consumed.has(id) || consumed.size >= 1024) throw new Error('Roster link replayed');\n consumed.set(id, payload.expiresAt);\n const handshake = createHostHandshake();\n const channel = handshake.accept(payload.publicKey);\n if (!channel) throw new Error('Invalid roster channel');\n return {\n proof: ports.sign({\n ...payload,\n hostId: ports.hostId,\n destinationHostId: payload.hostId,\n publicKey: handshake.publicKey,\n echo: payload.publicKey,\n issuedAt: ports.now(),\n expiresAt: ports.now() + LINK_TTL,\n }),\n channel: wrap(channel, payload.hostId, payload.epoch),\n };\n },\n };\n}\n"],"mappings":";;;;;;;AAQA,MAAa,8BAA8B;AAC3C,MAAa,8BAA8B;AAE3C,SAAgB,6BAA6B,OAAqB;CAChE,IAAI,SAAA,GACF,MAAM,IAAI,MAAM,qDAAkF;AACtG;AAEA,SAAgB,4BACd,mBACA,iBACA,WACA,gBACM;CACN,IAAI,cAAc,KAAA,KAAa,UAAU,cAAc,SAAS,UAAU,YAAY,KAAA,GACpF,MAAM,IAAI,MAAM,sCAAsC;CACxD,IAAI,UAAU,OAAO,mBAAmB;CACxC,IAAI,sBAAsB,KAAA,KAAa,sBAAsB,mBAAmB,UAAU,SAAS,WACjG,MAAM,IAAI,MAAM,yDAAyD;CAC3E,IAAI,gBAAgB,MAAM,IAAI,MAAM,gEAAgE;AACtG;;AAGA,MAAa,0BAAwD,UAAU;CAC7E,MAAM,EAAE,QAAQ,WAAW;CAC3B,IAAI,OAAO,OAAO,OAAO,IAAI,OAAO;CACpC,IAAI,OAAO,oBAAoB,OAAO,MAAM,OAAO,oB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,MAAM,IAAI,MAAM,wBAAwB;GACtD,OAAO;IACL,OAAO,MAAM,KAAK;KAChB,GAAG;KACH,QAAQ,MAAM;KACd,mBAAmB,QAAQ;KAC3B,WAAW,UAAU;KACrB,MAAM,QAAQ;KACd,UAAU,MAAM,IAAI;KACpB,WAAW,MAAM,IAAI,IAAI;IAC3B,CAAC;IACD,SAAS,KAAK,SAAS,QAAQ,QAAQ,QAAQ,KAAK;GACtD;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["REMOTE_CONVERSATION_SESSION_PROVENANCE","COORDINATOR_SESSION_PROVENANCE","COORDINATOR_SESSION_PROVENANCE","verifyEnvelope","createClientHandshake","createHostHandshake"],"sources":["../src/services/sessionCoordination/policy.ts","../src/services/sessionCoordination/index.ts","../src/services/peerLink/roster.ts"],"sourcesContent":["import {\n COORDINATOR_SESSION_PROVENANCE,\n REMOTE_CONVERSATION_SESSION_PROVENANCE,\n type PoSessionCommunicationPolicy,\n type PoSessionCommunicationSubject,\n} from '@agimon-ai/po-core/hubChannel';\n\n/** ponytail: a fixed per-coordinator budget; add configuration only when another number is needed. */\nexport const COORDINATOR_STARTS_PER_HOUR = 5;\nexport const COORDINATOR_START_WINDOW_MS = 60 * 60 * 1000;\n\nexport function assertCoordinatorStartBudget(count: number): void {\n if (count >= COORDINATOR_STARTS_PER_HOUR)\n throw new Error(`A coordinator can start at most ${COORDINATOR_STARTS_PER_HOUR} sessions an hour.`);\n}\n\nexport function assertCoordinatorStartScope(\n callerWorkspaceId: string | undefined,\n homeWorkspaceId: string | undefined,\n workspace: { id: string; kind?: 'session'; available?: boolean; sandbox?: string } | undefined,\n hasCoordinator: boolean,\n): void {\n if (workspace === undefined || workspace.available === false || workspace.sandbox !== undefined)\n throw new Error('The target workspace is unavailable.');\n if (workspace.id === callerWorkspaceId) return;\n if (callerWorkspaceId === undefined || callerWorkspaceId !== homeWorkspaceId || workspace.kind === 'session')\n throw new Error('Only the home coordinator can target another workspace.');\n if (hasCoordinator) throw new Error('This workspace has a coordinator. Ask it to start the session.');\n}\n\n/** Communication is symmetric. A message grant never grants lifecycle authority. */\nexport const canSessionsCommunicate: PoSessionCommunicationPolicy = (input) => {\n const { source, target } = input;\n if (source.id === target.id) return false;\n if (source.parentSessionId === target.id || target.parentSessionId === source.id) return true;\n if (\n source.sessionProvenance === REMOTE_CONVERSATION_SESSION_PROVENANCE ||\n target.sessionProvenance === REMOTE_CONVERSATION_SESSION_PROVENANCE\n )\n return false;\n const coordinates = (session: PoSessionCommunicationSubject): boolean =>\n session.sessionProvenance === COORDINATOR_SESSION_PROVENANCE;\n const home = (session: PoSessionCommunicationSubject): boolean =>\n coordinates(session) &&\n session.workspaceId !== undefined &&\n input.workspaces.some((workspace) => workspace.id === session.workspaceId && workspace.kind === 'session');\n const homeFallback = (coordinator: PoSessionCommunicationSubject, peer: PoSessionCommunicationSubject): boolean => {\n if (!home(coordinator) || peer.workspaceId === undefined) return false;\n const workspace = input.workspaces.find((entry) => entry.id === peer.workspaceId);\n if (!workspace || workspace.kind === 'session' || workspace.sandbox !== undefined || workspace.available === false)\n return false;\n return (\n !input.sessions.some((session) => session.workspaceId === workspace.id && coordinates(session)) &&\n !input.dormantSessions.some(\n (record) =>\n record.workspaceId === workspace.id &&\n record.sessionProvenance === COORDINATOR_SESSION_PROVENANCE &&\n !input.sessions.some((session) => session.id === record.sessionId),\n )\n );\n };\n if (\n (coordinates(source) || coordinates(target)) &&\n source.workspaceId !== undefined &&\n source.workspaceId === target.workspaceId\n )\n return true;\n if (coordinates(source) && coordinates(target) && (home(source) || home(target))) return true;\n if (homeFallback(source, target) || homeFallback(target, source)) return true;\n if (source.workspaceId !== undefined && source.workspaceId === target.workspaceId && input.filesOverlap) return true;\n return (source.groups ?? []).some((group) => target.groups?.includes(group) === true);\n};\n","import { COORDINATOR_SESSION_PROVENANCE } from '@agimon-ai/po-core/hubChannel';\n\nimport { assertCoordinatorStartBudget, assertCoordinatorStartScope, COORDINATOR_START_WINDOW_MS } from './policy';\nimport type {\n CoordinatorSettings,\n CoordinatorResult,\n CoordinatorWorkspace,\n CoordinatorCreateRequest,\n CoordinatorServiceOptions,\n CoordinatorService,\n} from './type';\n\nexport { COORDINATOR_STARTS_PER_HOUR } from './policy';\nconst FALLBACK_SLUG = 'workspace';\n\nexport type {\n CoordinatorSettings,\n CoordinatorResult,\n CoordinatorAddResult,\n CoordinatorCreateRequest,\n CoordinatorServiceOptions,\n CoordinatorService,\n} from './type';\n\n/** Kebab-case from the workspace name, else its folder name. */\nexport function workspaceSlug(workspace: { readonly name?: string; readonly root: string }): string {\n const source = workspace.name?.trim() || workspace.root.split(/[\\\\/]/u).filter(Boolean).pop() || '';\n const slug = source\n .toLowerCase()\n .replace(/[^a-z0-9]+/gu, '-')\n .replace(/^-+|-+$/gu, '');\n return slug || FALLBACK_SLUG;\n}\n\nexport function createCoordinatorService(options: CoordinatorServiceOptions): CoordinatorService {\n const opening = new Map<string, Promise<CoordinatorResult>>();\n const starts = new Map<string, number[]>();\n const now = (): number => options.now?.() ?? Date.now();\n\n const homeWorkspace = (): CoordinatorWorkspace | undefined =>\n options.workspaces().find((workspace) => workspace.kind === 'session');\n\n /** Live sessions first, so a live coordinator's record is never mistaken for a dormant one. Oldest wins. */\n const coordinatorsIn = (workspaceId: string): { sessionId: string; createdAt: string; live: boolean }[] => {\n const liveSessions = options.liveSessions();\n const live = liveSessions\n .filter(\n (session) =>\n session.sessionProvenance === COORDINATOR_SESSION_PROVENANCE && session.workspaceId === workspaceId,\n )\n .map((session) => ({ sessionId: session.id, createdAt: session.createdAt, live: true }));\n const dormant = options\n .records()\n .filter(\n (record) =>\n record.sessionProvenance === COORDINATOR_SESSION_PROVENANCE &&\n record.workspaceId === workspaceId &&\n !liveSessions.some((session) => session.id === record.sessionId),\n )\n .map((record) => ({ sessionId: record.sessionId, createdAt: record.createdAt, live: false }));\n return [...live, ...dormant].sort((a, b) => a.createdAt.localeCompare(b.createdAt));\n };\n\n const oldestCoordinator = (workspaceId: string) => {\n const found = coordinatorsIn(workspaceId);\n if (found.length > 1)\n options.notice(\n `Workspace '${workspaceId}' has ${found.length} coordinators; using the oldest, '${found[0]?.sessionId}'.`,\n );\n return found[0];\n };\n\n const open = async (target: string, settings: CoordinatorSettings): Promise<CoordinatorResult> => {\n const workspace = target === 'home' ? homeWorkspace() : options.workspaces().find((entry) => entry.id === target);\n if (target !== 'home') {\n if (workspace === undefined) throw new Error(`Workspace '${target}' not found.`);\n if (workspace.kind === 'session') throw new Error('The home workspace takes the home coordinator.');\n if (!coordinated(workspace)) throw new Error('This workspace cannot have a coordinator.');\n }\n if (workspace?.sandbox !== undefined) throw new Error('This workspace cannot have a coordinator.');\n const existing = workspace === undefined ? undefined : oldestCoordinator(workspace.id);\n if (existing !== undefined) {\n if (!existing.live) {\n const record = options.records().find((entry) => entry.sessionId === existing.sessionId);\n if (record === undefined) throw new Error('The coordinator record disappeared while reviving it.');\n await options.revive(record);\n }\n return { sessionId: existing.sessionId, created: false };\n }\n const request: CoordinatorCreateRequest = {\n name: settings.name,\n sessionProvenance: COORDINATOR_SESSION_PROVENANCE,\n selection: { profile: settings.profile },\n ...(settings.model === undefined ? {} : { model: settings.model }),\n };\n const { sessionId } =\n workspace === undefined || target === 'home'\n ? await options.createGeneral(request)\n : await options.createInWorkspace(workspace, request);\n // The persona rides on the record, so the admit path still knows it after a restart.\n const record = options.records().find((entry) => entry.sessionId === sessionId);\n const coordinator = {\n profile: settings.profile,\n name: settings.name,\n ...(settings.model === undefined ? {} : { model: settings.model }),\n };\n if (record === undefined || !options.saveRecord({ ...record, coordinator }))\n options.notice(`Coordinator '${sessionId}' persona could not be recorded.`);\n return { sessionId, created: true };\n };\n\n const ensureCoordinator = (target: string, settings: CoordinatorSettings): Promise<CoordinatorResult> => {\n const pending = opening.get(target);\n if (pending !== undefined) return pending;\n const run = open(target, settings).finally(() => opening.delete(target));\n opening.set(target, run);\n return run;\n };\n\n const workspaceSettings = (workspace: CoordinatorWorkspace, home: CoordinatorSettings): CoordinatorSettings => ({\n profile: home.profile,\n name: `${home.name}-${workspaceSlug(workspace)}`,\n ...(home.model === undefined ? {} : { model: home.model }),\n });\n\n // Sandboxed workspaces get no coordinator; their sessions live in the sandbox's own records.\n const coordinated = (workspace: CoordinatorWorkspace): boolean =>\n workspace.kind !== 'session' && workspace.available !== false && workspace.sandbox === undefined;\n\n const homePersona = (): CoordinatorSettings | undefined => {\n const general = homeWorkspace();\n const home = general === undefined ? undefined : oldestCoordinator(general.id);\n return home === undefined\n ? undefined\n : options.records().find((record) => record.sessionId === home.sessionId)?.coordinator;\n };\n\n const recordPersona = (sessionId: string, coordinator: CoordinatorSettings | undefined): void => {\n const record = options.records().find((entry) => entry.sessionId === sessionId);\n if (record === undefined) return;\n const { coordinator: _dropped, ...rest } = record;\n if (!options.saveRecord(coordinator === undefined ? rest : { ...rest, coordinator }))\n options.notice(`Coordinator '${sessionId}' persona could not be recorded.`);\n };\n\n const demote = async (sessionId: string): Promise<void> => {\n if (options.liveSessions().some((session) => session.id === sessionId)) await options.reopen(sessionId, {});\n else {\n const record = options.records().find((entry) => entry.sessionId === sessionId);\n if (record === undefined) return;\n const { sessionProvenance: _dropped, ...rest } = record;\n if (!options.saveRecord(rest)) throw new Error(`Session '${sessionId}' could not be made regular.`);\n }\n recordPersona(sessionId, undefined);\n };\n\n const ensureHome = async (settings: CoordinatorSettings): Promise<CoordinatorResult> => {\n const home = await ensureCoordinator('home', settings);\n const outcomes = await Promise.allSettled(\n options\n .workspaces()\n .filter(coordinated)\n .map((workspace) => ensureCoordinator(workspace.id, workspaceSettings(workspace, settings))),\n );\n for (const outcome of outcomes)\n if (outcome.status === 'rejected')\n options.notice(`A workspace coordinator could not be opened: ${String(outcome.reason)}`);\n return home;\n };\n\n return {\n ensureCoordinator,\n ensureHome,\n async workspaceAdmitted(workspaceId) {\n const workspace = options.workspaces().find((entry) => entry.id === workspaceId);\n const general = homeWorkspace();\n if (workspace === undefined || general === undefined || !coordinated(workspace)) return;\n const home = oldestCoordinator(general.id);\n if (home === undefined) return;\n const persona = options.records().find((record) => record.sessionId === home.sessionId)?.coordinator;\n if (persona === undefined) {\n options.notice(\n `Home coordinator '${home.sessionId}' has no recorded persona; workspace '${workspaceId}' gets none.`,\n );\n return;\n }\n await ensureCoordinator(workspaceId, workspaceSettings(workspace, persona));\n },\n async startSession(coordinatorSessionId, request) {\n const caller = options.liveSessions().find((session) => session.id === coordinatorSessionId);\n if (caller?.sessionProvenance !== COORDINATOR_SESSION_PROVENANCE)\n throw new Error('Only a coordinator can start sessions.');\n const name = request.name.trim();\n const brief = request.brief.trim();\n if (name === '' || brief === '') throw new Error('A started session needs a name and a brief.');\n if (\n request.workspaceId !== undefined &&\n (typeof request.workspaceId !== 'string' || request.workspaceId.trim() === '')\n )\n throw new Error('A target workspace ID must be non-empty text.');\n const workspace = options.workspaces().find((entry) => entry.id === (request.workspaceId ?? caller.workspaceId));\n assertCoordinatorStartScope(\n caller.workspaceId,\n homeWorkspace()?.id,\n workspace,\n workspace !== undefined && oldestCoordinator(workspace.id) !== undefined,\n );\n const at = now();\n const recent = (starts.get(coordinatorSessionId) ?? []).filter((time) => at - time < COORDINATOR_START_WINDOW_MS);\n assertCoordinatorStartBudget(recent.length);\n starts.set(coordinatorSessionId, [...recent, at]);\n // No parent link: a parent may close its children, and a coordinator never stops sessions.\n const { sessionId } =\n workspace!.kind === 'session'\n ? await options.createGeneral({ name })\n : await options.createInWorkspace(workspace!, { name });\n try {\n await options.prompt(sessionId, brief);\n } catch (error) {\n // Creation committed and spent its quota. Report the id so callers do not blindly retry.\n return { sessionId, promptError: error instanceof Error ? error.message : String(error) };\n }\n return { sessionId };\n },\n async add(workspaceId, profile) {\n if (profile !== undefined && (typeof profile !== 'string' || profile.trim() === ''))\n throw new Error('A coordinator profile must be non-empty text.');\n const workspace =\n workspaceId === undefined ? homeWorkspace() : options.workspaces().find((entry) => entry.id === workspaceId);\n if (workspaceId !== undefined) {\n if (workspace === undefined) throw new Error(`Workspace '${workspaceId}' not found.`);\n if (!coordinated(workspace)) throw new Error('This workspace cannot have a coordinator.');\n }\n // Reuse does not need a new persona, even when the default has since disappeared.\n const existing = workspace === undefined ? undefined : oldestCoordinator(workspace.id);\n const inherited = homePersona();\n const selected =\n profile?.trim() ??\n inherited?.profile ??\n options.defaultProfile(workspaceId === undefined ? undefined : workspace?.root);\n if (selected === undefined && existing === undefined)\n return { profileRequired: true, error: 'Choose a profile before adding a coordinator.' };\n if (selected === undefined && existing !== undefined) {\n if (!existing.live) {\n const record = options.records().find((entry) => entry.sessionId === existing.sessionId);\n if (record === undefined) throw new Error('The coordinator record disappeared while reviving it.');\n await options.revive(record);\n }\n return { sessionId: existing.sessionId, created: false };\n }\n const settings =\n profile !== undefined\n ? { profile: selected!, name: selected! }\n : (inherited ?? { profile: selected ?? '', name: selected ?? '' });\n if (profile !== undefined && existing === undefined)\n await options.validateProfile?.(selected!, workspaceId === undefined ? undefined : workspace);\n return workspaceId === undefined\n ? ensureHome(settings)\n : ensureCoordinator(workspaceId, workspaceSettings(workspace!, settings));\n },\n async setRole(sessionId, coordinator) {\n let live = options.liveSessions().find((session) => session.id === sessionId);\n const record = options.records().find((entry) => entry.sessionId === sessionId);\n const current = live ?? (record === undefined ? undefined : { ...record, id: record.sessionId });\n if (current?.workspaceId === undefined) throw new Error('Session not found.');\n if ((current.sessionProvenance === COORDINATOR_SESSION_PROVENANCE) === coordinator) return;\n if (!coordinator) return demote(sessionId);\n if (current.parentSessionId !== undefined) throw new Error('A nested session cannot become a coordinator.');\n // A worktree, workflow or voice session keeps the role its provenance gives it.\n if (current.sessionProvenance !== undefined)\n throw new Error(`A ${current.sessionProvenance} session cannot become a coordinator.`);\n const workspace = options.workspaces().find((entry) => entry.id === current.workspaceId);\n if (\n workspace === undefined ||\n workspace.sandbox !== undefined ||\n (workspace.kind !== 'session' && !coordinated(workspace))\n )\n throw new Error('This workspace cannot have a coordinator.');\n for (const other of coordinatorsIn(workspace.id)) await demote(other.sessionId);\n if (live === undefined) {\n await options.revive(record!);\n live = options.liveSessions().find((session) => session.id === sessionId);\n }\n // The session keeps its own persona; one without gets the default.\n const profile = live?.profile?.name ?? options.defaultProfile(workspace.root);\n await options.reopen(sessionId, {\n sessionProvenance: COORDINATOR_SESSION_PROVENANCE,\n ...(live?.profile === undefined && profile !== undefined ? { profile } : {}),\n });\n if (profile !== undefined) recordPersona(sessionId, { profile, name: current.name ?? profile });\n else options.notice(`Coordinator '${sessionId}' has no profile; new workspaces will not copy its persona.`);\n },\n };\n}\n","import { verifyEnvelope } from '@agimon-ai/po-web-security/deviceProof';\nimport {\n createClientHandshake,\n createHostHandshake,\n type SealedChannel,\n} from '@agimon-ai/po-web-security/nodeSealedChannel';\n\nimport type {\n RosterLinkProof,\n RosterPeerChannel,\n RosterPeerLinkPorts,\n RosterPeerLinks,\n SignedRosterLinkProof,\n} from './type';\n\nconst LINK_TTL = 60_000;\n\n/** Account links are separate from legacy session-peer secrets and permissions.\n * A fresh signed ephemeral exchange uses the host key in the verified C6 roster.\n * Coordinator availability is irrelevant. Roster removal or rotation fences all\n * existing channel uses; applications must sync and persist C6 before exposing it.\n */\nexport function createRosterPeerLink(ports: RosterPeerLinkPorts): RosterPeerLinks {\n const consumed = new Map<string, number>();\n function check(proof: SignedRosterLinkProof): RosterLinkProof {\n const snapshot = ports.roster();\n const payload = proof.payload;\n const host = snapshot.hosts.find((h) => h.hostId === payload.hostId);\n if (\n !host ||\n payload.hostId === ports.hostId ||\n payload.destinationHostId !== ports.hostId ||\n payload.networkId !== snapshot.networkId ||\n payload.epoch !== snapshot.epoch ||\n !payload.publicKey ||\n !payload.challenge ||\n typeof payload.echo !== 'string' ||\n payload.expiresAt - payload.issuedAt > LINK_TTL ||\n !verifyEnvelope(host.publicKey, 'po/host-request/v1', proof, ports.now())\n )\n throw new Error('Roster link refused');\n return payload;\n }\n function wrap(channel: SealedChannel, hostId: string, epoch: number): RosterPeerChannel {\n const snapshot = ports.roster();\n const remote = snapshot.hosts.find((h) => h.hostId === hostId)?.publicKey;\n const local = snapshot.hosts.find((h) => h.hostId === ports.hostId)?.publicKey;\n const valid = () => {\n const current = ports.roster();\n return (\n !!remote &&\n !!local &&\n current.networkId === snapshot.networkId &&\n current.epoch === epoch &&\n current.hosts.some((h) => h.hostId === hostId && h.publicKey === remote) &&\n current.hosts.some((h) => h.hostId === ports.hostId && h.publicKey === local)\n );\n };\n return {\n seal(plaintext) {\n if (!valid()) return { ok: false, failure: 'auth' };\n return channel.seal(plaintext);\n },\n async open(envelope) {\n if (!valid()) return undefined;\n const opened = channel.open(envelope);\n if (!opened.ok || !(await ports.verifyRequest(opened.plaintext, hostId)) || !valid()) return undefined;\n return opened.plaintext;\n },\n };\n }\n return {\n async connect(hostId, token, exchange) {\n const snapshot = ports.roster();\n if (!snapshot.hosts.some((h) => h.hostId === ports.hostId) || !snapshot.hosts.some((h) => h.hostId === hostId))\n throw new Error('Host is not in roster');\n const handshake = createClientHandshake();\n const payload: RosterLinkProof = {\n networkId: snapshot.networkId,\n epoch: snapshot.epoch,\n hostId: ports.hostId,\n destinationHostId: hostId,\n publicKey: handshake.publicKey,\n challenge: crypto.randomUUID(),\n echo: '',\n issuedAt: ports.now(),\n expiresAt: ports.now() + LINK_TTL,\n };\n const reply = check(await exchange(ports.sign(payload), token));\n if (\n reply.hostId !== hostId ||\n reply.challenge !== payload.challenge ||\n reply.echo !== payload.publicKey ||\n reply.epoch !== payload.epoch\n )\n throw new Error('Roster link response mismatch');\n const channel = handshake.accept(reply.publicKey);\n if (!channel) throw new Error('Invalid roster channel');\n return wrap(channel, hostId, payload.epoch);\n },\n async accept(proof, token) {\n const payload = check(proof);\n if (payload.echo !== '' || !(await ports.authorize(token, payload.hostId, payload.networkId)))\n throw new Error('Roster link denied');\n // Authorization may await a roster sync. Recheck before committing the link.\n check(proof);\n for (const [id, expiry] of consumed) if (expiry <= ports.now()) consumed.delete(id);\n const id = JSON.stringify([payload.hostId, payload.challenge]);\n if (consumed.has(id) || consumed.size >= 1024) throw new Error('Roster link replayed');\n consumed.set(id, payload.expiresAt);\n const handshake = createHostHandshake();\n const channel = handshake.accept(payload.publicKey);\n if (!channel) throw new Error('Invalid roster channel');\n return {\n proof: ports.sign({\n ...payload,\n hostId: ports.hostId,\n destinationHostId: payload.hostId,\n publicKey: handshake.publicKey,\n echo: payload.publicKey,\n issuedAt: ports.now(),\n expiresAt: ports.now() + LINK_TTL,\n }),\n channel: wrap(channel, payload.hostId, payload.epoch),\n };\n },\n };\n}\n"],"mappings":";;;;;;;AAQA,MAAa,8BAA8B;AAC3C,MAAa,8BAA8B;AAE3C,SAAgB,6BAA6B,OAAqB;CAChE,IAAI,SAAA,GACF,MAAM,IAAI,MAAM,qDAAkF;AACtG;AAEA,SAAgB,4BACd,mBACA,iBACA,WACA,gBACM;CACN,IAAI,cAAc,KAAA,KAAa,UAAU,cAAc,SAAS,UAAU,YAAY,KAAA,GACpF,MAAM,IAAI,MAAM,sCAAsC;CACxD,IAAI,UAAU,OAAO,mBAAmB;CACxC,IAAI,sBAAsB,KAAA,KAAa,sBAAsB,mBAAmB,UAAU,SAAS,WACjG,MAAM,IAAI,MAAM,yDAAyD;CAC3E,IAAI,gBAAgB,MAAM,IAAI,MAAM,gEAAgE;AACtG;;AAGA,MAAa,0BAAwD,UAAU;CAC7E,MAAM,EAAE,QAAQ,WAAW;CAC3B,IAAI,OAAO,OAAO,OAAO,IAAI,OAAO;CACpC,IAAI,OAAO,oBAAoB,OAAO,MAAM,OAAO,oBAAoB,OAAO,IAAI,OAAO;CACzF,IACE,OAAO,sBAAsBA,8BAAAA,0CAC7B,OAAO,sBAAsBA,8BAAAA,wCAE7B,OAAO;CACT,MAAM,eAAe,YACnB,QAAQ,sBAAsBC,8BAAAA;CAChC,MAAM,QAAQ,YACZ,YAAY,OAAO,KACnB,QAAQ,gBAAgB,KAAA,KACxB,MAAM,WAAW,MAAM,cAAc,UAAU,OAAO,QAAQ,eAAe,UAAU,SAAS,SAAS;CAC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AAM,UAAU,OAAO,QAAQ,QAAQ,QAAQ,SAAS,GACzF,MAAM,IAAI,MAAM,oBAAoB;GAEtC,MAAM,KAAK;GACX,KAAK,MAAM,CAAC,IAAI,WAAW,UAAU,IAAI,UAAU,MAAM,IAAI,GAAG,SAAS,OAAO,EAAE;GAClF,MAAM,KAAK,KAAK,UAAU,CAAC,QAAQ,QAAQ,QAAQ,SAAS,CAAC;GAC7D,IAAI,SAAS,IAAI,EAAE,KAAK,SAAS,QAAQ,MAAM,MAAM,IAAI,MAAM,sBAAsB;GACrF,SAAS,IAAI,IAAI,QAAQ,SAAS;GAClC,MAAM,aAAA,GAAYC,6CAAAA,oBAAAA,CAAoB;GACtC,MAAM,UAAU,UAAU,OAAO,QAAQ,SAAS;GAClD,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,wBAAwB;GACtD,OAAO;IACL,OAAO,MAAM,KAAK;KAChB,GAAG;KACH,QAAQ,MAAM;KACd,mBAAmB,QAAQ;KAC3B,WAAW,UAAU;KACrB,MAAM,QAAQ;KACd,UAAU,MAAM,IAAI;KACpB,WAAW,MAAM,IAAI,IAAI;IAC3B,CAAC;IACD,SAAS,KAAK,SAAS,QAAQ,QAAQ,QAAQ,KAAK;GACtD;EACF;CACF;AACF"}
|
package/dist/index.d.mts
CHANGED
|
@@ -84,6 +84,10 @@ interface CoordinatorResult {
|
|
|
84
84
|
readonly sessionId: string;
|
|
85
85
|
readonly created: boolean;
|
|
86
86
|
}
|
|
87
|
+
type CoordinatorAddResult = CoordinatorResult | {
|
|
88
|
+
readonly profileRequired: true;
|
|
89
|
+
readonly error: string;
|
|
90
|
+
};
|
|
87
91
|
interface CoordinatorWorkspace {
|
|
88
92
|
readonly id: string;
|
|
89
93
|
readonly kind?: 'session';
|
|
@@ -126,6 +130,8 @@ interface CoordinatorServiceOptions {
|
|
|
126
130
|
prompt(sessionId: string, text: string): Promise<unknown>;
|
|
127
131
|
/** The profile catalog's default under this root, or the personal one when no root is given. */
|
|
128
132
|
defaultProfile(root?: string): string | undefined;
|
|
133
|
+
/** Validates a request-local choice through the host profile resolver before creation. */
|
|
134
|
+
validateProfile?(profile: string, workspace?: CoordinatorWorkspace): Promise<void>;
|
|
129
135
|
/** Closes a live session and reopens it under the same id with this provenance, and this profile when given. */
|
|
130
136
|
reopen(sessionId: string, role: {
|
|
131
137
|
sessionProvenance?: string;
|
|
@@ -155,9 +161,9 @@ interface CoordinatorService {
|
|
|
155
161
|
}>;
|
|
156
162
|
/**
|
|
157
163
|
* The person's explicit add: the home coordinator when no workspace is named, else that workspace's. The persona
|
|
158
|
-
* is the home coordinator's when
|
|
164
|
+
* is the explicit profile when supplied, else the home coordinator's when recorded, else the default profile.
|
|
159
165
|
*/
|
|
160
|
-
add(workspaceId?: string): Promise<
|
|
166
|
+
add(workspaceId?: string, profile?: string): Promise<CoordinatorAddResult>;
|
|
161
167
|
/**
|
|
162
168
|
* Promotes a session to its workspace's coordinator, demoting any other one, or demotes it. A live session
|
|
163
169
|
* restarts to take on its role; a dormant one being demoted only has its record rewritten.
|
|
@@ -690,5 +696,5 @@ export declare function createPeerLink(options: {
|
|
|
690
696
|
*/
|
|
691
697
|
export declare function createRosterPeerLink(ports: RosterPeerLinkPorts): RosterPeerLinks;
|
|
692
698
|
//#endregion
|
|
693
|
-
export type { CoordinatorCreateRequest, CoordinatorResult, CoordinatorService, CoordinatorServiceOptions, CoordinatorSessionsOptions, CoordinatorSettings, DiscoveredSession, PeerLinkControl, PeerLinkInvite, PoSessionDeliveryInboxState, PoSessionDeliveryMetadata, PoSessionDeliveryMode, PoSessionDeliveryRequest, PoSessionDeliveryService, PoSessionInboxEntry, PoSessionInboxQuery, PoSessionOutboxEntry, RemoteSessionReference, RosterLinkHost, RosterLinkProof, RosterLinkSnapshot, RosterPeerChannel, RosterPeerLinkPorts, RosterPeerLinks, SessionActivityState, SessionCommunicationGroup, SessionDeliveryServiceOptions, SessionDirectory, SessionDirectoryOptions, SessionDiscoveryGrant, SessionGroupBridge, SessionGroupDeliveryAuthorizationOptions, SessionGroupMutation, SessionGroupStore, SessionGroupStoreOptions, SessionHostReachability, SessionIntercom, SessionIntercomMessage, SessionIntercomOptions, SessionIntercomSendRequest, SessionOperations, SessionPeer, SessionPeerConfig, SessionPeerEnvelope, SessionPeerReplayGuard, SessionPeerReplayGuardAsync, SessionPeers, SessionPresenceFacts, SessionPresenceObservation, SessionReportStatus, SessionRuntimeState, SessionVoiceReadiness, SessionsNamespaceOptions, SignedRosterLinkProof, StartSessionInput, StartSessionResult };
|
|
699
|
+
export type { CoordinatorAddResult, CoordinatorCreateRequest, CoordinatorResult, CoordinatorService, CoordinatorServiceOptions, CoordinatorSessionsOptions, CoordinatorSettings, DiscoveredSession, PeerLinkControl, PeerLinkInvite, PoSessionDeliveryInboxState, PoSessionDeliveryMetadata, PoSessionDeliveryMode, PoSessionDeliveryRequest, PoSessionDeliveryService, PoSessionInboxEntry, PoSessionInboxQuery, PoSessionOutboxEntry, RemoteSessionReference, RosterLinkHost, RosterLinkProof, RosterLinkSnapshot, RosterPeerChannel, RosterPeerLinkPorts, RosterPeerLinks, SessionActivityState, SessionCommunicationGroup, SessionDeliveryServiceOptions, SessionDirectory, SessionDirectoryOptions, SessionDiscoveryGrant, SessionGroupBridge, SessionGroupDeliveryAuthorizationOptions, SessionGroupMutation, SessionGroupStore, SessionGroupStoreOptions, SessionHostReachability, SessionIntercom, SessionIntercomMessage, SessionIntercomOptions, SessionIntercomSendRequest, SessionOperations, SessionPeer, SessionPeerConfig, SessionPeerEnvelope, SessionPeerReplayGuard, SessionPeerReplayGuardAsync, SessionPeers, SessionPresenceFacts, SessionPresenceObservation, SessionReportStatus, SessionRuntimeState, SessionVoiceReadiness, SessionsNamespaceOptions, SignedRosterLinkProof, StartSessionInput, StartSessionResult };
|
|
694
700
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":["_0","_0","_0","_0","_0"],"sources":["../src/services/backgroundWorkService/index.ts","../src/schemas/startSession.ts","../src/services/coordinatorSessions/type.ts","../src/services/coordinatorSessions/index.ts","../src/services/sessionsNamespace/type.ts","../src/services/sessionsNamespace/index.ts","../src/services/sessionCoordination/type.ts","../src/services/sessionCoordination/policy.ts","../src/services/sessionCoordination/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","../src/services/sessionPeers/type.ts","../src/services/sessionPeers/index.ts","../src/services/sealedPeerChannel/index.ts","../src/services/sessionGroupBridge/type.ts","../src/services/sessionGroupBridge/index.ts","../src/services/peerLink/type.ts","../src/services/peerLink/index.ts","../src/services/peerLink/roster.ts"],"mappings":";;;;;;;;;;;;;wBAmBgB,4BAA4B,KAAK,UAAU;;wBAoE3C,6BAA6B,SAAS;;;;qBCpFzC,0BAAwB,KAAA;;;;;;;UCDpB;;EAEf;;EAEA,gBAAgB;;UAGD;EACf;EACA;EACA;;UAGe;EACf;;EAEA;;;;qBCVW;;wBASG,uBAAuB,eAAe;wBAYhC,wBACpB,SAAS,4BACT,cACA,SAAS,cACR,QAAQ;wBAeK,uBACd,SAAS,6BACR,sBAAsB;;;qBC9CZ;;UAGI;EACf,KAAK,QAAQ,cAAc;EAC3B,KAAK,YAAY,cAAc,QAAQ,cAAc;EACrD,MAAM,mBAAmB,QAAQ,cAAc;;EAE/C;;UAGe,iCAAiC;EAChD;EACA,YAAY;EACZ;;wBAGc,sBAAsB,SAAS,UAAU;;YAK7C;IACR,yBAAyB;;;;;wBCJb,wBAAwB,SAAS,2BAA2B;;;;UCnB3D;WACN;WACA;WACA;;UAGM;WACN;WACA;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["_0","_0","_0","_0","_0"],"sources":["../src/services/backgroundWorkService/index.ts","../src/schemas/startSession.ts","../src/services/coordinatorSessions/type.ts","../src/services/coordinatorSessions/index.ts","../src/services/sessionsNamespace/type.ts","../src/services/sessionsNamespace/index.ts","../src/services/sessionCoordination/type.ts","../src/services/sessionCoordination/policy.ts","../src/services/sessionCoordination/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","../src/services/sessionPeers/type.ts","../src/services/sessionPeers/index.ts","../src/services/sealedPeerChannel/index.ts","../src/services/sessionGroupBridge/type.ts","../src/services/sessionGroupBridge/index.ts","../src/services/peerLink/type.ts","../src/services/peerLink/index.ts","../src/services/peerLink/roster.ts"],"mappings":";;;;;;;;;;;;;wBAmBgB,4BAA4B,KAAK,UAAU;;wBAoE3C,6BAA6B,SAAS;;;;qBCpFzC,0BAAwB,KAAA;;;;;;;UCDpB;;EAEf;;EAEA,gBAAgB;;UAGD;EACf;EACA;EACA;;UAGe;EACf;;EAEA;;;;qBCVW;;wBASG,uBAAuB,eAAe;wBAYhC,wBACpB,SAAS,4BACT,cACA,SAAS,cACR,QAAQ;wBAeK,uBACd,SAAS,6BACR,sBAAsB;;;qBC9CZ;;UAGI;EACf,KAAK,QAAQ,cAAc;EAC3B,KAAK,YAAY,cAAc,QAAQ,cAAc;EACrD,MAAM,mBAAmB,QAAQ,cAAc;;EAE/C;;UAGe,iCAAiC;EAChD;EACA,YAAY;EACZ;;wBAGc,sBAAsB,SAAS,UAAU;;YAK7C;IACR,yBAAyB;;;;;wBCJb,wBAAwB,SAAS,2BAA2B;;;;UCnB3D;WACN;WACA;WACA;;UAGM;WACN;WACA;;KAGC,uBA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EACf;EACA;;UAEe;EACf;EACA;EACA,gBAAgB;;UAED;EACf;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;;KAEU,6DAA6D,yBACvE;UAGe;;EAEf,KAAK,WAAW,oEAAoE;EACpF,KAAK,oBAAoB,QAAQ;;UAElB;EACf;EACA,UAAU;EACV;;EAEA,KAAK,SAAS,kBAAkB;;EAEhC,UAAU,eAAe,gBAAgB,oBAAoB;;EAE7D,cAAc,WAAW,YAAY,iBAAiB;;UAEvC;EACf,QACE,gBACA,eACA,WAAW,OAAO,uBAAuB,kBAAkB,QAAQ,yBAClE,QAAQ;EACX,OACE,OAAO,uBACP,gBACC;IAAU,OAAO;IAAuB,SAAS;;;qBAGzC;qBACA,mEAAuB,kBAAA;;YAIxB;IACR,kBAAkB;;;;;;wBCXN,eAAe;EAC7B,OAAO;EACP,UAAU;EACV,eAAe;EACf;EACA,QAAQ;EACR,UAAU,kBAAkB;EAC5B,eAAe;EACf;IACE;;;;;;;;wBCzDY,qBAAqB,OAAO,sBAAsB"}
|
package/dist/index.mjs
CHANGED
|
@@ -127,14 +127,6 @@ function createCoordinatorService(options) {
|
|
|
127
127
|
const home = general === void 0 ? void 0 : oldestCoordinator(general.id);
|
|
128
128
|
return home === void 0 ? void 0 : options.records().find((record) => record.sessionId === home.sessionId)?.coordinator;
|
|
129
129
|
};
|
|
130
|
-
const defaultPersona = (root) => {
|
|
131
|
-
const profile = options.defaultProfile(root);
|
|
132
|
-
if (profile === void 0) throw new Error("Choose a default profile before adding a coordinator.");
|
|
133
|
-
return {
|
|
134
|
-
profile,
|
|
135
|
-
name: profile
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
130
|
const recordPersona = (sessionId, coordinator) => {
|
|
139
131
|
const record = options.records().find((entry) => entry.sessionId === sessionId);
|
|
140
132
|
if (record === void 0) return;
|
|
@@ -200,12 +192,40 @@ function createCoordinatorService(options) {
|
|
|
200
192
|
}
|
|
201
193
|
return { sessionId };
|
|
202
194
|
},
|
|
203
|
-
async add(workspaceId) {
|
|
204
|
-
if (
|
|
205
|
-
const workspace = options.workspaces().find((entry) => entry.id === workspaceId);
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
|
|
195
|
+
async add(workspaceId, profile) {
|
|
196
|
+
if (profile !== void 0 && (typeof profile !== "string" || profile.trim() === "")) throw new Error("A coordinator profile must be non-empty text.");
|
|
197
|
+
const workspace = workspaceId === void 0 ? homeWorkspace() : options.workspaces().find((entry) => entry.id === workspaceId);
|
|
198
|
+
if (workspaceId !== void 0) {
|
|
199
|
+
if (workspace === void 0) throw new Error(`Workspace '${workspaceId}' not found.`);
|
|
200
|
+
if (!coordinated(workspace)) throw new Error("This workspace cannot have a coordinator.");
|
|
201
|
+
}
|
|
202
|
+
const existing = workspace === void 0 ? void 0 : oldestCoordinator(workspace.id);
|
|
203
|
+
const inherited = homePersona();
|
|
204
|
+
const selected = profile?.trim() ?? inherited?.profile ?? options.defaultProfile(workspaceId === void 0 ? void 0 : workspace?.root);
|
|
205
|
+
if (selected === void 0 && existing === void 0) return {
|
|
206
|
+
profileRequired: true,
|
|
207
|
+
error: "Choose a profile before adding a coordinator."
|
|
208
|
+
};
|
|
209
|
+
if (selected === void 0 && existing !== void 0) {
|
|
210
|
+
if (!existing.live) {
|
|
211
|
+
const record = options.records().find((entry) => entry.sessionId === existing.sessionId);
|
|
212
|
+
if (record === void 0) throw new Error("The coordinator record disappeared while reviving it.");
|
|
213
|
+
await options.revive(record);
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
sessionId: existing.sessionId,
|
|
217
|
+
created: false
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
const settings = profile !== void 0 ? {
|
|
221
|
+
profile: selected,
|
|
222
|
+
name: selected
|
|
223
|
+
} : inherited ?? {
|
|
224
|
+
profile: selected ?? "",
|
|
225
|
+
name: selected ?? ""
|
|
226
|
+
};
|
|
227
|
+
if (profile !== void 0 && existing === void 0) await options.validateProfile?.(selected, workspaceId === void 0 ? void 0 : workspace);
|
|
228
|
+
return workspaceId === void 0 ? ensureHome(settings) : ensureCoordinator(workspaceId, workspaceSettings(workspace, settings));
|
|
209
229
|
},
|
|
210
230
|
async setRole(sessionId, coordinator) {
|
|
211
231
|
let live = options.liveSessions().find((session) => session.id === sessionId);
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/services/sessionCoordination/policy.ts","../src/services/sessionCoordination/index.ts","../src/services/peerLink/roster.ts"],"sourcesContent":["import {\n COORDINATOR_SESSION_PROVENANCE,\n REMOTE_CONVERSATION_SESSION_PROVENANCE,\n type PoSessionCommunicationPolicy,\n type PoSessionCommunicationSubject,\n} from '@agimon-ai/po-core/hubChannel';\n\n/** ponytail: a fixed per-coordinator budget; add configuration only when another number is needed. */\nexport const COORDINATOR_STARTS_PER_HOUR = 5;\nexport const COORDINATOR_START_WINDOW_MS = 60 * 60 * 1000;\n\nexport function assertCoordinatorStartBudget(count: number): void {\n if (count >= COORDINATOR_STARTS_PER_HOUR)\n throw new Error(`A coordinator can start at most ${COORDINATOR_STARTS_PER_HOUR} sessions an hour.`);\n}\n\nexport function assertCoordinatorStartScope(\n callerWorkspaceId: string | undefined,\n homeWorkspaceId: string | undefined,\n workspace: { id: string; kind?: 'session'; available?: boolean; sandbox?: string } | undefined,\n hasCoordinator: boolean,\n): void {\n if (workspace === undefined || workspace.available === false || workspace.sandbox !== undefined)\n throw new Error('The target workspace is unavailable.');\n if (workspace.id === callerWorkspaceId) return;\n if (callerWorkspaceId === undefined || callerWorkspaceId !== homeWorkspaceId || workspace.kind === 'session')\n throw new Error('Only the home coordinator can target another workspace.');\n if (hasCoordinator) throw new Error('This workspace has a coordinator. Ask it to start the session.');\n}\n\n/** Communication is symmetric. A message grant never grants lifecycle authority. */\nexport const canSessionsCommunicate: PoSessionCommunicationPolicy = (input) => {\n const { source, target } = input;\n if (source.id === target.id) return false;\n if (source.parentSessionId === target.id || target.parentSessionId === source.id) return true;\n if (\n source.sessionProvenance === REMOTE_CONVERSATION_SESSION_PROVENANCE ||\n target.sessionProvenance === REMOTE_CONVERSATION_SESSION_PROVENANCE\n )\n return false;\n const coordinates = (session: PoSessionCommunicationSubject): boolean =>\n session.sessionProvenance === COORDINATOR_SESSION_PROVENANCE;\n const home = (session: PoSessionCommunicationSubject): boolean =>\n coordinates(session) &&\n session.workspaceId !== undefined &&\n input.workspaces.some((workspace) => workspace.id === session.workspaceId && workspace.kind === 'session');\n const homeFallback = (coordinator: PoSessionCommunicationSubject, peer: PoSessionCommunicationSubject): boolean => {\n if (!home(coordinator) || peer.workspaceId === undefined) return false;\n const workspace = input.workspaces.find((entry) => entry.id === peer.workspaceId);\n if (!workspace || workspace.kind === 'session' || workspace.sandbox !== undefined || workspace.available === false)\n return false;\n return (\n !input.sessions.some((session) => session.workspaceId === workspace.id && coordinates(session)) &&\n !input.dormantSessions.some(\n (record) =>\n record.workspaceId === workspace.id &&\n record.sessionProvenance === COORDINATOR_SESSION_PROVENANCE &&\n !input.sessions.some((session) => session.id === record.sessionId),\n )\n );\n };\n if (\n (coordinates(source) || coordinates(target)) &&\n source.workspaceId !== undefined &&\n source.workspaceId === target.workspaceId\n )\n return true;\n if (coordinates(source) && coordinates(target) && (home(source) || home(target))) return true;\n if (homeFallback(source, target) || homeFallback(target, source)) return true;\n if (source.workspaceId !== undefined && source.workspaceId === target.workspaceId && input.filesOverlap) return true;\n return (source.groups ?? []).some((group) => target.groups?.includes(group) === true);\n};\n","import { COORDINATOR_SESSION_PROVENANCE } from '@agimon-ai/po-core/hubChannel';\n\nimport { assertCoordinatorStartBudget, assertCoordinatorStartScope, COORDINATOR_START_WINDOW_MS } from './policy';\nimport type {\n CoordinatorSettings,\n CoordinatorResult,\n CoordinatorWorkspace,\n CoordinatorCreateRequest,\n CoordinatorServiceOptions,\n CoordinatorService,\n} from './type';\n\nexport { COORDINATOR_STARTS_PER_HOUR } from './policy';\nconst FALLBACK_SLUG = 'workspace';\n\nexport type {\n CoordinatorSettings,\n CoordinatorResult,\n CoordinatorCreateRequest,\n CoordinatorServiceOptions,\n CoordinatorService,\n} from './type';\n\n/** Kebab-case from the workspace name, else its folder name. */\nexport function workspaceSlug(workspace: { readonly name?: string; readonly root: string }): string {\n const source = workspace.name?.trim() || workspace.root.split(/[\\\\/]/u).filter(Boolean).pop() || '';\n const slug = source\n .toLowerCase()\n .replace(/[^a-z0-9]+/gu, '-')\n .replace(/^-+|-+$/gu, '');\n return slug || FALLBACK_SLUG;\n}\n\nexport function createCoordinatorService(options: CoordinatorServiceOptions): CoordinatorService {\n const opening = new Map<string, Promise<CoordinatorResult>>();\n const starts = new Map<string, number[]>();\n const now = (): number => options.now?.() ?? Date.now();\n\n const homeWorkspace = (): CoordinatorWorkspace | undefined =>\n options.workspaces().find((workspace) => workspace.kind === 'session');\n\n /** Live sessions first, so a live coordinator's record is never mistaken for a dormant one. Oldest wins. */\n const coordinatorsIn = (workspaceId: string): { sessionId: string; createdAt: string; live: boolean }[] => {\n const liveSessions = options.liveSessions();\n const live = liveSessions\n .filter(\n (session) =>\n session.sessionProvenance === COORDINATOR_SESSION_PROVENANCE && session.workspaceId === workspaceId,\n )\n .map((session) => ({ sessionId: session.id, createdAt: session.createdAt, live: true }));\n const dormant = options\n .records()\n .filter(\n (record) =>\n record.sessionProvenance === COORDINATOR_SESSION_PROVENANCE &&\n record.workspaceId === workspaceId &&\n !liveSessions.some((session) => session.id === record.sessionId),\n )\n .map((record) => ({ sessionId: record.sessionId, createdAt: record.createdAt, live: false }));\n return [...live, ...dormant].sort((a, b) => a.createdAt.localeCompare(b.createdAt));\n };\n\n const oldestCoordinator = (workspaceId: string) => {\n const found = coordinatorsIn(workspaceId);\n if (found.length > 1)\n options.notice(\n `Workspace '${workspaceId}' has ${found.length} coordinators; using the oldest, '${found[0]?.sessionId}'.`,\n );\n return found[0];\n };\n\n const open = async (target: string, settings: CoordinatorSettings): Promise<CoordinatorResult> => {\n const workspace = target === 'home' ? homeWorkspace() : options.workspaces().find((entry) => entry.id === target);\n if (target !== 'home') {\n if (workspace === undefined) throw new Error(`Workspace '${target}' not found.`);\n if (workspace.kind === 'session') throw new Error('The home workspace takes the home coordinator.');\n if (!coordinated(workspace)) throw new Error('This workspace cannot have a coordinator.');\n }\n if (workspace?.sandbox !== undefined) throw new Error('This workspace cannot have a coordinator.');\n const existing = workspace === undefined ? undefined : oldestCoordinator(workspace.id);\n if (existing !== undefined) {\n if (!existing.live) {\n const record = options.records().find((entry) => entry.sessionId === existing.sessionId);\n if (record === undefined) throw new Error('The coordinator record disappeared while reviving it.');\n await options.revive(record);\n }\n return { sessionId: existing.sessionId, created: false };\n }\n const request: CoordinatorCreateRequest = {\n name: settings.name,\n sessionProvenance: COORDINATOR_SESSION_PROVENANCE,\n selection: { profile: settings.profile },\n ...(settings.model === undefined ? {} : { model: settings.model }),\n };\n const { sessionId } =\n workspace === undefined || target === 'home'\n ? await options.createGeneral(request)\n : await options.createInWorkspace(workspace, request);\n // The persona rides on the record, so the admit path still knows it after a restart.\n const record = options.records().find((entry) => entry.sessionId === sessionId);\n const coordinator = {\n profile: settings.profile,\n name: settings.name,\n ...(settings.model === undefined ? {} : { model: settings.model }),\n };\n if (record === undefined || !options.saveRecord({ ...record, coordinator }))\n options.notice(`Coordinator '${sessionId}' persona could not be recorded.`);\n return { sessionId, created: true };\n };\n\n const ensureCoordinator = (target: string, settings: CoordinatorSettings): Promise<CoordinatorResult> => {\n const pending = opening.get(target);\n if (pending !== undefined) return pending;\n const run = open(target, settings).finally(() => opening.delete(target));\n opening.set(target, run);\n return run;\n };\n\n const workspaceSettings = (workspace: CoordinatorWorkspace, home: CoordinatorSettings): CoordinatorSettings => ({\n profile: home.profile,\n name: `${home.name}-${workspaceSlug(workspace)}`,\n ...(home.model === undefined ? {} : { model: home.model }),\n });\n\n // Sandboxed workspaces get no coordinator; their sessions live in the sandbox's own records.\n const coordinated = (workspace: CoordinatorWorkspace): boolean =>\n workspace.kind !== 'session' && workspace.available !== false && workspace.sandbox === undefined;\n\n const homePersona = (): CoordinatorSettings | undefined => {\n const general = homeWorkspace();\n const home = general === undefined ? undefined : oldestCoordinator(general.id);\n return home === undefined\n ? undefined\n : options.records().find((record) => record.sessionId === home.sessionId)?.coordinator;\n };\n\n const defaultPersona = (root?: string): CoordinatorSettings => {\n const profile = options.defaultProfile(root);\n if (profile === undefined) throw new Error('Choose a default profile before adding a coordinator.');\n return { profile, name: profile };\n };\n\n const recordPersona = (sessionId: string, coordinator: CoordinatorSettings | undefined): void => {\n const record = options.records().find((entry) => entry.sessionId === sessionId);\n if (record === undefined) return;\n const { coordinator: _dropped, ...rest } = record;\n if (!options.saveRecord(coordinator === undefined ? rest : { ...rest, coordinator }))\n options.notice(`Coordinator '${sessionId}' persona could not be recorded.`);\n };\n\n const demote = async (sessionId: string): Promise<void> => {\n if (options.liveSessions().some((session) => session.id === sessionId)) await options.reopen(sessionId, {});\n else {\n const record = options.records().find((entry) => entry.sessionId === sessionId);\n if (record === undefined) return;\n const { sessionProvenance: _dropped, ...rest } = record;\n if (!options.saveRecord(rest)) throw new Error(`Session '${sessionId}' could not be made regular.`);\n }\n recordPersona(sessionId, undefined);\n };\n\n const ensureHome = async (settings: CoordinatorSettings): Promise<CoordinatorResult> => {\n const home = await ensureCoordinator('home', settings);\n const outcomes = await Promise.allSettled(\n options\n .workspaces()\n .filter(coordinated)\n .map((workspace) => ensureCoordinator(workspace.id, workspaceSettings(workspace, settings))),\n );\n for (const outcome of outcomes)\n if (outcome.status === 'rejected')\n options.notice(`A workspace coordinator could not be opened: ${String(outcome.reason)}`);\n return home;\n };\n\n return {\n ensureCoordinator,\n ensureHome,\n async workspaceAdmitted(workspaceId) {\n const workspace = options.workspaces().find((entry) => entry.id === workspaceId);\n const general = homeWorkspace();\n if (workspace === undefined || general === undefined || !coordinated(workspace)) return;\n const home = oldestCoordinator(general.id);\n if (home === undefined) return;\n const persona = options.records().find((record) => record.sessionId === home.sessionId)?.coordinator;\n if (persona === undefined) {\n options.notice(\n `Home coordinator '${home.sessionId}' has no recorded persona; workspace '${workspaceId}' gets none.`,\n );\n return;\n }\n await ensureCoordinator(workspaceId, workspaceSettings(workspace, persona));\n },\n async startSession(coordinatorSessionId, request) {\n const caller = options.liveSessions().find((session) => session.id === coordinatorSessionId);\n if (caller?.sessionProvenance !== COORDINATOR_SESSION_PROVENANCE)\n throw new Error('Only a coordinator can start sessions.');\n const name = request.name.trim();\n const brief = request.brief.trim();\n if (name === '' || brief === '') throw new Error('A started session needs a name and a brief.');\n if (\n request.workspaceId !== undefined &&\n (typeof request.workspaceId !== 'string' || request.workspaceId.trim() === '')\n )\n throw new Error('A target workspace ID must be non-empty text.');\n const workspace = options.workspaces().find((entry) => entry.id === (request.workspaceId ?? caller.workspaceId));\n assertCoordinatorStartScope(\n caller.workspaceId,\n homeWorkspace()?.id,\n workspace,\n workspace !== undefined && oldestCoordinator(workspace.id) !== undefined,\n );\n const at = now();\n const recent = (starts.get(coordinatorSessionId) ?? []).filter((time) => at - time < COORDINATOR_START_WINDOW_MS);\n assertCoordinatorStartBudget(recent.length);\n starts.set(coordinatorSessionId, [...recent, at]);\n // No parent link: a parent may close its children, and a coordinator never stops sessions.\n const { sessionId } =\n workspace!.kind === 'session'\n ? await options.createGeneral({ name })\n : await options.createInWorkspace(workspace!, { name });\n try {\n await options.prompt(sessionId, brief);\n } catch (error) {\n // Creation committed and spent its quota. Report the id so callers do not blindly retry.\n return { sessionId, promptError: error instanceof Error ? error.message : String(error) };\n }\n return { sessionId };\n },\n async add(workspaceId) {\n if (workspaceId === undefined) return ensureHome(homePersona() ?? defaultPersona());\n const workspace = options.workspaces().find((entry) => entry.id === workspaceId);\n if (workspace === undefined) throw new Error(`Workspace '${workspaceId}' not found.`);\n if (!coordinated(workspace)) throw new Error('This workspace cannot have a coordinator.');\n return ensureCoordinator(\n workspaceId,\n workspaceSettings(workspace, homePersona() ?? defaultPersona(workspace.root)),\n );\n },\n async setRole(sessionId, coordinator) {\n let live = options.liveSessions().find((session) => session.id === sessionId);\n const record = options.records().find((entry) => entry.sessionId === sessionId);\n const current = live ?? (record === undefined ? undefined : { ...record, id: record.sessionId });\n if (current?.workspaceId === undefined) throw new Error('Session not found.');\n if ((current.sessionProvenance === COORDINATOR_SESSION_PROVENANCE) === coordinator) return;\n if (!coordinator) return demote(sessionId);\n if (current.parentSessionId !== undefined) throw new Error('A nested session cannot become a coordinator.');\n // A worktree, workflow or voice session keeps the role its provenance gives it.\n if (current.sessionProvenance !== undefined)\n throw new Error(`A ${current.sessionProvenance} session cannot become a coordinator.`);\n const workspace = options.workspaces().find((entry) => entry.id === current.workspaceId);\n if (\n workspace === undefined ||\n workspace.sandbox !== undefined ||\n (workspace.kind !== 'session' && !coordinated(workspace))\n )\n throw new Error('This workspace cannot have a coordinator.');\n for (const other of coordinatorsIn(workspace.id)) await demote(other.sessionId);\n if (live === undefined) {\n await options.revive(record!);\n live = options.liveSessions().find((session) => session.id === sessionId);\n }\n // The session keeps its own persona; one without gets the default.\n const profile = live?.profile?.name ?? options.defaultProfile(workspace.root);\n await options.reopen(sessionId, {\n sessionProvenance: COORDINATOR_SESSION_PROVENANCE,\n ...(live?.profile === undefined && profile !== undefined ? { profile } : {}),\n });\n if (profile !== undefined) recordPersona(sessionId, { profile, name: current.name ?? profile });\n else options.notice(`Coordinator '${sessionId}' has no profile; new workspaces will not copy its persona.`);\n },\n };\n}\n","import { verifyEnvelope } from '@agimon-ai/po-web-security/deviceProof';\nimport {\n createClientHandshake,\n createHostHandshake,\n type SealedChannel,\n} from '@agimon-ai/po-web-security/nodeSealedChannel';\n\nimport type {\n RosterLinkProof,\n RosterPeerChannel,\n RosterPeerLinkPorts,\n RosterPeerLinks,\n SignedRosterLinkProof,\n} from './type';\n\nconst LINK_TTL = 60_000;\n\n/** Account links are separate from legacy session-peer secrets and permissions.\n * A fresh signed ephemeral exchange uses the host key in the verified C6 roster.\n * Coordinator availability is irrelevant. Roster removal or rotation fences all\n * existing channel uses; applications must sync and persist C6 before exposing it.\n */\nexport function createRosterPeerLink(ports: RosterPeerLinkPorts): RosterPeerLinks {\n const consumed = new Map<string, number>();\n function check(proof: SignedRosterLinkProof): RosterLinkProof {\n const snapshot = ports.roster();\n const payload = proof.payload;\n const host = snapshot.hosts.find((h) => h.hostId === payload.hostId);\n if (\n !host ||\n payload.hostId === ports.hostId ||\n payload.destinationHostId !== ports.hostId ||\n payload.networkId !== snapshot.networkId ||\n payload.epoch !== snapshot.epoch ||\n !payload.publicKey ||\n !payload.challenge ||\n typeof payload.echo !== 'string' ||\n payload.expiresAt - payload.issuedAt > LINK_TTL ||\n !verifyEnvelope(host.publicKey, 'po/host-request/v1', proof, ports.now())\n )\n throw new Error('Roster link refused');\n return payload;\n }\n function wrap(channel: SealedChannel, hostId: string, epoch: number): RosterPeerChannel {\n const snapshot = ports.roster();\n const remote = snapshot.hosts.find((h) => h.hostId === hostId)?.publicKey;\n const local = snapshot.hosts.find((h) => h.hostId === ports.hostId)?.publicKey;\n const valid = () => {\n const current = ports.roster();\n return (\n !!remote &&\n !!local &&\n current.networkId === snapshot.networkId &&\n current.epoch === epoch &&\n current.hosts.some((h) => h.hostId === hostId && h.publicKey === remote) &&\n current.hosts.some((h) => h.hostId === ports.hostId && h.publicKey === local)\n );\n };\n return {\n seal(plaintext) {\n if (!valid()) return { ok: false, failure: 'auth' };\n return channel.seal(plaintext);\n },\n async open(envelope) {\n if (!valid()) return undefined;\n const opened = channel.open(envelope);\n if (!opened.ok || !(await ports.verifyRequest(opened.plaintext, hostId)) || !valid()) return undefined;\n return opened.plaintext;\n },\n };\n }\n return {\n async connect(hostId, token, exchange) {\n const snapshot = ports.roster();\n if (!snapshot.hosts.some((h) => h.hostId === ports.hostId) || !snapshot.hosts.some((h) => h.hostId === hostId))\n throw new Error('Host is not in roster');\n const handshake = createClientHandshake();\n const payload: RosterLinkProof = {\n networkId: snapshot.networkId,\n epoch: snapshot.epoch,\n hostId: ports.hostId,\n destinationHostId: hostId,\n publicKey: handshake.publicKey,\n challenge: crypto.randomUUID(),\n echo: '',\n issuedAt: ports.now(),\n expiresAt: ports.now() + LINK_TTL,\n };\n const reply = check(await exchange(ports.sign(payload), token));\n if (\n reply.hostId !== hostId ||\n reply.challenge !== payload.challenge ||\n reply.echo !== payload.publicKey ||\n reply.epoch !== payload.epoch\n )\n throw new Error('Roster link response mismatch');\n const channel = handshake.accept(reply.publicKey);\n if (!channel) throw new Error('Invalid roster channel');\n return wrap(channel, hostId, payload.epoch);\n },\n async accept(proof, token) {\n const payload = check(proof);\n if (payload.echo !== '' || !(await ports.authorize(token, payload.hostId, payload.networkId)))\n throw new Error('Roster link denied');\n // Authorization may await a roster sync. Recheck before committing the link.\n check(proof);\n for (const [id, expiry] of consumed) if (expiry <= ports.now()) consumed.delete(id);\n const id = JSON.stringify([payload.hostId, payload.challenge]);\n if (consumed.has(id) || consumed.size >= 1024) throw new Error('Roster link replayed');\n consumed.set(id, payload.expiresAt);\n const handshake = createHostHandshake();\n const channel = handshake.accept(payload.publicKey);\n if (!channel) throw new Error('Invalid roster channel');\n return {\n proof: ports.sign({\n ...payload,\n hostId: ports.hostId,\n destinationHostId: payload.hostId,\n publicKey: handshake.publicKey,\n echo: payload.publicKey,\n issuedAt: ports.now(),\n expiresAt: ports.now() + LINK_TTL,\n }),\n channel: wrap(channel, payload.hostId, payload.epoch),\n };\n },\n };\n}\n"],"mappings":";;;;;;AAQA,MAAa,8BAA8B;AAC3C,MAAa,8BAA8B;AAE3C,SAAgB,6BAA6B,OAAqB;CAChE,IAAI,SAAA,GACF,MAAM,IAAI,MAAM,qDAAkF;AACtG;AAEA,SAAgB,4BACd,mBACA,iBACA,WACA,gBACM;CACN,IAAI,cAAc,KAAA,KAAa,UAAU,cAAc,SAAS,UAAU,YAAY,KAAA,GACpF,MAAM,IAAI,MAAM,sCAAsC;CACxD,IAAI,UAAU,OAAO,mBAAmB;CACxC,IAAI,sBAAsB,KAAA,KAAa,sBAAsB,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;GAClC,MAAM,YAAY,oBAAoB;GACtC,MAAM,UAAU,UAAU,OAAO,QAAQ,SAAS;GAClD,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,wBAAwB;GACtD,OAAO;IACL,OAAO,MAAM,KAAK;KAChB,GAAG;KACH,QAAQ,MAAM;KACd,mBAAmB,QAAQ;KAC3B,WAAW,UAAU;KACrB,MAAM,QAAQ;KACd,UAAU,MAAM,IAAI;KACpB,WAAW,MAAM,IAAI,IAAI;IAC3B,CAAC;IACD,SAAS,KAAK,SAAS,QAAQ,QAAQ,QAAQ,KAAK;GACtD;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/services/sessionCoordination/policy.ts","../src/services/sessionCoordination/index.ts","../src/services/peerLink/roster.ts"],"sourcesContent":["import {\n COORDINATOR_SESSION_PROVENANCE,\n REMOTE_CONVERSATION_SESSION_PROVENANCE,\n type PoSessionCommunicationPolicy,\n type PoSessionCommunicationSubject,\n} from '@agimon-ai/po-core/hubChannel';\n\n/** ponytail: a fixed per-coordinator budget; add configuration only when another number is needed. */\nexport const COORDINATOR_STARTS_PER_HOUR = 5;\nexport const COORDINATOR_START_WINDOW_MS = 60 * 60 * 1000;\n\nexport function assertCoordinatorStartBudget(count: number): void {\n if (count >= COORDINATOR_STARTS_PER_HOUR)\n throw new Error(`A coordinator can start at most ${COORDINATOR_STARTS_PER_HOUR} sessions an hour.`);\n}\n\nexport function assertCoordinatorStartScope(\n callerWorkspaceId: string | undefined,\n homeWorkspaceId: string | undefined,\n workspace: { id: string; kind?: 'session'; available?: boolean; sandbox?: string } | undefined,\n hasCoordinator: boolean,\n): void {\n if (workspace === undefined || workspace.available === false || workspace.sandbox !== undefined)\n throw new Error('The target workspace is unavailable.');\n if (workspace.id === callerWorkspaceId) return;\n if (callerWorkspaceId === undefined || callerWorkspaceId !== homeWorkspaceId || workspace.kind === 'session')\n throw new Error('Only the home coordinator can target another workspace.');\n if (hasCoordinator) throw new Error('This workspace has a coordinator. Ask it to start the session.');\n}\n\n/** Communication is symmetric. A message grant never grants lifecycle authority. */\nexport const canSessionsCommunicate: PoSessionCommunicationPolicy = (input) => {\n const { source, target } = input;\n if (source.id === target.id) return false;\n if (source.parentSessionId === target.id || target.parentSessionId === source.id) return true;\n if (\n source.sessionProvenance === REMOTE_CONVERSATION_SESSION_PROVENANCE ||\n target.sessionProvenance === REMOTE_CONVERSATION_SESSION_PROVENANCE\n )\n return false;\n const coordinates = (session: PoSessionCommunicationSubject): boolean =>\n session.sessionProvenance === COORDINATOR_SESSION_PROVENANCE;\n const home = (session: PoSessionCommunicationSubject): boolean =>\n coordinates(session) &&\n session.workspaceId !== undefined &&\n input.workspaces.some((workspace) => workspace.id === session.workspaceId && workspace.kind === 'session');\n const homeFallback = (coordinator: PoSessionCommunicationSubject, peer: PoSessionCommunicationSubject): boolean => {\n if (!home(coordinator) || peer.workspaceId === undefined) return false;\n const workspace = input.workspaces.find((entry) => entry.id === peer.workspaceId);\n if (!workspace || workspace.kind === 'session' || workspace.sandbox !== undefined || workspace.available === false)\n return false;\n return (\n !input.sessions.some((session) => session.workspaceId === workspace.id && coordinates(session)) &&\n !input.dormantSessions.some(\n (record) =>\n record.workspaceId === workspace.id &&\n record.sessionProvenance === COORDINATOR_SESSION_PROVENANCE &&\n !input.sessions.some((session) => session.id === record.sessionId),\n )\n );\n };\n if (\n (coordinates(source) || coordinates(target)) &&\n source.workspaceId !== undefined &&\n source.workspaceId === target.workspaceId\n )\n return true;\n if (coordinates(source) && coordinates(target) && (home(source) || home(target))) return true;\n if (homeFallback(source, target) || homeFallback(target, source)) return true;\n if (source.workspaceId !== undefined && source.workspaceId === target.workspaceId && input.filesOverlap) return true;\n return (source.groups ?? []).some((group) => target.groups?.includes(group) === true);\n};\n","import { COORDINATOR_SESSION_PROVENANCE } from '@agimon-ai/po-core/hubChannel';\n\nimport { assertCoordinatorStartBudget, assertCoordinatorStartScope, COORDINATOR_START_WINDOW_MS } from './policy';\nimport type {\n CoordinatorSettings,\n CoordinatorResult,\n CoordinatorWorkspace,\n CoordinatorCreateRequest,\n CoordinatorServiceOptions,\n CoordinatorService,\n} from './type';\n\nexport { COORDINATOR_STARTS_PER_HOUR } from './policy';\nconst FALLBACK_SLUG = 'workspace';\n\nexport type {\n CoordinatorSettings,\n CoordinatorResult,\n CoordinatorAddResult,\n CoordinatorCreateRequest,\n CoordinatorServiceOptions,\n CoordinatorService,\n} from './type';\n\n/** Kebab-case from the workspace name, else its folder name. */\nexport function workspaceSlug(workspace: { readonly name?: string; readonly root: string }): string {\n const source = workspace.name?.trim() || workspace.root.split(/[\\\\/]/u).filter(Boolean).pop() || '';\n const slug = source\n .toLowerCase()\n .replace(/[^a-z0-9]+/gu, '-')\n .replace(/^-+|-+$/gu, '');\n return slug || FALLBACK_SLUG;\n}\n\nexport function createCoordinatorService(options: CoordinatorServiceOptions): CoordinatorService {\n const opening = new Map<string, Promise<CoordinatorResult>>();\n const starts = new Map<string, number[]>();\n const now = (): number => options.now?.() ?? Date.now();\n\n const homeWorkspace = (): CoordinatorWorkspace | undefined =>\n options.workspaces().find((workspace) => workspace.kind === 'session');\n\n /** Live sessions first, so a live coordinator's record is never mistaken for a dormant one. Oldest wins. */\n const coordinatorsIn = (workspaceId: string): { sessionId: string; createdAt: string; live: boolean }[] => {\n const liveSessions = options.liveSessions();\n const live = liveSessions\n .filter(\n (session) =>\n session.sessionProvenance === COORDINATOR_SESSION_PROVENANCE && session.workspaceId === workspaceId,\n )\n .map((session) => ({ sessionId: session.id, createdAt: session.createdAt, live: true }));\n const dormant = options\n .records()\n .filter(\n (record) =>\n record.sessionProvenance === COORDINATOR_SESSION_PROVENANCE &&\n record.workspaceId === workspaceId &&\n !liveSessions.some((session) => session.id === record.sessionId),\n )\n .map((record) => ({ sessionId: record.sessionId, createdAt: record.createdAt, live: false }));\n return [...live, ...dormant].sort((a, b) => a.createdAt.localeCompare(b.createdAt));\n };\n\n const oldestCoordinator = (workspaceId: string) => {\n const found = coordinatorsIn(workspaceId);\n if (found.length > 1)\n options.notice(\n `Workspace '${workspaceId}' has ${found.length} coordinators; using the oldest, '${found[0]?.sessionId}'.`,\n );\n return found[0];\n };\n\n const open = async (target: string, settings: CoordinatorSettings): Promise<CoordinatorResult> => {\n const workspace = target === 'home' ? homeWorkspace() : options.workspaces().find((entry) => entry.id === target);\n if (target !== 'home') {\n if (workspace === undefined) throw new Error(`Workspace '${target}' not found.`);\n if (workspace.kind === 'session') throw new Error('The home workspace takes the home coordinator.');\n if (!coordinated(workspace)) throw new Error('This workspace cannot have a coordinator.');\n }\n if (workspace?.sandbox !== undefined) throw new Error('This workspace cannot have a coordinator.');\n const existing = workspace === undefined ? undefined : oldestCoordinator(workspace.id);\n if (existing !== undefined) {\n if (!existing.live) {\n const record = options.records().find((entry) => entry.sessionId === existing.sessionId);\n if (record === undefined) throw new Error('The coordinator record disappeared while reviving it.');\n await options.revive(record);\n }\n return { sessionId: existing.sessionId, created: false };\n }\n const request: CoordinatorCreateRequest = {\n name: settings.name,\n sessionProvenance: COORDINATOR_SESSION_PROVENANCE,\n selection: { profile: settings.profile },\n ...(settings.model === undefined ? {} : { model: settings.model }),\n };\n const { sessionId } =\n workspace === undefined || target === 'home'\n ? await options.createGeneral(request)\n : await options.createInWorkspace(workspace, request);\n // The persona rides on the record, so the admit path still knows it after a restart.\n const record = options.records().find((entry) => entry.sessionId === sessionId);\n const coordinator = {\n profile: settings.profile,\n name: settings.name,\n ...(settings.model === undefined ? {} : { model: settings.model }),\n };\n if (record === undefined || !options.saveRecord({ ...record, coordinator }))\n options.notice(`Coordinator '${sessionId}' persona could not be recorded.`);\n return { sessionId, created: true };\n };\n\n const ensureCoordinator = (target: string, settings: CoordinatorSettings): Promise<CoordinatorResult> => {\n const pending = opening.get(target);\n if (pending !== undefined) return pending;\n const run = open(target, settings).finally(() => opening.delete(target));\n opening.set(target, run);\n return run;\n };\n\n const workspaceSettings = (workspace: CoordinatorWorkspace, home: CoordinatorSettings): CoordinatorSettings => ({\n profile: home.profile,\n name: `${home.name}-${workspaceSlug(workspace)}`,\n ...(home.model === undefined ? {} : { model: home.model }),\n });\n\n // Sandboxed workspaces get no coordinator; their sessions live in the sandbox's own records.\n const coordinated = (workspace: CoordinatorWorkspace): boolean =>\n workspace.kind !== 'session' && workspace.available !== false && workspace.sandbox === undefined;\n\n const homePersona = (): CoordinatorSettings | undefined => {\n const general = homeWorkspace();\n const home = general === undefined ? undefined : oldestCoordinator(general.id);\n return home === undefined\n ? undefined\n : options.records().find((record) => record.sessionId === home.sessionId)?.coordinator;\n };\n\n const recordPersona = (sessionId: string, coordinator: CoordinatorSettings | undefined): void => {\n const record = options.records().find((entry) => entry.sessionId === sessionId);\n if (record === undefined) return;\n const { coordinator: _dropped, ...rest } = record;\n if (!options.saveRecord(coordinator === undefined ? rest : { ...rest, coordinator }))\n options.notice(`Coordinator '${sessionId}' persona could not be recorded.`);\n };\n\n const demote = async (sessionId: string): Promise<void> => {\n if (options.liveSessions().some((session) => session.id === sessionId)) await options.reopen(sessionId, {});\n else {\n const record = options.records().find((entry) => entry.sessionId === sessionId);\n if (record === undefined) return;\n const { sessionProvenance: _dropped, ...rest } = record;\n if (!options.saveRecord(rest)) throw new Error(`Session '${sessionId}' could not be made regular.`);\n }\n recordPersona(sessionId, undefined);\n };\n\n const ensureHome = async (settings: CoordinatorSettings): Promise<CoordinatorResult> => {\n const home = await ensureCoordinator('home', settings);\n const outcomes = await Promise.allSettled(\n options\n .workspaces()\n .filter(coordinated)\n .map((workspace) => ensureCoordinator(workspace.id, workspaceSettings(workspace, settings))),\n );\n for (const outcome of outcomes)\n if (outcome.status === 'rejected')\n options.notice(`A workspace coordinator could not be opened: ${String(outcome.reason)}`);\n return home;\n };\n\n return {\n ensureCoordinator,\n ensureHome,\n async workspaceAdmitted(workspaceId) {\n const workspace = options.workspaces().find((entry) => entry.id === workspaceId);\n const general = homeWorkspace();\n if (workspace === undefined || general === undefined || !coordinated(workspace)) return;\n const home = oldestCoordinator(general.id);\n if (home === undefined) return;\n const persona = options.records().find((record) => record.sessionId === home.sessionId)?.coordinator;\n if (persona === undefined) {\n options.notice(\n `Home coordinator '${home.sessionId}' has no recorded persona; workspace '${workspaceId}' gets none.`,\n );\n return;\n }\n await ensureCoordinator(workspaceId, workspaceSettings(workspace, persona));\n },\n async startSession(coordinatorSessionId, request) {\n const caller = options.liveSessions().find((session) => session.id === coordinatorSessionId);\n if (caller?.sessionProvenance !== COORDINATOR_SESSION_PROVENANCE)\n throw new Error('Only a coordinator can start sessions.');\n const name = request.name.trim();\n const brief = request.brief.trim();\n if (name === '' || brief === '') throw new Error('A started session needs a name and a brief.');\n if (\n request.workspaceId !== undefined &&\n (typeof request.workspaceId !== 'string' || request.workspaceId.trim() === '')\n )\n throw new Error('A target workspace ID must be non-empty text.');\n const workspace = options.workspaces().find((entry) => entry.id === (request.workspaceId ?? caller.workspaceId));\n assertCoordinatorStartScope(\n caller.workspaceId,\n homeWorkspace()?.id,\n workspace,\n workspace !== undefined && oldestCoordinator(workspace.id) !== undefined,\n );\n const at = now();\n const recent = (starts.get(coordinatorSessionId) ?? []).filter((time) => at - time < COORDINATOR_START_WINDOW_MS);\n assertCoordinatorStartBudget(recent.length);\n starts.set(coordinatorSessionId, [...recent, at]);\n // No parent link: a parent may close its children, and a coordinator never stops sessions.\n const { sessionId } =\n workspace!.kind === 'session'\n ? await options.createGeneral({ name })\n : await options.createInWorkspace(workspace!, { name });\n try {\n await options.prompt(sessionId, brief);\n } catch (error) {\n // Creation committed and spent its quota. Report the id so callers do not blindly retry.\n return { sessionId, promptError: error instanceof Error ? error.message : String(error) };\n }\n return { sessionId };\n },\n async add(workspaceId, profile) {\n if (profile !== undefined && (typeof profile !== 'string' || profile.trim() === ''))\n throw new Error('A coordinator profile must be non-empty text.');\n const workspace =\n workspaceId === undefined ? homeWorkspace() : options.workspaces().find((entry) => entry.id === workspaceId);\n if (workspaceId !== undefined) {\n if (workspace === undefined) throw new Error(`Workspace '${workspaceId}' not found.`);\n if (!coordinated(workspace)) throw new Error('This workspace cannot have a coordinator.');\n }\n // Reuse does not need a new persona, even when the default has since disappeared.\n const existing = workspace === undefined ? undefined : oldestCoordinator(workspace.id);\n const inherited = homePersona();\n const selected =\n profile?.trim() ??\n inherited?.profile ??\n options.defaultProfile(workspaceId === undefined ? undefined : workspace?.root);\n if (selected === undefined && existing === undefined)\n return { profileRequired: true, error: 'Choose a profile before adding a coordinator.' };\n if (selected === undefined && existing !== undefined) {\n if (!existing.live) {\n const record = options.records().find((entry) => entry.sessionId === existing.sessionId);\n if (record === undefined) throw new Error('The coordinator record disappeared while reviving it.');\n await options.revive(record);\n }\n return { sessionId: existing.sessionId, created: false };\n }\n const settings =\n profile !== undefined\n ? { profile: selected!, name: selected! }\n : (inherited ?? { profile: selected ?? '', name: selected ?? '' });\n if (profile !== undefined && existing === undefined)\n await options.validateProfile?.(selected!, workspaceId === undefined ? undefined : workspace);\n return workspaceId === undefined\n ? ensureHome(settings)\n : ensureCoordinator(workspaceId, workspaceSettings(workspace!, settings));\n },\n async setRole(sessionId, coordinator) {\n let live = options.liveSessions().find((session) => session.id === sessionId);\n const record = options.records().find((entry) => entry.sessionId === sessionId);\n const current = live ?? (record === undefined ? undefined : { ...record, id: record.sessionId });\n if (current?.workspaceId === undefined) throw new Error('Session not found.');\n if ((current.sessionProvenance === COORDINATOR_SESSION_PROVENANCE) === coordinator) return;\n if (!coordinator) return demote(sessionId);\n if (current.parentSessionId !== undefined) throw new Error('A nested session cannot become a coordinator.');\n // A worktree, workflow or voice session keeps the role its provenance gives it.\n if (current.sessionProvenance !== undefined)\n throw new Error(`A ${current.sessionProvenance} session cannot become a coordinator.`);\n const workspace = options.workspaces().find((entry) => entry.id === current.workspaceId);\n if (\n workspace === undefined ||\n workspace.sandbox !== undefined ||\n (workspace.kind !== 'session' && !coordinated(workspace))\n )\n throw new Error('This workspace cannot have a coordinator.');\n for (const other of coordinatorsIn(workspace.id)) await demote(other.sessionId);\n if (live === undefined) {\n await options.revive(record!);\n live = options.liveSessions().find((session) => session.id === sessionId);\n }\n // The session keeps its own persona; one without gets the default.\n const profile = live?.profile?.name ?? options.defaultProfile(workspace.root);\n await options.reopen(sessionId, {\n sessionProvenance: COORDINATOR_SESSION_PROVENANCE,\n ...(live?.profile === undefined && profile !== undefined ? { profile } : {}),\n });\n if (profile !== undefined) recordPersona(sessionId, { profile, name: current.name ?? profile });\n else options.notice(`Coordinator '${sessionId}' has no profile; new workspaces will not copy its persona.`);\n },\n };\n}\n","import { verifyEnvelope } from '@agimon-ai/po-web-security/deviceProof';\nimport {\n createClientHandshake,\n createHostHandshake,\n type SealedChannel,\n} from '@agimon-ai/po-web-security/nodeSealedChannel';\n\nimport type {\n RosterLinkProof,\n RosterPeerChannel,\n RosterPeerLinkPorts,\n RosterPeerLinks,\n SignedRosterLinkProof,\n} from './type';\n\nconst LINK_TTL = 60_000;\n\n/** Account links are separate from legacy session-peer secrets and permissions.\n * A fresh signed ephemeral exchange uses the host key in the verified C6 roster.\n * Coordinator availability is irrelevant. Roster removal or rotation fences all\n * existing channel uses; applications must sync and persist C6 before exposing it.\n */\nexport function createRosterPeerLink(ports: RosterPeerLinkPorts): RosterPeerLinks {\n const consumed = new Map<string, number>();\n function check(proof: SignedRosterLinkProof): RosterLinkProof {\n const snapshot = ports.roster();\n const payload = proof.payload;\n const host = snapshot.hosts.find((h) => h.hostId === payload.hostId);\n if (\n !host ||\n payload.hostId === ports.hostId ||\n payload.destinationHostId !== ports.hostId ||\n payload.networkId !== snapshot.networkId ||\n payload.epoch !== snapshot.epoch ||\n !payload.publicKey ||\n !payload.challenge ||\n typeof payload.echo !== 'string' ||\n payload.expiresAt - payload.issuedAt > LINK_TTL ||\n !verifyEnvelope(host.publicKey, 'po/host-request/v1', proof, ports.now())\n )\n throw new Error('Roster link refused');\n return payload;\n }\n function wrap(channel: SealedChannel, hostId: string, epoch: number): RosterPeerChannel {\n const snapshot = ports.roster();\n const remote = snapshot.hosts.find((h) => h.hostId === hostId)?.publicKey;\n const local = snapshot.hosts.find((h) => h.hostId === ports.hostId)?.publicKey;\n const valid = () => {\n const current = ports.roster();\n return (\n !!remote &&\n !!local &&\n current.networkId === snapshot.networkId &&\n current.epoch === epoch &&\n current.hosts.some((h) => h.hostId === hostId && h.publicKey === remote) &&\n current.hosts.some((h) => h.hostId === ports.hostId && h.publicKey === local)\n );\n };\n return {\n seal(plaintext) {\n if (!valid()) return { ok: false, failure: 'auth' };\n return channel.seal(plaintext);\n },\n async open(envelope) {\n if (!valid()) return undefined;\n const opened = channel.open(envelope);\n if (!opened.ok || !(await ports.verifyRequest(opened.plaintext, hostId)) || !valid()) return undefined;\n return opened.plaintext;\n },\n };\n }\n return {\n async connect(hostId, token, exchange) {\n const snapshot = ports.roster();\n if (!snapshot.hosts.some((h) => h.hostId === ports.hostId) || !snapshot.hosts.some((h) => h.hostId === hostId))\n throw new Error('Host is not in roster');\n const handshake = createClientHandshake();\n const payload: RosterLinkProof = {\n networkId: snapshot.networkId,\n epoch: snapshot.epoch,\n hostId: ports.hostId,\n destinationHostId: hostId,\n publicKey: handshake.publicKey,\n challenge: crypto.randomUUID(),\n echo: '',\n issuedAt: ports.now(),\n expiresAt: ports.now() + LINK_TTL,\n };\n const reply = check(await exchange(ports.sign(payload), token));\n if (\n reply.hostId !== hostId ||\n reply.challenge !== payload.challenge ||\n reply.echo !== payload.publicKey ||\n reply.epoch !== payload.epoch\n )\n throw new Error('Roster link response mismatch');\n const channel = handshake.accept(reply.publicKey);\n if (!channel) throw new Error('Invalid roster channel');\n return wrap(channel, hostId, payload.epoch);\n },\n async accept(proof, token) {\n const payload = check(proof);\n if (payload.echo !== '' || !(await ports.authorize(token, payload.hostId, payload.networkId)))\n throw new Error('Roster link denied');\n // Authorization may await a roster sync. Recheck before committing the link.\n check(proof);\n for (const [id, expiry] of consumed) if (expiry <= ports.now()) consumed.delete(id);\n const id = JSON.stringify([payload.hostId, payload.challenge]);\n if (consumed.has(id) || consumed.size >= 1024) throw new Error('Roster link replayed');\n consumed.set(id, payload.expiresAt);\n const handshake = createHostHandshake();\n const channel = handshake.accept(payload.publicKey);\n if (!channel) throw new Error('Invalid roster channel');\n return {\n proof: ports.sign({\n ...payload,\n hostId: ports.hostId,\n destinationHostId: payload.hostId,\n publicKey: handshake.publicKey,\n echo: payload.publicKey,\n issuedAt: ports.now(),\n expiresAt: ports.now() + LINK_TTL,\n }),\n channel: wrap(channel, payload.hostId, payload.epoch),\n };\n },\n };\n}\n"],"mappings":";;;;;;AAQA,MAAa,8BAA8B;AAC3C,MAAa,8BAA8B;AAE3C,SAAgB,6BAA6B,OAAqB;CAChE,IAAI,SAAA,GACF,MAAM,IAAI,MAAM,qDAAkF;AACtG;AAEA,SAAgB,4BACd,mBACA,iBACA,WACA,gBACM;CACN,IAAI,cAAc,KAAA,KAAa,UAAU,cAAc,SAAS,UAAU,YAAY,KAAA,GACpF,MAAM,IAAI,MAAM,sCAAsC;CACxD,IAAI,UAAU,OAAO,mBAAmB;CACxC,IAAI,sBAAsB,KAAA,KAAa,sBAAsB,mBAAmB,UAAU,SAAS,WACjG,MAAM,IAAI,MAAM,yDAAyD;CAC3E,IAAI,gBAAgB,MAAM,IAAI,MAAM,gEAAgE;AACtG;;AAGA,MAAa,0BAAwD,UAAU;CAC7E,MAAM,EAAE,QAAQ,WAAW;CAC3B,IAAI,OAAO,OAAO,OAAO,IAAI,OAAO;CACpC,IAAI,OAAO,oBAAoB,OAAO,MAAM,OAAO,oBAAoB,OAAO,IAAI,OAAO;CACzF,IACE,OAAO,sBAAsB,0CAC7B,OAAO,sBAAsB,wCAE7B,OAAO;CACT,MAAM,eAAe,YACnB,QAAQ,sBAAsB;CAChC,MAAM,QAAQ,YACZ,YAAY,OAAO,KACnB,QAAQ,gBAAgB,KAAA,KACxB,MAAM,WAAW,MAAM,cAAc,UAAU,OAAO,QAAQ,eAAe,UAAU,SAAS,SAAS;CAC3G,MAAM,gBAAgB,aAA4C,SAAiD;EACjH,IAAI,CAAC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GAAG,SAAS,OAAO,EAAE;GAClF,MAAM,KAAK,KAAK,UAAU,CAAC,QAAQ,QAAQ,QAAQ,SAAS,CAAC;GAC7D,IAAI,SAAS,IAAI,EAAE,KAAK,SAAS,QAAQ,MAAM,MAAM,IAAI,MAAM,sBAAsB;GACrF,SAAS,IAAI,IAAI,QAAQ,SAAS;GAClC,MAAM,YAAY,oBAAoB;GACtC,MAAM,UAAU,UAAU,OAAO,QAAQ,SAAS;GAClD,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,wBAAwB;GACtD,OAAO;IACL,OAAO,MAAM,KAAK;KAChB,GAAG;KACH,QAAQ,MAAM;KACd,mBAAmB,QAAQ;KAC3B,WAAW,UAAU;KACrB,MAAM,QAAQ;KACd,UAAU,MAAM,IAAI;KACpB,WAAW,MAAM,IAAI,IAAI;IAC3B,CAAC;IACD,SAAS,KAAK,SAAS,QAAQ,QAAQ,QAAQ,KAAK;GACtD;EACF;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/po-session",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.126",
|
|
4
4
|
"description": "Shared session coordination services for Po.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -58,15 +58,15 @@
|
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@agimon-ai/po-config": "0.0.0-alpha.
|
|
62
|
-
"@agimon-ai/po-core": "0.0.0-alpha.
|
|
63
|
-
"@agimon-ai/po-web-security": "0.0.0-alpha.
|
|
61
|
+
"@agimon-ai/po-config": "0.0.0-alpha.126",
|
|
62
|
+
"@agimon-ai/po-core": "0.0.0-alpha.126",
|
|
63
|
+
"@agimon-ai/po-web-security": "0.0.0-alpha.126",
|
|
64
64
|
"@deepseek-ai/cordis": "4.0.5",
|
|
65
65
|
"typebox": "1.4.2"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@agimon-ai/po-build": "0.0.0-alpha.
|
|
69
|
-
"@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.
|
|
68
|
+
"@agimon-ai/po-build": "0.0.0-alpha.126",
|
|
69
|
+
"@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.126",
|
|
70
70
|
"@earendil-works/pi-coding-agent": "1.5.0",
|
|
71
71
|
"@types/node": "26.6.5",
|
|
72
72
|
"@vitest/coverage-v8": "5.0.4",
|