dsh-duet 0.3.0 → 0.3.2

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.
Files changed (44) hide show
  1. package/assets/avatar/desktop/companion.mjs +3 -4
  2. package/assets/avatar/desktop/manifest.json +1 -1
  3. package/desktop/bin/darwin-arm64/duet-avatar.app/Contents/MacOS/duet-avatar +0 -0
  4. package/desktop/bin/darwin-arm64/manifest.json +3 -3
  5. package/desktop/bin/win32-x64/duet-avatar.exe +0 -0
  6. package/desktop/bin/win32-x64/manifest.json +3 -3
  7. package/node_modules/dsh-duet-superagent/lib/duet.d.ts +19 -3
  8. package/node_modules/dsh-duet-superagent/lib/duet.js +156 -10
  9. package/node_modules/dsh-duet-superagent/lib/{feishu-rAGM9U9b.js → feishu-CwKBb-B_.js} +1 -1
  10. package/node_modules/dsh-duet-superagent/lib/feishu-watch.d.ts +1 -1
  11. package/node_modules/dsh-duet-superagent/lib/feishu-watch.js +1 -1
  12. package/node_modules/dsh-duet-superagent/lib/{github-pull-gSbjzypm.js → github-pull-DyfAy0yE.js} +1 -1
  13. package/node_modules/dsh-duet-superagent/lib/github-watch.d.ts +1 -1
  14. package/node_modules/dsh-duet-superagent/lib/github-watch.js +2 -2
  15. package/node_modules/dsh-duet-superagent/lib/index.js +2 -2
  16. package/node_modules/dsh-duet-superagent/lib/{poll-Dh7J1cdM.js → poll-BBkmV_GM.js} +4 -1
  17. package/node_modules/dsh-duet-superagent/lib/{registry-BTgyFZ8S.d.ts → registry-Ehgir8LC.d.ts} +70 -61
  18. package/node_modules/dsh-duet-superagent/lib/{runtime-CbDPyQoo.js → runtime-Ow0S-7ZZ.js} +45 -5
  19. package/package.json +6 -2
  20. package/src/avatar/surface.mjs +6 -1
  21. package/src/client/agent-entry.mjs +27 -0
  22. package/src/client/agent-tasks.mjs +42 -10
  23. package/src/client/agent-tool-views.mjs +190 -0
  24. package/src/client/audio.mjs +1 -1
  25. package/src/client/avatar-surfaces.mjs +3 -3
  26. package/src/client/browser.mjs +35 -27
  27. package/src/client/composer-bridge.mjs +1 -1
  28. package/src/client/connection-hint.mjs +20 -5
  29. package/src/client/entry.js +10 -3
  30. package/src/client/feedback.mjs +1 -1
  31. package/src/client/identity.mjs +1 -1
  32. package/src/client/settings.html +84 -80
  33. package/src/client/tutorial-adapter.mjs +5 -5
  34. package/src/client/tutorial.mjs +1 -1
  35. package/src/client/work-mode.mjs +46 -9
  36. package/src/host/agent-connection.mjs +6 -1
  37. package/src/host/assets.mjs +2 -0
  38. package/src/host/plugin.mjs +4 -2
  39. package/src/shared/avatar-menu-ui.mjs +30 -12
  40. package/src/shared/avatar-menu.mjs +4 -1
  41. package/src/shared/avatar-surface.mjs +1 -0
  42. package/src/shared/avatar-ui.mjs +2 -0
  43. package/src/shared/state.mjs +1 -1
  44. package/src/shared/work-mode.mjs +64 -4
