@agimon-ai/po-session 0.0.0-alpha.21 → 0.0.0-alpha.210

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/LICENSE +21 -149
  2. package/README.md +47 -1
  3. package/dist/apiContracts.cjs +34 -2
  4. package/dist/apiContracts.cjs.map +1 -1
  5. package/dist/apiContracts.d.mts +2 -2
  6. package/dist/apiContracts.d.mts.map +1 -1
  7. package/dist/apiContracts.mjs +35 -2
  8. package/dist/apiContracts.mjs.map +1 -1
  9. package/dist/extensions/native.mjs +410 -0
  10. package/dist/extensions/native.mjs.map +1 -0
  11. package/dist/extensions/server.cjs +1661 -113
  12. package/dist/extensions/server.cjs.map +1 -1
  13. package/dist/extensions/server.d.mts.map +1 -1
  14. package/dist/extensions/server.mjs +1657 -109
  15. package/dist/extensions/server.mjs.map +1 -1
  16. package/dist/extensions/web.mjs +361 -0
  17. package/dist/extensions/web.mjs.map +1 -0
  18. package/dist/index.cjs +410 -25
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/index.d.mts +599 -82
  21. package/dist/index.d.mts.map +1 -1
  22. package/dist/index.mjs +358 -1
  23. package/dist/index.mjs.map +1 -0
  24. package/dist/po-runtime-identity.json +1 -0
  25. package/dist/type-BlbiS10p.mjs +2622 -0
  26. package/dist/type-BlbiS10p.mjs.map +1 -0
  27. package/dist/type-DZtqhE4a.cjs +3083 -0
  28. package/dist/type-DZtqhE4a.cjs.map +1 -0
  29. package/llms.txt +4 -1
  30. package/locales/vi.json +29 -0
  31. package/locales/zh-CN.json +29 -0
  32. package/package.json +96 -11
  33. package/src/prompts/codemode-how-to-network/SKILL.md +49 -0
  34. package/src/prompts/codemode-how-to-session/SKILL.md +25 -0
  35. package/dist/sessionDelivery-4svjzWUW.mjs +0 -1028
  36. package/dist/sessionDelivery-4svjzWUW.mjs.map +0 -1
  37. package/dist/sessionDelivery-CGWuQyLV.cjs +0 -1219
  38. package/dist/sessionDelivery-CGWuQyLV.cjs.map +0 -1
package/dist/index.d.mts CHANGED
@@ -1,13 +1,59 @@
1
1
  import { PoBackgroundWorkService } from "@agimon-ai/po-core/backgroundWork";
2
+ import { Type } from "typebox";
3
+ import { PoHubSessionSelection, PoSessionCommunicationEndpoint, PoSessionCommunicationPolicy, PoSessionCoordinationPolicy, PoSessionPeerDescription } from "@agimon-ai/po-core/hubChannel";
4
+ import { PoCodemodeNamespace } from "@agimon-ai/po-core/codemode";
5
+ import { PoHeadlessTool } from "@agimon-ai/po-core/headless";
2
6
  import { FileSystem, PoSqliteService } from "@agimon-ai/po-core/platform";
7
+ import { SealedChannel } from "@agimon-ai/po-web-security/nodeSealedChannel";
8
+ import { SealedEnvelope } from "@agimon-ai/po-web-security";
9
+ import "@agimon-ai/po-core/serverPlugin";
10
+ import { PoSessionCoordination } from "@agimon-ai/po-core/packageApi";
3
11
  import { Context } from "@deepseek-ai/cordis";
4
- import { PoSessionCommunicationEndpoint } from "@agimon-ai/po-core/hubChannel";
12
+ import { OpenSessionRecord } from "@agimon-ai/po-core/history";
13
+ import { HostRequests } from "@agimon-ai/po-core/modelGateway";
5
14
  //#region src/services/backgroundWorkService/index.d.ts
6
15
  /** Creates the generation-bound, pull-based coordinator shared by session extensions. */
7
16
  export declare function createBackgroundWorkService(ctx: Context): PoBackgroundWorkService;
8
17
  /** Installs one coordinator in the current session service context. */
9
18
  export declare function provideBackgroundWorkService(context: Context): void;
10
19
  //#endregion
20
+ //#region src/schemas/startSession.d.ts
21
+ /** Input shared by start_session and the Session code-mode namespace. */
22
+ export declare const StartSessionParamsSchema: Type.TObject<{
23
+ name: Type.TString;
24
+ brief: Type.TString;
25
+ workspaceId: Type.TOptional<Type.TString>;
26
+ }>;
27
+ //#endregion
28
+ //#region src/services/coordinatorSessions/type.d.ts
29
+ interface CoordinatorSessionsOptions {
30
+ /** The calling session's provenance, read live. */
31
+ provenance(): string | undefined;
32
+ /** Host authorization bound to this session. */
33
+ coordination(): PoSessionCoordination | undefined;
34
+ /** Told the id of each session this one starts. It handles its own failures: a start is never undone by it. */
35
+ started?(sessionId: string): Promise<void>;
36
+ }
37
+ interface StartSessionInput {
38
+ name: string;
39
+ brief: string;
40
+ workspaceId?: string;
41
+ }
42
+ interface StartSessionResult {
43
+ sessionId: string;
44
+ /** Session creation committed, but its first prompt failed. Do not retry the start. */
45
+ promptError?: string;
46
+ /** True when the session took the brief as its goal, false when it read it as an ordinary prompt. */
47
+ goal?: boolean;
48
+ }
49
+ //#endregion
50
+ //#region src/services/coordinatorSessions/index.d.ts
51
+ export declare const START_SESSION_TOOL_NAME = "start_session";
52
+ /** Validate at every public entry, including compatibility forwarders. */
53
+ export declare function parseStartSessionInput(raw: unknown): StartSessionInput;
54
+ export declare function startCoordinatedSession(options: CoordinatorSessionsOptions, raw: unknown, signal?: AbortSignal): Promise<StartSessionResult>;
55
+ export declare function createStartSessionTool(options: CoordinatorSessionsOptions): PoHeadlessTool<typeof StartSessionParamsSchema>;
56
+ //#endregion
11
57
  //#region src/services/sessionGroups/type.d.ts
