@pageops/sdk 0.1.37 → 0.1.38

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.
package/README.md CHANGED
@@ -12,6 +12,11 @@ from the right-side `steps` contract. The middle timeline no longer re-renders
12
12
  the execution cards; it receives only selected model decisions and evidence
13
13
  activities shaped by the backend thought presenter.
14
14
 
15
+ Version `0.1.38` hides node progress in the right sidebar and keeps it only
16
+ inside chat answers, including live updates and historical Run selection. The
17
+ sidebar source-package controls remain available; backend step data is retained
18
+ for cancellation and history.
19
+
15
20
  `src/index.js` is the readable ESM runtime baseline, `src/styles.css` preserves
16
21
  the 0.1.34 styles, and `src/extensions.css` contains the new non-minified style
17
22
  rules. `npm run build` synchronizes ESM, UMD, and CSS under `dist/` without
package/dist/index.d.ts CHANGED
@@ -89,11 +89,9 @@ declare class PageOpsSDKController {
89
89
  private renderMessage;
90
90
  private renderSourceUploader;
91
91
  private renderSourceItem;
92
- private renderSteps;
93
92
  private renderThinkingProcess;
94
93
  private renderThinkingSteps;
95
94
  private renderThinkingTimeline;
96
- private renderExecutionSteps;
97
95
  private bindPanelEvents;
98
96
  }
99
97
  export declare const PageOpsSDK: PageOpsSDKController;
@@ -479,10 +479,18 @@ class V {
479
479
  this.typewriter.clear(), this.waitingForFirstContent = !1, (t = this.abortController) == null || t.abort(), this.abortController = null, e && this.renderPanel();
480
480
  }
481
481
  }
