dsh-taskbridge 1.8.0 → 1.9.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 (50) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +246 -231
  3. package/antigravity/agents/dsh-taskbridge.md +17 -14
  4. package/antigravity/skills/dsh-taskbridge/SKILL.md +40 -27
  5. package/bin/dsh-delegate-codex-agent.js +9 -4
  6. package/codex/skills/dsh-taskbridge/SKILL.md +131 -0
  7. package/codex/skills/dsh-taskbridge/rules-reference-96027c387cb9b7587efa4aa3836235d86db1108068e007dc08196e807ca25e5d.md +114 -0
  8. package/docs/INTRODUCTION.md +148 -119
  9. package/docs/INTRODUCTION.zh.md +151 -134
  10. package/docs/antigravity-integration.md +47 -42
  11. package/docs/assets/taskbridge-workflow.en.svg +72 -0
  12. package/docs/assets/taskbridge-workflow.zh.png +0 -0
  13. package/docs/claude-code.md +18 -18
  14. package/docs/codex-integration.md +139 -113
  15. package/docs/conversation-placement.md +7 -6
  16. package/docs/releases/1.8.0.zh.md +16 -16
  17. package/docs/releases/1.8.1.zh.md +24 -0
  18. package/docs/releases/1.9.0.zh.md +31 -0
  19. package/docs/runtime-compatibility.md +7 -9
  20. package/docs/silent-wait.md +17 -26
  21. package/docs/taskbridge-upgrade.md +4 -4
  22. package/lib/client.d.ts +74 -3
  23. package/lib/client.js +7 -7
  24. package/locale/en.json +7 -7
  25. package/locale/zh.json +7 -7
  26. package/package.json +11 -4
  27. package/src/antigravity/installer.js +1099 -1046
  28. package/src/antigravity/seam.js +142 -142
  29. package/src/client/api.js +258 -16
  30. package/src/client/index.jsx +130 -26
  31. package/src/client/task-cleanup.js +130 -5
  32. package/src/codex/agent-ownership.js +72 -12
  33. package/src/codex/installer.js +691 -268
  34. package/src/config/defaults.js +11 -15
  35. package/src/http/execution-plane.js +17 -0
  36. package/src/http/user-plane.js +17 -1
  37. package/src/index.d.ts +9 -1
  38. package/src/index.js +86 -64
  39. package/src/jobs/engine.js +279 -5
  40. package/src/jobs/history.js +18 -2
  41. package/src/jobs/plan-store.js +83 -0
  42. package/src/jobs/record-cleanup.js +714 -195
  43. package/src/mcp/server.js +271 -38
  44. package/src/mcp/wait.js +34 -15
  45. package/src/runtime/agent-runner.js +1 -0
  46. package/src/runtime/permissions.js +18 -0
  47. package/src/runtime/session-placement.js +36 -1
  48. package/src/runtime/worker-prompt.js +14 -9
  49. package/src/workspace/worktrees.js +155 -1
  50. package/codex/dsh-taskbridge.toml +0 -170
@@ -102,27 +102,23 @@ export const LIMITS = Object.freeze({
102
102
  });
103
103
 
104
104
  /**
105
- * Default activity-monitoring thresholds, in seconds of *inactivity*.
105
+ * Default progress-and-monitoring thresholds, in seconds.
106
106
  *
107
- * There is exactly ONE time base: consecutive time without real progress. Real progress
108
- * — model output, a reasoning step, a tool call or a tool result — resets it; a
109
- * heartbeat, a result poll, the self-check itself and a plain state read do not.
107
+ * `selfCheckSeconds` measures elapsed time from run start for one read-only local
108
+ * inspection (default 10 minutes; does not require a host to be waiting).
110
109
  *
111
- * Two reminders are measured on that clock, and each can be switched off with `0`:
112
- *
113
- * * `selfCheckSeconds` — one read-only local inspection (default 10 minutes);
114
- * * `attentionSeconds` — one notification to the commander asking it to check the
115
- * run's progress (default 40 minutes).
116
- *
117
- * Neither depends on total runtime, so a task that keeps working for hours produces
118
- * neither. Nothing here ever ends, cancels or restarts a run: a reminder is a REPORT,
119
- * never a verdict.
110
+ * `attentionSeconds` measures how long nothing new has been RETURNED to the commander
111
+ * (default 40 minutes). Internal model/tool activity, heartbeats, permission/question
112
+ * waits, and local self-checks do NOT reset this delivery clock; only a real stage
113
+ * result or terminal delivery moves it. Neither threshold ever ends, cancels, or restarts
114
+ * a run: a reminder is a progress checkpoint, never a verdict.
120
115
  */
