openfox 2.0.129 → 2.0.131

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +2 -0
  3. package/dist/CHANGELOG.md +44 -0
  4. package/dist/auth-D3WLIBTG.js +19 -0
  5. package/dist/{auto-config-454YE6KC.js → auto-config-5VSNLVNI.js} +6 -5
  6. package/dist/{backend-4YPEC3J2.js → backend-NDBY3DAQ.js} +4 -2
  7. package/dist/{chat-handler-TH6JBO6G.js → chat-handler-RAIMQU7F.js} +35 -35
  8. package/dist/{chunk-ISE55FOR.js → chunk-2AI7VYPN.js} +11 -1
  9. package/dist/{chunk-HO7A7TMF.js → chunk-55DGZIZ6.js} +15 -5
  10. package/dist/{chunk-L24A6GZ7.js → chunk-5AI3LHRQ.js} +85 -57
  11. package/dist/{chunk-ZFNBATE3.js → chunk-6EZDW4JS.js} +3 -2
  12. package/dist/{chunk-ZXWJ6JTL.js → chunk-6MUSEPV7.js} +1197 -225
  13. package/dist/{chunk-OHTBWA7L.js → chunk-6SUBBT2M.js} +13 -13
  14. package/dist/{chunk-6LX43YRA.js → chunk-7ET46SNE.js} +4 -4
  15. package/dist/{chunk-GIJUWPRQ.js → chunk-7JVBDBXE.js} +2 -2
  16. package/dist/{chunk-MYNNMV75.js → chunk-7LGMQ5KS.js} +54 -36
  17. package/dist/{chunk-ZIL6VKLU.js → chunk-BKMWZTNO.js} +3 -3
  18. package/dist/chunk-BMBOSVRM.js +7 -0
  19. package/dist/{auth-GTGIGX5X.js → chunk-CQGJ5RWB.js} +4 -4
  20. package/dist/{chunk-3B232XG4.js → chunk-DPFET73G.js} +2 -2
  21. package/dist/chunk-DQTN4B33.js +235 -0
  22. package/dist/{chunk-KBESUA3W.js → chunk-ELYHHEYL.js} +3 -3
  23. package/dist/{chunk-DABWCAXS.js → chunk-EUOWCVU6.js} +19 -6
  24. package/dist/{chunk-YJD5A375.js → chunk-FGNJMKDV.js} +5 -5
  25. package/dist/{chunk-ATWOXI52.js → chunk-HCYSGLY2.js} +1 -1
  26. package/dist/{chunk-OYBUJIC3.js → chunk-JU757HVI.js} +5 -1
  27. package/dist/{chunk-AQBRI7TM.js → chunk-KWAHD2JA.js} +13 -8
  28. package/dist/{chunk-N2Q3KYWM.js → chunk-LQKXJPKP.js} +8 -3
  29. package/dist/{chunk-EHFIUXWZ.js → chunk-LW6MMSTD.js} +2 -2
  30. package/dist/{chunk-ZIYETXOW.js → chunk-M5T4RDPJ.js} +4 -4
  31. package/dist/{chunk-66MG44TF.js → chunk-MGEYAYGU.js} +2 -2
  32. package/dist/{chunk-RV5G7QQU.js → chunk-MQMPIXON.js} +3 -3
  33. package/dist/{chunk-K2QKX4ZJ.js → chunk-OA2FURC3.js} +8 -2
  34. package/dist/{chunk-567L5OJ6.js → chunk-P57IBMK4.js} +2 -2
  35. package/dist/{chunk-P6GTPKE5.js → chunk-QJG5K3X2.js} +278 -16
  36. package/dist/{chunk-2COZT3YI.js → chunk-RQPHGBWI.js} +24 -24
  37. package/dist/chunk-SVALN5KE.js +394 -0
  38. package/dist/{session-status-6Q5B5PEN.js → chunk-T3S5MTMD.js} +2 -3
  39. package/dist/{chunk-7YP4O4XE.js → chunk-TACWRDDC.js} +3 -3
  40. package/dist/{chunk-7ZMOP5LS.js → chunk-TS5WKTFB.js} +18 -1
  41. package/dist/{chunk-PBFGJFGC.js → chunk-UV6IH6HK.js} +32 -10
  42. package/dist/{chunk-7RIEI2TE.js → chunk-WCM5ZW5N.js} +52 -17
  43. package/dist/{chunk-Y3BSBKHY.js → chunk-XE6UC5Z3.js} +2 -2
  44. package/dist/{chunk-26WS7AH6.js → chunk-Y6ZGHOKM.js} +39 -7
  45. package/dist/chunk-YNMP647F.js +24 -0
  46. package/dist/{chunk-H6YIVK67.js → chunk-ZCFQOC3C.js} +26 -6
  47. package/dist/{chunk-IJFKJ5D6.js → chunk-ZL4IAFF3.js} +4 -4
  48. package/dist/{chunk-JQMQ4DGC.js → chunk-ZVHUISW7.js} +76 -32
  49. package/dist/cli/dev.js +1 -1
  50. package/dist/cli/index.js +1 -1
  51. package/dist/client-E6QLHPHD.js +16 -0
  52. package/dist/{client-pure-GU2SV3DD.js → client-pure-FLKP6PTI.js} +2 -2
  53. package/dist/compactor-OEJAA2YP.js +32 -0
  54. package/dist/dynamic-context-Y555VDLA.js +52 -0
  55. package/dist/{events-GMHRX4LF.js → events-ZJPRGVL2.js} +9 -9
  56. package/dist/{folding-7K2GRPF4.js → folding-QRZOHY2I.js} +7 -7
  57. package/dist/http-client-P4XTKAZA.js +11 -0
  58. package/dist/{inspect-proxy-UKPU3Z64.js → inspect-proxy-A3OROWPG.js} +4 -4
  59. package/dist/launch-Y4H7FDU2.js +53 -0
  60. package/dist/{manager-NOKJQTTF.js → manager-TMBFBCQL.js} +5 -5
  61. package/dist/mcp-YU7AM3UV.js +120 -0
  62. package/dist/{model-catalog-ZLOWTQA7.js → model-catalog-2PCKTYGW.js} +2 -2
  63. package/dist/{oauth-provider-DGBC2YM6.js → oauth-provider-VHUS2KEG.js} +8 -2
  64. package/dist/orchestrator-SQN2SJ2A.js +64 -0
  65. package/dist/package.json +1 -1
  66. package/dist/{path-security-UDZ7UVWK.js → path-security-CBACXAMS.js} +13 -13
  67. package/dist/{platform-EMKWQTZX.js → platform-5LQXOZO3.js} +4 -4
  68. package/dist/plugins-registry.json +12 -0
  69. package/dist/{processor-7RDR675X.js → processor-MEHODYNE.js} +34 -34
  70. package/dist/{profiles-HXGJIPF2.js → profiles-EBCVFYG7.js} +2 -2
  71. package/dist/{project-creator-JF3YVQAH.js → project-creator-6AGQTNXB.js} +3 -3
  72. package/dist/{projects-TPSLCJP2.js → projects-5U37RUTL.js} +3 -3
  73. package/dist/{protocol-DMneA8mx.d.ts → protocol-BMUoqwYH.d.ts} +2 -1
  74. package/dist/{protocol-TS3GVTT3.js → protocol-Y7MRKRUO.js} +3 -3
  75. package/dist/provider/index.d.ts +4 -4
  76. package/dist/{provider-DXEICEIE.js → provider-6YRII4IV.js} +11 -11
  77. package/dist/{provider-manager-PU7RS2TK.js → provider-manager-URNJBK5Q.js} +11 -11
  78. package/dist/{registry-Z4GVYFTV.js → registry-CMSSZHDC.js} +5 -5
  79. package/dist/{serve-Z5ITDPCQ.js → serve-NPADSJG7.js} +45 -43
  80. package/dist/server/index.d.ts +28 -4
  81. package/dist/server/index.js +42 -40
  82. package/dist/server-5TY22HDN.js +56 -0
  83. package/dist/service-VPXGREXF.js +27 -0
  84. package/dist/{session-overrides-4WAD3X5Q.js → session-overrides-OECQYRDK.js} +7 -7
  85. package/dist/session-status-UFO5IFI7.js +10 -0
  86. package/dist/{sessions-D7VRCHQY.js → sessions-NMPX5ICI.js} +6 -6
  87. package/dist/{settings-VOWWO4VG.js → settings-MDCRNQBY.js} +3 -3
  88. package/dist/shared/index.d.ts +3 -3
  89. package/dist/shared/index.js +1 -1
  90. package/dist/skill-defaults/browser/SKILL.md +20 -1
  91. package/dist/{tasks-SE3DOPVP.js → tasks-MNPXK2S5.js} +14 -14
  92. package/dist/{tools-6XUSIJN2.js → tools-6BDT5YMT.js} +37 -37
  93. package/dist/{types-PAKlAzp9.d.ts → types-BIkpxjaj.d.ts} +11 -2
  94. package/dist/{types-BWuVnaBw.d.ts → types-CoY8Ka1C.d.ts} +1 -1
  95. package/dist/{update-EJUI6PSV.js → update-XKCOBE47.js} +2 -2
  96. package/dist/web/assets/{index-CGKd7WLQ.js → index-Bx5r3aJx.js} +88 -88
  97. package/dist/web/assets/{index-CbX8veVW.css → index-Y300llHY.css} +1 -1
  98. package/dist/web/index.html +2 -2
  99. package/dist/web/sw.js +1 -1
  100. package/dist/{workspace-6CUE26YA.js → workspace-LM646OHC.js} +4 -4
  101. package/package.json +1 -1
  102. package/plugins-registry.json +12 -0
  103. package/dist/chunk-HIRDDCPD.js +0 -7
  104. package/dist/chunk-PHP7PLFX.js +0 -151
  105. package/dist/chunk-RSB4AR2A.js +0 -108
  106. package/dist/client-RZGGDGUA.js +0 -16
  107. package/dist/compactor-WKFNTUXL.js +0 -32
  108. package/dist/dynamic-context-ZVE733UI.js +0 -28
  109. package/dist/http-client-ROVNSHF6.js +0 -11
  110. package/dist/launch-5ARSU7EM.js +0 -53
  111. package/dist/orchestrator-E6GIZGEN.js +0 -64
  112. package/dist/server-MUJ7EHEI.js +0 -56
  113. package/dist/service-INQWTYY2.js +0 -27
