dsh-taskbridge 1.7.1 → 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 +12 -0
  2. package/LICENSE +21 -21
  3. package/README.md +149 -290
  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 -631
  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 +2 -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 +3 -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 +4 -1
  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 -55
  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,162 +1,162 @@
1
- // Which native `ask_user_question` call a pending question belongs to.
2
- //
3
- // An answer is delivered by RESUMING the paused tool call, so the bridge must know exactly
4
- // which call that is. The rule is deliberately narrow, and it never searches for "some"
5
- // call:
6
- //
7
- // 1. the request's own `wait.callId` is the declared identity (the native tool sets it);
8
- // 2. that id must be found in the Session log as a `tool/call` whose name is
9
- // `ask_user_question`;
10
- // 3. it must be the NEWEST such call: a repeated id is the live one, an older duplicate
11
- // is a finished turn;
12
- // 4. it must have NO `tool/result` after it — a call that already returned is history, and
13
- // an answer delivered to it would resume nothing;
14
- // 5. its turn must still be the OPEN turn. A call whose turn closed can only arrive as a
15
- // new turn, so an answer cannot be replayed onto it.
16
- //
17
- // A legacy request that carries no `wait` at all is bound only when the open turn holds
18
- // exactly ONE live `ask_user_question` call: with one candidate the identity is proven, and
19
- // with two it is ambiguous, which is a refusal rather than a guess.
20
-
21
- /** The tool whose calls a question may bind to. */
22
- export const QUESTION_TOOL_NAME = 'ask_user_question';
23
-
24
- /**
25
- * Find one `tool/call` record by id, newest first.
26
- * @param {object} session - Session with `seq` and `eventAt`.
27
- * @param {string} callId - the id to find.
28
- * @returns {{ event: object, index: number } | null} the newest match.
29
- */
30
- function findCall(session, callId) {
31
- for (let index = session.seq - 1; index >= 0; index -= 1) {
32
- const event = session.eventAt(index);
33
- if (event === null || typeof event !== 'object' || event.type !== 'tool/call') continue;
34
- if (event.data?.callId === callId) return { event, index };
35
- }
36
- return null;
37
- }
38
-
39
- /**
40
- * The index of the last `turn/start` with no `turn/end` after it, or `null`.
41
- * @param {object} session - Session with `seq` and `eventAt`.
42
- * @returns {number | null} the open turn's start offset.
43
- */
44
- function openTurnStart(session) {
45
- for (let index = session.seq - 1; index >= 0; index -= 1) {
46
- const event = session.eventAt(index);
47
- if (event === null || typeof event !== 'object') continue;
48
- if (event.type === 'turn/end') return null;
49
- if (event.type === 'turn/start') return index;
50
- }
51
- return null;
52
- }
53
-
54
- /**
55
- * The tool-call id one `tool/result` event answers.
56
- *
57
- * DSH records the id under `data.message.toolCallId` (the result message carries the call it
58
- * belongs to); older/synthetic logs put it directly on `data.callId`. BOTH are read, because a
59
- * matcher that only knew one shape would report "no result yet" for a call that already
60
- * returned — and an answer would then be delivered to a finished call.
61
- * @param {object} event - a `tool/result` event.
62
- * @returns {string | null} the call id, or null when the event names none.
63
- */
64
- function resultCallId(event) {
65
- const nested = event?.data?.message?.toolCallId;
66
- if (typeof nested === 'string' && nested !== '') return nested;
67
- const flat = event?.data?.callId;
68
- if (typeof flat === 'string' && flat !== '') return flat;
69
- return null;
70
- }
71
-
72
- /**
73
- * Whether a call at one offset has already produced a `tool/result`.
74
- * @param {object} session - Session with `seq` and `eventAt`.
75
- * @param {string} callId - the call id.
76
- * @param {number} fromIndex - the call's own offset.
77
- * @returns {boolean} true when a result was recorded after it.
78
- */
79
- function hasResult(session, callId, fromIndex) {
80
- for (let index = fromIndex + 1; index < session.seq; index += 1) {
81
- const event = session.eventAt(index);
82
- if (event === null || typeof event !== 'object' || event.type !== 'tool/result') continue;
83
- if (resultCallId(event) === callId) return true;
84
- }
85
- return false;
86
- }
87
-
88
- /**
89
- * The live `ask_user_question` calls of the OPEN turn, oldest first.
90
- * @param {object} session - Session with `seq` and `eventAt`.
91
- * @param {number} turnStart - the open turn's start offset.
92
- * @returns {{ callId: string, seq: number, turn: number | null }[]} live calls.
93
- */
94
- function liveCallsOfTurn(session, turnStart) {
95
- const calls = [];
96
- for (let index = turnStart; index < session.seq; index += 1) {
97
- const event = session.eventAt(index);
98
- if (event === null || typeof event !== 'object' || event.type !== 'tool/call') continue;
99
- const name = event.data?.name;
100
- const callId = event.data?.callId;
101
- if (name !== QUESTION_TOOL_NAME || typeof callId !== 'string' || callId === '') continue;
102
- if (hasResult(session, callId, index)) continue;
103
- calls.push({
104
- callId,
105
- seq: index,
106
- turn: typeof event.data?.turn === 'number' ? event.data.turn : null,
107
- });
108
- }
109
- return calls;
110
- }
111
-
112
- /**
113
- * Resolve the ONE native call a question belongs to.
114
- * @param {object} request - `session`, `declaredCallId` (from `request.wait.callId`), `toolName`.
115
- * @returns {{ ok: true, callId: string, seq: number, turn: number | null }
116
- * | { ok: false, detail: string }} the binding, or why it is impossible.
117
- */
118
- export function QUESTION_CALL_BINDING(request) {
119
- const session = request?.session ?? null;
120
- if (session === null || typeof session !== 'object'
121
- || typeof session.eventAt !== 'function' || !Number.isInteger(session.seq)) {
122
- return { ok: false, detail: 'the asking session keeps no readable log' };
123
- }
124
- const turnStart = openTurnStart(session);
125
- if (turnStart === null) {
126
- return { ok: false, detail: 'no turn is open, so the question belongs to no live call' };
127
- }
128
- const declared = typeof request?.declaredCallId === 'string' && request.declaredCallId !== ''
129
- ? request.declaredCallId
130
- : null;
131
- if (declared !== null) {
132
- const found = findCall(session, declared);
133
- if (found === null) return { ok: false, detail: 'the declared call id is not in the session log' };
134
- const name = found.event.data?.name;
135
- if (name !== QUESTION_TOOL_NAME) {
136
- return { ok: false, detail: `the declared call is a ${String(name)} call, not a question` };
137
- }
138
- if (found.index < turnStart) {
139
- return { ok: false, detail: 'the declared call belongs to an earlier turn' };
140
- }
141
- if (hasResult(session, declared, found.index)) {
142
- return { ok: false, detail: 'the declared call already produced a result' };
143
- }
144
- return {
145
- ok: true,
146
- callId: declared,
147
- seq: found.index,
148
- turn: typeof found.event.data?.turn === 'number' ? found.event.data.turn : null,
149
- };
150
- }
151
- // A legacy request names no call. It is bound only when the open turn holds exactly ONE
152
- // live question call: two candidates make the identity ambiguous, and a guess could
153
- // resume the wrong operation.
154
- const candidates = liveCallsOfTurn(session, turnStart);
155
- if (candidates.length === 0) {
156
- return { ok: false, detail: 'the open turn holds no live question call' };
157
- }
158
- if (candidates.length > 1) {
159
- return { ok: false, detail: `the open turn holds ${candidates.length} live question calls, so the binding is ambiguous` };
160
- }
161
- return { ok: true, ...candidates[0] };
162
- }
1
+ // Which native `ask_user_question` call a pending question belongs to.
2
+ //
3
+ // An answer is delivered by RESUMING the paused tool call, so the bridge must know exactly
4
+ // which call that is. The rule is deliberately narrow, and it never searches for "some"
5
+ // call:
6
+ //
7
+ // 1. the request's own `wait.callId` is the declared identity (the native tool sets it);
8
+ // 2. that id must be found in the Session log as a `tool/call` whose name is
9
+ // `ask_user_question`;
10
+ // 3. it must be the NEWEST such call: a repeated id is the live one, an older duplicate
11
+ // is a finished turn;
12
+ // 4. it must have NO `tool/result` after it — a call that already returned is history, and
13
+ // an answer delivered to it would resume nothing;
14
+ // 5. its turn must still be the OPEN turn. A call whose turn closed can only arrive as a
15
+ // new turn, so an answer cannot be replayed onto it.
16
+ //
17
+ // A legacy request that carries no `wait` at all is bound only when the open turn holds
18
+ // exactly ONE live `ask_user_question` call: with one candidate the identity is proven, and
19
+ // with two it is ambiguous, which is a refusal rather than a guess.
20
+
21
+ /** The tool whose calls a question may bind to. */
22
+ export const QUESTION_TOOL_NAME = 'ask_user_question';
23
+
24
+ /**
25
+ * Find one `tool/call` record by id, newest first.
26
+ * @param {object} session - Session with `seq` and `eventAt`.
27
+ * @param {string} callId - the id to find.
28
+ * @returns {{ event: object, index: number } | null} the newest match.
29
+ */
30
+ function findCall(session, callId) {
31
+ for (let index = session.seq - 1; index >= 0; index -= 1) {
32
+ const event = session.eventAt(index);
33
+ if (event === null || typeof event !== 'object' || event.type !== 'tool/call') continue;
34
+ if (event.data?.callId === callId) return { event, index };
35
+ }
36
+ return null;
37
+ }
38
+
39
+ /**
40
+ * The index of the last `turn/start` with no `turn/end` after it, or `null`.
41
+ * @param {object} session - Session with `seq` and `eventAt`.
42
+ * @returns {number | null} the open turn's start offset.
43
+ */
44
+ function openTurnStart(session) {
45
+ for (let index = session.seq - 1; index >= 0; index -= 1) {
46
+ const event = session.eventAt(index);
47
+ if (event === null || typeof event !== 'object') continue;
48
+ if (event.type === 'turn/end') return null;
49
+ if (event.type === 'turn/start') return index;
50
+ }
51
+ return null;
52
+ }
53
+
54
+ /**
55
+ * The tool-call id one `tool/result` event answers.
56
+ *
57
+ * DSH records the id under `data.message.toolCallId` (the result message carries the call it
58
+ * belongs to); older/synthetic logs put it directly on `data.callId`. BOTH are read, because a
59
+ * matcher that only knew one shape would report "no result yet" for a call that already
60
+ * returned — and an answer would then be delivered to a finished call.
61
+ * @param {object} event - a `tool/result` event.
62
+ * @returns {string | null} the call id, or null when the event names none.
63
+ */
64
+ function resultCallId(event) {
65
+ const nested = event?.data?.message?.toolCallId;
66
+ if (typeof nested === 'string' && nested !== '') return nested;
67
+ const flat = event?.data?.callId;
68
+ if (typeof flat === 'string' && flat !== '') return flat;
69
+ return null;
70
+ }
71
+
72
+ /**
73
+ * Whether a call at one offset has already produced a `tool/result`.
74
+ * @param {object} session - Session with `seq` and `eventAt`.
75
+ * @param {string} callId - the call id.
76
+ * @param {number} fromIndex - the call's own offset.
77
+ * @returns {boolean} true when a result was recorded after it.
78
+ */
79
+ function hasResult(session, callId, fromIndex) {
80
+ for (let index = fromIndex + 1; index < session.seq; index += 1) {
81
+ const event = session.eventAt(index);
82
+ if (event === null || typeof event !== 'object' || event.type !== 'tool/result') continue;
83
+ if (resultCallId(event) === callId) return true;
84
+ }
85
+ return false;
86
+ }
87
+
88
+ /**
89
+ * The live `ask_user_question` calls of the OPEN turn, oldest first.
90
+ * @param {object} session - Session with `seq` and `eventAt`.
91
+ * @param {number} turnStart - the open turn's start offset.
92
+ * @returns {{ callId: string, seq: number, turn: number | null }[]} live calls.
93
+ */
94
+ function liveCallsOfTurn(session, turnStart) {
95
+ const calls = [];
96
+ for (let index = turnStart; index < session.seq; index += 1) {
97
+ const event = session.eventAt(index);
98
+ if (event === null || typeof event !== 'object' || event.type !== 'tool/call') continue;
99
+ const name = event.data?.name;
100
+ const callId = event.data?.callId;
101
+ if (name !== QUESTION_TOOL_NAME || typeof callId !== 'string' || callId === '') continue;
102
+ if (hasResult(session, callId, index)) continue;
103
+ calls.push({
104
+ callId,
105
+ seq: index,
106
+ turn: typeof event.data?.turn === 'number' ? event.data.turn : null,
107
+ });
108
+ }
109
+ return calls;
110
+ }
111
+
112
+ /**
113
+ * Resolve the ONE native call a question belongs to.
114
+ * @param {object} request - `session`, `declaredCallId` (from `request.wait.callId`), `toolName`.
115
+ * @returns {{ ok: true, callId: string, seq: number, turn: number | null }
116
+ * | { ok: false, detail: string }} the binding, or why it is impossible.
117
+ */
118
+ export function QUESTION_CALL_BINDING(request) {
119
+ const session = request?.session ?? null;
120
+ if (session === null || typeof session !== 'object'
121
+ || typeof session.eventAt !== 'function' || !Number.isInteger(session.seq)) {
122
+ return { ok: false, detail: 'the asking session keeps no readable log' };
123
+ }
124
+ const turnStart = openTurnStart(session);
125
+ if (turnStart === null) {
126
+ return { ok: false, detail: 'no turn is open, so the question belongs to no live call' };
127
+ }
128
+ const declared = typeof request?.declaredCallId === 'string' && request.declaredCallId !== ''
129
+ ? request.declaredCallId
130
+ : null;
131
+ if (declared !== null) {
132
+ const found = findCall(session, declared);
133
+ if (found === null) return { ok: false, detail: 'the declared call id is not in the session log' };
134
+ const name = found.event.data?.name;
135
+ if (name !== QUESTION_TOOL_NAME) {
136
+ return { ok: false, detail: `the declared call is a ${String(name)} call, not a question` };
137
+ }
138
+ if (found.index < turnStart) {
139
+ return { ok: false, detail: 'the declared call belongs to an earlier turn' };
140
+ }
141
+ if (hasResult(session, declared, found.index)) {
142
+ return { ok: false, detail: 'the declared call already produced a result' };
143
+ }
144
+ return {
145
+ ok: true,
146
+ callId: declared,
147
+ seq: found.index,
148
+ turn: typeof found.event.data?.turn === 'number' ? found.event.data.turn : null,
149
+ };
150
+ }
151
+ // A legacy request names no call. It is bound only when the open turn holds exactly ONE
152
+ // live question call: two candidates make the identity ambiguous, and a guess could
153
+ // resume the wrong operation.
154
+ const candidates = liveCallsOfTurn(session, turnStart);
155
+ if (candidates.length === 0) {
156
+ return { ok: false, detail: 'the open turn holds no live question call' };
157
+ }
158
+ if (candidates.length > 1) {
159
+ return { ok: false, detail: `the open turn holds ${candidates.length} live question calls, so the binding is ambiguous` };
160
+ }
161
+ return { ok: true, ...candidates[0] };
162
+ }