dsh-taskbridge 1.6.0 → 1.7.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.
Files changed (66) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/README.md +41 -41
  3. package/THIRD_PARTY_NOTICES.txt +23 -0
  4. package/codex/dsh-taskbridge.toml +140 -71
  5. package/docs/INTRODUCTION.md +44 -22
  6. package/docs/INTRODUCTION.zh.md +32 -26
  7. package/docs/codex-integration.md +90 -10
  8. package/docs/contracts-stage-b.md +4 -4
  9. package/docs/conversation-placement.md +25 -7
  10. package/docs/plugin-market.md +1 -1
  11. package/docs/releases/1.7.0.zh.md +11 -0
  12. package/docs/runtime-compatibility.md +4 -11
  13. package/docs/silent-wait.md +69 -31
  14. package/docs/taskbridge-upgrade.md +1 -1
  15. package/docs/worker-permissions.md +4 -14
  16. package/docs/workspace-grouping.md +126 -0
  17. package/lib/client.d.ts +365 -3
  18. package/lib/client.js +260 -5
  19. package/locale/en.json +1 -1
  20. package/locale/zh.json +1 -1
  21. package/package.json +7 -19
  22. package/src/client/api.js +550 -90
  23. package/src/client/index.jsx +699 -307
  24. package/src/client/sidebar.jsx +6 -5
  25. package/src/client/styles.js +251 -0
  26. package/src/client/task-cleanup.js +304 -0
  27. package/src/client/task-records-table.jsx +217 -0
  28. package/src/client/task-view.js +226 -10
  29. package/src/client/workspace-groups.js +482 -0
  30. package/src/client/workspaces-browser.jsx +770 -0
  31. package/src/codex/agent-ownership.js +270 -0
  32. package/src/codex/installer.js +525 -35
  33. package/src/codex/seam.js +5 -0
  34. package/src/config/defaults.js +63 -17
  35. package/src/config/settings.js +60 -62
  36. package/src/config/validate.js +126 -71
  37. package/src/http/respond.js +8 -0
  38. package/src/http/user-plane.js +197 -2
  39. package/src/index.js +50 -42
  40. package/src/jobs/activity.js +968 -78
  41. package/src/jobs/engine.js +784 -230
  42. package/src/jobs/history.js +188 -12
  43. package/src/jobs/plan-store.js +5 -0
  44. package/src/jobs/record-cleanup.js +196 -0
  45. package/src/jobs/task-tree.js +5 -3
  46. package/src/jobs/title.js +129 -12
  47. package/src/mcp/server.js +16 -8
  48. package/src/mcp/wait.js +64 -5
  49. package/src/runtime/agent-runner.js +53 -15
  50. package/src/runtime/worker-prompt.js +53 -0
  51. package/src/workspace/locks.js +288 -167
  52. package/docs/releases/1.4.0-token-benchmark.zh.md +0 -40
  53. package/docs/releases/1.4.0.zh.md +0 -54
  54. package/docs/releases/1.4.1.zh.md +0 -59
  55. package/docs/releases/1.4.2.zh.md +0 -23
  56. package/docs/releases/1.5.0-token-benchmark.zh.md +0 -73
  57. package/docs/releases/1.5.0.zh.md +0 -51
  58. package/docs/releases/1.5.1.zh.md +0 -70
  59. package/docs/releases/1.5.2.zh.md +0 -30
  60. package/docs/releases/1.5.3-test.1.zh.md +0 -28
  61. package/docs/releases/1.5.3-test.2.zh.md +0 -24
  62. package/docs/releases/1.5.3.zh.md +0 -33
  63. package/docs/releases/1.5.4.zh.md +0 -25
  64. package/src/review/preset.js +0 -868
  65. package/src/review/prompts.js +0 -145
  66. package/src/review/reviewer.js +0 -933
package/lib/client.d.ts CHANGED
@@ -42,9 +42,10 @@ export declare const inject: readonly ['slots'];
42
42
  export declare const MAIN_SLOT: 'main';
43
43
 