12
58
  /** pi-durable `SqliteDatabase`, reached through po-core so this package needs no direct dependency. */
13
59
  type SessionSqliteDatabase = Awaited<ReturnType<PoSqliteService['open']>>;
@@ -45,12 +91,379 @@ export declare class SessionGroupRevisionError extends Error {
45
91
  constructor(groupId: string, expected: number, actual: number);
46
92
  }
47
93
  //#endregion
94
+ //#region src/services/sessionDelivery/type.d.ts
95
+ export declare const PO_SESSION_DELIVERY_SERVICE = "po/session-delivery";
96
+ type PoSessionDeliveryInboxState = 'accepted' | 'admitting' | 'admitted' | 'recovery_required' | 'revoked';
97
+ type PoSessionDeliveryMode = 'prompt' | 'steer' | 'followUp';
98
+ interface PoSessionDeliveryMetadata extends Readonly<Record<string, string | undefined>> {
99
+ readonly worktreeId?: string;
100
+ readonly fromRole?: string;
101
+ /** Admit the prompt as a custom message, retaining the model text and separate display details. */
102
+ readonly customType?: string;
103
+ /** JSON-encoded custom-message details, persisted with the delivery for replay. */
104
+ readonly customDetails?: string;
105
+ }
106
+ interface PoSessionDeliveryRequest {
107
+ readonly deliveryId?: string;
108
+ readonly recipientKey: string;
109
+ readonly kind: string;
110
+ readonly prompt: string;
111
+ readonly delivery?: PoSessionDeliveryMode;
112
+ readonly metadata?: PoSessionDeliveryMetadata;
113
+ }
114
+ interface PoSessionInboxQuery {
115
+ readonly kind?: string;
116
+ readonly metadata?: PoSessionDeliveryMetadata;
117
+ readonly state?: PoSessionDeliveryInboxState;
118
+ readonly consumed?: boolean;
119
+ }
120
+ interface PoSessionInboxEntry {
121
+ readonly deliveryId: string;
122
+ readonly senderKey: string;
123
+ readonly recipientKey: string;
124
+ readonly kind: string;
125
+ readonly prompt: string;
126
+ readonly delivery: PoSessionDeliveryMode;
127
+ readonly metadata: PoSessionDeliveryMetadata;
128
+ readonly state: PoSessionDeliveryInboxState;
129
+ readonly consumed: boolean;
130
+ }
131
+ interface PoSessionOutboxEntry {
132
+ readonly deliveryId: string;
133
+ readonly recipientKey: string;
134
+ readonly kind: string;
135
+ readonly metadata: PoSessionDeliveryMetadata;
136
+ readonly state: 'queued' | 'acknowledged' | 'revoked';
137
+ readonly recipientState?: PoSessionDeliveryInboxState;
138
+ }
139
+ /** An outbox row with the time this session sent it. */
140
+ interface PoSessionSentEntry extends PoSessionOutboxEntry {
141
+ readonly createdAt: number;
142
+ }
143
+ /** Inbox rows folded into one message to this session itself. */
144
+ interface PoSessionDigestRequest {
145
+ readonly deliveryId: string;
146
+ /** The rows the digest stands for. They are marked consumed with it. */
147
+ readonly memberIds: readonly string[];
148
+ /** The exact text the session reads. */
149
+ readonly prompt: string;
150
+ readonly metadata?: PoSessionDeliveryMetadata;
151
+ }
152
+ interface PoSessionDeliveryService {
153
+ readonly recipientKey: string;
154
+ deliver(request: PoSessionDeliveryRequest): Promise<{
155
+ deliveryId: string;
156
+ }>;
157
+ waitForAdmission(deliveryId: string, timeoutMs?: number): Promise<PoSessionDeliveryInboxState | undefined>;
158
+ inbox(query?: PoSessionInboxQuery): Promise<readonly PoSessionInboxEntry[]>;
159
+ /** Optional host-routed peer envelope admission. Local-only consumers need no transport receiver. */
160
+ receive?(senderKey: string, kind: string, payload: unknown): Promise<PoSessionDeliveryInboxState | undefined>;
161
+ consume(deliveryId: string): Promise<boolean>;
162
+ outbox(deliveryId: string): Promise<PoSessionOutboxEntry | undefined>;
163
+ /** What this session sent since `since` (epoch ms), oldest first, to one recipient when named. */
164
+ sent(query: {
165
+ readonly since: number;
166
+ readonly recipientKey?: string;
167
+ }): Promise<readonly PoSessionSentEntry[]>;
168
+ /**
169
+ * Stores a digest and marks its members consumed in one transaction, then admits it once under its own id,
170
+ * also after a restart. A refused digest is never given up: it waits for `readmit`.
171
+ */
172
+ stageDigest(request: PoSessionDigestRequest): Promise<{
173
+ deliveryId: string;
174
+ }>;
175
+ /** Admits again every delivery a refusal left waiting. Call when the session can take input. */
176
+ readmit(): Promise<void>;
177
+ /** Notes that this session engaged with a peer without sending it anything: `sent` lists the row. */
178
+ record(entry: {
179
+ readonly recipientKey: string;
180
+ readonly kind: string;
181
+ }): Promise<void>;
182
+ /** Recheck queued deliveries immediately after a policy change. */
183
+ reauthorize?(): Promise<void>;
184
+ close(): Promise<void>;
185
+ }
186
+ interface SessionDeliveryServiceOptions {
187
+ /**
188
+ * Taken over by the service and closed by `close()`. On the edge every open returns the Durable
189
+ * Object's one shared database, so the service's table names must stay unique across that database.
190
+ */
191
+ readonly database: SessionSqliteDatabase;
192
+ readonly recipientKey: string;
193
+ readonly communication: PoSessionCommunicationEndpoint;
194
+ /** Host-owned relationship check applied before sends, retries, and recipient acceptance. */
195
+ readonly authorizePeer: (peerKey: string, metadata?: PoSessionDeliveryMetadata) => boolean | Promise<boolean>;
196
+ /**
197
+ * `requestId` is the delivery id; the recipient runtime dedupes on it, so a restart may replay an admission.
198
+ * A host admission refusal (`PoHeadlessPromptAdmissionError`) is retried; any other error fails the delivery at once.
199
+ */
200
+ readonly admitPrompt: (prompt: string, delivery: PoSessionDeliveryMode | undefined, requestId: string, metadata: PoSessionDeliveryMetadata) => Promise<void>;
201
+ /**
202
+ * Called once when a delivery ends in `recovery_required`: the recipient never read it. For a digest that
203
+ * keeps being refused, called with the first member from each sender whenever its retry window runs out.
204
+ */
205
+ readonly onUndeliverable?: (entry: PoSessionInboxEntry, error: unknown) => void;
206
+ /** How often and for how long a refused admission is retried. Defaults to every 5 seconds for 2 minutes. */
207
+ readonly admissionRetry?: {
208
+ readonly everyMs: number;
209
+ readonly forMs: number;
210
+ };
211
+ /** Reports a failure the service absorbed to keep delivering, such as a failed background pass. */
212
+ readonly onError: (error: unknown) => void;
213
+ }
214
+ declare module '@deepseek-ai/cordis' {
215
+ interface Context {
216
+ 'po/session-delivery': PoSessionDeliveryService;
217
+ }
218
+ }
219
+ /** Reads the currently active provider each time, without retaining a stale binding. */
220
+ export declare function readPoSessionDelivery(context: Context): PoSessionDeliveryService | undefined;
221
+ //#endregion
222
+ //#region src/services/logbook/type.d.ts
223
+ type LogbookLevel = 'info' | 'blocked';
224
+ interface LogbookQuery {
225
+ /** Only entries not yet marked read. */
226
+ readonly unread?: boolean;
227
+ /** Only entries from this session. */
228
+ readonly sessionId?: string;
229
+ readonly offset?: number;
230
+ readonly limit?: number;
231
+ }
232
+ interface LogbookEntry {
233
+ readonly id: string;
234
+ /** The writing session's id, attached by the host, never by the writer. */
235
+ readonly from: string;
236
+ /** The writer's session name when it wrote the entry. */
237
+ readonly name?: string;
238
+ readonly level: LogbookLevel;
239
+ readonly text: string;
240
+ /** ISO 8601 time the writer logged it. */
241
+ readonly at?: string;
242
+ readonly read: boolean;
243
+ }
244
+ interface LogbookPage {
245
+ /** Newest first. */
246
+ readonly entries: readonly LogbookEntry[];
247
+ /** Matching entries across every page. */
248
+ readonly total: number;
249
+ readonly nextOffset?: number;
250
+ }
251
+ //#endregion
252
+ //#region src/services/sessionsNamespace/type.d.ts
253
+ export declare const PO_SESSION_OPERATIONS_SERVICE = "po/session-operations";
254
+ /** Host-bound session operations. Caller identity is never accepted as input. */
255
+ interface SessionOperations {
256
+ list(signal: AbortSignal): Promise<unknown>;
257
+ /** `options.urgent` is honoured only where `lanes` is set. */
258
+ send(to: string, text: string, signal: AbortSignal, options?: {
259
+ urgent?: boolean;
260
+ }): Promise<unknown>;
261
+ /** True when a plain send waits for the end of the recipient's run and an urgent one interrupts it. */
262
+ lanes?: boolean;
263
+ read?(sessionId: string, signal: AbortSignal): Promise<unknown>;
264
+ /** A question whose answer comes back as a reply message. Returns its `requestId`. */
265
+ ask?(to: string, text: string, signal: AbortSignal): Promise<{
266
+ requestId: string;
267
+ }>;
268
+ reply?(requestId: string, text: string, signal: AbortSignal): Promise<unknown>;
269
+ /** Questions this session received and has not answered yet. */
270
+ pending?(signal: AbortSignal): Promise<unknown>;
271
+ /** Appends to the logbook of this session's coordinator in the hierarchy. Only `blocked` wakes it, batched. */
272
+ /** `settled` is the host's own stop report: `network.log` only ever passes the two public levels. */
273
+ log?(text: string, level: LogbookLevel | 'settled', signal: AbortSignal): Promise<{
274
+ to: readonly string[];
275
+ }>;
276
+ /** This session's own logbook, written by the sessions it coordinates. */
277
+ logbook?(query: LogbookQuery, signal: AbortSignal): Promise<LogbookPage>;
278
+ markRead?(ids: readonly string[], signal: AbortSignal): Promise<{
279
+ marked: number;
280
+ }>;
281
+ /**
282
+ * The live session `to` names when only the person's approval can reach it again: its `@session:` mention expired when
283
+ * this session compacted, and nothing else lets the two talk. Undefined for every other target.
284
+ */
285
+ mentionApprovalTarget?(to: string): {
286
+ sessionId: string;
287
+ name: string;
288
+ } | undefined;
289
+ /** The person approved messaging an expired mention again. False when it is no longer expired. */
290
+ restoreMention?(targetSessionId: string): boolean;
291
+ /** A host fallback covered completely by the network namespace. Never Team's richer intercom. */
292
+ fallbackToolName?: string;
293
+ }
294
+ /** One message from this session to another, for `network.send` and Team's intercom session fallback alike. */
295
+ interface SessionMessageRequest {
296
+ readonly delivery: PoSessionDeliveryService;
297
+ /** Stable per logical message: a repeated call with the same id is one message and one charge. */
298
+ readonly deliveryId: string;
299
+ readonly recipient: string;
300
+ readonly text: string;
301
+ /** Join the recipient's running turn instead of waiting for its end. Budgeted. */
302
+ readonly urgent?: boolean;
303
+ readonly senderName: string;
304
+ /** The address the recipient answers to: this session's id, or its peer reference on a linked host. */
305
+ readonly self: string;
306
+ /** Routing metadata of a linked recipient. */
307
+ readonly group?: PoSessionDeliveryMetadata;
308
+ }
309
+ interface SessionsNamespaceOptions extends CoordinatorSessionsOptions {
310
+ sessionId: string;
311
+ operations: SessionOperations;
312
+ assertAvailable(): void;
313
+ }
314
+ export declare function readSessionOperations(context: Context): SessionOperations | undefined;
315
+ declare module '@deepseek-ai/cordis' {
316
+ interface Context {
317
+ 'po/session-operations': SessionOperations;
318
+ }
319
+ }
320
+ //#endregion
321
+ //#region src/services/sessionsNamespace/index.d.ts
322
+ export declare function createSessionsNamespace(options: SessionsNamespaceOptions): PoCodemodeNamespace;
323
+ //#endregion
324
+ //#region src/services/sessionsNamespace/nodeOperations.d.ts
325
+ /**
326
+ * Sends one message, queued unless urgent. A queued message waits for the end of the recipient's run and
327
+ * arrives folded into one digest; an urgent one joins the running turn. Both spend the sender's budget.
328
+ */
329
+ export declare function sendSessionMessage(request: SessionMessageRequest): Promise<{
330
+ deliveryId: string;
331
+ lane: 'queue' | 'urgent';
332
+ }>;
333
+ //#endregion
334
+ //#region src/services/sessionCoordination/type.d.ts
335
+ /** The persona every coordinator of one person shares. */
336
+ interface CoordinatorSettings {
337
+ readonly profile: string;
338
+ readonly model?: string;
339
+ readonly name: string;
340
+ }
341
+ interface CoordinatorResult {
342
+ readonly sessionId: string;
343
+ readonly created: boolean;
344
+ }
345
+ type CoordinatorAddResult = CoordinatorResult | {
346
+ readonly profileRequired: true;
347
+ readonly error: string;
348
+ };
349
+ interface CoordinatorWorkspace {
350
+ readonly id: string;
351
+ readonly kind?: 'session';
352
+ readonly root: string;
353
+ readonly name?: string;
354
+ readonly available?: boolean;
355
+ readonly sandbox?: string;
356
+ }
357
+ interface CoordinatorLiveSession {
358
+ readonly id: string;
359
+ readonly name?: string;
360
+ readonly workspaceId?: string;
361
+ readonly sessionProvenance?: string;
362
+ readonly parentSessionId?: string;
363
+ readonly createdAt: string;
364
+ readonly profile?: {
365
+ readonly name: string;
366
+ };
367
+ }
368
+ interface CoordinatorCreateRequest {
369
+ readonly name: string;
370
+ readonly sessionProvenance?: string;
371
+ readonly selection?: PoHubSessionSelection;
372
+ readonly model?: string;
373
+ }
374
+ interface CoordinatorServiceOptions {
375
+ liveSessions(): readonly CoordinatorLiveSession[];
376
+ /** Every open-session record this host keeps, live or dormant. */
377
+ records(): readonly OpenSessionRecord[];
378
+ saveRecord(record: OpenSessionRecord): boolean;
379
+ workspaces(): readonly CoordinatorWorkspace[];
380
+ revive(record: OpenSessionRecord): Promise<void>;
381
+ /** A session in the general (`kind: 'session'`) workspace, in a folder the host allocates. */
382
+ createGeneral(request: CoordinatorCreateRequest): Promise<{
383
+ sessionId: string;
384
+ }>;
385
+ createInWorkspace(workspace: CoordinatorWorkspace, request: CoordinatorCreateRequest): Promise<{
386
+ sessionId: string;
387
+ }>;
388
+ prompt(sessionId: string, text: string): Promise<unknown>;
389
+ /** The profile catalog's default under this root, or the personal one when no root is given. */
390
+ defaultProfile(root?: string): string | undefined;
391
+ /** Validates a request-local choice through the host profile resolver before creation. */
392
+ validateProfile?(profile: string, workspace?: CoordinatorWorkspace): Promise<void>;
393
+ /** Closes a live session and reopens it under the same id with this provenance, and this profile when given. */
394
+ reopen(sessionId: string, role: {
395
+ sessionProvenance?: string;
396
+ profile?: string;
397
+ }): Promise<void>;
398
+ now?(): number;
399
+ notice(message: string): void;
400
+ }
401
+ interface CoordinatorService {
402
+ /**
403
+ * Finds the oldest live or dormant coordinator of the target (`'home'` or a workspace id), revives it, or creates
404
+ * one. Single-flight per target.
405
+ */
406
+ ensureCoordinator(target: string, settings: CoordinatorSettings): Promise<CoordinatorResult>;
407
+ /** Ensures the home coordinator only; workspaces get their own coordinator through an explicit add. */
408
+ ensureHome(settings: CoordinatorSettings): Promise<CoordinatorResult>;
409
+ /** Starts a briefed session in the caller's scope, or an uncoordinated workspace targeted by the home coordinator. */
410
+ startSession(coordinatorSessionId: string, request: {
411
+ name: string;
412
+ brief: string;
413
+ workspaceId?: string;
414
+ }): Promise<{
415
+ sessionId: string;
416
+ promptError?: string;
417
+ goal?: boolean;
418
+ }>;
419
+ /**
420
+ * The person's explicit add: the home coordinator when no workspace is named, else that workspace's. The persona
421
+ * is the explicit profile when supplied, else the home coordinator's when recorded, else the default profile.
422
+ */
423
+ add(workspaceId?: string, profile?: string): Promise<CoordinatorAddResult>;
424
+ /**
425
+ * Promotes a session to its workspace's coordinator, demoting any other one, or demotes it. A live session
426
+ * restarts to take on its role; a dormant one being demoted only has its record rewritten.
427
+ */
428
+ setRole(sessionId: string, coordinator: boolean): Promise<void>;
429
+ }
430
+ //#endregion
431
+ //#region src/services/sessionCoordination/policy.d.ts
432
+ /** ponytail: a fixed per-coordinator budget; add configuration only when another number is needed. */
433
+ export declare const COORDINATOR_STARTS_PER_HOUR = 5;
434
+ export declare const COORDINATOR_START_WINDOW_MS: number;
435
+ export declare function assertCoordinatorStartBudget(count: number): void;
436
+ export declare function assertCoordinatorStartScope(callerWorkspaceId: string | undefined, homeWorkspaceId: string | undefined, workspace: {
437
+ id: string;
438
+ kind?: 'session';
439
+ available?: boolean;
440
+ sandbox?: string;
441
+ } | undefined, hasCoordinator: boolean): void;
442
+ /** Communication is symmetric. A message grant never grants lifecycle authority. */
443
+ export declare const canSessionsCommunicate: PoSessionCommunicationPolicy;
444
+ /**
445
+ * The hierarchy only, never a group, a mention, shared files or a parent link: `target` coordinates
446
+ * `source` when it is the coordinator of `source`'s workspace, Home standing in for a workspace
447
+ * without one, or Home over a workspace coordinator.
448
+ */
449
+ export declare const sessionCoordinates: PoSessionCoordinationPolicy;
450
+ //#endregion
451
+ //#region src/services/sessionCoordination/index.d.ts
452
+ /** Kebab-case from the workspace name, else its folder name. */
453
+ export declare function workspaceSlug(workspace: {
454
+ readonly name?: string;
455
+ readonly root: string;
456
+ }): string;
457
+ export declare function createCoordinatorService(options: CoordinatorServiceOptions): CoordinatorService;
458
+ //#endregion
48
459
  //#region src/services/peerTransport/config.d.ts
