blun-king-cli 9.1.640 → 9.1.642
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/CHANGELOG.md +21 -0
- package/bin/blun.js +0 -0
- package/bin/core-bootstrap.js +0 -0
- package/bin/king.js +0 -0
- package/bin/launcher-mode.js +0 -0
- package/bin/launcher-runtime.js +0 -0
- package/bin/managed-node.js +0 -0
- package/bin/native-command-runner.js +0 -0
- package/bin/native-module-repair.js +0 -0
- package/bin/node-runtime.js +0 -0
- package/bin/node-version.js +0 -0
- package/bin/plugin-bootstrap.js +0 -0
- package/bin/private-paths.js +0 -0
- package/bin/standard-tools-bootstrap.js +0 -0
- package/bin/update-copy.js +0 -0
- package/bin/update-lease.js +0 -0
- package/bin/update-notice.js +0 -0
- package/blun.mjs +1232 -142
- package/package.json +1 -1
- package/telegram-plugin/dist/bridge.mjs +8 -0
- package/worker-host.mjs +300 -60
package/worker-host.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// BLUN_BUILD_INPUT_SHA256:
|
|
2
|
+
// BLUN_BUILD_INPUT_SHA256:e50c78300e52dc6fc7d8003478fe2fa01fe7fdff8b1a749e108e6627de244e7e
|
|
3
3
|
/*! wasm-webp 0.1.0
|
|
4
4
|
MIT License
|
|
5
5
|
|
|
@@ -21308,7 +21308,7 @@ const FLAG_DEFINITIONS = [
|
|
|
21308
21308
|
title: "Session queue policies",
|
|
21309
21309
|
description: "Apply explicitly persisted session queue admission rules.",
|
|
21310
21310
|
env: "BLUN_EXPERIMENTAL_QUEUE_POLICIES",
|
|
21311
|
-
default:
|
|
21311
|
+
default: true,
|
|
21312
21312
|
surface: "core"
|
|
21313
21313
|
},
|
|
21314
21314
|
{
|
|
@@ -29638,6 +29638,59 @@ var DenyAllPermissionPolicy = class {
|
|
|
29638
29638
|
};
|
|
29639
29639
|
}
|
|
29640
29640
|
};
|
|
29641
|
+
var InputControl = class {
|
|
29642
|
+
epoch = 0;
|
|
29643
|
+
stopped = false;
|
|
29644
|
+
provider;
|
|
29645
|
+
preparations = /* @__PURE__ */ new Set();
|
|
29646
|
+
listeners = /* @__PURE__ */ new Set();
|
|
29647
|
+
onChange(listener) {
|
|
29648
|
+
this.listeners.add(listener);
|
|
29649
|
+
return () => {
|
|
29650
|
+
this.listeners.delete(listener);
|
|
29651
|
+
};
|
|
29652
|
+
}
|
|
29653
|
+
changed(stop = false) {
|
|
29654
|
+
this.epoch++;
|
|
29655
|
+
this.stopped ||= stop;
|
|
29656
|
+
this.provider?.abort(new DOMException("INPUT_SUPERSEDED", "AbortError"));
|
|
29657
|
+
for (const controller of this.preparations) controller.abort(new DOMException("INPUT_SUPERSEDED", "AbortError"));
|
|
29658
|
+
for (const listener of this.listeners) listener();
|
|
29659
|
+
}
|
|
29660
|
+
async prepare(signal, operation) {
|
|
29661
|
+
const controller = new AbortController();
|
|
29662
|
+
this.preparations.add(controller);
|
|
29663
|
+
const preparationSignal = AbortSignal.any([signal, controller.signal]);
|
|
29664
|
+
try {
|
|
29665
|
+
return await abortable(Promise.resolve().then(() => {
|
|
29666
|
+
preparationSignal.throwIfAborted();
|
|
29667
|
+
return operation(preparationSignal);
|
|
29668
|
+
}), preparationSignal);
|
|
29669
|
+
} finally {
|
|
29670
|
+
this.preparations.delete(controller);
|
|
29671
|
+
}
|
|
29672
|
+
}
|
|
29673
|
+
beginProvider() {
|
|
29674
|
+
const controller = new AbortController();
|
|
29675
|
+
this.provider = controller;
|
|
29676
|
+
return controller;
|
|
29677
|
+
}
|
|
29678
|
+
endProvider(controller) {
|
|
29679
|
+
if (this.provider === controller) this.provider = void 0;
|
|
29680
|
+
}
|
|
29681
|
+
};
|
|
29682
|
+
var controls = /* @__PURE__ */ new WeakMap();
|
|
29683
|
+
function inputControl(signal) {
|
|
29684
|
+
let control = controls.get(signal);
|
|
29685
|
+
if (control === void 0) {
|
|
29686
|
+
control = new InputControl();
|
|
29687
|
+
controls.set(signal, control);
|
|
29688
|
+
}
|
|
29689
|
+
return control;
|
|
29690
|
+
}
|
|
29691
|
+
function inheritInputControl(signal, control) {
|
|
29692
|
+
if (control !== void 0) controls.set(signal, control);
|
|
29693
|
+
}
|
|
29641
29694
|
function migrateToolCall(toolCall) {
|
|
29642
29695
|
const { function: fn, ...rest } = toolCall;
|
|
29643
29696
|
return {
|
|
@@ -29924,8 +29977,11 @@ var FileSystemAgentRecordPersistence = class {
|
|
|
29924
29977
|
this.shouldClear = false;
|
|
29925
29978
|
const content = (this.options.blobStore !== void 0 ? await Promise.all(batch.map((record) => this.options.blobStore.offload(record))) : batch).map((e) => JSON.stringify(e) + "\n").join("");
|
|
29926
29979
|
const directory = dirname$3(this.filePath);
|
|
29927
|
-
await mkdir(directory, {
|
|
29928
|
-
|
|
29980
|
+
await mkdir(directory, {
|
|
29981
|
+
recursive: true,
|
|
29982
|
+
mode: 448
|
|
29983
|
+
});
|
|
29984
|
+
const fh = await open(this.filePath, shouldClear ? "w" : "a", 384);
|
|
29929
29985
|
try {
|
|
29930
29986
|
const before = await fh.stat();
|
|
29931
29987
|
if (shouldClear || before.size === 0) this.persistedRecordCount = 0;
|
|
@@ -183420,7 +183476,13 @@ function getSubagentExecutionCompletion(handle) {
|
|
|
183420
183476
|
var SessionSubagentHost = class {
|
|
183421
183477
|
session;
|
|
183422
183478
|
ownerAgentId;
|
|
183423
|
-
|
|
183479
|
+
inputLeases = /* @__PURE__ */ new WeakMap();
|
|
183480
|
+
assertInputLease(options) {
|
|
183481
|
+
const lease = this.inputLeases.get(options);
|
|
183482
|
+
if (lease?.active?.runInBackground) return;
|
|
183483
|
+
if (lease !== void 0 && (lease.control.stopped || lease.control.epoch !== lease.epoch)) throw new DOMException("INPUT_SUPERSEDED", "AbortError");
|
|
183484
|
+
}
|
|
183485
|
+
admissionClosed = false;
|
|
183424
183486
|
operations = new ExecutionLedger();
|
|
183425
183487
|
childExecutions = new ExecutionLedger();
|
|
183426
183488
|
preparedDisposers = /* @__PURE__ */ new Set();
|
|
@@ -183455,8 +183517,16 @@ var SessionSubagentHost = class {
|
|
|
183455
183517
|
assertAdmissionOpen() {
|
|
183456
183518
|
if (this.admissionClosed) throw new Error("Subagent admission is closed for quiescence");
|
|
183457
183519
|
}
|
|
183458
|
-
runOperation(id, operation) {
|
|
183520
|
+
runOperation(id, operation, input) {
|
|
183459
183521
|
this.assertAdmissionOpen();
|
|
183522
|
+
if (input !== void 0) {
|
|
183523
|
+
const control = inputControl(input.signal);
|
|
183524
|
+
this.inputLeases.set(input, {
|
|
183525
|
+
control,
|
|
183526
|
+
epoch: control.epoch
|
|
183527
|
+
});
|
|
183528
|
+
this.assertInputLease(input);
|
|
183529
|
+
}
|
|
183460
183530
|
const completion = operation();
|
|
183461
183531
|
this.operations.track(id, completion);
|
|
183462
183532
|
return completion;
|
|
@@ -183490,7 +183560,7 @@ var SessionSubagentHost = class {
|
|
|
183490
183560
|
return this.session.getReadyAgent(currentId);
|
|
183491
183561
|
}
|
|
183492
183562
|
async spawn(options) {
|
|
183493
|
-
return this.runOperation("spawn", () => this.spawnInner(options));
|
|
183563
|
+
return this.runOperation("spawn", () => this.spawnInner(options), options);
|
|
183494
183564
|
}
|
|
183495
183565
|
async spawnInner(options) {
|
|
183496
183566
|
options.signal.throwIfAborted();
|
|
@@ -183522,7 +183592,7 @@ var SessionSubagentHost = class {
|
|
|
183522
183592
|
});
|
|
183523
183593
|
}
|
|
183524
183594
|
async resume(agentId, options) {
|
|
183525
|
-
return this.runOperation("resume", () => this.resumeInner(agentId, options));
|
|
183595
|
+
return this.runOperation("resume", () => this.resumeInner(agentId, options), options);
|
|
183526
183596
|
}
|
|
183527
183597
|
async resumeInner(agentId, options) {
|
|
183528
183598
|
options.signal.throwIfAborted();
|
|
@@ -183549,7 +183619,7 @@ var SessionSubagentHost = class {
|
|
|
183549
183619
|
});
|
|
183550
183620
|
}
|
|
183551
183621
|
async retry(agentId, options) {
|
|
183552
|
-
return this.runOperation("retry", () => this.retryInner(agentId, options));
|
|
183622
|
+
return this.runOperation("retry", () => this.retryInner(agentId, options), options);
|
|
183553
183623
|
}
|
|
183554
183624
|
async retryInner(agentId, options) {
|
|
183555
183625
|
options.signal.throwIfAborted();
|
|
@@ -183561,6 +183631,7 @@ var SessionSubagentHost = class {
|
|
|
183561
183631
|
modelAlias: parent.config.modelAlias,
|
|
183562
183632
|
actionStyle: parent.config.actionStyle
|
|
183563
183633
|
});
|
|
183634
|
+
this.assertInputLease(runOptions);
|
|
183564
183635
|
this.emitSubagentStarted(parent, agentId);
|
|
183565
183636
|
if (child.turn.retry("agent-host") === null) throw new Error(`Agent instance "${agentId}" could not start a retry turn`);
|
|
183566
183637
|
this.observeFirstRequest(child, runOptions);
|
|
@@ -183627,7 +183698,7 @@ var SessionSubagentHost = class {
|
|
|
183627
183698
|
const { parent, child, profileName } = await this.ensureIdleSubagent(agentId, token);
|
|
183628
183699
|
signal?.throwIfAborted();
|
|
183629
183700
|
const source = child.records.fileSource;
|
|
183630
|
-
if (source === void 0 || resolve(source.path) !== wire || source.protocolVersion !== "1.4" || child.context.history.length === 0 || child.config.systemPrompt.length === 0) throw new Error("Preserved subagent context could not be verified.");
|
|
183701
|
+
if (source === void 0 || resolve(source.path$1) !== wire || source.protocolVersion !== "1.4" || child.context.history.length === 0 || child.config.systemPrompt.length === 0) throw new Error("Preserved subagent context could not be verified.");
|
|
183631
183702
|
await sourceReference.refreshAfterReplay();
|
|
183632
183703
|
this.assertAdmissionOpen();
|
|
183633
183704
|
const reference = createHash("sha256").update(JSON.stringify([
|
|
@@ -183675,7 +183746,7 @@ var SessionSubagentHost = class {
|
|
|
183675
183746
|
completion,
|
|
183676
183747
|
update: (message) => this.updateActiveRun(agentId, completion, message)
|
|
183677
183748
|
});
|
|
183678
|
-
})
|
|
183749
|
+
}, options)
|
|
183679
183750
|
};
|
|
183680
183751
|
} catch (error) {
|
|
183681
183752
|
await dispose();
|
|
@@ -183763,6 +183834,7 @@ var SessionSubagentHost = class {
|
|
|
183763
183834
|
}
|
|
183764
183835
|
runWithActiveChild(childId, options, run) {
|
|
183765
183836
|
this.assertAdmissionOpen();
|
|
183837
|
+
this.assertInputLease(options);
|
|
183766
183838
|
if (this.activeChildren.has(childId)) throw new Error(`Agent instance "${childId}" is already running`);
|
|
183767
183839
|
const controller = new AbortController();
|
|
183768
183840
|
const unlinkAbortSignal = linkAbortSignal(options.signal, controller);
|
|
@@ -183771,10 +183843,22 @@ var SessionSubagentHost = class {
|
|
|
183771
183843
|
runInBackground: options.runInBackground
|
|
183772
183844
|
};
|
|
183773
183845
|
this.activeChildren.set(childId, active);
|
|
183774
|
-
const
|
|
183846
|
+
const runOptions = {
|
|
183775
183847
|
...options,
|
|
183776
183848
|
signal: controller.signal
|
|
183777
|
-
}
|
|
183849
|
+
};
|
|
183850
|
+
const lease = this.inputLeases.get(options);
|
|
183851
|
+
if (lease !== void 0) {
|
|
183852
|
+
lease.active = active;
|
|
183853
|
+
this.inputLeases.set(runOptions, lease);
|
|
183854
|
+
}
|
|
183855
|
+
const unlinkInput = lease?.control.onChange(() => {
|
|
183856
|
+
if (active.runInBackground) return;
|
|
183857
|
+
const child = this.session.getReadyAgent(childId);
|
|
183858
|
+
if (child !== void 0) child.turn.stop(child.turn.currentId);
|
|
183859
|
+
});
|
|
183860
|
+
const completion = run(runOptions).finally(() => {
|
|
183861
|
+
unlinkInput?.();
|
|
183778
183862
|
unlinkAbortSignal();
|
|
183779
183863
|
if (this.activeChildren.get(childId) === active) this.activeChildren.delete(childId);
|
|
183780
183864
|
});
|
|
@@ -183800,6 +183884,7 @@ var SessionSubagentHost = class {
|
|
|
183800
183884
|
}
|
|
183801
183885
|
async runPromptTurn(parent, childId, child, profileName, options) {
|
|
183802
183886
|
options.signal.throwIfAborted();
|
|
183887
|
+
this.assertInputLease(options);
|
|
183803
183888
|
await this.triggerSubagentStart(parent, profileName, options.prompt, options.signal);
|
|
183804
183889
|
options.signal.throwIfAborted();
|
|
183805
183890
|
let childPrompt = options.prompt;
|
|
@@ -183807,6 +183892,7 @@ var SessionSubagentHost = class {
|
|
|
183807
183892
|
const gitContext = await collectGitContext(child.kaos, child.config.cwd);
|
|
183808
183893
|
if (gitContext) childPrompt = `${gitContext}\n\n${childPrompt}`;
|
|
183809
183894
|
}
|
|
183895
|
+
this.assertInputLease(options);
|
|
183810
183896
|
this.emitSubagentStarted(parent, childId);
|
|
183811
183897
|
if (child.turn.prompt([{
|
|
183812
183898
|
type: "text",
|
|
@@ -183822,6 +183908,7 @@ var SessionSubagentHost = class {
|
|
|
183822
183908
|
while (remainingContinuations > 0 && result.length < SUMMARY_MIN_LENGTH) {
|
|
183823
183909
|
remainingContinuations -= 1;
|
|
183824
183910
|
options.signal.throwIfAborted();
|
|
183911
|
+
this.assertInputLease(options);
|
|
183825
183912
|
child.turn.prompt([{
|
|
183826
183913
|
type: "text",
|
|
183827
183914
|
text: summary_continuation_default
|
|
@@ -247986,6 +248073,11 @@ async function prepareSkippedToolCall(step, call) {
|
|
|
247986
248073
|
await dispatchToolCall(step, call, call.args);
|
|
247987
248074
|
return makeResolvedToolCallTask(makeErrorToolResult(call, call.args, output));
|
|
247988
248075
|
}
|
|
248076
|
+
function waitForPreparationBoundary(step, operation) {
|
|
248077
|
+
if (step.canStart?.() === false) return Promise.reject(new DOMException("INPUT_SUPERSEDED", "AbortError"));
|
|
248078
|
+
if (step.inputControl === void 0) return waitForToolBoundary(step, () => operation(step.signal));
|
|
248079
|
+
return step.inputControl.prepare(step.signal, (signal) => operation(signal));
|
|
248080
|
+
}
|
|
247989
248081
|
function waitForToolBoundary(step, operation) {
|
|
247990
248082
|
if (step.programmaticParentCallId === void 0) return Promise.resolve(operation());
|
|
247991
248083
|
step.signal.throwIfAborted();
|
|
@@ -248013,6 +248105,11 @@ function makeResolvedToolCallTask(result) {
|
|
|
248013
248105
|
async function runPrepareToolExecutionHook(step, call) {
|
|
248014
248106
|
const { hooks, signal, turnId, currentStep, llm } = step;
|
|
248015
248107
|
const { toolCall, args } = call;
|
|
248108
|
+
if (step.canStart?.() === false) return {
|
|
248109
|
+
kind: "blocked",
|
|
248110
|
+
args,
|
|
248111
|
+
output: "INPUT_SUPERSEDED"
|
|
248112
|
+
};
|
|
248016
248113
|
const hook = hooks?.prepareToolExecution;
|
|
248017
248114
|
if (hook === void 0) return {
|
|
248018
248115
|
kind: "allowed",
|
|
@@ -248064,7 +248161,7 @@ async function runAuthorizeToolExecutionHook(step, call, args, execution) {
|
|
|
248064
248161
|
const hook = hooks?.authorizeToolExecution;
|
|
248065
248162
|
if (hook === void 0) return void 0;
|
|
248066
248163
|
try {
|
|
248067
|
-
return await
|
|
248164
|
+
return await waitForPreparationBoundary(step, (preparationSignal) => hook({
|
|
248068
248165
|
toolCall: call.toolCall,
|
|
248069
248166
|
toolCalls: step.toolCalls,
|
|
248070
248167
|
tool: call.tool,
|
|
@@ -248072,7 +248169,7 @@ async function runAuthorizeToolExecutionHook(step, call, args, execution) {
|
|
|
248072
248169
|
execution,
|
|
248073
248170
|
turnId,
|
|
248074
248171
|
stepNumber: currentStep,
|
|
248075
|
-
signal,
|
|
248172
|
+
signal: preparationSignal,
|
|
248076
248173
|
llm
|
|
248077
248174
|
}));
|
|
248078
248175
|
} catch (error) {
|
|
@@ -248126,6 +248223,7 @@ async function runRunnableToolCall(step, call, effectiveArgs, metadata, executio
|
|
|
248126
248223
|
function createNestedToolInvoker(step, parent) {
|
|
248127
248224
|
const controller = new AbortController();
|
|
248128
248225
|
const parentSignal = AbortSignal.any([step.signal, controller.signal]);
|
|
248226
|
+
inheritInputControl(parentSignal, step.inputControl);
|
|
248129
248227
|
let accepting = true;
|
|
248130
248228
|
let stopped = false;
|
|
248131
248229
|
let sequence = 0;
|
|
@@ -248152,6 +248250,7 @@ function createNestedToolInvoker(step, parent) {
|
|
|
248152
248250
|
while (reservedIds.has(id));
|
|
248153
248251
|
reservedIds.add(id);
|
|
248154
248252
|
const signal = input.signal === void 0 ? parentSignal : AbortSignal.any([parentSignal, input.signal]);
|
|
248253
|
+
inheritInputControl(signal, step.inputControl);
|
|
248155
248254
|
const run = async () => {
|
|
248156
248255
|
if (stopped) throw new Error("A nested tool stopped the turn.");
|
|
248157
248256
|
signal.throwIfAborted();
|
|
@@ -248241,6 +248340,10 @@ async function finalizePendingToolResult(step, pendingResult) {
|
|
|
248241
248340
|
async function executeTool(step, execution, toolCall, toolName, metadata, invokeTool) {
|
|
248242
248341
|
const { dispatchEvent, signal, turnId } = step;
|
|
248243
248342
|
signal.throwIfAborted();
|
|
248343
|
+
if (step.canStart?.() === false) return {
|
|
248344
|
+
output: "INPUT_SUPERSEDED",
|
|
248345
|
+
isError: true
|
|
248346
|
+
};
|
|
248244
248347
|
const executePromise = execution.execute({
|
|
248245
248348
|
turnId,
|
|
248246
248349
|
toolCallId: toolCall.id,
|
|
@@ -248394,6 +248497,8 @@ async function dispatchToolCall(step, call, args, displayFields) {
|
|
|
248394
248497
|
*/
|
|
248395
248498
|
async function executeLoopStep(deps) {
|
|
248396
248499
|
const { turnId, signal, buildMessages, buildMessagesStrict, dispatchEvent, llm, tools, hooks, executionObserver, log, currentStep, maxRetryAttempts, checkpointBeforeRetry, recordUsage, onStepStarted } = deps;
|
|
248500
|
+
const control = inputControl(signal);
|
|
248501
|
+
const inputEpoch = control.epoch;
|
|
248397
248502
|
if (hooks?.beforeStep !== void 0) {
|
|
248398
248503
|
const beforeStep = await hooks.beforeStep({
|
|
248399
248504
|
turnId,
|
|
@@ -248412,10 +248517,13 @@ async function executeLoopStep(deps) {
|
|
|
248412
248517
|
turnId,
|
|
248413
248518
|
currentStep,
|
|
248414
248519
|
stepUuid,
|
|
248415
|
-
onStepStarted
|
|
248520
|
+
onStepStarted,
|
|
248521
|
+
acceptOutput: () => !control.stopped && control.epoch === inputEpoch
|
|
248416
248522
|
});
|
|
248417
248523
|
const prepareRequestBoundary = llm.prepareRequestBoundary?.bind(llm);
|
|
248418
248524
|
const step = {
|
|
248525
|
+
inputControl: control,
|
|
248526
|
+
canStart: () => !control.stopped && control.epoch === inputEpoch,
|
|
248419
248527
|
tools,
|
|
248420
248528
|
hooks,
|
|
248421
248529
|
executionObserver,
|
|
@@ -248431,6 +248539,7 @@ async function executeLoopStep(deps) {
|
|
|
248431
248539
|
messages,
|
|
248432
248540
|
tools: tools ?? [],
|
|
248433
248541
|
signal,
|
|
248542
|
+
boundarySignal: signal,
|
|
248434
248543
|
...stepEvents.callbacks
|
|
248435
248544
|
};
|
|
248436
248545
|
if (prepareRequestBoundary === void 0) await stepEvents.start();
|
|
@@ -248480,6 +248589,12 @@ async function executeLoopStep(deps) {
|
|
|
248480
248589
|
log
|
|
248481
248590
|
};
|
|
248482
248591
|
let response;
|
|
248592
|
+
const provider = control.beginProvider();
|
|
248593
|
+
chatParams = {
|
|
248594
|
+
...chatParams,
|
|
248595
|
+
signal: AbortSignal.any([signal, provider.signal])
|
|
248596
|
+
};
|
|
248597
|
+
if (control.stopped || control.epoch !== inputEpoch) provider.abort();
|
|
248483
248598
|
try {
|
|
248484
248599
|
response = await chatWithRetry({
|
|
248485
248600
|
...retryInput,
|
|
@@ -248487,35 +248602,50 @@ async function executeLoopStep(deps) {
|
|
|
248487
248602
|
});
|
|
248488
248603
|
} catch (error) {
|
|
248489
248604
|
await stepEvents.drain();
|
|
248490
|
-
if (
|
|
248491
|
-
|
|
248492
|
-
|
|
248493
|
-
turnStep: `${turnId}.${String(currentStep)}`,
|
|
248494
|
-
model: llm.modelName
|
|
248495
|
-
});
|
|
248496
|
-
const strictMessages = await buildMessagesStrict();
|
|
248497
|
-
signal.throwIfAborted();
|
|
248498
|
-
let strictParams = {
|
|
248499
|
-
...chatParams,
|
|
248500
|
-
messages: strictMessages
|
|
248605
|
+
if (provider.signal.aborted && !signal.aborted) response = {
|
|
248606
|
+
toolCalls: [],
|
|
248607
|
+
usage: emptyUsage()
|
|
248501
248608
|
};
|
|
248502
|
-
if (
|
|
248503
|
-
|
|
248504
|
-
|
|
248505
|
-
|
|
248506
|
-
...retryInput,
|
|
248507
|
-
params: strictParams
|
|
248508
|
-
});
|
|
248509
|
-
} catch (strictError) {
|
|
248510
|
-
log?.error("strict resend still rejected by provider; request remains wire-invalid", {
|
|
248609
|
+
else if (buildMessagesStrict === void 0 || !isRecoverableRequestStructureError(error) || prepareRequestBoundary !== void 0 && stepEvents.hasOutput) throw error;
|
|
248610
|
+
else try {
|
|
248611
|
+
signal.throwIfAborted();
|
|
248612
|
+
log?.warn("provider rejected request structure; resending with strict projection", {
|
|
248511
248613
|
turnStep: `${turnId}.${String(currentStep)}`,
|
|
248512
|
-
model: llm.modelName
|
|
248513
|
-
originalError: errorMessage$4(error),
|
|
248514
|
-
strictError: errorMessage$4(strictError)
|
|
248614
|
+
model: llm.modelName
|
|
248515
248615
|
});
|
|
248516
|
-
|
|
248616
|
+
const strictMessages = await buildMessagesStrict();
|
|
248617
|
+
signal.throwIfAborted();
|
|
248618
|
+
let strictParams = {
|
|
248619
|
+
...chatParams,
|
|
248620
|
+
messages: strictMessages
|
|
248621
|
+
};
|
|
248622
|
+
if (prepareRequestBoundary !== void 0) strictParams = await prepareRequestBoundary(strictParams, buildMessagesStrict);
|
|
248623
|
+
signal.throwIfAborted();
|
|
248624
|
+
try {
|
|
248625
|
+
response = await chatWithRetry({
|
|
248626
|
+
...retryInput,
|
|
248627
|
+
params: strictParams
|
|
248628
|
+
});
|
|
248629
|
+
} catch (strictError) {
|
|
248630
|
+
if (provider.signal.aborted) throw strictError;
|
|
248631
|
+
log?.error("strict resend still rejected by provider; request remains wire-invalid", {
|
|
248632
|
+
turnStep: `${turnId}.${String(currentStep)}`,
|
|
248633
|
+
model: llm.modelName,
|
|
248634
|
+
originalError: errorMessage$4(error),
|
|
248635
|
+
strictError: errorMessage$4(strictError)
|
|
248636
|
+
});
|
|
248637
|
+
throw strictError;
|
|
248638
|
+
}
|
|
248639
|
+
log?.info("recovered after strict resend", { turnStep: `${turnId}.${String(currentStep)}` });
|
|
248640
|
+
} catch (strictBoundaryError) {
|
|
248641
|
+
if (!provider.signal.aborted || signal.aborted) throw strictBoundaryError;
|
|
248642
|
+
response = {
|
|
248643
|
+
toolCalls: [],
|
|
248644
|
+
usage: emptyUsage()
|
|
248645
|
+
};
|
|
248517
248646
|
}
|
|
248518
|
-
|
|
248647
|
+
} finally {
|
|
248648
|
+
control.endProvider(provider);
|
|
248519
248649
|
}
|
|
248520
248650
|
await stepEvents.start();
|
|
248521
248651
|
await stepEvents.drain();
|
|
@@ -248526,6 +248656,7 @@ async function executeLoopStep(deps) {
|
|
|
248526
248656
|
if (effectiveStopReason === "tool_use") {
|
|
248527
248657
|
if ((await runToolCallBatch(step, response)).stopTurn) effectiveStopReason = "end_turn";
|
|
248528
248658
|
}
|
|
248659
|
+
if (control.epoch !== inputEpoch) effectiveStopReason = control.stopped ? "end_turn" : "tool_use";
|
|
248529
248660
|
signal.throwIfAborted();
|
|
248530
248661
|
await dispatchEvent({
|
|
248531
248662
|
type: "step.end",
|
|
@@ -248636,8 +248767,10 @@ function createStepEventGate(deps) {
|
|
|
248636
248767
|
return startPromise;
|
|
248637
248768
|
};
|
|
248638
248769
|
const enqueue = (dispatch) => {
|
|
248770
|
+
if (!deps.acceptOutput()) return Promise.resolve();
|
|
248639
248771
|
hasOutput = true;
|
|
248640
248772
|
const queued = eventQueue.then(async () => {
|
|
248773
|
+
if (!deps.acceptOutput()) return;
|
|
248641
248774
|
await start();
|
|
248642
248775
|
await dispatch();
|
|
248643
248776
|
});
|
|
@@ -248741,6 +248874,10 @@ async function runTurn(input) {
|
|
|
248741
248874
|
try {
|
|
248742
248875
|
while (true) {
|
|
248743
248876
|
signal.throwIfAborted();
|
|
248877
|
+
if (inputControl(signal).stopped) {
|
|
248878
|
+
stopReason = "aborted";
|
|
248879
|
+
break;
|
|
248880
|
+
}
|
|
248744
248881
|
if (maxSteps !== void 0 && maxSteps > 0 && steps >= maxSteps) throw createMaxStepsExceededError(maxSteps);
|
|
248745
248882
|
steps += 1;
|
|
248746
248883
|
const stepNumber = steps;
|
|
@@ -248762,6 +248899,10 @@ async function runTurn(input) {
|
|
|
248762
248899
|
onStepStarted: setActiveStep.bind(void 0, stepNumber)
|
|
248763
248900
|
});
|
|
248764
248901
|
activeStep = void 0;
|
|
248902
|
+
if (inputControl(signal).stopped) {
|
|
248903
|
+
stopReason = "aborted";
|
|
248904
|
+
break;
|
|
248905
|
+
}
|
|
248765
248906
|
if (stepResult.stopReason === "tool_use") continue;
|
|
248766
248907
|
const terminalStopReason = stepResult.stopReason;
|
|
248767
248908
|
stopReason = terminalStopReason;
|
|
@@ -249455,7 +249596,8 @@ var init_prompt = __esmMin((() => {
|
|
|
249455
249596
|
sessionAdmissionSteerRequestSchema = admissionReadIdentitySchema.omit({ timeout_ms: true }).extend({ expected_turn_id: admissionTurnSchema });
|
|
249456
249597
|
sessionAdmissionCancelRequestSchema = object({
|
|
249457
249598
|
scope: admissionIdentitySchema,
|
|
249458
|
-
turn_id: admissionTurnSchema
|
|
249599
|
+
turn_id: admissionTurnSchema,
|
|
249600
|
+
graceful: boolean$1().optional()
|
|
249459
249601
|
}).strict();
|
|
249460
249602
|
sessionAdmissionCancelResponseSchema = sessionAdmissionCancelRequestSchema.extend({
|
|
249461
249603
|
session_id: string().min(1),
|
|
@@ -256401,6 +256543,43 @@ function convertMCPContentBlock(block) {
|
|
|
256401
256543
|
* `mcp__github__create_pr`) — embedded into the `<mcp_tool_result name="…">`
|
|
256402
256544
|
* wrap when the result is media-only, so the model can attribute binary parts.
|
|
256403
256545
|
*/
|
|
256546
|
+
async function retainOriginalText(parts, toolName, homedir) {
|
|
256547
|
+
const textParts = parts.flatMap((part) => {
|
|
256548
|
+
if (part.type !== "text") return [];
|
|
256549
|
+
const chunks = [];
|
|
256550
|
+
for (let offset = 0; offset < part.text.length; offset += 256) chunks.push(part.text.slice(offset, offset + 256));
|
|
256551
|
+
return [chunks];
|
|
256552
|
+
});
|
|
256553
|
+
const archive = JSON.stringify({
|
|
256554
|
+
version: 1,
|
|
256555
|
+
textParts
|
|
256556
|
+
}, null, 2);
|
|
256557
|
+
const outputPath = homedir === void 0 ? void 0 : await saveToolResult({
|
|
256558
|
+
homedir,
|
|
256559
|
+
toolName,
|
|
256560
|
+
toolCallId: "mcp-original",
|
|
256561
|
+
directoryPolicy: "private-retention"
|
|
256562
|
+
}, archive);
|
|
256563
|
+
if (outputPath === void 0) return "\n\n[Originaltext nicht gespeichert: Sitzungsverzeichnis fehlt oder Schreiben fehlgeschlagen. Die Ausgabe bleibt begrenzt.]";
|
|
256564
|
+
return [
|
|
256565
|
+
"",
|
|
256566
|
+
"",
|
|
256567
|
+
"MCP-Originaltext vor Kürzung gespeichert (JSON, version: 1, textParts: Zeichenabschnitte je Textblock; ohne Binärdaten).",
|
|
256568
|
+
`output_path: ${outputPath}`,
|
|
256569
|
+
"Mit Read seitenweise nachlesen. Zeichenabschnitte je Block ohne Trennzeichen verbinden; Blockreihenfolge erhalten."
|
|
256570
|
+
].join("\n");
|
|
256571
|
+
}
|
|
256572
|
+
function appendTextNotice(parts, text) {
|
|
256573
|
+
const last = parts.at(-1);
|
|
256574
|
+
if (last?.type === "text") parts[parts.length - 1] = {
|
|
256575
|
+
...last,
|
|
256576
|
+
text: last.text + text
|
|
256577
|
+
};
|
|
256578
|
+
else parts.push({
|
|
256579
|
+
type: "text",
|
|
256580
|
+
text
|
|
256581
|
+
});
|
|
256582
|
+
}
|
|
256404
256583
|
async function mcpResultToExecutableOutput(result, qualifiedToolName, options = {}) {
|
|
256405
256584
|
const converted = [];
|
|
256406
256585
|
for (const block of result.content) {
|
|
@@ -256408,8 +256587,10 @@ async function mcpResultToExecutableOutput(result, qualifiedToolName, options =
|
|
|
256408
256587
|
if (part !== null) converted.push(part);
|
|
256409
256588
|
}
|
|
256410
256589
|
const budgeted = applyTextBudget(wrapMediaOnly(converted, qualifiedToolName));
|
|
256590
|
+
const retentionNotice = budgeted.truncated ? await retainOriginalText(converted, qualifiedToolName, options.homedir) : void 0;
|
|
256411
256591
|
const capped = applyBinaryPartCap(await compressImageContentParts(budgeted.parts, { annotate: { persistOriginal: (bytes, mimeType) => persistOriginalImage(bytes, mimeType, options.originalsDir === void 0 ? {} : { dir: options.originalsDir }) } }));
|
|
256412
256592
|
const truncated = budgeted.truncated || capped.truncated;
|
|
256593
|
+
if (retentionNotice !== void 0) appendTextNotice(capped.parts, retentionNotice);
|
|
256413
256594
|
const output = collapseSingleText(capped.parts);
|
|
256414
256595
|
return truncated ? {
|
|
256415
256596
|
output,
|
|
@@ -264596,7 +264777,8 @@ async function budgetToolResultForModel(options) {
|
|
|
264596
264777
|
const outputPath = await saveToolResult({
|
|
264597
264778
|
homedir: options.homedir,
|
|
264598
264779
|
toolName: options.toolName,
|
|
264599
|
-
toolCallId: options.toolCallId
|
|
264780
|
+
toolCallId: options.toolCallId,
|
|
264781
|
+
directoryPolicy: "compatible-spill"
|
|
264600
264782
|
}, text);
|
|
264601
264783
|
if (outputPath === void 0) return options.result;
|
|
264602
264784
|
const output = renderPersistedToolResult(options.toolName, options.toolCallId, text, outputPath);
|
|
@@ -264615,19 +264797,33 @@ function persistableToolResultText(output) {
|
|
|
264615
264797
|
return output.map((part) => part.text).join("");
|
|
264616
264798
|
}
|
|
264617
264799
|
async function saveToolResult(options, text) {
|
|
264800
|
+
if (!isAbsolute$1(options.homedir)) return void 0;
|
|
264801
|
+
let createdPath;
|
|
264618
264802
|
try {
|
|
264619
264803
|
const dir = join$1(options.homedir, "tool-results");
|
|
264620
264804
|
await mkdir(dir, {
|
|
264621
264805
|
recursive: true,
|
|
264622
264806
|
mode: 448
|
|
264623
264807
|
});
|
|
264808
|
+
const info = await lstat(dir);
|
|
264809
|
+
if (info.isSymbolicLink()) return void 0;
|
|
264810
|
+
if (process.platform !== "win32") {
|
|
264811
|
+
if (info.uid !== process.getuid?.()) return void 0;
|
|
264812
|
+
if (options.directoryPolicy === "private-retention" && (info.mode & 63) !== 0) return;
|
|
264813
|
+
}
|
|
264814
|
+
const home = await realpath(options.homedir);
|
|
264815
|
+
if (normalize$3(await realpath(dir)) !== join$1(home, "tool-results")) return void 0;
|
|
264624
264816
|
const outputPath = join$1(dir, `${safeToolResultFileStem(options.toolName, options.toolCallId)}-${randomUUID()}.txt`);
|
|
264625
|
-
await
|
|
264626
|
-
|
|
264627
|
-
|
|
264628
|
-
|
|
264817
|
+
const file = await open(outputPath, "wx", 384);
|
|
264818
|
+
createdPath = outputPath;
|
|
264819
|
+
try {
|
|
264820
|
+
await file.writeFile(text, { encoding: "utf8" });
|
|
264821
|
+
} finally {
|
|
264822
|
+
await file.close();
|
|
264823
|
+
}
|
|
264629
264824
|
return outputPath;
|
|
264630
264825
|
} catch {
|
|
264826
|
+
if (createdPath !== void 0) await unlink(createdPath).catch(() => void 0);
|
|
264631
264827
|
return;
|
|
264632
264828
|
}
|
|
264633
264829
|
}
|
|
@@ -265160,6 +265356,7 @@ var TurnFlow = class {
|
|
|
265160
265356
|
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 2147483647) throw new Error("INVALID_PROMPT_TIMEOUT");
|
|
265161
265357
|
}
|
|
265162
265358
|
this.assertAdmissionOpen();
|
|
265359
|
+
this.stopRequested = false;
|
|
265163
265360
|
this.agent.records.logRecord({
|
|
265164
265361
|
type: "turn.prompt",
|
|
265165
265362
|
input,
|
|
@@ -265176,6 +265373,7 @@ var TurnFlow = class {
|
|
|
265176
265373
|
}
|
|
265177
265374
|
steer(input, origin = USER_PROMPT_ORIGIN) {
|
|
265178
265375
|
this.assertAdmissionOpen();
|
|
265376
|
+
this.stopRequested = false;
|
|
265179
265377
|
this.agent.records.logRecord({
|
|
265180
265378
|
type: "turn.steer",
|
|
265181
265379
|
input,
|
|
@@ -265189,7 +265387,7 @@ var TurnFlow = class {
|
|
|
265189
265387
|
}
|
|
265190
265388
|
/** Buffer only into the currently active turn; never launch from an idle state. */
|
|
265191
265389
|
steerActive(input, expectedTurnId, origin = USER_PROMPT_ORIGIN, onDisposition) {
|
|
265192
|
-
if (this.admissionClosed) return null;
|
|
265390
|
+
if (this.admissionClosed || this.stopRequested) return null;
|
|
265193
265391
|
const active = this.activeTurn;
|
|
265194
265392
|
if (active === null || active === "resuming" || !active.acceptingSteers || expectedTurnId !== void 0 && expectedTurnId !== this.currentId) return null;
|
|
265195
265393
|
this.agent.records.logRecord({
|
|
@@ -265280,7 +265478,19 @@ var TurnFlow = class {
|
|
|
265280
265478
|
this.turnId += 1;
|
|
265281
265479
|
this.activeTurn = "resuming";
|
|
265282
265480
|
}
|
|
265283
|
-
|
|
265481
|
+
stopRequested = false;
|
|
265482
|
+
stop(turnId) {
|
|
265483
|
+
const active = this.activeTurn;
|
|
265484
|
+
if (turnId !== this.currentId) return;
|
|
265485
|
+
this.stopRequested = true;
|
|
265486
|
+
if (active === null || active === "resuming") return;
|
|
265487
|
+
this.agent.records.logRecord({
|
|
265488
|
+
type: "turn.cancel",
|
|
265489
|
+
turnId
|
|
265490
|
+
});
|
|
265491
|
+
inputControl(active.controller.signal).changed(true);
|
|
265492
|
+
}
|
|
265493
|
+
cancel(turnId, reason) {
|
|
265284
265494
|
this.agent.records.logRecord({
|
|
265285
265495
|
type: "turn.cancel",
|
|
265286
265496
|
turnId
|
|
@@ -265351,6 +265561,8 @@ var TurnFlow = class {
|
|
|
265351
265561
|
timeoutMs
|
|
265352
265562
|
});
|
|
265353
265563
|
this.nextSteerSequence += 1;
|
|
265564
|
+
const active = this.activeTurn;
|
|
265565
|
+
if (origin.kind !== "background_task" && active !== null && active !== "resuming") inputControl(active.controller.signal).changed();
|
|
265354
265566
|
}
|
|
265355
265567
|
flushSteerBuffer(turnId = this.currentId, throughSequence = Number.POSITIVE_INFINITY) {
|
|
265356
265568
|
if (this.steerBuffer.length === 0) return false;
|
|
@@ -265411,7 +265623,7 @@ var TurnFlow = class {
|
|
|
265411
265623
|
* draining into it via `flushSteerBuffer`.
|
|
265412
265624
|
*/
|
|
265413
265625
|
onCompactionFinished() {
|
|
265414
|
-
if (this.admissionClosed) return;
|
|
265626
|
+
if (this.admissionClosed || this.stopRequested) return;
|
|
265415
265627
|
if (this.steerBuffer.length === 0) return;
|
|
265416
265628
|
if (this.activeTurn !== null) return;
|
|
265417
265629
|
const next = this.steerBuffer.shift();
|
|
@@ -265440,7 +265652,7 @@ var TurnFlow = class {
|
|
|
265440
265652
|
try {
|
|
265441
265653
|
if (this.agent.goal.getGoal().goal?.status === "active") return finish(await this.driveGoal(firstTurnId, input, origin, signal));
|
|
265442
265654
|
const end = await this.runOneTurn(firstTurnId, input, origin, signal, true);
|
|
265443
|
-
if (this.agent.goal.getGoal().goal?.status === "active" && end.event.reason !== "cancelled" && end.event.reason !== "failed" && end.event.reason !== "filtered") return finish(await this.driveGoal(this.allocateTurnId(), [{
|
|
265655
|
+
if (this.agent.goal.getGoal().goal?.status === "active" && !inputControl(signal).stopped && end.event.reason !== "cancelled" && end.event.reason !== "failed" && end.event.reason !== "filtered") return finish(await this.driveGoal(this.allocateTurnId(), [{
|
|
265444
265656
|
type: "text",
|
|
265445
265657
|
text: GOAL_CONTINUATION_PROMPT
|
|
265446
265658
|
}], goalContinuationOrigin(origin), signal));
|
|
@@ -265478,6 +265690,11 @@ var TurnFlow = class {
|
|
|
265478
265690
|
let turnInput = input;
|
|
265479
265691
|
let turnOrigin = origin;
|
|
265480
265692
|
while (true) {
|
|
265693
|
+
if (inputControl(signal).stopped) return { event: {
|
|
265694
|
+
type: "turn.ended",
|
|
265695
|
+
turnId,
|
|
265696
|
+
reason: "cancelled"
|
|
265697
|
+
} };
|
|
265481
265698
|
const goalBeforeTurn = this.agent.goal.getGoal().goal;
|
|
265482
265699
|
if (goalBeforeTurn?.status === "active" && goalBeforeTurn.budget.overBudget) {
|
|
265483
265700
|
await this.agent.goal.markBlocked({ reason: "A configured budget was reached" });
|
|
@@ -265567,7 +265784,13 @@ var TurnFlow = class {
|
|
|
265567
265784
|
let completedResponse;
|
|
265568
265785
|
let errorEvent;
|
|
265569
265786
|
try {
|
|
265787
|
+
const checkStop = () => {
|
|
265788
|
+
signal.throwIfAborted();
|
|
265789
|
+
if (inputControl(signal).stopped) throw new DOMException("INPUT_STOPPED", "AbortError");
|
|
265790
|
+
};
|
|
265791
|
+
checkStop();
|
|
265570
265792
|
const promptHookEnded = await this.applyUserPromptHook(turnId, input, origin, signal, startedAt);
|
|
265793
|
+
checkStop();
|
|
265571
265794
|
if (promptHookEnded !== void 0) {
|
|
265572
265795
|
ended = promptHookEnded.event;
|
|
265573
265796
|
blockedByUserPromptHook = promptHookEnded.blocked;
|
|
@@ -265586,6 +265809,7 @@ var TurnFlow = class {
|
|
|
265586
265809
|
this.agent.log.warn("Turn-start observation failed");
|
|
265587
265810
|
}
|
|
265588
265811
|
signal.throwIfAborted();
|
|
265812
|
+
checkStop();
|
|
265589
265813
|
const stopReason = await this.runStepLoop(turnId, signal, input, origin, (response) => {
|
|
265590
265814
|
completedResponse = response;
|
|
265591
265815
|
});
|
|
@@ -265838,7 +266062,7 @@ var TurnFlow = class {
|
|
|
265838
266062
|
},
|
|
265839
266063
|
settleStep: async ({ signal: stepSignal }) => {
|
|
265840
266064
|
if (stopForGoalBudget) this.setActiveSteerAcceptance(turnId, false);
|
|
265841
|
-
await this.agent.fullCompaction.afterStep(stepSignal);
|
|
266065
|
+
if (!inputControl(stepSignal).stopped) await this.agent.fullCompaction.afterStep(stepSignal);
|
|
265842
266066
|
},
|
|
265843
266067
|
afterStep: async () => {
|
|
265844
266068
|
deduper.endStep();
|
|
@@ -268730,7 +268954,10 @@ var ToolManager = class {
|
|
|
268730
268954
|
return {
|
|
268731
268955
|
approvalRule: qualified,
|
|
268732
268956
|
execute: async (context) => {
|
|
268733
|
-
return mcpResultToExecutableOutput(await client.callTool(tool.name, args ?? {}, context.signal), qualified, {
|
|
268957
|
+
return mcpResultToExecutableOutput(await client.callTool(tool.name, args ?? {}, context.signal), qualified, {
|
|
268958
|
+
originalsDir: this.agent.mediaOriginalsDir,
|
|
268959
|
+
homedir: this.agent.homedir
|
|
268960
|
+
});
|
|
268734
268961
|
}
|
|
268735
268962
|
};
|
|
268736
268963
|
}
|
|
@@ -269888,7 +270115,7 @@ var Agent$1 = class {
|
|
|
269888
270115
|
messages: await rebuildMessages()
|
|
269889
270116
|
};
|
|
269890
270117
|
let systemPrompt = this.effectiveSystemPrompt;
|
|
269891
|
-
const compacted = await this.fullCompaction.beforeStep(params.signal, {
|
|
270118
|
+
const compacted = await this.fullCompaction.beforeStep(params.boundarySignal ?? params.signal, {
|
|
269892
270119
|
messages: params.messages,
|
|
269893
270120
|
additionalMessages: steers.messages,
|
|
269894
270121
|
rebuildMessages,
|
|
@@ -270053,6 +270280,12 @@ var Agent$1 = class {
|
|
|
270053
270280
|
};
|
|
270054
270281
|
},
|
|
270055
270282
|
cancel: (payload) => {
|
|
270283
|
+
if (payload.graceful === true) {
|
|
270284
|
+
if (payload.turnId === void 0) throw new Error("STOP_TURN_REQUIRED");
|
|
270285
|
+
if (payload.turnId !== this.turn.currentId) return;
|
|
270286
|
+
this.turn.stop(payload.turnId);
|
|
270287
|
+
return Promise.all([this.turn.waitForExecutionEnd(), this.fullCompaction.waitForExecutionEnd()]).then(() => void 0);
|
|
270288
|
+
}
|
|
270056
270289
|
const waitForExecution = this.experimentalFlags.enabled("queue_policies") && payload.turnId !== void 0 && payload.turnId === this.turn.currentId;
|
|
270057
270290
|
if (this.turn.hasActiveTurn) this.telemetry.track("cancel", { from: "streaming" });
|
|
270058
270291
|
this.turn.cancel(payload.turnId, payload.cancellationReason === "timeout" ? new DOMException("Prompt execution timed out", "TimeoutError") : void 0);
|
|
@@ -335265,7 +335498,10 @@ async function appendSessionIndexEntry(homeDir, entry) {
|
|
|
335265
335498
|
recursive: true,
|
|
335266
335499
|
mode: 448
|
|
335267
335500
|
});
|
|
335268
|
-
await appendFile(indexPath, `${JSON.stringify(entry)}\n`,
|
|
335501
|
+
await appendFile(indexPath, `${JSON.stringify(entry)}\n`, {
|
|
335502
|
+
encoding: "utf-8",
|
|
335503
|
+
mode: 384
|
|
335504
|
+
});
|
|
335269
335505
|
}
|
|
335270
335506
|
async function readSessionIndex(homeDir, sessionsDir) {
|
|
335271
335507
|
let raw;
|
|
@@ -343333,12 +343569,14 @@ let SessionService = class SessionService extends Disposable {
|
|
|
343333
343569
|
sessionId: id,
|
|
343334
343570
|
agentId: "main",
|
|
343335
343571
|
expectedScope: request.scope,
|
|
343336
|
-
turnId: request.turn_id
|
|
343572
|
+
turnId: request.turn_id,
|
|
343573
|
+
graceful: request.graceful
|
|
343337
343574
|
});
|
|
343338
343575
|
return {
|
|
343339
343576
|
session_id: id,
|
|
343340
343577
|
scope: request.scope,
|
|
343341
343578
|
turn_id: request.turn_id,
|
|
343579
|
+
graceful: request.graceful,
|
|
343342
343580
|
settled: true
|
|
343343
343581
|
};
|
|
343344
343582
|
}
|
|
@@ -346379,13 +346617,14 @@ var Session = class {
|
|
|
346379
346617
|
this.ensureOpen();
|
|
346380
346618
|
await this.trackLocalInputRequest(() => this.rpc.cancel({ sessionId: this.id }));
|
|
346381
346619
|
}
|
|
346382
|
-
async cancelTurn(turnId, expectedScope) {
|
|
346620
|
+
async cancelTurn(turnId, expectedScope, graceful) {
|
|
346383
346621
|
this.ensureOpen();
|
|
346384
346622
|
if (!Number.isSafeInteger(turnId) || turnId < 0) throw new Error("INVALID_TURN_ID");
|
|
346385
346623
|
await this.trackLocalInputRequest(() => this.rpc.cancelTurn({
|
|
346386
346624
|
sessionId: this.id,
|
|
346387
346625
|
turnId,
|
|
346388
|
-
expectedScope
|
|
346626
|
+
expectedScope,
|
|
346627
|
+
graceful
|
|
346389
346628
|
}));
|
|
346390
346629
|
}
|
|
346391
346630
|
async setModel(model, options) {
|
|
@@ -347860,7 +348099,8 @@ var SDKRpcClientBase = class {
|
|
|
347860
348099
|
sessionId: input.sessionId,
|
|
347861
348100
|
agentId,
|
|
347862
348101
|
turnId: input.turnId,
|
|
347863
|
-
expectedScope: input.expectedScope
|
|
348102
|
+
expectedScope: input.expectedScope,
|
|
348103
|
+
graceful: input.graceful
|
|
347864
348104
|
});
|
|
347865
348105
|
}
|
|
347866
348106
|
async registerTool(input) {
|
|
@@ -350166,7 +350406,7 @@ function optionalBuildString(value) {
|
|
|
350166
350406
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
350167
350407
|
}
|
|
350168
350408
|
const BLUN_BUILD_INFO = {
|
|
350169
|
-
version: optionalBuildString("9.1.
|
|
350409
|
+
version: optionalBuildString("9.1.642"),
|
|
350170
350410
|
channel: typeof __BLUN_CHANNEL__ === "string" ? optionalBuildString(__BLUN_CHANNEL__) : void 0,
|
|
350171
350411
|
commit: typeof __BLUN_COMMIT__ === "string" ? optionalBuildString(__BLUN_COMMIT__) : void 0,
|
|
350172
350412
|
buildTarget: typeof __BLUN_BUILD_TARGET__ === "string" ? optionalBuildString(__BLUN_BUILD_TARGET__) : void 0
|