44
44
  /**
45
- * The host shell slot that lists the sidebar panels (the row). This bundle never
46
- * registers on `sidebar.workspaces`: two public sibling plugins own or replace it,
47
- * and competing for it would displace them.
45
+ * The host shell slot that lists the sidebar panels (the row). This registration adds only
46
+ * the task entry; the shell's workspace region (`sidebar.workspaces`) is taken by a SEPARATE,
47
+ * lower-priority registration ({@link registerWorkspacesBrowser}) that can fall back to DSH's
48
+ * own browser. See `docs/workspace-grouping.md`.
48
49
  */
49
50
  export declare const SIDEBAR_PANEL_SLOT: 'sidebar.panellist';
50
51
 
@@ -187,6 +188,205 @@ export declare function TaskbridgeSidebarIcon(): unknown;
187
188
  */
188
189
  export declare function TaskbridgeNavPanel(props: Record<string, unknown>): unknown;
189
190
 
191
+ // ---------------------------------------------------------------------------
192
+ // Grouped workspaces (the shell's `sidebar.workspaces` cell)
193
+ // ---------------------------------------------------------------------------
194
+
195
+ /** The host slot the grouped workspaces browser occupies. */
196
+ export declare const WORKSPACES_SLOT: 'sidebar.workspaces';
197
+
198
+ /**
199
+ * The host's published CHILD slot of its workspace browser: a list rendered INSIDE every native
200
+ * session row. This is the only thing this plugin registers in the sidebar's workspace area; the
201
+ * parent slot stays the host's, so native rows, names, order, search and menus are untouched.
202
+ */
203
+ export declare const SESSION_ROW_ACTION_SLOT: 'sidebar.workspaces.session.row.action';
204
+
205
+ /** The id of this plugin's row-action registration, namespaced against other plugins. */
206
+ export declare const SESSION_ROW_ACTION_ID: string;
207
+
208
+ /** Its order: after the host's own row actions (the host uses 100 and 200). */
209
+ export declare const SESSION_ROW_ACTION_ORDER: number;
210
+
211
+ /** @deprecated The plugin no longer registers on `sidebar.workspaces`. */
212
+ export declare const WORKSPACES_PRIORITY: number;
213
+
214
+ /** How the plugin's own grouping presents itself. */
215
+ export declare const WORKSPACE_VIEWS: Readonly<{
216
+ grouped: 'grouped';
217
+ passthrough: 'passthrough';
218
+ }>;
219
+
220
+ /** Sections the grouping model can produce. */
221
+ export declare const GROUP_KINDS: Readonly<{ container: 'container'; project: 'project' }>;
222
+
223
+ /** One identity row as `GET /api/dsh-delegate/session-map` publishes it. */
224
+ export interface DelegateSessionIdentity {
225
+ taskId: string;
226
+ sessionId: string;
227
+ workspaceId: string;
228
+ sourcePath: string;
229
+ executionPath: string;
230
+ isolation: string | null;
231
+ updatedAt: number;
232
+ }
233
+
234
+ /** One conversation of a task workspace (level 3 of the tree): a real (workspace, session) pair. */
235
+ export interface DelegateGroupedSession {
236
+ sessionId: string;
237
+ /** The native Workspace it really lives in; every action on this row addresses this pair. */
238
+ workspaceId: string;
239
+ taskId: string | null;
240
+ title: string;
241
+ isolation: string | null;
242
+ updatedAt: number;
243
+ archived: boolean;
244
+ }
245
+
246
+ /**
247
+ * One TASK WORKSPACE (level 2): the native Workspace one dispatched chain lives in.
248
+ *
249
+ * Two chains of one project can share one native Workspace, so a project can hold two nodes with
250
+ * the same `workspaceId`; the row's identity is `chainId`.
251
+ */
252
+ export interface DelegateGroupedWorkspace {
253
+ workspaceId: string;
254
+ /** The continuation chain this node stands for (its root task id, or a pair-derived key). */
255
+ chainId: string;
256
+ title: string;
257
+ /** The real execution path; a display node names the native record, it never impersonates it. */
258
+ path: string;
259
+ /**
260
+ * The Workspace also holds conversations this plugin cannot vouch for, so renaming or removing
261
+ * it as a whole would act on them: both operations are refused.
262
+ */
263
+ sharedWithOrdinary: boolean;
264
+ conversations: DelegateGroupedSession[];
265
+ }
266
+
267
+ /** One node of the tree: the TaskBridge container or one real source project. */
268
+ export interface DelegateWorkspaceGroup {
269
+ kind: 'container' | 'project';
270
+ key: string;
271
+ name: string;
272
+ path: string;
273
+ workspaceCount: number;
274
+ conversationCount: number;
275
+ /** Projects of the container. */
276
+ projects?: DelegateWorkspaceGroup[];
277
+ /** A project's task workspaces (one per dispatched chain). */
278
+ workspaces?: DelegateGroupedWorkspace[];
279
+ }
280
+
281
+ /** The TaskBridge section view model. */
282
+ export interface DelegateWorkspacesView {
283
+ ready: boolean;
284
+ groups: DelegateWorkspaceGroup[];
285
+ /** Native Workspaces the section does NOT claim; the native browser shows them itself. */
286
+ standalone: Array<{ workspaceId: string; title: string; path: string }>;
287
+ ungrouped: Array<{ sessionId: string; title: string; owned: boolean }>;
288
+ archived: Array<{ sessionId: string; title: string; workspaceId: string; taskId: string | null }>;
289
+ duplicates: Array<{ sessionId: string; workspaceId: string }>;
290
+ /** Task workspaces shown in the section. */
291
+ ownCount: number;
292
+ conversationCount: number;
293
+ workspaceCount: number;
294
+ /** Native Workspaces the section leaves to the browser because they also hold other ones. */
295
+ mixedCount: number;
296
+ standaloneCount: number;
297
+ }
298
+
299
+ /** Canonical key of one directory, folded exactly as `sessionPathKey` folds it. */
300
+ export declare function sourcePathKey(value: unknown): string;
301
+
302
+ /** Whether a path is the plugin's registered managed-worktree root. */
303
+ export declare function isManagedRootPath(path: unknown): boolean;
304
+
305
+ /** Short label of one path node (its last one or two segments). */
306
+ export declare function projectNameOf(path: unknown): string;
307
+
308
+ /** The host's Workspaces snapshot, or `null` when it cannot be read synchronously. */
309
+ export declare function readWorkspacesSnapshot(workspaces: unknown): unknown;
310
+
311
+ /** The snapshot normalized to the fields the model consumes. */
312
+ export declare function workspaceItems(snapshot: unknown): {
313
+ ready: boolean;
314
+ items: Array<{ workspaceId: string; title: string; path: string; sessionIds: string[]; pinned: boolean }>;
315
+ archivedSessionIds: string[];
316
+ ungroupedSessionIds: string[];
317
+ };
318
+
319
+ /** Identity rows narrowed to rows that name both a Session and a Workspace. */
320
+ export declare function identityRows(rows: unknown): DelegateSessionIdentity[];
321
+
322
+ /** Session titles derived from `/tasks` rows (id stated by the record, never inferred). */
323
+ export declare function sessionTitles(tasks: unknown): Map<string, string>;
324
+
325
+ /** Task records indexed by the session/workspace pair they prove, plus their titles. */
326
+ export declare function sessionIndex(tasks: unknown): {
327
+ titles: Map<string, string>;
328
+ pairs: Map<string, DelegateSessionIdentity>;
329
+ byTask: Map<string, DelegateSessionIdentity>;
330
+ /** Task id → the root task of its continuation chain. */
331
+ chainOf: Map<string, string>;
332
+ };
333
+
334
+ /** Build the TaskBridge section from the host snapshot, the identity map and task records. */
335
+ export declare function workspaceGroups(input: {
336
+ snapshot?: unknown;
337
+ identities?: unknown;
338
+ titles?: Map<string, string>;
339
+ tasks?: unknown;
340
+ }): DelegateWorkspacesView;
341
+
342
+ /** Which presentation the plugin's own grouping calls for. */
343
+ export declare function workspacesViewMode(input: {
344
+ ownCount?: number;
345
+ }): 'grouped' | 'passthrough';
346
+
347
+ /** Read the identity map from the operator plane; a refusal answers an empty list. */
348
+ export declare function loadSessionMap(api: { getSessionMap: () => Promise<unknown> }): Promise<object[]>;
349
+
350
+ /** Resolve one optional host service through `ctx.get`, or `null`. */
351
+ export declare function hostService(ctx: unknown, name: string): object | null;
352
+
353
+ /** Ask the operator for one line of text (the shell's dialog), or `null`. */
354
+ export declare function askText(message: string, initial: string, shell?: unknown): string | null;
355
+
356
+ /** Ask the operator to confirm a destructive action; an absent dialog answers NO. */
357
+ export declare function askConfirm(message: string, shell?: unknown): boolean;
358
+
359
+ /** Short display form of a session id. */
360
+ export declare function shortId(sessionId: unknown): string;
361
+
362
+ /** A host snapshot reused while its data is unchanged (safe for `useSyncExternalStore`). */
363
+ export declare function stableSnapshot(snapshot: unknown, cache?: { key: string | null; value: object | null }): object | null;
364
+
365
+ /** Session id → what proves it is a TaskBridge dispatch (identity row or record, plus its title). */
366
+ export declare function dispatchProof(identities: unknown, tasks: unknown): {
367
+ bySession: Map<string, DelegateSessionIdentity & { title?: string }>;
368
+ ready: boolean;
369
+ };
370
+
371
+ /**
372
+ * Register the per-session marker into the host's published child slot
373
+ * ({@link SESSION_ROW_ACTION_SLOT}). The parent slot is never registered: the native workspace
374
+ * rows, names, order, search, menus and actions stay exactly as the host renders them.
375
+ */
376
+ export declare function registerSessionRowMarker(
377
+ ctx: unknown,
378
+ options?: { store?: unknown; api?: unknown; sessionMap?: () => Promise<unknown> },
379
+ ): () => void;
380
+
381
+ /** The marker rendered inside one native session row (`sessionId` comes from the host). */
382
+ export declare function DispatchedSessionMarker(props: Record<string, unknown>): unknown;
383
+
384
+ /** The plugin's own grouping surface: TaskBridge → task workspace → conversation. */
385
+ export declare function TaskbridgeGrouping(props: Record<string, unknown>): unknown;
386
+
387
+ /** @deprecated Kept so an older import resolves; the plugin registers no such entry. */
388
+ export declare function registerWorkspacesBrowser(...args: unknown[]): () => void;
389
+
190
390
  /** Options accepted by {@link registerBundleConfiguration}. */
