@pi-chamber/web 0.7.0 → 0.7.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 (67) hide show
  1. package/README.md +2 -1
  2. package/bin/cli.js +2 -2
  3. package/bin/cli.test.js +98 -1
  4. package/bin/lib/DOCUMENTATION.md +2 -1
  5. package/bin/lib/cli-args.js +8 -5
  6. package/bin/lib/cli-startup.js +10 -7
  7. package/bin/lib/cli-startup.test.js +28 -0
  8. package/bin/lib/commands-startup.js +152 -6
  9. package/dist/assets/{CommitSection-BL61C8nr.js → CommitSection-DfAlM30E.js} +1 -1
  10. package/dist/assets/{DiagramEditor-CH_gE8Ho.js → DiagramEditor-TeJ1G_NN.js} +1 -1
  11. package/dist/assets/{DiagramView-D5PsfvzH.js → DiagramView-DKLIwNth.js} +1 -1
  12. package/dist/assets/{DiffView-CP49mbz0.js → DiffView-CZyqSs5W.js} +3 -3
  13. package/dist/assets/{FilesView-DQ0jIXPf.js → FilesView-rftA7fEL.js} +4 -4
  14. package/dist/assets/{GitView-BvIVUn8p.js → GitView-D5LMTT2M.js} +3 -3
  15. package/dist/assets/{JsonTreeView-4xkZ1oUB.js → JsonTreeView-DMI3-Smy.js} +1 -1
  16. package/dist/assets/{MarkdownRendererImpl-BYiITelR.js → MarkdownRendererImpl-gdd-5n9J.js} +1 -1
  17. package/dist/assets/{PatchDiff-cYVpwvLs.js → PatchDiff-GNB1NlAN.js} +1 -1
  18. package/dist/assets/{PierreDiffViewer-CxTRnaw4.js → PierreDiffViewer-DmJv2AoJ.js} +1 -1
  19. package/dist/assets/{SessionSwitcherContent-C_kE1AkY.js → SessionSwitcherContent-CWdDPll7.js} +1 -1
  20. package/dist/assets/{SessionSwitcherDropdown-CCXNg-hd.js → SessionSwitcherDropdown-Cx-Jfmvo.js} +2 -2
  21. package/dist/assets/{SessionUnreadDot-DcLebnEm.js → SessionUnreadDot-CKe4uVcf.js} +1 -1
  22. package/dist/assets/SettingsView-DaxkNy5C.js +4 -0
  23. package/dist/assets/{SettingsWindow-BCfEIGLV.js → SettingsWindow-D1M_rRDo.js} +1 -1
  24. package/dist/assets/{ToolOutputDialog-CG3Djpaw.js → ToolOutputDialog-CUKcp77A.js} +5 -5
  25. package/dist/assets/{ToolPartDiffPreview-Bno_Kf_v.js → ToolPartDiffPreview-CkzwXAC5.js} +1 -1
  26. package/dist/assets/{VirtualizedFileDiff-CtTCV9aT.js → VirtualizedFileDiff-sRc4lN0B.js} +3 -3
  27. package/dist/assets/{WindowsWindowControls-C1cyCACC.js → WindowsWindowControls-CCnU0ckO.js} +122 -122
  28. package/dist/assets/{collapsible-Y0lXAGWU.js → collapsible-B0cIItyf.js} +1 -1
  29. package/dist/assets/{computeVirtualFileMetrics-Ygq8IDgM.js → computeVirtualFileMetrics-B1uVA58l.js} +1 -1
  30. package/dist/assets/{contextFileOpenGuard-CdZD2lzt.js → contextFileOpenGuard-BuedQ5EQ.js} +1 -1
  31. package/dist/assets/{index-Cl-EsRzi.js → index-BA67uOfZ.js} +1 -1
  32. package/dist/assets/index-CcbDTf8Q.js +8 -0
  33. package/dist/assets/index-Cl3XbCeC.css +1 -0
  34. package/dist/assets/{isDiffPlainText-BOtu3iWK.js → isDiffPlainText-DLDFLL6P.js} +1 -1
  35. package/dist/assets/{isFilePlainText-DZkgwQ85.js → isFilePlainText-B2wwrpRU.js} +1 -1
  36. package/dist/assets/main-B5k0qpHJ.js +133 -0
  37. package/dist/assets/{main-hi9Mn-Bi.js → main-Bepu8Jr9.js} +2 -2
  38. package/dist/assets/{markdownCore-BnziCWjq.js → markdownCore-BfuFM7mg.js} +2 -2
  39. package/dist/assets/{miniChat-jlNYy4Yo.js → miniChat-Co0Snpgl.js} +2 -2
  40. package/dist/assets/{mobile-B2J6RZei.js → mobile-CSvL_Zyu.js} +2 -2
  41. package/dist/assets/{renderElectronMiniChatApp-D2j7dJjx.js → renderElectronMiniChatApp-DrMJ1RXX.js} +2 -2
  42. package/dist/assets/{renderMobileApp-DRMRL_Rc.js → renderMobileApp-B2toAnMW.js} +4 -4
  43. package/dist/assets/{runtimeSurface-DRCRpZ4U.js → runtimeSurface-DF3VwUlO.js} +1 -1
  44. package/dist/assets/{useInlineCommentController-BafZc9gs.js → useInlineCommentController-CxMP78jg.js} +2 -2
  45. package/dist/assets/usePanelSlide-DUuoQt5X.js +56 -0
  46. package/dist/assets/{usePushVisibilityBeacon-C6yhoKax.js → usePushVisibilityBeacon-CSPdFBaA.js} +2 -2
  47. package/dist/assets/{useSwitcherItems-D4fvD6XH.js → useSwitcherItems-zOeC2Cta.js} +1 -1
  48. package/dist/assets/{vendor-codemirror-language-data-DOlAvLSI.js → vendor-codemirror-language-data-C7_BPMCr.js} +2 -2
  49. package/dist/assets/{web-components-CDndDwR4.js → web-components-BYNCGylQ.js} +1 -1
  50. package/dist/index.html +4 -4
  51. package/dist/mini-chat.html +3 -3
  52. package/dist/mobile.html +3 -3
  53. package/package.json +1 -1
  54. package/server/lib/package-manager.js +32 -1
  55. package/server/lib/package-manager.test.js +21 -0
  56. package/server/lib/pi/attachment-store.js +95 -22
  57. package/server/lib/pi/attachment-store.test.js +23 -0
  58. package/server/lib/pi/routes.js +120 -43
  59. package/server/lib/pi/routes.test.js +63 -2
  60. package/server/lib/pi/session-daemon/DOCUMENTATION.md +1 -1
  61. package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +2 -0
  62. package/server/lib/pi/session-daemon/session-daemon.js +32 -3
  63. package/dist/assets/SettingsView-CfpCOseW.js +0 -4
  64. package/dist/assets/index--zDkVFU6.css +0 -1
  65. package/dist/assets/index-CiQblNLS.js +0 -8
  66. package/dist/assets/main-BlGDTFM8.js +0 -133
  67. package/dist/assets/usePanelSlide-C4DKnekW.js +0 -56
