psyclaw 0.29.8 → 0.29.10

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.
@@ -1 +1 @@
1
- {"version":3,"file":"profile.js","sourceRoot":"","sources":["../../../src/ars/profile.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAY,CAAC;AACxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,uDAAgE,CAAC;AACnG,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAkB,CAAC;AACnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,0CAAmD,CAAC;AACvF,MAAM,CAAC,MAAM,kBAAkB,GAAG,kEAA2E,CAAC;AAC9G,MAAM,CAAC,MAAM,uBAAuB,GAAG,sBAA+B,CAAC;AACvE,2GAA2G;AAC3G,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAa,CAAC;AACxD,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,2BAA2B;IAC3B,yBAAyB;CACjB,CAAC;AAEX,MAAM,2BAA2B,GAAG,kDAAkD,CAAC;AACvF,yFAAyF;AACzF,MAAM,CAAC,MAAM,uBAAuB,GAAG,cAAc,CAAC;AAWtD,2GAA2G;AAC3G,MAAM,CAAC,MAAM,kBAAkB,GAA+B;IAC5D;QACE,EAAE,EAAE,QAAQ;QACZ,KAAK,EAAE,eAAe;QACtB,OAAO,EAAE,CAAC,eAAe,CAAC;QAC1B,KAAK,EAAE,6BAA6B;KACrC;IACD;QACE,EAAE,EAAE,cAAc;QAClB,KAAK,EAAE,qBAAqB;QAC5B,OAAO,EAAE,CAAC,qBAAqB,EAAE,iBAAiB,CAAC;QACnD,KAAK,EAAE,4BAA4B;KACpC;IACD;QACE,EAAE,EAAE,WAAW;QACf,KAAK,EAAE,kBAAkB;QACzB,OAAO,EAAE,CAAC,kBAAkB,CAAC;QAC7B,KAAK,EAAE,6BAA6B;KACrC;CACF,CAAC;AAEF,MAAM,UAA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B,CAAC;AAED,SAAS,oBAAoB,CAAC,OAAqC;IACjE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG;QACZ,oBAAoB;QACpB,0VAA0V;KAC3V,CAAC;IACF,MAAM,YAAY,GAAsE;QACtF,MAAM,EAAE;YACN,SAAS,EAAE,wNAAwN;YACnO,OAAO,EAAE,gQAAgQ;SAC1Q;QACD,cAAc,EAAE;YACd,SAAS,EAAE,oPAAoP;YAC/P,OAAO,EAAE,6IAA6I;SACvJ;QACD,SAAS,EAAE;YACT,SAAS,EAAE,8OAA8O;YACzP,OAAO,EAAE,gHAAgH;SAC1H;KACF,CAAC;IACF,KAAK,MAAM,MAAM,IAAI,kBAAkB,EAAE,CAAC;QACxC,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACrC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,QAAuB,EAAE;IACvD,MAAM,OAAO,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC9C,OAAO;QACL,2BAA2B,2BAA2B,EAAE;QACxD,8HAA8H;QAC9H,sRAAsR;QACtR,yZAAyZ;QACzZ,yJAAyJ;QACzJ,uJAAuJ;QACvJ,uKAAuK;QACvK,wNAAwN;QACxN,sNAAsN;QACtN,GAAG,oBAAoB,CAAC,OAAO,CAAC;KACjC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -29,8 +29,10 @@ export const PSYCLAW_IDENTITY_PROMPT = [
29
29
  `For institutionally licensed full text, prefer psyclaw_workbench when available. Never handle credentials or bypass access controls.`,
30
30
  `In analysis mode, soft-takeover clear stats/data-analysis intents into the analysis-plan skill. Ask for a human choice on each proposed analysis (first option = concrete new method; 「已经足够」only as last option). Prefer natural-language confirmation (「可以」); /plan auto skips approval but every result must disclose 未经人审批. Default: local reproducible scripts; MCP only for special backends or explicit request. Never invent numbers. Before and after analysis, initiate crosschecks (/crosscheck or Panel checklist); skipping must mark 未经核对. Write analysis/HANDOFF.md before academic.`,
31
31
  `In academic mode, soft-route only the bundled ARS/Nature/compose allowlist without requiring /skill: from the user; any other skill needs explicit /skill:<name>. Consume HANDOFF and analysis/results; do not re-choose primary statistical tests—switch to analysis if numbers are missing. Call psyclaw_ars_multi_agent for Stage 3 seats instead of simulating reviewers in-session.`,
32
+ `Bundled research workflow skills are already in the npm package: ARS (deep-research, academic-paper, academic-paper-reviewer, academic-pipeline), Nature gap-fill (nature-figure, nature-ref-verifier, nature-polishing), academic-paper-strategist/composer, analysis-plan, academic-grill, and the scholar lenses. Never ask the user to install, download, or /plugin install these. To use them: stay in chat/analysis/academic and speak naturally (soft-route), or use /skill:<name> only when an explicit invoke is clearer—do not open an install conversation.`,
32
33
  `Thinking level cycles with Ctrl+Shift+T (not Ctrl+Shift+Tab — many terminals intercept that chord). Session modes still use Shift+Tab.`,
33
- `/help opens the Panel「使用速览」page (terminal tip only). /grill stays academic-grill. Scholar/journal distillation is recommended install distill-scholar / distill-journal (https://github.com/Exekiel179/distill-skills), not bundled nuwa. Bundled psychology lenses: kahneman/gelman/freud-perspective. Other Huashu flagships remain recommended. /crosscheck (alias /verify) is model-driven cross-verification.`,
34
+ `/help opens the Panel「使用速览」page (terminal tip only). /grill stays academic-grill. Optional recommended installs (not workflow core): distill-scholar / distill-journal (https://github.com/Exekiel179/distill-skills) and other Huashu flagships. Bundled psychology lenses: kahneman/gelman/freud-perspective. /crosscheck (alias /verify) is model-driven cross-verification.`,
35
+ `Use the psyclaw_wake_options tool (label 唤醒选项) whenever the researcher must pick among options or tick a checklist: it opens a Panel modal when the workbench SSE is connected, and always renders the same choices in the CLI. Prefer this over asking the user to type option numbers in free text.`,
34
36
  `Keep PsyClaw's internal governance vocabulary internal in reader-facing prose. Use natural disciplinary language.`,
35
37
  `When the user supplies a dataset without a fully specified question, propose 2-4 answerable questions, recommend one, and treat work as exploratory unless they state confirmatory intent.`,
36
38
  `Protect data minimization in prose. When producing a manuscript, write formal continuous prose in paper/*.md.`,
@@ -42,7 +44,7 @@ export const PSYCLAW_IDENTITY_PROMPT = [
42
44
  `After /init, do not enter a human-decision state for routine execution or repair. Continue through planned file writes, scripts, analysis tools, recoverable downloads, formatting, citation cleanup, missing reporting fields, effect-size and interval completion, and reproducibility recording. Request a researcher decision only when at least two substantively defensible choices remain, evidence and established methods cannot resolve them, and the choice changes the research question, sample treatment, operationalization, estimand, analysis method, or interpretation. Present the alternatives, evidence, consequences, and a recommendation; ask one decision at a time. Credentials, destructive operations, access-control bypass, raw-data overwrite, and external publication follow separate safety limits and are not research-method decisions.`,
43
45
  `For Markdown-to-DOCX export, check for Pandoc first; if it is unavailable, install it after approval and retry. Use python-docx only when a Pandoc installation has actually failed. Do not present manual Word conversion as the primary solution.`,
44
46
  `When a piece of evidence or a source is a Word or Office document (.docx, .xlsx, .pptx), convert it to Markdown or plain text before reading it (use pandoc, or the external MarkItDown tool if it is installed). Never try to read the raw binary. Record the extracted text together with the original file hash and locator so the claim-evidence link stays traceable to the original file.`,
45
- `After /init, the deliverable sequence is staged. After the Markdown analysis report, ask whether the user wants to develop it into a paper. If yes, separately ask whether to conduct literature research (warn that it can take substantial time and offer either a user-selected Skill or the system default), then ask whether to write the full manuscript and which writing Skill to use, then leave peer review for /review and ask which review Skill to use, and only after those stages offer DOCX export. If DOCX is requested before a manuscript exists, clearly export only the academically formatted analysis report and never label it as a paper.`,
47
+ `After /init, the deliverable sequence is staged. After the Markdown analysis report, ask whether the user wants to develop it into a paper. If yes, separately ask whether to conduct literature research (warn that it can take substantial time; default to bundled ARS deep-research via natural language in academic mode—never ask to install ARS), then ask whether to write the full manuscript (default bundled academic-paper / compose skills via chat soft-route), then leave peer review for /review or ARS reviewer seats, and only after those stages offer DOCX export. If DOCX is requested before a manuscript exists, clearly export only the academically formatted analysis report and never label it as a paper.`,
46
48
  `DOCX export defaults to APA 7 format. Before exporting, ask the reader for their preferred citation/output format (APA 7 is the default) and any submission requirements.`,
47
49
  `Manuscript deliverables always land at the convention locations (docs/文档规范.md): the editable Markdown source goes to paper/<name>.md and the APA-7 DOCX export to paper/<name>_APA7.docx. Publish through the psyclaw publish workflow so both files land correctly. Never leave the paper only in outputs/ or the project root. Prefer paper/ as the only manuscript location.`,
48
50
  `Every figure and table must be embedded in the document body, never only mentioned: write the Markdown with image links such as \`![Figure N caption](outputs/figures/figX.png)\` so the DOCX contains the images inline. Never deliver a document whose figures appear only as text references.`,
@@ -53,7 +55,7 @@ export const PSYCLAW_IDENTITY_PROMPT = [
53
55
  `After the reference list is final, export it next to the paper as references.ris (importable by Zotero, EndNote, and RefWorks) AND as references.md formatted as an APA 7 reference list — one hanging-indent entry per line, never a table. Every entry must follow: Author, A. A., & Author, B. B. (Year). Title of the article. Journal Name, Volume(Issue), Pages. https://doi.org/... ; list 1-20 authors in full (APA 7), use an ellipsis for 21+; never include "et al." inside the author list and never leave empty authors, empty volume/issue, duplicated article numbers, or "e82503-e82503"-style page duplication. Every row must come from the verification ledger, never re-typed from memory, and must match the in-text citations one to one.`,
54
56
  `Every time you add an in-text citation while writing the manuscript, record it through the psyclaw_cite tool with the DOI, a one-line reason for citing it at that position, and the sentence context. The system verifies the DOI against Crossref/OpenAlex, archives the reference in .psyclaw/references.jsonl, and appends the citation use with its reason to .psyclaw/citations.jsonl. Never add a citation without registering its reason: the archive must be able to answer "why is this source cited here" for every citation.`,
55
57
  `In an initialized project, store lawfully downloaded scholarly PDFs under literature/pdfs/. Automatically download only verified open-access PDFs; never bypass a paywall, login, CAPTCHA, or access control. When no open-access PDF is available, give the user a clickable https://doi.org/<DOI> link and ask them to download the paper through their own lawful access into literature/pdfs/. Before factual or literature-dependent statements enter manuscript prose, verify them against adequate evidence rather than DOI metadata alone. Before a manuscript is finalized or exported, check every cited DOI: all must be verified and every cited paper must have a recognizable local PDF; list the remaining downloads and explain that finalization should wait until they are supplied.`,
56
- `Figure generation is a top priority: produce every figure through a dedicated local figure skill such as nature-figure instead of hand-rolling matplotlib defaults, and ask the reader whether to install the figure skill when it is not available. Prefer richer charts when the data supports them: forest plots with 95% CI for regression/effect sizes, correlation heatmaps, violin + swarm plots for group comparisons, dumbbell/lollipop charts, radar profiles for dimension structures, waterfall plots, and residual diagnostics (QQ plot, fitted-vs-residual) — a bare ax.bar of means is not acceptable when a richer chart fits the data. For mediation/path/SEM diagrams use a dedicated local tool (Python graphviz dot, R semPlot/lavaan, or semopy semplot), never hand-drawn matplotlib boxes. All figures share one style configuration: 300 DPI PNG plus editable SVG (matplotlib savefig(format="svg"); graphviz format="svg") so the reader can edit shapes and text in PowerPoint/Word/Illustrator, consistent palette and fonts, label sizes ≥9pt, value annotations, correct aspect ratios, no clipped labels, no matplotlib default styling. Because you cannot visually inspect images, validate figures programmatically (size, non-blank content, no overflow warnings) and rely on the figure skill's deterministic output, then embed every figure in the report and the DOCX.`,
58
+ `Figure generation is a top priority: produce every figure through the bundled nature-figure skill (already shipped; never ask to install it) instead of hand-rolling matplotlib defaults. Prefer richer charts when the data supports them: forest plots with 95% CI for regression/effect sizes, correlation heatmaps, violin + swarm plots for group comparisons, dumbbell/lollipop charts, radar profiles for dimension structures, waterfall plots, and residual diagnostics (QQ plot, fitted-vs-residual) — a bare ax.bar of means is not acceptable when a richer chart fits the data. For mediation/path/SEM diagrams use a dedicated local tool (Python graphviz dot, R semPlot/lavaan, or semopy semplot), never hand-drawn matplotlib boxes. All figures share one style configuration: 300 DPI PNG plus editable SVG (matplotlib savefig(format="svg"); graphviz format="svg") so the reader can edit shapes and text in PowerPoint/Word/Illustrator, consistent palette and fonts, label sizes ≥9pt, value annotations, correct aspect ratios, no clipped labels, no matplotlib default styling. Because you cannot visually inspect images, validate figures programmatically (size, non-blank content, no overflow warnings) and rely on the figure skill's deterministic output, then embed every figure in the report and the DOCX.`,
57
59
  `Figures must contain NO Chinese text — no Chinese titles, axis labels, legends, or notes inside the image (Chinese fonts render inconsistently across systems). Use English labels and English notes inside the figure (e.g. "Pearson r", "*p<0.05"); put the figure title and any Chinese explanation as caption text ABOVE or BELOW the figure in the manuscript (a "**图N ...**" line or a markdown image caption), never as set_title inside the image; map Chinese variable names to short English labels inside the figure and give the Chinese names in the caption. Figure colors must be deliberate and attractive, never matplotlib defaults: categorical series use a high-distinction palette such as Okabe-Ito (#0072B2, #D55E00, #009E73, #CC79A7, #56B4E9, #E69F00, #F0E442, #000000); continuous values use RdBu_r / viridis / coolwarm with a colorbar; add value annotations, significance stars, subtle transparency and error bars/CI whiskers with clear styles; avoid grayish corporate colors as the only palette and avoid clashing raw primaries.`,
58
60
  `Never include a cost or token-usage estimate section (such as "成本估算") in the analysis report, paper, or delivery summary; token usage and cost are tracked in the psyclaw panel's Token usage view instead.`,
59
61
  `Heavy research stages — literature search and multi-source verification, full-manuscript writing, DOCX export — consume significant tokens and minutes. If the user has not already requested that stage, briefly explain the expected time and scope and ask whether to expand the task. This is ordinary scope confirmation, not a human-decision workflow state. Once the user requests the stage, proceed without repeated confirmations and use staged or fresh sessions when that reduces cost.`,
@@ -64,8 +66,8 @@ export const PSYCLAW_IDENTITY_PROMPT = [
64
66
  `Keep tool calls lean — every round-trip grows the cached context that every later turn re-reads, so a single session should stay under roughly 40-60 tool calls. Concrete discipline: (1) explore a dataset ONCE with a reusable script that writes a compact profile (shapes, dtypes, missing, ranges) to a JSON, then read/grep that JSON instead of running repeated inline python -c probes — 50+ ad-hoc probes in one session is the single biggest token waste; (2) run the analysis pipeline through the thin entrypoint (run_all.py) and on failure rerun only the failed step, never re-run passing steps; (3) batch related checks into one command with && / ; and reuse the script's saved outputs instead of recomputing; (4) verify writes by exit code, not by ls/cat round-trips; (5) read each file at most once and keep the result; (6) prefer one complete write over many small edits.`,
65
67
  `When a document contains an unresolved substantive research trade-off that meets the researcher-decision threshold, flag it at generation time with a machine-readable marker (for example needs-human-review: true plus one-line reason) and list it under “需研究者决定”. Do not flag routine data checks, automatically repairable reporting omissions, technical setup, formatting, or a single method that follows deterministically from the confirmed design.`,
66
68
  `For writing and review, honor a skill explicitly named by the user. Otherwise choose the closest available skill or the PsyClaw default, state the choice briefly, and proceed; do not turn routine skill routing into a researcher decision.`,
67
- `Before invoking any skill, confirm it is actually available in this session: check whether it is loaded or enabled (for example via .psyclaw/recommendations.json or the panel's enabled-capabilities endpoint), and only invoke it when a tool result proves it works. Never invoke, or claim to have invoked, a skill that is not present.`,
68
- `Match the task to the single best-fitting available skill and state that choice. If a suitable skill exists in psyclaw's recommended catalog or a host Skill directory but is not yet installed or enabled, offer installation or direct user selection; do not silently substitute an unrelated skill. When several skills plausibly fit, choose the closest one by task scope and explain the choice unless the user explicitly asked to select the skill. Skill routing is not a research-method decision.`,
69
+ `Before invoking any skill, confirm it is actually available in this session: check whether it is loaded or enabled (for example via .psyclaw/recommendations.json or the panel's enabled-capabilities endpoint), and only invoke it when a tool result proves it works. Never invoke, or claim to have invoked, a skill that is not present. Bundled ARS/Nature/compose/analysis-plan/grill skills are expected present; if a tool result shows them missing, treat it as a packaging/runtime fault and continue with ARS-native fallbacks—do not solicit /plugin install or recommended install for those.`,
70
+ `Match the task to the single best-fitting available skill and state that choice. Never offer installation for bundled workflow skills (ARS family, Nature gap-fill, academic-paper-strategist/composer, analysis-plan, academic-grill). For non-bundled skills that exist only in the recommended catalog or a host Skill directory, you may offer installation or direct user selection; do not silently substitute an unrelated skill. When several skills plausibly fit, choose the closest one by task scope and explain the choice unless the user explicitly asked to select the skill. Skill routing is not a research-method decision. Prefer natural-language use in the active mode (chat/analysis/academic soft-route) over asking the user to install anything.`,
69
71
  `Rule precedence: the never-fabricate and never-bypass constraints (never invent references, statistics, findings, or review opinions; never skip an evidence gate or approval) always win over any convenience or efficiency consideration; when two rules seem to conflict, the more specific rule wins and, where still ambiguous, choose the behavior that keeps claims verifiable and the user informed.`,
70
72
  ].join("\n");
71
73
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"branding.js","sourceRoot":"","sources":["../../src/branding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAEvE,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC;AAEtC,+FAA+F;AAC/F,MAAM,CAAC,MAAM,eAAe,GAAW,sBAAsB,EAAE,IAAI,OAAO,CAAC;AAE3E,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAE7C,iEAAiE;AACjE,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC;AACxC,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC;AACpC,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC;AACtC,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,WAAW,YAAY,oCAAoC;IAC3D,4BAA4B,YAAY,kDAAkD,YAAY,oKAAoK;IAC1Q,qKAAqK;IACrK,2NAA2N;IAC3N,mYAAmY;IACnY,2PAA2P;IAC3P,6KAA6K;IAC7K,sIAAsI;IACtI,okBAAokB;IACpkB,0XAA0X;IAC1X,wIAAwI;IACxI,oZAAoZ;IACpZ,mHAAmH;IACnH,4LAA4L;IAC5L,+GAA+G;IAC/G,wUAAwU;IACxU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AC/D,CAAC"}
@@ -1,8 +1,10 @@
1
1
  import { closeResearchWorkbench, openResearchWorkbench } from "./workbench.js";
2
+ import { extractAssistantDelta, extractAssistantText, messageIdOf, panelHub, } from "./hub.js";
2
3
  /**
3
4
  * Optional Pi extension for the local web projection. Binding is always loopback.
4
5
  */
5
6
  export default function psyclawPanelExtension(pi) {
7
+ let streamSeq = 0;
6
8
  pi.registerCommand("panel", {
7
9
  description: "打开科研工作台(浏览器)",
8
10
  handler: async (args, ctx) => {
@@ -27,8 +29,44 @@ export default function psyclawPanelExtension(pi) {
27
29
  }
28
30
  },
29
31
  });
30
- pi.on("session_shutdown", async () => {
31
- await closeResearchWorkbench();
32
- });
32
+ if (typeof pi.on === "function") {
33
+ pi.on("message_start", (event) => {
34
+ const message = event.message;
35
+ if (message?.role !== "assistant")
36
+ return;
37
+ const messageId = messageIdOf(event.message, `msg_${++streamSeq}`);
38
+ panelHub.broadcast({ type: "assistant_start", messageId });
39
+ });
40
+ pi.on("message_update", (event) => {
41
+ const message = event.message;
42
+ if (message?.role !== "assistant")
43
+ return;
44
+ const messageId = messageIdOf(event.message, `msg_${streamSeq || ++streamSeq}`);
45
+ const text = extractAssistantText(event.message);
46
+ const delta = extractAssistantDelta(event.assistantMessageEvent);
47
+ if (!delta && !text)
48
+ return;
49
+ panelHub.broadcast({
50
+ type: "assistant_delta",
51
+ messageId,
52
+ delta: delta || "",
53
+ text,
54
+ });
55
+ });
56
+ pi.on("message_end", (event) => {
57
+ const message = event.message;
58
+ if (message?.role !== "assistant")
59
+ return;
60
+ const messageId = messageIdOf(event.message, `msg_${streamSeq || ++streamSeq}`);
61
+ const text = extractAssistantText(event.message);
62
+ panelHub.broadcast({ type: "assistant_end", messageId, text });
63
+ });
64
+ pi.on("agent_settled", () => {
65
+ panelHub.broadcast({ type: "agent_settled" });
66
+ });
67
+ pi.on("session_shutdown", async () => {
68
+ await closeResearchWorkbench();
69
+ });
70
+ }
33
71
  }
34
72
  //# sourceMappingURL=extension.js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C,KAAK,CAAC,OAAO,EAAE,OAAO,SAAS,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;YAChF,MAAM,IAAI,GAAG,oBAAoB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACjD,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;YAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,EAAE,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;YACnC,MAAM,sBAAsB,EAAE,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -0,0 +1,81 @@
1
+ import type { ServerResponse } from "node:http";
2
+ export type WakeOptionsMode = "choice" | "checklist";
3
+ export interface WakeOptionItem {
4
+ id: string;
5
+ label: string;
6
+ description?: string;
7
+ /** Pre-checked for checklist mode. */
8
+ checked?: boolean;
9
+ }
10
+ export interface WakeOptionsPrompt {
11
+ id: string;
12
+ title: string;
13
+ prompt?: string;
14
+ mode: WakeOptionsMode;
15
+ options: WakeOptionItem[];
16
+ allowMultiple?: boolean;
17
+ minSelections?: number;
18
+ /** When true (default for checklist), apply selections to `.psyclaw/verify-checklist.json`. */
19
+ syncVerify?: boolean;
20
+ createdAt: string;
21
+ expiresAt: string;
22
+ }
23
+ export interface WakeOptionsAnswer {
24
+ promptId: string;
25
+ selectedIds: string[];
26
+ source: "panel" | "cli" | "timeout" | "cancel";
27
+ notes?: string;
28
+ }
29
+ export type PanelHubEvent = {
30
+ type: "assistant_start";
31
+ messageId: string;
32
+ } | {
33
+ type: "assistant_delta";
34
+ messageId: string;
35
+ delta: string;
36
+ text: string;
37
+ } | {
38
+ type: "assistant_end";
39
+ messageId: string;
40
+ text: string;
41
+ } | {
42
+ type: "agent_settled";
43
+ } | {
44
+ type: "user_echo";
45
+ text: string;
46
+ } | {
47
+ type: "wake_options";
48
+ prompt: WakeOptionsPrompt;
49
+ } | {
50
+ type: "wake_options_resolved";
51
+ promptId: string;
52
+ answer: WakeOptionsAnswer;
53
+ } | {
54
+ type: "ping";
55
+ at: string;
56
+ };
57
+ /**
58
+ * In-process hub bridging the Pi CLI session and Panel SSE clients.
59
+ * One process owns both the interactive session and the loopback Panel.
60
+ */
61
+ export declare class PanelHub {
62
+ private readonly clients;
63
+ private readonly wakeWaiters;
64
+ private pendingWake;
65
+ subscriberCount(): number;
66
+ /** True when at least one Panel browser tab is listening on SSE. */
67
+ hasPanelClients(): boolean;
68
+ getPendingWake(): WakeOptionsPrompt | undefined;
69
+ subscribe(response: ServerResponse): () => void;
70
+ broadcast(event: PanelHubEvent): void;
71
+ publishWake(prompt: WakeOptionsPrompt, timeoutMs: number): Promise<WakeOptionsAnswer>;
72
+ resolveWake(answer: WakeOptionsAnswer): boolean;
73
+ cancelWake(promptId: string, source?: "panel" | "cli" | "cancel"): boolean;
74
+ }
75
+ /** Process-wide hub shared by workbench server and Pi panel extension. */
76
+ export declare const panelHub: PanelHub;
77
+ /** Extract plain assistant text from a Pi AgentMessage-shaped object. */
78
+ export declare function extractAssistantText(message: unknown): string;
79
+ /** Extract streaming text delta from Pi assistantMessageEvent when present. */
80
+ export declare function extractAssistantDelta(assistantMessageEvent: unknown): string;
81
+ export declare function messageIdOf(message: unknown, fallback: string): string;
@@ -0,0 +1,122 @@
1
+ /**
2
+ * In-process hub bridging the Pi CLI session and Panel SSE clients.
3
+ * One process owns both the interactive session and the loopback Panel.
4
+ */
5
+ export class PanelHub {
6
+ clients = new Set();
7
+ wakeWaiters = new Map();
8
+ pendingWake;
9
+ subscriberCount() {
10
+ return this.clients.size;
11
+ }
12
+ /** True when at least one Panel browser tab is listening on SSE. */
13
+ hasPanelClients() {
14
+ return this.clients.size > 0;
15
+ }
16
+ getPendingWake() {
17
+ return this.pendingWake;
18
+ }
19
+ subscribe(response) {
20
+ this.clients.add(response);
21
+ response.write(`event: ready\ndata: ${JSON.stringify({ ok: true, at: new Date().toISOString() })}\n\n`);
22
+ if (this.pendingWake) {
23
+ response.write(`event: wake_options\ndata: ${JSON.stringify({ type: "wake_options", prompt: this.pendingWake })}\n\n`);
24
+ }
25
+ return () => {
26
+ this.clients.delete(response);
27
+ };
28
+ }
29
+ broadcast(event) {
30
+ const name = event.type;
31
+ const payload = `event: ${name}\ndata: ${JSON.stringify(event)}\n\n`;
32
+ for (const client of this.clients) {
33
+ try {
34
+ client.write(payload);
35
+ }
36
+ catch {
37
+ this.clients.delete(client);
38
+ }
39
+ }
40
+ }
41
+ publishWake(prompt, timeoutMs) {
42
+ if (this.wakeWaiters.has(prompt.id)) {
43
+ return Promise.reject(new Error(`wake-options id already pending: ${prompt.id}`));
44
+ }
45
+ this.pendingWake = prompt;
46
+ this.broadcast({ type: "wake_options", prompt });
47
+ return new Promise((resolve, reject) => {
48
+ const timer = setTimeout(() => {
49
+ this.wakeWaiters.delete(prompt.id);
50
+ if (this.pendingWake?.id === prompt.id)
51
+ this.pendingWake = undefined;
52
+ const answer = {
53
+ promptId: prompt.id,
54
+ selectedIds: [],
55
+ source: "timeout",
56
+ };
57
+ this.broadcast({ type: "wake_options_resolved", promptId: prompt.id, answer });
58
+ resolve(answer);
59
+ }, timeoutMs);
60
+ this.wakeWaiters.set(prompt.id, { resolve, reject, timer });
61
+ });
62
+ }
63
+ resolveWake(answer) {
64
+ const waiter = this.wakeWaiters.get(answer.promptId);
65
+ if (!waiter)
66
+ return false;
67
+ clearTimeout(waiter.timer);
68
+ this.wakeWaiters.delete(answer.promptId);
69
+ if (this.pendingWake?.id === answer.promptId)
70
+ this.pendingWake = undefined;
71
+ this.broadcast({ type: "wake_options_resolved", promptId: answer.promptId, answer });
72
+ waiter.resolve(answer);
73
+ return true;
74
+ }
75
+ cancelWake(promptId, source = "cancel") {
76
+ return this.resolveWake({ promptId, selectedIds: [], source });
77
+ }
78
+ }
79
+ /** Process-wide hub shared by workbench server and Pi panel extension. */
80
+ export const panelHub = new PanelHub();
81
+ /** Extract plain assistant text from a Pi AgentMessage-shaped object. */
82
+ export function extractAssistantText(message) {
83
+ if (!message || typeof message !== "object")
84
+ return "";
85
+ const row = message;
86
+ if (row.role !== undefined && row.role !== "assistant")
87
+ return "";
88
+ if (typeof row.content === "string")
89
+ return row.content;
90
+ if (!Array.isArray(row.content))
91
+ return "";
92
+ return row.content.map((part) => {
93
+ if (typeof part === "string")
94
+ return part;
95
+ if (!part || typeof part !== "object")
96
+ return "";
97
+ const item = part;
98
+ if (item.type === "text" && typeof item.text === "string")
99
+ return item.text;
100
+ return "";
101
+ }).join("");
102
+ }
103
+ /** Extract streaming text delta from Pi assistantMessageEvent when present. */
104
+ export function extractAssistantDelta(assistantMessageEvent) {
105
+ if (!assistantMessageEvent || typeof assistantMessageEvent !== "object")
106
+ return "";
107
+ const event = assistantMessageEvent;
108
+ if (event.type === "text_delta" && typeof event.delta === "string")
109
+ return event.delta;
110
+ if (typeof event.delta === "string")
111
+ return event.delta;
112
+ return "";
113
+ }
114
+ export function messageIdOf(message, fallback) {
115
+ if (message && typeof message === "object") {
116
+ const row = message;
117
+ if (typeof row.id === "string" && row.id.trim())
118
+ return row.id;
119
+ }
120
+ return fallback;
121
+ }
122
+ //# sourceMappingURL=hub.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hub.js","sourceRoot":"","sources":["../../../src/panel/hub.ts"],"names":[],"mappings":"AAiDA;;;GAGG;AACH,MAAM,OAAO,QAAQ;IACF,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IACpC,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;IACrD,WAAW,CAAgC;IAEnD,eAAe;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,oEAAoE;IACpE,eAAe;QAC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AAI,CAAC;QAC1C,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,OAAO,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,IAA0C,CAAC;QACxD,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC,IAAI,CAAC;QAC5E,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,qBAAqB,CAAC,qBAA8B;IAClE,IAAI,CAAC,qBAAqB,IAAI,OAAO,qBAAqB,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACnF,MAAM,KAAK,GAAG,qBAA4E,CAAC;IAC3F,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,KAAK,CAAC;IACvF,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,KAAK,CAAC;IACxD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAgB,EAAE,QAAgB;IAC5D,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC3C,MAAM,GAAG,GAAG,OAA2B,CAAC;QACxC,IAAI,OAAO,GAAG,CAAC,EAAE,KAAK,QAAQ,IAAI,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE;YAAE,OAAO,GAAG,CAAC,EAAE,CAAC;IACjE,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { type Server } from "node:http";
2
+ import { type PanelHub } from "./hub.js";
2
3
  export { verifyDoi } from "../core/doi.js";
3
4
  export interface ProjectDocument {
4
5
  path: string;
@@ -37,6 +38,8 @@ export interface PanelServerOptions {
37
38
  assistant?: (message: string) => Promise<{
38
39
  text: string;
39
40
  }>;
41
+ /** Shared SSE / wake-options hub (defaults to process singleton). */
42
+ hub?: PanelHub;
40
43
  /** Queue an approved installation task into the current PsyClaw model session. */
41
44
  installSkill?: (task: string) => Promise<void>;
42
45
  /** Queue an explicitly requested external-tool installation task. */
@@ -8,6 +8,7 @@ import { getAgentDir } from "@earendil-works/pi-coding-agent";
8
8
  import { listRuns, projectRunSnapshot } from "./projection.js";
9
9
  import { readSessionUsage } from "./usage.js";
10
10
  import { buildClaimLiteratureMap } from "./literature-map.js";
11
+ import { panelHub } from "./hub.js";
11
12
  import { discoverAgents } from "../agents/discover.js";
12
13
  import { KNOWN_AGENTS } from "../agents/catalog.js";
13
14
  import { recommendedAgentsForPanel } from "../agents/recommended-personas.js";
@@ -780,13 +781,22 @@ export function createPanelServer(root, options = {}) {
780
781
  // `dist/apps/panel`, keeping the same relative layout in src and dist.
781
782
  const panelHtmlPath = options.panelHtmlPath ??
782
783
  join(dirname(fileURLToPath(import.meta.url)), "..", "..", "apps", "panel", "index.html");
784
+ const hub = options.hub ?? panelHub;
783
785
  return createServer(async (request, response) => {
784
786
  const url = new URL(request.url ?? "/", "http://localhost");
785
787
  // Read-only surface: any write method is rejected before routing.
786
788
  // The panel is intentionally limited to ecosystem management and Provider
787
789
  // configuration. Project files, runs, evidence and manuscripts are read
788
790
  // only projections; legacy mutation routes remain unavailable over HTTP.
789
- const panelWriteRoutes = ["/api/provider-config", "/api/recommendation-state", "/api/install/execute", "/api/active-provider", "/api/assistant"];
791
+ const panelWriteRoutes = [
792
+ "/api/provider-config",
793
+ "/api/recommendation-state",
794
+ "/api/install/execute",
795
+ "/api/active-provider",
796
+ "/api/assistant",
797
+ "/api/crosscheck",
798
+ "/api/wake-options/respond",
799
+ ];
790
800
  // Kept false for source compatibility with the legacy handler below; the
791
801
  // method gate above makes pause/resume unreachable from the panel API.
792
802
  const runAction = false;
@@ -796,6 +806,72 @@ export function createPanelServer(root, options = {}) {
796
806
  return;
797
807
  }
798
808
  try {
809
+ if (url.pathname === "/api/assistant/stream") {
810
+ response.writeHead(200, {
811
+ "content-type": "text/event-stream; charset=utf-8",
812
+ "cache-control": "no-cache, no-transform",
813
+ connection: "keep-alive",
814
+ "x-accel-buffering": "no",
815
+ });
816
+ response.write(":\n\n");
817
+ const unsubscribe = hub.subscribe(response);
818
+ const heartbeat = setInterval(() => {
819
+ try {
820
+ response.write(`event: ping\ndata: ${JSON.stringify({ type: "ping", at: new Date().toISOString() })}\n\n`);
821
+ }
822
+ catch {
823
+ clearInterval(heartbeat);
824
+ unsubscribe();
825
+ }
826
+ }, 15_000);
827
+ request.on("close", () => {
828
+ clearInterval(heartbeat);
829
+ unsubscribe();
830
+ });
831
+ return;
832
+ }
833
+ if (url.pathname === "/api/wake-options/pending") {
834
+ const prompt = hub.getPendingWake();
835
+ response.writeHead(200, { "content-type": "application/json" });
836
+ response.end(JSON.stringify({
837
+ schemaVersion: "psyclaw/wake-options-pending/v1",
838
+ prompt: prompt ?? null,
839
+ panelClients: hub.subscriberCount(),
840
+ }));
841
+ return;
842
+ }
843
+ if (url.pathname === "/api/wake-options/respond") {
844
+ if (request.method !== "POST") {
845
+ response.writeHead(405, { "content-type": "application/json", allow: "POST" });
846
+ response.end(JSON.stringify({ error: "method not allowed" }));
847
+ return;
848
+ }
849
+ const body = await readJsonBody(request);
850
+ const promptId = String(body.promptId ?? "").trim();
851
+ const selectedIds = Array.isArray(body.selectedIds)
852
+ ? body.selectedIds.filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean)
853
+ : [];
854
+ const cancelled = body.cancel === true;
855
+ if (!promptId) {
856
+ response.writeHead(400, { "content-type": "application/json" });
857
+ response.end(JSON.stringify({ error: "promptId is required" }));
858
+ return;
859
+ }
860
+ const answer = {
861
+ promptId,
862
+ selectedIds: cancelled ? [] : selectedIds,
863
+ source: cancelled ? "cancel" : "panel",
864
+ ...(typeof body.notes === "string" && body.notes.trim() ? { notes: body.notes.trim() } : {}),
865
+ };
866
+ const ok = hub.resolveWake(answer);
867
+ response.writeHead(ok ? 200 : 409, { "content-type": "application/json" });
868
+ response.end(JSON.stringify({
869
+ schemaVersion: "psyclaw/wake-options-receipt/v1",
870
+ ok,
871
+ answer,
872
+ }));
873
+ return;
874
+ }
799
875
  if (url.pathname === "/api/runs") {
800
876
  const runs = await listRuns(root);
801
877
  response.writeHead(200, { "content-type": "application/json" });