dsh-coding 0.0.1 → 0.1.1-rc2
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.
- package/AGENTS.md +80 -0
- package/LICENSE +21 -21
- package/README.md +120 -54
- package/cordis.patch.yml +274 -4
- package/docs/CHANGELOG.md +47 -0
- package/docs/DETAIL.md +272 -0
- package/icon.svg +6 -6
- package/lib/apply-patch.js +268 -0
- package/lib/client/capsule.js +120 -0
- package/lib/client/card.js +308 -0
- package/lib/client/command-row.js +76 -0
- package/lib/client/config-page.js +392 -0
- package/lib/client/definition.js +164 -0
- package/lib/client/index.js +129 -0
- package/lib/client/locales.js +170 -0
- package/lib/client/mode-picker.js +77 -0
- package/lib/client/styles.js +283 -0
- package/lib/client.js +1802 -0
- package/lib/coding-projection.js +349 -0
- package/lib/config.js +218 -0
- package/lib/contract.js +138 -0
- package/lib/editor.js +23 -0
- package/lib/failures.js +142 -0
- package/lib/handoff.js +347 -0
- package/lib/index.js +110 -7
- package/lib/language.js +136 -0
- package/lib/memory.js +336 -0
- package/lib/messages.js +43 -0
- package/lib/models.js +154 -0
- package/lib/patch.js +235 -0
- package/lib/preset.js +1552 -0
- package/lib/reasoning-levels.js +28 -0
- package/lib/reasoning-projection.js +178 -0
- package/lib/reasoning.js +585 -0
- package/lib/stages.js +344 -0
- package/lib/state.js +585 -0
- package/lib/system-language.js +56 -0
- package/lib/types/apply-patch.d.ts +13 -0
- package/lib/types/client/capsule.d.ts +9 -0
- package/lib/types/client/card.d.ts +76 -0
- package/lib/types/client/command-row.d.ts +42 -0
- package/lib/types/client/config-page.d.ts +136 -0
- package/lib/types/client/definition.d.ts +51 -0
- package/lib/types/client/index.d.ts +10 -0
- package/lib/types/client/locales.d.ts +18 -0
- package/lib/types/client/mode-picker.d.ts +25 -0
- package/lib/types/client/styles.d.ts +28 -0
- package/lib/types/coding-projection.d.ts +116 -0
- package/lib/types/config.d.ts +208 -0
- package/lib/types/contract.d.ts +33 -0
- package/lib/types/editor.d.ts +9 -0
- package/lib/types/failures.d.ts +62 -0
- package/lib/types/handoff.d.ts +132 -0
- package/lib/types/index.d.ts +150 -0
- package/lib/types/language.d.ts +56 -0
- package/lib/types/memory.d.ts +71 -0
- package/lib/types/messages.d.ts +27 -0
- package/lib/types/models.d.ts +82 -0
- package/lib/types/patch.d.ts +37 -0
- package/lib/types/preset.d.ts +22 -0
- package/lib/types/reasoning-levels.d.ts +20 -0
- package/lib/types/reasoning-projection.d.ts +64 -0
- package/lib/types/reasoning.d.ts +141 -0
- package/lib/types/stages.d.ts +193 -0
- package/lib/types/state.d.ts +273 -0
- package/lib/types/system-language.d.ts +10 -0
- package/lib/types/verification-tool.d.ts +32 -0
- package/lib/types/verification.d.ts +77 -0
- package/lib/types/verifier.d.ts +9 -0
- package/lib/types/volatile.d.ts +17 -0
- package/lib/verification-tool.js +176 -0
- package/lib/verification.js +337 -0
- package/lib/verifier.js +25 -0
- package/lib/volatile.js +20 -0
- package/locale/en.json +3 -2
- package/locale/zh.json +3 -2
- package/package.json +84 -9
- package/lib/index.d.ts +0 -11
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Codex-compatible `apply_patch` tool for DSH.
|
|
3
|
+
*
|
|
4
|
+
* It resolves every file first, computes every hunk, then writes. That keeps a
|
|
5
|
+
* stale or ambiguous patch from leaving a half-edited tree behind and gives the
|
|
6
|
+
* model one clear A/M/D summary.
|
|
7
|
+
*/
|
|
8
|
+
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
9
|
+
import { APPLY_PATCH_DESCRIPTION, applyHunks, parsePatch, } from './patch.js';
|
|
10
|
+
function fail(message) {
|
|
11
|
+
throw new Error(`apply_patch: ${message}`);
|
|
12
|
+
}
|
|
13
|
+
/** Preset children can sit above Host services; the agent scope sees more. */
|
|
14
|
+
function scopesOf(ctx, exec) {
|
|
15
|
+
return [exec?.agent?.ctx, ctx].filter((scope) => scope !== undefined);
|
|
16
|
+
}
|
|
17
|
+
function serviceOf(ctx, exec, name) {
|
|
18
|
+
for (const scope of scopesOf(ctx, exec)) {
|
|
19
|
+
try {
|
|
20
|
+
const service = scope.get?.(name) ?? scope[name];
|
|
21
|
+
if (service !== undefined)
|
|
22
|
+
return service;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// Try the next scope.
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
function fsOf(ctx, exec) {
|
|
31
|
+
return serviceOf(ctx, exec, 'fs');
|
|
32
|
+
}
|
|
33
|
+
async function sessionCwd(ctx, exec) {
|
|
34
|
+
const workingDirectory = serviceOf(ctx, exec, 'workingDirectory');
|
|
35
|
+
if (exec.agent !== undefined && typeof workingDirectory?.ensure === 'function') {
|
|
36
|
+
try {
|
|
37
|
+
const value = await workingDirectory.ensure(exec.agent, exec.signal);
|
|
38
|
+
if (typeof value === 'string' && value !== '')
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// The session header remains the fallback.
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const cwd = exec.agent?.session?.header?.cwd;
|
|
46
|
+
return typeof cwd === 'string' && cwd !== '' ? cwd : undefined;
|
|
47
|
+
}
|
|
48
|
+
function sandboxPolicyOf(ctx, exec) {
|
|
49
|
+
const service = serviceOf(ctx, exec, 'sandboxPolicy');
|
|
50
|
+
if (typeof service?.resolve !== 'function')
|
|
51
|
+
return undefined;
|
|
52
|
+
try {
|
|
53
|
+
return service.resolve(exec.agent === undefined ? {} : { session: exec.agent.session });
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function resolveTarget(fs, path, cwd, signal) {
|
|
60
|
+
return fs.resolve(path, {
|
|
61
|
+
...(cwd === undefined ? {} : { cwd }),
|
|
62
|
+
signal,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
async function statFile(fs, target, signal) {
|
|
66
|
+
const info = await fs.stat(target, signal);
|
|
67
|
+
if (info === undefined)
|
|
68
|
+
fail(`file not found: ${target.displayPath}`);
|
|
69
|
+
if (info.type !== 'file')
|
|
70
|
+
fail(`not a regular file: ${target.displayPath}`);
|
|
71
|
+
return info;
|
|
72
|
+
}
|
|
73
|
+
function observe(ctx, target, observation, exec) {
|
|
74
|
+
if (typeof ctx.emit === 'function')
|
|
75
|
+
ctx.emit('fs/observed', target, observation, exec);
|
|
76
|
+
}
|
|
77
|
+
async function intentFor(ctx, target, fallback, exec) {
|
|
78
|
+
if (typeof ctx.waterfall !== 'function')
|
|
79
|
+
return fallback;
|
|
80
|
+
const intent = await ctx.waterfall('fs/write-intent', target, exec, () => fallback);
|
|
81
|
+
return intent ?? fallback;
|
|
82
|
+
}
|
|
83
|
+
async function planPatches(ctx, fs, files, exec, cwd, policy) {
|
|
84
|
+
const plans = [];
|
|
85
|
+
for (const file of files) {
|
|
86
|
+
const target = await resolveTarget(fs, file.path, cwd, exec.signal);
|
|
87
|
+
if (file.kind === 'add') {
|
|
88
|
+
if (await fs.stat(target, exec.signal) !== undefined) {
|
|
89
|
+
fail(`file already exists: ${target.displayPath}`);
|
|
90
|
+
}
|
|
91
|
+
observe(ctx, target, { kind: 'absent' }, exec);
|
|
92
|
+
plans.push({ kind: 'add', path: file.path, target, content: file.content, policy });
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const info = await statFile(fs, target, exec.signal);
|
|
96
|
+
observe(ctx, target, { kind: 'present', version: info.version }, exec);
|
|
97
|
+
if (file.kind === 'delete') {
|
|
98
|
+
if (typeof fs.deleteFile !== 'function') {
|
|
99
|
+
fail(`deleting files is not supported by the configured filesystem; delete ${target.displayPath} another way`);
|
|
100
|
+
}
|
|
101
|
+
plans.push({ kind: 'delete', path: file.path, target, version: info.version, policy });
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const original = await fs.readText(target, exec.signal);
|
|
105
|
+
const content = file.hunks.length === 0 ? original : applyHunks(original, file.hunks, file.path);
|
|
106
|
+
if (file.moveTo === undefined) {
|
|
107
|
+
plans.push({ kind: 'update', path: file.path, target, version: info.version, content, policy });
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const destination = await resolveTarget(fs, file.moveTo, cwd, exec.signal);
|
|
111
|
+
if (destination.targetKey === target.targetKey) {
|
|
112
|
+
plans.push({
|
|
113
|
+
kind: 'update',
|
|
114
|
+
path: file.path,
|
|
115
|
+
target,
|
|
116
|
+
version: info.version,
|
|
117
|
+
content,
|
|
118
|
+
moveTo: file.moveTo,
|
|
119
|
+
policy,
|
|
120
|
+
});
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (await fs.stat(destination, exec.signal) !== undefined) {
|
|
124
|
+
fail(`move destination already exists: ${destination.displayPath}`);
|
|
125
|
+
}
|
|
126
|
+
observe(ctx, destination, { kind: 'absent' }, exec);
|
|
127
|
+
plans.push({
|
|
128
|
+
kind: 'move',
|
|
129
|
+
path: file.path,
|
|
130
|
+
target,
|
|
131
|
+
version: info.version,
|
|
132
|
+
content,
|
|
133
|
+
destination,
|
|
134
|
+
moveTo: file.moveTo,
|
|
135
|
+
policy,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return plans;
|
|
139
|
+
}
|
|
140
|
+
async function writePlans(ctx, fs, plans, exec) {
|
|
141
|
+
const applied = [];
|
|
142
|
+
try {
|
|
143
|
+
for (const plan of plans) {
|
|
144
|
+
if (plan.kind === 'add') {
|
|
145
|
+
const intent = await intentFor(ctx, plan.target, { kind: 'createIfAbsent' }, exec);
|
|
146
|
+
const outcome = await fs.writeText(plan.target, plan.content, intent, exec.signal, plan.policy);
|
|
147
|
+
observe(ctx, plan.target, { kind: 'present', version: outcome.version }, exec);
|
|
148
|
+
applied.push({ path: plan.path, operation: 'created' });
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (plan.kind === 'update') {
|
|
152
|
+
const intent = await intentFor(ctx, plan.target, { kind: 'replaceIfVersion', version: plan.version }, exec);
|
|
153
|
+
const outcome = await fs.writeText(plan.target, plan.content, intent, exec.signal, plan.policy);
|
|
154
|
+
observe(ctx, plan.target, { kind: 'present', version: outcome.version }, exec);
|
|
155
|
+
applied.push({
|
|
156
|
+
path: plan.path,
|
|
157
|
+
operation: 'updated',
|
|
158
|
+
...(plan.moveTo === undefined ? {} : { moveTo: plan.moveTo }),
|
|
159
|
+
});
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
if (plan.kind === 'delete') {
|
|
163
|
+
if (typeof fs.deleteFile !== 'function')
|
|
164
|
+
fail('the filesystem no longer supports deletion');
|
|
165
|
+
await fs.deleteFile(plan.target, { version: plan.version }, exec.signal, plan.policy);
|
|
166
|
+
observe(ctx, plan.target, { kind: 'absent' }, exec);
|
|
167
|
+
applied.push({ path: plan.path, operation: 'deleted' });
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
if (typeof fs.deleteFile !== 'function')
|
|
171
|
+
fail('the filesystem no longer supports deletion');
|
|
172
|
+
const intent = await intentFor(ctx, plan.destination, { kind: 'createIfAbsent' }, exec);
|
|
173
|
+
const outcome = await fs.writeText(plan.destination, plan.content, intent, exec.signal, plan.policy);
|
|
174
|
+
observe(ctx, plan.destination, { kind: 'present', version: outcome.version }, exec);
|
|
175
|
+
await fs.deleteFile(plan.target, { version: plan.version }, exec.signal, plan.policy);
|
|
176
|
+
observe(ctx, plan.target, { kind: 'absent' }, exec);
|
|
177
|
+
applied.push({ path: plan.path, operation: 'moved', moveTo: plan.moveTo });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
const done = applied.map((file) => `${file.operation} ${file.path}`).join(', ');
|
|
182
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
183
|
+
const text = message.startsWith('apply_patch:') ? message : `apply_patch: ${message}`;
|
|
184
|
+
throw new Error(done === '' ? text : `${text}; already applied: ${done}`);
|
|
185
|
+
}
|
|
186
|
+
return { files: applied };
|
|
187
|
+
}
|
|
188
|
+
/** Parse and apply one Codex-format patch. Exported for focused tests. */
|
|
189
|
+
export async function applyPatchInput(ctx, input, exec) {
|
|
190
|
+
const fs = fsOf(ctx, exec);
|
|
191
|
+
if (fs === undefined)
|
|
192
|
+
fail('the filesystem capability is unavailable');
|
|
193
|
+
const files = parsePatch(input);
|
|
194
|
+
const cwd = await sessionCwd(ctx, exec);
|
|
195
|
+
const policy = sandboxPolicyOf(ctx, exec);
|
|
196
|
+
if (fs.sandboxMode !== undefined && policy === undefined) {
|
|
197
|
+
fail('the sandbox policy service is required for a confined filesystem');
|
|
198
|
+
}
|
|
199
|
+
const plans = await planPatches(ctx, fs, files, exec, cwd, policy);
|
|
200
|
+
return writePlans(ctx, fs, plans, exec);
|
|
201
|
+
}
|
|
202
|
+
export function renderPatchResult(value) {
|
|
203
|
+
const lines = value.files.map((file) => {
|
|
204
|
+
const letter = file.operation === 'created'
|
|
205
|
+
? 'A'
|
|
206
|
+
: file.operation === 'deleted'
|
|
207
|
+
? 'D'
|
|
208
|
+
: 'M';
|
|
209
|
+
const path = file.operation === 'moved'
|
|
210
|
+
? `${file.path} -> ${file.moveTo ?? file.path}`
|
|
211
|
+
: file.path;
|
|
212
|
+
return `${letter} ${path}`;
|
|
213
|
+
});
|
|
214
|
+
return `Success. Updated the following files:\n${lines.join('\n')}\n`;
|
|
215
|
+
}
|
|
216
|
+
/** Register `apply_patch` in an agent scope that has the filesystem service. */
|
|
217
|
+
export function registerApplyPatch(ctx, enabled = () => true) {
|
|
218
|
+
if (typeof ctx?.tools?.register !== 'function')
|
|
219
|
+
return;
|
|
220
|
+
ctx.tools.register(defineTool({
|
|
221
|
+
name: 'apply_patch',
|
|
222
|
+
description: APPLY_PATCH_DESCRIPTION,
|
|
223
|
+
parameters: {
|
|
224
|
+
input: {
|
|
225
|
+
type: 'string',
|
|
226
|
+
required: true,
|
|
227
|
+
description: 'The complete patch text, from "*** Begin Patch" through "*** End Patch".',
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
output: {
|
|
231
|
+
schema: {
|
|
232
|
+
type: 'object',
|
|
233
|
+
additionalProperties: false,
|
|
234
|
+
properties: {
|
|
235
|
+
files: {
|
|
236
|
+
type: 'array',
|
|
237
|
+
required: true,
|
|
238
|
+
items: {
|
|
239
|
+
type: 'object',
|
|
240
|
+
additionalProperties: false,
|
|
241
|
+
properties: {
|
|
242
|
+
path: { type: 'string', required: true },
|
|
243
|
+
operation: {
|
|
244
|
+
type: 'string',
|
|
245
|
+
required: true,
|
|
246
|
+
enum: ['created', 'updated', 'deleted', 'moved'],
|
|
247
|
+
},
|
|
248
|
+
moveTo: { type: 'string' },
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
render: (_args, value) => [{
|
|
255
|
+
type: 'text',
|
|
256
|
+
text: renderPatchResult(value),
|
|
257
|
+
}],
|
|
258
|
+
},
|
|
259
|
+
async execute(args, exec) {
|
|
260
|
+
if (!enabled())
|
|
261
|
+
throw new Error('apply_patch: disabled by Coding settings');
|
|
262
|
+
if (typeof args?.input !== 'string' || args.input.trim() === '') {
|
|
263
|
+
throw new Error('apply_patch: input must be a non-empty patch string');
|
|
264
|
+
}
|
|
265
|
+
return applyPatchInput(ctx, args.input, exec);
|
|
266
|
+
},
|
|
267
|
+
}));
|
|
268
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage capsule rendered in the Chat flow at each Coding tool call.
|
|
3
|
+
*
|
|
4
|
+
* It shows the state the runtime recorded — mode, stage path, verification,
|
|
5
|
+
* plan, worker, pending call, refusal — and nothing else. There is no control
|
|
6
|
+
* here: mode and stage changes re-enter the agent through `/coding`, which
|
|
7
|
+
* delivers them with `agent.followup()` / `agent.steer()`.
|
|
8
|
+
*
|
|
9
|
+
* The capsule is one plain status line at DSH's caption size; it deliberately
|
|
10
|
+
* avoids chips, pills, and custom colors, and uses only the shipped classes
|
|
11
|
+
* from `./styles.ts`.
|
|
12
|
+
*
|
|
13
|
+
* @module dsh-coding/client/capsule
|
|
14
|
+
*/
|
|
15
|
+
import { createElement as h, memo } from 'react';
|
|
16
|
+
/** The forward stage order every capsule renders against. */
|
|
17
|
+
const ALL_STAGES = ['requirements', 'plan', 'implement', 'verify', 'deliver'];
|
|
18
|
+
/**
|
|
19
|
+
* One turn's Coding stage capsule.
|
|
20
|
+
* @param props - Chat renderer props and the `dsh-coding` translate seat.
|
|
21
|
+
*/
|
|
22
|
+
export const CodingStageCapsule = memo(function CodingStageCapsule({ node, t }) {
|
|
23
|
+
const data = node.data;
|
|
24
|
+
const checkpoint = data.checkpoint;
|
|
25
|
+
const admitted = checkpoint?.allowedStages ?? ALL_STAGES;
|
|
26
|
+
const activeIndex = admitted.indexOf(data.stage);
|
|
27
|
+
const children = [
|
|
28
|
+
h('span', {
|
|
29
|
+
key: 'mode',
|
|
30
|
+
className: 'dsh-coding-faint',
|
|
31
|
+
'data-mode': data.mode,
|
|
32
|
+
// The card owns switching; the capsule only states the current mode.
|
|
33
|
+
title: t('hint.mode'),
|
|
34
|
+
}, t(`mode.${data.mode}`)),
|
|
35
|
+
h('span', { key: 'mode-sep', className: 'dsh-coding-faint', 'aria-hidden': 'true' }, '·'),
|
|
36
|
+
];
|
|
37
|
+
for (const [index, stage] of ALL_STAGES.entries()) {
|
|
38
|
+
if (index > 0) {
|
|
39
|
+
children.push(h('span', { key: `arrow-${stage}`, className: 'dsh-coding-arrow', 'aria-hidden': 'true' }, '→'));
|
|
40
|
+
}
|
|
41
|
+
const stageIndex = admitted.indexOf(stage);
|
|
42
|
+
const isActive = stage === data.stage;
|
|
43
|
+
children.push(h('span', {
|
|
44
|
+
key: stage,
|
|
45
|
+
className: 'dsh-coding-stage',
|
|
46
|
+
'data-stage': stage,
|
|
47
|
+
...isActive ? { 'data-active': 'true', 'data-current': 'true' } : {},
|
|
48
|
+
...stageIndex >= 0 && activeIndex >= 0 && stageIndex < activeIndex ? { 'data-done': 'true' } : {},
|
|
49
|
+
}, t(`stage.${stage}`)));
|
|
50
|
+
}
|
|
51
|
+
const verification = checkpoint?.verification;
|
|
52
|
+
children.push(h('span', { key: 'verify-sep', className: 'dsh-coding-faint', 'aria-hidden': 'true' }, '·'));
|
|
53
|
+
if (verification !== undefined) {
|
|
54
|
+
children.push(h('span', {
|
|
55
|
+
key: 'verification',
|
|
56
|
+
className: verification.passed ? 'dsh-coding-success' : 'dsh-coding-warn',
|
|
57
|
+
title: verification.command,
|
|
58
|
+
'data-verification': verification.passed ? 'passed' : 'failed',
|
|
59
|
+
}, t(verification.passed ? 'verification.passed' : 'verification.failed')));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
children.push(h('span', {
|
|
63
|
+
key: 'verification',
|
|
64
|
+
className: 'dsh-coding-faint',
|
|
65
|
+
'data-verification': 'none',
|
|
66
|
+
}, t('verification.none')));
|
|
67
|
+
}
|
|
68
|
+
if (checkpoint !== undefined && checkpoint.planItems > 0) {
|
|
69
|
+
const done = checkpoint.planItems - checkpoint.openPlanItems;
|
|
70
|
+
children.push(h('span', {
|
|
71
|
+
key: 'plan',
|
|
72
|
+
className: 'dsh-coding-muted',
|
|
73
|
+
'data-plan': String(checkpoint.planItems),
|
|
74
|
+
}, t('plan.progress', { done, total: checkpoint.planItems })));
|
|
75
|
+
}
|
|
76
|
+
if (checkpoint !== undefined && checkpoint.edits > 0) {
|
|
77
|
+
children.push(h('span', {
|
|
78
|
+
key: 'files',
|
|
79
|
+
className: 'dsh-coding-muted',
|
|
80
|
+
}, t('files', { count: checkpoint.edits })));
|
|
81
|
+
}
|
|
82
|
+
const worker = checkpoint?.worker;
|
|
83
|
+
if (worker !== undefined) {
|
|
84
|
+
const label = worker.status === 'running'
|
|
85
|
+
? 'worker.running'
|
|
86
|
+
: worker.status === 'completed' ? 'worker.completed' : 'worker.failed';
|
|
87
|
+
children.push(h('span', {
|
|
88
|
+
key: 'worker',
|
|
89
|
+
className: worker.status === 'failed' ? 'dsh-coding-warn' : 'dsh-coding-muted',
|
|
90
|
+
'data-worker': worker.status,
|
|
91
|
+
}, t(label, { role: worker.role })));
|
|
92
|
+
}
|
|
93
|
+
if (data.pending !== undefined) {
|
|
94
|
+
children.push(h('span', {
|
|
95
|
+
key: 'pending',
|
|
96
|
+
className: 'dsh-coding-muted',
|
|
97
|
+
'data-pending': data.pending.tool,
|
|
98
|
+
}, t('pending', { tool: data.pending.requested === undefined
|
|
99
|
+
? data.pending.tool
|
|
100
|
+
: `${data.pending.tool} → ${data.pending.requested}` })));
|
|
101
|
+
}
|
|
102
|
+
const refusal = checkpoint?.refusal;
|
|
103
|
+
if (refusal !== undefined) {
|
|
104
|
+
children.push(h('span', {
|
|
105
|
+
key: 'refusal',
|
|
106
|
+
className: 'dsh-coding-warn',
|
|
107
|
+
title: refusal.reason,
|
|
108
|
+
'data-refusal': refusal.target,
|
|
109
|
+
}, `${t('refused')}: ${refusal.target}`));
|
|
110
|
+
}
|
|
111
|
+
return h('div', {
|
|
112
|
+
className: 'dsh-coding-capsule',
|
|
113
|
+
role: 'group',
|
|
114
|
+
'aria-label': t('aria'),
|
|
115
|
+
'data-coding-capsule': '',
|
|
116
|
+
'data-stage': data.stage,
|
|
117
|
+
'data-mode': data.mode,
|
|
118
|
+
...data.partial ? { 'data-partial': 'true' } : {},
|
|
119
|
+
}, ...children);
|
|
120
|
+
});
|