@liyuera/dsh-chrome-browser 0.5.0 → 0.6.0

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":"activity.js","sourceRoot":"","sources":["../../src/client/activity.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAYH,8DAA8D;AAC9D,MAAM,QAAQ,GAAG,GAAG,CAAA;AAQpB,MAAM,IAAI,GAAiB,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;AAE5C,IAAI,QAAQ,GAAG,CAAC,CAAA;AAChB,IAAI,MAAM,GAAiB,IAAI,CAAA;AAC/B,IAAI,QAAQ,GAAiC,IAAI,CAAA;AAEjD,KAAK,UAAU,aAAa,CAAC,SAAiB;IAC5C,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,SAAS,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,kBAAkB,CAAC,SAAS,CAAC,EAAE,CAAA;QACnF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,2BAA2B,KAAK,EAAE,CAAC,CAAA;QAChE,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAoB,CAAA;QACpD,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,uBAAuB,CAAC,CAAA;QAC5E,MAAM,GAAG;YACP,MAAM,EAAE,IAAI,CAAC,MAAM,KAAK,IAAI;YAC5B,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;YACvD,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,C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The composer dock used to carry a full-width tab selector above the input
5
5
  * card. That row, its component and the session-binding routes behind it are
6
6
  * gone: the live tab list lives in the `@` menu, where a pick inserts a
7
- * reference chip and binds nothing. The dock carries the activity strip now.
7
+ * reference chip and binds nothing. The Session header carries the status chip.
8
8
  * @module @liyuera/dsh-chrome-browser/client
9
9
  */
10
10
  import type { Context as ClientContext } from '@deepseek-ai/cordis';
11
11
  /** Required services for the slot contribution and the `@` source. */
12
12
  export declare const inject: string[];
13
13
  /**
14
- * Client plugin body: register the activity strip and the `@` tab source.
14
+ * Client plugin body: register the Chrome status chip and the `@` tab source.
15
15
  * @param ctx - client root context.
16
16
  */
17
17
  export declare function apply(ctx: ClientContext): void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAUnE,sEAAsE;AACtE,eAAO,MAAM,MAAM,UAA6B,CAAA;AAEhD;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAc9C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAUnE,sEAAsE;AACtE,eAAO,MAAM,MAAM,UAA6B,CAAA;AAEhD;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAe9C"}
@@ -4,7 +4,7 @@
4
4
  * The composer dock used to carry a full-width tab selector above the input
5
5
  * card. That row, its component and the session-binding routes behind it are
6
6
  * gone: the live tab list lives in the `@` menu, where a pick inserts a
7
- * reference chip and binds nothing. The dock carries the activity strip now.
7
+ * reference chip and binds nothing. The Session header carries the status chip.
8
8
  * @module @liyuera/dsh-chrome-browser/client
9
9
  */
10
10
  import { BrowserActivity } from "./BrowserActivity.js";
@@ -14,17 +14,18 @@ import { tabIcon } from "./tab-icon.js";
14
14
  /** Required services for the slot contribution and the `@` source. */
15
15
  export const inject = ['slots', 'inputTriggers'];
16
16
  /**
17
- * Client plugin body: register the activity strip and the `@` tab source.
17
+ * Client plugin body: register the Chrome status chip and the `@` tab source.
18
18
  * @param ctx - client root context.
19
19
  */
