@pi-chamber/web 1.0.8-rc.2 → 1.0.8-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/assets/{AgentsSurface-CcWBqAWV.js → AgentsSurface-DbCBygRD.js} +1 -1
  2. package/dist/assets/{ChoicesArtifact-Kk-qvrSB.js → ChoicesArtifact-DUqhCvXh.js} +1 -1
  3. package/dist/assets/{DiagramView-DZUBo1uP.js → DiagramView-CnVOyJd2.js} +1 -1
  4. package/dist/assets/{DiffView-CiZy4jFA.js → DiffView-Db8JXsvA.js} +1 -1
  5. package/dist/assets/{FileSaveConflictDialog-DZ9NDwOO.js → FileSaveConflictDialog-D6xyf709.js} +1 -1
  6. package/dist/assets/{FilesView-DqiZ9kw9.js → FilesView-Cir0Wl9F.js} +1 -1
  7. package/dist/assets/{GitHubDetailScaffold-DM2DH7o8.js → GitHubDetailScaffold-US37Di_K.js} +1 -1
  8. package/dist/assets/{GitHubLinkPicker-ChB8NZ1h.js → GitHubLinkPicker-k_D-sk-e.js} +1 -1
  9. package/dist/assets/{GitHubListPrimitives-CibDiJGq.js → GitHubListPrimitives-DuUXrJGk.js} +1 -1
  10. package/dist/assets/{GitView--EaZQrBr.js → GitView-BdX_3XRr.js} +3 -3
  11. package/dist/assets/{IssuesSurface-CySTpaD1.js → IssuesSurface-Cw93HC0G.js} +2 -2
  12. package/dist/assets/{JsonTreeView-_yMHKKQZ.js → JsonTreeView-Bze4htWt.js} +1 -1
  13. package/dist/assets/{MarkdownRendererImpl-D_-2fQw0.js → MarkdownRendererImpl-Ch7NDkF9.js} +1 -1
  14. package/dist/assets/{PatchDiff-bHObDlhD.js → PatchDiff-l68Yz45X.js} +1 -1
  15. package/dist/assets/{PierreDiffViewer-UY7Cse-s.js → PierreDiffViewer-BHBySiXQ.js} +1 -1
  16. package/dist/assets/{PullRequestsSurface-iXy6chwc.js → PullRequestsSurface-CGD4_ljc.js} +2 -2
  17. package/dist/assets/{SessionSwitcherContent-DJGCa_wN.js → SessionSwitcherContent-DqP8OWzB.js} +1 -1
  18. package/dist/assets/{SessionSwitcherDropdown-CDOX-5Y2.js → SessionSwitcherDropdown-BkTg-cVd.js} +2 -2
  19. package/dist/assets/{SessionUnreadDot-Dwc3MdvA.js → SessionUnreadDot-CgvC3F5e.js} +1 -1
  20. package/dist/assets/SettingsView-CkIxCYhs.js +11 -0
  21. package/dist/assets/{SettingsWindow-CUg49Mfh.js → SettingsWindow-DSdhzapT.js} +1 -1
  22. package/dist/assets/{SubagentsArtifact-DUZX9tDe.js → SubagentsArtifact-BN3aX_8M.js} +1 -1
  23. package/dist/assets/{ToolOutputDialog-BuZZaRw4.js → ToolOutputDialog-CLwm4TjA.js} +1 -1
  24. package/dist/assets/{ToolPartDiffPreview-CKncG6i2.js → ToolPartDiffPreview-ERAStEKA.js} +1 -1
  25. package/dist/assets/{VirtualizedFileDiff-BGZiLPe_.js → VirtualizedFileDiff-DwR2fZHv.js} +1 -1
  26. package/dist/assets/VisualFrame-Dwp7B_st.js +22 -0
  27. package/dist/assets/{VisualsArtifact-Bq0vMO-i.js → VisualsArtifact-DlOxifHd.js} +1 -1
  28. package/dist/assets/{collapsible-Bro9KrfM.js → collapsible-CW-_qd6v.js} +1 -1
  29. package/dist/assets/{computeVirtualFileMetrics-DJQqK49u.js → computeVirtualFileMetrics-SlBfr8LB.js} +1 -1
  30. package/dist/assets/{contextFileOpenGuard-ByWK3Sru.js → contextFileOpenGuard-CHoFT50j.js} +1 -1
  31. package/dist/assets/{fileTreeStatus-CyJ3TOYD.js → fileTreeStatus-D0uiC1D0.js} +1 -1
  32. package/dist/assets/{gitStatusPredicates-BsXrwngT.js → gitStatusPredicates-Bj3pkh2e.js} +1 -1
  33. package/dist/assets/{githubLink-g2bmC0qi.js → githubLink-CheLNuP0.js} +1 -1
  34. package/dist/assets/index-BFkW-BPM.js +11 -0
  35. package/dist/assets/index-C5JgjS20.css +1 -0
  36. package/dist/assets/{index-C9rUUQ_Y.js → index-C8zaLvup.js} +1 -1
  37. package/dist/assets/{main-DT-4_fhe.js → main-CUEqZRu1.js} +2 -2
  38. package/dist/assets/{main-DsLMU9CT.js → main-V66ie29o.js} +4 -4
  39. package/dist/assets/{markdownCore-QmM_aOnZ.js → markdownCore-BRedKgCo.js} +1 -1
  40. package/dist/assets/{miniChat-BqGslD2z.js → miniChat-BXwuEQhz.js} +2 -2
  41. package/dist/assets/{mobile-C5JOcDIC.js → mobile-7s-xLDG3.js} +2 -2
  42. package/dist/assets/{nativeFileSave-DSMsJqXM.js → nativeFileSave-Bj-V_9ae.js} +1 -1
  43. package/dist/assets/{pi-session-focus-preference-Cc_S4zi1.js → pi-session-focus-preference-clbekCjz.js} +1 -1
  44. package/dist/assets/{renderDiffWithHighlighter-BXhnIAHg.js → renderDiffWithHighlighter-g9eKWi78.js} +1 -1
  45. package/dist/assets/{renderElectronMiniChatApp-CiSkecEE.js → renderElectronMiniChatApp-B6BN8YgC.js} +2 -2
  46. package/dist/assets/{renderFileWithHighlighter-CK29YZtC.js → renderFileWithHighlighter-DKl6vubK.js} +1 -1
  47. package/dist/assets/{renderMobileApp-C4JuoxsZ.js → renderMobileApp-Bp735rW7.js} +3 -3
  48. package/dist/assets/{runtimeEndpointReset-Dwj-jCDS.js → runtimeEndpointReset-CtHv_OMT.js} +7 -7
  49. package/dist/assets/{runtimeSurface-0K7vuUpd.js → runtimeSurface-DD4Vn4HC.js} +1 -1
  50. package/dist/assets/{selection-CnYkEsu_.js → selection-DDT954wY.js} +1 -1
  51. package/dist/assets/useAppFontEffects-DJCrUN2D.js +226 -0
  52. package/dist/assets/{useGitHubRemoteSearch-CgP-zEBj.js → useGitHubRemoteSearch-B77fMiwQ.js} +1 -1
  53. package/dist/assets/{useSwitcherItems-C8G5F0hs.js → useSwitcherItems-CFY3mP06.js} +1 -1
  54. package/dist/assets/{web-components-BpncHjnV.js → web-components-XIP_3VZv.js} +1 -1
  55. package/dist/index.html +4 -4
  56. package/dist/mini-chat.html +3 -3
  57. package/dist/mobile.html +3 -3
  58. package/package.json +2 -1
  59. package/pichamber.d.ts +139 -0
  60. package/plugins/subagents/extension.js +5 -5
  61. package/plugins/subagents/package.json +3 -2
  62. package/plugins/visuals/choices.js +8 -7
  63. package/plugins/visuals/extension.js +6 -6
  64. package/plugins/visuals/package.json +1 -1
  65. package/server/index.js +4 -0
  66. package/server/lib/marketplace/DOCUMENTATION.md +2 -2
  67. package/server/lib/marketplace/npm-registry.js +1 -1
  68. package/server/lib/marketplace/npm-registry.test.js +1 -1
  69. package/server/lib/marketplace/service.test.js +4 -4
  70. package/server/lib/open-url/DOCUMENTATION.md +1 -1
  71. package/server/lib/pi/extension-card.js +48 -0
  72. package/server/lib/pi/extension-card.test.js +35 -0
  73. package/server/lib/pi/extension-commands.js +49 -0
  74. package/server/lib/pi/extension-commands.test.js +38 -0
  75. package/server/lib/pi/extension-protocol.js +1 -2
  76. package/server/lib/pi/fixtures/pichamber-gui-demo.ts +52 -223
  77. package/server/lib/pi/routes-extension-events.test.js +35 -48
  78. package/server/lib/pi/routes.js +44 -54
  79. package/server/lib/pi/routes.test.js +32 -0
  80. package/server/lib/pi/session-daemon/DOCUMENTATION.md +7 -7
  81. package/server/lib/pi/session-daemon/extension-bridge-draft.test.js +0 -54
  82. package/server/lib/pi/session-daemon/extension-bridge.js +39 -162
  83. package/server/lib/pi/session-daemon/extension-controls.js +12 -57
  84. package/server/lib/pi/session-daemon/extension-controls.test.js +4 -34
  85. package/server/lib/pi/session-daemon/pichamber-api.js +38 -0
  86. package/server/lib/pi/session-daemon/pichamber-api.test.js +24 -0
  87. package/server/lib/pi/session-daemon/plugin-host.js +5 -7
  88. package/server/lib/pi/session-daemon/plugin-host.test.js +2 -3
  89. package/server/lib/pi/session-daemon/session-daemon-controls.e2e.test.js +53 -7
  90. package/server/lib/pi/session-daemon/session-daemon-drafts.e2e.test.js +5 -5
  91. package/server/lib/pi/session-daemon/session-daemon-extensions.e2e.test.js +9 -4
  92. package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +28 -71
  93. package/server/lib/pi/session-daemon/session-daemon-plugins.e2e.test.js +1 -1
  94. package/server/lib/pi/session-daemon/session-daemon.js +138 -78
  95. package/server/lib/pi/session-daemon/session-daemon.test.js +68 -0
  96. package/server/lib/pi/ui-settings-store.js +2 -1
  97. package/server/lib/plugins/DOCUMENTATION.md +3 -3
  98. package/server/lib/plugins/impact.js +2 -4
  99. package/server/lib/plugins/impact.test.js +0 -1
  100. package/server/lib/plugins/manifest.js +9 -5
  101. package/server/lib/plugins/manifest.test.js +5 -4
  102. package/server/lib/plugins/store.test.js +1 -1
  103. package/server/lib/plugins/visuals-extension.test.js +16 -14
  104. package/server/lib/wallpaper/DOCUMENTATION.md +25 -0
  105. package/server/lib/wallpaper/routes.js +63 -0
  106. package/server/lib/wallpaper/routes.test.js +109 -0
  107. package/server/lib/wallpaper/store.js +87 -0
  108. package/dist/assets/SettingsView-DA-U9lsj.js +0 -11
  109. package/dist/assets/VisualFrame-DBZkHFnG.js +0 -22
  110. package/dist/assets/index-B_L9GVYw.css +0 -1
  111. package/dist/assets/index-CKKWVoND.js +0 -11
  112. package/dist/assets/useAppFontEffects-CV5UyTRw.js +0 -226
  113. package/server/lib/pi/session-daemon/pichamber-ui.js +0 -44
