buckyos 0.7.170 → 0.7.175
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/cli/core/app.ts +2 -0
- package/cli/core/argv.ts +45 -239
- package/cli/core/command.ts +3 -35
- package/cli/dist/cli.mjs +2151 -673
- package/cli/dist/cli.mjs.map +1 -1
- package/cli/modules/agent.ts +3 -1
- package/cli/modules/app.ts +13 -2
- package/cli/modules/pikg.ts +70 -1
- package/cli/modules/runtime.ts +497 -0
- package/cli/modules/skill.ts +583 -161
- package/cli/modules/skill_lint.ts +462 -0
- package/cli/version.ts +1 -1
- package/dist/account-7a7bde6f.mjs +105 -0
- package/dist/account-7a7bde6f.mjs.map +1 -0
- package/dist/account-b12ac6b9.js +2 -0
- package/dist/account-b12ac6b9.js.map +1 -0
- package/dist/aicc-67851c41.mjs +582 -0
- package/dist/aicc-67851c41.mjs.map +1 -0
- package/dist/aicc-ccb36ef7.js +2 -0
- package/dist/aicc-ccb36ef7.js.map +1 -0
- package/dist/browser.cjs +1 -1
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +2 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.mjs +204 -194
- package/dist/browser.mjs.map +1 -1
- package/dist/did_object_client-6a1b108a.js +2 -0
- package/dist/did_object_client-6a1b108a.js.map +1 -0
- package/dist/did_object_client-7fa36f90.mjs +87 -0
- package/dist/did_object_client-7fa36f90.mjs.map +1 -0
- package/dist/did_object_client.d.ts +39 -0
- package/dist/did_object_client.d.ts.map +1 -0
- package/dist/{executor_client-5f4d0468.mjs → executor_client-c620d25c.mjs} +233 -748
- package/dist/executor_client-c620d25c.mjs.map +1 -0
- package/dist/executor_client-d4439d54.js +13 -0
- package/dist/executor_client-d4439d54.js.map +1 -0
- package/dist/executor_client.d.ts +129 -0
- package/dist/executor_client.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +209 -199
- package/dist/index.mjs.map +1 -1
- package/dist/internal/command_args.d.ts +67 -0
- package/dist/internal/command_args.d.ts.map +1 -0
- package/dist/krpc_client-26c2dc8b.js +2 -0
- package/dist/krpc_client-26c2dc8b.js.map +1 -0
- package/dist/krpc_client-673448e5.mjs +173 -0
- package/dist/krpc_client-673448e5.mjs.map +1 -0
- package/dist/krpc_client.d.ts +5 -1
- package/dist/krpc_client.d.ts.map +1 -1
- package/dist/{ndn_types-ab30fac0.mjs → ndn_types-0fac2499.mjs} +115 -215
- package/dist/ndn_types-0fac2499.mjs.map +1 -0
- package/dist/ndn_types-5b138882.js +2 -0
- package/dist/ndn_types-5b138882.js.map +1 -0
- package/dist/node.cjs +1 -1
- package/dist/node.cjs.map +1 -1
- package/dist/node.mjs +201 -194
- package/dist/node.mjs.map +1 -1
- package/dist/object_url-8fb5a7bf.js +2 -0
- package/dist/object_url-8fb5a7bf.js.map +1 -0
- package/dist/object_url-f72c1704.mjs +412 -0
- package/dist/object_url-f72c1704.mjs.map +1 -0
- package/dist/openai-ae2978de.mjs +163 -0
- package/dist/openai-ae2978de.mjs.map +1 -0
- package/dist/openai-f560d518.js +2 -0
- package/dist/openai-f560d518.js.map +1 -0
- package/dist/provision.cjs +6 -6
- package/dist/provision.cjs.map +1 -1
- package/dist/provision.mjs +4 -3
- package/dist/provision.mjs.map +1 -1
- package/dist/site_manager-11a7a468.mjs +6410 -0
- package/dist/site_manager-11a7a468.mjs.map +1 -0
- package/dist/site_manager-334b1a51.js +2 -0
- package/dist/site_manager-334b1a51.js.map +1 -0
- package/dist/{tus_client-b231b248.js → tus_client-809c90ab.js} +2 -2
- package/dist/{tus_client-b231b248.js.map → tus_client-809c90ab.js.map} +1 -1
- package/dist/{tus_client-d1ffe2d6.mjs → tus_client-893a3287.mjs} +2 -2
- package/dist/{tus_client-d1ffe2d6.mjs.map → tus_client-893a3287.mjs.map} +1 -1
- package/dist/xllm/core/action_parser.d.ts +15 -0
- package/dist/xllm/core/action_parser.d.ts.map +1 -0
- package/dist/xllm/core/behavior_loop.d.ts +20 -0
- package/dist/xllm/core/behavior_loop.d.ts.map +1 -0
- package/dist/xllm/core/behavior_result.d.ts +11 -0
- package/dist/xllm/core/behavior_result.d.ts.map +1 -0
- package/dist/xllm/core/config.d.ts +62 -0
- package/dist/xllm/core/config.d.ts.map +1 -0
- package/dist/xllm/core/context_window.d.ts +15 -0
- package/dist/xllm/core/context_window.d.ts.map +1 -0
- package/dist/xllm/core/deps.d.ts +97 -0
- package/dist/xllm/core/deps.d.ts.map +1 -0
- package/dist/xllm/core/errors.d.ts +94 -0
- package/dist/xllm/core/errors.d.ts.map +1 -0
- package/dist/xllm/core/interrupt.d.ts +31 -0
- package/dist/xllm/core/interrupt.d.ts.map +1 -0
- package/dist/xllm/core/json.d.ts +11 -0
- package/dist/xllm/core/json.d.ts.map +1 -0
- package/dist/xllm/core/json_check.d.ts +17 -0
- package/dist/xllm/core/json_check.d.ts.map +1 -0
- package/dist/xllm/core/loop.d.ts +135 -0
- package/dist/xllm/core/loop.d.ts.map +1 -0
- package/dist/xllm/core/messages.d.ts +18 -0
- package/dist/xllm/core/messages.d.ts.map +1 -0
- package/dist/xllm/core/observer.d.ts +14 -0
- package/dist/xllm/core/observer.d.ts.map +1 -0
- package/dist/xllm/core/open_runtime.d.ts +22 -0
- package/dist/xllm/core/open_runtime.d.ts.map +1 -0
- package/dist/xllm/core/prepare.d.ts +54 -0
- package/dist/xllm/core/prepare.d.ts.map +1 -0
- package/dist/xllm/core/prompt.d.ts +40 -0
- package/dist/xllm/core/prompt.d.ts.map +1 -0
- package/dist/xllm/core/protocol.d.ts +15 -0
- package/dist/xllm/core/protocol.d.ts.map +1 -0
- package/dist/xllm/core/result.d.ts +12 -0
- package/dist/xllm/core/result.d.ts.map +1 -0
- package/dist/xllm/core/run.d.ts +198 -0
- package/dist/xllm/core/run.d.ts.map +1 -0
- package/dist/xllm/core/rust_text.d.ts +20 -0
- package/dist/xllm/core/rust_text.d.ts.map +1 -0
- package/dist/xllm/core/site_policy.d.ts +5 -0
- package/dist/xllm/core/site_policy.d.ts.map +1 -0
- package/dist/xllm/core/store.d.ts +60 -0
- package/dist/xllm/core/store.d.ts.map +1 -0
- package/dist/xllm/core/suspension.d.ts +13 -0
- package/dist/xllm/core/suspension.d.ts.map +1 -0
- package/dist/xllm/core/tokenizer.d.ts +8 -0
- package/dist/xllm/core/tokenizer.d.ts.map +1 -0
- package/dist/xllm/core/types.d.ts +826 -0
- package/dist/xllm/core/types.d.ts.map +1 -0
- package/dist/xllm/core/xml.d.ts +19 -0
- package/dist/xllm/core/xml.d.ts.map +1 -0
- package/dist/xllm/dev/openai.d.ts +17 -0
- package/dist/xllm/dev/openai.d.ts.map +1 -0
- package/dist/xllm/dev/scripted.d.ts +46 -0
- package/dist/xllm/dev/scripted.d.ts.map +1 -0
- package/dist/xllm/dev.d.ts +5 -0
- package/dist/xllm/dev.d.ts.map +1 -0
- package/dist/xllm/hosts/browser/store.d.ts +41 -0
- package/dist/xllm/hosts/browser/store.d.ts.map +1 -0
- package/dist/xllm/hosts/deno/deno_api.d.ts +103 -0
- package/dist/xllm/hosts/deno/deno_api.d.ts.map +1 -0
- package/dist/xllm/hosts/deno/identity.d.ts +29 -0
- package/dist/xllm/hosts/deno/identity.d.ts.map +1 -0
- package/dist/xllm/hosts/deno/index.d.ts +47 -0
- package/dist/xllm/hosts/deno/index.d.ts.map +1 -0
- package/dist/xllm/hosts/deno/native_runtime.d.ts +93 -0
- package/dist/xllm/hosts/deno/native_runtime.d.ts.map +1 -0
- package/dist/xllm/hosts/deno/native_tools.d.ts +105 -0
- package/dist/xllm/hosts/deno/native_tools.d.ts.map +1 -0
- package/dist/xllm/hosts/deno/provider.d.ts +13 -0
- package/dist/xllm/hosts/deno/provider.d.ts.map +1 -0
- package/dist/xllm/hosts/deno/store.d.ts +60 -0
- package/dist/xllm/hosts/deno/store.d.ts.map +1 -0
- package/dist/xllm/index.d.ts +48 -0
- package/dist/xllm/index.d.ts.map +1 -0
- package/dist/xllm/providers/aicc.d.ts +22 -0
- package/dist/xllm/providers/aicc.d.ts.map +1 -0
- package/dist/xllm/providers/timeout.d.ts +12 -0
- package/dist/xllm/providers/timeout.d.ts.map +1 -0
- package/dist/xllm/runtime/compress.d.ts +149 -0
- package/dist/xllm/runtime/compress.d.ts.map +1 -0
- package/dist/xllm/runtime/did_object_resources.d.ts +21 -0
- package/dist/xllm/runtime/did_object_resources.d.ts.map +1 -0
- package/dist/xllm/runtime/hints.d.ts +23 -0
- package/dist/xllm/runtime/hints.d.ts.map +1 -0
- package/dist/xllm/runtime/site.d.ts +22 -0
- package/dist/xllm/runtime/site.d.ts.map +1 -0
- package/dist/xllm/runtime/site_manager.d.ts +38 -0
- package/dist/xllm/runtime/site_manager.d.ts.map +1 -0
- package/dist/xllm/runtime/site_tools.d.ts +76 -0
- package/dist/xllm/runtime/site_tools.d.ts.map +1 -0
- package/dist/xllm/runtime/step_renderer.d.ts +54 -0
- package/dist/xllm/runtime/step_renderer.d.ts.map +1 -0
- package/dist/xllm/runtime/task_model.d.ts +64 -0
- package/dist/xllm/runtime/task_model.d.ts.map +1 -0
- package/dist/xllm/runtime/tool_result.d.ts +39 -0
- package/dist/xllm/runtime/tool_result.d.ts.map +1 -0
- package/dist/xllm/runtime/types.d.ts +99 -0
- package/dist/xllm/runtime/types.d.ts.map +1 -0
- package/dist/xllm.cjs +2 -0
- package/dist/xllm.cjs.map +1 -0
- package/dist/xllm.mjs +1167 -0
- package/dist/xllm.mjs.map +1 -0
- package/dist/xllm_deno.cjs +2 -0
- package/dist/xllm_deno.cjs.map +1 -0
- package/dist/xllm_deno.mjs +2487 -0
- package/dist/xllm_deno.mjs.map +1 -0
- package/dist/xllm_dev.cjs +2 -0
- package/dist/xllm_dev.cjs.map +1 -0
- package/dist/xllm_dev.mjs +70 -0
- package/dist/xllm_dev.mjs.map +1 -0
- package/package.json +22 -1
- package/src/internal/command_args.ts +268 -0
- package/dist/executor_client-1ee523cf.js +0 -13
- package/dist/executor_client-1ee523cf.js.map +0 -1
- package/dist/executor_client-5f4d0468.mjs.map +0 -1
- package/dist/ndn_types-8c2696d5.js +0 -2
- package/dist/ndn_types-8c2696d5.js.map +0 -1
- package/dist/ndn_types-ab30fac0.mjs.map +0 -1
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
import { a as RPC_HTTP_ERROR_CODE, b as RPC_TRANSPORT_ERROR_CODE } from "./krpc_client-673448e5.mjs";
|
|
2
|
+
class LLMComputeException extends Error {
|
|
3
|
+
constructor(error) {
|
|
4
|
+
super(computeErrorMessage(error));
|
|
5
|
+
this.name = "LLMComputeException";
|
|
6
|
+
this.error = error;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function providerError(failure, message) {
|
|
10
|
+
return new LLMComputeException({ kind: "provider", failure, message });
|
|
11
|
+
}
|
|
12
|
+
function asComputeError(error) {
|
|
13
|
+
if (error instanceof LLMComputeException)
|
|
14
|
+
return error.error;
|
|
15
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
16
|
+
return { kind: "provider", failure: "unknown", message };
|
|
17
|
+
}
|
|
18
|
+
function failureDebug(failure) {
|
|
19
|
+
if (typeof failure === "object")
|
|
20
|
+
return `Refused { code: ${JSON.stringify(failure.refused.code)} }`;
|
|
21
|
+
return { transient: "Transient", permanent: "Permanent", unknown: "Unknown", context_limit: "ContextLimit" }[failure];
|
|
22
|
+
}
|
|
23
|
+
function stageDebug(stage) {
|
|
24
|
+
return { before_inference: "BeforeInference", before_tool_call: "BeforeToolCall", outcome_boundary: "OutcomeBoundary" }[stage];
|
|
25
|
+
}
|
|
26
|
+
function computeErrorMessage(e) {
|
|
27
|
+
switch (e.kind) {
|
|
28
|
+
case "timeout":
|
|
29
|
+
return "llm timeout";
|
|
30
|
+
case "cancelled":
|
|
31
|
+
return "llm cancelled";
|
|
32
|
+
case "provider":
|
|
33
|
+
return `llm provider failed (${failureDebug(e.failure)}): ${e.message}`;
|
|
34
|
+
case "output_parse":
|
|
35
|
+
return `llm output parse failed: ${e.message}`;
|
|
36
|
+
case "policy_rejected":
|
|
37
|
+
return `policy rejected: ${e.message}`;
|
|
38
|
+
case "tool_failed":
|
|
39
|
+
return `tool \`${e.tool}\` failed: ${e.message}`;
|
|
40
|
+
case "tool_runtime":
|
|
41
|
+
return `tool \`${e.tool}\` dispatch failed (effect_unknown=${e.effect_unknown}): ${e.message}`;
|
|
42
|
+
case "checkpoint":
|
|
43
|
+
return `checkpoint ${stageDebug(e.stage)} failed: ${e.message}`;
|
|
44
|
+
case "snapshot_corrupted":
|
|
45
|
+
return `snapshot corrupted: ${e.message}`;
|
|
46
|
+
case "internal":
|
|
47
|
+
return `internal: ${e.message}`;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function errorSource(e) {
|
|
51
|
+
switch (e.kind) {
|
|
52
|
+
case "timeout":
|
|
53
|
+
case "cancelled":
|
|
54
|
+
case "provider":
|
|
55
|
+
return "provider";
|
|
56
|
+
case "output_parse":
|
|
57
|
+
return "llm_output";
|
|
58
|
+
case "policy_rejected":
|
|
59
|
+
case "tool_failed":
|
|
60
|
+
return "tool";
|
|
61
|
+
case "tool_runtime":
|
|
62
|
+
case "checkpoint":
|
|
63
|
+
return "runtime";
|
|
64
|
+
case "snapshot_corrupted":
|
|
65
|
+
return "snapshot";
|
|
66
|
+
case "internal":
|
|
67
|
+
return "internal";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function llmCorrectable(e) {
|
|
71
|
+
return e.kind === "output_parse" || e.kind === "policy_rejected" || e.kind === "tool_failed";
|
|
72
|
+
}
|
|
73
|
+
function infraRetrySafe(e) {
|
|
74
|
+
switch (e.kind) {
|
|
75
|
+
case "timeout":
|
|
76
|
+
case "checkpoint":
|
|
77
|
+
return true;
|
|
78
|
+
case "provider":
|
|
79
|
+
return e.failure === "transient";
|
|
80
|
+
case "tool_runtime":
|
|
81
|
+
return !e.effect_unknown;
|
|
82
|
+
default:
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function refusedCode(failure) {
|
|
87
|
+
return typeof failure === "object" ? failure.refused.code : void 0;
|
|
88
|
+
}
|
|
89
|
+
function xllmErrorMessage(d) {
|
|
90
|
+
switch (d.kind) {
|
|
91
|
+
case "config":
|
|
92
|
+
return `config error: ${d.file}: ${d.field}: ${d.reason}`;
|
|
93
|
+
case "input":
|
|
94
|
+
return `input error: ${d.message}`;
|
|
95
|
+
case "capability":
|
|
96
|
+
return `capability error: ${d.message}`;
|
|
97
|
+
case "runtime_mismatch":
|
|
98
|
+
return `runtime mismatch: ${d.message}`;
|
|
99
|
+
case "recovery_blocked":
|
|
100
|
+
return `RecoveryBlocked: ${d.message}`;
|
|
101
|
+
case "tools":
|
|
102
|
+
return `tools error: ${d.message}`;
|
|
103
|
+
case "template":
|
|
104
|
+
return `template error in ${d.origin}: ${d.reason}`;
|
|
105
|
+
case "run_not_found":
|
|
106
|
+
return `run \`${d.run_id}\` not found under ${d.runs_dir}`;
|
|
107
|
+
case "run_busy":
|
|
108
|
+
return `run \`${d.run_id}\` is being executed by another process`;
|
|
109
|
+
case "workdir_busy":
|
|
110
|
+
return `working directory ${d.workdir} already has a tool-enabled run \`${d.run_id}\` executing; wait for it or use another directory`;
|
|
111
|
+
case "run_terminal":
|
|
112
|
+
return `run \`${d.run_id}\` is terminal (${d.status}); ${d.hint}`;
|
|
113
|
+
case "not_resumable":
|
|
114
|
+
return `run \`${d.run_id}\` cannot be resumed: ${d.reason}`;
|
|
115
|
+
case "corrupted_run":
|
|
116
|
+
return `run \`${d.run_id}\` record is corrupted: ${d.reason}`;
|
|
117
|
+
case "storage":
|
|
118
|
+
return `storage error: ${d.message}`;
|
|
119
|
+
case "extract":
|
|
120
|
+
return `result extraction failed: ${d.message}`;
|
|
121
|
+
case "compressor":
|
|
122
|
+
return `context compaction failed: ${d.message}`;
|
|
123
|
+
case "other":
|
|
124
|
+
return d.message;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
class XllmError extends Error {
|
|
128
|
+
constructor(detail) {
|
|
129
|
+
super(xllmErrorMessage(detail));
|
|
130
|
+
this.name = "XllmError";
|
|
131
|
+
this.detail = detail;
|
|
132
|
+
}
|
|
133
|
+
get kind() {
|
|
134
|
+
return this.detail.kind;
|
|
135
|
+
}
|
|
136
|
+
static config(file, field, reason) {
|
|
137
|
+
return new XllmError({ kind: "config", file, field, reason });
|
|
138
|
+
}
|
|
139
|
+
static input(message) {
|
|
140
|
+
return new XllmError({ kind: "input", message });
|
|
141
|
+
}
|
|
142
|
+
static capability(message) {
|
|
143
|
+
return new XllmError({ kind: "capability", message });
|
|
144
|
+
}
|
|
145
|
+
static runtimeMismatch(message) {
|
|
146
|
+
return new XllmError({ kind: "runtime_mismatch", message });
|
|
147
|
+
}
|
|
148
|
+
static tools(message) {
|
|
149
|
+
return new XllmError({ kind: "tools", message });
|
|
150
|
+
}
|
|
151
|
+
static template(origin, reason) {
|
|
152
|
+
return new XllmError({ kind: "template", origin, reason });
|
|
153
|
+
}
|
|
154
|
+
static notResumable(runId, reason) {
|
|
155
|
+
return new XllmError({ kind: "not_resumable", run_id: runId, reason });
|
|
156
|
+
}
|
|
157
|
+
static storage(message) {
|
|
158
|
+
return new XllmError({ kind: "storage", message });
|
|
159
|
+
}
|
|
160
|
+
static other(message) {
|
|
161
|
+
return new XllmError({ kind: "other", message });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function isRustWhitespace(c) {
|
|
165
|
+
return c >= 9 && c <= 13 || c === 32 || c === 133 || c === 160 || c === 5760 || c >= 8192 && c <= 8202 || c === 8232 || c === 8233 || c === 8239 || c === 8287 || c === 12288;
|
|
166
|
+
}
|
|
167
|
+
function rustTrimStart(s) {
|
|
168
|
+
let i = 0;
|
|
169
|
+
while (i < s.length && isRustWhitespace(s.charCodeAt(i)))
|
|
170
|
+
i++;
|
|
171
|
+
return i === 0 ? s : s.slice(i);
|
|
172
|
+
}
|
|
173
|
+
function rustTrimEnd(s) {
|
|
174
|
+
let j = s.length;
|
|
175
|
+
while (j > 0 && isRustWhitespace(s.charCodeAt(j - 1)))
|
|
176
|
+
j--;
|
|
177
|
+
return j === s.length ? s : s.slice(0, j);
|
|
178
|
+
}
|
|
179
|
+
function rustTrim(s) {
|
|
180
|
+
return rustTrimStart(rustTrimEnd(s));
|
|
181
|
+
}
|
|
182
|
+
function collapseWhitespace(s) {
|
|
183
|
+
const words = [];
|
|
184
|
+
let start = -1;
|
|
185
|
+
for (let i = 0; i < s.length; i++) {
|
|
186
|
+
if (isRustWhitespace(s.charCodeAt(i))) {
|
|
187
|
+
if (start >= 0)
|
|
188
|
+
words.push(s.slice(start, i));
|
|
189
|
+
start = -1;
|
|
190
|
+
} else if (start < 0) {
|
|
191
|
+
start = i;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (start >= 0)
|
|
195
|
+
words.push(s.slice(start));
|
|
196
|
+
return words.join(" ");
|
|
197
|
+
}
|
|
198
|
+
function isPairAt(s, i) {
|
|
199
|
+
const c = s.charCodeAt(i);
|
|
200
|
+
return c >= 55296 && c <= 56319 && i + 1 < s.length && (s.charCodeAt(i + 1) & 64512) === 56320;
|
|
201
|
+
}
|
|
202
|
+
function charOffset(s, n) {
|
|
203
|
+
let i = 0;
|
|
204
|
+
for (let k = 0; k < n && i < s.length; k++)
|
|
205
|
+
i += isPairAt(s, i) ? 2 : 1;
|
|
206
|
+
return i;
|
|
207
|
+
}
|
|
208
|
+
function charCount(s) {
|
|
209
|
+
let n = 0;
|
|
210
|
+
for (let i = 0; i < s.length; i += isPairAt(s, i) ? 2 : 1)
|
|
211
|
+
n++;
|
|
212
|
+
return n;
|
|
213
|
+
}
|
|
214
|
+
function rustTextContent(message) {
|
|
215
|
+
let out = "";
|
|
216
|
+
for (const b of message.content) {
|
|
217
|
+
if (b.type !== "text")
|
|
218
|
+
continue;
|
|
219
|
+
if (out !== "")
|
|
220
|
+
out += "\n";
|
|
221
|
+
out += b.text;
|
|
222
|
+
}
|
|
223
|
+
return out;
|
|
224
|
+
}
|
|
225
|
+
function compareCodePoints(a, b) {
|
|
226
|
+
let i = 0;
|
|
227
|
+
let j = 0;
|
|
228
|
+
while (i < a.length && j < b.length) {
|
|
229
|
+
const x = a.codePointAt(i);
|
|
230
|
+
const y = b.codePointAt(j);
|
|
231
|
+
if (x !== y)
|
|
232
|
+
return x - y;
|
|
233
|
+
i += x > 65535 ? 2 : 1;
|
|
234
|
+
j += y > 65535 ? 2 : 1;
|
|
235
|
+
}
|
|
236
|
+
return a.length - i - (b.length - j);
|
|
237
|
+
}
|
|
238
|
+
function serdeNumber(n) {
|
|
239
|
+
if (!Number.isFinite(n))
|
|
240
|
+
return "null";
|
|
241
|
+
if (Number.isInteger(n) && n > -(2 ** 63) && n < 2 ** 64)
|
|
242
|
+
return String(n);
|
|
243
|
+
const [mantissa, exponent] = Math.abs(n).toExponential().split("e");
|
|
244
|
+
const digits = mantissa.replace(".", "");
|
|
245
|
+
const length = digits.length;
|
|
246
|
+
const e = Number(exponent);
|
|
247
|
+
let s;
|
|
248
|
+
if (e >= -5 && e <= 15) {
|
|
249
|
+
if (length - 1 <= e)
|
|
250
|
+
s = `${digits}${"0".repeat(e + 1 - length)}.0`;
|
|
251
|
+
else if (e >= 0)
|
|
252
|
+
s = `${digits.slice(0, e + 1)}.${digits.slice(e + 1)}`;
|
|
253
|
+
else
|
|
254
|
+
s = `0.${"0".repeat(-e - 1)}${digits}`;
|
|
255
|
+
} else {
|
|
256
|
+
s = `${length > 1 ? `${digits[0]}.${digits.slice(1)}` : digits}e${e < 0 ? "-" : "+"}${Math.abs(e)}`;
|
|
257
|
+
}
|
|
258
|
+
return n < 0 ? `-${s}` : s;
|
|
259
|
+
}
|
|
260
|
+
function writeJson(v, indent) {
|
|
261
|
+
if (v === null || v === void 0)
|
|
262
|
+
return "null";
|
|
263
|
+
if (typeof v === "string")
|
|
264
|
+
return JSON.stringify(v);
|
|
265
|
+
if (typeof v === "number")
|
|
266
|
+
return serdeNumber(v);
|
|
267
|
+
if (typeof v === "boolean")
|
|
268
|
+
return v ? "true" : "false";
|
|
269
|
+
const inner = indent === void 0 ? void 0 : `${indent} `;
|
|
270
|
+
if (Array.isArray(v)) {
|
|
271
|
+
if (v.length === 0)
|
|
272
|
+
return "[]";
|
|
273
|
+
const items2 = v.map((x) => writeJson(x, inner));
|
|
274
|
+
return inner === void 0 ? `[${items2.join(",")}]` : `[${inner}${items2.join(`,${inner}`)}${indent}]`;
|
|
275
|
+
}
|
|
276
|
+
const keys = Object.keys(v).filter((k) => v[k] !== void 0).sort(compareCodePoints);
|
|
277
|
+
if (keys.length === 0)
|
|
278
|
+
return "{}";
|
|
279
|
+
const items = keys.map((k) => `${JSON.stringify(k)}:${inner === void 0 ? "" : " "}${writeJson(v[k], inner)}`);
|
|
280
|
+
return inner === void 0 ? `{${items.join(",")}}` : `{${inner}${items.join(`,${inner}`)}${indent}}`;
|
|
281
|
+
}
|
|
282
|
+
function serdeJson(value, pretty = false) {
|
|
283
|
+
return writeJson(value, pretty ? "\n" : void 0);
|
|
284
|
+
}
|
|
285
|
+
function canonicalJson(value) {
|
|
286
|
+
if (value === void 0)
|
|
287
|
+
return "null";
|
|
288
|
+
return serdeJson(JSON.parse(JSON.stringify(value)));
|
|
289
|
+
}
|
|
290
|
+
function cloneJson(value) {
|
|
291
|
+
return value === void 0 ? value : JSON.parse(JSON.stringify(value));
|
|
292
|
+
}
|
|
293
|
+
function jsonEqual(a, b) {
|
|
294
|
+
return canonicalJson(a) === canonicalJson(b);
|
|
295
|
+
}
|
|
296
|
+
function isObject(v) {
|
|
297
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
298
|
+
}
|
|
299
|
+
function nowMs() {
|
|
300
|
+
return Date.now();
|
|
301
|
+
}
|
|
302
|
+
function textMessage(role, text) {
|
|
303
|
+
return { role, content: [{ type: "text", text }] };
|
|
304
|
+
}
|
|
305
|
+
function textContent(message) {
|
|
306
|
+
return rustTextContent(message);
|
|
307
|
+
}
|
|
308
|
+
function toolCalls(message) {
|
|
309
|
+
const out = [];
|
|
310
|
+
for (const b of message.content) {
|
|
311
|
+
if (b.type === "tool_use")
|
|
312
|
+
out.push({ name: b.name, args: b.args ?? {}, call_id: b.call_id });
|
|
313
|
+
}
|
|
314
|
+
return out;
|
|
315
|
+
}
|
|
316
|
+
function validateResponse(response) {
|
|
317
|
+
const m = response.message;
|
|
318
|
+
if (!m || m.role !== "assistant")
|
|
319
|
+
return `invalid block response_message for role ${m == null ? void 0 : m.role}`;
|
|
320
|
+
for (const b of m.content ?? []) {
|
|
321
|
+
if (!["text", "image", "document", "tool_use", "thinking", "provider_state"].includes(b.type)) {
|
|
322
|
+
return `invalid block ${b.type} for role assistant`;
|
|
323
|
+
}
|
|
324
|
+
if (b.type === "tool_use" && !rustTrim(b.call_id ?? ""))
|
|
325
|
+
return "tool call without call_id";
|
|
326
|
+
}
|
|
327
|
+
return void 0;
|
|
328
|
+
}
|
|
329
|
+
function toolObservationMessage(callId, observation) {
|
|
330
|
+
let text;
|
|
331
|
+
let isError;
|
|
332
|
+
switch (observation.kind) {
|
|
333
|
+
case "success":
|
|
334
|
+
text = typeof observation.content === "string" ? observation.content : canonicalJson(observation.content);
|
|
335
|
+
isError = false;
|
|
336
|
+
break;
|
|
337
|
+
case "error":
|
|
338
|
+
text = observation.message;
|
|
339
|
+
isError = true;
|
|
340
|
+
break;
|
|
341
|
+
case "cancelled":
|
|
342
|
+
if (observation.effect_unknown) {
|
|
343
|
+
text = `[cancelled, result unknown] ${observation.reason}`;
|
|
344
|
+
isError = true;
|
|
345
|
+
} else {
|
|
346
|
+
text = `[cancelled] ${observation.reason}`;
|
|
347
|
+
isError = false;
|
|
348
|
+
}
|
|
349
|
+
break;
|
|
350
|
+
case "unresolved":
|
|
351
|
+
text = observation.effect_unknown ? `[unresolved: result unknown] ${observation.reason}` : `[not executed] ${observation.reason}`;
|
|
352
|
+
isError = true;
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
const block = isError ? { type: "tool_result", call_id: callId, content: [{ type: "text", text }], is_error: true } : { type: "tool_result", call_id: callId, content: [{ type: "text", text }] };
|
|
356
|
+
return { role: "tool", content: [block] };
|
|
357
|
+
}
|
|
358
|
+
const USAGE_COUNTERS = [
|
|
359
|
+
"input_tokens",
|
|
360
|
+
"output_tokens",
|
|
361
|
+
"total_tokens",
|
|
362
|
+
"cache_read_input_tokens",
|
|
363
|
+
"cache_write_input_tokens",
|
|
364
|
+
"cache_write_1h_input_tokens",
|
|
365
|
+
"reasoning_tokens",
|
|
366
|
+
"image_units",
|
|
367
|
+
"audio_seconds",
|
|
368
|
+
"video_seconds",
|
|
369
|
+
"reference_images",
|
|
370
|
+
"request_units",
|
|
371
|
+
"characters",
|
|
372
|
+
"audio_input_tokens",
|
|
373
|
+
"image_input_tokens",
|
|
374
|
+
"audio_output_tokens",
|
|
375
|
+
"image_output_tokens"
|
|
376
|
+
];
|
|
377
|
+
function mergeUsage(left, right) {
|
|
378
|
+
const out = {};
|
|
379
|
+
for (const k of USAGE_COUNTERS) {
|
|
380
|
+
const a = left[k];
|
|
381
|
+
const b = right[k];
|
|
382
|
+
if (a !== void 0 || b !== void 0)
|
|
383
|
+
out[k] = (a ?? 0) + (b ?? 0);
|
|
384
|
+
}
|
|
385
|
+
const cost = addCost(left.cost, right.cost);
|
|
386
|
+
if (cost)
|
|
387
|
+
out.cost = cost;
|
|
388
|
+
return out;
|
|
389
|
+
}
|
|
390
|
+
function addCost(a, b) {
|
|
391
|
+
if (a && b)
|
|
392
|
+
return a.currency === b.currency ? { amount: a.amount + b.amount, currency: a.currency } : void 0;
|
|
393
|
+
return a ?? b;
|
|
394
|
+
}
|
|
395
|
+
function addRecordUsage(base, extra) {
|
|
396
|
+
const cur = { ...base ?? {} };
|
|
397
|
+
for (const k of ["input_tokens", "output_tokens", "total_tokens", "request_units"]) {
|
|
398
|
+
if (extra[k] !== void 0)
|
|
399
|
+
cur[k] = (cur[k] ?? 0) + extra[k];
|
|
400
|
+
}
|
|
401
|
+
return cur;
|
|
402
|
+
}
|
|
403
|
+
const REFUSED_QUOTA_EXHAUSTED = "quota_exhausted";
|
|
404
|
+
const REFUSED_QUOTA_BUDGET_EXCEEDED = "quota_budget_exceeded";
|
|
405
|
+
const REFUSED_RESOURCE_NOT_PERMITTED = "resource_not_permitted";
|
|
406
|
+
const REFUSED_ATTRIBUTION_UNAVAILABLE = "attribution_unavailable";
|
|
407
|
+
const REFUSED_CREDENTIALS = "credentials";
|
|
408
|
+
const REFUSAL_CODES = [REFUSED_QUOTA_EXHAUSTED, REFUSED_QUOTA_BUDGET_EXCEEDED, REFUSED_RESOURCE_NOT_PERMITTED, REFUSED_ATTRIBUTION_UNAVAILABLE];
|
|
409
|
+
function anyJsonObjectSchema() {
|
|
410
|
+
return { type: "object", additionalProperties: true };
|
|
411
|
+
}
|
|
412
|
+
function refused(code) {
|
|
413
|
+
return { refused: { code } };
|
|
414
|
+
}
|
|
415
|
+
function aiccProviderFailure(error) {
|
|
416
|
+
const code = error.code;
|
|
417
|
+
if (code && REFUSAL_CODES.includes(code))
|
|
418
|
+
return refused(code);
|
|
419
|
+
if (code === "quota_unavailable")
|
|
420
|
+
return "transient";
|
|
421
|
+
const httpStatus = isObject(error.details) ? error.details.http_status : void 0;
|
|
422
|
+
if (code === "context_length_exceeded" || httpStatus === 413)
|
|
423
|
+
return "context_limit";
|
|
424
|
+
if (code === "timeout" || error.retriable === true)
|
|
425
|
+
return "transient";
|
|
426
|
+
return void 0;
|
|
427
|
+
}
|
|
428
|
+
function providerErrorFromRpc(context, err) {
|
|
429
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
430
|
+
const text = `${context}: ${message}`;
|
|
431
|
+
const code = typeof err === "object" && err !== null ? err.code : void 0;
|
|
432
|
+
if (typeof code !== "string" || !code)
|
|
433
|
+
return providerError("unknown", text);
|
|
434
|
+
const rawData = err.data;
|
|
435
|
+
const data = isObject(rawData) ? rawData : void 0;
|
|
436
|
+
const fromAicc = aiccProviderFailure({ ...data, code });
|
|
437
|
+
if (fromAicc)
|
|
438
|
+
return providerError(fromAicc, text);
|
|
439
|
+
if (code === RPC_HTTP_ERROR_CODE) {
|
|
440
|
+
const status = typeof (data == null ? void 0 : data.status) === "number" ? data.status : void 0;
|
|
441
|
+
if (status === 413)
|
|
442
|
+
return providerError("context_limit", text);
|
|
443
|
+
if (status === 408 || status === 504)
|
|
444
|
+
return providerError("transient", text);
|
|
445
|
+
if (status === 401 || status === 403)
|
|
446
|
+
return providerError(refused(REFUSED_CREDENTIALS), text);
|
|
447
|
+
return providerError("unknown", text);
|
|
448
|
+
}
|
|
449
|
+
if (code === RPC_TRANSPORT_ERROR_CODE)
|
|
450
|
+
return providerError("transient", text);
|
|
451
|
+
return providerError("unknown", text);
|
|
452
|
+
}
|
|
453
|
+
const DISABLE_FEATURES = {
|
|
454
|
+
tool_call: "tool_call",
|
|
455
|
+
json_schema: "json_schema",
|
|
456
|
+
web_search: "web_search",
|
|
457
|
+
vision: "vision",
|
|
458
|
+
image_generation: "image_generation",
|
|
459
|
+
streaming: "streaming"
|
|
460
|
+
};
|
|
461
|
+
function aiccErrorText(e) {
|
|
462
|
+
return e ? ` (${e.code}: ${e.message})` : "";
|
|
463
|
+
}
|
|
464
|
+
class AiccLlmClient {
|
|
465
|
+
constructor(client) {
|
|
466
|
+
this.client = client;
|
|
467
|
+
}
|
|
468
|
+
async infer(req) {
|
|
469
|
+
var _a;
|
|
470
|
+
const tools = req.allow_tool_calls ? req.tool_specs.map((s) => ({ type: "function", name: s.name, description: s.description, args_json_schema: s.args_schema })) : [];
|
|
471
|
+
const disable = {};
|
|
472
|
+
for (const f of req.disable_capabilities) {
|
|
473
|
+
const key = DISABLE_FEATURES[f];
|
|
474
|
+
if (key)
|
|
475
|
+
disable[key] = true;
|
|
476
|
+
}
|
|
477
|
+
let responseFormat;
|
|
478
|
+
if (req.force_json) {
|
|
479
|
+
responseFormat = req.json_schema !== void 0 ? { type: "json_schema", json_schema: { name: "llm_response", schema: req.json_schema } } : { type: "json_schema", json_schema: { name: "llm_response", schema: anyJsonObjectSchema(), strict: false } };
|
|
480
|
+
}
|
|
481
|
+
const common = {
|
|
482
|
+
messages: req.messages,
|
|
483
|
+
...tools.length ? { tools } : {},
|
|
484
|
+
...responseFormat ? { response_format: responseFormat } : {},
|
|
485
|
+
...req.temperature !== void 0 ? { temperature: req.temperature } : {},
|
|
486
|
+
...req.max_completion_tokens !== void 0 ? { max_output_tokens: req.max_completion_tokens } : {},
|
|
487
|
+
...req.trace_id ? { trace_id: req.trace_id } : {},
|
|
488
|
+
execution_mode: "immediate"
|
|
489
|
+
};
|
|
490
|
+
const exact = req.model_alias.includes("@");
|
|
491
|
+
const method = exact ? "chat.completions.create" : "helper.llm_chat";
|
|
492
|
+
let response;
|
|
493
|
+
try {
|
|
494
|
+
if (exact) {
|
|
495
|
+
const r = { exact_model: req.model_alias, ...common };
|
|
496
|
+
response = await this.client.chatCompletionsCreate(r);
|
|
497
|
+
} else {
|
|
498
|
+
const requirements = {};
|
|
499
|
+
if (req.allow_tool_calls && tools.length > 0)
|
|
500
|
+
requirements.tool_call = true;
|
|
501
|
+
if (req.force_json)
|
|
502
|
+
requirements.json_schema = true;
|
|
503
|
+
const r = {
|
|
504
|
+
logical_model: req.model_alias,
|
|
505
|
+
...common,
|
|
506
|
+
...Object.keys(requirements).length ? { requirements } : {},
|
|
507
|
+
...Object.keys(disable).length ? { disable } : {}
|
|
508
|
+
};
|
|
509
|
+
response = await this.client.helperLlmChat(r);
|
|
510
|
+
}
|
|
511
|
+
} catch (e) {
|
|
512
|
+
if (e instanceof LLMComputeException)
|
|
513
|
+
throw e;
|
|
514
|
+
throw providerErrorFromRpc(`aicc ${method} failed`, e);
|
|
515
|
+
}
|
|
516
|
+
if (response.status === "succeeded") {
|
|
517
|
+
if (!response.message)
|
|
518
|
+
throw providerError("unknown", `aicc ${method} succeeded but message is empty`);
|
|
519
|
+
const out = { message: response.message };
|
|
520
|
+
if (response.usage)
|
|
521
|
+
out.usage = response.usage;
|
|
522
|
+
if (response.cost)
|
|
523
|
+
out.cost = response.cost;
|
|
524
|
+
if (response.finish_reason)
|
|
525
|
+
out.finish_reason = response.finish_reason;
|
|
526
|
+
if (response.provider_task_ref)
|
|
527
|
+
out.provider_task_ref = response.provider_task_ref;
|
|
528
|
+
const model = (_a = response.route_trace) == null ? void 0 : _a.final_model;
|
|
529
|
+
if (model)
|
|
530
|
+
out.extra = { model };
|
|
531
|
+
return out;
|
|
532
|
+
}
|
|
533
|
+
if (response.status === "failed") {
|
|
534
|
+
const failure = (response.error && aiccProviderFailure(response.error)) ?? "unknown";
|
|
535
|
+
throw providerError(
|
|
536
|
+
failure,
|
|
537
|
+
`aicc ${method} failed${aiccErrorText(response.error)}: task_id=${response.task_id}, event_ref=${response.event_ref ?? ""}`
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
throw providerError(
|
|
541
|
+
"permanent",
|
|
542
|
+
`aicc ${method} returned async task \`${response.task_id}\`; xllm does not poll async tasks — use a synchronous-capable model`
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
export {
|
|
547
|
+
AiccLlmClient as A,
|
|
548
|
+
compareCodePoints as B,
|
|
549
|
+
charOffset as C,
|
|
550
|
+
collapseWhitespace as D,
|
|
551
|
+
addRecordUsage as E,
|
|
552
|
+
refusedCode as F,
|
|
553
|
+
LLMComputeException as L,
|
|
554
|
+
XllmError as X,
|
|
555
|
+
asComputeError as a,
|
|
556
|
+
infraRetrySafe as b,
|
|
557
|
+
computeErrorMessage as c,
|
|
558
|
+
charCount as d,
|
|
559
|
+
errorSource as e,
|
|
560
|
+
rustTrimEnd as f,
|
|
561
|
+
rustTrimStart as g,
|
|
562
|
+
aiccProviderFailure as h,
|
|
563
|
+
isObject as i,
|
|
564
|
+
anyJsonObjectSchema as j,
|
|
565
|
+
providerErrorFromRpc as k,
|
|
566
|
+
llmCorrectable as l,
|
|
567
|
+
cloneJson as m,
|
|
568
|
+
canonicalJson as n,
|
|
569
|
+
jsonEqual as o,
|
|
570
|
+
providerError as p,
|
|
571
|
+
nowMs as q,
|
|
572
|
+
rustTrim as r,
|
|
573
|
+
serdeJson as s,
|
|
574
|
+
textMessage as t,
|
|
575
|
+
textContent as u,
|
|
576
|
+
validateResponse as v,
|
|
577
|
+
toolCalls as w,
|
|
578
|
+
toolObservationMessage as x,
|
|
579
|
+
mergeUsage as y,
|
|
580
|
+
rustTextContent as z
|
|
581
|
+
};
|
|
582
|
+
//# sourceMappingURL=aicc-67851c41.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aicc-67851c41.mjs","sources":["../src/xllm/core/errors.ts","../src/xllm/core/rust_text.ts","../src/xllm/core/json.ts","../src/xllm/core/messages.ts","../src/xllm/providers/aicc.ts"],"sourcesContent":["import type { CheckpointStage, ErrorSource, LLMComputeError, ProviderFailure, RunStatus } from './types'\n\n// ------------------------------------------------------------ LLMComputeError\n\n/** A rejected `LlmClient.infer` (or any waist dependency) carries its `LLMComputeError`. */\nexport class LLMComputeException extends Error {\n readonly error: LLMComputeError\n\n constructor(error: LLMComputeError) {\n super(computeErrorMessage(error))\n this.name = 'LLMComputeException'\n this.error = error\n }\n}\n\nexport function providerError(failure: ProviderFailure, message: string): LLMComputeException {\n return new LLMComputeException({ kind: 'provider', failure, message })\n}\n\n/** What a dependency rejected with, as an `LLMComputeError`. A foreign error is a provider failure of unknown class. */\nexport function asComputeError(error: unknown): LLMComputeError {\n if (error instanceof LLMComputeException) return error.error\n const message = error instanceof Error ? error.message : String(error)\n return { kind: 'provider', failure: 'unknown', message }\n}\n\nfunction failureDebug(failure: ProviderFailure): string {\n if (typeof failure === 'object') return `Refused { code: ${JSON.stringify(failure.refused.code)} }`\n return { transient: 'Transient', permanent: 'Permanent', unknown: 'Unknown', context_limit: 'ContextLimit' }[failure]\n}\n\nfunction stageDebug(stage: CheckpointStage): string {\n return { before_inference: 'BeforeInference', before_tool_call: 'BeforeToolCall', outcome_boundary: 'OutcomeBoundary' }[stage]\n}\n\n/** Same text as Rust's `Display for LLMComputeError` (run.json `last_error.message`). */\nexport function computeErrorMessage(e: LLMComputeError): string {\n switch (e.kind) {\n case 'timeout': return 'llm timeout'\n case 'cancelled': return 'llm cancelled'\n case 'provider': return `llm provider failed (${failureDebug(e.failure)}): ${e.message}`\n case 'output_parse': return `llm output parse failed: ${e.message}`\n case 'policy_rejected': return `policy rejected: ${e.message}`\n case 'tool_failed': return `tool \\`${e.tool}\\` failed: ${e.message}`\n case 'tool_runtime': return `tool \\`${e.tool}\\` dispatch failed (effect_unknown=${e.effect_unknown}): ${e.message}`\n case 'checkpoint': return `checkpoint ${stageDebug(e.stage)} failed: ${e.message}`\n case 'snapshot_corrupted': return `snapshot corrupted: ${e.message}`\n case 'internal': return `internal: ${e.message}`\n }\n}\n\nexport function errorSource(e: LLMComputeError): ErrorSource {\n switch (e.kind) {\n case 'timeout': case 'cancelled': case 'provider': return 'provider'\n case 'output_parse': return 'llm_output'\n case 'policy_rejected': case 'tool_failed': return 'tool'\n case 'tool_runtime': case 'checkpoint': return 'runtime'\n case 'snapshot_corrupted': return 'snapshot'\n case 'internal': return 'internal'\n }\n}\n\n/** Feeding the error back to the model is a meaningful recovery; everything else ends the run. */\nexport function llmCorrectable(e: LLMComputeError): boolean {\n return e.kind === 'output_parse' || e.kind === 'policy_rejected' || e.kind === 'tool_failed'\n}\n\nexport function infraRetrySafe(e: LLMComputeError): boolean {\n switch (e.kind) {\n case 'timeout': case 'checkpoint': return true\n case 'provider': return e.failure === 'transient'\n case 'tool_runtime': return !e.effect_unknown\n default: return false\n }\n}\n\nexport function refusedCode(failure: ProviderFailure): string | undefined {\n return typeof failure === 'object' ? failure.refused.code : undefined\n}\n\n// ------------------------------------------------------------------ XllmError\n\n/** Pre-run errors of the SDK (`XllmError` in Rust): once a run exists, results come back as a `RunOutcome`. */\nexport type XllmErrorDetail =\n | { kind: 'config'; file: string; field: string; reason: string }\n | { kind: 'input'; message: string }\n | { kind: 'capability'; message: string }\n | { kind: 'runtime_mismatch'; message: string }\n | { kind: 'recovery_blocked'; message: string }\n | { kind: 'tools'; message: string }\n | { kind: 'template'; origin: string; reason: string }\n | { kind: 'run_not_found'; run_id: string; runs_dir: string }\n | { kind: 'run_busy'; run_id: string }\n | { kind: 'workdir_busy'; workdir: string; run_id: string }\n | { kind: 'run_terminal'; run_id: string; status: RunStatus; hint: string }\n | { kind: 'not_resumable'; run_id: string; reason: string }\n | { kind: 'corrupted_run'; run_id: string; reason: string }\n | { kind: 'storage'; message: string }\n | { kind: 'extract'; message: string }\n | { kind: 'compressor'; message: string }\n | { kind: 'other'; message: string }\n\nexport type XllmErrorKind = XllmErrorDetail['kind']\n\nfunction xllmErrorMessage(d: XllmErrorDetail): string {\n switch (d.kind) {\n case 'config': return `config error: ${d.file}: ${d.field}: ${d.reason}`\n case 'input': return `input error: ${d.message}`\n case 'capability': return `capability error: ${d.message}`\n case 'runtime_mismatch': return `runtime mismatch: ${d.message}`\n case 'recovery_blocked': return `RecoveryBlocked: ${d.message}`\n case 'tools': return `tools error: ${d.message}`\n case 'template': return `template error in ${d.origin}: ${d.reason}`\n case 'run_not_found': return `run \\`${d.run_id}\\` not found under ${d.runs_dir}`\n case 'run_busy': return `run \\`${d.run_id}\\` is being executed by another process`\n case 'workdir_busy':\n return `working directory ${d.workdir} already has a tool-enabled run \\`${d.run_id}\\` executing; wait for it or use another directory`\n case 'run_terminal': return `run \\`${d.run_id}\\` is terminal (${d.status}); ${d.hint}`\n case 'not_resumable': return `run \\`${d.run_id}\\` cannot be resumed: ${d.reason}`\n case 'corrupted_run': return `run \\`${d.run_id}\\` record is corrupted: ${d.reason}`\n case 'storage': return `storage error: ${d.message}`\n case 'extract': return `result extraction failed: ${d.message}`\n case 'compressor': return `context compaction failed: ${d.message}`\n case 'other': return d.message\n }\n}\n\nexport class XllmError extends Error {\n readonly detail: XllmErrorDetail\n\n constructor(detail: XllmErrorDetail) {\n super(xllmErrorMessage(detail))\n this.name = 'XllmError'\n this.detail = detail\n }\n\n get kind(): XllmErrorKind {\n return this.detail.kind\n }\n\n static config(file: string, field: string, reason: string): XllmError {\n return new XllmError({ kind: 'config', file, field, reason })\n }\n\n static input(message: string): XllmError {\n return new XllmError({ kind: 'input', message })\n }\n\n static capability(message: string): XllmError {\n return new XllmError({ kind: 'capability', message })\n }\n\n static runtimeMismatch(message: string): XllmError {\n return new XllmError({ kind: 'runtime_mismatch', message })\n }\n\n static tools(message: string): XllmError {\n return new XllmError({ kind: 'tools', message })\n }\n\n static template(origin: string, reason: string): XllmError {\n return new XllmError({ kind: 'template', origin, reason })\n }\n\n static notResumable(runId: string, reason: string): XllmError {\n return new XllmError({ kind: 'not_resumable', run_id: runId, reason })\n }\n\n static storage(message: string): XllmError {\n return new XllmError({ kind: 'storage', message })\n }\n\n static other(message: string): XllmError {\n return new XllmError({ kind: 'other', message })\n }\n}\n","// Rust string and JSON semantics for text the model sees: trimming with\n// Rust's whitespace set (`char::is_whitespace` differs from JS `trim` in\n// U+0085 and U+FEFF), lengths in Unicode scalar values, JSON written the way\n// serde_json writes it (keys in code point order, serde's number layout).\n\nimport type { AiMessage, JsonValue } from './types'\n\n/** `char::is_whitespace` (Unicode White_Space); every such char is a single UTF-16 unit. */\nfunction isRustWhitespace(c: number): boolean {\n return (c >= 0x09 && c <= 0x0d) || c === 0x20 || c === 0x85 || c === 0xa0 || c === 0x1680 || (c >= 0x2000 && c <= 0x200a) ||\n c === 0x2028 || c === 0x2029 || c === 0x202f || c === 0x205f || c === 0x3000\n}\n\n/** `str::trim_start`. */\nexport function rustTrimStart(s: string): string {\n let i = 0\n while (i < s.length && isRustWhitespace(s.charCodeAt(i))) i++\n return i === 0 ? s : s.slice(i)\n}\n\n/** `str::trim_end`. */\nexport function rustTrimEnd(s: string): string {\n let j = s.length\n while (j > 0 && isRustWhitespace(s.charCodeAt(j - 1))) j--\n return j === s.length ? s : s.slice(0, j)\n}\n\n/** `str::trim`. */\nexport function rustTrim(s: string): string {\n return rustTrimStart(rustTrimEnd(s))\n}\n\n/** `s.split_whitespace().collect::<Vec<_>>().join(\" \")`. */\nexport function collapseWhitespace(s: string): string {\n const words: string[] = []\n let start = -1\n for (let i = 0; i < s.length; i++) {\n if (isRustWhitespace(s.charCodeAt(i))) {\n if (start >= 0) words.push(s.slice(start, i))\n start = -1\n } else if (start < 0) {\n start = i\n }\n }\n if (start >= 0) words.push(s.slice(start))\n return words.join(' ')\n}\n\nfunction isPairAt(s: string, i: number): boolean {\n const c = s.charCodeAt(i)\n return c >= 0xd800 && c <= 0xdbff && i + 1 < s.length && (s.charCodeAt(i + 1) & 0xfc00) === 0xdc00\n}\n\n/** UTF-16 offset after the first `n` chars (Unicode scalar values) of `s`; `s.length` when it has fewer. */\nexport function charOffset(s: string, n: number): number {\n let i = 0\n for (let k = 0; k < n && i < s.length; k++) i += isPairAt(s, i) ? 2 : 1\n return i\n}\n\n/** `str::chars().count()`. */\nexport function charCount(s: string): number {\n let n = 0\n for (let i = 0; i < s.length; i += isPairAt(s, i) ? 2 : 1) n++\n return n\n}\n\n/** `AiMessage::text_content`: text blocks joined by `\\n`, a separator only once something was written. */\nexport function rustTextContent(message: AiMessage): string {\n let out = ''\n for (const b of message.content) {\n if (b.type !== 'text') continue\n if (out !== '') out += '\\n'\n out += b.text\n }\n return out\n}\n\n/** Order of Rust `String` (UTF-8 bytes, i.e. code points). */\nexport function compareCodePoints(a: string, b: string): number {\n let i = 0\n let j = 0\n while (i < a.length && j < b.length) {\n const x = a.codePointAt(i) as number\n const y = b.codePointAt(j) as number\n if (x !== y) return x - y\n i += x > 0xffff ? 2 : 1\n j += y > 0xffff ? 2 : 1\n }\n return (a.length - i) - (b.length - j)\n}\n\n/**\n * A number as serde_json writes the value it parsed from this number's JSON\n * text: an integer in the i64 / u64 range as is, anything else as an f64 in\n * the layout of serde_json's formatter (zmij): fixed notation for decimal\n * exponents -5..=15 (`0.00001`, `3.0`), else `1e+21` / `2.5e-7`.\n */\nfunction serdeNumber(n: number): string {\n if (!Number.isFinite(n)) return 'null'\n // -2^63 itself prints as -9223372036854776000, below i64::MIN: serde reads an f64.\n if (Number.isInteger(n) && n > -(2 ** 63) && n < 2 ** 64) return String(n)\n const [mantissa, exponent] = Math.abs(n).toExponential().split('e')\n const digits = mantissa.replace('.', '')\n const length = digits.length\n const e = Number(exponent)\n let s: string\n if (e >= -5 && e <= 15) {\n if (length - 1 <= e) s = `${digits}${'0'.repeat(e + 1 - length)}.0`\n else if (e >= 0) s = `${digits.slice(0, e + 1)}.${digits.slice(e + 1)}`\n else s = `0.${'0'.repeat(-e - 1)}${digits}`\n } else {\n s = `${length > 1 ? `${digits[0]}.${digits.slice(1)}` : digits}e${e < 0 ? '-' : '+'}${Math.abs(e)}`\n }\n return n < 0 ? `-${s}` : s\n}\n\nfunction writeJson(v: JsonValue | undefined, indent: string | undefined): string {\n if (v === null || v === undefined) return 'null'\n if (typeof v === 'string') return JSON.stringify(v)\n if (typeof v === 'number') return serdeNumber(v)\n if (typeof v === 'boolean') return v ? 'true' : 'false'\n const inner = indent === undefined ? undefined : `${indent} `\n if (Array.isArray(v)) {\n if (v.length === 0) return '[]'\n const items = v.map(x => writeJson(x, inner))\n return inner === undefined ? `[${items.join(',')}]` : `[${inner}${items.join(`,${inner}`)}${indent}]`\n }\n const keys = Object.keys(v).filter(k => v[k] !== undefined).sort(compareCodePoints)\n if (keys.length === 0) return '{}'\n const items = keys.map(k => `${JSON.stringify(k)}:${inner === undefined ? '' : ' '}${writeJson(v[k], inner)}`)\n return inner === undefined ? `{${items.join(',')}}` : `{${inner}${items.join(`,${inner}`)}${indent}}`\n}\n\n/** `serde_json::to_string` (or `to_string_pretty`) of a `Value`: keys in Rust's order, numbers as serde prints them. */\nexport function serdeJson(value: JsonValue, pretty = false): string {\n return writeJson(value, pretty ? '\\n' : undefined)\n}\n\n","// JSON helpers. serde_json (without `preserve_order`) writes object keys in\n// code point order; `canonicalJson` writes JSON exactly as serde_json does,\n// so lengths, comparisons and model-visible text match the Rust side.\n\nimport type { JsonValue } from './types'\nimport { serdeJson } from './rust_text'\n\n/** `serde_json::to_string` of the value (after a JSON round trip, so `toJSON` and `undefined` behave as in JSON). */\nexport function canonicalJson(value: unknown): string {\n if (value === undefined) return 'null'\n return serdeJson(JSON.parse(JSON.stringify(value)) as JsonValue)\n}\n\n/** Deep copy of a JSON value (drops `undefined` members like serialization does). */\nexport function cloneJson<T>(value: T): T {\n return value === undefined ? value : JSON.parse(JSON.stringify(value))\n}\n\n/** Structural equality of two JSON values, `undefined` members ignored. */\nexport function jsonEqual(a: unknown, b: unknown): boolean {\n return canonicalJson(a) === canonicalJson(b)\n}\n\nexport function isObject(v: unknown): v is { [key: string]: JsonValue } {\n return typeof v === 'object' && v !== null && !Array.isArray(v)\n}\n","import type { AiCost, AiMessage, AiRole } from '../../aicc_client'\nimport type { AiResponse, AiToolCall, AiUsage, JsonValue, Observation } from './types'\nimport { canonicalJson } from './json'\nimport { rustTextContent, rustTrim } from './rust_text'\n\nexport function nowMs(): number {\n return Date.now()\n}\n\nexport function textMessage(role: AiRole, text: string): AiMessage {\n return { role, content: [{ type: 'text', text }] }\n}\n\n/** All text blocks joined by `\\n` (`AiMessage::text_content`). */\nexport function textContent(message: AiMessage): string {\n return rustTextContent(message)\n}\n\n/** Tool-use blocks as calls, in message order (`AiMessage::tool_calls`). */\nexport function toolCalls(message: AiMessage): AiToolCall[] {\n const out: AiToolCall[] = []\n for (const b of message.content) {\n if (b.type === 'tool_use') out.push({ name: b.name, args: b.args ?? {}, call_id: b.call_id })\n }\n return out\n}\n\n/** `AiResponse::validate`: an assistant message with blocks allowed for the role and tool calls with ids. */\nexport function validateResponse(response: AiResponse): string | undefined {\n const m = response.message\n if (!m || m.role !== 'assistant') return `invalid block response_message for role ${m?.role}`\n for (const b of m.content ?? []) {\n if (!['text', 'image', 'document', 'tool_use', 'thinking', 'provider_state'].includes(b.type)) {\n return `invalid block ${b.type} for role assistant`\n }\n if (b.type === 'tool_use' && !rustTrim(b.call_id ?? '')) return 'tool call without call_id'\n }\n return undefined\n}\n\n/** The tool-role message carrying one observation back to the model. */\nexport function toolObservationMessage(callId: string, observation: Observation): AiMessage {\n let text: string\n let isError: boolean\n switch (observation.kind) {\n case 'success':\n text = typeof observation.content === 'string' ? observation.content : canonicalJson(observation.content)\n isError = false\n break\n case 'error':\n text = observation.message\n isError = true\n break\n case 'cancelled':\n if (observation.effect_unknown) {\n text = `[cancelled, result unknown] ${observation.reason}`\n isError = true\n } else {\n text = `[cancelled] ${observation.reason}`\n isError = false\n }\n break\n case 'unresolved':\n text = observation.effect_unknown ? `[unresolved: result unknown] ${observation.reason}` : `[not executed] ${observation.reason}`\n isError = true\n break\n }\n const block: AiMessage['content'][number] = isError\n ? { type: 'tool_result', call_id: callId, content: [{ type: 'text', text }], is_error: true }\n : { type: 'tool_result', call_id: callId, content: [{ type: 'text', text }] }\n return { role: 'tool', content: [block] }\n}\n\nconst USAGE_COUNTERS: (keyof AiUsage)[] = [\n 'input_tokens', 'output_tokens', 'total_tokens', 'cache_read_input_tokens', 'cache_write_input_tokens',\n 'cache_write_1h_input_tokens', 'reasoning_tokens', 'image_units', 'audio_seconds', 'video_seconds', 'reference_images',\n 'request_units', 'characters', 'audio_input_tokens', 'image_input_tokens', 'audio_output_tokens', 'image_output_tokens',\n]\n\n/** Sum of two usages (`merge_usage`): counters add, `cost` adds per currency, `reported_cost` is dropped. */\nexport function mergeUsage(left: AiUsage, right: AiUsage): AiUsage {\n const out: AiUsage = {}\n for (const k of USAGE_COUNTERS) {\n const a = left[k] as number | undefined\n const b = right[k] as number | undefined\n if (a !== undefined || b !== undefined) (out as Record<string, number>)[k] = (a ?? 0) + (b ?? 0)\n }\n const cost = addCost(left.cost, right.cost)\n if (cost) out.cost = cost\n return out\n}\n\nfunction addCost(a?: AiCost, b?: AiCost): AiCost | undefined {\n if (a && b) return a.currency === b.currency ? { amount: a.amount + b.amount, currency: a.currency } : undefined\n return a ?? b\n}\n\n/** `add_usage` of the run record: input / output / total tokens and request units. */\nexport function addRecordUsage(base: AiUsage | undefined, extra: AiUsage): AiUsage {\n const cur: AiUsage = { ...(base ?? {}) }\n for (const k of ['input_tokens', 'output_tokens', 'total_tokens', 'request_units'] as const) {\n if (extra[k] !== undefined) cur[k] = (cur[k] ?? 0) + (extra[k] as number)\n }\n return cur\n}\n\nexport function argsOf(args: Record<string, JsonValue> | undefined): Record<string, JsonValue> {\n return args ?? {}\n}\n","// AICC as an `LlmClient` (Rust `AiccLlmClient`). The client is the page's own\n// `AiccClient` (`getAiccClient()`): calls run under the page's session; xllm\n// never touches it.\n//\n// Error table (same order as Rust `aicc_provider_failure` /\n// `provider_error_from_rpc`, no matching on message text):\n// quota_exhausted / quota_budget_exceeded / resource_not_permitted /\n// attribution_unavailable → refused { code }\n// quota_unavailable → transient\n// context_length_exceeded, http_status 413 → context_limit\n// timeout, retriable → transient\n// kRPC http_error: 413 → context_limit, 408 / 504 → transient,\n// 401 / 403 → refused { credentials }, other → unknown\n// transport failure → transient\n// anything else → unknown\n\nimport type {\n AiccClient, AiccError, AiToolSpec, HelperModelRequirement, LlmChatHelperRequest, LlmChatInvokeRequest,\n LlmChatInvokeResponse, LlmResponseFormat, ModelDisable,\n} from '../../aicc_client'\nimport { RPC_HTTP_ERROR_CODE, RPC_TRANSPORT_ERROR_CODE } from '../../krpc_client'\nimport type { RPCError } from '../../krpc_client'\nimport type { AiResponse, JsonValue, LlmClient, LlmInferenceRequest, ProviderFailure } from '../core/types'\nimport { LLMComputeException, providerError } from '../core/errors'\nimport { isObject } from '../core/json'\n\nexport const REFUSED_QUOTA_EXHAUSTED = 'quota_exhausted'\nexport const REFUSED_QUOTA_BUDGET_EXCEEDED = 'quota_budget_exceeded'\nexport const REFUSED_RESOURCE_NOT_PERMITTED = 'resource_not_permitted'\nexport const REFUSED_ATTRIBUTION_UNAVAILABLE = 'attribution_unavailable'\n/** The service refused the caller's credentials: sign in again, then resume. */\nexport const REFUSED_CREDENTIALS = 'credentials'\n\nconst REFUSAL_CODES = [REFUSED_QUOTA_EXHAUSTED, REFUSED_QUOTA_BUDGET_EXCEEDED, REFUSED_RESOURCE_NOT_PERMITTED, REFUSED_ATTRIBUTION_UNAVAILABLE]\n\n/** `force_json` without a schema: any JSON object (a bare `{\"type\":\"object\"}` gets `{}` from Gemini). */\nexport function anyJsonObjectSchema(): JsonValue {\n return { type: 'object', additionalProperties: true }\n}\n\nfunction refused(code: string): ProviderFailure {\n return { refused: { code } }\n}\n\n/** Failure class of an AICC error, `undefined` when the error does not say. */\nexport function aiccProviderFailure(error: Partial<AiccError>): ProviderFailure | undefined {\n const code = error.code as string | undefined\n if (code && REFUSAL_CODES.includes(code)) return refused(code)\n if (code === 'quota_unavailable') return 'transient'\n const httpStatus = isObject(error.details) ? error.details.http_status : undefined\n if (code === 'context_length_exceeded' || httpStatus === 413) return 'context_limit'\n if (code === 'timeout' || error.retriable === true) return 'transient'\n return undefined\n}\n\n/** A failed AICC call (a rejected kRPC call) as a provider error. */\nexport function providerErrorFromRpc(context: string, err: unknown): LLMComputeException {\n const message = err instanceof Error ? err.message : String(err)\n const text = `${context}: ${message}`\n // Read the structured fields of an `RPCError` without `instanceof`: the\n // page's AICC client may come from another bundle of this SDK.\n const code = typeof err === 'object' && err !== null ? (err as Partial<RPCError>).code : undefined\n if (typeof code !== 'string' || !code) return providerError('unknown', text)\n const rawData = (err as Partial<RPCError>).data\n const data = isObject(rawData) ? rawData : undefined\n const fromAicc = aiccProviderFailure({ ...(data as Partial<AiccError> | undefined), code: code as AiccError['code'] })\n if (fromAicc) return providerError(fromAicc, text)\n if (code === RPC_HTTP_ERROR_CODE) {\n const status = typeof data?.status === 'number' ? data.status : undefined\n if (status === 413) return providerError('context_limit', text)\n if (status === 408 || status === 504) return providerError('transient', text)\n if (status === 401 || status === 403) return providerError(refused(REFUSED_CREDENTIALS), text)\n return providerError('unknown', text)\n }\n if (code === RPC_TRANSPORT_ERROR_CODE) return providerError('transient', text)\n return providerError('unknown', text)\n}\n\nconst DISABLE_FEATURES: Record<string, keyof ModelDisable> = {\n tool_call: 'tool_call', json_schema: 'json_schema', web_search: 'web_search', vision: 'vision',\n image_generation: 'image_generation', streaming: 'streaming',\n}\n\nfunction aiccErrorText(e: AiccError | undefined): string {\n return e ? ` (${e.code}: ${e.message})` : ''\n}\n\n/** `LlmClient` over the page's AICC client. */\nexport class AiccLlmClient implements LlmClient {\n constructor(private readonly client: AiccClient) {}\n\n async infer(req: LlmInferenceRequest): Promise<AiResponse> {\n const tools: AiToolSpec[] = req.allow_tool_calls\n ? req.tool_specs.map(s => ({ type: 'function', name: s.name, description: s.description, args_json_schema: s.args_schema }))\n : []\n const disable: ModelDisable = {}\n for (const f of req.disable_capabilities) {\n const key = DISABLE_FEATURES[f]\n if (key) (disable as Record<string, boolean>)[key] = true\n }\n let responseFormat: LlmResponseFormat | undefined\n if (req.force_json) {\n responseFormat = req.json_schema !== undefined\n ? { type: 'json_schema', json_schema: { name: 'llm_response', schema: req.json_schema } }\n : { type: 'json_schema', json_schema: { name: 'llm_response', schema: anyJsonObjectSchema(), strict: false } }\n }\n const common = {\n messages: req.messages,\n ...(tools.length ? { tools } : {}),\n ...(responseFormat ? { response_format: responseFormat } : {}),\n ...(req.temperature !== undefined ? { temperature: req.temperature } : {}),\n ...(req.max_completion_tokens !== undefined ? { max_output_tokens: req.max_completion_tokens } : {}),\n ...(req.trace_id ? { trace_id: req.trace_id } : {}),\n execution_mode: 'immediate' as const,\n }\n const exact = req.model_alias.includes('@')\n const method = exact ? 'chat.completions.create' : 'helper.llm_chat'\n let response: LlmChatInvokeResponse\n try {\n if (exact) {\n const r: LlmChatInvokeRequest = { exact_model: req.model_alias, ...common }\n response = await this.client.chatCompletionsCreate(r)\n } else {\n const requirements: HelperModelRequirement = {}\n if (req.allow_tool_calls && tools.length > 0) requirements.tool_call = true\n if (req.force_json) requirements.json_schema = true\n const r: LlmChatHelperRequest = {\n logical_model: req.model_alias, ...common,\n ...(Object.keys(requirements).length ? { requirements } : {}),\n ...(Object.keys(disable).length ? { disable } : {}),\n }\n response = await this.client.helperLlmChat(r)\n }\n } catch (e) {\n if (e instanceof LLMComputeException) throw e\n throw providerErrorFromRpc(`aicc ${method} failed`, e)\n }\n if (response.status === 'succeeded') {\n if (!response.message) throw providerError('unknown', `aicc ${method} succeeded but message is empty`)\n const out: AiResponse = { message: response.message }\n if (response.usage) out.usage = response.usage\n if (response.cost) out.cost = response.cost\n if (response.finish_reason) out.finish_reason = response.finish_reason\n if (response.provider_task_ref) out.provider_task_ref = response.provider_task_ref\n const model = response.route_trace?.final_model\n if (model) out.extra = { model }\n return out\n }\n if (response.status === 'failed') {\n const failure = (response.error && aiccProviderFailure(response.error)) ?? 'unknown'\n throw providerError(failure,\n `aicc ${method} failed${aiccErrorText(response.error)}: task_id=${response.task_id}, event_ref=${response.event_ref ?? ''}`)\n }\n throw providerError('permanent',\n `aicc ${method} returned async task \\`${response.task_id}\\`; xllm does not poll async tasks — use a synchronous-capable model`)\n }\n}\n"],"names":["items"],"mappings":";AAKO,MAAM,4BAA4B,MAAM;AAAA,EAG7C,YAAY,OAAwB;AAC5B,UAAA,oBAAoB,KAAK,CAAC;AAChC,SAAK,OAAO;AACZ,SAAK,QAAQ;AAAA,EACf;AACF;AAEgB,SAAA,cAAc,SAA0B,SAAsC;AAC5F,SAAO,IAAI,oBAAoB,EAAE,MAAM,YAAY,SAAS,SAAS;AACvE;AAGO,SAAS,eAAe,OAAiC;AAC9D,MAAI,iBAAiB;AAAqB,WAAO,MAAM;AACvD,QAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,SAAO,EAAE,MAAM,YAAY,SAAS,WAAW,QAAQ;AACzD;AAEA,SAAS,aAAa,SAAkC;AACtD,MAAI,OAAO,YAAY;AAAU,WAAO,mBAAmB,KAAK,UAAU,QAAQ,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