@@ -10,7 +10,7 @@ This module is the Pi-owned session-daemon foundation. A detached local daemon p
10
10
  - `extension-bridge.js` owns extension UI bindings, pending dialog lifecycle, normalized status/widget/panel/app state, snapshot projection, and extension event publication. `session-daemon.js` supplies runtime lookup, publication, redaction, and directory dependencies through its narrow factory interface.
11
11
  - `session-daemon.js`
12
12
  - `createPiSessionRuntime({ cwd, agentDir })` creates a persistent Pi runtime using the selected server-side cwd and Pi agent directory. It uses Pi's normal settings, credentials, models, sessions, skills, prompts, context discovery, and native extensions. Every runtime creation binds extensions through `session.bindExtensions()` in rpc-like mode with a daemon-owned UI bridge, so pi extensions load exactly as they do under the Pi CLI's RPC mode. Sessions created outside PiChamber (Pi CLI or any other writer of the cwd-scoped JSONL directory) are the same records: `sessions.list`/`open` hydrate from `getEntries()`, then overlay the live `session.messages` / `state.streamingMessage` turn while `isStreaming` is true, including an unpersisted user prompt that has not flushed to JSONL yet. A later prompt must overlay live turns onto that log rather than replace it. An unmatched `toolCall` projects as `running` only while `isStreaming` is authoritative; the same unmatched call in an idle persisted turn projects as a timestamped interruption error instead of malformed `completed` state. `getSession` also reports `isStreaming` and `lifecycle` so a restarted UI can restore the working/tooling state without waiting for the next token.
