dsh-taskbridge 1.7.0 → 1.8.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 (75) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +21 -21
  3. package/README.md +150 -289
  4. package/THIRD_PARTY_NOTICES.txt +23 -23
  5. package/antigravity/agents/dsh-taskbridge.md +31 -0
  6. package/antigravity/skills/dsh-taskbridge/SKILL.md +51 -0
  7. package/codex/dsh-taskbridge.toml +170 -627
  8. package/cordis.patch.yml +6 -6
  9. package/docs/INTRODUCTION.md +119 -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 +13 -2
  15. package/docs/contracts-stage-b.md +443 -443
  16. package/docs/plugin-market.md +30 -30
  17. package/docs/redaction-contract.md +170 -170
  18. package/docs/releases/1.7.0.zh.md +11 -11
  19. package/docs/releases/1.8.0.zh.md +16 -0
  20. package/docs/runtime-compatibility.md +1 -1
  21. package/docs/taskbridge-upgrade.md +28 -28
  22. package/docs/taskdispatch-upgrade.md +25 -25
  23. package/docs/workspace-contract.md +538 -538
  24. package/docs/workspace-grouping.md +126 -126
  25. package/icon.svg +1 -1
  26. package/lib/client.d.ts +733 -699
  27. package/lib/client.js +7 -7
  28. package/locale/en.json +1 -1
  29. package/locale/zh.json +1 -1
  30. package/package.json +149 -144
  31. package/src/antigravity/installer.js +1046 -0
  32. package/src/antigravity/seam.js +142 -0
  33. package/src/auth/fence.js +361 -361
  34. package/src/auth/grants.js +789 -789
  35. package/src/client/api.js +143 -0
  36. package/src/client/index.jsx +113 -3
  37. package/src/client/sidebar.jsx +862 -862
  38. package/src/client/styles.js +624 -624
  39. package/src/client/task-cleanup.js +304 -304
  40. package/src/client/task-records-table.jsx +217 -217
  41. package/src/client/task-view.js +307 -307
  42. package/src/client/workspace-groups.js +482 -482
  43. package/src/client/workspaces-browser.jsx +770 -770
  44. package/src/codex/agent-ownership.js +270 -270
  45. package/src/codex/installer.js +6 -0
  46. package/src/codex/toml.js +784 -784
  47. package/src/config/redact.js +245 -245
  48. package/src/config/store.js +186 -186
  49. package/src/credentials/seam.js +202 -202
  50. package/src/http/respond.js +6 -5
  51. package/src/http/user-plane.js +72 -0
  52. package/src/index.js +25 -0
  53. package/src/jobs/diagnostics.js +15 -15
  54. package/src/jobs/plan-store.js +1020 -1020
  55. package/src/jobs/review-note.js +63 -63
  56. package/src/jobs/task-descriptions.js +82 -82
  57. package/src/jobs/task-display.js +73 -73
  58. package/src/jobs/task-tree.js +786 -786
  59. package/src/jobs/title.js +134 -134
  60. package/src/mcp/continuation.js +317 -317
  61. package/src/mcp/server.js +12 -5
  62. package/src/model/connectivity.js +371 -371
  63. package/src/model/discovery.js +582 -582
  64. package/src/model/native-catalog.js +68 -68
  65. package/src/model/openai-adapter.js +671 -671
  66. package/src/model/probe.js +264 -264
  67. package/src/model/providers.js +756 -756
  68. package/src/model/routing.js +321 -321
  69. package/src/runtime/permissions.js +1619 -1619
  70. package/src/runtime/question-call.js +162 -162
  71. package/src/runtime/questions.js +909 -909
  72. package/src/runtime/worker-prompt.js +60 -53
  73. package/src/workspace/audit.js +775 -775
  74. package/src/workspace/preflight.js +424 -424
  75. package/src/workspace/worktrees.js +679 -679