@@ -0,0 +1,394 @@
1
+ import {
2
+ getAllInstructions,
3
+ getEnabledSkillMetadata
4
+ } from "./chunk-BKMWZTNO.js";
5
+ import {
6
+ buildTopLevelSystemPrompt
7
+ } from "./chunk-7JVBDBXE.js";
8
+ import {
9
+ getCurrentContextWindowId,
10
+ getEventStore
11
+ } from "./chunk-FGNJMKDV.js";
12
+ import {
13
+ findAgentById,
14
+ getRuntimeConfig,
15
+ getSubAgents,
16
+ loadAllAgentsDefault,
17
+ resolveDefaultAgentId
18
+ } from "./chunk-ELYHHEYL.js";
19
+ import {
20
+ logger
21
+ } from "./chunk-K44MW7JJ.js";
22
+ import {
23
+ getGlobalConfigDir
24
+ } from "./chunk-CQGTEGKL.js";
25
+
26
+ // src/server/chat/dynamic-context.ts
27
+ import { createHash, randomUUID } from "crypto";
28
+ function computeUnifiedDiff(oldText, newText) {
29
+ const oldLines = oldText.length === 0 ? [] : oldText.split("\n");
30
+ const newLines = newText.length === 0 ? [] : newText.split("\n");
31
+ const result = [];
32
+ if (oldText === newText) {
33
+ return oldLines.map((line) => ({ type: "unchanged", content: line }));
34
+ }
35
+ const lcs = /* @__PURE__ */ new Map();
36
+ for (let i2 = 0; i2 <= oldLines.length; i2++) {
37
+ lcs.set(i2, /* @__PURE__ */ new Map());
38
+ for (let j2 = 0; j2 <= newLines.length; j2++) {
39
+ lcs.get(i2).set(j2, 0);
40
+ }
41
+ }
42
+ for (let i2 = 1; i2 <= oldLines.length; i2++) {
43
+ for (let j2 = 1; j2 <= newLines.length; j2++) {
44
+ const oldLine = oldLines[i2 - 1];
45
+ const newLine = newLines[j2 - 1];
46
+ if (oldLine === newLine) {
47
+ lcs.get(i2).set(j2, (lcs.get(i2 - 1).get(j2 - 1) ?? 0) + 1);
48
+ } else {
49
+ const up = lcs.get(i2 - 1).get(j2) ?? 0;
50
+ const left = lcs.get(i2).get(j2 - 1) ?? 0;
51
+ lcs.get(i2).set(j2, Math.max(up, left));
52
+ }
53
+ }
54
+ }
55
+ let i = oldLines.length;
56
+ let j = newLines.length;
57
+ while (i > 0 || j > 0) {
58
+ const oldLine = oldLines[i - 1] ?? "";
59
+ const newLine = newLines[j - 1] ?? "";
60
+ if (i > 0 && j > 0 && oldLine === newLine) {
61
+ result.unshift({ type: "unchanged", content: oldLine });
62
+ i--;
63
+ j--;
64
+ } else if (i > 0 && j > 0) {
65
+ const lcsIM1J = lcs.get(i - 1)?.get(j) ?? 0;
66
+ const lcsIJM1 = lcs.get(i)?.get(j - 1) ?? 0;
67
+ if (lcsIM1J > lcsIJM1) {
68
+ result.unshift({ type: "removed", content: oldLine });
69
+ i--;
70
+ } else {
71
+ result.unshift({ type: "added", content: newLine });
72
+ j--;
73
+ }
74
+ } else if (i > 0) {
75
+ result.unshift({ type: "removed", content: oldLine });
76
+ i--;
77
+ } else {
78
+ result.unshift({ type: "added", content: newLine });
79
+ j--;
80
+ }
81
+ }
82
+ return result;
83
+ }
84
+ function computeDynamicContextHash(instructionContent, skills, toolFingerprint, modelName) {
85
+ const dynamicInputs = JSON.stringify({
86
+ instructions: instructionContent,
87
+ skills: skills.map((s) => s.id).sort(),
88
+ ...toolFingerprint ? { tools: toolFingerprint } : {},
89
+ ...modelName ? { model: modelName } : {}
90
+ });
91
+ return createHash("sha256").update(dynamicInputs).digest("hex");
92
+ }
93
+ function getToolFingerprint(tools) {
94
+ return tools.map((t) => `${t.function.name}:${JSON.stringify(t.function.parameters)}`).sort().join("|");
95
+ }
96
+ function getToolSetFingerprint(tools) {
97
+ return tools.map(getToolSignature).sort().join("|");
98
+ }
99
+ function computeToolDiff(oldTools, newTools) {
100
+ const oldNames = oldTools.map((t) => t.function.name).sort();
101
+ const newNames = newTools.map((t) => t.function.name).sort();
102
+ const oldSet = new Set(oldNames);
103
+ const newSet = new Set(newNames);
104
+ const result = [];
105
+ for (const name of oldNames) {
106
+ if (!newSet.has(name)) result.push({ type: "removed", content: name });
107
+ }
108
+ for (const name of newNames) {
109
+ if (!oldSet.has(name)) result.push({ type: "added", content: name });
110
+ }
111
+ return result;
112
+ }
113
+ function computePreviewToolDiff(oldCachedTools, unfilteredTools, newTools) {
114
+ const baseline = oldCachedTools && oldCachedTools.length > 0 ? oldCachedTools : unfilteredTools;
115
+ return computeToolDiff(baseline, newTools);
116
+ }
117
+ var MAX_TOOL_SCHEMA_LINES = 120;
118
+ function getToolSignature(tool) {
119
+ const fn = tool.function;
120
+ return `${fn.name}:${fn.description ?? ""}:${JSON.stringify(fn.parameters)}`;
121
+ }
122
+ function detectToolChanges(liveTools, cachedTools) {
123
+ const liveByName = new Map(liveTools.map((t) => [t.function.name, t]));
124
+ const cachedByName = new Map(cachedTools.map((t) => [t.function.name, t]));
125
+ const added = [];
126
+ const removed = [];
127
+ const changed = [];
128
+ for (const name of liveByName.keys()) {
129
+ const liveTool = liveByName.get(name);
130
+ const cachedTool = cachedByName.get(name);
131
+ if (!cachedTool) {
132
+ added.push({ name, tool: liveTool });
133
+ } else if (getToolSignature(liveTool) !== getToolSignature(cachedTool)) {
134
+ changed.push({ name, tool: liveTool });
135
+ }
136
+ }
137
+ for (const name of cachedByName.keys()) {
138
+ if (!liveByName.has(name)) removed.push(name);
139
+ }
140
+ added.sort((a, b) => a.name.localeCompare(b.name));
141
+ removed.sort();
142
+ changed.sort((a, b) => a.name.localeCompare(b.name));
143
+ return { added, removed, changed };
144
+ }
145
+ function hasToolChanges(changes) {
146
+ return changes.added.length > 0 || changes.removed.length > 0 || changes.changed.length > 0;
147
+ }
148
+ function formatToolDefinition(entry) {
149
+ const json = JSON.stringify(entry.tool, null, 2);
150
+ const lines = json.split("\n");
151
+ if (lines.length <= MAX_TOOL_SCHEMA_LINES) return `### ${entry.name}
152
+ ${json}`;
153
+ const visible = lines.slice(0, MAX_TOOL_SCHEMA_LINES);
154
+ const omitted = lines.length - visible.length;
155
+ return `### ${entry.name}
156
+ ${visible.join("\n")}
157
+ \u2026 ${omitted} more lines omitted`;
158
+ }
159
+ function renderToolChangeReminder(changes) {
160
+ if (!hasToolChanges(changes)) return null;
161
+ const sections = [];
162
+ if (changes.added.length > 0) {
163
+ sections.push(`Added:
164
+ ${changes.added.map(formatToolDefinition).join("\n")}`);
165
+ }
166
+ if (changes.removed.length > 0) {
167
+ sections.push(`Removed:
168
+ ${changes.removed.join("\n")}`);
169
+ }
170
+ if (changes.changed.length > 0) {
171
+ sections.push(`Changed:
172
+ ${changes.changed.map(formatToolDefinition).join("\n")}`);
173
+ }
174
+ return `<system-reminder>
175
+ The available tools have changed since your last turn. The definitions below are the exact tool schemas now available:
176
+ ${sections.join(
177
+ "\n"
178
+ )}
179
+ </system-reminder>`;
180
+ }
181
+ var MAX_PROMPT_DIFF_LINES = 40;
182
+ var MAX_PROMPT_DIFF_LINE_LENGTH = 200;
183
+ function renderSystemPromptDiff(oldPrompt, newPrompt) {
184
+ const diff = computeUnifiedDiff(oldPrompt, newPrompt);
185
+ const changedLines = diff.filter((line) => line.type !== "unchanged");
186
+ if (changedLines.length === 0) return null;
187
+ const visible = changedLines.slice(0, MAX_PROMPT_DIFF_LINES);
188
+ const lines = visible.map((line) => {
189
+ const marker = line.type === "added" ? "+" : "-";
190
+ const content = line.content.length > MAX_PROMPT_DIFF_LINE_LENGTH ? line.content.slice(0, MAX_PROMPT_DIFF_LINE_LENGTH) + "\u2026" : line.content;
191
+ return `${marker} ${content}`;
192
+ });
193
+ const omitted = changedLines.length - visible.length;
194
+ if (omitted > 0) {
195
+ lines.push(`\u2026 ${omitted} more line${omitted === 1 ? "" : "s"} omitted`);
196
+ }
197
+ return `<system-reminder>
198
+ Your system prompt has changed:
199
+ ${lines.join("\n")}
200
+ </system-reminder>`;
201
+ }
202
+ function injectSystemReminder(sessionId, append, content, type, name) {
203
+ const currentWindowId = getCurrentContextWindowId(sessionId);
204
+ const reminderMsgId = randomUUID();
205
+ append({
206
+ type: "message.start",
207
+ data: {
208
+ messageId: reminderMsgId,
209
+ role: "user",
210
+ content,
211
+ ...currentWindowId ? { contextWindowId: currentWindowId } : {},
212
+ isSystemGenerated: true,
213
+ messageKind: "auto-prompt",
214
+ metadata: { type, name, color: "#6b7280", kind: "reminder" }
215
+ }
216
+ });
217
+ append({
218
+ type: "message.done",
219
+ data: { messageId: reminderMsgId }
220
+ });
221
+ }
222
+ async function injectDriftReminders(sessionManager, sessionId, agentDef, options, append) {
223
+ const cached = sessionManager.getCachedPrompt(sessionId);
224
+ if (!cached) {
225
+ return { injectedToolReminder: false, injectedPromptReminder: false };
226
+ }
227
+ const { getToolRegistryForAgent } = await import("./tools-6BDT5YMT.js");
228
+ const liveTools = getToolRegistryForAgent(agentDef, sessionId).definitions;
229
+ let injectedToolReminder = false;
230
+ let injectedPromptReminder = false;
231
+ const liveToolFingerprint = getToolSetFingerprint(liveTools);
232
+ const announcedToolFingerprint = sessionManager.getAnnouncedToolFingerprint(sessionId) ?? getToolSetFingerprint(cached.tools);
233
+ if (announcedToolFingerprint !== liveToolFingerprint) {
234
+ const changes = detectToolChanges(liveTools, cached.tools);
235
+ if (hasToolChanges(changes)) {
236
+ const reminder = renderToolChangeReminder(changes);
237
+ if (reminder) {
238
+ injectSystemReminder(sessionId, append, reminder, "tools", "Tools");
239
+ injectedToolReminder = true;
240
+ }
241
+ sessionManager.setDynamicContextChanged(sessionId, true);
242
+ }
243
+ sessionManager.setAnnouncedToolFingerprint(sessionId, liveToolFingerprint);
244
+ }
245
+ const livePromptHash = computeDynamicContextHash(
246
+ options.instructionContent,
247
+ options.skills,
248
+ void 0,
249
+ options.modelName
250
+ );
251
+ const announcedPromptHash = sessionManager.getAnnouncedPromptHash(sessionId) ?? cached.promptHash ?? cached.hash;
252
+ if (announcedPromptHash !== livePromptHash) {
253
+ const reminder = renderSystemPromptDiff(cached.systemPrompt, options.buildNewSystemPrompt());
254
+ if (reminder) {
255
+ injectSystemReminder(sessionId, append, reminder, "system-prompt", "System Prompt");
256
+ injectedPromptReminder = true;
257
+ }
258
+ sessionManager.setAnnouncedPromptHash(sessionId, livePromptHash);
259
+ }
260
+ return { injectedToolReminder, injectedPromptReminder };
261
+ }
262
+ async function checkToolChangesAndInject(sessionManager, sessionId, agentDef, options, append) {
263
+ return injectDriftReminders(sessionManager, sessionId, agentDef, options, append);
264
+ }
265
+ function createEventStoreAppend(sessionId) {
266
+ return (event) => {
267
+ try {
268
+ getEventStore().append(sessionId, event);
269
+ } catch {
270
+ }
271
+ };
272
+ }
273
+ function resolveConcreteModelName(sessionManager, sessionId, agentId) {
274
+ const effective = sessionManager.resolveEffectiveProviderModel(sessionId, agentId);
275
+ if (effective.providerId && effective.model) {
276
+ const pm = sessionManager.getProviderManager();
277
+ const resolvedModel = pm.resolveModel(effective.providerId, effective.model);
278
+ const effectiveModel = resolvedModel ?? effective.model;
279
+ const client = pm.createClient(effective.providerId, effectiveModel, effective.reasoningEffort);
280
+ if (client) return client.getModel();
281
+ }
282
+ return sessionManager.getProviderManager().getCurrentModel() ?? "";
283
+ }
284
+ async function injectContextDriftReminders(sessionManager, sessionId, append) {
285
+ try {
286
+ const allAgents = await loadAllAgentsDefault(sessionManager.getProjectWorkdir(sessionId));
287
+ const session = sessionManager.requireSession(sessionId);
288
+ const agentDef = findAgentById(session.mode, allAgents) ?? findAgentById(resolveDefaultAgentId(), allAgents);
289
+ const { instructionContent, skills } = await loadSessionContext(sessionManager, sessionId);
290
+ const subAgentDefs = getSubAgents(allAgents);
291
+ const modelName = resolveConcreteModelName(sessionManager, sessionId, agentDef.metadata.id);
292
+ return await injectDriftReminders(
293
+ sessionManager,
294
+ sessionId,
295
+ agentDef,
296
+ {
297
+ modelName,
298
+ instructionContent: instructionContent ?? "",
299
+ skills,
300
+ buildNewSystemPrompt: () => buildTopLevelSystemPrompt(session.workdir, instructionContent || void 0, skills, subAgentDefs, modelName)
301
+ },
302
+ append ?? createEventStoreAppend(sessionId)
303
+ );
304
+ } catch (error) {
305
+ logger.warn("injectContextDriftReminders failed", {
306
+ sessionId,
307
+ error: error instanceof Error ? error.message : String(error)
308
+ });
309
+ return { injectedToolReminder: false, injectedPromptReminder: false };
310
+ }
311
+ }
312
+ async function injectContextDriftRemindersForSessions(sessionManager, sessionIds) {
313
+ for (const sessionId of sessionIds) {
314
+ await injectContextDriftReminders(sessionManager, sessionId);
315
+ }
316
+ }
317
+ async function loadSessionContext(sessionManager, sessionId) {
318
+ const session = sessionManager.requireSession(sessionId);
319
+ const { content: instructionContent } = await getAllInstructions(session.workdir, session.projectId);
320
+ const runtimeConfig = getRuntimeConfig();
321
+ const configDir = getGlobalConfigDir(runtimeConfig.mode ?? "production");
322
+ const skills = await getEnabledSkillMetadata(configDir, sessionManager.getProjectWorkdir(sessionId));
323
+ return { instructionContent: instructionContent ?? "", skills };
324
+ }
325
+ function resolveAgentDef(sessionManager, sessionId) {
326
+ return loadAllAgentsDefault(sessionManager.getProjectWorkdir(sessionId)).then((allAgents) => {
327
+ const session = sessionManager.requireSession(sessionId);
328
+ return findAgentById(session.mode, allAgents) ?? findAgentById(resolveDefaultAgentId(), allAgents);
329
+ });
330
+ }
331
+ async function buildCachedPrompt(sessionManager, sessionId, agentDef, modelName) {
332
+ const { instructionContent, skills } = await loadSessionContext(sessionManager, sessionId);
333
+ const { getToolRegistryForAgent } = await import("./tools-6BDT5YMT.js");
334
+ const tools = getToolRegistryForAgent(agentDef, sessionId).definitions;
335
+ const toolFingerprint = getToolFingerprint(tools);
336
+ const allAgents = await loadAllAgentsDefault(sessionManager.getProjectWorkdir(sessionId));
337
+ const subAgentDefs = getSubAgents(allAgents);
338
+ const session = sessionManager.requireSession(sessionId);
339
+ const systemPrompt = buildTopLevelSystemPrompt(
340
+ session.workdir,
341
+ instructionContent || void 0,
342
+ skills,
343
+ subAgentDefs,
344
+ modelName
345
+ );
346
+ const hash = computeDynamicContextHash(instructionContent, skills, toolFingerprint, modelName);
347
+ const promptHash = computeDynamicContextHash(instructionContent, skills, void 0, modelName);
348
+ return { systemPrompt, tools, hash, promptHash };
349
+ }
350
+ async function computeSessionHash(sessionManager, sessionId, modelName) {
351
+ const { instructionContent, skills } = await loadSessionContext(sessionManager, sessionId);
352
+ const agentDef = await resolveAgentDef(sessionManager, sessionId);
353
+ const { getToolRegistryForAgent } = await import("./tools-6BDT5YMT.js");
354
+ const tools = getToolRegistryForAgent(agentDef, sessionId).definitions;
355
+ const toolFingerprint = getToolFingerprint(tools);
356
+ return computeDynamicContextHash(instructionContent, skills, toolFingerprint, modelName);
357
+ }
358
+ async function applyDynamicContext(sessionManager, sessionId, modelName) {
359
+ const session = sessionManager.requireSession(sessionId);
360
+ const allAgents = await loadAllAgentsDefault(sessionManager.getProjectWorkdir(sessionId));
361
+ const agentDef = findAgentById(session.mode, allAgents) ?? findAgentById(resolveDefaultAgentId(), allAgents);
362
+ const { systemPrompt, tools, hash, promptHash } = await buildCachedPrompt(
363
+ sessionManager,
364
+ sessionId,
365
+ agentDef,
366
+ modelName
367
+ );
368
+ sessionManager.setCachedPrompt(sessionId, systemPrompt, tools, hash, promptHash);
369
+ sessionManager.setAnnouncedPromptHash(sessionId, promptHash);
370
+ sessionManager.setAnnouncedToolFingerprint(sessionId, getToolSetFingerprint(tools));
371
+ sessionManager.setDynamicContextChanged(sessionId, false);
372
+ sessionManager.clearDebugDump(sessionId);
373
+ logger.debug("applyDynamicContext done", { sessionId, hash, toolCount: tools.length });
374
+ }
375
+
376
+ export {
377
+ computeUnifiedDiff,
378
+ computeDynamicContextHash,
379
+ getToolFingerprint,
380
+ getToolSetFingerprint,
381
+ computeToolDiff,
382
+ computePreviewToolDiff,
383
+ getToolSignature,
384
+ detectToolChanges,
385
+ renderToolChangeReminder,
386
+ renderSystemPromptDiff,
387
+ checkToolChangesAndInject,
388
+ injectContextDriftReminders,
389
+ injectContextDriftRemindersForSessions,
390
+ buildCachedPrompt,
391
+ computeSessionHash,
392
+ applyDynamicContext
393
+ };
394
+ //# sourceMappingURL=chunk-SVALN5KE.js.map
@@ -1,5 +1,3 @@
1
- import "./chunk-YLJ4XMA6.js";
2
-
3
1
  // src/server/routes/session-status.ts
