kfc-code-cli 0.0.1-alpha.6 → 0.0.1-alpha.7

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.
Files changed (2) hide show
  1. package/dist/main.mjs +409 -370
  2. package/package.json +5 -3
package/dist/main.mjs CHANGED
@@ -675,8 +675,8 @@ function sanitizeToolCallData(data) {
675
675
  tool_name: data.tool_name,
676
676
  args: data.args,
677
677
  ...data.activity_description !== void 0 ? { activity_description: data.activity_description } : {},
678
- ...data.user_facing_name !== void 0 ? { user_facing_name: data.user_facing_name } : {},
679
- ...data.input_display !== void 0 ? { input_display: data.input_display } : {}
678
+ user_facing_name: data.user_facing_name,
679
+ input_display: data.input_display
680
680
  };
681
681
  }
682
682
  function toolCallDataToKosongToolCall(data) {
@@ -870,11 +870,11 @@ function extractTextOnly(message) {
870
870
  function cloneMessage(message) {
871
871
  return {
872
872
  role: message.role,
873
- ...message.name !== void 0 ? { name: message.name } : {},
873
+ name: message.name,
874
874
  content: message.content.map((p) => ({ ...p })),
875
875
  toolCalls: message.toolCalls.map((tc) => ({ ...tc })),
876
- ...message.toolCallId !== void 0 ? { toolCallId: message.toolCallId } : {},
877
- ...message.partial !== void 0 ? { partial: message.partial } : {}
876
+ toolCallId: message.toolCallId,
877
+ partial: message.partial
878
878
  };
879
879
  }
880
880
  //#endregion
@@ -892,9 +892,9 @@ function buildToolResultRecord(turnId, parentUuid, toolCallId, normalisedOutput,
892
892
  turn_id: turnId,
893
893
  tool_call_id: toolCallId,
894
894
  output: normalisedOutput,
895
- ...parentUuid !== void 0 ? { parent_uuid: parentUuid } : {},
896
- ...result.isError !== void 0 ? { is_error: result.isError } : {},
897
- ...result.synthetic !== void 0 ? { synthetic: result.synthetic } : {}
895
+ parent_uuid: parentUuid,
896
+ is_error: result.isError,
897
+ synthetic: result.synthetic
898
898
  };
899
899
  }
900
900
  function buildStepBeginRecord(input) {
@@ -911,8 +911,8 @@ function buildStepEndRecord(input) {
911
911
  uuid: input.uuid,
912
912
  turn_id: input.turnId,
913
913
  step: input.step,
914
- ...input.usage !== void 0 ? { usage: input.usage } : {},
915
- ...input.finishReason !== void 0 ? { finish_reason: input.finishReason } : {}
914
+ usage: input.usage,
915
+ finish_reason: input.finishReason
916
916
  };
917
917
  }
918
918
  function buildContentPartRecord(input) {
@@ -986,7 +986,7 @@ function buildCompactionRecord(summary) {
986
986
  pre_compact_tokens: summary.preCompactTokens,
987
987
  post_compact_tokens: summary.postCompactTokens,
988
988
  trigger: summary.trigger,
989
- ...summary.archiveFile !== void 0 ? { archive_file: summary.archiveFile } : {}
989
+ archive_file: summary.archiveFile
990
990
  };
991
991
  }
992
992
  //#endregion
@@ -1006,7 +1006,7 @@ function buildCompactionRecord(summary) {
1006
1006
  var BaseContextState = class {
1007
1007
  journalWriter;
1008
1008
  projector;
1009
- _currentTurnId;
1009
+ currentTurnId;
1010
1010
  memory;
1011
1011
  _broken = false;
1012
1012
  _brokenError;
@@ -1025,12 +1025,12 @@ var BaseContextState = class {
1025
1025
  constructor(opts) {
1026
1026
  this.journalWriter = opts.journalWriter;
1027
1027
  this.projector = opts.projector ?? new DefaultConversationProjector();
1028
- this._currentTurnId = opts.currentTurnId;
1028
+ this.currentTurnId = opts.currentTurnId;
1029
1029
  this.memory = new ContextStateMemory({
1030
1030
  initialModel: opts.initialModel,
1031
1031
  ...opts.initialSystemPrompt !== void 0 ? { initialSystemPrompt: opts.initialSystemPrompt } : {},
1032
1032
  ...opts.initialActiveTools !== void 0 ? { initialActiveTools: opts.initialActiveTools } : {},
1033
- ...opts.initialHistory !== void 0 ? { initialHistory: opts.initialHistory } : {},
1033
+ initialHistory: opts.initialHistory,
1034
1034
  ...opts.initialTokenCount !== void 0 ? { initialTokenCount: opts.initialTokenCount } : {},
1035
1035
  ...opts.initialThinkingLevel !== void 0 ? { initialThinkingLevel: opts.initialThinkingLevel } : {}
1036
1036
  });
@@ -1053,9 +1053,6 @@ var BaseContextState = class {
1053
1053
  get beforeStep() {
1054
1054
  return this.memory.beforeStep;
1055
1055
  }
1056
- currentTurnId() {
1057
- return this._currentTurnId();
1058
- }
1059
1056
  buildMessages() {
1060
1057
  return this.projector.project({
1061
1058
  history: this.memory.getHistory(),
@@ -1082,10 +1079,10 @@ var BaseContextState = class {
1082
1079
  await this.journalWriter.append(buildUserMessageRecord(turnId, input));
1083
1080
  this.memory.appendUserContent(userInputToContentParts(input));
1084
1081
  }
1085
- async appendToolResult(parentUuid, toolCallId, result, turnIdOverride) {
1082
+ async appendToolResult(parentUuid, toolCallId, result) {
1086
1083
  this.assertNotBroken();
1087
1084
  const normalisedOutput = result.output === void 0 ? null : result.output;
1088
- const turnId = turnIdOverride ?? this.currentTurnId();
1085
+ const turnId = this.currentTurnId();
1089
1086
  await this.journalWriter.append(buildToolResultRecord(turnId, parentUuid, toolCallId, normalisedOutput, result));
1090
1087
  this.memory.appendToolResult(toolCallId, toolResultOutputToContentParts(normalisedOutput));
1091
1088
  }
@@ -1171,8 +1168,8 @@ var WiredContextState = class extends BaseContextState {
1171
1168
  ...opts.initialSystemPrompt !== void 0 ? { initialSystemPrompt: opts.initialSystemPrompt } : {},
1172
1169
  ...opts.initialActiveTools !== void 0 ? { initialActiveTools: opts.initialActiveTools } : {},
1173
1170
  currentTurnId: opts.currentTurnId,
1174
- ...opts.projector !== void 0 ? { projector: opts.projector } : {},
1175
- ...opts.initialHistory !== void 0 ? { initialHistory: opts.initialHistory } : {},
1171
+ projector: opts.projector,
1172
+ initialHistory: opts.initialHistory,
1176
1173
  ...opts.initialTokenCount !== void 0 ? { initialTokenCount: opts.initialTokenCount } : {},
1177
1174
  ...opts.initialThinkingLevel !== void 0 ? { initialThinkingLevel: opts.initialThinkingLevel } : {}
1178
1175
  });
@@ -1186,8 +1183,8 @@ var InMemoryContextState = class extends BaseContextState {
1186
1183
  ...opts.initialSystemPrompt !== void 0 ? { initialSystemPrompt: opts.initialSystemPrompt } : {},
1187
1184
  ...opts.initialActiveTools !== void 0 ? { initialActiveTools: opts.initialActiveTools } : {},
1188
1185
  currentTurnId: opts.currentTurnId ?? (() => "embedded"),
1189
- ...opts.projector !== void 0 ? { projector: opts.projector } : {},
1190
- ...opts.initialHistory !== void 0 ? { initialHistory: opts.initialHistory } : {},
1186
+ projector: opts.projector,
1187
+ initialHistory: opts.initialHistory,
1191
1188
  ...opts.initialThinkingLevel !== void 0 ? { initialThinkingLevel: opts.initialThinkingLevel } : {}
1192
1189
  });
1193
1190
  }
@@ -2269,7 +2266,7 @@ function toKosongContentPart(part) {
2269
2266
  type: "video_url",
2270
2267
  videoUrl: {
2271
2268
  url: part.source.url,
2272
- ...part.source.id !== void 0 ? { id: part.source.id } : {}
2269
+ id: part.source.id
2273
2270
  }
2274
2271
  };
2275
2272
  return {
@@ -2312,8 +2309,8 @@ function createChatStreamingCallbacks(deps) {
2312
2309
  emit({
2313
2310
  type: "tool_call_part",
2314
2311
  tool_call_id: part.tool_call_id,
2315
- ...part.name !== void 0 ? { name: part.name } : {},
2316
- ...part.arguments_chunk !== void 0 ? { arguments_chunk: part.arguments_chunk } : {}
2312
+ name: part.name,
2313
+ arguments_chunk: part.arguments_chunk
2317
2314
  });
2318
2315
  },
2319
2316
  onPrefetchedResult: (toolCallId, result) => {
@@ -2395,6 +2392,15 @@ async function classifyToolCalls(step, response, deferred) {
2395
2392
  });
2396
2393
  continue;
2397
2394
  }
2395
+ if (toolCall.error !== void 0) {
2396
+ const output = `Invalid input for tool "${toolCall.name}": ${toolCall.error}`;
2397
+ await writeFallbackToolCallAndResult(context, stepUuid, turnId, currentStep, toolCall, output);
2398
+ deferred.set(toolCall.id, {
2399
+ output,
2400
+ isError: true
2401
+ });
2402
+ continue;
2403
+ }
2398
2404
  const parsed = tool.inputSchema.safeParse(toolCall.args);
2399
2405
  if (!parsed.success) {
2400
2406
  const output = `Invalid input for tool "${toolCall.name}": ${parsed.error.message}`;
@@ -2446,6 +2452,7 @@ async function classifyToolCalls(step, response, deferred) {
2446
2452
  }
2447
2453
  async function executePendingCalls(step, pending, deferred) {
2448
2454
  const { config, context, emit, signal, turnId, currentStep, stepUuid, toolCallByProviderId } = step;
2455
+ const postContentCallbacks = [];
2449
2456
  for (const [index, item] of pending.entries()) {
2450
2457
  if (index > 0) signal.throwIfAborted();
2451
2458
  const { toolCall, tool, parsedArgs, hookResult } = item;
@@ -2464,13 +2471,20 @@ async function executePendingCalls(step, pending, deferred) {
2464
2471
  try {
2465
2472
  const prefetched = step.prefetchedResults.get(toolCall.id);
2466
2473
  if (prefetched !== void 0) toolResult = prefetched;
2467
- else toolResult = await raceExecuteWithGraceTimeout(tool.execute(toolCall.id, effectiveInput, signal, (update) => {
2468
- emit({
2469
- type: "tool.progress",
2470
- toolCallId: toolCall.id,
2471
- update
2472
- });
2473
- }, { wireUuid: toolCallByProviderId.get(toolCall.id) }), signal, toolCall.name);
2474
+ else toolResult = await raceExecuteWithGraceTimeout(tool.execute({
2475
+ turnId,
2476
+ toolCallId: toolCall.id,
2477
+ args: effectiveInput,
2478
+ signal,
2479
+ onUpdate: (update) => {
2480
+ emit({
2481
+ type: "tool.progress",
2482
+ toolCallId: toolCall.id,
2483
+ update
2484
+ });
2485
+ },
2486
+ wireUuid: toolCallByProviderId.get(toolCall.id)
2487
+ }), signal, toolCall.name);
2474
2488
  } catch (error) {
2475
2489
  const output = isAbortError$3(error) || signal.aborted ? `Tool "${toolCall.name}" was aborted` : `Tool "${toolCall.name}" failed: ${errorMessage$1(error)}`;
2476
2490
  const syntheticResult = {
@@ -2539,7 +2553,9 @@ async function executePendingCalls(step, pending, deferred) {
2539
2553
  isError: finalResult.isError === true
2540
2554
  });
2541
2555
  await context.appendToolResult(toolCallByProviderId.get(toolCall.id), toolCall.id, adapted);
2556
+ if (!finalResult.isError && finalResult.postContent) postContentCallbacks.push(finalResult.postContent);
2542
2557
  }
2558
+ for (const callback of postContentCallbacks) await callback();
2543
2559
  }
2544
2560
  function findTool(tools, name) {
2545
2561
  return tools.find((tool) => tool.name === name);
@@ -2644,7 +2660,7 @@ async function executeSoulStep(deps) {
2644
2660
  tools: visibleTools,
2645
2661
  model,
2646
2662
  systemPrompt: context.systemPrompt,
2647
- ...overrides?.effort !== void 0 ? { effort: overrides.effort } : {},
2663
+ effort: overrides?.effort,
2648
2664
  signal,
2649
2665
  ...createChatStreamingCallbacks({
2650
2666
  emit,
@@ -2654,7 +2670,7 @@ async function executeSoulStep(deps) {
2654
2670
  stepUuid,
2655
2671
  prefetchedResults
2656
2672
  }),
2657
- ...config.contextWindow !== void 0 ? { contextWindow: config.contextWindow } : {}
2673
+ contextWindow: config.contextWindow
2658
2674
  });
2659
2675
  recordUsage(response.usage);
2660
2676
  const deferredResults = /* @__PURE__ */ new Map();
@@ -2679,7 +2695,7 @@ async function executeSoulStep(deps) {
2679
2695
  turnId,
2680
2696
  step: currentStep,
2681
2697
  usage: toStepEndUsage(response.usage),
2682
- ...response.stopReason !== void 0 ? { finishReason: response.stopReason } : {}
2698
+ finishReason: response.stopReason
2683
2699
  });
2684
2700
  await executePendingCalls(step, pending, deferredResults);
2685
2701
  signal.throwIfAborted();
@@ -2705,8 +2721,8 @@ function toStepEndUsage(usage) {
2705
2721
  return {
2706
2722
  input_tokens: usage.input,
2707
2723
  output_tokens: usage.output,
2708
- ...usage.cache_read !== void 0 ? { cache_read_tokens: usage.cache_read } : {},
2709
- ...usage.cache_write !== void 0 ? { cache_write_tokens: usage.cache_write } : {}
2724
+ cache_read_tokens: usage.cache_read,
2725
+ cache_write_tokens: usage.cache_write
2710
2726
  };
2711
2727
  }
2712
2728
  //#endregion
@@ -3145,7 +3161,7 @@ var SoulRegistry = class {
3145
3161
  uuid: spawnedUuid,
3146
3162
  data: {
3147
3163
  agent_id: agentId,
3148
- ...request.agentName !== void 0 ? { agent_name: request.agentName } : {},
3164
+ agent_name: request.agentName,
3149
3165
  parent_tool_call_id: request.parentToolCallId,
3150
3166
  ...request.parentToolCallUuid !== void 0 ? { parent_tool_call_uuid: request.parentToolCallUuid } : {},
3151
3167
  ...request.parentAgentId !== void 0 && request.parentAgentId !== "" && request.parentAgentId !== "agent_main" ? { parent_agent_id: request.parentAgentId } : {},
@@ -3156,7 +3172,7 @@ var SoulRegistry = class {
3156
3172
  type: "subagent.spawned",
3157
3173
  data: {
3158
3174
  agent_id: agentId,
3159
- ...request.agentName !== void 0 ? { agent_name: request.agentName } : {},
3175
+ agent_name: request.agentName,
3160
3176
  parent_tool_call_id: request.parentToolCallId,
3161
3177
  ...request.parentToolCallUuid !== void 0 ? { parent_tool_call_uuid: request.parentToolCallUuid } : {},
3162
3178
  ...request.parentAgentId !== void 0 && request.parentAgentId !== "" && request.parentAgentId !== "agent_main" ? { parent_agent_id: request.parentAgentId } : {},
@@ -3458,7 +3474,7 @@ async function runSubagentTurn(deps, agentId, request, signal) {
3458
3474
  uuid: spawnedUuid,
3459
3475
  data: {
3460
3476
  agent_id: agentId,
3461
- ...request.agentName !== void 0 ? { agent_name: request.agentName } : {},
3477
+ agent_name: request.agentName,
3462
3478
  parent_tool_call_id: request.parentToolCallId,
3463
3479
  ...request.parentToolCallUuid !== void 0 ? { parent_tool_call_uuid: request.parentToolCallUuid } : {},
3464
3480
  ...request.parentAgentId !== void 0 && request.parentAgentId !== "" && request.parentAgentId !== "agent_main" ? { parent_agent_id: request.parentAgentId } : {},
@@ -3469,7 +3485,7 @@ async function runSubagentTurn(deps, agentId, request, signal) {
3469
3485
  type: "subagent.spawned",
3470
3486
  data: {
3471
3487
  agent_id: agentId,
3472
- ...request.agentName !== void 0 ? { agent_name: request.agentName } : {},
3488
+ agent_name: request.agentName,
3473
3489
  parent_tool_call_id: request.parentToolCallId,
3474
3490
  ...request.parentToolCallUuid !== void 0 ? { parent_tool_call_uuid: request.parentToolCallUuid } : {},
3475
3491
  ...request.parentAgentId !== void 0 && request.parentAgentId !== "" && request.parentAgentId !== "agent_main" ? { parent_agent_id: request.parentAgentId } : {},
@@ -3502,7 +3518,7 @@ async function runSubagentTurn(deps, agentId, request, signal) {
3502
3518
  type: "session_initialized",
3503
3519
  agent_type: "sub",
3504
3520
  agent_id: agentId,
3505
- ...request.agentName !== void 0 ? { agent_name: request.agentName } : {},
3521
+ agent_name: request.agentName,
3506
3522
  parent_session_id: parentSessionId,
3507
3523
  ...request.parentAgentId !== void 0 && request.parentAgentId !== "" && request.parentAgentId !== "agent_main" ? { parent_agent_id: request.parentAgentId } : {},
3508
3524
  parent_tool_call_id: request.parentToolCallId,
@@ -3514,13 +3530,13 @@ async function runSubagentTurn(deps, agentId, request, signal) {
3514
3530
  childContext = new WiredContextState({
3515
3531
  journalWriter: childJournalWriter,
3516
3532
  initialModel: childModel,
3517
- ...childSystemPrompt !== void 0 ? { initialSystemPrompt: childSystemPrompt } : {},
3533
+ initialSystemPrompt: childSystemPrompt,
3518
3534
  currentTurnId: () => `${agentId}_turn`
3519
3535
  });
3520
3536
  childContextRef = childContext;
3521
3537
  } else childContext = new InMemoryContextState({
3522
3538
  initialModel: childModel,
3523
- ...childSystemPrompt !== void 0 ? { initialSystemPrompt: childSystemPrompt } : {}
3539
+ initialSystemPrompt: childSystemPrompt
3524
3540
  });
3525
3541
  const childTurnId = `${agentId}_turn`;
3526
3542
  const baseChildRuntime = { kosong: runtimeSlot?.current().runtime.kosong ?? parentRuntime.kosong };
@@ -3531,7 +3547,7 @@ async function runSubagentTurn(deps, agentId, request, signal) {
3531
3547
  id: agentId,
3532
3548
  kind: "subagent",
3533
3549
  parent_tool_call_id: request.parentToolCallId,
3534
- ...request.agentName !== void 0 ? { name: request.agentName } : {}
3550
+ name: request.agentName
3535
3551
  };
3536
3552
  baseSink = createSubagentSinkWrapper({
3537
3553
  childJournalWriter,
@@ -3679,8 +3695,8 @@ async function runSubagentTurn(deps, agentId, request, signal) {
3679
3695
  if (endReason === "done") turnEndRecord.usage = {
3680
3696
  input_tokens: usage.input,
3681
3697
  output_tokens: usage.output,
3682
- ...usage.cache_read !== void 0 ? { cache_read_tokens: usage.cache_read } : {},
3683
- ...usage.cache_write !== void 0 ? { cache_write_tokens: usage.cache_write } : {}
3698
+ cache_read_tokens: usage.cache_read,
3699
+ cache_write_tokens: usage.cache_write
3684
3700
  };
3685
3701
  await childJournalWriter.append(turnEndRecord);
3686
3702
  } catch {}
@@ -3838,7 +3854,11 @@ var ToolStreamingPrefetchScope = class {
3838
3854
  return;
3839
3855
  }
3840
3856
  if (!safe) return void 0;
3841
- return tool.execute(toolCall.id, toolCall.args, signal);
3857
+ return tool.execute({
3858
+ toolCallId: toolCall.id,
3859
+ args: toolCall.args,
3860
+ signal
3861
+ });
3842
3862
  }
3843
3863
  discard(reason) {
3844
3864
  this.binding?.discardStreaming(reason);
@@ -4236,7 +4256,7 @@ function actionToRulePattern(action, fallbackToolName) {
4236
4256
  //#endregion
4237
4257
  //#region ../../packages/kimi-core/src/soul-plus/permission/before-tool-call.ts
4238
4258
  function buildBeforeToolCall(options) {
4239
- const rules = [...options.rules];
4259
+ const getRules = options.rules;
4240
4260
  const mode = options.mode;
4241
4261
  const approvalRuntime = options.approvalRuntime;
4242
4262
  const approvalSource = options.approvalSource;
@@ -4248,7 +4268,7 @@ function buildBeforeToolCall(options) {
4248
4268
  return async (ctx, signal) => {
4249
4269
  const toolName = ctx.toolCall.name;
4250
4270
  const args = ctx.args;
4251
- const { decision, matchedRule } = checkRulesDetailed(rules, toolName, args, mode);
4271
+ const { decision, matchedRule } = checkRulesDetailed(getRules(), toolName, args, mode());
4252
4272
  if (decision === "allow") return;
4253
4273
  if (decision === "deny") return {
4254
4274
  block: true,
@@ -4270,7 +4290,7 @@ function buildBeforeToolCall(options) {
4270
4290
  action,
4271
4291
  display,
4272
4292
  source: approvalSource,
4273
- ...turnId !== void 0 ? { turnId } : {},
4293
+ turnId,
4274
4294
  step
4275
4295
  }, signal), timeoutMs, signal);
4276
4296
  if (result.approved) return void 0;
@@ -4426,8 +4446,8 @@ var DefaultToolCallUseCase = class {
4426
4446
  this.deps = deps;
4427
4447
  }
4428
4448
  buildBeforeToolCall(context) {
4429
- const rules = context.permissionRules ?? this.deps.policy.getSessionRules();
4430
- const mode = context.permissionMode ?? this.deps.policy.getPermissionMode();
4449
+ const rules = context.permissionRules ?? this.deps.policy.getSessionRules;
4450
+ const mode = context.permissionMode ?? this.deps.policy.getPermissionMode;
4431
4451
  const approvalSource = context.approvalSource ?? approvalSourceForActor(context);
4432
4452
  const permissionClosure = buildBeforeToolCall({
4433
4453
  rules,
@@ -4472,9 +4492,9 @@ var DefaultToolCallUseCase = class {
4472
4492
  stepNumber: btcCtx.stepNumber,
4473
4493
  stepUuid: btcCtx.stepUuid,
4474
4494
  display: {
4475
- ...activityDescription !== void 0 ? { activityDescription } : {},
4476
- ...userFacingName !== void 0 ? { userFacingName } : {},
4477
- ...inputDisplay !== void 0 ? { inputDisplay } : {}
4495
+ activityDescription,
4496
+ userFacingName,
4497
+ inputDisplay
4478
4498
  }
4479
4499
  });
4480
4500
  if (wireUuid !== void 0) btcCtx.toolCallByProviderId?.set(btcCtx.toolCall.id, wireUuid);
@@ -4606,7 +4626,7 @@ var DefaultToolExecutionScopeFactory = class {
4606
4626
  policy: this.deps.policy,
4607
4627
  transcript,
4608
4628
  resultPolicy,
4609
- ...planMode !== void 0 ? { planMode } : {},
4629
+ planMode,
4610
4630
  consumeToolOutcome: (toolCallId) => {
4611
4631
  const outcome = outcomes.get(toolCallId);
4612
4632
  outcomes.delete(toolCallId);
@@ -4618,11 +4638,19 @@ var DefaultToolExecutionScopeFactory = class {
4618
4638
  name: inner.name,
4619
4639
  description: inner.description,
4620
4640
  inputSchema: inner.inputSchema,
4621
- async execute(toolCallId, args, signal, onUpdate, ctx) {
4641
+ async execute(ctx) {
4642
+ const { toolCallId, turnId, args, signal, onUpdate, wireUuid } = ctx;
4622
4643
  try {
4623
4644
  const planModeResult = await maybeExecutePlanFileTool(inner.name, args, planMode);
4624
4645
  if (planModeResult !== void 0) return planModeResult;
4625
- return await inner.execute(toolCallId, args, signal, onUpdate, ctx);
4646
+ return await inner.execute({
4647
+ toolCallId,
4648
+ turnId,
4649
+ args,
4650
+ signal,
4651
+ onUpdate,
4652
+ wireUuid
4653
+ });
4626
4654
  } catch (error) {
4627
4655
  if (isAbortLike(error, signal)) outcomes.set(toolCallId, { kind: "abort" });
4628
4656
  else outcomes.set(toolCallId, {
@@ -4648,9 +4676,9 @@ var DefaultToolExecutionScopeFactory = class {
4648
4676
  actor,
4649
4677
  turnId,
4650
4678
  toolsByName,
4651
- ...permissionRules !== void 0 ? { permissionRules } : {},
4652
- ...permissionMode !== void 0 ? { permissionMode } : {},
4653
- ...approvalSource !== void 0 ? { approvalSource } : {}
4679
+ permissionRules,
4680
+ permissionMode,
4681
+ approvalSource
4654
4682
  };
4655
4683
  return {
4656
4684
  tools: wrappedTools,
@@ -4730,10 +4758,17 @@ function wrapPlanModeTool(inner, planMode) {
4730
4758
  name: inner.name,
4731
4759
  description: inner.description,
4732
4760
  inputSchema: inner.inputSchema,
4733
- async execute(toolCallId, args, signal, onUpdate, ctx) {
4761
+ async execute(ctx) {
4762
+ const { toolCallId, args, signal, onUpdate, wireUuid } = ctx;
4734
4763
  const planModeResult = await maybeExecutePlanFileTool(inner.name, args, planMode);
4735
4764
  if (planModeResult !== void 0) return planModeResult;
4736
- return inner.execute(toolCallId, args, signal, onUpdate, ctx);
4765
+ return inner.execute({
4766
+ toolCallId,
4767
+ args,
4768
+ signal,
4769
+ onUpdate,
4770
+ wireUuid
4771
+ });
4737
4772
  }
4738
4773
  };
4739
4774
  copyToolMetadata(inner, wrapped);
@@ -4857,7 +4892,7 @@ function createSoulRegistryForSession(deps) {
4857
4892
  sessionDir: deps.sessionDir ?? "",
4858
4893
  parentModel: deps.parentModel,
4859
4894
  workDir: deps.workDir ?? process.cwd(),
4860
- ...deps.pathConfig !== void 0 ? { pathConfig: deps.pathConfig } : {},
4895
+ pathConfig: deps.pathConfig,
4861
4896
  sessionId: deps.sessionId,
4862
4897
  parentSessionId: deps.sessionId,
4863
4898
  toolExecutionScopeFactory: deps.toolExecutionScopeFactory ?? createWalOnlyToolExecutionScopeFactory(),
@@ -4901,7 +4936,7 @@ var AgentTool = class {
4901
4936
  this.backgroundManager = backgroundManager;
4902
4937
  this.typeRegistry = typeRegistry;
4903
4938
  }
4904
- async execute(toolCallId, args, signal, _onUpdate, ctx) {
4939
+ async execute({ toolCallId, args, signal, wireUuid }) {
4905
4940
  try {
4906
4941
  const agentName = args.subagent_type?.length ? args.subagent_type : "coder";
4907
4942
  if (args.runInBackground && this.typeRegistry?.has(agentName)) {
@@ -4913,7 +4948,7 @@ var AgentTool = class {
4913
4948
  const request = {
4914
4949
  parentAgentId: this.parentAgentId,
4915
4950
  parentToolCallId: toolCallId,
4916
- ...ctx?.wireUuid !== void 0 ? { parentToolCallUuid: ctx.wireUuid } : {},
4951
+ parentToolCallUuid: wireUuid,
4917
4952
  agentName,
4918
4953
  prompt: args.prompt,
4919
4954
  description: args.description,
@@ -5013,7 +5048,7 @@ var AskUserQuestionTool = class {
5013
5048
  getActivityDescription(_args) {
5014
5049
  return "Asking user a question";
5015
5050
  }
5016
- async execute(toolCallId, args, signal, _onUpdate) {
5051
+ async execute({ toolCallId, args, signal }) {
5017
5052
  if (this.getPermissionMode() === "bypassPermissions") return {
5018
5053
  isError: false,
5019
5054
  content: "{\"answers\": {}, \"note\": \"Running in non-interactive (yolo) mode. Make your own decision.\"}"
@@ -5103,7 +5138,7 @@ var SkillTool = class SkillTool {
5103
5138
  initialQueryDepth
5104
5139
  });
5105
5140
  }
5106
- async execute(_toolCallId, args, signal, _onUpdate) {
5141
+ async execute({ args, turnId }) {
5107
5142
  const currentDepth = this.deps.initialQueryDepth ?? this.deps.queryDepth ?? 0;
5108
5143
  if (currentDepth >= 3) throw new NestedSkillTooDeepError(3, args.skill);
5109
5144
  const skill = this.deps.skillManager.getSkill(args.skill);
@@ -5113,9 +5148,13 @@ var SkillTool = class SkillTool {
5113
5148
  const skillArgs = args.args ?? "";
5114
5149
  const skillType = skill.metadata.type;
5115
5150
  if (skillType !== void 0 && skillType !== "prompt" && skillType !== "inline") return errorResult(`Skill "${skill.name}" is not an inline skill and cannot be invoked by the model in v1.`);
5116
- const trigger = currentDepth === 0 ? "claude-proactive" : "nested-skill";
5117
- await this.deps.inlineWriter.inject(skill, skillArgs, nextDepth, trigger);
5118
- return { content: `Skill "${skill.name}" loaded inline. Follow its instructions.` };
5151
+ return {
5152
+ content: `Skill "${skill.name}" loaded inline. Follow its instructions.`,
5153
+ postContent: async () => {
5154
+ const trigger = currentDepth === 0 ? "claude-proactive" : "nested-skill";
5155
+ await this.deps.inlineWriter.inject(skill, skillArgs, nextDepth, trigger, turnId);
5156
+ }
5157
+ };
5119
5158
  }
5120
5159
  };
5121
5160
  function errorResult(message) {
@@ -5160,7 +5199,7 @@ var EnterPlanModeTool = class {
5160
5199
  getActivityDescription(_args) {
5161
5200
  return "Requesting to enter plan mode";
5162
5201
  }
5163
- async execute(toolCallId, args, signal, _onUpdate) {
5202
+ async execute({ toolCallId, args, signal }) {
5164
5203
  if (this.deps.isPlanModeActive()) return {
5165
5204
  isError: true,
5166
5205
  content: "Plan mode is already active. Use ExitPlanMode when the plan is ready."
@@ -5282,7 +5321,7 @@ var ExitPlanModeTool = class {
5282
5321
  getActivityDescription(_args) {
5283
5322
  return "Presenting plan and exiting plan mode";
5284
5323
  }
5285
- async execute(toolCallId, args, signal, _onUpdate) {
5324
+ async execute({ toolCallId, args, signal }) {
5286
5325
  if (!this.deps.isPlanModeActive()) return {
5287
5326
  isError: true,
5288
5327
  content: "ExitPlanMode can only be called while plan mode is active. Use EnterPlanMode (or /plan) first."
@@ -5385,7 +5424,7 @@ var ExitPlanModeTool = class {
5385
5424
  return {
5386
5425
  ok: true,
5387
5426
  plan: source.plan,
5388
- ...source.path !== void 0 ? { path: source.path } : {}
5427
+ path: source.path
5389
5428
  };
5390
5429
  }
5391
5430
  if (args.plan === void 0 || args.plan.trim().length === 0) return {
@@ -5547,7 +5586,7 @@ async function requestPlanApproval(approvalRuntime, turnState, toolCallId, args,
5547
5586
  display: {
5548
5587
  kind: "plan_review",
5549
5588
  plan: args.plan,
5550
- ...args.path !== void 0 ? { path: args.path } : {},
5589
+ path: args.path,
5551
5590
  ...args.options !== void 0 ? { options: [...args.options] } : {}
5552
5591
  },
5553
5592
  source: approvalSourceForPlanMode(turnState),
@@ -5559,11 +5598,11 @@ async function requestPlanApproval(approvalRuntime, turnState, toolCallId, args,
5559
5598
  };
5560
5599
  if (response.response === "approved") return {
5561
5600
  approved: true,
5562
- ...response.selected_label !== void 0 ? { chosenLabel: response.selected_label } : {}
5601
+ chosenLabel: response.selected_label
5563
5602
  };
5564
5603
  return {
5565
5604
  approved: false,
5566
- ...response.feedback !== void 0 ? { feedback: response.feedback } : {}
5605
+ feedback: response.feedback
5567
5606
  };
5568
5607
  }
5569
5608
  async function requestEnterPlanModeApproval(approvalRuntime, turnState, toolCallId, args, signal) {
@@ -5575,14 +5614,14 @@ async function requestEnterPlanModeApproval(approvalRuntime, turnState, toolCall
5575
5614
  display: {
5576
5615
  kind: "generic",
5577
5616
  summary: "Enter plan mode",
5578
- ...reason !== void 0 ? { detail: reason } : {}
5617
+ detail: reason
5579
5618
  },
5580
5619
  source: approvalSourceForPlanMode(turnState),
5581
5620
  ...turnState.getCurrentTurnId() !== void 0 ? { turnId: turnState.getCurrentTurnId() } : {}
5582
5621
  }, signal);
5583
5622
  return {
5584
5623
  approved: response.approved,
5585
- ...response.feedback !== void 0 ? { feedback: response.feedback } : {}
5624
+ feedback: response.feedback
5586
5625
  };
5587
5626
  }
5588
5627
  function approvalSourceForPlanMode(turnState) {
@@ -5603,8 +5642,7 @@ var SkillInlineWriter = class {
5603
5642
  constructor(deps) {
5604
5643
  this.deps = deps;
5605
5644
  }
5606
- async inject(skill, args, depth, trigger = "claude-proactive") {
5607
- const turnId = this.deps.currentTurnId?.() ?? "pending";
5645
+ async inject(skill, args, depth, trigger = "claude-proactive", turnId) {
5608
5646
  const eventData = {
5609
5647
  skill_name: skill.name,
5610
5648
  execution_mode: "inline",
@@ -5614,7 +5652,7 @@ var SkillInlineWriter = class {
5614
5652
  };
5615
5653
  await this.deps.sessionJournal.appendSkillInvoked({
5616
5654
  type: "skill_invoked",
5617
- turn_id: turnId,
5655
+ turn_id: turnId ?? "pending",
5618
5656
  data: eventData
5619
5657
  });
5620
5658
  this.deps.eventBus?.emit({
@@ -5869,7 +5907,7 @@ function bridgeSummaryMessage(providerSummary, messagesCount, preCompactTokens,
5869
5907
  preCompactTokens,
5870
5908
  postCompactTokens: estimateTokens(providerSummary.content),
5871
5909
  trigger,
5872
- ...archiveFile !== void 0 ? { archiveFile } : {}
5910
+ archiveFile
5873
5911
  };
5874
5912
  }
5875
5913
  //#endregion
@@ -6584,10 +6622,10 @@ var NotificationManager = class {
6584
6622
  title: input.title,
6585
6623
  body: input.body,
6586
6624
  severity: input.severity,
6587
- ...input.payload !== void 0 ? { payload: input.payload } : {},
6625
+ payload: input.payload,
6588
6626
  targets,
6589
- ...input.dedupe_key !== void 0 ? { dedupe_key: input.dedupe_key } : {},
6590
- ...input.envelope_id !== void 0 ? { envelope_id: input.envelope_id } : {}
6627
+ dedupe_key: input.dedupe_key,
6628
+ envelope_id: input.envelope_id
6591
6629
  };
6592
6630
  const deliveredAt = {};
6593
6631
  const wantsLlm = targets.includes("llm");
@@ -6856,14 +6894,14 @@ var SessionMetaService = class {
6856
6894
  session_id: meta.session_id,
6857
6895
  created_at: meta.created_at,
6858
6896
  updated_at: meta.last_updated,
6859
- ...meta.title !== void 0 ? { custom_title: meta.title } : {},
6897
+ custom_title: meta.title,
6860
6898
  ...meta.tags !== void 0 ? { tags: [...meta.tags] } : {},
6861
- ...meta.description !== void 0 ? { description: meta.description } : {},
6862
- ...meta.archived !== void 0 ? { archived: meta.archived } : {},
6863
- ...meta.color !== void 0 ? { color: meta.color } : {},
6864
- ...meta.last_model !== void 0 ? { model: meta.last_model } : {},
6899
+ description: meta.description,
6900
+ archived: meta.archived,
6901
+ color: meta.color,
6902
+ model: meta.last_model,
6865
6903
  turn_count: meta.turn_count,
6866
- ...meta.plan_slug !== void 0 ? { plan_slug: meta.plan_slug } : {},
6904
+ plan_slug: meta.plan_slug,
6867
6905
  ...meta.producer !== void 0 ? { producer: { ...meta.producer } } : {},
6868
6906
  last_exit_code: "dirty"
6869
6907
  }));
@@ -6897,9 +6935,9 @@ function toWirePatch(p) {
6897
6935
  var DynamicInjectionManager = class {
6898
6936
  providers = [];
6899
6937
  onProviderError;
6900
- constructor(deps = {}) {
6901
- if (deps.initialProviders !== void 0) for (const provider of deps.initialProviders) this.register(provider);
6902
- this.onProviderError = deps.onProviderError;
6938
+ constructor(options = {}) {
6939
+ if (options.initialProviders !== void 0) for (const provider of options.initialProviders) this.register(provider);
6940
+ this.onProviderError = options.onProviderError;
6903
6941
  }
6904
6942
  /**
6905
6943
  * Register a provider. Registration is idempotent on `id`: a second
@@ -7255,10 +7293,10 @@ function hasReminderWithoutNewUser(history, fingerprint) {
7255
7293
  * built-in providers (plan-mode + yolo-mode). Hosts that want additional
7256
7294
  * providers can `register` them after construction.
7257
7295
  */
7258
- function createDefaultDynamicInjectionManager(deps = {}) {
7296
+ function createDefaultDynamicInjectionManager(options = {}) {
7259
7297
  return new DynamicInjectionManager({
7260
- ...deps,
7261
- initialProviders: [new PlanModeInjectionProvider(), new YoloModeInjectionProvider()]
7298
+ initialProviders: [new PlanModeInjectionProvider(), new YoloModeInjectionProvider()],
7299
+ ...options
7262
7300
  });
7263
7301
  }
7264
7302
  //#endregion
@@ -7556,7 +7594,7 @@ function flushPart(message, part, toolCallIndexMap) {
7556
7594
  type: "function",
7557
7595
  id: part.id,
7558
7596
  function: part.function,
7559
- ...part.extras !== void 0 ? { extras: part.extras } : {}
7597
+ extras: part.extras
7560
7598
  };
7561
7599
  const arrayIdx = message.toolCalls.length;
7562
7600
  message.toolCalls.push(storedCall);
@@ -20560,7 +20598,7 @@ var TurnManager = class {
20560
20598
  kind: "begin",
20561
20599
  turnId,
20562
20600
  userInput: input.text,
20563
- ...input.parts !== void 0 ? { userInputParts: input.parts } : {},
20601
+ userInputParts: input.parts,
20564
20602
  inputKind: "user",
20565
20603
  agentType: this.agentType
20566
20604
  });
@@ -20607,7 +20645,7 @@ var TurnManager = class {
20607
20645
  permissionMode: this.permissionMode,
20608
20646
  turnNumber: this.extractTurnNumber(turnId),
20609
20647
  history: this.deps.contextState.getHistory(),
20610
- ...planFilePath !== void 0 ? { planFilePath } : {}
20648
+ planFilePath
20611
20649
  };
20612
20650
  const contextBackedWrites = [];
20613
20651
  const injections = manager.computeInjections(ctx, { appendSystemReminder: (data) => {
@@ -20651,12 +20689,12 @@ var TurnManager = class {
20651
20689
  }
20652
20690
  launchTurn(turnId) {
20653
20691
  const controller = this.deps.soulRegistry.getOrCreate("main").abortController;
20654
- const effectiveRules = mergeTurnRules(this.sessionRules, this.pendingTurnOverrides);
20692
+ const turnOverrides = this.pendingTurnOverrides;
20655
20693
  this.pendingTurnOverrides = void 0;
20656
20694
  const approvalSource = this.agentType === "sub" ? {
20657
20695
  kind: "subagent",
20658
20696
  agent_id: this.agentId,
20659
- ...this.subagentType !== void 0 ? { subagent_type: this.subagentType } : {}
20697
+ subagent_type: this.subagentType
20660
20698
  } : {
20661
20699
  kind: "soul",
20662
20700
  agent_id: this.agentId
@@ -20666,7 +20704,7 @@ var TurnManager = class {
20666
20704
  sessionId: this.sessionId,
20667
20705
  agentId: this.agentId,
20668
20706
  kind: this.agentType === "sub" ? "subagent" : this.agentType === "independent" ? "independent" : "main",
20669
- ...this.subagentType !== void 0 ? { subagentType: this.subagentType } : {}
20707
+ subagentType: this.subagentType
20670
20708
  });
20671
20709
  const runtimeBundle = this.runtimeSlot?.current();
20672
20710
  const baseRuntime = runtimeBundle?.runtime ?? this.runtime;
@@ -20676,14 +20714,14 @@ var TurnManager = class {
20676
20714
  const scoped = scope.buildSoulConfig({
20677
20715
  tools: this.deps.tools,
20678
20716
  turnId,
20679
- permissionRules: effectiveRules,
20680
- permissionMode: this.permissionMode,
20717
+ permissionRules: () => mergeTurnRules(this.sessionRules, turnOverrides),
20718
+ permissionMode: () => this.permissionMode,
20681
20719
  approvalSource
20682
20720
  });
20683
20721
  soulConfig = {
20684
20722
  tools: [...scoped.tools],
20685
- ...scoped.beforeToolCall !== void 0 ? { beforeToolCall: scoped.beforeToolCall } : {},
20686
- ...scoped.afterToolCall !== void 0 ? { afterToolCall: scoped.afterToolCall } : {}
20723
+ beforeToolCall: scoped.beforeToolCall,
20724
+ afterToolCall: scoped.afterToolCall
20687
20725
  };
20688
20726
  } else soulConfig = { tools: [...this.deps.tools] };
20689
20727
  const compactionConfig = this.runtimeSlot !== void 0 ? runtimeBundle?.compactionConfig : this.compactionConfig;
@@ -20704,7 +20742,7 @@ var TurnManager = class {
20704
20742
  }, signal);
20705
20743
  if (result.blockAction) return {
20706
20744
  block: true,
20707
- ...result.reason !== void 0 ? { reason: result.reason } : {}
20745
+ reason: result.reason
20708
20746
  };
20709
20747
  },
20710
20748
  afterStep: async (ctx, signal) => {
@@ -20787,7 +20825,7 @@ var TurnManager = class {
20787
20825
  error_type: "internal",
20788
20826
  details: {
20789
20827
  name,
20790
- ...stack !== void 0 ? { stack } : {}
20828
+ stack
20791
20829
  }
20792
20830
  });
20793
20831
  result = void 0;
@@ -20886,7 +20924,7 @@ var TurnManager = class {
20886
20924
  total,
20887
20925
  percent: total > 0 ? Math.max(0, Math.min(100, Math.round(used / total * 100))) : 0
20888
20926
  },
20889
- ...tokenUsage !== void 0 ? { token_usage: tokenUsage } : {},
20927
+ token_usage: tokenUsage,
20890
20928
  plan_mode: this.planMode,
20891
20929
  yolo: this.permissionMode === "bypassPermissions",
20892
20930
  model: this.deps.contextState.model
@@ -20951,10 +20989,10 @@ var SoulPlus = class {
20951
20989
  const eventBus = deps.eventBus;
20952
20990
  const { toolRegistry, hostToolNames, isToolEnabled } = createSoulPlusToolRegistry({
20953
20991
  tools: deps.tools,
20954
- ...deps.enabledToolNames !== void 0 ? { enabledToolNames: deps.enabledToolNames } : {}
20992
+ enabledToolNames: deps.enabledToolNames
20955
20993
  });
20956
20994
  this.hostToolNames = hostToolNames;
20957
- const permissionRules = [];
20995
+ const permissionRules = () => [];
20958
20996
  const stateMachine = deps.lifecycleStateMachine ?? new SessionLifecycleStateMachine();
20959
20997
  const gate = new SoulLifecycleGate(stateMachine);
20960
20998
  const contextState = deps.contextState;
@@ -20965,7 +21003,7 @@ var SoulPlus = class {
20965
21003
  model: contextState.model,
20966
21004
  runtime: deps.runtime,
20967
21005
  compactionProvider: deps.compactionProvider,
20968
- ...deps.compactionConfig !== void 0 ? { compactionConfig: deps.compactionConfig } : {}
21006
+ compactionConfig: deps.compactionConfig
20969
21007
  });
20970
21008
  const runtime = runtimeSlot.current().runtime;
20971
21009
  const approvalRuntime = deps.approvalRuntime;
@@ -20977,8 +21015,8 @@ var SoulPlus = class {
20977
21015
  }) : void 0;
20978
21016
  const planController = new PlanSessionController({
20979
21017
  sessionId: deps.sessionId,
20980
- ...deps.pathConfig !== void 0 ? { paths: deps.pathConfig } : {},
20981
- ...sessionMeta !== void 0 ? { sessionMeta } : {}
21018
+ paths: deps.pathConfig,
21019
+ sessionMeta
20982
21020
  });
20983
21021
  this.planController = planController;
20984
21022
  const compactionProvider = deps.compactionProvider;
@@ -21051,12 +21089,12 @@ var SoulPlus = class {
21051
21089
  dynamicInjectionManager,
21052
21090
  sessionId: deps.sessionId,
21053
21091
  planFilePathProvider: () => planController.getPlanFilePath() ?? void 0,
21054
- ...deps.sessionRules !== void 0 ? { sessionRules: deps.sessionRules } : {},
21055
- ...deps.permissionMode !== void 0 ? { permissionMode: deps.permissionMode } : {},
21056
- ...toolExecutionScopeFactory !== void 0 ? { toolExecutionScopeFactory } : {},
21057
- ...approvalRuntime !== void 0 ? { approvalRuntime } : {},
21058
- ...deps.hookEngine !== void 0 ? { hookEngine: deps.hookEngine } : {},
21059
- ...deps.compactionConfig !== void 0 ? { compactionConfig: deps.compactionConfig } : {}
21092
+ sessionRules: deps.sessionRules,
21093
+ permissionMode: deps.permissionMode,
21094
+ toolExecutionScopeFactory,
21095
+ approvalRuntime,
21096
+ hookEngine: deps.hookEngine,
21097
+ compactionConfig: deps.compactionConfig
21060
21098
  });
21061
21099
  turnManagerRef.bind(turnManager);
21062
21100
  const setPlanMode = createPlanModeSetter({
@@ -21079,8 +21117,8 @@ var SoulPlus = class {
21079
21117
  sessionJournal,
21080
21118
  sessionEventBus: eventBus,
21081
21119
  contextState,
21082
- ...deps.onShellDeliver !== void 0 ? { onShellDeliver: deps.onShellDeliver } : {},
21083
- ...deps.logger !== void 0 ? { logger: deps.logger } : {}
21120
+ onShellDeliver: deps.onShellDeliver,
21121
+ logger: deps.logger
21084
21122
  });
21085
21123
  this.lifecycle = {
21086
21124
  stateMachine,
@@ -21549,7 +21587,8 @@ var KosongAdapter = class {
21549
21587
  const toolCalls = result.message.toolCalls.map((tc) => ({
21550
21588
  id: tc.id,
21551
21589
  name: tc.function.name,
21552
- args: parseToolArgs(tc.function.arguments)
21590
+ rawArgs: tc.function.arguments,
21591
+ ...parseToolArgs(tc.function.arguments)
21553
21592
  }));
21554
21593
  const usage = mapUsage(result.usage);
21555
21594
  const stopReason = mapFinishReason(result.finishReason);
@@ -21558,12 +21597,12 @@ var KosongAdapter = class {
21558
21597
  role: "assistant",
21559
21598
  content: contentBlocks,
21560
21599
  ...toolCalls.length > 0 ? { tool_calls: toolCalls } : {},
21561
- ...stopReason !== void 0 ? { stop_reason: stopReason } : {}
21600
+ stop_reason: stopReason
21562
21601
  },
21563
21602
  toolCalls,
21564
21603
  usage,
21565
21604
  actualModel: activeProvider.modelName,
21566
- ...stopReason !== void 0 ? { stopReason } : {}
21605
+ stopReason
21567
21606
  };
21568
21607
  if (params.contextWindow !== void 0 && usage.input > params.contextWindow) throw new ContextOverflowError(`Implicit context overflow: input=${String(usage.input)} exceeds contextWindow=${String(params.contextWindow)}`, usage);
21569
21608
  return response;
@@ -21609,11 +21648,14 @@ function isRecord$8(value) {
21609
21648
  return typeof value === "object" && value !== null && !Array.isArray(value);
21610
21649
  }
21611
21650
  function parseToolArgs(raw) {
21612
- if (raw === null || raw.length === 0) return {};
21651
+ if (raw === null || raw.length === 0) return { args: {} };
21613
21652
  try {
21614
- return JSON.parse(raw);
21615
- } catch {
21616
- return {};
21653
+ return { args: JSON.parse(raw) };
21654
+ } catch (error) {
21655
+ return {
21656
+ args: {},
21657
+ error: error.message
21658
+ };
21617
21659
  }
21618
21660
  }
21619
21661
  function mapUsage(raw) {
@@ -21986,8 +22028,8 @@ var WiredApprovalRuntime = class {
21986
22028
  return {
21987
22029
  approved: data.response === "approved",
21988
22030
  response: data.response,
21989
- ...data.feedback !== void 0 ? { feedback: data.feedback } : {},
21990
- ...data.selected_label !== void 0 ? { selected_label: data.selected_label } : {}
22031
+ feedback: data.feedback,
22032
+ selected_label: data.selected_label
21991
22033
  };
21992
22034
  }
21993
22035
  resolve(requestId, response) {
@@ -22009,7 +22051,7 @@ var WiredApprovalRuntime = class {
22009
22051
  data: {
22010
22052
  request_id: requestId,
22011
22053
  response: response.response,
22012
- ...response.feedback !== void 0 ? { feedback: response.feedback } : {},
22054
+ feedback: response.feedback,
22013
22055
  ...response.selected_label !== void 0 ? { selected_label: response.selected_label } : {}
22014
22056
  }
22015
22057
  };
@@ -22017,8 +22059,8 @@ var WiredApprovalRuntime = class {
22017
22059
  const result = {
22018
22060
  approved: response.response === "approved",
22019
22061
  response: response.response,
22020
- ...response.feedback !== void 0 ? { feedback: response.feedback } : {},
22021
- ...response.selected_label !== void 0 ? { selected_label: response.selected_label } : {}
22062
+ feedback: response.feedback,
22063
+ selected_label: response.selected_label
22022
22064
  };
22023
22065
  entry.deferred.resolve(result);
22024
22066
  for (const target of cascadeTargets) queueMicrotask(() => {
@@ -22302,7 +22344,7 @@ var ThinkTool = class {
22302
22344
  metadata = { source: "builtin" };
22303
22345
  description = DESCRIPTION$3;
22304
22346
  inputSchema = ThinkInputSchema;
22305
- async execute(_toolCallId, _args, _signal, _onUpdate) {
22347
+ async execute(_ctx) {
22306
22348
  return {
22307
22349
  content: "",
22308
22350
  isError: false
@@ -22540,7 +22582,7 @@ var BackgroundProcessManager = class {
22540
22582
  endedAt: null,
22541
22583
  waiters: [],
22542
22584
  terminalFired: false,
22543
- ...this.sessionDir !== void 0 ? { outputSessionDir: this.sessionDir } : {},
22585
+ outputSessionDir: this.sessionDir,
22544
22586
  persistWriteQueue: Promise.resolve(),
22545
22587
  outputWriteQueue: Promise.resolve()
22546
22588
  };
@@ -22958,7 +23000,7 @@ var TaskListTool = class {
22958
23000
  constructor(manager) {
22959
23001
  this.manager = manager;
22960
23002
  }
22961
- async execute(_toolCallId, args, _signal, _onUpdate) {
23003
+ async execute({ args }) {
22962
23004
  return {
22963
23005
  content: formatTaskList(this.manager.list(args.active_only ?? true, args.limit ?? 20)),
22964
23006
  isError: false
@@ -22984,7 +23026,7 @@ var TaskOutputTool = class {
22984
23026
  constructor(manager) {
22985
23027
  this.manager = manager;
22986
23028
  }
22987
- async execute(_toolCallId, args, _signal, _onUpdate) {
23029
+ async execute({ args }) {
22988
23030
  const info = this.manager.getTask(args.task_id);
22989
23031
  if (!info) return {
22990
23032
  isError: true,
@@ -23028,7 +23070,7 @@ var TaskStopTool = class {
23028
23070
  constructor(manager) {
23029
23071
  this.manager = manager;
23030
23072
  }
23031
- async execute(_toolCallId, args, _signal, _onUpdate) {
23073
+ async execute({ args }) {
23032
23074
  const info = this.manager.getTask(args.task_id);
23033
23075
  if (!info) return {
23034
23076
  isError: true,
@@ -23068,7 +23110,7 @@ var WebSearchTool = class {
23068
23110
  constructor(provider) {
23069
23111
  this.provider = provider;
23070
23112
  }
23071
- async execute(toolCallId, args, _signal, _onUpdate) {
23113
+ async execute({ toolCallId, args }) {
23072
23114
  try {
23073
23115
  const opts = { toolCallId };
23074
23116
  if (args.limit !== void 0) opts.limit = args.limit;
@@ -23116,7 +23158,7 @@ var FetchURLTool = class {
23116
23158
  constructor(fetcher) {
23117
23159
  this.fetcher = fetcher;
23118
23160
  }
23119
- async execute(toolCallId, args, _signal, _onUpdate) {
23161
+ async execute({ toolCallId, args }) {
23120
23162
  try {
23121
23163
  const opts = { toolCallId };
23122
23164
  if (args.format !== void 0) opts.format = args.format;
@@ -23647,7 +23689,7 @@ var ReadMediaFileTool = class {
23647
23689
  this.capabilities = capabilities;
23648
23690
  this.description = buildDescription(capabilities);
23649
23691
  }
23650
- async execute(_toolCallId, args, _signal, _onUpdate) {
23692
+ async execute({ args }) {
23651
23693
  if (!args.path) return {
23652
23694
  isError: true,
23653
23695
  content: "File path cannot be empty."
@@ -23716,7 +23758,7 @@ var ReadMediaFileTool = class {
23716
23758
  type: "url",
23717
23759
  url: uploaded.url,
23718
23760
  media_type: fileType.mimeType,
23719
- ...uploaded.id !== void 0 ? { id: uploaded.id } : {}
23761
+ id: uploaded.id
23720
23762
  }
23721
23763
  };
23722
23764
  } else mediaPart = {
@@ -23974,7 +24016,7 @@ var ReadTool = class {
23974
24016
  this.kaos = kaos;
23975
24017
  this.workspace = workspace;
23976
24018
  }
23977
- async execute(_toolCallId, args, _signal, _onUpdate) {
24019
+ async execute({ args }) {
23978
24020
  let safePath;
23979
24021
  try {
23980
24022
  safePath = resolvePathAccess(args.path, this.workspace.workspaceDir, this.workspace, {
@@ -24063,7 +24105,7 @@ var WriteTool = class {
24063
24105
  this.workspace = workspace;
24064
24106
  this.planModeChecker = options?.planModeChecker;
24065
24107
  }
24066
- async execute(_toolCallId, args, _signal, _onUpdate) {
24108
+ async execute({ args }) {
24067
24109
  if (this.planModeChecker?.isPlanModeActive() === true) {
24068
24110
  const planPath = this.planModeChecker.getPlanFilePath();
24069
24111
  if (planPath === null || resolve(args.path) !== resolve(planPath)) return {
@@ -24136,7 +24178,7 @@ var EditTool = class {
24136
24178
  this.workspace = workspace;
24137
24179
  this.planModeChecker = options?.planModeChecker;
24138
24180
  }
24139
- async execute(_toolCallId, args, _signal, _onUpdate) {
24181
+ async execute({ args }) {
24140
24182
  if (this.planModeChecker?.isPlanModeActive() === true) {
24141
24183
  const planPath = this.planModeChecker.getPlanFilePath();
24142
24184
  if (planPath === null || resolve(args.path) !== resolve(planPath)) return {
@@ -24294,8 +24336,8 @@ var ShellTool = class {
24294
24336
  kind: "command",
24295
24337
  command: input.command,
24296
24338
  language,
24297
- ...input.cwd !== void 0 ? { cwd: input.cwd } : {},
24298
- ...input.description !== void 0 ? { description: input.description } : {}
24339
+ cwd: input.cwd,
24340
+ description: input.description
24299
24341
  }),
24300
24342
  getResultDisplay: (_input, result) => ({
24301
24343
  kind: "command_output",
@@ -24332,7 +24374,7 @@ var ShellTool = class {
24332
24374
  };
24333
24375
  return this.kaos.execWithEnv([...args], mergedEnv);
24334
24376
  }
24335
- async execute(_toolCallId, args, signal, _onUpdate) {
24377
+ async execute({ args, signal }) {
24336
24378
  if (signal.aborted) return {
24337
24379
  isError: true,
24338
24380
  content: "Aborted before command started"
@@ -28883,7 +28925,7 @@ var GrepTool = class {
28883
28925
  this.kaos = kaos;
28884
28926
  this.workspace = workspace;
28885
28927
  }
28886
- async execute(_toolCallId, args, signal, _onUpdate) {
28928
+ async execute({ args, signal }) {
28887
28929
  if (signal.aborted) return {
28888
28930
  isError: true,
28889
28931
  content: "Aborted before search started"
@@ -29283,7 +29325,7 @@ var GlobTool = class {
29283
29325
  this.kaos = kaos;
29284
29326
  this.workspace = workspace;
29285
29327
  }
29286
- async execute(_toolCallId, args, _signal, _onUpdate) {
29328
+ async execute({ args }) {
29287
29329
  if (isPureWildcard(args.pattern)) {
29288
29330
  const dirList = [this.workspace.workspaceDir, ...this.workspace.additionalDirs].map((d) => ` - ${d}`).join("\n");
29289
29331
  let tree;
@@ -29523,7 +29565,7 @@ var SetTodoListTool = class {
29523
29565
  if (args.todos.length === 0) return "Clearing todo list";
29524
29566
  return "Updating todo list";
29525
29567
  }
29526
- async execute(_toolCallId, args, _signal, _onUpdate) {
29568
+ async execute({ args }) {
29527
29569
  if (args.todos === void 0) {
29528
29570
  const current = this.store.getTodos();
29529
29571
  return {
@@ -29752,7 +29794,7 @@ function createWireRequest(options) {
29752
29794
  from: options.from ?? "client",
29753
29795
  to: options.to ?? "core",
29754
29796
  method: options.method,
29755
- ...options.data !== void 0 ? { data: options.data } : {}
29797
+ data: options.data
29756
29798
  };
29757
29799
  }
29758
29800
  function createWireResponse(options) {
@@ -29764,8 +29806,8 @@ function createWireResponse(options) {
29764
29806
  from: options.from ?? "core",
29765
29807
  to: options.to ?? "client",
29766
29808
  ...options.requestId !== void 0 && options.requestId !== "" ? { request_id: options.requestId } : {},
29767
- ...options.data !== void 0 ? { data: options.data } : {},
29768
- ...options.error !== void 0 ? { error: options.error } : {}
29809
+ data: options.data,
29810
+ error: options.error
29769
29811
  };
29770
29812
  }
29771
29813
  function createWireEvent(options) {
@@ -29779,10 +29821,10 @@ function createWireEvent(options) {
29779
29821
  method: options.method,
29780
29822
  seq: options.seq,
29781
29823
  ...options.requestId !== void 0 && options.requestId !== "" ? { request_id: options.requestId } : {},
29782
- ...options.turnId !== void 0 ? { turn_id: options.turnId } : {},
29783
- ...options.agentType !== void 0 ? { agent_type: options.agentType } : {},
29784
- ...options.source !== void 0 ? { source: options.source } : {},
29785
- ...options.data !== void 0 ? { data: options.data } : {}
29824
+ turn_id: options.turnId,
29825
+ agent_type: options.agentType,
29826
+ source: options.source,
29827
+ data: options.data
29786
29828
  };
29787
29829
  }
29788
29830
  //#endregion
@@ -29868,10 +29910,10 @@ var WireEventPipeline = class {
29868
29910
  method: ctx.draft.method,
29869
29911
  sessionId: ctx.sessionId,
29870
29912
  seq: this.seq++,
29871
- ...ctx.draft.requestId !== void 0 ? { requestId: ctx.draft.requestId } : {},
29872
- ...ctx.draft.turnId !== void 0 ? { turnId: ctx.draft.turnId } : {},
29913
+ requestId: ctx.draft.requestId,
29914
+ turnId: ctx.draft.turnId,
29873
29915
  agentType: ctx.draft.agentType ?? "main",
29874
- ...ctx.draft.source !== void 0 ? { source: ctx.draft.source } : {},
29916
+ source: ctx.draft.source,
29875
29917
  data: ctx.draft.data
29876
29918
  });
29877
29919
  await next();
@@ -29929,8 +29971,8 @@ function draft(event, ctx, method, data) {
29929
29971
  return {
29930
29972
  method,
29931
29973
  data,
29932
- ...ctx.currentTurnId !== void 0 ? { turnId: ctx.currentTurnId } : {},
29933
- ...event.source !== void 0 ? { source: event.source } : {}
29974
+ turnId: ctx.currentTurnId,
29975
+ source: event.source
29934
29976
  };
29935
29977
  }
29936
29978
  const BUS_EVENT_TRANSLATORS = {
@@ -29961,7 +30003,7 @@ const BUS_EVENT_TRANSLATORS = {
29961
30003
  tool_call_part: (event, ctx) => {
29962
30004
  return draft(event, ctx, "tool.call.delta", {
29963
30005
  tool_call_id: event.tool_call_id,
29964
- ...event.name !== void 0 ? { name: event.name } : {},
30006
+ name: event.name,
29965
30007
  arguments_part: event.arguments_chunk ?? null
29966
30008
  });
29967
30009
  },
@@ -29980,7 +30022,7 @@ const BUS_EVENT_TRANSLATORS = {
29980
30022
  return draft(event, ctx, "tool.result", {
29981
30023
  tool_call_id: event.toolCallId,
29982
30024
  output: event.output,
29983
- ...event.isError !== void 0 ? { is_error: event.isError } : {}
30025
+ is_error: event.isError
29984
30026
  });
29985
30027
  },
29986
30028
  "compaction.begin": (event, ctx) => {
@@ -29988,16 +30030,16 @@ const BUS_EVENT_TRANSLATORS = {
29988
30030
  },
29989
30031
  "compaction.end": (event, ctx) => {
29990
30032
  return draft(event, ctx, "compaction.end", {
29991
- ...event.tokensBefore !== void 0 ? { tokens_before: event.tokensBefore } : {},
29992
- ...event.tokensAfter !== void 0 ? { tokens_after: event.tokensAfter } : {}
30033
+ tokens_before: event.tokensBefore,
30034
+ tokens_after: event.tokensAfter
29993
30035
  });
29994
30036
  },
29995
30037
  "session.error": (event, ctx) => {
29996
30038
  return draft(event, ctx, "session.error", {
29997
30039
  error: event.error,
29998
- ...event.error_type !== void 0 ? { error_type: event.error_type } : {},
29999
- ...event.retry_after_ms !== void 0 ? { retry_after_ms: event.retry_after_ms } : {},
30000
- ...event.details !== void 0 ? { details: event.details } : {}
30040
+ error_type: event.error_type,
30041
+ retry_after_ms: event.retry_after_ms,
30042
+ details: event.details
30001
30043
  });
30002
30044
  },
30003
30045
  "hook.triggered": (event, ctx) => draft(event, ctx, "hook.triggered", {
@@ -30086,7 +30128,7 @@ function installWireEventBridge(opts) {
30086
30128
  const pipeline = new WireEventPipeline({
30087
30129
  sessionId,
30088
30130
  transport: server,
30089
- ...getEventFilter !== void 0 ? { getEventFilter } : {}
30131
+ getEventFilter
30090
30132
  });
30091
30133
  const soulListener = (event) => {
30092
30134
  const draft = translateBusEvent(event, currentTurnId);
@@ -30442,13 +30484,13 @@ async function readSubagentReplay(options) {
30442
30484
  id: agentId,
30443
30485
  parent_session_id: options.parentSessionId,
30444
30486
  parent_tool_call_id: spawned.data.parent_tool_call_id,
30445
- ...name !== void 0 ? { name } : {}
30487
+ name
30446
30488
  };
30447
30489
  const source = {
30448
30490
  id: agentId,
30449
30491
  kind: "subagent",
30450
30492
  parent_tool_call_id: spawned.data.parent_tool_call_id,
30451
- ...name !== void 0 ? { name } : {}
30493
+ name
30452
30494
  };
30453
30495
  const childRecords = [init, ...childReplay.records];
30454
30496
  for (const record of childRecords) records.push({
@@ -30591,7 +30633,7 @@ var DefaultSessionApplicationService = class {
30591
30633
  input.prepare?.({
30592
30634
  sessionId,
30593
30635
  eventBus,
30594
- ...hookEngine !== void 0 ? { hookEngine } : {}
30636
+ hookEngine
30595
30637
  });
30596
30638
  const systemPrompt = input.systemPrompt ?? this.deps.defaultSystemPromptProvider?.();
30597
30639
  const enabledToolNames = this.deps.enabledToolNamesProvider?.();
@@ -30611,22 +30653,22 @@ var DefaultSessionApplicationService = class {
30611
30653
  const managed = await this.deps.sessionManager.createSession({
30612
30654
  sessionId,
30613
30655
  runtime,
30614
- ...runtimeSlot !== void 0 ? { runtimeSlot } : {},
30656
+ runtimeSlot,
30615
30657
  tools: this.deps.toolsProvider(),
30616
- ...enabledToolNames !== void 0 ? { enabledToolNames } : {},
30658
+ enabledToolNames,
30617
30659
  model,
30618
- ...systemPrompt !== void 0 ? { systemPrompt } : {},
30660
+ systemPrompt,
30619
30661
  eventBus,
30620
30662
  workspaceDir: this.deps.workspaceDir,
30621
30663
  compactionProvider,
30622
- ...compactionConfig !== void 0 ? { compactionConfig } : {},
30664
+ compactionConfig,
30623
30665
  ...this.deps.approvalRuntime !== void 0 ? { approvalRuntime: this.deps.approvalRuntime } : {},
30624
30666
  ...this.deps.approvalRuntimeFactory !== void 0 ? { approvalRuntimeFactory: this.deps.approvalRuntimeFactory } : {},
30625
- ...hookEngine !== void 0 ? { hookEngine } : {},
30626
- ...this.deps.skillManager !== void 0 ? { skillManager: this.deps.skillManager } : {},
30667
+ hookEngine,
30668
+ skillManager: this.deps.skillManager,
30627
30669
  ...this.deps.agentTypeRegistry !== void 0 ? { agentTypeRegistry: this.deps.agentTypeRegistry } : {},
30628
30670
  ...this.deps.questionRuntimeProvider !== void 0 ? { questionRuntime: this.deps.questionRuntimeProvider({ sessionId }) } : {},
30629
- ...this.deps.logger !== void 0 ? { logger: this.deps.logger } : {}
30671
+ logger: this.deps.logger
30630
30672
  });
30631
30673
  this.deps.sessionLifecycle?.onSessionCreated?.(managed);
30632
30674
  return {
@@ -30643,7 +30685,7 @@ var DefaultSessionApplicationService = class {
30643
30685
  input?.prepare?.({
30644
30686
  sessionId,
30645
30687
  eventBus,
30646
- ...hookEngine !== void 0 ? { hookEngine } : {}
30688
+ hookEngine
30647
30689
  });
30648
30690
  const initialModel = (await new StateCache(this.deps.pathConfig.statePath(sessionId)).read())?.model ?? this.deps.defaultModelProvider();
30649
30691
  const runtimeBundle = await this.deps.runtimeBundleProvider?.({
@@ -30660,18 +30702,18 @@ var DefaultSessionApplicationService = class {
30660
30702
  const runtimeSlot = runtimeSlotBundle !== void 0 ? createSessionRuntimeSlot(runtimeSlotBundle) : void 0;
30661
30703
  const managed = await this.deps.sessionManager.resumeSession(sessionId, {
30662
30704
  runtime,
30663
- ...runtimeSlot !== void 0 ? { runtimeSlot } : {},
30705
+ runtimeSlot,
30664
30706
  tools: this.deps.toolsProvider(),
30665
30707
  eventBus,
30666
30708
  compactionProvider,
30667
- ...compactionConfig !== void 0 ? { compactionConfig } : {},
30709
+ compactionConfig,
30668
30710
  ...this.deps.approvalRuntime !== void 0 ? { approvalRuntime: this.deps.approvalRuntime } : {},
30669
30711
  ...this.deps.approvalRuntimeFactory !== void 0 ? { approvalRuntimeFactory: this.deps.approvalRuntimeFactory } : {},
30670
- ...hookEngine !== void 0 ? { hookEngine } : {},
30671
- ...this.deps.skillManager !== void 0 ? { skillManager: this.deps.skillManager } : {},
30712
+ hookEngine,
30713
+ skillManager: this.deps.skillManager,
30672
30714
  ...this.deps.agentTypeRegistry !== void 0 ? { agentTypeRegistry: this.deps.agentTypeRegistry } : {},
30673
30715
  ...this.deps.questionRuntimeProvider !== void 0 ? { questionRuntime: this.deps.questionRuntimeProvider({ sessionId }) } : {},
30674
- ...this.deps.logger !== void 0 ? { logger: this.deps.logger } : {}
30716
+ logger: this.deps.logger
30675
30717
  });
30676
30718
  const runtimeBundleProvider = this.deps.runtimeBundleProvider;
30677
30719
  if (runtimeSlot !== void 0 && runtimeBundleProvider !== void 0 && managed.contextState.model !== runtimeSlot.current().model) {
@@ -30733,7 +30775,7 @@ var DefaultSessionApplicationService = class {
30733
30775
  return {
30734
30776
  session_id: sessionId,
30735
30777
  turn_count: turnCount,
30736
- ...lastTurnId !== void 0 ? { last_turn_id: lastTurnId } : {},
30778
+ last_turn_id: lastTurnId,
30737
30779
  status,
30738
30780
  ...planPath !== null ? { plan_path: planPath } : {}
30739
30781
  };
@@ -30767,7 +30809,7 @@ var DefaultSessionApplicationService = class {
30767
30809
  return readSessionReplay({
30768
30810
  sessionId,
30769
30811
  pathConfig: this.deps.pathConfig,
30770
- ...fromSeq !== void 0 ? { fromSeq } : {}
30812
+ fromSeq
30771
30813
  });
30772
30814
  }
30773
30815
  rollback(sessionId, nTurnsBack) {
@@ -30964,7 +31006,7 @@ var SessionStateApprovalStateStore = class {
30964
31006
  created_at: now,
30965
31007
  updated_at: now
30966
31008
  },
30967
- ...nextActions !== void 0 ? { auto_approve_actions: nextActions } : {},
31009
+ auto_approve_actions: nextActions,
30968
31010
  permission_mode: nextMode
30969
31011
  };
30970
31012
  await this.stateCache.write(next);
@@ -30992,9 +31034,9 @@ function createWireHookSender(opts) {
30992
31034
  requestId: message.requestId,
30993
31035
  result: {
30994
31036
  ok: data.ok ?? true,
30995
- ...blockAction !== void 0 ? { blockAction } : {},
30996
- ...data.reason !== void 0 ? { reason: data.reason } : {},
30997
- ...additionalContext !== void 0 ? { additionalContext } : {}
31037
+ blockAction,
31038
+ reason: data.reason,
31039
+ additionalContext
30998
31040
  }
30999
31041
  };
31000
31042
  } };
@@ -31027,14 +31069,14 @@ function createWireQuestionRuntime(reverse, sessionId) {
31027
31069
  tool_call_id: req.toolCallId,
31028
31070
  questions: req.questions.map((question) => ({
31029
31071
  question: question.question,
31030
- ...question.header !== void 0 ? { header: question.header } : {},
31031
- ...question.body !== void 0 ? { body: question.body } : {},
31072
+ header: question.header,
31073
+ body: question.body,
31032
31074
  multi_select: question.multiSelect ?? false,
31033
- ...question.otherLabel !== void 0 ? { other_label: question.otherLabel } : {},
31075
+ other_label: question.otherLabel,
31034
31076
  ...question.otherDescription !== void 0 ? { other_description: question.otherDescription } : {},
31035
31077
  options: question.options.map((option) => ({
31036
31078
  label: option.label,
31037
- ...option.description !== void 0 ? { description: option.description } : {}
31079
+ description: option.description
31038
31080
  }))
31039
31081
  }))
31040
31082
  }, { signal: req.signal })).data ?? {};
@@ -31350,7 +31392,7 @@ const CONVERSATION_HANDLER_DESCRIPTORS = [
31350
31392
  }
31351
31393
  const dispatch = await ctx.sessionApplication.prompt(msg.session_id, {
31352
31394
  text: inputText,
31353
- ...inputParts !== void 0 ? { parts: inputParts } : {}
31395
+ parts: inputParts
31354
31396
  });
31355
31397
  return createWireResponse({
31356
31398
  requestId: msg.id,
@@ -31401,8 +31443,8 @@ const CONVERSATION_HANDLER_DESCRIPTORS = [
31401
31443
  (ctx.approvalRuntimesBySession.get(msg.session_id) ?? ctx.approval)?.resolveRemote({
31402
31444
  request_id: payload.request_id,
31403
31445
  response: payload.response,
31404
- ...payload.feedback !== void 0 ? { feedback: payload.feedback } : {},
31405
- ...payload.scope !== void 0 ? { scope: payload.scope } : {}
31446
+ feedback: payload.feedback,
31447
+ scope: payload.scope
31406
31448
  });
31407
31449
  } catch {}
31408
31450
  return createWireResponse({
@@ -31763,9 +31805,9 @@ const PROCESS_HANDLER_DESCRIPTORS = [
31763
31805
  ctx.router.registerProcessMethod("session.create", async (msg) => {
31764
31806
  const payload = msg.data ?? {};
31765
31807
  const data = { session_id: (await ctx.sessionApplication.createSession({
31766
- ...payload.session_id !== void 0 ? { sessionId: payload.session_id } : {},
31767
- ...payload.model !== void 0 ? { model: payload.model } : {},
31768
- ...payload.system_prompt !== void 0 ? { systemPrompt: payload.system_prompt } : {},
31808
+ sessionId: payload.session_id,
31809
+ model: payload.model,
31810
+ systemPrompt: payload.system_prompt,
31769
31811
  prepare: ({ sessionId, hookEngine: sessionHookEngine }) => {
31770
31812
  prepareSessionHooks(ctx, sessionId, sessionHookEngine);
31771
31813
  }
@@ -31847,7 +31889,7 @@ function buildExternalToolProxy(options) {
31847
31889
  source: "external",
31848
31890
  originalName: options.name
31849
31891
  },
31850
- async execute(toolCallId, args, signal) {
31892
+ async execute({ toolCallId, args, signal }) {
31851
31893
  try {
31852
31894
  const response = await options.sendToolCall({
31853
31895
  id: toolCallId,
@@ -31898,7 +31940,7 @@ const TOOLS_HANDLER_DESCRIPTORS = [
31898
31940
  })).data ?? {};
31899
31941
  return {
31900
31942
  output: data.output ?? "",
31901
- ...data.is_error !== void 0 ? { is_error: data.is_error } : {}
31943
+ is_error: data.is_error
31902
31944
  };
31903
31945
  }
31904
31946
  }));
@@ -32067,9 +32109,9 @@ function createWireApprovalRuntimeFactory(reverse, runtimesBySession) {
32067
32109
  const parsed = ApprovalDecisionSchema.parse(reply.data ?? {});
32068
32110
  const decision = {
32069
32111
  response: parsed.response,
32070
- ...parsed.feedback !== void 0 ? { feedback: parsed.feedback } : {},
32112
+ feedback: parsed.feedback,
32071
32113
  ...parsed.selected_label !== void 0 ? { selected_label: parsed.selected_label } : {},
32072
- ...parsed.scope !== void 0 ? { scope: parsed.scope } : {}
32114
+ scope: parsed.scope
32073
32115
  };
32074
32116
  runtime.resolveRemote({
32075
32117
  request_id: frame.data.request_id,
@@ -32111,15 +32153,15 @@ function registerDefaultWireHandlers(deps) {
32111
32153
  ...deps.compactionConfigProvider !== void 0 ? { compactionConfigProvider: deps.compactionConfigProvider } : {},
32112
32154
  ...deps.runtimeBundleProvider !== void 0 ? { runtimeBundleProvider: deps.runtimeBundleProvider } : {},
32113
32155
  eventBusProvider: () => eventBusProvider?.() ?? eventBus,
32114
- ...approvalRuntime !== void 0 ? { approvalRuntime } : {},
32115
- ...approvalRuntimeFactory !== void 0 ? { approvalRuntimeFactory } : {},
32156
+ approvalRuntime,
32157
+ approvalRuntimeFactory,
32116
32158
  workspaceDir,
32117
- ...approvalStateStore !== void 0 ? { approvalStateStore } : {},
32118
- ...deps.skillManager !== void 0 ? { skillManager: deps.skillManager } : {},
32119
- ...deps.agentTypeRegistry !== void 0 ? { agentTypeRegistry: deps.agentTypeRegistry } : {},
32159
+ approvalStateStore,
32160
+ skillManager: deps.skillManager,
32161
+ agentTypeRegistry: deps.agentTypeRegistry,
32120
32162
  questionRuntimeProvider: ({ sessionId }) => reverse !== void 0 ? createWireQuestionRuntime(reverse, sessionId) : void 0,
32121
- ...rebuildRuntimeForModel !== void 0 ? { rebuildRuntimeForModel } : {},
32122
- ...backgroundProcessManager !== void 0 ? { backgroundProcessManager } : {},
32163
+ rebuildRuntimeForModel,
32164
+ backgroundProcessManager,
32123
32165
  sessionLifecycle: {
32124
32166
  onSessionCreated: (managed) => deps.sessionLifecycle?.onSessionCreated?.(managed),
32125
32167
  onSessionDestroyed: (sessionId) => {
@@ -32132,7 +32174,7 @@ function registerDefaultWireHandlers(deps) {
32132
32174
  sessionId,
32133
32175
  eventBus: sessionEventBus
32134
32176
  }) ?? hookEngine,
32135
- ...deps.logger !== void 0 ? { logger: deps.logger } : {}
32177
+ logger: deps.logger
32136
32178
  });
32137
32179
  const initialHooksRef = { current: [] };
32138
32180
  const handlerContext = {
@@ -32141,16 +32183,16 @@ function registerDefaultWireHandlers(deps) {
32141
32183
  sessionState,
32142
32184
  supportedWireEvents: SUPPORTED_WIRE_EVENTS,
32143
32185
  supportedWireMethods: SUPPORTED_WIRE_METHODS,
32144
- ...reverse !== void 0 ? { reverse } : {},
32145
- ...authService !== void 0 ? { authService } : {},
32146
- ...mcpRegistry !== void 0 ? { mcpRegistry } : {},
32147
- ...modelsProvider !== void 0 ? { modelsProvider } : {},
32148
- ...configProvider !== void 0 ? { configProvider } : {},
32186
+ reverse,
32187
+ authService,
32188
+ mcpRegistry,
32189
+ modelsProvider,
32190
+ configProvider,
32149
32191
  defaultModel,
32150
32192
  ...deps.defaultModelProvider !== void 0 ? { defaultModelProvider: deps.defaultModelProvider } : {},
32151
- ...hookEngine !== void 0 ? { hookEngine } : {},
32193
+ hookEngine,
32152
32194
  usesPerSessionHookEngine: hookEngineProvider !== void 0,
32153
- ...approvalRuntime !== void 0 ? { approval: approvalRuntime } : {},
32195
+ approval: approvalRuntime,
32154
32196
  approvalRuntimesBySession,
32155
32197
  initialHooksRef,
32156
32198
  registerWireHooksForSession
@@ -32923,16 +32965,16 @@ async function readSessionInfo(paths, sessionId) {
32923
32965
  if (state !== null) return {
32924
32966
  session_id: state.session_id,
32925
32967
  created_at: state.created_at,
32926
- ...state.model !== void 0 ? { model: state.model } : {},
32927
- ...state.workspace_dir !== void 0 ? { workspace_dir: state.workspace_dir } : {},
32928
- ...state.custom_title !== void 0 ? { title: state.custom_title } : {},
32929
- ...lastActivity !== void 0 ? { last_activity: lastActivity } : {},
32930
- ...state.producer !== void 0 ? { producer: state.producer } : {}
32968
+ model: state.model,
32969
+ workspace_dir: state.workspace_dir,
32970
+ title: state.custom_title,
32971
+ last_activity: lastActivity,
32972
+ producer: state.producer
32931
32973
  };
32932
32974
  return {
32933
32975
  session_id: sessionId,
32934
32976
  created_at: 0,
32935
- ...lastActivity !== void 0 ? { last_activity: lastActivity } : {}
32977
+ last_activity: lastActivity
32936
32978
  };
32937
32979
  }
32938
32980
  //#endregion
@@ -33206,7 +33248,7 @@ var SessionManager = class {
33206
33248
  const contextState = new WiredContextState({
33207
33249
  journalWriter,
33208
33250
  initialModel: options.model,
33209
- ...options.systemPrompt !== void 0 ? { initialSystemPrompt: options.systemPrompt } : {},
33251
+ initialSystemPrompt: options.systemPrompt,
33210
33252
  currentTurnId: () => turnManagerRef?.getCurrentTurnId() ?? "no_turn"
33211
33253
  });
33212
33254
  contextStateRef = contextState;
@@ -33248,8 +33290,8 @@ var SessionManager = class {
33248
33290
  ...options.enabledToolNames !== void 0 ? { enabledToolNames: options.enabledToolNames } : {},
33249
33291
  lifecycleStateMachine,
33250
33292
  producer: this.producer,
33251
- ...options.onShellDeliver !== void 0 ? { onShellDeliver: options.onShellDeliver } : {},
33252
- ...options.skillManager !== void 0 ? { skillManager: options.skillManager } : {},
33293
+ onShellDeliver: options.onShellDeliver,
33294
+ skillManager: options.skillManager,
33253
33295
  ...options.questionRuntime !== void 0 ? { questionRuntime: options.questionRuntime } : {},
33254
33296
  ...runtimeBundle.compactionConfig !== void 0 ? { compactionConfig: runtimeBundle.compactionConfig } : {},
33255
33297
  compactionProvider: runtimeBundle.compactionProvider,
@@ -33258,11 +33300,11 @@ var SessionManager = class {
33258
33300
  journalWriter,
33259
33301
  producer: this.producer
33260
33302
  }),
33261
- ...approvalRuntime !== void 0 ? { approvalRuntime } : {},
33262
- ...options.hookEngine !== void 0 ? { hookEngine: options.hookEngine } : {},
33303
+ approvalRuntime,
33304
+ hookEngine: options.hookEngine,
33263
33305
  ...options.toolExecutionScopeFactory !== void 0 ? { toolExecutionScopeFactory: options.toolExecutionScopeFactory } : {},
33264
- ...options.sessionRules !== void 0 ? { sessionRules: options.sessionRules } : {},
33265
- ...options.permissionMode !== void 0 ? { permissionMode: options.permissionMode } : {},
33306
+ sessionRules: options.sessionRules,
33307
+ permissionMode: options.permissionMode,
33266
33308
  stateCache,
33267
33309
  initialMeta,
33268
33310
  pathConfig: this.paths,
@@ -33273,7 +33315,7 @@ var SessionManager = class {
33273
33315
  sessionDir,
33274
33316
  workDir: options.workspaceDir
33275
33317
  } : {},
33276
- ...options.logger !== void 0 ? { logger: options.logger } : {}
33318
+ logger: options.logger
33277
33319
  });
33278
33320
  turnManagerRef = soulPlus.getTurnManager();
33279
33321
  const disposeStateTracking = this.attachStateTracker(sessionId, stateCache, turnManagerRef);
@@ -33398,13 +33440,13 @@ var SessionManager = class {
33398
33440
  created_at: stateData.created_at ?? now,
33399
33441
  turn_count: stateData.turn_count ?? 0,
33400
33442
  last_updated: stateData.updated_at ?? now,
33401
- ...stateData.custom_title !== void 0 ? { title: stateData.custom_title } : {},
33443
+ title: stateData.custom_title,
33402
33444
  ...stateData.tags !== void 0 ? { tags: [...stateData.tags] } : {},
33403
- ...stateData.description !== void 0 ? { description: stateData.description } : {},
33404
- ...stateData.archived !== void 0 ? { archived: stateData.archived } : {},
33405
- ...stateData.color !== void 0 ? { color: stateData.color } : {},
33445
+ description: stateData.description,
33446
+ archived: stateData.archived,
33447
+ color: stateData.color,
33406
33448
  last_model: stateData.model,
33407
- ...stateData.plan_slug !== void 0 ? { plan_slug: stateData.plan_slug } : {},
33449
+ plan_slug: stateData.plan_slug,
33408
33450
  producer: replayResult.producer,
33409
33451
  last_exit_code: "dirty"
33410
33452
  };
@@ -33430,8 +33472,8 @@ var SessionManager = class {
33430
33472
  ...options.enabledToolNames !== void 0 ? { enabledToolNames: options.enabledToolNames } : {},
33431
33473
  lifecycleStateMachine,
33432
33474
  producer: this.producer,
33433
- ...options.onShellDeliver !== void 0 ? { onShellDeliver: options.onShellDeliver } : {},
33434
- ...options.skillManager !== void 0 ? { skillManager: options.skillManager } : {},
33475
+ onShellDeliver: options.onShellDeliver,
33476
+ skillManager: options.skillManager,
33435
33477
  ...options.questionRuntime !== void 0 ? { questionRuntime: options.questionRuntime } : {},
33436
33478
  ...runtimeBundle.compactionConfig !== void 0 ? { compactionConfig: runtimeBundle.compactionConfig } : {},
33437
33479
  compactionProvider: runtimeBundle.compactionProvider,
@@ -33440,10 +33482,10 @@ var SessionManager = class {
33440
33482
  journalWriter,
33441
33483
  producer: this.producer
33442
33484
  }),
33443
- ...approvalRuntime !== void 0 ? { approvalRuntime } : {},
33444
- ...options.hookEngine !== void 0 ? { hookEngine: options.hookEngine } : {},
33485
+ approvalRuntime,
33486
+ hookEngine: options.hookEngine,
33445
33487
  ...options.toolExecutionScopeFactory !== void 0 ? { toolExecutionScopeFactory: options.toolExecutionScopeFactory } : {},
33446
- ...options.sessionRules !== void 0 ? { sessionRules: options.sessionRules } : {},
33488
+ sessionRules: options.sessionRules,
33447
33489
  permissionMode: effectivePermissionMode,
33448
33490
  stateCache,
33449
33491
  initialMeta,
@@ -33455,7 +33497,7 @@ var SessionManager = class {
33455
33497
  sessionDir,
33456
33498
  workDir: stateData.workspace_dir ?? process.cwd()
33457
33499
  } : {},
33458
- ...options.logger !== void 0 ? { logger: options.logger } : {}
33500
+ logger: options.logger
33459
33501
  });
33460
33502
  turnManagerRef = soulPlus.getTurnManager();
33461
33503
  const disposeStateTracking = this.attachStateTracker(sessionId, stateCache, turnManagerRef);
@@ -33725,14 +33767,14 @@ var SessionManager = class {
33725
33767
  updated_at: now,
33726
33768
  model: managed.contextState.model,
33727
33769
  permission_mode: currentPermissionMode,
33728
- ...meta?.title !== void 0 ? { custom_title: meta.title } : {},
33770
+ custom_title: meta?.title,
33729
33771
  ...meta?.tags !== void 0 ? { tags: [...meta.tags] } : {},
33730
- ...meta?.description !== void 0 ? { description: meta.description } : {},
33731
- ...meta?.archived !== void 0 ? { archived: meta.archived } : {},
33732
- ...meta?.color !== void 0 ? { color: meta.color } : {},
33772
+ description: meta?.description,
33773
+ archived: meta?.archived,
33774
+ color: meta?.color,
33733
33775
  turn_count: meta?.turn_count ?? existing.turn_count ?? 0,
33734
- ...meta?.plan_slug !== void 0 ? { plan_slug: meta.plan_slug } : {},
33735
- ...currentThinkingLevel !== void 0 ? { thinking_level: currentThinkingLevel } : {},
33776
+ plan_slug: meta?.plan_slug,
33777
+ thinking_level: currentThinkingLevel,
33736
33778
  ...currentPlanMode ? { plan_mode: true } : { plan_mode: false },
33737
33779
  todos: cloneTodoItems(currentTodos),
33738
33780
  last_exit_code: "clean"
@@ -33744,7 +33786,7 @@ var SessionManager = class {
33744
33786
  permission_mode: currentPermissionMode,
33745
33787
  plan_mode: currentPlanMode,
33746
33788
  turn_count: meta?.turn_count ?? 0,
33747
- ...currentThinkingLevel !== void 0 ? { thinking_level: currentThinkingLevel } : {},
33789
+ thinking_level: currentThinkingLevel,
33748
33790
  todos: cloneTodoItems(currentTodos),
33749
33791
  last_exit_code: "clean"
33750
33792
  };
@@ -41191,7 +41233,7 @@ async function parseSkillFromFile(opts) {
41191
41233
  content,
41192
41234
  metadata,
41193
41235
  source: opts.source,
41194
- ...mermaid !== void 0 ? { mermaid } : {}
41236
+ mermaid
41195
41237
  };
41196
41238
  }
41197
41239
  /**
@@ -76214,8 +76256,8 @@ var GoogleGenAIChatProvider = class {
76214
76256
  apiKey: this._apiKey,
76215
76257
  ...this._vertexai ? {
76216
76258
  vertexai: true,
76217
- ...this._project !== void 0 ? { project: this._project } : {},
76218
- ...this._location !== void 0 ? { location: this._location } : {}
76259
+ project: this._project,
76260
+ location: this._location
76219
76261
  } : {}
76220
76262
  });
76221
76263
  }
@@ -77845,8 +77887,8 @@ function kimiOverrides(provider, model, env) {
77845
77887
  }
77846
77888
  }
77847
77889
  return {
77848
- ...nextProvider !== void 0 ? { provider: nextProvider } : {},
77849
- ...nextModel !== void 0 ? { model: nextModel } : {}
77890
+ provider: nextProvider,
77891
+ model: nextModel
77850
77892
  };
77851
77893
  }
77852
77894
  function openaiOverrides(provider, env) {
@@ -78009,8 +78051,8 @@ function resolveModelAlias(config, nameOrAlias) {
78009
78051
  async function createProviderFromConfig(config, modelNameOrAlias, deps) {
78010
78052
  const requestedModel = modelNameOrAlias ?? config.defaultModel;
78011
78053
  const effectiveConfig = resolveEffectiveConfig(config, {
78012
- ...deps?.env !== void 0 ? { env: deps.env } : {},
78013
- ...requestedModel !== void 0 ? { requestedModel } : {}
78054
+ env: deps?.env,
78055
+ requestedModel
78014
78056
  });
78015
78057
  let providerName;
78016
78058
  let modelName;
@@ -78070,7 +78112,7 @@ var DeferredOAuthChatProvider = class DeferredOAuthChatProvider {
78070
78112
  return provider.files.uploadVideo({
78071
78113
  data: input.data,
78072
78114
  mimeType: input.mimeType,
78073
- ...input.filename !== void 0 ? { filename: input.filename } : {}
78115
+ filename: input.filename
78074
78116
  });
78075
78117
  }
78076
78118
  withThinking(effort) {
@@ -78232,11 +78274,11 @@ function createVideoUploader(provider) {
78232
78274
  const uploaded = await uploadVideo({
78233
78275
  data: input.data,
78234
78276
  mimeType: input.mimeType,
78235
- ...input.filename !== void 0 ? { filename: input.filename } : {}
78277
+ filename: input.filename
78236
78278
  });
78237
78279
  return {
78238
78280
  url: uploaded.videoUrl.url,
78239
- ...uploaded.videoUrl.id !== void 0 ? { id: uploaded.videoUrl.id } : {}
78281
+ id: uploaded.videoUrl.id
78240
78282
  };
78241
78283
  };
78242
78284
  }
@@ -78266,20 +78308,20 @@ async function createDefaultSoulPlusRuntimeBundle(options) {
78266
78308
  };
78267
78309
  if (options.kimiConfig === void 0) throw new Error("createDefaultSoulPlusWireClient: provide either runtime+compactionProvider or kimiConfig");
78268
78310
  const provider = await createProviderFromConfig(options.kimiConfig, defaultModel, {
78269
- ...options.oauthResolver !== void 0 ? { oauthResolver: options.oauthResolver } : {},
78270
- ...options.deferOAuth !== void 0 ? { deferOAuth: options.deferOAuth } : {},
78271
- ...options.defaultHeaders !== void 0 ? { defaultHeaders: options.defaultHeaders } : {}
78311
+ oauthResolver: options.oauthResolver,
78312
+ deferOAuth: options.deferOAuth,
78313
+ defaultHeaders: options.defaultHeaders
78272
78314
  });
78273
78315
  const videoUploader = createVideoUploader(provider);
78274
78316
  return {
78275
78317
  runtime: createRuntime({ kosong: createKosongAdapter({
78276
78318
  provider,
78277
- ...options.tokenRefresher !== void 0 ? { tokenRefresher: options.tokenRefresher } : {}
78319
+ tokenRefresher: options.tokenRefresher
78278
78320
  }) }),
78279
78321
  compactionProvider: createKosongCompactionProvider(provider),
78280
78322
  defaultModel,
78281
78323
  maxContextSize,
78282
- ...videoUploader !== void 0 ? { videoUploader } : {}
78324
+ videoUploader
78283
78325
  };
78284
78326
  }
78285
78327
  const LLM_NOT_CONFIGURED_MESSAGE = "No LLM configured. Run /login to authenticate.";
@@ -78740,7 +78782,7 @@ var LocalKaos = class {
78740
78782
  "pipe"
78741
78783
  ],
78742
78784
  detached: !isWindows,
78743
- ...env !== void 0 ? { env } : {}
78785
+ env
78744
78786
  });
78745
78787
  await waitForSpawn(child);
78746
78788
  return new LocalProcess(child);
@@ -93213,7 +93255,7 @@ function toUsageRow(raw, defaultLabel) {
93213
93255
  label: name,
93214
93256
  used: used ?? 0,
93215
93257
  limit: limit ?? 0,
93216
- ...resetHint !== void 0 ? { resetHint } : {}
93258
+ resetHint
93217
93259
  };
93218
93260
  }
93219
93261
  function limitLabel(item, detail, window, idx) {
@@ -93411,7 +93453,7 @@ function applyManagedKimiCodeConfig(config, options) {
93411
93453
  provider: KIMI_CODE_PROVIDER_NAME,
93412
93454
  model: model.id,
93413
93455
  maxContextSize: model.contextLength,
93414
- ...capabilities !== void 0 ? { capabilities } : {}
93456
+ capabilities
93415
93457
  };
93416
93458
  }
93417
93459
  config.models = existingModels;
@@ -93446,7 +93488,7 @@ async function provisionManagedKimiCodeConfigAfterLogin(options) {
93446
93488
  const config = loadConfig({ pathConfig: options.pathConfig });
93447
93489
  const applied = applyManagedKimiCodeConfig(config, {
93448
93490
  models,
93449
- ...options.baseUrl !== void 0 ? { baseUrl: options.baseUrl } : {}
93491
+ baseUrl: options.baseUrl
93450
93492
  });
93451
93493
  await saveConfig(config, { pathConfig: options.pathConfig });
93452
93494
  return {
@@ -93665,15 +93707,15 @@ function createDefaultSoulPlusWebProviders(options) {
93665
93707
  const fetchBaseUrl = fetchService?.baseUrl ?? (kimiCodeOAuth !== void 0 ? `${moonshotBase}/fetch` : void 0);
93666
93708
  return {
93667
93709
  webSearchProvider: searchBaseUrl !== void 0 ? new MoonshotWebSearchProvider({
93668
- ...searchOAuth !== void 0 ? { oauthManager: searchOAuth } : {},
93669
- ...searchService?.apiKey !== void 0 ? { apiKey: searchService.apiKey } : {},
93710
+ oauthManager: searchOAuth,
93711
+ apiKey: searchService?.apiKey,
93670
93712
  baseUrl: searchBaseUrl,
93671
93713
  userAgent: options.userAgent,
93672
93714
  ...searchService?.customHeaders !== void 0 ? { customHeaders: searchService.customHeaders } : {}
93673
93715
  }) : new StubWebSearchProvider(),
93674
93716
  urlFetcher: fetchBaseUrl !== void 0 ? new MoonshotFetchURLProvider({
93675
- ...fetchOAuth !== void 0 ? { oauthManager: fetchOAuth } : {},
93676
- ...fetchService?.apiKey !== void 0 ? { apiKey: fetchService.apiKey } : {},
93717
+ oauthManager: fetchOAuth,
93718
+ apiKey: fetchService?.apiKey,
93677
93719
  baseUrl: fetchBaseUrl,
93678
93720
  userAgent: options.userAgent,
93679
93721
  ...fetchService?.customHeaders !== void 0 ? { customHeaders: fetchService.customHeaders } : {},
@@ -93728,8 +93770,8 @@ var DefaultSoulPlusOAuthServiceImpl = class {
93728
93770
  const name = providerName ?? "managed:kimi-code";
93729
93771
  const manager = this.managerFor(name);
93730
93772
  const accessToken = await manager.hasToken() ? await manager.ensureFresh() : (await manager.login({
93731
- ...options?.signal !== void 0 ? { signal: options.signal } : {},
93732
- ...options?.onDeviceCode !== void 0 ? { onDeviceCode: options.onDeviceCode } : {}
93773
+ signal: options?.signal,
93774
+ onDeviceCode: options?.onDeviceCode
93733
93775
  })).accessToken;
93734
93776
  await provisionManagedKimiCodeConfigAfterLogin({
93735
93777
  pathConfig: this.options.pathConfig,
@@ -93963,10 +94005,10 @@ async function scanSessionWire(sessionDir) {
93963
94005
  }
93964
94006
  }
93965
94007
  return {
93966
- ...firstActivityMs !== void 0 ? { firstActivityMs } : {},
93967
- ...lastActivityMs !== void 0 ? { lastActivityMs } : {},
93968
- ...lastUserMessageMs !== void 0 ? { lastUserMessageMs } : {},
93969
- ...firstUserInput !== void 0 ? { firstUserInput } : {}
94008
+ firstActivityMs,
94009
+ lastActivityMs,
94010
+ lastUserMessageMs,
94011
+ firstUserInput
93970
94012
  };
93971
94013
  }
93972
94014
  function normalizeTimestampMs(value) {
@@ -94236,7 +94278,7 @@ var KimiWireClient = class {
94236
94278
  const message = createWireRequest({
94237
94279
  method,
94238
94280
  sessionId: options?.sessionId ?? "__process__",
94239
- ...data !== void 0 ? { data } : {}
94281
+ data
94240
94282
  });
94241
94283
  const response = await this.sendRequestMessage(message, options);
94242
94284
  if (response.error !== void 0) throw new WireResponseError(response);
@@ -94245,8 +94287,8 @@ var KimiWireClient = class {
94245
94287
  initialize(data) {
94246
94288
  return this.request("initialize", {
94247
94289
  protocol_version: data?.protocol_version ?? "2.1",
94248
- ...data?.capabilities !== void 0 ? { capabilities: data.capabilities } : {},
94249
- ...data?.hooks !== void 0 ? { hooks: data.hooks } : {}
94290
+ capabilities: data?.capabilities,
94291
+ hooks: data?.hooks
94250
94292
  });
94251
94293
  }
94252
94294
  getModels() {
@@ -94365,7 +94407,7 @@ var KimiWireClient = class {
94365
94407
  getBackgroundTaskOutput(sessionId, taskId, tail) {
94366
94408
  return this.request("session.getBackgroundTaskOutput", {
94367
94409
  task_id: taskId,
94368
- ...tail !== void 0 ? { tail } : {}
94410
+ tail
94369
94411
  }, { sessionId });
94370
94412
  }
94371
94413
  rollback(sessionId, nTurnsBack) {
@@ -94377,7 +94419,7 @@ var KimiWireClient = class {
94377
94419
  activateSkill(sessionId, name, args) {
94378
94420
  return this.request("session.activateSkill", {
94379
94421
  name,
94380
- ...args !== void 0 ? { args } : {}
94422
+ args
94381
94423
  }, { sessionId });
94382
94424
  }
94383
94425
  mcpList() {
@@ -94408,7 +94450,7 @@ var KimiWireClient = class {
94408
94450
  return this.request("mcp.getPrompt", {
94409
94451
  server_id: serverId,
94410
94452
  name,
94411
- ...args !== void 0 ? { arguments: args } : {}
94453
+ arguments: args
94412
94454
  });
94413
94455
  }
94414
94456
  mcpStartAuth(serverId) {
@@ -94441,7 +94483,7 @@ var KimiWireClient = class {
94441
94483
  addSystemReminder(sessionId, content, category) {
94442
94484
  return this.request("session.addSystemReminder", {
94443
94485
  content,
94444
- ...category !== void 0 ? { category } : {}
94486
+ category
94445
94487
  }, { sessionId });
94446
94488
  }
94447
94489
  registerTool(sessionId, data) {
@@ -94630,7 +94672,7 @@ async function startCoreWireServer(options) {
94630
94672
  kosong: options.runtime.kosong,
94631
94673
  tools: options.tools ?? [],
94632
94674
  ...options.enabledToolNames !== void 0 ? { enabledToolNames: options.enabledToolNames } : {},
94633
- ...options.approval !== void 0 ? { approval: options.approval } : {},
94675
+ approval: options.approval,
94634
94676
  ...options.enableWiredApprovals !== void 0 ? { enableWiredApprovals: options.enableWiredApprovals } : {},
94635
94677
  eventBus,
94636
94678
  eventBusProvider: () => new SessionEventBus(),
@@ -94640,7 +94682,7 @@ async function startCoreWireServer(options) {
94640
94682
  }),
94641
94683
  workspaceDir: options.workspaceDir,
94642
94684
  defaultModel: options.defaultModel,
94643
- ...options.runtimeProvider !== void 0 ? { runtimeProvider: options.runtimeProvider } : {},
94685
+ runtimeProvider: options.runtimeProvider,
94644
94686
  ...options.defaultModelProvider !== void 0 ? { defaultModelProvider: options.defaultModelProvider } : {},
94645
94687
  ...options.compactionProviderProvider !== void 0 ? { compactionProviderProvider: options.compactionProviderProvider } : {},
94646
94688
  ...options.compactionConfigProvider !== void 0 ? { compactionConfigProvider: options.compactionConfigProvider } : {},
@@ -94650,19 +94692,19 @@ async function startCoreWireServer(options) {
94650
94692
  pathConfig: options.pathConfig,
94651
94693
  server: options.transport,
94652
94694
  hookEngine,
94653
- ...options.skillManager !== void 0 ? { skillManager: options.skillManager } : {},
94695
+ skillManager: options.skillManager,
94654
94696
  ...options.agentTypeRegistry !== void 0 ? { agentTypeRegistry: options.agentTypeRegistry } : {},
94655
- ...options.mcpRegistry !== void 0 ? { mcpRegistry: options.mcpRegistry } : {},
94656
- ...options.authService !== void 0 ? { authService: options.authService } : {},
94697
+ mcpRegistry: options.mcpRegistry,
94698
+ authService: options.authService,
94657
94699
  ...options.backgroundProcessManager !== void 0 ? { backgroundProcessManager: options.backgroundProcessManager } : {},
94658
94700
  sessionLifecycle: {
94659
94701
  onSessionCreated: installBridge,
94660
94702
  onSessionDestroyed: disposeBridge
94661
94703
  },
94662
- ...options.modelsProvider !== void 0 ? { modelsProvider: options.modelsProvider } : {},
94663
- ...options.configProvider !== void 0 ? { configProvider: options.configProvider } : {},
94664
- ...options.logger !== void 0 ? { logger: options.logger } : {},
94665
- ...options.skillManager !== void 0 ? { skillManager: options.skillManager } : {}
94704
+ modelsProvider: options.modelsProvider,
94705
+ configProvider: options.configProvider,
94706
+ logger: options.logger,
94707
+ skillManager: options.skillManager
94666
94708
  }).getEventFilter;
94667
94709
  options.transport.onMessage = (frame) => {
94668
94710
  (async () => {
@@ -94810,7 +94852,7 @@ async function createDefaultSoulPlusWireClient(options) {
94810
94852
  enabledToolNames: defaults.enabledToolNames,
94811
94853
  webSearchProvider: webProviders.webSearchProvider,
94812
94854
  urlFetcher: webProviders.urlFetcher,
94813
- ...activeVideoUploader !== void 0 ? { videoUploader: activeVideoUploader } : {}
94855
+ videoUploader: activeVideoUploader
94814
94856
  });
94815
94857
  const backgroundManager = builtin.backgroundManager;
94816
94858
  const handle = await createInProcessWireClient({
@@ -94833,7 +94875,7 @@ async function createDefaultSoulPlusWireClient(options) {
94833
94875
  ...activeDefaultModel.length > 0 ? { default_model: activeDefaultModel } : {}
94834
94876
  }),
94835
94877
  configProvider: () => effectiveConfig,
94836
- ...options.logger !== void 0 ? { logger: options.logger } : {},
94878
+ logger: options.logger,
94837
94879
  backgroundProcessManager: backgroundManager,
94838
94880
  ...options.defaultTimeoutMs !== void 0 ? { defaultTimeoutMs: options.defaultTimeoutMs } : {}
94839
94881
  });
@@ -95378,7 +95420,7 @@ var ThinkingComponent = class {
95378
95420
  * Reuses the diff algorithm from approval/DiffPreview.tsx, but outputs
95379
95421
  * formatted text lines instead of React elements.
95380
95422
  */
95381
- function computeDiffLines(oldText, newText, oldStart = 1, newStart = 1) {
95423
+ function computeDiffLines(oldText, newText, oldStart = 1, newStart = 1, isIncomplete = false) {
95382
95424
  const oldLines = oldText ? oldText.split("\n") : [];
95383
95425
  const newLines = newText ? newText.split("\n") : [];
95384
95426
  const m = oldLines.length;
@@ -95414,10 +95456,16 @@ function computeDiffLines(oldText, newText, oldStart = 1, newStart = 1) {
95414
95456
  }
95415
95457
  const result = [];
95416
95458
  for (let k = reversed.length - 1; k >= 0; k--) result.push(reversed[k]);
95459
+ if (isIncomplete && result.length > 0) {
95460
+ let lastNonDelete = result.length - 1;
95461
+ while (lastNonDelete >= 0 && result[lastNonDelete].kind === "delete") lastNonDelete--;
95462
+ if (lastNonDelete >= 0) result.length = lastNonDelete + 1;
95463
+ else result.length = 0;
95464
+ }
95417
95465
  return result;
95418
95466
  }
95419
- function renderDiffLines(oldText, newText, path, oldStart, newStart, maxLines) {
95420
- const changedLines = computeDiffLines(oldText, newText, oldStart ?? 1, newStart ?? 1).filter((l) => l.kind !== "context");
95467
+ function renderDiffLines(oldText, newText, path, isIncomplete = false, oldStart, newStart, maxLines) {
95468
+ const changedLines = computeDiffLines(oldText, newText, oldStart ?? 1, newStart ?? 1, isIncomplete).filter((l) => l.kind !== "context");
95421
95469
  const added = changedLines.filter((l) => l.kind === "add").length;
95422
95470
  const removed = changedLines.filter((l) => l.kind === "delete").length;
95423
95471
  const output = [];
@@ -95867,7 +95915,7 @@ var ToolCallComponent = class extends Container {
95867
95915
  this.buildPlanPreview();
95868
95916
  return;
95869
95917
  }
95870
- if (this.toolCall.streamingArguments !== void 0) {
95918
+ if (this.result === void 0 && this.toolCall.streamingArguments !== void 0) {
95871
95919
  this.buildStreamingPreview(this.toolCall.streamingArguments);
95872
95920
  return;
95873
95921
  }
@@ -95886,7 +95934,7 @@ var ToolCallComponent = class extends Container {
95886
95934
  const oldStr = str(this.toolCall.args["old_string"]);
95887
95935
  const newStr = str(this.toolCall.args["new_string"]);
95888
95936
  if (oldStr.length === 0 && newStr.length === 0) return;
95889
- const allLines = renderDiffLines(oldStr, newStr, str(this.toolCall.args["file_path"] ?? this.toolCall.args["path"]));
95937
+ const allLines = renderDiffLines(oldStr, newStr, str(this.toolCall.args["file_path"] ?? this.toolCall.args["path"]), false);
95890
95938
  const shown = allLines.slice(0, CALL_PREVIEW_LINES);
95891
95939
  const remaining = allLines.length - shown.length;
95892
95940
  for (const line of shown) this.addChild(new Text(line, 2, 0));
@@ -95917,7 +95965,7 @@ var ToolCallComponent = class extends Container {
95917
95965
  const oldStr = extractPartialStringField(streamText, "old_string") ?? "";
95918
95966
  const newStr = extractPartialStringField(streamText, "new_string") ?? "";
95919
95967
  if (oldStr.length === 0 && newStr.length === 0) return;
95920
- const allLines = renderDiffLines(oldStr, newStr, extractPartialStringField(streamText, "file_path") ?? extractPartialStringField(streamText, "path") ?? "");
95968
+ const allLines = renderDiffLines(oldStr, newStr, extractPartialStringField(streamText, "file_path") ?? extractPartialStringField(streamText, "path") ?? "", true);
95921
95969
  const shown = allLines.slice(0, CALL_PREVIEW_LINES);
95922
95970
  const remaining = allLines.length - shown.length;
95923
95971
  for (const line of shown) this.addChild(new Text(line, 2, 0));
@@ -96267,7 +96315,7 @@ function emitStatus(state, message, color) {
96267
96315
  turnId: state.currentTurnId,
96268
96316
  renderMode: "plain",
96269
96317
  content: message,
96270
- ...color !== void 0 ? { color } : {}
96318
+ color
96271
96319
  });
96272
96320
  }
96273
96321
  function emitNotice(state, title, detail) {
@@ -96277,7 +96325,7 @@ function emitNotice(state, title, detail) {
96277
96325
  turnId: state.currentTurnId,
96278
96326
  renderMode: "notice",
96279
96327
  content: title,
96280
- ...detail !== void 0 ? { detail } : {}
96328
+ detail
96281
96329
  });
96282
96330
  }
96283
96331
  /** Red. */
@@ -96732,7 +96780,7 @@ async function refreshConfigAfterLogin(client, ctx) {
96732
96780
  const selected = defaultModel !== void 0 ? availableModels[defaultModel] : void 0;
96733
96781
  const patch = {
96734
96782
  availableModels,
96735
- ...defaultModel !== void 0 ? { model: defaultModel } : {},
96783
+ model: defaultModel,
96736
96784
  ...selected?.maxContextSize !== void 0 ? { maxContextTokens: selected.maxContextSize } : {},
96737
96785
  ...typeof config["defaultThinking"] === "boolean" ? { thinking: config["defaultThinking"] } : {}
96738
96786
  };
@@ -96967,13 +97015,12 @@ function parseSlashInput(input) {
96967
97015
  const trimmed = input.slice(1).trim();
96968
97016
  if (trimmed.length === 0) return null;
96969
97017
  const spaceIdx = trimmed.indexOf(" ");
96970
- if (spaceIdx === -1) return {
96971
- name: trimmed,
96972
- args: ""
96973
- };
97018
+ const name = spaceIdx === -1 ? trimmed : trimmed.slice(0, spaceIdx);
97019
+ const args = spaceIdx === -1 ? "" : trimmed.slice(spaceIdx + 1).trim();
97020
+ if (name.includes("/")) return null;
96974
97021
  return {
96975
- name: trimmed.slice(0, spaceIdx),
96976
- args: trimmed.slice(spaceIdx + 1).trim()
97022
+ name,
97023
+ args
96977
97024
  };
96978
97025
  }
96979
97026
  //#endregion
@@ -98307,7 +98354,7 @@ function projectToolCall(state, record) {
98307
98354
  id: tool.id,
98308
98355
  name: tool.name,
98309
98356
  args: tool.args,
98310
- ...tool.description !== void 0 ? { description: tool.description } : {}
98357
+ description: tool.description
98311
98358
  };
98312
98359
  state.toolCalls.set(tool.id, toolCall);
98313
98360
  state.entries.push(entry("tool_call", "", "plain", {
@@ -98357,13 +98404,11 @@ function toolCallFromRecord(record) {
98357
98404
  const id = stringValue(data["tool_call_id"]);
98358
98405
  const name = stringValue(data["tool_name"]);
98359
98406
  if (id === void 0 || name === void 0) return void 0;
98360
- const args = isObject(data["args"]) ? data["args"] : {};
98361
- const description = stringValue(data["activity_description"]);
98362
98407
  return {
98363
98408
  id,
98364
98409
  name,
98365
- args,
98366
- ...description !== void 0 ? { description } : {}
98410
+ args: isObject(data["args"]) ? data["args"] : {},
98411
+ description: stringValue(data["activity_description"])
98367
98412
  };
98368
98413
  }
98369
98414
  function toolResultFromRecord(record) {
@@ -98378,7 +98423,7 @@ function toolResultFromRecord(record) {
98378
98423
  function ensureSubagent(parent, id, name) {
98379
98424
  if (parent.subagent === void 0) parent.subagent = {
98380
98425
  id,
98381
- ...name !== void 0 ? { name } : {},
98426
+ name,
98382
98427
  toolCalls: []
98383
98428
  };
98384
98429
  return parent.subagent;
@@ -98389,8 +98434,8 @@ function entry(kind, content, renderMode, extras) {
98389
98434
  kind,
98390
98435
  renderMode,
98391
98436
  content,
98392
- ...extras?.turnId !== void 0 ? { turnId: extras.turnId } : {},
98393
- ...extras?.toolCallData !== void 0 ? { toolCallData: extras.toolCallData } : {}
98437
+ turnId: extras?.turnId,
98438
+ toolCallData: extras?.toolCallData
98394
98439
  };
98395
98440
  }
98396
98441
  function userContentToText(content) {
@@ -98855,7 +98900,7 @@ async function dispatchSlashCommand(input, state, buildCtx, addEntry) {
98855
98900
  kind: "status",
98856
98901
  renderMode: "plain",
98857
98902
  content: result.message,
98858
- ...result.color !== void 0 ? { color: result.color } : {}
98903
+ color: result.color
98859
98904
  });
98860
98905
  return true;
98861
98906
  }
@@ -100113,9 +100158,9 @@ function extractFromArgs(toolName, detail) {
100113
100158
  type: "shell",
100114
100159
  language: stringField(detail, "language") ?? "bash",
100115
100160
  command,
100116
- ...cwd !== void 0 ? { cwd } : {},
100117
- ...toolDescription !== void 0 ? { description: toolDescription } : {},
100118
- ...danger !== void 0 ? { danger } : {}
100161
+ cwd,
100162
+ description: toolDescription,
100163
+ danger
100119
100164
  }],
100120
100165
  description: toolDescription ?? ""
100121
100166
  };
@@ -100141,17 +100186,14 @@ function extractFromArgs(toolName, detail) {
100141
100186
  description: ""
100142
100187
  };
100143
100188
  const url = stringField(detail, "url");
100144
- if (url !== void 0) {
100145
- const method = stringField(detail, "method");
100146
- return {
100147
- blocks: [{
100148
- type: "url_fetch",
100149
- url,
100150
- ...method !== void 0 ? { method } : {}
100151
- }],
100152
- description: ""
100153
- };
100154
- }
100189
+ if (url !== void 0) return {
100190
+ blocks: [{
100191
+ type: "url_fetch",
100192
+ url,
100193
+ method: stringField(detail, "method")
100194
+ }],
100195
+ description: ""
100196
+ };
100155
100197
  const query = stringField(detail, "query");
100156
100198
  if (query !== void 0) return {
100157
100199
  blocks: [{
@@ -100161,17 +100203,14 @@ function extractFromArgs(toolName, detail) {
100161
100203
  description: ""
100162
100204
  };
100163
100205
  const pattern = stringField(detail, "pattern");
100164
- if (pattern !== void 0) {
100165
- const scope = stringField(detail, "path");
100166
- return {
100167
- blocks: [{
100168
- type: "search",
100169
- query: pattern,
100170
- ...scope !== void 0 ? { scope } : {}
100171
- }],
100172
- description: ""
100173
- };
100174
- }
100206
+ if (pattern !== void 0) return {
100207
+ blocks: [{
100208
+ type: "search",
100209
+ query: pattern,
100210
+ scope: stringField(detail, "path")
100211
+ }],
100212
+ description: ""
100213
+ };
100175
100214
  if (filePath !== void 0) return {
100176
100215
  blocks: [{
100177
100216
  type: "file_op",
@@ -100194,13 +100233,13 @@ function adaptPanelResponse(response) {
100194
100233
  if (response.response === "approved_for_session") return {
100195
100234
  response: "approved",
100196
100235
  scope: "session",
100197
- ...response.feedback !== void 0 ? { feedback: response.feedback } : {},
100198
- ...response.selected_label !== void 0 ? { selected_label: response.selected_label } : {}
100236
+ feedback: response.feedback,
100237
+ selected_label: response.selected_label
100199
100238
  };
100200
100239
  return {
100201
100240
  response: response.response === "approved" ? "approved" : response.response === "rejected" ? "rejected" : "cancelled",
100202
- ...response.feedback !== void 0 ? { feedback: response.feedback } : {},
100203
- ...response.selected_label !== void 0 ? { selected_label: response.selected_label } : {}
100241
+ feedback: response.feedback,
100242
+ selected_label: response.selected_label
100204
100243
  };
100205
100244
  }
100206
100245
  function describeApproval(display, action) {
@@ -100268,9 +100307,9 @@ function adaptDisplay(display) {
100268
100307
  type: "shell",
100269
100308
  language: display.language ?? "bash",
100270
100309
  command,
100271
- ...display.cwd !== void 0 ? { cwd: display.cwd } : {},
100272
- ...display.description !== void 0 ? { description: display.description } : {},
100273
- ...danger !== void 0 ? { danger } : {}
100310
+ cwd: display.cwd,
100311
+ description: display.description,
100312
+ danger
100274
100313
  }];
100275
100314
  }
100276
100315
  case "diff": return [{
@@ -100283,29 +100322,29 @@ function adaptDisplay(display) {
100283
100322
  type: "file_op",
100284
100323
  operation: display.operation,
100285
100324
  path: display.path ?? "",
100286
- ...display.detail !== void 0 ? { detail: display.detail } : {}
100325
+ detail: display.detail
100287
100326
  }];
100288
100327
  case "url_fetch": return [{
100289
100328
  type: "url_fetch",
100290
100329
  url: display.url ?? "",
100291
- ...display.method !== void 0 ? { method: display.method } : {}
100330
+ method: display.method
100292
100331
  }];
100293
100332
  case "search": return [{
100294
100333
  type: "search",
100295
100334
  query: display.query ?? "",
100296
- ...display.scope !== void 0 ? { scope: display.scope } : {}
100335
+ scope: display.scope
100297
100336
  }];
100298
100337
  case "agent_call": return [{
100299
100338
  type: "invocation",
100300
100339
  kind: "agent",
100301
100340
  name: display.agent_name ?? "",
100302
- ...display.prompt !== void 0 ? { description: display.prompt } : {}
100341
+ description: display.prompt
100303
100342
  }];
100304
100343
  case "skill_call": return [{
100305
100344
  type: "invocation",
100306
100345
  kind: "skill",
100307
100346
  name: display.skill_name ?? "",
100308
- ...display.args !== void 0 ? { description: display.args } : {}
100347
+ description: display.args
100309
100348
  }];
100310
100349
  case "task_stop": return [{
100311
100350
  type: "brief",
@@ -100363,7 +100402,7 @@ function truncateOneLine(text, max) {
100363
100402
  const DIFF_SUMMARY_MAX_LINES = 10;
100364
100403
  function renderDisplayBlock(block, expanded) {
100365
100404
  switch (block.type) {
100366
- case "diff": return renderDiffLines(block.old_text, block.new_text, block.path, block.old_start, block.new_start, expanded ? void 0 : DIFF_SUMMARY_MAX_LINES);
100405
+ case "diff": return renderDiffLines(block.old_text, block.new_text, block.path, false, block.old_start, block.new_start, expanded ? void 0 : DIFF_SUMMARY_MAX_LINES);
100367
100406
  case "shell": {
100368
100407
  const lines = [];
100369
100408
  if (block.cwd !== void 0 && block.cwd.length > 0) lines.push(chalk.dim(`cwd: ${block.cwd}`));
@@ -100443,7 +100482,7 @@ var ApprovalPanelComponent = class extends Container {
100443
100482
  this.onResponse({
100444
100483
  response: option.response,
100445
100484
  feedback: feedback || void 0,
100446
- ...option.selected_label !== void 0 ? { selected_label: option.selected_label } : {}
100485
+ selected_label: option.selected_label
100447
100486
  });
100448
100487
  }
100449
100488
  selectAndSubmit(index) {
@@ -102183,7 +102222,7 @@ var KimiTUI = class {
102183
102222
  kind: "status",
102184
102223
  renderMode: "plain",
102185
102224
  content: message,
102186
- ...color !== void 0 ? { color } : {}
102225
+ color
102187
102226
  });
102188
102227
  },
102189
102228
  showNotice: (title, detail) => {