13
- - Extension bridging: blocking dialogs (`ctx.ui.select/confirm/input/editor`, plus the PiChamber-specific `ctx.ui.form` which resolves with a values object keyed by field id) publish an `extension.dialog` event and stay pending until answered by the `extensions.respond` private command; every answer, timeout, abort, session close, or daemon stop publishes an authoritative `extension.dialog.dismiss` event before resolving the extension so every connected client removes the modal (timeouts resolve defaults, abort resolves cancellation, form answers travel as a sanitized `values` record and are rejected unless required fields, number bounds, select options, and checkbox values match the pending form); fire-and-forget calls publish `extension.notify`, `extension.status`, `extension.widget`, session-scoped `extension.editor`, and `extension.title`; extension errors publish `extension.error`; appended custom entries and displayed custom messages publish `extension.entry` / `extension.message`. `pichamber.ui` entries with a stable `id` are additionally mirrored into normalized `extension.ui` panel events (latest wins per id, `removed: true` unregisters) and `pichamber.app` entries into sandboxed `extension.app` app surfaces; both are kept in per-session maps and replayed through `session.snapshot` so reconnects rebuild live panels. TUI-only component replacement, footers, and themes remain intentional no-ops; standard RPC editor replacement and window titles are projected to the focused browser session. Pending dialogs are cancelled when the owning runtime hits idle disposal or daemon stop so no extension thread blocks forever. Unknown dialog responses return `{ resolved: false }` rather than throwing so a stale client retry cannot tear down the shared socket.
13
+ - Extension bridging: blocking dialogs (`ctx.ui.select/confirm/input/editor`, plus the PiChamber-specific `ctx.ui.form` which resolves with a values object keyed by field id) publish an `extension.dialog` event and stay pending until answered by the `extensions.respond` private command; every answer, timeout, abort, session close, or daemon stop publishes an authoritative `extension.dialog.dismiss` event before resolving the extension so every connected client removes the modal (timeouts resolve defaults, abort resolves cancellation, form answers travel as a sanitized `values` record and are rejected unless required fields, number bounds, select options, and checkbox values match the pending form); fire-and-forget calls publish `extension.notify`, `extension.status`, `extension.widget`, session-scoped `extension.editor`, and `extension.title`; extension errors publish `extension.error`; appended custom entries and displayed custom messages publish `extension.entry` / `extension.message`. `pichamber.ui` entries with a stable `id` are additionally mirrored into normalized `extension.ui` panel events (latest wins per id, `removed: true` unregisters) and `pichamber.app` entries into sandboxed `extension.app` app surfaces; extension live state is kept in per-session maps and included in both `sessions.open` and `session.snapshot`. The open response must cover every extension event at or below its `lastSequence`, so first attach cannot skip one-time startup statuses before the browser stream connects; reconnect snapshots rebuild the same live panels. TUI-only component replacement, footers, and themes remain intentional no-ops; standard RPC editor replacement and window titles are projected to the focused browser session. Pending dialogs are cancelled when the owning runtime hits idle disposal or daemon stop so no extension thread blocks forever. Unknown dialog responses return `{ resolved: false }` rather than throwing so a stale client retry cannot tear down the shared socket.
14
14
  - `createSessionDaemon(options)` starts/stops the authenticated local socket daemon and validates its endpoint and setup inputs.
15
15
  - `daemon-process.js` is the detached private-process entrypoint. It reads the daemon credential from its owner-only sidecar, starts the socket, writes non-secret identity state only after readiness, and removes only its own state on signal shutdown.
16
16
  - `ipc-client.js` is the server-only authenticated request client. It owns JSONL framing and never exposes endpoint or credential values to callers.
