@denizokcu/haze 0.9.0 → 0.10.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.
- package/CHANGELOG.md +57 -17
- package/README.md +119 -64
- package/dist/cli/chat/chatMetrics.d.ts +17 -1
- package/dist/cli/chat/chatMetrics.js +22 -5
- package/dist/cli/chat/contextReport.d.ts +11 -0
- package/dist/cli/chat/contextReport.js +44 -0
- package/dist/cli/chat/fileMentionSuggestions.d.ts +29 -0
- package/dist/cli/chat/fileMentionSuggestions.js +91 -0
- package/dist/cli/chat/inputSuggestions.d.ts +5 -0
- package/dist/cli/chat/inputSuggestions.js +17 -3
- package/dist/cli/chat/sessionLifecycle.d.ts +58 -0
- package/dist/cli/chat/sessionLifecycle.js +155 -0
- package/dist/cli/chat/sessionRecorder.js +7 -9
- package/dist/cli/chat/startupInfo.d.ts +1 -0
- package/dist/cli/chat/startupInfo.js +11 -0
- package/dist/cli/chat/tips.d.ts +21 -0
- package/dist/cli/chat/tips.js +43 -0
- package/dist/cli/chat/wizardDispatch.d.ts +64 -0
- package/dist/cli/chat/wizardDispatch.js +645 -0
- package/dist/cli/commands/chat.d.ts +1 -0
- package/dist/cli/commands/chat.js +181 -700
- package/dist/cli/commands/chatModes.d.ts +1 -1
- package/dist/cli/commands/chatModes.js +7 -2
- package/dist/cli/commands/commandHelp.js +5 -3
- package/dist/cli/commands/commands.d.ts +3 -2
- package/dist/cli/commands/commands.js +12 -13
- package/dist/cli/commands/fleetCommand.d.ts +14 -0
- package/dist/cli/commands/fleetCommand.js +46 -0
- package/dist/cli/commands/formatters.d.ts +5 -0
- package/dist/cli/commands/formatters.js +33 -6
- package/dist/cli/commands/logsCommand.js +1 -7
- package/dist/cli/commands/modelCommand.js +1 -1
- package/dist/cli/commands/providerWizard.d.ts +1 -0
- package/dist/cli/commands/providerWizard.js +13 -0
- package/dist/cli/commands/runCommand.d.ts +1 -0
- package/dist/cli/commands/runCommand.js +25 -5
- package/dist/cli/commands/sessionPicker.d.ts +9 -0
- package/dist/cli/commands/sessionPicker.js +29 -0
- package/dist/cli/commands/settingsSummary.js +6 -4
- package/dist/cli/commands/skillConfirmRemove.js +4 -3
- package/dist/cli/commands/skillWizard.d.ts +2 -0
- package/dist/cli/commands/skillWizard.js +16 -6
- package/dist/cli/commands/streaming/idleTimer.d.ts +26 -0
- package/dist/cli/commands/streaming/idleTimer.js +24 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +2 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.js +4 -2
- package/dist/cli/commands/streaming/turnRuntime.js +6 -4
- package/dist/cli/commands/streaming.d.ts +13 -1
- package/dist/cli/commands/streaming.js +42 -19
- package/dist/cli/commands/wizardActions.d.ts +6 -0
- package/dist/cli/commands/wizardActions.js +6 -0
- package/dist/cli/commands/wizardSuggestions.d.ts +8 -0
- package/dist/cli/commands/wizardSuggestions.js +60 -12
- package/dist/cli/commands/wizardTransition.d.ts +4 -0
- package/dist/cli/commands/wizardTransition.js +1 -2
- package/dist/cli/index.js +17 -3
- package/dist/cli/terminalTitle.d.ts +6 -0
- package/dist/cli/terminalTitle.js +36 -0
- package/dist/config/inputHistory.d.ts +3 -3
- package/dist/config/inputHistory.js +12 -18
- package/dist/config/modelDiscovery.d.ts +20 -0
- package/dist/config/modelDiscovery.js +51 -0
- package/dist/config/providerPresets.d.ts +16 -4
- package/dist/config/providerPresets.js +263 -34
- package/dist/config/providers.d.ts +2 -0
- package/dist/config/providers.js +7 -0
- package/dist/config/settings.d.ts +22 -0
- package/dist/config/settings.js +29 -1
- package/dist/config/skillSettings.d.ts +6 -13
- package/dist/config/skillSettings.js +20 -19
- package/dist/core/agent/budgets.d.ts +26 -0
- package/dist/core/agent/budgets.js +34 -0
- package/dist/core/agent/compaction.js +17 -3
- package/dist/core/agent/contextBudget.d.ts +8 -0
- package/dist/core/agent/contextBudget.js +29 -0
- package/dist/core/agent/errors.js +6 -2
- package/dist/core/agent/events.d.ts +12 -0
- package/dist/core/agent/toolOutputStore.d.ts +5 -0
- package/dist/core/agent/toolOutputStore.js +18 -1
- package/dist/core/agent/workState.d.ts +1 -1
- package/dist/core/agent/workState.js +0 -4
- package/dist/core/attachments/imageAttachments.d.ts +90 -0
- package/dist/core/attachments/imageAttachments.js +245 -0
- package/dist/core/attachments/readBlessings.d.ts +37 -0
- package/dist/core/attachments/readBlessings.js +79 -0
- package/dist/core/goal/requestClassifier.d.ts +0 -3
- package/dist/core/goal/requestClassifier.js +0 -13
- package/dist/core/io/boundedRead.js +76 -29
- package/dist/core/limits/byteBudgets.d.ts +5 -0
- package/dist/core/limits/byteBudgets.js +5 -0
- package/dist/core/limits/textBudgets.d.ts +23 -0
- package/dist/core/limits/textBudgets.js +23 -0
- package/dist/core/process/backgroundRegistry.d.ts +35 -0
- package/dist/core/process/backgroundRegistry.js +194 -0
- package/dist/core/process/runBoundedProcess.d.ts +3 -0
- package/dist/core/process/runBoundedProcess.js +65 -29
- package/dist/core/safety/urlGuard.d.ts +2 -1
- package/dist/core/safety/urlGuard.js +3 -2
- package/dist/core/session/sessionSlimming.js +47 -4
- package/dist/core/session/sessionStore.d.ts +37 -0
- package/dist/core/session/sessionStore.js +95 -9
- package/dist/core/subagent/contracts.d.ts +116 -0
- package/dist/core/subagent/contracts.js +54 -0
- package/dist/core/subagent/executionProfiles.d.ts +28 -0
- package/dist/core/subagent/executionProfiles.js +45 -0
- package/dist/core/subagent/subagentCoordinator.d.ts +74 -0
- package/dist/core/subagent/subagentCoordinator.js +134 -0
- package/dist/core/subagent/subagentRunner.d.ts +211 -145
- package/dist/core/subagent/subagentRunner.js +228 -98
- package/dist/core/subagent/workspaceMutationPolicy.d.ts +11 -0
- package/dist/core/subagent/workspaceMutationPolicy.js +52 -0
- package/dist/core/tasks/taskStorage.js +12 -1
- package/dist/llm/client.d.ts +20 -29
- package/dist/llm/client.js +29 -28
- package/dist/llm/hazeTools.d.ts +2013 -78
- package/dist/llm/hazeTools.js +16 -7
- package/dist/llm/lsp.d.ts +2 -0
- package/dist/llm/lsp.js +18 -3
- package/dist/llm/requestContext.d.ts +22 -1
- package/dist/llm/requestContext.js +45 -5
- package/dist/llm/systemPrompt.d.ts +4 -1
- package/dist/llm/systemPrompt.js +14 -4
- package/dist/llm/toolResultTypes.d.ts +1 -1
- package/dist/llm/tools/bashTool.d.ts +874 -32
- package/dist/llm/tools/bashTool.js +25 -4
- package/dist/llm/tools/fetchTool.d.ts +26 -26
- package/dist/llm/tools/fetchTool.js +1 -1
- package/dist/llm/tools/fileToolShared.d.ts +2 -1
- package/dist/llm/tools/fileToolShared.js +5 -5
- package/dist/llm/tools/grepRunner.d.ts +5 -0
- package/dist/llm/tools/grepRunner.js +52 -71
- package/dist/llm/tools/outputCap.d.ts +2 -6
- package/dist/llm/tools/outputCap.js +2 -6
- package/dist/llm/tools/processTool.d.ts +1077 -0
- package/dist/llm/tools/processTool.js +41 -0
- package/dist/llm/tools/toolContext.d.ts +8 -0
- package/dist/llm/tools/toolContext.js +22 -11
- package/dist/llm/tools/workspaceFile.d.ts +9 -1
- package/dist/llm/tools/workspaceFile.js +33 -4
- package/dist/llm/webFetch.js +24 -11
- package/dist/llm/workerContext.d.ts +18 -0
- package/dist/llm/workerContext.js +55 -0
- package/dist/skills/SkillLoader.d.ts +2 -2
- package/dist/skills/SkillRegistry.d.ts +3 -2
- package/dist/skills/SkillRegistry.js +43 -13
- package/dist/skills/builder/SkillBuilder.d.ts +3 -0
- package/dist/skills/builder/SkillBuilder.js +23 -5
- package/dist/skills/skillTools.js +11 -4
- package/dist/skills/types.d.ts +6 -1
- package/dist/ui/components/TextInput.d.ts +5 -2
- package/dist/ui/components/TextInput.js +76 -8
- package/dist/utils/format.d.ts +2 -0
- package/dist/utils/format.js +8 -0
- package/dist/utils/fs.d.ts +0 -1
- package/dist/utils/fs.js +0 -4
- package/dist/utils/openPath.d.ts +2 -0
- package/dist/utils/openPath.js +9 -0
- package/package.json +1 -1
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { IMAGE_ATTACHMENT_BYTES, IMAGE_ATTACHMENTS_PER_MESSAGE } from '../limits/byteBudgets.js';
|
|
5
|
+
import { workspaceRoot } from '../../utils/path.js';
|
|
6
|
+
import { formatBytes } from '../../utils/format.js';
|
|
7
|
+
/**
|
|
8
|
+
* User-attached images for one prompt (F03).
|
|
9
|
+
*
|
|
10
|
+
* Attachments are resolved from `@path` mentions typed by the user in the
|
|
11
|
+
* interactive chat: host-path allowed (workspace-relative, absolute, or `~/`),
|
|
12
|
+
* real-path deduped, extension-allowlisted, byte-bounded. The module is UI-
|
|
13
|
+
* and provider-agnostic (constitution VI): the capability gate takes the
|
|
14
|
+
* provider shape explicitly, never settings I/O.
|
|
15
|
+
*/
|
|
16
|
+
/** Extension allowlist → media type. Only these image kinds can be attached. */
|
|
17
|
+
export const IMAGE_MEDIA_TYPES = {
|
|
18
|
+
'.png': 'image/png',
|
|
19
|
+
'.jpg': 'image/jpeg',
|
|
20
|
+
'.jpeg': 'image/jpeg',
|
|
21
|
+
'.gif': 'image/gif',
|
|
22
|
+
'.webp': 'image/webp',
|
|
23
|
+
};
|
|
24
|
+
export const IMAGE_EXTENSIONS = Object.keys(IMAGE_MEDIA_TYPES);
|
|
25
|
+
/**
|
|
26
|
+
* `@token` candidates. The lookbehind keeps emails/handles intact
|
|
27
|
+
* (`user@example.com` never matches at `@example.com`). Backslash escapes
|
|
28
|
+
* (`\ `, `\(`, …) are part of the token so paths containing spaces — the
|
|
29
|
+
* default macOS screenshot filename is `Bildschirmfoto YYYY-MM-DD um HH.MM.SS.png` —
|
|
30
|
+
* survive intact. The escape is removed during resolution, never silently.
|
|
31
|
+
*/
|
|
32
|
+
const MENTION_PATTERN = /(?<![\w@])@((?:[\w./~-]|\\.)+)/g;
|
|
33
|
+
/**
|
|
34
|
+
* Bare path candidates (no `@`). The lookahead requires a `/` somewhere in
|
|
35
|
+
* the token so ordinary prose ("I named it cat.png") is never scanned; the
|
|
36
|
+
* lookbehind stops mid-word matches and skips anything right after `@`
|
|
37
|
+
* (handled by `MENTION_PATTERN`), `.`, or `/`. Backslash escapes are part
|
|
38
|
+
* of the token. Routing (image attachment vs read-blessing) happens during
|
|
39
|
+
* resolution based on extension and stat result.
|
|
40
|
+
*/
|
|
41
|
+
const BARE_PATH_PATTERN = /(?<![\w.@/])(?=[\w.~/-]*\/)((?:[\w./~-]|\\.)+)(?![\w.-])/gi;
|
|
42
|
+
/**
|
|
43
|
+
* Extract path-like attachment candidates from prompt text. Two forms are
|
|
44
|
+
* recognised:
|
|
45
|
+
*
|
|
46
|
+
* - Explicit `@token` mentions: any path-like token after `@`. A candidate
|
|
47
|
+
* must contain a `.` or `/` so bare handles (`@here`) are skipped.
|
|
48
|
+
* - Bare paths: a token that ends in an allowlisted image extension AND
|
|
49
|
+
* contains `/`. The separator keeps prose like "I named it cat.png" out;
|
|
50
|
+
* the existence check during resolution is the final gate.
|
|
51
|
+
*
|
|
52
|
+
* Whether a candidate is really an attachment is decided during resolution.
|
|
53
|
+
*/
|
|
54
|
+
export function extractPathMentions(text) {
|
|
55
|
+
const mentions = [];
|
|
56
|
+
const seen = new Set();
|
|
57
|
+
for (const match of text.matchAll(MENTION_PATTERN)) {
|
|
58
|
+
const token = match[1];
|
|
59
|
+
if (!token || (!token.includes('.') && !token.includes('/')))
|
|
60
|
+
continue;
|
|
61
|
+
if (seen.has(match[0]))
|
|
62
|
+
continue;
|
|
63
|
+
seen.add(match[0]);
|
|
64
|
+
mentions.push({ mention: match[0], token });
|
|
65
|
+
}
|
|
66
|
+
for (const match of text.matchAll(BARE_PATH_PATTERN)) {
|
|
67
|
+
const token = match[1];
|
|
68
|
+
if (!token || !token.includes('/'))
|
|
69
|
+
continue;
|
|
70
|
+
if (seen.has(match[0]))
|
|
71
|
+
continue;
|
|
72
|
+
seen.add(match[0]);
|
|
73
|
+
mentions.push({ mention: match[0], token });
|
|
74
|
+
}
|
|
75
|
+
return mentions;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Resolve an `@token` mention to a host path. Relative tokens resolve against
|
|
79
|
+
* the workspace root but may escape it (`../shot.png`); `~/` expands to the
|
|
80
|
+
* home directory; absolute tokens stay absolute. Attachments are explicit
|
|
81
|
+
* user-typed references, so host paths outside the workspace are allowed.
|
|
82
|
+
*/
|
|
83
|
+
function resolveAttachmentPath(token) {
|
|
84
|
+
if (token === '~' || token.startsWith('~/'))
|
|
85
|
+
return path.join(os.homedir(), token.slice(1));
|
|
86
|
+
return path.resolve(workspaceRoot(), token);
|
|
87
|
+
}
|
|
88
|
+
/** Workspace-relative for files inside the project, `~/…` under the home directory, absolute otherwise. */
|
|
89
|
+
function displayPathFor(realPath) {
|
|
90
|
+
const relativeTo = (root) => {
|
|
91
|
+
const relative = path.relative(root, realPath);
|
|
92
|
+
return relative.startsWith('..') || path.isAbsolute(relative) ? undefined : relative || '.';
|
|
93
|
+
};
|
|
94
|
+
const inWorkspace = relativeTo(workspaceRoot());
|
|
95
|
+
if (inWorkspace !== undefined)
|
|
96
|
+
return inWorkspace;
|
|
97
|
+
const inHome = relativeTo(os.homedir());
|
|
98
|
+
return inHome !== undefined ? path.join('~', inHome) : realPath;
|
|
99
|
+
}
|
|
100
|
+
function notAnImageError(token) {
|
|
101
|
+
return new Error(`Not an image: @${token}. Only ${IMAGE_EXTENSIONS.join(', ')} files can be attached.`);
|
|
102
|
+
}
|
|
103
|
+
async function statFile(absolutePath) {
|
|
104
|
+
try {
|
|
105
|
+
return await fs.stat(absolutePath);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Resolve `@path` mentions into image attachments.
|
|
113
|
+
*
|
|
114
|
+
* - Mentions that do not resolve to an existing file stay literal
|
|
115
|
+
* prompt text (emails, handles, typos) — no error.
|
|
116
|
+
* - Existing paths with a non-image extension stay literal text too; the
|
|
117
|
+
* read-blessing resolver picks them up so the model can `readFile` them.
|
|
118
|
+
* - Existing image-extension paths that are not regular files (e.g. a
|
|
119
|
+
* directory named `foo.png`) fail loudly — that is a genuine attach-intent
|
|
120
|
+
* mismatch, not silent drop.
|
|
121
|
+
* - An `@` mention is an explicit user-typed reference, so any host path
|
|
122
|
+
* works: workspace-relative (including `../`), absolute, or `~/`. The real
|
|
123
|
+
* path dedupes aliases (symlinks, `..` segments) instead of confining
|
|
124
|
+
* reads; `.gitignore` is not enforced here (documented in AGENTS.md).
|
|
125
|
+
* - Size and per-message count are bounded by named limits; errors name them.
|
|
126
|
+
* - The same file mentioned twice is attached once; both mentions are stripped.
|
|
127
|
+
*/
|
|
128
|
+
export async function resolveImageAttachments(text) {
|
|
129
|
+
const mentions = extractPathMentions(text);
|
|
130
|
+
if (mentions.length === 0)
|
|
131
|
+
return { text, attachments: [] };
|
|
132
|
+
const attachments = [];
|
|
133
|
+
const seenRealPaths = new Set();
|
|
134
|
+
const strippedTokens = new Set();
|
|
135
|
+
for (const { token } of mentions) {
|
|
136
|
+
// Backslash escapes (`\ `, `\(`, …) are removed for filesystem resolution
|
|
137
|
+
// but kept in `token` so the mention can be stripped from the prompt
|
|
138
|
+
// exactly as the user typed it. macOS screenshot paths and other host
|
|
139
|
+
// paths commonly contain spaces; without unescape the file would never
|
|
140
|
+
// resolve and the mention would silently become plain text.
|
|
141
|
+
const resolveToken = token.replace(/\\(.)/g, '$1');
|
|
142
|
+
// A sentence-ending period ("@shot.png.") is not part of the filename, so
|
|
143
|
+
// fall back to the trailing-dot-stripped form when the verbatim path does
|
|
144
|
+
// not exist; the image is then attached instead of being silently left as
|
|
145
|
+
// text.
|
|
146
|
+
let fileToken = resolveToken;
|
|
147
|
+
let absolutePath = resolveAttachmentPath(resolveToken);
|
|
148
|
+
let stats = await statFile(absolutePath);
|
|
149
|
+
if (!stats) {
|
|
150
|
+
const trimmed = resolveToken.replace(/\.+$/, '');
|
|
151
|
+
if (trimmed && trimmed !== resolveToken) {
|
|
152
|
+
const trimmedPath = resolveAttachmentPath(trimmed);
|
|
153
|
+
const trimmedStats = await statFile(trimmedPath);
|
|
154
|
+
if (trimmedStats) {
|
|
155
|
+
fileToken = trimmed;
|
|
156
|
+
absolutePath = trimmedPath;
|
|
157
|
+
stats = trimmedStats;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (!stats)
|
|
162
|
+
continue; // Not an existing path: leave the mention as literal text.
|
|
163
|
+
const mediaType = IMAGE_MEDIA_TYPES[path.extname(fileToken).toLowerCase()];
|
|
164
|
+
if (!mediaType)
|
|
165
|
+
continue; // Non-image extension: leave as text; resolveReadBlessings blesses it.
|
|
166
|
+
if (!stats.isFile())
|
|
167
|
+
throw notAnImageError(fileToken); // Image extension but directory: genuine mismatch.
|
|
168
|
+
const realPath = await fs.realpath(absolutePath);
|
|
169
|
+
if (seenRealPaths.has(realPath)) {
|
|
170
|
+
strippedTokens.add(token); // Same file already attached; still strip the repeat.
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (stats.size > IMAGE_ATTACHMENT_BYTES) {
|
|
174
|
+
throw new Error(`Image too large: @${fileToken} is ${formatBytes(stats.size)}; the attachment limit is ${formatBytes(IMAGE_ATTACHMENT_BYTES)} per image.`);
|
|
175
|
+
}
|
|
176
|
+
if (attachments.length >= IMAGE_ATTACHMENTS_PER_MESSAGE) {
|
|
177
|
+
throw new Error(`Too many image attachments: at most ${IMAGE_ATTACHMENTS_PER_MESSAGE} per message.`);
|
|
178
|
+
}
|
|
179
|
+
const data = new Uint8Array(await fs.readFile(realPath));
|
|
180
|
+
seenRealPaths.add(realPath);
|
|
181
|
+
strippedTokens.add(token);
|
|
182
|
+
attachments.push({
|
|
183
|
+
displayPath: displayPathFor(realPath),
|
|
184
|
+
absolutePath: realPath,
|
|
185
|
+
fileName: path.basename(realPath),
|
|
186
|
+
mediaType,
|
|
187
|
+
bytes: data.byteLength,
|
|
188
|
+
data,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
if (strippedTokens.size === 0)
|
|
192
|
+
return { text, attachments };
|
|
193
|
+
// Strip attached mentions (explicit `@` and bare), then tidy the double
|
|
194
|
+
// space a mid-line removal can leave behind. The lookbehind keeps line-
|
|
195
|
+
// leading indentation intact.
|
|
196
|
+
const cleaned = text
|
|
197
|
+
.replace(MENTION_PATTERN, (mention, token) => strippedTokens.has(token) ? '' : mention)
|
|
198
|
+
.replace(BARE_PATH_PATTERN, (match, token) => strippedTokens.has(token) ? '' : match)
|
|
199
|
+
.replace(/(?<=[^\n])[ \t]{2,}/g, ' ')
|
|
200
|
+
.trim();
|
|
201
|
+
return { text: cleaned, attachments };
|
|
202
|
+
}
|
|
203
|
+
/** Build the turn's user message: plain string without attachments, multipart with. */
|
|
204
|
+
export function userTurnMessage(text, attachments) {
|
|
205
|
+
if (attachments.length === 0)
|
|
206
|
+
return { role: 'user', content: text };
|
|
207
|
+
const parts = [
|
|
208
|
+
...(text.trim() ? [{ type: 'text', text }] : []),
|
|
209
|
+
...attachments.map(attachment => ({ type: 'file', mediaType: attachment.mediaType, data: attachment.data, filename: attachment.fileName })),
|
|
210
|
+
];
|
|
211
|
+
return { role: 'user', content: parts };
|
|
212
|
+
}
|
|
213
|
+
/** Minimal prompt text used when a message contains only images. */
|
|
214
|
+
export const IMAGE_ONLY_PROMPT_TEXT = 'See the attached image.';
|
|
215
|
+
/**
|
|
216
|
+
* Loud capability gate (constitution VII): images only go to providers the
|
|
217
|
+
* user explicitly marked image-capable. Returns undefined when the provider
|
|
218
|
+
* may receive image parts, otherwise an actionable error message.
|
|
219
|
+
*/
|
|
220
|
+
export function imageCapabilityError(provider) {
|
|
221
|
+
if (provider?.capabilities?.images === true)
|
|
222
|
+
return undefined;
|
|
223
|
+
if (!provider)
|
|
224
|
+
return 'No provider is configured. Run /provider to add one, then attach the image again.';
|
|
225
|
+
return `Provider '${provider.name}' is not marked image-capable. Enable image input for it via /provider, or switch models.`;
|
|
226
|
+
}
|
|
227
|
+
/** Guard for AI SDK `file` parts carrying images, in any message role. */
|
|
228
|
+
export function isImageFilePart(value) {
|
|
229
|
+
if (typeof value !== 'object' || value == null)
|
|
230
|
+
return false;
|
|
231
|
+
const part = value;
|
|
232
|
+
return part.type === 'file' && typeof part.mediaType === 'string' && part.mediaType.startsWith('image/');
|
|
233
|
+
}
|
|
234
|
+
/** Byte size of a file part's data without serializing it. */
|
|
235
|
+
export function imageFilePartBytes(data) {
|
|
236
|
+
let candidate = data;
|
|
237
|
+
if (typeof candidate === 'object' && candidate != null && candidate.type === 'data') {
|
|
238
|
+
candidate = candidate.data;
|
|
239
|
+
}
|
|
240
|
+
if (candidate instanceof Uint8Array || candidate instanceof ArrayBuffer)
|
|
241
|
+
return candidate.byteLength;
|
|
242
|
+
if (typeof candidate === 'string')
|
|
243
|
+
return Math.floor(candidate.length * 3 / 4); // base64 payload
|
|
244
|
+
return 0;
|
|
245
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-blessings for paths the user mentioned in the prompt (F03 follow-on).
|
|
3
|
+
*
|
|
4
|
+
* When the user types `@path` or a bare path containing `/`, the model is
|
|
5
|
+
* allowed to `readFile` / `grep` it even outside `process.cwd()`. This module
|
|
6
|
+
* resolves those mentions into a deduped list of blessed real paths. The
|
|
7
|
+
* read-tooling layer consults `isPathBlessed` to skip workspace confinement
|
|
8
|
+
* for them. Mutating tools never consult this set.
|
|
9
|
+
*
|
|
10
|
+
* Like image attachments: an `@` mention is an explicit user-typed reference,
|
|
11
|
+
* so host paths are allowed. Unlike image attachments: text paths stay in the
|
|
12
|
+
* prompt text (the model needs the cue to know what to read).
|
|
13
|
+
*/
|
|
14
|
+
export interface BlessedPath {
|
|
15
|
+
/** Canonical real path (post-symlink-resolution). */
|
|
16
|
+
realPath: string;
|
|
17
|
+
/** Whether the blessed path is a directory; directories bless the whole tree. */
|
|
18
|
+
isDirectory: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface ResolvedReadBlessings {
|
|
21
|
+
blessedPaths: BlessedPath[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Resolve `@path` and bare-path mentions into read-blessings.
|
|
25
|
+
*
|
|
26
|
+
* - Image-extension paths are skipped — `resolveImageAttachments` owns them.
|
|
27
|
+
* - Mentions that do not resolve to an existing file or directory are skipped.
|
|
28
|
+
* - The real path dedupes aliases (symlinks, `..` segments).
|
|
29
|
+
* - Mentions are NOT stripped from the prompt text: the model needs them as a
|
|
30
|
+
* cue to know what to read.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveReadBlessings(text: string): Promise<ResolvedReadBlessings>;
|
|
33
|
+
/**
|
|
34
|
+
* Whether a requested real path may be read outside workspace confinement.
|
|
35
|
+
* True if the path is itself blessed, or falls inside a blessed directory.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isPathBlessed(requestedRealPath: string, blessed: readonly BlessedPath[]): boolean;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { extractPathMentions, IMAGE_MEDIA_TYPES } from './imageAttachments.js';
|
|
5
|
+
import { workspaceRoot } from '../../utils/path.js';
|
|
6
|
+
function resolveAttachmentPath(token) {
|
|
7
|
+
if (token === '~' || token.startsWith('~/'))
|
|
8
|
+
return path.join(os.homedir(), token.slice(1));
|
|
9
|
+
return path.resolve(workspaceRoot(), token);
|
|
10
|
+
}
|
|
11
|
+
async function statFile(absolutePath) {
|
|
12
|
+
try {
|
|
13
|
+
return await fs.stat(absolutePath);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolve `@path` and bare-path mentions into read-blessings.
|
|
21
|
+
*
|
|
22
|
+
* - Image-extension paths are skipped — `resolveImageAttachments` owns them.
|
|
23
|
+
* - Mentions that do not resolve to an existing file or directory are skipped.
|
|
24
|
+
* - The real path dedupes aliases (symlinks, `..` segments).
|
|
25
|
+
* - Mentions are NOT stripped from the prompt text: the model needs them as a
|
|
26
|
+
* cue to know what to read.
|
|
27
|
+
*/
|
|
28
|
+
export async function resolveReadBlessings(text) {
|
|
29
|
+
const mentions = extractPathMentions(text);
|
|
30
|
+
if (mentions.length === 0)
|
|
31
|
+
return { blessedPaths: [] };
|
|
32
|
+
const blessedPaths = [];
|
|
33
|
+
const seenRealPaths = new Set();
|
|
34
|
+
for (const { token } of mentions) {
|
|
35
|
+
// Backslash escapes are removed for filesystem resolution (same rule as
|
|
36
|
+
// image attachments). See imageAttachments.ts for the rationale.
|
|
37
|
+
const resolveToken = token.replace(/\\(.)/g, '$1');
|
|
38
|
+
// Image-extension paths are owned by the image attachment system; skip
|
|
39
|
+
// them here so an attached image is not also blessed for read.
|
|
40
|
+
if (IMAGE_MEDIA_TYPES[path.extname(resolveToken).toLowerCase()])
|
|
41
|
+
continue;
|
|
42
|
+
// Sentence-ending period is not part of the filename — same fallback as
|
|
43
|
+
// for image attachments.
|
|
44
|
+
let absolutePath = resolveAttachmentPath(resolveToken);
|
|
45
|
+
let stats = await statFile(absolutePath);
|
|
46
|
+
if (!stats) {
|
|
47
|
+
const trimmed = resolveToken.replace(/\.+$/, '');
|
|
48
|
+
if (trimmed && trimmed !== resolveToken) {
|
|
49
|
+
const trimmedPath = resolveAttachmentPath(trimmed);
|
|
50
|
+
const trimmedStats = await statFile(trimmedPath);
|
|
51
|
+
if (trimmedStats) {
|
|
52
|
+
absolutePath = trimmedPath;
|
|
53
|
+
stats = trimmedStats;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (!stats)
|
|
58
|
+
continue;
|
|
59
|
+
const realPath = await fs.realpath(absolutePath);
|
|
60
|
+
if (seenRealPaths.has(realPath))
|
|
61
|
+
continue;
|
|
62
|
+
seenRealPaths.add(realPath);
|
|
63
|
+
blessedPaths.push({ realPath, isDirectory: stats.isDirectory() });
|
|
64
|
+
}
|
|
65
|
+
return { blessedPaths };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Whether a requested real path may be read outside workspace confinement.
|
|
69
|
+
* True if the path is itself blessed, or falls inside a blessed directory.
|
|
70
|
+
*/
|
|
71
|
+
export function isPathBlessed(requestedRealPath, blessed) {
|
|
72
|
+
for (const entry of blessed) {
|
|
73
|
+
if (entry.realPath === requestedRealPath)
|
|
74
|
+
return true;
|
|
75
|
+
if (entry.isDirectory && requestedRealPath.startsWith(`${entry.realPath}${path.sep}`))
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
export type RequestIntent = 'implement' | 'fix' | 'test' | 'review' | 'plan' | 'answer' | 'unknown';
|
|
2
2
|
export declare function isPlanOnlyRequest(value: string): boolean;
|
|
3
|
-
export declare function isPlanImplementationRequest(value: string): boolean;
|
|
4
|
-
export declare function isValidationRequest(value: string): boolean;
|
|
5
|
-
export declare function isActionRequest(value: string): boolean;
|
|
6
3
|
export declare function classifyRequestIntent(value: string): RequestIntent;
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
export function isPlanOnlyRequest(value) {
|
|
2
2
|
return /\b(create|make|write|draft|outline)\s+(?:a\s+)?plan\b|\bplan\s+(?:for|to)\b/i.test(value) && !/\bimplement|execute|do\b/i.test(value);
|
|
3
3
|
}
|
|
4
|
-
export function isPlanImplementationRequest(value) {
|
|
5
|
-
return /\b(implement|execute|do)\b.*\bplan\b|\bplan\.md\b|\btest_plan\.md\b/i.test(value);
|
|
6
|
-
}
|
|
7
|
-
export function isValidationRequest(value) {
|
|
8
|
-
if (isPlanOnlyRequest(value))
|
|
9
|
-
return false;
|
|
10
|
-
return /\b(run|verify|test|tests|check|validate)\b/i.test(value);
|
|
11
|
-
}
|
|
12
|
-
export function isActionRequest(value) {
|
|
13
|
-
if (isPlanOnlyRequest(value))
|
|
14
|
-
return false;
|
|
15
|
-
return /\b(add|create|write|implement|update|fix|change|support|wire|test|tests|document|docs|documentation|run|verify)\b/i.test(value);
|
|
16
|
-
}
|
|
17
4
|
export function classifyRequestIntent(value) {
|
|
18
5
|
if (isPlanOnlyRequest(value))
|
|
19
6
|
return 'plan';
|
|
@@ -2,9 +2,9 @@ import { createReadStream } from 'node:fs';
|
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
3
|
import { StringDecoder } from 'node:string_decoder';
|
|
4
4
|
import { TEXT_LINE_BYTES } from '../limits/byteBudgets.js';
|
|
5
|
-
|
|
6
|
-
const input = createReadStream(file);
|
|
7
|
-
let lineNumber =
|
|
5
|
+
async function* iterateBoundedUtf8LinesFrom(file, maxLineBytes, startByte, previousLineNumber) {
|
|
6
|
+
const input = createReadStream(file, startByte > 0 ? { start: startByte } : undefined);
|
|
7
|
+
let lineNumber = previousLineNumber;
|
|
8
8
|
let retained = [];
|
|
9
9
|
let retainedBytes = 0;
|
|
10
10
|
let lineBytes = 0;
|
|
@@ -50,37 +50,84 @@ export async function* iterateBoundedUtf8Lines(file, maxLineBytes) {
|
|
|
50
50
|
if (lineBytes > 0 || retainedBytes > 0)
|
|
51
51
|
yield finish();
|
|
52
52
|
}
|
|
53
|
-
export async function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
export async function* iterateBoundedUtf8Lines(file, maxLineBytes) {
|
|
54
|
+
yield* iterateBoundedUtf8LinesFrom(file, maxLineBytes, 0, 0);
|
|
55
|
+
}
|
|
56
|
+
const MAX_LINE_INDEX_FILES = 8;
|
|
57
|
+
const MAX_LINE_CHECKPOINTS = 8_192;
|
|
58
|
+
const lineIndexCache = new Map();
|
|
59
|
+
function sameFileSignature(index, stat) {
|
|
60
|
+
return index.size === stat.size && index.mtimeMs === stat.mtimeMs && index.ctimeMs === stat.ctimeMs;
|
|
61
|
+
}
|
|
62
|
+
async function buildLineIndex(file, stat) {
|
|
63
|
+
let totalLines = 1;
|
|
64
|
+
let byteOffset = 0;
|
|
65
|
+
let stride = 256;
|
|
66
|
+
let trailingNewline = false;
|
|
67
|
+
let checkpoints = [{ lineNumber: 1, byteOffset: 0 }];
|
|
68
|
+
for await (const value of createReadStream(file)) {
|
|
69
|
+
const chunk = Buffer.isBuffer(value) ? value : Buffer.from(value);
|
|
70
|
+
let cursor = 0;
|
|
71
|
+
while (cursor < chunk.length) {
|
|
72
|
+
const newline = chunk.indexOf(10, cursor);
|
|
73
|
+
if (newline === -1)
|
|
74
|
+
break;
|
|
75
|
+
totalLines++;
|
|
76
|
+
const lineStart = byteOffset + newline + 1;
|
|
77
|
+
if ((totalLines - 1) % stride === 0)
|
|
78
|
+
checkpoints.push({ lineNumber: totalLines, byteOffset: lineStart });
|
|
79
|
+
if (checkpoints.length > MAX_LINE_CHECKPOINTS) {
|
|
80
|
+
stride *= 2;
|
|
81
|
+
checkpoints = checkpoints.filter(point => (point.lineNumber - 1) % stride === 0);
|
|
82
|
+
}
|
|
83
|
+
cursor = newline + 1;
|
|
60
84
|
}
|
|
85
|
+
trailingNewline = chunk.length > 0 ? chunk[chunk.length - 1] === 10 : trailingNewline;
|
|
86
|
+
byteOffset += chunk.length;
|
|
61
87
|
}
|
|
88
|
+
return { size: stat.size, mtimeMs: stat.mtimeMs, ctimeMs: stat.ctimeMs, totalLines, trailingNewline, checkpoints };
|
|
89
|
+
}
|
|
90
|
+
async function lineIndex(file) {
|
|
62
91
|
const stat = await fs.stat(file);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
92
|
+
const cached = lineIndexCache.get(file);
|
|
93
|
+
if (cached && sameFileSignature(cached, stat)) {
|
|
94
|
+
lineIndexCache.delete(file);
|
|
95
|
+
lineIndexCache.set(file, cached);
|
|
96
|
+
return cached;
|
|
67
97
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
98
|
+
const index = await buildLineIndex(file, stat);
|
|
99
|
+
lineIndexCache.delete(file);
|
|
100
|
+
lineIndexCache.set(file, index);
|
|
101
|
+
while (lineIndexCache.size > MAX_LINE_INDEX_FILES) {
|
|
102
|
+
const oldest = lineIndexCache.keys().next().value;
|
|
103
|
+
if (oldest == null)
|
|
104
|
+
break;
|
|
105
|
+
lineIndexCache.delete(oldest);
|
|
106
|
+
}
|
|
107
|
+
return index;
|
|
108
|
+
}
|
|
109
|
+
export async function readUtf8LinesPage(file, offset, limit) {
|
|
110
|
+
const index = await lineIndex(file);
|
|
111
|
+
const lines = [];
|
|
112
|
+
if (limit <= 0 || offset > index.totalLines)
|
|
113
|
+
return { lines, totalLines: index.totalLines };
|
|
114
|
+
let checkpoint = index.checkpoints[0];
|
|
115
|
+
for (const candidate of index.checkpoints) {
|
|
116
|
+
if (candidate.lineNumber > offset)
|
|
117
|
+
break;
|
|
118
|
+
checkpoint = candidate;
|
|
119
|
+
}
|
|
120
|
+
for await (const entry of iterateBoundedUtf8LinesFrom(file, TEXT_LINE_BYTES, checkpoint.byteOffset, checkpoint.lineNumber - 1)) {
|
|
121
|
+
if (entry.lineNumber < offset)
|
|
122
|
+
continue;
|
|
123
|
+
lines.push(entry.oversized ? `${entry.line}\n[Line truncated at ${TEXT_LINE_BYTES} bytes]` : entry.line);
|
|
124
|
+
if (lines.length >= limit)
|
|
125
|
+
break;
|
|
82
126
|
}
|
|
83
|
-
|
|
127
|
+
const includesSyntheticLastLine = index.size === 0 || index.trailingNewline;
|
|
128
|
+
if (includesSyntheticLastLine && offset <= index.totalLines && index.totalLines < offset + limit && lines.length < limit)
|
|
129
|
+
lines.push('');
|
|
130
|
+
return { lines, totalLines: index.totalLines };
|
|
84
131
|
}
|
|
85
132
|
export async function readUtf8Prefix(file, maxBytes) {
|
|
86
133
|
const stat = await fs.stat(file);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const BASH_STREAM_BYTES: number;
|
|
2
|
+
export declare const BACKGROUND_PROCESS_OUTPUT_BYTES: number;
|
|
2
3
|
export declare const GREP_STREAM_BYTES: number;
|
|
3
4
|
export declare const PROCESS_STDERR_BYTES: number;
|
|
4
5
|
export declare const TOOL_OUTPUT_ENTRY_BYTES: number;
|
|
@@ -11,3 +12,7 @@ export declare const SKILL_MARKDOWN_BYTES: number;
|
|
|
11
12
|
export declare const EXACT_MUTATION_BYTES: number;
|
|
12
13
|
export declare const JSONL_LINE_BYTES: number;
|
|
13
14
|
export declare const TEXT_LINE_BYTES: number;
|
|
15
|
+
/** Maximum size of one user-attached image (checked before the read). */
|
|
16
|
+
export declare const IMAGE_ATTACHMENT_BYTES: number;
|
|
17
|
+
/** Maximum number of image attachments in a single user message. */
|
|
18
|
+
export declare const IMAGE_ATTACHMENTS_PER_MESSAGE = 4;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export const BASH_STREAM_BYTES = 2 * 1024 * 1024;
|
|
2
|
+
export const BACKGROUND_PROCESS_OUTPUT_BYTES = 256 * 1024;
|
|
2
3
|
export const GREP_STREAM_BYTES = 8 * 1024 * 1024;
|
|
3
4
|
export const PROCESS_STDERR_BYTES = 64 * 1024;
|
|
4
5
|
export const TOOL_OUTPUT_ENTRY_BYTES = 2 * 1024 * 1024;
|
|
@@ -11,3 +12,7 @@ export const SKILL_MARKDOWN_BYTES = 256 * 1024;
|
|
|
11
12
|
export const EXACT_MUTATION_BYTES = 8 * 1024 * 1024;
|
|
12
13
|
export const JSONL_LINE_BYTES = 4 * 1024 * 1024;
|
|
13
14
|
export const TEXT_LINE_BYTES = 1024 * 1024;
|
|
15
|
+
/** Maximum size of one user-attached image (checked before the read). */
|
|
16
|
+
export const IMAGE_ATTACHMENT_BYTES = 5 * 1024 * 1024;
|
|
17
|
+
/** Maximum number of image attachments in a single user message. */
|
|
18
|
+
export const IMAGE_ATTACHMENTS_PER_MESSAGE = 4;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-facing text caps (characters). Byte budgets live in `byteBudgets.ts`;
|
|
3
|
+
* these bound the text returned to the model or persisted in previews so
|
|
4
|
+
* callers cite a named constant instead of a magic number (CR-014).
|
|
5
|
+
*/
|
|
6
|
+
/** Per-page cap for numbered file content returned by readFile/listFiles-style tools. */
|
|
7
|
+
export declare const MAX_OUTPUT_CHARS = 50000;
|
|
8
|
+
/** Default compact cap for stored bash output shown to the model. */
|
|
9
|
+
export declare const COMPACT_COMMAND_CHARS = 12000;
|
|
10
|
+
/** Compact cap for passing-validation summaries. */
|
|
11
|
+
export declare const SHORT_VALIDATION_CHARS = 2000;
|
|
12
|
+
/** Total rendered size cap for grep match output. */
|
|
13
|
+
export declare const GREP_MAX_OUTPUT_CHARS = 30000;
|
|
14
|
+
/** Per-line cap for rendered grep matches. */
|
|
15
|
+
export declare const GREP_MAX_LINE_CHARS = 500;
|
|
16
|
+
/** Bounded excerpt of older messages kept by /compact-style compaction. */
|
|
17
|
+
export declare const COMPACTION_OLDER_CHARS = 8000;
|
|
18
|
+
/** Session JSONL values up to this size stay inline; larger ones become previews. */
|
|
19
|
+
export declare const SESSION_INLINE_VALUE_BYTES: number;
|
|
20
|
+
/** Preview length for slimmed session values. */
|
|
21
|
+
export declare const SESSION_PREVIEW_CHARS: number;
|
|
22
|
+
/** Strings longer than this are truncated in session snapshots. */
|
|
23
|
+
export declare const SESSION_LARGE_STRING_CHARS: number;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-facing text caps (characters). Byte budgets live in `byteBudgets.ts`;
|
|
3
|
+
* these bound the text returned to the model or persisted in previews so
|
|
4
|
+
* callers cite a named constant instead of a magic number (CR-014).
|
|
5
|
+
*/
|
|
6
|
+
/** Per-page cap for numbered file content returned by readFile/listFiles-style tools. */
|
|
7
|
+
export const MAX_OUTPUT_CHARS = 50_000;
|
|
8
|
+
/** Default compact cap for stored bash output shown to the model. */
|
|
9
|
+
export const COMPACT_COMMAND_CHARS = 12_000;
|
|
10
|
+
/** Compact cap for passing-validation summaries. */
|
|
11
|
+
export const SHORT_VALIDATION_CHARS = 2_000;
|
|
12
|
+
/** Total rendered size cap for grep match output. */
|
|
13
|
+
export const GREP_MAX_OUTPUT_CHARS = 30_000;
|
|
14
|
+
/** Per-line cap for rendered grep matches. */
|
|
15
|
+
export const GREP_MAX_LINE_CHARS = 500;
|
|
16
|
+
/** Bounded excerpt of older messages kept by /compact-style compaction. */
|
|
17
|
+
export const COMPACTION_OLDER_CHARS = 8_000;
|
|
18
|
+
/** Session JSONL values up to this size stay inline; larger ones become previews. */
|
|
19
|
+
export const SESSION_INLINE_VALUE_BYTES = 32 * 1024;
|
|
20
|
+
/** Preview length for slimmed session values. */
|
|
21
|
+
export const SESSION_PREVIEW_CHARS = 4 * 1024;
|
|
22
|
+
/** Strings longer than this are truncated in session snapshots. */
|
|
23
|
+
export const SESSION_LARGE_STRING_CHARS = 8 * 1024;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type BackgroundProcessStatus = 'running' | 'exited' | 'failed' | 'killed';
|
|
2
|
+
export interface BackgroundProcessSummary {
|
|
3
|
+
backgroundId: string;
|
|
4
|
+
pid?: number;
|
|
5
|
+
command: string;
|
|
6
|
+
cwd: string;
|
|
7
|
+
startedAt: string;
|
|
8
|
+
status: BackgroundProcessStatus;
|
|
9
|
+
code?: number | null;
|
|
10
|
+
signal?: NodeJS.Signals | null;
|
|
11
|
+
outputHandle: string;
|
|
12
|
+
outputBytes: {
|
|
13
|
+
totalBytes: number;
|
|
14
|
+
retainedBytes: number;
|
|
15
|
+
omittedBytes: number;
|
|
16
|
+
};
|
|
17
|
+
error?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function backgroundProcessCount(): number;
|
|
20
|
+
export declare function subscribeBackgroundProcesses(listener: () => void): () => void;
|
|
21
|
+
export declare function listBackgroundProcesses(): BackgroundProcessSummary[];
|
|
22
|
+
export declare function getBackgroundProcess(backgroundId: string): BackgroundProcessSummary | undefined;
|
|
23
|
+
export declare function startBackgroundProcess(input: {
|
|
24
|
+
command: string;
|
|
25
|
+
cwd: string;
|
|
26
|
+
}): BackgroundProcessSummary;
|
|
27
|
+
export declare function killBackgroundProcess(backgroundId: string, killGraceMs?: number): Promise<BackgroundProcessSummary | undefined>;
|
|
28
|
+
/** Terminate every owned tree and clear the session-local registry and handles. */
|
|
29
|
+
export declare function teardownBackgroundProcesses(killGraceMs?: number): Promise<BackgroundProcessSummary[]>;
|
|
30
|
+
/** Install CLI-level abnormal-exit teardown for SIGINT and SIGTERM. */
|
|
31
|
+
export declare function installBackgroundProcessSignalHandlers(): void;
|
|
32
|
+
/** Best-effort synchronous safety net for process.exit and otherwise unawaitable exits. */
|
|
33
|
+
export declare function terminateBackgroundProcessesSync(): void;
|
|
34
|
+
/** Test-only reset; callers should normally use teardownBackgroundProcesses. */
|
|
35
|
+
export declare function resetBackgroundProcessesForTests(): Promise<void>;
|