@denizokcu/haze 0.4.0 → 0.5.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 +28 -0
- package/README.md +31 -29
- package/dist/cli/commands/chat.js +106 -48
- package/dist/cli/commands/commands.js +15 -1
- package/dist/cli/commands/streaming.d.ts +4 -0
- package/dist/cli/commands/streaming.js +242 -111
- package/dist/config/contextFiles.d.ts +6 -0
- package/dist/config/contextFiles.js +47 -16
- package/dist/config/providers.d.ts +2 -5
- package/dist/config/providers.js +16 -12
- package/dist/core/agent/requestAssembly.js +12 -1
- package/dist/core/agent/toolOutputStore.d.ts +6 -1
- package/dist/core/agent/toolOutputStore.js +33 -1
- package/dist/core/bashOutput/ansi.d.ts +1 -0
- package/dist/core/bashOutput/ansi.js +7 -0
- package/dist/core/bashOutput/command.d.ts +2 -0
- package/dist/core/bashOutput/command.js +62 -0
- package/dist/core/bashOutput/lineFilter.d.ts +25 -0
- package/dist/core/bashOutput/lineFilter.js +62 -0
- package/dist/core/bashOutput/reducers/content.d.ts +3 -0
- package/dist/core/bashOutput/reducers/content.js +134 -0
- package/dist/core/bashOutput/reducers/git.d.ts +1 -0
- package/dist/core/bashOutput/reducers/git.js +147 -0
- package/dist/core/bashOutput/reducers/search.d.ts +7 -0
- package/dist/core/bashOutput/reducers/search.js +76 -0
- package/dist/core/bashOutput/reducers/validation.d.ts +2 -0
- package/dist/core/bashOutput/reducers/validation.js +41 -0
- package/dist/core/bashOutput/registry.d.ts +4 -0
- package/dist/core/bashOutput/registry.js +126 -0
- package/dist/core/bashOutput/types.d.ts +46 -0
- package/dist/core/bashOutput/types.js +1 -0
- package/dist/core/goal/completionPolicy.d.ts +1 -0
- package/dist/core/goal/completionPolicy.js +4 -0
- package/dist/core/safety/urlGuard.d.ts +37 -0
- package/dist/core/safety/urlGuard.js +206 -0
- package/dist/core/subagent/subagentRunner.d.ts +1 -1
- package/dist/core/subagent/subagentRunner.js +2 -2
- package/dist/core/toolOutput/reduction.d.ts +25 -0
- package/dist/core/toolOutput/reduction.js +23 -0
- package/dist/llm/client.d.ts +2 -2
- package/dist/llm/client.js +6 -4
- package/dist/llm/hazeTools.d.ts +133 -16
- package/dist/llm/hazeTools.js +205 -31
- package/dist/llm/initPrompt.js +2 -1
- package/dist/llm/systemPrompt.js +3 -1
- package/dist/llm/toolResultTypes.d.ts +1 -1
- package/dist/llm/webFetch.d.ts +57 -0
- package/dist/llm/webFetch.js +270 -0
- package/dist/ui/components/MarkdownText.d.ts +2 -0
- package/dist/ui/components/MarkdownText.js +116 -3
- package/package.json +17 -10
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { promises as dns } from 'node:dns';
|
|
2
|
+
/**
|
|
3
|
+
* Blocked IPv4 and IPv6 ranges as CIDR strings. Centralized so the policy reads
|
|
4
|
+
* in one place. Covers loopback, link-local, private, and other non-routable /
|
|
5
|
+
* metadata-bearing ranges (e.g. 169.254.169.254 = AWS/cloud metadata).
|
|
6
|
+
*/
|
|
7
|
+
const BLOCKED_IPV4_CIDRS = [
|
|
8
|
+
parseIpv4Cidr('0.0.0.0/8'), // "this network"
|
|
9
|
+
parseIpv4Cidr('10.0.0.0/8'), // private
|
|
10
|
+
parseIpv4Cidr('100.64.0.0/10'), // CGNAT
|
|
11
|
+
parseIpv4Cidr('127.0.0.0/8'), // loopback
|
|
12
|
+
parseIpv4Cidr('169.254.0.0/16'), // link-local / cloud metadata
|
|
13
|
+
parseIpv4Cidr('172.16.0.0/12'), // private
|
|
14
|
+
parseIpv4Cidr('192.0.0.0/24'), // IETF protocol assignments
|
|
15
|
+
parseIpv4Cidr('192.0.2.0/24'), // TEST-NET-1
|
|
16
|
+
parseIpv4Cidr('192.168.0.0/16'), // private
|
|
17
|
+
parseIpv4Cidr('198.18.0.0/15'), // benchmarking
|
|
18
|
+
parseIpv4Cidr('198.51.100.0/24'), // TEST-NET-2
|
|
19
|
+
parseIpv4Cidr('203.0.113.0/24'), // TEST-NET-3
|
|
20
|
+
parseIpv4Cidr('224.0.0.0/4'), // multicast
|
|
21
|
+
parseIpv4Cidr('240.0.0.0/4'), // reserved
|
|
22
|
+
];
|
|
23
|
+
const BLOCKED_IPV6_CIDRS = [
|
|
24
|
+
parseIpv6Cidr('::/128'), // unspecified
|
|
25
|
+
parseIpv6Cidr('::1/128'), // loopback
|
|
26
|
+
parseIpv6Cidr('::ffff:0:0/96'), // IPv4-mapped (checked via v4 ranges too, but be explicit)
|
|
27
|
+
parseIpv6Cidr('64:ff9b::/96'), // NAT64
|
|
28
|
+
parseIpv6Cidr('100::/64'), // discard prefix
|
|
29
|
+
parseIpv6Cidr('fc00::/7'), // unique local
|
|
30
|
+
parseIpv6Cidr('fe80::/10'), // link-local
|
|
31
|
+
parseIpv6Cidr('ff00::/8'), // multicast
|
|
32
|
+
];
|
|
33
|
+
/** Hostnames that are always blocked regardless of resolution. */
|
|
34
|
+
const BLOCKED_HOSTNAMES = new Set([
|
|
35
|
+
'localhost',
|
|
36
|
+
'localhost.localdomain',
|
|
37
|
+
'ip6-localhost',
|
|
38
|
+
'ip6-loopback',
|
|
39
|
+
'broadcasthost',
|
|
40
|
+
]);
|
|
41
|
+
function parseIpv4Cidr(cidr) {
|
|
42
|
+
const [ip, bitsStr] = cidr.split('/');
|
|
43
|
+
const bits = Number(bitsStr);
|
|
44
|
+
const octets = ip.split('.').map(Number);
|
|
45
|
+
const start = (((octets[0] << 24) >>> 0) + (octets[1] << 16) + (octets[2] << 8) + octets[3]) >>> 0;
|
|
46
|
+
const mask = bits === 0 ? 0 : (0xffffffff << (32 - bits)) >>> 0;
|
|
47
|
+
return { start: (start & mask) >>> 0, mask, bits };
|
|
48
|
+
}
|
|
49
|
+
function parseIpv6Cidr(cidr) {
|
|
50
|
+
const [ip, bitsStr] = cidr.split('/');
|
|
51
|
+
const bits = Number(bitsStr);
|
|
52
|
+
const num = ipv6ToBigInt(ip);
|
|
53
|
+
const mask = bits === 0 ? 0n : ((0xffffffffffffffffffffffffffffffffn << BigInt(128 - bits)) & 0xffffffffffffffffffffffffffffffffn);
|
|
54
|
+
return { start: num & mask, mask, bits };
|
|
55
|
+
}
|
|
56
|
+
function ipv4ToInt(ip) {
|
|
57
|
+
const octets = ip.split('.');
|
|
58
|
+
if (octets.length !== 4)
|
|
59
|
+
return undefined;
|
|
60
|
+
const nums = octets.map(Number);
|
|
61
|
+
if (nums.some(n => !Number.isInteger(n) || n < 0 || n > 255))
|
|
62
|
+
return undefined;
|
|
63
|
+
return (((nums[0] << 24) >>> 0) + (nums[1] << 16) + (nums[2] << 8) + nums[3]) >>> 0;
|
|
64
|
+
}
|
|
65
|
+
function ipv6ToBigInt(ip) {
|
|
66
|
+
const normalized = normalizeIpv6(ip);
|
|
67
|
+
const parts = normalized.split(':');
|
|
68
|
+
const groups = parts.map(part => BigInt(parseInt(part || '0', 16)));
|
|
69
|
+
let result = 0n;
|
|
70
|
+
for (const group of groups) {
|
|
71
|
+
result = (result << 16n) + group;
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
function normalizeIpv6(ip) {
|
|
76
|
+
if (!ip.includes(':'))
|
|
77
|
+
return ip;
|
|
78
|
+
let expanded = ip;
|
|
79
|
+
// Handle IPv4-in-IPv6 dotted quad in the last group.
|
|
80
|
+
const lastColon = expanded.lastIndexOf(':');
|
|
81
|
+
const tail = expanded.slice(lastColon + 1);
|
|
82
|
+
if (tail.includes('.')) {
|
|
83
|
+
const v4 = ipv4ToInt(tail);
|
|
84
|
+
if (v4 != null) {
|
|
85
|
+
const g1 = (v4 >> 16) & 0xffff;
|
|
86
|
+
const g2 = v4 & 0xffff;
|
|
87
|
+
expanded = `${expanded.slice(0, lastColon + 1)}${g1.toString(16)}:${g2.toString(16)}`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Expand :: shorthand.
|
|
91
|
+
if (expanded.includes('::')) {
|
|
92
|
+
const [head, tail2] = expanded.split('::');
|
|
93
|
+
const headGroups = head ? head.split(':') : [];
|
|
94
|
+
const tailGroups = tail2 ? tail2.split(':') : [];
|
|
95
|
+
const missing = 8 - headGroups.length - tailGroups.length;
|
|
96
|
+
expanded = [...headGroups, ...Array.from({ length: missing }, () => '0'), ...tailGroups].join(':');
|
|
97
|
+
}
|
|
98
|
+
return expanded;
|
|
99
|
+
}
|
|
100
|
+
function isIpv6(ip) {
|
|
101
|
+
return ip.includes(':');
|
|
102
|
+
}
|
|
103
|
+
function ipv4InBlockedRange(ip) {
|
|
104
|
+
const value = ipv4ToInt(ip);
|
|
105
|
+
if (value == null)
|
|
106
|
+
return false;
|
|
107
|
+
for (const range of BLOCKED_IPV4_CIDRS) {
|
|
108
|
+
if ((value & range.mask) >>> 0 === range.start)
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
function ipv6InBlockedRange(ip) {
|
|
114
|
+
let num;
|
|
115
|
+
try {
|
|
116
|
+
num = ipv6ToBigInt(ip);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
for (const range of BLOCKED_IPV6_CIDRS) {
|
|
122
|
+
if ((num & range.mask) === range.start)
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Check whether a literal IP address (v4 or v6) is in a blocked range.
|
|
129
|
+
* Returns false for non-IP strings (hostnames are resolved separately).
|
|
130
|
+
*/
|
|
131
|
+
export function isBlockedIp(ip) {
|
|
132
|
+
// Strip IPv6 bracket form for literal checks.
|
|
133
|
+
const cleaned = ip.replace(/^\[|\]$/g, '');
|
|
134
|
+
if (isIpv6(cleaned))
|
|
135
|
+
return ipv6InBlockedRange(cleaned);
|
|
136
|
+
return ipv4InBlockedRange(cleaned);
|
|
137
|
+
}
|
|
138
|
+
function hostLooksLikeIp(host) {
|
|
139
|
+
const cleaned = host.replace(/^\[|\]$/g, '');
|
|
140
|
+
if (cleaned.includes(':'))
|
|
141
|
+
return true; // IPv6
|
|
142
|
+
return /^\d{1,3}(\.\d{1,3}){3}$/.test(cleaned);
|
|
143
|
+
}
|
|
144
|
+
const defaultLookup = async (hostname) => {
|
|
145
|
+
const records = await dns.lookup(hostname, { all: true });
|
|
146
|
+
return records.map(record => record.address);
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Validate a URL for outbound fetching.
|
|
150
|
+
*
|
|
151
|
+
* Checks scheme allowlist, blocks well-known dangerous hostnames, blocks
|
|
152
|
+
* literal private/loopback/link-local IPs, and (if the host is a DNS name)
|
|
153
|
+
* resolves it to reject names that point at private/loopback/link-local IPs.
|
|
154
|
+
*
|
|
155
|
+
* `lookup` is injectable for deterministic offline tests.
|
|
156
|
+
*/
|
|
157
|
+
export async function validateUrl(input, options) {
|
|
158
|
+
let url;
|
|
159
|
+
try {
|
|
160
|
+
url = new URL(input);
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return { ok: false, reasonCode: 'invalid_url', reason: `Not a valid URL: ${input}` };
|
|
164
|
+
}
|
|
165
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
166
|
+
return {
|
|
167
|
+
ok: false,
|
|
168
|
+
reasonCode: 'blocked_scheme',
|
|
169
|
+
reason: `Scheme '${url.protocol.replace(':', '')}' is not allowed; only http and https are permitted.`,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const host = url.hostname.toLowerCase();
|
|
173
|
+
if (BLOCKED_HOSTNAMES.has(host)) {
|
|
174
|
+
return { ok: false, reasonCode: 'blocked_host', reason: `Hostname '${host}' is blocked.` };
|
|
175
|
+
}
|
|
176
|
+
// Check userinfo/host confusion and empty host (e.g. "http:///").
|
|
177
|
+
if (!host) {
|
|
178
|
+
return { ok: false, reasonCode: 'blocked_host', reason: 'URL has no hostname.' };
|
|
179
|
+
}
|
|
180
|
+
// If the host is a literal IP, check ranges directly (no DNS needed).
|
|
181
|
+
if (hostLooksLikeIp(host)) {
|
|
182
|
+
if (isBlockedIp(host)) {
|
|
183
|
+
return { ok: false, reasonCode: 'blocked_address', reason: `Address '${host}' is private, loopback, link-local, or otherwise blocked.` };
|
|
184
|
+
}
|
|
185
|
+
return { ok: true, url };
|
|
186
|
+
}
|
|
187
|
+
// Hostname: resolve and reject if ANY resolved address is blocked.
|
|
188
|
+
// This defeats DNS rebinding (public hostname pointing at an internal IP).
|
|
189
|
+
const lookup = options?.lookup ?? defaultLookup;
|
|
190
|
+
let addresses;
|
|
191
|
+
try {
|
|
192
|
+
addresses = await lookup(host);
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
return { ok: false, reasonCode: 'blocked_host', reason: `Could not resolve hostname '${host}'.` };
|
|
196
|
+
}
|
|
197
|
+
if (addresses.length === 0) {
|
|
198
|
+
return { ok: false, reasonCode: 'blocked_host', reason: `Hostname '${host}' did not resolve to any address.` };
|
|
199
|
+
}
|
|
200
|
+
for (const address of addresses) {
|
|
201
|
+
if (isBlockedIp(address)) {
|
|
202
|
+
return { ok: false, reasonCode: 'blocked_address', reason: `Hostname '${host}' resolves to blocked address '${address}'.` };
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return { ok: true, url };
|
|
206
|
+
}
|
|
@@ -31,6 +31,6 @@ export declare function createSubagentTool(options: {
|
|
|
31
31
|
session?: PromptSession;
|
|
32
32
|
}): import("ai").Tool<{
|
|
33
33
|
task: string;
|
|
34
|
-
tools?: ("listFiles" | "editFile" | "replaceLines" | "writeFile" | "readFile" | "grep" | "bash" | "readToolOutput")[] | undefined;
|
|
34
|
+
tools?: ("listFiles" | "editFile" | "replaceLines" | "writeFile" | "readFile" | "grep" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
35
35
|
maxSteps?: number | undefined;
|
|
36
36
|
}, SubagentResult>;
|
|
@@ -2,7 +2,7 @@ import { streamText, stepCountIs, tool } from 'ai';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { buildSubagentPrompt } from '../../llm/systemPrompt.js';
|
|
4
4
|
import { hazeTools } from '../../llm/hazeTools.js';
|
|
5
|
-
const ALL_TOOLS = ['listFiles', 'readFile', 'grep', 'bash', 'readToolOutput', 'editFile', 'replaceLines', 'writeFile'];
|
|
5
|
+
const ALL_TOOLS = ['listFiles', 'readFile', 'grep', 'bash', 'readToolOutput', 'editFile', 'replaceLines', 'writeFile', 'fetch'];
|
|
6
6
|
const STEP_LIMIT = 25;
|
|
7
7
|
const MAX_SUMMARY = 4000;
|
|
8
8
|
const TOOL_ONLY_LIMIT = 12;
|
|
@@ -116,7 +116,7 @@ export function createSubagentTool(options) {
|
|
|
116
116
|
description: 'Spawn subagents to run independent tasks in parallel. ONLY use when a request clearly decomposes into 2+ independent subtasks that can run concurrently — spawn all of them in one step. Do NOT use for single tasks, sequential work, or anything that benefits from conversation context; do those directly instead. Subagents have no conversation history and return a summary.',
|
|
117
117
|
inputSchema: z.object({
|
|
118
118
|
task: z.string().min(1).describe('Clear, specific task for the subagent to complete.'),
|
|
119
|
-
tools: z.array(z.enum(['listFiles', 'readFile', 'grep', 'bash', 'readToolOutput', 'editFile', 'replaceLines', 'writeFile'])).optional().describe('Tools the subagent can use. Defaults to all tools.'),
|
|
119
|
+
tools: z.array(z.enum(['listFiles', 'readFile', 'grep', 'bash', 'readToolOutput', 'editFile', 'replaceLines', 'writeFile', 'fetch'])).optional().describe('Tools the subagent can use. Defaults to all tools.'),
|
|
120
120
|
maxSteps: z.number().int().positive().max(50).optional().describe('Maximum tool-call rounds. Default 25.'),
|
|
121
121
|
}),
|
|
122
122
|
execute: async ({ task, tools, maxSteps }, context) => runSubagent(task, {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type ReductionPressure = 'conservative' | 'normal' | 'aggressive';
|
|
2
|
+
export type ReductionContentKind = 'validation' | 'log' | 'search' | 'diff' | 'json' | 'table' | 'web' | 'source-outline' | 'generic';
|
|
3
|
+
export type ReductionParseTier = 'full' | 'degraded' | 'passthrough';
|
|
4
|
+
export interface ReductionMetrics {
|
|
5
|
+
rawChars: number;
|
|
6
|
+
returnedChars: number;
|
|
7
|
+
rawTokensEstimate: number;
|
|
8
|
+
returnedTokensEstimate: number;
|
|
9
|
+
estimatedSavedTokens: number;
|
|
10
|
+
savingsPct: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ToolOutputReductionMetadata extends ReductionMetrics {
|
|
13
|
+
reducerName: string;
|
|
14
|
+
contentKind: ReductionContentKind;
|
|
15
|
+
lossy: boolean;
|
|
16
|
+
parseTier: ReductionParseTier;
|
|
17
|
+
rawHandle?: string;
|
|
18
|
+
handle?: string;
|
|
19
|
+
omittedChars: number;
|
|
20
|
+
warning?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function estimateReductionTokens(text: string): number;
|
|
23
|
+
export declare function reductionMetrics(raw: string, returned: string): ReductionMetrics;
|
|
24
|
+
export declare function retrievalHint(handle: string): string;
|
|
25
|
+
export declare function isInflating(raw: string, returned: string): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function estimateReductionTokens(text) {
|
|
2
|
+
return Math.ceil(text.length / 4);
|
|
3
|
+
}
|
|
4
|
+
export function reductionMetrics(raw, returned) {
|
|
5
|
+
const rawTokensEstimate = estimateReductionTokens(raw);
|
|
6
|
+
const returnedTokensEstimate = estimateReductionTokens(returned);
|
|
7
|
+
const estimatedSavedTokens = Math.max(0, rawTokensEstimate - returnedTokensEstimate);
|
|
8
|
+
const savingsPct = rawTokensEstimate === 0 ? 0 : Number(((estimatedSavedTokens / rawTokensEstimate) * 100).toFixed(1));
|
|
9
|
+
return {
|
|
10
|
+
rawChars: raw.length,
|
|
11
|
+
returnedChars: returned.length,
|
|
12
|
+
rawTokensEstimate,
|
|
13
|
+
returnedTokensEstimate,
|
|
14
|
+
estimatedSavedTokens,
|
|
15
|
+
savingsPct,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function retrievalHint(handle) {
|
|
19
|
+
return `Use readToolOutput with handle ${handle} for the original output.`;
|
|
20
|
+
}
|
|
21
|
+
export function isInflating(raw, returned) {
|
|
22
|
+
return raw.trim().length > 0 && returned.length > raw.length;
|
|
23
|
+
}
|
package/dist/llm/client.d.ts
CHANGED
|
@@ -24,8 +24,8 @@ export declare function modelWithConfig(session?: {
|
|
|
24
24
|
cacheKey: string;
|
|
25
25
|
capabilities: ProviderCapabilities;
|
|
26
26
|
};
|
|
27
|
-
}>;
|
|
28
|
-
export declare function model(): Promise<import("@ai-sdk/provider").LanguageModelV3>;
|
|
27
|
+
} | undefined>;
|
|
28
|
+
export declare function model(): Promise<import("@ai-sdk/provider").LanguageModelV3 | undefined>;
|
|
29
29
|
export declare function cacheKeyFor(name: string, cwd?: string): string;
|
|
30
30
|
export declare function providerRequestSettings(config: ModelRuntimeConfig): {
|
|
31
31
|
headers?: {
|
package/dist/llm/client.js
CHANGED
|
@@ -17,9 +17,11 @@ function capabilities(providerName, baseURL) {
|
|
|
17
17
|
export async function modelWithConfig(session) {
|
|
18
18
|
const settings = await readSettings();
|
|
19
19
|
const selection = activeModel(settings);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
20
|
+
if (!selection)
|
|
21
|
+
return undefined;
|
|
22
|
+
const baseURL = selection.provider.url;
|
|
23
|
+
const apiKey = selection.provider.key ?? settings.apiKey ?? 'not-needed';
|
|
24
|
+
const name = selection.model;
|
|
23
25
|
const cacheSeed = session?.cwd ?? process.cwd();
|
|
24
26
|
const cacheKey = crypto.createHash('sha256').update(`${cacheSeed}\0${name}`).digest('hex').slice(0, 32);
|
|
25
27
|
return {
|
|
@@ -34,7 +36,7 @@ export async function modelWithConfig(session) {
|
|
|
34
36
|
};
|
|
35
37
|
}
|
|
36
38
|
export async function model() {
|
|
37
|
-
return (await modelWithConfig())
|
|
39
|
+
return (await modelWithConfig())?.model;
|
|
38
40
|
}
|
|
39
41
|
export function cacheKeyFor(name, cwd) {
|
|
40
42
|
const seed = cwd ?? process.cwd();
|
package/dist/llm/hazeTools.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { ToolDiffLine, ToolFailureReasonCode } from './toolResultTypes.js';
|
|
2
|
+
import { type ContextFile } from '../config/contextFiles.js';
|
|
2
3
|
export declare const hazeTools: {
|
|
3
4
|
listFiles: import("ai").Tool<{
|
|
4
5
|
path: string;
|
|
5
6
|
recursive: boolean;
|
|
6
7
|
maxEntries: number;
|
|
7
8
|
includeIgnored: boolean;
|
|
9
|
+
includeSizes: boolean;
|
|
8
10
|
cursor?: string | undefined;
|
|
9
11
|
}, {
|
|
10
12
|
ok: boolean;
|
|
@@ -21,22 +23,23 @@ export declare const hazeTools: {
|
|
|
21
23
|
duplicateSkipped: true;
|
|
22
24
|
toolName: string;
|
|
23
25
|
reason: string;
|
|
24
|
-
} | {
|
|
26
|
+
} | ({
|
|
25
27
|
path: string;
|
|
26
28
|
recursive: boolean;
|
|
27
29
|
includeIgnored: boolean;
|
|
30
|
+
includeSizes: boolean;
|
|
28
31
|
cursor: string | undefined;
|
|
29
32
|
nextCursor: string | undefined;
|
|
30
33
|
ignoredSkipped: number;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
type: "file" | "directory";
|
|
34
|
-
size?: number;
|
|
35
|
-
}[];
|
|
34
|
+
entryFormat: string;
|
|
35
|
+
entries: string[];
|
|
36
36
|
truncated: boolean;
|
|
37
|
-
}
|
|
37
|
+
} & {
|
|
38
|
+
applicableProjectInstructions?: ContextFile[];
|
|
39
|
+
})>;
|
|
38
40
|
readFile: import("ai").Tool<{
|
|
39
41
|
path: string;
|
|
42
|
+
mode: "exact" | "outline";
|
|
40
43
|
allowIgnored: boolean;
|
|
41
44
|
offset?: number | undefined;
|
|
42
45
|
limit?: number | undefined;
|
|
@@ -55,8 +58,12 @@ export declare const hazeTools: {
|
|
|
55
58
|
duplicateSkipped: true;
|
|
56
59
|
toolName: string;
|
|
57
60
|
reason: string;
|
|
58
|
-
} | {
|
|
61
|
+
} | ({
|
|
62
|
+
outline?: boolean | undefined;
|
|
63
|
+
outlineEntries?: number | undefined;
|
|
64
|
+
warning?: string | undefined;
|
|
59
65
|
path: string;
|
|
66
|
+
mode: "exact" | "outline";
|
|
60
67
|
startLine: number;
|
|
61
68
|
endLine: number;
|
|
62
69
|
totalLines: number;
|
|
@@ -64,7 +71,9 @@ export declare const hazeTools: {
|
|
|
64
71
|
nextOffset: number | undefined;
|
|
65
72
|
truncated: boolean;
|
|
66
73
|
lineTruncated: boolean;
|
|
67
|
-
}
|
|
74
|
+
} & {
|
|
75
|
+
applicableProjectInstructions?: ContextFile[];
|
|
76
|
+
})>;
|
|
68
77
|
grep: import("ai").Tool<{
|
|
69
78
|
pattern: string;
|
|
70
79
|
path: string;
|
|
@@ -87,7 +96,7 @@ export declare const hazeTools: {
|
|
|
87
96
|
duplicateSkipped: true;
|
|
88
97
|
toolName: string;
|
|
89
98
|
reason: string;
|
|
90
|
-
} | {
|
|
99
|
+
} | ({
|
|
91
100
|
pattern: string;
|
|
92
101
|
path: string;
|
|
93
102
|
glob: string | null;
|
|
@@ -95,10 +104,17 @@ export declare const hazeTools: {
|
|
|
95
104
|
matches: never[];
|
|
96
105
|
totalMatches: number;
|
|
97
106
|
truncated: boolean;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
107
|
+
} & {
|
|
108
|
+
applicableProjectInstructions?: ContextFile[];
|
|
109
|
+
}) | ({
|
|
110
|
+
suggestion: string | undefined;
|
|
111
|
+
omittedChars: number;
|
|
112
|
+
rawChars: number;
|
|
113
|
+
returnedChars: number;
|
|
114
|
+
rawTokensEstimate: number;
|
|
115
|
+
returnedTokensEstimate: number;
|
|
116
|
+
estimatedSavedTokens: number;
|
|
117
|
+
savingsPct: number;
|
|
102
118
|
pattern: string;
|
|
103
119
|
path: string;
|
|
104
120
|
glob: string | null;
|
|
@@ -112,9 +128,16 @@ export declare const hazeTools: {
|
|
|
112
128
|
totalMatches: number;
|
|
113
129
|
returnedMatches: number;
|
|
114
130
|
omittedMatches: number;
|
|
131
|
+
omittedResultLines: number;
|
|
132
|
+
lineTruncated: boolean;
|
|
115
133
|
truncated: boolean;
|
|
116
|
-
|
|
117
|
-
|
|
134
|
+
reducerName: string;
|
|
135
|
+
contentKind: string;
|
|
136
|
+
lossy: boolean;
|
|
137
|
+
parseTier: string;
|
|
138
|
+
} & {
|
|
139
|
+
applicableProjectInstructions?: ContextFile[];
|
|
140
|
+
})>;
|
|
118
141
|
replaceLines: import("ai").Tool<{
|
|
119
142
|
path: string;
|
|
120
143
|
startLine: number;
|
|
@@ -122,6 +145,15 @@ export declare const hazeTools: {
|
|
|
122
145
|
content: string;
|
|
123
146
|
allowIgnored: boolean;
|
|
124
147
|
}, {
|
|
148
|
+
ok: boolean;
|
|
149
|
+
toolName: string;
|
|
150
|
+
path: string;
|
|
151
|
+
error: string;
|
|
152
|
+
reasonCode: "scoped_instructions_discovered";
|
|
153
|
+
recoverable: boolean;
|
|
154
|
+
suggestedNextStep: string;
|
|
155
|
+
applicableProjectInstructions: ContextFile[];
|
|
156
|
+
} | {
|
|
125
157
|
ok: boolean;
|
|
126
158
|
toolName: string;
|
|
127
159
|
path: string | undefined;
|
|
@@ -156,6 +188,15 @@ export declare const hazeTools: {
|
|
|
156
188
|
overwriteExisting: boolean;
|
|
157
189
|
allowIgnored: boolean;
|
|
158
190
|
}, {
|
|
191
|
+
ok: boolean;
|
|
192
|
+
toolName: string;
|
|
193
|
+
path: string;
|
|
194
|
+
error: string;
|
|
195
|
+
reasonCode: "scoped_instructions_discovered";
|
|
196
|
+
recoverable: boolean;
|
|
197
|
+
suggestedNextStep: string;
|
|
198
|
+
applicableProjectInstructions: ContextFile[];
|
|
199
|
+
} | {
|
|
159
200
|
ok: boolean;
|
|
160
201
|
toolName: string;
|
|
161
202
|
path: string | undefined;
|
|
@@ -184,6 +225,15 @@ export declare const hazeTools: {
|
|
|
184
225
|
}[];
|
|
185
226
|
allowIgnored: boolean;
|
|
186
227
|
}, {
|
|
228
|
+
ok: boolean;
|
|
229
|
+
toolName: string;
|
|
230
|
+
path: string;
|
|
231
|
+
error: string;
|
|
232
|
+
reasonCode: "scoped_instructions_discovered";
|
|
233
|
+
recoverable: boolean;
|
|
234
|
+
suggestedNextStep: string;
|
|
235
|
+
applicableProjectInstructions: ContextFile[];
|
|
236
|
+
} | {
|
|
187
237
|
ok: boolean;
|
|
188
238
|
toolName: string;
|
|
189
239
|
path: string | undefined;
|
|
@@ -240,10 +290,77 @@ export declare const hazeTools: {
|
|
|
240
290
|
handle: string;
|
|
241
291
|
offset: number;
|
|
242
292
|
limit: number;
|
|
293
|
+
contextLines: number;
|
|
294
|
+
query?: string | undefined;
|
|
243
295
|
}, import("../core/agent/toolOutputStore.js").StoredToolOutputPage | {
|
|
244
296
|
ok: boolean;
|
|
245
297
|
error: string;
|
|
246
298
|
}>;
|
|
299
|
+
fetch: import("ai").Tool<{
|
|
300
|
+
url: string;
|
|
301
|
+
format: "text" | "auto";
|
|
302
|
+
}, {
|
|
303
|
+
ok: boolean;
|
|
304
|
+
toolName: string;
|
|
305
|
+
path: string | undefined;
|
|
306
|
+
error: string;
|
|
307
|
+
reasonCode: ToolFailureReasonCode | undefined;
|
|
308
|
+
recoverable: boolean;
|
|
309
|
+
suggestedNextStep: string;
|
|
310
|
+
recoveryTool: string | undefined;
|
|
311
|
+
recoveryInput: unknown;
|
|
312
|
+
} | {
|
|
313
|
+
ok: true;
|
|
314
|
+
duplicateSkipped: true;
|
|
315
|
+
toolName: string;
|
|
316
|
+
reason: string;
|
|
317
|
+
} | {
|
|
318
|
+
handle: string;
|
|
319
|
+
rawHandle: string;
|
|
320
|
+
omittedChars: number;
|
|
321
|
+
rawChars: number;
|
|
322
|
+
returnedChars: number;
|
|
323
|
+
rawTokensEstimate: number;
|
|
324
|
+
returnedTokensEstimate: number;
|
|
325
|
+
estimatedSavedTokens: number;
|
|
326
|
+
savingsPct: number;
|
|
327
|
+
ok: boolean;
|
|
328
|
+
url: string;
|
|
329
|
+
status: number;
|
|
330
|
+
statusText: string;
|
|
331
|
+
contentType: string;
|
|
332
|
+
bytes: number;
|
|
333
|
+
redirected: boolean;
|
|
334
|
+
extractionMethod: "json" | "text" | "markdown";
|
|
335
|
+
truncated: boolean;
|
|
336
|
+
content: string;
|
|
337
|
+
reducerName: string;
|
|
338
|
+
contentKind: string;
|
|
339
|
+
lossy: boolean;
|
|
340
|
+
parseTier: string;
|
|
341
|
+
} | {
|
|
342
|
+
omittedChars: number;
|
|
343
|
+
rawChars: number;
|
|
344
|
+
returnedChars: number;
|
|
345
|
+
rawTokensEstimate: number;
|
|
346
|
+
returnedTokensEstimate: number;
|
|
347
|
+
estimatedSavedTokens: number;
|
|
348
|
+
savingsPct: number;
|
|
349
|
+
ok: boolean;
|
|
350
|
+
url: string;
|
|
351
|
+
status: number;
|
|
352
|
+
statusText: string;
|
|
353
|
+
contentType: string;
|
|
354
|
+
bytes: number;
|
|
355
|
+
redirected: boolean;
|
|
356
|
+
extractionMethod: "json" | "text" | "markdown";
|
|
357
|
+
truncated: boolean;
|
|
358
|
+
content: string;
|
|
359
|
+
reducerName: string;
|
|
360
|
+
contentKind: string;
|
|
361
|
+
lossy: boolean;
|
|
362
|
+
parseTier: string;
|
|
363
|
+
}>;
|
|
247
364
|
bash: import("ai").Tool<{
|
|
248
365
|
command: string;
|
|
249
366
|
allowMutation: boolean;
|