dsh-taskbridge 1.7.1 → 1.8.1

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 (84) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +21 -21
  3. package/README.md +733 -877
  4. package/THIRD_PARTY_NOTICES.txt +23 -23
  5. package/antigravity/agents/dsh-taskbridge.md +32 -0
  6. package/antigravity/skills/dsh-taskbridge/SKILL.md +51 -0
  7. package/codex/dsh-taskbridge.toml +181 -631
  8. package/cordis.patch.yml +6 -6
  9. package/docs/INTRODUCTION.md +122 -295
  10. package/docs/INTRODUCTION.zh.md +134 -279
  11. package/docs/antigravity-integration.md +42 -0
  12. package/docs/auth-contract.md +138 -138
  13. package/docs/claude-code.md +6 -11
  14. package/docs/codex-integration.md +2 -2
  15. package/docs/contracts-stage-b.md +443 -443
  16. package/docs/conversation-placement.md +7 -6
  17. package/docs/plugin-market.md +30 -30
  18. package/docs/redaction-contract.md +170 -170
  19. package/docs/releases/1.7.0.zh.md +11 -11
  20. package/docs/releases/1.8.0.zh.md +16 -0
  21. package/docs/releases/1.8.1.zh.md +24 -0
  22. package/docs/runtime-compatibility.md +1 -1
  23. package/docs/taskbridge-upgrade.md +28 -28
  24. package/docs/taskdispatch-upgrade.md +25 -25
  25. package/docs/workspace-contract.md +538 -538
  26. package/docs/workspace-grouping.md +126 -126
  27. package/icon.svg +1 -1
  28. package/lib/client.d.ts +804 -699
  29. package/lib/client.js +7 -7
  30. package/locale/en.json +1 -1
  31. package/locale/zh.json +1 -1
  32. package/package.json +150 -144
  33. package/src/antigravity/installer.js +1068 -0
  34. package/src/antigravity/seam.js +142 -0
  35. package/src/auth/fence.js +361 -361
  36. package/src/auth/grants.js +789 -789
  37. package/src/client/api.js +266 -3
  38. package/src/client/index.jsx +224 -11
  39. package/src/client/sidebar.jsx +862 -862
  40. package/src/client/styles.js +624 -624
  41. package/src/client/task-cleanup.js +429 -304
  42. package/src/client/task-records-table.jsx +217 -217
  43. package/src/client/task-view.js +307 -307
  44. package/src/client/workspace-groups.js +482 -482
  45. package/src/client/workspaces-browser.jsx +770 -770
  46. package/src/codex/agent-ownership.js +270 -270
  47. package/src/codex/installer.js +6 -0
  48. package/src/codex/toml.js +784 -784
  49. package/src/config/defaults.js +11 -15
  50. package/src/config/redact.js +245 -245
  51. package/src/config/store.js +186 -186
  52. package/src/credentials/seam.js +202 -202
  53. package/src/http/respond.js +6 -5
  54. package/src/http/user-plane.js +83 -1
  55. package/src/index.js +25 -0
  56. package/src/jobs/diagnostics.js +15 -15
  57. package/src/jobs/engine.js +1 -0
  58. package/src/jobs/history.js +1 -1
  59. package/src/jobs/plan-store.js +1103 -1020
  60. package/src/jobs/record-cleanup.js +452 -7
  61. package/src/jobs/review-note.js +63 -63
  62. package/src/jobs/task-descriptions.js +82 -82
  63. package/src/jobs/task-display.js +73 -73
  64. package/src/jobs/task-tree.js +786 -786
  65. package/src/jobs/title.js +134 -134
  66. package/src/mcp/continuation.js +317 -317
  67. package/src/mcp/server.js +34 -27
  68. package/src/mcp/wait.js +34 -15
  69. package/src/model/connectivity.js +371 -371
  70. package/src/model/discovery.js +582 -582
  71. package/src/model/native-catalog.js +68 -68
  72. package/src/model/openai-adapter.js +671 -671
  73. package/src/model/probe.js +264 -264
  74. package/src/model/providers.js +756 -756
  75. package/src/model/routing.js +321 -321
  76. package/src/runtime/agent-runner.js +1 -0
  77. package/src/runtime/permissions.js +1619 -1619
  78. package/src/runtime/question-call.js +162 -162
  79. package/src/runtime/questions.js +909 -909
  80. package/src/runtime/session-placement.js +36 -1
  81. package/src/runtime/worker-prompt.js +61 -55
  82. package/src/workspace/audit.js +775 -775
  83. package/src/workspace/preflight.js +424 -424
  84. package/src/workspace/worktrees.js +833 -679