121
116
  export const MONITORING_DEFAULTS = Object.freeze({
122
- /** No-progress span after which one read-only local self-check is performed (0 = off). */
117
+ /** Elapsed seconds from run start after which one read-only local self-check runs (0 = off). */
123
118
  selfCheckSeconds: 10 * 60,
124
119
  /**
125
- * No-progress span after which the wait reports the run progress check (0 = off).
120
+ * Seconds without returning a new result to the commander before the wait reports a
121
+ * run progress check (0 = off).
126
122
  *
127
123
  * This is the ONE notification interval: it doubles as the point at which a host is
128
124
  * asked to confirm the goal, so there is no second duration to configure.
@@ -237,6 +237,15 @@ async function submitTask({ req, res, connection, deps }) {
237
237
  const continueFromTaskId = body.continueFromTaskId === undefined || body.continueFromTaskId === null
238
238
  ? undefined
239
239
  : body.continueFromTaskId;
240
+ if (body.reuseWorktreeFromTaskId !== undefined && body.reuseWorktreeFromTaskId !== null
241
+ && typeof body.reuseWorktreeFromTaskId !== 'string') {
242
+ throw new HttpError(400, 'JOB_ISOLATION_REFUSED', 'reuseWorktreeFromTaskId must be a string', {
243
+ field: 'reuseWorktreeFromTaskId',
244
+ });
245
+ }
246
+ const reuseWorktreeFromTaskId = typeof body.reuseWorktreeFromTaskId === 'string'
247
+ ? body.reuseWorktreeFromTaskId
248
+ : undefined;
240
249
  // The Agent Teams decision travels as the commander's own field and is folded into the
241
250
  // existing overrides channel (the engine's per-task choice path). A non-boolean is
242
251
  // refused here rather than reaching the engine's sanitiser as a coercible value.
@@ -277,6 +286,7 @@ async function submitTask({ req, res, connection, deps }) {
277
286
  ...(body.title === undefined ? {} : { title: body.title }),
278
287
  overrides,
279
288
  ...(continueFromTaskId === undefined ? {} : { continueFromTaskId }),
289
+ ...(reuseWorktreeFromTaskId === undefined ? {} : { reuseWorktreeFromTaskId }),
280
290
  ...hierarchyFields,
281
291
  ...goalField,
282
292
  });
@@ -297,6 +307,7 @@ async function submitTask({ req, res, connection, deps }) {
297
307
  ...(body.title === undefined ? {} : { title: body.title }),
298
308
  overrides,
299
309
  ...(continueFromTaskId === undefined ? {} : { continueFromTaskId }),
310
+ ...(reuseWorktreeFromTaskId === undefined ? {} : { reuseWorktreeFromTaskId }),
300
311
  ...hierarchyFields,
301
312
  ...goalField,
302
313
  });
@@ -383,6 +394,11 @@ async function decidePermission({ req, res, connection, deps }) {
383
394
  if (body.fingerprint !== undefined && body.fingerprint !== null && typeof body.fingerprint !== 'string') {
384
395
  throw new HttpError(400, 'PERMISSION_FINGERPRINT_INVALID', 'fingerprint must be a string when present');
385
396
  }
397
+ if (body.scope !== undefined && body.scope !== null && body.scope !== 'once' && body.scope !== 'task-command') {
398
+ throw new HttpError(400, 'PERMISSION_DECISION_INVALID', 'scope must be once or task-command when present', {
399
+ field: 'scope',
400
+ });
401
+ }
386
402
  const result = await deps.engine.decidePermission({
387
403
  // The verified connection, not `body.connectionId`: a caller cannot name an owner.
388
404
  connectionId: connection.connectionId,
@@ -391,6 +407,7 @@ async function decidePermission({ req, res, connection, deps }) {
391
407
  decision: body.decision,
392
408
  ...(typeof body.reason === 'string' ? { reason: body.reason } : {}),
393
409
  ...(typeof body.fingerprint === 'string' ? { fingerprint: body.fingerprint } : {}),
410
+ ...(typeof body.scope === 'string' ? { scope: body.scope } : {}),
394
411
  });
395
412
  sendJson(res, 200, { ok: true, ...result });
396
413
  }
@@ -42,7 +42,7 @@ import { sameRecordedDirectory } from '../jobs/continuation-identity.js';
42
42
  import { buildTaskTree } from '../jobs/task-tree.js';
43
43
  import { findDisplayNode } from '../jobs/task-display.js';
44
44
  import { MAX_PLAN_BATCH, PLAN_CODES } from '../jobs/plan-store.js';
45
- import { cleanupOverview, runCleanup } from '../jobs/record-cleanup.js';
45
+ import { cleanupOverview, runCleanup, runOrphanCleanup } from '../jobs/record-cleanup.js';
46
46
 
47
47
  /**
48
48
  * Route prefix, already below `/api` because the native exact-route registry
@@ -594,6 +594,16 @@ export function userPlaneRoutes(deps) {
594
594
  return jsonResponse(200, { ok: true, ...outcome });
595
595
  },
596
596
  },
597
+ {
598
+ path: `${USER_PLANE_PREFIX}/tasks/cleanup-orphans`,
599
+ methods: ['POST'],
600
+ requestBody: BODY_MODE,
601
+ fetch: async (request) => {
602
+ const body = await readJsonRequest(request);
603
+ const outcome = await runOrphanCleanup(deps, body);
604
+ return jsonResponse(200, { ok: true, ...outcome });
605
+ },
606
+ },
597
607
  {
598
608
  path: `${USER_PLANE_PREFIX}/tasks/cancel`,
599
609
  methods: ['POST'],
@@ -913,6 +923,9 @@ async function runCodexIntegration(deps, action) {
913
923
  'this host does not expose the Codex integration, so nothing can be installed or reported',
914
924
  );
915
925
  }
926
+ if (deps.codexStartupRefresh) {
927
+ try { await deps.codexStartupRefresh; } catch { /* startup refresh logs its own warning */ }
928
+ }
916
929
  let outcome;
