kfc-code-cli 0.0.1-alpha.6 → 0.0.1-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.mjs +672 -513
- 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
|
-
|
|
679
|
-
|
|
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
|
-
|
|
873
|
+
name: message.name,
|
|
874
874
|
content: message.content.map((p) => ({ ...p })),
|
|
875
875
|
toolCalls: message.toolCalls.map((tc) => ({ ...tc })),
|
|
876
|
-
|
|
877
|
-
|
|
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
|
-
|
|
896
|
-
|
|
897
|
-
|
|
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
|
-
|
|
915
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
|
1082
|
+
async appendToolResult(parentUuid, toolCallId, result) {
|
|
1086
1083
|
this.assertNotBroken();
|
|
1087
1084
|
const normalisedOutput = result.output === void 0 ? null : result.output;
|
|
1088
|
-
const turnId =
|
|
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
|
-
|
|
1175
|
-
|
|
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
|
-
|
|
1190
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2316
|
-
|
|
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(
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2709
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3683
|
-
|
|
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(
|
|
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
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
|
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(
|
|
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
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
5601
|
+
chosenLabel: response.selected_label
|
|
5563
5602
|
};
|
|
5564
5603
|
return {
|
|
5565
5604
|
approved: false,
|
|
5566
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
6625
|
+
payload: input.payload,
|
|
6588
6626
|
targets,
|
|
6589
|
-
|
|
6590
|
-
|
|
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
|
-
|
|
6897
|
+
custom_title: meta.title,
|
|
6860
6898
|
...meta.tags !== void 0 ? { tags: [...meta.tags] } : {},
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
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
|
-
|
|
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(
|
|
6901
|
-
if (
|
|
6902
|
-
this.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(
|
|
7296
|
+
function createDefaultDynamicInjectionManager(options = {}) {
|
|
7259
7297
|
return new DynamicInjectionManager({
|
|
7260
|
-
|
|
7261
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
20686
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
20981
|
-
|
|
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
|
-
|
|
21055
|
-
|
|
21056
|
-
|
|
21057
|
-
|
|
21058
|
-
|
|
21059
|
-
|
|
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
|
-
|
|
21083
|
-
|
|
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
|
-
|
|
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
|
-
|
|
21600
|
+
stop_reason: stopReason
|
|
21562
21601
|
},
|
|
21563
21602
|
toolCalls,
|
|
21564
21603
|
usage,
|
|
21565
21604
|
actualModel: activeProvider.modelName,
|
|
21566
|
-
|
|
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
|
-
|
|
21990
|
-
|
|
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
|
-
|
|
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
|
-
|
|
22021
|
-
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
|
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
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
24298
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
29768
|
-
|
|
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
|
-
|
|
29783
|
-
|
|
29784
|
-
|
|
29785
|
-
|
|
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
|
-
|
|
29872
|
-
|
|
29913
|
+
requestId: ctx.draft.requestId,
|
|
29914
|
+
turnId: ctx.draft.turnId,
|
|
29873
29915
|
agentType: ctx.draft.agentType ?? "main",
|
|
29874
|
-
|
|
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
|
-
|
|
29933
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
29992
|
-
|
|
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
|
-
|
|
29999
|
-
|
|
30000
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
30656
|
+
runtimeSlot,
|
|
30615
30657
|
tools: this.deps.toolsProvider(),
|
|
30616
|
-
|
|
30658
|
+
enabledToolNames,
|
|
30617
30659
|
model,
|
|
30618
|
-
|
|
30660
|
+
systemPrompt,
|
|
30619
30661
|
eventBus,
|
|
30620
30662
|
workspaceDir: this.deps.workspaceDir,
|
|
30621
30663
|
compactionProvider,
|
|
30622
|
-
|
|
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
|
-
|
|
30626
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
30705
|
+
runtimeSlot,
|
|
30664
30706
|
tools: this.deps.toolsProvider(),
|
|
30665
30707
|
eventBus,
|
|
30666
30708
|
compactionProvider,
|
|
30667
|
-
|
|
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
|
-
|
|
30671
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
30996
|
-
|
|
30997
|
-
|
|
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
|
-
|
|
31031
|
-
|
|
31072
|
+
header: question.header,
|
|
31073
|
+
body: question.body,
|
|
31032
31074
|
multi_select: question.multiSelect ?? false,
|
|
31033
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
31405
|
-
|
|
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
|
-
|
|
31767
|
-
|
|
31768
|
-
|
|
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
|
-
|
|
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
|
-
|
|
32112
|
+
feedback: parsed.feedback,
|
|
32071
32113
|
...parsed.selected_label !== void 0 ? { selected_label: parsed.selected_label } : {},
|
|
32072
|
-
|
|
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
|
-
|
|
32115
|
-
|
|
32156
|
+
approvalRuntime,
|
|
32157
|
+
approvalRuntimeFactory,
|
|
32116
32158
|
workspaceDir,
|
|
32117
|
-
|
|
32118
|
-
|
|
32119
|
-
|
|
32159
|
+
approvalStateStore,
|
|
32160
|
+
skillManager: deps.skillManager,
|
|
32161
|
+
agentTypeRegistry: deps.agentTypeRegistry,
|
|
32120
32162
|
questionRuntimeProvider: ({ sessionId }) => reverse !== void 0 ? createWireQuestionRuntime(reverse, sessionId) : void 0,
|
|
32121
|
-
|
|
32122
|
-
|
|
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
|
-
|
|
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
|
-
|
|
32145
|
-
|
|
32146
|
-
|
|
32147
|
-
|
|
32148
|
-
|
|
32186
|
+
reverse,
|
|
32187
|
+
authService,
|
|
32188
|
+
mcpRegistry,
|
|
32189
|
+
modelsProvider,
|
|
32190
|
+
configProvider,
|
|
32149
32191
|
defaultModel,
|
|
32150
32192
|
...deps.defaultModelProvider !== void 0 ? { defaultModelProvider: deps.defaultModelProvider } : {},
|
|
32151
|
-
|
|
32193
|
+
hookEngine,
|
|
32152
32194
|
usesPerSessionHookEngine: hookEngineProvider !== void 0,
|
|
32153
|
-
|
|
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
|
-
|
|
32927
|
-
|
|
32928
|
-
|
|
32929
|
-
|
|
32930
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
33252
|
-
|
|
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
|
-
|
|
33262
|
-
|
|
33303
|
+
approvalRuntime,
|
|
33304
|
+
hookEngine: options.hookEngine,
|
|
33263
33305
|
...options.toolExecutionScopeFactory !== void 0 ? { toolExecutionScopeFactory: options.toolExecutionScopeFactory } : {},
|
|
33264
|
-
|
|
33265
|
-
|
|
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
|
-
|
|
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
|
-
|
|
33443
|
+
title: stateData.custom_title,
|
|
33402
33444
|
...stateData.tags !== void 0 ? { tags: [...stateData.tags] } : {},
|
|
33403
|
-
|
|
33404
|
-
|
|
33405
|
-
|
|
33445
|
+
description: stateData.description,
|
|
33446
|
+
archived: stateData.archived,
|
|
33447
|
+
color: stateData.color,
|
|
33406
33448
|
last_model: stateData.model,
|
|
33407
|
-
|
|
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
|
-
|
|
33434
|
-
|
|
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
|
-
|
|
33444
|
-
|
|
33485
|
+
approvalRuntime,
|
|
33486
|
+
hookEngine: options.hookEngine,
|
|
33445
33487
|
...options.toolExecutionScopeFactory !== void 0 ? { toolExecutionScopeFactory: options.toolExecutionScopeFactory } : {},
|
|
33446
|
-
|
|
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
|
-
|
|
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
|
-
|
|
33770
|
+
custom_title: meta?.title,
|
|
33729
33771
|
...meta?.tags !== void 0 ? { tags: [...meta.tags] } : {},
|
|
33730
|
-
|
|
33731
|
-
|
|
33732
|
-
|
|
33772
|
+
description: meta?.description,
|
|
33773
|
+
archived: meta?.archived,
|
|
33774
|
+
color: meta?.color,
|
|
33733
33775
|
turn_count: meta?.turn_count ?? existing.turn_count ?? 0,
|
|
33734
|
-
|
|
33735
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
76218
|
-
|
|
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
|
-
|
|
77849
|
-
|
|
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
|
-
|
|
78013
|
-
|
|
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
|
-
|
|
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
|
-
|
|
78277
|
+
filename: input.filename
|
|
78236
78278
|
});
|
|
78237
78279
|
return {
|
|
78238
78280
|
url: uploaded.videoUrl.url,
|
|
78239
|
-
|
|
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
|
-
|
|
78270
|
-
|
|
78271
|
-
|
|
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
|
-
|
|
78319
|
+
tokenRefresher: options.tokenRefresher
|
|
78278
78320
|
}) }),
|
|
78279
78321
|
compactionProvider: createKosongCompactionProvider(provider),
|
|
78280
78322
|
defaultModel,
|
|
78281
78323
|
maxContextSize,
|
|
78282
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
93669
|
-
|
|
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
|
-
|
|
93676
|
-
|
|
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
|
-
|
|
93732
|
-
|
|
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
|
-
|
|
93967
|
-
|
|
93968
|
-
|
|
93969
|
-
|
|
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
|
-
|
|
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
|
-
|
|
94249
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
94695
|
+
skillManager: options.skillManager,
|
|
94654
94696
|
...options.agentTypeRegistry !== void 0 ? { agentTypeRegistry: options.agentTypeRegistry } : {},
|
|
94655
|
-
|
|
94656
|
-
|
|
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
|
-
|
|
94663
|
-
|
|
94664
|
-
|
|
94665
|
-
|
|
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
|
-
|
|
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
|
-
|
|
94878
|
+
logger: options.logger,
|
|
94837
94879
|
backgroundProcessManager: backgroundManager,
|
|
94838
94880
|
...options.defaultTimeoutMs !== void 0 ? { defaultTimeoutMs: options.defaultTimeoutMs } : {}
|
|
94839
94881
|
});
|
|
@@ -95042,26 +95084,21 @@ function pinoToLogger(p) {
|
|
|
95042
95084
|
async function createKimiAgent() {
|
|
95043
95085
|
const workDir = process.cwd();
|
|
95044
95086
|
const version = getVersion();
|
|
95045
|
-
const { client, dispose
|
|
95087
|
+
const { client, dispose, maxContextSize, defaultModel, defaultThinking, defaultYolo, defaultPlanMode, availableModels, syncSessionRuntime } = await createDefaultSoulPlusWireClient({
|
|
95046
95088
|
workspaceDir: workDir,
|
|
95047
95089
|
userAgent: `KimiCLI/${version}`,
|
|
95048
95090
|
defaultHeaders: buildKimiDefaultHeaders(version),
|
|
95049
95091
|
logger: pinoToLogger(getLogger()).child({ component: "session" })
|
|
95050
95092
|
});
|
|
95051
95093
|
client.onRequest("hook.request", async () => ({ ok: true }));
|
|
95052
|
-
const dispose = async () => {
|
|
95053
|
-
await disposeClient();
|
|
95054
|
-
};
|
|
95055
95094
|
return {
|
|
95056
95095
|
client,
|
|
95057
|
-
model:
|
|
95096
|
+
model: defaultModel,
|
|
95058
95097
|
defaultThinking,
|
|
95059
95098
|
defaultModes: {
|
|
95060
95099
|
yolo: defaultYolo,
|
|
95061
95100
|
planMode: defaultPlanMode
|
|
95062
95101
|
},
|
|
95063
|
-
theme,
|
|
95064
|
-
defaultEditor,
|
|
95065
95102
|
availableModels,
|
|
95066
95103
|
maxContextSize,
|
|
95067
95104
|
syncSessionRuntime,
|
|
@@ -95212,6 +95249,40 @@ function shellQuote(path) {
|
|
|
95212
95249
|
return `'${path.replace(/'/g, "'\\''")}'`;
|
|
95213
95250
|
}
|
|
95214
95251
|
//#endregion
|
|
95252
|
+
//#region src/tui/components/media/image-thumbnail.ts
|
|
95253
|
+
/**
|
|
95254
|
+
* Transcript-side rendering of a pasted image.
|
|
95255
|
+
*
|
|
95256
|
+
* On terminals that speak the Kitty graphics protocol or iTerm2 inline
|
|
95257
|
+
* image protocol (detected by pi-tui's `getCapabilities()`), we show
|
|
95258
|
+
* the actual image. Everywhere else we fall back to a one-line text
|
|
95259
|
+
* marker matching the placeholder the user sees in the input box —
|
|
95260
|
+
* this keeps the transcript readable on Terminal.app / Linux default
|
|
95261
|
+
* terminals / `script` recordings without extra chrome.
|
|
95262
|
+
*
|
|
95263
|
+
* Height is capped at ~12 rows so a single screenshot can't monopolize
|
|
95264
|
+
* the viewport; pi-tui handles proportional scaling internally.
|
|
95265
|
+
*/
|
|
95266
|
+
const MAX_IMAGE_ROWS = 12;
|
|
95267
|
+
var ImageThumbnail = class extends Container {
|
|
95268
|
+
constructor(attachment, colors) {
|
|
95269
|
+
super();
|
|
95270
|
+
const caps = getCapabilities();
|
|
95271
|
+
if (!(caps.images === "kitty" || caps.images === "iterm2")) {
|
|
95272
|
+
this.addChild(new Text(chalk.dim.cyan(` ${attachment.placeholder}`), 0, 0));
|
|
95273
|
+
return;
|
|
95274
|
+
}
|
|
95275
|
+
const image = new Image(Buffer.from(attachment.bytes).toString("base64"), attachment.mime, { fallbackColor: (s) => chalk.hex(colors.textDim)(s) }, {
|
|
95276
|
+
maxHeightCells: MAX_IMAGE_ROWS,
|
|
95277
|
+
filename: attachment.placeholder
|
|
95278
|
+
}, {
|
|
95279
|
+
widthPx: attachment.width,
|
|
95280
|
+
heightPx: attachment.height
|
|
95281
|
+
});
|
|
95282
|
+
this.addChild(image);
|
|
95283
|
+
}
|
|
95284
|
+
};
|
|
95285
|
+
//#endregion
|
|
95215
95286
|
//#region src/tui/components/messages/assistant-message.ts
|
|
95216
95287
|
const BULLET$1 = "⏺ ";
|
|
95217
95288
|
const INDENT$1 = " ";
|
|
@@ -95251,44 +95322,41 @@ var AssistantMessageComponent = class {
|
|
|
95251
95322
|
}
|
|
95252
95323
|
};
|
|
95253
95324
|
//#endregion
|
|
95254
|
-
//#region src/tui/components/
|
|
95325
|
+
//#region src/tui/components/messages/skill-activation.ts
|
|
95255
95326
|
/**
|
|
95256
|
-
*
|
|
95327
|
+
* Skill activation card.
|
|
95257
95328
|
*
|
|
95258
|
-
*
|
|
95259
|
-
*
|
|
95260
|
-
* the actual image. Everywhere else we fall back to a one-line text
|
|
95261
|
-
* marker matching the placeholder the user sees in the input box —
|
|
95262
|
-
* this keeps the transcript readable on Terminal.app / Linux default
|
|
95263
|
-
* terminals / `script` recordings without extra chrome.
|
|
95329
|
+
* 用户跑 `/skill:foo bar` 时不再把 SKILL.md 正文铺在 user 气泡里 ——
|
|
95330
|
+
* 只显示一张紧凑卡片:
|
|
95264
95331
|
*
|
|
95265
|
-
*
|
|
95266
|
-
*
|
|
95332
|
+
* ▶ Activated skill: foo
|
|
95333
|
+
* bar
|
|
95334
|
+
*
|
|
95335
|
+
* 第二行(args)可省。skill 正文已经经由 `client.prompt` 进了 LLM
|
|
95336
|
+
* 的上下文,用户视角无需再看到。
|
|
95337
|
+
*
|
|
95338
|
+
* Resume 重放仍会通过磁盘上的 user_message WAL 把 skill 正文当 user
|
|
95339
|
+
* 消息渲染(核心层未引入 skill_activated WAL 类型)—— 视为已知限制。
|
|
95267
95340
|
*/
|
|
95268
|
-
const
|
|
95269
|
-
var
|
|
95270
|
-
constructor(
|
|
95341
|
+
const ARGS_PREVIEW_MAX = 200;
|
|
95342
|
+
var SkillActivationComponent = class extends Container {
|
|
95343
|
+
constructor(name, args, colors) {
|
|
95271
95344
|
super();
|
|
95272
|
-
|
|
95273
|
-
|
|
95274
|
-
|
|
95275
|
-
|
|
95345
|
+
this.addChild(new Spacer(1));
|
|
95346
|
+
const head = chalk.hex(colors.primary).bold("▶ Activated skill: ") + chalk.hex(colors.user).bold(name);
|
|
95347
|
+
this.addChild(new Text(head, 0, 0));
|
|
95348
|
+
const trimmed = args?.trim() ?? "";
|
|
95349
|
+
if (trimmed.length > 0) {
|
|
95350
|
+
const preview = trimmed.length > ARGS_PREVIEW_MAX ? trimmed.slice(0, ARGS_PREVIEW_MAX) + "…" : trimmed;
|
|
95351
|
+
this.addChild(new Text(" " + chalk.hex(colors.textDim)(preview), 0, 0));
|
|
95276
95352
|
}
|
|
95277
|
-
const image = new Image(Buffer.from(attachment.bytes).toString("base64"), attachment.mime, { fallbackColor: (s) => chalk.hex(colors.textDim)(s) }, {
|
|
95278
|
-
maxHeightCells: MAX_IMAGE_ROWS,
|
|
95279
|
-
filename: attachment.placeholder
|
|
95280
|
-
}, {
|
|
95281
|
-
widthPx: attachment.width,
|
|
95282
|
-
heightPx: attachment.height
|
|
95283
|
-
});
|
|
95284
|
-
this.addChild(image);
|
|
95285
95353
|
}
|
|
95286
95354
|
};
|
|
95287
95355
|
//#endregion
|
|
95288
95356
|
//#region src/tui/components/messages/thinking.ts
|
|
95289
95357
|
const BULLET = "⏺ ";
|
|
95290
95358
|
const INDENT = " ";
|
|
95291
|
-
const PREVIEW_LINES$1 =
|
|
95359
|
+
const PREVIEW_LINES$1 = 3;
|
|
95292
95360
|
const SPINNER_FRAMES = [
|
|
95293
95361
|
"⠋",
|
|
95294
95362
|
"⠙",
|
|
@@ -95342,7 +95410,7 @@ var ThinkingComponent = class {
|
|
|
95342
95410
|
const visibleLines = contentLines.length > PREVIEW_LINES$1 ? contentLines.slice(contentLines.length - PREVIEW_LINES$1) : contentLines;
|
|
95343
95411
|
return [
|
|
95344
95412
|
"",
|
|
95345
|
-
|
|
95413
|
+
chalk.hex(this.color)(`${SPINNER_FRAMES[this.spinnerFrame] ?? SPINNER_FRAMES[0]} `) + chalk.hex(this.color)("thinking..."),
|
|
95346
95414
|
...visibleLines.map((line) => INDENT + line)
|
|
95347
95415
|
];
|
|
95348
95416
|
}
|
|
@@ -95378,7 +95446,7 @@ var ThinkingComponent = class {
|
|
|
95378
95446
|
* Reuses the diff algorithm from approval/DiffPreview.tsx, but outputs
|
|
95379
95447
|
* formatted text lines instead of React elements.
|
|
95380
95448
|
*/
|
|
95381
|
-
function computeDiffLines(oldText, newText, oldStart = 1, newStart = 1) {
|
|
95449
|
+
function computeDiffLines(oldText, newText, oldStart = 1, newStart = 1, isIncomplete = false) {
|
|
95382
95450
|
const oldLines = oldText ? oldText.split("\n") : [];
|
|
95383
95451
|
const newLines = newText ? newText.split("\n") : [];
|
|
95384
95452
|
const m = oldLines.length;
|
|
@@ -95414,10 +95482,16 @@ function computeDiffLines(oldText, newText, oldStart = 1, newStart = 1) {
|
|
|
95414
95482
|
}
|
|
95415
95483
|
const result = [];
|
|
95416
95484
|
for (let k = reversed.length - 1; k >= 0; k--) result.push(reversed[k]);
|
|
95485
|
+
if (isIncomplete && result.length > 0) {
|
|
95486
|
+
let lastNonDelete = result.length - 1;
|
|
95487
|
+
while (lastNonDelete >= 0 && result[lastNonDelete].kind === "delete") lastNonDelete--;
|
|
95488
|
+
if (lastNonDelete >= 0) result.length = lastNonDelete + 1;
|
|
95489
|
+
else result.length = 0;
|
|
95490
|
+
}
|
|
95417
95491
|
return result;
|
|
95418
95492
|
}
|
|
95419
|
-
function renderDiffLines(oldText, newText, path, oldStart, newStart, maxLines) {
|
|
95420
|
-
const changedLines = computeDiffLines(oldText, newText, oldStart ?? 1, newStart ?? 1).filter((l) => l.kind !== "context");
|
|
95493
|
+
function renderDiffLines(oldText, newText, path, isIncomplete = false, oldStart, newStart, maxLines) {
|
|
95494
|
+
const changedLines = computeDiffLines(oldText, newText, oldStart ?? 1, newStart ?? 1, isIncomplete).filter((l) => l.kind !== "context");
|
|
95421
95495
|
const added = changedLines.filter((l) => l.kind === "add").length;
|
|
95422
95496
|
const removed = changedLines.filter((l) => l.kind === "delete").length;
|
|
95423
95497
|
const output = [];
|
|
@@ -95538,7 +95612,7 @@ function extractApprovedPlan(output) {
|
|
|
95538
95612
|
}
|
|
95539
95613
|
const STREAMING_FIELD_RE$1 = /"(path|file_path|command|pattern|query|url|description|title|name)"\s*:\s*"((?:\\.|[^"\\])*)"/g;
|
|
95540
95614
|
function unescapeJsonString$1(s) {
|
|
95541
|
-
return s.
|
|
95615
|
+
return s.replaceAll(/\\(["\\/bfnrt])/g, (_, ch) => {
|
|
95542
95616
|
switch (ch) {
|
|
95543
95617
|
case "n": return "\n";
|
|
95544
95618
|
case "t": return " ";
|
|
@@ -95600,7 +95674,7 @@ function extractPartialStringField(text, key) {
|
|
|
95600
95674
|
const hex = text.slice(i + 2, i + 6);
|
|
95601
95675
|
const code = Number.parseInt(hex, 16);
|
|
95602
95676
|
if (Number.isNaN(code)) return out;
|
|
95603
|
-
out += String.
|
|
95677
|
+
out += String.fromCodePoint(code);
|
|
95604
95678
|
i += 6;
|
|
95605
95679
|
continue;
|
|
95606
95680
|
}
|
|
@@ -95867,7 +95941,7 @@ var ToolCallComponent = class extends Container {
|
|
|
95867
95941
|
this.buildPlanPreview();
|
|
95868
95942
|
return;
|
|
95869
95943
|
}
|
|
95870
|
-
if (this.toolCall.streamingArguments !== void 0) {
|
|
95944
|
+
if (this.result === void 0 && this.toolCall.streamingArguments !== void 0) {
|
|
95871
95945
|
this.buildStreamingPreview(this.toolCall.streamingArguments);
|
|
95872
95946
|
return;
|
|
95873
95947
|
}
|
|
@@ -95886,7 +95960,7 @@ var ToolCallComponent = class extends Container {
|
|
|
95886
95960
|
const oldStr = str(this.toolCall.args["old_string"]);
|
|
95887
95961
|
const newStr = str(this.toolCall.args["new_string"]);
|
|
95888
95962
|
if (oldStr.length === 0 && newStr.length === 0) return;
|
|
95889
|
-
const allLines = renderDiffLines(oldStr, newStr, str(this.toolCall.args["file_path"] ?? this.toolCall.args["path"]));
|
|
95963
|
+
const allLines = renderDiffLines(oldStr, newStr, str(this.toolCall.args["file_path"] ?? this.toolCall.args["path"]), false);
|
|
95890
95964
|
const shown = allLines.slice(0, CALL_PREVIEW_LINES);
|
|
95891
95965
|
const remaining = allLines.length - shown.length;
|
|
95892
95966
|
for (const line of shown) this.addChild(new Text(line, 2, 0));
|
|
@@ -95917,7 +95991,7 @@ var ToolCallComponent = class extends Container {
|
|
|
95917
95991
|
const oldStr = extractPartialStringField(streamText, "old_string") ?? "";
|
|
95918
95992
|
const newStr = extractPartialStringField(streamText, "new_string") ?? "";
|
|
95919
95993
|
if (oldStr.length === 0 && newStr.length === 0) return;
|
|
95920
|
-
const allLines = renderDiffLines(oldStr, newStr, extractPartialStringField(streamText, "file_path") ?? extractPartialStringField(streamText, "path") ?? "");
|
|
95994
|
+
const allLines = renderDiffLines(oldStr, newStr, extractPartialStringField(streamText, "file_path") ?? extractPartialStringField(streamText, "path") ?? "", true);
|
|
95921
95995
|
const shown = allLines.slice(0, CALL_PREVIEW_LINES);
|
|
95922
95996
|
const remaining = allLines.length - shown.length;
|
|
95923
95997
|
for (const line of shown) this.addChild(new Text(line, 2, 0));
|
|
@@ -96053,10 +96127,11 @@ var WelcomeComponent = class {
|
|
|
96053
96127
|
"",
|
|
96054
96128
|
...infoLines
|
|
96055
96129
|
];
|
|
96056
|
-
const lines = [
|
|
96057
|
-
|
|
96058
|
-
|
|
96059
|
-
|
|
96130
|
+
const lines = [
|
|
96131
|
+
"",
|
|
96132
|
+
primary("╭" + "─".repeat(width - 2) + "╮"),
|
|
96133
|
+
primary("│") + " ".repeat(width - 2) + primary("│")
|
|
96134
|
+
];
|
|
96060
96135
|
for (const content of contentLines) {
|
|
96061
96136
|
const truncated = truncateToWidth(content, innerWidth, "…");
|
|
96062
96137
|
const vis = visibleWidth(truncated);
|
|
@@ -96202,6 +96277,7 @@ function createTranscriptComponent(state, entry) {
|
|
|
96202
96277
|
}
|
|
96203
96278
|
return msg;
|
|
96204
96279
|
}
|
|
96280
|
+
case "skill_activation": return new SkillActivationComponent(entry.skillName ?? entry.content, entry.skillArgs, state.colors);
|
|
96205
96281
|
case "assistant": return createAssistantEntry(state, entry.content);
|
|
96206
96282
|
case "thinking": return new ThinkingComponent(entry.content, state.colors, true);
|
|
96207
96283
|
case "tool_call":
|
|
@@ -96267,7 +96343,7 @@ function emitStatus(state, message, color) {
|
|
|
96267
96343
|
turnId: state.currentTurnId,
|
|
96268
96344
|
renderMode: "plain",
|
|
96269
96345
|
content: message,
|
|
96270
|
-
|
|
96346
|
+
color
|
|
96271
96347
|
});
|
|
96272
96348
|
}
|
|
96273
96349
|
function emitNotice(state, title, detail) {
|
|
@@ -96277,7 +96353,7 @@ function emitNotice(state, title, detail) {
|
|
|
96277
96353
|
turnId: state.currentTurnId,
|
|
96278
96354
|
renderMode: "notice",
|
|
96279
96355
|
content: title,
|
|
96280
|
-
|
|
96356
|
+
detail
|
|
96281
96357
|
});
|
|
96282
96358
|
}
|
|
96283
96359
|
/** Red. */
|
|
@@ -96344,7 +96420,7 @@ function buildImagePart(att) {
|
|
|
96344
96420
|
}
|
|
96345
96421
|
//#endregion
|
|
96346
96422
|
//#region src/tui/theme/pi-tui-theme.ts
|
|
96347
|
-
const HEADING_HASH_PREFIX = /^((?:\
|
|
96423
|
+
const HEADING_HASH_PREFIX = /^((?:\x1B\[[0-9;]*m)*)#{1,6}[ \t]+/;
|
|
96348
96424
|
function createMarkdownTheme(colors) {
|
|
96349
96425
|
const stripHash = (text) => text.replace(HEADING_HASH_PREFIX, "$1");
|
|
96350
96426
|
return {
|
|
@@ -96590,7 +96666,7 @@ function fetchSnapshot(gitRoot) {
|
|
|
96590
96666
|
const seen = /* @__PURE__ */ new Set();
|
|
96591
96667
|
for (const path of tracked) seen.add(path);
|
|
96592
96668
|
for (const path of untracked) seen.add(path);
|
|
96593
|
-
const merged = [...seen].
|
|
96669
|
+
const merged = [...seen].toSorted();
|
|
96594
96670
|
const files = merged.length > MAX_ENTRIES ? merged.slice(0, MAX_ENTRIES) : merged;
|
|
96595
96671
|
return {
|
|
96596
96672
|
files,
|
|
@@ -96732,7 +96808,7 @@ async function refreshConfigAfterLogin(client, ctx) {
|
|
|
96732
96808
|
const selected = defaultModel !== void 0 ? availableModels[defaultModel] : void 0;
|
|
96733
96809
|
const patch = {
|
|
96734
96810
|
availableModels,
|
|
96735
|
-
|
|
96811
|
+
model: defaultModel,
|
|
96736
96812
|
...selected?.maxContextSize !== void 0 ? { maxContextTokens: selected.maxContextSize } : {},
|
|
96737
96813
|
...typeof config["defaultThinking"] === "boolean" ? { thinking: config["defaultThinking"] } : {}
|
|
96738
96814
|
};
|
|
@@ -96746,6 +96822,7 @@ function createAuthCommands(deps = {}) {
|
|
|
96746
96822
|
aliases: [],
|
|
96747
96823
|
description: "Clear OAuth credentials",
|
|
96748
96824
|
mode: "both",
|
|
96825
|
+
priority: 40,
|
|
96749
96826
|
async execute(_args, _ctx) {
|
|
96750
96827
|
if (deps.client === void 0) return ok$2("OAuth is unavailable: no wire client is attached.");
|
|
96751
96828
|
if (!(await deps.client.authStatus(providerName)).providers.some((provider) => provider.provider_name === providerName && provider.has_token)) return ok$2("Not logged in.");
|
|
@@ -96757,6 +96834,7 @@ function createAuthCommands(deps = {}) {
|
|
|
96757
96834
|
aliases: [],
|
|
96758
96835
|
description: "Start OAuth device code login flow",
|
|
96759
96836
|
mode: "both",
|
|
96837
|
+
priority: 40,
|
|
96760
96838
|
async execute(_args, ctx) {
|
|
96761
96839
|
if (deps.client === void 0) return ok$2("OAuth is unavailable: no wire client is attached.");
|
|
96762
96840
|
const disposeDeviceCodeHandler = deps.client.onRequest("auth.device_code", (req) => {
|
|
@@ -96805,6 +96883,7 @@ const shellCommands = [
|
|
|
96805
96883
|
aliases: ["quit", "q"],
|
|
96806
96884
|
description: "Exit the application",
|
|
96807
96885
|
mode: "both",
|
|
96886
|
+
priority: 20,
|
|
96808
96887
|
async execute() {
|
|
96809
96888
|
return { type: "exit" };
|
|
96810
96889
|
}
|
|
@@ -96814,6 +96893,7 @@ const shellCommands = [
|
|
|
96814
96893
|
aliases: ["h", "?"],
|
|
96815
96894
|
description: "Show available commands and shortcuts",
|
|
96816
96895
|
mode: "both",
|
|
96896
|
+
priority: 80,
|
|
96817
96897
|
async execute(_args, _ctx) {
|
|
96818
96898
|
return ok$1("__show_help__");
|
|
96819
96899
|
}
|
|
@@ -96823,6 +96903,7 @@ const shellCommands = [
|
|
|
96823
96903
|
aliases: [],
|
|
96824
96904
|
description: "Show version information",
|
|
96825
96905
|
mode: "both",
|
|
96906
|
+
priority: 20,
|
|
96826
96907
|
async execute(_args, ctx) {
|
|
96827
96908
|
return ok$1(`Kimi Code v${ctx.appState.version}`);
|
|
96828
96909
|
}
|
|
@@ -96832,6 +96913,7 @@ const shellCommands = [
|
|
|
96832
96913
|
aliases: [],
|
|
96833
96914
|
description: "Start a fresh session in the current workspace",
|
|
96834
96915
|
mode: "both",
|
|
96916
|
+
priority: 80,
|
|
96835
96917
|
async execute() {
|
|
96836
96918
|
return {
|
|
96837
96919
|
type: "reload",
|
|
@@ -96844,6 +96926,7 @@ const shellCommands = [
|
|
|
96844
96926
|
aliases: ["resume"],
|
|
96845
96927
|
description: "Browse and resume sessions",
|
|
96846
96928
|
mode: "both",
|
|
96929
|
+
priority: 80,
|
|
96847
96930
|
async execute(_args, _ctx) {
|
|
96848
96931
|
return ok$1("__show_sessions__");
|
|
96849
96932
|
}
|
|
@@ -96853,6 +96936,7 @@ const shellCommands = [
|
|
|
96853
96936
|
aliases: ["rename"],
|
|
96854
96937
|
description: "Set or show session title",
|
|
96855
96938
|
mode: "both",
|
|
96939
|
+
priority: 60,
|
|
96856
96940
|
async execute(args, ctx) {
|
|
96857
96941
|
const trimmed = args.trim();
|
|
96858
96942
|
if (trimmed.length === 0) {
|
|
@@ -96873,6 +96957,7 @@ const shellCommands = [
|
|
|
96873
96957
|
aliases: ["yes"],
|
|
96874
96958
|
description: "Toggle auto-approve mode",
|
|
96875
96959
|
mode: "both",
|
|
96960
|
+
priority: 100,
|
|
96876
96961
|
async execute(args, ctx) {
|
|
96877
96962
|
let enabled;
|
|
96878
96963
|
if (args === "on") enabled = true;
|
|
@@ -96889,6 +96974,7 @@ const shellCommands = [
|
|
|
96889
96974
|
aliases: [],
|
|
96890
96975
|
description: "Toggle plan mode",
|
|
96891
96976
|
mode: "both",
|
|
96977
|
+
priority: 100,
|
|
96892
96978
|
async execute(args, ctx) {
|
|
96893
96979
|
const subcmd = args.trim().toLowerCase();
|
|
96894
96980
|
if (subcmd === "view") {
|
|
@@ -96916,6 +97002,7 @@ const shellCommands = [
|
|
|
96916
97002
|
aliases: [],
|
|
96917
97003
|
description: "Switch LLM model",
|
|
96918
97004
|
mode: "both",
|
|
97005
|
+
priority: 100,
|
|
96919
97006
|
async execute(args, ctx) {
|
|
96920
97007
|
const trimmed = args.trim();
|
|
96921
97008
|
if (trimmed.length === 0) return ok$1("__show_model_picker__");
|
|
@@ -96928,6 +97015,7 @@ const shellCommands = [
|
|
|
96928
97015
|
aliases: ["status"],
|
|
96929
97016
|
description: "Show session tokens + context window + plan quotas",
|
|
96930
97017
|
mode: "both",
|
|
97018
|
+
priority: 60,
|
|
96931
97019
|
async execute() {
|
|
96932
97020
|
return ok$1("__show_usage__");
|
|
96933
97021
|
}
|
|
@@ -96947,6 +97035,7 @@ const soulCommands = [{
|
|
|
96947
97035
|
aliases: [],
|
|
96948
97036
|
description: "Compact the conversation context",
|
|
96949
97037
|
mode: "both",
|
|
97038
|
+
priority: 80,
|
|
96950
97039
|
async execute(args, ctx) {
|
|
96951
97040
|
const customInstruction = args.trim() || void 0;
|
|
96952
97041
|
await ctx.client.compact(ctx.appState.sessionId, customInstruction);
|
|
@@ -96967,13 +97056,12 @@ function parseSlashInput(input) {
|
|
|
96967
97056
|
const trimmed = input.slice(1).trim();
|
|
96968
97057
|
if (trimmed.length === 0) return null;
|
|
96969
97058
|
const spaceIdx = trimmed.indexOf(" ");
|
|
96970
|
-
|
|
96971
|
-
|
|
96972
|
-
|
|
96973
|
-
};
|
|
97059
|
+
const name = spaceIdx === -1 ? trimmed : trimmed.slice(0, spaceIdx);
|
|
97060
|
+
const args = spaceIdx === -1 ? "" : trimmed.slice(spaceIdx + 1).trim();
|
|
97061
|
+
if (name.includes("/")) return null;
|
|
96974
97062
|
return {
|
|
96975
|
-
name
|
|
96976
|
-
args
|
|
97063
|
+
name,
|
|
97064
|
+
args
|
|
96977
97065
|
};
|
|
96978
97066
|
}
|
|
96979
97067
|
//#endregion
|
|
@@ -97030,11 +97118,17 @@ var SlashCommandRegistry = class {
|
|
|
97030
97118
|
}
|
|
97031
97119
|
return [...bestScores.values()].toSorted((a, b) => b.score - a.score || a.def.name.localeCompare(b.def.name)).map(({ def }) => def);
|
|
97032
97120
|
}
|
|
97033
|
-
/**
|
|
97121
|
+
/**
|
|
97122
|
+
* List all registered commands, optionally filtered by mode.
|
|
97123
|
+
* Built-in commands come first, sorted alphabetically; skill commands
|
|
97124
|
+
* follow in their original registration order.
|
|
97125
|
+
*/
|
|
97034
97126
|
listAll(mode) {
|
|
97035
97127
|
const all = [...this.commands.values()];
|
|
97036
|
-
|
|
97037
|
-
|
|
97128
|
+
const filtered = mode === void 0 ? all : all.filter((def) => def.mode === mode || def.mode === "both");
|
|
97129
|
+
const builtins = filtered.filter((def) => !def.name.startsWith(SKILL_COMMAND_PREFIX)).toSorted((a, b) => (b.priority ?? 0) - (a.priority ?? 0) || a.name.localeCompare(b.name));
|
|
97130
|
+
const skills = filtered.filter((def) => def.name.startsWith(SKILL_COMMAND_PREFIX));
|
|
97131
|
+
return [...builtins, ...skills];
|
|
97038
97132
|
}
|
|
97039
97133
|
/** Get the number of registered commands. */
|
|
97040
97134
|
get size() {
|
|
@@ -97605,9 +97699,7 @@ var TodoPanelComponent = class {
|
|
|
97605
97699
|
render(width) {
|
|
97606
97700
|
if (this.todos.length === 0) return [];
|
|
97607
97701
|
const c = this.colors;
|
|
97608
|
-
const lines = [];
|
|
97609
|
-
lines.push(chalk.hex(c.border)("─".repeat(width)));
|
|
97610
|
-
lines.push(chalk.hex(c.primary).bold(" Todo"));
|
|
97702
|
+
const lines = [chalk.hex(c.border)("─".repeat(width)), chalk.hex(c.primary).bold(" Todo")];
|
|
97611
97703
|
for (const todo of this.todos) lines.push(renderRow(todo, c));
|
|
97612
97704
|
return lines.map((line) => truncateToWidth(line, width));
|
|
97613
97705
|
}
|
|
@@ -97977,7 +98069,7 @@ function enqueueMessage(state, text) {
|
|
|
97977
98069
|
}
|
|
97978
98070
|
function recallLastQueued(state) {
|
|
97979
98071
|
if (state.queuedMessages.length === 0) return void 0;
|
|
97980
|
-
const last = state.queuedMessages
|
|
98072
|
+
const last = state.queuedMessages.at(-1);
|
|
97981
98073
|
state.queuedMessages = state.queuedMessages.slice(0, -1);
|
|
97982
98074
|
return last.text;
|
|
97983
98075
|
}
|
|
@@ -98043,6 +98135,66 @@ function sendMessageInternal(state, addEntry, input, options) {
|
|
|
98043
98135
|
});
|
|
98044
98136
|
});
|
|
98045
98137
|
}
|
|
98138
|
+
/**
|
|
98139
|
+
* Activate a skill: render a compact activation card (no skill body in
|
|
98140
|
+
* the transcript) and forward the prepared prompt — `skill.content +
|
|
98141
|
+
* "\n\nUser request:\n" + args` — to core via `client.prompt`. Keeps
|
|
98142
|
+
* the skill body out of the user-visible transcript while still feeding
|
|
98143
|
+
* it into the LLM exactly as the legacy path did.
|
|
98144
|
+
*/
|
|
98145
|
+
function sendSkillActivation(state, addEntry, skillName, skillArgs, fullPrompt) {
|
|
98146
|
+
addEntry({
|
|
98147
|
+
id: nextTranscriptId(),
|
|
98148
|
+
kind: "skill_activation",
|
|
98149
|
+
turnId: void 0,
|
|
98150
|
+
renderMode: "plain",
|
|
98151
|
+
content: `Activated skill: ${skillName}`,
|
|
98152
|
+
skillName,
|
|
98153
|
+
skillArgs
|
|
98154
|
+
});
|
|
98155
|
+
state.currentTurnId = void 0;
|
|
98156
|
+
state.assistantDraft = "";
|
|
98157
|
+
state.assistantStreamActive = false;
|
|
98158
|
+
state.thinkingDraft = "";
|
|
98159
|
+
disposeActiveThinkingComponent(state);
|
|
98160
|
+
state.activeToolCalls.clear();
|
|
98161
|
+
state.streamingToolCallArguments.clear();
|
|
98162
|
+
state.livePane = {
|
|
98163
|
+
...state.livePane,
|
|
98164
|
+
mode: "waiting",
|
|
98165
|
+
thinkingText: "",
|
|
98166
|
+
assistantText: "",
|
|
98167
|
+
pendingToolCall: null,
|
|
98168
|
+
pendingApproval: null,
|
|
98169
|
+
pendingQuestion: null
|
|
98170
|
+
};
|
|
98171
|
+
state.appState.isStreaming = true;
|
|
98172
|
+
state.appState.streamingPhase = "waiting";
|
|
98173
|
+
state.appState.streamingStartTime = Date.now();
|
|
98174
|
+
state.footer.setState(state.appState);
|
|
98175
|
+
state.ui.requestRender();
|
|
98176
|
+
state.client.prompt(state.appState.sessionId, { input: fullPrompt }).catch((error) => {
|
|
98177
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
98178
|
+
state.appState.isStreaming = false;
|
|
98179
|
+
state.appState.streamingPhase = "idle";
|
|
98180
|
+
state.livePane = {
|
|
98181
|
+
mode: "idle",
|
|
98182
|
+
thinkingText: "",
|
|
98183
|
+
assistantText: "",
|
|
98184
|
+
pendingToolCall: null,
|
|
98185
|
+
pendingApproval: null,
|
|
98186
|
+
pendingQuestion: null
|
|
98187
|
+
};
|
|
98188
|
+
state.footer.setState(state.appState);
|
|
98189
|
+
addEntry({
|
|
98190
|
+
id: nextTranscriptId(),
|
|
98191
|
+
kind: "status",
|
|
98192
|
+
renderMode: "plain",
|
|
98193
|
+
content: `Skill "${skillName}" failed: ${message}`,
|
|
98194
|
+
color: state.colors.error
|
|
98195
|
+
});
|
|
98196
|
+
});
|
|
98197
|
+
}
|
|
98046
98198
|
/** Send from user input: enqueue if busy, otherwise send immediately. */
|
|
98047
98199
|
function sendMessage(state, addEntry, input, options) {
|
|
98048
98200
|
if (state.appState.isStreaming || state.appState.isCompacting) {
|
|
@@ -98307,7 +98459,7 @@ function projectToolCall(state, record) {
|
|
|
98307
98459
|
id: tool.id,
|
|
98308
98460
|
name: tool.name,
|
|
98309
98461
|
args: tool.args,
|
|
98310
|
-
|
|
98462
|
+
description: tool.description
|
|
98311
98463
|
};
|
|
98312
98464
|
state.toolCalls.set(tool.id, toolCall);
|
|
98313
98465
|
state.entries.push(entry("tool_call", "", "plain", {
|
|
@@ -98357,13 +98509,11 @@ function toolCallFromRecord(record) {
|
|
|
98357
98509
|
const id = stringValue(data["tool_call_id"]);
|
|
98358
98510
|
const name = stringValue(data["tool_name"]);
|
|
98359
98511
|
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
98512
|
return {
|
|
98363
98513
|
id,
|
|
98364
98514
|
name,
|
|
98365
|
-
args,
|
|
98366
|
-
|
|
98515
|
+
args: isObject(data["args"]) ? data["args"] : {},
|
|
98516
|
+
description: stringValue(data["activity_description"])
|
|
98367
98517
|
};
|
|
98368
98518
|
}
|
|
98369
98519
|
function toolResultFromRecord(record) {
|
|
@@ -98378,7 +98528,7 @@ function toolResultFromRecord(record) {
|
|
|
98378
98528
|
function ensureSubagent(parent, id, name) {
|
|
98379
98529
|
if (parent.subagent === void 0) parent.subagent = {
|
|
98380
98530
|
id,
|
|
98381
|
-
|
|
98531
|
+
name,
|
|
98382
98532
|
toolCalls: []
|
|
98383
98533
|
};
|
|
98384
98534
|
return parent.subagent;
|
|
@@ -98389,8 +98539,8 @@ function entry(kind, content, renderMode, extras) {
|
|
|
98389
98539
|
kind,
|
|
98390
98540
|
renderMode,
|
|
98391
98541
|
content,
|
|
98392
|
-
|
|
98393
|
-
|
|
98542
|
+
turnId: extras?.turnId,
|
|
98543
|
+
toolCallData: extras?.toolCallData
|
|
98394
98544
|
};
|
|
98395
98545
|
}
|
|
98396
98546
|
function userContentToText(content) {
|
|
@@ -98744,36 +98894,71 @@ function endCompaction(state, tokensBefore, tokensAfter) {
|
|
|
98744
98894
|
state.ui.requestRender();
|
|
98745
98895
|
}
|
|
98746
98896
|
//#endregion
|
|
98897
|
+
//#region src/tui/commands/skill-commands.ts
|
|
98898
|
+
const SKILL_ACTIVATION_SENTINEL_PREFIX = "__activate_skill__:";
|
|
98899
|
+
async function fetchSkills(client, sessionId) {
|
|
98900
|
+
const skills = (await client.listSkills(sessionId))?.skills ?? [];
|
|
98901
|
+
const out = [];
|
|
98902
|
+
for (const s of skills) {
|
|
98903
|
+
if (typeof s?.name !== "string" || s.name.length === 0) continue;
|
|
98904
|
+
if (typeof s.content !== "string") continue;
|
|
98905
|
+
out.push({
|
|
98906
|
+
name: s.name,
|
|
98907
|
+
content: s.content,
|
|
98908
|
+
...typeof s.description === "string" ? { description: s.description } : {}
|
|
98909
|
+
});
|
|
98910
|
+
}
|
|
98911
|
+
return out;
|
|
98912
|
+
}
|
|
98913
|
+
function buildSkillCommand(skill) {
|
|
98914
|
+
return {
|
|
98915
|
+
name: `${SKILL_COMMAND_PREFIX}${skill.name}`,
|
|
98916
|
+
aliases: [],
|
|
98917
|
+
description: skill.description ?? "",
|
|
98918
|
+
mode: "both",
|
|
98919
|
+
async execute(args) {
|
|
98920
|
+
const trimmed = args.trim();
|
|
98921
|
+
const prompt = trimmed.length > 0 ? `${skill.content}\n\nUser request:\n${trimmed}` : skill.content;
|
|
98922
|
+
const payload = {
|
|
98923
|
+
name: skill.name,
|
|
98924
|
+
args: trimmed,
|
|
98925
|
+
prompt
|
|
98926
|
+
};
|
|
98927
|
+
return {
|
|
98928
|
+
type: "ok",
|
|
98929
|
+
message: `${SKILL_ACTIVATION_SENTINEL_PREFIX}${JSON.stringify(payload)}`
|
|
98930
|
+
};
|
|
98931
|
+
}
|
|
98932
|
+
};
|
|
98933
|
+
}
|
|
98934
|
+
//#endregion
|
|
98747
98935
|
//#region src/tui/commands/skill-dispatch.ts
|
|
98748
98936
|
/**
|
|
98749
|
-
*
|
|
98937
|
+
* 探测 `/name args` 是否对应某个 skill。命中返回 activate(含拼好的
|
|
98938
|
+
* prompt);未命中或查询失败返回 unknown,message 由调用方推到 transcript。
|
|
98750
98939
|
*/
|
|
98751
98940
|
async function tryDispatchSkill(client, sessionId, name, args) {
|
|
98752
98941
|
let skills;
|
|
98753
98942
|
try {
|
|
98754
98943
|
skills = (await client.listSkills(sessionId))?.skills ?? [];
|
|
98755
|
-
} catch (
|
|
98944
|
+
} catch (error) {
|
|
98756
98945
|
return {
|
|
98757
|
-
|
|
98758
|
-
message: `Unknown command: /${name} (skill lookup failed: ${
|
|
98946
|
+
kind: "unknown",
|
|
98947
|
+
message: `Unknown command: /${name} (skill lookup failed: ${error instanceof Error ? error.message : String(error)})`
|
|
98759
98948
|
};
|
|
98760
98949
|
}
|
|
98761
|
-
|
|
98762
|
-
|
|
98950
|
+
const skill = skills.find((s) => s.name === name);
|
|
98951
|
+
if (skill === void 0 || typeof skill.content !== "string") return {
|
|
98952
|
+
kind: "unknown",
|
|
98763
98953
|
message: `Unknown command: /${name}`
|
|
98764
98954
|
};
|
|
98765
|
-
|
|
98766
|
-
|
|
98767
|
-
|
|
98768
|
-
|
|
98769
|
-
|
|
98770
|
-
}
|
|
98771
|
-
}
|
|
98772
|
-
return {
|
|
98773
|
-
matched: true,
|
|
98774
|
-
message: `Skill "${name}" failed: ${err instanceof Error ? err.message : String(err)}`
|
|
98775
|
-
};
|
|
98776
|
-
}
|
|
98955
|
+
const trimmed = args.trim();
|
|
98956
|
+
return {
|
|
98957
|
+
kind: "activate",
|
|
98958
|
+
name,
|
|
98959
|
+
args: trimmed,
|
|
98960
|
+
prompt: trimmed.length > 0 ? `${skill.content}\n\nUser request:\n${trimmed}` : skill.content
|
|
98961
|
+
};
|
|
98777
98962
|
}
|
|
98778
98963
|
//#endregion
|
|
98779
98964
|
//#region src/tui/commands/dispatch.ts
|
|
@@ -98782,7 +98967,12 @@ async function dispatchSlashCommand(input, state, buildCtx, addEntry) {
|
|
|
98782
98967
|
if (!parsed) return false;
|
|
98783
98968
|
const def = state.registry.find(parsed.name);
|
|
98784
98969
|
if (!def) {
|
|
98970
|
+
const ctx = buildCtx();
|
|
98785
98971
|
const result = await tryDispatchSkill(state.client, state.appState.sessionId, parsed.name, parsed.args);
|
|
98972
|
+
if (result.kind === "activate") {
|
|
98973
|
+
ctx.activateSkill(result.name, result.args, result.prompt);
|
|
98974
|
+
return true;
|
|
98975
|
+
}
|
|
98786
98976
|
addEntry({
|
|
98787
98977
|
id: `slash-${Date.now()}`,
|
|
98788
98978
|
kind: "status",
|
|
@@ -98850,12 +99040,30 @@ async function dispatchSlashCommand(input, state, buildCtx, addEntry) {
|
|
|
98850
99040
|
ctx.sendAsMessage(msg);
|
|
98851
99041
|
return true;
|
|
98852
99042
|
}
|
|
99043
|
+
if (result.message.startsWith("__activate_skill__:")) {
|
|
99044
|
+
const raw = result.message.slice(19);
|
|
99045
|
+
let payload;
|
|
99046
|
+
try {
|
|
99047
|
+
payload = JSON.parse(raw);
|
|
99048
|
+
} catch (error) {
|
|
99049
|
+
addEntry({
|
|
99050
|
+
id: `slash-err-${Date.now()}`,
|
|
99051
|
+
kind: "status",
|
|
99052
|
+
renderMode: "plain",
|
|
99053
|
+
content: `Skill activation failed: malformed payload (${error instanceof Error ? error.message : String(error)})`,
|
|
99054
|
+
color: state.colors.error
|
|
99055
|
+
});
|
|
99056
|
+
return true;
|
|
99057
|
+
}
|
|
99058
|
+
ctx.activateSkill(payload.name, payload.args, payload.prompt);
|
|
99059
|
+
return true;
|
|
99060
|
+
}
|
|
98853
99061
|
addEntry({
|
|
98854
99062
|
id: `slash-${Date.now()}`,
|
|
98855
99063
|
kind: "status",
|
|
98856
99064
|
renderMode: "plain",
|
|
98857
99065
|
content: result.message,
|
|
98858
|
-
|
|
99066
|
+
color: result.color
|
|
98859
99067
|
});
|
|
98860
99068
|
return true;
|
|
98861
99069
|
}
|
|
@@ -98941,7 +99149,7 @@ function handleContentDelta(ectx, data) {
|
|
|
98941
99149
|
//#region src/tui/handlers/tool.ts
|
|
98942
99150
|
const STREAMING_FIELD_RE = /"(path|file_path|command|pattern|query|url|description|title|name)"\s*:\s*"((?:\\.|[^"\\])*)"/g;
|
|
98943
99151
|
function unescapeJsonString(s) {
|
|
98944
|
-
return s.
|
|
99152
|
+
return s.replaceAll(/\\(["\\/bfnrt])/g, (_, ch) => {
|
|
98945
99153
|
switch (ch) {
|
|
98946
99154
|
case "n": return "\n";
|
|
98947
99155
|
case "t": return " ";
|
|
@@ -99224,7 +99432,7 @@ var ChoicePickerComponent = class extends Container {
|
|
|
99224
99432
|
super();
|
|
99225
99433
|
this.opts = opts;
|
|
99226
99434
|
const currentIdx = opts.options.findIndex((o) => o.value === opts.currentValue);
|
|
99227
|
-
this.selectedIndex = currentIdx
|
|
99435
|
+
this.selectedIndex = Math.max(currentIdx, 0);
|
|
99228
99436
|
}
|
|
99229
99437
|
handleInput(data) {
|
|
99230
99438
|
if (matchesKey(data, Key.escape)) {
|
|
@@ -99247,12 +99455,13 @@ var ChoicePickerComponent = class extends Container {
|
|
|
99247
99455
|
}
|
|
99248
99456
|
render(width) {
|
|
99249
99457
|
const { colors } = this.opts;
|
|
99250
|
-
const lines = [];
|
|
99251
|
-
lines.push(chalk.hex(colors.primary)("─".repeat(width)));
|
|
99252
|
-
lines.push(chalk.hex(colors.primary).bold(` ${this.opts.title}`));
|
|
99253
99458
|
const hint = this.opts.hint ?? "↑↓ navigate · Enter select · Esc cancel";
|
|
99254
|
-
lines
|
|
99255
|
-
|
|
99459
|
+
const lines = [
|
|
99460
|
+
chalk.hex(colors.primary)("─".repeat(width)),
|
|
99461
|
+
chalk.hex(colors.primary).bold(` ${this.opts.title}`),
|
|
99462
|
+
chalk.hex(colors.textMuted)(` ${hint}`),
|
|
99463
|
+
""
|
|
99464
|
+
];
|
|
99256
99465
|
for (let i = 0; i < this.opts.options.length; i++) {
|
|
99257
99466
|
const opt = this.opts.options[i];
|
|
99258
99467
|
const isSelected = i === this.selectedIndex;
|
|
@@ -99410,31 +99619,28 @@ var HelpPanelComponent = class extends Container {
|
|
|
99410
99619
|
const muted = chalk.hex(c.textMuted);
|
|
99411
99620
|
const kbdColor = chalk.hex(c.warning);
|
|
99412
99621
|
const slashColor = chalk.hex(c.primary);
|
|
99413
|
-
const lines = [];
|
|
99414
|
-
lines.push(accent("─".repeat(width)));
|
|
99415
|
-
lines.push(accent.bold(" help ") + muted("· Esc / Enter / q to close · ↑↓ scroll"));
|
|
99416
|
-
lines.push("");
|
|
99417
|
-
lines.push(` ${dim("Sure, Kimi is ready to help! Just send a message to get started.")}`);
|
|
99418
|
-
lines.push("");
|
|
99419
|
-
lines.push(` ${chalk.bold("Keyboard shortcuts")}`);
|
|
99420
99622
|
const shortcuts = this.opts.shortcuts ?? DEFAULT_KEYBOARD_SHORTCUTS;
|
|
99421
99623
|
const kbdWidth = Math.max(8, ...shortcuts.map((s) => s.keys.length));
|
|
99422
|
-
|
|
99423
|
-
lines.push("");
|
|
99424
|
-
lines.push(` ${chalk.bold("Slash commands")}`);
|
|
99425
|
-
const sortedCmds = [...this.opts.commands].sort((a, b) => a.name.localeCompare(b.name));
|
|
99624
|
+
const sortedCmds = [...this.opts.commands].toSorted((a, b) => a.name.localeCompare(b.name));
|
|
99426
99625
|
const cmdLabels = sortedCmds.map((c) => {
|
|
99427
99626
|
const aliases = c.aliases.length > 0 ? ` (${c.aliases.map((a) => "/" + a).join(", ")})` : "";
|
|
99428
99627
|
return `/${c.name}${aliases}`;
|
|
99429
99628
|
});
|
|
99430
99629
|
const cmdWidth = Math.max(12, ...cmdLabels.map((l) => l.length));
|
|
99431
|
-
|
|
99432
|
-
|
|
99433
|
-
|
|
99434
|
-
|
|
99435
|
-
|
|
99436
|
-
|
|
99437
|
-
|
|
99630
|
+
const lines = [
|
|
99631
|
+
accent("─".repeat(width)),
|
|
99632
|
+
accent.bold(" help ") + muted("· Esc / Enter / q to close · ↑↓ scroll"),
|
|
99633
|
+
"",
|
|
99634
|
+
` ${dim("Sure, Kimi is ready to help! Just send a message to get started.")}`,
|
|
99635
|
+
"",
|
|
99636
|
+
` ${chalk.bold("Keyboard shortcuts")}`,
|
|
99637
|
+
...shortcuts.map((s) => ` ${kbdColor(s.keys.padEnd(kbdWidth))} ${dim(s.description)}`),
|
|
99638
|
+
"",
|
|
99639
|
+
` ${chalk.bold("Slash commands")}`,
|
|
99640
|
+
...sortedCmds.map((cmd, i) => ` ${slashColor(cmdLabels[i].padEnd(cmdWidth))} ${dim(cmd.description)}`),
|
|
99641
|
+
"",
|
|
99642
|
+
accent("─".repeat(width))
|
|
99643
|
+
];
|
|
99438
99644
|
const content = lines.slice(1, lines.length - 1);
|
|
99439
99645
|
const maxVisible = Math.max(5, this.opts.maxVisible ?? 24);
|
|
99440
99646
|
if (content.length > maxVisible) {
|
|
@@ -99445,7 +99651,7 @@ var HelpPanelComponent = class extends Container {
|
|
|
99445
99651
|
lines[0],
|
|
99446
99652
|
...slice,
|
|
99447
99653
|
scrollInfo,
|
|
99448
|
-
lines
|
|
99654
|
+
lines.at(-1)
|
|
99449
99655
|
].map((line) => truncateToWidth(line, width));
|
|
99450
99656
|
}
|
|
99451
99657
|
this.scrollTop = 0;
|
|
@@ -99619,8 +99825,7 @@ var SessionPickerComponent = class extends Container {
|
|
|
99619
99825
|
}
|
|
99620
99826
|
render(width) {
|
|
99621
99827
|
const colors = this.colors;
|
|
99622
|
-
const lines = [];
|
|
99623
|
-
lines.push(chalk.hex(colors.primary)("─".repeat(width)));
|
|
99828
|
+
const lines = [chalk.hex(colors.primary)("─".repeat(width))];
|
|
99624
99829
|
if (this.loading) {
|
|
99625
99830
|
lines.push(chalk.hex(colors.primary).bold("Sessions"));
|
|
99626
99831
|
lines.push(chalk.hex(colors.textMuted)("Loading sessions..."));
|
|
@@ -100113,9 +100318,9 @@ function extractFromArgs(toolName, detail) {
|
|
|
100113
100318
|
type: "shell",
|
|
100114
100319
|
language: stringField(detail, "language") ?? "bash",
|
|
100115
100320
|
command,
|
|
100116
|
-
|
|
100117
|
-
|
|
100118
|
-
|
|
100321
|
+
cwd,
|
|
100322
|
+
description: toolDescription,
|
|
100323
|
+
danger
|
|
100119
100324
|
}],
|
|
100120
100325
|
description: toolDescription ?? ""
|
|
100121
100326
|
};
|
|
@@ -100141,17 +100346,14 @@ function extractFromArgs(toolName, detail) {
|
|
|
100141
100346
|
description: ""
|
|
100142
100347
|
};
|
|
100143
100348
|
const url = stringField(detail, "url");
|
|
100144
|
-
if (url !== void 0) {
|
|
100145
|
-
|
|
100146
|
-
|
|
100147
|
-
|
|
100148
|
-
|
|
100149
|
-
|
|
100150
|
-
|
|
100151
|
-
|
|
100152
|
-
description: ""
|
|
100153
|
-
};
|
|
100154
|
-
}
|
|
100349
|
+
if (url !== void 0) return {
|
|
100350
|
+
blocks: [{
|
|
100351
|
+
type: "url_fetch",
|
|
100352
|
+
url,
|
|
100353
|
+
method: stringField(detail, "method")
|
|
100354
|
+
}],
|
|
100355
|
+
description: ""
|
|
100356
|
+
};
|
|
100155
100357
|
const query = stringField(detail, "query");
|
|
100156
100358
|
if (query !== void 0) return {
|
|
100157
100359
|
blocks: [{
|
|
@@ -100161,17 +100363,14 @@ function extractFromArgs(toolName, detail) {
|
|
|
100161
100363
|
description: ""
|
|
100162
100364
|
};
|
|
100163
100365
|
const pattern = stringField(detail, "pattern");
|
|
100164
|
-
if (pattern !== void 0) {
|
|
100165
|
-
|
|
100166
|
-
|
|
100167
|
-
|
|
100168
|
-
|
|
100169
|
-
|
|
100170
|
-
|
|
100171
|
-
|
|
100172
|
-
description: ""
|
|
100173
|
-
};
|
|
100174
|
-
}
|
|
100366
|
+
if (pattern !== void 0) return {
|
|
100367
|
+
blocks: [{
|
|
100368
|
+
type: "search",
|
|
100369
|
+
query: pattern,
|
|
100370
|
+
scope: stringField(detail, "path")
|
|
100371
|
+
}],
|
|
100372
|
+
description: ""
|
|
100373
|
+
};
|
|
100175
100374
|
if (filePath !== void 0) return {
|
|
100176
100375
|
blocks: [{
|
|
100177
100376
|
type: "file_op",
|
|
@@ -100194,13 +100393,13 @@ function adaptPanelResponse(response) {
|
|
|
100194
100393
|
if (response.response === "approved_for_session") return {
|
|
100195
100394
|
response: "approved",
|
|
100196
100395
|
scope: "session",
|
|
100197
|
-
|
|
100198
|
-
|
|
100396
|
+
feedback: response.feedback,
|
|
100397
|
+
selected_label: response.selected_label
|
|
100199
100398
|
};
|
|
100200
100399
|
return {
|
|
100201
100400
|
response: response.response === "approved" ? "approved" : response.response === "rejected" ? "rejected" : "cancelled",
|
|
100202
|
-
|
|
100203
|
-
|
|
100401
|
+
feedback: response.feedback,
|
|
100402
|
+
selected_label: response.selected_label
|
|
100204
100403
|
};
|
|
100205
100404
|
}
|
|
100206
100405
|
function describeApproval(display, action) {
|
|
@@ -100268,9 +100467,9 @@ function adaptDisplay(display) {
|
|
|
100268
100467
|
type: "shell",
|
|
100269
100468
|
language: display.language ?? "bash",
|
|
100270
100469
|
command,
|
|
100271
|
-
|
|
100272
|
-
|
|
100273
|
-
|
|
100470
|
+
cwd: display.cwd,
|
|
100471
|
+
description: display.description,
|
|
100472
|
+
danger
|
|
100274
100473
|
}];
|
|
100275
100474
|
}
|
|
100276
100475
|
case "diff": return [{
|
|
@@ -100283,29 +100482,29 @@ function adaptDisplay(display) {
|
|
|
100283
100482
|
type: "file_op",
|
|
100284
100483
|
operation: display.operation,
|
|
100285
100484
|
path: display.path ?? "",
|
|
100286
|
-
|
|
100485
|
+
detail: display.detail
|
|
100287
100486
|
}];
|
|
100288
100487
|
case "url_fetch": return [{
|
|
100289
100488
|
type: "url_fetch",
|
|
100290
100489
|
url: display.url ?? "",
|
|
100291
|
-
|
|
100490
|
+
method: display.method
|
|
100292
100491
|
}];
|
|
100293
100492
|
case "search": return [{
|
|
100294
100493
|
type: "search",
|
|
100295
100494
|
query: display.query ?? "",
|
|
100296
|
-
|
|
100495
|
+
scope: display.scope
|
|
100297
100496
|
}];
|
|
100298
100497
|
case "agent_call": return [{
|
|
100299
100498
|
type: "invocation",
|
|
100300
100499
|
kind: "agent",
|
|
100301
100500
|
name: display.agent_name ?? "",
|
|
100302
|
-
|
|
100501
|
+
description: display.prompt
|
|
100303
100502
|
}];
|
|
100304
100503
|
case "skill_call": return [{
|
|
100305
100504
|
type: "invocation",
|
|
100306
100505
|
kind: "skill",
|
|
100307
100506
|
name: display.skill_name ?? "",
|
|
100308
|
-
|
|
100507
|
+
description: display.args
|
|
100309
100508
|
}];
|
|
100310
100509
|
case "task_stop": return [{
|
|
100311
100510
|
type: "brief",
|
|
@@ -100363,7 +100562,7 @@ function truncateOneLine(text, max) {
|
|
|
100363
100562
|
const DIFF_SUMMARY_MAX_LINES = 10;
|
|
100364
100563
|
function renderDisplayBlock(block, expanded) {
|
|
100365
100564
|
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);
|
|
100565
|
+
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
100566
|
case "shell": {
|
|
100368
100567
|
const lines = [];
|
|
100369
100568
|
if (block.cwd !== void 0 && block.cwd.length > 0) lines.push(chalk.dim(`cwd: ${block.cwd}`));
|
|
@@ -100443,7 +100642,7 @@ var ApprovalPanelComponent = class extends Container {
|
|
|
100443
100642
|
this.onResponse({
|
|
100444
100643
|
response: option.response,
|
|
100445
100644
|
feedback: feedback || void 0,
|
|
100446
|
-
|
|
100645
|
+
selected_label: option.selected_label
|
|
100447
100646
|
});
|
|
100448
100647
|
}
|
|
100449
100648
|
selectAndSubmit(index) {
|
|
@@ -101170,10 +101369,7 @@ function registerReverseRPCHandlers(state, client, callbacks) {
|
|
|
101170
101369
|
showPanel: (payload) => showQuestionDialog(state, payload),
|
|
101171
101370
|
hidePanel: () => hideQuestionDialog(state)
|
|
101172
101371
|
});
|
|
101173
|
-
|
|
101174
|
-
disposers.push(client.onRequest("approval.request", createApprovalRequestHandler(state)));
|
|
101175
|
-
disposers.push(client.onRequest("question.ask", createQuestionAskHandler(state)));
|
|
101176
|
-
return disposers;
|
|
101372
|
+
return [client.onRequest("approval.request", createApprovalRequestHandler(state)), client.onRequest("question.ask", createQuestionAskHandler(state))];
|
|
101177
101373
|
}
|
|
101178
101374
|
//#endregion
|
|
101179
101375
|
//#region src/utils/clipboard/clipboard-native.ts
|
|
@@ -101515,44 +101711,6 @@ function readUInt32BE(b, off) {
|
|
|
101515
101711
|
return b[off] * 16777216 + (b[off + 1] << 16) + (b[off + 2] << 8) + b[off + 3] >>> 0;
|
|
101516
101712
|
}
|
|
101517
101713
|
//#endregion
|
|
101518
|
-
//#region src/tui/commands/skill-commands.ts
|
|
101519
|
-
async function fetchSkills(client, sessionId) {
|
|
101520
|
-
const skills = (await client.listSkills(sessionId))?.skills ?? [];
|
|
101521
|
-
const out = [];
|
|
101522
|
-
for (const s of skills) {
|
|
101523
|
-
if (typeof s?.name !== "string" || s.name.length === 0) continue;
|
|
101524
|
-
if (typeof s.content !== "string") continue;
|
|
101525
|
-
out.push({
|
|
101526
|
-
name: s.name,
|
|
101527
|
-
content: s.content,
|
|
101528
|
-
...typeof s.description === "string" ? { description: s.description } : {}
|
|
101529
|
-
});
|
|
101530
|
-
}
|
|
101531
|
-
return out;
|
|
101532
|
-
}
|
|
101533
|
-
function buildSkillCommand(skill) {
|
|
101534
|
-
return {
|
|
101535
|
-
name: `${SKILL_COMMAND_PREFIX}${skill.name}`,
|
|
101536
|
-
aliases: [],
|
|
101537
|
-
description: skill.description ?? "",
|
|
101538
|
-
mode: "both",
|
|
101539
|
-
async execute(args, ctx) {
|
|
101540
|
-
const trimmed = args.trim();
|
|
101541
|
-
const prompt = trimmed.length > 0 ? `${skill.content}\n\nUser request:\n${trimmed}` : skill.content;
|
|
101542
|
-
try {
|
|
101543
|
-
await ctx.client.prompt(ctx.appState.sessionId, { input: prompt });
|
|
101544
|
-
} catch (err) {
|
|
101545
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
101546
|
-
return {
|
|
101547
|
-
type: "ok",
|
|
101548
|
-
message: `Skill "${skill.name}" failed: ${msg}`
|
|
101549
|
-
};
|
|
101550
|
-
}
|
|
101551
|
-
return { type: "ok" };
|
|
101552
|
-
}
|
|
101553
|
-
};
|
|
101554
|
-
}
|
|
101555
|
-
//#endregion
|
|
101556
101714
|
//#region src/tui/components/editor/file-mention-provider.ts
|
|
101557
101715
|
/**
|
|
101558
101716
|
* `@file` autocomplete provider for the input box.
|
|
@@ -101662,7 +101820,7 @@ function rankForEmptyQuery(files, snapshot) {
|
|
|
101662
101820
|
const result = [];
|
|
101663
101821
|
const cap = MAX_SUGGESTIONS_WHEN_EMPTY;
|
|
101664
101822
|
const inFiles = new Set(files);
|
|
101665
|
-
const byRecency = [...snapshot.recencyOrder.entries()].filter(([path]) => inFiles.has(path)).
|
|
101823
|
+
const byRecency = [...snapshot.recencyOrder.entries()].filter(([path]) => inFiles.has(path)).toSorted((a, b) => a[1] - b[1]);
|
|
101666
101824
|
for (const [path] of byRecency) {
|
|
101667
101825
|
if (result.length >= cap) break;
|
|
101668
101826
|
if (picked.has(path)) continue;
|
|
@@ -101670,7 +101828,7 @@ function rankForEmptyQuery(files, snapshot) {
|
|
|
101670
101828
|
result.push(path);
|
|
101671
101829
|
}
|
|
101672
101830
|
if (result.length < cap) {
|
|
101673
|
-
const byMtime = files.filter((p) => !picked.has(p) && snapshot.mtimeByPath.has(p)).
|
|
101831
|
+
const byMtime = files.filter((p) => !picked.has(p) && snapshot.mtimeByPath.has(p)).toSorted((a, b) => (snapshot.mtimeByPath.get(b) ?? 0) - (snapshot.mtimeByPath.get(a) ?? 0));
|
|
101674
101832
|
for (const path of byMtime) {
|
|
101675
101833
|
if (result.length >= cap) break;
|
|
101676
101834
|
picked.add(path);
|
|
@@ -101678,7 +101836,7 @@ function rankForEmptyQuery(files, snapshot) {
|
|
|
101678
101836
|
}
|
|
101679
101837
|
}
|
|
101680
101838
|
if (result.length < cap) {
|
|
101681
|
-
const rest = files.filter((p) => !picked.has(p)).
|
|
101839
|
+
const rest = files.filter((p) => !picked.has(p)).toSorted((a, b) => basename(a).localeCompare(basename(b)) || a.localeCompare(b));
|
|
101682
101840
|
for (const path of rest) {
|
|
101683
101841
|
if (result.length >= cap) break;
|
|
101684
101842
|
result.push(path);
|
|
@@ -102183,7 +102341,7 @@ var KimiTUI = class {
|
|
|
102183
102341
|
kind: "status",
|
|
102184
102342
|
renderMode: "plain",
|
|
102185
102343
|
content: message,
|
|
102186
|
-
|
|
102344
|
+
color
|
|
102187
102345
|
});
|
|
102188
102346
|
},
|
|
102189
102347
|
showNotice: (title, detail) => {
|
|
@@ -102199,6 +102357,7 @@ var KimiTUI = class {
|
|
|
102199
102357
|
showUsage(this.state);
|
|
102200
102358
|
},
|
|
102201
102359
|
sendAsMessage: (text) => sendMessage(this.state, (e) => this.addEntry(e), text),
|
|
102360
|
+
activateSkill: (name, args, fullPrompt) => sendSkillActivation(this.state, (e) => this.addEntry(e), name, args, fullPrompt),
|
|
102202
102361
|
performReload: (action) => performReload(this.state, action, this.buildInputHooks())
|
|
102203
102362
|
};
|
|
102204
102363
|
}
|
|
@@ -102246,9 +102405,9 @@ async function runShell(opts, version) {
|
|
|
102246
102405
|
isReplaying: false,
|
|
102247
102406
|
streamingPhase: "idle",
|
|
102248
102407
|
streamingStartTime: 0,
|
|
102249
|
-
theme:
|
|
102408
|
+
theme: "dark",
|
|
102250
102409
|
version,
|
|
102251
|
-
editorCommand:
|
|
102410
|
+
editorCommand: null,
|
|
102252
102411
|
availableModels: ctx.availableModels,
|
|
102253
102412
|
sessionTitle: null
|
|
102254
102413
|
};
|
|
@@ -102382,7 +102541,7 @@ async function promptForInstallConfirmation(options) {
|
|
|
102382
102541
|
const output = options.output ?? process.stdout;
|
|
102383
102542
|
const choices = createInstallPromptChoices(options.target);
|
|
102384
102543
|
let selectedIndex = getDefaultInstallPromptSelection(choices);
|
|
102385
|
-
return
|
|
102544
|
+
return new Promise((resolve) => {
|
|
102386
102545
|
let lineCount = 0;
|
|
102387
102546
|
const hadRawMode = "isRaw" in input ? input.isRaw === true : false;
|
|
102388
102547
|
const canSetRawMode = typeof input.setRawMode === "function";
|