20
20
  export function apply(ctx) {
21
- // The activity strip: rendered above the composer only while one of this
22
- // plugin's tools is running, so a user who looks up mid-task can see that the
23
- // agent is driving their browser and on which tab.
24
- ctx.slots.inject('conversation.input.dock', () => ctx.slots.register({
25
- name: 'conversation.input.dock',
21
+ // The status chip: the last item in the Session header's trailing utilities,
22
+ // so the state of the browser bridge sits with the other session-level
23
+ // facts. It stays mounted and stays visible — a chip that only appears while
24
+ // a call runs flickers past, because these calls finish in milliseconds.
25
+ ctx.slots.inject('conversation.session.header.utilities', () => ctx.slots.register({
26
+ name: 'conversation.session.header.utilities',
26
27
  id: 'chrome-browser-activity',
27
- order: 4,
28
+ order: 90,
28
29
  }, BrowserActivity));
29
30
  ctx.effect(() => ctx.inputTriggers.registerSource(createChromeTabSource({ listTabs: listChromeTabs, iconFor: tabIcon })), 'chrome-browser: @ tab source');
30
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAuB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,sEAAsE;AACtE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;AAEhD;;;GAGG;AACH,MAAM,U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AC,MAAM,CACR,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,cAAc,CAAC,qBAAqB,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,EAC7G,8BAA8B,CAC/B,CAAA;AACH,CAAC"}
package/lib/client.js CHANGED
@@ -38,40 +38,70 @@ window.__ModuleLoader__.load({
38
38
  * Browser-side activity probe: `GET /chrome-browser/activity` behind a short
39
39
  * cache.
40
40
  *
41
- * The strip polls this while a session view is open, so a dropped request or an
42
- * unreachable host answers "not active" rather than throwing into React: an
43
- * indicator that flickers an error is worse than one that stays hidden.
41
+ * The header chip polls this while a session view is open. An unreachable host
42
+ * answers "offline" rather than throwing into React: a chip that flickers an
43
+ * error is worse than one that says the bridge is not there, which is also the
44
+ * truth.
44
45
  * @module @liyuera/dsh-chrome-browser/client/activity
45
46
  */
46
47
  /** One snapshot per this window, however many callers ask. */
47
- const CACHE_MS$1 = 900;
48
- const IDLE = { active: false };
48
+ const CACHE_MS$1 = 400;
49
+ /** What the chip shows when the host cannot be reached at all. */
50
+ const OFFLINE = { phase: "offline" };
49
51
  let cachedAt$1 = 0;
50
- let cached$1 = IDLE;
52
+ let cached$1 = OFFLINE;
51
53
  let inflight$1 = null;
54
+ /**
55
+ * Turn one host answer into the phase the chip renders.
56
+ *
57
+ * The link decides first: an extension that is not attached, or is running
58
+ * older files than the plugin ships, is a condition the user has to fix, and it
59
+ * outranks whatever the last call happened to do — a `done` flash drawn on top
60
+ * of a disconnected bridge would be actively misleading.
61
+ * @param body - the parsed route answer.
62
+ * @returns the phase and the fields that belong to it.
63
+ */
64
+ function phaseOf(body) {
65
+ const rest = {
66
+ ...body.tool === void 0 ? {} : { tool: body.tool },
67
+ ...body.tabId === void 0 ? {} : { tabId: body.tabId },
68
+ ...body.detail === void 0 ? {} : { detail: body.detail },
69
+ ...body.since === void 0 ? {} : { since: body.since }
70
+ };
71
+ if (body.connected === false) return {
72
+ phase: "offline",
73
+ ...rest
74
+ };
75
+ if (body.stale === true) return {
76
+ phase: "stale",
77
+ ...rest
78
+ };
79
+ const phase = body.phase;
80
+ if (phase === "running" || phase === "done" || phase === "error") return {
81
+ phase,
82
+ ...rest
83
+ };
84
+ return {
85
+ phase: "ready",
86
+ ...rest
87
+ };
88
+ }
52
89
  async function fetchActivity(sessionId) {
53
90
  try {
54
91
  const query = sessionId === "" ? "" : `?sessionId=${encodeURIComponent(sessionId)}`;
55
92
  const body = await (await fetch(`/chrome-browser/activity${query}`)).json();
56
93
  if (body.ok !== true) throw new Error(body.error ?? "activity probe failed");
57
- cached$1 = {
58
- active: body.active === true,
59
- ...body.tool === void 0 ? {} : { tool: body.tool },
60
- ...body.tabId === void 0 ? {} : { tabId: body.tabId },
61
- ...body.startedAt === void 0 ? {} : { startedAt: body.startedAt },
62
- ...body.lastTool === void 0 ? {} : { lastTool: body.lastTool },
63
- ...body.lastAt === void 0 ? {} : { lastAt: body.lastAt }
64
- };
94
+ cached$1 = phaseOf(body);
65
95
  } catch {
66
- cached$1 = IDLE;
96
+ cached$1 = OFFLINE;
67
97
  }
68
98
  cachedAt$1 = Date.now();
69
99
  return cached$1;
70
100
  }
71
101
  /**
72
102
  * Read the plugin's current activity for one session.
73
- * @param sessionId - the session the strip belongs to.
74
- * @returns the snapshot, or an inactive one while the host is unreachable.
103
+ * @param sessionId - the session the chip belongs to.
104
+ * @returns the snapshot, or an offline one while the host is unreachable.
75
105
  */
76
106
  async function readChromeActivity(sessionId) {
77
107
  if (Date.now() - cachedAt$1 < CACHE_MS$1) return cached$1;
@@ -83,26 +113,30 @@ window.__ModuleLoader__.load({
83
113
  //#endregion
84
114
  //#region lib/client/BrowserActivity.js
85
115
  /**
86
- * Browser activity strip: the one place the user can see, without reading the
87
- * transcript, that the agent is driving their browser right now.
116
+ * Chrome status chip: the one place the user can see, without reading the
117
+ * transcript, whether the plugin can drive their browser and what it is doing
118
+ * with it right now.
88
119
  *
89
- * It renders **nothing** while the plugin is idle — a permanent badge would be
90
- * noise, and the per-call cards already carry the detail. When a call is in
91
- * flight it names the tool and the tab, so a user who looks up mid-task can
92
- * tell what is happening and on which page.
120
+ * It sits at the end of the Session header's utilities and is **always**
121
+ * rendered — a pale idle state that is legible at a glance, and a louder one
122
+ * only for the phases that ask for attention (a call in flight, a failure, an
123
+ * extension that needs reloading). An indicator that appears only while a call
124
+ * runs is not readable: those calls finish in milliseconds, so it reads as a
125
+ * flicker rather than as information.
93
126
  * @module @liyuera/dsh-chrome-browser/client/activity-strip
94
127
  */
95
- /** Poll interval while the strip is mounted; the host caches for slightly less. */
128
+ /** Poll interval while the chip is mounted; the host caches for slightly less. */
96
129
  const POLL_MS = 1e3;
97
130
  /**
98
- * Human labels for the running call. A tool with no label shows its wire name,
99
- * so adding a tool never leaves the strip blank.
131
+ * Human labels for the tool a phase belongs to. A tool with no label shows its
132
+ * wire name, so adding a tool never leaves the chip blank.
100
133
  */
101
134
  const TOOL_LABELS = {
102
135
  chrome_tabs: "列出标签页",
103
136
  chrome_read: "读取页面",
104
137
  chrome_navigate: "导航",
105
138
  chrome_open: "打开标签页",
139
+ chrome_close: "关闭标签页",
106
140
  chrome_screenshot: "截图",
107
141
  chrome_click: "点击",
108
142
  chrome_hover: "悬停",
@@ -114,48 +148,121 @@ window.__ModuleLoader__.load({
114
148
  chrome_console: "读取控制台",
115
149
  chrome_request_help: "等待你操作"
116
150
  };
151
+ /** What each phase says, and what a reader who wants more gets on hover. */
152
+ const PHASES = {
153
+ offline: {
154
+ text: "Chrome 未连接",
155
+ hint: "扩展没有连上。检查 chrome://extensions 里 dsh Chrome Control 是否已加载。"
156
+ },
157
+ stale: {
158
+ text: "扩展待更新",
159
+ hint: "扩展在跑旧文件,插件正在请它重载;若一直如此,手动重新加载一次扩展。"
160
+ },
161
+ running: {
162
+ text: "工作中",
163
+ hint: "正在操作你的 Chrome。"
164
+ },
165
+ done: {
166
+ text: "完成",
167
+ hint: "上一次调用已完成。"
168
+ },
169
+ error: {
170
+ text: "失败",
171
+ hint: "上一次调用失败。"
172
+ },
173
+ ready: {
174
+ text: "Chrome 就绪",
175
+ hint: "扩展已连接,空闲中。"
176
+ }
177
+ };
178
+ /** Only the pulse needs a stylesheet; every size is inline on purpose. */
117
179
  const STYLE_ID = "dsh-chrome-browser-activity";
118
- const STRIP_CSS = `
119
- .cb-activity {
120
- display: flex;
121
- align-items: center;
122
- gap: 6px;
123
- margin: 0 0 6px;
124
- padding: 3px 8px;
125
- width: fit-content;
126
- border: 1px solid var(--dsw-alias-border-l1);
127
- border-radius: 999px;
128
- background: var(--dsw-specific-tip);
129
- color: var(--dsw-alias-label-primary);
130
- font-size: 12px;
131
- line-height: 18px;
132
- }
133
- .cb-activity img { width: 14px; height: 14px; }
134
- .cb-activity .cb-dot {
135
- width: 6px;
136
- height: 6px;
137
- border-radius: 50%;
138
- background: currentColor;
139
- animation: cb-pulse 1.2s ease-in-out infinite;
140
- }
141
- @keyframes cb-pulse { 0%, 100% { opacity: .3 } 50% { opacity: 1 } }
142
- @media (prefers-reduced-motion: reduce) { .cb-activity .cb-dot { animation: none } }
143
- .cb-activity .cb-activity-tab { opacity: .7 }
144
- `;
180
+ const PULSE_CSS = "@keyframes cb-pulse { 0%, 100% { opacity: .25 } 50% { opacity: 1 } }";
145
181
  function ensureStyles() {
146
182
  if (document.getElementById(STYLE_ID) !== null) return;
147
183
  const style = document.createElement("style");
148
184
  style.id = STYLE_ID;
149
- style.textContent = STRIP_CSS;
185
+ style.textContent = PULSE_CSS;
150
186
  document.head.appendChild(style);
151
187
  }
188
+ /** The colour each phase draws its dot and its text in. */
189
+ const PHASE_COLOR = {
190
+ ready: {
191
+ dot: "var(--dsw-alias-state-success-primary)",
192
+ ink: "var(--dsw-alias-label-secondary)"
193
+ },
194
+ offline: { dot: "var(--dsw-alias-state-idle-primary)" },
195
+ stale: {
196
+ dot: "var(--dsw-alias-state-warn-primary)",
197
+ ink: "var(--dsw-alias-state-warn-primary)"
198
+ },
199
+ running: {
200
+ dot: "var(--dsw-alias-state-success-primary)",
201
+ ink: "var(--dsw-alias-label-primary)"
202
+ },
203
+ done: {
204
+ dot: "var(--dsw-alias-state-success-primary)",
205
+ ink: "var(--dsw-alias-state-success-primary)"
206
+ },
207
+ error: {
208
+ dot: "var(--dsw-alias-state-error-primary)",
209
+ ink: "var(--dsw-alias-state-error-primary)"
210
+ }
211
+ };
152
212
  /**
153
- * Render the strip while one of this plugin's tools is running.
154
- * @param props - the dock entry's session identity.
155
- * @returns the strip, or null while nothing is running.
213
+ * Sizes that must hold whatever the surrounding header does.
214
+ *
215
+ * These are inline rather than a rule set: the chip carries this plugin's own
216
+ * 512px artwork, and a stylesheet that fails to apply does not degrade it to a
217
+ * plain label — it renders the raw icon at full size and takes the header with
218
+ * it. Measured, not assumed.
219
+ */
220
+ const CHIP_STYLE = {
221
+ display: "inline-flex",
222
+ alignItems: "center",
223
+ gap: 5,
224
+ padding: "1px 8px 1px 6px",
225
+ borderRadius: 999,
226
+ fontSize: 12,
227
+ lineHeight: "18px",
228
+ height: 22,
229
+ maxHeight: 22,
230
+ whiteSpace: "nowrap",
231
+ overflow: "hidden",
232
+ flex: "none",
233
+ border: "1px solid transparent",
234
+ color: "var(--dsw-alias-label-secondary)"
235
+ };
236
+ const ICON_STYLE = {
237
+ width: 13,
238
+ height: 13,
239
+ flex: "none",
240
+ opacity: .75
241
+ };
242
+ /** The words one phase shows, given the call it belongs to. */
243
+ function wording(state) {
244
+ const phase = PHASES[state.phase];
245
+ const label = state.tool === void 0 ? void 0 : TOOL_LABELS[state.tool] ?? state.tool;
246
+ if (state.phase === "running" && label !== void 0) return {
247
+ text: label,
248
+ hint: `${phase.hint}${label}${state.tabId === void 0 ? "" : ` · 标签页 ${state.tabId}`}`
249
+ };
250
+ if (state.phase === "error") return {
251
+ text: phase.text,
252
+ hint: state.detail === void 0 ? phase.hint : `上一次调用失败:${state.detail}`
253
+ };
254
+ return {
255
+ text: phase.text,
256
+ hint: phase.hint
257
+ };
258
+ }
259
+ /**
260
+ * Render the persistent Chrome status chip.
261
+ * @param props - the header utility's session identity.
262
+ * @returns the chip.
156
263
  */
157
264
  function BrowserActivity({ sessionId }) {
158
- const [state, setState] = (0, react.useState)({ active: false });
265
+ const [state, setState] = (0, react.useState)({ phase: "ready" });
159
266
  (0, react.useEffect)(() => {
160
267
  ensureStyles();
161
268
  let live = true;
@@ -172,25 +279,40 @@ window.__ModuleLoader__.load({
172
279
  clearInterval(timer);
173
280
  };
174
281
  }, [sessionId]);
175
- if (!state.active) return null;
176
- const tool = state.tool ?? "";
177
- return (0, react_jsx_runtime.jsxs)("div", {
178
- className: "cb-activity",
282
+ const { text, hint } = wording(state);
283
+ const color = PHASE_COLOR[state.phase];
284
+ return (0, react_jsx_runtime.jsxs)("span", {
285
+ className: "cb-status",
286
+ "data-phase": state.phase,
179
287
  role: "status",
180
288
  "aria-live": "polite",
289
+ title: hint,
290
+ style: {
291
+ ...CHIP_STYLE,
292
+ ...color.ink === void 0 ? {} : { color: color.ink }
293
+ },
181
294
  children: [
182
295
  (0, react_jsx_runtime.jsx)("span", {
183
- className: "cb-dot",
184
- "aria-hidden": "true"
296
+ "aria-hidden": "true",
297
+ style: {
298
+ width: 6,
299
+ height: 6,
300
+ borderRadius: "50%",
301
+ flex: "none",
302
+ background: color.dot,
303
+ opacity: state.phase === "ready" ? .55 : 1,
304
+ ...state.phase === "running" ? { animation: "cb-pulse 1.2s ease-in-out infinite" } : {}
305
+ }
185
306
  }),
186
307
  (0, react_jsx_runtime.jsx)("img", {
187
308
  src: CHROME_ICON_SRC,
188
309
  alt: "",
189
- "aria-hidden": "true"
310
+ "aria-hidden": "true",
311
+ style: ICON_STYLE
190
312
  }),
191
- (0, react_jsx_runtime.jsx)("span", { children: TOOL_LABELS[tool] ?? tool }),
192
- state.tabId === void 0 ? null : (0, react_jsx_runtime.jsxs)("span", {
193
- className: "cb-activity-tab",
313
+ (0, react_jsx_runtime.jsx)("span", { children: text }),
314
+ state.phase !== "running" || state.tabId === void 0 ? null : (0, react_jsx_runtime.jsxs)("span", {
315
+ style: { opacity: .7 },
194
316
  children: ["标签页 ", state.tabId]
195
317
  })
196
318
  ]
@@ -410,20 +532,20 @@ window.__ModuleLoader__.load({
410
532
  * The composer dock used to carry a full-width tab selector above the input
411
533
  * card. That row, its component and the session-binding routes behind it are
412
534
  * gone: the live tab list lives in the `@` menu, where a pick inserts a
413
- * reference chip and binds nothing. The dock carries the activity strip now.
535
+ * reference chip and binds nothing. The Session header carries the status chip.
414
536
  * @module @liyuera/dsh-chrome-browser/client
415
537
  */
416
538
  /** Required services for the slot contribution and the `@` source. */
417
539
  const inject = ["slots", "inputTriggers"];
418
540
  /**
419
- * Client plugin body: register the activity strip and the `@` tab source.
541
+ * Client plugin body: register the Chrome status chip and the `@` tab source.
420
542
  * @param ctx - client root context.
421
543
  */
422
544
  function apply(ctx) {
423
- ctx.slots.inject("conversation.input.dock", () => ctx.slots.register({
424
- name: "conversation.input.dock",
545
+ ctx.slots.inject("conversation.session.header.utilities", () => ctx.slots.register({
546
+ name: "conversation.session.header.utilities",
425
547
  id: "chrome-browser-activity",
426
- order: 4
548
+ order: 90
427
549
  }, BrowserActivity));
428
550
  ctx.effect(() => ctx.inputTriggers.registerSource(createChromeTabSource({
429
551
  listTabs: listChromeTabs,