917
930
  try {
918
931
  outcome = action === 'status' ? await seam.status() : await seam.run(action);
@@ -954,6 +967,9 @@ async function runAntigravityIntegration(deps, action) {
954
967
  'this host does not expose the Antigravity integration, so nothing can be installed or reported',
955
968
  );
956
969
  }
970
+ if (deps.antigravityStartupRefresh) {
971
+ try { await deps.antigravityStartupRefresh; } catch { /* startup refresh logs its own warning */ }
972
+ }
957
973
  let outcome;
958
974
  try {
959
975
  outcome = action === 'status' ? await seam.status() : await seam.run(action);
package/src/index.d.ts CHANGED
@@ -112,8 +112,13 @@ export interface DelegateSubmitRequest {
112
112
  title?: string;
113
113
  goalDescription?: string;
114
114
  continueFromTaskId?: string;
115
+ reuseWorktreeFromTaskId?: string;
115
116
  planNodeId?: string;
116
117
  parentNodeId?: string;
118
+ autoPreflight?: boolean;
119
+ allowShared?: boolean;
120
+ wait?: boolean;
121
+ waitSeconds?: number;
117
122
  overrides?: {
118
123
  model?: string;
119
124
  reasoningEffort?: string;
@@ -227,7 +232,7 @@ export interface DelegatePendingPermission {
227
232
  deadlineAt: number;
228
233
  decision: 'allow-once' | 'reject' | null;
229
234
  decidedAt: number | null;
230
- decidedBy: 'commander' | 'deadline' | 'asker' | 'stop' | 'binding' | 'restart' | null;
235
+ decidedBy: 'commander' | 'commander-task-command' | 'deadline' | 'asker' | 'stop' | 'binding' | 'restart' | null;
231
236
  decisionReason: string | null;
232
237
  /** Closed native outcome: `allowed-once` is the only grant. */
233
238
  outcome: 'allowed-once' | 'rejected' | 'cancelled' | 'unavailable' | null;
@@ -237,6 +242,9 @@ export interface DelegatePendingPermission {
237
242
  argumentsComplete: boolean;
238
243
  callReread: boolean;
239
244
  turnOpen: boolean;
245
+ /** Effective scope. `task-command` can appear in historical preview receipts. */
246
+ scope?: 'once' | 'task-command';
247
+ reusedFromRequestId?: string;
240
248
  boundsApplied: string[];
241
249
  } | null;
242
250
  /** Present only for an `allowed-once`; states that it covers one call. */
package/src/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  // dsh-delegate — native DSH plugin entry point.
2
2
  //
3
3
  // Load order matters and is visible here: services are injected, configuration is
4
- // read, a byte-exact shipped Codex agent is refreshed, both HTTP planes are
5
- // registered on their respective carriers, and the native
6
- // provider/adapter/worktree/history machinery is constructed. The persisted
7
- // local-call switch is restored at startup and defaults to OFF; no task is
8
- // dispatched until an operator enables it in the DSH plugin settings.
4
+ // read, the native provider/adapter/worktree/history machinery is constructed,
5
+ // both HTTP planes are registered on their respective carriers immediately, and
6
+ // byte-exact shipped Codex / Antigravity integrations are refreshed in parallel.
7
+ // The persisted local-call switch is restored at startup and defaults to OFF;
8
+ // no task is dispatched until an operator enables it in the DSH plugin settings.
9
9
  //
10
10
  // Service access is deliberately split in three:
11
11
  //
@@ -296,67 +296,10 @@ export async function apply(ctx, config = {}) {
296
296
  hasQuestionService: () => hasQuestionService(ctx),
297
297
  logger,
298
298
  }),
299
+ codexStartupRefresh: null,
300
+ antigravityStartupRefresh: null,
299
301
  };
300
302
 
301
- try {
302
- // Both halves of the installed-integration check: a byte-exact shipped agent is
303
- // refreshed, and an ALREADY INSTALLED managed `mcp_servers.dsh-delegate` entry that
304
- // is merely stale (for example one written before `tool_timeout_sec` existed) is
305
- // upgraded in place. Nothing is created here — a home without an entry stays
306
- // without one — and an entry this plugin cannot prove it wrote is refused and left
307
- // byte-identical.
308
- //
309
- // The TARGET is the seam's own decision (`startupTarget`), not a second read of
310
- // `process.env`: an explicit `CODEX_HOME`, else the home this plugin recorded from a
311
- // successful install, else the default only when it is a real directory. A default
312
- // that is a link is reported instead of walked, so the automatic upgrade never
313
- // writes into a tree nobody named.
314
- const target = await deps.codex?.startupTarget?.();
315
- let migration = null;
316
- if (target?.home) {
317
- migration = await deps.codex?.refreshManagedIntegration({
318
- startupTarget: target,
319
- // The pre-write copy lives in the plugin's own data directory: supportable, not
320
- // packaged, and never inside the Codex home.
321
- backupDir: join(dataDir, 'codex-config-backup'),
322
- });
323
- } else if (target !== undefined && target !== null) {
324
- logger?.info?.(`dsh-delegate: Codex integration check skipped (${target.reason})`);
325
- }
326
- if (migration?.changed.includes('agent')) {
327
- logger?.info?.(`dsh-delegate: refreshed a managed Codex agent template to ${pluginVersion}`);
328
- }
329
- if (migration?.changed.includes('mcp')) {
330
- logger?.info?.('dsh-delegate: upgraded a stale managed Codex MCP entry in place');
331
- }
332
- for (const refusal of migration?.refused ?? []) {
333
- logger?.warn?.(`dsh-delegate: Codex integration refresh was refused (${refusal.code})`);
334
- }
335
- } catch (error) {
336
- logger?.warn?.(`dsh-delegate: Codex integration refresh check failed (${diagnostic(error?.message ?? error, 200)})`);
337
- }
338
-
339
- try {
340
- const agyTarget = await deps.antigravity?.startupTarget?.();
341
- let agyMigration = null;
342
- if (agyTarget?.home) {
343
- agyMigration = await deps.antigravity?.refreshManagedIntegration({ startupTarget: agyTarget });
344
- } else if (agyTarget !== undefined && agyTarget !== null) {
345
- logger?.info?.(`dsh-delegate: Antigravity integration check skipped (${agyTarget.reason})`);
346
- }
347
- if (agyMigration?.changed.includes('plugin')) {
348
- logger?.info?.(`dsh-delegate: refreshed a managed Antigravity plugin bundle to ${pluginVersion}`);
349
- }
350
- if (agyMigration?.changed.includes('mcp')) {
351
- logger?.info?.('dsh-delegate: upgraded a stale managed Antigravity MCP entry in place');
352
- }
353
- for (const refusal of agyMigration?.refused ?? []) {
354
- logger?.warn?.(`dsh-delegate: Antigravity integration refresh was refused (${refusal.code})`);
355
- }
356
- } catch (error) {
357
- logger?.warn?.(`dsh-delegate: Antigravity integration refresh check failed (${diagnostic(error?.message ?? error, 200)})`);
358
- }
359
-
360
303
  /**
361
304
  * Bring the native routes and the adapter's served snapshot to the state this
362
305
  * settings snapshot describes, and return the mapping both sides agree on.
@@ -570,6 +513,85 @@ export async function apply(ctx, config = {}) {
570
513
  credentials,
571
514
  deps,
572
515
  });
516
+
517
+ // Run Codex and Antigravity startup refreshes AFTER both HTTP planes are registered
518
+ // (and in parallel), so clicking "Enable immediately" in DSH Desktop never leaves
519
+ // `/api/dsh-delegate/*` returning 404 while Windows PowerShell checks symlink paths.
520
+ // The `/codex` and `/antigravity` user-plane routes await their respective refresh
521
+ // promise before reading or mutating files so there is no startup read/write race.
522
+ const codexStartupRefresh = (async () => {
523
+ try {
524
+ // Both halves of the installed-integration check: a byte-exact shipped agent is
525
+ // refreshed, and an ALREADY INSTALLED managed `mcp_servers.dsh-delegate` entry that
526
+ // is merely stale (for example one written before `tool_timeout_sec` existed) is
527
+ // upgraded in place. Nothing is created here — a home without an entry stays
528
+ // without one — and an entry this plugin cannot prove it wrote is refused and left
529
+ // byte-identical.
530
+ //
531
+ // The TARGET is the seam's own decision (`startupTarget`), not a second read of
532
+ // `process.env`: an explicit `CODEX_HOME`, else the home this plugin recorded from a
533
+ // successful install, else the default only when it is a real directory. A default
534
+ // that is a link is reported instead of walked, so the automatic upgrade never
535
+ // writes into a tree nobody named.
536
+ const target = await deps.codex?.startupTarget?.();
537
+ let migration = null;
538
+ if (target?.home) {
539
+ migration = await deps.codex?.refreshManagedIntegration({
540
+ startupTarget: target,
541
+ // The pre-write copy lives in the plugin's own data directory: supportable, not
542
+ // packaged, and never inside the Codex home.
543
+ backupDir: join(dataDir, 'codex-config-backup'),
544
+ });
545
+ } else if (target !== undefined && target !== null) {
546
+ logger?.info?.(`dsh-delegate: Codex integration check skipped (${target.reason})`);
547
+ }
548
+ if (migration?.changed.includes('agent')) {
549
+ logger?.info?.(`dsh-delegate: refreshed a managed Codex skill template to ${pluginVersion}`);
550
+ }
551
+ if (migration?.changed.includes('legacyAgent')) {
552
+ logger?.info?.('dsh-delegate: removed managed legacy Codex subagent files');
553
+ }
554
+ if (migration?.changed.includes('mcp')) {
555
+ logger?.info?.('dsh-delegate: upgraded a stale managed Codex MCP entry in place');
556
+ }
557
+ for (const refusal of migration?.refused ?? []) {
558
+ logger?.warn?.(`dsh-delegate: Codex integration refresh was refused (${refusal.code})`);
559
+ }
560
+ } catch (error) {
561
+ logger?.warn?.(`dsh-delegate: Codex integration refresh check failed (${diagnostic(error?.message ?? error, 200)})`);
562
+ }
563
+ })().finally(() => {
564
+ if (deps.codexStartupRefresh === codexStartupRefresh) deps.codexStartupRefresh = null;
565
+ });
566
+ deps.codexStartupRefresh = codexStartupRefresh;
567
+
568
+ const antigravityStartupRefresh = (async () => {
569
+ try {
570
+ const agyTarget = await deps.antigravity?.startupTarget?.();
571
+ let agyMigration = null;
572
+ if (agyTarget?.home) {
573
+ agyMigration = await deps.antigravity?.refreshManagedIntegration({ startupTarget: agyTarget });
574
+ } else if (agyTarget !== undefined && agyTarget !== null) {
575
+ logger?.info?.(`dsh-delegate: Antigravity integration check skipped (${agyTarget.reason})`);
576
+ }
577
+ if (agyMigration?.changed.includes('plugin')) {
578
+ logger?.info?.(`dsh-delegate: refreshed a managed Antigravity plugin bundle to ${pluginVersion}`);
579
+ }
580
+ if (agyMigration?.changed.includes('mcp')) {
581
+ logger?.info?.('dsh-delegate: upgraded a stale managed Antigravity MCP entry in place');
582
+ }
583
+ for (const refusal of agyMigration?.refused ?? []) {
584
+ logger?.warn?.(`dsh-delegate: Antigravity integration refresh was refused (${refusal.code})`);
585
+ }
586
+ } catch (error) {
587
+ logger?.warn?.(`dsh-delegate: Antigravity integration refresh check failed (${diagnostic(error?.message ?? error, 200)})`);
588
+ }
589
+ })().finally(() => {
590
+ if (deps.antigravityStartupRefresh === antigravityStartupRefresh) deps.antigravityStartupRefresh = null;
591
+ });
592
+ deps.antigravityStartupRefresh = antigravityStartupRefresh;
593
+
594
+ await Promise.all([codexStartupRefresh, antigravityStartupRefresh]);
573
595
  }
574
596
 
575
597
  /**