49
460
  declare const PEER_CONFIG_VERSION = 1;
50
461
  interface SessionPeer {
51
462
  readonly hostId: string;
52
463
  readonly url: string;
53
464
  readonly secret: string;
465
+ readonly linkGeneration?: string;
466
+ readonly urlGeneration?: number;
54
467
  /** Explicit remote durable-message targets. Empty means no delivery grant. */
55
468
  readonly allowedSessionIds: readonly string[];
56
469
  /** Explicit remote Voice media targets. Empty means no media grant. */
@@ -60,6 +473,14 @@ interface SessionPeerConfig {
60
473
  readonly version: typeof PEER_CONFIG_VERSION;
61
474
  readonly hostId: string;
62
475
  readonly peers: readonly SessionPeer[];
476
+ readonly self?: {
477
+ readonly urlGeneration: number;
478
+ readonly announcedUrl?: string;
479
+ };
480
+ readonly revoked?: readonly {
481
+ readonly hostId: string;
482
+ readonly linkGeneration: string;
483
+ }[];
63
484
  }
64
485
  interface SessionPeerReplayGuard {
65
486
  admit(request: Request, now?: number): boolean;
@@ -69,7 +490,7 @@ interface SessionPeerReplayGuardAsync {
69
490
  admit(request: Request, now?: number): Promise<boolean>;
70
491
  close(): Promise<void>;
71
492
  }
72
- export declare function sessionPeerConfigPath(homeDirectory: string): string;
493
+ export declare function sessionPeerConfigPath(homeDirectory: string, environment?: Readonly<Record<string, string | undefined>>): string;
73
494
  //#endregion
74
495
  //#region src/services/peerTransport/sync.d.ts
75
496
  /**
@@ -77,13 +498,13 @@ export declare function sessionPeerConfigPath(homeDirectory: string): string;
77
498
  *
78
499
  * @deprecated Node-only sync shim; use readSessionPeerConfigAsync. Removed in M2.
79
500
  */
80
- export declare function readSessionPeerConfig(homeDirectory: string): SessionPeerConfig | undefined;
501
+ export declare function readSessionPeerConfig(homeDirectory: string, environment?: Readonly<Record<string, string | undefined>>): SessionPeerConfig | undefined;
81
502
  /**
82
503
  * Persists accepted peer signatures so a valid request cannot be replayed within its clock-skew window.
83
504
  *
84
505
  * @deprecated Node-only sync shim; use createPeerReplayGuardAsync. Removed in M2.
85
506
  */
86
- export declare function createPeerReplayGuard(homeDirectory: string): SessionPeerReplayGuard;
507
+ export declare function createPeerReplayGuard(homeDirectory: string, environment?: Readonly<Record<string, string | undefined>>): SessionPeerReplayGuard;
87
508
  //#endregion
88
509
  //#region src/services/peerTransport/index.d.ts
89
510
  /** chord IO context, reached through po-core so this package needs no direct dependency. */
@@ -99,7 +520,7 @@ interface SessionPeerEnvelope {
99
520
  readonly payload: unknown;
100
521
  }
101
522
  /** Reads operator-provisioned peers. Invalid or unreadable config fails closed. */
102
- export declare function readSessionPeerConfigAsync(fs: FileSystem, homeDirectory: string, context: IoContext): Promise<SessionPeerConfig | undefined>;
523
+ export declare function readSessionPeerConfigAsync(fs: FileSystem, homeDirectory: string, context: IoContext, environment?: Readonly<Record<string, string | undefined>>): Promise<SessionPeerConfig | undefined>;
103
524
  /** `peer/<host-id>/<session-id>` is the only remote target spelling. */
104
525
  export declare function parseRemoteSessionReference(value: string): RemoteSessionReference | undefined;
105
526
  export declare function peerSessionReference(hostId: string, sessionId: string): string;
@@ -114,7 +535,10 @@ export declare function verifyPeerRequest(config: SessionPeerConfig, request: Re
114
535
  export declare function createPeerCommunication(options: {
115
536
  readonly local: PoSessionCommunicationEndpoint;
116
537
  /** Read once by the caller, for example with readSessionPeerConfigAsync. */
117
- readonly config: SessionPeerConfig | undefined;
538
+ readonly config: SessionPeerConfig | undefined | (() => SessionPeerConfig | undefined);
539
+ readonly onError?: (error: unknown) => void;
540
+ /** Rechecked after the asynchronous handshake, immediately before transport send. */
541
+ readonly canPublish?: (target: string, type: string, payload: unknown) => boolean;
118
542
  readonly fetch?: typeof fetch;
119
543
  }): PoSessionCommunicationEndpoint;
120
544
  //#endregion
@@ -179,81 +603,6 @@ export declare function createSessionDirectory(options: SessionDirectoryOptions)
179
603
  /** Opens a revisioned SQLite registry for communication-only group membership. */
180
604
  export declare function createSessionGroupStore(options: SessionGroupStoreOptions): Promise<SessionGroupStore>;
181
605
  //#endregion
182
- //#region src/services/sessionDelivery/type.d.ts
183
- export declare const PO_SESSION_DELIVERY_SERVICE = "po/session-delivery";
184
- type PoSessionDeliveryInboxState = 'accepted' | 'admitting' | 'admitted' | 'recovery_required';
185
- type PoSessionDeliveryMode = 'prompt' | 'steer' | 'followUp';
186
- interface PoSessionDeliveryMetadata extends Readonly<Record<string, string | undefined>> {
187
- readonly worktreeId?: string;
188
- readonly fromRole?: string;
189
- }
190
- interface PoSessionDeliveryRequest {
191
- readonly deliveryId?: string;
192
- readonly recipientKey: string;
193
- readonly kind: string;
194
- readonly prompt: string;
195
- readonly delivery?: PoSessionDeliveryMode;
196
- readonly metadata?: PoSessionDeliveryMetadata;
197
- }
198
- interface PoSessionInboxQuery {
199
- readonly kind?: string;
200
- readonly metadata?: PoSessionDeliveryMetadata;
201
- readonly state?: PoSessionDeliveryInboxState;
202
- readonly consumed?: boolean;
203
- }
204
- interface PoSessionInboxEntry {
205
- readonly deliveryId: string;
206
- readonly senderKey: string;
207
- readonly recipientKey: string;
208
- readonly kind: string;
209
- readonly prompt: string;
210
- readonly delivery: PoSessionDeliveryMode;
211
- readonly metadata: PoSessionDeliveryMetadata;
212
- readonly state: PoSessionDeliveryInboxState;
213
- readonly consumed: boolean;
214
- }
215
- interface PoSessionOutboxEntry {
216
- readonly deliveryId: string;
217
- readonly recipientKey: string;
218
- readonly kind: string;
219
- readonly metadata: PoSessionDeliveryMetadata;
220
- readonly state: 'queued' | 'acknowledged';
221
- readonly recipientState?: PoSessionDeliveryInboxState;
222
- }
223
- interface PoSessionDeliveryService {
224
- readonly recipientKey: string;
225
- deliver(request: PoSessionDeliveryRequest): Promise<{
226
- deliveryId: string;
227
- }>;
228
- waitForAdmission(deliveryId: string, timeoutMs?: number): Promise<PoSessionDeliveryInboxState | undefined>;
229
- inbox(query?: PoSessionInboxQuery): Promise<readonly PoSessionInboxEntry[]>;
230
- /** Optional host-routed peer envelope admission. Local-only consumers need no transport receiver. */
231
- receive?(senderKey: string, kind: string, payload: unknown): Promise<PoSessionDeliveryInboxState | undefined>;
232
- consume(deliveryId: string): Promise<boolean>;
233
- outbox(deliveryId: string): Promise<PoSessionOutboxEntry | undefined>;
234
- close(): Promise<void>;
235
- }
236
- interface SessionDeliveryServiceOptions {
237
- /**
238
- * Taken over by the service and closed by `close()`. On the edge every open returns the Durable
239
- * Object's one shared database, so the service's table names must stay unique across that database.
240
- */
241
- readonly database: SessionSqliteDatabase;
242
- readonly recipientKey: string;
243
- readonly communication: PoSessionCommunicationEndpoint;
244
- /** Host-owned relationship check applied before sends, retries, and recipient acceptance. */
245
- readonly authorizePeer: (peerKey: string, metadata?: PoSessionDeliveryMetadata) => boolean | Promise<boolean>;
246
- /** `requestId` is the delivery id; the recipient runtime dedupes on it, so a restart may replay an admission. */
247
- readonly admitPrompt: (prompt: string, delivery: PoSessionDeliveryMode | undefined, requestId: string) => Promise<void>;
248
- }
249
- declare module '@deepseek-ai/cordis' {
250
- interface Context {
251
- 'po/session-delivery': PoSessionDeliveryService;
252
- }
253
- }
254
- /** Reads the currently active provider each time, without retaining a stale binding. */
255
- export declare function readPoSessionDelivery(context: Context): PoSessionDeliveryService | undefined;
256
- //#endregion
257
606
  //#region src/services/sessionDelivery/index.d.ts
258
607
  /** Opens and starts one durable delivery endpoint. */
259
608
  export declare function createSessionDeliveryService(options: SessionDeliveryServiceOptions): Promise<PoSessionDeliveryService>;
@@ -329,5 +678,173 @@ export declare function createSessionIntercom(options: SessionIntercomOptions):
329
678
  /** Builds the dynamic delivery check used before every send, retry, and recipient acceptance. */
330
679
  export declare function createSessionGroupDeliveryAuthorizer(options: SessionGroupDeliveryAuthorizationOptions): (peerKey: string, metadata: PoSessionDeliveryMetadata | undefined) => Promise<boolean>;
331
680
  //#endregion
332
- export type { DiscoveredSession, PoSessionDeliveryInboxState, PoSessionDeliveryMetadata, PoSessionDeliveryMode, PoSessionDeliveryRequest, PoSessionDeliveryService, PoSessionInboxEntry, PoSessionInboxQuery, PoSessionOutboxEntry, RemoteSessionReference, SessionActivityState, SessionCommunicationGroup, SessionDeliveryServiceOptions, SessionDirectory, SessionDirectoryOptions, SessionDiscoveryGrant, SessionGroupDeliveryAuthorizationOptions, SessionGroupMutation, SessionGroupStore, SessionGroupStoreOptions, SessionHostReachability, SessionIntercom, SessionIntercomMessage, SessionIntercomOptions, SessionIntercomSendRequest, SessionPeer, SessionPeerConfig, SessionPeerEnvelope, SessionPeerReplayGuard, SessionPeerReplayGuardAsync, SessionPresenceFacts, SessionPresenceObservation, SessionReportStatus, SessionRuntimeState, SessionVoiceReadiness };
681
+ //#region src/services/sessionPeers/type.d.ts
682
+ interface SessionPeers {
683
+ current(): SessionPeerConfig | undefined;
684
+ identity(): Promise<SessionPeerConfig>;
685
+ link(peer: SessionPeer): Promise<void>;
686
+ unlink(hostId: string, linkGeneration?: string): Promise<void>;
687
+ rebind(hostId: string, url: string, urlGeneration: number): Promise<boolean>;
688
+ announce(url: string): Promise<SessionPeerConfig>;
689
+ subscribe(listener: () => void): () => void;
690
+ }
691
+ //#endregion
692
+ //#region src/services/sessionPeers/index.d.ts
693
+ export declare const PO_SESSION_PEERS_SERVICE = "po/session-peers";
694
+ export declare const PO_SESSION_PEERS_CONTRACT: import("@agimon-ai/po-core/serverPlugin").PoServiceContract<SessionPeers>;
695
+ declare module '@deepseek-ai/cordis' {
696
+ interface Context {
697
+ 'po/session-peers': SessionPeers;
698
+ }
699
+ }
700
+ /** Link URLs are routing hints, never identity or authorization. */
701
+ export declare function peerOrigin(value: string): string;
702
+ /** One host-owned snapshot, updated only after its private atomic write succeeds. */
703
+ export declare function createSessionPeers(options: {
704
+ fs: FileSystem;
705
+ homeDirectory: string;
706
+ environment?: Readonly<Record<string, string | undefined>>;
707
+ }): Promise<SessionPeers>;
708
+ export declare function requireSessionPeers(context: Context): SessionPeers;
709
+ //#endregion
710
+ //#region src/services/sealedPeerChannel/index.d.ts
711
+ /** One fresh nodeSealedChannel epoch per exchange. Never persist or reuse counters with a new key. */
712
+ declare function createSealedPeerChannels(): {
713
+ handshake(peer: SessionPeer, publicKey: string, confirmation: unknown, now?: number): {
714
+ epochId: string;
715
+ publicKey: string;
716
+ echo: string;
717
+ confirmation: SealedEnvelope;
718
+ };
719
+ take(peer: SessionPeer, epochId: string, now?: number): SealedChannel | undefined;
720
+ clear(): void;
721
+ };
722
+ //#endregion
723
+ //#region src/services/sessionGroupBridge/type.d.ts
724
+ interface SessionGroupAdvert {
725
+ readonly reference: string;
726
+ readonly name: string;
727
+ readonly groups: readonly string[];
728
+ }
729
+ interface SessionGroupBridge {
730
+ readonly groups: SessionGroupStore;
731
+ updateLocal(sessionId: string, name: string, groups: readonly string[]): Promise<void>;
732
+ removeLocal(sessionId: string): Promise<void>;
733
+ merge(hostId: string, value: unknown): Promise<boolean>;
734
+ advert(): readonly SessionGroupAdvert[];
735
+ peersFor(sessionId: string): readonly PoSessionPeerDescription[];
736
+ metadataFor(sessionId: string, target: string): PoSessionDeliveryMetadata | undefined;
737
+ subscribe(listener: () => void): () => void;
738
+ refresh(): Promise<void>;
739
+ close(): Promise<void>;
740
+ }
741
+ //#endregion
742
+ //#region src/services/sessionGroupBridge/index.d.ts
743
+ export declare const PO_SESSION_GROUP_BRIDGE_SERVICE = "po/session-group-bridge";
744
+ declare module '@deepseek-ai/cordis' {
745
+ interface Context {
746
+ 'po/session-group-bridge': SessionGroupBridge;
747
+ }
748
+ }
749
+ export declare const namedSessionGroupId: (name: string) => string;
750
+ export declare function readSessionGroupBridge(context: Context): SessionGroupBridge | undefined;
751
+ //#endregion
752
+ //#region src/services/peerLink/type.d.ts
753
+ interface PeerLinkInvite {
754
+ readonly inviteId: string;
755
+ readonly hostId: string;
756
+ readonly url: string;
757
+ readonly ecdhPublicKey: string;
758
+ readonly expiresAt: number;
759
+ }
760
+ interface PeerLinkControl {
761
+ /** Account links never inherit session invitation permissions. */
762
+ readonly network?: RosterPeerLinks;
763
+ prepare(): Promise<PeerLinkInvite>;
764
+ accept(invite: PeerLinkInvite): Promise<void>;
765
+ unlink(hostId: string): Promise<void>;
766
+ hint(hostId: string, url: string): Promise<boolean>;
767
+ announce(): Promise<void>;
768
+ /** Invites every same-owner computer on the account roster that is not linked yet. */
769
+ auto(): Promise<void>;
770
+ control(request: Request, body: string): Promise<Response>;
771
+ close(): void;
772
+ }
773
+ interface RosterLinkHost {
774
+ hostId: string;
775
+ publicKey: string;
776
+ }
777
+ interface RosterLinkSnapshot {
778
+ networkId: string;
779
+ epoch: number;
780
+ hosts: readonly RosterLinkHost[];
781
+ }
782
+ interface RosterLinkProof {
783
+ networkId: string;
784
+ epoch: number;
785
+ hostId: string;
786
+ destinationHostId: string;
787
+ publicKey: string;
788
+ challenge: string;
789
+ /** Response binds the requesting ephemeral key as well as its challenge. */
790
+ echo: string;
791
+ issuedAt: number;
792
+ expiresAt: number;
793
+ }
794
+ type SignedRosterLinkProof = import('@agimon-ai/po-web-security').SignedFederationEnvelope<RosterLinkProof, 'po/host-request/v1'>;
795
+ interface RosterPeerChannel {
796
+ /** Rechecks the live roster on every use; never falls back to plaintext. */
797
+ seal(plaintext: Uint8Array): import('@agimon-ai/po-web-security/nodeSealedChannel').SealResult;
798
+ open(envelope: unknown): Promise<Uint8Array | undefined>;
799
+ }
800
+ interface RosterPeerLinkPorts {
801
+ hostId: string;
802
+ roster(): RosterLinkSnapshot;
803
+ now(): number;
804
+ /** Use signEnvelope with this host's key. */
805
+ sign(payload: RosterLinkProof): SignedRosterLinkProof;
806
+ /** Verify token issuer, audience, current membership and proof-bound caller host. */
807
+ authorize(token: string, hostId: string, networkId: string): Promise<boolean>;
808
+ /** Destination C3/C4 verification, including durable nonces. No session-peer shortcut. */
809
+ verifyRequest(plaintext: Uint8Array, hostId: string): Promise<boolean>;
810
+ }
811
+ interface RosterPeerLinks {
812
+ connect(hostId: string, token: string, exchange: (proof: SignedRosterLinkProof, token: string) => Promise<SignedRosterLinkProof>): Promise<RosterPeerChannel>;
813
+ accept(proof: SignedRosterLinkProof, token: string): Promise<{
814
+ proof: SignedRosterLinkProof;
815
+ channel: RosterPeerChannel;
816
+ }>;
817
+ }
818
+ export declare const PO_ROSTER_PEER_SERVICE = "po/roster-peer";
819
+ export declare const PO_ROSTER_PEER_CONTRACT: import("@agimon-ai/po-core/serverPlugin").PoServiceContract<RosterPeerLinks>;
820
+ declare module '@deepseek-ai/cordis' {
821
+ interface Context {
822
+ 'po/roster-peer': RosterPeerLinks;
823
+ }
824
+ }
825
+ //#endregion
826
+ //#region src/services/peerLink/index.d.ts
827
+ /** Public-key-only broker. Link secrets never pass through the paired device. */
828
+ export declare function createPeerLink(options: {
829
+ peers: SessionPeers;
830
+ network?: RosterPeerLinks;
831
+ /** Same-owner computers on a fresh account roster. Absent while this computer is not in an account. */
832
+ hosts?: () => Pick<HostRequests, 'hosts' | 'fetch' | 'verify'> | undefined;
833
+ groups?: () => SessionGroupBridge | undefined;
834
+ origin(): string | undefined;
835
+ replay: SessionPeerReplayGuardAsync;
836
+ channels: ReturnType<typeof createSealedPeerChannels>;
837
+ fetch?: typeof fetch;
838
+ now?: () => number;
839
+ }): PeerLinkControl;
840
+ //#endregion
841
+ //#region src/services/peerLink/roster.d.ts
842
+ /** Account links are separate from legacy session-peer secrets and permissions.
843
+ * A fresh signed ephemeral exchange uses the host key in the verified C6 roster.
844
+ * Coordinator availability is irrelevant. Roster removal or rotation fences all
845
+ * existing channel uses; applications must sync and persist C6 before exposing it.
846
+ */
847
+ export declare function createRosterPeerLink(ports: RosterPeerLinkPorts): RosterPeerLinks;
848
+ //#endregion
849
+ export type { CoordinatorAddResult, CoordinatorCreateRequest, CoordinatorResult, CoordinatorService, CoordinatorServiceOptions, CoordinatorSessionsOptions, CoordinatorSettings, DiscoveredSession, PeerLinkControl, PeerLinkInvite, PoSessionDeliveryInboxState, PoSessionDeliveryMetadata, PoSessionDeliveryMode, PoSessionDeliveryRequest, PoSessionDeliveryService, PoSessionInboxEntry, PoSessionInboxQuery, PoSessionOutboxEntry, PoSessionSentEntry, RemoteSessionReference, RosterLinkHost, RosterLinkProof, RosterLinkSnapshot, RosterPeerChannel, RosterPeerLinkPorts, RosterPeerLinks, SessionActivityState, SessionCommunicationGroup, SessionDeliveryServiceOptions, SessionDirectory, SessionDirectoryOptions, SessionDiscoveryGrant, SessionGroupBridge, SessionGroupDeliveryAuthorizationOptions, SessionGroupMutation, SessionGroupStore, SessionGroupStoreOptions, SessionHostReachability, SessionIntercom, SessionIntercomMessage, SessionIntercomOptions, SessionIntercomSendRequest, SessionMessageRequest, SessionOperations, SessionPeer, SessionPeerConfig, SessionPeerEnvelope, SessionPeerReplayGuard, SessionPeerReplayGuardAsync, SessionPeers, SessionPresenceFacts, SessionPresenceObservation, SessionReportStatus, SessionRuntimeState, SessionVoiceReadiness, SessionsNamespaceOptions, SignedRosterLinkProof, StartSessionInput, StartSessionResult };
333
850
  //# sourceMappingURL=index.d.mts.map