@@ -295,6 +295,8 @@ describe('Pi session daemon extension bridging', () => {
295
295
  ui.setStatus('my-ext', 'Processing…');
296
296
  const status = await client.next((message) => message.event === 'extension.status');
297
297
  expect(status.payload).toMatchObject({ key: 'my-ext', text: 'Processing…' });
298
+ const opened = await client.request('sessions.open', { sessionId: session.sessionId });
299
+ expect(opened.result.extensionStatuses).toEqual([{ key: 'my-ext', text: 'Processing…' }]);
298
300
  ui.setStatus('my-ext', undefined);
299
301
  const cleared = await client.next((message) => message.event === 'extension.status' && !message.payload?.text);
300
302
  expect(cleared.payload.key).toBe('my-ext');
@@ -287,6 +287,14 @@ export function createSessionDaemon({
287
287
  if (typeof requested === 'string' && requested.trim().length > 0) {
288
288
  const validated = await validateDirectoryPath(requested);
289
289
  knownDirectories.add(validated);
290
+ // PiChamber projects are trusted by default — auto-trust on explicit add/select
291
+ // so skills (and other resources) never trigger the trust popup for known dirs.
292
+ try {
293
+ const trustStore = createTrustStore(agentDir);
294
+ if (trustStore.get(validated) === null && hasTrustRequiringProjectResources(validated)) {
295
+ trustStore.set(validated, true);
296
+ }
297
+ } catch {}
290
298
  return validated;
291
299
  }
292
300
  return activeDirectory || cwd;
@@ -990,6 +998,7 @@ export function createSessionDaemon({
990
998
  const isStreaming = session.isStreaming === true;
991
999
  const retry = retryStateBySession.get(session.sessionId);
992
1000
  const compaction = compactionStateFor(session);
1001
+ const extensionSnapshot = extensionBridge.getSnapshotState(session.sessionId);
993
1002
  return {
994
1003
  session: {
995
1004
  id: session.sessionId, directory: targetDir, createdAt, updatedAt: createdAt,
@@ -1006,6 +1015,12 @@ export function createSessionDaemon({
1006
1015
  ...(compaction ? { compaction } : {}),
1007
1016
  ...(activeRunStartedAt.has(session.sessionId) ? { runStartedAt: activeRunStartedAt.get(session.sessionId) } : {}),
1008
1017
  serverNow: Date.now(),
1018
+ ...(extensionSnapshot.statuses ? { extensionStatuses: extensionSnapshot.statuses } : {}),
1019
+ ...(extensionSnapshot.widgets ? { extensionWidgets: extensionSnapshot.widgets } : {}),
1020
+ ...(extensionSnapshot.dialogs ? { extensionDialogs: extensionSnapshot.dialogs } : {}),
1021
+ ...(extensionSnapshot.panels ? { extensionPanels: extensionSnapshot.panels } : {}),
1022
+ ...(extensionSnapshot.apps ? { extensionApps: extensionSnapshot.apps } : {}),
1023
+ ...(extensionSnapshot.title ? { extensionTitle: extensionSnapshot.title } : {}),
1009
1024
  };
1010
1025
  };
1011
1026
 
@@ -1380,7 +1395,15 @@ export function createSessionDaemon({
1380
1395
  const readPiSettings = (requestedDirectory) => {
1381
1396
  const targetDir = requestedDirectory || activeDirectory || cwd;
1382
1397
  const trustStore = createTrustStore(agentDir);
1383
- const trust = trustStore.get(targetDir);
1398
+ let trust = trustStore.get(targetDir);
1399
+ // Auto-trust known PiChamber projects so the skills popup never appears.
1400
+ // `knownDirectories` tracks every dir the user explicitly added/selected.
1401
+ if (trust === null && knownDirectories.has(targetDir) && hasTrustRequiringProjectResources(targetDir)) {
1402
+ try {
1403
+ trustStore.set(targetDir, true);
1404
+ trust = true;
1405
+ } catch {}
1406
+ }
1384
1407
  const manager = createSettingsManager({ cwd: targetDir, agentDir, projectTrusted: trust === true });
1385
1408
  const global = manager.getGlobalSettings();
1386
1409
  const project = manager.getProjectSettings();
@@ -1421,8 +1444,14 @@ export function createSessionDaemon({
1421
1444
  if (hasTrust && payload.trust !== null && typeof payload.trust !== 'boolean') {
1422
1445
  throw new SessionDaemonProtocolError('INVALID_ARGUMENT', 'The project trust decision is invalid.');
1423
1446
  }
1424
- if (hasTrust && runtime?.session?.isStreaming) {
1425
- throw new SessionDaemonProtocolError('SESSION_BUSY', 'Project trust cannot change during an active session.');
1447
+ if (hasTrust) {
1448
+ const targetRuntimes = runtimeRegistry?.listByDirectory?.(targetDir) ?? [];
1449
+ const inheritsActive = runtime && runtime.cwd === targetDir ? [runtime] : [];
1450
+ const allTarget = targetRuntimes.length > 0 ? targetRuntimes : inheritsActive;
1451
+ const isTargetStreaming = allTarget.some((r) => r.session?.isStreaming);
1452
+ if (isTargetStreaming) {
1453
+ throw new SessionDaemonProtocolError('SESSION_BUSY', 'Project trust cannot change during an active session.');
1454
+ }
1426
1455
  }
1427
1456
  const trustStore = createTrustStore(agentDir);
1428
1457
  if (hasTrust) trustStore.set(targetDir, payload.trust);