@liyuera/dsh-chrome-browser 0.4.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.
- package/README.md +38 -4
- package/extension/icons/icon-128.png +0 -0
- package/extension/icons/icon-16.png +0 -0
- package/extension/icons/icon-32.png +0 -0
- package/extension/icons/icon-48.png +0 -0
- package/extension/manifest.json +10 -4
- package/extension/service-worker.js +82 -5
- package/lib/activity.d.ts +35 -22
- package/lib/activity.d.ts.map +1 -1
- package/lib/activity.js +68 -28
- package/lib/activity.js.map +1 -1
- package/lib/backend.d.ts +77 -2
- package/lib/backend.d.ts.map +1 -1
- package/lib/backend.js +138 -3
- package/lib/backend.js.map +1 -1
- package/lib/client/BrowserActivity.d.ts +14 -11
- package/lib/client/BrowserActivity.d.ts.map +1 -1
- package/lib/client/BrowserActivity.js +86 -45
- package/lib/client/BrowserActivity.js.map +1 -1
- package/lib/client/activity.d.ts +16 -9
- package/lib/client/activity.d.ts.map +1 -1
- package/lib/client/activity.js +41 -20
- package/lib/client/activity.js.map +1 -1
- package/lib/client/index.d.ts +2 -2
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +9 -8
- package/lib/client/index.js.map +1 -1
- package/lib/client.js +195 -73
- package/lib/client.js.map +1 -1
- package/lib/expressions.d.ts +11 -0
- package/lib/expressions.d.ts.map +1 -1
- package/lib/expressions.js +25 -0
- package/lib/expressions.js.map +1 -1
- package/lib/extension-package.d.ts +49 -0
- package/lib/extension-package.d.ts.map +1 -1
- package/lib/extension-package.js +115 -0
- package/lib/extension-package.js.map +1 -1
- package/lib/routes.d.ts.map +1 -1
- package/lib/routes.js +14 -2
- package/lib/routes.js.map +1 -1
- package/lib/skill.d.ts.map +1 -1
- package/lib/skill.js +5 -4
- package/lib/skill.js.map +1 -1
- package/lib/tools.d.ts.map +1 -1
- package/lib/tools.js +48 -9
- package/lib/tools.js.map +1 -1
- package/package.json +3 -2
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* transcript,
|
|
3
|
+
* Chrome status chip: the one place the user can see, without reading the
|
|
4
|
+
* transcript, whether the plugin can drive their browser and what it is doing
|
|
5
|
+
* with it right now.
|
|
5
6
|
*
|
|
6
|
-
* It
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* It sits at the end of the Session header's utilities and is **always**
|
|
8
|
+
* rendered — a pale idle state that is legible at a glance, and a louder one
|
|
9
|
+
* only for the phases that ask for attention (a call in flight, a failure, an
|
|
10
|
+
* extension that needs reloading). An indicator that appears only while a call
|
|
11
|
+
* runs is not readable: those calls finish in milliseconds, so it reads as a
|
|
12
|
+
* flicker rather than as information.
|
|
10
13
|
* @module @liyuera/dsh-chrome-browser/client/activity-strip
|
|
11
14
|
*/
|
|
12
15
|
import { useEffect, useState } from 'react';
|
|
13
16
|
import { CHROME_ICON_SRC } from "./chrome-icon.js";
|
|
14
17
|
import { readChromeActivity } from "./activity.js";
|
|
15
|
-
/** Poll interval while the
|
|
18
|
+
/** Poll interval while the chip is mounted; the host caches for slightly less. */
|
|
16
19
|
const POLL_MS = 1000;
|
|
17
20
|
/**
|
|
18
|
-
* Human labels for the
|
|
19
|
-
* so adding a tool never leaves the
|
|
21
|
+
* Human labels for the tool a phase belongs to. A tool with no label shows its
|
|
22
|
+
* wire name, so adding a tool never leaves the chip blank.
|
|
20
23
|
*/
|
|
21
24
|
const TOOL_LABELS = {
|
|
22
25
|
chrome_tabs: '列出标签页',
|
|
23
26
|
chrome_read: '读取页面',
|
|
24
27
|
chrome_navigate: '导航',
|
|
25
28
|
chrome_open: '打开标签页',
|
|
29
|
+
chrome_close: '关闭标签页',
|
|
26
30
|
chrome_screenshot: '截图',
|
|
27
31
|
chrome_click: '点击',
|
|
28
32
|
chrome_hover: '悬停',
|
|
@@ -34,49 +38,79 @@ const TOOL_LABELS = {
|
|
|
34
38
|
chrome_console: '读取控制台',
|
|
35
39
|
chrome_request_help: '等待你操作',
|
|
36
40
|
};
|
|
41
|
+
/** What each phase says, and what a reader who wants more gets on hover. */
|
|
42
|
+
const PHASES = {
|
|
43
|
+
offline: { text: 'Chrome 未连接', hint: '扩展没有连上。检查 chrome://extensions 里 dsh Chrome Control 是否已加载。' },
|
|
44
|
+
stale: { text: '扩展待更新', hint: '扩展在跑旧文件,插件正在请它重载;若一直如此,手动重新加载一次扩展。' },
|
|
45
|
+
running: { text: '工作中', hint: '正在操作你的 Chrome。' },
|
|
46
|
+
done: { text: '完成', hint: '上一次调用已完成。' },
|
|
47
|
+
error: { text: '失败', hint: '上一次调用失败。' },
|
|
48
|
+
ready: { text: 'Chrome 就绪', hint: '扩展已连接,空闲中。' },
|
|
49
|
+
};
|
|
50
|
+
/** Only the pulse needs a stylesheet; every size is inline on purpose. */
|
|
37
51
|
const STYLE_ID = 'dsh-chrome-browser-activity';
|
|
38
|
-
const
|
|
39
|
-
.cb-activity {
|
|
40
|
-
display: flex;
|
|
41
|
-
align-items: center;
|
|
42
|
-
gap: 6px;
|
|
43
|
-
margin: 0 0 6px;
|
|
44
|
-
padding: 3px 8px;
|
|
45
|
-
width: fit-content;
|
|
46
|
-
border: 1px solid var(--dsw-alias-border-l1);
|
|
47
|
-
border-radius: 999px;
|
|
48
|
-
background: var(--dsw-specific-tip);
|
|
49
|
-
color: var(--dsw-alias-label-primary);
|
|
50
|
-
font-size: 12px;
|
|
51
|
-
line-height: 18px;
|
|
52
|
-
}
|
|
53
|
-
.cb-activity img { width: 14px; height: 14px; }
|
|
54
|
-
.cb-activity .cb-dot {
|
|
55
|
-
width: 6px;
|
|
56
|
-
height: 6px;
|
|
57
|
-
border-radius: 50%;
|
|
58
|
-
background: currentColor;
|
|
59
|
-
animation: cb-pulse 1.2s ease-in-out infinite;
|
|
60
|
-
}
|
|
61
|
-
@keyframes cb-pulse { 0%, 100% { opacity: .3 } 50% { opacity: 1 } }
|
|
62
|
-
@media (prefers-reduced-motion: reduce) { .cb-activity .cb-dot { animation: none } }
|
|
63
|
-
.cb-activity .cb-activity-tab { opacity: .7 }
|
|
64
|
-
`;
|
|
52
|
+
const PULSE_CSS = '@keyframes cb-pulse { 0%, 100% { opacity: .25 } 50% { opacity: 1 } }';
|
|
65
53
|
function ensureStyles() {
|
|
66
54
|
if (document.getElementById(STYLE_ID) !== null)
|
|
67
55
|
return;
|
|
68
56
|
const style = document.createElement('style');
|
|
69
57
|
style.id = STYLE_ID;
|
|
70
|
-
style.textContent =
|
|
58
|
+
style.textContent = PULSE_CSS;
|
|
71
59
|
document.head.appendChild(style);
|
|
72
60
|
}
|
|
61
|
+
/** The colour each phase draws its dot and its text in. */
|
|
62
|
+
const PHASE_COLOR = {
|
|
63
|
+
ready: { dot: 'var(--dsw-alias-state-success-primary)', ink: 'var(--dsw-alias-label-secondary)' },
|
|
64
|
+
offline: { dot: 'var(--dsw-alias-state-idle-primary)' },
|
|
65
|
+
stale: { dot: 'var(--dsw-alias-state-warn-primary)', ink: 'var(--dsw-alias-state-warn-primary)' },
|
|
66
|
+
running: { dot: 'var(--dsw-alias-state-success-primary)', ink: 'var(--dsw-alias-label-primary)' },
|
|
67
|
+
done: { dot: 'var(--dsw-alias-state-success-primary)', ink: 'var(--dsw-alias-state-success-primary)' },
|
|
68
|
+
error: { dot: 'var(--dsw-alias-state-error-primary)', ink: 'var(--dsw-alias-state-error-primary)' },
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Sizes that must hold whatever the surrounding header does.
|
|
72
|
+
*
|
|
73
|
+
* These are inline rather than a rule set: the chip carries this plugin's own
|
|
74
|
+
* 512px artwork, and a stylesheet that fails to apply does not degrade it to a
|
|
75
|
+
* plain label — it renders the raw icon at full size and takes the header with
|
|
76
|
+
* it. Measured, not assumed.
|
|
77
|
+
*/
|
|
78
|
+
const CHIP_STYLE = {
|
|
79
|
+
display: 'inline-flex',
|
|
80
|
+
alignItems: 'center',
|
|
81
|
+
gap: 5,
|
|
82
|
+
padding: '1px 8px 1px 6px',
|
|
83
|
+
borderRadius: 999,
|
|
84
|
+
fontSize: 12,
|
|
85
|
+
lineHeight: '18px',
|
|
86
|
+
height: 22,
|
|
87
|
+
maxHeight: 22,
|
|
88
|
+
whiteSpace: 'nowrap',
|
|
89
|
+
overflow: 'hidden',
|
|
90
|
+
flex: 'none',
|
|
91
|
+
border: '1px solid transparent',
|
|
92
|
+
color: 'var(--dsw-alias-label-secondary)',
|
|
93
|
+
};
|
|
94
|
+
const ICON_STYLE = { width: 13, height: 13, flex: 'none', opacity: 0.75 };
|
|
95
|
+
/** The words one phase shows, given the call it belongs to. */
|
|
96
|
+
function wording(state) {
|
|
97
|
+
const phase = PHASES[state.phase];
|
|
98
|
+
const label = state.tool === undefined ? undefined : TOOL_LABELS[state.tool] ?? state.tool;
|
|
99
|
+
if (state.phase === 'running' && label !== undefined) {
|
|
100
|
+
return { text: label, hint: `${phase.hint}${label}${state.tabId === undefined ? '' : ` · 标签页 ${state.tabId}`}` };
|
|
101
|
+
}
|
|
102
|
+
if (state.phase === 'error') {
|
|
103
|
+
return { text: phase.text, hint: state.detail === undefined ? phase.hint : `上一次调用失败:${state.detail}` };
|
|
104
|
+
}
|
|
105
|
+
return { text: phase.text, hint: phase.hint };
|
|
106
|
+
}
|
|
73
107
|
/**
|
|
74
|
-
* Render the
|
|
75
|
-
* @param props - the
|
|
76
|
-
* @returns the
|
|
108
|
+
* Render the persistent Chrome status chip.
|
|
109
|
+
* @param props - the header utility's session identity.
|
|
110
|
+
* @returns the chip.
|
|
77
111
|
*/
|
|
78
112
|
export function BrowserActivity({ sessionId }) {
|
|
79
|
-
const [state, setState] = useState({
|
|
113
|
+
const [state, setState] = useState({ phase: 'ready' });
|
|
80
114
|
useEffect(() => {
|
|
81
115
|
ensureStyles();
|
|
82
116
|
let live = true;
|
|
@@ -92,9 +126,16 @@ export function BrowserActivity({ sessionId }) {
|
|
|
92
126
|
clearInterval(timer);
|
|
93
127
|
};
|
|
94
128
|
}, [sessionId]);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
129
|
+
const { text, hint } = wording(state);
|
|
130
|
+
const color = PHASE_COLOR[state.phase];
|
|
131
|
+
return (_jsxs("span", { className: "cb-status", "data-phase": state.phase, role: "status", "aria-live": "polite", title: hint, style: { ...CHIP_STYLE, ...(color.ink === undefined ? {} : { color: color.ink }) }, children: [_jsx("span", { "aria-hidden": "true", style: {
|
|
132
|
+
width: 6,
|
|
133
|
+
height: 6,
|
|
134
|
+
borderRadius: '50%',
|
|
135
|
+
flex: 'none',
|
|
136
|
+
background: color.dot,
|
|
137
|
+
opacity: state.phase === 'ready' ? 0.55 : 1,
|
|
138
|
+
...(state.phase === 'running' ? { animation: 'cb-pulse 1.2s ease-in-out infinite' } : {}),
|
|
139
|
+
} }), _jsx("img", { src: CHROME_ICON_SRC, alt: "", "aria-hidden": "true", style: ICON_STYLE }), _jsx("span", { children: text }), state.phase !== 'running' || state.tabId === undefined ? null : _jsxs("span", { style: { opacity: 0.7 }, children: ["\u6807\u7B7E\u9875 ", state.tabId] })] }));
|
|
99
140
|
}
|
|
100
141
|
//# sourceMappingURL=BrowserActivity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserActivity.js","sourceRoot":"","sources":["../../src/client/BrowserActivity.tsx"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"BrowserActivity.js","sourceRoot":"","sources":["../../src/client/BrowserActivity.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;AAEH,OAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAGlD,kFAAkF;AAClF,MAAM,OAAO,GAAG,IAAI,CAAA;AAEpB;;;G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,EAAC,EAAE,iBAAa,MAAM,EAAC,KAAK,EAAE,UAAU,GAAI,EAC1E,yBAAO,IAAI,GAAQ,EAClB,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAM,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,oCAAO,KAAK,CAAC,KAAK,IAAQ,IACnH,CACR,CAAA;AACH,CAAC"}
|
package/lib/client/activity.d.ts
CHANGED
|
@@ -2,24 +2,31 @@
|
|
|
2
2
|
* Browser-side activity probe: `GET /chrome-browser/activity` behind a short
|
|
3
3
|
* cache.
|
|
4
4
|
*
|
|
5
|
-
* The
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* The header chip polls this while a session view is open. An unreachable host
|
|
6
|
+
* answers "offline" rather than throwing into React: a chip that flickers an
|
|
7
|
+
* error is worse than one that says the bridge is not there, which is also the
|
|
8
|
+
* truth.
|
|
8
9
|
* @module @liyuera/dsh-chrome-browser/client/activity
|
|
9
10
|
*/
|
|
11
|
+
/** Which of the states the chip can show. */
|
|
12
|
+
export type ActivityPhase = 'offline' | 'stale' | 'running' | 'done' | 'error' | 'ready';
|
|
10
13
|
/** One snapshot as the host route answers it. */
|
|
11
14
|
export interface ActivityInfo {
|
|
12
|
-
|
|
15
|
+
/** State to render. */
|
|
16
|
+
phase: ActivityPhase;
|
|
17
|
+
/** Tool the phase belongs to, when it belongs to a call. */
|
|
13
18
|
tool?: string;
|
|
19
|
+
/** Tab that call named, when it named one. */
|
|
14
20
|
tabId?: string;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
/** Failure text, shortened, when the phase is `error`. */
|
|
22
|
+
detail?: string;
|
|
23
|
+
/** Epoch milliseconds this phase began. */
|
|
24
|
+
since?: number;
|
|
18
25
|
}
|
|
19
26
|
/**
|
|
20
27
|
* Read the plugin's current activity for one session.
|
|
21
|
-
* @param sessionId - the session the
|
|
22
|
-
* @returns the snapshot, or an
|
|
28
|
+
* @param sessionId - the session the chip belongs to.
|
|
29
|
+
* @returns the snapshot, or an offline one while the host is unreachable.
|
|
23
30
|
*/
|
|
24
31
|
export declare function readChromeActivity(sessionId: string): Promise<ActivityInfo>;
|
|
25
32
|
/** Drop the cache; exposed so a test can start from a clean probe. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../../src/client/activity.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../../src/client/activity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,6CAA6C;AAC7C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAA;AAExF,iDAAiD;AACjD,MAAM,WAAW,YAAY;IAC3B,uBAAuB;IACvB,KAAK,EAAE,aAAa,CAAA;IACpB,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AA4DD;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAIjF;AAED,sEAAsE;AACtE,wBAAgB,wBAAwB,IAAI,IAAI,CAI/C"}
|
package/lib/client/activity.js
CHANGED
|
@@ -2,17 +2,45 @@
|
|
|
2
2
|
* Browser-side activity probe: `GET /chrome-browser/activity` behind a short
|
|
3
3
|
* cache.
|
|
4
4
|
*
|
|
5
|
-
* The
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* The header chip polls this while a session view is open. An unreachable host
|
|
6
|
+
* answers "offline" rather than throwing into React: a chip that flickers an
|
|
7
|
+
* error is worse than one that says the bridge is not there, which is also the
|
|
8
|
+
* truth.
|
|
8
9
|
* @module @liyuera/dsh-chrome-browser/client/activity
|
|
9
10
|
*/
|
|
10
11
|
/** One snapshot per this window, however many callers ask. */
|
|
11
|
-
const CACHE_MS =
|
|
12
|
-
|
|
12
|
+
const CACHE_MS = 400;
|
|
13
|
+
/** What the chip shows when the host cannot be reached at all. */
|
|
14
|
+
const OFFLINE = { phase: 'offline' };
|
|
13
15
|
let cachedAt = 0;
|
|
14
|
-
let cached =
|
|
16
|
+
let cached = OFFLINE;
|
|
15
17
|
let inflight = null;
|
|
18
|
+
/**
|
|
19
|
+
* Turn one host answer into the phase the chip renders.
|
|
20
|
+
*
|
|
21
|
+
* The link decides first: an extension that is not attached, or is running
|
|
22
|
+
* older files than the plugin ships, is a condition the user has to fix, and it
|
|
23
|
+
* outranks whatever the last call happened to do — a `done` flash drawn on top
|
|
24
|
+
* of a disconnected bridge would be actively misleading.
|
|
25
|
+
* @param body - the parsed route answer.
|
|
26
|
+
* @returns the phase and the fields that belong to it.
|
|
27
|
+
*/
|
|
28
|
+
function phaseOf(body) {
|
|
29
|
+
const rest = {
|
|
30
|
+
...(body.tool === undefined ? {} : { tool: body.tool }),
|
|
31
|
+
...(body.tabId === undefined ? {} : { tabId: body.tabId }),
|
|
32
|
+
...(body.detail === undefined ? {} : { detail: body.detail }),
|
|
33
|
+
...(body.since === undefined ? {} : { since: body.since }),
|
|
34
|
+
};
|
|
35
|
+
if (body.connected === false)
|
|
36
|
+
return { phase: 'offline', ...rest };
|
|
37
|
+
if (body.stale === true)
|
|
38
|
+
return { phase: 'stale', ...rest };
|
|
39
|
+
const phase = body.phase;
|
|
40
|
+
if (phase === 'running' || phase === 'done' || phase === 'error')
|
|
41
|
+
return { phase, ...rest };
|
|
42
|
+
return { phase: 'ready', ...rest };
|
|
43
|
+
}
|
|
16
44
|
async function fetchActivity(sessionId) {
|
|
17
45
|
try {
|
|
18
46
|
const query = sessionId === '' ? '' : `?sessionId=${encodeURIComponent(sessionId)}`;
|
|
@@ -20,27 +48,20 @@ async function fetchActivity(sessionId) {
|
|
|
20
48
|
const body = await response.json();
|
|
21
49
|
if (body.ok !== true)
|
|
22
50
|
throw new Error(body.error ?? 'activity probe failed');
|
|
23
|
-
cached =
|
|
24
|
-
active: body.active === true,
|
|
25
|
-
...(body.tool === undefined ? {} : { tool: body.tool }),
|
|
26
|
-
...(body.tabId === undefined ? {} : { tabId: body.tabId }),
|
|
27
|
-
...(body.startedAt === undefined ? {} : { startedAt: body.startedAt }),
|
|
28
|
-
...(body.lastTool === undefined ? {} : { lastTool: body.lastTool }),
|
|
29
|
-
...(body.lastAt === undefined ? {} : { lastAt: body.lastAt }),
|
|
30
|
-
};
|
|
51
|
+
cached = phaseOf(body);
|
|
31
52
|
}
|
|
32
53
|
catch {
|
|
33
|
-
// The
|
|
34
|
-
//
|
|
35
|
-
cached =
|
|
54
|
+
// The chip says the bridge is not there; the README and the extension
|
|
55
|
+
// status route own explaining why.
|
|
56
|
+
cached = OFFLINE;
|
|
36
57
|
}
|
|
37
58
|
cachedAt = Date.now();
|
|
38
59
|
return cached;
|
|
39
60
|
}
|
|
40
61
|
/**
|
|
41
62
|
* Read the plugin's current activity for one session.
|
|
42
|
-
* @param sessionId - the session the
|
|
43
|
-
* @returns the snapshot, or an
|
|
63
|
+
* @param sessionId - the session the chip belongs to.
|
|
64
|
+
* @returns the snapshot, or an offline one while the host is unreachable.
|
|
44
65
|
*/
|
|
45
66
|
export async function readChromeActivity(sessionId) {
|
|
46
67
|
if (Date.now() - cachedAt < CACHE_MS)
|
|
@@ -51,7 +72,7 @@ export async function readChromeActivity(sessionId) {
|
|
|
51
72
|
/** Drop the cache; exposed so a test can start from a clean probe. */
|
|
52
73
|
export function resetChromeActivityCache() {
|
|
53
74
|
cachedAt = 0;
|
|
54
|
-
cached =
|
|
75
|
+
cached = OFFLINE;
|
|
55
76
|
inflight = null;
|
|
56
77
|
}
|
|
57
78
|
//# sourceMappingURL=activity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity.js","sourceRoot":"","sources":["../../src/client/activity.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"activity.js","sourceRoot":"","sources":["../../src/client/activity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAmBH,8DAA8D;AAC9D,MAAM,QAAQ,GAAG,GAAG,CAAA;AAUpB,kEAAkE;AAClE,MAAM,OAAO,GAAiB,EAAE,KAAK,EAAE,SAAS,EAAE,CAAA;AAElD,IAAI,QAAQ,GAAG,CAAC,CAAA;AAChB,IAAI,MAAM,GAAiB,OAAO,CAAA;AAClC,IAAI,QAAQ,GAAiC,IAAI,CAAA;AAEjD;;;;;;;;;GASG;AACH,SAAS,OAAO,CAAC,IAAoB;IACnC,MAAM,IAAI,GAAG;QACX,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;QACvD,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QAC1D,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAC7D,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;KAC3D,CAAA;IACD,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK;QAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,CA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CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,QAAQ,GAAG,IAAI,CAAA,CAAC,CAAC,CAAC,CAAA;IACxE,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,wBAAwB;IACtC,QAAQ,GAAG,CAAC,CAAA;IACZ,MAAM,GAAG,OAAO,CAAA;IAChB,QAAQ,GAAG,IAAI,CAAA;AACjB,CAAC"}
|
package/lib/client/index.d.ts
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
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
|
|
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
|
|
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,
|
|
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"}
|
package/lib/client/index.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
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:
|
|
28
|
+
order: 90,
|
|
28
29
|
}, BrowserActivity));
|
|
29
30
|
ctx.effect(() => ctx.inputTriggers.registerSource(createChromeTabSource({ listTabs: listChromeTabs, iconFor: tabIcon })), 'chrome-browser: @ tab source');
|
|
30
31
|
}
|
package/lib/client/index.js.map
CHANGED
|
@@ -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,UAAU,KAAK,CAAC,GAAkB;IACtC,
|
|
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,UAAU,KAAK,CAAC,GAAkB;IACtC,6EAA6E;IAC7E,uEAAuE;IACvE,6EAA6E;IAC7E,yEAAyE;IACzE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,uCAAuC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC;QACjF,IAAI,EAAE,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