@denizokcu/haze 0.6.0 → 0.7.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 +19 -0
- package/README.md +59 -12
- package/dist/cli/chat/TaskBar.d.ts +9 -0
- package/dist/cli/chat/TaskBar.js +40 -0
- package/dist/cli/chat/chatMetrics.d.ts +11 -0
- package/dist/cli/chat/chatMetrics.js +50 -0
- package/dist/cli/chat/inputSuggestions.d.ts +16 -0
- package/dist/cli/chat/inputSuggestions.js +55 -0
- package/dist/cli/chat/messages.d.ts +9 -0
- package/dist/cli/chat/messages.js +76 -0
- package/dist/cli/chat/sessionRecorder.d.ts +12 -0
- package/dist/cli/chat/sessionRecorder.js +21 -0
- package/dist/cli/chat/startupInfo.d.ts +4 -0
- package/dist/cli/chat/startupInfo.js +53 -0
- package/dist/cli/chat/turnState.d.ts +5 -0
- package/dist/cli/chat/turnState.js +20 -0
- package/dist/cli/commands/chat.d.ts +0 -1
- package/dist/cli/commands/chat.js +293 -894
- package/dist/cli/commands/chatModes.d.ts +8 -0
- package/dist/cli/commands/chatModes.js +44 -0
- package/dist/cli/commands/commandHelp.d.ts +6 -0
- package/dist/cli/commands/commandHelp.js +25 -0
- package/dist/cli/commands/commands.d.ts +1 -1
- package/dist/cli/commands/commands.js +41 -267
- package/dist/cli/commands/formatters.js +12 -4
- package/dist/cli/commands/initCommand.d.ts +2 -0
- package/dist/cli/commands/initCommand.js +19 -0
- package/dist/cli/commands/logsCommand.d.ts +2 -0
- package/dist/cli/commands/logsCommand.js +63 -0
- package/dist/cli/commands/lspWizard.d.ts +14 -0
- package/dist/cli/commands/lspWizard.js +44 -0
- package/dist/cli/commands/mcpWizard.d.ts +15 -0
- package/dist/cli/commands/mcpWizard.js +69 -0
- package/dist/cli/commands/modelCommand.d.ts +2 -0
- package/dist/cli/commands/modelCommand.js +36 -0
- package/dist/cli/commands/providerWizard.d.ts +30 -0
- package/dist/cli/commands/providerWizard.js +114 -0
- package/dist/cli/commands/runCommand.d.ts +16 -0
- package/dist/cli/commands/runCommand.js +170 -0
- package/dist/cli/commands/settingsSummary.d.ts +3 -0
- package/dist/cli/commands/settingsSummary.js +40 -0
- package/dist/cli/commands/skillConfirmRemove.d.ts +11 -0
- package/dist/cli/commands/skillConfirmRemove.js +19 -0
- package/dist/cli/commands/skillCreation.d.ts +12 -0
- package/dist/cli/commands/skillCreation.js +14 -0
- package/dist/cli/commands/skillWizard.d.ts +15 -0
- package/dist/cli/commands/skillWizard.js +38 -0
- package/dist/cli/commands/streaming/assistantText.d.ts +17 -0
- package/dist/cli/commands/streaming/assistantText.js +115 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +55 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.js +102 -0
- package/dist/cli/commands/streaming/toolResultState.d.ts +13 -0
- package/dist/cli/commands/streaming/toolResultState.js +25 -0
- package/dist/cli/commands/streaming/turnRuntime.d.ts +78 -0
- package/dist/cli/commands/streaming/turnRuntime.js +86 -0
- package/dist/cli/commands/streaming.d.ts +9 -25
- package/dist/cli/commands/streaming.js +82 -347
- package/dist/cli/commands/wizardActions.d.ts +40 -0
- package/dist/cli/commands/wizardActions.js +40 -0
- package/dist/cli/commands/wizardInput.d.ts +4 -0
- package/dist/cli/commands/wizardInput.js +19 -0
- package/dist/cli/commands/wizardPrompts.d.ts +22 -0
- package/dist/cli/commands/wizardPrompts.js +52 -0
- package/dist/cli/commands/wizardSuggestions.d.ts +23 -0
- package/dist/cli/commands/wizardSuggestions.js +139 -0
- package/dist/cli/index.js +62 -4
- package/dist/config/contextFiles.d.ts +8 -1
- package/dist/config/contextFiles.js +25 -12
- package/dist/config/lspSettings.js +3 -6
- package/dist/config/mcpSettings.js +5 -5
- package/dist/config/providers.js +4 -4
- package/dist/config/skillSettings.js +4 -3
- package/dist/core/agent/budgets.d.ts +6 -0
- package/dist/core/agent/budgets.js +6 -0
- package/dist/core/agent/compaction.js +1 -1
- package/dist/core/agent/requestAssembly.d.ts +0 -7
- package/dist/core/agent/requestAssembly.js +27 -5
- package/dist/core/agent/toolOutputStore.js +5 -4
- package/dist/core/agent/toolResults.d.ts +31 -0
- package/dist/core/agent/toolResults.js +42 -0
- package/dist/core/agent/turnPolicy.d.ts +8 -0
- package/dist/core/agent/turnPolicy.js +23 -0
- package/dist/core/agent/workState.d.ts +18 -5
- package/dist/core/agent/workState.js +39 -20
- package/dist/core/bashOutput/reducers/content.d.ts +1 -0
- package/dist/core/bashOutput/reducers/content.js +1 -1
- package/dist/core/bashOutput/reducers/gh.d.ts +1 -0
- package/dist/core/bashOutput/reducers/gh.js +77 -0
- package/dist/core/bashOutput/registry.js +8 -0
- package/dist/core/goal/sessionGoal.d.ts +6 -30
- package/dist/core/goal/sessionGoal.js +3 -68
- package/dist/core/safety/bashClassifier.js +30 -0
- package/dist/core/safety/urlGuard.d.ts +1 -0
- package/dist/core/safety/urlGuard.js +6 -1
- package/dist/core/session/sessionSlimming.d.ts +5 -0
- package/dist/core/session/sessionSlimming.js +78 -0
- package/dist/core/session/sessionStore.d.ts +23 -3
- package/dist/core/session/sessionStore.js +30 -10
- package/dist/core/subagent/subagentRunner.d.ts +11 -1
- package/dist/core/subagent/subagentRunner.js +1 -0
- package/dist/llm/capabilities.d.ts +12 -0
- package/dist/llm/capabilities.js +10 -0
- package/dist/llm/client.d.ts +1 -0
- package/dist/llm/client.js +11 -2
- package/dist/llm/hazeTools.d.ts +31 -32
- package/dist/llm/hazeTools.js +40 -567
- package/dist/llm/lsp.d.ts +46 -1
- package/dist/llm/lsp.js +9 -9
- package/dist/llm/lspTools.d.ts +2 -20
- package/dist/llm/mcp.js +9 -0
- package/dist/llm/requestContext.js +7 -22
- package/dist/llm/systemPrompt.d.ts +1 -0
- package/dist/llm/systemPrompt.js +1 -1
- package/dist/llm/tools/bashTool.d.ts +5 -0
- package/dist/llm/tools/bashTool.js +81 -0
- package/dist/llm/tools/editMatch.d.ts +55 -0
- package/dist/llm/tools/editMatch.js +99 -0
- package/dist/llm/tools/failures.d.ts +36 -0
- package/dist/llm/tools/failures.js +38 -0
- package/dist/llm/tools/fetchTool.d.ts +65 -0
- package/dist/llm/tools/fetchTool.js +45 -0
- package/dist/llm/tools/fileToolShared.d.ts +10 -0
- package/dist/llm/tools/fileToolShared.js +43 -0
- package/dist/llm/tools/grepParse.d.ts +13 -0
- package/dist/llm/tools/grepParse.js +67 -0
- package/dist/llm/tools/outputCap.d.ts +53 -0
- package/dist/llm/tools/outputCap.js +67 -0
- package/dist/llm/tools/storedOutputTool.d.ts +10 -0
- package/dist/llm/tools/storedOutputTool.js +17 -0
- package/dist/llm/tools/taskTool.d.ts +28 -0
- package/dist/llm/tools/taskTool.js +41 -0
- package/dist/llm/tools/toolContext.d.ts +69 -0
- package/dist/llm/tools/toolContext.js +187 -0
- package/dist/llm/tools/workspaceFile.d.ts +33 -0
- package/dist/llm/tools/workspaceFile.js +27 -0
- package/dist/llm/webFetch.d.ts +13 -1
- package/dist/llm/webFetch.js +91 -7
- package/dist/skills/builder/SkillBuilder.d.ts +3 -0
- package/dist/skills/builder/SkillBuilder.js +1 -1
- package/dist/ui/components/TextInput.js +1 -99
- package/dist/ui/inputBuffer.d.ts +28 -0
- package/dist/ui/inputBuffer.js +99 -0
- package/dist/utils/collections.d.ts +6 -0
- package/dist/utils/collections.js +9 -0
- package/dist/utils/path.d.ts +2 -0
- package/dist/utils/path.js +40 -0
- package/package.json +1 -2
|
@@ -178,6 +178,8 @@ export async function validateUrl(input, options) {
|
|
|
178
178
|
return { ok: false, reasonCode: 'blocked_host', reason: 'URL has no hostname.' };
|
|
179
179
|
}
|
|
180
180
|
// If the host is a literal IP, check ranges directly (no DNS needed).
|
|
181
|
+
// No resolvedAddresses: literal IPs carry no DNS-rebinding surface, so the
|
|
182
|
+
// caller can connect to the URL as-is without pinning.
|
|
181
183
|
if (hostLooksLikeIp(host)) {
|
|
182
184
|
if (isBlockedIp(host)) {
|
|
183
185
|
return { ok: false, reasonCode: 'blocked_address', reason: `Address '${host}' is private, loopback, link-local, or otherwise blocked.` };
|
|
@@ -202,5 +204,8 @@ export async function validateUrl(input, options) {
|
|
|
202
204
|
return { ok: false, reasonCode: 'blocked_address', reason: `Hostname '${host}' resolves to blocked address '${address}'.` };
|
|
203
205
|
}
|
|
204
206
|
}
|
|
205
|
-
|
|
207
|
+
// Surface the validated addresses so the caller can pin the connection to
|
|
208
|
+
// one of them, closing the DNS-rebinding TOCTOU between this check and the
|
|
209
|
+
// actual connect (a public hostname that later re-resolves to an internal IP).
|
|
210
|
+
return { ok: true, url, resolvedAddresses: addresses };
|
|
206
211
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ModelMessage } from 'ai';
|
|
2
|
+
import type { SessionEntry } from './sessionStore.js';
|
|
3
|
+
export declare function slimConversationSnapshot(messages: ModelMessage[]): ModelMessage[];
|
|
4
|
+
export declare function prepareSessionEntryForWrite(entry: SessionEntry): SessionEntry | undefined;
|
|
5
|
+
export declare const SESSION_INLINE_VALUE_BYTES: number;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const INLINE_VALUE_BYTES = 32 * 1024;
|
|
2
|
+
const PREVIEW_CHARS = 4 * 1024;
|
|
3
|
+
const LARGE_STRING_CHARS = 8 * 1024;
|
|
4
|
+
function jsonByteLength(value) {
|
|
5
|
+
try {
|
|
6
|
+
return Buffer.byteLength(JSON.stringify(value), 'utf8');
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return Buffer.byteLength(String(value), 'utf8');
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function previewText(value) {
|
|
13
|
+
const text = typeof value === 'string' ? value : JSON.stringify(value, null, 2) ?? String(value);
|
|
14
|
+
return text.length > PREVIEW_CHARS ? text.slice(0, PREVIEW_CHARS) : text;
|
|
15
|
+
}
|
|
16
|
+
function slimLargeValue(value) {
|
|
17
|
+
const bytes = jsonByteLength(value);
|
|
18
|
+
if (bytes <= INLINE_VALUE_BYTES)
|
|
19
|
+
return value;
|
|
20
|
+
return {
|
|
21
|
+
omitted: true,
|
|
22
|
+
reason: 'session_size_limit',
|
|
23
|
+
originalBytes: bytes,
|
|
24
|
+
preview: previewText(value),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function slimUnknown(value, seen = new WeakSet()) {
|
|
28
|
+
if (typeof value === 'string') {
|
|
29
|
+
if (value.length <= LARGE_STRING_CHARS)
|
|
30
|
+
return value;
|
|
31
|
+
return `${value.slice(0, PREVIEW_CHARS)}\n\n[Session value truncated: ${value.length - PREVIEW_CHARS} characters omitted]`;
|
|
32
|
+
}
|
|
33
|
+
if (value == null || typeof value !== 'object')
|
|
34
|
+
return value;
|
|
35
|
+
if (seen.has(value))
|
|
36
|
+
return '[Circular]';
|
|
37
|
+
seen.add(value);
|
|
38
|
+
if (Array.isArray(value))
|
|
39
|
+
return value.map(item => slimUnknown(item, seen));
|
|
40
|
+
const record = value;
|
|
41
|
+
if (record.type === 'tool-result') {
|
|
42
|
+
return {
|
|
43
|
+
...record,
|
|
44
|
+
output: slimLargeValue(record.output),
|
|
45
|
+
result: slimLargeValue(record.result),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const next = {};
|
|
49
|
+
for (const [key, child] of Object.entries(record))
|
|
50
|
+
next[key] = slimUnknown(child, seen);
|
|
51
|
+
return next;
|
|
52
|
+
}
|
|
53
|
+
export function slimConversationSnapshot(messages) {
|
|
54
|
+
return slimUnknown(messages);
|
|
55
|
+
}
|
|
56
|
+
export function prepareSessionEntryForWrite(entry) {
|
|
57
|
+
if (entry.type === 'event') {
|
|
58
|
+
if (entry.name === 'message_update')
|
|
59
|
+
return undefined;
|
|
60
|
+
if (entry.name === 'tool_end' && entry.text) {
|
|
61
|
+
try {
|
|
62
|
+
const event = JSON.parse(entry.text);
|
|
63
|
+
event.output = slimLargeValue(event.output);
|
|
64
|
+
event.error = slimLargeValue(event.error);
|
|
65
|
+
return { ...entry, text: JSON.stringify(event) };
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return entry;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return entry;
|
|
72
|
+
}
|
|
73
|
+
if (entry.type === 'conversation_snapshot') {
|
|
74
|
+
return { ...entry, messages: slimConversationSnapshot(entry.messages) };
|
|
75
|
+
}
|
|
76
|
+
return entry;
|
|
77
|
+
}
|
|
78
|
+
export const SESSION_INLINE_VALUE_BYTES = INLINE_VALUE_BYTES;
|
|
@@ -37,7 +37,27 @@ export declare function createSession(options?: {
|
|
|
37
37
|
}): Promise<HazeSession>;
|
|
38
38
|
export declare function latestSession(cwd?: string, sessionsDir?: string): Promise<HazeSession | undefined>;
|
|
39
39
|
export declare function appendSessionEntry(session: HazeSession, entry: SessionEntry): Promise<void>;
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
export interface ReadSessionEntriesResult {
|
|
41
|
+
entries: SessionEntry[];
|
|
42
|
+
/** Per-line parse failures, e.g. `Line 3: Unexpected token...`. Empty when every line parsed. */
|
|
43
|
+
parseErrors: string[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Read a session file and parse each non-empty line as a JSONL entry.
|
|
47
|
+
*
|
|
48
|
+
* Malformed lines are not silently discarded: they are reported in
|
|
49
|
+
* `parseErrors` (with their 1-based line number) so callers can surface the
|
|
50
|
+
* loss in debug mode instead of silently dropping messages.
|
|
51
|
+
*/
|
|
52
|
+
export declare function readSessionEntries(session: HazeSession): Promise<ReadSessionEntriesResult>;
|
|
53
|
+
export interface RestoreConversationResult {
|
|
54
|
+
messages: ModelMessage[];
|
|
55
|
+
parseErrors: string[];
|
|
56
|
+
}
|
|
57
|
+
export declare function restoreConversation(session: HazeSession): Promise<RestoreConversationResult>;
|
|
58
|
+
export interface RestoreWorkStateResult {
|
|
59
|
+
state: WorkState | undefined;
|
|
60
|
+
parseErrors: string[];
|
|
61
|
+
}
|
|
62
|
+
export declare function restoreWorkState(session: HazeSession): Promise<RestoreWorkStateResult>;
|
|
43
63
|
export declare function formatSession(session: HazeSession): string;
|
|
@@ -2,6 +2,7 @@ import crypto from 'node:crypto';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
4
|
import { HAZE_DIR } from '../../config/paths.js';
|
|
5
|
+
import { prepareSessionEntryForWrite } from './sessionSlimming.js';
|
|
5
6
|
const DEFAULT_SESSIONS_DIR = path.join(HAZE_DIR, 'sessions');
|
|
6
7
|
function cwdHash(cwd = process.cwd()) {
|
|
7
8
|
return crypto.createHash('sha256').update(path.resolve(cwd)).digest('hex').slice(0, 16);
|
|
@@ -35,29 +36,48 @@ export async function latestSession(cwd = process.cwd(), sessionsDir = DEFAULT_S
|
|
|
35
36
|
return { id, file: path.join(dir, latest), cwd: path.resolve(cwd) };
|
|
36
37
|
}
|
|
37
38
|
export async function appendSessionEntry(session, entry) {
|
|
39
|
+
const prepared = prepareSessionEntryForWrite(entry);
|
|
40
|
+
if (!prepared)
|
|
41
|
+
return;
|
|
38
42
|
await fs.ensureDir(path.dirname(session.file));
|
|
39
|
-
await fs.appendFile(session.file, `${JSON.stringify(
|
|
43
|
+
await fs.appendFile(session.file, `${JSON.stringify(prepared)}\n`, 'utf8');
|
|
40
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Read a session file and parse each non-empty line as a JSONL entry.
|
|
47
|
+
*
|
|
48
|
+
* Malformed lines are not silently discarded: they are reported in
|
|
49
|
+
* `parseErrors` (with their 1-based line number) so callers can surface the
|
|
50
|
+
* loss in debug mode instead of silently dropping messages.
|
|
51
|
+
*/
|
|
41
52
|
export async function readSessionEntries(session) {
|
|
42
53
|
const raw = await fs.readFile(session.file, 'utf8');
|
|
43
|
-
|
|
54
|
+
const entries = [];
|
|
55
|
+
const parseErrors = [];
|
|
56
|
+
// Number by true file position: a stray blank line (e.g. from corruption) must not shift
|
|
57
|
+
// the reported line number away from where the malformed line actually sits.
|
|
58
|
+
const lines = raw.split('\n');
|
|
59
|
+
for (let i = 0; i < lines.length; i++) {
|
|
60
|
+
const line = lines[i];
|
|
61
|
+
if (!line)
|
|
62
|
+
continue; // skip blank lines (e.g. the trailing newline)
|
|
44
63
|
try {
|
|
45
|
-
|
|
64
|
+
entries.push(JSON.parse(line));
|
|
46
65
|
}
|
|
47
|
-
catch {
|
|
48
|
-
|
|
66
|
+
catch (error) {
|
|
67
|
+
parseErrors.push(`Line ${i + 1}: ${error instanceof Error ? error.message : String(error)}`);
|
|
49
68
|
}
|
|
50
|
-
}
|
|
69
|
+
}
|
|
70
|
+
return { entries, parseErrors };
|
|
51
71
|
}
|
|
52
72
|
export async function restoreConversation(session) {
|
|
53
|
-
const entries = await readSessionEntries(session);
|
|
73
|
+
const { entries, parseErrors } = await readSessionEntries(session);
|
|
54
74
|
const snapshots = entries.filter((entry) => entry.type === 'conversation_snapshot');
|
|
55
|
-
return snapshots.at(-1)?.messages ?? [];
|
|
75
|
+
return { messages: snapshots.at(-1)?.messages ?? [], parseErrors };
|
|
56
76
|
}
|
|
57
77
|
export async function restoreWorkState(session) {
|
|
58
|
-
const entries = await readSessionEntries(session);
|
|
78
|
+
const { entries, parseErrors } = await readSessionEntries(session);
|
|
59
79
|
const snapshots = entries.filter((entry) => entry.type === 'work_state_snapshot');
|
|
60
|
-
return snapshots.at(-1)?.state;
|
|
80
|
+
return { state: snapshots.at(-1)?.state, parseErrors };
|
|
61
81
|
}
|
|
62
82
|
export function formatSession(session) {
|
|
63
83
|
return `${session.id} · ${session.file}`;
|
|
@@ -17,6 +17,15 @@ export interface SubagentResult {
|
|
|
17
17
|
durationMs: number;
|
|
18
18
|
error?: string;
|
|
19
19
|
}
|
|
20
|
+
declare function toolSummary(output: unknown): string;
|
|
21
|
+
declare function toolOnlyStepCount(steps: Array<{
|
|
22
|
+
toolCalls: unknown[];
|
|
23
|
+
text: string;
|
|
24
|
+
}>): number;
|
|
25
|
+
export declare const internals: {
|
|
26
|
+
toolSummary: typeof toolSummary;
|
|
27
|
+
toolOnlyStepCount: typeof toolOnlyStepCount;
|
|
28
|
+
};
|
|
20
29
|
export declare function runSubagent(task: string, options: {
|
|
21
30
|
model: Parameters<typeof streamText>[0]['model'];
|
|
22
31
|
contextFiles: ContextFile[];
|
|
@@ -31,6 +40,7 @@ export declare function createSubagentTool(options: {
|
|
|
31
40
|
session?: PromptSession;
|
|
32
41
|
}): import("ai").Tool<{
|
|
33
42
|
task: string;
|
|
34
|
-
tools?: ("
|
|
43
|
+
tools?: ("editFile" | "replaceLines" | "writeFile" | "listFiles" | "readFile" | "grep" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
35
44
|
maxSteps?: number | undefined;
|
|
36
45
|
}, SubagentResult>;
|
|
46
|
+
export {};
|
|
@@ -29,6 +29,7 @@ function toolOnlyStepCount(steps) {
|
|
|
29
29
|
}
|
|
30
30
|
return count;
|
|
31
31
|
}
|
|
32
|
+
export const internals = { toolSummary, toolOnlyStepCount };
|
|
32
33
|
export async function runSubagent(task, options) {
|
|
33
34
|
const start = performance.now();
|
|
34
35
|
const toolNames = (options.allowedTools ?? ALL_TOOLS).filter(t => ALL_TOOLS.includes(t));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ToolSet } from 'ai';
|
|
2
|
+
import type { ToolCategory } from './requestContext.js';
|
|
3
|
+
export interface LoadedCapability {
|
|
4
|
+
category: ToolCategory;
|
|
5
|
+
tools: ToolSet;
|
|
6
|
+
}
|
|
7
|
+
export declare function addCapabilityTools(input: {
|
|
8
|
+
availableTools: ToolSet;
|
|
9
|
+
toolCategories: Map<string, ToolCategory>;
|
|
10
|
+
loaded: LoadedCapability;
|
|
11
|
+
skipCollisions?: boolean;
|
|
12
|
+
}): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function addCapabilityTools(input) {
|
|
2
|
+
const existing = new Set(Object.keys(input.availableTools));
|
|
3
|
+
for (const [name, value] of Object.entries(input.loaded.tools)) {
|
|
4
|
+
if (input.skipCollisions && existing.has(name))
|
|
5
|
+
continue;
|
|
6
|
+
input.toolCategories.set(name, input.loaded.category);
|
|
7
|
+
input.availableTools[name] = value;
|
|
8
|
+
existing.add(name);
|
|
9
|
+
}
|
|
10
|
+
}
|
package/dist/llm/client.d.ts
CHANGED
package/dist/llm/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createOpenAI } from '@ai-sdk/openai';
|
|
2
2
|
import crypto from 'node:crypto';
|
|
3
3
|
import { readSettings } from '../config/settings.js';
|
|
4
|
-
import { activeModel } from '../config/providers.js';
|
|
4
|
+
import { activeModel, resolveModelSelector } from '../config/providers.js';
|
|
5
5
|
function capabilities(providerName, baseURL) {
|
|
6
6
|
const directOpenAI = providerName === 'openai' || /api\.openai\.com/i.test(baseURL);
|
|
7
7
|
const openRouter = providerName === 'openrouter' || /openrouter\.ai/i.test(baseURL);
|
|
@@ -16,7 +16,16 @@ function capabilities(providerName, baseURL) {
|
|
|
16
16
|
}
|
|
17
17
|
export async function modelWithConfig(session) {
|
|
18
18
|
const settings = await readSettings();
|
|
19
|
-
const
|
|
19
|
+
const override = session?.modelSelector?.trim();
|
|
20
|
+
let selection;
|
|
21
|
+
if (override) {
|
|
22
|
+
const resolved = resolveModelSelector(settings, override);
|
|
23
|
+
if (resolved.status === 'found')
|
|
24
|
+
selection = { provider: resolved.provider, model: resolved.model };
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
selection = activeModel(settings);
|
|
28
|
+
}
|
|
20
29
|
if (!selection)
|
|
21
30
|
return undefined;
|
|
22
31
|
const baseURL = selection.provider.url;
|
package/dist/llm/hazeTools.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { ToolDiffLine
|
|
2
|
-
import { type ContextFile } from '../config/contextFiles.js';
|
|
1
|
+
import type { ToolDiffLine } from './toolResultTypes.js';
|
|
3
2
|
export declare const hazeTools: {
|
|
4
3
|
listFiles: import("ai").Tool<{
|
|
5
4
|
path: string;
|
|
@@ -13,7 +12,7 @@ export declare const hazeTools: {
|
|
|
13
12
|
toolName: string;
|
|
14
13
|
path: string | undefined;
|
|
15
14
|
error: string;
|
|
16
|
-
reasonCode: ToolFailureReasonCode | undefined;
|
|
15
|
+
reasonCode: import("./toolResultTypes.js").ToolFailureReasonCode | undefined;
|
|
17
16
|
recoverable: boolean;
|
|
18
17
|
suggestedNextStep: string;
|
|
19
18
|
recoveryTool: string | undefined;
|
|
@@ -35,7 +34,7 @@ export declare const hazeTools: {
|
|
|
35
34
|
entries: string[];
|
|
36
35
|
truncated: boolean;
|
|
37
36
|
} & {
|
|
38
|
-
applicableProjectInstructions?: ContextFile[];
|
|
37
|
+
applicableProjectInstructions?: import("../config/contextFiles.js").ContextFile[];
|
|
39
38
|
})>;
|
|
40
39
|
readFile: import("ai").Tool<{
|
|
41
40
|
path: string;
|
|
@@ -48,7 +47,7 @@ export declare const hazeTools: {
|
|
|
48
47
|
toolName: string;
|
|
49
48
|
path: string | undefined;
|
|
50
49
|
error: string;
|
|
51
|
-
reasonCode: ToolFailureReasonCode | undefined;
|
|
50
|
+
reasonCode: import("./toolResultTypes.js").ToolFailureReasonCode | undefined;
|
|
52
51
|
recoverable: boolean;
|
|
53
52
|
suggestedNextStep: string;
|
|
54
53
|
recoveryTool: string | undefined;
|
|
@@ -72,7 +71,7 @@ export declare const hazeTools: {
|
|
|
72
71
|
truncated: boolean;
|
|
73
72
|
lineTruncated: boolean;
|
|
74
73
|
} & {
|
|
75
|
-
applicableProjectInstructions?: ContextFile[];
|
|
74
|
+
applicableProjectInstructions?: import("../config/contextFiles.js").ContextFile[];
|
|
76
75
|
})>;
|
|
77
76
|
grep: import("ai").Tool<{
|
|
78
77
|
pattern: string;
|
|
@@ -86,7 +85,7 @@ export declare const hazeTools: {
|
|
|
86
85
|
toolName: string;
|
|
87
86
|
path: string | undefined;
|
|
88
87
|
error: string;
|
|
89
|
-
reasonCode: ToolFailureReasonCode | undefined;
|
|
88
|
+
reasonCode: import("./toolResultTypes.js").ToolFailureReasonCode | undefined;
|
|
90
89
|
recoverable: boolean;
|
|
91
90
|
suggestedNextStep: string;
|
|
92
91
|
recoveryTool: string | undefined;
|
|
@@ -105,7 +104,7 @@ export declare const hazeTools: {
|
|
|
105
104
|
totalMatches: number;
|
|
106
105
|
truncated: boolean;
|
|
107
106
|
} & {
|
|
108
|
-
applicableProjectInstructions?: ContextFile[];
|
|
107
|
+
applicableProjectInstructions?: import("../config/contextFiles.js").ContextFile[];
|
|
109
108
|
}) | ({
|
|
110
109
|
suggestion: string | undefined;
|
|
111
110
|
omittedChars: number;
|
|
@@ -136,7 +135,7 @@ export declare const hazeTools: {
|
|
|
136
135
|
lossy: boolean;
|
|
137
136
|
parseTier: string;
|
|
138
137
|
} & {
|
|
139
|
-
applicableProjectInstructions?: ContextFile[];
|
|
138
|
+
applicableProjectInstructions?: import("../config/contextFiles.js").ContextFile[];
|
|
140
139
|
})>;
|
|
141
140
|
replaceLines: import("ai").Tool<{
|
|
142
141
|
path: string;
|
|
@@ -147,22 +146,22 @@ export declare const hazeTools: {
|
|
|
147
146
|
}, {
|
|
148
147
|
ok: boolean;
|
|
149
148
|
toolName: string;
|
|
150
|
-
path: string;
|
|
149
|
+
path: string | undefined;
|
|
151
150
|
error: string;
|
|
152
|
-
reasonCode: "
|
|
151
|
+
reasonCode: import("./toolResultTypes.js").ToolFailureReasonCode | undefined;
|
|
153
152
|
recoverable: boolean;
|
|
154
153
|
suggestedNextStep: string;
|
|
155
|
-
|
|
154
|
+
recoveryTool: string | undefined;
|
|
155
|
+
recoveryInput: unknown;
|
|
156
156
|
} | {
|
|
157
157
|
ok: boolean;
|
|
158
158
|
toolName: string;
|
|
159
|
-
path: string
|
|
159
|
+
path: string;
|
|
160
160
|
error: string;
|
|
161
|
-
reasonCode:
|
|
161
|
+
reasonCode: "scoped_instructions_discovered";
|
|
162
162
|
recoverable: boolean;
|
|
163
163
|
suggestedNextStep: string;
|
|
164
|
-
|
|
165
|
-
recoveryInput: unknown;
|
|
164
|
+
applicableProjectInstructions: import("../config/contextFiles.js").ContextFile[];
|
|
166
165
|
} | {
|
|
167
166
|
ok: true;
|
|
168
167
|
duplicateSkipped: true;
|
|
@@ -190,22 +189,22 @@ export declare const hazeTools: {
|
|
|
190
189
|
}, {
|
|
191
190
|
ok: boolean;
|
|
192
191
|
toolName: string;
|
|
193
|
-
path: string;
|
|
192
|
+
path: string | undefined;
|
|
194
193
|
error: string;
|
|
195
|
-
reasonCode: "
|
|
194
|
+
reasonCode: import("./toolResultTypes.js").ToolFailureReasonCode | undefined;
|
|
196
195
|
recoverable: boolean;
|
|
197
196
|
suggestedNextStep: string;
|
|
198
|
-
|
|
197
|
+
recoveryTool: string | undefined;
|
|
198
|
+
recoveryInput: unknown;
|
|
199
199
|
} | {
|
|
200
200
|
ok: boolean;
|
|
201
201
|
toolName: string;
|
|
202
|
-
path: string
|
|
202
|
+
path: string;
|
|
203
203
|
error: string;
|
|
204
|
-
reasonCode:
|
|
204
|
+
reasonCode: "scoped_instructions_discovered";
|
|
205
205
|
recoverable: boolean;
|
|
206
206
|
suggestedNextStep: string;
|
|
207
|
-
|
|
208
|
-
recoveryInput: unknown;
|
|
207
|
+
applicableProjectInstructions: import("../config/contextFiles.js").ContextFile[];
|
|
209
208
|
} | {
|
|
210
209
|
ok: true;
|
|
211
210
|
duplicateSkipped: true;
|
|
@@ -227,22 +226,22 @@ export declare const hazeTools: {
|
|
|
227
226
|
}, {
|
|
228
227
|
ok: boolean;
|
|
229
228
|
toolName: string;
|
|
230
|
-
path: string;
|
|
229
|
+
path: string | undefined;
|
|
231
230
|
error: string;
|
|
232
|
-
reasonCode: "
|
|
231
|
+
reasonCode: import("./toolResultTypes.js").ToolFailureReasonCode | undefined;
|
|
233
232
|
recoverable: boolean;
|
|
234
233
|
suggestedNextStep: string;
|
|
235
|
-
|
|
234
|
+
recoveryTool: string | undefined;
|
|
235
|
+
recoveryInput: unknown;
|
|
236
236
|
} | {
|
|
237
237
|
ok: boolean;
|
|
238
238
|
toolName: string;
|
|
239
|
-
path: string
|
|
239
|
+
path: string;
|
|
240
240
|
error: string;
|
|
241
|
-
reasonCode:
|
|
241
|
+
reasonCode: "scoped_instructions_discovered";
|
|
242
242
|
recoverable: boolean;
|
|
243
243
|
suggestedNextStep: string;
|
|
244
|
-
|
|
245
|
-
recoveryInput: unknown;
|
|
244
|
+
applicableProjectInstructions: import("../config/contextFiles.js").ContextFile[];
|
|
246
245
|
} | {
|
|
247
246
|
ok: true;
|
|
248
247
|
duplicateSkipped: true;
|
|
@@ -298,13 +297,13 @@ export declare const hazeTools: {
|
|
|
298
297
|
}>;
|
|
299
298
|
fetch: import("ai").Tool<{
|
|
300
299
|
url: string;
|
|
301
|
-
format: "
|
|
300
|
+
format: "auto" | "text";
|
|
302
301
|
}, {
|
|
303
302
|
ok: boolean;
|
|
304
303
|
toolName: string;
|
|
305
304
|
path: string | undefined;
|
|
306
305
|
error: string;
|
|
307
|
-
reasonCode: ToolFailureReasonCode | undefined;
|
|
306
|
+
reasonCode: import("./toolResultTypes.js").ToolFailureReasonCode | undefined;
|
|
308
307
|
recoverable: boolean;
|
|
309
308
|
suggestedNextStep: string;
|
|
310
309
|
recoveryTool: string | undefined;
|