agentbox-sdk 0.1.520 → 0.1.522
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/index.d.ts +2 -2
- package/dist/agents/index.js +2 -2
- package/dist/{chunk-V4M4LPPT.js → chunk-AE2FQ6YU.js} +6 -2
- package/dist/{chunk-7PZKMK4U.js → chunk-EQ5AFLAW.js} +369 -102
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{types-Bhntrw9V.d.ts → types-DM6zUiv1.d.ts} +30 -11
- package/package.json +1 -1
package/dist/agents/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as AgentProviderName, h as AgentOptions, t as AgentRunConfig, s as AgentRun, r as AgentResult,
|
|
2
|
-
export { a as AgentApprovalMode, c as AgentCommandConfig, d as AgentCostData, e as AgentExecutionRequest, f as AgentLocalMcpConfig, g as AgentMcpConfig, i as AgentOptionsBase, j as AgentOptionsMap, k as AgentPermissionDecision, l as AgentPermissionKind, m as AgentPermissionResponse, n as AgentProviderAdapter, p as AgentReasoningEffort, q as AgentRemoteMcpConfig, u as AgentRunSink, v as AgentSetupRequest, w as AgentSkillConfig, x as AgentSubAgentConfig, y as AgentUserAnswer, z as AgentUserQuestion, E as ClaudeCodeAgentOptions, F as ClaudeCodeHookConfig, G as ClaudeCodeHookEvent, H as ClaudeCodeHookHandler, I as ClaudeCodeHookMatcherGroup, J as ClaudeCodeHooksConfig, K as ClaudeCodeProviderOptions, L as CodexAgentOptions, M as CodexCommandHook, N as CodexHookEvent, O as CodexHookMatcherGroup, P as CodexHooksConfig, Q as CodexModelProviderConfig, R as CodexProviderOptions, S as CodexSkillEntry, T as DataContent, U as EmbeddedSkillConfig, V as FilePart, W as HarnessCommandDescriptor, X as HarnessCommandInvocation, Y as HarnessCommandSource, _ as ImagePart, $ as MAX_HARNESS_COMMANDS, a0 as MAX_HARNESS_COMMAND_ARGUMENT_HINT, a1 as MAX_HARNESS_COMMAND_DESCRIPTION, a2 as MAX_HARNESS_COMMAND_NAME,
|
|
1
|
+
import { o as AgentProviderName, h as AgentOptions, t as AgentRunConfig, s as AgentRun, r as AgentResult, al as RawAgentEvent, b as AgentAttachRequest, B as AttachedRun, as as SetupLayout, ay as UserContent } from '../types-DM6zUiv1.js';
|
|
2
|
+
export { a as AgentApprovalMode, c as AgentCommandConfig, d as AgentCostData, e as AgentExecutionRequest, f as AgentLocalMcpConfig, g as AgentMcpConfig, i as AgentOptionsBase, j as AgentOptionsMap, k as AgentPermissionDecision, l as AgentPermissionKind, m as AgentPermissionResponse, n as AgentProviderAdapter, p as AgentReasoningEffort, q as AgentRemoteMcpConfig, u as AgentRunSink, v as AgentSetupRequest, w as AgentSkillConfig, x as AgentSubAgentConfig, y as AgentUserAnswer, z as AgentUserQuestion, E as ClaudeCodeAgentOptions, F as ClaudeCodeHookConfig, G as ClaudeCodeHookEvent, H as ClaudeCodeHookHandler, I as ClaudeCodeHookMatcherGroup, J as ClaudeCodeHooksConfig, K as ClaudeCodeProviderOptions, L as CodexAgentOptions, M as CodexCommandHook, N as CodexHookEvent, O as CodexHookMatcherGroup, P as CodexHooksConfig, Q as CodexModelProviderConfig, R as CodexProviderOptions, S as CodexSkillEntry, T as DataContent, U as EmbeddedSkillConfig, V as FilePart, W as HarnessCommandDescriptor, X as HarnessCommandInvocation, Y as HarnessCommandSource, _ as ImagePart, $ as MAX_HARNESS_COMMANDS, a0 as MAX_HARNESS_COMMAND_ARGUMENT_HINT, a1 as MAX_HARNESS_COMMAND_DESCRIPTION, a2 as MAX_HARNESS_COMMAND_NAME, a6 as NativeParkBackgroundWork, ab as OpenCodeAgentOptions, ac as OpenCodeCommandEntry, ad as OpenCodePluginConfig, ae as OpenCodePluginEvent, af as OpenCodePluginHookConfig, ag as OpenCodeProviderOptions, ah as OpenCodeSkillEntry, ai as OpenRouterPlugin, an as RepoSkillConfig, au as TextPart, az as UserContentPart, aA as builtinHarnessCommands, aB as claudeHarnessCommands, aC as codexHarnessCommands, aD as codexSkillMention, aG as openCodeHarnessCommands, aH as parseHarnessCommandInvocation, aI as skillDirective } from '../types-DM6zUiv1.js';
|
|
3
3
|
import { S as Sandbox } from '../Sandbox-DcKAU-E3.js';
|
|
4
4
|
export { AgentProvider } from '../enums.js';
|
|
5
5
|
import 'e2b';
|
package/dist/agents/index.js
CHANGED
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
parseHarnessCommandInvocation,
|
|
16
16
|
resolveHarnessCommand,
|
|
17
17
|
skillDirective
|
|
18
|
-
} from "../chunk-
|
|
19
|
-
import "../chunk-
|
|
18
|
+
} from "../chunk-EQ5AFLAW.js";
|
|
19
|
+
import "../chunk-AE2FQ6YU.js";
|
|
20
20
|
import {
|
|
21
21
|
AGENT_RESERVED_PORTS,
|
|
22
22
|
collectAllAgentReservedPorts
|
|
@@ -452,10 +452,14 @@ var OpenCodeLogAssembler = class {
|
|
|
452
452
|
}
|
|
453
453
|
const text = (this.textByPartId.get(partId) ?? "") + delta;
|
|
454
454
|
this.textByPartId.set(partId, text);
|
|
455
|
+
const previous = this.byPartId.get(partId);
|
|
456
|
+
const previousPart = isRecord(
|
|
457
|
+
previous?.properties?.part
|
|
458
|
+
) ? (previous?.properties).part : null;
|
|
455
459
|
const part = {
|
|
460
|
+
...previousPart ? clone(previousPart) : { type: "text" },
|
|
456
461
|
id: partId,
|
|
457
|
-
messageID: messageId ?? void 0,
|
|
458
|
-
type: "text",
|
|
462
|
+
messageID: messageId ?? previousPart?.messageID ?? void 0,
|
|
459
463
|
text
|
|
460
464
|
};
|
|
461
465
|
if (parentTaskCallId) {
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
createNormalizedEvent,
|
|
3
3
|
normalizeRawAgentEvent,
|
|
4
4
|
toAISDKStream
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-AE2FQ6YU.js";
|
|
6
6
|
import {
|
|
7
7
|
AgentBoxError,
|
|
8
8
|
AsyncQueue,
|
|
@@ -2369,6 +2369,235 @@ var BackgroundWaitFinish = class {
|
|
|
2369
2369
|
}
|
|
2370
2370
|
};
|
|
2371
2371
|
|
|
2372
|
+
// src/agents/providers/claude-native-session.ts
|
|
2373
|
+
var PARK_BUFFER_LIMIT = 16 * 1024 * 1024;
|
|
2374
|
+
var WAKE_RETRY_MS = [0, 1e3, 2e3, 4e3, 8e3, 16e3, 3e4, 6e4];
|
|
2375
|
+
var WAKE_RETRY_CEILING_MS = 6e4;
|
|
2376
|
+
var NO_USER = "No user is attached to approve this request.";
|
|
2377
|
+
var parkedSessions = /* @__PURE__ */ new Map();
|
|
2378
|
+
function findParkedNativeSession(sessionId) {
|
|
2379
|
+
return parkedSessions.get(sessionId);
|
|
2380
|
+
}
|
|
2381
|
+
function turnEdges(message) {
|
|
2382
|
+
const m = message;
|
|
2383
|
+
const state = m.type === "system" && m.subtype === "session_state_changed" ? m.state : void 0;
|
|
2384
|
+
return {
|
|
2385
|
+
started: m.type === "system" && (m.subtype === "init" || state === "running"),
|
|
2386
|
+
// A turn that dies without a result would otherwise stay active forever
|
|
2387
|
+
// and inflate the turn count an adopting run skips; idle clears it too.
|
|
2388
|
+
ended: m.type === "result" || state === "idle"
|
|
2389
|
+
};
|
|
2390
|
+
}
|
|
2391
|
+
var NativeClaudeSession = class {
|
|
2392
|
+
constructor(sessionId, kill) {
|
|
2393
|
+
this.sessionId = sessionId;
|
|
2394
|
+
this.kill = kill;
|
|
2395
|
+
}
|
|
2396
|
+
sessionId;
|
|
2397
|
+
kill;
|
|
2398
|
+
prompt = new AsyncQueue();
|
|
2399
|
+
query;
|
|
2400
|
+
iterator;
|
|
2401
|
+
handlers;
|
|
2402
|
+
parked;
|
|
2403
|
+
// Absolute end of the background budget, carried across parks so a CLI
|
|
2404
|
+
// that is adopted and parked again cannot extend its own ceiling.
|
|
2405
|
+
parkDeadline = Infinity;
|
|
2406
|
+
buffer = [];
|
|
2407
|
+
bufferedBytes = 0;
|
|
2408
|
+
bufferedResults = 0;
|
|
2409
|
+
bufferOverflowed = false;
|
|
2410
|
+
turnActive = false;
|
|
2411
|
+
pumping;
|
|
2412
|
+
ending;
|
|
2413
|
+
bind(query) {
|
|
2414
|
+
this.query = query;
|
|
2415
|
+
this.iterator = query[Symbol.asyncIterator]();
|
|
2416
|
+
}
|
|
2417
|
+
get isParked() {
|
|
2418
|
+
return this.parked !== void 0;
|
|
2419
|
+
}
|
|
2420
|
+
canUseTool = async (toolName, input, options) => {
|
|
2421
|
+
const handlers = this.handlers;
|
|
2422
|
+
if (!handlers) return { behavior: "deny", message: NO_USER };
|
|
2423
|
+
const result = await handlers.canUseTool(toolName, input, options);
|
|
2424
|
+
if (this.handlers !== handlers && result?.behavior === "deny")
|
|
2425
|
+
return { behavior: "deny", message: NO_USER };
|
|
2426
|
+
return result;
|
|
2427
|
+
};
|
|
2428
|
+
preToolUse = async (input, toolUseID, options) => this.handlers ? this.handlers.preToolUse(input, toolUseID, options) : {};
|
|
2429
|
+
/** Attach a run: `preamble` is read first, then the CLI's own output. */
|
|
2430
|
+
open(handlers, preamble = [], handoff) {
|
|
2431
|
+
this.handlers = handlers;
|
|
2432
|
+
const queue = [...preamble];
|
|
2433
|
+
let pending = handoff;
|
|
2434
|
+
return {
|
|
2435
|
+
[Symbol.asyncIterator]: () => ({
|
|
2436
|
+
next: () => {
|
|
2437
|
+
if (queue.length > 0)
|
|
2438
|
+
return Promise.resolve({ done: false, value: queue.shift() });
|
|
2439
|
+
if (pending) {
|
|
2440
|
+
const next = pending;
|
|
2441
|
+
pending = void 0;
|
|
2442
|
+
return next;
|
|
2443
|
+
}
|
|
2444
|
+
return this.pull();
|
|
2445
|
+
}
|
|
2446
|
+
})
|
|
2447
|
+
};
|
|
2448
|
+
}
|
|
2449
|
+
/**
|
|
2450
|
+
* Keep the CLI after the attached run settles. `inflight` is a read that
|
|
2451
|
+
* run started but never consumed; its message is buffered, not lost.
|
|
2452
|
+
*/
|
|
2453
|
+
park(tasks, ttlMs, parking, inflight) {
|
|
2454
|
+
if (this.ending || !this.iterator) return false;
|
|
2455
|
+
this.handlers = void 0;
|
|
2456
|
+
this.parkDeadline = Math.min(
|
|
2457
|
+
this.parkDeadline,
|
|
2458
|
+
Number.isFinite(ttlMs) ? Date.now() + Math.max(0, ttlMs) : Infinity
|
|
2459
|
+
);
|
|
2460
|
+
const parked = { tasks, parking, waking: false, wokeAt: 0 };
|
|
2461
|
+
if (Number.isFinite(this.parkDeadline)) {
|
|
2462
|
+
parked.timer = setTimeout(
|
|
2463
|
+
() => {
|
|
2464
|
+
if (this.parked !== parked) return;
|
|
2465
|
+
debugClaude("\u2605 parked CLI ran out of background budget; ending it");
|
|
2466
|
+
void this.end();
|
|
2467
|
+
},
|
|
2468
|
+
Math.min(Math.max(0, this.parkDeadline - Date.now()), 2147483647)
|
|
2469
|
+
);
|
|
2470
|
+
parked.timer.unref?.();
|
|
2471
|
+
}
|
|
2472
|
+
this.parked = parked;
|
|
2473
|
+
parkedSessions.set(this.sessionId, this);
|
|
2474
|
+
void this.pump(inflight);
|
|
2475
|
+
return true;
|
|
2476
|
+
}
|
|
2477
|
+
/**
|
|
2478
|
+
* A later run takes the parked CLI over: it learns what was live and how
|
|
2479
|
+
* many results precede its own turn, then reads what was buffered. An
|
|
2480
|
+
* attach-only run with nothing to stream leaves the park alone (undefined).
|
|
2481
|
+
*/
|
|
2482
|
+
adopt(handlers, attachOnly) {
|
|
2483
|
+
const parked = this.parked;
|
|
2484
|
+
if (!parked) return void 0;
|
|
2485
|
+
const turns = this.bufferedResults + (this.turnActive ? 1 : 0);
|
|
2486
|
+
if (attachOnly && turns === 0) return void 0;
|
|
2487
|
+
clearTimeout(parked.timer);
|
|
2488
|
+
this.parked = void 0;
|
|
2489
|
+
parkedSessions.delete(this.sessionId);
|
|
2490
|
+
const budgetLeftMs = Number.isFinite(this.parkDeadline) ? Math.max(0, this.parkDeadline - Date.now()) : null;
|
|
2491
|
+
const preamble = [
|
|
2492
|
+
{ _parked: { tasks: parked.tasks, turns, budgetLeftMs } },
|
|
2493
|
+
...this.buffer
|
|
2494
|
+
];
|
|
2495
|
+
this.buffer = [];
|
|
2496
|
+
this.bufferedBytes = 0;
|
|
2497
|
+
this.bufferedResults = 0;
|
|
2498
|
+
this.bufferOverflowed = false;
|
|
2499
|
+
const handoff = this.pumping;
|
|
2500
|
+
this.pumping = void 0;
|
|
2501
|
+
return this.open(handlers, preamble, handoff);
|
|
2502
|
+
}
|
|
2503
|
+
/** Close the CLI and the background work it owns. Idempotent. */
|
|
2504
|
+
end() {
|
|
2505
|
+
return this.ending ??= (async () => {
|
|
2506
|
+
const parked = this.parked;
|
|
2507
|
+
this.parked = void 0;
|
|
2508
|
+
this.handlers = void 0;
|
|
2509
|
+
clearTimeout(parked?.timer);
|
|
2510
|
+
if (parkedSessions.get(this.sessionId) === this)
|
|
2511
|
+
parkedSessions.delete(this.sessionId);
|
|
2512
|
+
try {
|
|
2513
|
+
await this.kill();
|
|
2514
|
+
} finally {
|
|
2515
|
+
if (parked) parked.parking.onEnded?.();
|
|
2516
|
+
}
|
|
2517
|
+
})();
|
|
2518
|
+
}
|
|
2519
|
+
pull() {
|
|
2520
|
+
return this.iterator.next().then((result) => {
|
|
2521
|
+
if (!result.done) {
|
|
2522
|
+
const { started, ended } = turnEdges(result.value);
|
|
2523
|
+
if (started) this.turnActive = true;
|
|
2524
|
+
if (ended) this.turnActive = false;
|
|
2525
|
+
}
|
|
2526
|
+
return result;
|
|
2527
|
+
});
|
|
2528
|
+
}
|
|
2529
|
+
async pump(first) {
|
|
2530
|
+
let next = first;
|
|
2531
|
+
while (this.parked) {
|
|
2532
|
+
next ??= this.pull();
|
|
2533
|
+
this.pumping = next;
|
|
2534
|
+
let result;
|
|
2535
|
+
try {
|
|
2536
|
+
result = await next;
|
|
2537
|
+
} catch (error) {
|
|
2538
|
+
if (this.pumping !== next) return;
|
|
2539
|
+
debugClaude("parked CLI stream failed: %o", error);
|
|
2540
|
+
void this.end();
|
|
2541
|
+
return;
|
|
2542
|
+
}
|
|
2543
|
+
if (this.pumping !== next) return;
|
|
2544
|
+
this.pumping = void 0;
|
|
2545
|
+
next = void 0;
|
|
2546
|
+
if (result.done) {
|
|
2547
|
+
debugClaude("\u2605 parked CLI exited");
|
|
2548
|
+
void this.end();
|
|
2549
|
+
return;
|
|
2550
|
+
}
|
|
2551
|
+
this.hold(result.value);
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
hold(message) {
|
|
2555
|
+
if (message && typeof message === "object" && "_parked" in message) return;
|
|
2556
|
+
const { started } = turnEdges(message);
|
|
2557
|
+
const isResult = message.type === "result";
|
|
2558
|
+
if (isResult) this.bufferedResults++;
|
|
2559
|
+
if (started || isResult) this.wake();
|
|
2560
|
+
if (message.type === "stream_event") return;
|
|
2561
|
+
const size = Buffer.byteLength(JSON.stringify(message) ?? "");
|
|
2562
|
+
if (this.bufferedBytes + size > PARK_BUFFER_LIMIT) {
|
|
2563
|
+
if (!this.bufferOverflowed) {
|
|
2564
|
+
this.bufferOverflowed = true;
|
|
2565
|
+
this.buffer.push({ _notice: "park_buffer_overflow" });
|
|
2566
|
+
this.wake();
|
|
2567
|
+
}
|
|
2568
|
+
return;
|
|
2569
|
+
}
|
|
2570
|
+
this.bufferedBytes += size;
|
|
2571
|
+
this.buffer.push(message);
|
|
2572
|
+
}
|
|
2573
|
+
wake() {
|
|
2574
|
+
const parked = this.parked;
|
|
2575
|
+
if (!parked || parked.waking) return;
|
|
2576
|
+
if (parked.wokeAt && Date.now() - parked.wokeAt < WAKE_RETRY_CEILING_MS)
|
|
2577
|
+
return;
|
|
2578
|
+
parked.waking = true;
|
|
2579
|
+
void (async () => {
|
|
2580
|
+
try {
|
|
2581
|
+
for (let attempt = 0; ; attempt++) {
|
|
2582
|
+
const delay = WAKE_RETRY_MS[attempt] ?? WAKE_RETRY_CEILING_MS;
|
|
2583
|
+
if (delay) await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2584
|
+
if (this.parked !== parked) return;
|
|
2585
|
+
try {
|
|
2586
|
+
if (await parked.parking.onWake() !== false) {
|
|
2587
|
+
parked.wokeAt = Date.now();
|
|
2588
|
+
return;
|
|
2589
|
+
}
|
|
2590
|
+
} catch (error) {
|
|
2591
|
+
debugClaude("wake callback failed: %o", error);
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
} finally {
|
|
2595
|
+
parked.waking = false;
|
|
2596
|
+
}
|
|
2597
|
+
})();
|
|
2598
|
+
}
|
|
2599
|
+
};
|
|
2600
|
+
|
|
2372
2601
|
// src/agents/providers/claude-code.ts
|
|
2373
2602
|
var DAEMON_PROTOCOL_VERSION = "11";
|
|
2374
2603
|
var DAEMON_PORT = 43180;
|
|
@@ -3646,7 +3875,8 @@ ${serialized}` : serialized;
|
|
|
3646
3875
|
await Promise.allSettled([...pendingReplies]);
|
|
3647
3876
|
}
|
|
3648
3877
|
};
|
|
3649
|
-
const
|
|
3878
|
+
const parkOption = request.options.provider?.parkBackgroundWork;
|
|
3879
|
+
const parking = parkOption && "wakeUrl" in parkOption ? parkOption : void 0;
|
|
3650
3880
|
await consumeClaudeMessages(
|
|
3651
3881
|
request,
|
|
3652
3882
|
sink,
|
|
@@ -3784,12 +4014,12 @@ async function consumeClaudeMessages(request, sink, messages, executeStartedAt,
|
|
|
3784
4014
|
);
|
|
3785
4015
|
};
|
|
3786
4016
|
const budgetLeftMs = () => Math.max(0, timeoutMs - waitedMs - (pendingWait?.elapsedMs() ?? 0));
|
|
3787
|
-
const tryPark = async () => {
|
|
4017
|
+
const tryPark = async (inflight) => {
|
|
3788
4018
|
const live = tracker.liveTasks();
|
|
3789
4019
|
const ttlMs = budgetLeftMs();
|
|
3790
4020
|
if (!wait.park || live.length === 0 || isAborted() || ttlMs <= 0)
|
|
3791
4021
|
return false;
|
|
3792
|
-
parked = await wait.park(live, ttlMs).catch(() => false);
|
|
4022
|
+
parked = await wait.park(live, ttlMs, inflight).catch(() => false);
|
|
3793
4023
|
if (parked)
|
|
3794
4024
|
debugClaude(
|
|
3795
4025
|
"\u2605 parked the harness with %d background task(s); settling",
|
|
@@ -3827,7 +4057,7 @@ async function consumeClaudeMessages(request, sink, messages, executeStartedAt,
|
|
|
3827
4057
|
break;
|
|
3828
4058
|
}
|
|
3829
4059
|
if ("reason" in step) {
|
|
3830
|
-
if (!(step.reason === "finished" && await tryPark()))
|
|
4060
|
+
if (!(step.reason === "finished" && await tryPark(next)))
|
|
3831
4061
|
expiry = step.reason;
|
|
3832
4062
|
break;
|
|
3833
4063
|
}
|
|
@@ -4147,31 +4377,29 @@ async function consumeClaudeMessages(request, sink, messages, executeStartedAt,
|
|
|
4147
4377
|
async function executeNativeClaude(request, sink, wait = {}) {
|
|
4148
4378
|
const { query } = await import("@anthropic-ai/claude-agent-sdk");
|
|
4149
4379
|
const claudeDir = claudeConfigDir(request.options);
|
|
4150
|
-
const
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
const prompt = new AsyncQueue();
|
|
4380
|
+
const attachOnly = request.run.resumeParked === true;
|
|
4381
|
+
const input = attachOnly ? [] : await validateProviderUserInput(request.provider, request.run.input);
|
|
4382
|
+
const parkOption = request.options.provider?.parkBackgroundWork;
|
|
4383
|
+
const parking = parkOption && "onWake" in parkOption ? parkOption : void 0;
|
|
4155
4384
|
const sessionId = request.run.resumeSessionId ?? randomUUID();
|
|
4385
|
+
if (request.run.forkSessionId)
|
|
4386
|
+
await findParkedNativeSession(request.run.forkSessionId)?.end();
|
|
4387
|
+
const adopting = request.run.resumeSessionId ? findParkedNativeSession(request.run.resumeSessionId) : void 0;
|
|
4156
4388
|
const controller = new AbortController();
|
|
4157
4389
|
const tracker = new BackgroundTaskTracker();
|
|
4158
4390
|
let handle;
|
|
4159
4391
|
let processHandle;
|
|
4160
|
-
let stopped;
|
|
4161
4392
|
let cancelled = false;
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
controller.abort();
|
|
4166
|
-
if (processHandle) await processHandle.kill();
|
|
4167
|
-
})();
|
|
4393
|
+
let parked = false;
|
|
4394
|
+
let session;
|
|
4395
|
+
const stop = () => session?.end() ?? Promise.resolve();
|
|
4168
4396
|
sink.setAbort(async () => {
|
|
4169
4397
|
cancelled = true;
|
|
4170
4398
|
await stop();
|
|
4171
4399
|
});
|
|
4172
4400
|
sink.setSessionId(sessionId);
|
|
4173
4401
|
const messageId = randomUUID();
|
|
4174
|
-
|
|
4402
|
+
const userMessage = {
|
|
4175
4403
|
type: "user",
|
|
4176
4404
|
uuid: messageId,
|
|
4177
4405
|
message: {
|
|
@@ -4181,7 +4409,7 @@ async function executeNativeClaude(request, sink, wait = {}) {
|
|
|
4181
4409
|
)
|
|
4182
4410
|
},
|
|
4183
4411
|
parent_tool_use_id: null
|
|
4184
|
-
}
|
|
4412
|
+
};
|
|
4185
4413
|
const hostEnv = Object.fromEntries(
|
|
4186
4414
|
Object.entries({ ...process.env, ...request.options.env }).filter(
|
|
4187
4415
|
(entry) => entry[1] !== void 0
|
|
@@ -4209,9 +4437,87 @@ async function executeNativeClaude(request, sink, wait = {}) {
|
|
|
4209
4437
|
const autoApprove = shouldAutoApproveClaudeTools(request.options);
|
|
4210
4438
|
const interactiveQuestions = hasInteractiveQuestions(request.options);
|
|
4211
4439
|
let planning = options.permissionMode === "plan";
|
|
4212
|
-
|
|
4440
|
+
const handlers = {
|
|
4441
|
+
async preToolUse(input2) {
|
|
4442
|
+
if (input2.hook_event_name !== "PreToolUse") return {};
|
|
4443
|
+
planning = input2.permission_mode === "plan";
|
|
4444
|
+
return interactiveQuestions && ["AskUserQuestion", "ExitPlanMode"].includes(input2.tool_name) ? {
|
|
4445
|
+
hookSpecificOutput: {
|
|
4446
|
+
hookEventName: "PreToolUse",
|
|
4447
|
+
permissionDecision: "ask"
|
|
4448
|
+
}
|
|
4449
|
+
} : {};
|
|
4450
|
+
},
|
|
4451
|
+
async canUseTool(toolName, input2, context) {
|
|
4452
|
+
if (cancelled || context.signal.aborted)
|
|
4453
|
+
return {
|
|
4454
|
+
behavior: "deny",
|
|
4455
|
+
message: "Run cancelled",
|
|
4456
|
+
interrupt: true
|
|
4457
|
+
};
|
|
4458
|
+
const isQuestion = toolName === "AskUserQuestion";
|
|
4459
|
+
const isPlan = toolName === "ExitPlanMode";
|
|
4460
|
+
if ((isQuestion || isPlan) && !interactiveQuestions)
|
|
4461
|
+
return {
|
|
4462
|
+
behavior: "deny",
|
|
4463
|
+
message: "No interactive user is available."
|
|
4464
|
+
};
|
|
4465
|
+
if (!isQuestion && !isPlan && planning && toolName !== "EnterPlanMode")
|
|
4466
|
+
return {
|
|
4467
|
+
behavior: "deny",
|
|
4468
|
+
message: "Finish planning before requesting write access."
|
|
4469
|
+
};
|
|
4470
|
+
if (!isQuestion && !isPlan && autoApprove)
|
|
4471
|
+
return { behavior: "allow", updatedInput: input2 };
|
|
4472
|
+
try {
|
|
4473
|
+
const response = await sink.requestPermission({
|
|
4474
|
+
type: "permission.requested",
|
|
4475
|
+
provider: request.provider,
|
|
4476
|
+
runId: request.runId,
|
|
4477
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4478
|
+
requestId: context.toolUseID,
|
|
4479
|
+
kind: isQuestion ? "question" : isPlan ? "plan" : "tool",
|
|
4480
|
+
toolName,
|
|
4481
|
+
...isQuestion ? { questions: normalizeUserQuestions("claude-code", input2) } : {},
|
|
4482
|
+
title: isQuestion ? "Your input is needed" : isPlan ? "Review the plan" : context.title ?? `Allow ${toolName}?`,
|
|
4483
|
+
message: context.description ?? context.decisionReason,
|
|
4484
|
+
input: input2,
|
|
4485
|
+
canRemember: false
|
|
4486
|
+
});
|
|
4487
|
+
if (isPlan && response.decision === "allow") planning = false;
|
|
4488
|
+
if (!cancelled && !context.signal.aborted && response.decision === "allow")
|
|
4489
|
+
return {
|
|
4490
|
+
behavior: "allow",
|
|
4491
|
+
updatedInput: isQuestion ? {
|
|
4492
|
+
...input2,
|
|
4493
|
+
answers: questionReply(
|
|
4494
|
+
"claude-code",
|
|
4495
|
+
input2,
|
|
4496
|
+
response.answers ?? []
|
|
4497
|
+
)
|
|
4498
|
+
} : input2
|
|
4499
|
+
};
|
|
4500
|
+
return { behavior: "deny", message: "The user denied this action" };
|
|
4501
|
+
} catch {
|
|
4502
|
+
return {
|
|
4503
|
+
behavior: "deny",
|
|
4504
|
+
message: "Run cancelled",
|
|
4505
|
+
interrupt: true
|
|
4506
|
+
};
|
|
4507
|
+
}
|
|
4508
|
+
}
|
|
4509
|
+
};
|
|
4510
|
+
const startCli = () => {
|
|
4511
|
+
const fresh = new NativeClaudeSession(sessionId, async () => {
|
|
4512
|
+
fresh.prompt.finish();
|
|
4513
|
+
handle?.close();
|
|
4514
|
+
controller.abort();
|
|
4515
|
+
if (processHandle) await processHandle.kill();
|
|
4516
|
+
});
|
|
4517
|
+
session = fresh;
|
|
4518
|
+
fresh.prompt.push(userMessage);
|
|
4213
4519
|
handle = query({
|
|
4214
|
-
prompt,
|
|
4520
|
+
prompt: fresh.prompt,
|
|
4215
4521
|
options: {
|
|
4216
4522
|
...options,
|
|
4217
4523
|
// Use the SDK-matched CLI by default; an installed CLI is an explicit override.
|
|
@@ -4232,89 +4538,42 @@ async function executeNativeClaude(request, sink, wait = {}) {
|
|
|
4232
4538
|
});
|
|
4233
4539
|
return processHandle.child;
|
|
4234
4540
|
},
|
|
4541
|
+
// Routed through the session so that whichever run is attached
|
|
4542
|
+
// decides, and a parked CLI with nobody attached is never left
|
|
4543
|
+
// waiting on a decision.
|
|
4235
4544
|
hooks: {
|
|
4236
4545
|
...options.hooks,
|
|
4237
4546
|
PreToolUse: [
|
|
4238
4547
|
...options.hooks?.PreToolUse ?? [],
|
|
4239
|
-
{
|
|
4240
|
-
hooks: [
|
|
4241
|
-
async (input2) => {
|
|
4242
|
-
if (input2.hook_event_name !== "PreToolUse") return {};
|
|
4243
|
-
planning = input2.permission_mode === "plan";
|
|
4244
|
-
return interactiveQuestions && ["AskUserQuestion", "ExitPlanMode"].includes(
|
|
4245
|
-
input2.tool_name
|
|
4246
|
-
) ? {
|
|
4247
|
-
hookSpecificOutput: {
|
|
4248
|
-
hookEventName: "PreToolUse",
|
|
4249
|
-
permissionDecision: "ask"
|
|
4250
|
-
}
|
|
4251
|
-
} : {};
|
|
4252
|
-
}
|
|
4253
|
-
]
|
|
4254
|
-
}
|
|
4548
|
+
{ hooks: [fresh.preToolUse] }
|
|
4255
4549
|
]
|
|
4256
4550
|
},
|
|
4257
|
-
|
|
4258
|
-
if (cancelled || context.signal.aborted)
|
|
4259
|
-
return {
|
|
4260
|
-
behavior: "deny",
|
|
4261
|
-
message: "Run cancelled",
|
|
4262
|
-
interrupt: true
|
|
4263
|
-
};
|
|
4264
|
-
const isQuestion = toolName === "AskUserQuestion";
|
|
4265
|
-
const isPlan = toolName === "ExitPlanMode";
|
|
4266
|
-
if ((isQuestion || isPlan) && !interactiveQuestions)
|
|
4267
|
-
return {
|
|
4268
|
-
behavior: "deny",
|
|
4269
|
-
message: "No interactive user is available."
|
|
4270
|
-
};
|
|
4271
|
-
if (!isQuestion && !isPlan && planning && toolName !== "EnterPlanMode")
|
|
4272
|
-
return {
|
|
4273
|
-
behavior: "deny",
|
|
4274
|
-
message: "Finish planning before requesting write access."
|
|
4275
|
-
};
|
|
4276
|
-
if (!isQuestion && !isPlan && autoApprove)
|
|
4277
|
-
return { behavior: "allow", updatedInput: input2 };
|
|
4278
|
-
try {
|
|
4279
|
-
const response = await sink.requestPermission({
|
|
4280
|
-
type: "permission.requested",
|
|
4281
|
-
provider: request.provider,
|
|
4282
|
-
runId: request.runId,
|
|
4283
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4284
|
-
requestId: context.toolUseID,
|
|
4285
|
-
kind: isQuestion ? "question" : isPlan ? "plan" : "tool",
|
|
4286
|
-
toolName,
|
|
4287
|
-
...isQuestion ? { questions: normalizeUserQuestions("claude-code", input2) } : {},
|
|
4288
|
-
title: isQuestion ? "Your input is needed" : isPlan ? "Review the plan" : context.title ?? `Allow ${toolName}?`,
|
|
4289
|
-
message: context.description ?? context.decisionReason,
|
|
4290
|
-
input: input2,
|
|
4291
|
-
canRemember: false
|
|
4292
|
-
});
|
|
4293
|
-
if (isPlan && response.decision === "allow") planning = false;
|
|
4294
|
-
if (!cancelled && !context.signal.aborted && response.decision === "allow")
|
|
4295
|
-
return {
|
|
4296
|
-
behavior: "allow",
|
|
4297
|
-
updatedInput: isQuestion ? {
|
|
4298
|
-
...input2,
|
|
4299
|
-
answers: questionReply(
|
|
4300
|
-
"claude-code",
|
|
4301
|
-
input2,
|
|
4302
|
-
response.answers ?? []
|
|
4303
|
-
)
|
|
4304
|
-
} : input2
|
|
4305
|
-
};
|
|
4306
|
-
return { behavior: "deny", message: "The user denied this action" };
|
|
4307
|
-
} catch {
|
|
4308
|
-
return {
|
|
4309
|
-
behavior: "deny",
|
|
4310
|
-
message: "Run cancelled",
|
|
4311
|
-
interrupt: true
|
|
4312
|
-
};
|
|
4313
|
-
}
|
|
4314
|
-
}
|
|
4551
|
+
canUseTool: fresh.canUseTool
|
|
4315
4552
|
}
|
|
4316
4553
|
});
|
|
4317
|
-
|
|
4554
|
+
fresh.bind(handle);
|
|
4555
|
+
return fresh.open(handlers);
|
|
4556
|
+
};
|
|
4557
|
+
const notice = (item) => (async function* () {
|
|
4558
|
+
yield item;
|
|
4559
|
+
})();
|
|
4560
|
+
try {
|
|
4561
|
+
let messages;
|
|
4562
|
+
const adopted = adopting?.adopt(handlers, attachOnly);
|
|
4563
|
+
if (adopted) {
|
|
4564
|
+
debugClaude("\u2605 adopting the CLI parked for session %s", sessionId);
|
|
4565
|
+
session = adopting;
|
|
4566
|
+
if (!attachOnly) adopting.prompt.push(userMessage);
|
|
4567
|
+
messages = adopted;
|
|
4568
|
+
} else if (attachOnly) {
|
|
4569
|
+
messages = notice({
|
|
4570
|
+
_notice: adopting ? "no_parked_turn" : "no_parked_run",
|
|
4571
|
+
sessionId
|
|
4572
|
+
});
|
|
4573
|
+
} else {
|
|
4574
|
+
messages = startCli();
|
|
4575
|
+
}
|
|
4576
|
+
const live = session?.query;
|
|
4318
4577
|
sink.setRaw({ query: live, claudeDir, runId: request.runId });
|
|
4319
4578
|
sink.emitEvent(
|
|
4320
4579
|
createNormalizedEvent("run.started", {
|
|
@@ -4329,30 +4588,38 @@ async function executeNativeClaude(request, sink, wait = {}) {
|
|
|
4329
4588
|
{ messageId }
|
|
4330
4589
|
)
|
|
4331
4590
|
);
|
|
4591
|
+
const owned = session;
|
|
4332
4592
|
await consumeClaudeMessages(
|
|
4333
4593
|
request,
|
|
4334
4594
|
sink,
|
|
4335
|
-
|
|
4595
|
+
messages,
|
|
4336
4596
|
Date.now(),
|
|
4337
4597
|
stop,
|
|
4338
4598
|
() => cancelled,
|
|
4339
4599
|
{
|
|
4340
4600
|
...wait,
|
|
4601
|
+
attachOnly,
|
|
4341
4602
|
// Native owns the CLI: ask it to stop leftover tasks before closing it.
|
|
4342
4603
|
stopTasks: async (ids) => {
|
|
4604
|
+
if (!live) return;
|
|
4343
4605
|
await Promise.all(
|
|
4344
4606
|
ids.map((id) => live.stopTask(id).catch(() => void 0))
|
|
4345
4607
|
);
|
|
4346
|
-
}
|
|
4608
|
+
},
|
|
4609
|
+
...parking && owned ? {
|
|
4610
|
+
park: async (tasks, ttlMs, inflight) => parked = owned.park(tasks, ttlMs, parking, inflight),
|
|
4611
|
+
// The CLI lives on in the session; nothing to let go of.
|
|
4612
|
+
detach: async () => void 0
|
|
4613
|
+
} : {}
|
|
4347
4614
|
},
|
|
4348
4615
|
tracker
|
|
4349
4616
|
);
|
|
4350
4617
|
} catch (error) {
|
|
4351
|
-
await stop();
|
|
4618
|
+
if (!parked) await stop();
|
|
4352
4619
|
if (cancelled) sink.cancel();
|
|
4353
4620
|
else throw error;
|
|
4354
4621
|
} finally {
|
|
4355
|
-
await stop();
|
|
4622
|
+
if (!parked) await stop();
|
|
4356
4623
|
}
|
|
4357
4624
|
}
|
|
4358
4625
|
|
|
@@ -8028,8 +8295,8 @@ var Agent = class {
|
|
|
8028
8295
|
throw new Error("AgentRunConfig.forkAtMessageId requires forkSessionId.");
|
|
8029
8296
|
}
|
|
8030
8297
|
if (runConfig.resumeParked) {
|
|
8031
|
-
if (this.provider !== AgentProvider.ClaudeCode || !this.options.sandbox) {
|
|
8032
|
-
throw new Error("AgentRunConfig.resumeParked is only supported for claude-code sandbox runs.");
|
|
8298
|
+
if (this.provider !== AgentProvider.ClaudeCode || !this.options.sandbox && this.options.configuration !== "native") {
|
|
8299
|
+
throw new Error("AgentRunConfig.resumeParked is only supported for claude-code sandbox or native runs.");
|
|
8033
8300
|
}
|
|
8034
8301
|
if (!runConfig.resumeSessionId) {
|
|
8035
8302
|
throw new Error("AgentRunConfig.resumeParked requires resumeSessionId.");
|
package/dist/events/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AISDKEvent, C as BackgroundTask, D as BackgroundTasksEvent, Z as HarnessCommandsEvent, a3 as MessageCompletedEvent, a4 as MessageInjectedEvent, a5 as MessageStartedEvent,
|
|
1
|
+
export { A as AISDKEvent, C as BackgroundTask, D as BackgroundTasksEvent, Z as HarnessCommandsEvent, a3 as MessageCompletedEvent, a4 as MessageInjectedEvent, a5 as MessageStartedEvent, a7 as NativePlanEvent, a8 as NormalizedAgentEvent, a9 as NormalizedAgentEventBase, aa as NormalizedAgentEventType, aj as PermissionRequestedEvent, ak as PermissionResolvedEvent, al as RawAgentEvent, am as ReasoningDeltaEvent, ao as RunCancelledEvent, ap as RunCompletedEvent, aq as RunErrorEvent, ar as RunStartedEvent, at as TextDeltaEvent, av as ToolCallCompletedEvent, aw as ToolCallDeltaEvent, ax as ToolCallStartedEvent, aE as createNormalizedEvent, aF as normalizeRawAgentEvent, aJ as toAISDKEvent, aK as toAISDKStream } from '../types-DM6zUiv1.js';
|
|
2
2
|
import { AgentProvider } from '../enums.js';
|
|
3
3
|
import '../Sandbox-DcKAU-E3.js';
|
|
4
4
|
import 'e2b';
|
package/dist/events/index.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AISDKEvent, a as AgentApprovalMode, b as AgentAttachRequest, c as AgentCommandConfig, d as AgentCostData, e as AgentExecutionRequest, f as AgentLocalMcpConfig, g as AgentMcpConfig, h as AgentOptions, i as AgentOptionsBase, j as AgentOptionsMap, k as AgentPermissionDecision, l as AgentPermissionKind, m as AgentPermissionResponse, n as AgentProviderAdapter, o as AgentProviderName, p as AgentReasoningEffort, q as AgentRemoteMcpConfig, r as AgentResult, s as AgentRun, t as AgentRunConfig, u as AgentRunSink, v as AgentSetupRequest, w as AgentSkillConfig, x as AgentSubAgentConfig, y as AgentUserAnswer, z as AgentUserQuestion, B as AttachedRun, C as BackgroundTask, D as BackgroundTasksEvent, E as ClaudeCodeAgentOptions, F as ClaudeCodeHookConfig, G as ClaudeCodeHookEvent, H as ClaudeCodeHookHandler, I as ClaudeCodeHookMatcherGroup, J as ClaudeCodeHooksConfig, K as ClaudeCodeProviderOptions, L as CodexAgentOptions, M as CodexCommandHook, N as CodexHookEvent, O as CodexHookMatcherGroup, P as CodexHooksConfig, Q as CodexModelProviderConfig, R as CodexProviderOptions, S as CodexSkillEntry, T as DataContent, U as EmbeddedSkillConfig, V as FilePart, W as HarnessCommandDescriptor, X as HarnessCommandInvocation, Y as HarnessCommandSource, Z as HarnessCommandsEvent, _ as ImagePart, $ as MAX_HARNESS_COMMANDS, a0 as MAX_HARNESS_COMMAND_ARGUMENT_HINT, a1 as MAX_HARNESS_COMMAND_DESCRIPTION, a2 as MAX_HARNESS_COMMAND_NAME, a3 as MessageCompletedEvent, a4 as MessageInjectedEvent, a5 as MessageStartedEvent, a6 as
|
|
1
|
+
export { A as AISDKEvent, a as AgentApprovalMode, b as AgentAttachRequest, c as AgentCommandConfig, d as AgentCostData, e as AgentExecutionRequest, f as AgentLocalMcpConfig, g as AgentMcpConfig, h as AgentOptions, i as AgentOptionsBase, j as AgentOptionsMap, k as AgentPermissionDecision, l as AgentPermissionKind, m as AgentPermissionResponse, n as AgentProviderAdapter, o as AgentProviderName, p as AgentReasoningEffort, q as AgentRemoteMcpConfig, r as AgentResult, s as AgentRun, t as AgentRunConfig, u as AgentRunSink, v as AgentSetupRequest, w as AgentSkillConfig, x as AgentSubAgentConfig, y as AgentUserAnswer, z as AgentUserQuestion, B as AttachedRun, C as BackgroundTask, D as BackgroundTasksEvent, E as ClaudeCodeAgentOptions, F as ClaudeCodeHookConfig, G as ClaudeCodeHookEvent, H as ClaudeCodeHookHandler, I as ClaudeCodeHookMatcherGroup, J as ClaudeCodeHooksConfig, K as ClaudeCodeProviderOptions, L as CodexAgentOptions, M as CodexCommandHook, N as CodexHookEvent, O as CodexHookMatcherGroup, P as CodexHooksConfig, Q as CodexModelProviderConfig, R as CodexProviderOptions, S as CodexSkillEntry, T as DataContent, U as EmbeddedSkillConfig, V as FilePart, W as HarnessCommandDescriptor, X as HarnessCommandInvocation, Y as HarnessCommandSource, Z as HarnessCommandsEvent, _ as ImagePart, $ as MAX_HARNESS_COMMANDS, a0 as MAX_HARNESS_COMMAND_ARGUMENT_HINT, a1 as MAX_HARNESS_COMMAND_DESCRIPTION, a2 as MAX_HARNESS_COMMAND_NAME, a3 as MessageCompletedEvent, a4 as MessageInjectedEvent, a5 as MessageStartedEvent, a6 as NativeParkBackgroundWork, a7 as NativePlanEvent, a8 as NormalizedAgentEvent, a9 as NormalizedAgentEventBase, aa as NormalizedAgentEventType, ab as OpenCodeAgentOptions, ac as OpenCodeCommandEntry, ad as OpenCodePluginConfig, ae as OpenCodePluginEvent, af as OpenCodePluginHookConfig, ag as OpenCodeProviderOptions, ah as OpenCodeSkillEntry, ai as OpenRouterPlugin, aj as PermissionRequestedEvent, ak as PermissionResolvedEvent, al as RawAgentEvent, am as ReasoningDeltaEvent, an as RepoSkillConfig, ao as RunCancelledEvent, ap as RunCompletedEvent, aq as RunErrorEvent, ar as RunStartedEvent, as as SetupLayout, at as TextDeltaEvent, au as TextPart, av as ToolCallCompletedEvent, aw as ToolCallDeltaEvent, ax as ToolCallStartedEvent, ay as UserContent, az as UserContentPart, aA as builtinHarnessCommands, aB as claudeHarnessCommands, aC as codexHarnessCommands, aD as codexSkillMention, aE as createNormalizedEvent, aF as normalizeRawAgentEvent, aG as openCodeHarnessCommands, aH as parseHarnessCommandInvocation, aI as skillDirective, aJ as toAISDKEvent, aK as toAISDKStream } from './types-DM6zUiv1.js';
|
|
2
2
|
export { AGENT_RESERVED_PORTS, Agent, HarnessCapabilities, HarnessCommand, agentboxRoot, collectAllAgentReservedPorts, getAgentLayout, harnessCapabilities, resolveHarnessCommand } from './agents/index.js';
|
|
3
3
|
export { A as AsyncCommandHandle, C as CommandEvent, a as CommandOptions, b as CommandResult, D as DaytonaProviderOptions, c as DaytonaSandboxOptions, E as E2bProviderOptions, d as E2bSandboxOptions, G as GitCloneOptions, L as LocalDockerProviderOptions, e as LocalDockerSandboxOptions, M as ModalProviderOptions, f as ModalSandboxOptions, S as Sandbox, g as SandboxDescriptor, h as SandboxListOptions, i as SandboxOptions, j as SandboxOptionsBase, k as SandboxOptionsMap, l as SandboxProviderName, m as SandboxRaw, n as SandboxRawMap, o as SandboxResourceSpec, T as TarballEntry, V as VercelGitSource, p as VercelProviderOptions, q as VercelSandboxOptions } from './Sandbox-DcKAU-E3.js';
|
|
4
4
|
export { SandboxAdapter, buildGitCloneCommand } from './sandboxes/index.js';
|
package/dist/index.js
CHANGED
|
@@ -15,14 +15,14 @@ import {
|
|
|
15
15
|
parseHarnessCommandInvocation,
|
|
16
16
|
resolveHarnessCommand,
|
|
17
17
|
skillDirective
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-EQ5AFLAW.js";
|
|
19
19
|
import {
|
|
20
20
|
ProviderLogAssembler,
|
|
21
21
|
createNormalizedEvent,
|
|
22
22
|
normalizeRawAgentEvent,
|
|
23
23
|
toAISDKEvent,
|
|
24
24
|
toAISDKStream
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-AE2FQ6YU.js";
|
|
26
26
|
import {
|
|
27
27
|
Sandbox,
|
|
28
28
|
SandboxAdapter,
|
|
@@ -495,7 +495,7 @@ interface AgentRunConfig {
|
|
|
495
495
|
systemPrompt?: string;
|
|
496
496
|
resumeSessionId?: string;
|
|
497
497
|
/**
|
|
498
|
-
* claude-code sandbox runs: attach to the harness parked for
|
|
498
|
+
* claude-code sandbox and native runs: attach to the harness parked for
|
|
499
499
|
* {@link resumeSessionId} without sending {@link input}, and stream the
|
|
500
500
|
* turn it started on its own. Completes with empty text when nothing is
|
|
501
501
|
* parked or no such turn exists. See `provider.parkBackgroundWork`.
|
|
@@ -714,21 +714,40 @@ interface OpenCodeProviderOptions {
|
|
|
714
714
|
args?: string[];
|
|
715
715
|
plugins?: OpenCodePluginConfig[];
|
|
716
716
|
}
|
|
717
|
+
/**
|
|
718
|
+
* Parking for native (`configuration: "native"`) runs, where this process
|
|
719
|
+
* owns the CLI: the parked CLI lives on in this process, so the next run
|
|
720
|
+
* resuming the session must run in this same process to adopt it.
|
|
721
|
+
*/
|
|
722
|
+
interface NativeParkBackgroundWork {
|
|
723
|
+
/**
|
|
724
|
+
* The parked CLI started a turn on its own with nobody attached. Start a
|
|
725
|
+
* run with `resumeParked` in this process to stream it. Resolve `false`
|
|
726
|
+
* (or throw) to be asked again with backoff; anything else counts as
|
|
727
|
+
* accepted until a run attaches.
|
|
728
|
+
*/
|
|
729
|
+
onWake(): Promise<boolean | void> | boolean | void;
|
|
730
|
+
/** The parked CLI is gone: its work finished and it exited, or its budget ran out. */
|
|
731
|
+
onEnded?(): void;
|
|
732
|
+
}
|
|
717
733
|
interface ClaudeCodeProviderOptions {
|
|
718
734
|
/**
|
|
719
|
-
*
|
|
720
|
-
*
|
|
721
|
-
*
|
|
722
|
-
*
|
|
723
|
-
*
|
|
724
|
-
*
|
|
725
|
-
*
|
|
726
|
-
*
|
|
735
|
+
* End a run at its answer even when background work is still live, and
|
|
736
|
+
* keep the CLI alive for it (a "parked" run) instead of holding the run
|
|
737
|
+
* open. A run whose turn ends with nothing live is unaffected. The next run
|
|
738
|
+
* resuming that session takes the CLI over. The park lasts what is left of
|
|
739
|
+
* `backgroundTaskTimeoutMs`.
|
|
740
|
+
*
|
|
741
|
+
* Sandbox runs: when the CLI starts a turn on its own with nobody attached
|
|
742
|
+
* (a task finished, a schedule fired) the daemon POSTs
|
|
743
|
+
* `{ runId, sessionId }` to `wakeUrl` with
|
|
744
|
+
* `Authorization: Bearer <wakeToken>`; stream that turn with
|
|
745
|
+
* `resumeParked`. Native runs: see {@link NativeParkBackgroundWork}.
|
|
727
746
|
*/
|
|
728
747
|
parkBackgroundWork?: {
|
|
729
748
|
wakeUrl: string;
|
|
730
749
|
wakeToken: string;
|
|
731
|
-
};
|
|
750
|
+
} | NativeParkBackgroundWork;
|
|
732
751
|
/** Request fast mode explicitly; false overrides inherited fast settings. */
|
|
733
752
|
fastMode?: boolean;
|
|
734
753
|
binary?: string;
|
|
@@ -1009,4 +1028,4 @@ interface AgentProviderAdapter<P extends AgentProviderName = AgentProviderName>
|
|
|
1009
1028
|
attachSendMessage(request: AgentAttachRequest<P>, content: UserContent): Promise<void>;
|
|
1010
1029
|
}
|
|
1011
1030
|
|
|
1012
|
-
export { MAX_HARNESS_COMMANDS as $, type AISDKEvent as A, type AttachedRun as B, type BackgroundTask as C, type BackgroundTasksEvent as D, type ClaudeCodeAgentOptions as E, type ClaudeCodeHookConfig as F, type ClaudeCodeHookEvent as G, type ClaudeCodeHookHandler as H, type ClaudeCodeHookMatcherGroup as I, type ClaudeCodeHooksConfig as J, type ClaudeCodeProviderOptions as K, type CodexAgentOptions as L, type CodexCommandHook as M, type CodexHookEvent as N, type CodexHookMatcherGroup as O, type CodexHooksConfig as P, type CodexModelProviderConfig as Q, type CodexProviderOptions as R, type CodexSkillEntry as S, type DataContent as T, type EmbeddedSkillConfig as U, type FilePart as V, type HarnessCommandDescriptor as W, type HarnessCommandInvocation as X, type HarnessCommandSource as Y, type HarnessCommandsEvent as Z, type ImagePart as _, type AgentApprovalMode as a, MAX_HARNESS_COMMAND_ARGUMENT_HINT as a0, MAX_HARNESS_COMMAND_DESCRIPTION as a1, MAX_HARNESS_COMMAND_NAME as a2, type MessageCompletedEvent as a3, type MessageInjectedEvent as a4, type MessageStartedEvent as a5, type
|
|
1031
|
+
export { MAX_HARNESS_COMMANDS as $, type AISDKEvent as A, type AttachedRun as B, type BackgroundTask as C, type BackgroundTasksEvent as D, type ClaudeCodeAgentOptions as E, type ClaudeCodeHookConfig as F, type ClaudeCodeHookEvent as G, type ClaudeCodeHookHandler as H, type ClaudeCodeHookMatcherGroup as I, type ClaudeCodeHooksConfig as J, type ClaudeCodeProviderOptions as K, type CodexAgentOptions as L, type CodexCommandHook as M, type CodexHookEvent as N, type CodexHookMatcherGroup as O, type CodexHooksConfig as P, type CodexModelProviderConfig as Q, type CodexProviderOptions as R, type CodexSkillEntry as S, type DataContent as T, type EmbeddedSkillConfig as U, type FilePart as V, type HarnessCommandDescriptor as W, type HarnessCommandInvocation as X, type HarnessCommandSource as Y, type HarnessCommandsEvent as Z, type ImagePart as _, type AgentApprovalMode as a, MAX_HARNESS_COMMAND_ARGUMENT_HINT as a0, MAX_HARNESS_COMMAND_DESCRIPTION as a1, MAX_HARNESS_COMMAND_NAME as a2, type MessageCompletedEvent as a3, type MessageInjectedEvent as a4, type MessageStartedEvent as a5, type NativeParkBackgroundWork as a6, type NativePlanEvent as a7, type NormalizedAgentEvent as a8, type NormalizedAgentEventBase as a9, builtinHarnessCommands as aA, claudeHarnessCommands as aB, codexHarnessCommands as aC, codexSkillMention as aD, createNormalizedEvent as aE, normalizeRawAgentEvent as aF, openCodeHarnessCommands as aG, parseHarnessCommandInvocation as aH, skillDirective as aI, toAISDKEvent as aJ, toAISDKStream as aK, type NormalizedAgentEventType as aa, type OpenCodeAgentOptions as ab, type OpenCodeCommandEntry as ac, type OpenCodePluginConfig as ad, type OpenCodePluginEvent as ae, type OpenCodePluginHookConfig as af, type OpenCodeProviderOptions as ag, type OpenCodeSkillEntry as ah, type OpenRouterPlugin as ai, type PermissionRequestedEvent as aj, type PermissionResolvedEvent as ak, type RawAgentEvent as al, type ReasoningDeltaEvent as am, type RepoSkillConfig as an, type RunCancelledEvent as ao, type RunCompletedEvent as ap, type RunErrorEvent as aq, type RunStartedEvent as ar, type SetupLayout as as, type TextDeltaEvent as at, type TextPart as au, type ToolCallCompletedEvent as av, type ToolCallDeltaEvent as aw, type ToolCallStartedEvent as ax, type UserContent as ay, type UserContentPart as az, type AgentAttachRequest as b, type AgentCommandConfig as c, type AgentCostData as d, type AgentExecutionRequest as e, type AgentLocalMcpConfig as f, type AgentMcpConfig as g, type AgentOptions as h, type AgentOptionsBase as i, type AgentOptionsMap as j, type AgentPermissionDecision as k, type AgentPermissionKind as l, type AgentPermissionResponse as m, type AgentProviderAdapter as n, type AgentProviderName as o, type AgentReasoningEffort as p, type AgentRemoteMcpConfig as q, type AgentResult as r, type AgentRun as s, type AgentRunConfig as t, type AgentRunSink as u, type AgentSetupRequest as v, type AgentSkillConfig as w, type AgentSubAgentConfig as x, type AgentUserAnswer as y, type AgentUserQuestion as z };
|