4
2
  var SESSION_STATUS_SCHEMA_VERSION = 1;
5
3
  function projectSessionStatus(inputs) {
@@ -28,8 +26,9 @@ function projectSessionStatus(inputs) {
28
26
  }
29
27
  };
30
28
  }
29
+
31
30
  export {
32
31
  SESSION_STATUS_SCHEMA_VERSION,
33
32
  projectSessionStatus
34
33
  };
35
- //# sourceMappingURL=session-status-6Q5B5PEN.js.map
34
+ //# sourceMappingURL=chunk-T3S5MTMD.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  updateSessionMcpDisabledServers
3
- } from "./chunk-AQBRI7TM.js";
3
+ } from "./chunk-KWAHD2JA.js";
4
4
  import {
5
5
  getDatabase
6
- } from "./chunk-OYBUJIC3.js";
6
+ } from "./chunk-JU757HVI.js";
7
7
 
8
8
  // src/server/mcp/session-overrides.ts
9
9
  var sessionOverrides = /* @__PURE__ */ new Map();
@@ -62,4 +62,4 @@ export {
62
62
  clearSessionOverrides,
63
63
  getAllSessionOverrides
64
64
  };
65
- //# sourceMappingURL=chunk-7YP4O4XE.js.map
65
+ //# sourceMappingURL=chunk-TACWRDDC.js.map
@@ -157,6 +157,23 @@ var MODEL_PROFILES = [
157
157
  supportsVision: false
158
158
  }