package/src/mcp/server.js CHANGED
@@ -2,7 +2,7 @@
2
2
  //
3
3
  // Design rule taken from SPEC §10–11: an external MCP client may *exercise* an
4
4
  // authorization the operator already created, and may do nothing else. So this
5
- // server exposes eight tools and maps each one onto one execution-plane route:
5
+ // server exposes eleven tools and maps each execution tool onto one execution-plane route:
6
6
  //
7
7
  // delegate_status → GET /dsh-delegate/x/status
8
8
  // delegate_submit → POST /dsh-delegate/x/tasks
@@ -10,8 +10,11 @@
10
10
  // delegate_wait → POST /dsh-delegate/x/tasks/observe (repeated)
11
11
  // delegate_cancel → POST /dsh-delegate/x/tasks/cancel
12
12
  // delegate_permission_decide → POST /dsh-delegate/x/tasks/permission
13
+ // delegate_question_answer → POST /dsh-delegate/x/tasks/question
13
14
  // delegate_review → POST /dsh-delegate/x/tasks/review
15
+ // delegate_plan → POST /dsh-delegate/x/plans
14
16
  // delegate_preflight → POST /dsh-delegate/x/workspace/preflight
17
+ // delegate_metrics → local process census (no plane route)
15
18
  //
16
19
  // `delegate_wait` is a read like `delegate_result`, and it is the one tool whose
17
20
  // single call may take a long time: it composes several BOUNDED observation