191
391
  export interface DelegateBundleConfigOptions {
192
392
  /** Page store; the component subscribes to it itself. */
@@ -306,6 +506,119 @@ export declare function codexTargetView(
306
506
  /** Chinese one-line summary of an action outcome (`changed` / `refused`). */
307
507
  export declare function describeCodexOutcome(outcome: unknown): string;
308
508
 
509
+ /**
510
+ * One execution chain as the cleanup surface sees it.
511
+ *
512
+ * `selectable` is the host's own verdict plus the exact-rounds check made in the page;
513
+ * `blockers` carries the host's stable codes and is what a disabled checkbox explains.
514
+ */
515
+ export interface DelegateCleanupCandidate {
516
+ chainId: string;
517
+ taskIds: string[];
518
+ roundCount: number;
519
+ title: string;
520
+ planNodeId: string | null;
521
+ parentNodeId: string | null;
522
+ nodeId: string | null;
523
+ nodeKind: string;
524
+ selectable: boolean;
525
+ blockers: string[];
526
+ reason: string | null;
527
+ }
528
+
529
+ /** One chain of a cleanup request: its identity and its exact rounds. */
530
+ export interface DelegateCleanupChain {
531
+ chainId: string;
532
+ taskIds: string[];
533
+ }
534
+
535
+ /** What the confirmation shows before anything is sent. */
536
+ export interface DelegateCleanupSummary {
537
+ chains: number;
538
+ rounds: number;
539
+ empty: boolean;
540
+ executable: boolean;
541
+ problems: string[];
542
+ }
543
+
544
+ /** Once one request may name. Mirrors `MAX_CLEANUP_CHAINS` on the host. */
545
+ export declare const MAX_CLEANUP_CHAINS: number;
546
+
547
+ /** Chinese label for one cleanup blocker code. */
548
+ export declare function cleanupBlockerLabel(code: string): string;
549
+
550
+ /** Every execution chain of a rendered tree, in pre-order, with its eligibility. */
551
+ export declare function cleanupCandidates(view: unknown): DelegateCleanupCandidate[];
552
+
553
+ /** Chain id -> the rounds that were selected; anything stale is disabled. */
554
+ export declare function withSelectionState(
555
+ candidate: DelegateCleanupCandidate,
556
+ selectedTaskIds: string[],
557
+ ): DelegateCleanupCandidate;
558
+
559
+ /** Drop selections that no longer name a selectable chain of the current tree. */
560
+ export declare function pruneCleanupSelection(
561
+ selection: Record<string, string[]>,
562
+ candidates: DelegateCleanupCandidate[],
563
+ ): { selection: Record<string, string[]>; dropped: string[] };
564
+
565
+ /** Toggle one chain in a selection (a new object; the input is not mutated). */
566
+ export declare function toggleCleanupSelection(
567
+ selection: Record<string, string[]>,
568
+ candidate: DelegateCleanupCandidate,
569
+ ): Record<string, string[]>;
570
+
571
+ /** Chain/round counts and any problem that blocks the confirmation. */
572
+ export declare function cleanupSelectionSummary(
573
+ selection: Record<string, string[]>,
574
+ candidates: DelegateCleanupCandidate[],
575
+ ): DelegateCleanupSummary;
576
+
577
+ /** Project a selection onto the exact request body the host accepts. */
578
+ export declare function cleanupRequest(
579
+ selection: Record<string, string[]>,
580
+ candidates: DelegateCleanupCandidate[],
581
+ ): { body: { chains: DelegateCleanupChain[] }; problems: string[] };
582
+
583
+ /** Stable fingerprint of a selection, for change detection across refreshes. */
584
+ export declare function cleanupSelectionKey(
585
+ candidates: DelegateCleanupCandidate[],
586
+ selection: Record<string, string[]>,
587
+ ): string;
588
+
589
+ /** The removed ids and counts of a completed cleanup. */
590
+ export declare function cleanupOutcome(outcome: unknown): {
591
+ chains: number;
592
+ rounds: number;
593
+ deletedTaskIds: string[];
594
+ };
595
+
596
+ /** Plain-Chinese description of one completed cleanup. */
597
+ export declare function describeCleanupOutcome(outcome: unknown): string;
598
+
599
+ /** The irreversible-action warning shown beside the confirm button. */
600
+ export declare function cleanupWarningText(): string;
601
+
602
+ /**
603
+ * The operator's execution-choice block, normalized for display.
604
+ *
605
+ * A document (or a host) that predates the block opens at the OFF default, so an
606
+ * upgraded installation never presents agent collaboration as already decided on.
607
+ */
608
+ export declare function executionOf(
609
+ source: unknown,
610
+ ): { agentTeamsDefault: boolean | unknown };
611
+
612
+ /** The documented default a NEW task gets when nothing else decides. */
613
+ export declare const AGENT_TEAMS_DEFAULT_FOR_NEW_TASKS: false;
614
+
615
+ /** Where a task's frozen Agent Teams decision came from. */
616
+ export declare const AGENT_TEAMS_ORIGIN_LABELS: Readonly<{
617
+ request: string;
618
+ continuation: string;
619
+ 'settings-default': string;
620
+ }>;
621
+
309
622
  /** Shape the registration factory returns as `module.exports`. */
310
623
  export interface DelegateClientModule {
311
624
  PLUGIN_CONFIG_SLOT: typeof PLUGIN_CONFIG_SLOT;
@@ -319,6 +632,23 @@ export interface DelegateClientModule {
319
632
  exportDocument: typeof exportDocument;
320
633
  /** G09 batch plan creation: the pure form-draft → request projection. */
321
634
  planCreateRequest: typeof planCreateRequest;
635
+ /** Task-record cleanup: the chain projection, selection and confirmation text. */
636
+ MAX_CLEANUP_CHAINS: typeof MAX_CLEANUP_CHAINS;
637
+ cleanupBlockerLabel: typeof cleanupBlockerLabel;
638
+ cleanupCandidates: typeof cleanupCandidates;
639
+ withSelectionState: typeof withSelectionState;
640
+ pruneCleanupSelection: typeof pruneCleanupSelection;
641
+ toggleCleanupSelection: typeof toggleCleanupSelection;
642
+ cleanupSelectionSummary: typeof cleanupSelectionSummary;
643
+ cleanupRequest: typeof cleanupRequest;
644
+ cleanupSelectionKey: typeof cleanupSelectionKey;
645
+ cleanupOutcome: typeof cleanupOutcome;
646
+ describeCleanupOutcome: typeof describeCleanupOutcome;
647
+ cleanupWarningText: typeof cleanupWarningText;
648
+ /** Execution choices: the new-task Agent Teams default and its origin labels. */
649
+ executionOf: typeof executionOf;
650
+ AGENT_TEAMS_DEFAULT_FOR_NEW_TASKS: typeof AGENT_TEAMS_DEFAULT_FOR_NEW_TASKS;
651
+ AGENT_TEAMS_ORIGIN_LABELS: typeof AGENT_TEAMS_ORIGIN_LABELS;
322
652
  /** G08 native left navigation: slot names, projection and navigation. */
323
653
  MAIN_SLOT: typeof MAIN_SLOT;
324
654
  SIDEBAR_PANEL_SLOT: typeof SIDEBAR_PANEL_SLOT;
@@ -334,4 +664,36 @@ export interface DelegateClientModule {
334
664
  locateSession: typeof locateSession;
335
665
  TaskbridgeSidebarIcon: typeof TaskbridgeSidebarIcon;
336
666
  TaskbridgeNavPanel: typeof TaskbridgeNavPanel;
667
+ /**
668
+ * The sidebar integration: the host's published per-session child slot, the marker it renders,
669
+ * and the plugin's own three-level grouping with its pure model.
670
+ */
671
+ SESSION_ROW_ACTION_SLOT: typeof SESSION_ROW_ACTION_SLOT;
672
+ SESSION_ROW_ACTION_ID: typeof SESSION_ROW_ACTION_ID;
673
+ SESSION_ROW_ACTION_ORDER: typeof SESSION_ROW_ACTION_ORDER;
674
+ WORKSPACES_SLOT: typeof WORKSPACES_SLOT;
675
+ WORKSPACES_PRIORITY: typeof WORKSPACES_PRIORITY;
676
+ WORKSPACE_VIEWS: typeof WORKSPACE_VIEWS;
677
+ GROUP_KINDS: typeof GROUP_KINDS;
678
+ registerSessionRowMarker: typeof registerSessionRowMarker;
679
+ DispatchedSessionMarker: typeof DispatchedSessionMarker;
680
+ TaskbridgeGrouping: typeof TaskbridgeGrouping;
681
+ dispatchProof: typeof dispatchProof;
682
+ registerWorkspacesBrowser: typeof registerWorkspacesBrowser;
683
+ workspacesViewMode: typeof workspacesViewMode;
684
+ workspaceGroups: typeof workspaceGroups;
685
+ workspaceItems: typeof workspaceItems;
686
+ identityRows: typeof identityRows;
687
+ sessionTitles: typeof sessionTitles;
688
+ sessionIndex: typeof sessionIndex;
689
+ sourcePathKey: typeof sourcePathKey;
690
+ isManagedRootPath: typeof isManagedRootPath;
691
+ projectNameOf: typeof projectNameOf;
692
+ readWorkspacesSnapshot: typeof readWorkspacesSnapshot;
693
+ loadSessionMap: typeof loadSessionMap;
694
+ hostService: typeof hostService;
695
+ askText: typeof askText;
696
+ askConfirm: typeof askConfirm;
697
+ shortId: typeof shortId;
698
+ stableSnapshot: typeof stableSnapshot;
337
699
  }