buckyos 0.7.206 → 0.7.208
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/dist/cli.mjs +1 -1
- package/cli/dist/cli.mjs.map +1 -1
- package/cli/version.ts +1 -1
- package/dist/{aiws_write-eeea8ed3.js → aiws_write-825bb6ba.js} +3 -3
- package/dist/aiws_write-825bb6ba.js.map +1 -0
- package/dist/{aiws_write-47c90e76.mjs → aiws_write-83ddc6cc.mjs} +30 -2
- package/dist/aiws_write-83ddc6cc.mjs.map +1 -0
- package/dist/app-frame.cjs +1 -1
- package/dist/app-frame.cjs.map +1 -1
- package/dist/app-frame.d.ts +3 -0
- package/dist/app-frame.d.ts.map +1 -1
- package/dist/app-frame.mjs +14 -3
- package/dist/app-frame.mjs.map +1 -1
- package/dist/browser.cjs +1 -1
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +4 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.mjs +11 -6
- package/dist/browser.mjs.map +1 -1
- package/dist/{content_objid-0a095cbd.mjs → content_objid-76434848.mjs} +2 -2
- package/dist/{content_objid-0a095cbd.mjs.map → content_objid-76434848.mjs.map} +1 -1
- package/dist/{content_objid-4742308a.js → content_objid-addf9e2b.js} +2 -2
- package/dist/{content_objid-4742308a.js.map → content_objid-addf9e2b.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +11 -6
- package/dist/index.mjs.map +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +4 -0
- package/dist/node.d.ts.map +1 -1
- package/dist/node.mjs +10 -5
- package/dist/node.mjs.map +1 -1
- package/dist/sdk_core.d.ts +18 -0
- package/dist/sdk_core.d.ts.map +1 -1
- package/dist/{site_manager-91b4d899.mjs → site_manager-604ee369.mjs} +207 -141
- package/dist/site_manager-604ee369.mjs.map +1 -0
- package/dist/site_manager-70710895.js +2 -0
- package/dist/site_manager-70710895.js.map +1 -0
- package/dist/user_preferences-1d49850a.mjs +158 -0
- package/dist/user_preferences-1d49850a.mjs.map +1 -0
- package/dist/user_preferences-7288c989.js +2 -0
- package/dist/user_preferences-7288c989.js.map +1 -0
- package/dist/user_preferences.d.ts +50 -0
- package/dist/user_preferences.d.ts.map +1 -0
- package/dist/xllm/core/loop.d.ts.map +1 -1
- package/dist/xllm/core/types.d.ts +0 -2
- package/dist/xllm/core/types.d.ts.map +1 -1
- package/dist/xllm/hosts/deno/native_runtime.d.ts.map +1 -1
- package/dist/xllm/hosts/deno/native_tools.d.ts +2 -1
- package/dist/xllm/hosts/deno/native_tools.d.ts.map +1 -1
- package/dist/xllm/index.d.ts +3 -2
- package/dist/xllm/index.d.ts.map +1 -1
- package/dist/xllm/runtime/hints.d.ts +9 -4
- package/dist/xllm/runtime/hints.d.ts.map +1 -1
- package/dist/xllm/runtime/step_renderer.d.ts +4 -4
- package/dist/xllm/runtime/step_renderer.d.ts.map +1 -1
- package/dist/xllm/runtime/text_budget.d.ts +5 -0
- package/dist/xllm/runtime/text_budget.d.ts.map +1 -0
- package/dist/xllm/runtime/tool_result.d.ts +14 -1
- package/dist/xllm/runtime/tool_result.d.ts.map +1 -1
- package/dist/xllm.cjs +1 -1
- package/dist/xllm.cjs.map +1 -1
- package/dist/xllm.mjs +35 -29
- package/dist/xllm_deno.cjs +1 -1
- package/dist/xllm_deno.cjs.map +1 -1
- package/dist/xllm_deno.mjs +123 -42
- package/dist/xllm_deno.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/aiws_write-47c90e76.mjs.map +0 -1
- package/dist/aiws_write-eeea8ed3.js.map +0 -1
- package/dist/runtime_env-39e4df98.mjs +0 -44
- package/dist/runtime_env-39e4df98.mjs.map +0 -1
- package/dist/runtime_env-6396e1eb.js +0 -2
- package/dist/runtime_env-6396e1eb.js.map +0 -1
- package/dist/site_manager-716a2cf5.js +0 -2
- package/dist/site_manager-716a2cf5.js.map +0 -1
- package/dist/site_manager-91b4d899.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as canonicalJson, r as rustTrim, o as jsonEqual, L as LLMComputeException, i as isObject, m as cloneJson, t as textMessage, q as nowMs, u as textContent, c as computeErrorMessage, v as validateResponse, w as toolCalls, a as asComputeError, x as toolObservationMessage, y as mergeUsage, l as llmCorrectable, f as rustTrimEnd, X as XllmError, z as rustTextContent,
|
|
1
|
+
import { n as canonicalJson, r as rustTrim, o as jsonEqual, L as LLMComputeException, i as isObject, m as cloneJson, t as textMessage, q as nowMs, u as textContent, c as computeErrorMessage, v as validateResponse, w as toolCalls, a as asComputeError, x as toolObservationMessage, y as mergeUsage, l as llmCorrectable, f as rustTrimEnd, X as XllmError, z as rustTextContent, B as compareCodePoints, s as serdeJson, C as charOffset, D as collapseWhitespace, d as charCount, e as errorSource, E as addRecordUsage, F as refusedCode } from "./aicc-67851c41.mjs";
|
|
2
2
|
function utf8Length(s) {
|
|
3
3
|
let n = 0;
|
|
4
4
|
for (let i = 0; i < s.length; i++) {
|
|
@@ -237,7 +237,7 @@ function behaviorDecision(r) {
|
|
|
237
237
|
function stepFromResult(r) {
|
|
238
238
|
var _a;
|
|
239
239
|
const step = {
|
|
240
|
-
meta: { step_index: 0, started_at_ms: 0
|
|
240
|
+
meta: { step_index: 0, started_at_ms: 0 },
|
|
241
241
|
assistant_text: r.assistant_text,
|
|
242
242
|
report_end: r.report_end
|
|
243
243
|
};
|
|
@@ -278,7 +278,7 @@ function resultFromStep(step) {
|
|
|
278
278
|
}
|
|
279
279
|
function syntheticErrorStep(message) {
|
|
280
280
|
return {
|
|
281
|
-
meta: { step_index: 0, started_at_ms: 0
|
|
281
|
+
meta: { step_index: 0, started_at_ms: 0 },
|
|
282
282
|
assistant_text: "",
|
|
283
283
|
report_end: false,
|
|
284
284
|
action_results: [{ kind: "error", call_id: "", message }]
|
|
@@ -650,7 +650,7 @@ function prepareStep(ctx, step, startedAtMs) {
|
|
|
650
650
|
ctx.state.next_action_id += 1;
|
|
651
651
|
a.call_id = String(ctx.state.next_action_id);
|
|
652
652
|
}
|
|
653
|
-
step.meta = { step_index: stepIndex, started_at_ms: startedAtMs
|
|
653
|
+
step.meta = { step_index: stepIndex, started_at_ms: startedAtMs };
|
|
654
654
|
if (ctx.request.behavior_name)
|
|
655
655
|
step.meta.behavior_name = ctx.request.behavior_name;
|
|
656
656
|
return step;
|
|
@@ -1367,8 +1367,7 @@ class LLMContext {
|
|
|
1367
1367
|
behavior_name: snapshot.request.behavior_name || void 0,
|
|
1368
1368
|
step_index: snapshot.state.next_step_index,
|
|
1369
1369
|
started_at_ms: nowMs(),
|
|
1370
|
-
ended_at_ms: nowMs()
|
|
1371
|
-
compression_level: "full"
|
|
1370
|
+
ended_at_ms: nowMs()
|
|
1372
1371
|
},
|
|
1373
1372
|
assistant_text: result.assistant_text,
|
|
1374
1373
|
observation: result.observation,
|
|
@@ -4080,35 +4079,45 @@ class MemoryHintLedger {
|
|
|
4080
4079
|
static seeded(ns, keys) {
|
|
4081
4080
|
const l = new MemoryHintLedger();
|
|
4082
4081
|
for (const k of keys)
|
|
4083
|
-
l.mark(ns, k);
|
|
4082
|
+
l.mark(ns, k, "");
|
|
4084
4083
|
return l;
|
|
4085
4084
|
}
|
|
4086
|
-
|
|
4085
|
+
origin(ns, key) {
|
|
4087
4086
|
var _a;
|
|
4088
|
-
return (
|
|
4087
|
+
return (_a = this.inner.get(ns)) == null ? void 0 : _a.get(key);
|
|
4088
|
+
}
|
|
4089
|
+
seen(ns, key) {
|
|
4090
|
+
return this.origin(ns, key) !== void 0;
|
|
4089
4091
|
}
|
|
4090
|
-
mark(ns, key) {
|
|
4092
|
+
mark(ns, key, origin) {
|
|
4091
4093
|
let s = this.inner.get(ns);
|
|
4092
4094
|
if (!s)
|
|
4093
|
-
this.inner.set(ns, s = /* @__PURE__ */ new
|
|
4094
|
-
s.
|
|
4095
|
+
this.inner.set(ns, s = /* @__PURE__ */ new Map());
|
|
4096
|
+
s.set(key, origin);
|
|
4095
4097
|
}
|
|
4096
4098
|
clear(ns) {
|
|
4097
4099
|
this.inner.delete(ns);
|
|
4098
4100
|
}
|
|
4099
4101
|
keys(ns) {
|
|
4100
|
-
|
|
4102
|
+
var _a;
|
|
4103
|
+
return [...((_a = this.inner.get(ns)) == null ? void 0 : _a.keys()) ?? []].sort();
|
|
4101
4104
|
}
|
|
4102
4105
|
}
|
|
4103
|
-
function
|
|
4106
|
+
function dedupText(hint, origin) {
|
|
4107
|
+
const h = rustTrim(hint).replace(/\.+$/, "");
|
|
4108
|
+
return origin === "" ? `${h}; it is shown in full above.` : `${h}; same as the result of call ${origin} above.`;
|
|
4109
|
+
}
|
|
4110
|
+
function applyHints(result, ledger, callId) {
|
|
4104
4111
|
if (result.dedup) {
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
result.
|
|
4112
|
+
const origin = ledger.origin(HINT_NS_DEDUP, result.dedup.key);
|
|
4113
|
+
if (origin !== void 0) {
|
|
4114
|
+
const text = dedupText(result.dedup.hint, origin);
|
|
4115
|
+
result.output = text;
|
|
4116
|
+
result.summary = text;
|
|
4117
|
+
result.detail = origin === "" ? { dedup: result.dedup.key } : { dedup: result.dedup.key, dedup_of: origin };
|
|
4109
4118
|
delete result.partial_output;
|
|
4110
4119
|
} else {
|
|
4111
|
-
ledger.mark(HINT_NS_DEDUP, result.dedup.key);
|
|
4120
|
+
ledger.mark(HINT_NS_DEDUP, result.dedup.key, callId);
|
|
4112
4121
|
}
|
|
4113
4122
|
}
|
|
4114
4123
|
const kept = [];
|
|
@@ -4119,7 +4128,7 @@ function applyHints(result, ledger) {
|
|
|
4119
4128
|
if (key !== void 0) {
|
|
4120
4129
|
if (ledger.seen(HINT_NS_ONCE, key))
|
|
4121
4130
|
continue;
|
|
4122
|
-
ledger.mark(HINT_NS_ONCE, key);
|
|
4131
|
+
ledger.mark(HINT_NS_ONCE, key, callId);
|
|
4123
4132
|
}
|
|
4124
4133
|
kept.push(h);
|
|
4125
4134
|
}
|
|
@@ -4142,6 +4151,107 @@ ${rustTrimEnd(text)}
|
|
|
4142
4151
|
</output>
|
|
4143
4152
|
${renderHintBlock(hints)}`;
|
|
4144
4153
|
}
|
|
4154
|
+
const RESULT_BUDGET_TOKENS = 16 * 1024;
|
|
4155
|
+
const encoder = new TextEncoder();
|
|
4156
|
+
const decoder = new TextDecoder();
|
|
4157
|
+
function tokensOf$1(bytes) {
|
|
4158
|
+
return Math.ceil(bytes / 4);
|
|
4159
|
+
}
|
|
4160
|
+
function floorBoundary(b, i) {
|
|
4161
|
+
i = Math.min(i, b.length);
|
|
4162
|
+
while (i > 0 && i < b.length && (b[i] & 192) === 128)
|
|
4163
|
+
i--;
|
|
4164
|
+
return i;
|
|
4165
|
+
}
|
|
4166
|
+
function ceilBoundary(b, i) {
|
|
4167
|
+
i = Math.min(i, b.length);
|
|
4168
|
+
while (i < b.length && (b[i] & 192) === 128)
|
|
4169
|
+
i++;
|
|
4170
|
+
return i;
|
|
4171
|
+
}
|
|
4172
|
+
function clipToBudget(text, budget, more) {
|
|
4173
|
+
const b = encoder.encode(text);
|
|
4174
|
+
const tokens = tokensOf$1(b.length);
|
|
4175
|
+
if (tokens <= budget)
|
|
4176
|
+
return [text, false];
|
|
4177
|
+
const markerRoom = 96 + (more === void 0 ? 0 : encoder.encode(more).length);
|
|
4178
|
+
const keep = Math.max(0, Math.floor(b.length * budget / Math.max(tokens, 1)) - markerRoom);
|
|
4179
|
+
const headEnd = floorBoundary(b, Math.floor(keep / 2));
|
|
4180
|
+
const tailStart = Math.max(ceilBoundary(b, b.length - (keep - Math.floor(keep / 2))), headEnd);
|
|
4181
|
+
const omitted = tailStart - headEnd;
|
|
4182
|
+
const marker = more === void 0 ? `
|
|
4183
|
+
…[${omitted} bytes omitted]…
|
|
4184
|
+
` : `
|
|
4185
|
+
…[${omitted} bytes omitted; ${more}]…
|
|
4186
|
+
`;
|
|
4187
|
+
return [`${decoder.decode(b.slice(0, headEnd))}${marker}${decoder.decode(b.slice(tailStart))}`, true];
|
|
4188
|
+
}
|
|
4189
|
+
function clipToDefaultBudget(text, more) {
|
|
4190
|
+
return clipToBudget(text, RESULT_BUDGET_TOKENS, more);
|
|
4191
|
+
}
|
|
4192
|
+
const AGENT_TOOL_PROTOCOL_VERSION = "1";
|
|
4193
|
+
function asToolResult(value) {
|
|
4194
|
+
if (!isObject(value) || value.agent_tool_protocol !== AGENT_TOOL_PROTOCOL_VERSION)
|
|
4195
|
+
return void 0;
|
|
4196
|
+
const status = value.status ?? "success";
|
|
4197
|
+
if (status !== "success" && status !== "error" && status !== "pending")
|
|
4198
|
+
return void 0;
|
|
4199
|
+
return {
|
|
4200
|
+
...value,
|
|
4201
|
+
status,
|
|
4202
|
+
summary: typeof value.summary === "string" ? value.summary : "",
|
|
4203
|
+
detail: value.detail === void 0 ? {} : value.detail
|
|
4204
|
+
};
|
|
4205
|
+
}
|
|
4206
|
+
function fullText(isError, output2, detail, summary, title) {
|
|
4207
|
+
const out = output2 !== void 0 && rustTrim(output2) !== "" ? output2 : void 0;
|
|
4208
|
+
const summaryT = rustTrim(summary);
|
|
4209
|
+
const titleT = rustTrim(title);
|
|
4210
|
+
const detailText = typeof detail === "string" && rustTrim(detail) !== "" ? detail : void 0;
|
|
4211
|
+
const detailJson = () => {
|
|
4212
|
+
if (detail === void 0 || detail === null)
|
|
4213
|
+
return void 0;
|
|
4214
|
+
if (isObject(detail) && Object.keys(detail).length === 0)
|
|
4215
|
+
return void 0;
|
|
4216
|
+
return clipToDefaultBudget(canonicalJson(detail))[0];
|
|
4217
|
+
};
|
|
4218
|
+
if (isError) {
|
|
4219
|
+
if (summaryT && out !== void 0)
|
|
4220
|
+
return `${summaryT}
|
|
4221
|
+
${rustTrim(out)}`;
|
|
4222
|
+
if (summaryT)
|
|
4223
|
+
return summaryT;
|
|
4224
|
+
if (out !== void 0)
|
|
4225
|
+
return rustTrim(out);
|
|
4226
|
+
return detailText ?? (titleT || void 0) ?? detailJson() ?? "tool error";
|
|
4227
|
+
}
|
|
4228
|
+
if (out !== void 0)
|
|
4229
|
+
return out;
|
|
4230
|
+
return detailText ?? (summaryT ? summary : void 0) ?? (titleT || void 0) ?? detailJson() ?? "Success";
|
|
4231
|
+
}
|
|
4232
|
+
function observationText(r) {
|
|
4233
|
+
return fullText(r.status === "error", r.output, r.detail, r.summary, r.title ?? "");
|
|
4234
|
+
}
|
|
4235
|
+
const RESULT_BUDGET_MORE = "narrow the call (a range, a filter, less output) to see the rest";
|
|
4236
|
+
const tokensOf = (s) => Math.ceil(new TextEncoder().encode(s).length / 4);
|
|
4237
|
+
function fitResultBudget(r, budget = RESULT_BUDGET_TOKENS) {
|
|
4238
|
+
if (tokensOf(observationText(r)) <= budget)
|
|
4239
|
+
return;
|
|
4240
|
+
const summaryBudget = Math.floor(budget / 4);
|
|
4241
|
+
if (tokensOf(r.summary) > summaryBudget)
|
|
4242
|
+
r.summary = clipToBudget(r.summary, summaryBudget)[0];
|
|
4243
|
+
if (r.status === "error") {
|
|
4244
|
+
const rest = Math.max(0, budget - (tokensOf(rustTrim(r.summary)) + 1));
|
|
4245
|
+
if (r.output !== void 0)
|
|
4246
|
+
r.output = clipToBudget(r.output, rest, RESULT_BUDGET_MORE)[0];
|
|
4247
|
+
} else {
|
|
4248
|
+
r.output = clipToBudget(observationText(r), budget, RESULT_BUDGET_MORE)[0];
|
|
4249
|
+
}
|
|
4250
|
+
delete r.dedup;
|
|
4251
|
+
}
|
|
4252
|
+
function toHost(r) {
|
|
4253
|
+
return JSON.parse(JSON.stringify(r));
|
|
4254
|
+
}
|
|
4145
4255
|
function xmlEscape(s) {
|
|
4146
4256
|
return s.replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
4147
4257
|
}
|
|
@@ -4216,13 +4326,12 @@ function commandLineText(r) {
|
|
|
4216
4326
|
}
|
|
4217
4327
|
class XmlStepRenderer {
|
|
4218
4328
|
constructor(options = {}) {
|
|
4219
|
-
this.
|
|
4220
|
-
this.maxResultChars = options.maxResultChars ?? 4 * 1024;
|
|
4329
|
+
this.maxResultChars = options.maxResultChars ?? RESULT_BUDGET_TOKENS * 4;
|
|
4221
4330
|
this.timestamps = options.timestamps ?? true;
|
|
4222
4331
|
}
|
|
4223
4332
|
/** History records without wall-clock timestamps (a byte-stable prefix; hosted runs use it). */
|
|
4224
4333
|
withoutTimestamps() {
|
|
4225
|
-
return new XmlStepRenderer({
|
|
4334
|
+
return new XmlStepRenderer({ maxResultChars: this.maxResultChars, timestamps: false });
|
|
4226
4335
|
}
|
|
4227
4336
|
render(step) {
|
|
4228
4337
|
return this.renderFull(step);
|
|
@@ -4263,7 +4372,17 @@ ${records.join("\n")}
|
|
|
4263
4372
|
}
|
|
4264
4373
|
}
|
|
4265
4374
|
function output(title, body) {
|
|
4266
|
-
return { title, body,
|
|
4375
|
+
return { title, body, hints: [] };
|
|
4376
|
+
}
|
|
4377
|
+
function clipBody(input, maxChars) {
|
|
4378
|
+
if (maxChars === 0)
|
|
4379
|
+
return input;
|
|
4380
|
+
const end = charOffset(input, maxChars);
|
|
4381
|
+
if (end >= input.length)
|
|
4382
|
+
return input;
|
|
4383
|
+
const total = [...input].length;
|
|
4384
|
+
return `${rustTrimEnd(input.slice(0, end))}
|
|
4385
|
+
…[${total - maxChars} characters omitted by the renderer]`;
|
|
4267
4386
|
}
|
|
4268
4387
|
function clip(input, maxChars) {
|
|
4269
4388
|
if (maxChars === 0)
|
|
@@ -4316,14 +4435,14 @@ function renderOneActionResultFull(action, obs, maxBodyChars) {
|
|
|
4316
4435
|
case "success": {
|
|
4317
4436
|
const view = toolResultViewFromHost(obs.host);
|
|
4318
4437
|
if (view)
|
|
4319
|
-
return withActionTitleId(action, renderToolResultFull(action, view, maxBodyChars
|
|
4320
|
-
const
|
|
4321
|
-
return withActionTitleId(action, output(`Run ${command}`, formatActionResultBody(body
|
|
4438
|
+
return withActionTitleId(action, renderToolResultFull(action, view, maxBodyChars));
|
|
4439
|
+
const body = clipBody(stringifyContent(obs.content), maxBodyChars);
|
|
4440
|
+
return withActionTitleId(action, output(`Run ${command}`, formatActionResultBody(body)));
|
|
4322
4441
|
}
|
|
4323
4442
|
case "error": {
|
|
4324
4443
|
const view = toolResultViewFromHost(obs.host);
|
|
4325
4444
|
if (view)
|
|
4326
|
-
return withActionTitleId(action, renderToolResultFull(action, view, maxBodyChars
|
|
4445
|
+
return withActionTitleId(action, renderToolResultFull(action, view, maxBodyChars));
|
|
4327
4446
|
const [msg] = clip(obs.message, Math.max(maxBodyChars, 1024));
|
|
4328
4447
|
return withActionTitleId(action, output(`Run ${command}`, `Error: ${msg}`));
|
|
4329
4448
|
}
|
|
@@ -4343,18 +4462,17 @@ function renderOneActionResultCompact(action, obs, maxBodyChars) {
|
|
|
4343
4462
|
case "success": {
|
|
4344
4463
|
const view = toolResultViewFromHost(obs.host);
|
|
4345
4464
|
if (view)
|
|
4346
|
-
return withActionTitleId(action, renderToolResultCompact(action, view, maxBodyChars
|
|
4347
|
-
const
|
|
4348
|
-
const body = rustTrim(clipped);
|
|
4465
|
+
return withActionTitleId(action, renderToolResultCompact(action, view, maxBodyChars));
|
|
4466
|
+
const body = rustTrim(clipBody(stringifyContent(obs.content), maxBodyChars));
|
|
4349
4467
|
return withActionTitleId(
|
|
4350
4468
|
action,
|
|
4351
|
-
output(`Run ${command}`, body === "" ? "Success" : formatActionResultBody(body
|
|
4469
|
+
output(`Run ${command}`, body === "" ? "Success" : formatActionResultBody(body))
|
|
4352
4470
|
);
|
|
4353
4471
|
}
|
|
4354
4472
|
case "error": {
|
|
4355
4473
|
const view = toolResultViewFromHost(obs.host);
|
|
4356
4474
|
if (view)
|
|
4357
|
-
return withActionTitleId(action, renderToolResultCompact(action, view, maxBodyChars
|
|
4475
|
+
return withActionTitleId(action, renderToolResultCompact(action, view, maxBodyChars));
|
|
4358
4476
|
const [msg] = clip(obs.message, maxBodyChars);
|
|
4359
4477
|
return withActionTitleId(action, output(`Run ${command}`, `Error: ${msg}`));
|
|
4360
4478
|
}
|
|
@@ -4374,14 +4492,14 @@ function renderUnpairedActionResult(obs, maxBodyChars) {
|
|
|
4374
4492
|
case "success": {
|
|
4375
4493
|
const view = toolResultViewFromHost(obs.host);
|
|
4376
4494
|
if (view)
|
|
4377
|
-
return renderToolResultFullPlaceholder(view, maxBodyChars
|
|
4378
|
-
const
|
|
4379
|
-
return output("Step result", formatActionResultBody(body
|
|
4495
|
+
return renderToolResultFullPlaceholder(view, maxBodyChars);
|
|
4496
|
+
const body = clipBody(stringifyContent(obs.content), maxBodyChars);
|
|
4497
|
+
return output("Step result", formatActionResultBody(body));
|
|
4380
4498
|
}
|
|
4381
4499
|
case "error": {
|
|
4382
4500
|
const view = toolResultViewFromHost(obs.host);
|
|
4383
4501
|
if (view)
|
|
4384
|
-
return renderToolResultFullPlaceholder(view, maxBodyChars
|
|
4502
|
+
return renderToolResultFullPlaceholder(view, maxBodyChars);
|
|
4385
4503
|
const [msg] = clip(obs.message, Math.max(maxBodyChars, 1024));
|
|
4386
4504
|
return output("Step error", `Error: ${msg}`);
|
|
4387
4505
|
}
|
|
@@ -4399,18 +4517,17 @@ function unresolvedBody(effectUnknown, body) {
|
|
|
4399
4517
|
const label = effectUnknown ? "Unresolved (result unknown, side effects unconfirmed)" : "Not executed";
|
|
4400
4518
|
return body === "" ? label : `${label}: ${body}`;
|
|
4401
4519
|
}
|
|
4402
|
-
function renderToolResultFull(action, result, maxBodyChars
|
|
4403
|
-
const rendered = renderToolResultFullPlaceholder(result, maxBodyChars
|
|
4520
|
+
function renderToolResultFull(action, result, maxBodyChars) {
|
|
4521
|
+
const rendered = renderToolResultFullPlaceholder(result, maxBodyChars);
|
|
4404
4522
|
rendered.title = toolResultTitle(action, result);
|
|
4405
4523
|
rendered.hints = hintTexts(result);
|
|
4406
4524
|
return rendered;
|
|
4407
4525
|
}
|
|
4408
|
-
function renderToolResultFullPlaceholder(result, maxBodyChars
|
|
4409
|
-
const
|
|
4410
|
-
|
|
4411
|
-
return { title: toolResultTitle(void 0, result), body: formatActionResultBody(clipped, fallbackTruncated || wasClipped), fence, hints: [] };
|
|
4526
|
+
function renderToolResultFullPlaceholder(result, maxBodyChars) {
|
|
4527
|
+
const body = result.status === "pending" ? toolResultPendingBody(result) : fullText(result.status === "error", result.output, result.detail, result.summary, result.title);
|
|
4528
|
+
return { title: toolResultTitle(void 0, result), body: formatActionResultBody(clipBody(body, maxBodyChars)), hints: [] };
|
|
4412
4529
|
}
|
|
4413
|
-
function renderToolResultCompact(action, result, maxBodyChars
|
|
4530
|
+
function renderToolResultCompact(action, result, maxBodyChars) {
|
|
4414
4531
|
const title = toolResultTitle(action, result);
|
|
4415
4532
|
let body;
|
|
4416
4533
|
if (result.status === "pending")
|
|
@@ -4419,8 +4536,7 @@ function renderToolResultCompact(action, result, maxBodyChars, fallbackTruncated
|
|
|
4419
4536
|
body = toolResultErrorBody(result);
|
|
4420
4537
|
else
|
|
4421
4538
|
body = rustTrim(result.summary) || rustTrim(result.title) || "Success";
|
|
4422
|
-
|
|
4423
|
-
return output(title, formatActionResultBody(clipped, fallbackTruncated || wasClipped));
|
|
4539
|
+
return output(title, formatActionResultBody(clipBody(body, maxBodyChars)));
|
|
4424
4540
|
}
|
|
4425
4541
|
function toolResultTitle(action, result) {
|
|
4426
4542
|
const title = rustTrim(result.title);
|
|
@@ -4431,25 +4547,6 @@ function toolResultTitle(action, result) {
|
|
|
4431
4547
|
return rustTrim(command);
|
|
4432
4548
|
return action ? `Run ${actionCommandText(action)}` : "Step result";
|
|
4433
4549
|
}
|
|
4434
|
-
function toolResultFullBody(result, emptyFallback) {
|
|
4435
|
-
if (result.output !== void 0) {
|
|
4436
|
-
const out = rustTrimEnd(result.output);
|
|
4437
|
-
if (out !== "")
|
|
4438
|
-
return [out, "output"];
|
|
4439
|
-
}
|
|
4440
|
-
if (result.detail !== void 0) {
|
|
4441
|
-
if (typeof result.detail === "string")
|
|
4442
|
-
return [rustTrimEnd(result.detail), "output"];
|
|
4443
|
-
return [serdeJson(result.detail, true), "json"];
|
|
4444
|
-
}
|
|
4445
|
-
const summary = rustTrim(result.summary);
|
|
4446
|
-
if (summary !== "")
|
|
4447
|
-
return [summary, "output"];
|
|
4448
|
-
const title = rustTrim(result.title);
|
|
4449
|
-
if (title !== "")
|
|
4450
|
-
return [title, "output"];
|
|
4451
|
-
return [emptyFallback, "output"];
|
|
4452
|
-
}
|
|
4453
4550
|
function toolResultErrorBody(result) {
|
|
4454
4551
|
const output2 = result.output === void 0 ? "" : rustTrim(result.output);
|
|
4455
4552
|
const lines2 = [rustTrim(result.summary) || output2 || rustTrim(result.title) || "Error"];
|
|
@@ -4471,11 +4568,8 @@ function toolResultPendingBody(result) {
|
|
|
4471
4568
|
${partial}`);
|
|
4472
4569
|
return lines2.join("\n");
|
|
4473
4570
|
}
|
|
4474
|
-
function formatActionResultBody(body
|
|
4475
|
-
|
|
4476
|
-
if (truncated)
|
|
4477
|
-
s += "\n[truncated]";
|
|
4478
|
-
return s;
|
|
4571
|
+
function formatActionResultBody(body) {
|
|
4572
|
+
return rustTrimEnd(body) || "Success";
|
|
4479
4573
|
}
|
|
4480
4574
|
function cancelledLabel(effectUnknown) {
|
|
4481
4575
|
return effectUnknown ? "Cancelled (result unknown)" : "Cancelled";
|
|
@@ -4546,7 +4640,7 @@ function renderInheritedStepRecord(step, timestamps) {
|
|
|
4546
4640
|
const report = reportText === "" ? "" : `<report end="${step.report_end}"${outcome}>${escapeXmlText(reportText)}</report>
|
|
4547
4641
|
`;
|
|
4548
4642
|
const times = timestamps ? ` started_at_ms="${step.meta.started_at_ms}" ended_at_ms="${step.meta.ended_at_ms ?? ""}"` : "";
|
|
4549
|
-
return `<step_record behavior="${step.meta.behavior_name ?? ""}" index="${step.meta.step_index}"${times}
|
|
4643
|
+
return `<step_record behavior="${step.meta.behavior_name ?? ""}" index="${step.meta.step_index}"${times}>
|
|
4550
4644
|
<observation>${observation}</observation>
|
|
4551
4645
|
<intent>${thought}</intent>
|
|
4552
4646
|
${report}<actions>
|
|
@@ -4563,7 +4657,7 @@ function renderHistoryActionsCompact(step, maxBodyChars) {
|
|
|
4563
4657
|
const part = renderOneActionResultCompact(actions[i], results[i], maxBodyChars);
|
|
4564
4658
|
parts.push(`- ${part.title}
|
|
4565
4659
|
|
|
4566
|
-
|
|
4660
|
+
\`\`\`output
|
|
4567
4661
|
${part.body}
|
|
4568
4662
|
\`\`\``);
|
|
4569
4663
|
}
|
|
@@ -5406,7 +5500,7 @@ class XllmRun {
|
|
|
5406
5500
|
}
|
|
5407
5501
|
const manager = await rebuildToolset(record, runtime, deps.tasks, store.runDir(runId));
|
|
5408
5502
|
for (const key of record.hints_once ?? [])
|
|
5409
|
-
manager.hintLedger().mark(HINT_NS_ONCE, key);
|
|
5503
|
+
manager.hintLedger().mark(HINT_NS_ONCE, key, "");
|
|
5410
5504
|
if (limits.max_tokens !== void 0)
|
|
5411
5505
|
record.config.limits.max_tokens = limits.max_tokens;
|
|
5412
5506
|
if (limits.timeout_secs !== void 0)
|
|
@@ -6027,40 +6121,6 @@ function classifyError(err) {
|
|
|
6027
6121
|
function unresolvedReason(tool) {
|
|
6028
6122
|
return `the \`${tool}\` call was dispatched before the previous executor stopped; its effect is unknown. Do not assume it succeeded or failed — check the actual state before repeating it.`;
|
|
6029
6123
|
}
|
|
6030
|
-
const AGENT_TOOL_PROTOCOL_VERSION = "1";
|
|
6031
|
-
function asToolResult(value) {
|
|
6032
|
-
if (!isObject(value) || value.agent_tool_protocol !== AGENT_TOOL_PROTOCOL_VERSION)
|
|
6033
|
-
return void 0;
|
|
6034
|
-
const status = value.status ?? "success";
|
|
6035
|
-
if (status !== "success" && status !== "error" && status !== "pending")
|
|
6036
|
-
return void 0;
|
|
6037
|
-
return {
|
|
6038
|
-
...value,
|
|
6039
|
-
status,
|
|
6040
|
-
summary: typeof value.summary === "string" ? value.summary : "",
|
|
6041
|
-
detail: value.detail === void 0 ? {} : value.detail
|
|
6042
|
-
};
|
|
6043
|
-
}
|
|
6044
|
-
function observationText(r) {
|
|
6045
|
-
if (r.status === "error") {
|
|
6046
|
-
const summary = rustTrim(r.summary);
|
|
6047
|
-
const output2 = rustTrim(r.output ?? "") || void 0;
|
|
6048
|
-
if (summary && output2)
|
|
6049
|
-
return `${summary}
|
|
6050
|
-
${output2}`;
|
|
6051
|
-
if (summary)
|
|
6052
|
-
return summary;
|
|
6053
|
-
if (output2)
|
|
6054
|
-
return output2;
|
|
6055
|
-
return "tool error";
|
|
6056
|
-
}
|
|
6057
|
-
if (r.output !== void 0 && rustTrim(r.output))
|
|
6058
|
-
return r.output;
|
|
6059
|
-
return rustTrim(r.summary) ? r.summary : canonicalJson(r.detail);
|
|
6060
|
-
}
|
|
6061
|
-
function toHost(r) {
|
|
6062
|
-
return JSON.parse(JSON.stringify(r));
|
|
6063
|
-
}
|
|
6064
6124
|
const MAX_IN_TOOL_WAIT_MS = 30 * 6e4;
|
|
6065
6125
|
const DEFAULT_TASK_WAIT_MS = 25e3;
|
|
6066
6126
|
function followupHint(f, taskId, cancellable) {
|
|
@@ -6297,7 +6357,7 @@ class SiteToolManager {
|
|
|
6297
6357
|
const text = resultText(settled.ok);
|
|
6298
6358
|
return { kind: "success", call_id: callId, content: text, bytes: utf8Length(text), truncated: false };
|
|
6299
6359
|
}
|
|
6300
|
-
const observation = envelope.status === "pending" ? await this.waitPending(call.name, callId, envelope, ctx) : envelopeObservation(callId, envelope, applyHints(envelope, this.ledger));
|
|
6360
|
+
const observation = envelope.status === "pending" ? await this.waitPending(call.name, callId, envelope, ctx) : (fitResultBudget(envelope), envelopeObservation(callId, envelope, applyHints(envelope, this.ledger, callId)));
|
|
6301
6361
|
const host = observation.kind === "success" || observation.kind === "error" ? observation.host : void 0;
|
|
6302
6362
|
const taskId = isObject(host) && typeof host.task_id === "string" ? rustTrim(host.task_id) : "";
|
|
6303
6363
|
if (taskId)
|
|
@@ -6374,38 +6434,44 @@ export {
|
|
|
6374
6434
|
isIdempotent as a7,
|
|
6375
6435
|
AGENT_TOOL_PROTOCOL_VERSION as a8,
|
|
6376
6436
|
asToolResult as a9,
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6437
|
+
followupGeneralHint as aA,
|
|
6438
|
+
followupHint as aB,
|
|
6439
|
+
inCallWaitMs as aC,
|
|
6440
|
+
resultView as aD,
|
|
6441
|
+
taskStateObservation as aE,
|
|
6442
|
+
waitUntilMs as aF,
|
|
6443
|
+
TimeoutLlmClient as aG,
|
|
6444
|
+
normalizePath as aH,
|
|
6445
|
+
PLANNED_RUNTIME_KINDS as aI,
|
|
6446
|
+
BUILTIN_TOOL_GROUP_BASH as aJ,
|
|
6447
|
+
BUILTIN_TOOL_GROUP_BASH_CORE as aK,
|
|
6448
|
+
resolveConfigPath as aL,
|
|
6449
|
+
fitResultBudget as aa,
|
|
6450
|
+
fullText as ab,
|
|
6451
|
+
observationText as ac,
|
|
6452
|
+
toHost as ad,
|
|
6453
|
+
RESULT_BUDGET_TOKENS as ae,
|
|
6454
|
+
clipToBudget as af,
|
|
6455
|
+
clipToDefaultBudget as ag,
|
|
6456
|
+
XmlStepRenderer as ah,
|
|
6457
|
+
toolResultViewFromHost as ai,
|
|
6458
|
+
LlmSummarizeCompressor as aj,
|
|
6459
|
+
SUMMARIZE_MODEL_ALIAS as ak,
|
|
6460
|
+
compactionTargetTokens as al,
|
|
6461
|
+
compress as am,
|
|
6462
|
+
compressHistory as an,
|
|
6463
|
+
compressOptions as ao,
|
|
6464
|
+
isSummaryMessage as ap,
|
|
6465
|
+
parseSummaryMessage as aq,
|
|
6466
|
+
summaryMessage as ar,
|
|
6467
|
+
summaryModel as as,
|
|
6468
|
+
HINT_NS_DEDUP as at,
|
|
6469
|
+
HINT_NS_ONCE as au,
|
|
6470
|
+
MemoryHintLedger as av,
|
|
6471
|
+
applyHints as aw,
|
|
6472
|
+
dedupText as ax,
|
|
6473
|
+
renderHintBlock as ay,
|
|
6474
|
+
renderWithHints as az,
|
|
6409
6475
|
SNAPSHOT_FORMAT_VERSION as b,
|
|
6410
6476
|
stateFromRequest as c,
|
|
6411
6477
|
describeToolSource as d,
|
|
@@ -6432,4 +6498,4 @@ export {
|
|
|
6432
6498
|
assemblePrompt as y,
|
|
6433
6499
|
RUNTIME_PROTOCOL_VERSION as z
|
|
6434
6500
|
};
|
|
6435
|
-
//# sourceMappingURL=site_manager-
|
|
6501
|
+
//# sourceMappingURL=site_manager-604ee369.mjs.map
|