@jmfederico/pi-web 1.202607.1 → 1.202607.2

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 (56) hide show
  1. package/README.md +8 -8
  2. package/dist/cli.js +17 -5
  3. package/dist/cli.js.map +1 -1
  4. package/dist/client/assets/{CodeViewer-uASb28Y1.js → CodeViewer-B4M13447.js} +1 -1
  5. package/dist/client/assets/{TerminalPanel-DfTmykFw.js → TerminalPanel-Bmvj-Ecn.js} +1 -1
  6. package/dist/client/assets/{UnifiedDiffViewer-laQN1x7P.js → UnifiedDiffViewer-C0hygwRo.js} +1 -1
  7. package/dist/client/assets/index-TvPsRyS1.js +3545 -0
  8. package/dist/client/index.html +1 -1
  9. package/dist/config.js +13 -0
  10. package/dist/config.js.map +1 -1
  11. package/dist/server/diagnostics/nodePtyNativeModule.js +36 -0
  12. package/dist/server/diagnostics/nodePtyNativeModule.js.map +1 -0
  13. package/dist/server/git/gitService.js +176 -5
  14. package/dist/server/git/gitService.js.map +1 -1
  15. package/dist/server/piWebStatus.js +6 -3
  16. package/dist/server/piWebStatus.js.map +1 -1
  17. package/dist/server/realtime/sessionEventHub.js +4 -0
  18. package/dist/server/realtime/sessionEventHub.js.map +1 -1
  19. package/dist/server/sessiond.js +47 -7
  20. package/dist/server/sessiond.js.map +1 -1
  21. package/dist/server/sessions/authService.js +58 -7
  22. package/dist/server/sessions/authService.js.map +1 -1
  23. package/dist/server/sessions/globalProviderPolicy.js +98 -0
  24. package/dist/server/sessions/globalProviderPolicy.js.map +1 -0
  25. package/dist/server/sessions/modelCatalogRefresher.js +184 -0
  26. package/dist/server/sessions/modelCatalogRefresher.js.map +1 -0
  27. package/dist/server/sessions/piSessionService.js +736 -100
  28. package/dist/server/sessions/piSessionService.js.map +1 -1
  29. package/dist/server/sessions/plainTextTheme.js +112 -0
  30. package/dist/server/sessions/plainTextTheme.js.map +1 -0
  31. package/dist/server/sessions/sessionCommandService.js +68 -9
  32. package/dist/server/sessions/sessionCommandService.js.map +1 -1
  33. package/dist/server/sessions/sessionNotificationStore.js +484 -0
  34. package/dist/server/sessions/sessionNotificationStore.js.map +1 -0
  35. package/dist/server/sessions/sessionRoutes.js +175 -0
  36. package/dist/server/sessions/sessionRoutes.js.map +1 -1
  37. package/dist/server/sessions/sessionTreeProjection.js +250 -0
  38. package/dist/server/sessions/sessionTreeProjection.js.map +1 -0
  39. package/dist/server/sessions/sessionUnreadStore.js +520 -0
  40. package/dist/server/sessions/sessionUnreadStore.js.map +1 -0
  41. package/dist/server/sessions/spawnSessionTool.js +2 -2
  42. package/dist/server/sessions/spawnSessionTool.js.map +1 -1
  43. package/dist/server/sessions/spawnSubsessionTool.js +10 -12
  44. package/dist/server/sessions/spawnSubsessionTool.js.map +1 -1
  45. package/dist/shared/apiTypes.d.ts +159 -2
  46. package/dist/shared/apiTypes.js +10 -0
  47. package/dist/shared/apiTypes.js.map +1 -1
  48. package/dist/shared/capabilities.js +6 -0
  49. package/dist/shared/capabilities.js.map +1 -1
  50. package/dist/shared/federatedRoutes.js +8 -0
  51. package/dist/shared/federatedRoutes.js.map +1 -1
  52. package/docs/config.md +32 -4
  53. package/docs/plugins.md +10 -6
  54. package/install.sh +1 -1
  55. package/package.json +8 -7
  56. package/dist/client/assets/index-Dhapi0oR.js +0 -3093
