dsh-taskbridge 1.5.4 → 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 (74) hide show
  1. package/CHANGELOG.md +80 -59
  2. package/README.md +51 -50
  3. package/THIRD_PARTY_NOTICES.txt +23 -0
  4. package/bin/dsh-delegate-mcp.d.ts +1 -0
  5. package/bin/dsh-delegate-mcp.js +1 -0
  6. package/codex/dsh-taskbridge.toml +148 -71
  7. package/docs/INTRODUCTION.md +44 -22
  8. package/docs/INTRODUCTION.zh.md +32 -26
  9. package/docs/codex-integration.md +99 -19
  10. package/docs/contracts-stage-b.md +4 -4
  11. package/docs/conversation-placement.md +25 -7
  12. package/docs/plugin-market.md +1 -1
  13. package/docs/releases/1.6.0.zh.md +11 -0
  14. package/docs/releases/1.7.0.zh.md +11 -0
  15. package/docs/runtime-compatibility.md +10 -11
  16. package/docs/silent-wait.md +69 -31
  17. package/docs/taskbridge-upgrade.md +1 -1
  18. package/docs/worker-permissions.md +11 -21
  19. package/docs/workspace-grouping.md +126 -0
  20. package/lib/client.d.ts +581 -0
  21. package/lib/client.js +332 -3461
  22. package/locale/en.json +1 -1
  23. package/locale/zh.json +1 -1
  24. package/package.json +7 -19
  25. package/src/client/api.js +895 -90
  26. package/src/client/index.jsx +1363 -296
  27. package/src/client/sidebar.jsx +862 -0
  28. package/src/client/styles.js +340 -0
  29. package/src/client/task-cleanup.js +304 -0
  30. package/src/client/task-records-table.jsx +217 -0
  31. package/src/client/task-view.js +307 -0
  32. package/src/client/workspace-groups.js +482 -0
  33. package/src/client/workspaces-browser.jsx +770 -0
  34. package/src/codex/agent-ownership.js +270 -0
  35. package/src/codex/installer.js +528 -35
  36. package/src/codex/seam.js +5 -0
  37. package/src/config/defaults.js +63 -17
  38. package/src/config/settings.js +60 -62
  39. package/src/config/validate.js +126 -71
  40. package/src/http/execution-plane.js +200 -1
  41. package/src/http/respond.js +26 -2
  42. package/src/http/user-plane.js +566 -2
  43. package/src/index.d.ts +55 -0
  44. package/src/index.js +58 -42
  45. package/src/jobs/activity.js +968 -78
  46. package/src/jobs/engine.js +1010 -230
  47. package/src/jobs/history.js +224 -12
  48. package/src/jobs/plan-store.js +1020 -0
  49. package/src/jobs/record-cleanup.js +196 -0
  50. package/src/jobs/task-display.js +73 -0
  51. package/src/jobs/task-tree.js +786 -0
  52. package/src/jobs/title.js +129 -12
  53. package/src/mcp/server.js +206 -10
  54. package/src/mcp/wait.js +64 -5
  55. package/src/runtime/agent-runner.js +101 -15
  56. package/src/runtime/worker-prompt.js +53 -0
  57. package/src/workspace/locks.js +288 -167
  58. package/docs/assets/taskbridge-workflow.en.png +0 -0
  59. package/docs/assets/taskbridge-workflow.zh.png +0 -0
  60. package/docs/releases/1.4.0-token-benchmark.zh.md +0 -40
  61. package/docs/releases/1.4.0.zh.md +0 -54
  62. package/docs/releases/1.4.1.zh.md +0 -59
  63. package/docs/releases/1.4.2.zh.md +0 -23
  64. package/docs/releases/1.5.0-token-benchmark.zh.md +0 -73
  65. package/docs/releases/1.5.0.zh.md +0 -51
  66. package/docs/releases/1.5.1.zh.md +0 -70
  67. package/docs/releases/1.5.2.zh.md +0 -30
  68. package/docs/releases/1.5.3-test.1.zh.md +0 -28
  69. package/docs/releases/1.5.3-test.2.zh.md +0 -24
  70. package/docs/releases/1.5.3.zh.md +0 -33
  71. package/docs/releases/1.5.4.zh.md +0 -25
  72. package/src/review/preset.js +0 -868
  73. package/src/review/prompts.js +0 -145
  74. package/src/review/reviewer.js +0 -933