482
+ /**
483
+ * Consume an SSE event without duplicating node progress in the sidebar.
484
+ * Full steps remain available for cancellation; public thoughts update only
485
+ * the answer-local timeline. This method does not make remote requests.
486
+ * @param {string} e Backend event name.
487
+ * @param {object} t Event payload for steps, thoughts, content or completion.
488
+ * @returns {void}
489
+ */
482
490
  handleStreamEvent(e, t) {
483
491
  var s, r;
484
492
  if (e === "step") {
485
- this.upsertStep(t), this.renderExecutionSteps(!0);
493
+ this.upsertStep(t);
486
494
  return;
487
495
  }
488
496
  if (e === "thought") {
@@ -587,7 +595,14 @@ class V {
587
595
  stopSourceRefresh() {
588
596
  this.sourceRefreshTimer && clearTimeout(this.sourceRefreshTimer), this.sourceRefreshTimer = null;
589
597
  }
590
- renderPanel(e = this.asking, t = !1) {
598
+ /**
599
+ * Recreate the chat shell and source controls while keeping progress in answers.
600
+ * Preserve chat scroll unless following the active answer; bind DOM listeners
601
+ * after replacement. The sidebar contains no node progress or auto-scroll.
602
+ * @param {boolean} e Whether to scroll the chat to its latest message.
603
+ * @returns {void} No-op when the SDK panel is closed; no remote requests.
604
+ */
605
+ renderPanel(e = this.asking) {
591
606
  var g;
592
607
  if (!this.panel) return;
593
608
  const s = (g = this.panel.querySelector(".po-messages")) == null ? void 0 : g.scrollTop, r = this.questionUnavailableReason(), n = r || (this.asking ? "回答生成中,请稍候" : this.sourceSnapshots.length ? "请输入页面分析问题,Enter 发送,Shift + Enter 换行" : "可直接闲聊;业务问题需先上传代码包"), c = !!(r || this.asking), p = r ? '<button type="submit" disabled>暂不可提问</button>' : this.asking ? '<button class="po-stop" type="button" data-action="stop-answer" aria-label="停止输出" title="停止输出"><span aria-hidden="true"></span></button>' : '<button type="submit">发送</button>', m = C.map((o) => `
@@ -618,7 +633,7 @@ class V {
618
633
  </section>
619
634
  <form class="po-composer"><textarea ${c ? "disabled" : ""} placeholder="${l(n)}"></textarea>${p}</form>
620
635
  </main>
621
- <aside class="po-trace"><header><h2>执行过程</h2><button data-action="close">×</button></header><section>${this.renderSourceUploader()}<div class="po-steps">${this.renderSteps()}</div></section></aside>
636
+ <aside class="po-trace"><header><h2>执行过程</h2><button data-action="close">×</button></header><section>${this.renderSourceUploader()}</section></aside>
622
637
  `, this.bindPanelEvents(), e) {
623
638
  const o = this.panel.querySelector(".po-messages");
624
639
  o && (o.scrollTop = o.scrollHeight);
@@ -626,10 +641,6 @@ class V {
626
641
  const o = this.panel.querySelector(".po-messages");
627
642
  o && (o.scrollTop = s);
628
643
  }
629
- if (t) {
630
- const o = this.panel.querySelector(".po-trace > section");
631
- o && (o.scrollTop = o.scrollHeight);
632
- }
633
644
  }
634
645
  renderAnswerState() {
635
646
  const n = messageTime(this.activeQuestionStartedAt), c = this.renderThinkingProcess(), e = this.asking && this.waitingForFirstContent ? `<article class="po-message assistant waiting" role="status" aria-live="polite">${n}<b>PageOps 分析</b><div class="po-ai-waiting"><span class="po-ai-spinner" aria-hidden="true"></span><span>正在理解问题并检索证据</span></div>${c}</article>` : "", t = this.streaming ? `<article class="po-message assistant streaming">${n}<b>PageOps 分析</b><div><span data-streaming-content>${R(this.streaming)}</span>${this.asking ? '<span class="po-typing-cursor" aria-hidden="true"></span>' : ""}</div>${c}</article>` : "", s = this.answerError ? `<article class="po-message assistant answer-error" role="alert">${n}<b>PageOps 分析</b><strong>本次回答失败</strong><div>${l(this.answerError)}</div></article>` : "", r = this.answerStopped ? '<div class="po-stream-stopped" role="status">已停止输出</div>' : "";
@@ -683,20 +694,6 @@ class V {
683
694
  const t = e.filename || "未命名代码包", s = e.created_at ? O(e.created_at) : "刚刚上传", r = G(e.archive_bytes || e.total_bytes || 0), n = String((b = (w = e.metadata) == null ? void 0 : w.analysis_status) != null ? b : "unknown"), c = typeof ((S = e.metadata) == null ? void 0 : S.tag) == "string" ? e.metadata.tag : "", p = typeof (($ = e.metadata) == null ? void 0 : $.branch) == "string" ? e.metadata.branch : "", m = c ? `Tag: ${c}` : p ? `Branch: ${p}` : "未记录代码引用", g = typeof ((E = e.metadata) == null ? void 0 : E.remark) == "string" && e.metadata.remark ? e.metadata.remark : "无备注", o = typeof ((A = e.metadata) == null ? void 0 : A.uploader) == "string" ? e.metadata.uploader : "未知用户", y = (T = { pending: "项目记忆等待更新", running: "项目记忆更新中", ready: "项目记忆已就绪", failed: "项目记忆更新失败" }[n]) != null ? T : "项目记忆状态未知";
684
695
  return `<article class="po-source-item ${this.selectedSourceSnapshotId != null && this.sourceSnapshotValue(e) === String(this.selectedSourceSnapshotId) || this.selectedSourceSnapshotId == null && e === this.sourceSnapshots[0] ? "selected" : ""}"><strong>${l(t)}</strong><span>${l(m)}</span><span>备注:${l(g)}</span><span>上传人:${l(o)} · ${l(s)} · ${l(r)}</span><span>${l(y)} · 当前问答${this.selectedSourceSnapshotId == null && e === this.sourceSnapshots[0] ? "默认" : ""}引用</span></article>`;
685
696
  }
686
- renderSteps() {
687
- return this.runLoading ? '<div class="po-trace-state"><span class="po-ai-spinner" aria-hidden="true"></span><span>正在恢复本次执行过程</span></div>' : this.runLoadError ? `<div class="po-trace-state failed" role="alert">${l(this.runLoadError)}</div>` : (this.steps.length ? this.steps : [{ id: "idle", title: "等待任务", status: "pending", summary: "发送问题后,这里会展示完整分析过程。" }]).map((t) => {
688
- var c, p, m;
689
- const s = (c = t.metrics) != null && c.length ? `<div class="po-step-metrics">${t.metrics.map((g) => `<span>${l(g)}</span>`).join("")}</div>` : "", r = (p = t.details) != null && p.length ? `<div class="po-step-details">${t.details.map((g) => `<div><span>${l(g.label)}</span><p>${l(g.value)}</p></div>`).join("")}</div>` : "", n = !!(s || r);
690
- return `<details class="po-step ${t.status}" ${t.status === "running" || t.status === "failed" ? "open" : ""} ${n ? "" : "data-static"}>
691
- <summary>
692
- <span class="po-step-dot" aria-hidden="true"></span>
693
- <span class="po-step-copy"><strong>${l(t.title)}</strong><small>${l((m = t.summary) != null ? m : "")}</small>${s}</span>
694
- <span class="po-step-status">${Z(t.status)}</span>
695
- </summary>
696
- ${r}
697
- </details>`;
698
- }).join("");
699
- }
700
697
  renderThinkingProcess() {
701
698
  if (!this.asking && !this.thoughts.length && !this.runLoading && !this.runLoadError) return "";
702
699
  const e = this.asking && !this.streaming, t = this.asking && !this.streaming ? "思考中" : this.runLoading ? "加载中" : this.runLoadError ? "加载失败" : "已思考完成", s = thinkingDuration(this.thoughts, this.activeQuestionStartedAt);
@@ -716,14 +713,6 @@ class V {
716
713
  var e;
717
714
  (e = this.panel) == null || e.querySelectorAll(".po-thinking-content").forEach((t) => t.innerHTML = this.renderThinkingSteps());
718
715
  }
719
- renderExecutionSteps(e = !1) {
720
- var s, r;
721
- const t = (s = this.panel) == null ? void 0 : s.querySelector(".po-steps");
722
- if (t && (t.innerHTML = this.renderSteps(), e)) {
723
- const n = (r = this.panel) == null ? void 0 : r.querySelector(".po-trace > section");
724
- n && (n.scrollTop = n.scrollHeight);
725
- }
726
- }
727
716
  bindPanelEvents() {
728
717
  var e, t, s, r, n, c, p, m, g, o, y, w, b, S, $, E, A, T, h, d;
729
718
  (t = (e = this.panel) == null ? void 0 : e.querySelector('[data-action="new"]')) == null || t.addEventListener("click", () => void this.newConversation()), (r = (s = this.panel) == null ? void 0 : s.querySelector('[data-action="close"]')) == null || r.addEventListener("click", () => this.close()), (c = (n = this.panel) == null ? void 0 : n.querySelector('[data-action="stop-answer"]')) == null || c.addEventListener("click", () => this.cancelActiveAnswer(!0)), (p = this.panel) == null || p.querySelectorAll("[data-audience]").forEach((h) => {
@@ -842,9 +831,6 @@ function G(a) {
842
831
  t /= 1024, s += 1;
843
832
  return `${t >= 10 || s === 0 ? t.toFixed(0) : t.toFixed(1)} ${e[s]}`;
844
833
  }
845
- function Z(a) {
846
- return { pending: "等待中", running: "执行中", completed: "已完成", failed: "失败", cancelled: "已停止" }[a];
847
- }
848
834
  const Y = new V();
849
835
  export {
850
836
  Y as PageOpsSDK
@@ -479,10 +479,18 @@ class V {
479
479
  this.typewriter.clear(), this.waitingForFirstContent = !1, (t = this.abortController) == null || t.abort(), this.abortController = null, e && this.renderPanel();
480
480
  }
481
481
  }
482
+ /**
483
+ * Consume an SSE event without duplicating node progress in the sidebar.
484
+ * Full steps remain available for cancellation; public thoughts update only
485
+ * the answer-local timeline. This method does not make remote requests.
486
+ * @param {string} e Backend event name.
487
+ * @param {object} t Event payload for steps, thoughts, content or completion.
488
+ * @returns {void}
489
+ */
482
490
  handleStreamEvent(e, t) {
483
491
  var s, r;
484
492
  if (e === "step") {
485
- this.upsertStep(t), this.renderExecutionSteps(!0);
493
+ this.upsertStep(t);
486
494
  return;
487
495
  }
488
496
  if (e === "thought") {
@@ -587,7 +595,14 @@ class V {
587
595
  stopSourceRefresh() {
588
596
  this.sourceRefreshTimer && clearTimeout(this.sourceRefreshTimer), this.sourceRefreshTimer = null;
589
597
  }
590
- renderPanel(e = this.asking, t = !1) {
598
+ /**
599
+ * Recreate the chat shell and source controls while keeping progress in answers.
600
+ * Preserve chat scroll unless following the active answer; bind DOM listeners
601
+ * after replacement. The sidebar contains no node progress or auto-scroll.
602
+ * @param {boolean} e Whether to scroll the chat to its latest message.
603
+ * @returns {void} No-op when the SDK panel is closed; no remote requests.
604
+ */
605
+ renderPanel(e = this.asking) {
591
606
  var g;
592
607
  if (!this.panel) return;
593
608
  const s = (g = this.panel.querySelector(".po-messages")) == null ? void 0 : g.scrollTop, r = this.questionUnavailableReason(), n = r || (this.asking ? "回答生成中,请稍候" : this.sourceSnapshots.length ? "请输入页面分析问题,Enter 发送,Shift + Enter 换行" : "可直接闲聊;业务问题需先上传代码包"), c = !!(r || this.asking), p = r ? '<button type="submit" disabled>暂不可提问</button>' : this.asking ? '<button class="po-stop" type="button" data-action="stop-answer" aria-label="停止输出" title="停止输出"><span aria-hidden="true"></span></button>' : '<button type="submit">发送</button>', m = C.map((o) => `
@@ -618,7 +633,7 @@ class V {
618
633
  </section>
619
634
  <form class="po-composer"><textarea ${c ? "disabled" : ""} placeholder="${l(n)}"></textarea>${p}</form>
620
635
  </main>
621
- <aside class="po-trace"><header><h2>执行过程</h2><button data-action="close">×</button></header><section>${this.renderSourceUploader()}<div class="po-steps">${this.renderSteps()}</div></section></aside>
636
+ <aside class="po-trace"><header><h2>执行过程</h2><button data-action="close">×</button></header><section>${this.renderSourceUploader()}</section></aside>
622
637
  `, this.bindPanelEvents(), e) {
623
638
  const o = this.panel.querySelector(".po-messages");
624
639
  o && (o.scrollTop = o.scrollHeight);
@@ -626,10 +641,6 @@ class V {
626
641
  const o = this.panel.querySelector(".po-messages");
627
642
  o && (o.scrollTop = s);
628
643
  }
629
- if (t) {
630
- const o = this.panel.querySelector(".po-trace > section");
631
- o && (o.scrollTop = o.scrollHeight);
632
- }
633
644
  }
634
645
  renderAnswerState() {
635
646
  const n = messageTime(this.activeQuestionStartedAt), c = this.renderThinkingProcess(), e = this.asking && this.waitingForFirstContent ? `<article class="po-message assistant waiting" role="status" aria-live="polite">${n}<b>PageOps 分析</b><div class="po-ai-waiting"><span class="po-ai-spinner" aria-hidden="true"></span><span>正在理解问题并检索证据</span></div>${c}</article>` : "", t = this.streaming ? `<article class="po-message assistant streaming">${n}<b>PageOps 分析</b><div><span data-streaming-content>${R(this.streaming)}</span>${this.asking ? '<span class="po-typing-cursor" aria-hidden="true"></span>' : ""}</div>${c}</article>` : "", s = this.answerError ? `<article class="po-message assistant answer-error" role="alert">${n}<b>PageOps 分析</b><strong>本次回答失败</strong><div>${l(this.answerError)}</div></article>` : "", r = this.answerStopped ? '<div class="po-stream-stopped" role="status">已停止输出</div>' : "";
@@ -683,20 +694,6 @@ class V {
683
694
  const t = e.filename || "未命名代码包", s = e.created_at ? O(e.created_at) : "刚刚上传", r = G(e.archive_bytes || e.total_bytes || 0), n = String((b = (w = e.metadata) == null ? void 0 : w.analysis_status) != null ? b : "unknown"), c = typeof ((S = e.metadata) == null ? void 0 : S.tag) == "string" ? e.metadata.tag : "", p = typeof (($ = e.metadata) == null ? void 0 : $.branch) == "string" ? e.metadata.branch : "", m = c ? `Tag: ${c}` : p ? `Branch: ${p}` : "未记录代码引用", g = typeof ((E = e.metadata) == null ? void 0 : E.remark) == "string" && e.metadata.remark ? e.metadata.remark : "无备注", o = typeof ((A = e.metadata) == null ? void 0 : A.uploader) == "string" ? e.metadata.uploader : "未知用户", y = (T = { pending: "项目记忆等待更新", running: "项目记忆更新中", ready: "项目记忆已就绪", failed: "项目记忆更新失败" }[n]) != null ? T : "项目记忆状态未知";
684
695
  return `<article class="po-source-item ${this.selectedSourceSnapshotId != null && this.sourceSnapshotValue(e) === String(this.selectedSourceSnapshotId) || this.selectedSourceSnapshotId == null && e === this.sourceSnapshots[0] ? "selected" : ""}"><strong>${l(t)}</strong><span>${l(m)}</span><span>备注:${l(g)}</span><span>上传人:${l(o)} · ${l(s)} · ${l(r)}</span><span>${l(y)} · 当前问答${this.selectedSourceSnapshotId == null && e === this.sourceSnapshots[0] ? "默认" : ""}引用</span></article>`;
685
696
  }
686
- renderSteps() {
687
- return this.runLoading ? '<div class="po-trace-state"><span class="po-ai-spinner" aria-hidden="true"></span><span>正在恢复本次执行过程</span></div>' : this.runLoadError ? `<div class="po-trace-state failed" role="alert">${l(this.runLoadError)}</div>` : (this.steps.length ? this.steps : [{ id: "idle", title: "等待任务", status: "pending", summary: "发送问题后,这里会展示完整分析过程。" }]).map((t) => {
688
- var c, p, m;
689
- const s = (c = t.metrics) != null && c.length ? `<div class="po-step-metrics">${t.metrics.map((g) => `<span>${l(g)}</span>`).join("")}</div>` : "", r = (p = t.details) != null && p.length ? `<div class="po-step-details">${t.details.map((g) => `<div><span>${l(g.label)}</span><p>${l(g.value)}</p></div>`).join("")}</div>` : "", n = !!(s || r);
690
- return `<details class="po-step ${t.status}" ${t.status === "running" || t.status === "failed" ? "open" : ""} ${n ? "" : "data-static"}>
691
- <summary>
692
- <span class="po-step-dot" aria-hidden="true"></span>
693
- <span class="po-step-copy"><strong>${l(t.title)}</strong><small>${l((m = t.summary) != null ? m : "")}</small>${s}</span>
694
- <span class="po-step-status">${Z(t.status)}</span>
695
- </summary>
696
- ${r}
697
- </details>`;
698
- }).join("");
699
- }
700
697
  renderThinkingProcess() {
701
698
  if (!this.asking && !this.thoughts.length && !this.runLoading && !this.runLoadError) return "";
702
699
  const e = this.asking && !this.streaming, t = this.asking && !this.streaming ? "思考中" : this.runLoading ? "加载中" : this.runLoadError ? "加载失败" : "已思考完成", s = thinkingDuration(this.thoughts, this.activeQuestionStartedAt);
@@ -716,14 +713,6 @@ class V {
716
713
  var e;
717
714
  (e = this.panel) == null || e.querySelectorAll(".po-thinking-content").forEach((t) => t.innerHTML = this.renderThinkingSteps());
718
715
  }
719
- renderExecutionSteps(e = !1) {
720
- var s, r;
721
- const t = (s = this.panel) == null ? void 0 : s.querySelector(".po-steps");
722
- if (t && (t.innerHTML = this.renderSteps(), e)) {
723
- const n = (r = this.panel) == null ? void 0 : r.querySelector(".po-trace > section");
724
- n && (n.scrollTop = n.scrollHeight);
725
- }
726
- }
727
716
  bindPanelEvents() {
728
717
  var e, t, s, r, n, c, p, m, g, o, y, w, b, S, $, E, A, T, h, d;
729
718
  (t = (e = this.panel) == null ? void 0 : e.querySelector('[data-action="new"]')) == null || t.addEventListener("click", () => void this.newConversation()), (r = (s = this.panel) == null ? void 0 : s.querySelector('[data-action="close"]')) == null || r.addEventListener("click", () => this.close()), (c = (n = this.panel) == null ? void 0 : n.querySelector('[data-action="stop-answer"]')) == null || c.addEventListener("click", () => this.cancelActiveAnswer(!0)), (p = this.panel) == null || p.querySelectorAll("[data-audience]").forEach((h) => {
@@ -842,8 +831,5 @@ function G(a) {
842
831
  t /= 1024, s += 1;
843
832
  return `${t >= 10 || s === 0 ? t.toFixed(0) : t.toFixed(1)} ${e[s]}`;
844
833
  }
845
- function Z(a) {
846
- return { pending: "等待中", running: "执行中", completed: "已完成", failed: "失败", cancelled: "已停止" }[a];
847
- }
848
834
  const Y = new V();
849
835
  exports.PageOpsSDK=Y;}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pageops/sdk",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "description": "PageOps embeddable frontend SDK",
5
5
  "type": "module",
6
6
  "main": "dist/pageops-sdk.umd.cjs",