@@ -0,0 +1,520 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
4
+ import { piWebDataDir } from "../../config.js";
5
+ import { SESSION_UNREAD_CATALOG_ID_MAX_LENGTH, SESSION_UNREAD_COMPLETED_AT_MAX_LENGTH, SESSION_UNREAD_CWD_MAX_LENGTH, SESSION_UNREAD_LIMIT, SESSION_UNREAD_SESSION_ID_MAX_LENGTH, } from "../../shared/apiTypes.js";
6
+ const SESSION_UNREAD_STATE_VERSION = 1;
7
+ const SESSION_UNREAD_FILE_MODE = 0o600;
8
+ /**
9
+ * Daemon-owned unread completion catalog.
10
+ *
11
+ * Completion orders are global and never reused within a catalog epoch. An
12
+ * acknowledgement must carry both the epoch and the observed completion order,
13
+ * so neither an old completion nor a client from reset state can clear newer
14
+ * work.
15
+ */
16
+ export class SessionUnreadStore {
17
+ constructor(options = {}) {
18
+ this.unreadByIdentity = new Map();
19
+ this.activeByIdentity = new Map();
20
+ this.excludedByIdentity = new Map();
21
+ this.catalogRevision = 0;
22
+ this.nextCompletionOrder = 0;
23
+ this.persistenceGeneration = 0;
24
+ this.durablePersistenceGeneration = 0;
25
+ this.now = options.now ?? (() => new Date());
26
+ this.persistence = options.persistence;
27
+ this.createCatalogId = options.createCatalogId ?? randomUUID;
28
+ this.onPersistenceError = options.onPersistenceError ?? (() => undefined);
29
+ this.loaded = this.persistence === undefined;
30
+ // A persisted store receives its epoch from disk or creates one during
31
+ // load; synchronous in-memory stores are ready immediately.
32
+ this.catalogId = this.loaded ? this.freshCatalogId() : "";
33
+ }
34
+ load() {
35
+ if (this.loaded)
36
+ return Promise.resolve();
37
+ if (this.loadPromise !== undefined)
38
+ return this.loadPromise;
39
+ const loadPromise = this.loadPersistedState();
40
+ this.loadPromise = loadPromise;
41
+ return loadPromise;
42
+ }
43
+ /** Current in-memory state. Transport boundaries should use `durableCatalogSnapshot`. */
44
+ catalogSnapshot() {
45
+ this.requireLoaded();
46
+ return {
47
+ catalogId: this.catalogId,
48
+ catalogRevision: this.catalogRevision,
49
+ sessions: [...this.unreadByIdentity.values()]
50
+ .sort((left, right) => right.completionOrder - left.completionOrder)
51
+ .map((summary) => ({ ...summary })),
52
+ };
53
+ }
54
+ observeActivityState(sessionId, cwd, active) {
55
+ this.requireLoaded();
56
+ const identity = requireIdentity(sessionId, cwd);
57
+ const key = sessionIdentityKey(identity);
58
+ if (this.excludedByIdentity.has(key)) {
59
+ this.activeByIdentity.delete(key);
60
+ return [];
61
+ }
62
+ if (active) {
63
+ this.activeByIdentity.set(key, identity);
64
+ return [];
65
+ }
66
+ if (!this.activeByIdentity.has(key))
67
+ return [];
68
+ const completionOrder = incrementSafe(this.nextCompletionOrder, "Session unread completion order exhausted");
69
+ const willExceedLimit = !this.unreadByIdentity.has(key) && this.unreadByIdentity.size >= SESSION_UNREAD_LIMIT;
70
+ this.assertRevisionCapacity(willExceedLimit ? 2 : 1);
71
+ const completedAt = this.now().toISOString();
72
+ this.activeByIdentity.delete(key);
73
+ this.nextCompletionOrder = completionOrder;
74
+ const summary = {
75
+ sessionId,
76
+ cwd,
77
+ completionOrder,
78
+ completedAt,
79
+ };
80
+ // Reinsert existing identities so map order remains completion order.
81
+ this.unreadByIdentity.delete(key);
82
+ this.unreadByIdentity.set(key, summary);
83
+ const mutations = [this.mutation(identity, summary), ...this.trimToLimit()];
84
+ this.schedulePersist();
85
+ return mutations;
86
+ }
87
+ /** Clear only the transient active latch for a runtime that is closing or rebinding. */
88
+ forgetActivity(sessionId, cwd) {
89
+ this.requireLoaded();
90
+ const identity = requireIdentity(sessionId, cwd);
91
+ this.activeByIdentity.delete(sessionIdentityKey(identity));
92
+ }
93
+ /**
94
+ * Suppress unread tracking until this identity is explicitly forgotten and
95
+ * remove state recorded before it was verified as a tracked sub-session.
96
+ */
97
+ excludeSession(sessionId, cwd) {
98
+ this.requireLoaded();
99
+ const identity = requireIdentity(sessionId, cwd);
100
+ const key = sessionIdentityKey(identity);
101
+ const current = this.unreadByIdentity.get(key);
102
+ this.assertRevisionCapacity(current === undefined ? 0 : 1);
103
+ this.excludedByIdentity.set(key, identity);
104
+ this.activeByIdentity.delete(key);
105
+ if (current === undefined)
106
+ return [];
107
+ this.unreadByIdentity.delete(key);
108
+ const mutations = [this.mutation(identity, null)];
109
+ this.schedulePersist();
110
+ return mutations;
111
+ }
112
+ acknowledge(sessionId, request) {
113
+ this.requireLoaded();
114
+ const identity = requireIdentity(sessionId, request.cwd);
115
+ requireCatalogId(request.catalogId);
116
+ requirePositiveSafeInteger(request.throughCompletionOrder, "throughCompletionOrder");
117
+ if (request.catalogId !== this.catalogId)
118
+ return { mutations: [] };
119
+ const key = sessionIdentityKey(identity);
120
+ const current = this.unreadByIdentity.get(key);
121
+ if (current === undefined || current.completionOrder > request.throughCompletionOrder) {
122
+ return { mutations: [] };
123
+ }
124
+ this.assertRevisionCapacity(1);
125
+ this.unreadByIdentity.delete(key);
126
+ const mutations = [this.mutation(identity, null)];
127
+ this.schedulePersist();
128
+ return { mutations };
129
+ }
130
+ /** Remove durable unread and all transient lifecycle state for one identity. */
131
+ forgetSession(sessionId, cwd) {
132
+ this.requireLoaded();
133
+ const identity = requireIdentity(sessionId, cwd);
134
+ const key = sessionIdentityKey(identity);
135
+ const current = this.unreadByIdentity.get(key);
136
+ this.assertRevisionCapacity(current === undefined ? 0 : 1);
137
+ this.activeByIdentity.delete(key);
138
+ this.excludedByIdentity.delete(key);
139
+ if (current === undefined)
140
+ return [];
141
+ this.unreadByIdentity.delete(key);
142
+ const mutations = [this.mutation(identity, null)];
143
+ this.schedulePersist();
144
+ return mutations;
145
+ }
146
+ reconcileCwd(cwd, sessionIds) {
147
+ this.requireLoaded();
148
+ const boundedCwd = requireBoundedNonEmptyString(cwd, "cwd", SESSION_UNREAD_CWD_MAX_LENGTH);
149
+ const retained = new Set(sessionIds);
150
+ const removed = [...this.unreadByIdentity.entries()]
151
+ .filter(([, summary]) => summary.cwd === boundedCwd && !retained.has(summary.sessionId));
152
+ this.assertRevisionCapacity(removed.length);
153
+ for (const [key, identity] of this.activeByIdentity) {
154
+ if (identity.cwd === boundedCwd && !retained.has(identity.sessionId))
155
+ this.activeByIdentity.delete(key);
156
+ }
157
+ for (const [key, identity] of this.excludedByIdentity) {
158
+ if (identity.cwd === boundedCwd && !retained.has(identity.sessionId))
159
+ this.excludedByIdentity.delete(key);
160
+ }
161
+ const mutations = [];
162
+ for (const [key, summary] of removed) {
163
+ this.unreadByIdentity.delete(key);
164
+ mutations.push(this.mutation(summary, null));
165
+ }
166
+ if (mutations.length > 0)
167
+ this.schedulePersist();
168
+ return mutations;
169
+ }
170
+ /** Wait until all currently queued state is durably represented or throw. */
171
+ async flush() {
172
+ this.requireLoaded();
173
+ await this.waitForPersistenceWorker();
174
+ if (this.persistenceFailure === undefined
175
+ && this.persistenceGeneration === this.durablePersistenceGeneration)
176
+ return;
177
+ // Retry the latest complete snapshot once. Failed/intermediate snapshots
178
+ // are coalesced because completion orders and revisions are cumulative.
179
+ this.ensurePersistenceWorker();
180
+ await this.waitForPersistenceWorker();
181
+ this.throwIfPersistenceFailed();
182
+ }
183
+ /** Snapshot safe to expose to a client that may subsequently acknowledge it. */
184
+ async durableCatalogSnapshot() {
185
+ let snapshot;
186
+ do {
187
+ await this.flush();
188
+ snapshot = this.catalogSnapshot();
189
+ } while (this.persistenceGeneration !== this.durablePersistenceGeneration);
190
+ return snapshot;
191
+ }
192
+ async loadPersistedState() {
193
+ const persistence = this.persistence;
194
+ if (persistence === undefined) {
195
+ this.loaded = true;
196
+ return;
197
+ }
198
+ let value;
199
+ let resetState = false;
200
+ try {
201
+ value = await persistence.load();
202
+ }
203
+ catch (error) {
204
+ this.reportPersistenceError("load", error);
205
+ if (!(error instanceof SessionUnreadPersistenceCorruptionError))
206
+ throw error;
207
+ resetState = true;
208
+ }
209
+ if (!resetState && value !== undefined) {
210
+ try {
211
+ this.installPersistedState(parsePersistedState(value));
212
+ }
213
+ catch (error) {
214
+ this.reportPersistenceError("load", error);
215
+ resetState = true;
216
+ }
217
+ }
218
+ else if (value === undefined) {
219
+ resetState = true;
220
+ }
221
+ if (resetState) {
222
+ this.resetInMemoryState();
223
+ // Persist even an empty epoch so the catalog identity itself survives a
224
+ // clean daemon restart and a corrupt file is repaired once.
225
+ this.schedulePersist();
226
+ await this.waitForPersistenceWorker();
227
+ try {
228
+ this.throwIfPersistenceFailed();
229
+ }
230
+ catch (error) {
231
+ this.loaded = false;
232
+ throw error;
233
+ }
234
+ }
235
+ this.loaded = true;
236
+ }
237
+ resetInMemoryState() {
238
+ this.catalogId = this.freshCatalogId();
239
+ this.catalogRevision = 0;
240
+ this.nextCompletionOrder = 0;
241
+ this.unreadByIdentity.clear();
242
+ this.activeByIdentity.clear();
243
+ this.excludedByIdentity.clear();
244
+ }
245
+ mutation(identity, unread) {
246
+ this.catalogRevision = incrementSafe(this.catalogRevision, "Session unread catalog revision exhausted");
247
+ return {
248
+ event: {
249
+ type: "sessions.unread",
250
+ catalogId: this.catalogId,
251
+ catalogRevision: this.catalogRevision,
252
+ sessionId: identity.sessionId,
253
+ cwd: identity.cwd,
254
+ unread: unread === null ? null : { ...unread },
255
+ },
256
+ };
257
+ }
258
+ trimToLimit() {
259
+ const mutations = [];
260
+ while (this.unreadByIdentity.size > SESSION_UNREAD_LIMIT) {
261
+ let oldestKey;
262
+ let oldest;
263
+ for (const [key, summary] of this.unreadByIdentity) {
264
+ if (oldest === undefined || summary.completionOrder < oldest.completionOrder) {
265
+ oldestKey = key;
266
+ oldest = summary;
267
+ }
268
+ }
269
+ if (oldestKey === undefined || oldest === undefined)
270
+ break;
271
+ this.unreadByIdentity.delete(oldestKey);
272
+ mutations.push(this.mutation(oldest, null));
273
+ }
274
+ return mutations;
275
+ }
276
+ assertRevisionCapacity(count) {
277
+ if (!Number.isSafeInteger(this.catalogRevision + count)) {
278
+ throw new Error("Session unread catalog revision exhausted");
279
+ }
280
+ }
281
+ schedulePersist() {
282
+ if (this.persistence === undefined)
283
+ return;
284
+ const generation = incrementSafe(this.persistenceGeneration, "Session unread persistence generation exhausted");
285
+ this.persistenceGeneration = generation;
286
+ this.pendingPersistence = { generation, state: this.persistedState() };
287
+ // Once a save fails, mutations continue replacing the one pending snapshot
288
+ // but do not hammer storage; the service's backoff (or an explicit flush)
289
+ // owns the next retry attempt.
290
+ if (this.persistenceFailure === undefined)
291
+ this.ensurePersistenceWorker();
292
+ }
293
+ ensurePersistenceWorker() {
294
+ if (this.persistence === undefined || this.persistenceWorker !== undefined || this.pendingPersistence === undefined)
295
+ return;
296
+ const worker = this.runPersistenceWorker();
297
+ this.persistenceWorker = worker;
298
+ void worker.finally(() => {
299
+ if (this.persistenceWorker === worker)
300
+ this.persistenceWorker = undefined;
301
+ });
302
+ }
303
+ async runPersistenceWorker() {
304
+ const persistence = this.persistence;
305
+ if (persistence === undefined)
306
+ return;
307
+ while (this.pendingPersistence !== undefined) {
308
+ const pending = this.pendingPersistence;
309
+ this.pendingPersistence = undefined;
310
+ try {
311
+ await persistence.save(pending.state);
312
+ this.durablePersistenceGeneration = pending.generation;
313
+ this.persistenceFailure = undefined;
314
+ }
315
+ catch (error) {
316
+ // A newer pending snapshot subsumes this failed one. Otherwise retain
317
+ // this exact snapshot so a later flush can retry without a new mutation.
318
+ this.pendingPersistence ??= pending;
319
+ this.persistenceFailure = { error };
320
+ this.reportPersistenceError("save", error);
321
+ return;
322
+ }
323
+ }
324
+ }
325
+ async waitForPersistenceWorker() {
326
+ let worker = this.persistenceWorker;
327
+ while (worker !== undefined) {
328
+ await worker;
329
+ worker = this.persistenceWorker;
330
+ }
331
+ }
332
+ throwIfPersistenceFailed() {
333
+ const failure = this.persistenceFailure;
334
+ if (failure !== undefined)
335
+ throw failure.error;
336
+ }
337
+ persistedState() {
338
+ return {
339
+ version: SESSION_UNREAD_STATE_VERSION,
340
+ catalogId: this.catalogId,
341
+ catalogRevision: this.catalogRevision,
342
+ nextCompletionOrder: this.nextCompletionOrder,
343
+ sessions: [...this.unreadByIdentity.values()].map((summary) => ({ ...summary })),
344
+ };
345
+ }
346
+ installPersistedState(state) {
347
+ this.catalogId = state.catalogId;
348
+ this.catalogRevision = state.catalogRevision;
349
+ this.nextCompletionOrder = state.nextCompletionOrder;
350
+ this.unreadByIdentity.clear();
351
+ for (const summary of [...state.sessions].sort((left, right) => left.completionOrder - right.completionOrder)) {
352
+ this.unreadByIdentity.set(sessionIdentityKey(summary), { ...summary });
353
+ }
354
+ }
355
+ freshCatalogId() {
356
+ return requireCatalogId(this.createCatalogId());
357
+ }
358
+ requireLoaded() {
359
+ if (!this.loaded)
360
+ throw new Error("Session unread store must be loaded before use");
361
+ }
362
+ reportPersistenceError(operation, error) {
363
+ try {
364
+ this.onPersistenceError(operation, error);
365
+ }
366
+ catch {
367
+ // Error reporting must not poison future serialized persistence work.
368
+ }
369
+ }
370
+ }
371
+ class SessionUnreadPersistenceCorruptionError extends Error {
372
+ constructor(cause) {
373
+ super("Session unread persistence contains invalid JSON", { cause });
374
+ }
375
+ }
376
+ export class FileSessionUnreadPersistence {
377
+ constructor(filePath = defaultSessionUnreadFilePath()) {
378
+ this.filePath = filePath;
379
+ }
380
+ async load() {
381
+ let source;
382
+ try {
383
+ source = await readFile(this.filePath, "utf8");
384
+ }
385
+ catch (error) {
386
+ if (isNodeError(error) && error.code === "ENOENT")
387
+ return undefined;
388
+ throw error;
389
+ }
390
+ try {
391
+ const value = JSON.parse(source);
392
+ return value;
393
+ }
394
+ catch (error) {
395
+ throw new SessionUnreadPersistenceCorruptionError(error);
396
+ }
397
+ }
398
+ async save(state) {
399
+ await mkdir(dirname(this.filePath), { recursive: true });
400
+ const tempPath = `${this.filePath}.${process.pid.toString()}-${randomUUID()}.tmp`;
401
+ try {
402
+ await writeFile(tempPath, `${JSON.stringify(state, null, 2)}\n`, {
403
+ encoding: "utf8",
404
+ mode: SESSION_UNREAD_FILE_MODE,
405
+ flag: "wx",
406
+ });
407
+ await rename(tempPath, this.filePath);
408
+ }
409
+ finally {
410
+ await rm(tempPath, { force: true }).catch(() => undefined);
411
+ }
412
+ }
413
+ }
414
+ export function defaultSessionUnreadFilePath(env = process.env, cwd = process.cwd()) {
415
+ return join(piWebDataDir(env, cwd), "session-unread.json");
416
+ }
417
+ function parsePersistedState(value) {
418
+ const record = requireRecord(value, "Session unread state must be an object");
419
+ if (record["version"] !== SESSION_UNREAD_STATE_VERSION)
420
+ throw new Error("Unsupported session unread state version");
421
+ const catalogId = requireCatalogId(record["catalogId"]);
422
+ const catalogRevision = requireNonNegativeSafeInteger(record["catalogRevision"], "catalogRevision");
423
+ const nextCompletionOrder = requireNonNegativeSafeInteger(record["nextCompletionOrder"], "nextCompletionOrder");
424
+ const rawSessions = record["sessions"];
425
+ if (!Array.isArray(rawSessions))
426
+ throw new Error("Session unread sessions must be an array");
427
+ if (rawSessions.length > SESSION_UNREAD_LIMIT)
428
+ throw new Error("Session unread state exceeds its session limit");
429
+ const sessions = rawSessions.map(parseSummary);
430
+ const identities = new Set();
431
+ const orders = new Set();
432
+ for (const summary of sessions) {
433
+ const key = sessionIdentityKey(summary);
434
+ if (identities.has(key))
435
+ throw new Error("Duplicate session unread identity");
436
+ if (orders.has(summary.completionOrder))
437
+ throw new Error("Duplicate session unread completion order");
438
+ identities.add(key);
439
+ orders.add(summary.completionOrder);
440
+ }
441
+ const maxOrder = sessions.reduce((maximum, summary) => Math.max(maximum, summary.completionOrder), 0);
442
+ if (nextCompletionOrder < maxOrder)
443
+ throw new Error("Session unread completion order is inconsistent");
444
+ if (catalogRevision < nextCompletionOrder)
445
+ throw new Error("Session unread catalog revision is inconsistent");
446
+ return {
447
+ version: SESSION_UNREAD_STATE_VERSION,
448
+ catalogId,
449
+ catalogRevision,
450
+ nextCompletionOrder,
451
+ sessions,
452
+ };
453
+ }
454
+ function parseSummary(value) {
455
+ const record = requireRecord(value, "Session unread summary must be an object");
456
+ const completedAt = requireBoundedNonEmptyString(record["completedAt"], "completedAt", SESSION_UNREAD_COMPLETED_AT_MAX_LENGTH);
457
+ const completedDate = new Date(completedAt);
458
+ if (!Number.isFinite(completedDate.getTime()) || completedDate.toISOString() !== completedAt) {
459
+ throw new Error("Session unread completedAt must be a canonical ISO timestamp");
460
+ }
461
+ return {
462
+ sessionId: requireBoundedNonEmptyString(record["sessionId"], "sessionId", SESSION_UNREAD_SESSION_ID_MAX_LENGTH),
463
+ cwd: requireBoundedNonEmptyString(record["cwd"], "cwd", SESSION_UNREAD_CWD_MAX_LENGTH),
464
+ completionOrder: requirePositiveSafeInteger(record["completionOrder"], "completionOrder"),
465
+ completedAt,
466
+ };
467
+ }
468
+ function requireRecord(value, message) {
469
+ if (!isRecord(value))
470
+ throw new Error(message);
471
+ return value;
472
+ }
473
+ function isRecord(value) {
474
+ return typeof value === "object" && value !== null && !Array.isArray(value);
475
+ }
476
+ function requireNonEmptyString(value, field) {
477
+ if (typeof value !== "string" || value === "")
478
+ throw new Error(`Session unread ${field} must be a non-empty string`);
479
+ return value;
480
+ }
481
+ function requireBoundedNonEmptyString(value, field, maxLength) {
482
+ const parsed = requireNonEmptyString(value, field);
483
+ if (parsed.length > maxLength)
484
+ throw new Error(`Session unread ${field} exceeds its length limit`);
485
+ return parsed;
486
+ }
487
+ function requireCatalogId(value) {
488
+ return requireBoundedNonEmptyString(value, "catalogId", SESSION_UNREAD_CATALOG_ID_MAX_LENGTH);
489
+ }
490
+ function requireNonNegativeSafeInteger(value, field) {
491
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
492
+ throw new Error(`Session unread ${field} must be a non-negative safe integer`);
493
+ }
494
+ return value;
495
+ }
496
+ function requirePositiveSafeInteger(value, field) {
497
+ const parsed = requireNonNegativeSafeInteger(value, field);
498
+ if (parsed === 0)
499
+ throw new Error(`Session unread ${field} must be positive`);
500
+ return parsed;
501
+ }
502
+ function requireIdentity(sessionId, cwd) {
503
+ return {
504
+ sessionId: requireBoundedNonEmptyString(sessionId, "sessionId", SESSION_UNREAD_SESSION_ID_MAX_LENGTH),
505
+ cwd: requireBoundedNonEmptyString(cwd, "cwd", SESSION_UNREAD_CWD_MAX_LENGTH),
506
+ };
507
+ }
508
+ function sessionIdentityKey(identity) {
509
+ return JSON.stringify([identity.sessionId, identity.cwd]);
510
+ }
511
+ function incrementSafe(value, message) {
512
+ const next = value + 1;
513
+ if (!Number.isSafeInteger(next))
514
+ throw new Error(message);
515
+ return next;
516
+ }
517
+ function isNodeError(error) {
518
+ return error instanceof Error && "code" in error;
519
+ }
520
+ //# sourceMappingURL=sessionUnreadStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessionUnreadStore.js","sourceRoot":"","sources":["../../../src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AS,kBAAkB,CAAC,QAA+B;IACzD,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,aAAa,CAAC,KAAa,EAAE,OAAe;IACnD,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC;IACvB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1D,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,CAAC;AACnD,CAAC"}
@@ -18,8 +18,8 @@ export function createSpawnSessionToolDefinition(spawningCwd, deps) {
18
18
  return defineTool({
19
19
  name: "spawn_session",
20
20
  label: "Spawn session",
21
- description: "Start a new independent pi-web session and send it an initial prompt. The session is not tracked by the caller, can be opened by a human, and runs without returning its later output to the caller.",
22
- promptSnippet: "spawn_session: start a new independent session with a first prompt",
21
+ description: "Start a fully independent session; its transcript and results are unavailable here. Use only when the user or active workflow explicitly requests a separate session.",
22
+ promptSnippet: "spawn_session: independent session; results unavailable here; explicit requests only",
23
23
  parameters: SpawnSessionParams,
24
24
  async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
25
25
  // Failures throw: the agent loop turns the thrown message into an error
@@ -1 +1 @@
1
- {"version":3,"file":"spawnSessionTool.js","sourceRoot":"","sources":["../../../src/server/sessions/spawnSessionTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAyB,MAAM,iCAAiC,CAAC;AAuBpF,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC;IACrC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;QAClB,WAAW,EAAE,gIAAgI;KAC9I,C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I,CAAC,MAAM,CAAC;IACrC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;QAClB,WAAW,EAAE,gIAAgI;KAC9I,CAAC;IACF,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;QAC7B,WAAW,EAAE,mKAAmK;KACjL,CAAC,CAAC;CACJ,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAAC,WAAmB,EAAE,IAA0B;IAC9F,OAAO,UAAU,CAAqD;QACpE,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE,uKAAuK;QACpL,aAAa,EAAE,sFAAsF;QACrG,UAAU,EAAE,kBAAkB;QAC9B,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG;YACxD,wEAAwE;YACxE,2EAA2E;YAC3E,sCAAsC;YACtC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC;gBAC9B,WAAW;gBACX,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,GAAG,CAAC,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;aACzD,CAAC,CAAC;YACH,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,+BAA+B,MAAM,CAAC,SAAS,OAAO,MAAM,CAAC,GAAG,GAAG,EAAE,CAAC;gBACtG,OAAO,EAAE,MAAM;aAChB,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -44,7 +44,7 @@ function statusLine(summary) {
44
44
  return `- ${summary.sessionId} [${summary.status}] in ${summary.cwd}`;
45
45
  }
46
46
  function workingInspectionGuidance(sessionId) {
47
- return `Subsession ${sessionId} is working; partial output is withheld. Continue independent work, or call yield_to_subsessions alone and last at the join point. Completion notices wake you; do not poll.`;
47
+ return `Subsession ${sessionId} is working; partial output is withheld. Continue other work, or call yield_to_subsessions alone and last at the join point. Completion notices wake you; do not poll.`;
48
48
  }
49
49
  function renderEntry(entry) {
50
50
  const header = `#${String(entry.index)} ${entry.role}`;
@@ -96,18 +96,18 @@ function renderTranscript(result) {
96
96
  * Tools that let an agent spawn *tracked* child sessions, inspect them, and
97
97
  * explicitly yield at a join point.
98
98
  *
99
- * Unlike `spawn_session` (fire-and-forget peers), a subsession records its
100
- * parent in its session header, the parent is notified when it stops working,
101
- * and the parent may read its transcript/result. The tools are constructed
102
- * per-session, carrying the spawning cwd for project-scope validation; the
103
- * parent's identity is taken from the live extension context at call time.
99
+ * A subsession records its parent in its session header, the parent is notified
100
+ * when it stops working, and the parent may read its transcript/result. The
101
+ * tools are constructed per-session, carrying the spawning cwd for
102
+ * project-scope validation; the parent's identity is taken from the live
103
+ * extension context at call time.
104
104
  */
105
105
  export function createSubsessionToolDefinitions(spawningCwd, deps) {
106
106
  const spawnTool = defineTool({
107
107
  name: "spawn_subsession",
108
108
  label: "Spawn subsession",
109
- description: "Start a tracked child and return immediately. Continue independent work, then use yield_to_subsessions at the join point. Completion notices wake you; do not poll.",
110
- promptSnippet: "spawn_subsession: tracked parallel work; continue, then join with yield_to_subsessions",
109
+ description: "Start a tracked child session to carry out part of the current task and return immediately. Its transcript and result are available here after it finishes.",
110
+ promptSnippet: "spawn_subsession: tracked child work for the current task; result available after completion",
111
111
  parameters: SpawnSubsessionParams,
112
112
  async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
113
113
  const parentSessionId = ctx.sessionManager.getSessionId();
@@ -121,7 +121,7 @@ export function createSubsessionToolDefinitions(spawningCwd, deps) {
121
121
  ...(ctx.model === undefined ? {} : { model: ctx.model }),
122
122
  });
123
123
  return {
124
- content: [{ type: "text", text: `Started tracked subsession ${result.sessionId} in ${result.cwd}. Continue independent work, then join with yield_to_subsessions; do not poll.` }],
124
+ content: [{ type: "text", text: `Started tracked subsession ${result.sessionId} in ${result.cwd}. Continue other work, then join with yield_to_subsessions; do not poll.` }],
125
125
  details: result,
126
126
  };
127
127
  },
@@ -188,9 +188,7 @@ export function createSubsessionToolDefinitions(spawningCwd, deps) {
188
188
  description: "At a join point, end this run while tracked children work; completion notices wake you. If none work, continue. Call alone and last; do not poll.",
189
189
  promptSnippet: "yield_to_subsessions: end the run at a join point; call alone and last",
190
190
  promptGuidelines: [
191
- "After independent work, yield only at a join point; use spawn_session for fire-and-forget work.",
192
- "Call alone and last; a mixed tool batch may continue the run.",
193
- "Completion notices wake you; do not poll inspection tools.",
191
+ "After calling spawn_subsession, you can continue with other work. At the join point, call yield_to_subsessions alone and last; completion notices wake you, so do not poll.",
194
192
  ],
195
193
  parameters: YieldToSubsessionsParams,
196
194
  async execute(_toolCallId, _params, _signal, _onUpdate, ctx) {