@xenosystem/agent-sdk 0.8.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +511 -0
- package/dist/agents/index.cjs +17 -0
- package/dist/agents/index.d.cts +244 -0
- package/dist/agents/index.d.ts +244 -0
- package/dist/agents/index.js +17 -0
- package/dist/agents/metafile-cjs.json +1 -0
- package/dist/agents/metafile-esm.json +1 -0
- package/dist/artifacts/browser.cjs +1 -0
- package/dist/artifacts/browser.d.cts +8 -0
- package/dist/artifacts/browser.d.ts +8 -0
- package/dist/artifacts/browser.js +1 -0
- package/dist/artifacts/diff-artifact-C2tQZWcs.d.cts +354 -0
- package/dist/artifacts/diff-artifact-C2tQZWcs.d.ts +354 -0
- package/dist/artifacts/index.cjs +10 -0
- package/dist/artifacts/index.d.cts +588 -0
- package/dist/artifacts/index.d.ts +588 -0
- package/dist/artifacts/index.js +10 -0
- package/dist/artifacts/metafile-cjs.json +1 -0
- package/dist/artifacts/metafile-esm.json +1 -0
- package/dist/automation/index.cjs +438 -0
- package/dist/automation/index.d.cts +878 -0
- package/dist/automation/index.d.ts +878 -0
- package/dist/automation/index.js +438 -0
- package/dist/automation/metafile-cjs.json +1 -0
- package/dist/automation/metafile-esm.json +1 -0
- package/dist/control-plane/index.cjs +7 -0
- package/dist/control-plane/index.d.cts +403 -0
- package/dist/control-plane/index.d.ts +403 -0
- package/dist/control-plane/index.js +7 -0
- package/dist/control-plane/metafile-cjs.json +1 -0
- package/dist/control-plane/metafile-esm.json +1 -0
- package/dist/control-room/index.cjs +1 -0
- package/dist/control-room/index.d.cts +216 -0
- package/dist/control-room/index.d.ts +216 -0
- package/dist/control-room/index.js +1 -0
- package/dist/control-room/metafile-cjs.json +1 -0
- package/dist/control-room/metafile-esm.json +1 -0
- package/dist/electron/index.cjs +1476 -0
- package/dist/electron/index.d.cts +1583 -0
- package/dist/electron/index.d.ts +1583 -0
- package/dist/electron/index.js +1476 -0
- package/dist/electron/metafile-cjs.json +1 -0
- package/dist/electron/metafile-esm.json +1 -0
- package/dist/governance/index.cjs +33 -0
- package/dist/governance/index.d.cts +397 -0
- package/dist/governance/index.d.ts +397 -0
- package/dist/governance/index.js +33 -0
- package/dist/governance/metafile-cjs.json +1 -0
- package/dist/governance/metafile-esm.json +1 -0
- package/dist/hooks/index.cjs +9 -0
- package/dist/hooks/index.d.cts +198 -0
- package/dist/hooks/index.d.ts +198 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/metafile-cjs.json +1 -0
- package/dist/hooks/metafile-esm.json +1 -0
- package/dist/hosted/index.cjs +1 -0
- package/dist/hosted/index.d.cts +490 -0
- package/dist/hosted/index.d.ts +490 -0
- package/dist/hosted/index.js +1 -0
- package/dist/hosted/metafile-cjs.json +1 -0
- package/dist/hosted/metafile-esm.json +1 -0
- package/dist/index.cjs +2161 -0
- package/dist/index.d.cts +12259 -0
- package/dist/index.d.ts +12259 -0
- package/dist/index.js +2161 -0
- package/dist/intelligence/index.cjs +10 -0
- package/dist/intelligence/index.d.cts +220 -0
- package/dist/intelligence/index.d.ts +220 -0
- package/dist/intelligence/index.js +10 -0
- package/dist/intelligence/metafile-cjs.json +1 -0
- package/dist/intelligence/metafile-esm.json +1 -0
- package/dist/mcp/index.cjs +28 -0
- package/dist/mcp/index.d.cts +960 -0
- package/dist/mcp/index.d.ts +960 -0
- package/dist/mcp/index.js +28 -0
- package/dist/mcp/metafile-cjs.json +1 -0
- package/dist/mcp/metafile-esm.json +1 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/oracle/index.cjs +1 -0
- package/dist/oracle/index.d.cts +310 -0
- package/dist/oracle/index.d.ts +310 -0
- package/dist/oracle/index.js +1 -0
- package/dist/oracle/metafile-cjs.json +1 -0
- package/dist/oracle/metafile-esm.json +1 -0
- package/dist/providers/index.cjs +11 -0
- package/dist/providers/index.d.cts +462 -0
- package/dist/providers/index.d.ts +462 -0
- package/dist/providers/index.js +11 -0
- package/dist/providers/metafile-cjs.json +1 -0
- package/dist/providers/metafile-esm.json +1 -0
- package/dist/recipes/index.cjs +2 -0
- package/dist/recipes/index.d.cts +86 -0
- package/dist/recipes/index.d.ts +86 -0
- package/dist/recipes/index.js +2 -0
- package/dist/recipes/metafile-cjs.json +1 -0
- package/dist/recipes/metafile-esm.json +1 -0
- package/dist/research/index.cjs +3 -0
- package/dist/research/index.d.cts +285 -0
- package/dist/research/index.d.ts +285 -0
- package/dist/research/index.js +3 -0
- package/dist/research/metafile-cjs.json +1 -0
- package/dist/research/metafile-esm.json +1 -0
- package/dist/session/index.cjs +56 -0
- package/dist/session/index.d.cts +523 -0
- package/dist/session/index.d.ts +523 -0
- package/dist/session/index.js +56 -0
- package/dist/session/metafile-cjs.json +1 -0
- package/dist/session/metafile-esm.json +1 -0
- package/dist/sharing/index.cjs +4 -0
- package/dist/sharing/index.d.cts +272 -0
- package/dist/sharing/index.d.ts +272 -0
- package/dist/sharing/index.js +4 -0
- package/dist/sharing/metafile-cjs.json +1 -0
- package/dist/sharing/metafile-esm.json +1 -0
- package/dist/skills/index.cjs +6 -0
- package/dist/skills/index.d.cts +277 -0
- package/dist/skills/index.d.ts +277 -0
- package/dist/skills/index.js +6 -0
- package/dist/skills/metafile-cjs.json +1 -0
- package/dist/skills/metafile-esm.json +1 -0
- package/dist/soul/index.cjs +32 -0
- package/dist/soul/index.d.cts +138 -0
- package/dist/soul/index.d.ts +138 -0
- package/dist/soul/index.js +32 -0
- package/dist/soul/metafile-cjs.json +1 -0
- package/dist/soul/metafile-esm.json +1 -0
- package/dist/terminal/index.cjs +4 -0
- package/dist/terminal/index.d.cts +55 -0
- package/dist/terminal/index.d.ts +55 -0
- package/dist/terminal/index.js +4 -0
- package/dist/terminal/metafile-cjs.json +1 -0
- package/dist/terminal/metafile-esm.json +1 -0
- package/dist/ui/index.cjs +35 -0
- package/dist/ui/index.d.cts +298 -0
- package/dist/ui/index.d.ts +298 -0
- package/dist/ui/index.js +35 -0
- package/dist/ui/metafile-cjs.json +1 -0
- package/dist/ui/metafile-esm.json +1 -0
- package/dist/utils/index.cjs +23 -0
- package/dist/utils/index.d.cts +245 -0
- package/dist/utils/index.d.ts +245 -0
- package/dist/utils/index.js +23 -0
- package/dist/utils/metafile-cjs.json +1 -0
- package/dist/utils/metafile-esm.json +1 -0
- package/native/mxc/LICENSE.microsoft-mxc-sdk.md +21 -0
- package/native/mxc/README.md +25 -0
- package/native/mxc/bin/arm64/lxc-exec +0 -0
- package/native/mxc/bin/arm64/mxc-exec-mac +0 -0
- package/native/mxc/bin/arm64/wxc-exec.exe +0 -0
- package/native/mxc/bin/arm64/wxc-host-prep.exe +0 -0
- package/native/mxc/bin/x64/lxc-exec +0 -0
- package/native/mxc/bin/x64/wxc-exec.exe +0 -0
- package/native/mxc/bin/x64/wxc-host-prep.exe +0 -0
- package/native/mxc/package.json +58 -0
- package/ownership/CLEAN_ROOM_CONTRIBUTOR_GUIDE.md +63 -0
- package/ownership/audit.mjs +727 -0
- package/ownership/evidence/PROPRIETARY-COMMAND-1/implementation-record.md +77 -0
- package/ownership/evidence/PROPRIETARY-COMMAND-1/provenance-review.md +51 -0
- package/ownership/evidence/PROPRIETARY-MEDIA-1/implementation-record.md +131 -0
- package/ownership/evidence/PROPRIETARY-MEDIA-1/provenance-review.md +50 -0
- package/ownership/evidence/PROPRIETARY-PTY-1/implementation-record.md +86 -0
- package/ownership/evidence/PROPRIETARY-PTY-1/provenance-review.md +52 -0
- package/ownership/evidence/PROPRIETARY-RUNTIME-1/implementation-record.md +68 -0
- package/ownership/evidence/PROPRIETARY-RUNTIME-1/provenance-review.md +32 -0
- package/ownership/evidence/PROPRIETARY-TOOLCHAIN-1/implementation-record.md +53 -0
- package/ownership/evidence/PROPRIETARY-TOOLCHAIN-1/provenance-review.md +32 -0
- package/ownership/evidence/PROPRIETARY-UI-1/implementation-record.md +96 -0
- package/ownership/evidence/PROPRIETARY-UI-1/provenance-review.md +46 -0
- package/ownership/ownership-policy.json +232 -0
- package/ownership/ownership-policy.schema.json +192 -0
- package/ownership/templates/clean-room-implementation-record.md +70 -0
- package/ownership/templates/provenance-review.md +51 -0
- package/package.json +209 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
type TextEncoding = "utf8" | "utf8-bom" | "utf16le" | "utf16be";
|
|
2
|
+
type LineEnding = "LF" | "CRLF";
|
|
3
|
+
interface TextFileContents {
|
|
4
|
+
content: string;
|
|
5
|
+
encoding: TextEncoding;
|
|
6
|
+
lineEnding: LineEnding;
|
|
7
|
+
sizeBytes: number;
|
|
8
|
+
}
|
|
9
|
+
declare function hasFile(filePath: string): boolean;
|
|
10
|
+
declare function hasDir(dirPath: string): boolean;
|
|
11
|
+
declare function readFileSafe(filePath: string, fallback?: string): string;
|
|
12
|
+
declare function ensureDir(dirPath: string): Promise<void>;
|
|
13
|
+
declare function writeAtomic(filePath: string, content: string | Buffer): Promise<void>;
|
|
14
|
+
declare function appendLine(filePath: string, line: string): Promise<void>;
|
|
15
|
+
declare function detectTextEncoding(buffer: Buffer): TextEncoding;
|
|
16
|
+
declare function decodeTextBuffer(buffer: Buffer, encoding: TextEncoding): string;
|
|
17
|
+
declare function encodeTextBuffer(content: string, encoding: TextEncoding): Buffer;
|
|
18
|
+
declare function detectLineEnding(content: string): LineEnding;
|
|
19
|
+
declare function normalizeLineEndings(content: string, lineEnding: LineEnding): string;
|
|
20
|
+
declare function readTextFile(filePath: string): Promise<TextFileContents>;
|
|
21
|
+
declare function writeTextFile(filePath: string, content: string, options?: {
|
|
22
|
+
encoding?: TextEncoding;
|
|
23
|
+
lineEnding?: LineEnding;
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
declare function detectPreferredLineEnding(baseDir: string): Promise<LineEnding>;
|
|
26
|
+
declare function findSimilarFile(filePath: string): string | null;
|
|
27
|
+
declare function readIfExists(filePath: string): Promise<string | null>;
|
|
28
|
+
declare function existsSync(filePath: string): boolean;
|
|
29
|
+
declare function listFiles(dir: string, pattern?: RegExp): Promise<string[]>;
|
|
30
|
+
declare function listDirs(dir: string): Promise<string[]>;
|
|
31
|
+
declare function deleteFile(filePath: string): Promise<void>;
|
|
32
|
+
declare function deleteDir(dirPath: string): Promise<void>;
|
|
33
|
+
declare function safeJsonParse<T>(str: string, fallback: T): T;
|
|
34
|
+
declare function safeJsonStringify(obj: unknown, fallback?: string): string;
|
|
35
|
+
declare function parseJsonLines<T>(content: string): T[];
|
|
36
|
+
interface ParsedDocument<T = Record<string, unknown>> {
|
|
37
|
+
frontmatter: T;
|
|
38
|
+
content: string;
|
|
39
|
+
}
|
|
40
|
+
declare function parseDocument<T = Record<string, unknown>>(raw: string): ParsedDocument<T>;
|
|
41
|
+
declare function stringifyDocument(frontmatter: Record<string, unknown>, content: string): string;
|
|
42
|
+
declare function hasFrontmatter(raw: string): boolean;
|
|
43
|
+
declare function isPathSafe(basePath: string, targetPath: string): boolean;
|
|
44
|
+
declare function safeResolvePath(basePath: string, targetPath: string): string;
|
|
45
|
+
declare const PLATFORM: NodeJS.Platform;
|
|
46
|
+
declare const IS_WINDOWS: boolean;
|
|
47
|
+
declare const IS_MAC: boolean;
|
|
48
|
+
declare const IS_LINUX: boolean;
|
|
49
|
+
declare const OS_VERSION: string;
|
|
50
|
+
declare const HOME_DIR: string;
|
|
51
|
+
declare function getConfigDir(): string;
|
|
52
|
+
declare function getProjectConfigDir(cwd: string): string;
|
|
53
|
+
declare function getShellName(): string;
|
|
54
|
+
declare function isGitRepo(cwd: string): boolean;
|
|
55
|
+
declare function validateRequired(params: Record<string, unknown>, required: string[]): string | null;
|
|
56
|
+
declare function getString(params: Record<string, unknown>, key: string, defaultValue?: string): string;
|
|
57
|
+
declare function getNumber(params: Record<string, unknown>, key: string, defaultValue?: number): number;
|
|
58
|
+
declare function getBoolean(params: Record<string, unknown>, key: string, defaultValue?: boolean): boolean;
|
|
59
|
+
declare function validateRegexPattern(pattern: string): string | null;
|
|
60
|
+
declare function createSafeRegex(pattern: string, flags?: string, _timeoutMs?: number): RegExp;
|
|
61
|
+
declare function safeRegexTest(regex: RegExp, text: string, _timeoutMs?: number): boolean;
|
|
62
|
+
declare enum LogLevel {
|
|
63
|
+
DEBUG = 0,
|
|
64
|
+
INFO = 1,
|
|
65
|
+
WARN = 2,
|
|
66
|
+
ERROR = 3,
|
|
67
|
+
SILENT = 4
|
|
68
|
+
}
|
|
69
|
+
declare function setLogLevel(level: LogLevel): void;
|
|
70
|
+
declare function getLogLevel(): LogLevel;
|
|
71
|
+
declare function debug(msg: string, data?: unknown): void;
|
|
72
|
+
declare function info(msg: string, data?: unknown): void;
|
|
73
|
+
declare function warn(msg: string, data?: unknown): void;
|
|
74
|
+
declare function error(msg: string, data?: unknown): void;
|
|
75
|
+
interface RetryOptions {
|
|
76
|
+
maxRetries?: number;
|
|
77
|
+
baseDelayMs?: number;
|
|
78
|
+
maxDelayMs?: number;
|
|
79
|
+
jitterMs?: number;
|
|
80
|
+
signal?: AbortSignal;
|
|
81
|
+
onBeforeAttempt?: (attempt: number) => void;
|
|
82
|
+
shouldRetry?: (error: unknown, attempt: number) => boolean;
|
|
83
|
+
getDelayMs?: (error: unknown, attempt: number, defaultDelayMs: number) => number | null | undefined;
|
|
84
|
+
onAbort?: () => Error;
|
|
85
|
+
}
|
|
86
|
+
interface RetryErrorContext {
|
|
87
|
+
statusCode?: number;
|
|
88
|
+
retryAfterMs?: number;
|
|
89
|
+
requestId?: string;
|
|
90
|
+
cfRay?: string;
|
|
91
|
+
}
|
|
92
|
+
declare class ApiTransientError extends Error {
|
|
93
|
+
readonly statusCode?: number;
|
|
94
|
+
readonly body?: string;
|
|
95
|
+
readonly retryAfterMs?: number;
|
|
96
|
+
readonly requestId?: string;
|
|
97
|
+
readonly cfRay?: string;
|
|
98
|
+
constructor(message: string, context?: RetryErrorContext);
|
|
99
|
+
}
|
|
100
|
+
declare function getRetryErrorContext(error: unknown): RetryErrorContext;
|
|
101
|
+
declare function isRetryableError(error: unknown): boolean;
|
|
102
|
+
declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
103
|
+
type TokenEstimator = (text: string, model: string) => number;
|
|
104
|
+
type TokenAccountingSource = "exact" | "provider-reported" | "estimated";
|
|
105
|
+
interface TokenAccountingResult {
|
|
106
|
+
tokens: number;
|
|
107
|
+
source: TokenAccountingSource;
|
|
108
|
+
adapterId: string;
|
|
109
|
+
}
|
|
110
|
+
interface TokenAccountingAdapter {
|
|
111
|
+
readonly id: string;
|
|
112
|
+
readonly source: Exclude<TokenAccountingSource, "provider-reported">;
|
|
113
|
+
countText(text: string, model: string): number;
|
|
114
|
+
countImage?(input: {
|
|
115
|
+
model: string;
|
|
116
|
+
detail?: "auto" | "low" | "high";
|
|
117
|
+
}): number;
|
|
118
|
+
safetyMarginRatio?(model: string): number;
|
|
119
|
+
}
|
|
120
|
+
declare const estimateTokensForModel: TokenEstimator;
|
|
121
|
+
declare const conservativeTokenAccountingAdapter: TokenAccountingAdapter;
|
|
122
|
+
declare function accountTextTokens(text: string, model: string, adapter?: TokenAccountingAdapter): TokenAccountingResult;
|
|
123
|
+
declare function estimateTokens(text: string): number;
|
|
124
|
+
declare function truncateToTokens(text: string, maxTokens: number): string;
|
|
125
|
+
declare function fitsInBudget(text: string, budget: number): boolean;
|
|
126
|
+
declare function remainingBudget(used: number, total: number): number;
|
|
127
|
+
declare function calculateCost(model: string, inputTokens: number, outputTokens: number): number;
|
|
128
|
+
declare function formatCost(cost: number): string;
|
|
129
|
+
declare function copyTextToClipboard(text: string): void;
|
|
130
|
+
declare function isBenchmarkMode(): boolean;
|
|
131
|
+
declare function isBenchmarkLeakPath(filePath: string): boolean;
|
|
132
|
+
declare function filterBenchmarkLeakPaths(paths: string[]): string[];
|
|
133
|
+
declare function benchmarkLeakError(target: string): string;
|
|
134
|
+
declare function commandMentionsBenchmarkLeak(command: string): boolean;
|
|
135
|
+
declare function getBenchmarkReferenceOverwriteHint(command: string): string | null;
|
|
136
|
+
interface ImageUrlBlock {
|
|
137
|
+
type: "image_url";
|
|
138
|
+
image_url: {
|
|
139
|
+
url: string;
|
|
140
|
+
detail?: "auto" | "low" | "high";
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
interface ResourceContentBlock {
|
|
144
|
+
type: "resource";
|
|
145
|
+
uri?: string;
|
|
146
|
+
mimeType?: string;
|
|
147
|
+
text?: string;
|
|
148
|
+
data?: string;
|
|
149
|
+
}
|
|
150
|
+
type ToolAssistantContentBlock = TextBlock | ImageUrlBlock | ResourceContentBlock;
|
|
151
|
+
type ToolResultContent = string | ToolAssistantContentBlock[];
|
|
152
|
+
type ToolOperationState = "registered" | "starting" | "running_foreground" | "running_background" | "waiting_for_input" | "stalled" | "verifying" | "completed" | "failed" | "timed_out" | "cancelled" | "orphaned";
|
|
153
|
+
type ToolCompletionPolicy = "await" | "observe" | "detach";
|
|
154
|
+
interface ExpectedOutputContract {
|
|
155
|
+
path: string;
|
|
156
|
+
kind?: "file" | "directory";
|
|
157
|
+
nonEmpty?: boolean;
|
|
158
|
+
}
|
|
159
|
+
interface ToolEvidence {
|
|
160
|
+
id: string;
|
|
161
|
+
kind: "artifact" | "process" | "verification";
|
|
162
|
+
status: "pending" | "verified" | "failed";
|
|
163
|
+
path?: string;
|
|
164
|
+
observedAt: string;
|
|
165
|
+
operationId: string;
|
|
166
|
+
detail?: Record<string, string | number | boolean | null>;
|
|
167
|
+
}
|
|
168
|
+
interface ToolOperationSnapshot {
|
|
169
|
+
schemaVersion: 1;
|
|
170
|
+
operationId: string;
|
|
171
|
+
turnId: string;
|
|
172
|
+
generation: number;
|
|
173
|
+
toolCallId: string;
|
|
174
|
+
toolName: string;
|
|
175
|
+
ownerSessionId?: string;
|
|
176
|
+
state: ToolOperationState;
|
|
177
|
+
terminal: boolean;
|
|
178
|
+
presentation: "foreground" | "background";
|
|
179
|
+
completionPolicy: ToolCompletionPolicy;
|
|
180
|
+
promotable: boolean;
|
|
181
|
+
processId?: string;
|
|
182
|
+
taskId?: string;
|
|
183
|
+
pid?: number;
|
|
184
|
+
commandFingerprint?: string;
|
|
185
|
+
outputPath?: string;
|
|
186
|
+
startedAt: string;
|
|
187
|
+
lastActivityAt: string;
|
|
188
|
+
deadlineAt?: string;
|
|
189
|
+
elapsedMs: number;
|
|
190
|
+
idleMs: number;
|
|
191
|
+
outputBytes: number;
|
|
192
|
+
nextOffset: number;
|
|
193
|
+
exitCode?: number | null;
|
|
194
|
+
completionReason?: string;
|
|
195
|
+
suggestedNextAction?: string;
|
|
196
|
+
expectedOutputs?: ExpectedOutputContract[];
|
|
197
|
+
evidence?: ToolEvidence[];
|
|
198
|
+
}
|
|
199
|
+
interface ToolResult {
|
|
200
|
+
success: boolean;
|
|
201
|
+
output: string;
|
|
202
|
+
error?: string;
|
|
203
|
+
errorCode?: string;
|
|
204
|
+
errorDetails?: Record<string, unknown>;
|
|
205
|
+
assistantContent?: ToolAssistantContentBlock[];
|
|
206
|
+
assistantOnlyContent?: ToolAssistantContentBlock[];
|
|
207
|
+
operation?: ToolOperationSnapshot;
|
|
208
|
+
evidence?: ToolEvidence[];
|
|
209
|
+
retryable?: boolean;
|
|
210
|
+
}
|
|
211
|
+
interface TextBlock {
|
|
212
|
+
type: "text";
|
|
213
|
+
text: string;
|
|
214
|
+
}
|
|
215
|
+
interface ToolResultBlock {
|
|
216
|
+
type: "tool_result";
|
|
217
|
+
tool_use_id: string;
|
|
218
|
+
content: string;
|
|
219
|
+
assistant_content?: ToolAssistantContentBlock[];
|
|
220
|
+
assistant_only_content?: ToolAssistantContentBlock[];
|
|
221
|
+
is_error?: boolean;
|
|
222
|
+
operation?: ToolOperationSnapshot;
|
|
223
|
+
evidence?: ToolEvidence[];
|
|
224
|
+
retryable?: boolean;
|
|
225
|
+
}
|
|
226
|
+
declare function toolAssistantContentToText(blocks: ToolAssistantContentBlock[]): string;
|
|
227
|
+
declare function toolResultContentToText(content: ToolResultContent): string;
|
|
228
|
+
declare function buildToolResultText(result: ToolResult): string;
|
|
229
|
+
declare function getToolResultTransportContent(block: {
|
|
230
|
+
content: ToolResultContent;
|
|
231
|
+
assistant_content?: ToolAssistantContentBlock[];
|
|
232
|
+
assistant_only_content?: ToolAssistantContentBlock[];
|
|
233
|
+
operation?: ToolResult["operation"];
|
|
234
|
+
evidence?: ToolResult["evidence"];
|
|
235
|
+
retryable?: boolean;
|
|
236
|
+
}): ToolResultContent;
|
|
237
|
+
declare function hasNonTextToolResultContent(content: ToolResultContent): boolean;
|
|
238
|
+
declare function toTransportAssistantBlocks(content: ToolResultContent): ToolAssistantContentBlock[];
|
|
239
|
+
declare function buildToolResultBlock(toolUseId: string, result: ToolResult): ToolResultBlock;
|
|
240
|
+
interface XenoAsciiControlCharacterPolicy {
|
|
241
|
+
allowTab?: boolean;
|
|
242
|
+
allowLineBreaks?: boolean;
|
|
243
|
+
}
|
|
244
|
+
declare function hasDisallowedAsciiControlCharacter(value: string, policy?: XenoAsciiControlCharacterPolicy): boolean;
|
|
245
|
+
export { ApiTransientError, HOME_DIR, IS_LINUX, IS_MAC, IS_WINDOWS, type LineEnding, LogLevel, OS_VERSION, PLATFORM, type ParsedDocument, type RetryErrorContext, type RetryOptions, type TextEncoding, type TextFileContents, type TokenAccountingAdapter, type TokenAccountingResult, type TokenAccountingSource, type TokenEstimator, type XenoAsciiControlCharacterPolicy, accountTextTokens, appendLine, benchmarkLeakError, buildToolResultBlock, buildToolResultText, calculateCost, commandMentionsBenchmarkLeak, conservativeTokenAccountingAdapter, copyTextToClipboard, createSafeRegex, debug, decodeTextBuffer, deleteDir, deleteFile, detectLineEnding, detectPreferredLineEnding, detectTextEncoding, encodeTextBuffer, ensureDir, error, estimateTokens, estimateTokensForModel, existsSync, filterBenchmarkLeakPaths, findSimilarFile, fitsInBudget, formatCost, getBenchmarkReferenceOverwriteHint, getBoolean, getConfigDir, getLogLevel, getNumber, getProjectConfigDir, getRetryErrorContext, getShellName, getString, getToolResultTransportContent, hasDir, hasDisallowedAsciiControlCharacter, hasFile, hasFrontmatter, hasNonTextToolResultContent, info, isBenchmarkLeakPath, isBenchmarkMode, isGitRepo, isPathSafe, isRetryableError, listDirs, listFiles, normalizeLineEndings, parseDocument, parseJsonLines, readFileSafe, readIfExists, readTextFile, remainingBudget, safeJsonParse, safeJsonStringify, safeRegexTest, safeResolvePath, setLogLevel, stringifyDocument, toTransportAssistantBlocks, toolAssistantContentToText, toolResultContentToText, truncateToTokens, validateRegexPattern, validateRequired, warn, withRetry, writeAtomic, writeTextFile };
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
type TextEncoding = "utf8" | "utf8-bom" | "utf16le" | "utf16be";
|
|
2
|
+
type LineEnding = "LF" | "CRLF";
|
|
3
|
+
interface TextFileContents {
|
|
4
|
+
content: string;
|
|
5
|
+
encoding: TextEncoding;
|
|
6
|
+
lineEnding: LineEnding;
|
|
7
|
+
sizeBytes: number;
|
|
8
|
+
}
|
|
9
|
+
declare function hasFile(filePath: string): boolean;
|
|
10
|
+
declare function hasDir(dirPath: string): boolean;
|
|
11
|
+
declare function readFileSafe(filePath: string, fallback?: string): string;
|
|
12
|
+
declare function ensureDir(dirPath: string): Promise<void>;
|
|
13
|
+
declare function writeAtomic(filePath: string, content: string | Buffer): Promise<void>;
|
|
14
|
+
declare function appendLine(filePath: string, line: string): Promise<void>;
|
|
15
|
+
declare function detectTextEncoding(buffer: Buffer): TextEncoding;
|
|
16
|
+
declare function decodeTextBuffer(buffer: Buffer, encoding: TextEncoding): string;
|
|
17
|
+
declare function encodeTextBuffer(content: string, encoding: TextEncoding): Buffer;
|
|
18
|
+
declare function detectLineEnding(content: string): LineEnding;
|
|
19
|
+
declare function normalizeLineEndings(content: string, lineEnding: LineEnding): string;
|
|
20
|
+
declare function readTextFile(filePath: string): Promise<TextFileContents>;
|
|
21
|
+
declare function writeTextFile(filePath: string, content: string, options?: {
|
|
22
|
+
encoding?: TextEncoding;
|
|
23
|
+
lineEnding?: LineEnding;
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
declare function detectPreferredLineEnding(baseDir: string): Promise<LineEnding>;
|
|
26
|
+
declare function findSimilarFile(filePath: string): string | null;
|
|
27
|
+
declare function readIfExists(filePath: string): Promise<string | null>;
|
|
28
|
+
declare function existsSync(filePath: string): boolean;
|
|
29
|
+
declare function listFiles(dir: string, pattern?: RegExp): Promise<string[]>;
|
|
30
|
+
declare function listDirs(dir: string): Promise<string[]>;
|
|
31
|
+
declare function deleteFile(filePath: string): Promise<void>;
|
|
32
|
+
declare function deleteDir(dirPath: string): Promise<void>;
|
|
33
|
+
declare function safeJsonParse<T>(str: string, fallback: T): T;
|
|
34
|
+
declare function safeJsonStringify(obj: unknown, fallback?: string): string;
|
|
35
|
+
declare function parseJsonLines<T>(content: string): T[];
|
|
36
|
+
interface ParsedDocument<T = Record<string, unknown>> {
|
|
37
|
+
frontmatter: T;
|
|
38
|
+
content: string;
|
|
39
|
+
}
|
|
40
|
+
declare function parseDocument<T = Record<string, unknown>>(raw: string): ParsedDocument<T>;
|
|
41
|
+
declare function stringifyDocument(frontmatter: Record<string, unknown>, content: string): string;
|
|
42
|
+
declare function hasFrontmatter(raw: string): boolean;
|
|
43
|
+
declare function isPathSafe(basePath: string, targetPath: string): boolean;
|
|
44
|
+
declare function safeResolvePath(basePath: string, targetPath: string): string;
|
|
45
|
+
declare const PLATFORM: NodeJS.Platform;
|
|
46
|
+
declare const IS_WINDOWS: boolean;
|
|
47
|
+
declare const IS_MAC: boolean;
|
|
48
|
+
declare const IS_LINUX: boolean;
|
|
49
|
+
declare const OS_VERSION: string;
|
|
50
|
+
declare const HOME_DIR: string;
|
|
51
|
+
declare function getConfigDir(): string;
|
|
52
|
+
declare function getProjectConfigDir(cwd: string): string;
|
|
53
|
+
declare function getShellName(): string;
|
|
54
|
+
declare function isGitRepo(cwd: string): boolean;
|
|
55
|
+
declare function validateRequired(params: Record<string, unknown>, required: string[]): string | null;
|
|
56
|
+
declare function getString(params: Record<string, unknown>, key: string, defaultValue?: string): string;
|
|
57
|
+
declare function getNumber(params: Record<string, unknown>, key: string, defaultValue?: number): number;
|
|
58
|
+
declare function getBoolean(params: Record<string, unknown>, key: string, defaultValue?: boolean): boolean;
|
|
59
|
+
declare function validateRegexPattern(pattern: string): string | null;
|
|
60
|
+
declare function createSafeRegex(pattern: string, flags?: string, _timeoutMs?: number): RegExp;
|
|
61
|
+
declare function safeRegexTest(regex: RegExp, text: string, _timeoutMs?: number): boolean;
|
|
62
|
+
declare enum LogLevel {
|
|
63
|
+
DEBUG = 0,
|
|
64
|
+
INFO = 1,
|
|
65
|
+
WARN = 2,
|
|
66
|
+
ERROR = 3,
|
|
67
|
+
SILENT = 4
|
|
68
|
+
}
|
|
69
|
+
declare function setLogLevel(level: LogLevel): void;
|
|
70
|
+
declare function getLogLevel(): LogLevel;
|
|
71
|
+
declare function debug(msg: string, data?: unknown): void;
|
|
72
|
+
declare function info(msg: string, data?: unknown): void;
|
|
73
|
+
declare function warn(msg: string, data?: unknown): void;
|
|
74
|
+
declare function error(msg: string, data?: unknown): void;
|
|
75
|
+
interface RetryOptions {
|
|
76
|
+
maxRetries?: number;
|
|
77
|
+
baseDelayMs?: number;
|
|
78
|
+
maxDelayMs?: number;
|
|
79
|
+
jitterMs?: number;
|
|
80
|
+
signal?: AbortSignal;
|
|
81
|
+
onBeforeAttempt?: (attempt: number) => void;
|
|
82
|
+
shouldRetry?: (error: unknown, attempt: number) => boolean;
|
|
83
|
+
getDelayMs?: (error: unknown, attempt: number, defaultDelayMs: number) => number | null | undefined;
|
|
84
|
+
onAbort?: () => Error;
|
|
85
|
+
}
|
|
86
|
+
interface RetryErrorContext {
|
|
87
|
+
statusCode?: number;
|
|
88
|
+
retryAfterMs?: number;
|
|
89
|
+
requestId?: string;
|
|
90
|
+
cfRay?: string;
|
|
91
|
+
}
|
|
92
|
+
declare class ApiTransientError extends Error {
|
|
93
|
+
readonly statusCode?: number;
|
|
94
|
+
readonly body?: string;
|
|
95
|
+
readonly retryAfterMs?: number;
|
|
96
|
+
readonly requestId?: string;
|
|
97
|
+
readonly cfRay?: string;
|
|
98
|
+
constructor(message: string, context?: RetryErrorContext);
|
|
99
|
+
}
|
|
100
|
+
declare function getRetryErrorContext(error: unknown): RetryErrorContext;
|
|
101
|
+
declare function isRetryableError(error: unknown): boolean;
|
|
102
|
+
declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
103
|
+
type TokenEstimator = (text: string, model: string) => number;
|
|
104
|
+
type TokenAccountingSource = "exact" | "provider-reported" | "estimated";
|
|
105
|
+
interface TokenAccountingResult {
|
|
106
|
+
tokens: number;
|
|
107
|
+
source: TokenAccountingSource;
|
|
108
|
+
adapterId: string;
|
|
109
|
+
}
|
|
110
|
+
interface TokenAccountingAdapter {
|
|
111
|
+
readonly id: string;
|
|
112
|
+
readonly source: Exclude<TokenAccountingSource, "provider-reported">;
|
|
113
|
+
countText(text: string, model: string): number;
|
|
114
|
+
countImage?(input: {
|
|
115
|
+
model: string;
|
|
116
|
+
detail?: "auto" | "low" | "high";
|
|
117
|
+
}): number;
|
|
118
|
+
safetyMarginRatio?(model: string): number;
|
|
119
|
+
}
|
|
120
|
+
declare const estimateTokensForModel: TokenEstimator;
|
|
121
|
+
declare const conservativeTokenAccountingAdapter: TokenAccountingAdapter;
|
|
122
|
+
declare function accountTextTokens(text: string, model: string, adapter?: TokenAccountingAdapter): TokenAccountingResult;
|
|
123
|
+
declare function estimateTokens(text: string): number;
|
|
124
|
+
declare function truncateToTokens(text: string, maxTokens: number): string;
|
|
125
|
+
declare function fitsInBudget(text: string, budget: number): boolean;
|
|
126
|
+
declare function remainingBudget(used: number, total: number): number;
|
|
127
|
+
declare function calculateCost(model: string, inputTokens: number, outputTokens: number): number;
|
|
128
|
+
declare function formatCost(cost: number): string;
|
|
129
|
+
declare function copyTextToClipboard(text: string): void;
|
|
130
|
+
declare function isBenchmarkMode(): boolean;
|
|
131
|
+
declare function isBenchmarkLeakPath(filePath: string): boolean;
|
|
132
|
+
declare function filterBenchmarkLeakPaths(paths: string[]): string[];
|
|
133
|
+
declare function benchmarkLeakError(target: string): string;
|
|
134
|
+
declare function commandMentionsBenchmarkLeak(command: string): boolean;
|
|
135
|
+
declare function getBenchmarkReferenceOverwriteHint(command: string): string | null;
|
|
136
|
+
interface ImageUrlBlock {
|
|
137
|
+
type: "image_url";
|
|
138
|
+
image_url: {
|
|
139
|
+
url: string;
|
|
140
|
+
detail?: "auto" | "low" | "high";
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
interface ResourceContentBlock {
|
|
144
|
+
type: "resource";
|
|
145
|
+
uri?: string;
|
|
146
|
+
mimeType?: string;
|
|
147
|
+
text?: string;
|
|
148
|
+
data?: string;
|
|
149
|
+
}
|
|
150
|
+
type ToolAssistantContentBlock = TextBlock | ImageUrlBlock | ResourceContentBlock;
|
|
151
|
+
type ToolResultContent = string | ToolAssistantContentBlock[];
|
|
152
|
+
type ToolOperationState = "registered" | "starting" | "running_foreground" | "running_background" | "waiting_for_input" | "stalled" | "verifying" | "completed" | "failed" | "timed_out" | "cancelled" | "orphaned";
|
|
153
|
+
type ToolCompletionPolicy = "await" | "observe" | "detach";
|
|
154
|
+
interface ExpectedOutputContract {
|
|
155
|
+
path: string;
|
|
156
|
+
kind?: "file" | "directory";
|
|
157
|
+
nonEmpty?: boolean;
|
|
158
|
+
}
|
|
159
|
+
interface ToolEvidence {
|
|
160
|
+
id: string;
|
|
161
|
+
kind: "artifact" | "process" | "verification";
|
|
162
|
+
status: "pending" | "verified" | "failed";
|
|
163
|
+
path?: string;
|
|
164
|
+
observedAt: string;
|
|
165
|
+
operationId: string;
|
|
166
|
+
detail?: Record<string, string | number | boolean | null>;
|
|
167
|
+
}
|
|
168
|
+
interface ToolOperationSnapshot {
|
|
169
|
+
schemaVersion: 1;
|
|
170
|
+
operationId: string;
|
|
171
|
+
turnId: string;
|
|
172
|
+
generation: number;
|
|
173
|
+
toolCallId: string;
|
|
174
|
+
toolName: string;
|
|
175
|
+
ownerSessionId?: string;
|
|
176
|
+
state: ToolOperationState;
|
|
177
|
+
terminal: boolean;
|
|
178
|
+
presentation: "foreground" | "background";
|
|
179
|
+
completionPolicy: ToolCompletionPolicy;
|
|
180
|
+
promotable: boolean;
|
|
181
|
+
processId?: string;
|
|
182
|
+
taskId?: string;
|
|
183
|
+
pid?: number;
|
|
184
|
+
commandFingerprint?: string;
|
|
185
|
+
outputPath?: string;
|
|
186
|
+
startedAt: string;
|
|
187
|
+
lastActivityAt: string;
|
|
188
|
+
deadlineAt?: string;
|
|
189
|
+
elapsedMs: number;
|
|
190
|
+
idleMs: number;
|
|
191
|
+
outputBytes: number;
|
|
192
|
+
nextOffset: number;
|
|
193
|
+
exitCode?: number | null;
|
|
194
|
+
completionReason?: string;
|
|
195
|
+
suggestedNextAction?: string;
|
|
196
|
+
expectedOutputs?: ExpectedOutputContract[];
|
|
197
|
+
evidence?: ToolEvidence[];
|
|
198
|
+
}
|
|
199
|
+
interface ToolResult {
|
|
200
|
+
success: boolean;
|
|
201
|
+
output: string;
|
|
202
|
+
error?: string;
|
|
203
|
+
errorCode?: string;
|
|
204
|
+
errorDetails?: Record<string, unknown>;
|
|
205
|
+
assistantContent?: ToolAssistantContentBlock[];
|
|
206
|
+
assistantOnlyContent?: ToolAssistantContentBlock[];
|
|
207
|
+
operation?: ToolOperationSnapshot;
|
|
208
|
+
evidence?: ToolEvidence[];
|
|
209
|
+
retryable?: boolean;
|
|
210
|
+
}
|
|
211
|
+
interface TextBlock {
|
|
212
|
+
type: "text";
|
|
213
|
+
text: string;
|
|
214
|
+
}
|
|
215
|
+
interface ToolResultBlock {
|
|
216
|
+
type: "tool_result";
|
|
217
|
+
tool_use_id: string;
|
|
218
|
+
content: string;
|
|
219
|
+
assistant_content?: ToolAssistantContentBlock[];
|
|
220
|
+
assistant_only_content?: ToolAssistantContentBlock[];
|
|
221
|
+
is_error?: boolean;
|
|
222
|
+
operation?: ToolOperationSnapshot;
|
|
223
|
+
evidence?: ToolEvidence[];
|
|
224
|
+
retryable?: boolean;
|
|
225
|
+
}
|
|
226
|
+
declare function toolAssistantContentToText(blocks: ToolAssistantContentBlock[]): string;
|
|
227
|
+
declare function toolResultContentToText(content: ToolResultContent): string;
|
|
228
|
+
declare function buildToolResultText(result: ToolResult): string;
|
|
229
|
+
declare function getToolResultTransportContent(block: {
|
|
230
|
+
content: ToolResultContent;
|
|
231
|
+
assistant_content?: ToolAssistantContentBlock[];
|
|
232
|
+
assistant_only_content?: ToolAssistantContentBlock[];
|
|
233
|
+
operation?: ToolResult["operation"];
|
|
234
|
+
evidence?: ToolResult["evidence"];
|
|
235
|
+
retryable?: boolean;
|
|
236
|
+
}): ToolResultContent;
|
|
237
|
+
declare function hasNonTextToolResultContent(content: ToolResultContent): boolean;
|
|
238
|
+
declare function toTransportAssistantBlocks(content: ToolResultContent): ToolAssistantContentBlock[];
|
|
239
|
+
declare function buildToolResultBlock(toolUseId: string, result: ToolResult): ToolResultBlock;
|
|
240
|
+
interface XenoAsciiControlCharacterPolicy {
|
|
241
|
+
allowTab?: boolean;
|
|
242
|
+
allowLineBreaks?: boolean;
|
|
243
|
+
}
|
|
244
|
+
declare function hasDisallowedAsciiControlCharacter(value: string, policy?: XenoAsciiControlCharacterPolicy): boolean;
|
|
245
|
+
export { ApiTransientError, HOME_DIR, IS_LINUX, IS_MAC, IS_WINDOWS, type LineEnding, LogLevel, OS_VERSION, PLATFORM, type ParsedDocument, type RetryErrorContext, type RetryOptions, type TextEncoding, type TextFileContents, type TokenAccountingAdapter, type TokenAccountingResult, type TokenAccountingSource, type TokenEstimator, type XenoAsciiControlCharacterPolicy, accountTextTokens, appendLine, benchmarkLeakError, buildToolResultBlock, buildToolResultText, calculateCost, commandMentionsBenchmarkLeak, conservativeTokenAccountingAdapter, copyTextToClipboard, createSafeRegex, debug, decodeTextBuffer, deleteDir, deleteFile, detectLineEnding, detectPreferredLineEnding, detectTextEncoding, encodeTextBuffer, ensureDir, error, estimateTokens, estimateTokensForModel, existsSync, filterBenchmarkLeakPaths, findSimilarFile, fitsInBudget, formatCost, getBenchmarkReferenceOverwriteHint, getBoolean, getConfigDir, getLogLevel, getNumber, getProjectConfigDir, getRetryErrorContext, getShellName, getString, getToolResultTransportContent, hasDir, hasDisallowedAsciiControlCharacter, hasFile, hasFrontmatter, hasNonTextToolResultContent, info, isBenchmarkLeakPath, isBenchmarkMode, isGitRepo, isPathSafe, isRetryableError, listDirs, listFiles, normalizeLineEndings, parseDocument, parseJsonLines, readFileSafe, readIfExists, readTextFile, remainingBudget, safeJsonParse, safeJsonStringify, safeRegexTest, safeResolvePath, setLogLevel, stringifyDocument, toTransportAssistantBlocks, toolAssistantContentToText, toolResultContentToText, truncateToTokens, validateRegexPattern, validateRequired, warn, withRetry, writeAtomic, writeTextFile };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import{readdirSync as A,readFileSync as X}from"node:fs";import{existsSync as R,statSync as M}from"node:fs";import*as c from"node:fs/promises";import*as a from"node:path";function It(t){try{return R(t)&&M(t).isFile()}catch{return!1}}function Dt(t){try{return R(t)&&M(t).isDirectory()}catch{return!1}}function Ft(t,e=""){try{return X(t,"utf-8")}catch{return e}}async function C(t){await c.mkdir(t,{recursive:!0})}async function z(t,e){let n=a.dirname(t);await C(n);let r=Math.random().toString(36).substring(2,15),o=`${t}.tmp.${process.pid}.${r}`;try{await c.writeFile(o,e),await c.rename(o,t)}finally{try{await c.unlink(o)}catch{}}}async function Wt(t,e){let n=a.dirname(t);await C(n),await c.appendFile(t,e+`
|
|
2
|
+
`,"utf-8")}function Y(t){return t.length>=3&&t[0]===239&&t[1]===187&&t[2]===191?"utf8-bom":t.length>=2&&t[0]===255&&t[1]===254?"utf16le":t.length>=2&&t[0]===254&&t[1]===255?"utf16be":"utf8"}function S(t){let e=Buffer.from(t);for(let n=0;n+1<e.length;n+=2){let r=e[n];e[n]=e[n+1],e[n+1]=r}return e}function G(t,e){switch(e){case"utf8-bom":return t.subarray(3).toString("utf8");case"utf16le":return t.subarray(2).toString("utf16le");case"utf16be":return S(t.subarray(2)).toString("utf16le");default:return t.toString("utf8")}}function U(t,e){switch(e){case"utf8-bom":return Buffer.concat([Buffer.from([239,187,191]),Buffer.from(t,"utf8")]);case"utf16le":return Buffer.concat([Buffer.from([255,254]),Buffer.from(t,"utf16le")]);case"utf16be":return Buffer.concat([Buffer.from([254,255]),S(Buffer.from(t,"utf16le"))]);default:return Buffer.from(t,"utf8")}}function K(t){return t.includes(`\r
|
|
3
|
+
`)?"CRLF":"LF"}function Q(t,e){let n=t.replace(/\r\n/g,`
|
|
4
|
+
`);return e==="CRLF"?n.replace(/\n/g,`\r
|
|
5
|
+
`):n}async function Z(t){let e=await c.readFile(t),n=Y(e),r=G(e,n);return{content:r,encoding:n,lineEnding:K(r),sizeBytes:e.length}}async function jt(t,e,n){let r=Q(e,n?.lineEnding??"LF");await z(t,U(r,n?.encoding??"utf8"))}async function qt(t){let e=new Set,n=a.resolve(t);for(;!e.has(n);){e.add(n);try{let o=A(n,{withFileTypes:!0}).filter(i=>i.isFile()).map(i=>i.name).sort();for(let i of o){if(i.startsWith("."))continue;let s=a.extname(i).toLowerCase();if([".ts",".tsx",".js",".jsx",".json",".md",".txt",".yaml",".yml",".css",".html",".xml",".sh",".ps1"].includes(s))try{let u=a.join(n,i),l=await Z(u);if(l.content.length>0)return l.lineEnding}catch{}}}catch{}let r=a.dirname(n);if(r===n)break;n=r}return"LF"}function V(t,e,n){let r=[],o=[{dir:t,depth:0}],i=new Set;for(;o.length>0&&r.length<n;){let s=o.shift();if(!i.has(s.dir)){i.add(s.dir);try{let u=A(s.dir,{withFileTypes:!0});for(let l of u){let d=a.join(s.dir,l.name);if(l.isFile()){if(r.push(d),r.length>=n)break;continue}l.isDirectory()&&s.depth<e&&!l.name.startsWith(".")&&l.name!=="node_modules"&&o.push({dir:d,depth:s.depth+1})}}catch{}}}return r}function Ht(t){try{let e=a.dirname(t),n=a.basename(t,a.extname(t)).toLowerCase(),r=a.basename(t).toLowerCase(),i=[e,a.dirname(e)].flatMap(u=>V(u,2,500)),s=null;for(let u of i){let l=a.basename(u).toLowerCase(),d=a.basename(u,a.extname(u)).toLowerCase(),m=null;if(l===r?m=0:d===n?m=1:(l.includes(n)||n.includes(d))&&(m=2),m===null)continue;let E=a.relative(e,u).split(a.sep).length,k=m+E*.01;(!s||k<s.score)&&(s={filePath:u,score:k})}return s?.filePath??null}catch{}return null}async function Jt(t){try{return await c.readFile(t,"utf-8")}catch(e){if(e.code==="ENOENT")return null;throw e}}function Xt(t){return R(t)}async function zt(t,e){try{let r=(await c.readdir(t,{withFileTypes:!0})).filter(o=>o.isFile()).map(o=>a.join(t,o.name));return e&&(r=r.filter(o=>e.test(a.basename(o)))),r}catch(n){if(n.code==="ENOENT")return[];throw n}}async function Yt(t){try{return(await c.readdir(t,{withFileTypes:!0})).filter(n=>n.isDirectory()).map(n=>a.join(t,n.name))}catch(e){if(e.code==="ENOENT")return[];throw e}}async function Gt(t){try{await c.unlink(t)}catch(e){if(e.code!=="ENOENT")throw e}}async function Ut(t){try{await c.rm(t,{recursive:!0,force:!0})}catch(e){if(e.code!=="ENOENT")throw e}}function Qt(t,e){try{return JSON.parse(t)}catch{return e}}function Zt(t,e="{}"){try{return JSON.stringify(t)}catch{return e}}function Vt(t){let e=[];for(let n of t.split(`
|
|
6
|
+
`)){let r=n.trim();if(r)try{e.push(JSON.parse(r))}catch{}}return e}function ee(t){let e=tt(t);return{frontmatter:e.frontmatter,content:e.content.trim()}}function ne(t,e){let n=Object.fromEntries(Object.entries(t).filter(([r,o])=>o!==void 0));return["---",v(n),"---","",e].join(`
|
|
7
|
+
`)}function re(t){return t.trimStart().startsWith("---")}function tt(t){let e=t.replace(/^\uFEFF/,"");if(!e.startsWith("---"))return{frontmatter:{},content:t};let n=e.search(/\r?\n/);if(n<0||e.slice(0,n).trim()!=="---")return{frontmatter:{},content:t};let r=e.slice(n+(e[n]==="\r"?2:1)),o=r.match(/(?:^|\r?\n)---[ \t]*(?:\r?\n|$)/);if(!o||o.index===void 0)throw new Error("YAML frontmatter is not closed.");let i=r.slice(0,o.index),s=o[0],u=o.index+s.length;return{frontmatter:$(i),content:r.slice(u)}}function $(t){let e={},n=t.split(/\r?\n/);for(let r=0;r<n.length;r+=1){let o=n[r];if(!o.trim()||o.trimStart().startsWith("#"))continue;if(/^\s/.test(o))throw new Error(`Unexpected indentation at line ${r+1}.`);let i=nt(o,r+1);if(i.key==="<<")throw new Error("YAML merge keys are not supported.");if(i.value!==""){e[i.key]=N(i.value,r+1);continue}let s=et(n,r+1);e[i.key]=s.value,r=s.nextIndex-1}return e}function et(t,e){let n=[],r=e;for(;r<t.length;r+=1){let i=t[r];if(!i.trim()){n.push(i);continue}if(!/^\s/.test(i))break;n.push(i.replace(/^ {2}/,""))}let o=n.filter(i=>i.trim()&&!i.trimStart().startsWith("#"));return o.length===0?{value:{},nextIndex:r}:o.every(i=>i.trimStart().startsWith("- "))?{value:o.map((i,s)=>N(i.trimStart().slice(2),e+s+1)),nextIndex:r}:{value:$(n.join(`
|
|
8
|
+
`)),nextIndex:r}}function nt(t,e){let n=t.indexOf(":");if(n<=0)throw new Error(`Invalid YAML line ${e}.`);let r=t.slice(0,n).trim(),o=t.slice(n+1).trim();if(!r)throw new Error(`Invalid YAML key at line ${e}.`);return{key:r,value:o}}function N(t,e){if(t==="")return"";if(t==="[]")return[];if(t==="{}")return{};if(t==="true")return!0;if(t==="false")return!1;if(t==="null"||t==="~")return null;if(/^-?\d+(?:\.\d+)?$/.test(t))return Number(t);if(t.startsWith('"'))return _(t,e);if(t.startsWith("'")){if(!t.endsWith("'"))throw new Error(`Unclosed quoted scalar at line ${e}.`);return t.slice(1,-1).replace(/''/g,"'")}if(t.startsWith("[")||t.startsWith("{"))return _(t,e);if(t.includes("[")||t.includes("]")||t.includes("{")||t.includes("}"))throw new Error(`Unsupported YAML scalar at line ${e}.`);return t}function _(t,e){try{return JSON.parse(t)}catch{throw new Error(`Invalid YAML scalar at line ${e}.`)}}function v(t,e=""){return Object.entries(t).map(([n,r])=>rt(n,r,e)).join(`
|
|
9
|
+
`)}function rt(t,e,n){return Array.isArray(e)?`${n}${t}: ${JSON.stringify(e)}`:e&&typeof e=="object"?`${n}${t}:
|
|
10
|
+
${v(e,`${n} `)}`:`${n}${t}: ${JSON.stringify(e)}`}import*as f from"path";function ot(t,e){let n=f.resolve(t),r=f.resolve(t,e);return r===n?!0:n===f.parse(n).root?r.startsWith(n):r.startsWith(n+f.sep)}function ie(t,e){if(f.isAbsolute(e))return f.resolve(e);if(!ot(t,e))throw new Error(`PathSecurity: Path traversal attempt detected: ${e}`);return f.resolve(t,e)}import{homedir as it,platform as st,release as at}from"node:os";import{execSync as ut}from"node:child_process";import{resolve as L}from"node:path";var T=st(),ct=T==="win32",le=T==="darwin",fe=T==="linux",de=at(),lt=it();function pe(){return L(lt,".xeno-code")}function me(t){return L(t,".xeno-code")}function ge(){return ct?"powershell":process.env.SHELL?.split("/").pop()??"bash"}function he(t){try{return ut("git rev-parse --is-inside-work-tree",{cwd:t,stdio:"ignore"}),!0}catch{return!1}}function ye(t,e){for(let n of e)if(t[n]===void 0||t[n]===null||t[n]==="")return`Missing required parameter: ${n}`;return null}function we(t,e,n){let r=t[e];if(r==null){if(n!==void 0)return n;throw new Error(`Missing required parameter: ${e}`)}if(typeof r!="string")throw new Error(`Parameter ${e} must be a string, got ${typeof r}`);return r}function be(t,e,n){let r=t[e];if(r==null){if(n!==void 0)return n;throw new Error(`Missing required parameter: ${e}`)}if(typeof r!="number")throw new Error(`Parameter ${e} must be a number, got ${typeof r}`);if(isNaN(r))throw new Error(`Parameter ${e} is NaN`);return r}function Ee(t,e,n){let r=t[e];if(r==null){if(n!==void 0)return n;throw new Error(`Missing required parameter: ${e}`)}if(typeof r!="boolean")throw new Error(`Parameter ${e} must be a boolean, got ${typeof r}`);return r}function ft(t){if(t.length>5e3)return"Pattern too long (max 5000 characters)";let n=[/(\.\*){3,}/,/(\+\+|\*\*)/,/(.*\+.*\+.*\+)/];for(let r of n)if(r.test(t))return"Pattern contains potentially unsafe constructs that could cause excessive backtracking";return null}function Re(t,e,n=5e3){let r=ft(t);if(r)throw new Error(r);try{return new RegExp(t,e)}catch(o){let i=o instanceof Error?o.message:String(o);throw new Error(`Invalid regex pattern: ${i}`)}}function Te(t,e,n=1e3){if(e.length>1e5)throw new Error(`Input too large for safe regex test (${e.length} chars, max 100000)`);return t.test(e)}var dt=(i=>(i[i.DEBUG=0]="DEBUG",i[i.INFO=1]="INFO",i[i.WARN=2]="WARN",i[i.ERROR=3]="ERROR",i[i.SILENT=4]="SILENT",i))(dt||{}),g=1;function Ae(t){g=t}function Me(){return g}function p(){return new Date().toISOString()}function Ce(t,e){g<=0&&(e!==void 0?process.stderr.write(`[${p()}] DEBUG: ${t} ${h(e)}
|
|
11
|
+
`):process.stderr.write(`[${p()}] DEBUG: ${t}
|
|
12
|
+
`))}function Se(t,e){g<=1&&(e!==void 0?process.stderr.write(`[${p()}] INFO: ${t} ${h(e)}
|
|
13
|
+
`):process.stderr.write(`[${p()}] INFO: ${t}
|
|
14
|
+
`))}function _e(t,e){g<=2&&(e!==void 0?process.stderr.write(`[${p()}] WARN: ${t} ${h(e)}
|
|
15
|
+
`):process.stderr.write(`[${p()}] WARN: ${t}
|
|
16
|
+
`))}function $e(t,e){g<=3&&(e!==void 0?process.stderr.write(`[${p()}] ERROR: ${t} ${h(e)}
|
|
17
|
+
`):process.stderr.write(`[${p()}] ERROR: ${t}
|
|
18
|
+
`))}function h(t){if(t==null)return"";if(t instanceof Error)return t.message;if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}var w=class extends Error{statusCode;body;retryAfterMs;requestId;cfRay;constructor(e,n={}){super(e),this.name="ApiTransientError",this.statusCode=n.statusCode,this.retryAfterMs=n.retryAfterMs,this.requestId=n.requestId,this.cfRay=n.cfRay}},x={maxRetries:3,baseDelayMs:1e3,maxDelayMs:3e4,jitterMs:300};function y(t,e){let n=process.env[t],r=n?Number.parseInt(n,10):Number.NaN;return!Number.isFinite(r)||r<0?e:r}function pt(t={}){let e=Math.max(0,t.maxRetries??y("XENO_API_MAX_RETRIES",x.maxRetries)),n=Math.max(50,t.baseDelayMs??y("XENO_API_BASE_DELAY_MS",x.baseDelayMs)),r=Math.max(n,t.maxDelayMs??y("XENO_API_MAX_DELAY_MS",x.maxDelayMs)),o=Math.max(0,t.jitterMs??y("XENO_API_RETRY_JITTER_MS",x.jitterMs));return{maxRetries:e,baseDelayMs:n,maxDelayMs:r,jitterMs:o}}function mt(t,e,n){if(e.retryAfterMs&&e.retryAfterMs>0)return Math.min(e.retryAfterMs,n.maxDelayMs);let r=Math.min(n.baseDelayMs*Math.pow(2,t),n.maxDelayMs),o=Math.floor(Math.random()*n.jitterMs);return Math.min(r+o,n.maxDelayMs)}function B(t){let e=t.toLowerCase();return e.includes("rate limit")||e.includes("too many requests")||e.includes("429")}function gt(t){let e=t.toLowerCase();return e.includes("network")||e.includes("timeout")||e.includes("fetch failed")||e.includes("socket hang up")||e.includes("econnreset")||e.includes("eai_again")||e.includes("enotfound")||e.includes("econnrefused")||e.includes("tls")||e.includes("temporarily unavailable")}function O(t){if(t instanceof w)return{statusCode:t.statusCode,retryAfterMs:t.retryAfterMs,requestId:t.requestId,cfRay:t.cfRay};if(!(t instanceof Error))return{};let e=t;if(e.statusCode!==void 0||e.retryAfterMs!==void 0||e.requestId!==void 0||e.cfRay!==void 0)return{statusCode:e.statusCode,retryAfterMs:e.retryAfterMs,requestId:e.requestId,cfRay:e.cfRay};let n=t.message.toLowerCase();return B(n)?{statusCode:429}:{}}function ht(t){if(t&&typeof t=="object"&&"retryable"in t)return t.retryable===!0;if(t instanceof w){let{statusCode:e}=O(t);if(e)return e===429||e>=500||e===408||e===409||e===425}if(t instanceof Error){let e=t.name?.toLowerCase()??"";return e==="aborterror"||e==="agentinterruptederror"||t.message.toLowerCase().includes("aborted")||t.message.toLowerCase().includes("interrupted")?!1:t.message.includes("503")||t.message.includes("504")||t.message.includes("502")||t.message.includes("500")||t.message.includes("408")||t.message.includes("425")?!0:B(t.message)||gt(t.message.toLowerCase())}return!1}function xt(t){if(t.onAbort)return t.onAbort();let e=new Error("The operation was aborted");return e.name="AbortError",e}async function ve(t,e={}){let n=pt(e),r;for(let o=0;o<=n.maxRetries;o++)try{if(e.signal?.aborted)throw xt(e);return e.onBeforeAttempt?.(o),await t()}catch(i){if(r=i,!(e.shouldRetry?e.shouldRetry(i,o):ht(i))||o===n.maxRetries)throw i;let u=O(i),l=mt(o,u,n),d=e.getDelayMs?.(i,o,l),m=typeof d=="number"&&d>=0?d:l;await new Promise(E=>setTimeout(E,m))}throw r}var yt=(t,e)=>{if(!t)return 0;let n=e.toLowerCase(),r=n.includes("claude")?3.5:n.includes("gemini")?3.8:(/(^|[/_-])(gpt|o\d)/.test(n),4),o=[...t].filter(s=>s.codePointAt(0)>127).length,i=Math.ceil(t.length/r);return Math.max(1,i+Math.ceil(o*.35))},wt=Object.freeze({id:"xeno-conservative-v1",source:"estimated",countText:yt,countImage:({detail:t})=>t==="high"?2e3:t==="low"?512:1200,safetyMarginRatio:t=>{let e=t.toLowerCase();return e.includes("claude")?.12:e.includes("gemini")?.14:/(^|[/_-])(gpt|o\d)/.test(e)?.1:.18}});function Be(t,e,n=wt){return{tokens:Math.max(0,Math.ceil(n.countText(t,e))),source:n.source,adapterId:n.id}}function bt(t){return t?Math.ceil(t.length/4):0}function Oe(t,e){if(!t||e<=0)return"";let n=e*4;if(t.length<=n)return t;let r=t.slice(0,n),o=r.lastIndexOf(" ");return o>n*.8&&(r=r.slice(0,o)),r+"..."}function Pe(t,e){return bt(t)<=e}function Ie(t,e){return Math.max(0,e-t)}var Et={"claude-opus-4-6-thinking":{input:15,output:75},"claude-opus-4-6":{input:15,output:75},"claude-opus-4-5-thinking":{input:15,output:75},"claude-sonnet-4-6":{input:3,output:15},"claude-sonnet-4-5-thinking":{input:3,output:15},"claude-sonnet-4-5":{input:3,output:15},"gemini-2.5-flash":{input:.15,output:.6},"gemini-2.5-flash-lite":{input:.075,output:.3},"gemini-3-flash":{input:.15,output:.6},"gemini-3-pro-high":{input:1.25,output:5},"gpt-5":{input:5,output:15},"gpt-5-codex":{input:5,output:15},"gpt-5.1":{input:5,output:15},"gpt-5.1-codex":{input:5,output:15},"gpt-5.2":{input:5,output:15},"gpt-5.2-codex":{input:5,output:15},"kimi-k2":{input:.6,output:2.4},"kimi-k2-thinking":{input:.6,output:2.4},"kimi-k2.5":{input:.6,output:2.4}};function Fe(t,e,n){let r=Et[t];return r?e/1e6*r.input+n/1e6*r.output:0}function We(t){return t<=0?"$0.00":t<.001?"<$0.001":t<.01?`$${t.toFixed(4)}`:t<1?`$${t.toFixed(3)}`:`$${t.toFixed(2)}`}import{spawnSync as Rt}from"node:child_process";function He(t){let e=process.platform==="win32"?[{command:"clip.exe",args:[]}]:process.platform==="darwin"?[{command:"pbcopy",args:[]}]:[{command:"wl-copy",args:[]},{command:"xclip",args:["-selection","clipboard"]},{command:"xsel",args:["--clipboard","--input"]}],n=null;for(let r of e)try{let o=Rt(r.command,r.args,{input:t,encoding:"utf8"});if(o.error){n=o.error.message;continue}if(o.status===0)return;n=o.stderr||o.stdout||`exit ${o.status}`}catch(o){n=o instanceof Error?o.message:String(o)}throw new Error(`Clipboard copy failed${n?`: ${n}`:""}`)}function I(t){return t.replace(/\\/g,"/").toLowerCase()}var Tt=["golden","solution","answer","expected"],kt=["expected","golden","reference","answer","answers"],At=new Set([";","&&","||","|"]);function D(t){return I(t).replace(/^\.\/+/,"").split("/").map(e=>e.trim()).filter(e=>e.length>0)}function Mt(t){return Tt.some(e=>t.includes(e))}function P(t){return kt.some(e=>t.includes(e))}function F(t){return t.split("::",1)[0]?.split("?",1)[0]?.split("#",1)[0]??t}function b(t){let e=t.trim().replace(/^[({]+/,"").replace(/[),;]+$/,"");return(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1)),e}function Ct(t){return t.match(/"[^"]*"|'[^']*'|&&|\|\||[;|]|[^\s;|&]+/g)?.map(b).filter(e=>e.length>0)??[]}function W(t){let e=D(t),n=F(e.at(-1)??"");return P(n)||e.some(r=>P(r))}function j(t){let e=I(b(t));return!e||e==="/dev/null"||e.startsWith("/tmp/")||e.startsWith("tmp/")||e.startsWith("/var/tmp/")||e.startsWith("var/tmp/")?!1:e.startsWith("/app/")||e.startsWith("./")?!0:!e.startsWith("/")}function St(t){return/[\\/]/.test(t)||/\.[A-Za-z0-9]{1,8}$/.test(t)}function _t(t){let e=Ct(t);for(let n=0;n<e.length;n+=1){let r=e[n]?.toLowerCase();if(r!=="cp"&&r!=="mv"&&r!=="rsync"&&r!=="install")continue;let o=[];for(let s=n+1;s<e.length;s+=1){let u=e[s];if(!u||At.has(u))break;u!=="--"&&(u.startsWith("-")||o.push(u))}if(o.length<2)continue;let i=o.at(-1);if(j(i)){for(let s of o.slice(0,-1))if(St(s)&&W(s))return{sourcePath:s,destinationPath:i,operation:r}}}return null}function $t(t){let e=[/\bcat\s+(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))\s*>\s*(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))/i,/\bdd\b[\s\S]*?\bif=(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))[\s\S]*?\bof=(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))/i];for(let n of e){let r=t.match(n);if(!r)continue;let o=b(r[1]??r[2]??r[3]??""),i=b(r[4]??r[5]??r[6]??"");if(!(!o||!i)&&W(o)&&j(i))return{sourcePath:o,destinationPath:i,operation:n.source.startsWith("\\bdd")?"dd":"redirect"}}return null}function q(){return process.env.XENO_BENCHMARK_MODE?.trim().toLowerCase()==="terminal-bench"}function H(t){let e=D(t);if(e.includes("solution")||e.includes("xeno-audit")||e.includes(".xeno")&&e.includes("audit"))return!0;let n=F(e.at(-1)??"");return e.includes("tests")&&Mt(n)}function Xe(t){return q()?t.filter(e=>!H(e)):t}function ze(t){return`Benchmark safety: access to verifier answer or benchmark trace artifacts is blocked (${t}). Use task inputs and verifier logic, not golden, solution, or agent audit files.`}function Ye(t){return t.split(/[\s"'`;|&]+/).map(e=>e.trim()).filter(e=>e.length>0&&/[\\/]/.test(e)).some(e=>H(e))}function Ge(t){if(!q())return null;let e=_t(t)??$t(t);return e?["[xeno guidance]",`Benchmark safety blocked ${e.operation} from reference-like source ${e.sourcePath} to protected destination ${e.destinationPath}.`,"Do not copy expected, golden, reference, or answer files over task inputs or submission artifacts to make validation pass.","If a previous check polluted an input, restore/regenerate the original source input, then rerun the actual script or program under test."].join(`
|
|
19
|
+
`):null}function Nt(t){return/^data:([^;,]+)[;,]/i.exec(t.trim())?.[1]}function vt(t){let e=[];for(let n of t){if(n.type==="text"){e.push(n.text);continue}if(n.type==="image_url"){e.push(`[image ${Nt(n.image_url.url)??"unknown"}]`);continue}let r=n.text??n.data;if(r&&r.trim().length>0){e.push(r);continue}let o=n.uri??n.mimeType??"resource";e.push(`[resource ${o}]`)}return e.join(`
|
|
20
|
+
|
|
21
|
+
`).trim()}function J(t){let e=t.trim();return e.length>0?[{type:"text",text:e}]:[]}function Ke(t){return typeof t=="string"?t:vt(t)}function Lt(t){if(t.success)return t.output;let e=[`Error: ${t.error??"Tool execution failed"}`];return t.output.trim().length>0&&e.push(t.output),e.join(`
|
|
22
|
+
`)}function Qe(t){let e=t.assistant_content&&t.assistant_content.length>0?t.assistant_content:typeof t.content=="string"?J(t.content):t.content,n=t.assistant_only_content??[],r=Bt(t),o=[...e,...n,...r?[r]:[]];return o.length>0?o:t.content}function Bt(t){let e=t.operation;if(!e)return null;let n=t.evidence??e.evidence??[],r=n.filter(i=>i.status==="verified").length,o=n.filter(i=>i.status==="failed").length;return{type:"text",text:["[xeno_operation]",`operation_id: ${e.operationId}`,`state: ${e.state}`,`terminal: ${e.terminal?"yes":"no"}`,`completion_policy: ${e.completionPolicy}`,e.taskId?`task_id: ${e.taskId}`:null,e.completionReason?`completion_reason: ${e.completionReason}`:null,`evidence: ${r} verified, ${o} failed`,t.retryable===void 0?null:`retryable: ${t.retryable?"yes":"no"}`,"[/xeno_operation]"].filter(i=>!!i).join(`
|
|
23
|
+
`)}}function Ze(t){return Array.isArray(t)&&t.some(e=>e.type!=="text")}function Ve(t){return typeof t=="string"?J(t):t}function tn(t,e){return{type:"tool_result",tool_use_id:t,content:Lt(e),...e.assistantContent&&e.assistantContent.length>0?{assistant_content:e.assistantContent}:{},...e.assistantOnlyContent&&e.assistantOnlyContent.length>0?{assistant_only_content:e.assistantOnlyContent}:{},is_error:!e.success,...e.operation?{operation:e.operation}:{},...e.evidence&&e.evidence.length>0?{evidence:e.evidence}:{},...e.retryable!==void 0?{retryable:e.retryable}:{}}}function nn(t,e={}){for(let n of t){let r=n.codePointAt(0);if(r===127)return!0;if(!(r>31)&&!(r===9&&e.allowTab===!0)&&!((r===10||r===13)&&e.allowLineBreaks===!0))return!0}return!1}export{w as ApiTransientError,lt as HOME_DIR,fe as IS_LINUX,le as IS_MAC,ct as IS_WINDOWS,dt as LogLevel,de as OS_VERSION,T as PLATFORM,Be as accountTextTokens,Wt as appendLine,ze as benchmarkLeakError,tn as buildToolResultBlock,Lt as buildToolResultText,Fe as calculateCost,Ye as commandMentionsBenchmarkLeak,wt as conservativeTokenAccountingAdapter,He as copyTextToClipboard,Re as createSafeRegex,Ce as debug,G as decodeTextBuffer,Ut as deleteDir,Gt as deleteFile,K as detectLineEnding,qt as detectPreferredLineEnding,Y as detectTextEncoding,U as encodeTextBuffer,C as ensureDir,$e as error,bt as estimateTokens,yt as estimateTokensForModel,Xt as existsSync,Xe as filterBenchmarkLeakPaths,Ht as findSimilarFile,Pe as fitsInBudget,We as formatCost,Ge as getBenchmarkReferenceOverwriteHint,Ee as getBoolean,pe as getConfigDir,Me as getLogLevel,be as getNumber,me as getProjectConfigDir,O as getRetryErrorContext,ge as getShellName,we as getString,Qe as getToolResultTransportContent,Dt as hasDir,nn as hasDisallowedAsciiControlCharacter,It as hasFile,re as hasFrontmatter,Ze as hasNonTextToolResultContent,Se as info,H as isBenchmarkLeakPath,q as isBenchmarkMode,he as isGitRepo,ot as isPathSafe,ht as isRetryableError,Yt as listDirs,zt as listFiles,Q as normalizeLineEndings,ee as parseDocument,Vt as parseJsonLines,Ft as readFileSafe,Jt as readIfExists,Z as readTextFile,Ie as remainingBudget,Qt as safeJsonParse,Zt as safeJsonStringify,Te as safeRegexTest,ie as safeResolvePath,Ae as setLogLevel,ne as stringifyDocument,Ve as toTransportAssistantBlocks,vt as toolAssistantContentToText,Ke as toolResultContentToText,Oe as truncateToTokens,ft as validateRegexPattern,ye as validateRequired,_e as warn,ve as withRetry,z as writeAtomic,jt as writeTextFile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/utils/fs.ts":{"bytes":10330,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/utils/json.ts":{"bytes":842,"imports":[],"format":"esm"},"src/utils/yaml.ts":{"bytes":5668,"imports":[],"format":"esm"},"src/utils/path-security.ts":{"bytes":1024,"imports":[{"path":"path","kind":"import-statement","external":true}],"format":"esm"},"src/utils/platform.ts":{"bytes":1012,"imports":[{"path":"node:os","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/utils/validation.ts":{"bytes":5519,"imports":[],"format":"esm"},"src/utils/logger.ts":{"bytes":3873,"imports":[],"format":"esm"},"src/utils/retry.ts":{"bytes":9294,"imports":[],"format":"esm"},"src/utils/tokens.ts":{"bytes":3306,"imports":[],"format":"esm"},"src/utils/cost.ts":{"bytes":1876,"imports":[],"format":"esm"},"src/utils/clipboard.ts":{"bytes":1196,"imports":[{"path":"node:child_process","kind":"import-statement","external":true}],"format":"esm"},"src/utils/benchmark-safety.ts":{"bytes":6703,"imports":[],"format":"esm"},"src/utils/tool-result-content.ts":{"bytes":4887,"imports":[],"format":"esm"},"src/utils/text-security.ts":{"bytes":833,"imports":[],"format":"esm"},"src/utils/index.ts":{"bytes":1490,"imports":[{"path":"src/utils/fs.ts","kind":"import-statement","original":"./fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"./json.js"},{"path":"src/utils/yaml.ts","kind":"import-statement","original":"./yaml.js"},{"path":"src/utils/path-security.ts","kind":"import-statement","original":"./path-security.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"./platform.js"},{"path":"src/utils/validation.ts","kind":"import-statement","original":"./validation.js"},{"path":"src/utils/logger.ts","kind":"import-statement","original":"./logger.js"},{"path":"src/utils/retry.ts","kind":"import-statement","original":"./retry.js"},{"path":"src/utils/tokens.ts","kind":"import-statement","original":"./tokens.js"},{"path":"src/utils/cost.ts","kind":"import-statement","original":"./cost.js"},{"path":"src/utils/clipboard.ts","kind":"import-statement","original":"./clipboard.js"},{"path":"src/utils/benchmark-safety.ts","kind":"import-statement","original":"./benchmark-safety.js"},{"path":"src/utils/tool-result-content.ts","kind":"import-statement","original":"./tool-result-content.js"},{"path":"src/utils/text-security.ts","kind":"import-statement","original":"./text-security.js"}],"format":"esm"}},"outputs":{"dist/utils/index.cjs":{"imports":[{"path":"node:fs","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:fs/promises","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"node:os","kind":"require-call","external":true},{"path":"node:child_process","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:child_process","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/utils/index.ts","inputs":{"src/utils/index.ts":{"bytesInOutput":1866},"src/utils/fs.ts":{"bytesInOutput":4051},"src/utils/json.ts":{"bytesInOutput":239},"src/utils/yaml.ts":{"bytesInOutput":2639},"src/utils/path-security.ts":{"bytesInOutput":313},"src/utils/platform.ts":{"bytesInOutput":483},"src/utils/validation.ts":{"bytesInOutput":1423},"src/utils/logger.ts":{"bytesInOutput":913},"src/utils/retry.ts":{"bytesInOutput":2918},"src/utils/tokens.ts":{"bytesInOutput":904},"src/utils/cost.ts":{"bytesInOutput":933},"src/utils/clipboard.ts":{"bytesInOutput":604},"src/utils/benchmark-safety.ts":{"bytesInOutput":3108},"src/utils/tool-result-content.ts":{"bytesInOutput":2072},"src/utils/text-security.ts":{"bytesInOutput":180}},"bytes":24527}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/utils/fs.ts":{"bytes":10330,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/utils/json.ts":{"bytes":842,"imports":[],"format":"esm"},"src/utils/yaml.ts":{"bytes":5668,"imports":[],"format":"esm"},"src/utils/path-security.ts":{"bytes":1024,"imports":[{"path":"path","kind":"import-statement","external":true}],"format":"esm"},"src/utils/platform.ts":{"bytes":1012,"imports":[{"path":"node:os","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/utils/validation.ts":{"bytes":5519,"imports":[],"format":"esm"},"src/utils/logger.ts":{"bytes":3873,"imports":[],"format":"esm"},"src/utils/retry.ts":{"bytes":9294,"imports":[],"format":"esm"},"src/utils/tokens.ts":{"bytes":3306,"imports":[],"format":"esm"},"src/utils/cost.ts":{"bytes":1876,"imports":[],"format":"esm"},"src/utils/clipboard.ts":{"bytes":1196,"imports":[{"path":"node:child_process","kind":"import-statement","external":true}],"format":"esm"},"src/utils/benchmark-safety.ts":{"bytes":6703,"imports":[],"format":"esm"},"src/utils/tool-result-content.ts":{"bytes":4887,"imports":[],"format":"esm"},"src/utils/text-security.ts":{"bytes":833,"imports":[],"format":"esm"},"src/utils/index.ts":{"bytes":1490,"imports":[{"path":"src/utils/fs.ts","kind":"import-statement","original":"./fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"./json.js"},{"path":"src/utils/yaml.ts","kind":"import-statement","original":"./yaml.js"},{"path":"src/utils/path-security.ts","kind":"import-statement","original":"./path-security.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"./platform.js"},{"path":"src/utils/validation.ts","kind":"import-statement","original":"./validation.js"},{"path":"src/utils/logger.ts","kind":"import-statement","original":"./logger.js"},{"path":"src/utils/retry.ts","kind":"import-statement","original":"./retry.js"},{"path":"src/utils/tokens.ts","kind":"import-statement","original":"./tokens.js"},{"path":"src/utils/cost.ts","kind":"import-statement","original":"./cost.js"},{"path":"src/utils/clipboard.ts","kind":"import-statement","original":"./clipboard.js"},{"path":"src/utils/benchmark-safety.ts","kind":"import-statement","original":"./benchmark-safety.js"},{"path":"src/utils/tool-result-content.ts","kind":"import-statement","original":"./tool-result-content.js"},{"path":"src/utils/text-security.ts","kind":"import-statement","original":"./text-security.js"}],"format":"esm"}},"outputs":{"dist/utils/index.js":{"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true}],"exports":["ApiTransientError","HOME_DIR","IS_LINUX","IS_MAC","IS_WINDOWS","LogLevel","OS_VERSION","PLATFORM","accountTextTokens","appendLine","benchmarkLeakError","buildToolResultBlock","buildToolResultText","calculateCost","commandMentionsBenchmarkLeak","conservativeTokenAccountingAdapter","copyTextToClipboard","createSafeRegex","debug","decodeTextBuffer","deleteDir","deleteFile","detectLineEnding","detectPreferredLineEnding","detectTextEncoding","encodeTextBuffer","ensureDir","error","estimateTokens","estimateTokensForModel","existsSync","filterBenchmarkLeakPaths","findSimilarFile","fitsInBudget","formatCost","getBenchmarkReferenceOverwriteHint","getBoolean","getConfigDir","getLogLevel","getNumber","getProjectConfigDir","getRetryErrorContext","getShellName","getString","getToolResultTransportContent","hasDir","hasDisallowedAsciiControlCharacter","hasFile","hasFrontmatter","hasNonTextToolResultContent","info","isBenchmarkLeakPath","isBenchmarkMode","isGitRepo","isPathSafe","isRetryableError","listDirs","listFiles","normalizeLineEndings","parseDocument","parseJsonLines","readFileSafe","readIfExists","readTextFile","remainingBudget","safeJsonParse","safeJsonStringify","safeRegexTest","safeResolvePath","setLogLevel","stringifyDocument","toTransportAssistantBlocks","toolAssistantContentToText","toolResultContentToText","truncateToTokens","validateRegexPattern","validateRequired","warn","withRetry","writeAtomic","writeTextFile"],"entryPoint":"src/utils/index.ts","inputs":{"src/utils/fs.ts":{"bytesInOutput":3994},"src/utils/index.ts":{"bytesInOutput":0},"src/utils/json.ts":{"bytesInOutput":239},"src/utils/yaml.ts":{"bytesInOutput":2639},"src/utils/path-security.ts":{"bytesInOutput":311},"src/utils/platform.ts":{"bytesInOutput":491},"src/utils/validation.ts":{"bytesInOutput":1425},"src/utils/logger.ts":{"bytesInOutput":915},"src/utils/retry.ts":{"bytesInOutput":2918},"src/utils/tokens.ts":{"bytesInOutput":904},"src/utils/cost.ts":{"bytesInOutput":933},"src/utils/clipboard.ts":{"bytesInOutput":601},"src/utils/benchmark-safety.ts":{"bytesInOutput":3090},"src/utils/tool-result-content.ts":{"bytesInOutput":2069},"src/utils/text-security.ts":{"bytesInOutput":180}},"bytes":22467}}}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE
|