159
159
  },
160
+ {
161
+ pattern: "gpt-5",
162
+ profile: {
163
+ name: "GPT-5",
164
+ // OpenAI's gpt-5 family only accepts temperature = 1 (and top_p = 1);
165
+ // any other value is rejected with a 400.
166
+ temperature: 1,
167
+ topP: 1,
168
+ defaultMaxTokens: 16384,
169
+ supportsVision: true,
170
+ // gpt-5 is a Responses-API family: /v1/chat/completions rejects tools
171
+ // with any reasoning_effort other than "none", while /v1/responses
172
+ // supports tools + effort together. Route it there on the openai
173
+ // backend; on chat completions the request builder clamps the effort.
174
+ apiProtocol: "responses"
175
+ }
176
+ },
160
177
  {
161
178
  pattern: "gemma-4",
162
179
  profile: {
@@ -188,4 +205,4 @@ export {
188
205
  getModelProfile,
189
206
  modelSupportsVision
190
207
  };
191
- //# sourceMappingURL=chunk-7ZMOP5LS.js.map
208
+ //# sourceMappingURL=chunk-TS5WKTFB.js.map
@@ -4,60 +4,81 @@ var BACKEND_CAPABILITIES = {
4
4
  supportsChatTemplateKwargs: true,
5
5
  supportsTopK: true,
6
6
  supportsNumCtx: false,
7
- routesEffortViaChatTemplateKwargs: false
7
+ routesEffortViaChatTemplateKwargs: false,
8
+ usesMaxCompletionTokens: false
8
9
  },
9
10
  sglang: {
10
11
  supportsChatTemplateKwargs: true,
11
12
  supportsTopK: true,
12
13
  supportsNumCtx: false,
13
- routesEffortViaChatTemplateKwargs: false
14
+ routesEffortViaChatTemplateKwargs: false,
15
+ usesMaxCompletionTokens: false
14
16
  },
15
17
  openai: {
16
18
  supportsChatTemplateKwargs: false,
17
19
  supportsTopK: false,
18
20
  supportsNumCtx: false,
19
- routesEffortViaChatTemplateKwargs: false
21
+ routesEffortViaChatTemplateKwargs: false,
22
+ usesMaxCompletionTokens: true
20
23
  },
21
24
  anthropic: {
22
25
  supportsChatTemplateKwargs: false,
23
26
  supportsTopK: false,
24
27
  supportsNumCtx: false,
25
- routesEffortViaChatTemplateKwargs: false
28
+ routesEffortViaChatTemplateKwargs: false,
29
+ usesMaxCompletionTokens: false
26
30
  },
27
31
  ollama: {
28
32
  supportsChatTemplateKwargs: false,
29
33
  supportsTopK: false,
30
34
  supportsNumCtx: true,
31
- routesEffortViaChatTemplateKwargs: false
35
+ routesEffortViaChatTemplateKwargs: false,
36
+ usesMaxCompletionTokens: false
32
37
  },
33
38
  llamacpp: {
34
39
  supportsChatTemplateKwargs: false,
35
40
  supportsTopK: true,
36
41
  supportsNumCtx: false,
37
- routesEffortViaChatTemplateKwargs: true
42
+ routesEffortViaChatTemplateKwargs: true,
43
+ usesMaxCompletionTokens: false
38
44
  },
39
45
  lmstudio: {
40
46
  supportsChatTemplateKwargs: false,
41
47
  supportsTopK: true,
42
48
  supportsNumCtx: false,
43
- routesEffortViaChatTemplateKwargs: false
49
+ routesEffortViaChatTemplateKwargs: false,
50
+ usesMaxCompletionTokens: false
44
51
  },
45
52
  "opencode-go": {
46
53
  supportsChatTemplateKwargs: false,
47
54
  supportsTopK: true,
48
55
  supportsNumCtx: false,
49
- routesEffortViaChatTemplateKwargs: false
56
+ routesEffortViaChatTemplateKwargs: false,
57
+ usesMaxCompletionTokens: false
50
58
  },
51
59
  unknown: {
52
60
  supportsChatTemplateKwargs: true,
53
61
  supportsTopK: true,
54
62
  supportsNumCtx: false,
55
- routesEffortViaChatTemplateKwargs: false
63
+ routesEffortViaChatTemplateKwargs: false,
64
+ usesMaxCompletionTokens: false
56
65
  }
57
66
  };
58
67
  function getBackendCapabilities(backend) {
59
68
  return BACKEND_CAPABILITIES[backend];
60
69
  }
70
+ var HOST_BACKEND_MAP = {
71
+ "api.openai.com": "openai",
72
+ "api.anthropic.com": "anthropic"
73
+ };
74
+ function detectBackendFromUrl(url) {
75
+ try {
76
+ const host = new URL(url).hostname.toLowerCase();
77
+ return HOST_BACKEND_MAP[host];
78
+ } catch {
79
+ return void 0;
80
+ }
81
+ }
61
82
  function getBackendDisplayName(backend) {
62
83
  switch (backend) {
63
84
  case "vllm":
@@ -83,6 +104,7 @@ function getBackendDisplayName(backend) {
83
104
 
84
105
  export {
85
106
  getBackendCapabilities,
107
+ detectBackendFromUrl,
86
108
  getBackendDisplayName
87
109
  };
88
- //# sourceMappingURL=chunk-PBFGJFGC.js.map
110
+ //# sourceMappingURL=chunk-UV6IH6HK.js.map
@@ -4,42 +4,45 @@ import {
4
4
  getToolRegistryForAgent,
5
5
  processEventsForConversation,
6
6
  runTopLevelAgentLoop
7
- } from "./chunk-L24A6GZ7.js";
7
+ } from "./chunk-5AI3LHRQ.js";
8
+ import {
9
+ TurnMetrics,
10
+ createChatDoneEvent,
11
+ createMessageStartEvent
12
+ } from "./chunk-7ET46SNE.js";
8
13
  import {
9
14
  buildCachedPrompt,
15
+ checkToolChangesAndInject,
10
16
  computeDynamicContextHash,
11
17
  getToolFingerprint
12
- } from "./chunk-PHP7PLFX.js";
18
+ } from "./chunk-SVALN5KE.js";
13
19
  import {
14
20
  getAllInstructions,
15
21
  getEnabledSkillMetadata
16
- } from "./chunk-ZIL6VKLU.js";
17
- import {
18
- TurnMetrics,
19
- createChatDoneEvent,
20
- createMessageStartEvent
21
- } from "./chunk-6LX43YRA.js";
22
+ } from "./chunk-BKMWZTNO.js";
22
23
  import {
23
24
  buildAgentReminder,
24
- buildAgentSmallReminder
25
- } from "./chunk-GIJUWPRQ.js";
25
+ buildAgentSmallReminder,
26
+ buildTopLevelSystemPrompt
27
+ } from "./chunk-7JVBDBXE.js";
26
28
  import {
27
29
  PathAccessDeniedError
28
- } from "./chunk-26WS7AH6.js";
30
+ } from "./chunk-Y6ZGHOKM.js";
29
31
  import {
30
32
  getCurrentContextWindowId,
31
33
  getCurrentWindowMessageOptions,
32
34
  getEventStore
33
- } from "./chunk-YJD5A375.js";
35
+ } from "./chunk-FGNJMKDV.js";
34
36
  import {
35
37
  buildSnapshotFromSessionState
36
- } from "./chunk-ZIYETXOW.js";
38
+ } from "./chunk-M5T4RDPJ.js";
37
39
  import {
38
40
  findAgentById,
39
41
  getRuntimeConfig,
42
+ getSubAgents,
40
43
  loadAllAgentsDefault,
41
44
  resolveDefaultAgentId
42
- } from "./chunk-KBESUA3W.js";
45
+ } from "./chunk-ELYHHEYL.js";
43
46
  import {
44
47
  logger
45
48
  } from "./chunk-K44MW7JJ.js";