package/src/index.d.ts CHANGED
@@ -112,6 +112,8 @@ export interface DelegateSubmitRequest {
112
112
  title?: string;
113
113
  goalDescription?: string;
114
114
  continueFromTaskId?: string;
115
+ planNodeId?: string;
116
+ parentNodeId?: string;
115
117
  overrides?: {
116
118
  model?: string;
117
119
  reasoningEffort?: string;
@@ -121,6 +123,59 @@ export interface DelegateSubmitRequest {
121
123
  agentTeams?: boolean;
122
124
  }
123
125
 
126
+ export interface DelegatePlanNode {
127
+ nodeId: string;
128
+ parentNodeId: string | null;
129
+ title: string;
130
+ goalDescription?: string;
131
+ sourcePath: string | null;
132
+ sourcePathDigest: string | null;
133
+ connectionId: string;
134
+ sequence: number;
135
+ createdAt: number;
136
+ updatedAt: number;
137
+ hostAcceptance: {
138
+ accepted: boolean;
139
+ state: 'accepted' | 'changes-requested';
140
+ decision: 'accepted' | 'changes-requested';
141
+ acceptedAt: number;
142
+ by: 'commander';
143
+ note: string;
144
+ noteChars: number;
145
+ completionSummary?: string;
146
+ } | null;
147
+ reviewHistory?: Array<{
148
+ accepted: boolean;
149
+ state: 'accepted' | 'changes-requested';
150
+ decision: 'accepted' | 'changes-requested';
151
+ acceptedAt: number;
152
+ by: 'commander';
153
+ note: string;
154
+ noteChars: number;
155
+ completionSummary?: string;
156
+ }>;
157
+ }
158
+
159
+ export interface DelegatePlanRequest {
160
+ action: 'create' | 'update' | 'review' | 'get' | 'list';
161
+ nodeId?: string;
162
+ parentNodeId?: string;
163
+ workspacePath?: string;
164
+ title?: string;
165
+ goalDescription?: string;
166
+ decision?: 'accepted' | 'changes-requested';
167
+ note?: string;
168
+ completionSummary?: string;
169
+ nodes?: Array<{
170
+ key?: string;
171
+ parentKey?: string;
172
+ parentNodeId?: string;
173
+ title: string;
174
+ goalDescription?: string;
175
+ workspacePath?: string;
176
+ }>;
177
+ }
178
+
124
179
  /**
125
180
  * One pending per-call permission request, as the task view publishes it.
126
181
  *
package/src/index.js CHANGED
@@ -29,7 +29,7 @@
29
29
  // `cannot set property "…" without provide` in Cordis, and provide/effect is what
30
30
  // makes the face disappear again on unload.
31
31
 
32
- import { mkdir } from 'node:fs/promises';
32
+ import { mkdir, stat } from 'node:fs/promises';
33
33
  import { homedir } from 'node:os';
34
34
  import { join } from 'node:path';
35
35
 
@@ -41,6 +41,8 @@ import { AuthorizationRegistry } from './auth/grants.js';
41
41
  import { bindAllowsExternalConnections } from './auth/fence.js';
42
42
  import { JobEngine } from './jobs/engine.js';
43
43
  import { HistoryStore } from './jobs/history.js';
44
+ import { PlanStore } from './jobs/plan-store.js';
45
+ import { TaskDisplayStore } from './jobs/task-display.js';
44
46
  import { WorkspaceLocks } from './workspace/locks.js';
45
47
  import { createGitRunner } from './workspace/audit.js';
46
48
  import { WorktreeManager } from './workspace/worktrees.js';
@@ -53,10 +55,9 @@ import { probeModel } from './model/probe.js';
53
55
  import { createExecutionHandler, EXECUTION_PREFIX } from './http/execution-plane.js';
54
56
  import { wrapUserPlaneRoutes } from './http/user-plane.js';
55
57
  import { diagnostic } from './runtime/agent-runner.js';
56
- import { SessionStore, liveControllerAccessor } from './runtime/session-placement.js';
58
+ import { ensureWorkspace, SessionStore, liveControllerAccessor } from './runtime/session-placement.js';
57
59
  import { publishRuntimeEndpoint, resolveDefaultEndpointDiscoveryPath } from './runtime/endpoint-discovery.js';
58
60
  import { resolveCodexActionSeam } from './codex/seam.js';
59
- import { ReviewPreset } from './review/preset.js';
60
61
  import { configureDelegatedSession, policyServicesOf } from './runtime/sandbox.js';
61
62
  import { PermissionBridge, PERMISSION_DEFAULT_TIMEOUT_MS } from './runtime/permissions.js';
62
63
  import { QuestionBridge } from './runtime/questions.js';
@@ -102,9 +103,7 @@ export const Config = z.object({
102
103
  * Mount the delegation service.
103
104
  *
104
105
  * `config` is the operator's settings document and is validated by {@link Config}
105
- * before this runs. A test may additionally pass a `reviewPresetImporter`, which
106
- * replaces the solver used to find the native review tool packages; it is not
107
- * part of the published schema and a real deployment never provides one.
106
+ * before this runs.
108
107
  * @param {import('@deepseek-ai/cordis').Context} ctx - plugin context.
109
108
  * @param {object} config - plugin config.
110
109
  * @returns {Promise<void>} resolves after registration.
@@ -155,6 +154,8 @@ export async function apply(ctx, config = {}) {
155
154
  const providerRegistry = createProviderRegistry({ llm: ctx.llm, adapter });
156
155
 
157
156
  const history = new HistoryStore(dataDir);
157
+ const plans = new PlanStore(dataDir);
158
+ const taskDisplay = new TaskDisplayStore(dataDir);
158
159
  const worktrees = new WorktreeManager({ runGit }, { rootDir: join(dataDir, 'worktrees') });
159
160
  // The task-thread identity map: task id -> the DSH Workspace/Session that task
160
161
  // drove, plus the paths and (for an isolated run) the tree ownership facts a
@@ -163,32 +164,6 @@ export async function apply(ctx, config = {}) {
163
164
  // conversation. Stores identities only, never transcript content.
164
165
  const sessionStore = new SessionStore(dataDir, { logger });
165
166
 
166
- // The independent review composes its own read-only agent preset instead of
167
- // joining the deployment default (which mounts `dsh-tool-subagent`, a tool a
168
- // scope restriction cannot remove). The composition is registered LAZILY on the
169
- // first review request — the registry's own diagnostic may wait for the Host
170
- // Loader tree to settle, and must not run inside this row's activation — and is
171
- // removed again on unload by the effect below. It never touches the configured
172
- // default, the installed profile, or a user preset.
173
- const reviewPreset = new ReviewPreset({
174
- registry: agentPresets,
175
- logger,
176
- ...(typeof config?.reviewPresetImporter === 'function' ? { importer: config.reviewPresetImporter } : {}),
177
- });
178
- const readPresets = () => ctx.get('agentPresets', false) ?? null;
179
- const reviewPresets = {
180
- /**
181
- * A live facade so a registry that appears (or is replaced) after load is
182
- * observed on the next review instead of being frozen at startup.
183
- */
184
- get id() { return reviewPreset.createdId; },
185
- owns(id) { return reviewPreset.owns(id); },
186
- preparation: (bounds) => {
187
- reviewPreset.attach(readPresets());
188
- return reviewPreset.preparation(bounds ?? {});
189
- },
190
- };
191
-
192
167
  /**
193
168
  * Report a native controller whose read was refused, on the plugin's logger.
194
169
  *
@@ -205,10 +180,49 @@ export async function apply(ctx, config = {}) {
205
180
  logger?.warn?.(`dsh-delegate: the DSH ${serviceName} could not be read (${diagnostic(error?.message ?? error, 200)})`);
206
181
  };
207
182
 
183
+ // DSH's Workspace Tree computes parents from registered directories. The plugin
184
+ // already puts isolated checkouts below this root, so no task directory moves.
185
+ //
186
+ // The root is the managed worktrees directory the manager itself owns
187
+ // (`<data>/dsh-delegate/worktrees`), which `WorktreeManager.ensureRoot` creates with
188
+ // the same 0o700 mode a first isolated run would use — nothing from an earlier
189
+ // version has to move, and no user Workspace is renamed or reparented. Registering it
190
+ // is what makes DSH's own "按工作区树" (视图选项 → 分组方式) nest every isolated task
191
+ // Workspace under one TaskBridge group; the plugin never draws that tree itself.
192
+ //
193
+ // Registration is idempotent and reversible: one pending attempt at a time, a success
194
+ // is remembered (so a later failure cannot loop), and the disposer forgets it. It
195
+ // never deletes a Workspace, so no user data is touched.
196
+ let worktreeWorkspaceRegistration = null;
197
+ let worktreeWorkspaceRegistered = false;
198
+ function registerWorktreeWorkspace() {
199
+ if (worktreeWorkspaceRegistered) return Promise.resolve({ registered: true });
200
+ if (worktreeWorkspaceRegistration !== null) return worktreeWorkspaceRegistration;
201
+ worktreeWorkspaceRegistration = (async () => {
202
+ try {
203
+ const workspaces = deps.workspaces.current;
204
+ if (typeof workspaces?.create !== 'function') return { registered: false, reason: 'WORKSPACES_UNAVAILABLE' };
205
+ // Create-if-missing, then resolve: DSH compares real paths when it derives the
206
+ // tree, and every containment check below already works on real paths.
207
+ const path = await worktrees.ensureRoot();
208
+ if (!(await stat(path)).isDirectory()) return { registered: false, reason: 'ROOT_NOT_A_DIRECTORY' };
209
+ const workspace = await ensureWorkspace(workspaces, path, 'TaskBridge');
210
+ if (workspace.namingError) logger?.warn?.('dsh-delegate: could not name the TaskBridge workspace', workspace.namingError);
211
+ worktreeWorkspaceRegistered = true;
212
+ return { registered: true, workspaceId: workspace.workspaceId, path };
213
+ } catch (error) {
214
+ if (error?.code !== 'ENOENT') {
215
+ logger?.warn?.('dsh-delegate: could not register the TaskBridge workspace', diagnostic(error?.message ?? error, 200));
216
+ }
217
+ return { registered: false, reason: typeof error?.code === 'string' ? error.code : 'REGISTRATION_FAILED' };
218
+ }
219
+ })().finally(() => { worktreeWorkspaceRegistration = null; });
220
+ return worktreeWorkspaceRegistration;
221
+ }
222
+
208
223
  const deps = {
209
224
  agents: ctx.agents,
210
225
  agentPresets,
211
- reviewPresets,
212
226
  sessions: ctx.sessions,
213
227
  // The native Workspace and Session controllers. Both are read non-strictly
214
228
  // and, more importantly, LAZILY: a harness that does not compose them must
@@ -234,7 +248,10 @@ export async function apply(ctx, config = {}) {
234
248
  locks,
235
249
  runGit,
236
250
  worktrees,
251
+ registerWorktreeWorkspace,
237
252
  history,
253
+ plans,
254
+ taskDisplay,
238
255
  providerRegistry,
239
256
  credentials,
240
257
  logger,
@@ -250,8 +267,6 @@ export async function apply(ctx, config = {}) {
250
267
  // always has a place to keep the original bytes.
251
268
  backupDir: join(dataDir, 'codex-config-backup'),
252
269
  }),
253
- // The runner calls this only for worker jobs. Reviews intentionally use their
254
- // own read-only tool policy and are not put into a delegated worker sandbox.
255
270
  configureDelegatedSession,
256
271
  // `ctx.sandboxPolicy` and `ctx.approval` own the two facts the delegated
257
272
  // policy writes, so the runner reads them back through these live services
@@ -452,9 +467,6 @@ export async function apply(ctx, config = {}) {
452
467
  // a directory-level mode to configure.
453
468
  conversation: 'per-task',
454
469
  conversationContinuation: 'continueFromTaskId',
455
- // Whether the review's own composition was ever registered, i.e. whether a
456
- // read-only review has been attempted in this activation. Lazy by design.
457
- reviewPreset: reviewPreset.createdId ?? 'not-registered',
458
470
  });
459
471
 
460
472
  // ---- user plane: authenticated DSH settings and task controls --------------
@@ -496,15 +508,19 @@ export async function apply(ctx, config = {}) {
496
508
  );
497
509
  }
498
510
 
511
+ // Register the managed root at every activation, so a fresh install (no worktree yet)
512
+ // gets the TaskBridge group too, and an upgrade groups the child Workspaces that
513
+ // already exist under it. An isolate that has not created its tree is what this makes
514
+ // possible: the directory is created inside the plugin's own managed data directory.
515
+ void registerWorktreeWorkspace();
516
+
499
517
  // ---- stop everything on unload ------------------------------------------
500
518
  ctx.effect(() => async () => {
501
519
  await engine.dispose();
502
- // Jobs are gone before the review composition is: a disposed engine holds no
503
- // runner that could mount a preset this disposer is about to remove.
504
- await reviewPreset.dispose();
505
520
  // History is flushed before the store is closed so a task that finished during
506
521
  // teardown is still durable. The session map is flushed on the same terms.
507
522
  await history.dispose();
523
+ await plans.dispose();
508
524
  await sessionStore.dispose();
509
525
  providerRegistry.dispose();
510
526
  auth.revokeAll();
@@ -522,12 +538,12 @@ export async function apply(ctx, config = {}) {
522
538
  engine,
523
539
  locks,
524
540
  history,
541
+ plans,
525
542
  sessionStore,
526
543
  worktrees,
527
544
  providerRegistry,
528
545
  credentials,
529
546
  deps,
530
- reviewPreset,
531
547
  });
532
548
  }
533
549