openfox 2.0.89 → 2.0.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/CHANGELOG.md +25 -0
- package/dist/{chat-handler-NOTXEOLF.js → chat-handler-PC5BUJGA.js} +26 -22
- package/dist/chunk-3NGD6IVM.js +65 -0
- package/dist/{chunk-E5D7V7XC.js → chunk-4IBFA5IF.js} +8 -8
- package/dist/{chunk-VFMHWU3E.js → chunk-54Q4TGG6.js} +7 -3
- package/dist/{chunk-TAHZHEJ4.js → chunk-6J5IZ2NL.js} +10 -3
- package/dist/{chunk-EZWSS7LG.js → chunk-6OAJNCRY.js} +9 -1
- package/dist/{chunk-SYU5GNPN.js → chunk-7YBGCZSI.js} +2 -2
- package/dist/{chunk-AGYP7AUV.js → chunk-AXFPEGJI.js} +2 -2
- package/dist/{chunk-67AVIA5G.js → chunk-BJHPUMRX.js} +2 -2
- package/dist/{chunk-Q4OPCXV4.js → chunk-C56Z4OVW.js} +2 -2
- package/dist/{chunk-U7RLUZBP.js → chunk-CFK34T26.js} +1 -1
- package/dist/{chunk-47WNBFDO.js → chunk-CND2YWIJ.js} +2 -2
- package/dist/{chunk-J2IVK667.js → chunk-DH32AHTL.js} +2 -2
- package/dist/{chunk-7JC5YWST.js → chunk-DVVRKNFS.js} +62 -475
- package/dist/chunk-FSLCOA4R.js +144 -0
- package/dist/{chunk-NTYWC6PD.js → chunk-GH5PL3JW.js} +3 -3
- package/dist/chunk-GPODFKPQ.js +7 -0
- package/dist/{chunk-5OGOPB3I.js → chunk-JJY5O2WH.js} +236 -146
- package/dist/{chunk-J7R25K6N.js → chunk-JX6WL56A.js} +7 -7
- package/dist/{chunk-NGIOAASU.js → chunk-K2O7JTCX.js} +1 -243
- package/dist/{chunk-RNXMN5QY.js → chunk-LT4MPTGU.js} +4 -4
- package/dist/{chunk-7TFKWFY3.js → chunk-NGN3Q26A.js} +88 -72
- package/dist/chunk-NLJXZZTB.js +246 -0
- package/dist/{chunk-OVSB5SFF.js → chunk-NO65CC2R.js} +82 -32
- package/dist/{chunk-N54PQSCH.js → chunk-OQTLFO4R.js} +3 -2
- package/dist/{chunk-U2ECZUAX.js → chunk-Q7CN4JOO.js} +22 -75
- package/dist/{chunk-Q6AKRIM2.js → chunk-ST4NYXLH.js} +9 -2
- package/dist/chunk-SXHGRPCI.js +443 -0
- package/dist/{chunk-2GQ7X2NP.js → chunk-U7D72C4O.js} +4 -4
- package/dist/{chunk-4S76VMPH.js → chunk-VJEVCZZA.js} +6 -4
- package/dist/{chunk-VPFUXGMM.js → chunk-VKWVPQJ5.js} +3 -1
- package/dist/{chunk-3QHXJ3DJ.js → chunk-WPACSSBS.js} +3 -3
- package/dist/{chunk-ANYBIATF.js → chunk-WWC3R3YL.js} +2 -2
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/{client-2KVPLIV4.js → client-RBXMHFX3.js} +5 -5
- package/dist/{compactor-W2CUKE22.js → compactor-HW6GBRAG.js} +11 -10
- package/dist/{config-JN6MW5SL.js → config-XIYAPMX3.js} +2 -2
- package/dist/dynamic-context-TDD3Q43F.js +27 -0
- package/dist/{events-OD7MN3FL.js → events-ICX5KVET.js} +7 -7
- package/dist/{folding-TDDQ5CXT.js → folding-L2L4OHX6.js} +5 -5
- package/dist/http-client-E3CV6E5D.js +11 -0
- package/dist/{inspect-proxy-CN2MUFQ5.js → inspect-proxy-NZ3VSMSC.js} +4 -4
- package/dist/{manager-6UIC3QKJ.js → manager-ZPQ6VSM5.js} +5 -5
- package/dist/orchestrator-56LSHPPK.js +55 -0
- package/dist/package.json +1 -1
- package/dist/{path-security-M2JDUBKK.js → path-security-XENIR7SX.js} +10 -10
- package/dist/{platform-55N6FRRU.js → platform-UKZ2QC34.js} +4 -4
- package/dist/{processor-FE4ZJ7GS.js → processor-H6NFFRI2.js} +25 -22
- package/dist/{project-creator-W5VW22DC.js → project-creator-2WMZYQME.js} +3 -3
- package/dist/{projects-HZ3WVTKG.js → projects-N6KVZGMS.js} +3 -3
- package/dist/{protocol-BUA2W2KM.js → protocol-3GNSIGP4.js} +3 -3
- package/dist/{protocol-DKJPL2Ci.d.ts → protocol-CaSHnORC.d.ts} +15 -4
- package/dist/provider/index.d.ts +4 -4
- package/dist/{provider-I2P3NYUI.js → provider-SYYZI2KX.js} +8 -8
- package/dist/{provider-manager-OLDOHCR2.js → provider-manager-P3ZSA5QS.js} +6 -6
- package/dist/registry-ERUV33AP.js +46 -0
- package/dist/{serve-UMPDBCVG.js → serve-KNVANLAK.js} +32 -28
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +31 -27
- package/dist/server-H3525HD6.js +45 -0
- package/dist/session-overrides-NPVYNHTM.js +20 -0
- package/dist/{sessions-Q6SYLG6U.js → sessions-7KCM5QH4.js} +7 -5
- package/dist/{settings-PFZWX6VY.js → settings-2OVKFWR5.js} +3 -3
- package/dist/shared/index.d.ts +3 -3
- package/dist/shared/index.js +1 -1
- package/dist/{tools-NLKP65HF.js → tools-DXBIHSMY.js} +23 -20
- package/dist/{types-C4NrLRR1.d.ts → types-CHCZiJvw.d.ts} +4 -0
- package/dist/{types-B97Fb4vm.d.ts → types-Cw7L4Bze.d.ts} +1 -1
- package/dist/{update-BHTE5TMY.js → update-4BGMFSEG.js} +2 -2
- package/dist/{update-server-V6GJ43WH.js → update-server-4I6LXE5K.js} +2 -2
- package/dist/web/assets/index-Chu9JX0M.js +316 -0
- package/dist/web/assets/index-mS37wyUs.css +32 -0
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/dist/{workspace-N4QHV6J2.js → workspace-YLTMP3OX.js} +4 -4
- package/package.json +1 -1
- package/dist/chunk-TH4JF6XP.js +0 -7
- package/dist/http-client-IPJGJXNJ.js +0 -11
- package/dist/orchestrator-NQDWCULY.js +0 -51
- package/dist/server-4PB7BNE6.js +0 -41
- package/dist/web/assets/index-BQfVUhSC.css +0 -32
- package/dist/web/assets/index-C5sTYb--.js +0 -306
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getPlatformShell
|
|
3
|
+
} from "./chunk-WWC3R3YL.js";
|
|
4
|
+
|
|
5
|
+
// src/server/tools/tool-policy.ts
|
|
6
|
+
var ALWAYS_ALLOWED = /* @__PURE__ */ new Set(["step_done"]);
|
|
7
|
+
var ALWAYS_ALLOWED_FOR_SUBAGENTS = /* @__PURE__ */ new Set(["return_value"]);
|
|
8
|
+
var TOP_LEVEL_ONLY_TOOLS = /* @__PURE__ */ new Set(["call_sub_agent"]);
|
|
9
|
+
function computeEffectiveTools(allowedTools, type) {
|
|
10
|
+
const tools = /* @__PURE__ */ new Set();
|
|
11
|
+
for (const entry of allowedTools) {
|
|
12
|
+
const baseName = entry.includes(":") ? entry.split(":")[0] : entry;
|
|
13
|
+
if (baseName === "return_value" && type === "agent") continue;
|
|
14
|
+
tools.add(baseName);
|
|
15
|
+
}
|
|
16
|
+
const alwaysAllowed = type === "sub-agent" ? ALWAYS_ALLOWED_FOR_SUBAGENTS : ALWAYS_ALLOWED;
|
|
17
|
+
for (const tool of alwaysAllowed) {
|
|
18
|
+
tools.add(tool);
|
|
19
|
+
}
|
|
20
|
+
return tools;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/server/chat/prompts.ts
|
|
24
|
+
import { basename } from "path";
|
|
25
|
+
function buildBasePrompt(workdir, customInstructions, skills, modelName) {
|
|
26
|
+
const instructionsSection = customInstructions ? `
|
|
27
|
+
|
|
28
|
+
## CUSTOM INSTRUCTIONS
|
|
29
|
+
|
|
30
|
+
${customInstructions}` : "";
|
|
31
|
+
const modelLine = modelName ? `
|
|
32
|
+
Model: ${modelName}` : "";
|
|
33
|
+
return `You are OpenFox, an agentic assistant.
|
|
34
|
+
|
|
35
|
+
Today's date is ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0].replace(/-/g, "/")}
|
|
36
|
+
|
|
37
|
+
## ENVIRONMENT
|
|
38
|
+
Working directory: ${workdir}
|
|
39
|
+
Platform: ${process.platform} (${process.arch})
|
|
40
|
+
Shell (run_command): ${basename(getPlatformShell().command)}${modelLine}
|
|
41
|
+
|
|
42
|
+
## CORE BEHAVIOR
|
|
43
|
+
Help user complete tasks safely and efficiently.
|
|
44
|
+
Do everything to satisfy user requirements.
|
|
45
|
+
Read file before editing.
|
|
46
|
+
Prefer precise, minimal changes.
|
|
47
|
+
Use available tools when needed.
|
|
48
|
+
Explain tradeoffs clearly when requirements are ambiguous.
|
|
49
|
+
Follow repository and project instructions exactly.
|
|
50
|
+
Commands run from your working directory \u2014 do not prepend "cd /path/" to change to a directory you are already in.
|
|
51
|
+
|
|
52
|
+
## MODE CONTROL
|
|
53
|
+
OpenFox appends runtime control as USER-role messages wrapped in <system-reminder>...</system-reminder>.
|
|
54
|
+
These reminders are authoritative, treat them as higher-priority operational constraints.
|
|
55
|
+
Never say "user reminded me"; they are runtime mode injected by OpenFox.
|
|
56
|
+
|
|
57
|
+
## WORKFLOW
|
|
58
|
+
Reminder = planning mode: focus on understanding, exploration, clarification, criteria quality.
|
|
59
|
+
Reminder = build mode: focus on implementation, verification, completing approved criteria.
|
|
60
|
+
|
|
61
|
+
## TONE AND STYLE
|
|
62
|
+
Be concise, direct, and to the point.
|
|
63
|
+
Explain non-trivial bash commands (what & why).
|
|
64
|
+
Output renders as CLI markdown (CommonMark).
|
|
65
|
+
Only use tools for tasks, not communication.
|
|
66
|
+
No emojis unless asked.
|
|
67
|
+
Minimize tokens, stay on-topic.
|
|
68
|
+
No preamble/postamble.
|
|
69
|
+
Keep responses under ~4 lines unless detail requested.
|
|
70
|
+
|
|
71
|
+
### Examples
|
|
72
|
+
user: 2 + 2
|
|
73
|
+
assistant: 4
|
|
74
|
+
|
|
75
|
+
user: what command should I run to list files in the current directory?
|
|
76
|
+
assistant: ls
|
|
77
|
+
|
|
78
|
+
user: what command should I run to watch files in the current directory?
|
|
79
|
+
assistant: [use the ls tool to list the files in the current directory, then read docs/commands in the relevant file to find out how to watch files]
|
|
80
|
+
npm run dev
|
|
81
|
+
|
|
82
|
+
user: what files are in the directory src/?
|
|
83
|
+
assistant: [runs ls and sees foo.c, bar.c, baz.c]
|
|
84
|
+
user: which file contains the implementation of foo?
|
|
85
|
+
assistant: src/foo.c
|
|
86
|
+
|
|
87
|
+
user: write tests for new feature
|
|
88
|
+
assistant: [uses run_command tool to find where similar tests are defined, uses concurrent read file tool use blocks in one tool call to read relevant files at the same time, uses edit file tool to write new tests]
|
|
89
|
+
|
|
90
|
+
## FILE REFERENCES
|
|
91
|
+
@ prefix, e.g. @src/index.ts or @web/components/.
|
|
92
|
+
Relative to the working directory above. Strip leading @ and resolve against working directory, never treat as absolute path.
|
|
93
|
+
|
|
94
|
+
## IMPORTANT GUARDRAILS
|
|
95
|
+
NEVER delete/git checkout already modified file: would result in data loss.
|
|
96
|
+
|
|
97
|
+
# Proactiveness
|
|
98
|
+
Allowed to be proactive, but only when user asks you to do something. Balance:
|
|
99
|
+
1. Doing the right thing when asked, including taking actions and follow-up actions
|
|
100
|
+
2. Not surprising user with actions you take without asking
|
|
101
|
+
For example, if user asks you how to approach something, you should do your best to answer their question first, and not immediately jump into taking actions.
|
|
102
|
+
3. Do not add additional code explanation summary unless requested by user. After working on a file, just stop, rather than providing an explanation of what you did.
|
|
103
|
+
|
|
104
|
+
# Following conventions
|
|
105
|
+
Understand file's code conventions. Mimic code style, use existing libraries and utilities, follow existing patterns.
|
|
106
|
+
NEVER assume that a given library is available. To use library or framework, first check that codebase already uses given library.
|
|
107
|
+
When you create new component, first look at existing components to see how written; then consider framework choice, naming conventions, typing, other conventions.
|
|
108
|
+
When you edit code, look at code's surrounding context (imports) to understand code's choice of frameworks and libraries. Then consider how to make given change in way that is most idiomatic.
|
|
109
|
+
Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.
|
|
110
|
+
|
|
111
|
+
# Code style
|
|
112
|
+
IMPORTANT: DO NOT ADD ***ANY*** COMMENTS unless asked
|
|
113
|
+
|
|
114
|
+
# Doing tasks
|
|
115
|
+
User will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:
|
|
116
|
+
Use run_command or Explorer sub-agent to understand the codebase and user's query.
|
|
117
|
+
Implement solution using all tools available to you.
|
|
118
|
+
Verify the solution if possible with tests. NEVER assume specific test framework or test script. Check README or search codebase to determine testing approach.
|
|
119
|
+
VERY IMPORTANT: When you have completed a task, you MUST run lint and typecheck commands (e.g. npm run lint, npm run typecheck, ruff, etc.) with run_command to ensure your code is correct.
|
|
120
|
+
NEVER commit changes unless user explicitly asks you to. VERY IMPORTANT only commit when explicitly asked, otherwise user will feel that you are being too proactive.
|
|
121
|
+
|
|
122
|
+
# Tool usage policy
|
|
123
|
+
When doing file search, prefer to use the call_sub_agent tool with the "explorer" in order to reduce context usage, except if this would take less than 3 calls to get the information.
|
|
124
|
+
You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance.
|
|
125
|
+
|
|
126
|
+
${instructionsSection}
|
|
127
|
+
${buildSkillsSection(skills)}
|
|
128
|
+
`;
|
|
129
|
+
}
|
|
130
|
+
function buildSkillsSection(skills) {
|
|
131
|
+
if (!skills || skills.length === 0) return "";
|
|
132
|
+
const listing = skills.map((s, i) => `${i + 1}. **${s.id}** - ${s.description}`).join("\n");
|
|
133
|
+
return `
|
|
134
|
+
## AVAILABLE SKILLS
|
|
135
|
+
|
|
136
|
+
You can load specialized knowledge using the load_skill tool. Only load a skill when you need its instructions for the current task.
|
|
137
|
+
|
|
138
|
+
${listing}
|
|
139
|
+
|
|
140
|
+
To load a skill, call load_skill with the skill ID. The skill's detailed instructions will be returned as a tool result.
|
|
141
|
+
`;
|
|
142
|
+
}
|
|
143
|
+
function buildSubAgentsSection(subAgentDefs) {
|
|
144
|
+
if (subAgentDefs.length === 0) return "";
|
|
145
|
+
const listing = subAgentDefs.map((agent, i) => {
|
|
146
|
+
const tools = (agent.metadata.allowedTools || []).join(", ");
|
|
147
|
+
return `${i + 1}. **${agent.metadata.id}** - ${agent.metadata.description}
|
|
148
|
+
- Has access to: ${tools}`;
|
|
149
|
+
}).join("\n\n");
|
|
150
|
+
return `
|
|
151
|
+
## AVAILABLE SUB-AGENTS
|
|
152
|
+
|
|
153
|
+
You can call specialized sub-agents for specific tasks using the call_sub_agent tool:
|
|
154
|
+
|
|
155
|
+
${listing}
|
|
156
|
+
|
|
157
|
+
To call a sub-agent, use the call_sub_agent tool with:
|
|
158
|
+
- subAgentType: The ID of the sub-agent
|
|
159
|
+
- prompt: Clear description of what you need
|
|
160
|
+
`;
|
|
161
|
+
}
|
|
162
|
+
function buildTopLevelSystemPrompt(workdir, customInstructions, skills, subAgentDefs, modelName) {
|
|
163
|
+
const base = buildBasePrompt(workdir, customInstructions, skills, modelName);
|
|
164
|
+
const subAgents = subAgentDefs ? buildSubAgentsSection(subAgentDefs) : "";
|
|
165
|
+
return base + subAgents;
|
|
166
|
+
}
|
|
167
|
+
function buildToolPermissionsSection(allowedTools, isSubAgent) {
|
|
168
|
+
if (!allowedTools || allowedTools.length === 0) {
|
|
169
|
+
return "\n\n## AVAILABLE TOOLS\n\nYou have no tools available.";
|
|
170
|
+
}
|
|
171
|
+
const toolPermissions = /* @__PURE__ */ new Map();
|
|
172
|
+
const baseTools = [];
|
|
173
|
+
for (const entry of allowedTools) {
|
|
174
|
+
const colonIdx = entry.indexOf(":");
|
|
175
|
+
if (colonIdx === -1) {
|
|
176
|
+
if (entry !== "return_value" || isSubAgent) {
|
|
177
|
+
baseTools.push(entry);
|
|
178
|
+
}
|
|
179
|
+
} else {
|
|
180
|
+
const toolName = entry.slice(0, colonIdx);
|
|
181
|
+
const actionsStr = entry.slice(colonIdx + 1);
|
|
182
|
+
const actions = actionsStr.split(",").filter(Boolean);
|
|
183
|
+
const existing = toolPermissions.get(toolName) || [];
|
|
184
|
+
toolPermissions.set(toolName, [...existing, ...actions]);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const effectiveTools = computeEffectiveTools(allowedTools, isSubAgent ? "sub-agent" : "agent");
|
|
188
|
+
for (const tool of effectiveTools) {
|
|
189
|
+
if (!baseTools.includes(tool) && !toolPermissions.has(tool)) {
|
|
190
|
+
baseTools.push(tool);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const parts = [];
|
|
194
|
+
for (const [toolName, actions] of toolPermissions) {
|
|
195
|
+
parts.push(`${toolName}: ${actions.join(", ")}`);
|
|
196
|
+
}
|
|
197
|
+
for (const tool of baseTools) {
|
|
198
|
+
if (!toolPermissions.has(tool)) {
|
|
199
|
+
parts.push(tool);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const toolsList = parts.join(", ");
|
|
203
|
+
return `
|
|
204
|
+
|
|
205
|
+
## AVAILABLE TOOLS
|
|
206
|
+
|
|
207
|
+
You have access to these tools: ${toolsList}`;
|
|
208
|
+
}
|
|
209
|
+
function buildAgentReminder(agentDef) {
|
|
210
|
+
const toolPermissions = buildToolPermissionsSection(agentDef.metadata.allowedTools, agentDef.metadata.subagent);
|
|
211
|
+
return `<system-reminder>
|
|
212
|
+
${agentDef.prompt}${toolPermissions}
|
|
213
|
+
</system-reminder>`;
|
|
214
|
+
}
|
|
215
|
+
function buildAgentSmallReminder(name) {
|
|
216
|
+
return `<system-reminder>
|
|
217
|
+
Reminder: you are in '${name}' mode.
|
|
218
|
+
</system-reminder>`;
|
|
219
|
+
}
|
|
220
|
+
var COMPACTION_PROMPT = `You are a helpful AI assistant tasked with summarizing conversations for continuation.
|
|
221
|
+
|
|
222
|
+
Summarize the conversation history concisely, preserving:
|
|
223
|
+
1. What was done and what is currently being worked on
|
|
224
|
+
2. All file modifications made (file paths and what changed)
|
|
225
|
+
3. All errors encountered and how they were resolved
|
|
226
|
+
4. Current progress on each task
|
|
227
|
+
5. Important technical decisions and WHY they were made
|
|
228
|
+
6. Requirements that should persist
|
|
229
|
+
7. Next steps or pending actions that should be continued after compaction
|
|
230
|
+
8. The user's current question, prompt, or active request
|
|
231
|
+
|
|
232
|
+
Do not respond to any questions in the conversation, only output the summary.
|
|
233
|
+
Be thorough but concise. Output as a structured summary.`;
|
|
234
|
+
|
|
235
|
+
export {
|
|
236
|
+
ALWAYS_ALLOWED,
|
|
237
|
+
ALWAYS_ALLOWED_FOR_SUBAGENTS,
|
|
238
|
+
TOP_LEVEL_ONLY_TOOLS,
|
|
239
|
+
computeEffectiveTools,
|
|
240
|
+
buildBasePrompt,
|
|
241
|
+
buildTopLevelSystemPrompt,
|
|
242
|
+
buildAgentReminder,
|
|
243
|
+
buildAgentSmallReminder,
|
|
244
|
+
COMPACTION_PROMPT
|
|
245
|
+
};
|
|
246
|
+
//# sourceMappingURL=chunk-NLJXZZTB.js.map
|
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
|
-
applyDynamicContext,
|
|
3
|
-
computeSessionHash,
|
|
4
2
|
runAgentTurn,
|
|
5
3
|
runChatTurn
|
|
6
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-Q7CN4JOO.js";
|
|
7
5
|
import {
|
|
8
6
|
devServerManager,
|
|
9
7
|
executeSubAgent,
|
|
10
8
|
getToolRegistryForAgent
|
|
11
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DVVRKNFS.js";
|
|
12
10
|
import {
|
|
13
11
|
checkAborted,
|
|
14
12
|
onProcessEvent,
|
|
15
13
|
spawnShellProcess
|
|
16
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-U7D72C4O.js";
|
|
15
|
+
import {
|
|
16
|
+
killProcessTree,
|
|
17
|
+
terminateProcessTree
|
|
18
|
+
} from "./chunk-I72ACQ6R.js";
|
|
17
19
|
import {
|
|
18
20
|
gitSpawnEnv
|
|
19
21
|
} from "./chunk-J7GAZGZT.js";
|
|
22
|
+
import {
|
|
23
|
+
applyDynamicContext,
|
|
24
|
+
computeSessionHash,
|
|
25
|
+
computeUnifiedDiff
|
|
26
|
+
} from "./chunk-FSLCOA4R.js";
|
|
20
27
|
import {
|
|
21
28
|
createChatErrorMessage,
|
|
22
29
|
createChatMessageMessage,
|
|
@@ -31,34 +38,30 @@ import {
|
|
|
31
38
|
parseClientMessage,
|
|
32
39
|
serializeServerMessage,
|
|
33
40
|
storedEventToServerMessage
|
|
34
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-CND2YWIJ.js";
|
|
35
42
|
import {
|
|
36
43
|
getPendingQuestionsForSession,
|
|
37
44
|
provideAnswer
|
|
38
45
|
} from "./chunk-EU3WWTFH.js";
|
|
39
46
|
import {
|
|
40
47
|
appendCompactionPrompt
|
|
41
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-VJEVCZZA.js";
|
|
42
49
|
import {
|
|
43
50
|
TurnMetrics,
|
|
44
51
|
createMessageStartEvent
|
|
45
|
-
} from "./chunk-
|
|
46
|
-
import {
|
|
47
|
-
getPlatformShell
|
|
48
|
-
} from "./chunk-ANYBIATF.js";
|
|
49
|
-
import {
|
|
50
|
-
killProcessTree,
|
|
51
|
-
terminateProcessTree
|
|
52
|
-
} from "./chunk-I72ACQ6R.js";
|
|
52
|
+
} from "./chunk-K2O7JTCX.js";
|
|
53
53
|
import {
|
|
54
54
|
combineEventsWithSnapshot,
|
|
55
55
|
getCurrentContextWindowId,
|
|
56
56
|
getEventStore
|
|
57
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-LT4MPTGU.js";
|
|
58
|
+
import {
|
|
59
|
+
getPlatformShell
|
|
60
|
+
} from "./chunk-WWC3R3YL.js";
|
|
58
61
|
import {
|
|
59
62
|
buildMessagesFromStoredEvents,
|
|
60
63
|
foldPendingConfirmations
|
|
61
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-AXFPEGJI.js";
|
|
62
65
|
import {
|
|
63
66
|
deleteItemFromDir,
|
|
64
67
|
findAgentById,
|
|
@@ -67,10 +70,10 @@ import {
|
|
|
67
70
|
loadAllAgentsDefault,
|
|
68
71
|
resolveDefaultAgentId,
|
|
69
72
|
saveItemToDir
|
|
70
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-NGN3Q26A.js";
|
|
71
74
|
import {
|
|
72
75
|
getMaxVisibleItems
|
|
73
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-54Q4TGG6.js";
|
|
74
77
|
import {
|
|
75
78
|
logger
|
|
76
79
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -79,7 +82,7 @@ import {
|
|
|
79
82
|
} from "./chunk-VUQCQXXJ.js";
|
|
80
83
|
import {
|
|
81
84
|
createServerMessage
|
|
82
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-CFK34T26.js";
|
|
83
86
|
import {
|
|
84
87
|
getGlobalConfigDir
|
|
85
88
|
} from "./chunk-CQGTEGKL.js";
|
|
@@ -1436,7 +1439,7 @@ function processQueueAndRestartTurn(sessionManager, sessionId, drainFn, queueMod
|
|
|
1436
1439
|
var activeAgents = /* @__PURE__ */ new Map();
|
|
1437
1440
|
var abortedSessions = /* @__PURE__ */ new Set();
|
|
1438
1441
|
var MAX_SEND_QUEUE_SIZE = 1e3;
|
|
1439
|
-
function createWebSocketServer(httpServer, _config, getLLMClient, getActiveProvider, sessionManager, providerManager) {
|
|
1442
|
+
function createWebSocketServer(httpServer, _config, getLLMClient, getActiveProvider, sessionManager, providerManager, getMcpServers) {
|
|
1440
1443
|
const wss = new WebSocketServer({ server: httpServer });
|
|
1441
1444
|
const clients = /* @__PURE__ */ new Map();
|
|
1442
1445
|
moduleClients = clients;
|
|
@@ -1787,7 +1790,8 @@ function createWebSocketServer(httpServer, _config, getLLMClient, getActiveProvi
|
|
|
1787
1790
|
statsForSession,
|
|
1788
1791
|
startTurnWithCompletionChain,
|
|
1789
1792
|
cleanupAfterTurn,
|
|
1790
|
-
enqueueSend
|
|
1793
|
+
enqueueSend,
|
|
1794
|
+
getMcpServers
|
|
1791
1795
|
);
|
|
1792
1796
|
} catch (error) {
|
|
1793
1797
|
logger.error("Error handling client message", { error, type: message.type });
|
|
@@ -1840,7 +1844,7 @@ function createWebSocketServer(httpServer, _config, getLLMClient, getActiveProvi
|
|
|
1840
1844
|
broadcastAll
|
|
1841
1845
|
};
|
|
1842
1846
|
}
|
|
1843
|
-
async function handleClientMessage(ws, client, message, _getLLMClient, _getActiveProvider, sessionManager, _broadcastForSession, _providerManager, _getSessionLLMClient, _getSessionStatsIdentity, llmForSession, statsForSession, _startTurnWithCompletionChain, cleanupAfterTurn, enqueueSendFn) {
|
|
1847
|
+
async function handleClientMessage(ws, client, message, _getLLMClient, _getActiveProvider, sessionManager, _broadcastForSession, _providerManager, _getSessionLLMClient, _getSessionStatsIdentity, llmForSession, statsForSession, _startTurnWithCompletionChain, cleanupAfterTurn, enqueueSendFn, getMcpServers) {
|
|
1844
1848
|
const send = (msg) => {
|
|
1845
1849
|
if (ws.readyState === WebSocket2.OPEN) {
|
|
1846
1850
|
const seq = client.lastSentSeq + 1;
|
|
@@ -1913,11 +1917,16 @@ async function handleClientMessage(ws, client, message, _getLLMClient, _getActiv
|
|
|
1913
1917
|
};
|
|
1914
1918
|
sendContextState();
|
|
1915
1919
|
const cachedHash = sessionManager.getCachedPrompt(session.id)?.hash;
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1920
|
+
(async () => {
|
|
1921
|
+
try {
|
|
1922
|
+
await mcpReadyPromise;
|
|
1923
|
+
if (getMcpServers) {
|
|
1924
|
+
const servers = getMcpServers();
|
|
1925
|
+
if (servers.length > 0) {
|
|
1926
|
+
send(createServerMessage("mcp.servers.changed", { servers }));
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
if (cachedHash) {
|
|
1921
1930
|
const currentHash = await computeSessionHash(sessionManager, session.id);
|
|
1922
1931
|
if (currentHash !== cachedHash) {
|
|
1923
1932
|
sessionManager.setDynamicContextChanged(session.id, true);
|
|
@@ -1926,10 +1935,10 @@ async function handleClientMessage(ws, client, message, _getLLMClient, _getActiv
|
|
|
1926
1935
|
sessionManager.setDynamicContextChanged(session.id, false);
|
|
1927
1936
|
sendContextState();
|
|
1928
1937
|
}
|
|
1929
|
-
} catch {
|
|
1930
1938
|
}
|
|
1931
|
-
}
|
|
1932
|
-
|
|
1939
|
+
} catch {
|
|
1940
|
+
}
|
|
1941
|
+
})();
|
|
1933
1942
|
break;
|
|
1934
1943
|
}
|
|
1935
1944
|
// =========================================================================
|
|
@@ -2031,6 +2040,47 @@ async function handleClientMessage(ws, client, message, _getLLMClient, _getActiv
|
|
|
2031
2040
|
})();
|
|
2032
2041
|
break;
|
|
2033
2042
|
}
|
|
2043
|
+
case "context.applyDynamic.preview": {
|
|
2044
|
+
if (!client.activeSessionId) {
|
|
2045
|
+
send(createErrorMessage("NO_SESSION", "No active session", message.id));
|
|
2046
|
+
return;
|
|
2047
|
+
}
|
|
2048
|
+
const sessionId = client.activeSessionId;
|
|
2049
|
+
const session = sessionManager.requireSession(sessionId);
|
|
2050
|
+
try {
|
|
2051
|
+
const { buildCachedPrompt } = await import("./dynamic-context-TDD3Q43F.js");
|
|
2052
|
+
const allAgents = await import("./registry-ERUV33AP.js");
|
|
2053
|
+
const agentDef = allAgents.findAgentById(session.mode, await allAgents.loadAllAgentsDefault()) ?? allAgents.findAgentById("planner", await allAgents.loadAllAgentsDefault());
|
|
2054
|
+
const { systemPrompt: newPrompt, hash: newHash } = await buildCachedPrompt(sessionManager, sessionId, agentDef);
|
|
2055
|
+
const oldCached = sessionManager.getCachedPrompt(sessionId);
|
|
2056
|
+
const oldPrompt = oldCached?.systemPrompt;
|
|
2057
|
+
const diff = oldPrompt ? computeUnifiedDiff(oldPrompt, newPrompt) : [];
|
|
2058
|
+
send({
|
|
2059
|
+
type: "context.preview",
|
|
2060
|
+
payload: {
|
|
2061
|
+
oldPrompt,
|
|
2062
|
+
newPrompt,
|
|
2063
|
+
oldHash: oldCached?.hash,
|
|
2064
|
+
newHash,
|
|
2065
|
+
diff
|
|
2066
|
+
},
|
|
2067
|
+
id: message.id
|
|
2068
|
+
});
|
|
2069
|
+
} catch (error) {
|
|
2070
|
+
logger.error("Failed to preview dynamic context", {
|
|
2071
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
2072
|
+
sessionId
|
|
2073
|
+
});
|
|
2074
|
+
send(
|
|
2075
|
+
createErrorMessage(
|
|
2076
|
+
"ERROR",
|
|
2077
|
+
`Failed to preview: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
2078
|
+
message.id
|
|
2079
|
+
)
|
|
2080
|
+
);
|
|
2081
|
+
}
|
|
2082
|
+
break;
|
|
2083
|
+
}
|
|
2034
2084
|
case "context.applyDynamic": {
|
|
2035
2085
|
if (!client.activeSessionId) {
|
|
2036
2086
|
send(createErrorMessage("NO_SESSION", "No active session", message.id));
|
|
@@ -2222,4 +2272,4 @@ export {
|
|
|
2222
2272
|
signalMcpReady,
|
|
2223
2273
|
createWebSocketServer
|
|
2224
2274
|
};
|
|
2225
|
-
//# sourceMappingURL=chunk-
|
|
2275
|
+
//# sourceMappingURL=chunk-NO65CC2R.js.map
|
|
@@ -106,7 +106,8 @@ var mcpServerSchema = z.object({
|
|
|
106
106
|
headers: z.record(z.string(), z.string()).optional(),
|
|
107
107
|
disabledTools: z.array(z.string()).optional(),
|
|
108
108
|
cachedTools: z.array(cachedToolSchema).optional(),
|
|
109
|
-
timeout: z.number().positive().optional()
|
|
109
|
+
timeout: z.number().positive().optional(),
|
|
110
|
+
disabled: z.boolean().optional()
|
|
110
111
|
});
|
|
111
112
|
var llmConfigSchema = z.object({
|
|
112
113
|
timeout: z.number().optional(),
|
|
@@ -322,4 +323,4 @@ export {
|
|
|
322
323
|
removeProvider,
|
|
323
324
|
activateProvider
|
|
324
325
|
};
|
|
325
|
-
//# sourceMappingURL=chunk-
|
|
326
|
+
//# sourceMappingURL=chunk-OQTLFO4R.js.map
|
|
@@ -1,38 +1,45 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAssemblyResult,
|
|
3
|
-
getAllInstructions,
|
|
4
3
|
getConversationMessages,
|
|
5
|
-
getEnabledSkillMetadata,
|
|
6
4
|
getToolRegistryForAgent,
|
|
7
5
|
processEventsForConversation,
|
|
8
6
|
runTopLevelAgentLoop
|
|
9
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DVVRKNFS.js";
|
|
8
|
+
import {
|
|
9
|
+
buildCachedPrompt,
|
|
10
|
+
computeDynamicContextHash,
|
|
11
|
+
getToolFingerprint
|
|
12
|
+
} from "./chunk-FSLCOA4R.js";
|
|
13
|
+
import {
|
|
14
|
+
getAllInstructions,
|
|
15
|
+
getEnabledSkillMetadata
|
|
16
|
+
} from "./chunk-SXHGRPCI.js";
|
|
10
17
|
import {
|
|
11
18
|
PathAccessDeniedError
|
|
12
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-WPACSSBS.js";
|
|
13
20
|
import {
|
|
14
21
|
TurnMetrics,
|
|
15
|
-
buildAgentReminder,
|
|
16
|
-
buildAgentSmallReminder,
|
|
17
|
-
buildTopLevelSystemPrompt,
|
|
18
22
|
createChatDoneEvent,
|
|
19
23
|
createMessageStartEvent
|
|
20
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-K2O7JTCX.js";
|
|
25
|
+
import {
|
|
26
|
+
buildAgentReminder,
|
|
27
|
+
buildAgentSmallReminder
|
|
28
|
+
} from "./chunk-NLJXZZTB.js";
|
|
21
29
|
import {
|
|
22
30
|
getCurrentContextWindowId,
|
|
23
31
|
getCurrentWindowMessageOptions,
|
|
24
32
|
getEventStore
|
|
25
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-LT4MPTGU.js";
|
|
26
34
|
import {
|
|
27
35
|
buildSnapshotFromSessionState
|
|
28
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-AXFPEGJI.js";
|
|
29
37
|
import {
|
|
30
38
|
findAgentById,
|
|
31
39
|
getRuntimeConfig,
|
|
32
|
-
getSubAgents,
|
|
33
40
|
loadAllAgentsDefault,
|
|
34
41
|
resolveDefaultAgentId
|
|
35
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-NGN3Q26A.js";
|
|
36
43
|
import {
|
|
37
44
|
logger
|
|
38
45
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -40,67 +47,9 @@ import {
|
|
|
40
47
|
getGlobalConfigDir
|
|
41
48
|
} from "./chunk-CQGTEGKL.js";
|
|
42
49
|
|
|
43
|
-
// src/server/chat/dynamic-context.ts
|
|
44
|
-
import { createHash } from "crypto";
|
|
45
|
-
function computeDynamicContextHash(instructionContent, skills, toolFingerprint) {
|
|
46
|
-
const dynamicInputs = JSON.stringify({
|
|
47
|
-
instructions: instructionContent,
|
|
48
|
-
skills: skills.map((s) => s.id).sort(),
|
|
49
|
-
...toolFingerprint ? { tools: toolFingerprint } : {}
|
|
50
|
-
});
|
|
51
|
-
return createHash("sha256").update(dynamicInputs).digest("hex");
|
|
52
|
-
}
|
|
53
|
-
function getToolFingerprint(tools) {
|
|
54
|
-
return tools.map((t) => `${t.function.name}:${JSON.stringify(t.function.parameters)}`).sort().join("|");
|
|
55
|
-
}
|
|
56
|
-
async function loadSessionContext(sessionManager, sessionId) {
|
|
57
|
-
const session = sessionManager.requireSession(sessionId);
|
|
58
|
-
const { content: instructionContent } = await getAllInstructions(session.workdir, session.projectId);
|
|
59
|
-
const runtimeConfig = getRuntimeConfig();
|
|
60
|
-
const configDir = getGlobalConfigDir(runtimeConfig.mode ?? "production");
|
|
61
|
-
const skills = await getEnabledSkillMetadata(configDir, runtimeConfig.workdir);
|
|
62
|
-
return { instructionContent: instructionContent ?? "", skills };
|
|
63
|
-
}
|
|
64
|
-
function resolveAgentDef(sessionManager, sessionId) {
|
|
65
|
-
return loadAllAgentsDefault().then((allAgents) => {
|
|
66
|
-
const session = sessionManager.requireSession(sessionId);
|
|
67
|
-
return findAgentById(session.mode, allAgents) ?? findAgentById(resolveDefaultAgentId(), allAgents);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
async function buildCachedPrompt(sessionManager, sessionId, agentDef) {
|
|
71
|
-
const { instructionContent, skills } = await loadSessionContext(sessionManager, sessionId);
|
|
72
|
-
const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-NLKP65HF.js");
|
|
73
|
-
const tools = getToolRegistryForAgent2(agentDef).definitions;
|
|
74
|
-
const toolFingerprint = getToolFingerprint(tools);
|
|
75
|
-
const allAgents = await loadAllAgentsDefault();
|
|
76
|
-
const subAgentDefs = getSubAgents(allAgents);
|
|
77
|
-
const session = sessionManager.requireSession(sessionId);
|
|
78
|
-
const systemPrompt = buildTopLevelSystemPrompt(session.workdir, instructionContent || void 0, skills, subAgentDefs);
|
|
79
|
-
const hash = computeDynamicContextHash(instructionContent, skills, toolFingerprint);
|
|
80
|
-
return { systemPrompt, tools, hash };
|
|
81
|
-
}
|
|
82
|
-
async function computeSessionHash(sessionManager, sessionId) {
|
|
83
|
-
const { instructionContent, skills } = await loadSessionContext(sessionManager, sessionId);
|
|
84
|
-
const agentDef = await resolveAgentDef(sessionManager, sessionId);
|
|
85
|
-
const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-NLKP65HF.js");
|
|
86
|
-
const tools = getToolRegistryForAgent2(agentDef).definitions;
|
|
87
|
-
const toolFingerprint = getToolFingerprint(tools);
|
|
88
|
-
return computeDynamicContextHash(instructionContent, skills, toolFingerprint);
|
|
89
|
-
}
|
|
90
|
-
async function applyDynamicContext(sessionManager, sessionId) {
|
|
91
|
-
const session = sessionManager.requireSession(sessionId);
|
|
92
|
-
const allAgents = await loadAllAgentsDefault();
|
|
93
|
-
const agentDef = findAgentById(session.mode, allAgents) ?? findAgentById(resolveDefaultAgentId(), allAgents);
|
|
94
|
-
const { systemPrompt, tools, hash } = await buildCachedPrompt(sessionManager, sessionId, agentDef);
|
|
95
|
-
sessionManager.setCachedPrompt(sessionId, systemPrompt, tools, hash);
|
|
96
|
-
sessionManager.setDynamicContextChanged(sessionId, false);
|
|
97
|
-
sessionManager.clearDebugDump(sessionId);
|
|
98
|
-
logger.debug("applyDynamicContext done", { sessionId, hash, toolCount: tools.length });
|
|
99
|
-
}
|
|
100
|
-
|
|
101
50
|
// src/server/chat/orchestrator.ts
|
|
102
51
|
async function buildRetryPatterns() {
|
|
103
|
-
const { getSetting, SETTINGS_KEYS } = await import("./settings-
|
|
52
|
+
const { getSetting, SETTINGS_KEYS } = await import("./settings-2OVKFWR5.js");
|
|
104
53
|
const raw = getSetting(SETTINGS_KEYS.RETRY_PATTERNS);
|
|
105
54
|
if (!raw) {
|
|
106
55
|
const oldXmlProtection = getSetting("llm.disableXmlProtection");
|
|
@@ -331,7 +280,7 @@ async function runAgentTurn(options, turnMetrics, agentId, append, callbacks) {
|
|
|
331
280
|
toolChoice: input.toolChoice
|
|
332
281
|
});
|
|
333
282
|
},
|
|
334
|
-
getToolRegistry: () => getToolRegistryForAgent(agentDef),
|
|
283
|
+
getToolRegistry: () => getToolRegistryForAgent(agentDef, options.sessionId),
|
|
335
284
|
getConversationMessages: buildGetConversationMessages(options.sessionId, options.llmClient, append),
|
|
336
285
|
injectAgentReminder: () => injectAgentReminder(options.sessionId, agentDef),
|
|
337
286
|
...options.initialCompacting ? { initialCompacting: true } : {},
|
|
@@ -357,9 +306,7 @@ function buildSnapshot(sessionManager, sessionId, _lastStats) {
|
|
|
357
306
|
}
|
|
358
307
|
|
|
359
308
|
export {
|
|
360
|
-
computeSessionHash,
|
|
361
|
-
applyDynamicContext,
|
|
362
309
|
runChatTurn,
|
|
363
310
|
runAgentTurn
|
|
364
311
|
};
|
|
365
|
-
//# sourceMappingURL=chunk-
|
|
312
|
+
//# sourceMappingURL=chunk-Q7CN4JOO.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getDatabase
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6OAJNCRY.js";
|
|
4
4
|
|
|
5
5
|
// src/server/db/projects.ts
|
|
6
6
|
function createProject(name, workdir) {
|
|
@@ -79,6 +79,10 @@ function updateProject(id, updates) {
|
|
|
79
79
|
sets.push("workspace_root_dir = ?");
|
|
80
80
|
values.push(updates.workspaceRootDir);
|
|
81
81
|
}
|
|
82
|
+
if (updates.mcpOverrides !== void 0) {
|
|
83
|
+
sets.push("mcp_overrides = ?");
|
|
84
|
+
values.push(updates.mcpOverrides !== null ? JSON.stringify(updates.mcpOverrides) : null);
|
|
85
|
+
}
|
|
82
86
|
values.push(id);
|
|
83
87
|
const result = db.prepare(
|
|
84
88
|
`
|
|
@@ -108,6 +112,9 @@ function rowToProject(row) {
|
|
|
108
112
|
...row.danger_level ? { dangerLevel: row.danger_level } : {},
|
|
109
113
|
isStarred: !!row.is_starred,
|
|
110
114
|
...row.workspace_root_dir ? { workspaceRootDir: row.workspace_root_dir } : {},
|
|
115
|
+
...row.mcp_overrides ? {
|
|
116
|
+
mcpOverrides: JSON.parse(row.mcp_overrides)
|
|
117
|
+
} : {},
|
|
111
118
|
createdAt: row.created_at,
|
|
112
119
|
updatedAt: row.updated_at
|
|
113
120
|
};
|
|
@@ -122,4 +129,4 @@ export {
|
|
|
122
129
|
deleteProject,
|
|
123
130
|
toggleStar
|
|
124
131
|
};
|
|
125
|
-
//# sourceMappingURL=chunk-
|
|
132
|
+
//# sourceMappingURL=chunk-ST4NYXLH.js.map
|