@husk-ai/core 0.1.1
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/dist/audit.d.ts +65 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +87 -0
- package/dist/audit.js.map +1 -0
- package/dist/browse.d.ts +66 -0
- package/dist/browse.d.ts.map +1 -0
- package/dist/browse.js +217 -0
- package/dist/browse.js.map +1 -0
- package/dist/config.d.ts +73 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +61 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +59 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +40 -0
- package/dist/errors.js.map +1 -0
- package/dist/ids.d.ts +7 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +29 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/lifecycle.d.ts +38 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +52 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/logger.d.ts +20 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +59 -0
- package/dist/logger.js.map +1 -0
- package/dist/net.d.ts +48 -0
- package/dist/net.d.ts.map +1 -0
- package/dist/net.js +219 -0
- package/dist/net.js.map +1 -0
- package/dist/spec.d.ts +832 -0
- package/dist/spec.d.ts.map +1 -0
- package/dist/spec.js +191 -0
- package/dist/spec.js.map +1 -0
- package/dist/types/agent.d.ts +168 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/agent.js +2 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/computer.d.ts +205 -0
- package/dist/types/computer.d.ts.map +1 -0
- package/dist/types/computer.js +9 -0
- package/dist/types/computer.js.map +1 -0
- package/dist/types/model.d.ts +197 -0
- package/dist/types/model.d.ts.map +1 -0
- package/dist/types/model.js +16 -0
- package/dist/types/model.js.map +1 -0
- package/dist/types/transcript.d.ts +64 -0
- package/dist/types/transcript.d.ts.map +1 -0
- package/dist/types/transcript.js +3 -0
- package/dist/types/transcript.js.map +1 -0
- package/dist/util.d.ts +69 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +236 -0
- package/dist/util.js.map +1 -0
- package/package.json +26 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The model contract.
|
|
3
|
+
*
|
|
4
|
+
* One surface over Anthropic, OpenAI, Google, Groq, OpenRouter, Ollama, LM Studio
|
|
5
|
+
* and anything else that speaks tool-calling chat. Providers translate; callers do not.
|
|
6
|
+
*/
|
|
7
|
+
export type Role = 'system' | 'user' | 'assistant' | 'tool';
|
|
8
|
+
export interface TextPart {
|
|
9
|
+
type: 'text';
|
|
10
|
+
text: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ImagePart {
|
|
13
|
+
type: 'image';
|
|
14
|
+
mimeType: string;
|
|
15
|
+
/** base64, with no data: prefix. */
|
|
16
|
+
data: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ToolCallPart {
|
|
19
|
+
type: 'tool_call';
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
args: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
export interface ToolResultPart {
|
|
25
|
+
type: 'tool_result';
|
|
26
|
+
toolCallId: string;
|
|
27
|
+
content: string;
|
|
28
|
+
isError?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface ThinkingPart {
|
|
31
|
+
type: 'thinking';
|
|
32
|
+
text: string;
|
|
33
|
+
signature?: string;
|
|
34
|
+
}
|
|
35
|
+
export type ContentPart = TextPart | ImagePart | ToolCallPart | ToolResultPart | ThinkingPart;
|
|
36
|
+
export interface ModelMessage {
|
|
37
|
+
role: Role;
|
|
38
|
+
content: string | ContentPart[];
|
|
39
|
+
/** Present on tool messages so providers that need it can round-trip. */
|
|
40
|
+
name?: string;
|
|
41
|
+
}
|
|
42
|
+
/** JSON Schema draft-07 subset. Kept loose on purpose, because providers vary. */
|
|
43
|
+
export type JSONSchema = Record<string, unknown>;
|
|
44
|
+
export interface ToolSchema {
|
|
45
|
+
name: string;
|
|
46
|
+
description: string;
|
|
47
|
+
parameters: JSONSchema;
|
|
48
|
+
}
|
|
49
|
+
export type ToolChoice = 'auto' | 'none' | 'required' | {
|
|
50
|
+
name: string;
|
|
51
|
+
};
|
|
52
|
+
export interface ChatRequest {
|
|
53
|
+
/** An alias (sonnet, gemma) or a fully-qualified id (anthropic/claude-sonnet-5). */
|
|
54
|
+
model: string;
|
|
55
|
+
messages: ModelMessage[];
|
|
56
|
+
system?: string;
|
|
57
|
+
tools?: ToolSchema[];
|
|
58
|
+
toolChoice?: ToolChoice;
|
|
59
|
+
temperature?: number;
|
|
60
|
+
topP?: number;
|
|
61
|
+
maxTokens?: number;
|
|
62
|
+
stop?: string[];
|
|
63
|
+
/** Ask for extended reasoning where the provider supports it. */
|
|
64
|
+
thinking?: {
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
budgetTokens?: number;
|
|
67
|
+
};
|
|
68
|
+
responseFormat?: {
|
|
69
|
+
type: 'text';
|
|
70
|
+
} | {
|
|
71
|
+
type: 'json';
|
|
72
|
+
schema?: JSONSchema;
|
|
73
|
+
};
|
|
74
|
+
signal?: AbortSignal;
|
|
75
|
+
metadata?: Record<string, string>;
|
|
76
|
+
}
|
|
77
|
+
export interface Usage {
|
|
78
|
+
inputTokens: number;
|
|
79
|
+
outputTokens: number;
|
|
80
|
+
cacheReadTokens?: number;
|
|
81
|
+
cacheWriteTokens?: number;
|
|
82
|
+
/** Zero for local models. Estimated from the price table otherwise. */
|
|
83
|
+
costUsd?: number;
|
|
84
|
+
}
|
|
85
|
+
export type FinishReason = 'stop' | 'length' | 'tool_calls' | 'content_filter' | 'error' | 'aborted';
|
|
86
|
+
export interface ChatResponse {
|
|
87
|
+
/** Resolved fully-qualified model id. */
|
|
88
|
+
model: string;
|
|
89
|
+
text: string;
|
|
90
|
+
thinking?: string;
|
|
91
|
+
toolCalls: ToolCallPart[];
|
|
92
|
+
finishReason: FinishReason;
|
|
93
|
+
usage: Usage;
|
|
94
|
+
latencyMs: number;
|
|
95
|
+
raw?: unknown;
|
|
96
|
+
/**
|
|
97
|
+
* Things the caller must know that did not stop the call -- above all, a
|
|
98
|
+
* fallback to a different model than the one requested.
|
|
99
|
+
*
|
|
100
|
+
* The streaming path can emit a `warning` event mid-flight; a single-shot
|
|
101
|
+
* `chat()` has nowhere else to put one, and without this a request for Opus
|
|
102
|
+
* that quietly ran on a 1.5B local model comes back as a plain 200. The
|
|
103
|
+
* substitution is visible in `model`, but only to someone who thought to
|
|
104
|
+
* compare it against what they asked for.
|
|
105
|
+
*/
|
|
106
|
+
warnings?: Array<{
|
|
107
|
+
message: string;
|
|
108
|
+
code?: string;
|
|
109
|
+
detail?: Record<string, unknown>;
|
|
110
|
+
}>;
|
|
111
|
+
}
|
|
112
|
+
export type StreamEvent = {
|
|
113
|
+
type: 'start';
|
|
114
|
+
model: string;
|
|
115
|
+
} | {
|
|
116
|
+
type: 'thinking_delta';
|
|
117
|
+
text: string;
|
|
118
|
+
} | {
|
|
119
|
+
type: 'text_delta';
|
|
120
|
+
text: string;
|
|
121
|
+
} | {
|
|
122
|
+
type: 'tool_call';
|
|
123
|
+
call: ToolCallPart;
|
|
124
|
+
} | {
|
|
125
|
+
type: 'usage';
|
|
126
|
+
usage: Usage;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Something the caller must know that did not stop the stream -- most often a
|
|
130
|
+
* fallback to a different model. Silently answering with a weaker model than
|
|
131
|
+
* the one that was asked for is worse than failing, so a router that falls
|
|
132
|
+
* back is required to emit this.
|
|
133
|
+
*/
|
|
134
|
+
| {
|
|
135
|
+
type: 'warning';
|
|
136
|
+
message: string;
|
|
137
|
+
code?: string;
|
|
138
|
+
detail?: Record<string, unknown>;
|
|
139
|
+
} | {
|
|
140
|
+
type: 'done';
|
|
141
|
+
response: ChatResponse;
|
|
142
|
+
} | {
|
|
143
|
+
type: 'error';
|
|
144
|
+
error: {
|
|
145
|
+
message: string;
|
|
146
|
+
code?: string;
|
|
147
|
+
retryable?: boolean;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
export interface ModelInfo {
|
|
151
|
+
/** Fully-qualified, as provider slash model. */
|
|
152
|
+
id: string;
|
|
153
|
+
provider: string;
|
|
154
|
+
/** The bare model name the provider expects on the wire. */
|
|
155
|
+
name: string;
|
|
156
|
+
displayName: string;
|
|
157
|
+
contextWindow: number;
|
|
158
|
+
maxOutputTokens: number;
|
|
159
|
+
supportsTools: boolean;
|
|
160
|
+
supportsVision: boolean;
|
|
161
|
+
supportsStreaming: boolean;
|
|
162
|
+
supportsThinking?: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* USD per million tokens. Absent or zero for local models.
|
|
165
|
+
*
|
|
166
|
+
* `cacheWritePerMTok` is separate because writing a cache entry is not priced
|
|
167
|
+
* as a fraction of input everywhere -- Anthropic charges 1.25x input, others
|
|
168
|
+
* charge nothing. Deriving it from a single global multiplier is wrong for
|
|
169
|
+
* every provider but one.
|
|
170
|
+
*/
|
|
171
|
+
pricing?: {
|
|
172
|
+
inputPerMTok: number;
|
|
173
|
+
outputPerMTok: number;
|
|
174
|
+
cacheReadPerMTok?: number;
|
|
175
|
+
cacheWritePerMTok?: number;
|
|
176
|
+
};
|
|
177
|
+
/** True when the model can be run at no cost, whether local or on a provider free tier. */
|
|
178
|
+
free?: boolean;
|
|
179
|
+
tags?: string[];
|
|
180
|
+
}
|
|
181
|
+
export interface ModelProvider {
|
|
182
|
+
readonly id: string;
|
|
183
|
+
readonly displayName: string;
|
|
184
|
+
/** Ordered fallback preference; higher is tried first when a model is ambiguous. */
|
|
185
|
+
readonly priority: number;
|
|
186
|
+
isAvailable(): Promise<{
|
|
187
|
+
available: boolean;
|
|
188
|
+
reason?: string;
|
|
189
|
+
hint?: string;
|
|
190
|
+
}>;
|
|
191
|
+
listModels(): Promise<ModelInfo[]>;
|
|
192
|
+
chat(req: ChatRequest): Promise<ChatResponse>;
|
|
193
|
+
stream(req: ChatRequest): AsyncIterable<StreamEvent>;
|
|
194
|
+
}
|
|
195
|
+
/** Flatten any message content down to plain text. */
|
|
196
|
+
export declare function messageText(m: ModelMessage): string;
|
|
197
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/types/model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,IAAI,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;AAE5D,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AACD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;CACd;AACD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,WAAW,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AACD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,aAAa,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AACD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,YAAY,GAAG,c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CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B,WAAW,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/E,UAAU,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IACnC,IAAI,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAC9C,MAAM,CAAC,GAAG,EAAE,WAAW,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;CACtD;AAED,sDAAsD;AACtD,wBAAgB,WAAW,CAAC,CAAC,EAAE,YAAY,GAAG,MAAM,CAMnD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The model contract.
|
|
3
|
+
*
|
|
4
|
+
* One surface over Anthropic, OpenAI, Google, Groq, OpenRouter, Ollama, LM Studio
|
|
5
|
+
* and anything else that speaks tool-calling chat. Providers translate; callers do not.
|
|
6
|
+
*/
|
|
7
|
+
/** Flatten any message content down to plain text. */
|
|
8
|
+
export function messageText(m) {
|
|
9
|
+
if (typeof m.content === 'string')
|
|
10
|
+
return m.content;
|
|
11
|
+
return m.content
|
|
12
|
+
.map((p) => (p.type === 'text' ? p.text : p.type === 'tool_result' ? p.content : ''))
|
|
13
|
+
.filter(Boolean)
|
|
14
|
+
.join('\n');
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/types/model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoKH,sDAAsD;AACtD,MAAM,UAAU,WAAW,CAAC,CAAe;IACzC,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC,OAAO,CAAC;IACpD,OAAO,CAAC,CAAC,OAAO;SACb,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SACpF,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** Normalised conversation history, whatever it was exported from. */
|
|
2
|
+
export type TranscriptSource = 'claude-code' | 'claude-web' | 'chatgpt' | 'cursor' | 'openai-api' | 'anthropic-api' | 'markdown' | 'jsonl' | 'gemini' | 'universal' | 'unknown';
|
|
3
|
+
export interface TranscriptMessage {
|
|
4
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
5
|
+
content: string;
|
|
6
|
+
ts?: string;
|
|
7
|
+
/** Present when the message is a tool call or a tool result. */
|
|
8
|
+
toolName?: string;
|
|
9
|
+
toolInput?: unknown;
|
|
10
|
+
meta?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export interface Transcript {
|
|
13
|
+
id: string;
|
|
14
|
+
source: TranscriptSource;
|
|
15
|
+
title?: string;
|
|
16
|
+
createdAt?: string;
|
|
17
|
+
updatedAt?: string;
|
|
18
|
+
/** Where it came from: a file path, an export id, a URL. */
|
|
19
|
+
origin?: string;
|
|
20
|
+
messages: TranscriptMessage[];
|
|
21
|
+
meta?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
export interface ImportInput {
|
|
24
|
+
/** A file or directory path. */
|
|
25
|
+
path?: string;
|
|
26
|
+
/** Raw content, when the caller already has it. */
|
|
27
|
+
content?: string;
|
|
28
|
+
/** Hint the importer, skipping detection. */
|
|
29
|
+
source?: TranscriptSource;
|
|
30
|
+
}
|
|
31
|
+
export interface TranscriptImporter {
|
|
32
|
+
readonly id: TranscriptSource;
|
|
33
|
+
readonly displayName: string;
|
|
34
|
+
/** Cheap sniff returning a 0..1 confidence. Must not throw. */
|
|
35
|
+
detect(input: {
|
|
36
|
+
path?: string;
|
|
37
|
+
content?: string;
|
|
38
|
+
}): Promise<number>;
|
|
39
|
+
parse(input: ImportInput): Promise<Transcript[]>;
|
|
40
|
+
/** Where this tool usually keeps its history, for zero-argument discovery. */
|
|
41
|
+
defaultLocations?(): string[];
|
|
42
|
+
}
|
|
43
|
+
/** What the distiller pulls out of a transcript before it becomes a husk. */
|
|
44
|
+
export interface DistilledAgent {
|
|
45
|
+
name: string;
|
|
46
|
+
description: string;
|
|
47
|
+
persona: string;
|
|
48
|
+
knowledge: Array<{
|
|
49
|
+
title: string;
|
|
50
|
+
content: string;
|
|
51
|
+
source?: string;
|
|
52
|
+
}>;
|
|
53
|
+
examples: Array<{
|
|
54
|
+
user: string;
|
|
55
|
+
assistant: string;
|
|
56
|
+
}>;
|
|
57
|
+
suggestedTools: string[];
|
|
58
|
+
suggestedModel?: string;
|
|
59
|
+
needsComputer: boolean;
|
|
60
|
+
/** 0..1, how much signal the distiller actually found. */
|
|
61
|
+
confidence: number;
|
|
62
|
+
notes: string[];
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=transcript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../src/types/transcript.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,YAAY,GACZ,SAAS,GACT,QAAQ,GACR,YAAY,GACZ,eAAe,GACf,UAAU,GACV,OAAO,GACP,QAAQ,GACR,WAAW,GACX,SAAS,CAAC;AAEd,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,CAA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AAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtE,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrD,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript.js","sourceRoot":"","sources":["../../src/types/transcript.ts"],"names":[],"mappings":"AAAA,sEAAsE"}
|
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
/**
|
|
3
|
+
* Where a UTF-8 character actually starts, at or before `i`.
|
|
4
|
+
*
|
|
5
|
+
* Slicing a byte buffer at an arbitrary offset lands in the middle of a
|
|
6
|
+
* multi-byte character about as often as not, and `toString('utf8')` renders
|
|
7
|
+
* the orphaned halves as U+FFFD. Cutting a 200 KB log used to leave a few of
|
|
8
|
+
* those at each seam -- rare enough to look like the program's own output was
|
|
9
|
+
* corrupt rather than like husk's scissors, which is the worse failure.
|
|
10
|
+
*/
|
|
11
|
+
export declare function startOfChar(buf: Buffer, i: number): number;
|
|
12
|
+
/** The end of the last whole character at or before `i`. */
|
|
13
|
+
export declare function endOfChar(buf: Buffer, i: number): number;
|
|
14
|
+
/**
|
|
15
|
+
* The length of the buffer with any trailing *incomplete* character removed.
|
|
16
|
+
*
|
|
17
|
+
* Distinct from {@link endOfChar}, which answers "where is the boundary at or
|
|
18
|
+
* before offset i". Here the offset is the end of the buffer, and the question
|
|
19
|
+
* is whether the last character finished -- a lead byte announces its own
|
|
20
|
+
* length, so a sequence that runs off the end is detectable.
|
|
21
|
+
*/
|
|
22
|
+
export declare function completeCharEnd(buf: Buffer): number;
|
|
23
|
+
/**
|
|
24
|
+
* The next character boundary at or after `i`.
|
|
25
|
+
*
|
|
26
|
+
* Used for the *start* of a kept tail, where {@link startOfChar} would be
|
|
27
|
+
* wrong: rounding backwards keeps more bytes than the budget allowed, which is
|
|
28
|
+
* how a cap of 38 came back as 39.
|
|
29
|
+
*/
|
|
30
|
+
export declare function nextCharBoundary(buf: Buffer, i: number): number;
|
|
31
|
+
/**
|
|
32
|
+
* Cut oversized text down to `maxBytes`, keeping both ends.
|
|
33
|
+
*
|
|
34
|
+
* The middle is where a long log is least interesting -- the command line and
|
|
35
|
+
* the first errors are at the top, the failure and the exit are at the bottom.
|
|
36
|
+
* What is dropped is always said, inline, in bytes.
|
|
37
|
+
*
|
|
38
|
+
* Two things it now gets right that it did not: the seams land on character
|
|
39
|
+
* boundaries, and the result honours the cap. The marker and newlines are
|
|
40
|
+
* counted against the budget rather than added on top, so `clampText(s, 10)`
|
|
41
|
+
* no longer returns 38 bytes -- a cap the caller chose for a token budget was
|
|
42
|
+
* being exceeded by the very code enforcing it.
|
|
43
|
+
*/
|
|
44
|
+
export declare function clampText(input: string, maxBytes: number): {
|
|
45
|
+
text: string;
|
|
46
|
+
truncated: boolean;
|
|
47
|
+
};
|
|
48
|
+
export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
49
|
+
export interface RetryOptions {
|
|
50
|
+
attempts?: number;
|
|
51
|
+
baseMs?: number;
|
|
52
|
+
maxMs?: number;
|
|
53
|
+
signal?: AbortSignal;
|
|
54
|
+
shouldRetry?: (err: unknown, attempt: number) => boolean;
|
|
55
|
+
onRetry?: (err: unknown, attempt: number, delayMs: number) => void;
|
|
56
|
+
}
|
|
57
|
+
/** Exponential backoff with full jitter. */
|
|
58
|
+
export declare function retry<T>(fn: (attempt: number) => Promise<T>, opts?: RetryOptions): Promise<T>;
|
|
59
|
+
/** Race a promise against a timeout without leaking the timer. */
|
|
60
|
+
export declare function withTimeout<T>(p: Promise<T>, ms: number, message?: string): Promise<T>;
|
|
61
|
+
export declare function redact(input: string): string;
|
|
62
|
+
/** Approximate token count. Good enough for budgeting; never for billing. */
|
|
63
|
+
export declare function estimateTokens(text: string): number;
|
|
64
|
+
export declare function formatBytes(n: number): string;
|
|
65
|
+
export declare function formatDuration(ms: number): string;
|
|
66
|
+
export declare function deepMerge<T>(base: T, patch: unknown): T;
|
|
67
|
+
/** Bounded-concurrency map that preserves input order. */
|
|
68
|
+
export declare function mapLimit<T, R>(items: T[], limit: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
|
|
69
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAM1D;AAED,4DAA4D;AAC5D,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMnD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAI/D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OA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ED,0DAA0D;AAC1D,wBAAsB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAYxH"}
|
package/dist/util.js
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
/**
|
|
3
|
+
* Where a UTF-8 character actually starts, at or before `i`.
|
|
4
|
+
*
|
|
5
|
+
* Slicing a byte buffer at an arbitrary offset lands in the middle of a
|
|
6
|
+
* multi-byte character about as often as not, and `toString('utf8')` renders
|
|
7
|
+
* the orphaned halves as U+FFFD. Cutting a 200 KB log used to leave a few of
|
|
8
|
+
* those at each seam -- rare enough to look like the program's own output was
|
|
9
|
+
* corrupt rather than like husk's scissors, which is the worse failure.
|
|
10
|
+
*/
|
|
11
|
+
export function startOfChar(buf, i) {
|
|
12
|
+
let at = i;
|
|
13
|
+
// Continuation bytes are 10xxxxxx. Walk back to the lead byte. Four is the
|
|
14
|
+
// longest a legal sequence gets, so a bounded walk cannot loop on bad input.
|
|
15
|
+
for (let steps = 0; at > 0 && steps < 4 && (buf[at] & 0xc0) === 0x80; steps++)
|
|
16
|
+
at--;
|
|
17
|
+
return at;
|
|
18
|
+
}
|
|
19
|
+
/** The end of the last whole character at or before `i`. */
|
|
20
|
+
export function endOfChar(buf, i) {
|
|
21
|
+
if (i >= buf.byteLength)
|
|
22
|
+
return buf.byteLength;
|
|
23
|
+
return startOfChar(buf, i);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The length of the buffer with any trailing *incomplete* character removed.
|
|
27
|
+
*
|
|
28
|
+
* Distinct from {@link endOfChar}, which answers "where is the boundary at or
|
|
29
|
+
* before offset i". Here the offset is the end of the buffer, and the question
|
|
30
|
+
* is whether the last character finished -- a lead byte announces its own
|
|
31
|
+
* length, so a sequence that runs off the end is detectable.
|
|
32
|
+
*/
|
|
33
|
+
export function completeCharEnd(buf) {
|
|
34
|
+
const start = startOfChar(buf, buf.byteLength - 1);
|
|
35
|
+
if (start < 0)
|
|
36
|
+
return 0;
|
|
37
|
+
const lead = buf[start];
|
|
38
|
+
const len = lead < 0x80 ? 1 : lead >= 0xf0 ? 4 : lead >= 0xe0 ? 3 : lead >= 0xc0 ? 2 : 1;
|
|
39
|
+
return start + len <= buf.byteLength ? buf.byteLength : start;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The next character boundary at or after `i`.
|
|
43
|
+
*
|
|
44
|
+
* Used for the *start* of a kept tail, where {@link startOfChar} would be
|
|
45
|
+
* wrong: rounding backwards keeps more bytes than the budget allowed, which is
|
|
46
|
+
* how a cap of 38 came back as 39.
|
|
47
|
+
*/
|
|
48
|
+
export function nextCharBoundary(buf, i) {
|
|
49
|
+
let at = Math.max(0, i);
|
|
50
|
+
while (at < buf.byteLength && (buf[at] & 0xc0) === 0x80)
|
|
51
|
+
at++;
|
|
52
|
+
return at;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Cut oversized text down to `maxBytes`, keeping both ends.
|
|
56
|
+
*
|
|
57
|
+
* The middle is where a long log is least interesting -- the command line and
|
|
58
|
+
* the first errors are at the top, the failure and the exit are at the bottom.
|
|
59
|
+
* What is dropped is always said, inline, in bytes.
|
|
60
|
+
*
|
|
61
|
+
* Two things it now gets right that it did not: the seams land on character
|
|
62
|
+
* boundaries, and the result honours the cap. The marker and newlines are
|
|
63
|
+
* counted against the budget rather than added on top, so `clampText(s, 10)`
|
|
64
|
+
* no longer returns 38 bytes -- a cap the caller chose for a token budget was
|
|
65
|
+
* being exceeded by the very code enforcing it.
|
|
66
|
+
*/
|
|
67
|
+
export function clampText(input, maxBytes) {
|
|
68
|
+
const buf = Buffer.from(input, 'utf8');
|
|
69
|
+
const marker = (omitted) => `\n... [${omitted} bytes elided by husk] ...\n`;
|
|
70
|
+
if (buf.byteLength <= maxBytes)
|
|
71
|
+
return { text: input, truncated: false };
|
|
72
|
+
// The marker's own length depends on the number printed inside it, which
|
|
73
|
+
// depends on how much we keep. Budgeting against the largest that number can
|
|
74
|
+
// be -- the whole input -- settles it in one pass and can only leave slack.
|
|
75
|
+
const budget = Math.max(0, maxBytes - Buffer.byteLength(marker(buf.byteLength)));
|
|
76
|
+
const half = Math.floor(budget / 2);
|
|
77
|
+
if (half < 1) {
|
|
78
|
+
// No room for both ends plus an honest marker. Say what happened and keep
|
|
79
|
+
// nothing rather than emit something longer than the cap we were given.
|
|
80
|
+
const text = marker(buf.byteLength).trim();
|
|
81
|
+
return { text: Buffer.byteLength(text) <= maxBytes ? text : '', truncated: true };
|
|
82
|
+
}
|
|
83
|
+
const headEnd = endOfChar(buf, half);
|
|
84
|
+
const tailStart = nextCharBoundary(buf, buf.byteLength - half);
|
|
85
|
+
const head = buf.subarray(0, headEnd).toString('utf8');
|
|
86
|
+
const tail = buf.subarray(tailStart).toString('utf8');
|
|
87
|
+
const omitted = tailStart - headEnd;
|
|
88
|
+
return { text: `${head}${marker(omitted)}${tail}`, truncated: true };
|
|
89
|
+
}
|
|
90
|
+
export function sleep(ms, signal) {
|
|
91
|
+
return new Promise((resolve, reject) => {
|
|
92
|
+
if (signal?.aborted)
|
|
93
|
+
return reject(new Error('aborted'));
|
|
94
|
+
const t = setTimeout(resolve, ms);
|
|
95
|
+
signal?.addEventListener('abort', () => {
|
|
96
|
+
clearTimeout(t);
|
|
97
|
+
reject(new Error('aborted'));
|
|
98
|
+
}, { once: true });
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/** Exponential backoff with full jitter. */
|
|
102
|
+
export async function retry(fn, opts = {}) {
|
|
103
|
+
const attempts = opts.attempts ?? 3;
|
|
104
|
+
const base = opts.baseMs ?? 250;
|
|
105
|
+
const max = opts.maxMs ?? 8000;
|
|
106
|
+
let lastErr;
|
|
107
|
+
for (let a = 1; a <= attempts; a++) {
|
|
108
|
+
try {
|
|
109
|
+
return await fn(a);
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
lastErr = err;
|
|
113
|
+
if (a === attempts)
|
|
114
|
+
break;
|
|
115
|
+
if (opts.shouldRetry && !opts.shouldRetry(err, a))
|
|
116
|
+
break;
|
|
117
|
+
const ceiling = Math.min(max, base * 2 ** (a - 1));
|
|
118
|
+
const delay = Math.floor(Math.random() * ceiling);
|
|
119
|
+
opts.onRetry?.(err, a, delay);
|
|
120
|
+
await sleep(delay, opts.signal);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
throw lastErr;
|
|
124
|
+
}
|
|
125
|
+
/** Race a promise against a timeout without leaking the timer. */
|
|
126
|
+
export async function withTimeout(p, ms, message = 'timed out') {
|
|
127
|
+
let timer;
|
|
128
|
+
try {
|
|
129
|
+
return await Promise.race([
|
|
130
|
+
p,
|
|
131
|
+
new Promise((_, reject) => {
|
|
132
|
+
timer = setTimeout(() => reject(new Error(message)), ms);
|
|
133
|
+
}),
|
|
134
|
+
]);
|
|
135
|
+
}
|
|
136
|
+
finally {
|
|
137
|
+
if (timer)
|
|
138
|
+
clearTimeout(timer);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** Anything that looks like a credential, before it reaches a log or a model. */
|
|
142
|
+
const SECRET_PATTERNS = [
|
|
143
|
+
/\b(sk-ant-[A-Za-z0-9_-]{20,})/g,
|
|
144
|
+
// The class must include `-` and `_`: OpenAI project keys are `sk-proj-...`,
|
|
145
|
+
// and [A-Za-z0-9] stops at the second dash, leaving 7 characters that never
|
|
146
|
+
// reach the 20-char minimum. Measured: a full sk-proj- key passed through
|
|
147
|
+
// redact() completely untouched.
|
|
148
|
+
/\b(sk-[A-Za-z0-9_-]{20,})/g,
|
|
149
|
+
/\b(gsk_[A-Za-z0-9]{20,})/g,
|
|
150
|
+
/\b(AIza[0-9A-Za-z_-]{30,})/g,
|
|
151
|
+
/\b(ghp_[A-Za-z0-9]{30,})/g,
|
|
152
|
+
/\b(github_pat_[A-Za-z0-9_]{30,})/g,
|
|
153
|
+
/\b(xox[baprs]-[A-Za-z0-9-]{10,})/g,
|
|
154
|
+
/\b(AKIA[0-9A-Z]{16})\b/g,
|
|
155
|
+
/\b(npm_[A-Za-z0-9]{30,})/g,
|
|
156
|
+
/\b(fo1_[A-Za-z0-9_-]{20,})/g,
|
|
157
|
+
/\b(xai-[A-Za-z0-9]{20,})/g,
|
|
158
|
+
// A bearer token has no prefix of its own -- the only thing marking it is
|
|
159
|
+
// the header it arrives in. Without this, any provider husk has no pattern
|
|
160
|
+
// for leaks in full the moment a request is logged or an error echoes its
|
|
161
|
+
// headers back.
|
|
162
|
+
/((?:Authorization|Proxy-Authorization)\s*:\s*(?:Bearer|Basic|Token)\s+)[A-Za-z0-9._~+/=-]{16,}/gi,
|
|
163
|
+
/(-----BEGIN (?:RSA |EC |OPENSSH |PGP )?PRIVATE KEY-----)[\s\S]*?(-----END [^-]*-----)/g,
|
|
164
|
+
];
|
|
165
|
+
export function redact(input) {
|
|
166
|
+
let out = input;
|
|
167
|
+
for (const re of SECRET_PATTERNS)
|
|
168
|
+
out = out.replace(re, (m) => mask(m));
|
|
169
|
+
return out;
|
|
170
|
+
}
|
|
171
|
+
function mask(s) {
|
|
172
|
+
if (s.includes('PRIVATE KEY'))
|
|
173
|
+
return '[redacted private key]';
|
|
174
|
+
// For a header match the name and scheme are not the secret, and keeping
|
|
175
|
+
// them is the difference between "Authorization: Bearer [redacted]" and a
|
|
176
|
+
// bare "[redacted]" that leaves a reader guessing which header leaked.
|
|
177
|
+
const header = /^((?:Authorization|Proxy-Authorization)\s*:\s*(?:Bearer|Basic|Token)\s+)/i.exec(s);
|
|
178
|
+
if (header)
|
|
179
|
+
return `${header[1]}[redacted]`;
|
|
180
|
+
const keep = Math.min(6, Math.floor(s.length / 4));
|
|
181
|
+
return `${s.slice(0, keep)}...[redacted]`;
|
|
182
|
+
}
|
|
183
|
+
/** Approximate token count. Good enough for budgeting; never for billing. */
|
|
184
|
+
export function estimateTokens(text) {
|
|
185
|
+
if (!text)
|
|
186
|
+
return 0;
|
|
187
|
+
return Math.ceil(text.length / 3.6);
|
|
188
|
+
}
|
|
189
|
+
export function formatBytes(n) {
|
|
190
|
+
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
191
|
+
let i = 0;
|
|
192
|
+
let v = n;
|
|
193
|
+
while (v >= 1024 && i < units.length - 1) {
|
|
194
|
+
v /= 1024;
|
|
195
|
+
i++;
|
|
196
|
+
}
|
|
197
|
+
return `${v < 10 && i > 0 ? v.toFixed(1) : Math.round(v)}${units[i]}`;
|
|
198
|
+
}
|
|
199
|
+
export function formatDuration(ms) {
|
|
200
|
+
if (ms < 1000)
|
|
201
|
+
return `${Math.round(ms)}ms`;
|
|
202
|
+
if (ms < 60_000)
|
|
203
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
204
|
+
const m = Math.floor(ms / 60_000);
|
|
205
|
+
const s = Math.round((ms % 60_000) / 1000);
|
|
206
|
+
return `${m}m${s.toString().padStart(2, '0')}s`;
|
|
207
|
+
}
|
|
208
|
+
export function deepMerge(base, patch) {
|
|
209
|
+
if (patch === undefined || patch === null)
|
|
210
|
+
return base;
|
|
211
|
+
if (Array.isArray(patch) || typeof patch !== 'object')
|
|
212
|
+
return patch;
|
|
213
|
+
if (typeof base !== 'object' || base === null || Array.isArray(base))
|
|
214
|
+
return patch;
|
|
215
|
+
const out = { ...base };
|
|
216
|
+
for (const [k, v] of Object.entries(patch)) {
|
|
217
|
+
out[k] = deepMerge(base[k], v);
|
|
218
|
+
}
|
|
219
|
+
return out;
|
|
220
|
+
}
|
|
221
|
+
/** Bounded-concurrency map that preserves input order. */
|
|
222
|
+
export async function mapLimit(items, limit, fn) {
|
|
223
|
+
const results = new Array(items.length);
|
|
224
|
+
let cursor = 0;
|
|
225
|
+
const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
226
|
+
for (;;) {
|
|
227
|
+
const i = cursor++;
|
|
228
|
+
if (i >= items.length)
|
|
229
|
+
return;
|
|
230
|
+
results[i] = await fn(items[i], i);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
await Promise.all(workers);
|
|
234
|
+
return results;
|
|
235
|
+
}
|
|
236
|
+
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,CAAS;IAChD,IAAI,EAAE,GAAG,CAAC,CAAC;IACX,2EAA2E;IAC3E,6EAA6E;IAC7E,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAE,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE;QAAE,EAAE,EAAE,CAAC;IACrF,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,SAAS,CAAC,GAAW,EAAE,CAAS;IAC9C,IAAI,CAAC,IAAI,GAAG,CAAC,UAAU;QAAE,OAAO,GAAG,CAAC,UAAU,CAAC;IAC/C,OAAO,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IACnD,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IACxB,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAE,CAAC;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CAAE,IAAgC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,GAAQ,CAAC;AAClB,CAAC;AAED,0DAA0D;AAC1D,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAO,KAAU,EAAE,KAAa,EAAE,EAA0C;IACxG,MAAM,OAAO,GAAG,IAAI,KAAK,CAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3C,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,IAAI,EAAE;QAC/E,SAAS,CAAC;YACR,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC;YACnB,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM;gBAAE,OAAO;YAC9B,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC3B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@husk-ai/core",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Shared contracts, types and primitives for Husk.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.build.json",
|
|
20
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
21
|
+
"test": "vitest run --passWithNoTests"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"zod": "^3.23.8"
|
|
25
|
+
}
|
|
26
|
+
}
|