openfox 2.0.17 → 2.0.20
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/agent-defaults/builder.agent.md +1 -2
- package/dist/agent-defaults/code-reviewer.agent.md +1 -1
- package/dist/agent-defaults/planner.agent.md +4 -1
- package/dist/agent-defaults/verifier.agent.md +1 -1
- package/dist/{chat-handler-DTMB43CD.js → chat-handler-KNDSH5WR.js} +7 -7
- package/dist/{chunk-BC7R4HLY.js → chunk-3QQ4QKAU.js} +74 -573
- package/dist/{chunk-LX66KJPL.js → chunk-6PLAWCHQ.js} +31 -56
- package/dist/{chunk-FWJ6YXGA.js → chunk-ASM2Z7JU.js} +3 -3
- package/dist/{chunk-L7TDUIQY.js → chunk-DX37WNM7.js} +28 -3
- package/dist/{chunk-J7KOV4ST.js → chunk-GI24G4OW.js} +3 -3
- package/dist/{chunk-5ANV7YUX.js → chunk-T67KB6ZS.js} +8 -8
- package/dist/{chunk-KYR4NVNX.js → chunk-TVQTTZYW.js} +93 -55
- package/dist/{chunk-MS3PEYZK.js → chunk-VDC2QL2O.js} +5 -5
- package/dist/{chunk-SYG2ENUQ.js → chunk-YBWY4DKY.js} +2 -2
- package/dist/{chunk-YGNOTMV7.js → chunk-YYXOZJYE.js} +2 -2
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/{compactor-R7GRFBOU.js → compactor-EOQYEOFS.js} +5 -5
- package/dist/{events-4K52FKPR.js → events-JKPHAR5W.js} +3 -3
- package/dist/{folding-QIBNKYA6.js → folding-PI67HWBR.js} +2 -2
- package/dist/{orchestrator-FNAU26B6.js → orchestrator-ZVPFU2ZF.js} +6 -6
- package/dist/package.json +1 -1
- package/dist/{processor-3YZVK4JT.js → processor-DKAYI3PV.js} +7 -7
- package/dist/{serve-CRZ7NHSP.js → serve-24IV7E3C.js} +9 -9
- package/dist/server/index.js +8 -8
- package/dist/{server-JKNV2NCJ.js → server-CN7ML6XN.js} +8 -8
- package/dist/{tools-YWC3AJ66.js → tools-ZUOBYTVD.js} +5 -5
- package/dist/web/assets/index-00migM5L.js +301 -0
- package/dist/web/index.html +1 -1
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/dist/web/assets/index-e6TyhL8M.js +0 -301
|
@@ -210,7 +210,7 @@ function deepCloneMessage(msg) {
|
|
|
210
210
|
return cloned;
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
// src/server/events/
|
|
213
|
+
// src/server/events/fold-messages.ts
|
|
214
214
|
import stripAnsi from "strip-ansi";
|
|
215
215
|
function cloneMessage(message) {
|
|
216
216
|
return {
|
|
@@ -282,13 +282,9 @@ function appendSnapshotMessageContext(result, message) {
|
|
|
282
282
|
contextMsg.attachments = message.attachments;
|
|
283
283
|
}
|
|
284
284
|
result.push(contextMsg);
|
|
285
|
-
if (!message.toolCalls)
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
285
|
+
if (!message.toolCalls) return;
|
|
288
286
|
for (const toolCall of message.toolCalls) {
|
|
289
|
-
if (!toolCall.result)
|
|
290
|
-
continue;
|
|
291
|
-
}
|
|
287
|
+
if (!toolCall.result) continue;
|
|
292
288
|
result.push({
|
|
293
289
|
role: "tool",
|
|
294
290
|
content: stripAnsi(
|
|
@@ -303,9 +299,6 @@ Error: ${toolCall.result.error}` : `Error: ${toolCall.result.error}`
|
|
|
303
299
|
function applyStoredMessageEvents(initialMessages, events) {
|
|
304
300
|
return applyEvents(initialMessages, events, { timestampAsNumber: false });
|
|
305
301
|
}
|
|
306
|
-
function getTimestamp(event) {
|
|
307
|
-
return event.timestamp ?? Date.now();
|
|
308
|
-
}
|
|
309
302
|
function applyTurnEventsToSnapshotMessages(initialMessages, events) {
|
|
310
303
|
const messages = applyEvents(initialMessages, events, {
|
|
311
304
|
timestampAsNumber: true
|
|
@@ -435,9 +428,7 @@ function buildContextMessagesFromEventHistory(events, windowId, options) {
|
|
|
435
428
|
}
|
|
436
429
|
const snapshot = snapshotEvent.data;
|
|
437
430
|
const snapshotMessages = snapshot.messages.reduce((result, message) => {
|
|
438
|
-
if (!shouldIncludeContextMessage(message, windowId, options))
|
|
439
|
-
return result;
|
|
440
|
-
}
|
|
431
|
+
if (!shouldIncludeContextMessage(message, windowId, options)) return result;
|
|
441
432
|
appendSnapshotMessageContext(result, message);
|
|
442
433
|
return result;
|
|
443
434
|
}, []);
|
|
@@ -450,6 +441,21 @@ function foldTurnEventsToSnapshotMessages(events) {
|
|
|
450
441
|
function foldTurnEventsToSnapshotMessagesFromInitial(events, initialMessages) {
|
|
451
442
|
return applyTurnEventsToSnapshotMessages(initialMessages, events);
|
|
452
443
|
}
|
|
444
|
+
function getMessagesForWindow(messages, windowId) {
|
|
445
|
+
return messages.filter((m) => m.contextWindowId === windowId);
|
|
446
|
+
}
|
|
447
|
+
function buildContextMessagesFromMessages(messages, windowId) {
|
|
448
|
+
return getMessagesForWindow(messages, windowId).reduce((result, message) => {
|
|
449
|
+
if (!shouldIncludeContextMessage(message, windowId)) return result;
|
|
450
|
+
appendSnapshotMessageContext(result, message);
|
|
451
|
+
return result;
|
|
452
|
+
}, []);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// src/server/events/fold-state.ts
|
|
456
|
+
function getTimestamp(event) {
|
|
457
|
+
return event.timestamp ?? Date.now();
|
|
458
|
+
}
|
|
453
459
|
function foldCriteria(events) {
|
|
454
460
|
let criteria = [];
|
|
455
461
|
for (const event of events) {
|
|
@@ -531,10 +537,7 @@ function foldContextState(events, initialWindowId) {
|
|
|
531
537
|
case "file.read": {
|
|
532
538
|
const data = event.data;
|
|
533
539
|
if (data.contextWindowId === currentContextWindowId) {
|
|
534
|
-
readFilesMap.set(data.path, {
|
|
535
|
-
path: data.path,
|
|
536
|
-
tokenCount: data.tokenCount
|
|
537
|
-
});
|
|
540
|
+
readFilesMap.set(data.path, { path: data.path, tokenCount: data.tokenCount });
|
|
538
541
|
}
|
|
539
542
|
break;
|
|
540
543
|
}
|
|
@@ -627,15 +630,10 @@ function foldSessionState(events, initialWindowId, maxTokens, initialMessages) {
|
|
|
627
630
|
const event = events[i];
|
|
628
631
|
if (event.type === "turn.snapshot") {
|
|
629
632
|
const snapshotData = event.data;
|
|
630
|
-
if (snapshotData.cachedSystemPrompt && !cachedSystemPrompt)
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
if (snapshotData.dynamicContextHash && !dynamicContextHash) {
|
|
634
|
-
dynamicContextHash = snapshotData.dynamicContextHash;
|
|
635
|
-
}
|
|
636
|
-
if (snapshotData.metadataEntries && Object.keys(metadataEntries).length === 0) {
|
|
633
|
+
if (snapshotData.cachedSystemPrompt && !cachedSystemPrompt) cachedSystemPrompt = snapshotData.cachedSystemPrompt;
|
|
634
|
+
if (snapshotData.dynamicContextHash && !dynamicContextHash) dynamicContextHash = snapshotData.dynamicContextHash;
|
|
635
|
+
if (snapshotData.metadataEntries && Object.keys(metadataEntries).length === 0)
|
|
637
636
|
metadataEntries = snapshotData.metadataEntries;
|
|
638
|
-
}
|
|
639
637
|
}
|
|
640
638
|
}
|
|
641
639
|
let sessionInit;
|
|
@@ -678,18 +676,12 @@ function foldSessionState(events, initialWindowId, maxTokens, initialMessages) {
|
|
|
678
676
|
const existing = visionFallbacks.find(
|
|
679
677
|
(v) => v.messageId === data.messageId && v.attachmentId === data.attachmentId
|
|
680
678
|
);
|
|
681
|
-
if (existing)
|
|
682
|
-
existing.description = data.description;
|
|
683
|
-
}
|
|
679
|
+
if (existing) existing.description = data.description;
|
|
684
680
|
break;
|
|
685
681
|
}
|
|
686
682
|
case "pattern.retry": {
|
|
687
683
|
const data = event.data;
|
|
688
|
-
formatRetries.push({
|
|
689
|
-
attempt: data.attempt,
|
|
690
|
-
maxAttempts: data.maxAttempts,
|
|
691
|
-
timestamp: getTimestamp(event)
|
|
692
|
-
});
|
|
684
|
+
formatRetries.push({ attempt: data.attempt, maxAttempts: data.maxAttempts, timestamp: getTimestamp(event) });
|
|
693
685
|
break;
|
|
694
686
|
}
|
|
695
687
|
case "chat.ask_user": {
|
|
@@ -713,10 +705,7 @@ function foldSessionState(events, initialWindowId, maxTokens, initialMessages) {
|
|
|
713
705
|
}
|
|
714
706
|
case "context.compacted": {
|
|
715
707
|
const data = event.data;
|
|
716
|
-
contextWindows.push({
|
|
717
|
-
...data,
|
|
718
|
-
timestamp: getTimestamp(event)
|
|
719
|
-
});
|
|
708
|
+
contextWindows.push({ ...data, timestamp: getTimestamp(event) });
|
|
720
709
|
break;
|
|
721
710
|
}
|
|
722
711
|
}
|
|
@@ -782,9 +771,7 @@ function buildSnapshotFromSessionState(input) {
|
|
|
782
771
|
break;
|
|
783
772
|
}
|
|
784
773
|
}
|
|
785
|
-
if (!initialWindowId)
|
|
786
|
-
initialWindowId = "legacy-window-1";
|
|
787
|
-
}
|
|
774
|
+
if (!initialWindowId) initialWindowId = "legacy-window-1";
|
|
788
775
|
const foldedState = foldSessionState(events, initialWindowId, maxTokens);
|
|
789
776
|
const latestSnapshotIndex = events.map((event) => event.type).lastIndexOf("turn.snapshot");
|
|
790
777
|
const latestSnapshotEvent = latestSnapshotIndex >= 0 ? events[latestSnapshotIndex] : void 0;
|
|
@@ -817,18 +804,6 @@ function buildSnapshotFromSessionState(input) {
|
|
|
817
804
|
...input.dynamicContextHash !== void 0 ? { dynamicContextHash: input.dynamicContextHash } : foldedState.dynamicContextHash !== void 0 ? { dynamicContextHash: foldedState.dynamicContextHash } : {}
|
|
818
805
|
};
|
|
819
806
|
}
|
|
820
|
-
function getMessagesForWindow(messages, windowId) {
|
|
821
|
-
return messages.filter((m) => m.contextWindowId === windowId);
|
|
822
|
-
}
|
|
823
|
-
function buildContextMessagesFromMessages(messages, windowId) {
|
|
824
|
-
return getMessagesForWindow(messages, windowId).reduce((result, message) => {
|
|
825
|
-
if (!shouldIncludeContextMessage(message, windowId)) {
|
|
826
|
-
return result;
|
|
827
|
-
}
|
|
828
|
-
appendSnapshotMessageContext(result, message);
|
|
829
|
-
return result;
|
|
830
|
-
}, []);
|
|
831
|
-
}
|
|
832
807
|
|
|
833
808
|
export {
|
|
834
809
|
spreadOptionalMessageFields,
|
|
@@ -842,6 +817,8 @@ export {
|
|
|
842
817
|
buildContextMessagesFromEventHistory,
|
|
843
818
|
foldTurnEventsToSnapshotMessages,
|
|
844
819
|
foldTurnEventsToSnapshotMessagesFromInitial,
|
|
820
|
+
getMessagesForWindow,
|
|
821
|
+
buildContextMessagesFromMessages,
|
|
845
822
|
foldCriteria,
|
|
846
823
|
foldTodos,
|
|
847
824
|
foldMetadata,
|
|
@@ -852,8 +829,6 @@ export {
|
|
|
852
829
|
foldPendingConfirmations,
|
|
853
830
|
foldSessionState,
|
|
854
831
|
buildSnapshot,
|
|
855
|
-
buildSnapshotFromSessionState
|
|
856
|
-
getMessagesForWindow,
|
|
857
|
-
buildContextMessagesFromMessages
|
|
832
|
+
buildSnapshotFromSessionState
|
|
858
833
|
};
|
|
859
|
-
//# sourceMappingURL=chunk-
|
|
834
|
+
//# sourceMappingURL=chunk-6PLAWCHQ.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
COMPACTION_PROMPT,
|
|
3
3
|
createMessageStartEvent
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DX37WNM7.js";
|
|
5
5
|
import {
|
|
6
6
|
getCurrentWindowMessageOptions
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YBWY4DKY.js";
|
|
8
8
|
|
|
9
9
|
// src/server/context/compactor.ts
|
|
10
10
|
function appendCompactionPrompt(sessionId, append) {
|
|
@@ -31,4 +31,4 @@ export {
|
|
|
31
31
|
shouldCompact,
|
|
32
32
|
getCompactionTarget
|
|
33
33
|
};
|
|
34
|
-
//# sourceMappingURL=chunk-
|
|
34
|
+
//# sourceMappingURL=chunk-ASM2Z7JU.js.map
|
|
@@ -8,6 +8,24 @@ import {
|
|
|
8
8
|
logger
|
|
9
9
|
} from "./chunk-K44MW7JJ.js";
|
|
10
10
|
|
|
11
|
+
// src/server/tools/tool-policy.ts
|
|
12
|
+
var ALWAYS_ALLOWED = /* @__PURE__ */ new Set(["step_done"]);
|
|
13
|
+
var ALWAYS_ALLOWED_FOR_SUBAGENTS = /* @__PURE__ */ new Set(["return_value"]);
|
|
14
|
+
var TOP_LEVEL_ONLY_TOOLS = /* @__PURE__ */ new Set(["call_sub_agent"]);
|
|
15
|
+
function computeEffectiveTools(allowedTools, type) {
|
|
16
|
+
const tools = /* @__PURE__ */ new Set();
|
|
17
|
+
for (const entry of allowedTools) {
|
|
18
|
+
const baseName = entry.includes(":") ? entry.split(":")[0] : entry;
|
|
19
|
+
if (baseName === "return_value" && type === "agent") continue;
|
|
20
|
+
tools.add(baseName);
|
|
21
|
+
}
|
|
22
|
+
const alwaysAllowed = type === "sub-agent" ? ALWAYS_ALLOWED_FOR_SUBAGENTS : ALWAYS_ALLOWED;
|
|
23
|
+
for (const tool of alwaysAllowed) {
|
|
24
|
+
tools.add(tool);
|
|
25
|
+
}
|
|
26
|
+
return tools;
|
|
27
|
+
}
|
|
28
|
+
|
|
11
29
|
// src/server/chat/prompts.ts
|
|
12
30
|
function buildBasePrompt(workdir, customInstructions, skills, modelName) {
|
|
13
31
|
const instructionsSection = customInstructions ? `
|
|
@@ -199,8 +217,11 @@ function buildToolPermissionsSection(allowedTools, isSubAgent) {
|
|
|
199
217
|
toolPermissions.set(toolName, [...existing, ...actions]);
|
|
200
218
|
}
|
|
201
219
|
}
|
|
202
|
-
|
|
203
|
-
|
|
220
|
+
const effectiveTools = computeEffectiveTools(allowedTools, isSubAgent ? "sub-agent" : "agent");
|
|
221
|
+
for (const tool of effectiveTools) {
|
|
222
|
+
if (!baseTools.includes(tool) && !toolPermissions.has(tool)) {
|
|
223
|
+
baseTools.push(tool);
|
|
224
|
+
}
|
|
204
225
|
}
|
|
205
226
|
const parts = [];
|
|
206
227
|
for (const [toolName, actions] of toolPermissions) {
|
|
@@ -658,6 +679,10 @@ async function consumeStreamGenerator(gen, onEvent) {
|
|
|
658
679
|
}
|
|
659
680
|
|
|
660
681
|
export {
|
|
682
|
+
ALWAYS_ALLOWED,
|
|
683
|
+
ALWAYS_ALLOWED_FOR_SUBAGENTS,
|
|
684
|
+
TOP_LEVEL_ONLY_TOOLS,
|
|
685
|
+
computeEffectiveTools,
|
|
661
686
|
buildBasePrompt,
|
|
662
687
|
buildTopLevelSystemPrompt,
|
|
663
688
|
buildSubAgentSystemPrompt,
|
|
@@ -674,4 +699,4 @@ export {
|
|
|
674
699
|
createChatDoneEvent,
|
|
675
700
|
consumeStreamGenerator
|
|
676
701
|
};
|
|
677
|
-
//# sourceMappingURL=chunk-
|
|
702
|
+
//# sourceMappingURL=chunk-DX37WNM7.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getEventStore,
|
|
3
3
|
updateSessionMetadata
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YBWY4DKY.js";
|
|
5
5
|
import {
|
|
6
6
|
buildMessagesFromStoredEvents,
|
|
7
7
|
foldPendingConfirmations
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-6PLAWCHQ.js";
|
|
9
9
|
import {
|
|
10
10
|
createContextStateMessage,
|
|
11
11
|
createSessionStateMessage
|
|
@@ -154,4 +154,4 @@ export {
|
|
|
154
154
|
needsNameGenerationCheck,
|
|
155
155
|
applyGeneratedSessionName
|
|
156
156
|
};
|
|
157
|
-
//# sourceMappingURL=chunk-
|
|
157
|
+
//# sourceMappingURL=chunk-GI24G4OW.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
appendCompactionPrompt
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ASM2Z7JU.js";
|
|
4
4
|
import {
|
|
5
5
|
injectWorkflowKickoffIfNeeded,
|
|
6
6
|
runAgentTurn,
|
|
7
7
|
runChatTurn
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VDC2QL2O.js";
|
|
9
9
|
import {
|
|
10
10
|
applyDynamicContext,
|
|
11
11
|
checkAborted,
|
|
@@ -22,11 +22,11 @@ import {
|
|
|
22
22
|
loadAllAgentsDefault,
|
|
23
23
|
saveItemToDir,
|
|
24
24
|
spawnShellProcess
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-TVQTTZYW.js";
|
|
26
26
|
import {
|
|
27
27
|
TurnMetrics,
|
|
28
28
|
createMessageStartEvent
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-DX37WNM7.js";
|
|
30
30
|
import {
|
|
31
31
|
getPlatformShell,
|
|
32
32
|
onProcessEvent
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
getCurrentContextWindowId,
|
|
36
36
|
getEventStore,
|
|
37
37
|
getRuntimeConfig
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-YBWY4DKY.js";
|
|
39
39
|
import {
|
|
40
40
|
createChatErrorMessage,
|
|
41
41
|
createChatMessageMessage,
|
|
@@ -1775,7 +1775,7 @@ async function handleClientMessage(ws, client, message, _getLLMClient, _getActiv
|
|
|
1775
1775
|
const runtimeConfig = getRuntimeConfig();
|
|
1776
1776
|
const configDir = getGlobalConfigDir(runtimeConfig.mode ?? "production");
|
|
1777
1777
|
const skills = await getEnabledSkillMetadata(configDir, runtimeConfig.workdir);
|
|
1778
|
-
const { createToolRegistry } = await import("./tools-
|
|
1778
|
+
const { createToolRegistry } = await import("./tools-ZUOBYTVD.js");
|
|
1779
1779
|
const allTools = createToolRegistry().definitions;
|
|
1780
1780
|
const toolFingerprint = getToolFingerprint(allTools);
|
|
1781
1781
|
const currentHash = computeDynamicContextHash(instructionContent, skills, toolFingerprint);
|
|
@@ -1848,7 +1848,7 @@ async function handleClientMessage(ws, client, message, _getLLMClient, _getActiv
|
|
|
1848
1848
|
const runtimeConfig = getRuntimeConfig();
|
|
1849
1849
|
const configDir = getGlobalConfigDir(runtimeConfig.mode ?? "production");
|
|
1850
1850
|
const skills = await getEnabledSkillMetadata(configDir, runtimeConfig.workdir);
|
|
1851
|
-
const { createToolRegistry } = await import("./tools-
|
|
1851
|
+
const { createToolRegistry } = await import("./tools-ZUOBYTVD.js");
|
|
1852
1852
|
const allTools = createToolRegistry().definitions;
|
|
1853
1853
|
const toolFingerprint = getToolFingerprint(allTools);
|
|
1854
1854
|
const currentHash = computeDynamicContextHash(instructionContent, skills, toolFingerprint);
|
|
@@ -2069,4 +2069,4 @@ export {
|
|
|
2069
2069
|
signalMcpReady,
|
|
2070
2070
|
createWebSocketServer
|
|
2071
2071
|
};
|
|
2072
|
-
//# sourceMappingURL=chunk-
|
|
2072
|
+
//# sourceMappingURL=chunk-T67KB6ZS.js.map
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
buildBasePrompt,
|
|
8
8
|
buildSubAgentSystemPrompt,
|
|
9
9
|
buildTopLevelSystemPrompt,
|
|
10
|
+
computeEffectiveTools,
|
|
10
11
|
consumeStreamGenerator,
|
|
11
12
|
createChatDoneEvent,
|
|
12
13
|
createMessageDoneEvent,
|
|
@@ -14,7 +15,7 @@ import {
|
|
|
14
15
|
createToolCallEvent,
|
|
15
16
|
createToolResultEvent,
|
|
16
17
|
streamLLMPure
|
|
17
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-DX37WNM7.js";
|
|
18
19
|
import {
|
|
19
20
|
startInspectProxy
|
|
20
21
|
} from "./chunk-DL6ZILAF.js";
|
|
@@ -39,7 +40,7 @@ import {
|
|
|
39
40
|
getCurrentWindowMessageOptions,
|
|
40
41
|
getEventStore,
|
|
41
42
|
getRuntimeConfig
|
|
42
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-YBWY4DKY.js";
|
|
43
44
|
import {
|
|
44
45
|
buildContextMessagesFromEventHistory,
|
|
45
46
|
foldContextState,
|
|
@@ -48,7 +49,7 @@ import {
|
|
|
48
49
|
handleToolCall,
|
|
49
50
|
handleToolResult,
|
|
50
51
|
stripOrphanedToolCalls
|
|
51
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-6PLAWCHQ.js";
|
|
52
53
|
import {
|
|
53
54
|
createChatDoneMessage,
|
|
54
55
|
createChatMessageMessage,
|
|
@@ -479,7 +480,7 @@ function validateAction(action, allowed, startTime) {
|
|
|
479
480
|
return void 0;
|
|
480
481
|
}
|
|
481
482
|
function checkActionPermission(action, permittedActions, startTime) {
|
|
482
|
-
if (action && permittedActions && !permittedActions.includes(action)) {
|
|
483
|
+
if (action && permittedActions && permittedActions.length > 0 && !permittedActions.includes(action)) {
|
|
483
484
|
return {
|
|
484
485
|
success: false,
|
|
485
486
|
error: `Action '${action}' not allowed. Available: ${permittedActions.join(", ")}`,
|
|
@@ -962,7 +963,8 @@ var readFileTool = createTool(
|
|
|
962
963
|
metadata: {
|
|
963
964
|
encoding,
|
|
964
965
|
confidence: Math.round(confidence * 100) / 100,
|
|
965
|
-
lineCount: totalLines
|
|
966
|
+
lineCount: totalLines,
|
|
967
|
+
path: fullPath
|
|
966
968
|
}
|
|
967
969
|
});
|
|
968
970
|
}
|
|
@@ -1059,7 +1061,10 @@ var writeFileTool = createTool(
|
|
|
1059
1061
|
if (newHash) {
|
|
1060
1062
|
context.sessionManager.updateFileHash(context.sessionId, fullPath, newHash);
|
|
1061
1063
|
}
|
|
1062
|
-
return helpers.success(output, false,
|
|
1064
|
+
return helpers.success(output, false, {
|
|
1065
|
+
...diagnostics.length > 0 && { diagnostics },
|
|
1066
|
+
metadata: { path: fullPath }
|
|
1067
|
+
});
|
|
1063
1068
|
}
|
|
1064
1069
|
);
|
|
1065
1070
|
|
|
@@ -1318,7 +1323,8 @@ Make sure whitespace and indentation match exactly.`
|
|
|
1318
1323
|
}
|
|
1319
1324
|
return helpers.success(output, false, {
|
|
1320
1325
|
...diagnostics.length > 0 && { diagnostics },
|
|
1321
|
-
...editContextRegions.length > 0 && { editContext: { regions: editContextRegions } }
|
|
1326
|
+
...editContextRegions.length > 0 && { editContext: { regions: editContextRegions } },
|
|
1327
|
+
metadata: { path: fullPath }
|
|
1322
1328
|
});
|
|
1323
1329
|
});
|
|
1324
1330
|
}
|
|
@@ -1496,16 +1502,15 @@ function executeCommand(command, cwd, timeout, signal, onProgress) {
|
|
|
1496
1502
|
const proc = spawnShellProcess(command, cwd, signal, true);
|
|
1497
1503
|
let stdout = "";
|
|
1498
1504
|
let stderr = "";
|
|
1499
|
-
let
|
|
1505
|
+
let timedOut = false;
|
|
1500
1506
|
let aborted = false;
|
|
1501
1507
|
let exited = false;
|
|
1502
1508
|
const timer = setTimeout(() => {
|
|
1503
|
-
|
|
1509
|
+
timedOut = true;
|
|
1504
1510
|
void terminateProcessTree(proc, { exited: () => exited });
|
|
1505
|
-
reject(new Error(`Command timed out after ${timeout}ms`));
|
|
1506
1511
|
}, timeout);
|
|
1507
1512
|
const onAbort = () => {
|
|
1508
|
-
if (!
|
|
1513
|
+
if (!timedOut && !aborted) {
|
|
1509
1514
|
aborted = true;
|
|
1510
1515
|
void terminateProcessTree(proc, { exited: () => exited });
|
|
1511
1516
|
}
|
|
@@ -1525,7 +1530,16 @@ function executeCommand(command, cwd, timeout, signal, onProgress) {
|
|
|
1525
1530
|
exited = true;
|
|
1526
1531
|
clearTimeout(timer);
|
|
1527
1532
|
signal?.removeEventListener("abort", onAbort);
|
|
1528
|
-
if (
|
|
1533
|
+
if (timedOut) {
|
|
1534
|
+
let output = stdout.trim();
|
|
1535
|
+
if (output) output += "\n\n";
|
|
1536
|
+
output += `[Exit code: 124]
|
|
1537
|
+
[Process timed out after ${timeout}ms]`;
|
|
1538
|
+
resolve6({
|
|
1539
|
+
stdout: output,
|
|
1540
|
+
stderr: stderr.trim(),
|
|
1541
|
+
exitCode: 124
|
|
1542
|
+
});
|
|
1529
1543
|
return;
|
|
1530
1544
|
}
|
|
1531
1545
|
if (aborted) {
|
|
@@ -2536,7 +2550,7 @@ ${CONTINUE_PROMPT}` : CONTINUE_PROMPT;
|
|
|
2536
2550
|
sessionManager.setCurrentContextSize(sessionId, result.usage.promptTokens);
|
|
2537
2551
|
if (!compacting) {
|
|
2538
2552
|
const contextState = sessionManager.getContextState(sessionId);
|
|
2539
|
-
const { shouldCompact, appendCompactionPrompt } = await import("./compactor-
|
|
2553
|
+
const { shouldCompact, appendCompactionPrompt } = await import("./compactor-EOQYEOFS.js");
|
|
2540
2554
|
if (shouldCompact(contextState.currentTokens, contextState.maxTokens, runtimeConfig.context.compactionThreshold)) {
|
|
2541
2555
|
appendCompactionPrompt(sessionId, append);
|
|
2542
2556
|
compacting = true;
|
|
@@ -3341,7 +3355,7 @@ var callSubAgentTool = {
|
|
|
3341
3355
|
};
|
|
3342
3356
|
}
|
|
3343
3357
|
try {
|
|
3344
|
-
const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-
|
|
3358
|
+
const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-ZUOBYTVD.js");
|
|
3345
3359
|
const toolRegistry = getToolRegistryForAgent2(agentDef);
|
|
3346
3360
|
const turnMetrics = new TurnMetrics();
|
|
3347
3361
|
const result = await executeSubAgent({
|
|
@@ -4147,7 +4161,7 @@ async function computeContextHash(sessionManager, sessionId) {
|
|
|
4147
4161
|
const runtimeConfig = getRuntimeConfig();
|
|
4148
4162
|
const configDir = getGlobalConfigDir(runtimeConfig.mode ?? "production");
|
|
4149
4163
|
const skills = await getEnabledSkillMetadata(configDir, runtimeConfig.workdir);
|
|
4150
|
-
const { createToolRegistry: createToolRegistry2 } = await import("./tools-
|
|
4164
|
+
const { createToolRegistry: createToolRegistry2 } = await import("./tools-ZUOBYTVD.js");
|
|
4151
4165
|
const allTools = createToolRegistry2().definitions;
|
|
4152
4166
|
const toolFingerprint = getToolFingerprint(allTools);
|
|
4153
4167
|
const hash = computeDynamicContextHash(instructionContent, skills, toolFingerprint);
|
|
@@ -4260,7 +4274,7 @@ var mcpConfigTool = createTool(
|
|
|
4260
4274
|
await saveGlobalConfig(mcpConfigMode, { ...globalConfig, mcpServers: updated });
|
|
4261
4275
|
}
|
|
4262
4276
|
async function rebuildTools() {
|
|
4263
|
-
const { setMcpTools: setMcpTools2 } = await import("./tools-
|
|
4277
|
+
const { setMcpTools: setMcpTools2 } = await import("./tools-ZUOBYTVD.js");
|
|
4264
4278
|
const mcpTools = createMcpTools(mcpManagerForTools);
|
|
4265
4279
|
setMcpTools2(mcpTools);
|
|
4266
4280
|
}
|
|
@@ -4361,6 +4375,37 @@ var mcpConfigTool = createTool(
|
|
|
4361
4375
|
);
|
|
4362
4376
|
|
|
4363
4377
|
// src/server/tools/index.ts
|
|
4378
|
+
var _builtInTools;
|
|
4379
|
+
function getBuiltInTools() {
|
|
4380
|
+
if (!_builtInTools) {
|
|
4381
|
+
_builtInTools = [
|
|
4382
|
+
readFileTool,
|
|
4383
|
+
writeFileTool,
|
|
4384
|
+
editFileTool,
|
|
4385
|
+
runCommandTool,
|
|
4386
|
+
askUserTool,
|
|
4387
|
+
sessionMetadataTool,
|
|
4388
|
+
callSubAgentTool,
|
|
4389
|
+
loadSkillTool,
|
|
4390
|
+
returnValueTool,
|
|
4391
|
+
webFetchTool,
|
|
4392
|
+
devServerTool,
|
|
4393
|
+
stepDoneTool,
|
|
4394
|
+
backgroundProcessTool,
|
|
4395
|
+
mcpConfigTool
|
|
4396
|
+
];
|
|
4397
|
+
}
|
|
4398
|
+
return _builtInTools;
|
|
4399
|
+
}
|
|
4400
|
+
function getBuiltInToolNames() {
|
|
4401
|
+
if (BUILT_IN_TOOL_NAMES_CACHE.size === 0) {
|
|
4402
|
+
for (const t of getBuiltInTools()) {
|
|
4403
|
+
BUILT_IN_TOOL_NAMES_CACHE.add(t.name);
|
|
4404
|
+
}
|
|
4405
|
+
}
|
|
4406
|
+
return BUILT_IN_TOOL_NAMES_CACHE;
|
|
4407
|
+
}
|
|
4408
|
+
var BUILT_IN_TOOL_NAMES_CACHE = /* @__PURE__ */ new Set();
|
|
4364
4409
|
function parseToolPermissions(allowedTools) {
|
|
4365
4410
|
const result = {};
|
|
4366
4411
|
for (const entry of allowedTools) {
|
|
@@ -4396,9 +4441,8 @@ function validateToolAction(toolName, action, permissions) {
|
|
|
4396
4441
|
function extractSubAgentPrompt(args) {
|
|
4397
4442
|
return args["prompt"] || args["query"] || args["task"] || "";
|
|
4398
4443
|
}
|
|
4399
|
-
function createRegistryFromTools(tools, allowedTools, toolPermissions) {
|
|
4444
|
+
function createRegistryFromTools(tools, allowedTools, toolPermissions, agentId, isSubAgent) {
|
|
4400
4445
|
const toolMap = /* @__PURE__ */ new Map();
|
|
4401
|
-
const allowedToolsSet = new Set(allowedTools || []);
|
|
4402
4446
|
for (const tool of tools) {
|
|
4403
4447
|
toolMap.set(tool.name, tool);
|
|
4404
4448
|
}
|
|
@@ -4431,18 +4475,22 @@ function createRegistryFromTools(tools, allowedTools, toolPermissions) {
|
|
|
4431
4475
|
truncated: false
|
|
4432
4476
|
};
|
|
4433
4477
|
}
|
|
4434
|
-
const
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4478
|
+
const isMcpTool = !getBuiltInToolNames().has(name);
|
|
4479
|
+
const hasRestrictions = allowedTools !== void 0;
|
|
4480
|
+
if (!isMcpTool && hasRestrictions) {
|
|
4481
|
+
const effectiveTools = computeEffectiveTools(allowedTools, isSubAgent ? "sub-agent" : "agent");
|
|
4482
|
+
if (!effectiveTools.has(name)) {
|
|
4483
|
+
logger.debug("Permission denied: tool not in allowed list", {
|
|
4484
|
+
tool: name,
|
|
4485
|
+
allowedTools
|
|
4486
|
+
});
|
|
4487
|
+
return {
|
|
4488
|
+
success: false,
|
|
4489
|
+
error: createPermissionErrorMessage(name, allowedTools, agentId, isSubAgent),
|
|
4490
|
+
durationMs: 0,
|
|
4491
|
+
truncated: false
|
|
4492
|
+
};
|
|
4493
|
+
}
|
|
4446
4494
|
}
|
|
4447
4495
|
if (toolPermissions) {
|
|
4448
4496
|
const action = args["action"];
|
|
@@ -4503,30 +4551,20 @@ function setMcpTools(tools) {
|
|
|
4503
4551
|
mcpToolsOverride = tools;
|
|
4504
4552
|
}
|
|
4505
4553
|
function getAllToolsMap() {
|
|
4506
|
-
const
|
|
4507
|
-
readFileTool,
|
|
4508
|
-
writeFileTool,
|
|
4509
|
-
editFileTool,
|
|
4510
|
-
runCommandTool,
|
|
4511
|
-
askUserTool,
|
|
4512
|
-
sessionMetadataTool,
|
|
4513
|
-
callSubAgentTool,
|
|
4514
|
-
loadSkillTool,
|
|
4515
|
-
returnValueTool,
|
|
4516
|
-
webFetchTool,
|
|
4517
|
-
devServerTool,
|
|
4518
|
-
stepDoneTool,
|
|
4519
|
-
backgroundProcessTool,
|
|
4520
|
-
mcpConfigTool
|
|
4521
|
-
].map((t) => [t.name, t]);
|
|
4554
|
+
const builtInEntries = getBuiltInTools().map((t) => [t.name, t]);
|
|
4522
4555
|
const mcpEntries = mcpToolsOverride.map((t) => [t.name, t]);
|
|
4523
|
-
return new Map([...
|
|
4556
|
+
return new Map([...builtInEntries, ...mcpEntries]);
|
|
4524
4557
|
}
|
|
4525
|
-
function createPermissionErrorMessage(toolName, allowedTools) {
|
|
4526
|
-
|
|
4558
|
+
function createPermissionErrorMessage(toolName, allowedTools, agentId, isSubAgent) {
|
|
4559
|
+
const effectiveTools = computeEffectiveTools(allowedTools, isSubAgent ? "sub-agent" : "agent");
|
|
4560
|
+
const available = [...effectiveTools].sort();
|
|
4561
|
+
if (agentId) {
|
|
4562
|
+
return `Tool '${toolName}' is not available in '${agentId}' mode. Available: ${available.join(", ")}`;
|
|
4563
|
+
}
|
|
4564
|
+
if (available.length === 0) {
|
|
4527
4565
|
return `Tool '${toolName}' is not in your allowed tools list. No tools are allowed.`;
|
|
4528
4566
|
}
|
|
4529
|
-
return `Tool '${toolName}' is not in your allowed tools list. Available: ${
|
|
4567
|
+
return `Tool '${toolName}' is not in your allowed tools list. Available: ${available.join(", ")}`;
|
|
4530
4568
|
}
|
|
4531
4569
|
function addReturnValueToAllowedTools(allowedTools) {
|
|
4532
4570
|
if (!allowedTools.includes("return_value")) {
|
|
@@ -4552,7 +4590,7 @@ function getToolRegistryForSubAgent(toolNames) {
|
|
|
4552
4590
|
if (rv) tools.push(rv);
|
|
4553
4591
|
}
|
|
4554
4592
|
const allowedToolsWithReturnValue = addReturnValueToAllowedTools(toolNames);
|
|
4555
|
-
return createRegistryFromTools(tools, allowedToolsWithReturnValue, toolPermissions);
|
|
4593
|
+
return createRegistryFromTools(tools, allowedToolsWithReturnValue, toolPermissions, void 0, true);
|
|
4556
4594
|
}
|
|
4557
4595
|
function getToolRegistryForAgent(agentDef) {
|
|
4558
4596
|
if (agentDef.metadata.subagent) {
|
|
@@ -4560,15 +4598,15 @@ function getToolRegistryForAgent(agentDef) {
|
|
|
4560
4598
|
}
|
|
4561
4599
|
const allTools = getAllToolsMap();
|
|
4562
4600
|
const tools = [];
|
|
4563
|
-
const allowedTools = [];
|
|
4564
4601
|
for (const [name, tool] of allTools.entries()) {
|
|
4565
4602
|
if (name === "return_value") {
|
|
4566
4603
|
continue;
|
|
4567
4604
|
}
|
|
4568
4605
|
tools.push(tool);
|
|
4569
|
-
allowedTools.push(name);
|
|
4570
4606
|
}
|
|
4571
|
-
|
|
4607
|
+
const allowedTools = agentDef.metadata.allowedTools;
|
|
4608
|
+
const toolPermissions = parseToolPermissions(allowedTools);
|
|
4609
|
+
return createRegistryFromTools(tools, allowedTools, toolPermissions, agentDef.metadata.id, false);
|
|
4572
4610
|
}
|
|
4573
4611
|
function createToolRegistry() {
|
|
4574
4612
|
return createRegistryFromTools(Array.from(getAllToolsMap().values()));
|
|
@@ -4640,4 +4678,4 @@ export {
|
|
|
4640
4678
|
getToolRegistryForAgent,
|
|
4641
4679
|
createToolRegistry
|
|
4642
4680
|
};
|
|
4643
|
-
//# sourceMappingURL=chunk-
|
|
4681
|
+
//# sourceMappingURL=chunk-TVQTTZYW.js.map
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
loadAllAgentsDefault,
|
|
15
15
|
processEventsForConversation,
|
|
16
16
|
runTopLevelAgentLoop
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-TVQTTZYW.js";
|
|
18
18
|
import {
|
|
19
19
|
TurnMetrics,
|
|
20
20
|
WORKFLOW_KICKOFF_PROMPT,
|
|
@@ -22,16 +22,16 @@ import {
|
|
|
22
22
|
buildAgentSmallReminder,
|
|
23
23
|
createChatDoneEvent,
|
|
24
24
|
createMessageStartEvent
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-DX37WNM7.js";
|
|
26
26
|
import {
|
|
27
27
|
getCurrentContextWindowId,
|
|
28
28
|
getCurrentWindowMessageOptions,
|
|
29
29
|
getEventStore,
|
|
30
30
|
getRuntimeConfig
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-YBWY4DKY.js";
|
|
32
32
|
import {
|
|
33
33
|
buildSnapshotFromSessionState
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-6PLAWCHQ.js";
|
|
35
35
|
import {
|
|
36
36
|
getGlobalConfigDir
|
|
37
37
|
} from "./chunk-CQGTEGKL.js";
|
|
@@ -320,4 +320,4 @@ export {
|
|
|
320
320
|
runAgentTurn,
|
|
321
321
|
injectWorkflowKickoffIfNeeded
|
|
322
322
|
};
|
|
323
|
-
//# sourceMappingURL=chunk-
|
|
323
|
+
//# sourceMappingURL=chunk-VDC2QL2O.js.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
foldContextState,
|
|
6
6
|
foldSessionState,
|
|
7
7
|
spreadOptionalMessageFields
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-6PLAWCHQ.js";
|
|
9
9
|
import {
|
|
10
10
|
getDatabase
|
|
11
11
|
} from "./chunk-FBGWG4N6.js";
|
|
@@ -1397,4 +1397,4 @@ export {
|
|
|
1397
1397
|
truncateSessionMessages,
|
|
1398
1398
|
getRecentUserPromptsForSession
|
|
1399
1399
|
};
|
|
1400
|
-
//# sourceMappingURL=chunk-
|
|
1400
|
+
//# sourceMappingURL=chunk-YBWY4DKY.js.map
|