@yukino.js/yukino 0.0.1 → 0.0.3-dev
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/README.md +34 -27
- package/dist/{acp-IVY5HZR4.js → acp-J6EPN6TP.js} +6 -6
- package/dist/{agent-QANDY7FO.js → agent-LA65FOAB.js} +1 -1
- package/dist/anthropic-YP6DY2F3.js +4 -0
- package/dist/{chunk-UPNNYP7M.js → chunk-2UNWKNDU.js} +1 -1
- package/dist/{chunk-T4O4GQVL.js → chunk-675L7SRF.js} +98 -98
- package/dist/{chunk-VWUGGYUP.js → chunk-7CVY4FXY.js} +1 -1
- package/dist/{chunk-SOO5OXX2.js → chunk-CT773IEX.js} +3 -3
- package/dist/{chunk-RAS3ORX3.js → chunk-JEOQXHOX.js} +29 -29
- package/dist/chunk-M5H5EYXN.js +5 -0
- package/dist/{chunk-SAJCBGHL.js → chunk-P77AEADG.js} +1 -1
- package/dist/{chunk-XO7ITAWR.js → chunk-Y6COQ5UY.js} +1 -1
- package/dist/{chunk-RCXKUD3Y.js → chunk-ZQP5DTJA.js} +1 -1
- package/dist/{esm-ZTIYTMTS.js → esm-NCEEJIH3.js} +3 -3
- package/dist/lib/{agent-6FZX4P2Y.js → agent-KDWPLLAV.js} +5 -5
- package/dist/lib/{anthropic-IP23YZ3P.js → anthropic-OJALXK4E.js} +4 -6
- package/dist/lib/{chunk-O7ELJUEK.js → chunk-24L3QT3J.js} +8 -2
- package/dist/lib/{chunk-KA6POJKI.js → chunk-2DEH6DOX.js} +9 -11
- package/dist/lib/{chunk-I34MAQRE.js → chunk-6AKRDUQF.js} +6 -2
- package/dist/lib/{chunk-2VF3XTGH.js → chunk-77FSPN6Y.js} +148 -60
- package/dist/lib/{chunk-5TGXH7BX.js → chunk-7G4AI2PP.js} +5 -55
- package/dist/lib/{chunk-6OMQD7MK.js → chunk-7SU77J32.js} +9 -1
- package/dist/lib/{chunk-FFM2LB4C.js → chunk-EFNPK4SJ.js} +7 -2
- package/dist/lib/{chunk-QYBQT2DM.js → chunk-SS7OJYHN.js} +27 -9
- package/dist/lib/{chunk-AZRC67RW.js → chunk-WOMWIFSN.js} +2 -2
- package/dist/lib/{chunk-5DVQ64YL.js → chunk-ZF52ER22.js} +3 -3
- package/dist/lib/index.d.ts +69 -52
- package/dist/lib/index.js +331 -123
- package/dist/lib/{openai-EMJ6U4FW.js → openai-FB7BBZVN.js} +3 -3
- package/dist/lib/{permissions-KZ5ACZAX.js → permissions-BZRN4RES.js} +3 -3
- package/dist/lib/{providers-2CGZPBFI.js → providers-7ZGRBCQ4.js} +1 -1
- package/dist/lib/{sandbox-runtime-CCQ3X3SM.js → sandbox-runtime-QDN5SXPM.js} +1 -1
- package/dist/lib/{tool-filter-CKHZUUBQ.js → tool-filter-PY6XY254.js} +1 -1
- package/dist/main.js +223 -217
- package/dist/{openai-YXYO5OW6.js → openai-2FE77NB2.js} +14 -14
- package/dist/{permissions-VCDMNX3L.js → permissions-R7P7RWZU.js} +1 -1
- package/dist/{providers-HNMBGGW6.js → providers-EZFC2EPW.js} +1 -1
- package/dist/{server-ZHQILOBP.js → server-54LNMGWU.js} +1 -1
- package/package.json +19 -12
- package/postinstall.mjs +80 -0
- package/dist/anthropic-6YLT4JZR.js +0 -4
- package/dist/chunk-5VOCXSSX.js +0 -5
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
NetworkError,
|
|
10
10
|
RateLimitError,
|
|
11
11
|
clampThinkingLevel,
|
|
12
|
+
containsContextLengthError,
|
|
12
13
|
ensureToolPairing,
|
|
13
14
|
getMaxOutputTokens,
|
|
14
15
|
getSupportedThinkingLevels,
|
|
@@ -17,11 +18,11 @@ import {
|
|
|
17
18
|
thinkingBudgetForLevel,
|
|
18
19
|
toAnthropicThinkingEffort,
|
|
19
20
|
toReasoningEffort
|
|
20
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-SS7OJYHN.js";
|
|
21
22
|
import {
|
|
22
23
|
MCP_TOOL_PREFIX,
|
|
23
24
|
isMcpToolLike
|
|
24
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-6AKRDUQF.js";
|
|
25
26
|
import {
|
|
26
27
|
asErrorString,
|
|
27
28
|
asRecord,
|
|
@@ -30,7 +31,7 @@ import {
|
|
|
30
31
|
createChildLogger,
|
|
31
32
|
isRecord,
|
|
32
33
|
strArg
|
|
33
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-7SU77J32.js";
|
|
34
35
|
import {
|
|
35
36
|
__export
|
|
36
37
|
} from "./chunk-MLKGABMK.js";
|
|
@@ -40,13 +41,11 @@ var anthropic_exports = {};
|
|
|
40
41
|
__export(anthropic_exports, {
|
|
41
42
|
AnthropicClient: () => AnthropicClient,
|
|
42
43
|
buildAnthropicMessages: () => buildAnthropicMessages,
|
|
43
|
-
fetchModelContextWindow: () => fetchModelContextWindow,
|
|
44
44
|
markLastUserTailForCache: () => markLastUserTailForCache,
|
|
45
45
|
markToolsForCache: () => markToolsForCache,
|
|
46
46
|
needsToolSearchBeta: () => needsToolSearchBeta
|
|
47
47
|
});
|
|
48
48
|
import Anthropic from "@anthropic-ai/sdk";
|
|
49
|
-
import { safeParseAsync, z } from "zod";
|
|
50
49
|
|
|
51
50
|
// src/mcp/strategy.ts
|
|
52
51
|
var strategy_exports = {};
|
|
@@ -158,54 +157,6 @@ function toAnthropicToolSchema(schema, useExplicitCustomType) {
|
|
|
158
157
|
);
|
|
159
158
|
}
|
|
160
159
|
var log = createChildLogger({ module: "llm" });
|
|
161
|
-
var MODEL_FETCH_TIMEOUT_MS = 3e3;
|
|
162
|
-
var ModelContextWindowResSchema = z.object({
|
|
163
|
-
max_input_tokens: z.coerce.number()
|
|
164
|
-
});
|
|
165
|
-
async function fetchModelContextWindow(config) {
|
|
166
|
-
if (config.protocol !== "anthropic") {
|
|
167
|
-
return 0;
|
|
168
|
-
}
|
|
169
|
-
const apiKey = resolveAPIKey(config);
|
|
170
|
-
const base = config.base_url.replace(/\/+$/, "");
|
|
171
|
-
const url = `${base}/v1/models/${encodeURIComponent(config.model)}`;
|
|
172
|
-
const controller = new AbortController();
|
|
173
|
-
const timer = setTimeout(() => {
|
|
174
|
-
controller.abort();
|
|
175
|
-
}, MODEL_FETCH_TIMEOUT_MS);
|
|
176
|
-
try {
|
|
177
|
-
const res = await fetch(url, {
|
|
178
|
-
method: "GET",
|
|
179
|
-
headers: {
|
|
180
|
-
"anthropic-version": "2023-06-01",
|
|
181
|
-
...apiKey ? { "x-api-key": apiKey } : {}
|
|
182
|
-
},
|
|
183
|
-
signal: controller.signal
|
|
184
|
-
});
|
|
185
|
-
if (!res.ok) {
|
|
186
|
-
return 0;
|
|
187
|
-
}
|
|
188
|
-
const body = await res.json();
|
|
189
|
-
const { success, error, data } = await safeParseAsync(
|
|
190
|
-
ModelContextWindowResSchema,
|
|
191
|
-
body
|
|
192
|
-
);
|
|
193
|
-
if (!success) {
|
|
194
|
-
log.warn(
|
|
195
|
-
{ message: error.message },
|
|
196
|
-
"model context window schema validation failed"
|
|
197
|
-
);
|
|
198
|
-
return 0;
|
|
199
|
-
}
|
|
200
|
-
const maxInputTokens = data.max_input_tokens;
|
|
201
|
-
return Math.max(maxInputTokens, 0);
|
|
202
|
-
} catch (err) {
|
|
203
|
-
log.error({ err }, "failed to fetch model context window");
|
|
204
|
-
return 0;
|
|
205
|
-
} finally {
|
|
206
|
-
clearTimeout(timer);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
160
|
function userBlocksFor(content) {
|
|
210
161
|
if (typeof content === "string") {
|
|
211
162
|
return [{ type: "text", text: content }];
|
|
@@ -579,7 +530,7 @@ function markLastUserTailForCache(messages) {
|
|
|
579
530
|
}
|
|
580
531
|
function classifyAnthropicError(err) {
|
|
581
532
|
if (err instanceof Anthropic.APIError) {
|
|
582
|
-
if (err.status === 413 /* PromptTooLong */ ||
|
|
533
|
+
if (err.status === 413 /* PromptTooLong */ || err.status === 400 /* BadRequest */ && containsContextLengthError(err.message)) {
|
|
583
534
|
return new ContextTooLongError(`Prompt too long: ${err.message}`);
|
|
584
535
|
}
|
|
585
536
|
if (err.status === 401 /* InvalidAPIKey */) {
|
|
@@ -616,7 +567,6 @@ export {
|
|
|
616
567
|
strategy_exports,
|
|
617
568
|
markToolsForCache,
|
|
618
569
|
needsToolSearchBeta,
|
|
619
|
-
fetchModelContextWindow,
|
|
620
570
|
buildAnthropicMessages,
|
|
621
571
|
AnthropicClient,
|
|
622
572
|
markLastUserTailForCache,
|
|
@@ -249,7 +249,15 @@ __export(paths_exports, {
|
|
|
249
249
|
});
|
|
250
250
|
import { realpathSync } from "fs";
|
|
251
251
|
import { homedir as homedir2 } from "os";
|
|
252
|
-
import {
|
|
252
|
+
import {
|
|
253
|
+
basename as basename2,
|
|
254
|
+
dirname as dirname2,
|
|
255
|
+
isAbsolute,
|
|
256
|
+
join as join2,
|
|
257
|
+
relative,
|
|
258
|
+
resolve,
|
|
259
|
+
sep
|
|
260
|
+
} from "path";
|
|
253
261
|
function canonicalPath(path) {
|
|
254
262
|
let current = resolve(path);
|
|
255
263
|
const missing = [];
|
|
@@ -42,7 +42,9 @@ var SandboxRuntimeSandbox = class {
|
|
|
42
42
|
}
|
|
43
43
|
async prepare(command, config, context) {
|
|
44
44
|
if (!await this.available()) {
|
|
45
|
-
throw new Error(
|
|
45
|
+
throw new Error(
|
|
46
|
+
this.availabilityError ?? "sandbox runtime is unavailable"
|
|
47
|
+
);
|
|
46
48
|
}
|
|
47
49
|
const runtime = await this.loadRuntime();
|
|
48
50
|
const runtimeConfig = runtime.SandboxRuntimeConfigSchema.parse(
|
|
@@ -86,7 +88,10 @@ var SandboxRuntimeSandbox = class {
|
|
|
86
88
|
executable,
|
|
87
89
|
args,
|
|
88
90
|
env: prepared.env,
|
|
89
|
-
annotateStderr: (stderr) => runtime.SandboxManager.annotateStderrWithSandboxFailures(
|
|
91
|
+
annotateStderr: (stderr) => runtime.SandboxManager.annotateStderrWithSandboxFailures(
|
|
92
|
+
commandId,
|
|
93
|
+
stderr
|
|
94
|
+
),
|
|
90
95
|
cleanup: () => {
|
|
91
96
|
runtime.SandboxManager.cleanupAfterCommand();
|
|
92
97
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createChildLogger
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7SU77J32.js";
|
|
4
4
|
import {
|
|
5
5
|
__export
|
|
6
6
|
} from "./chunk-MLKGABMK.js";
|
|
@@ -219,7 +219,7 @@ function resolveAPIKey(p) {
|
|
|
219
219
|
}
|
|
220
220
|
return process.env[envVar] ?? "";
|
|
221
221
|
}
|
|
222
|
-
var MCPServerConfigSchema = z.
|
|
222
|
+
var MCPServerConfigSchema = z.looseObject({
|
|
223
223
|
name: z.string(),
|
|
224
224
|
command: z.string().optional(),
|
|
225
225
|
args: z.array(z.string()).optional(),
|
|
@@ -228,11 +228,11 @@ var MCPServerConfigSchema = z.object({
|
|
|
228
228
|
headers: z.record(z.string(), z.string()).optional(),
|
|
229
229
|
env: z.record(z.string(), z.string()).optional()
|
|
230
230
|
});
|
|
231
|
-
var HookConfigSchema = z.
|
|
231
|
+
var HookConfigSchema = z.looseObject({
|
|
232
232
|
id: z.string().optional(),
|
|
233
233
|
event: z.string(),
|
|
234
234
|
condition: z.string().optional(),
|
|
235
|
-
action: z.
|
|
235
|
+
action: z.looseObject({
|
|
236
236
|
type: z.string(),
|
|
237
237
|
command: z.string().optional(),
|
|
238
238
|
url: z.string().optional(),
|
|
@@ -244,13 +244,14 @@ var HookConfigSchema = z.object({
|
|
|
244
244
|
async: z.boolean().optional(),
|
|
245
245
|
on_error: z.string().optional()
|
|
246
246
|
});
|
|
247
|
-
var SandboxYamlConfigSchema = z.
|
|
247
|
+
var SandboxYamlConfigSchema = z.looseObject({
|
|
248
248
|
enabled: z.boolean().optional(),
|
|
249
249
|
backend: z.enum(["native", "sandbox-runtime"]).optional(),
|
|
250
250
|
auto_allow: z.boolean().optional(),
|
|
251
251
|
network_enabled: z.boolean().optional()
|
|
252
252
|
});
|
|
253
253
|
var AppConfigSchema = z.looseObject({
|
|
254
|
+
default_provider: z.number().default(0),
|
|
254
255
|
providers: z.array(ProviderConfigSchema),
|
|
255
256
|
permission_mode: z.string().optional(),
|
|
256
257
|
mcp_servers: z.array(MCPServerConfigSchema).default([]),
|
|
@@ -276,7 +277,7 @@ function loadSingleFile(path) {
|
|
|
276
277
|
const raw = yaml.load(data);
|
|
277
278
|
if (!isRecord(raw)) {
|
|
278
279
|
log.error({ path }, "invalid yaml");
|
|
279
|
-
return { providers: [], mcp_servers: [], hooks: [] };
|
|
280
|
+
return { default_provider: 0, providers: [], mcp_servers: [], hooks: [] };
|
|
280
281
|
}
|
|
281
282
|
const parsed = safeParse(AppConfigSchema, raw);
|
|
282
283
|
if (parsed.success) {
|
|
@@ -287,6 +288,7 @@ function loadSingleFile(path) {
|
|
|
287
288
|
};
|
|
288
289
|
}
|
|
289
290
|
log.error({ error: parsed.error }, "config error");
|
|
291
|
+
let defaultProvider = 0;
|
|
290
292
|
let providers = [];
|
|
291
293
|
let permissionMode;
|
|
292
294
|
let mcpServers = [];
|
|
@@ -294,6 +296,12 @@ function loadSingleFile(path) {
|
|
|
294
296
|
let sandbox = void 0;
|
|
295
297
|
let enableCoordinatorMode = false;
|
|
296
298
|
let enableFork = true;
|
|
299
|
+
if ("default_provider" in raw) {
|
|
300
|
+
const parsed2 = safeParse(z.number(), raw.default_provider);
|
|
301
|
+
if (parsed2.success) {
|
|
302
|
+
defaultProvider = parsed2.data;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
297
305
|
if ("providers" in raw) {
|
|
298
306
|
const parsed2 = safeParse(z.array(ProviderConfigSchema), raw.providers);
|
|
299
307
|
if (parsed2.success) {
|
|
@@ -340,6 +348,7 @@ function loadSingleFile(path) {
|
|
|
340
348
|
enableFork = Boolean(raw.enable_fork);
|
|
341
349
|
}
|
|
342
350
|
return {
|
|
351
|
+
default_provider: defaultProvider,
|
|
343
352
|
providers,
|
|
344
353
|
permission_mode: permissionMode,
|
|
345
354
|
mcp_servers: mcpServers,
|
|
@@ -510,7 +519,7 @@ function loadConfig(path, options = {}) {
|
|
|
510
519
|
const candidate = globalConfigPath();
|
|
511
520
|
if (!existsSync(candidate)) {
|
|
512
521
|
if (options.allowEmptyProviders) {
|
|
513
|
-
return { providers: [], mcp_servers: [], hooks: [] };
|
|
522
|
+
return { default_provider: 0, providers: [], mcp_servers: [], hooks: [] };
|
|
514
523
|
}
|
|
515
524
|
throw new ConfigError(`No config file found, expected ${candidate}.`);
|
|
516
525
|
}
|
|
@@ -554,7 +563,11 @@ function ensureToolPairing(messages) {
|
|
|
554
563
|
}
|
|
555
564
|
}
|
|
556
565
|
for (const toolUseId of pending) {
|
|
557
|
-
results.push({
|
|
566
|
+
results.push({
|
|
567
|
+
toolUseId,
|
|
568
|
+
content: INTERRUPTED_TOOL_RESULT,
|
|
569
|
+
isError: true
|
|
570
|
+
});
|
|
558
571
|
}
|
|
559
572
|
out.push({
|
|
560
573
|
...resultMessages[0] ?? { role: "user", content: "" },
|
|
@@ -586,7 +599,8 @@ __export(errors_exports, {
|
|
|
586
599
|
ContextTooLongError: () => ContextTooLongError,
|
|
587
600
|
LLMError: () => LLMError,
|
|
588
601
|
NetworkError: () => NetworkError,
|
|
589
|
-
RateLimitError: () => RateLimitError
|
|
602
|
+
RateLimitError: () => RateLimitError,
|
|
603
|
+
containsContextLengthError: () => containsContextLengthError
|
|
590
604
|
});
|
|
591
605
|
var LLMError = class extends Error {
|
|
592
606
|
constructor(message) {
|
|
@@ -620,6 +634,9 @@ var ContextTooLongError = class extends LLMError {
|
|
|
620
634
|
this.name = "ContextTooLongError";
|
|
621
635
|
}
|
|
622
636
|
};
|
|
637
|
+
function containsContextLengthError(msg) {
|
|
638
|
+
return /context_length_exceeded/i.test(msg) || /maximum\s+context\s+length/i.test(msg) || /prompts?\s+(?:is\s+)?too\s+long/i.test(msg);
|
|
639
|
+
}
|
|
623
640
|
|
|
624
641
|
export {
|
|
625
642
|
globalConfigPath,
|
|
@@ -651,5 +668,6 @@ export {
|
|
|
651
668
|
RateLimitError,
|
|
652
669
|
NetworkError,
|
|
653
670
|
ContextTooLongError,
|
|
671
|
+
containsContextLengthError,
|
|
654
672
|
errors_exports
|
|
655
673
|
};
|
|
@@ -47,12 +47,12 @@ import { readFileSync } from "fs";
|
|
|
47
47
|
import path from "path";
|
|
48
48
|
import { fileURLToPath } from "url";
|
|
49
49
|
import { z } from "zod";
|
|
50
|
-
var PackageJsonSchema = z.
|
|
50
|
+
var PackageJsonSchema = z.looseObject({
|
|
51
51
|
version: z.string()
|
|
52
52
|
});
|
|
53
53
|
function resolveVersion() {
|
|
54
54
|
if (true) {
|
|
55
|
-
return "0.0.
|
|
55
|
+
return "0.0.3-dev";
|
|
56
56
|
}
|
|
57
57
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
58
58
|
for (const levels of ["..", "../.."]) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mcpCallPermissionContent
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6AKRDUQF.js";
|
|
4
4
|
import {
|
|
5
5
|
canonicalPath,
|
|
6
6
|
createChildLogger,
|
|
7
7
|
isPathWithin,
|
|
8
8
|
isRecord,
|
|
9
9
|
strArg
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-7SU77J32.js";
|
|
11
11
|
import {
|
|
12
12
|
__export
|
|
13
13
|
} from "./chunk-MLKGABMK.js";
|
|
@@ -313,7 +313,7 @@ function loadRulesFile(path) {
|
|
|
313
313
|
}
|
|
314
314
|
return [];
|
|
315
315
|
}
|
|
316
|
-
const YamlEntrySchema = z.
|
|
316
|
+
const YamlEntrySchema = z.looseObject({
|
|
317
317
|
rule: z.string().optional(),
|
|
318
318
|
effect: z.string().optional()
|
|
319
319
|
});
|