openfox 2.0.0-beta.5 → 2.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/{chat-handler-BM6EBFKS.js → chat-handler-XIAY7O5X.js} +14 -27
  2. package/dist/{chunk-NNEHZT3V.js → chunk-2ZS2B5HW.js} +11 -3
  3. package/dist/{chunk-HGAMIPFO.js → chunk-7FDY3EOH.js} +18 -176
  4. package/dist/{chunk-V6DYJV5R.js → chunk-7TTEGAO6.js} +12 -10
  5. package/dist/{chunk-T4HV6GS5.js → chunk-BVHFMAVN.js} +1 -1
  6. package/dist/{chunk-OBD6D5ZO.js → chunk-CDDMHSZF.js} +4 -4
  7. package/dist/{chunk-X36JIWSF.js → chunk-DFITQ75T.js} +135 -147
  8. package/dist/{chunk-HHAJ3QF6.js → chunk-EMJGF3A7.js} +9 -24
  9. package/dist/{chunk-RF2JGDSS.js → chunk-IGSZUXQP.js} +3 -3
  10. package/dist/{chunk-I67T2E5K.js → chunk-KAYUPVHQ.js} +6 -6
  11. package/dist/{chunk-CLGRPDZT.js → chunk-LN22TXNK.js} +196 -91
  12. package/dist/{chunk-UH27FDT7.js → chunk-NPHYEUYE.js} +124 -12
  13. package/dist/{chunk-DFWGWULB.js → chunk-QN5ST54E.js} +2935 -3127
  14. package/dist/{chunk-PSJIT5LZ.js → chunk-RFNEDBVO.js} +4 -4
  15. package/dist/chunk-RI6GAMNP.js +13 -0
  16. package/dist/{chunk-XL7SW5B4.js → chunk-XJEOP6XU.js} +5 -4
  17. package/dist/cli/dev.js +1 -1
  18. package/dist/cli/index.js +1 -1
  19. package/dist/compactor-TDNRM3A7.js +9 -0
  20. package/dist/{config-YU7NYZYG.js → config-QUT7YZQ7.js} +9 -8
  21. package/dist/{events-T37KTNCX.js → events-PQ3KTI5H.js} +8 -7
  22. package/dist/{folding-IIKWAGG2.js → folding-CXORTBAU.js} +2 -2
  23. package/dist/{orchestrator-JTUHXF7C.js → orchestrator-GAOENX5Q.js} +18 -22
  24. package/dist/package.json +1 -1
  25. package/dist/{processor-66YBBQ6B.js → processor-6VIYGURD.js} +8 -9
  26. package/dist/{protocol-CiYlonA5.d.ts → protocol-CDOV1pyc.d.ts} +11 -0
  27. package/dist/{protocol-ALBHLBBF.js → protocol-CN24IKQN.js} +3 -5
  28. package/dist/{provider-HTJEB3ON.js → provider-4T6BVPMD.js} +25 -10
  29. package/dist/{serve-EUEQ6ERI.js → serve-W3ETJJP3.js} +25 -26
  30. package/dist/server/index.d.ts +1 -6
  31. package/dist/server/index.js +15 -16
  32. package/dist/{settings-VRAOAPLA.js → settings-6XX56F3F.js} +2 -2
  33. package/dist/shared/index.d.ts +2 -2
  34. package/dist/shared/index.js +1 -1
  35. package/dist/{tools-56LACLKH.js → tools-SDXWIYSA.js} +11 -13
  36. package/dist/web/assets/index-Dm6t3VVB.js +299 -0
  37. package/dist/web/assets/{index-C5gaXnFj.css → index-aa3jRAZ9.css} +2 -2
  38. package/dist/web/index.html +2 -2
  39. package/dist/web/sw.js +1 -1
  40. package/dist/workflow-defaults/default.workflow.json +3 -3
  41. package/package.json +1 -1
  42. package/dist/auto-compaction-2ZAYDXGF.js +0 -27
  43. package/dist/chunk-CGZHLM3K.js +0 -70
  44. package/dist/chunk-SZKEGZIB.js +0 -140
  45. package/dist/runtime-config-NPSPMRDA.js +0 -9
  46. package/dist/vision-fallback-3MIZZ6NQ.js +0 -22
  47. package/dist/web/assets/index-DQ2Vv-Yl.js +0 -317
  48. /package/dist/web/{workbox-7fc22fbe.js → workbox-8c29f6e4.js} +0 -0
