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/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
 
@@ -55,10 +55,9 @@ import { probeModel } from './model/probe.js';
55
55
  import { createExecutionHandler, EXECUTION_PREFIX } from './http/execution-plane.js';
56
56
  import { wrapUserPlaneRoutes } from './http/user-plane.js';
57
57
  import { diagnostic } from './runtime/agent-runner.js';
58
- import { SessionStore, liveControllerAccessor } from './runtime/session-placement.js';
58
+ import { ensureWorkspace, SessionStore, liveControllerAccessor } from './runtime/session-placement.js';
59
59
  import { publishRuntimeEndpoint, resolveDefaultEndpointDiscoveryPath } from './runtime/endpoint-discovery.js';
60
60
  import { resolveCodexActionSeam } from './codex/seam.js';
61
- import { ReviewPreset } from './review/preset.js';
62
61
  import { configureDelegatedSession, policyServicesOf } from './runtime/sandbox.js';
63
62
  import { PermissionBridge, PERMISSION_DEFAULT_TIMEOUT_MS } from './runtime/permissions.js';
64
63
  import { QuestionBridge } from './runtime/questions.js';
@@ -104,9 +103,7 @@ export const Config = z.object({
104
103
  * Mount the delegation service.
105
104
  *
106
105
  * `config` is the operator's settings document and is validated by {@link Config}
107
- * before this runs. A test may additionally pass a `reviewPresetImporter`, which
108
- * replaces the solver used to find the native review tool packages; it is not
109
- * part of the published schema and a real deployment never provides one.
106
+ * before this runs.
110
107
  * @param {import('@deepseek-ai/cordis').Context} ctx - plugin context.
111
108
  * @param {object} config - plugin config.
112
109
  * @returns {Promise<void>} resolves after registration.
@@ -167,32 +164,6 @@ export async function apply(ctx, config = {}) {
167
164
  // conversation. Stores identities only, never transcript content.
168
165
  const sessionStore = new SessionStore(dataDir, { logger });
169
166
 
170
- // The independent review composes its own read-only agent preset instead of
171
- // joining the deployment default (which mounts `dsh-tool-subagent`, a tool a
172
- // scope restriction cannot remove). The composition is registered LAZILY on the
173
- // first review request — the registry's own diagnostic may wait for the Host
174
- // Loader tree to settle, and must not run inside this row's activation — and is
175
- // removed again on unload by the effect below. It never touches the configured
176
- // default, the installed profile, or a user preset.
177
- const reviewPreset = new ReviewPreset({
178
- registry: agentPresets,
179
- logger,
180
- ...(typeof config?.reviewPresetImporter === 'function' ? { importer: config.reviewPresetImporter } : {}),
181
- });
182
- const readPresets = () => ctx.get('agentPresets', false) ?? null;
183
- const reviewPresets = {
184
- /**
185
- * A live facade so a registry that appears (or is replaced) after load is
186
- * observed on the next review instead of being frozen at startup.
187
- */
188
- get id() { return reviewPreset.createdId; },
189
- owns(id) { return reviewPreset.owns(id); },
190
- preparation: (bounds) => {
191
- reviewPreset.attach(readPresets());
192
- return reviewPreset.preparation(bounds ?? {});
193
- },
194
- };
195
-
196
167
  /**
197
168
  * Report a native controller whose read was refused, on the plugin's logger.
198
169
  *
@@ -209,10 +180,49 @@ export async function apply(ctx, config = {}) {
209
180
  logger?.warn?.(`dsh-delegate: the DSH ${serviceName} could not be read (${diagnostic(error?.message ?? error, 200)})`);
210
181
  };
211
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
+
212
223
  const deps = {
213
224
  agents: ctx.agents,
214
225
  agentPresets,
215
- reviewPresets,
216
226
  sessions: ctx.sessions,
217
227
  // The native Workspace and Session controllers. Both are read non-strictly
218
228
  // and, more importantly, LAZILY: a harness that does not compose them must
@@ -238,6 +248,7 @@ export async function apply(ctx, config = {}) {
238
248
  locks,
239
249
  runGit,
240
250
  worktrees,
251
+ registerWorktreeWorkspace,
241
252
  history,
242
253
  plans,
243
254
  taskDisplay,
@@ -256,8 +267,6 @@ export async function apply(ctx, config = {}) {
256
267
  // always has a place to keep the original bytes.
257
268
  backupDir: join(dataDir, 'codex-config-backup'),
258
269
  }),
259
- // The runner calls this only for worker jobs. Reviews intentionally use their
260
- // own read-only tool policy and are not put into a delegated worker sandbox.
261
270
  configureDelegatedSession,
262
271
  // `ctx.sandboxPolicy` and `ctx.approval` own the two facts the delegated
263
272
  // policy writes, so the runner reads them back through these live services
@@ -458,9 +467,6 @@ export async function apply(ctx, config = {}) {
458
467
  // a directory-level mode to configure.
459
468
  conversation: 'per-task',
460
469
  conversationContinuation: 'continueFromTaskId',
461
- // Whether the review's own composition was ever registered, i.e. whether a
462
- // read-only review has been attempted in this activation. Lazy by design.
463
- reviewPreset: reviewPreset.createdId ?? 'not-registered',
464
470
  });
465
471
 
466
472
  // ---- user plane: authenticated DSH settings and task controls --------------
@@ -502,12 +508,15 @@ export async function apply(ctx, config = {}) {
502
508
  );
503
509
  }
504
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
+
505
517
  // ---- stop everything on unload ------------------------------------------
506
518
  ctx.effect(() => async () => {
507
519
  await engine.dispose();
508
- // Jobs are gone before the review composition is: a disposed engine holds no
509
- // runner that could mount a preset this disposer is about to remove.
510
- await reviewPreset.dispose();
511
520
  // History is flushed before the store is closed so a task that finished during
512
521
  // teardown is still durable. The session map is flushed on the same terms.
513
522
  await history.dispose();
@@ -535,7 +544,6 @@ export async function apply(ctx, config = {}) {
535
544
  providerRegistry,
536
545
  credentials,
537
546
  deps,
538
- reviewPreset,
539
547
  });
540
548
  }
541
549