@@ -1,63 +1,63 @@
1
- // The one bound and normalization for a host-review note.
2
- //
3
- // A review note is free prose: Chinese, line breaks and emoji are ordinary in it. That is
4
- // why the bound is counted in Unicode code points — `Array.from(text).length` — rather than
5
- // in UTF-16 units, where an emoji counts twice. The same rule applies at every entry point
6
- // (MCP schema, HTTP route, engine, durable history projection), because a note one layer
7
- // accepts and another cuts is worse than a refusal: the caller would be told "recorded"
8
- // about text that was never recorded.
9
- //
10
- // This module has no imports on purpose: `src/mcp/server.js` is loaded by the standalone
11
- // MCP binary, which must not pull the engine or any native DSH module in through a shared
12
- // constant.
13
-
14
- /** Longest review note, in Unicode code points. */
15
- export const REVIEW_NOTE_MAX_CHARS = 8_000;
16
-
17
- /**
18
- * The normalization applied wherever a note is accepted or stored: surrounding whitespace
19
- * only. The body of the note is preserved exactly.
20
- * @param {unknown} value - candidate note.
21
- * @returns {string} the trimmed note, or '' for a non-string.
22
- */
23
- export function normalizeReviewNote(value) {
24
- return typeof value === 'string' ? value.trim() : '';
25
- }
26
-
27
- /**
28
- * @param {string} value - text to measure.
29
- * @returns {number} length in Unicode code points (0 for a non-string).
30
- */
31
- export function reviewNoteLength(value) {
32
- return typeof value === 'string' ? Array.from(value).length : 0;
33
- }
34
-
35
- /**
36
- * Refusal facts for an over-long note, so every surface reports the same numbers.
37
- * @param {string} value - the rejected note.
38
- * @returns {{ limit: number, length: number, message: string }} bound, actual length, message.
39
- */
40
- export function reviewNoteOverflow(value) {
41
- const length = reviewNoteLength(value);
42
- return {
43
- limit: REVIEW_NOTE_MAX_CHARS,
44
- length,
45
- message: `note must be at most ${REVIEW_NOTE_MAX_CHARS} Unicode code points, but it is ${length}`,
46
- };
47
- }
48
-
49
- /**
50
- * Cut a string to a code-point bound.
51
- *
52
- * Only for a stored value that reached the document some other way (an older build, a
53
- * hand-edited file). An accepted request is REFUSED when it is too long, never shortened.
54
- * @param {unknown} value - candidate text.
55
- * @param {number} [limit] - code points to keep.
56
- * @returns {string | null} bounded text, or null when the value is not a non-empty string.
57
- */
58
- export function truncateCodePoints(value, limit = REVIEW_NOTE_MAX_CHARS) {
59
- if (typeof value !== 'string' || value === '') return null;
60
- const points = Array.from(value);
61
- if (points.length <= limit) return value;
62
- return points.slice(0, limit).join('');
63
- }
1
+ // The one bound and normalization for a host-review note.
2
+ //
3
+ // A review note is free prose: Chinese, line breaks and emoji are ordinary in it. That is
4
+ // why the bound is counted in Unicode code points — `Array.from(text).length` — rather than
5
+ // in UTF-16 units, where an emoji counts twice. The same rule applies at every entry point
6
+ // (MCP schema, HTTP route, engine, durable history projection), because a note one layer
7
+ // accepts and another cuts is worse than a refusal: the caller would be told "recorded"
8
+ // about text that was never recorded.
9
+ //
10
+ // This module has no imports on purpose: `src/mcp/server.js` is loaded by the standalone
11
+ // MCP binary, which must not pull the engine or any native DSH module in through a shared
12
+ // constant.
13
+
14
+ /** Longest review note, in Unicode code points. */
15
+ export const REVIEW_NOTE_MAX_CHARS = 8_000;
16
+
17
+ /**
18
+ * The normalization applied wherever a note is accepted or stored: surrounding whitespace
19
+ * only. The body of the note is preserved exactly.
20
+ * @param {unknown} value - candidate note.
21
+ * @returns {string} the trimmed note, or '' for a non-string.
22
+ */
23
+ export function normalizeReviewNote(value) {
24
+ return typeof value === 'string' ? value.trim() : '';
25
+ }
26
+
27
+ /**
28
+ * @param {string} value - text to measure.
29
+ * @returns {number} length in Unicode code points (0 for a non-string).
30
+ */
31
+ export function reviewNoteLength(value) {
32
+ return typeof value === 'string' ? Array.from(value).length : 0;
33
+ }
34
+
35
+ /**
36
+ * Refusal facts for an over-long note, so every surface reports the same numbers.
37
+ * @param {string} value - the rejected note.
38
+ * @returns {{ limit: number, length: number, message: string }} bound, actual length, message.
39
+ */
40
+ export function reviewNoteOverflow(value) {
41
+ const length = reviewNoteLength(value);
42
+ return {
43
+ limit: REVIEW_NOTE_MAX_CHARS,
44
+ length,
45
+ message: `note must be at most ${REVIEW_NOTE_MAX_CHARS} Unicode code points, but it is ${length}`,
46
+ };
47
+ }
48
+
49
+ /**
50
+ * Cut a string to a code-point bound.
51
+ *
52
+ * Only for a stored value that reached the document some other way (an older build, a
53
+ * hand-edited file). An accepted request is REFUSED when it is too long, never shortened.
54
+ * @param {unknown} value - candidate text.
55
+ * @param {number} [limit] - code points to keep.
56
+ * @returns {string | null} bounded text, or null when the value is not a non-empty string.
57
+ */
58
+ export function truncateCodePoints(value, limit = REVIEW_NOTE_MAX_CHARS) {
59
+ if (typeof value !== 'string' || value === '') return null;
60
+ const points = Array.from(value);
61
+ if (points.length <= limit) return value;
62
+ return points.slice(0, limit).join('');
63
+ }
@@ -1,82 +1,82 @@
1
- // Shared contract for `goalDescription` and `completionSummary`: <= 2000 Unicode code points
2
- // (Chinese, newlines and emoji count once), trimmed, non-strings refused, re-checked post-redaction.
3
-
4
- export const TASK_DESCRIPTION_MAX_CHARS = 2_000;
5
-
6
- export const TASK_DESCRIPTION_FIELDS = Object.freeze({
7
- goal: 'goalDescription',
8
- summary: 'completionSummary',
9
- });
10
-
11
- export function normalizeTaskDescription(value) {
12
- return typeof value === 'string' ? value.trim() : '';
13
- }
14
-
15
- export function taskDescriptionLength(value) {
16
- return typeof value === 'string' ? Array.from(value).length : 0;
17
- }
18
-
19
- /** Build refusal facts naming field, measured code-point length and limit (never echoing text). */
20
- export function taskDescriptionRefusal(field, value, reason) {
21
- const limit = TASK_DESCRIPTION_MAX_CHARS;
22
- const length = taskDescriptionLength(value);
23
- if (reason === 'type') {
24
- return {
25
- field,
26
- limit,
27
- length,
28
- unit: 'unicode-code-points',
29
- message: `${field} must be a string of at most ${limit} Unicode code points`,
30
- };
31
- }
32
- return {
33
- field,
34
- limit,
35
- length,
36
- unit: 'unicode-code-points',
37
- message: `${field} must be at most ${limit} Unicode code points, but it is ${length}`,
38
- };
39
- }
40
-
41
- export function taskDescriptionPresent(value) {
42
- if (value === undefined) return false;
43
- return typeof value === 'string' ? value.trim() !== '' : true;
44
- }
45
-
46
- export function readTaskDescription(value, field) {
47
- if (!taskDescriptionPresent(value)) return { ok: true, value: null, length: 0 };
48
- if (typeof value !== 'string') {
49
- return { ok: false, refusal: taskDescriptionRefusal(field, value, 'type') };
50
- }
51
- const text = value.trim();
52
- if (text === '') return { ok: true, value: null, length: 0 };
53
- const length = taskDescriptionLength(text);
54
- if (length > TASK_DESCRIPTION_MAX_CHARS) {
55
- return { ok: false, refusal: taskDescriptionRefusal(field, text, 'length') };
56
- }
57
- return { ok: true, value: text, length };
58
- }
59
-
60
- /** Canonicalize once: type, trim, inbound bound, redact, and post-redaction bound. */
61
- export function canonicalTaskDescription(value, field, redact) {
62
- const read = readTaskDescription(value, field);
63
- if (read.ok === false) return read;
64
- if (read.value === null) return read;
65
- const masked = typeof redact === 'function' ? redact(read.value) : read.value;
66
- const stored = typeof masked === 'string' ? masked.trim() : '';
67
- if (stored === '') return { ok: true, value: null, length: 0 };
68
- const length = taskDescriptionLength(stored);
69
- if (length > TASK_DESCRIPTION_MAX_CHARS) {
70
- return { ok: false, refusal: taskDescriptionRefusal(field, stored, 'length') };
71
- }
72
- return { ok: true, value: stored, length };
73
- }
74
-
75
- /** Load-only code-point truncation leaving room for a marker without splitting surrogate pairs. */
76
- export function truncateTaskDescription(value, markerChars = 0, limit = TASK_DESCRIPTION_MAX_CHARS) {
77
- if (typeof value !== 'string' || value === '') return null;
78
- const points = Array.from(value);
79
- if (points.length <= limit) return value;
80
- const keep = Math.max(0, limit - Math.max(0, Math.trunc(markerChars)));
81
- return points.slice(0, keep).join('');
82
- }
1
+ // Shared contract for `goalDescription` and `completionSummary`: <= 2000 Unicode code points
2
+ // (Chinese, newlines and emoji count once), trimmed, non-strings refused, re-checked post-redaction.
3
+
4
+ export const TASK_DESCRIPTION_MAX_CHARS = 2_000;
5
+
6
+ export const TASK_DESCRIPTION_FIELDS = Object.freeze({
7
+ goal: 'goalDescription',
8
+ summary: 'completionSummary',
9
+ });
10
+
11
+ export function normalizeTaskDescription(value) {
12
+ return typeof value === 'string' ? value.trim() : '';
13
+ }
14
+
15
+ export function taskDescriptionLength(value) {
16
+ return typeof value === 'string' ? Array.from(value).length : 0;
17
+ }
18
+
19
+ /** Build refusal facts naming field, measured code-point length and limit (never echoing text). */
20
+ export function taskDescriptionRefusal(field, value, reason) {
21
+ const limit = TASK_DESCRIPTION_MAX_CHARS;
22
+ const length = taskDescriptionLength(value);
23
+ if (reason === 'type') {
24
+ return {
25
+ field,
26
+ limit,
27
+ length,
28
+ unit: 'unicode-code-points',
29
+ message: `${field} must be a string of at most ${limit} Unicode code points`,
30
+ };
31
+ }
32
+ return {
33
+ field,
34
+ limit,
35
+ length,
36
+ unit: 'unicode-code-points',
37
+ message: `${field} must be at most ${limit} Unicode code points, but it is ${length}`,
38
+ };
39
+ }
40
+
41
+ export function taskDescriptionPresent(value) {
42
+ if (value === undefined) return false;
43
+ return typeof value === 'string' ? value.trim() !== '' : true;
44
+ }
45
+
46
+ export function readTaskDescription(value, field) {
47
+ if (!taskDescriptionPresent(value)) return { ok: true, value: null, length: 0 };
48
+ if (typeof value !== 'string') {
49
+ return { ok: false, refusal: taskDescriptionRefusal(field, value, 'type') };
50
+ }
51
+ const text = value.trim();
52
+ if (text === '') return { ok: true, value: null, length: 0 };
53
+ const length = taskDescriptionLength(text);
54
+ if (length > TASK_DESCRIPTION_MAX_CHARS) {
55
+ return { ok: false, refusal: taskDescriptionRefusal(field, text, 'length') };
56
+ }
57
+ return { ok: true, value: text, length };
58
+ }
59
+
60
+ /** Canonicalize once: type, trim, inbound bound, redact, and post-redaction bound. */
61
+ export function canonicalTaskDescription(value, field, redact) {
62
+ const read = readTaskDescription(value, field);
63
+ if (read.ok === false) return read;
64
+ if (read.value === null) return read;
65
+ const masked = typeof redact === 'function' ? redact(read.value) : read.value;
66
+ const stored = typeof masked === 'string' ? masked.trim() : '';
67
+ if (stored === '') return { ok: true, value: null, length: 0 };
68
+ const length = taskDescriptionLength(stored);
69
+ if (length > TASK_DESCRIPTION_MAX_CHARS) {
70
+ return { ok: false, refusal: taskDescriptionRefusal(field, stored, 'length') };
71
+ }
72
+ return { ok: true, value: stored, length };
73
+ }
74
+
75
+ /** Load-only code-point truncation leaving room for a marker without splitting surrogate pairs. */
76
+ export function truncateTaskDescription(value, markerChars = 0, limit = TASK_DESCRIPTION_MAX_CHARS) {
77
+ if (typeof value !== 'string' || value === '') return null;
78
+ const points = Array.from(value);
79
+ if (points.length <= limit) return value;
80
+ const keep = Math.max(0, limit - Math.max(0, Math.trunc(markerChars)));
81
+ return points.slice(0, keep).join('');
82
+ }
@@ -1,73 +1,73 @@
1
- import { createHash } from 'node:crypto';
2
- import { JsonDocument } from '../config/store.js';
3
-
4
- const MAX_ARCHIVES = 2048;
5
- const ARCHIVABLE = 'accepted';
6
-
7
- function chainsOf(node) {
8
- return node.kind === 'plan' ? node.executions : [node.chain];
9
- }
10
-
11
- // Hash only the facts that made this subtree eligible. A continuation, a changed
12
- // review or a missing history entry brings the subtree back into the active view.
13
- function activityStamp(node) {
14
- const evidence = [node.nodeId, node.nodeStatus, node.hostAcceptance?.acceptedAt ?? null];
15
- for (const chain of chainsOf(node)) {
16
- evidence.push(chain.rounds.map((round) => [round.taskId, round.state, round.hostAcceptance?.acceptedAt ?? null]));
17
- }
18
- evidence.push(node.children.map(activityStamp));
19
- return createHash('sha256').update(JSON.stringify(evidence)).digest('hex');
20
- }
21
-
22
- export function findDisplayNode(roots, nodeId) {
23
- const remaining = [...roots];
24
- while (remaining.length > 0) {
25
- const node = remaining.pop();
26
- if (node.nodeId === nodeId) return node;
27
- remaining.push(...node.children);
28
- }
29
- return null;
30
- }
31
-
32
- export class TaskDisplayStore extends JsonDocument {
33
- constructor(dataDir) {
34
- super(dataDir, 'task-display.json', {
35
- schemaVersion: 1,
36
- initial: () => ({ schemaVersion: 1, archives: {} }),
37
- });
38
- }
39
-
40
- async project(tree) {
41
- const { archives } = await this.load();
42
- if (!archives || typeof archives !== 'object' || Array.isArray(archives)) throw new Error('invalid display archive');
43
- const hidden = new Set();
44
- const visit = (node) => {
45
- node.displayArchived = node.nodeStatus === ARCHIVABLE
46
- && Object.hasOwn(archives, node.nodeId)
47
- && archives[node.nodeId] === activityStamp(node);
48
- if (node.displayArchived) hidden.add(node.nodeId);
49
- for (const child of node.children) visit(child);
50
- };
51
- for (const root of tree.roots) visit(root);
52
- for (const node of tree.flatNodes) node.displayArchived = hidden.has(node.nodeId);
53
- }
54
-
55
- async setArchived(node, archived, knownIds) {
56
- if (archived && node.nodeStatus !== ARCHIVABLE) return { conflict: 'TASK_DISPLAY_NOT_ACCEPTED' };
57
- let limitReached = false;
58
- await this.commit((draft) => {
59
- if (!draft.archives || typeof draft.archives !== 'object' || Array.isArray(draft.archives)) throw new Error('invalid display archive');
60
- for (const id of Object.keys(draft.archives)) {
61
- if (!knownIds.has(id)) delete draft.archives[id];
62
- }
63
- if (!archived) {
64
- delete draft.archives[node.nodeId];
65
- } else if (Object.hasOwn(draft.archives, node.nodeId) || Object.keys(draft.archives).length < MAX_ARCHIVES) {
66
- Object.defineProperty(draft.archives, node.nodeId, { value: activityStamp(node), enumerable: true, configurable: true, writable: true });
67
- } else {
68
- limitReached = true;
69
- }
70
- });
71
- return limitReached ? { conflict: 'TASK_DISPLAY_LIMIT' } : { archived };
72
- }
73
- }
1
+ import { createHash } from 'node:crypto';
2
+ import { JsonDocument } from '../config/store.js';
3
+
4
+ const MAX_ARCHIVES = 2048;
5
+ const ARCHIVABLE = 'accepted';
6
+
7
+ function chainsOf(node) {
8
+ return node.kind === 'plan' ? node.executions : [node.chain];
9
+ }
10
+
11
+ // Hash only the facts that made this subtree eligible. A continuation, a changed
12
+ // review or a missing history entry brings the subtree back into the active view.
13
+ function activityStamp(node) {
14
+ const evidence = [node.nodeId, node.nodeStatus, node.hostAcceptance?.acceptedAt ?? null];
15
+ for (const chain of chainsOf(node)) {
16
+ evidence.push(chain.rounds.map((round) => [round.taskId, round.state, round.hostAcceptance?.acceptedAt ?? null]));
17
+ }
18
+ evidence.push(node.children.map(activityStamp));
19
+ return createHash('sha256').update(JSON.stringify(evidence)).digest('hex');
20
+ }
21
+
22
+ export function findDisplayNode(roots, nodeId) {
23
+ const remaining = [...roots];
24
+ while (remaining.length > 0) {
25
+ const node = remaining.pop();
26
+ if (node.nodeId === nodeId) return node;
27
+ remaining.push(...node.children);
28
+ }
29
+ return null;
30
+ }
31
+
32
+ export class TaskDisplayStore extends JsonDocument {
33
+ constructor(dataDir) {
34
+ super(dataDir, 'task-display.json', {
35
+ schemaVersion: 1,
36
+ initial: () => ({ schemaVersion: 1, archives: {} }),
37
+ });
38
+ }
39
+
40
+ async project(tree) {
41
+ const { archives } = await this.load();
42
+ if (!archives || typeof archives !== 'object' || Array.isArray(archives)) throw new Error('invalid display archive');
43
+ const hidden = new Set();
44
+ const visit = (node) => {
45
+ node.displayArchived = node.nodeStatus === ARCHIVABLE
46
+ && Object.hasOwn(archives, node.nodeId)
47
+ && archives[node.nodeId] === activityStamp(node);
48
+ if (node.displayArchived) hidden.add(node.nodeId);
49
+ for (const child of node.children) visit(child);
50
+ };
51
+ for (const root of tree.roots) visit(root);
52
+ for (const node of tree.flatNodes) node.displayArchived = hidden.has(node.nodeId);
53
+ }
54
+
55
+ async setArchived(node, archived, knownIds) {
56
+ if (archived && node.nodeStatus !== ARCHIVABLE) return { conflict: 'TASK_DISPLAY_NOT_ACCEPTED' };
57
+ let limitReached = false;
58
+ await this.commit((draft) => {
59
+ if (!draft.archives || typeof draft.archives !== 'object' || Array.isArray(draft.archives)) throw new Error('invalid display archive');
60
+ for (const id of Object.keys(draft.archives)) {
61
+ if (!knownIds.has(id)) delete draft.archives[id];
62
+ }
63
+ if (!archived) {
64
+ delete draft.archives[node.nodeId];
65
+ } else if (Object.hasOwn(draft.archives, node.nodeId) || Object.keys(draft.archives).length < MAX_ARCHIVES) {
66
+ Object.defineProperty(draft.archives, node.nodeId, { value: activityStamp(node), enumerable: true, configurable: true, writable: true });
67
+ } else {
68
+ limitReached = true;
69
+ }
70
+ });
71
+ return limitReached ? { conflict: 'TASK_DISPLAY_LIMIT' } : { archived };
72
+ }
73
+ }