@@ -470,9 +473,12 @@ export const TOOLS = Object.freeze([
470
473
  title: 'Wait for a task to need you',
471
474
  description: 'Follow ONE task this connection submitted and return as soon as it needs the host. '
472
475
  + 'A single call blocks for up to waitSeconds (default 3600) and returns a COMPACT answer: '
473
- + '`reason` is `permission` (a per-call request is pending), `attention` (the run has been silent for '
474
- + 'the configured inactivity threshold, ten minutes by default, so it may be stuck), `ready` (the run '
475
- + 'ended and is awaiting host review), `failed`, `cancelled` or `interrupted`. '
476
+ + '`reason` is `permission` (a per-call request is pending), `question` (the worker asked a native '
477
+ + 'question that needs `delegate_question_answer`), `attention` (a progress check because nothing new was '
478
+ + 'returned to the host for the operator-configured delivery interval in DSH settings — 40 minutes by '
479
+ + 'default; internal worker activity does not reset this clock and it does NOT imply the run is stuck — '
480
+ + 'or a `repeated-tool-failure` reminder), `ready` (the run ended and is awaiting host review), `failed`, '
481
+ + '`cancelled` or `interrupted`. '
476
482
  + 'An `attention` answer may instead carry a `failure` block (kind `repeated-tool-failure`, with '
477
483
  + 'a stable `eventId`, toolName/failureCode/consecutive): the worker repeated the SAME operation and failed the same way '
478
484
  + 'several times in a row. It is a question for the host, and it is REDELIVERED until you acknowledge it with '
@@ -1398,19 +1404,16 @@ function compactJson(value) {
1398
1404
  }
1399
1405
 
1400
1406
  /**
1401
- * Whether a projected value fits the tool-text bound in either encoding.
1407
+ * Whether a projected value fits the tool-text bound when serialized compactly.
1402
1408
  *
1403
- * The bound must hold for *both* the compact and the two-space encoding because
1404
- * the published answer alone is not the whole JSON a client parses: a client that
1405
- * re-serializes it, or a host that pretty-prints the envelope, must not be able to
1406
- * push past {@link MAX_TOOL_TEXT_CHARS}.
1409
+ * Compact JSON (no indentation whitespace) is what {@link boundedJson} publishes to MCP
1410
+ * clients so wait, permission, and result turns avoid wasting commander context tokens
1411
+ * on formatting spaces.
1407
1412
  * @param {unknown} value - projected JSON value.
1408
1413
  * @returns {boolean} true when the value fits.
1409
1414
  */
1410
1415
  function fitsBound(value) {
1411
- const compact = compactJson(value);
1412
- if (compact.length > MAX_TOOL_TEXT_CHARS) return false;
1413
- return JSON.stringify(value, null, 2).length <= MAX_TOOL_TEXT_CHARS;
1416
+ return compactJson(value).length <= MAX_TOOL_TEXT_CHARS;
1414
1417
  }
1415
1418
 
1416
1419
  /**
@@ -2297,7 +2300,7 @@ function boundedJson(value) {
2297
2300
  } catch {
2298
2301
  return refuseResult('MCP_RESULT_UNSERIALIZABLE', 'the delegated call answered with a value that could not be serialized');
2299
2302
  }
2300
- if (fitsBound(value)) return { text: JSON.stringify(redactDeepStrings(value), null, 2), isError: false };
2303
+ if (fitsBound(value)) return { text: JSON.stringify(redactDeepStrings(value)), isError: false };
2301
2304
 
2302
2305
  const stages = [
2303
2306
  { executionText: TRUNCATED_FIELD_CAPS.executionTextChars, reviewText: TRUNCATED_FIELD_CAPS.reviewTextChars, lists: 50, permissionEvidence: 8 },
@@ -2340,7 +2343,7 @@ function boundedJson(value) {
2340
2343
  projected.questionAnswerable = isQuestionAnswerable(projected.question);
2341
2344
  projected.grantsAccess = false;
2342
2345
  }
2343
- return JSON.stringify(redactDeepStrings(projected), null, 2);
2346
+ return JSON.stringify(redactDeepStrings(projected));
2344
2347
  };
2345
2348
  for (const stage of stages) {
2346
2349
  const text = apply(stage);
@@ -2490,8 +2493,6 @@ function rescueQuestion(value, fullTextChars) {
2490
2493
  payload.failureAck = questionRescueAck;
2491
2494
  }
2492
2495
  const redacted = redactDeepStrings(payload);
2493
- const pretty = JSON.stringify(redacted, null, 2);
2494
- if (pretty.length <= MAX_TOOL_TEXT_CHARS) return { text: pretty, isError: false };
2495
2496
  const compact = JSON.stringify(redacted);
2496
2497
  if (compact.length <= MAX_TOOL_TEXT_CHARS) return { text: compact, isError: false };
2497
2498
  }
@@ -2610,7 +2611,7 @@ function permissionRescue(value, fullTextChars) {
2610
2611
  permissionDecidable: false,
2611
2612
  truncation: truncationBlock(records, fullTextChars, entries),
2612
2613
  });
2613
- return JSON.stringify(redactDeepStrings(payload), null, 2);
2614
+ return JSON.stringify(redactDeepStrings(payload));
2614
2615
  }
2615
2616
  if (entries.length === 0) {
2616
2617
  // A RECEIPT-ONLY rescue: no live request survived to publish, but the decision must
@@ -2624,7 +2625,7 @@ function permissionRescue(value, fullTextChars) {
2624
2625
  actionable: true,
2625
2626
  truncation: truncationBlock(records, fullTextChars, entries),
2626
2627
  });
2627
- return JSON.stringify(redactDeepStrings(payload), null, 2);
2628
+ return JSON.stringify(redactDeepStrings(payload));
2628
2629
  }
2629
2630
  const tasks = entries.map((entry) => {
2630
2631
  const pending = render(entry);
@@ -2640,7 +2641,7 @@ function permissionRescue(value, fullTextChars) {
2640
2641
  const payload = withReceipt(entries.length === 1 && entries[0].path === 'task'
2641
2642
  ? { ok: value.ok, task: tasks[0], truncation: truncationBlock(records, fullTextChars, entries) }
2642
2643
  : { ok: value.ok, tasks, truncation: truncationBlock(records, fullTextChars, entries) });
2643
- return JSON.stringify(redactDeepStrings(payload), null, 2);
2644
+ return JSON.stringify(redactDeepStrings(payload));
2644
2645
  };
2645
2646
  }
2646
2647
 
@@ -2699,13 +2700,13 @@ function refuseResult(code, message, extra = {}) {
2699
2700
  ok: false,
2700
2701
  error: { code, message, ...extra },
2701
2702
  truncation: { truncated: true, fullResultIncluded: false },
2702
- }), null, 2);
2703
+ }));
2703
2704
  if (text.length <= MAX_TOOL_TEXT_CHARS) return { text, isError: true };
2704
2705
  // The refusal itself is larger than the bound, which only happens if the bound
2705
2706
  // is configured absurdly small. This minimal form is still valid JSON and still
2706
2707
  // says the answer was refused rather than delivered.
2707
2708
  return {
2708
- text: JSON.stringify({ ok: false, error: { code, truncated: true }, truncation: { truncated: true, fullResultIncluded: false } }, null, 2),
2709
+ text: JSON.stringify({ ok: false, error: { code, truncated: true }, truncation: { truncated: true, fullResultIncluded: false } }),
2709
2710
  isError: true,
2710
2711
  };
2711
2712
  }
@@ -3359,8 +3360,9 @@ export function createMcpServer(options) {
3359
3360
  + 'When an APPLIED decision\'s follow-up wait fails or is cancelled, the call still succeeds with that '
3360
3361
  + 'receipt, `reason: null` and a `waitError` block: only the waiting ended, the execution was not '
3361
3362
  + 'stopped, and the decision must not be resent. To follow a task without polling, use '
3362
- + 'delegate_wait({ taskId }): one call blocks until the task needs you (permission, ready, failed, '
3363
- + 'cancelled, interrupted) or until its own one-hour deadline, in which case it answers reason '
3363
+ + 'delegate_wait({ taskId }): one call blocks until the task needs you (permission, question, '
3364
+ + 'attention, ready, failed, cancelled, interrupted) or until its own one-hour deadline, in which '
3365
+ + 'case it answers reason '
3364
3366
  + '`wait-limit` with `actionable: false` and you call it again with the same taskId instead of '
3365
3367
  + 'reviewing or resubmitting anything. Omit waitSeconds for normal waiting: the default already '
3366
3368
  + 'covers an hour, it cannot be raised above 3600, and a shorter value is only for a one-off '
@@ -3376,9 +3378,13 @@ export function createMcpServer(options) {
3376
3378
  + 'time limit is an OUTER limit: the observation did not end and the worker did not stop, so continue '
3377
3379
  + 'the SAME exec cell and ask for the longest yield the host supports (roughly 1200000 ms when a '
3378
3380
  + 'yield/pragmas parameter exists, not a minute) instead of re-issuing every second. (c) `attention` '
3379
- + 'is genuine inactivity: no activity for the configured threshold (ten minutes by default) while the '
3380
- + 'task still runs. (d) The task\'s total execution timeout is the worker\'s own budget, reported as a '
3381
- + 'terminal state — it is not `wait-limit`, not `attention` and not a client-side event. A real '
3381
+ + 'is either a run progress check (nothing new was delivered back to the host for the operator-configured '
3382
+ + 'delivery interval in DSH settings — 40 minutes by default; internal worker activity, heartbeats, '
3383
+ + 'permission/question waits and the local self-check do not reset it, and it does NOT imply the run is '
3384
+ + 'stuck) or a `repeated-tool-failure` reminder while the task still runs. (d) There is NO default total '
3385
+ + 'execution timeout: an execution timeout (`JOB_TIMEOUT`, reported as a terminal state) only applies when '
3386
+ + 'an explicit cap is supplied via `overrides.timeoutSeconds` — it is not `wait-limit`, not `attention` '
3387
+ + 'and not a client-side event. A real '
3382
3388
  + 'failure is worth one de-duplicated reminder; an ordinary single failing test inside the worker is '
3383
3389
  + 'the worker\'s job to fix and is not a host event. '
3384
3390
  + '`interrupted` never means the execution stopped by itself: this call returns it at once '
@@ -3401,7 +3407,8 @@ export function createMcpServer(options) {
3401
3407
  + 'PROGRAM, not the host model: the host\'s own turns, token usage and cost are reported as '
3402
3408
  + '`not-integrated` because this process cannot observe them. '
3403
3409
  + 'When a task reaches `ready`/`awaiting-host-review`, finish YOUR review and record it with '
3404
- + 'delegate_review ({ taskId, decision: "accepted" | "changes-requested", note }): that call is the '
3410
+ + 'delegate_review ({ taskId, decision: "accepted" | "changes-requested", note, completionSummary? }): '
3411
+ + 'that call is the '
3405
3412
  + 'only thing that records host acceptance, and until it is made the task stays unreviewed. '
3406
3413
  + 'Completion is never acceptance on its own, and a review cannot approve permissions, change '
3407
3414
  + 'settings or models, merge the diff or create work. The first decision is final for that task; '
package/src/mcp/wait.js CHANGED
@@ -166,6 +166,15 @@ const SETTLED_STATE_REASONS = Object.freeze({
166
166
  interrupted: 'interrupted',
167
167
  });
168
168
 
169
+ /**
170
+ * Fields dropped from `compactTask` during an interactive pause (`permission` / `question`).
171
+ * The host only needs the task identity and live pending request/question to decide and continue;
172
+ * repeating static routing, monitoring history, and empty review persistence on every approval
173
+ * turn wastes commander context tokens. All of them remain present on `attention`, terminal
174
+ * returns, and `delegate_result`.
175
+ */
176
+ const INTERACTIVE_PAUSE_DROP = new Set(['route', 'hostAcceptance']);
177
+
169
178
  /**
170
179
  * Compact one observation's task view into what a wait answer carries.
171
180
  *
@@ -173,12 +182,16 @@ const SETTLED_STATE_REASONS = Object.freeze({
173
182
  * answer small and keeps a diff from reaching a host through the one tool that is
174
183
  * supposed to be cheap.
175
184
  * @param {object | null | undefined} task - observation `task`.
185
+ * @param {{ interactivePause?: boolean }} [options] - `interactivePause`: omit bulky monitoring
186
+ * and static routing fields on live `permission` / `question` turns.
176
187
  * @returns {object} the compact task.
177
188
  */
178
- export function compactTask(task) {
189
+ export function compactTask(task, options = {}) {
179
190
  if (task === null || typeof task !== 'object' || Array.isArray(task)) return {};
191
+ const interactivePause = options?.interactivePause === true;
180
192
  const out = {};
181
193
  for (const key of TASK_FIELDS) {
194
+ if (interactivePause && INTERACTIVE_PAUSE_DROP.has(key)) continue;
182
195
  if (task[key] !== undefined) out[key] = task[key];
183
196
  }
184
197
  // A wait NEVER carries the review note body: the conclusion's state, time and length are
@@ -203,15 +216,17 @@ export function compactTask(task) {
203
216
  : {}),
204
217
  };
205
218
  }
206
- if (task.reviewPersistence !== undefined) out.reviewPersistence = task.reviewPersistence;
207
- // Activity and self-check are small, bounded summaries the engine produced for
208
- // exactly this purpose; they are carried whole rather than re-projected here — EXCEPT
209
- // the fields a wait must never carry whatever depth they arrive at. An engine (or a
210
- // fixture) that nested a diff or execution prose inside `activity` would otherwise put
211
- // evidence on the one answer that is supposed to be cheap, so evidence keys are
212
- // dropped at any depth.
213
- if (task.activity !== undefined) out.activity = stripEvidenceFields(task.activity);
214
- if (task.selfCheck !== undefined) out.selfCheck = stripEvidenceFields(task.selfCheck);
219
+ if (!interactivePause) {
220
+ if (task.reviewPersistence !== undefined) out.reviewPersistence = task.reviewPersistence;
221
+ // Activity and self-check are small, bounded summaries the engine produced for
222
+ // exactly this purpose; they are carried whole rather than re-projected here — EXCEPT
223
+ // the fields a wait must never carry whatever depth they arrive at. An engine (or a
224
+ // fixture) that nested a diff or execution prose inside `activity` would otherwise put
225
+ // evidence on the one answer that is supposed to be cheap, so evidence keys are
226
+ // dropped at any depth.
227
+ if (task.activity !== undefined) out.activity = stripEvidenceFields(task.activity);
228
+ if (task.selfCheck !== undefined) out.selfCheck = stripEvidenceFields(task.selfCheck);
229
+ }
215
230
  return out;
216
231
  }
217
232
 
@@ -310,9 +325,11 @@ function instructionFor(reason, facts = {}) {
310
325
  + 'a real drift from the goal. Nothing was cancelled, restarted, resubmitted or re-queued, and this '
311
326
  + 'interval will not be reported again.';
312
327
  }
313
- return 'Nothing has been reported back for the configured no-progress threshold (ten minutes by default) '
314
- + 'while the task is still running. The run may be stuck. Check the current tool and idle time; cancel '
315
- + 'or follow up deliberately rather than assuming completion.';
328
+ return 'Nothing new has been returned to the host for the operator-configured delivery interval in DSH '
329
+ + 'settings (40 minutes by default; internal worker activity does not reset this clock) while the task '
330
+ + 'is still running. This is a progress check, not a verdict that the run is stuck: inspect the current '
331
+ + 'activity and elapsed state, and keep waiting on the same taskId unless you find a concrete error or '
332
+ + 'drift from the goal.';
316
333
  case 'ready':
317
334
  return 'The run ended and is awaiting host review. Read delegate_result for the diff and evidence; '
318
335
  + 'completion is not host acceptance.';
@@ -736,14 +753,16 @@ export async function waitForTask(options) {
736
753
  * @returns {object} compact answer.
737
754
  */
738
755
  function answer(reason, observation, facts = {}) {
739
- const task = compactTask(observation?.task);
756
+ const task = compactTask(observation?.task, {
757
+ interactivePause: reason === 'permission' || reason === 'question',
758
+ });
740
759
  // A resolved interruption carries the state and terminal flag its resolution decided;
741
760
  // every other answer derives them from the reason and the published task.
742
761
  const state = facts.resolved === true
743
762
  ? (facts.resolvedState ?? null)
744
763
  : resolvedTaskState(task, reason);
745
764
  // The repeated-failure diagnostic, when THAT is what the reminder was about. It is
746
- // what lets a host tell "silent for ten minutes" from "kept failing the same call",
765
+ // what lets a host tell the run progress check from "kept failing the same call",
747
766
  // which need different decisions. Only the bounded fields the engine produced travel.
748
767
  const failure = reason === 'attention' && observation?.failure !== null
749
768
  && typeof observation?.failure === 'object'