@@ -787,7 +787,10 @@ const KV = {
787
787
  /** Runtime: the main Session's ID. */
788
788
  runtime: { masterId: record("master-id") },
789
789
  /** Sessions: prompt revisions each Session has worked under, ordered oldest first; the last entry (`.at(-1)`) is its active revision. */
790
- sessions: { prompts: family("session-prompts:") },
790
+ sessions: {
791
+ prompts: family("session-prompts:"),
792
+ model: family("session-model-display:")
793
+ },
791
794
  /** Schema 11 migration: legacy main-Session queues imported into the effect table. */
792
795
  queues: {
793
796
  relays: record("relay-queue"),
@@ -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" | "communication" | "delivery";
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" | "communication" | "delivery";
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 { SettingsOrigin as A, Store as C, RoleModel as D, Variable as E, Commands as M, Tally as N, Settings as O, 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, SetupProblem as j, SettingsBlock 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 };
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-Dh7J1cdM.js";
2
- import { i as pullOf, m as readRepositoryPath, o as readPull, p as readGithub, r as pullEndNotices, t as claimPull } from "./github-pull-gSbjzypm.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-rAGM9U9b.js";
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();
@@ -10165,7 +10205,7 @@ function executorTools(host, ticket) {
10165
10205
  "failed",
10166
10206
  "dropped"
10167
10207
  ]),
10168
- summary: z.string().min(1),
10208
+ summary: z.string().min(1).describe(ticket.channels.some((channel) => channel.source === "duet") ? "A brief result for the main session to understand and announce. Put the complete user-facing deliverable in the task session final response, not in this summary." : "Report the actual outcome and supporting evidence as the work and handoff sections specify."),
10169
10209
  human_action: z.string().trim().min(1).max(1e3).nullish().describe("One concrete question for a person, also with state=progress; omit to keep the pending one, null to clear it."),
10170
10210
  question_for_trigger_id: z.string().optional().describe("With human_action: the human message that raised the question, which is asked where that person wrote."),
10171
10211
  pr_number: z.number().int().positive().nullish().describe(`The ticket's PR: its source PR, or one by ${host.github.deployment.github.login} from a branch named after this ticket (DSH_SUPERAGENT_NAME).`),
@@ -10650,4 +10690,4 @@ var Runtime = class extends Service {
10650
10690
  }
10651
10691
  };
10652
10692
  //#endregion
10653
- export { reasonText as a, ticketStage as c, REASONS as i, USER_ERRORS as l, resolveRoleModel as n, said as o, Engine as r, canRetry as s, Runtime as t, UserError as u };
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.0",
3
+ "version": "0.3.2",
4
4
  "description": "duet(二重奏):只用语音就能操作 DSH,边听边说、随时插话的全双工语音助手。",
5
5
  "keywords": [
6
6
  "dsh-plugin",
@@ -24,6 +24,7 @@
24
24
  "check": "node scripts/check-package.mjs",
25
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",
26
26
  "test:work-mode": "node tests/browser/work-mode.mjs",
27
+ "test:agent-navigation": "node tests/browser/agent-tool-views.mjs && node tests/browser/work-mode.mjs && node tests/browser/agent-tasks.mjs",
27
28
  "test:host": "node tests/host/isolated-host.mjs",
28
29
  "build:avatar": "node scripts/build-avatar.mjs",
29
30
  "build:avatar:desktop": "node scripts/build-avatar-desktop.mjs",
@@ -75,7 +76,10 @@
75
76
  "@deepseek-ai/dsh-api-session-controller",
76
77
  "@deepseek-ai/dsh-api-workspace-controller",
77
78
  "@deepseek-ai/dsh-client-ui-session",
78
- "@deepseek-ai/dsh-client-ui-conversation"
79
+ "@deepseek-ai/dsh-client-ui-conversation",
80
+ "@deepseek-ai/dsh-client-ui-tool",
81
+ "@deepseek-ai/dsh-client-ui-chat",
82
+ "@deepseek-ai/dsh-client-ui-workspace"
79
83
  ],
80
84
  "platform": "web"
81
85
  }
@@ -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(e.textContent!==n.text)e.textContent=n.text
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
@@ -0,0 +1,27 @@
1
+ import {focusedSession,openLocalSession} from './composer.mjs'
2
+
3
+ /** A connection owns one initial navigation; later task focus stays independent. */
4
+ export function agentEntryNavigation(ctx,signal,enabled=()=>true){
5
+ let id=null,ready=false,used=false
6
+ async function go(){
7
+ if(!ready||!id||used||signal.aborted)return
8
+ used=true
9
+ if(!enabled())return
10
+ const target=id,before=focusedSession(ctx)
11
+ try{
12
+ for(let n=0;n<10;n++){
13
+ await ctx.sessions.refresh();signal.throwIfAborted()
14
+ if(!enabled())return
15
+ if(focusedSession(ctx)!==before)return
16
+ if(ctx.sessions.list.getSnapshot().byId?.[target]){
17
+ await openLocalSession(ctx,target,signal);return
18
+ }
19
+ await new Promise(resolve=>setTimeout(resolve,300))
20
+ }
21
+ }catch{/* Navigation is optional and must not close a voice connection. */}
22
+ }
23
+ return {
24
+ frame(frame){if(typeof frame?.main_session_id==='string'&&/^orchestrator-[a-f0-9]{32}$/.test(frame.main_session_id)){id=frame.main_session_id;void go()}},
25
+ connected(){ready=true;void go()},
26
+ }
27
+ }
@@ -1,5 +1,6 @@
1
1
  import {focusedSession,openLocalSession} from './composer.mjs'