@@ -1,6 +1,3 @@
1
- import {
2
- getDatabase
3
- } from "./chunk-FBGWG4N6.js";
4
1
  import {
5
2
  buildContextMessagesFromEventHistory,
6
3
  buildMessagesFromStoredEvents,
@@ -8,10 +5,10 @@ import {
8
5
  foldContextState,
9
6
  foldSessionState,
10
7
  spreadOptionalMessageFields
11
- } from "./chunk-XL7SW5B4.js";
8
+ } from "./chunk-XJEOP6XU.js";
12
9
  import {
13
- getRuntimeConfig
14
- } from "./chunk-CGZHLM3K.js";
10
+ getDatabase
11
+ } from "./chunk-FBGWG4N6.js";
15
12
  import {
16
13
  logger
17
14
  } from "./chunk-K44MW7JJ.js";
@@ -104,6 +101,18 @@ var EventStore = class {
104
101
  CREATE INDEX IF NOT EXISTS idx_events_session_type
105
102
  ON events(session_id, event_type)
106
103
  `);
104
+ this.db.exec(`
105
+ CREATE TABLE IF NOT EXISTS tombstones (
106
+ session_id TEXT NOT NULL,
107
+ seq INTEGER NOT NULL,
108
+ timestamp INTEGER NOT NULL,
109
+ UNIQUE(session_id, seq)
110
+ )
111
+ `);
112
+ this.db.exec(`
113
+ CREATE INDEX IF NOT EXISTS idx_tombstones_session_seq
114
+ ON tombstones(session_id, seq)
115
+ `);
107
116
  }
108
117
  // --------------------------------------------------------------------------
109
118
  // Append
@@ -182,10 +191,41 @@ var EventStore = class {
182
191
  * Get all events for a session, optionally starting from a specific seq
183
192
  */
184
193
  getEvents(sessionId, fromSeq) {
185
- const query = fromSeq !== void 0 ? `SELECT * FROM events WHERE session_id = ? AND seq >= ? ORDER BY seq` : `SELECT * FROM events WHERE session_id = ? ORDER BY seq`;
194
+ const query = fromSeq !== void 0 ? `SELECT e.* FROM events e
195
+ LEFT JOIN tombstones t ON e.session_id = t.session_id AND e.seq = t.seq
196
+ WHERE e.session_id = ? AND e.seq >= ? AND t.seq IS NULL
197
+ ORDER BY e.seq` : `SELECT e.* FROM events e
198
+ LEFT JOIN tombstones t ON e.session_id = t.session_id AND e.seq = t.seq
199
+ WHERE e.session_id = ? AND t.seq IS NULL
200
+ ORDER BY e.seq`;
186
201
  const rows = fromSeq !== void 0 ? this.db.prepare(query).all(sessionId, fromSeq) : this.db.prepare(query).all(sessionId);
187
202
  return rows.map((row) => this.rowToStoredEvent(row));
188
203
  }
204
+ /**
205
+ * Soft-delete (tombstone) events by sequence number.
206
+ * Tombstoned events are hidden from getEvents but remain in the database.
207
+ *
208
+ * @param sessionId - The session ID
209
+ * @param seqs - Array of sequence numbers to tombstone
210
+ * @returns The number of events tombstoned
211
+ */
212
+ tombstoneEvents(sessionId, seqs) {
213
+ if (seqs.length === 0) return 0;
214
+ const timestamp = Date.now();
215
+ const insert = this.db.prepare(
216
+ `INSERT OR IGNORE INTO tombstones (session_id, seq, timestamp)
217
+ VALUES (?, ?, ?)`
218
+ );
219
+ let count = 0;
220
+ const transaction = this.db.transaction(() => {
221
+ for (const seq of seqs) {
222
+ const result = insert.run(sessionId, seq, timestamp);
223
+ count += result.changes;
224
+ }
225
+ });
226
+ transaction();
227
+ return count;
228
+ }
189
229
  /**
190
230
  * Get the latest sequence number for a session
191
231
  */
@@ -791,6 +831,70 @@ function mapSessionSummaryRow(row) {
791
831
  };
792
832
  }
793
833
 
834
+ // src/server/config.ts
835
+ import { z } from "zod";
836
+ var backendSchema = z.enum(["auto", "vllm", "sglang", "ollama", "llamacpp"]).default("auto");
837
+ var envSchema = z.object({
838
+ // New env var name, with fallback to old name for backward compatibility
839
+ OPENFOX_LLM_URL: z.string().url().optional(),
840
+ OPENFOX_VLLM_URL: z.string().url().optional(),
841
+ OPENFOX_BACKEND: backendSchema,
842
+ OPENFOX_MODEL_NAME: z.string().default("qwen3.5-122b-int4-autoround"),
843
+ OPENFOX_MAX_CONTEXT: z.coerce.number().default(2e5),
844
+ OPENFOX_PORT: z.coerce.number().default(10369),
845
+ OPENFOX_HOST: z.string().optional(),
846
+ OPENFOX_WORKDIR: z.string().optional(),
847
+ OPENFOX_DB_PATH: z.string().default("./openfox.db"),
848
+ OPENFOX_LOG_LEVEL: z.enum(["debug", "info", "warn", "error"]).default("info"),
849
+ OPENFOX_DISABLE_THINKING: z.coerce.boolean().default(false),
850
+ OPENFOX_DEV: z.coerce.boolean().default(false)
851
+ });
852
+ function loadConfig() {
853
+ const env = envSchema.parse(process.env);
854
+ const llmUrl = env.OPENFOX_LLM_URL ?? env.OPENFOX_VLLM_URL ?? "http://localhost:8000/v1";
855
+ const workdir = env.OPENFOX_WORKDIR ?? process.cwd();
856
+ return {
857
+ llm: {
858
+ baseUrl: llmUrl,
859
+ model: env.OPENFOX_MODEL_NAME,
860
+ timeout: 3e5,
861
+ // 5 minutes (deprecated, kept for backward compatibility)
862
+ idleTimeout: 3e5,
863
+ // 5 minutes of inactivity
864
+ backend: env.OPENFOX_BACKEND,
865
+ disableThinking: env.OPENFOX_DISABLE_THINKING
866
+ },
867
+ context: {
868
+ maxTokens: env.OPENFOX_MAX_CONTEXT,
869
+ compactionThreshold: 0.85,
870
+ compactionTarget: 0.6
871
+ },
872
+ agent: {
873
+ maxIterations: 10,
874
+ maxConsecutiveFailures: 3,
875
+ toolTimeout: 3e5
876
+ },
877
+ server: {
878
+ port: env.OPENFOX_PORT,
879
+ ...env.OPENFOX_HOST !== void 0 ? { host: env.OPENFOX_HOST } : {}
880
+ },
881
+ database: {
882
+ path: env.OPENFOX_DB_PATH
883
+ },
884
+ mode: env.OPENFOX_DEV ? "development" : "production",
885
+ workdir
886
+ };
887
+ }
888
+
889
+ // src/server/runtime-config.ts
890
+ var runtimeConfig = null;
891
+ function setRuntimeConfig(config) {
892
+ runtimeConfig = config;
893
+ }
894
+ function getRuntimeConfig() {
895
+ return runtimeConfig ?? loadConfig();
896
+ }
897
+
794
898
  // src/server/events/session.ts
795
899
  function toSnapshotMessage(message) {
796
900
  return {
@@ -873,6 +977,10 @@ function getCurrentContextWindowId(sessionId) {
873
977
  const contextResult = foldContextState(events, "");
874
978
  return contextResult.currentContextWindowId || void 0;
875
979
  }
980
+ function getCurrentWindowMessageOptions(sessionId) {
981
+ const contextWindowId = getCurrentContextWindowId(sessionId);
982
+ return contextWindowId ? { contextWindowId } : void 0;
983
+ }
876
984
  function getReadFilesCache(sessionId) {
877
985
  const state = getSessionState(sessionId);
878
986
  return state?.readFiles ?? [];
@@ -1097,11 +1205,11 @@ function emitChatError(sessionId, error, recoverable) {
1097
1205
  data: { error, recoverable }
1098
1206
  });
1099
1207
  }
1100
- function emitFormatRetry(sessionId, attempt, maxAttempts) {
1208
+ function emitPatternRetry(sessionId, messageId, pattern, field, attempt, maxAttempts, matchedContent) {
1101
1209
  const eventStore = getEventStore();
1102
1210
  eventStore.append(sessionId, {
1103
- type: "format.retry",
1104
- data: { attempt, maxAttempts }
1211
+ type: "pattern.retry",
1212
+ data: { messageId, pattern, field, attempt, maxAttempts, matchedContent }
1105
1213
  });
1106
1214
  }
1107
1215
  function emitTurnSnapshot(sessionId, snapshot) {
@@ -1227,10 +1335,14 @@ export {
1227
1335
  listSessions,
1228
1336
  listSessionsByProject,
1229
1337
  deleteSession,
1338
+ loadConfig,
1339
+ setRuntimeConfig,
1340
+ getRuntimeConfig,
1230
1341
  getSessionState,
1231
1342
  getCurrentWindowMessages,
1232
1343
  getContextMessages,
1233
1344
  getCurrentContextWindowId,
1345
+ getCurrentWindowMessageOptions,
1234
1346
  getReadFilesCache,
1235
1347
  isFileInCache,
1236
1348
  emitSessionInitialized,
@@ -1255,10 +1367,10 @@ export {
1255
1367
  emitContextState,
1256
1368
  emitChatDone,
1257
1369
  emitChatError,
1258
- emitFormatRetry,
1370
+ emitPatternRetry,
1259
1371
  emitTurnSnapshot,
1260
1372
  truncateSessionMessages,
1261
1373
  compactContext,
1262
1374
  getRecentUserPromptsForSession
1263
1375
  };
1264
- //# sourceMappingURL=chunk-UH27FDT7.js.map
1376
+ //# sourceMappingURL=chunk-NPHYEUYE.js.map