@@ -49,7 +52,7 @@ import {
49
52
 
50
53
  // src/server/chat/orchestrator.ts
51
54
  async function buildRetryPatterns() {
52
- const { getSetting, SETTINGS_KEYS } = await import("./settings-VOWWO4VG.js");
55
+ const { getSetting, SETTINGS_KEYS } = await import("./settings-MDCRNQBY.js");
53
56
  const raw = getSetting(SETTINGS_KEYS.RETRY_PATTERNS);
54
57
  if (!raw) {
55
58
  const oldXmlProtection = getSetting("llm.disableXmlProtection");
@@ -244,6 +247,27 @@ async function runAgentTurn(options, turnMetrics, agentId, append, callbacks) {
244
247
  const runtimeConfig = getRuntimeConfig();
245
248
  const configDir = getGlobalConfigDir(runtimeConfig.mode ?? "production");
246
249
  const skills = await getEnabledSkillMetadata(configDir, options.sessionManager.getProjectWorkdir(options.sessionId));
250
+ if (!options.warmup) {
251
+ const modelName = agentLlmClient.getModel();
252
+ await checkToolChangesAndInject(
253
+ options.sessionManager,
254
+ options.sessionId,
255
+ agentDef,
256
+ {
257
+ modelName,
258
+ instructionContent: instructionContent ?? "",
259
+ skills,
260
+ buildNewSystemPrompt: () => buildTopLevelSystemPrompt(
261
+ session.workdir,
262
+ instructionContent || void 0,
263
+ skills,
264
+ getSubAgents(allAgents),
265
+ modelName
266
+ )
267
+ },
268
+ append
269
+ );
270
+ }
247
271
  return runTopLevelAgentLoop(
248
272
  {
249
273
  mode: agentId,
@@ -290,7 +314,14 @@ async function runAgentTurn(options, turnMetrics, agentId, append, callbacks) {
290
314
  agentDef,
291
315
  agentLlmClient.getModel()
292
316
  );
293
- options.sessionManager.setCachedPrompt(options.sessionId, result.systemPrompt, result.tools, result.hash);
317
+ options.sessionManager.setCachedPrompt(
318
+ options.sessionId,
319
+ result.systemPrompt,
320
+ result.tools,
321
+ result.hash,
322
+ result.promptHash
323
+ );
324
+ options.sessionManager.setAnnouncedPromptHash(options.sessionId, result.promptHash);
294
325
  return createAssemblyResult({
295
326
  systemPrompt: result.systemPrompt,
296
327
  messages: input.messages,
@@ -302,6 +333,10 @@ async function runAgentTurn(options, turnMetrics, agentId, append, callbacks) {
302
333
  getToolRegistry: () => getToolRegistryForAgent(agentDef, options.sessionId),
303
334
  getConversationMessages: buildGetConversationMessages(options.sessionId, resolveAgentClient, append),
304
335
  injectAgentReminder: () => injectAgentReminder(options.sessionId, agentDef),
336
+ rebuildCachedContext: async () => {
337
+ const { applyDynamicContext } = await import("./dynamic-context-Y555VDLA.js");
338
+ await applyDynamicContext(options.sessionManager, options.sessionId, agentLlmClient.getModel());
339
+ },
305
340
  ...options.initialCompacting ? { initialCompacting: true } : {},
306
341
  ...callbacks?.injectKickoff ? { injectKickoff: callbacks.injectKickoff } : {},
307
342
  ...callbacks?.onToolExecuted ? { onToolExecuted: callbacks.onToolExecuted } : {},
@@ -329,4 +364,4 @@ export {
329
364
  runChatTurn,
330
365
  runAgentTurn
331
366
  };
332
- //# sourceMappingURL=chunk-7RIEI2TE.js.map
367
+ //# sourceMappingURL=chunk-WCM5ZW5N.js.map