@hy-sde-org/dsh-tool-debug 0.1.1-rc.2
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/LICENSE +26 -0
- package/README.md +54 -0
- package/cordis.patch.yml +15 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +473 -0
- package/dist/index.js.map +1 -0
- package/dist/invariant.d.ts +16 -0
- package/dist/invariant.d.ts.map +1 -0
- package/dist/invariant.js +23 -0
- package/dist/invariant.js.map +1 -0
- package/dist/render.d.ts +319 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +524 -0
- package/dist/render.js.map +1 -0
- package/dist/session.d.ts +34 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +40 -0
- package/dist/session.js.map +1 -0
- package/dist/types.d.ts +80 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +60 -0
- package/dist/types.js.map +1 -0
- package/examples/agent-preset/agent.cordis.yml +50 -0
- package/examples/agent-preset/preset.yml +3 -0
- package/package.json +85 -0
package/dist/render.js
ADDED
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result formatting for the `debug` tool: one closed JSON output shape, the
|
|
3
|
+
* schema that declares it, and pure formatters that project it into
|
|
4
|
+
* model-facing text. All formatters are bounded by `maxResultChars`.
|
|
5
|
+
* Formatting ported from oh-my-pi's `tools/debug.ts` (MIT) and adapted to the
|
|
6
|
+
* DSH tool-output contract.
|
|
7
|
+
* @module @hy-sde-org/dsh-tool-debug/render
|
|
8
|
+
*/
|
|
9
|
+
export { DEBUG_ACTIONS, isDebugAction, DEBUG_READONLY_ACTIONS } from "./types.js";
|
|
10
|
+
/** Cap on the total length of any rendered result. */
|
|
11
|
+
export const DEFAULT_MAX_RESULT_CHARS = 16_000;
|
|
12
|
+
/**
|
|
13
|
+
* Project a DAP session summary into the canonical plain record.
|
|
14
|
+
* @param snapshot - the DAP session summary.
|
|
15
|
+
* @returns the projected plain session record.
|
|
16
|
+
*/
|
|
17
|
+
export function projectSession(snapshot) {
|
|
18
|
+
const record = {};
|
|
19
|
+
if (snapshot.id !== undefined)
|
|
20
|
+
record.id = snapshot.id;
|
|
21
|
+
if (snapshot.adapter !== undefined)
|
|
22
|
+
record.adapter = snapshot.adapter;
|
|
23
|
+
if (snapshot.cwd !== undefined)
|
|
24
|
+
record.cwd = snapshot.cwd;
|
|
25
|
+
if (snapshot.program !== undefined)
|
|
26
|
+
record.program = snapshot.program;
|
|
27
|
+
if (snapshot.status !== undefined)
|
|
28
|
+
record.status = snapshot.status;
|
|
29
|
+
if (snapshot.stopReason !== undefined)
|
|
30
|
+
record.stopReason = snapshot.stopReason;
|
|
31
|
+
if (snapshot.frameName !== undefined)
|
|
32
|
+
record.frameName = snapshot.frameName;
|
|
33
|
+
if (snapshot.line !== undefined)
|
|
34
|
+
record.line = snapshot.line;
|
|
35
|
+
if (snapshot.source?.path !== undefined)
|
|
36
|
+
record.sourcePath = snapshot.source.path;
|
|
37
|
+
if (snapshot.instructionPointerReference !== undefined) {
|
|
38
|
+
record.instructionPointerReference = snapshot.instructionPointerReference;
|
|
39
|
+
}
|
|
40
|
+
if (snapshot.needsConfigurationDone !== undefined) {
|
|
41
|
+
record.needsConfigurationDone = snapshot.needsConfigurationDone;
|
|
42
|
+
}
|
|
43
|
+
if (snapshot.exitCode !== undefined)
|
|
44
|
+
record.exitCode = snapshot.exitCode;
|
|
45
|
+
return record;
|
|
46
|
+
}
|
|
47
|
+
/** Bounded text: truncate long renderings to `maxResultChars` with a note. */
|
|
48
|
+
function truncate(text, maxResultChars) {
|
|
49
|
+
if (text.length <= maxResultChars)
|
|
50
|
+
return text;
|
|
51
|
+
return `${text.slice(0, maxResultChars)}\n… (truncated)`;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Format the primary stop location of a session snapshot.
|
|
55
|
+
* @param snapshot - the session snapshot.
|
|
56
|
+
* @returns a `path:line:column` string, or null when the location is unknown.
|
|
57
|
+
*/
|
|
58
|
+
export function formatLocation(snapshot) {
|
|
59
|
+
if (!snapshot?.source?.path || snapshot.line === undefined) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return `${snapshot.source.path}:${snapshot.line}${snapshot.column !== undefined ? `:${snapshot.column}` : ''}`;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Format one session snapshot into human-readable lines.
|
|
66
|
+
* @param snapshot - the session snapshot.
|
|
67
|
+
* @returns the rendered lines.
|
|
68
|
+
*/
|
|
69
|
+
export function formatSessionSnapshot(snapshot) {
|
|
70
|
+
const lines = [
|
|
71
|
+
`Session ${snapshot.id}`,
|
|
72
|
+
`Adapter: ${snapshot.adapter}`,
|
|
73
|
+
`Status: ${snapshot.status}`,
|
|
74
|
+
`CWD: ${snapshot.cwd}`,
|
|
75
|
+
];
|
|
76
|
+
if (snapshot.program)
|
|
77
|
+
lines.push(`Program: ${snapshot.program}`);
|
|
78
|
+
if (snapshot.stopReason)
|
|
79
|
+
lines.push(`Stop reason: ${snapshot.stopReason}`);
|
|
80
|
+
if (snapshot.frameName)
|
|
81
|
+
lines.push(`Frame: ${snapshot.frameName}`);
|
|
82
|
+
if (snapshot.instructionPointerReference) {
|
|
83
|
+
lines.push(`Instruction pointer: ${snapshot.instructionPointerReference}`);
|
|
84
|
+
}
|
|
85
|
+
const location = formatLocation(snapshot);
|
|
86
|
+
if (location)
|
|
87
|
+
lines.push(`Location: ${location}`);
|
|
88
|
+
if (snapshot.needsConfigurationDone) {
|
|
89
|
+
lines.push('Configuration: pending configurationDone; set breakpoints, then continue.');
|
|
90
|
+
}
|
|
91
|
+
if (snapshot.exitCode !== undefined)
|
|
92
|
+
lines.push(`Exit code: ${snapshot.exitCode}`);
|
|
93
|
+
return lines;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Format source breakpoints registered for a file.
|
|
97
|
+
* @param filePath - the source file path.
|
|
98
|
+
* @param breakpoints - the source breakpoint records.
|
|
99
|
+
* @returns the rendered breakpoint text.
|
|
100
|
+
*/
|
|
101
|
+
export function formatBreakpoints(filePath, breakpoints) {
|
|
102
|
+
const lines = [`Breakpoints for ${filePath}:`];
|
|
103
|
+
if (breakpoints.length === 0) {
|
|
104
|
+
lines.push('(none)');
|
|
105
|
+
return lines.join('\n');
|
|
106
|
+
}
|
|
107
|
+
for (const breakpoint of breakpoints) {
|
|
108
|
+
lines.push(`- line ${breakpoint.line}: ${breakpoint.verified ? 'verified' : 'pending'}${breakpoint.condition ? ` if ${breakpoint.condition}` : ''}${breakpoint.message ? ` (${breakpoint.message})` : ''}`);
|
|
109
|
+
}
|
|
110
|
+
return lines.join('\n');
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Format function breakpoints registered for the session.
|
|
114
|
+
* @param breakpoints - the function breakpoint records.
|
|
115
|
+
* @returns the rendered breakpoint text.
|
|
116
|
+
*/
|
|
117
|
+
export function formatFunctionBreakpoints(breakpoints) {
|
|
118
|
+
const lines = ['Function breakpoints:'];
|
|
119
|
+
if (breakpoints.length === 0) {
|
|
120
|
+
lines.push('(none)');
|
|
121
|
+
return lines.join('\n');
|
|
122
|
+
}
|
|
123
|
+
for (const breakpoint of breakpoints) {
|
|
124
|
+
lines.push(`- ${breakpoint.name}: ${breakpoint.verified ? 'verified' : 'pending'}${breakpoint.condition ? ` if ${breakpoint.condition}` : ''}${breakpoint.message ? ` (${breakpoint.message})` : ''}`);
|
|
125
|
+
}
|
|
126
|
+
return lines.join('\n');
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Format the current stack frames.
|
|
130
|
+
* @param frames - the stack frames.
|
|
131
|
+
* @returns the rendered stack trace text.
|
|
132
|
+
*/
|
|
133
|
+
export function formatStackFrames(frames) {
|
|
134
|
+
const lines = ['Stack trace:'];
|
|
135
|
+
if (frames.length === 0) {
|
|
136
|
+
lines.push('(empty)');
|
|
137
|
+
return lines.join('\n');
|
|
138
|
+
}
|
|
139
|
+
for (const frame of frames) {
|
|
140
|
+
const location = frame.source?.path
|
|
141
|
+
? `${frame.source.path}:${frame.line}:${frame.column}`
|
|
142
|
+
: `<unknown>:${frame.line}:${frame.column}`;
|
|
143
|
+
lines.push(`- #${frame.id} ${frame.name} @ ${location}`);
|
|
144
|
+
}
|
|
145
|
+
return lines.join('\n');
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Format the debuggee's threads.
|
|
149
|
+
* @param threads - the DAP threads.
|
|
150
|
+
* @returns the rendered thread list text.
|
|
151
|
+
*/
|
|
152
|
+
export function formatThreads(threads) {
|
|
153
|
+
const lines = ['Threads:'];
|
|
154
|
+
if (threads.length === 0) {
|
|
155
|
+
lines.push('(none)');
|
|
156
|
+
return lines.join('\n');
|
|
157
|
+
}
|
|
158
|
+
for (const thread of threads) {
|
|
159
|
+
lines.push(`- ${thread.id}: ${thread.name}`);
|
|
160
|
+
}
|
|
161
|
+
return lines.join('\n');
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Format the scopes of a stack frame.
|
|
165
|
+
* @param scopes - the DAP scopes.
|
|
166
|
+
* @returns the rendered scope list text.
|
|
167
|
+
*/
|
|
168
|
+
export function formatScopes(scopes) {
|
|
169
|
+
const lines = ['Scopes:'];
|
|
170
|
+
if (scopes.length === 0) {
|
|
171
|
+
lines.push('(none)');
|
|
172
|
+
return lines.join('\n');
|
|
173
|
+
}
|
|
174
|
+
for (const scope of scopes) {
|
|
175
|
+
lines.push(`- ${scope.name}: ref=${scope.variablesReference}, expensive=${scope.expensive ? 'yes' : 'no'}${scope.presentationHint ? `, hint=${scope.presentationHint}` : ''}`);
|
|
176
|
+
}
|
|
177
|
+
return lines.join('\n');
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Format the variables of a variable reference.
|
|
181
|
+
* @param variables - the DAP variables.
|
|
182
|
+
* @returns the rendered variable list text.
|
|
183
|
+
*/
|
|
184
|
+
export function formatVariables(variables) {
|
|
185
|
+
const lines = ['Variables:'];
|
|
186
|
+
if (variables.length === 0) {
|
|
187
|
+
lines.push('(none)');
|
|
188
|
+
return lines.join('\n');
|
|
189
|
+
}
|
|
190
|
+
for (const variable of variables) {
|
|
191
|
+
lines.push(`- ${variable.name} = ${variable.value}${variable.type ? ` (${variable.type})` : ''}${variable.variablesReference > 0 ? ` [ref=${variable.variablesReference}]` : ''}`);
|
|
192
|
+
}
|
|
193
|
+
return lines.join('\n');
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Format a source label, optionally with line and column.
|
|
197
|
+
* @param source - the DAP source, or undefined.
|
|
198
|
+
* @param line - optional source line.
|
|
199
|
+
* @param column - optional source column.
|
|
200
|
+
* @returns the formatted `base:line:column` label, or null when unknown.
|
|
201
|
+
*/
|
|
202
|
+
export function formatSourceLabel(source, line, column) {
|
|
203
|
+
if (!source?.path && !source?.name) {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
const base = source.path ?? source.name ?? '<unknown>';
|
|
207
|
+
if (line === undefined) {
|
|
208
|
+
return base;
|
|
209
|
+
}
|
|
210
|
+
return `${base}:${line}${column !== undefined ? `:${column}` : ''}`;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Format disassembled instructions.
|
|
214
|
+
* @param instructions - the disassembled instructions.
|
|
215
|
+
* @returns the rendered disassembly text.
|
|
216
|
+
*/
|
|
217
|
+
export function formatDisassembly(instructions) {
|
|
218
|
+
const lines = ['Disassembly:'];
|
|
219
|
+
if (instructions.length === 0) {
|
|
220
|
+
lines.push('(empty)');
|
|
221
|
+
return lines.join('\n');
|
|
222
|
+
}
|
|
223
|
+
const addressWidth = Math.max(...instructions.map(instruction => instruction.address.length));
|
|
224
|
+
const bytesWidth = Math.max(...instructions.map(instruction => instruction.instructionBytes?.length ?? 0), 2);
|
|
225
|
+
for (const instruction of instructions) {
|
|
226
|
+
const location = formatSourceLabel(instruction.location, instruction.line, instruction.column);
|
|
227
|
+
const parts = [
|
|
228
|
+
instruction.address.padEnd(addressWidth),
|
|
229
|
+
(instruction.instructionBytes ?? '').padEnd(bytesWidth),
|
|
230
|
+
instruction.instruction,
|
|
231
|
+
];
|
|
232
|
+
if (instruction.symbol) {
|
|
233
|
+
parts.push(`<${instruction.symbol}>`);
|
|
234
|
+
}
|
|
235
|
+
if (location) {
|
|
236
|
+
parts.push(`[${location}]`);
|
|
237
|
+
}
|
|
238
|
+
lines.push(parts
|
|
239
|
+
.filter(part => part.length > 0)
|
|
240
|
+
.join(' ')
|
|
241
|
+
.trimEnd());
|
|
242
|
+
}
|
|
243
|
+
return lines.join('\n');
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Format a memory read result as a hex/ascii dump.
|
|
247
|
+
* @param address - the memory address read.
|
|
248
|
+
* @param data - the base64-encoded buffer string, or undefined.
|
|
249
|
+
* @param unreadableBytes - optional count of unreadable bytes.
|
|
250
|
+
* @returns the rendered memory dump text.
|
|
251
|
+
*/
|
|
252
|
+
export function formatMemoryRead(address, data, unreadableBytes) {
|
|
253
|
+
const lines = [`Memory at ${address}:`];
|
|
254
|
+
const buffer = data ? Buffer.from(data, 'base64') : Buffer.alloc(0);
|
|
255
|
+
if (buffer.length === 0) {
|
|
256
|
+
lines.push('(no readable bytes)');
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
for (let offset = 0; offset < buffer.length; offset += 16) {
|
|
260
|
+
const chunk = buffer.subarray(offset, offset + 16);
|
|
261
|
+
const hex = Array.from(chunk, byte => byte.toString(16).padStart(2, '0')).join(' ');
|
|
262
|
+
const ascii = Array.from(chunk, byte => (byte >= 32 && byte < 127 ? String.fromCharCode(byte) : '.')).join('');
|
|
263
|
+
lines.push(`${(offset === 0 ? address : `+0x${offset.toString(16)}`).padEnd(18)} ${hex.padEnd(47)} |${ascii}|`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (unreadableBytes !== undefined && unreadableBytes > 0) {
|
|
267
|
+
lines.push(`Unreadable bytes: ${unreadableBytes}`);
|
|
268
|
+
}
|
|
269
|
+
return lines.join('\n');
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Render a simple aligned text table.
|
|
273
|
+
* @param headers - the column headers.
|
|
274
|
+
* @param rows - the table rows.
|
|
275
|
+
* @returns the rendered table text.
|
|
276
|
+
*/
|
|
277
|
+
export function formatTable(headers, rows) {
|
|
278
|
+
const widths = headers.map((header, index) => Math.max(header.length, ...rows.map(row => (row[index] ?? '').length)));
|
|
279
|
+
const formatRow = (row) => row.map((cell, index) => (cell ?? '').padEnd(widths[index] ?? 0)).join(' ');
|
|
280
|
+
return [formatRow(headers), formatRow(widths.map(width => '-'.repeat(width ?? 0))), ...rows.map(formatRow)].join('\n');
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Format loaded modules of the debuggee as a table.
|
|
284
|
+
* @param modules - the DAP modules.
|
|
285
|
+
* @returns the rendered module table text.
|
|
286
|
+
*/
|
|
287
|
+
export function formatModules(modules) {
|
|
288
|
+
if (modules.length === 0) {
|
|
289
|
+
return 'Modules:\n(none)';
|
|
290
|
+
}
|
|
291
|
+
return [
|
|
292
|
+
'Modules:',
|
|
293
|
+
formatTable(['ID', 'Name', 'Path', 'Symbols', 'Range'], modules.map(module => [
|
|
294
|
+
String(module.id),
|
|
295
|
+
module.name,
|
|
296
|
+
module.path ?? '',
|
|
297
|
+
module.symbolStatus ?? '',
|
|
298
|
+
module.addressRange ?? '',
|
|
299
|
+
])),
|
|
300
|
+
].join('\n');
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Format source files loaded by the debuggee.
|
|
304
|
+
* @param sources - the DAP sources.
|
|
305
|
+
* @returns the rendered loaded-sources text.
|
|
306
|
+
*/
|
|
307
|
+
export function formatLoadedSources(sources) {
|
|
308
|
+
const lines = ['Loaded sources:'];
|
|
309
|
+
if (sources.length === 0) {
|
|
310
|
+
lines.push('(none)');
|
|
311
|
+
return lines.join('\n');
|
|
312
|
+
}
|
|
313
|
+
for (const source of sources) {
|
|
314
|
+
const label = source.path ?? source.name ?? '<unknown>';
|
|
315
|
+
lines.push(`- ${label}${source.sourceReference !== undefined ? ` [ref=${source.sourceReference}]` : ''}`);
|
|
316
|
+
}
|
|
317
|
+
return lines.join('\n');
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Format instruction breakpoints.
|
|
321
|
+
* @param breakpoints - the instruction breakpoint records.
|
|
322
|
+
* @returns the rendered breakpoint text.
|
|
323
|
+
*/
|
|
324
|
+
export function formatInstructionBreakpoints(breakpoints) {
|
|
325
|
+
const lines = ['Instruction breakpoints:'];
|
|
326
|
+
if (breakpoints.length === 0) {
|
|
327
|
+
lines.push('(none)');
|
|
328
|
+
return lines.join('\n');
|
|
329
|
+
}
|
|
330
|
+
for (const breakpoint of breakpoints) {
|
|
331
|
+
const location = `${breakpoint.instructionReference}${breakpoint.offset !== undefined ? `+${breakpoint.offset}` : ''}`;
|
|
332
|
+
lines.push(`- ${location}: ${breakpoint.verified ? 'verified' : 'pending'}${breakpoint.condition ? ` if ${breakpoint.condition}` : ''}${breakpoint.hitCondition ? ` after ${breakpoint.hitCondition}` : ''}${breakpoint.message ? ` (${breakpoint.message})` : ''}`);
|
|
333
|
+
}
|
|
334
|
+
return lines.join('\n');
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Format data-breakpoint availability info.
|
|
338
|
+
* @param info - the data-breakpoint info response.
|
|
339
|
+
* @returns the rendered info text.
|
|
340
|
+
*/
|
|
341
|
+
export function formatDataBreakpointInfo(info) {
|
|
342
|
+
const lines = [`Data breakpoint info: ${info.description}`];
|
|
343
|
+
lines.push(`Data ID: ${info.dataId ?? '(not available)'}`);
|
|
344
|
+
if (info.accessTypes && info.accessTypes.length > 0) {
|
|
345
|
+
lines.push(`Access types: ${info.accessTypes.join(', ')}`);
|
|
346
|
+
}
|
|
347
|
+
if (info.canPersist !== undefined) {
|
|
348
|
+
lines.push(`Persistent: ${info.canPersist ? 'yes' : 'no'}`);
|
|
349
|
+
}
|
|
350
|
+
return lines.join('\n');
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Format data breakpoints.
|
|
354
|
+
* @param breakpoints - the data breakpoint records.
|
|
355
|
+
* @returns the rendered breakpoint text.
|
|
356
|
+
*/
|
|
357
|
+
export function formatDataBreakpoints(breakpoints) {
|
|
358
|
+
const lines = ['Data breakpoints:'];
|
|
359
|
+
if (breakpoints.length === 0) {
|
|
360
|
+
lines.push('(none)');
|
|
361
|
+
return lines.join('\n');
|
|
362
|
+
}
|
|
363
|
+
for (const breakpoint of breakpoints) {
|
|
364
|
+
lines.push(`- ${breakpoint.dataId}: ${breakpoint.verified ? 'verified' : 'pending'}${breakpoint.accessType ? ` (${breakpoint.accessType})` : ''}${breakpoint.condition ? ` if ${breakpoint.condition}` : ''}${breakpoint.hitCondition ? ` after ${breakpoint.hitCondition}` : ''}${breakpoint.message ? ` (${breakpoint.message})` : ''}`);
|
|
365
|
+
}
|
|
366
|
+
return lines.join('\n');
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Format a custom DAP request response.
|
|
370
|
+
* @param command - the custom request command name.
|
|
371
|
+
* @param body - the response body.
|
|
372
|
+
* @returns the rendered serialized response text.
|
|
373
|
+
*/
|
|
374
|
+
export function formatCustomResponse(command, body) {
|
|
375
|
+
let serialized = '';
|
|
376
|
+
try {
|
|
377
|
+
serialized = JSON.stringify(body, null, 2) ?? 'null';
|
|
378
|
+
}
|
|
379
|
+
catch {
|
|
380
|
+
serialized = String(body);
|
|
381
|
+
}
|
|
382
|
+
return `${command} response:\n${serialized}`;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Format all sessions under the manager.
|
|
386
|
+
* @param sessions - the session summaries.
|
|
387
|
+
* @returns the rendered session list text.
|
|
388
|
+
*/
|
|
389
|
+
export function formatSessions(sessions) {
|
|
390
|
+
if (sessions.length === 0) {
|
|
391
|
+
return 'No debug sessions.';
|
|
392
|
+
}
|
|
393
|
+
return sessions
|
|
394
|
+
.map((session) => {
|
|
395
|
+
const location = formatLocation(session);
|
|
396
|
+
return [
|
|
397
|
+
`${session.id}: ${session.status}`,
|
|
398
|
+
` adapter=${session.adapter}`,
|
|
399
|
+
` cwd=${session.cwd}`,
|
|
400
|
+
...(session.program ? [` program=${session.program}`] : []),
|
|
401
|
+
...(location ? [` location=${location}`] : []),
|
|
402
|
+
...(session.stopReason ? [` reason=${session.stopReason}`] : []),
|
|
403
|
+
].join('\n');
|
|
404
|
+
})
|
|
405
|
+
.join('\n\n');
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Format an evaluation result.
|
|
409
|
+
* @param evaluation - the picked evaluation fields.
|
|
410
|
+
* @returns the rendered evaluation text.
|
|
411
|
+
*/
|
|
412
|
+
export function formatEvaluation(evaluation) {
|
|
413
|
+
const lines = [`Result: ${evaluation.result}`];
|
|
414
|
+
if (evaluation.type)
|
|
415
|
+
lines.push(`Type: ${evaluation.type}`);
|
|
416
|
+
if (evaluation.variablesReference > 0) {
|
|
417
|
+
lines.push(`Variables ref: ${evaluation.variablesReference}`);
|
|
418
|
+
}
|
|
419
|
+
return lines.join('\n');
|
|
420
|
+
}
|
|
421
|
+
/** Canonical session-record property specs (all optional on purpose). */
|
|
422
|
+
const SESSION_PROPERTIES = {
|
|
423
|
+
id: { type: 'string' },
|
|
424
|
+
adapter: { type: 'string' },
|
|
425
|
+
cwd: { type: 'string' },
|
|
426
|
+
program: { type: 'string' },
|
|
427
|
+
status: { type: 'string' },
|
|
428
|
+
stopReason: { type: 'string' },
|
|
429
|
+
frameName: { type: 'string' },
|
|
430
|
+
line: { type: 'number' },
|
|
431
|
+
sourcePath: { type: 'string' },
|
|
432
|
+
instructionPointerReference: { type: 'string' },
|
|
433
|
+
needsConfigurationDone: { type: 'boolean' },
|
|
434
|
+
exitCode: { type: 'number' },
|
|
435
|
+
};
|
|
436
|
+
/** Schema declaring the closed `debug` tool output value shape. */
|
|
437
|
+
export const DEBUG_OUTPUT_SCHEMA = {
|
|
438
|
+
type: 'object',
|
|
439
|
+
additionalProperties: false,
|
|
440
|
+
properties: {
|
|
441
|
+
action: { type: 'string', required: true },
|
|
442
|
+
success: { type: 'boolean', required: true },
|
|
443
|
+
message: { type: 'string', required: true },
|
|
444
|
+
session: {
|
|
445
|
+
type: 'object',
|
|
446
|
+
additionalProperties: false,
|
|
447
|
+
properties: SESSION_PROPERTIES,
|
|
448
|
+
},
|
|
449
|
+
sessions: {
|
|
450
|
+
type: 'array',
|
|
451
|
+
items: { type: 'object', additionalProperties: false, properties: SESSION_PROPERTIES },
|
|
452
|
+
},
|
|
453
|
+
state: { type: 'string' },
|
|
454
|
+
timedOut: { type: 'boolean' },
|
|
455
|
+
output: { type: 'string' },
|
|
456
|
+
},
|
|
457
|
+
};
|
|
458
|
+
/**
|
|
459
|
+
* Compose a message from the durable value; callers pre-set `message`.
|
|
460
|
+
* @param _args - the debug tool arguments (unused).
|
|
461
|
+
* @param value - the durable tool output value.
|
|
462
|
+
* @returns the message text.
|
|
463
|
+
*/
|
|
464
|
+
export function renderDebugCall(_args, value) {
|
|
465
|
+
return value.message ?? '(no output)';
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Deterministic one-line summary of a `debug` call for UIs.
|
|
469
|
+
* @param args - the debug tool arguments.
|
|
470
|
+
* @returns the one-line summary text.
|
|
471
|
+
*/
|
|
472
|
+
export function summarizeDebugCall(args) {
|
|
473
|
+
const action = args.action ? args.action.replaceAll('_', ' ') : 'request';
|
|
474
|
+
if (args.program)
|
|
475
|
+
return `${action} ${args.program}`;
|
|
476
|
+
if (args.file && args.line !== undefined)
|
|
477
|
+
return `${action} ${args.file}:${args.line}`;
|
|
478
|
+
if (args.function)
|
|
479
|
+
return `${action} ${args.function}`;
|
|
480
|
+
if (args.expression)
|
|
481
|
+
return `${action} ${args.expression}`;
|
|
482
|
+
if (args.command)
|
|
483
|
+
return `${action} ${args.command}`;
|
|
484
|
+
if (args.memory_reference)
|
|
485
|
+
return `${action} ${args.memory_reference}`;
|
|
486
|
+
if (args.instruction_reference)
|
|
487
|
+
return `${action} ${args.instruction_reference}`;
|
|
488
|
+
if (args.data_id)
|
|
489
|
+
return `${action} ${args.data_id}`;
|
|
490
|
+
if (args.name)
|
|
491
|
+
return `${action} ${args.name}`;
|
|
492
|
+
return action;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Pure, side-effect-free pending-call view for UIs (softly typed for replay).
|
|
496
|
+
* @param args - the debug tool arguments.
|
|
497
|
+
* @returns the generic pending-call view.
|
|
498
|
+
*/
|
|
499
|
+
export function presentDebugCall(args) {
|
|
500
|
+
const action = args.action ?? 'request';
|
|
501
|
+
return {
|
|
502
|
+
card: 'generic',
|
|
503
|
+
title: `debug ${action}`,
|
|
504
|
+
kind: 'execute',
|
|
505
|
+
rawInput: { action: args.action, program: args.program },
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Project a rendered result into a {message} + detail value.
|
|
510
|
+
* @param action - the debug action performed.
|
|
511
|
+
* @param text - the rendered result text.
|
|
512
|
+
* @param extra - additional fields to include in the output value.
|
|
513
|
+
* @param maxResultChars - cap on the total rendered message length.
|
|
514
|
+
* @returns the constructed tool output value.
|
|
515
|
+
*/
|
|
516
|
+
export function makeDebugOutput(action, text, extra, maxResultChars) {
|
|
517
|
+
return {
|
|
518
|
+
action,
|
|
519
|
+
success: true,
|
|
520
|
+
message: truncate(text, maxResultChars),
|
|
521
|
+
...extra,
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAqBH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA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,CAAC,IAAI;QAAE,OAAO,GAAG,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAA;IAC9C,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAA4B;IAC3D,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,SAAS,CAAA;IACvC,OAAO;QACL,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS,MAAM,EAAE;QACxB,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE;KACzD,CAAA;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAuB,EACvB,IAAY,EACZ,KAA8D,EAC9D,cAAsB;IAEtB,OAAO;QACL,MAAM;QACN,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;QACvC,GAAG,KAAK;KACT,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derive the workspace root a `debug` call resolves paths against: the calling
|
|
3
|
+
* agent's per-session workspace (`exec.agent.session.header.cwd`), mirroring
|
|
4
|
+
* the filesystem and LSP tools. When a call supplies an explicit `cwd`, paths
|
|
5
|
+
* are resolved against that instead (still relative to the session workspace
|
|
6
|
+
* when `cwd` itself is relative).
|
|
7
|
+
* @module @hy-sde-org/dsh-tool-debug/session
|
|
8
|
+
*/
|
|
9
|
+
import type { ToolExecution } from '@deepseek-ai/dsh-tools';
|
|
10
|
+
/**
|
|
11
|
+
* The session workspace cwd for this call, or `undefined` when none applies.
|
|
12
|
+
* @param exec - the tool-execution context; only its optional `agent` is read.
|
|
13
|
+
* @returns the calling agent's session cwd, or undefined for a non-agent caller.
|
|
14
|
+
*/
|
|
15
|
+
export declare function sessionCwd(exec: ToolExecution): string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a user-supplied path against the session workspace (absolute paths
|
|
18
|
+
* pass through; relative paths join `base`).
|
|
19
|
+
* @param input - the path as the model provided it.
|
|
20
|
+
* @param base - the resolution root (session cwd or an explicit call cwd).
|
|
21
|
+
* @returns the resolved absolute path.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveToCwd(input: string, base: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* The effective working directory for one call: the explicit `cwd` arg when
|
|
26
|
+
* present (absolute, or joined onto the session cwd), else the session cwd.
|
|
27
|
+
* @param args - parsed call arguments.
|
|
28
|
+
* @param workspace - the session workspace cwd (required).
|
|
29
|
+
* @returns the resolved call working directory.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveCallCwd(args: {
|
|
32
|
+
readonly cwd?: string;
|
|
33
|
+
}, workspace: string): string;
|
|
34
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAE3D;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAElE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE;IAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAGzF"}
|
package/dist/session.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derive the workspace root a `debug` call resolves paths against: the calling
|
|
3
|
+
* agent's per-session workspace (`exec.agent.session.header.cwd`), mirroring
|
|
4
|
+
* the filesystem and LSP tools. When a call supplies an explicit `cwd`, paths
|
|
5
|
+
* are resolved against that instead (still relative to the session workspace
|
|
6
|
+
* when `cwd` itself is relative).
|
|
7
|
+
* @module @hy-sde-org/dsh-tool-debug/session
|
|
8
|
+
*/
|
|
9
|
+
import * as path from 'node:path';
|
|
10
|
+
/**
|
|
11
|
+
* The session workspace cwd for this call, or `undefined` when none applies.
|
|
12
|
+
* @param exec - the tool-execution context; only its optional `agent` is read.
|
|
13
|
+
* @returns the calling agent's session cwd, or undefined for a non-agent caller.
|
|
14
|
+
*/
|
|
15
|
+
export function sessionCwd(exec) {
|
|
16
|
+
return exec.agent?.session.header.cwd;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolve a user-supplied path against the session workspace (absolute paths
|
|
20
|
+
* pass through; relative paths join `base`).
|
|
21
|
+
* @param input - the path as the model provided it.
|
|
22
|
+
* @param base - the resolution root (session cwd or an explicit call cwd).
|
|
23
|
+
* @returns the resolved absolute path.
|
|
24
|
+
*/
|
|
25
|
+
export function resolveToCwd(input, base) {
|
|
26
|
+
return path.isAbsolute(input) ? input : path.resolve(base, input);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The effective working directory for one call: the explicit `cwd` arg when
|
|
30
|
+
* present (absolute, or joined onto the session cwd), else the session cwd.
|
|
31
|
+
* @param args - parsed call arguments.
|
|
32
|
+
* @param workspace - the session workspace cwd (required).
|
|
33
|
+
* @returns the resolved call working directory.
|
|
34
|
+
*/
|
|
35
|
+
export function resolveCallCwd(args, workspace) {
|
|
36
|
+
if (args.cwd === undefined)
|
|
37
|
+
return workspace;
|
|
38
|
+
return path.isAbsolute(args.cwd) ? args.cwd : path.resolve(workspace, args.cwd);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAGjC;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAmB;IAC5C,OAAO,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAA;AACvC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,IAAY;IACtD,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACnE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,IAA+B,EAAE,SAAiB;IAC/E,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAC5C,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;AACjF,CAAC"}
|