dsh-duet 0.3.1 → 0.3.3
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 +2 -0
- package/assets/avatar/desktop/companion.mjs +3 -4
- package/assets/avatar/desktop/manifest.json +1 -1
- package/desktop/bin/darwin-arm64/duet-avatar.app/Contents/MacOS/duet-avatar +0 -0
- package/desktop/bin/darwin-arm64/manifest.json +3 -3
- package/desktop/bin/win32-x64/duet-avatar.exe +0 -0
- package/desktop/bin/win32-x64/manifest.json +3 -3
- package/node_modules/dsh-duet-superagent/lib/duet.d.ts +17 -2
- package/node_modules/dsh-duet-superagent/lib/duet.js +99 -4
- package/node_modules/dsh-duet-superagent/lib/{feishu-rAGM9U9b.js → feishu-CwKBb-B_.js} +1 -1
- package/node_modules/dsh-duet-superagent/lib/feishu-watch.d.ts +1 -1
- package/node_modules/dsh-duet-superagent/lib/feishu-watch.js +1 -1
- package/node_modules/dsh-duet-superagent/lib/{github-pull-gSbjzypm.js → github-pull-DyfAy0yE.js} +1 -1
- package/node_modules/dsh-duet-superagent/lib/github-watch.d.ts +1 -1
- package/node_modules/dsh-duet-superagent/lib/github-watch.js +2 -2
- package/node_modules/dsh-duet-superagent/lib/index.js +2 -2
- package/node_modules/dsh-duet-superagent/lib/{poll-Dh7J1cdM.js → poll-BBkmV_GM.js} +4 -1
- package/node_modules/dsh-duet-superagent/lib/{registry-BTgyFZ8S.d.ts → registry-Ehgir8LC.d.ts} +70 -61
- package/node_modules/dsh-duet-superagent/lib/{runtime-mbw1-2iK.js → runtime-Ow0S-7ZZ.js} +44 -4
- package/package.json +2 -2
- package/src/avatar/companion.mjs +5 -3
- package/src/avatar/surface.mjs +6 -1
- package/src/client/agent-tasks.mjs +144 -17
- package/src/client/audio.mjs +1 -1
- package/src/client/avatar-surfaces.mjs +3 -3
- package/src/client/avatar.mjs +15 -2
- package/src/client/browser.mjs +24 -24
- package/src/client/composer-bridge.mjs +1 -1
- package/src/client/connection-hint.mjs +1 -1
- package/src/client/entry.js +2 -2
- package/src/client/feedback.mjs +1 -1
- package/src/client/identity.mjs +1 -1
- package/src/client/interactions.mjs +5 -4
- package/src/client/notice.mjs +30 -9
- package/src/client/settings.html +5 -4
- package/src/client/sidebar-layout.mjs +26 -0
- package/src/client/tutorial-adapter.mjs +5 -5
- package/src/client/tutorial.mjs +1 -1
- package/src/client/work-mode.mjs +12 -6
- package/src/host/agent-connection.mjs +6 -1
- package/src/host/assets.mjs +1 -0
- package/src/host/auth.mjs +13 -0
- package/src/host/avatar.mjs +32 -13
- package/src/host/plugin.mjs +22 -17
- package/src/host/proxy.mjs +3 -2
- package/src/host/sync-feed.mjs +3 -2
- package/src/shared/avatar-menu-ui.mjs +30 -12
- package/src/shared/avatar-menu.mjs +4 -1
- package/src/shared/avatar-surface.mjs +1 -0
- package/src/shared/avatar-ui.mjs +2 -0
- package/src/shared/state.mjs +29 -4
- package/src/shared/work-mode.mjs +20 -0
package/node_modules/dsh-duet-superagent/lib/{registry-BTgyFZ8S.d.ts → registry-Ehgir8LC.d.ts}
RENAMED
|
@@ -12,6 +12,71 @@ declare const ADMISSION_OPTIONS: {
|
|
|
12
12
|
};
|
|
13
13
|
type AdmissionRow = { [C in AdmissionCell]?: typeof ADMISSION_OPTIONS[C][number]; };
|
|
14
14
|
//#endregion
|
|
15
|
+
//#region src/policy.d.ts
|
|
16
|
+
declare const RoleModelSchema: z.ZodObject<{
|
|
17
|
+
provider: z.ZodString;
|
|
18
|
+
model: z.ZodString;
|
|
19
|
+
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, z.core.$strict>;
|
|
21
|
+
type RoleModel = z.infer<typeof RoleModelSchema>;
|
|
22
|
+
declare const SettingsSchema: z.ZodObject<{
|
|
23
|
+
paused: z.ZodDefault<z.ZodBoolean>;
|
|
24
|
+
sources: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
25
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
26
|
+
config: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
27
|
+
}, z.core.$strict>>>;
|
|
28
|
+
policy: z.ZodDefault<z.ZodObject<{
|
|
29
|
+
rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
30
|
+
id: z.ZodString;
|
|
31
|
+
name: z.ZodString;
|
|
32
|
+
enabled: z.ZodBoolean;
|
|
33
|
+
instruction: z.ZodString;
|
|
34
|
+
}, z.core.$strict>>>;
|
|
35
|
+
sources: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
36
|
+
allowed: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
37
|
+
id: z.ZodString;
|
|
38
|
+
name: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, z.core.$strict>>>;
|
|
40
|
+
admission: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<AdmissionRow, unknown, z.core.$ZodTypeInternals<AdmissionRow, unknown>>>>;
|
|
41
|
+
}, z.core.$catchall<z.ZodUnknown>>>>;
|
|
42
|
+
}, z.core.$strict>>;
|
|
43
|
+
eval: z.ZodDefault<z.ZodObject<{
|
|
44
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
45
|
+
off: "off";
|
|
46
|
+
observe: "observe";
|
|
47
|
+
auto: "auto";
|
|
48
|
+
}>>;
|
|
49
|
+
timeoutSeconds: z.ZodDefault<z.ZodNumber>;
|
|
50
|
+
model: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
51
|
+
provider: z.ZodString;
|
|
52
|
+
model: z.ZodString;
|
|
53
|
+
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
54
|
+
}, z.core.$strict>>>;
|
|
55
|
+
}, z.core.$strict>>;
|
|
56
|
+
executor: z.ZodDefault<z.ZodObject<{
|
|
57
|
+
model: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
58
|
+
provider: z.ZodString;
|
|
59
|
+
model: z.ZodString;
|
|
60
|
+
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, z.core.$strict>>>;
|
|
62
|
+
maxWorkers: z.ZodDefault<z.ZodNumber>;
|
|
63
|
+
directory: z.ZodDefault<z.ZodString>;
|
|
64
|
+
prepare: z.ZodDefault<z.ZodString>;
|
|
65
|
+
blockedCommands: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
66
|
+
}, z.core.$strict>>;
|
|
67
|
+
}, z.core.$strict>;
|
|
68
|
+
type Settings = z.infer<typeof SettingsSchema>;
|
|
69
|
+
type SettingsBlock = 'policy' | 'eval' | 'executor' | `source:${string}`;
|
|
70
|
+
type SettingsSave = SettingsBlock | 'pause';
|
|
71
|
+
type SettingsOrigin = 'panel' | 'tool' | 'sync';
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/app/role-models.d.ts
|
|
74
|
+
type ModelDisplay = {
|
|
75
|
+
provider: string;
|
|
76
|
+
model: string;
|
|
77
|
+
source: 'response' | 'request' | 'selection' | 'configured';
|
|
78
|
+
};
|
|
79
|
+
//#endregion
|
|
15
80
|
//#region src/infra/commands.d.ts
|
|
16
81
|
interface Tally {
|
|
17
82
|
skipped: number;
|
|
@@ -82,64 +147,6 @@ interface SetupProblem {
|
|
|
82
147
|
detail: string;
|
|
83
148
|
}
|
|
84
149
|
//#endregion
|
|
85
|
-
//#region src/policy.d.ts
|
|
86
|
-
declare const RoleModelSchema: z.ZodObject<{
|
|
87
|
-
provider: z.ZodString;
|
|
88
|
-
model: z.ZodString;
|
|
89
|
-
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
90
|
-
}, z.core.$strict>;
|
|
91
|
-
type RoleModel = z.infer<typeof RoleModelSchema>;
|
|
92
|
-
declare const SettingsSchema: z.ZodObject<{
|
|
93
|
-
paused: z.ZodDefault<z.ZodBoolean>;
|
|
94
|
-
sources: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
95
|
-
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
96
|
-
config: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
97
|
-
}, z.core.$strict>>>;
|
|
98
|
-
policy: z.ZodDefault<z.ZodObject<{
|
|
99
|
-
rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
100
|
-
id: z.ZodString;
|
|
101
|
-
name: z.ZodString;
|
|
102
|
-
enabled: z.ZodBoolean;
|
|
103
|
-
instruction: z.ZodString;
|
|
104
|
-
}, z.core.$strict>>>;
|
|
105
|
-
sources: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
106
|
-
allowed: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
107
|
-
id: z.ZodString;
|
|
108
|
-
name: z.ZodOptional<z.ZodString>;
|
|
109
|
-
}, z.core.$strict>>>;
|
|
110
|
-
admission: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<AdmissionRow, unknown, z.core.$ZodTypeInternals<AdmissionRow, unknown>>>>;
|
|
111
|
-
}, z.core.$catchall<z.ZodUnknown>>>>;
|
|
112
|
-
}, z.core.$strict>>;
|
|
113
|
-
eval: z.ZodDefault<z.ZodObject<{
|
|
114
|
-
mode: z.ZodDefault<z.ZodEnum<{
|
|
115
|
-
off: "off";
|
|
116
|
-
observe: "observe";
|
|
117
|
-
auto: "auto";
|
|
118
|
-
}>>;
|
|
119
|
-
timeoutSeconds: z.ZodDefault<z.ZodNumber>;
|
|
120
|
-
model: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
121
|
-
provider: z.ZodString;
|
|
122
|
-
model: z.ZodString;
|
|
123
|
-
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
124
|
-
}, z.core.$strict>>>;
|
|
125
|
-
}, z.core.$strict>>;
|
|
126
|
-
executor: z.ZodDefault<z.ZodObject<{
|
|
127
|
-
model: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
128
|
-
provider: z.ZodString;
|
|
129
|
-
model: z.ZodString;
|
|
130
|
-
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
131
|
-
}, z.core.$strict>>>;
|
|
132
|
-
maxWorkers: z.ZodDefault<z.ZodNumber>;
|
|
133
|
-
directory: z.ZodDefault<z.ZodString>;
|
|
134
|
-
prepare: z.ZodDefault<z.ZodString>;
|
|
135
|
-
blockedCommands: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
136
|
-
}, z.core.$strict>>;
|
|
137
|
-
}, z.core.$strict>;
|
|
138
|
-
type Settings = z.infer<typeof SettingsSchema>;
|
|
139
|
-
type SettingsBlock = 'policy' | 'eval' | 'executor' | `source:${string}`;
|
|
140
|
-
type SettingsSave = SettingsBlock | 'pause';
|
|
141
|
-
type SettingsOrigin = 'panel' | 'tool' | 'sync';
|
|
142
|
-
//#endregion
|
|
143
150
|
//#region src/app/execution-environment.d.ts
|
|
144
151
|
interface Variable {
|
|
145
152
|
key: string;
|
|
@@ -555,6 +562,8 @@ declare class Sessions {
|
|
|
555
562
|
} | {
|
|
556
563
|
model_retry?: undefined;
|
|
557
564
|
};
|
|
565
|
+
/** Observed request/response first; a pending selection is never labelled as executed. */
|
|
566
|
+
modelInfo(sessionId: string): ModelDisplay | null;
|
|
558
567
|
private updateModelHealth;
|
|
559
568
|
private ticketOf;
|
|
560
569
|
private decorate;
|
|
@@ -661,7 +670,7 @@ declare class Prompts {
|
|
|
661
670
|
key: string;
|
|
662
671
|
text: string;
|
|
663
672
|
} | {
|
|
664
|
-
name: "scope" | "
|
|
673
|
+
name: "scope" | "delivery" | "communication";
|
|
665
674
|
kind: "team";
|
|
666
675
|
heading: string;
|
|
667
676
|
text: string;
|
|
@@ -677,7 +686,7 @@ declare class Prompts {
|
|
|
677
686
|
key: string;
|
|
678
687
|
text: string;
|
|
679
688
|
} | {
|
|
680
|
-
name: "scope" | "
|
|
689
|
+
name: "scope" | "delivery" | "communication";
|
|
681
690
|
kind: "team";
|
|
682
691
|
heading: string;
|
|
683
692
|
text: string;
|
|
@@ -1506,4 +1515,4 @@ declare class SourceRegistry implements SourceScope {
|
|
|
1506
1515
|
private resolve;
|
|
1507
1516
|
}
|
|
1508
1517
|
//#endregion
|
|
1509
|
-
export {
|
|
1518
|
+
export { ModelDisplay as A, Store as C, SetupProblem as D, Variable as E, Settings as M, SettingsBlock as N, Commands as O, SettingsOrigin as P, Effects as S, HealthEntry as T, pollTicketPulls as _, Health as a, Prompts as b, GithubConfig as c, githubKind as d, inject as f, pollThreads as g, pollRound as h, TriggerContext as i, RoleModel as j, Tally as k, Retry as l, pollFailure as m, ChannelLink as n, SourceContext as o, name as p, SourceKind as r, SourceHost as s, SourceRegistry as t, apply as u, GithubComment as v, HealthBoard as w, Sessions as x, commentTrigger as y };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as checkedImText, B as liveTicket, C as withoutDirectory, D as Commands, F as key, G as threadKey, H as readUntil, I as followupOwners, K as ticketOutcome, L as isoTime, M as sameName, N as wordCount, P as LIMITS, R as latestAssignment, S as verifyEnvironment, T as writeEnvironment, U as runningAssignment, V as reached, W as settled, _ as WORKER_COMMANDS, b as runAsWorker, f as SETUP_FIELDS, g as workerProbe, h as resolveFeishuBot, k as SetupError, m as resolveDeployment, o as KV, q as waitsForPerson, s as health, v as agentVariables, w as workerBin, x as verifyDirectory, y as applyEnvironment, z as latestReport } from "./poll-
|
|
2
|
-
import { i as pullOf, m as readRepositoryPath, o as readPull, p as readGithub, r as pullEndNotices, t as claimPull } from "./github-pull-
|
|
3
|
-
import { b as feishuTriggerId, d as feishuChatLink, f as feishuRead, g as feishuRef, m as readFeishuLink, p as feishuReferences, r as feishuSettings } from "./feishu-
|
|
1
|
+
import { A as checkedImText, B as liveTicket, C as withoutDirectory, D as Commands, F as key, G as threadKey, H as readUntil, I as followupOwners, K as ticketOutcome, L as isoTime, M as sameName, N as wordCount, P as LIMITS, R as latestAssignment, S as verifyEnvironment, T as writeEnvironment, U as runningAssignment, V as reached, W as settled, _ as WORKER_COMMANDS, b as runAsWorker, f as SETUP_FIELDS, g as workerProbe, h as resolveFeishuBot, k as SetupError, m as resolveDeployment, o as KV, q as waitsForPerson, s as health, v as agentVariables, w as workerBin, x as verifyDirectory, y as applyEnvironment, z as latestReport } from "./poll-BBkmV_GM.js";
|
|
2
|
+
import { i as pullOf, m as readRepositoryPath, o as readPull, p as readGithub, r as pullEndNotices, t as claimPull } from "./github-pull-DyfAy0yE.js";
|
|
3
|
+
import { b as feishuTriggerId, d as feishuChatLink, f as feishuRead, g as feishuRef, m as readFeishuLink, p as feishuReferences, r as feishuSettings } from "./feishu-CwKBb-B_.js";
|
|
4
4
|
import { Service } from "@deepseek-ai/cordis";
|
|
5
5
|
import { chmodSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
6
6
|
import { basename, dirname, join } from "node:path";
|
|
@@ -2838,6 +2838,7 @@ function triggerCard(trigger, disposition) {
|
|
|
2838
2838
|
preview: preview$1(trigger.text),
|
|
2839
2839
|
chars: trigger.text.length,
|
|
2840
2840
|
read: `trigger/${trigger.id}`,
|
|
2841
|
+
...trigger.source === "duet" && trigger.meta.duet_session ? { duet_session: trigger.meta.duet_session } : {},
|
|
2841
2842
|
...disposition ? { disposition: {
|
|
2842
2843
|
...disposition.filtered ? { filtered: reasonText(disposition.filtered) } : {},
|
|
2843
2844
|
...disposition.decisionId ? { decision_id: disposition.decisionId } : {},
|
|
@@ -5209,6 +5210,7 @@ function triggerMessage(trigger, link, note, repliesTo) {
|
|
|
5209
5210
|
from: trigger.actor.id,
|
|
5210
5211
|
thread: threadKey(trigger.threads[0]),
|
|
5211
5212
|
at: trigger.at,
|
|
5213
|
+
...trigger.source === "duet" && trigger.meta.duet_session ? { duet_session: trigger.meta.duet_session } : {},
|
|
5212
5214
|
...capped(trigger.text, TRIGGER_CHARS, `trigger/${trigger.id}`),
|
|
5213
5215
|
...link,
|
|
5214
5216
|
...note ? { routing_note: note } : {},
|
|
@@ -7566,6 +7568,22 @@ const THREAD_FILTERS = [
|
|
|
7566
7568
|
];
|
|
7567
7569
|
//#endregion
|
|
7568
7570
|
//#region src/app/role-models.ts
|
|
7571
|
+
/** A small display projection, never the request envelope or provider credentials. */
|
|
7572
|
+
function modelDisplay(value, source) {
|
|
7573
|
+
if (!value || typeof value !== "object") return null;
|
|
7574
|
+
const { provider, model } = value;
|
|
7575
|
+
return typeof provider === "string" && provider.length > 0 && typeof model === "string" && model.length > 0 ? {
|
|
7576
|
+
provider,
|
|
7577
|
+
model,
|
|
7578
|
+
source
|
|
7579
|
+
} : null;
|
|
7580
|
+
}
|
|
7581
|
+
function eventModelDisplay(event) {
|
|
7582
|
+
const data = event.data;
|
|
7583
|
+
if (event.type === "request/header") return modelDisplay(data?.header?.config, "request");
|
|
7584
|
+
if (event.type === "assistant/message" && data?.message?.source?.kind === "model") return modelDisplay(data.message.source, "response");
|
|
7585
|
+
return null;
|
|
7586
|
+
}
|
|
7569
7587
|
/** Resolve a configured route through the live provider; catalog membership is not a restriction. */
|
|
7570
7588
|
async function resolveRoleModel(ctx, model) {
|
|
7571
7589
|
const effort = model.reasoningEffort === void 0 ? {} : { reasoningEffort: ReasoningEffortId(model.reasoningEffort) };
|
|
@@ -9311,6 +9329,8 @@ var Sessions = class {
|
|
|
9311
9329
|
const agent = ctx.agents.get(session.id);
|
|
9312
9330
|
const binding = agent && agent.session === session ? this.bindings.get(agent) : void 0;
|
|
9313
9331
|
if (!agent || !binding || binding.subagent) return;
|
|
9332
|
+
const model = eventModelDisplay(event);
|
|
9333
|
+
if (model) this.host.store.set(KV.sessions.model(agent.id), model);
|
|
9314
9334
|
this.retryHealth.observe(agent.id, event);
|
|
9315
9335
|
this.updateModelHealth();
|
|
9316
9336
|
});
|
|
@@ -9463,6 +9483,24 @@ var Sessions = class {
|
|
|
9463
9483
|
const retry = sessionId ? this.retryHealth.get(sessionId) : void 0;
|
|
9464
9484
|
return retry ? { model_retry: retry } : {};
|
|
9465
9485
|
}
|
|
9486
|
+
/** Observed request/response first; a pending selection is never labelled as executed. */
|
|
9487
|
+
modelInfo(sessionId) {
|
|
9488
|
+
const observed = this.host.store.get(KV.sessions.model(sessionId));
|
|
9489
|
+
if (observed) return observed;
|
|
9490
|
+
const agent = this.ctx.agents.get(sessionId);
|
|
9491
|
+
const requested = modelDisplay(agent?.session.requestHeader()?.config, "request");
|
|
9492
|
+
if (requested) return requested;
|
|
9493
|
+
const selected = agent?.session.snapshotEvents().filter((e) => e.type === "model/selection").at(-1);
|
|
9494
|
+
if (selected) {
|
|
9495
|
+
const value = modelDisplay(selected.data, "selection");
|
|
9496
|
+
if (value) return value;
|
|
9497
|
+
}
|
|
9498
|
+
const saved = ticketOfSession(sessionId) ? this.host.store.get(`duet:worker-model:${sessionId}`) : null;
|
|
9499
|
+
if (saved) try {
|
|
9500
|
+
return modelDisplay(JSON.parse(String(saved)), "configured");
|
|
9501
|
+
} catch {}
|
|
9502
|
+
return modelDisplay(sessionId === this.host.masterId ? this.host.store.settings().eval.model : this.host.store.settings().executor.model, "configured");
|
|
9503
|
+
}
|
|
9466
9504
|
updateModelHealth() {
|
|
9467
9505
|
const retries = this.retryHealth.list();
|
|
9468
9506
|
this.host.health.set(retries.length ? {
|
|
@@ -9489,6 +9527,8 @@ var Sessions = class {
|
|
|
9489
9527
|
}
|
|
9490
9528
|
const binding = { disposers: [] };
|
|
9491
9529
|
this.bindings.set(agent, binding);
|
|
9530
|
+
const recorded = agent.session.snapshotEvents().map(eventModelDisplay).filter(Boolean).at(-1);
|
|
9531
|
+
if (recorded) this.host.store.set(KV.sessions.model(agent.id), recorded);
|
|
9492
9532
|
this.retryHealth.restore(agent.id, agent.session.snapshotEvents());
|
|
9493
9533
|
if (agent.status === "idle") this.retryHealth.clear(agent.id);
|
|
9494
9534
|
this.updateModelHealth();
|
|
@@ -10650,4 +10690,4 @@ var Runtime = class extends Service {
|
|
|
10650
10690
|
}
|
|
10651
10691
|
};
|
|
10652
10692
|
//#endregion
|
|
10653
|
-
export {
|
|
10693
|
+
export { Engine as a, said as c, USER_ERRORS as d, UserError as f, guides as i, canRetry as l, resolveRoleModel as n, REASONS as o, followupNotice as r, reasonText as s, Runtime as t, ticketStage as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-duet",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "duet(二重奏):只用语音就能操作 DSH,边听边说、随时插话的全双工语音助手。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh-plugin",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "node scripts/test.mjs",
|
|
24
24
|
"check": "node scripts/check-package.mjs",
|
|
25
|
-
"test:browser": "node tests/browser/entry-loading.mjs && node tests/browser/settings.mjs && node tests/browser/tutorial.mjs && node tests/browser/feedback.mjs && node tests/browser/connection-hint.mjs && node tests/browser/update-notice.mjs && node tests/browser/voices.mjs && node tests/browser/controls-layout.mjs && node tests/browser/resilience.mjs && node tests/browser/page-binding.mjs && node tests/browser/stop-task.mjs && node tests/browser/desktop-settings.mjs && node tests/browser/desktop-identity.mjs && node tests/browser/audio-interruption.mjs",
|
|
25
|
+
"test:browser": "node tests/browser/entry-loading.mjs && node tests/browser/settings.mjs && node tests/browser/tutorial.mjs && node tests/browser/feedback.mjs && node tests/browser/connection-hint.mjs && node tests/browser/update-notice.mjs && node tests/browser/voices.mjs && node tests/browser/controls-layout.mjs && node tests/browser/resilience.mjs && node tests/browser/page-binding.mjs && node tests/browser/stop-task.mjs && node tests/browser/desktop-settings.mjs && node tests/browser/desktop-identity.mjs && node tests/browser/audio-interruption.mjs && node tests/browser/agent-task-sidebar.mjs",
|
|
26
26
|
"test:work-mode": "node tests/browser/work-mode.mjs",
|
|
27
27
|
"test:agent-navigation": "node tests/browser/agent-tool-views.mjs && node tests/browser/work-mode.mjs && node tests/browser/agent-tasks.mjs",
|
|
28
28
|
"test:host": "node tests/host/isolated-host.mjs",
|
package/src/avatar/companion.mjs
CHANGED
|
@@ -117,7 +117,8 @@ const close=()=>{
|
|
|
117
117
|
model?.update({...frame,rms:0,text:''});model?.dispose();socket.close()
|
|
118
118
|
void invoke('hide_avatar').catch(()=>{})
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
let nativeVisibility
|
|
121
|
+
const notifyReady=()=>{if(failed)send({type:'failed'});else if(ready)send({type:'ready',protocol:AVATAR_UI_PROTOCOL,...(typeof nativeVisibility?.visible==='boolean'?{window_visible:nativeVisibility.visible,fullscreen_suppressed:nativeVisibility.fullscreen_suppressed===true}:{})})}
|
|
121
122
|
// Serialize native resize and hit-mask updates, including rapid preference changes.
|
|
122
123
|
// The owning page persists the preference; this window never opens a second store.
|
|
123
124
|
const requestSize=size=>{
|
|
@@ -139,7 +140,7 @@ const requestSize=size=>{
|
|
|
139
140
|
return sizePending
|
|
140
141
|
}
|
|
141
142
|
try{model=mountAvatarRenderer($('avatar'),{modelURL:'./character.glb',onReady(){
|
|
142
|
-
void Promise.all([pointerReady,requestSize(desiredSize)]).then(async()=>{if(closed||failed)return;ready=true;await refreshMask();if(closed)return;notifyReady()
|
|
143
|
+
void Promise.all([pointerReady,requestSize(desiredSize)]).then(async()=>{if(closed||failed)return;nativeVisibility=await invoke('show_avatar');if(closed)return;ready=true;await refreshMask();if(closed)return;notifyReady()})
|
|
143
144
|
.catch(()=>{failed=true;send({type:'failed'});close()})
|
|
144
145
|
},onError(){failed=true;notifyReady()}})}catch{failed=true}
|
|
145
146
|
socket.onopen=notifyReady
|
|
@@ -148,7 +149,8 @@ socket.onmessage=e=>{
|
|
|
148
149
|
liveness.touch()
|
|
149
150
|
try{
|
|
150
151
|
const message=JSON.parse(e.data)
|
|
151
|
-
if(message.type==='
|
|
152
|
+
if(message.type==='shutdown'){close()}
|
|
153
|
+
else if(message.type==='frame'){
|
|
152
154
|
frame=avatarFrame(message);last=Date.now();model?.update(frame);void requestSize(frame.size)
|
|
153
155
|
if(frame.mode==='off')clearInput();caption();controls()
|
|
154
156
|
}else if(message.type==='input_effect'){
|
package/src/avatar/surface.mjs
CHANGED
|
@@ -24,7 +24,12 @@ export function mountCompanionSurface(root,{send,changed}) {
|
|
|
24
24
|
const tag=n.kind==='break'?'br':n.kind==='heading'?'h3':n.kind==='button'?'button':n.kind==='checkbox'?'input':'span'
|
|
25
25
|
const e=element(n.action||'node'+index,tag)
|
|
26
26
|
if(n.taskState)e.dataset.taskState=n.taskState;else delete e.dataset.taskState
|
|
27
|
-
if(
|
|
27
|
+
if(n.countdown!==undefined){
|
|
28
|
+
let copy=e.querySelector('[data-task-copy]'),count=e.querySelector('[data-task-countdown-label]')
|
|
29
|
+
if(!copy||!count){copy=document.createElement('span');copy.dataset.taskCopy='';count=document.createElement('small');count.dataset.taskCountdownLabel='';e.replaceChildren(copy,count)}
|
|
30
|
+
copy.textContent=n.text;copy.style.cssText='min-width:0;white-space:pre-line;overflow-wrap:anywhere'
|
|
31
|
+
count.textContent=`${n.countdown}s 后消失`;count.style.cssText='margin-left:auto;flex-shrink:0;color:#737b85;font:400 10px/1.4 system-ui;white-space:nowrap'
|
|
32
|
+
}else if(e.textContent!==n.text||e.querySelector('[data-task-countdown-label]'))e.textContent=n.text
|
|
28
33
|
if(n.kind==='checkbox'){e.type='checkbox';e.checked=n.checked}
|
|
29
34
|
if(n.kind==='button'||n.kind==='checkbox'){
|
|
30
35
|
e.dataset.surfaceAction=n.action
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import {sidebarElement,clipToSidebar} from './sidebar-layout.mjs'
|
|
1
2
|
import {focusedSession,openLocalSession} from './composer.mjs'
|
|
2
|
-
import {
|
|
3
|
+
import {taskBubbleCardStyle} from '../shared/avatar-ui.mjs'
|
|
4
|
+
import {TASK_STATES as states, noteTaskNoticeVisit, taskCardState, visibleTaskRows, taskCompletionSeconds} from '../shared/work-mode.mjs'
|
|
3
5
|
const active=new Set(['queued','pending','running','progress','waiting','waiting_user','blocked'])
|
|
4
6
|
const bubbleCSS=`
|
|
7
|
+
[data-duet-agent-tasks][data-sidebar-tasks]{pointer-events:none}
|
|
8
|
+
[data-duet-agent-tasks][data-sidebar-tasks]::before{display:none}
|
|
9
|
+
[data-duet-agent-tasks][data-sidebar-tasks]>summary,[data-duet-agent-tasks][data-sidebar-tasks]>[data-task-list]{pointer-events:auto}
|
|
5
10
|
[data-duet-agent-tasks]{position:fixed;isolation:isolate;z-index:2147483599;margin:0;color:CanvasText;font:13px/1.35 -apple-system,BlinkMacSystemFont,system-ui,sans-serif}
|
|
6
11
|
[data-duet-agent-tasks] summary,[data-duet-agent-tasks] [data-task-list]{box-sizing:border-box;background:Canvas;border:1px solid color-mix(in srgb,CanvasText 12%,Canvas);box-shadow:0 8px 22px -7px #0003,0 1px 4px #0001}
|
|
7
12
|
[data-duet-agent-tasks] summary{position:relative;display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;column-gap:8px;padding:7px 15px;border-radius:24px;text-align:start;list-style:none;cursor:pointer;user-select:none}
|
|
@@ -17,9 +22,27 @@ const bubbleCSS=`
|
|
|
17
22
|
[data-duet-agent-tasks][data-inline] summary{display:none}
|
|
18
23
|
[data-duet-agent-tasks][data-inline] [data-task-list]{position:static;width:100%;max-height:65vh;overflow:auto}
|
|
19
24
|
[data-duet-agent-tasks] [data-task-list]{background:transparent!important;border:0;box-shadow:none;padding:0;backdrop-filter:none!important;-webkit-backdrop-filter:none!important}
|
|
20
|
-
[data-duet-agent-tasks] [data-task-list] button{
|
|
25
|
+
[data-duet-agent-tasks] [data-task-list] button{${taskBubbleCardStyle};margin-bottom:8px}
|
|
21
26
|
[data-duet-agent-tasks] [data-task-list] button span{font-size:13px;font-weight:550;line-height:1.5;overflow-wrap:anywhere}
|
|
27
|
+
[data-duet-agent-tasks][data-sidebar-tasks] summary{display:none}
|
|
28
|
+
[data-duet-agent-tasks][data-sidebar-tasks] [data-task-list]{position:relative;overflow:visible;max-height:none}
|
|
29
|
+
[data-duet-agent-tasks][data-sidebar-tasks] [data-task-list] button{position:absolute;left:0;top:var(--task-y);width:100%;height:72px;min-height:0;margin:0;padding:9px 10px;gap:7px;align-items:flex-start;border-radius:13px;background:#f4f8fc!important;backdrop-filter:none;box-shadow:0 3px 10px #243c5620;text-align:left;transition:box-shadow .18s}
|
|
30
|
+
[data-duet-agent-tasks][data-sidebar-tasks] [data-task-copy]{min-width:0;flex:1}
|
|
31
|
+
[data-duet-agent-tasks][data-sidebar-tasks] [data-task-name]{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:12px;line-height:18px}
|
|
32
|
+
[data-duet-agent-tasks][data-sidebar-tasks] [data-task-progress]{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;font-size:11px;line-height:16px;color:#617287;font-weight:400;margin-top:3px;white-space:pre-wrap}
|
|
33
|
+
[data-duet-agent-tasks][data-sidebar-tasks] [data-task-state]::before{margin-top:2px}
|
|
34
|
+
/* Keep the invisible anchor's geometry/hit area, so replacing it with the
|
|
35
|
+
detail does not move its neighbours or flicker between hover targets. */
|
|
36
|
+
[data-duet-agent-tasks][data-sidebar-tasks] button[data-expanded]{opacity:0;z-index:100!important}
|
|
37
|
+
[data-duet-task-detail]{position:fixed;z-index:2147483600;box-sizing:border-box;border-radius:16px;overflow:auto;box-shadow:0 10px 32px #243c5640;background:#fff;animation:duet-task-detail-in .16s ease-out}
|
|
38
|
+
[data-duet-task-detail]>button{${taskBubbleCardStyle};align-items:flex-start;border-radius:16px;background:#fff;backdrop-filter:none;box-shadow:none}
|
|
39
|
+
[data-duet-task-detail] [data-task-copy]{min-width:0;flex:1}
|
|
40
|
+
[data-duet-task-detail] [data-task-name]{display:block;font-size:13px;font-weight:600;white-space:normal;overflow-wrap:anywhere}
|
|
41
|
+
[data-duet-task-detail] [data-task-progress]{display:block;font-size:12px;line-height:1.6;color:#617287;white-space:pre-wrap;overflow-wrap:anywhere;margin-top:6px}
|
|
42
|
+
@keyframes duet-task-detail-in{from{opacity:0}to{opacity:1}}
|
|
43
|
+
@media(prefers-reduced-motion:reduce){[data-duet-task-detail]{animation:none}}
|
|
22
44
|
[data-task-state]::before{content:'';display:block;flex:0 0 18px;width:18px;height:18px;box-sizing:border-box;border:2px solid #62a0cd45;border-top-color:#468abf;border-radius:50%;animation:duet-task-spin 1s linear infinite}
|
|
45
|
+
[data-task-state=running]::before{flex:0 0 16px;width:16px;min-width:16px;max-width:16px;height:16px;min-height:16px;max-height:16px;padding:0;border:0;border-radius:0;box-sizing:content-box;background:center/16px 16px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='%23d8e8f5' stroke-width='2.4'/%3E%3Cpath d='M12 3a9 9 0 0 1 9 9' fill='none' stroke='%234c91c7' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E");transform-origin:50% 50%;animation:duet-task-spin 1.1s linear infinite}
|
|
23
46
|
[data-task-state=completed]::before{content:'✓';border:0;background:#dcefe8;color:#23845e;text-align:center;font:600 14px/18px system-ui;animation:none}
|
|
24
47
|
[data-task-state=waiting]::before{content:'?';border:0;background:#fff0d9;color:#ad7523;text-align:center;font:600 13px/18px system-ui;animation:none}
|
|
25
48
|
[data-task-state=failed]::before,[data-task-state=stopped]::before{content:'!';border:0;background:#f8e3e3;color:#b45353;text-align:center;font:600 13px/18px system-ui;animation:none}
|
|
@@ -33,22 +56,60 @@ const bubbleCSS=`
|
|
|
33
56
|
|
|
34
57
|
/** A local, connection-owned projection; never turn the model's short handles into UI routes. */
|
|
35
58
|
export function agentTaskPanel(ctx,anchor,notice,presentation=()=>null){
|
|
36
|
-
let box,summary,title,statusLine,count,list,attempt,currentFrame,limit=50,lifecycle,resize,mutations,raf=0,tracked
|
|
59
|
+
let box,summary,title,statusLine,count,list,attempt,currentFrame,limit=50,lifecycle,resize,mutations,raf=0,tracked,timer,releaseTaskLayout
|
|
60
|
+
let countdowns=[]
|
|
61
|
+
let detail,detailSource,detailTimer,suppressedDetail
|
|
62
|
+
function closeDetail(){
|
|
63
|
+
clearTimeout(detailTimer);detail?.remove();detail=null
|
|
64
|
+
detailSource?.removeAttribute('data-expanded');detailSource?.removeAttribute('aria-expanded');detailSource=null
|
|
65
|
+
}
|
|
66
|
+
const laterClose=()=>{clearTimeout(detailTimer);detailTimer=setTimeout(closeDetail,140)}
|
|
67
|
+
function showDetail(button){
|
|
68
|
+
if(!box?.hasAttribute('data-sidebar-tasks'))return
|
|
69
|
+
if(suppressedDetail===button)return
|
|
70
|
+
clearTimeout(detailTimer)
|
|
71
|
+
if(detailSource===button&&detail)return
|
|
72
|
+
closeDetail();detailSource=button;button.dataset.expanded='';button.setAttribute('aria-expanded','true')
|
|
73
|
+
const a=button.getBoundingClientRect()
|
|
74
|
+
detail=document.createElement('div');detail.dataset.duetTaskDetail=''
|
|
75
|
+
detail.setAttribute('role','region');detail.setAttribute('aria-label','任务最新进度')
|
|
76
|
+
// Lay out one separate card at its final width. Fade opacity only: no
|
|
77
|
+
// animated width or per-frame text wrapping, and never move over the pet.
|
|
78
|
+
const x=Math.min(innerWidth-48,a.left),width=Math.max(40,Math.min(320,innerWidth-x-8))
|
|
79
|
+
Object.assign(detail.style,{left:x+'px',width:width+'px',maxHeight:Math.min(360,innerHeight-16)+'px'})
|
|
80
|
+
const copy=button.cloneNode(true);copy.removeAttribute('data-expanded');copy.removeAttribute('aria-expanded');copy.removeAttribute('style');copy.title=''
|
|
81
|
+
copy.onclick=()=>button.click();detail.append(copy);document.body.append(detail)
|
|
82
|
+
detail.style.top=Math.max(8,Math.min(a.top,innerHeight-detail.offsetHeight-8))+'px'
|
|
83
|
+
detail.onpointerenter=()=>clearTimeout(detailTimer);detail.onpointerleave=laterClose
|
|
84
|
+
detail.onfocusin=()=>clearTimeout(detailTimer);detail.onfocusout=laterClose
|
|
85
|
+
}
|
|
37
86
|
function reset(){
|
|
87
|
+
closeDetail();suppressedDetail=null
|
|
88
|
+
releaseTaskLayout?.(false);releaseTaskLayout=null
|
|
89
|
+
clearInterval(timer);timer=null;countdowns=[]
|
|
38
90
|
attempt?.abort();lifecycle?.abort();resize?.disconnect();mutations?.disconnect();cancelAnimationFrame(raf)
|
|
39
91
|
box?.remove();box=null;currentFrame=null;tracked=null;raf=0;limit=50
|
|
40
92
|
}
|
|
41
93
|
function place(){
|
|
42
|
-
if(!box
|
|
43
|
-
const view=presentation(),
|
|
94
|
+
if(!box)return
|
|
95
|
+
const view=presentation(),web=location.protocol!=='dsh-app:'&&!view?.native&&!['desktop','connecting','recovering','other'].includes(view?.mode)
|
|
96
|
+
releaseTaskLayout=view?.taskLayout??releaseTaskLayout
|
|
97
|
+
releaseTaskLayout?.(web&&!box.hidden)
|
|
98
|
+
if(box.hidden)return
|
|
99
|
+
const pet=view?.anchor,stage=pet?.querySelector('[data-duet-avatar-stage]')||pet
|
|
100
|
+
const sidebar=web?sidebarElement(anchor()):null,bounds=sidebar?.getBoundingClientRect()
|
|
101
|
+
box.toggleAttribute('data-sidebar-tasks',Boolean(bounds))
|
|
102
|
+
clipToSidebar(summary,null);clipToSidebar(list,null)
|
|
44
103
|
// Native presentation is projected through avatar-surfaces, not positioned
|
|
45
104
|
// against the DSH toolbar. Keep it off-page during desktop reconnects too.
|
|
46
105
|
if(view?.native || ['desktop','connecting','recovering','other'].includes(view?.mode)){
|
|
106
|
+
closeDetail()
|
|
107
|
+
if(box.hasAttribute('data-inline')&&list.querySelectorAll('button[data-task-state]').length>3){box.removeAttribute('data-inline');summary.hidden=false;box.open=false}
|
|
47
108
|
box.style.visibility='hidden';return
|
|
48
109
|
}
|
|
49
110
|
const target=stage?.isConnected && stage.getBoundingClientRect().height?stage:anchor()
|
|
50
111
|
if(!target?.isConnected){box.style.visibility='hidden';return}
|
|
51
|
-
if(target!==tracked){resize.disconnect();resize.observe(target);tracked=target}
|
|
112
|
+
if(target!==tracked){resize.disconnect();resize.observe(target);if(sidebar&&sidebar!==target)resize.observe(sidebar);tracked=target}
|
|
52
113
|
const a=target.getBoundingClientRect(), gap=8
|
|
53
114
|
if(!a.width||!a.height){box.style.visibility='hidden';return}
|
|
54
115
|
box.style.visibility='visible'
|
|
@@ -60,10 +121,34 @@ export function agentTaskPanel(ctx,anchor,notice,presentation=()=>null){
|
|
|
60
121
|
const inline=box.hasAttribute('data-inline')
|
|
61
122
|
if(inline)box.style.width=Math.min(innerWidth-2*gap,width)+'px';else box.style.width=''
|
|
62
123
|
const card=inline?box:summary
|
|
63
|
-
const
|
|
64
|
-
const
|
|
124
|
+
const hasPet=target===stage
|
|
125
|
+
const left=clamp(bounds&&!hasPet?bounds.left+gap:a.right+gap,innerWidth-card.offsetWidth)
|
|
126
|
+
const top=clamp(bounds&&!hasPet?a.top-card.offsetHeight-gap:a.top+(a.height-card.offsetHeight)/2,innerHeight-card.offsetHeight)
|
|
65
127
|
Object.assign(box.style,{left:left+'px',top:top+'px'})
|
|
66
|
-
if(
|
|
128
|
+
if(bounds){
|
|
129
|
+
if(!box.hasAttribute('data-inline')){box.setAttribute('data-inline','');summary.hidden=true;box.open=true}
|
|
130
|
+
// Keep every task reachable in a bounded fan. Hover changes only its layer,
|
|
131
|
+
// not its neighbours' positions, so moving between tasks stays predictable.
|
|
132
|
+
const buttons=[...list.children].filter(e=>e.matches('button[data-task-state]'))
|
|
133
|
+
const step=Math.min(52,(Math.min(270,innerHeight*.36)-72)/Math.max(1,buttons.length-1))
|
|
134
|
+
const height=72+Math.max(0,buttons.length-1)*step
|
|
135
|
+
// The portrait viewport contains transparent side gutters. Cards may
|
|
136
|
+
// overlap that gutter, while the central body remains unobstructed.
|
|
137
|
+
const x=hasPet?Math.max(bounds.left+gap,a.left+a.width*.82+gap):bounds.left+gap
|
|
138
|
+
const w=Math.min(180,Math.max(40,bounds.right-x-gap))
|
|
139
|
+
const toolbar=anchor()?.getBoundingClientRect()
|
|
140
|
+
const bottom=Math.min(innerHeight-gap,toolbar?.top>height+gap?toolbar.top-gap:innerHeight-gap)
|
|
141
|
+
const y=Math.max(gap,Math.min(hasPet?a.top+(a.height-height)/2:a.top-height-gap,bottom-height))
|
|
142
|
+
Object.assign(box.style,{left:x+'px',top:y+'px',width:w+'px'})
|
|
143
|
+
Object.assign(list.style,{width:'100%',height:height+'px',left:'',top:'',bottom:'',maxHeight:'none'})
|
|
144
|
+
buttons.forEach((button,i)=>{
|
|
145
|
+
button.style.setProperty('--task-y',i*step+'px');button.style.zIndex=String(i+1)
|
|
146
|
+
})
|
|
147
|
+
return
|
|
148
|
+
}
|
|
149
|
+
list.style.height=''
|
|
150
|
+
if(inline){Object.assign(list.style,{width:'100%',left:'',top:'',bottom:'',maxHeight:'65vh'});clipToSidebar(list,bounds);return}
|
|
151
|
+
clipToSidebar(summary,bounds)
|
|
67
152
|
if(!box.open)return
|
|
68
153
|
list.style.width=Math.min(264,innerWidth-left-gap)+'px'
|
|
69
154
|
const below=innerHeight-top-summary.offsetHeight-2*gap,above=top-2*gap
|
|
@@ -71,8 +156,18 @@ export function agentTaskPanel(ctx,anchor,notice,presentation=()=>null){
|
|
|
71
156
|
Object.assign(list.style,{left:clamp(left,innerWidth-list.offsetWidth)+'px',
|
|
72
157
|
top:up?'auto':top+summary.offsetHeight+gap+'px',bottom:up?innerHeight-top+gap+'px':'auto',
|
|
73
158
|
maxHeight:Math.max(32,Math.min(innerHeight*.46,up?above:below))+'px'})
|
|
159
|
+
clipToSidebar(list,bounds)
|
|
74
160
|
}
|
|
75
161
|
function schedule(){if(!raf)raf=requestAnimationFrame(()=>{raf=0;place()})}
|
|
162
|
+
function tick(){
|
|
163
|
+
for(const {row,button,label} of countdowns){
|
|
164
|
+
const seconds=taskCompletionSeconds(row)
|
|
165
|
+
if(seconds===0){update({...currentFrame,focus:null},false);return}
|
|
166
|
+
if(button.dataset.taskCountdown!==String(seconds)){
|
|
167
|
+
button.dataset.taskCountdown=String(seconds);label.textContent=`${seconds}s 后消失`
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
76
171
|
function observe(){
|
|
77
172
|
if(!currentFrame || document.hidden || !document.hasFocus())return
|
|
78
173
|
const id=focusedSession(ctx)
|
|
@@ -117,14 +212,22 @@ export function agentTaskPanel(ctx,anchor,notice,presentation=()=>null){
|
|
|
117
212
|
list=document.createElement('div');list.dataset.taskList=''
|
|
118
213
|
box.append(summary,list,style);document.body.append(box)
|
|
119
214
|
lifecycle=new AbortController();const {signal}=lifecycle
|
|
120
|
-
resize=new ResizeObserver(schedule);mutations=new MutationObserver(schedule)
|
|
121
|
-
mutations.observe(
|
|
122
|
-
window.addEventListener('resize',schedule,{signal});document.addEventListener('scroll',schedule,{signal,capture:true,passive:true})
|
|
215
|
+
resize=new ResizeObserver(schedule);mutations=new MutationObserver(records=>{if(records.some(r=>!box?.contains(r.target)))schedule()})
|
|
216
|
+
mutations.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:['class','style','hidden']})
|
|
217
|
+
window.addEventListener('resize',()=>{closeDetail();schedule()},{signal});document.addEventListener('scroll',e=>{if(!detail?.contains(e.target)){closeDetail();schedule()}},{signal,capture:true,passive:true})
|
|
123
218
|
window.addEventListener('duet:avatar-presentation',schedule,{signal})
|
|
124
219
|
box.addEventListener('toggle',place,{signal})
|
|
125
|
-
document.addEventListener('pointerdown',e=>{if(box.open&&!box.hasAttribute('data-inline')&&!box.contains(e.target))box.open=false},{signal,capture:true})
|
|
220
|
+
document.addEventListener('pointerdown',e=>{if(!presentation()?.native&&box.open&&!box.hasAttribute('data-inline')&&!box.contains(e.target))box.open=false},{signal,capture:true})
|
|
126
221
|
document.addEventListener('keydown',e=>{if(box.open&&!box.hasAttribute('data-inline')&&e.key==='Escape'){box.open=false;summary.focus()}},{signal})
|
|
222
|
+
document.addEventListener('keydown',e=>{if(e.key==='Escape'){suppressedDetail=detailSource;closeDetail()}},{signal})
|
|
223
|
+
document.addEventListener('pointermove',e=>{
|
|
224
|
+
if(!suppressedDetail)return
|
|
225
|
+
const r=suppressedDetail.getBoundingClientRect()
|
|
226
|
+
if(e.clientX<r.left||e.clientX>r.right||e.clientY<r.top||e.clientY>r.bottom)suppressedDetail=null
|
|
227
|
+
},{signal,passive:true})
|
|
228
|
+
document.addEventListener('pointerdown',e=>{if(!box.contains(e.target)&&!detail?.contains(e.target))closeDetail()},{signal,capture:true})
|
|
127
229
|
}
|
|
230
|
+
closeDetail()
|
|
128
231
|
currentFrame=frame
|
|
129
232
|
const candidates=frame.rows.filter(r=>r && /^worker-[a-f0-9]{32}$/.test(r.session_id))
|
|
130
233
|
const id=focusedSession(ctx)
|
|
@@ -143,25 +246,49 @@ export function agentTaskPanel(ctx,anchor,notice,presentation=()=>null){
|
|
|
143
246
|
summary.setAttribute('aria-label',['代理任务',title.textContent,statusLine.textContent,count.textContent].join(','))
|
|
144
247
|
box.toggleAttribute('data-stacked',rows.length>1)
|
|
145
248
|
box.hidden=!rows.length
|
|
146
|
-
const
|
|
249
|
+
const view=presentation(),web=location.protocol!=='dsh-app:'&&!view?.native&&!['desktop','connecting','recovering','other'].includes(view?.mode)
|
|
250
|
+
const inline=web||rows.length<=3,wasInline=box.hasAttribute('data-inline')
|
|
147
251
|
box.toggleAttribute('data-inline',inline);summary.hidden=inline
|
|
148
252
|
if(inline)box.open=true;else if(wasInline)box.open=false
|
|
149
253
|
if(box.hidden)box.open=false
|
|
150
254
|
list.replaceChildren()
|
|
255
|
+
countdowns=[]
|
|
151
256
|
if(!rows.length)list.textContent='还没有任务'
|
|
152
257
|
for(const r of rows.slice(0,limit)){
|
|
153
258
|
const button=document.createElement('button');button.type='button'
|
|
154
|
-
const label=document.createElement('span');label.
|
|
259
|
+
const label=document.createElement('span');label.dataset.taskCopy=''
|
|
260
|
+
const name=document.createElement('span');name.dataset.taskName='';name.textContent=r.name||'未命名任务'
|
|
261
|
+
const progress=document.createElement('small');progress.dataset.taskProgress=''
|
|
262
|
+
progress.textContent=typeof r.progress==='string'&&r.progress.trim()?r.progress:(states[r.state]||'状态待确认')+' · 暂无进度更新'
|
|
263
|
+
progress.style.cssText='font-size:11px;font-weight:400;overflow-wrap:anywhere'
|
|
155
264
|
button.dataset.taskState=taskCardState(r)
|
|
156
|
-
button.title=
|
|
265
|
+
button.title=name.textContent+' · '+(states[r.state]||'状态待确认')+' · '+progress.textContent
|
|
157
266
|
button.setAttribute('aria-label',button.title)
|
|
158
|
-
|
|
267
|
+
label.append(name,document.createTextNode('\n'),progress)
|
|
268
|
+
button.append(label)
|
|
269
|
+
const expand=()=>showDetail(button)
|
|
270
|
+
button.onpointerenter=expand;button.onfocus=expand
|
|
271
|
+
button.onpointerleave=laterClose
|
|
272
|
+
button.onblur=laterClose
|
|
273
|
+
const seconds=taskCompletionSeconds(r)
|
|
274
|
+
if(seconds!==null){
|
|
275
|
+
const countdown=document.createElement('small');countdown.dataset.taskCountdownLabel=''
|
|
276
|
+
countdown.style.cssText='margin-left:auto;flex-shrink:0;color:#737b85;font:400 10px/1.4 system-ui;white-space:nowrap'
|
|
277
|
+
countdown.textContent=`${seconds}s 后消失`;button.dataset.taskCountdown=String(seconds)
|
|
278
|
+
button.append(countdown);countdowns.push({row:r,button,label:countdown})
|
|
279
|
+
}
|
|
280
|
+
button.onclick=()=>void open(r.session_id,false);list.append(button)
|
|
159
281
|
}
|
|
160
282
|
if(rows.length>limit){
|
|
161
283
|
const more=document.createElement('button');more.type='button';more.textContent='查看更多任务(剩余 '+(rows.length-limit)+')'
|
|
162
284
|
more.onclick=()=>{limit+=50;update({...currentFrame,focus:null},false)};list.append(more)
|
|
163
285
|
}
|
|
164
286
|
if(follow&&rows.some(r=>r.session_id===frame.focus))void open(frame.focus,true)
|
|
287
|
+
// Expire every completed row, including those behind the collapsed summary.
|
|
288
|
+
clearInterval(timer);timer=rows.some(r=>taskCompletionSeconds(r)!==null)?setInterval(()=>{
|
|
289
|
+
if(rows.some(r=>taskCompletionSeconds(r)===0))update({...currentFrame,focus:null},false)
|
|
290
|
+
else tick()
|
|
291
|
+
},1000):null
|
|
165
292
|
place()
|
|
166
293
|
}
|
|
167
294
|
return {update,reset,observe}
|
package/src/client/audio.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { microphoneConstraints } from './microphone.mjs?v=0.3.
|
|
1
|
+
import { microphoneConstraints } from './microphone.mjs?v=0.3.3'
|
|
2
2
|
import { captionCue, captionAt, AudioCaptionTimeline } from '../shared/avatar.mjs'
|
|
3
3
|
|
|
4
4
|
export const AUDIO_STOP_PROTOCOL = 'audio_stop_candidates_v1'
|
|
@@ -19,8 +19,8 @@ export function mountAvatarSurfaces({avatar,canActivate=()=>false}) {
|
|
|
19
19
|
let action=actionIds.get(node);if(!action){action=`a${++actionSerial}`;actionIds.set(node,action)}
|
|
20
20
|
const gesture=node.hasAttribute('data-duet-user-gesture')&&!canActivate()
|
|
21
21
|
actions.set(action,node)
|
|
22
|
-
const text=node.matches('summary')?[...node.children].map(n=>n.textContent).join('\n'):node.textContent
|
|
23
|
-
nodes.push({kind:node.matches('input')?'checkbox':'button',text:node.matches('input')?'':text.slice(0,4000),action,disabled:node.disabled===true,checked:node.checked===true,gesture,label:node.getAttribute('aria-label')||node.closest('label')?.textContent.slice(0,100)||'',...(node.dataset.taskState?{taskState:node.dataset.taskState}:{})})
|
|
22
|
+
const text=node.matches('summary')?[...node.children].map(n=>n.textContent).join('\n'):(node.querySelector('[data-task-copy]')||node).textContent
|
|
23
|
+
nodes.push({kind:node.matches('input')?'checkbox':'button',text:node.matches('input')?'':text.slice(0,4000),action,disabled:node.disabled===true,checked:node.checked===true,gesture,label:node.getAttribute('aria-label')||node.closest('label')?.textContent.slice(0,100)||'',...(node.dataset.taskState?{taskState:node.dataset.taskState}:{}),...(node.hasAttribute('data-task-countdown')?{countdown:Number(node.dataset.taskCountdown)}:{})})
|
|
24
24
|
return
|
|
25
25
|
}
|
|
26
26
|
if(/^H[1-6]$/.test(node.tagName)){nodes.push({kind:'heading',text:node.textContent.slice(0,4000)});return}
|
|
@@ -46,7 +46,7 @@ export function mountAvatarSurfaces({avatar,canActivate=()=>false}) {
|
|
|
46
46
|
const key=JSON.stringify({id,nodes,target,layout}),changed=key!==last
|
|
47
47
|
// Cosmetic countdown text does not invalidate an in-flight click. All other
|
|
48
48
|
// content and action state still fence stale confirmations.
|
|
49
|
-
const actionKey=JSON.stringify({id,target,nodes:nodes.map(n=>n.action&&actions.get(n.action)?.hasAttribute('data-duet-live-text')?{...n,text:''}:n)})
|
|
49
|
+
const actionKey=JSON.stringify({id,target,nodes:nodes.map(({countdown,...n})=>n.action&&actions.get(n.action)?.hasAttribute('data-duet-live-text')?{...n,text:''}:n)})
|
|
50
50
|
if(changed)current={id,revision:(current?.revision||0)+(actionKey!==semantic?1:0),nodes,target,...(layout?{layout}:{})}
|
|
51
51
|
semantic=actionKey
|
|
52
52
|
// A real click must happen in the playback document. Keep that counterpart visible.
|