2
- import {TASK_STATES as states, noteTaskVisit, visibleTaskRows} from '../shared/work-mode.mjs'
2
+ import {taskBubbleCardStyle} from '../shared/avatar-ui.mjs'
3
+ import {TASK_STATES as states, noteTaskNoticeVisit, taskCardState, visibleTaskRows, taskModelLabel, taskCompletionSeconds} from '../shared/work-mode.mjs'
3
4
  const active=new Set(['queued','pending','running','progress','waiting','waiting_user','blocked'])
4
5
  const bubbleCSS=`
5
6
  [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}
@@ -17,7 +18,7 @@ const bubbleCSS=`
17
18
  [data-duet-agent-tasks][data-inline] summary{display:none}
18
19
  [data-duet-agent-tasks][data-inline] [data-task-list]{position:static;width:100%;max-height:65vh;overflow:auto}
19
20
  [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{display:flex;align-items:center;gap:12px;width:100%;box-sizing:border-box;padding:14px 16px;margin:0 0 8px;border:1px solid #ffffff90;border-radius:20px;background:#f7f9fbe8;color:#253344;text-align:left;cursor:pointer;box-shadow:0 6px 18px -8px #172c4938;backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px)}
21
+ [data-duet-agent-tasks] [data-task-list] button{${taskBubbleCardStyle};margin-bottom:8px}
21
22
  [data-duet-agent-tasks] [data-task-list] button span{font-size:13px;font-weight:550;line-height:1.5;overflow-wrap:anywhere}
22
23
  [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}
23
24
  [data-task-state=completed]::before{content:'✓';border:0;background:#dcefe8;color:#23845e;text-align:center;font:600 14px/18px system-ui;animation:none}
@@ -33,8 +34,10 @@ const bubbleCSS=`
33
34
 
34
35
  /** A local, connection-owned projection; never turn the model's short handles into UI routes. */
35
36
  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
37
+ let box,summary,title,statusLine,count,list,attempt,currentFrame,limit=50,lifecycle,resize,mutations,raf=0,tracked,timer
38
+ let countdowns=[]
37
39
  function reset(){
40
+ clearInterval(timer);timer=null;countdowns=[]
38
41
  attempt?.abort();lifecycle?.abort();resize?.disconnect();mutations?.disconnect();cancelAnimationFrame(raf)
39
42
  box?.remove();box=null;currentFrame=null;tracked=null;raf=0;limit=50
40
43
  }
@@ -73,11 +76,21 @@ export function agentTaskPanel(ctx,anchor,notice,presentation=()=>null){
73
76
  maxHeight:Math.max(32,Math.min(innerHeight*.46,up?above:below))+'px'})
74
77
  }
75
78
  function schedule(){if(!raf)raf=requestAnimationFrame(()=>{raf=0;place()})}
79
+ function tick(){
80
+ for(const {row,button,label} of countdowns){
81
+ const seconds=taskCompletionSeconds(row)
82
+ if(seconds===0){update({...currentFrame,focus:null},false);return}
83
+ if(button.dataset.taskCountdown!==String(seconds)){
84
+ button.dataset.taskCountdown=String(seconds);label.textContent=`${seconds}s 后消失`
85
+ }
86
+ }
87
+ }
76
88
  function observe(){
77
89
  if(!currentFrame || document.hidden || !document.hasFocus())return
78
90
  const id=focusedSession(ctx)
79
- if(visibleTaskRows(currentFrame.rows).some(r=>r.session_id===id && r.finished_at)){
80
- noteTaskVisit(id); update({...currentFrame,focus:null},false)
91
+ const row=visibleTaskRows(currentFrame.rows).find(r=>r.session_id===id&&(r.finished_at||taskCardState(r)==='waiting'))
92
+ if(row){
93
+ noteTaskNoticeVisit(row); update({...currentFrame,focus:null},false)
81
94
  }
82
95
  }
83
96
  async function open(id,automatic){
@@ -127,8 +140,10 @@ export function agentTaskPanel(ctx,anchor,notice,presentation=()=>null){
127
140
  currentFrame=frame
128
141
  const candidates=frame.rows.filter(r=>r && /^worker-[a-f0-9]{32}$/.test(r.session_id))
129
142
  const id=focusedSession(ctx)
130
- if(!document.hidden && document.hasFocus() && visibleTaskRows(candidates).some(r=>r.finished_at && r.session_id===id))
131
- noteTaskVisit(id)
143
+ if(!document.hidden && document.hasFocus()){
144
+ const selected=candidates.find(r=>r.session_id===id)
145
+ if(selected)noteTaskNoticeVisit(selected)
146
+ }
132
147
  const rows=visibleTaskRows(candidates)
133
148
  const running=rows.filter(r=>active.has(r.state)).length,unread=rows.filter(r=>r.finished_at).length
134
149
  const lead=rows.find(r=>r.state==='waiting_user')||rows.find(r=>active.has(r.state))||rows[0]
@@ -145,20 +160,37 @@ export function agentTaskPanel(ctx,anchor,notice,presentation=()=>null){
145
160
  if(inline)box.open=true;else if(wasInline)box.open=false
146
161
  if(box.hidden)box.open=false
147
162
  list.replaceChildren()
163
+ countdowns=[]
148
164
  if(!rows.length)list.textContent='还没有任务'
149
165
  for(const r of rows.slice(0,limit)){
150
166
  const button=document.createElement('button');button.type='button'
151
- const label=document.createElement('span');label.textContent=r.name||'未命名任务'
152
- button.dataset.taskState=['completed','merged','ready','ended'].includes(r.state)?'completed':['failed'].includes(r.state)?'failed':['stopped','dropped','closed','cancelled'].includes(r.state)?'stopped':['queued','pending','running','progress'].includes(r.state)?'running':'waiting'
167
+ const label=document.createElement('span');label.dataset.taskCopy='';label.textContent=r.name||'未命名任务'
168
+ const model=document.createElement('small');model.textContent=taskModelLabel(r.model_info)
169
+ model.style.cssText='display:block;font-size:10px;font-weight:400;opacity:.7;overflow-wrap:anywhere'
170
+ button.dataset.taskState=taskCardState(r)
153
171
  button.title=label.textContent+' · '+(states[r.state]||'状态待确认')
154
172
  button.setAttribute('aria-label',button.title)
155
- button.append(label);button.onclick=()=>void open(r.session_id,false);list.append(button)
173
+ label.append(document.createTextNode('\n'),model)
174
+ button.append(label)
175
+ const seconds=taskCompletionSeconds(r)
176
+ if(seconds!==null){
177
+ const countdown=document.createElement('small');countdown.dataset.taskCountdownLabel=''
178
+ countdown.style.cssText='margin-left:auto;flex-shrink:0;color:#737b85;font:400 10px/1.4 system-ui;white-space:nowrap'
179
+ countdown.textContent=`${seconds}s 后消失`;button.dataset.taskCountdown=String(seconds)
180
+ button.append(countdown);countdowns.push({row:r,button,label:countdown})
181
+ }
182
+ button.onclick=()=>void open(r.session_id,false);list.append(button)
156
183
  }
157
184
  if(rows.length>limit){
158
185
  const more=document.createElement('button');more.type='button';more.textContent='查看更多任务(剩余 '+(rows.length-limit)+')'
159
186
  more.onclick=()=>{limit+=50;update({...currentFrame,focus:null},false)};list.append(more)
160
187
  }
161
188
  if(follow&&rows.some(r=>r.session_id===frame.focus))void open(frame.focus,true)
189
+ // Expire every completed row, including those behind the collapsed summary.
190
+ clearInterval(timer);timer=rows.some(r=>taskCompletionSeconds(r)!==null)?setInterval(()=>{
191
+ if(rows.some(r=>taskCompletionSeconds(r)===0))update({...currentFrame,focus:null},false)
192
+ else tick()
193
+ },1000):null
162
194
  place()
163
195
  }
164
196
  return {update,reset,observe}