@@ -20,7 +20,6 @@ import {
20
20
  } from '@earendil-works/pi-coding-agent';
21
21
 
22
22
  import {
23
- MAX_EXTENSION_APP_HTML_CHARS,
24
23
  isValidCustomInputItems,
25
24
  sanitizeExtensionFormFields,
26
25
  validateExtensionFormValues,
@@ -29,11 +28,10 @@ import { createPiModelConfigStore } from '../model-config-store.js';
29
28
  import { clampThinkingLevel, getSupportedThinkingLevels, isPiThinkingLevel } from '../thinking-levels.js';
30
29
  import {
31
30
  createExtensionBridge,
32
- extractExtensionDescriptor,
33
31
  isDisplayedExtensionEntryType,
34
- isIddExtensionEntry,
32
+ isRetiredExtensionEntry,
35
33
  } from './extension-bridge.js';
36
- import { commandName, createComposerControlsExtension, isComposerControlsExtensionPath } from './extension-controls.js';
34
+ import { commandName, normalizeExtensionCommandArgs, parseExtensionCommandName } from '../extension-commands.js';
37
35
  import { resolveExtensionName } from './extension-name.js';
38
36
  import { createExtensionTheme } from './extension-theme.js';
39
37
  import {
@@ -85,7 +83,7 @@ import { createSessionEngineRouter } from './session-engine-router.js';
85
83
  import { createPendingInputIndex } from './pending-input.js';
86
84
  import { createExtensionCustomHost } from './extension-custom-host.js';
87
85
  import { resolveExtensionMode } from './extension-ui-mode.js';
88
- import { createPichamberUi } from './pichamber-ui.js';
86
+ import { createPichamberApi } from './pichamber-api.js';
89
87
  import { createExtensionPaletteResolver, isTerminalColors } from './extension-palette.js';
90
88
 
91
89
  const textFromContent = (content) => (
@@ -98,8 +96,10 @@ const textFromContent = (content) => (
98
96
  // Extensions should use optional detection, e.g.:
99
97
  // const marker = (globalThis as any).__PICHAMBER__;
100
98
  // or `process.env.PICHAMBER === "1"`. The object is frozen and versioned.
101
- // `globalThis.pichamber` holds PiChamber's own dialog calls (`pichamber.ui`),
102
- // kept off Pi's `ctx.ui` so a method Pi adds later cannot be shadowed.
99
+ // `globalThis.pichamber` is the extension API (pichamber-api.js), kept off
100
+ // Pi's `ctx.ui` so a method Pi adds later cannot be shadowed. Its presence is
101
+ // the documented way to detect PiChamber; `__PICHAMBER__` is the marker
102
+ // extensions written for 1.0.6 and 1.0.7 check.
103
103
  if (!globalThis.__PICHAMBER__) {
104
104
  try {
105
105
  globalThis.__PICHAMBER__ = Object.freeze({
@@ -115,7 +115,7 @@ if (!globalThis.__PICHAMBER__) {
115
115
  }
116
116
  if (!globalThis.pichamber) {
117
117
  try {
118
- globalThis.pichamber = Object.freeze({ version: 1, ui: createPichamberUi() });
118
+ globalThis.pichamber = createPichamberApi();
119
119
  } catch {}
120
120
  }
121
121
  if (!process.env.PICHAMBER) {
@@ -172,12 +172,10 @@ export async function createPiSessionRuntime({ cwd, agentDir = getAgentDir(), se
172
172
  cwd: runtimeCwd,
173
173
  agentDir: runtimeAgentDir,
174
174
  resourceLoaderOptions: {
175
- // PiChamber plugins load after Pi's built-ins (plugin-host.js); the
176
- // composer-controls listener loads last (extension-controls.js).
175
+ // PiChamber plugins load after Pi's built-ins (plugin-host.js).
177
176
  extensionFactories: [
178
177
  ...getBuiltinExtensionFactories(),
179
178
  ...(hooks?.pluginExtensionFactories?.() ?? []),
180
- ...(hooks?.internalExtensionFactories?.() ?? []),
181
179
  ],
182
180
  },
183
181
  });
@@ -453,6 +451,17 @@ export function createSessionDaemon({
453
451
  const retryStateBySession = new Map();
454
452
  const compactionStateBySession = new Map();
455
453
  const activeRunStartedAt = new Map();
454
+ // Model and thinking changes clients asked for (sessions.setModel /
455
+ // setThinking), counted per session, so a command's before/after
456
+ // comparison never credits another client's change to the extension.
457
+ const clientModelChangesBySession = new Map();
458
+ // Sequence of the last `session.model` an extension command chose; sent
459
+ // with session details and snapshots so a reconnecting composer still
460
+ // sees a choice it missed live.
461
+ const extensionModelSequenceBySession = new Map();
462
+ const noteClientModelChange = (sessionId) => {
463
+ clientModelChangesBySession.set(sessionId, (clientModelChangesBySession.get(sessionId) ?? 0) + 1);
464
+ };
456
465
  const sendGenerationBySession = new Map();
457
466
  const settledSendGenerationBySession = new Map();
458
467
  // Pi's reload() is identity-preserving but is not safe during a turn,
@@ -715,7 +724,7 @@ export function createSessionDaemon({
715
724
  cwd: outsideSandbox(targetCwd),
716
725
  agentDir,
717
726
  resourceLoaderOptions: {
718
- extensionFactories: [...getBuiltinExtensionFactories(), ...pluginHost.extensionFactories(), ...internalExtensionFactories()],
727
+ extensionFactories: [...getBuiltinExtensionFactories(), ...pluginHost.extensionFactories()],
719
728
  },
720
729
  });
721
730
 
@@ -858,6 +867,16 @@ export function createSessionDaemon({
858
867
  || (runtime?.session?.sessionId === sessionId ? runtime : undefined),
859
868
  getDefaultDirectory: () => defaultDirectory(),
860
869
  getSequence: () => sequence,
870
+ // What `pi.appendEntry` does, for `pichamber.card(ctx, ...)`, which has
871
+ // the session but not the extension's `pi`. It writes through the
872
+ // extension's own session, as `pi.appendEntry` does, so a card made in
873
+ // `session_start` (before the runtime is registered) is saved too.
874
+ appendSessionEntry: (session, customType, data) => {
875
+ const manager = session?.sessionManager;
876
+ if (!manager) throw new Error('The session is no longer available.');
877
+ const entry = manager.getEntry(manager.appendCustomEntry(customType, data));
878
+ if (entry) publishSessionEvent(session.sessionId, { type: 'entry_appended', entry }, manager.getCwd?.());
879
+ },
861
880
  protocolError: (code, message) => new SessionDaemonProtocolError(code, message),
862
881
  renderExtensionMessage: (session, message) => extensionMessageRenderer.renderMessage(session, message),
863
882
  requestSessionShutdown: (sessionId) => shutdownRequestedBySession.add(sessionId),
@@ -865,12 +884,6 @@ export function createSessionDaemon({
865
884
  customHost,
866
885
  resolveExtensionMode: resolveBindingExtensionMode,
867
886
  });
868
- // Factories PiChamber itself adds to every runtime, after plugins: the
869
- // listener for composer controls extensions declare on `pi.events`.
870
- const composerControlsExtension = createComposerControlsExtension(
871
- (sessionId, data) => extensionBridge.setComposerControl(sessionId, data),
872
- );
873
- const internalExtensionFactories = () => [composerControlsExtension];
874
887
 
875
888
  // `custom()` commands from browsers. Unknown or closed surfaces answer
876
889
  // `accepted: false` instead of throwing, like stale dialog responses, so a
@@ -925,9 +938,6 @@ export function createSessionDaemon({
925
938
  const {
926
939
  buildExtensionBindings,
927
940
  clearExtensionState,
928
- mirrorExtensionApp,
929
- mirrorExtensionPanel,
930
- rebuildSessionPanelsAndApps,
931
941
  publishExtensionCustomMessage,
932
942
  reloadSession,
933
943
  resolveExtensionDialog,
@@ -935,13 +945,6 @@ export function createSessionDaemon({
935
945
  resetExtensionDraft,
936
946
  } = extensionBridge;
937
947
 
938
- const rebuildSessionExtensionState = (activeRuntime) => {
939
- const session = activeRuntime?.session;
940
- if (!session?.sessionId) return;
941
- const entries = session.sessionManager?.getBranch?.() ?? session.sessionManager?.getEntries?.();
942
- rebuildSessionPanelsAndApps(session.sessionId, Array.isArray(entries) ? entries : []);
943
- };
944
-
945
948
  // Thread extension hooks through our own default factory. Injected test or
946
949
  // host factories keep their single-argument contract and ignore the hooks.
947
950
  const baseCreateRuntime = injectCreateRuntime
@@ -949,7 +952,6 @@ export function createSessionDaemon({
949
952
  const createRuntime = (runtimeOptions, extraHooks) => baseCreateRuntime(runtimeOptions, {
950
953
  createExtensionBindings: buildExtensionBindings,
951
954
  pluginExtensionFactories: pluginHost.extensionFactories,
952
- internalExtensionFactories,
953
955
  ...extraHooks,
954
956
  });
955
957
 
@@ -1045,6 +1047,7 @@ export function createSessionDaemon({
1045
1047
  } : { steering: 0, followUp: 0 },
1046
1048
  ...(model?.provider && model?.id ? { model: { providerId: model.provider, modelId: model.id } } : {}),
1047
1049
  ...(activeSession?.thinkingLevel ? { thinking: activeSession.thinkingLevel } : {}),
1050
+ ...(session.sessionId && extensionModelSequenceBySession.has(session.sessionId) ? { extensionModelSequence: extensionModelSequenceBySession.get(session.sessionId) } : {}),
1048
1051
  ...(typeof lastAssistant?.text === 'string' ? { lastText: lastAssistant.text } : {}),
1049
1052
  ...(typeof lastAssistant?.thinking === 'string' ? { lastThinking: lastAssistant.thinking } : {}),
1050
1053
  ...(session.sessionId && activeRunStartedAt.has(session.sessionId) ? { runStartedAt: activeRunStartedAt.get(session.sessionId) } : {}),
@@ -1056,8 +1059,6 @@ export function createSessionDaemon({
1056
1059
  extensionControls: extensionSnapshot.controls ?? [],
1057
1060
  ...(extensionSnapshot.widgets ? { extensionWidgets: extensionSnapshot.widgets } : {}),
1058
1061
  ...(extensionSnapshot.dialogs ? { extensionDialogs: extensionSnapshot.dialogs } : {}),
1059
- ...(extensionSnapshot.panels ? { extensionPanels: extensionSnapshot.panels } : {}),
1060
- ...(extensionSnapshot.apps ? { extensionApps: extensionSnapshot.apps } : {}),
1061
1062
  ...(extensionSnapshot.title ? { extensionTitle: extensionSnapshot.title } : {}),
1062
1063
  ...(extensionSnapshot.working ? { extensionWorking: extensionSnapshot.working } : {}),
1063
1064
  ...(extensionSnapshot.draftTracked ? { extensionDraftTracked: true } : {}),
@@ -1243,7 +1244,6 @@ export function createSessionDaemon({
1243
1244
  // No client asked for it, so listings skip it until it holds a
1244
1245
  // conversation or a name.
1245
1246
  if (!sessionFile && newRuntime.session) implicitSessions.add(newRuntime.session);
1246
- rebuildSessionExtensionState(newRuntime);
1247
1247
  if (activate) {
1248
1248
  runtime = newRuntime;
1249
1249
  activeDirectory = canonicalRuntimeCwd;
@@ -1532,6 +1532,8 @@ export function createSessionDaemon({
1532
1532
  const released = releaseResult?.released === true;
1533
1533
  shutdownRequestedBySession.delete(sessionId);
1534
1534
  compactionStateBySession.delete(sessionId);
1535
+ clientModelChangesBySession.delete(sessionId);
1536
+ extensionModelSequenceBySession.delete(sessionId);
1535
1537
  userBash.clearSession(sessionId);
1536
1538
  if (targetRuntime === runtime) runtime = undefined;
1537
1539
  // Publish only after a successful lease release so a
@@ -1675,7 +1677,8 @@ export function createSessionDaemon({
1675
1677
  case 'sessions.abortBash':
1676
1678
  case 'sessions.delete':
1677
1679
  case 'sessions.rename':
1678
- case 'extensions.control': {
1680
+ case 'extensions.control':
1681
+ case 'extensions.command': {
1679
1682
  const candidate = message?.payload?.sessionId;
1680
1683
  return isValidIdleSessionId(candidate) ? candidate : undefined;
1681
1684
  }
@@ -2015,7 +2018,6 @@ export function createSessionDaemon({
2015
2018
  }
2016
2019
  runtime = newRuntime;
2017
2020
  activeDirectory = directory;
2018
- rebuildSessionExtensionState(newRuntime);
2019
2021
  rememberRuntimeSession();
2020
2022
  return newRuntime;
2021
2023
  };
@@ -2111,14 +2113,12 @@ export function createSessionDaemon({
2111
2113
  let latestUserMessageId;
2112
2114
  return entries.flatMap((entry) => {
2113
2115
  // Extension-authored content: displayed custom messages (`sendMessage`)
2114
- // and PiChamber GUI entries (`appendEntry('pichamber.*')`) without a stable
2115
- // id surface as one-off extension-role transcript items. Other custom entries
2116
- // are private extension state that Pi never displays, and entries with a
2117
- // stable id are mirrored into live panels/apps instead, so they stay out of the
2118
- // transcript.
2116
+ // and PiChamber cards (`pichamber.card`, or `pichamber.ui` from 1.0.6)
2117
+ // surface as extension-role transcript items. Other custom entries are
2118
+ // private extension state that Pi never displays.
2119
2119
  if (entry?.type === 'custom') {
2120
2120
  if (!isDisplayedExtensionEntryType(entry.customType) || typeof entry.id !== 'string') return [];
2121
- if (isIddExtensionEntry(entry)) return [];
2121
+ if (isRetiredExtensionEntry(entry)) return [];
2122
2122
  const timestamp = Date.parse(entry.timestamp);
2123
2123
  return [{
2124
2124
  message: {
@@ -2420,6 +2420,7 @@ export function createSessionDaemon({
2420
2420
  ...(session.sessionName ? { title: session.sessionName } : {}),
2421
2421
  ...(sessionModel ? { model: sessionModel } : {}),
2422
2422
  ...(sessionThinking ? { thinking: sessionThinking } : {}),
2423
+ ...(extensionModelSequenceBySession.has(session.sessionId) ? { extensionModelSequence: extensionModelSequenceBySession.get(session.sessionId) } : {}),
2423
2424
  messageCount: allMessages.length,
2424
2425
  },
2425
2426
  messages: page.messages,
@@ -2438,8 +2439,6 @@ export function createSessionDaemon({
2438
2439
  extensionControls: extensionSnapshot.controls ?? [],
2439
2440
  ...(extensionSnapshot.widgets ? { extensionWidgets: extensionSnapshot.widgets } : {}),
2440
2441
  ...(extensionSnapshot.dialogs ? { extensionDialogs: extensionSnapshot.dialogs } : {}),
2441
- ...(extensionSnapshot.panels ? { extensionPanels: extensionSnapshot.panels } : {}),
2442
- ...(extensionSnapshot.apps ? { extensionApps: extensionSnapshot.apps } : {}),
2443
2442
  ...(extensionSnapshot.title ? { extensionTitle: extensionSnapshot.title } : {}),
2444
2443
  ...(extensionSnapshot.working ? { extensionWorking: extensionSnapshot.working } : {}),
2445
2444
  ...(extensionSnapshot.draftTracked ? { extensionDraftTracked: true } : {}),
@@ -2725,13 +2724,11 @@ export function createSessionDaemon({
2725
2724
  // A draft is not the daemon's active session and is not remembered
2726
2725
  // for a restart: nothing has been sent in it. It gets the idle
2727
2726
  // lifetime of any view-only session, so an abandoned draft goes away.
2728
- rebuildSessionExtensionState(newRuntime);
2729
2727
  touchIdleDisposal(newRuntime.session.sessionId);
2730
2728
  return projectActiveSession(newRuntime, targetCwd);
2731
2729
  }
2732
2730
  runtime = newRuntime;
2733
2731
  activeDirectory = targetCwd;
2734
- rebuildSessionExtensionState(newRuntime);
2735
2732
  rememberRuntimeSession();
2736
2733
  const created = projectActiveSession(newRuntime, targetCwd);
2737
2734
  const createdTitle = created.session.title
@@ -4143,8 +4140,13 @@ export function createSessionDaemon({
4143
4140
  // `requireExtensionCommand`: the text must be a command the session's
4144
4141
  // extensions register once the runtime is settled, or nothing runs. A
4145
4142
  // composer control sets it, so its `/command` never reaches the model as a
4146
- // prompt when a queued recreation drops the extension behind it.
4147
- const runSessionInput = async (payload, delivery, { keepDraft = false, requireExtensionCommand = false } = {}) => {
4143
+ // prompt when a queued recreation drops the extension behind it, and so does
4144
+ // a card action (`extensions.command`), which answers `COMMAND_UNAVAILABLE`.
4145
+ const runSessionInput = async (payload, delivery, {
4146
+ keepDraft = false,
4147
+ requireExtensionCommand = false,
4148
+ unavailableCode = 'CONTROL_UNAVAILABLE',
4149
+ } = {}) => {
4148
4150
  if (!payload || typeof payload !== 'object' || typeof payload.sessionId !== 'string'
4149
4151
  || typeof payload.text !== 'string' || payload.text.length === 0 || Buffer.byteLength(payload.text) > 64 * 1024) {
4150
4152
  throw new SessionDaemonProtocolError('INVALID_PROMPT', 'The session prompt is invalid.');
@@ -4216,7 +4218,9 @@ export function createSessionDaemon({
4216
4218
  && registeredExtensionCommands.some((command) => command?.invocationName === slashInvocation),
4217
4219
  );
4218
4220
  if (requireExtensionCommand && !isExtensionCommand) {
4219
- throw new SessionDaemonProtocolError('CONTROL_UNAVAILABLE', 'The command for this control is not available.');
4221
+ throw new SessionDaemonProtocolError(unavailableCode, unavailableCode === 'CONTROL_UNAVAILABLE'
4222
+ ? 'The command for this control is not available.'
4223
+ : 'The extension command is not available.');
4220
4224
  }
4221
4225
  // Like the Pi CLI, never persist an auto-title. Lists derive the display
4222
4226
  // title from the first user prompt; publish that derived title live (not
@@ -4258,6 +4262,8 @@ export function createSessionDaemon({
4258
4262
  const prevModel = activeRuntime.session?.model
4259
4263
  ? { provider: activeRuntime.session.model.provider, id: activeRuntime.session.model.id }
4260
4264
  : null;
4265
+ const prevThinking = activeRuntime.session?.thinkingLevel;
4266
+ const prevClientModelChanges = clientModelChangesBySession.get(payload.sessionId) ?? 0;
4261
4267
  let promptPromise;
4262
4268
  // A command's custom() surfaces are titled with its name (see
4263
4269
  // describeCustomOrigin). Cleared when the command settles.
@@ -4376,12 +4382,27 @@ export function createSessionDaemon({
4376
4382
  if (!shouldRetain) {
4377
4383
  removeUserStart(payload.sessionId, generation);
4378
4384
  }
4379
- if (sendGenerationBySession.get(payload.sessionId) !== generation) return;
4380
4385
  const curModel = activeRuntime.session?.model;
4381
- if (
4382
- curModel?.provider && curModel?.id
4383
- && (curModel.provider !== prevModel?.provider || curModel.id !== prevModel?.id)
4384
- ) {
4386
+ const modelChanged = curModel?.provider !== prevModel?.provider || curModel?.id !== prevModel?.id;
4387
+ // An extension command that switched the model or thinking (a mode
4388
+ // command such as /balance) made a choice of its own: `source:
4389
+ // 'extension'` tells clients to replace any unsent composer pick with
4390
+ // it, also when only thinking changed and the model stayed the same.
4391
+ // A change a client asked for while the command ran is that client's,
4392
+ // so it is not credited to the extension. This belongs to the command,
4393
+ // not the send generation: a steer sent while it ran must not skip it.
4394
+ const extensionChoice = isExtensionCommand
4395
+ && (clientModelChangesBySession.get(payload.sessionId) ?? 0) === prevClientModelChanges
4396
+ && (modelChanged || activeRuntime.session?.thinkingLevel !== prevThinking);
4397
+ if (extensionChoice && curModel?.provider && curModel?.id) {
4398
+ publish('session.model', {
4399
+ model: { providerId: curModel.provider, modelId: curModel.id },
4400
+ source: 'extension',
4401
+ }, payload.sessionId, activeRuntime.cwd);
4402
+ extensionModelSequenceBySession.set(payload.sessionId, sequence);
4403
+ }
4404
+ if (sendGenerationBySession.get(payload.sessionId) !== generation) return;
4405
+ if (modelChanged && !extensionChoice && curModel?.provider && curModel?.id) {
4385
4406
  publish('session.model', {
4386
4407
  model: { providerId: curModel.provider, modelId: curModel.id },
4387
4408
  }, payload.sessionId, activeRuntime.cwd);
@@ -4497,6 +4518,43 @@ export function createSessionDaemon({
4497
4518
  return { ran: true };
4498
4519
  };
4499
4520
 
4521
+ // A click on a card action:
4522
+ // the extension's own command, run the way a composer control runs one.
4523
+ // The name must be one the session's extensions register right now
4524
+ // (`COMMAND_UNAVAILABLE` otherwise), so a typo or a stale card never
4525
+ // reaches the model as a prompt, and it runs at once, also mid-turn,
4526
+ // without adding anything to the transcript.
4527
+ const runExtensionCommand = async (payload) => {
4528
+ const sessionId = payload?.sessionId;
4529
+ const name = parseExtensionCommandName(payload?.command);
4530
+ if (typeof sessionId !== 'string' || sessionId.length === 0 || sessionId.length > 256 || !name
4531
+ || (payload.args !== undefined && typeof payload.args !== 'string')) {
4532
+ throw new SessionDaemonProtocolError('INVALID_ARGUMENT', 'The command request is invalid.');
4533
+ }
4534
+ const args = normalizeExtensionCommandArgs(payload.args);
4535
+ const target = runtimeRegistry?.findBySessionId(sessionId)
4536
+ || (runtime?.session?.sessionId === sessionId ? runtime : undefined)
4537
+ || await activateSession(sessionId, payload.directory);
4538
+ const registered = target?.session?.extensionRunner?.getRegisteredCommands?.();
4539
+ if (!Array.isArray(registered) || !registered.some((command) => command?.invocationName === name)) {
4540
+ throw new SessionDaemonProtocolError('COMMAND_UNAVAILABLE', 'The extension command is not available.');
4541
+ }
4542
+ const clientId = typeof payload.clientId === 'string' && payload.clientId.length > 0 && payload.clientId.length <= 128
4543
+ ? payload.clientId
4544
+ : undefined;
4545
+ await runSessionInput({
4546
+ sessionId,
4547
+ text: args ? `/${name} ${args}` : `/${name}`,
4548
+ directory: target.cwd,
4549
+ ...(clientId ? { clientId } : {}),
4550
+ }, target.session.isStreaming ? 'steer' : undefined, {
4551
+ keepDraft: true,
4552
+ requireExtensionCommand: true,
4553
+ unavailableCode: 'COMMAND_UNAVAILABLE',
4554
+ });
4555
+ return { ran: true };
4556
+ };
4557
+
4500
4558
  const treeForSession = async (sessionId, requestedDirectory) => {
4501
4559
  // Idle protection is owned by the request-dispatch guard; the release
4502
4560
  // re-arms even when projection below throws.
@@ -4687,26 +4745,14 @@ export function createSessionDaemon({
4687
4745
  case 'entry_appended': {
4688
4746
  const entry = event.entry;
4689
4747
  if (entry?.type !== 'custom' || !isDisplayedExtensionEntryType(entry.customType)) break;
4690
- const descriptor = extractExtensionDescriptor(entry);
4691
- const isIdd = isIddExtensionEntry(entry);
4692
- if (!isIdd) {
4693
- const timestamp = Date.parse(entry.timestamp);
4694
- publish('extension.entry', {
4695
- id: typeof entry.id === 'string' ? entry.id : `ext-${sessionId}-${sequence + 1}`,
4696
- customType: entry.customType,
4697
- ...(entry.data !== undefined ? { data: redactAttachmentValues(entry.data) } : {}),
4698
- createdAt: Number.isFinite(timestamp) ? timestamp : Date.now(),
4699
- }, sessionId, directory);
4700
- }
4701
- // Declarative GUI payloads are additionally mirrored into normalized
4702
- // live state so panels/apps update in place and survive reconnects.
4703
- if (descriptor) {
4704
- if (entry.customType === 'pichamber.app') {
4705
- mirrorExtensionApp(sessionId, descriptor, directory);
4706
- } else {
4707
- mirrorExtensionPanel(sessionId, descriptor, directory);
4708
- }
4709
- }
4748
+ if (isRetiredExtensionEntry(entry)) break;
4749
+ const timestamp = Date.parse(entry.timestamp);
4750
+ publish('extension.entry', {
4751
+ id: typeof entry.id === 'string' ? entry.id : `ext-${sessionId}-${sequence + 1}`,
4752
+ customType: entry.customType,
4753
+ ...(entry.data !== undefined ? { data: redactAttachmentValues(entry.data) } : {}),
4754
+ createdAt: Number.isFinite(timestamp) ? timestamp : Date.now(),
4755
+ }, sessionId, directory);
4710
4756
  break;
4711
4757
  }
4712
4758
  case 'tool_execution_start': {
@@ -4957,7 +5003,9 @@ export function createSessionDaemon({
4957
5003
  if (event.model?.provider && event.model?.id) {
4958
5004
  publish('session.model', {
4959
5005
  model: { providerId: event.model.provider, modelId: event.model.id },
5006
+ ...(event.source === 'extension' ? { source: 'extension' } : {}),
4960
5007
  }, sessionId, directory);
5008
+ if (event.source === 'extension') extensionModelSequenceBySession.set(sessionId, sequence);
4961
5009
  }
4962
5010
  break;
4963
5011
  case 'thinking_level_changed':
@@ -5044,6 +5092,16 @@ export function createSessionDaemon({
5044
5092
  protocolVersion: PROTOCOL_VERSION,
5045
5093
  pendingInput,
5046
5094
  getSequence: () => sequence,
5095
+ // What `pi.appendEntry` does, for `pichamber.card(ctx, ...)`, which has
5096
+ // the session but not the extension's `pi`. It writes through the
5097
+ // extension's own session, as `pi.appendEntry` does, so a card made in
5098
+ // `session_start` (before the runtime is registered) is saved too.
5099
+ appendSessionEntry: (session, customType, data) => {
5100
+ const manager = session?.sessionManager;
5101
+ if (!manager) throw new Error('The session is no longer available.');
5102
+ const entry = manager.getEntry(manager.appendCustomEntry(customType, data));
5103
+ if (entry) publishSessionEvent(session.sessionId, { type: 'entry_appended', entry }, manager.getCwd?.());
5104
+ },
5047
5105
  });
5048
5106
 
5049
5107
  const handleRequest = async (socket, message) => {
@@ -5086,7 +5144,7 @@ export function createSessionDaemon({
5086
5144
  'sessions.setThinking', 'sessions.discardDraft', 'sessions.compact', 'sessions.bash', 'sessions.abortBash', 'sessions.release', 'engines.list', 'providers.list', 'providers.refresh', 'providers.config.get', 'providers.models.set', 'providers.models.add', 'providers.status', 'providers.hosts', 'providers.oauth.refresh', 'providers.login',
5087
5145
  'providers.login.respond', 'providers.login.status', 'providers.logout', 'settings.get', 'settings.set',
5088
5146
  'resources.list', 'resources.update', 'resources.prompts.create', 'resources.prompts.update', 'resources.prompts.delete',
5089
- 'extensions.list', 'extensions.respond', 'extensions.control', 'extensions.draft', 'extensions.palette',
5147
+ 'extensions.list', 'extensions.respond', 'extensions.control', 'extensions.command', 'extensions.draft', 'extensions.palette',
5090
5148
  'extensions.config.list', 'extensions.config.set', 'extensions.packages.remove',
5091
5149
  'extensions.packages.install', 'extensions.packages.update',
5092
5150
  'openUrl.publish', 'archive.publish', 'plugins.configure',
@@ -5337,6 +5395,11 @@ export function createSessionDaemon({
5337
5395
  writeFrame(socket, { protocolVersion: PROTOCOL_VERSION, kind: 'response', requestId: message.requestId, result });
5338
5396
  return;
5339
5397
  }
5398
+ case 'extensions.command': {
5399
+ const result = await runExtensionCommand(message.payload);
5400
+ writeFrame(socket, { protocolVersion: PROTOCOL_VERSION, kind: 'response', requestId: message.requestId, result });
5401
+ return;
5402
+ }
5340
5403
  case 'extensions.custom.input':
5341
5404
  case 'extensions.custom.viewport':
5342
5405
  case 'extensions.custom.close':
@@ -5390,8 +5453,6 @@ export function createSessionDaemon({
5390
5453
  directory: activeRuntime.cwd,
5391
5454
  extensions: (Array.isArray(extensionPaths) ? extensionPaths : [])
5392
5455
  .filter((extensionPath) => typeof extensionPath === 'string' && extensionPath.length > 0)
5393
- // PiChamber's own listener is part of the app, not an extension.
5394
- .filter((extensionPath) => !isComposerControlsExtensionPath(extensionPath))
5395
5456
  // Opaque id only: server filesystem paths must never reach the
5396
5457
  // browser (see DOCUMENTATION.md route invariants).
5397
5458
  .map((extensionPath) => ({
@@ -5529,7 +5590,6 @@ export function createSessionDaemon({
5529
5590
  }
5530
5591
  case 'sessions.open': {
5531
5592
  const activeRuntime = await activateSession(message.payload?.sessionId, message.payload?.directory || message.payload?.cwd);
5532
- rebuildSessionExtensionState(activeRuntime);
5533
5593
  const detail = projectActiveSession(activeRuntime, activeRuntime.cwd, { limit: message.payload?.limit });
5534
5594
  writeDetailResponse(socket, message.requestId, detail);
5535
5595
  return;
@@ -5592,7 +5652,6 @@ export function createSessionDaemon({
5592
5652
  const previousLeafId = activeRuntime.session.sessionManager?.getLeafId?.() ?? null;
5593
5653
  const result = await activeRuntime.session.navigateTree(messageId);
5594
5654
  if (result?.cancelled) throw new SessionDaemonProtocolError('SESSION_TREE_NOT_FOUND', 'Pi cancelled tree navigation.');
5595
- rebuildSessionExtensionState(activeRuntime);
5596
5655
  const newLeafId = activeRuntime.session.sessionManager?.getLeafId?.() ?? null;
5597
5656
  const navigation = {
5598
5657
  targetEntryId: messageId,
@@ -5623,7 +5682,6 @@ export function createSessionDaemon({
5623
5682
  await acquireResidentLease({ cwd: activeRuntime.cwd, sessionId: activeRuntime.session.sessionId });
5624
5683
  }
5625
5684
  rememberRuntimeSession();
5626
- rebuildSessionExtensionState(activeRuntime);
5627
5685
  const forkedDetail = projectActiveSession(activeRuntime, activeRuntime.cwd);
5628
5686
  // The guard re-arms the source session on release; arm the forked
5629
5687
  // identity explicitly since it was created inside this dispatch.
@@ -5693,6 +5751,7 @@ export function createSessionDaemon({
5693
5751
  }
5694
5752
  case 'sessions.setModel': {
5695
5753
  const activeRuntime = await activateSession(message.payload?.sessionId, message.payload?.directory || message.payload?.cwd);
5754
+ noteClientModelChange(message.payload.sessionId);
5696
5755
  await setSessionModel(activeRuntime, message.payload?.model);
5697
5756
  publishSessionModel(activeRuntime.session, message.payload.sessionId, activeRuntime.cwd);
5698
5757
  writeFrame(socket, { protocolVersion: PROTOCOL_VERSION, kind: 'response', requestId: message.requestId, result: {} });
@@ -5700,6 +5759,7 @@ export function createSessionDaemon({
5700
5759
  }
5701
5760
  case 'sessions.setThinking': {
5702
5761
  const activeRuntime = await activateSession(message.payload?.sessionId, message.payload?.directory || message.payload?.cwd);
5762
+ noteClientModelChange(message.payload.sessionId);
5703
5763
  applyThinking(activeRuntime, message.payload?.thinking, message.payload.sessionId, activeRuntime.cwd);
5704
5764
  writeFrame(socket, { protocolVersion: PROTOCOL_VERSION, kind: 'response', requestId: message.requestId, result: {} });
5705
5765
  return;
@@ -822,6 +822,74 @@ describe('Pi session daemon spike', () => {
822
822
  await client.close();
823
823
  });
824
824
 
825
+ it('marks a model or thinking choice made by an extension command as the extension\'s', async () => {
826
+ const root = await mkdtemp(join(tmpdir(), 'pichamber-pi-daemon-extension-mode-'));
827
+ const endpoint = testDaemonEndpoint(root);
828
+ const runtime = new FakeRuntime({ cwd: root, session: new FakeSession('pi-session-old') });
829
+ daemon = createSessionDaemon({ endpoint, credential, cwd: root, createRuntime: async () => runtime });
830
+ await daemon.start();
831
+
832
+ const client = connectClient(endpoint);
833
+ await client.authenticate();
834
+ await client.request('sessions.create', { cwd: root });
835
+ const session = runtime.session;
836
+ session.extensionRunner = {
837
+ getRegisteredCommands: () => [{ invocationName: 'balance' }, { invocationName: 'plan' }],
838
+ };
839
+ const prompt = session.prompt.bind(session);
840
+ session.prompt = async (text, options) => {
841
+ await prompt(text, options);
842
+ // A mode command keeps the model and changes only the thinking level.
843
+ if (text === '/balance') session.setThinkingLevel('high');
844
+ };
845
+ const chosen = client.next((frame) => frame.event === 'session.model');
846
+ await client.request('sessions.prompt', { sessionId: 'pi-session-new', text: '/balance' });
847
+ await expect(chosen).resolves.toMatchObject({
848
+ payload: { model: { providerId: 'test', modelId: 'model' }, source: 'extension' },
849
+ });
850
+ // Session details carry the choice's sequence for a client that missed it.
851
+ const { sequence: choiceSequence } = await chosen;
852
+ const detail = await client.request('sessions.open', { sessionId: 'pi-session-new', directory: root });
853
+ expect(detail.result.session.extensionModelSequence).toBe(choiceSequence);
854
+
855
+ // A command that changes neither publishes nothing, so it cannot replace
856
+ // an unsent composer pick. (\`next\` also sees earlier frames, hence the
857
+ // check for a second one.)
858
+ let seen = 0;
859
+ const second = client.next((frame) => frame.event === 'session.model' && ++seen === 2);
860
+ await client.request('sessions.prompt', { sessionId: 'pi-session-new', text: '/plan' });
861
+ await expect(second).rejects.toThrow('Timed out');
862
+ await client.close();
863
+ });
864
+
865
+ it('does not credit a client\'s change during a command to the extension', async () => {
866
+ const root = await mkdtemp(join(tmpdir(), 'pichamber-pi-daemon-extension-mode-'));
867
+ const endpoint = testDaemonEndpoint(root);
868
+ const runtime = new FakeRuntime({ cwd: root, session: new FakeSession('pi-session-old') });
869
+ daemon = createSessionDaemon({ endpoint, credential, cwd: root, createRuntime: async () => runtime });
870
+ await daemon.start();
871
+
872
+ const client = connectClient(endpoint);
873
+ await client.authenticate();
874
+ await client.request('sessions.create', { cwd: root });
875
+ const session = runtime.session;
876
+ session.extensionRunner = { getRegisteredCommands: () => [{ invocationName: 'plan' }] };
877
+ let release;
878
+ const gate = new Promise((resolve) => { release = resolve; });
879
+ const prompt = session.prompt.bind(session);
880
+ // /plan waits (on a dialog, say) and changes nothing itself.
881
+ session.prompt = async (text, options) => {
882
+ await prompt(text, options);
883
+ if (text === '/plan') await gate;
884
+ };
885
+ const credited = client.next((frame) => frame.event === 'session.model' && frame.payload.source === 'extension');
886
+ await client.request('sessions.prompt', { sessionId: 'pi-session-new', text: '/plan' });
887
+ await client.request('sessions.setThinking', { sessionId: 'pi-session-new', thinking: 'high' });
888
+ release();
889
+ await expect(credited).rejects.toThrow('Timed out');
890
+ await client.close();
891
+ });
892
+
825
893
  it('creates a global session from the literal home-directory target', async () => {
826
894
  const root = await mkdtemp(join(tmpdir(), 'pichamber-pi-daemon-'));
827
895
  const endpoint = testDaemonEndpoint(root);
@@ -49,7 +49,8 @@ const PORTABLE_FIELDS = new Set([
49
49
  'recentAgents', 'recentEfforts', 'diffLayoutPreference', 'gitChangesViewMode',
50
50
  'filesViewShowGitignored', 'messageLimit',
51
51
  'responseStyleEnabled', 'responseStylePreset', 'responseStyleCustomInstructions',
52
- 'draftStarters', 'draftStartersVisible', 'draftStartersScheduleTaskAdded',
52
+ 'draftStarters', 'draftStartersVisible', 'draftStartersScheduleTaskAdded', 'draftWallpaper', 'draftWallpaperMotion',
53
+ 'draftWallpaperPicture', 'draftWallpaperInSessions', 'draftWallpaperImageVersion',
53
54
  'autoCreateWorktree', 'globalBehaviorPrompt', 'skillCatalogs', 'messageStreamTransport',
54
55
  ]);
55
56
 
@@ -20,13 +20,13 @@ disabled, and a disabled plugin loads no agent code.
20
20
  `defaultEnabled` (must be false for bundled plugins), `replaceable`
21
21
  (maps to the Pi factory's `replaceable`), `state` (`{ type: 'boolean' | 'enum',
22
22
  scope: 'global' | 'project', default, label, description?, options? }` per key),
23
- `contributes.composerToggles` (`{ id, state, label, icon, description? }`,
23
+ `contributes.controls` (`{ id, kind: 'toggle', state, label, icon, description? }`,
24
24
  bound to a boolean key; optional), `contributes.settings` (ordered keys,
25
25
  never a key a composer toggle sets), and
26
26
  `contributes.ui` (native UI id). The agent half must be a `.js`/`.mjs`
27
27
  module inside the package. The package `version` is the plugin version,
28
28
  its `name` is `packageName`, and its `keywords` (lowercased, at most 16,
29
- without the listing keywords `pi-package` and `pichamber-plugin`) are
29
+ without the listing keywords `pi-package` and `pichamber`) are
30
30
  `keywords`, which the marketplace matches a search against.
31
31
  - `registry.js` reads `packages/web/plugins/registry.json`
32
32
  (`{ version: 1, plugins: [id] }`) and loads each listed folder. An invalid
@@ -152,7 +152,7 @@ Listed in `packages/web/plugins/registry.json`, one folder each:
152
152
  file) or an image file in the project (`path` to a `.png`, `.jpg`, `.webp`,
153
153
  `.gif` or `.svg`, sent as a `data:` URL). It reports the options as a
154
154
  partial result, waits a turn of the event loop so they reach clients first,
155
- then asks with `pichamber.ui.choose(ctx, ...)` and its own tool call id, and returns the
155
+ then asks with `pichamber.choose(ctx, ...)` and its own tool call id, and returns the
156
156
  chosen option and the user's note. The details are
157
157
  `{ title, options, answer }`: `answer` is `{ id, note? }`, `null` when the
158
158
  question was closed, and absent when the client could not ask. Under plain
@@ -1,7 +1,6 @@
1
1
  import { pathToFileURL } from 'node:url';
2
2
 
3
3
  import { defaultPluginState } from './manifest.js';
4
- import { createInertPichamberUi } from '../pi/session-daemon/pichamber-ui.js';
5
4
 
6
5
  // Agent impact is measured, not declared: the server runs a plugin's agent
7
6
  // half once against a recording stand-in for the Pi extension API and reports
@@ -109,13 +108,12 @@ export const measurePluginImpact = async (manifest, {
109
108
  if (typeof factory !== 'function') throw new Error('the agent half has no default export');
110
109
  const recording = createRecordingApi();
111
110
  const defaults = defaultPluginState(manifest);
112
- const pichamber = {
111
+ const plugin = {
113
112
  id: manifest.id,
114
- ui: createInertPichamberUi(),
115
113
  state: () => ({ ...defaults }),
116
114
  onStateChange: () => () => {},
117
115
  };
118
- await withTimeout(Promise.resolve(factory(recording.api, pichamber)), timeoutMs);
116
+ await withTimeout(Promise.resolve(factory(recording.api, plugin)), timeoutMs);
119
117
  return { impact: recording.result() };
120
118
  } catch (error) {
121
119
  return { impact: null, impactError: shortReason(error) };
@@ -22,7 +22,6 @@ describe('plugin impact', () => {
22
22
  const manifest = await fixture(`
23
23
  export default function (pi, pichamber) {
24
24
  if (pichamber.state().on !== true) throw new Error('defaults missing');
25
- pichamber.ui.choose({}, 'T', []).then(() => {});
26
25
  pi.registerTool({ name: 'a_tool', description: 'Does a.', parameters: { type: 'object' } });
27
26
  pi.registerTool({ name: 'b_tool', description: 'Does b.', parameters: { type: 'object' }, exposure: 'deferred' });
28
27
  pi.on('before_agent_start', () => {});