negotium 0.22.6 → 0.22.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 (70) hide show
  1. package/dist/agent-helpers.js +1349 -410
  2. package/dist/agent-helpers.js.map +7 -7
  3. package/dist/background-bash.js +12 -12
  4. package/dist/background-bash.js.map +2 -2
  5. package/dist/browser-runtime.js +81 -52
  6. package/dist/browser-runtime.js.map +4 -4
  7. package/dist/canonical-mcp-bridge.js +9 -8
  8. package/dist/canonical-mcp-bridge.js.map +1 -1
  9. package/dist/{chunk-e59kzyvy.js → chunk-1gznvrth.js} +5 -4
  10. package/dist/{chunk-e59kzyvy.js.map → chunk-1gznvrth.js.map} +2 -2
  11. package/dist/chunk-2mx7fq49.js +6 -0
  12. package/dist/{chunk-bnyvxss3.js.map → chunk-2mx7fq49.js.map} +1 -1
  13. package/dist/{chunk-1mba9m1j.js → chunk-9zn0bkc9.js} +116 -77
  14. package/dist/{chunk-1mba9m1j.js.map → chunk-9zn0bkc9.js.map} +2 -2
  15. package/dist/{chunk-ww8a4ej4.js → chunk-f7p0h1gs.js} +5 -5
  16. package/dist/{chunk-ww8a4ej4.js.map → chunk-f7p0h1gs.js.map} +2 -2
  17. package/dist/{chunk-9a50csg6.js → chunk-pr8p6pap.js} +125 -116
  18. package/dist/{chunk-9a50csg6.js.map → chunk-pr8p6pap.js.map} +7 -7
  19. package/dist/chunk-q5djsg78.js +200 -0
  20. package/dist/chunk-q5djsg78.js.map +9 -0
  21. package/dist/{chunk-1e0nxy7p.js → chunk-z4r7tt2p.js} +12 -12
  22. package/dist/{chunk-1e0nxy7p.js.map → chunk-z4r7tt2p.js.map} +2 -2
  23. package/dist/hosted-agent.js +128 -120
  24. package/dist/hosted-agent.js.map +4 -4
  25. package/dist/main.js +5174 -3278
  26. package/dist/main.js.map +9 -9
  27. package/dist/mcp-catalog.js +4 -4
  28. package/dist/mcp-catalog.js.map +1 -1
  29. package/dist/mcp-factories.js +1563 -632
  30. package/dist/mcp-factories.js.map +7 -7
  31. package/dist/mcp-servers.js +5 -5
  32. package/dist/mcp-servers.js.map +1 -1
  33. package/dist/media.js +3 -3
  34. package/dist/media.js.map +1 -1
  35. package/dist/outbox.js +15 -15
  36. package/dist/outbox.js.map +2 -2
  37. package/dist/platform-runtime.js +7 -7
  38. package/dist/platform-runtime.js.map +1 -1
  39. package/dist/prompts.js +6 -6
  40. package/dist/prompts.js.map +2 -2
  41. package/dist/query-runtime.js +18 -16
  42. package/dist/query-runtime.js.map +2 -2
  43. package/dist/registry.js +20 -19
  44. package/dist/registry.js.map +2 -2
  45. package/dist/rollout.js +41 -41
  46. package/dist/rollout.js.map +2 -2
  47. package/dist/runtime/src/platform/playwright/manager.ts +77 -15
  48. package/dist/runtime/src/storage/api-topics.ts +6 -0
  49. package/dist/runtime/src/storage/browser-profiles.ts +18 -0
  50. package/dist/runtime/src/topics/lifecycle.ts +2 -5
  51. package/dist/runtime/src/topics/update.ts +17 -0
  52. package/dist/runtime/src/types/api.ts +6 -0
  53. package/dist/runtime/src/version.ts +1 -1
  54. package/dist/runtime-gateway.js +12 -12
  55. package/dist/runtime-gateway.js.map +2 -2
  56. package/dist/runtime-helpers.js +54 -52
  57. package/dist/runtime-helpers.js.map +2 -2
  58. package/dist/sqlite.js +5 -3
  59. package/dist/sqlite.js.map +2 -2
  60. package/dist/storage.js +640 -664
  61. package/dist/storage.js.map +3 -3
  62. package/dist/types/packages/core/src/platform/playwright/manager.d.ts +8 -0
  63. package/dist/types/packages/core/src/storage/api-topics.d.ts +1 -0
  64. package/dist/types/packages/core/src/storage/browser-profiles.d.ts +4 -0
  65. package/dist/types/packages/core/src/types/api.d.ts +6 -0
  66. package/dist/types/packages/core/src/version.d.ts +1 -1
  67. package/dist/vault.js +22 -20
  68. package/dist/vault.js.map +2 -2
  69. package/package.json +1 -1
  70. package/dist/chunk-bnyvxss3.js +0 -77
package/dist/storage.js CHANGED
@@ -13,484 +13,188 @@ var __export = (target, all) => {
13
13
  set: __exportSetter.bind(all, name)
14
14
  });
15
15
  };
16
+ var __require = import.meta.require;
16
17
 
17
18
  // ../../packages/core/src/storage/activity-log.ts
18
19
  var exports_activity_log = {};
19
20
  __export(exports_activity_log, {
20
- readSentFilesForTopic: () => readSentFilesForTopic,
21
- removeSentFilesForTopic: () => removeSentFilesForTopic,
22
- rotateOldLogs: () => rotateOldLogs,
21
+ writeSentFileLog: () => writeSentFileLog,
23
22
  writeLog: () => writeLog,
24
- writeSentFileLog: () => writeSentFileLog
23
+ rotateOldLogs: () => rotateOldLogs,
24
+ removeSentFilesForTopic: () => removeSentFilesForTopic,
25
+ readSentFilesForTopic: () => readSentFilesForTopic
25
26
  });
27
+ import {
28
+ existsSync,
29
+ mkdirSync as mkdirSync3,
30
+ readdirSync,
31
+ renameSync as renameSync2,
32
+ statSync as statSync2,
33
+ unlinkSync as unlinkSync3,
34
+ writeFileSync as writeFileSync2
35
+ } from "fs";
36
+ import { basename, join as join2 } from "path";
26
37
 
27
- // ../../packages/core/src/storage/api-messages.ts
28
- var exports_api_messages = {};
29
- __export(exports_api_messages, {
30
- anonymizeApiMessages: () => anonymizeApiMessages,
31
- appendApiMessage: () => appendApiMessage,
32
- captureMessageSnapshotForTopic: () => captureMessageSnapshotForTopic,
33
- copyMessageSnapshotToTopic: () => copyMessageSnapshotToTopic,
34
- copyMessagesForTopic: () => copyMessagesForTopic,
35
- countThreadReplies: () => countThreadReplies,
36
- deleteMessagesForTopic: () => deleteMessagesForTopic,
37
- findRecentUserMessage: () => findRecentUserMessage,
38
- findThreadRootsByPrefix: () => findThreadRootsByPrefix,
39
- getAllMessagesForTopic: () => getAllMessagesForTopic,
40
- getApiMessage: () => getApiMessage,
41
- getLastMessagePreviews: () => getLastMessagePreviews,
42
- getMessagesForTopicAfterRowid: () => getMessagesForTopicAfterRowid,
43
- getThreadSummaries: () => getThreadSummaries,
44
- listApiMessages: () => listApiMessages,
45
- listApiMessagesByKind: () => listApiMessagesByKind,
46
- listThreadMessageRows: () => listThreadMessageRows,
47
- listThreadMessages: () => listThreadMessages,
48
- listTopicIdsForAttachment: () => listTopicIdsForAttachment,
49
- listTopicThreadRoots: () => listTopicThreadRoots,
50
- registerApiMessageAppendHook: () => registerApiMessageAppendHook,
51
- setApiMessageReactions: () => setApiMessageReactions,
52
- softDeleteApiMessage: () => softDeleteApiMessage,
53
- softDeleteApiMessagesByIdPrefix: () => softDeleteApiMessagesByIdPrefix,
54
- topicHasAttachmentFileId: () => topicHasAttachmentFileId,
55
- updateApiMessageAskUserQuestion: () => updateApiMessageAskUserQuestion,
56
- updateApiMessageSubagentCard: () => updateApiMessageSubagentCard,
57
- updateApiMessageText: () => updateApiMessageText,
58
- updateApiMessageUsage: () => updateApiMessageUsage
59
- });
38
+ // ../../packages/core/src/platform/jsonl.ts
39
+ import {
40
+ appendFileSync,
41
+ closeSync,
42
+ fsyncSync,
43
+ mkdirSync,
44
+ openSync,
45
+ readFileSync,
46
+ renameSync,
47
+ statSync,
48
+ unlinkSync as unlinkSync2,
49
+ writeFileSync
50
+ } from "fs";
51
+ import { dirname } from "path";
60
52
 
61
- // ../../packages/core/src/storage/api-topic-brief.ts
62
- var exports_api_topic_brief = {};
63
- __export(exports_api_topic_brief, {
64
- deleteTopicBrief: () => deleteTopicBrief,
65
- getTopicBrief: () => getTopicBrief,
66
- listTopicBriefs: () => listTopicBriefs,
67
- resolveTopicBrief: () => resolveTopicBrief,
68
- setTopicBrief: () => setTopicBrief
69
- });
53
+ // ../../packages/core/src/platform/file-utils.ts
54
+ import { unlinkSync } from "fs";
70
55
 
71
- // ../../packages/core/src/storage/wiki-summary-names.ts
72
- var exports_wiki_summary_names = {};
73
- __export(exports_wiki_summary_names, {
74
- isTopicBriefFile: () => isTopicBriefFile,
75
- isTopicSummaryFile: () => isTopicSummaryFile,
76
- wikiBriefStorageKey: () => wikiBriefStorageKey,
77
- wikiSummaryFilename: () => wikiSummaryFilename,
78
- wikiSummarySlug: () => wikiSummarySlug,
79
- wikiSummaryStorageSlug: () => wikiSummaryStorageSlug
80
- });
56
+ // ../../packages/core/src/platform/logger.ts
57
+ import pino from "pino";
58
+ function createStdioLogger(options = {}) {
59
+ const development = options.development ?? true;
60
+ return pino({
61
+ level: options.level ?? process.env.LOG_LEVEL ?? "info",
62
+ transport: development ? {
63
+ target: "pino-pretty",
64
+ options: {
65
+ colorize: true,
66
+ translateTime: "SYS:yyyy-mm-dd HH:MM:ss",
67
+ destination: 2
68
+ }
69
+ } : undefined
70
+ }, pino.destination(2));
71
+ }
72
+ var logger = createStdioLogger();
81
73
 
82
- // ../../packages/core/src/storage/api-topic-config.ts
83
- var exports_api_topic_config = {};
84
- __export(exports_api_topic_config, {
85
- deleteApiTopicConfig: () => deleteApiTopicConfig,
86
- getApiTopicConfig: () => getApiTopicConfig,
87
- setApiTopicConfig: () => setApiTopicConfig
74
+ // ../../packages/core/src/platform/file-utils.ts
75
+ function createSafeUnlink(host) {
76
+ return (path, warnLabel) => {
77
+ try {
78
+ host.unlink(path);
79
+ } catch (e) {
80
+ if (e?.code === "ENOENT")
81
+ return;
82
+ if (warnLabel)
83
+ host.warn({ err: e, path }, warnLabel);
84
+ }
85
+ };
86
+ }
87
+ var defaultSafeUnlink = createSafeUnlink({
88
+ unlink: unlinkSync,
89
+ warn: (context, message) => logger.warn(context, message)
88
90
  });
91
+ function safeUnlink(path, warnLabel) {
92
+ defaultSafeUnlink(path, warnLabel);
93
+ }
89
94
 
90
- // ../../packages/core/src/storage/api-topics.ts
91
- var exports_api_topics = {};
92
- __export(exports_api_topics, {
93
- SURFACE_SCOPE_STAMP_RETRY_INTERVAL_MS: () => SURFACE_SCOPE_STAMP_RETRY_INTERVAL_MS,
94
- addParticipantToDB: () => addParticipantToDB,
95
- aiMentionFromMode: () => aiMentionFromMode,
96
- clearTopicSessionId: () => clearTopicSessionId,
97
- defaultSurfaceScope: () => defaultSurfaceScope,
98
- defaultTopicSurface: () => defaultTopicSurface,
99
- deleteTopic: () => deleteTopic,
100
- findTopicTitleConflict: () => findTopicTitleConflict,
101
- getManagerTopicForUser: () => getManagerTopicForUser,
102
- getTopic: () => getTopic,
103
- getTopicByName: () => getTopicByName,
104
- getTopicByNameAndKind: () => getTopicByNameAndKind,
105
- getTopicByNameForUser: () => getTopicByNameForUser,
106
- getTopicMemoryOrigin: () => getTopicMemoryOrigin,
107
- getTopicSessionId: () => getTopicSessionId,
108
- grantSubagentTellTarget: () => grantSubagentTellTarget,
109
- inferAiMode: () => inferAiMode,
110
- inferTopicKind: () => inferTopicKind,
111
- isSurfaceScopeRequired: () => isSurfaceScopeRequired,
112
- isSurfaceScopeStampPending: () => isSurfaceScopeStampPending,
113
- isTopicVisible: () => isTopicVisible,
114
- listSubagentChildTopicIds: () => listSubagentChildTopicIds,
115
- listSubagentTellTargetIds: () => listSubagentTellTargetIds,
116
- listTopics: () => listTopics,
117
- localSurfaceScopeStatus: () => localSurfaceScopeStatus,
118
- normalizeAiMode: () => normalizeAiMode,
119
- normalizeSurfaceScope: () => normalizeSurfaceScope,
120
- normalizeTopicKind: () => normalizeTopicKind,
121
- normalizeTopicState: () => normalizeTopicState,
122
- normalizeTopicSurface: () => normalizeTopicSurface,
123
- normalizeTopicVisibility: () => normalizeTopicVisibility,
124
- removeParticipantFromDB: () => removeParticipantFromDB,
125
- reparentTopicChildren: () => reparentTopicChildren,
126
- retryPendingSurfaceScopeStamp: () => retryPendingSurfaceScopeStamp,
127
- revokeSubagentTellTarget: () => revokeSubagentTellTarget,
128
- setApiTopicAgent: () => setApiTopicAgent,
129
- setDefaultSurfaceScope: () => setDefaultSurfaceScope,
130
- setMountedSurfaceScopeCount: () => setMountedSurfaceScopeCount,
131
- setSurfaceScopeRequired: () => setSurfaceScopeRequired,
132
- setTopicSessionId: () => setTopicSessionId,
133
- setTopicSurfaceScope: () => setTopicSurfaceScope,
134
- setTopicSurfaces: () => setTopicSurfaces,
135
- stampUnscopedOtiumTopics: () => stampUnscopedOtiumTopics,
136
- surfaceScopeStampStatus: () => surfaceScopeStampStatus,
137
- upsertTopic: () => upsertTopic
138
- });
95
+ // ../../packages/core/src/platform/jsonl.ts
96
+ function readJsonlLines(filePath) {
97
+ return readFileSync(filePath, "utf-8").trim().split(`
98
+ `).filter(Boolean);
99
+ }
100
+ var LOCK_SUFFIX = ".lock";
101
+ var LOCK_RETRY_MS = 5;
102
+ var DEFAULT_LOCK_STALE_MS = 5000;
103
+ var LOCK_TIMEOUT_HEADROOM_MS = 1500;
104
+ function lockStaleMs() {
105
+ const raw = Number.parseInt(process.env.NEGOTIUM_JSONL_LOCK_STALE_MS ?? "", 10);
106
+ return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_LOCK_STALE_MS;
107
+ }
108
+ function lockTimeoutMs() {
109
+ return lockStaleMs() + LOCK_TIMEOUT_HEADROOM_MS;
110
+ }
111
+ var LOCK_SLEEP = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
139
112
 
140
- // ../../packages/core/src/storage/app-settings.ts
141
- var exports_app_settings = {};
142
- __export(exports_app_settings, {
143
- DEFAULT_AI_NAME: () => DEFAULT_AI_NAME,
144
- getGlobalAiName: () => getGlobalAiName,
145
- setGlobalAiName: () => setGlobalAiName
146
- });
113
+ class JsonlLockTimeoutError extends Error {
114
+ filePath;
115
+ timeoutMs;
116
+ constructor(filePath, timeoutMs) {
117
+ super(`jsonl append lock busy after ${timeoutMs}ms; nothing written to ${filePath}`);
118
+ this.filePath = filePath;
119
+ this.timeoutMs = timeoutMs;
120
+ this.name = "JsonlLockTimeoutError";
121
+ }
122
+ }
123
+ function sleepForAppendLock(ms) {
124
+ Atomics.wait(LOCK_SLEEP, 0, 0, ms);
125
+ }
126
+ function tryAcquireAppendLock(lockPath) {
127
+ try {
128
+ closeSync(openSync(lockPath, "wx"));
129
+ return true;
130
+ } catch (e) {
131
+ if (e.code !== "EEXIST")
132
+ throw e;
133
+ return false;
134
+ }
135
+ }
136
+ function isStaleLock(lockPath) {
137
+ try {
138
+ return Date.now() - statSync(lockPath).mtimeMs > lockStaleMs();
139
+ } catch {
140
+ return false;
141
+ }
142
+ }
143
+ function appendJsonlEntry(filePath, entry) {
144
+ appendJsonlLine(filePath, `${JSON.stringify(entry)}
145
+ `);
146
+ }
147
+ function appendJsonlLine(filePath, line) {
148
+ mkdirSync(dirname(filePath), { recursive: true });
149
+ const lockPath = `${filePath}${LOCK_SUFFIX}`;
150
+ const payload = line.endsWith(`
151
+ `) ? line : `${line}
152
+ `;
153
+ let acquired = tryAcquireAppendLock(lockPath);
154
+ if (!acquired && isStaleLock(lockPath)) {
155
+ safeUnlink(lockPath);
156
+ acquired = tryAcquireAppendLock(lockPath);
157
+ }
158
+ if (!acquired) {
159
+ const start = Date.now();
160
+ const timeoutMs = lockTimeoutMs();
161
+ while (!acquired && Date.now() - start < timeoutMs) {
162
+ sleepForAppendLock(LOCK_RETRY_MS);
163
+ acquired = tryAcquireAppendLock(lockPath);
164
+ if (!acquired && isStaleLock(lockPath)) {
165
+ safeUnlink(lockPath);
166
+ acquired = tryAcquireAppendLock(lockPath);
167
+ }
168
+ }
169
+ }
170
+ if (!acquired)
171
+ throw new JsonlLockTimeoutError(filePath, lockTimeoutMs());
172
+ try {
173
+ appendFileSync(filePath, payload);
174
+ } finally {
175
+ safeUnlink(lockPath);
176
+ }
177
+ }
147
178
 
148
- // ../../packages/core/src/storage/ask-user-gates.ts
149
- var exports_ask_user_gates = {};
150
- __export(exports_ask_user_gates, {
151
- cancelAskUserGate: () => cancelAskUserGate,
152
- claimAskUserGateAndSelect: () => claimAskUserGateAndSelect,
153
- prepareAskUserGate: () => prepareAskUserGate,
154
- quarantineAskUserGate: () => quarantineAskUserGate,
155
- quarantineForeignAskUserGates: () => quarantineForeignAskUserGates
156
- });
157
-
158
- // ../../packages/core/src/storage/conversations.ts
159
- var exports_conversations = {};
160
- __export(exports_conversations, {
161
- ConversationLogDivergedError: () => ConversationLogDivergedError,
162
- appendConversationEvent: () => appendConversationEvent,
163
- appendConversationEventStrict: () => appendConversationEventStrict,
164
- appendRawConversationEventStrict: () => appendRawConversationEventStrict,
165
- cloneConversationLog: () => cloneConversationLog,
166
- findLastSessionIdForAgent: () => findLastSessionIdForAgent,
167
- getActiveConversationPath: () => getActiveConversationPath,
168
- getConversationPath: () => getConversationPath,
169
- hasActiveConversation: () => hasActiveConversation,
170
- readConversation: () => readConversation,
171
- readRawConversation: () => readRawConversation,
172
- replaceConversationStrict: () => replaceConversationStrict,
173
- replaceRawConversationStrict: () => replaceRawConversationStrict
174
- });
175
-
176
- // ../../packages/core/src/storage/decisions.ts
177
- var exports_decisions = {};
178
- __export(exports_decisions, {
179
- DECISION_STATUS_VALUES: () => DECISION_STATUS_VALUES,
180
- createDecisions: () => createDecisions,
181
- decisionScopeKey: () => decisionScopeKey,
182
- deleteDecisions: () => deleteDecisions,
183
- getDecisionFilePath: () => getDecisionFilePath,
184
- getDecisionGraphSvgPath: () => getDecisionGraphSvgPath,
185
- readDecisions: () => readDecisions,
186
- renderDecisionList: () => renderDecisionList,
187
- updateDecisions: () => updateDecisions,
188
- validateDecisionGraph: () => validateDecisionGraph,
189
- writeDecisionGraphSvg: () => writeDecisionGraphSvg,
190
- writeDecisions: () => writeDecisions
191
- });
192
-
193
- // ../../packages/core/src/storage/forum/index.ts
194
- var exports_forum = {};
195
- __export(exports_forum, {
196
- addTopic: () => addTopic,
197
- clearDmSessionId: () => clearDmSessionId,
198
- clearSessionForTopic: () => clearSessionForTopic,
199
- findUserByThread: () => findUserByThread,
200
- flushSessionCache: () => flushSessionCache,
201
- getAllTopics: () => getAllTopics,
202
- getAllUserIds: () => getAllUserIds,
203
- getCommunicateThreadId: () => getCommunicateThreadId,
204
- getDmSessionId: () => getDmSessionId,
205
- getLastShownConfig: () => getLastShownConfig,
206
- getSessionForTopic: () => getSessionForTopic,
207
- getTopicAgent: () => getTopicAgent,
208
- getTopicByName: () => getTopicByName2,
209
- getTopicDescription: () => getTopicDescription,
210
- getTopicMcpConfig: () => getTopicMcpConfig,
211
- getTopicNames: () => getTopicNames,
212
- getUserConfig: () => getUserConfig,
213
- removeTopic: () => removeTopic,
214
- renameTopic: () => renameTopic,
215
- setDmSessionId: () => setDmSessionId,
216
- setLastShownConfig: () => setLastShownConfig,
217
- setSessionForTopic: () => setSessionForTopic,
218
- setTopicAgent: () => setTopicAgent,
219
- setTopicDescription: () => setTopicDescription,
220
- setTopicForkOrigin: () => setTopicForkOrigin,
221
- setTopicMcpEnabled: () => setTopicMcpEnabled,
222
- setTopicMcpExtra: () => setTopicMcpExtra,
223
- updateTopicThreadId: () => updateTopicThreadId
224
- });
225
-
226
- // ../../packages/core/src/storage/runtime-process-leases.ts
227
- var exports_runtime_process_leases = {};
228
- __export(exports_runtime_process_leases, {
229
- PROCESS_LEASE_HEARTBEAT_MS: () => PROCESS_LEASE_HEARTBEAT_MS,
230
- PROCESS_LEASE_STALE_MS: () => PROCESS_LEASE_STALE_MS,
231
- acquireRuntimeProcessLease: () => acquireRuntimeProcessLease,
232
- getRuntimeProcessLease: () => getRuntimeProcessLease,
233
- heartbeatRuntimeProcessLease: () => heartbeatRuntimeProcessLease,
234
- isRuntimeProcessLeaseAlive: () => isRuntimeProcessLeaseAlive,
235
- listRuntimeProcessLeases: () => listRuntimeProcessLeases,
236
- releaseRuntimeProcessLease: () => releaseRuntimeProcessLease,
237
- removeDeadRuntimeProcessLeases: () => removeDeadRuntimeProcessLeases,
238
- waitForRequiredRuntimeProcessLease: () => waitForRequiredRuntimeProcessLease,
239
- waitForRuntimeProcessLease: () => waitForRuntimeProcessLease
240
- });
241
-
242
- // ../../packages/core/src/storage/session-asks.ts
243
- var exports_session_asks = {};
244
- __export(exports_session_asks, {
245
- PENDING_ASK_TTL_MS: () => PENDING_ASK_TTL_MS,
246
- clearPendingAsk: () => clearPendingAsk,
247
- clearPendingAskSources: () => clearPendingAskSources,
248
- createPendingAsk: () => createPendingAsk,
249
- deletePendingAsksForTopic: () => deletePendingAsksForTopic,
250
- describePendingAskState: () => describePendingAskState,
251
- listPendingAsksForCaller: () => listPendingAsksForCaller,
252
- markPendingAskSources: () => markPendingAskSources,
253
- markPendingAskState: () => markPendingAskState,
254
- releasePendingAsk: () => releasePendingAsk
255
- });
256
-
257
- // ../../packages/core/src/storage/tasks.ts
258
- var exports_tasks = {};
259
- __export(exports_tasks, {
260
- TASK_STATUS_VALUES: () => TASK_STATUS_VALUES,
261
- createTasks: () => createTasks,
262
- deleteTasks: () => deleteTasks,
263
- getTaskFilePath: () => getTaskFilePath,
264
- readTasks: () => readTasks,
265
- renderTaskList: () => renderTaskList,
266
- taskFileMtimeNs: () => taskFileMtimeNs,
267
- taskScopeKey: () => taskScopeKey,
268
- updateTasks: () => updateTasks,
269
- writeTasks: () => writeTasks
270
- });
271
-
272
- // ../../packages/core/src/storage/token-stats.ts
273
- var exports_token_stats = {};
274
- __export(exports_token_stats, {
275
- calcCost: () => calcCost,
276
- deleteTopicStats: () => deleteTopicStats,
277
- getStats: () => getStats,
278
- getTopicStats: () => getTopicStats,
279
- recordUsage: () => recordUsage,
280
- tokenStatsFileId: () => tokenStatsFileId
281
- });
282
-
283
- // ../../packages/core/src/storage/topic-archive.ts
284
- var exports_topic_archive = {};
285
- __export(exports_topic_archive, {
286
- archiveConversationEvents: () => archiveConversationEvents,
287
- archiveTopicMessages: () => archiveTopicMessages
288
- });
289
-
290
- // ../../packages/core/src/storage/topic-transcript.ts
291
- var exports_topic_transcript = {};
292
- __export(exports_topic_transcript, {
293
- formatTopicArchiveTranscriptRecord: () => formatTopicArchiveTranscriptRecord
294
- });
295
-
296
- // ../../packages/core/src/storage/wiki.ts
297
- var exports_wiki = {};
298
- __export(exports_wiki, {
299
- getSharedWikiDir: () => getSharedWikiDir,
300
- getTopicMemoryFilePaths: () => getTopicMemoryFilePaths,
301
- getWikiDir: () => getWikiDir
302
- });
303
-
304
- // ../../packages/core/src/storage/topic-archive-state.ts
305
- var exports_topic_archive_state = {};
306
- __export(exports_topic_archive_state, {
307
- claimTopicArchiveJob: () => claimTopicArchiveJob,
308
- deleteTopicArchiveState: () => deleteTopicArchiveState,
309
- getTopicArchiveState: () => getTopicArchiveState,
310
- setTopicArchiveState: () => setTopicArchiveState,
311
- settleTopicArchiveJob: () => settleTopicArchiveJob
312
- });
313
-
314
- // ../../packages/core/src/storage/topic-settings.ts
315
- var exports_topic_settings = {};
316
- __export(exports_topic_settings, {
317
- getTopicAgentSwitchState: () => getTopicAgentSwitchState,
318
- setTopicAgentAndClearSession: () => setTopicAgentAndClearSession,
319
- setTopicAgentAndSession: () => setTopicAgentAndSession
320
- });
321
-
322
- // ../../packages/core/src/storage/activity-log.ts
323
- import {
324
- existsSync,
325
- mkdirSync as mkdirSync3,
326
- readdirSync,
327
- renameSync as renameSync2,
328
- statSync as statSync2,
329
- unlinkSync as unlinkSync3,
330
- writeFileSync as writeFileSync2
331
- } from "fs";
332
- import { basename, join as join2 } from "path";
333
-
334
- // ../../packages/core/src/platform/jsonl.ts
335
- import {
336
- appendFileSync,
337
- closeSync,
338
- fsyncSync,
339
- mkdirSync,
340
- openSync,
341
- readFileSync,
342
- renameSync,
343
- statSync,
344
- unlinkSync as unlinkSync2,
345
- writeFileSync
346
- } from "fs";
347
- import { dirname } from "path";
348
-
349
- // ../../packages/core/src/platform/file-utils.ts
350
- import { unlinkSync } from "fs";
351
-
352
- // ../../packages/core/src/platform/logger.ts
353
- import pino from "pino";
354
- function createStdioLogger(options = {}) {
355
- const development = options.development ?? true;
356
- return pino({
357
- level: options.level ?? process.env.LOG_LEVEL ?? "info",
358
- transport: development ? {
359
- target: "pino-pretty",
360
- options: {
361
- colorize: true,
362
- translateTime: "SYS:yyyy-mm-dd HH:MM:ss",
363
- destination: 2
364
- }
365
- } : undefined
366
- }, pino.destination(2));
179
+ // ../../packages/core/src/security/sanitize.ts
180
+ function sanitizeTopicName(name, lowercase = false) {
181
+ const safe = name.replace(/[^a-zA-Z0-9\uAC00-\uD7A3_-]/g, "_") || "_";
182
+ return lowercase ? safe.toLowerCase() : safe;
367
183
  }
368
- var logger = createStdioLogger();
369
-
370
- // ../../packages/core/src/platform/file-utils.ts
371
- function createSafeUnlink(host) {
372
- return (path, warnLabel) => {
373
- try {
374
- host.unlink(path);
375
- } catch (e) {
376
- if (e?.code === "ENOENT")
377
- return;
378
- if (warnLabel)
379
- host.warn({ err: e, path }, warnLabel);
380
- }
381
- };
184
+ function sanitizeFileName(name) {
185
+ const safe = name.replace(/[^a-zA-Z0-9._-]/g, "_") || "_";
186
+ if (safe === "." || safe === "..")
187
+ return "_";
188
+ return safe;
382
189
  }
383
- var defaultSafeUnlink = createSafeUnlink({
384
- unlink: unlinkSync,
385
- warn: (context, message) => logger.warn(context, message)
386
- });
387
- function safeUnlink(path, warnLabel) {
388
- defaultSafeUnlink(path, warnLabel);
190
+ function sanitizeId(id) {
191
+ return id.replace(/[^a-zA-Z0-9_-]/g, "_") || "_";
389
192
  }
390
193
 
391
- // ../../packages/core/src/platform/jsonl.ts
392
- function readJsonlLines(filePath) {
393
- return readFileSync(filePath, "utf-8").trim().split(`
394
- `).filter(Boolean);
395
- }
396
- var LOCK_SUFFIX = ".lock";
397
- var LOCK_RETRY_MS = 5;
398
- var DEFAULT_LOCK_STALE_MS = 5000;
399
- var LOCK_TIMEOUT_HEADROOM_MS = 1500;
400
- function lockStaleMs() {
401
- const raw = Number.parseInt(process.env.NEGOTIUM_JSONL_LOCK_STALE_MS ?? "", 10);
402
- return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_LOCK_STALE_MS;
403
- }
404
- function lockTimeoutMs() {
405
- return lockStaleMs() + LOCK_TIMEOUT_HEADROOM_MS;
406
- }
407
- var LOCK_SLEEP = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
408
-
409
- class JsonlLockTimeoutError extends Error {
410
- filePath;
411
- timeoutMs;
412
- constructor(filePath, timeoutMs) {
413
- super(`jsonl append lock busy after ${timeoutMs}ms; nothing written to ${filePath}`);
414
- this.filePath = filePath;
415
- this.timeoutMs = timeoutMs;
416
- this.name = "JsonlLockTimeoutError";
417
- }
418
- }
419
- function sleepForAppendLock(ms) {
420
- Atomics.wait(LOCK_SLEEP, 0, 0, ms);
421
- }
422
- function tryAcquireAppendLock(lockPath) {
423
- try {
424
- closeSync(openSync(lockPath, "wx"));
425
- return true;
426
- } catch (e) {
427
- if (e.code !== "EEXIST")
428
- throw e;
429
- return false;
430
- }
431
- }
432
- function isStaleLock(lockPath) {
433
- try {
434
- return Date.now() - statSync(lockPath).mtimeMs > lockStaleMs();
435
- } catch {
436
- return false;
437
- }
438
- }
439
- function appendJsonlEntry(filePath, entry) {
440
- appendJsonlLine(filePath, `${JSON.stringify(entry)}
441
- `);
442
- }
443
- function appendJsonlLine(filePath, line) {
444
- mkdirSync(dirname(filePath), { recursive: true });
445
- const lockPath = `${filePath}${LOCK_SUFFIX}`;
446
- const payload = line.endsWith(`
447
- `) ? line : `${line}
448
- `;
449
- let acquired = tryAcquireAppendLock(lockPath);
450
- if (!acquired && isStaleLock(lockPath)) {
451
- safeUnlink(lockPath);
452
- acquired = tryAcquireAppendLock(lockPath);
453
- }
454
- if (!acquired) {
455
- const start = Date.now();
456
- const timeoutMs = lockTimeoutMs();
457
- while (!acquired && Date.now() - start < timeoutMs) {
458
- sleepForAppendLock(LOCK_RETRY_MS);
459
- acquired = tryAcquireAppendLock(lockPath);
460
- if (!acquired && isStaleLock(lockPath)) {
461
- safeUnlink(lockPath);
462
- acquired = tryAcquireAppendLock(lockPath);
463
- }
464
- }
465
- }
466
- if (!acquired)
467
- throw new JsonlLockTimeoutError(filePath, lockTimeoutMs());
468
- try {
469
- appendFileSync(filePath, payload);
470
- } finally {
471
- safeUnlink(lockPath);
472
- }
473
- }
474
-
475
- // ../../packages/core/src/security/sanitize.ts
476
- function sanitizeTopicName(name, lowercase = false) {
477
- const safe = name.replace(/[^a-zA-Z0-9\uAC00-\uD7A3_-]/g, "_") || "_";
478
- return lowercase ? safe.toLowerCase() : safe;
479
- }
480
- function sanitizeFileName(name) {
481
- const safe = name.replace(/[^a-zA-Z0-9._-]/g, "_") || "_";
482
- if (safe === "." || safe === "..")
483
- return "_";
484
- return safe;
485
- }
486
- function sanitizeId(id) {
487
- return id.replace(/[^a-zA-Z0-9_-]/g, "_") || "_";
488
- }
489
-
490
- // ../../packages/core/src/storage/storage-host.ts
491
- import { mkdirSync as mkdirSync2 } from "fs";
492
- import { homedir } from "os";
493
- import { dirname as dirname2, join, resolve } from "path";
194
+ // ../../packages/core/src/storage/storage-host.ts
195
+ import { mkdirSync as mkdirSync2 } from "fs";
196
+ import { homedir } from "os";
197
+ import { dirname as dirname2, join, resolve } from "path";
494
198
 
495
199
  // ../../packages/core/src/storage/sqlite.ts
496
200
  var isBun = typeof process.versions.bun === "string";
@@ -878,6 +582,40 @@ function removeSentFilesForTopic(userId, topicName) {
878
582
  logger.warn({ err: e, userId, topicName }, "Failed to remove sent-files for topic");
879
583
  }
880
584
  }
585
+ // ../../packages/core/src/storage/api-messages.ts
586
+ var exports_api_messages = {};
587
+ __export(exports_api_messages, {
588
+ updateApiMessageUsage: () => updateApiMessageUsage,
589
+ updateApiMessageText: () => updateApiMessageText,
590
+ updateApiMessageSubagentCard: () => updateApiMessageSubagentCard,
591
+ updateApiMessageAskUserQuestion: () => updateApiMessageAskUserQuestion,
592
+ topicHasAttachmentFileId: () => topicHasAttachmentFileId,
593
+ softDeleteApiMessagesByIdPrefix: () => softDeleteApiMessagesByIdPrefix,
594
+ softDeleteApiMessage: () => softDeleteApiMessage,
595
+ setApiMessageReactions: () => setApiMessageReactions,
596
+ registerApiMessageAppendHook: () => registerApiMessageAppendHook,
597
+ listTopicThreadRoots: () => listTopicThreadRoots,
598
+ listTopicIdsForAttachment: () => listTopicIdsForAttachment,
599
+ listThreadMessages: () => listThreadMessages,
600
+ listThreadMessageRows: () => listThreadMessageRows,
601
+ listApiMessagesByKind: () => listApiMessagesByKind,
602
+ listApiMessages: () => listApiMessages,
603
+ getThreadSummaries: () => getThreadSummaries,
604
+ getMessagesForTopicAfterRowid: () => getMessagesForTopicAfterRowid,
605
+ getLastMessagePreviews: () => getLastMessagePreviews,
606
+ getApiMessage: () => getApiMessage,
607
+ getAllMessagesForTopic: () => getAllMessagesForTopic,
608
+ findThreadRootsByPrefix: () => findThreadRootsByPrefix,
609
+ findRecentUserMessage: () => findRecentUserMessage,
610
+ deleteMessagesForTopic: () => deleteMessagesForTopic,
611
+ countThreadReplies: () => countThreadReplies,
612
+ copyMessagesForTopic: () => copyMessagesForTopic,
613
+ copyMessageSnapshotToTopic: () => copyMessageSnapshotToTopic,
614
+ captureMessageSnapshotForTopic: () => captureMessageSnapshotForTopic,
615
+ appendApiMessage: () => appendApiMessage,
616
+ anonymizeApiMessages: () => anonymizeApiMessages
617
+ });
618
+
881
619
  // ../../packages/core/src/storage/forum-db.ts
882
620
  var db = internalStorageDatabase;
883
621
 
@@ -1272,7 +1010,26 @@ function getAllMessagesForTopic(topicId) {
1272
1010
  function getMessagesForTopicAfterRowid(topicId, afterRowid) {
1273
1011
  return db.query("SELECT *, rowid AS rowid FROM api_messages WHERE topic_id = ? AND rowid > ? AND deleted = 0 ORDER BY rowid ASC").all(topicId, afterRowid);
1274
1012
  }
1013
+ // ../../packages/core/src/storage/api-topic-brief.ts
1014
+ var exports_api_topic_brief = {};
1015
+ __export(exports_api_topic_brief, {
1016
+ setTopicBrief: () => setTopicBrief,
1017
+ resolveTopicBrief: () => resolveTopicBrief,
1018
+ listTopicBriefs: () => listTopicBriefs,
1019
+ getTopicBrief: () => getTopicBrief,
1020
+ deleteTopicBrief: () => deleteTopicBrief
1021
+ });
1022
+
1275
1023
  // ../../packages/core/src/storage/wiki-summary-names.ts
1024
+ var exports_wiki_summary_names = {};
1025
+ __export(exports_wiki_summary_names, {
1026
+ wikiSummaryStorageSlug: () => wikiSummaryStorageSlug,
1027
+ wikiSummarySlug: () => wikiSummarySlug,
1028
+ wikiSummaryFilename: () => wikiSummaryFilename,
1029
+ wikiBriefStorageKey: () => wikiBriefStorageKey,
1030
+ isTopicSummaryFile: () => isTopicSummaryFile,
1031
+ isTopicBriefFile: () => isTopicBriefFile
1032
+ });
1276
1033
  var WIKI_SUMMARY_DATE_PREFIX = /^\d{4}-\d{2}-\d{2}-/;
1277
1034
  function wikiSummarySlug(value) {
1278
1035
  return value.replaceAll(/[^a-zA-Z0-9\uAC00-\uD7A3_-]+/g, "-").slice(0, 120) || "_";
@@ -1369,6 +1126,12 @@ function listTopicBriefs() {
1369
1126
  return rows.map(rowToBrief);
1370
1127
  }
1371
1128
  // ../../packages/core/src/storage/api-topic-config.ts
1129
+ var exports_api_topic_config = {};
1130
+ __export(exports_api_topic_config, {
1131
+ setApiTopicConfig: () => setApiTopicConfig,
1132
+ getApiTopicConfig: () => getApiTopicConfig,
1133
+ deleteApiTopicConfig: () => deleteApiTopicConfig
1134
+ });
1372
1135
  function tableColumns(table) {
1373
1136
  const rows = db.query(`PRAGMA table_info(${table})`).all();
1374
1137
  return new Set(rows.map((row) => row.name));
@@ -1480,6 +1243,56 @@ function setApiTopicConfig(topicId, config) {
1480
1243
  function deleteApiTopicConfig(topicId) {
1481
1244
  db.query("DELETE FROM api_topic_config WHERE topic_id = ?").run(topicId);
1482
1245
  }
1246
+ // ../../packages/core/src/storage/api-topics.ts
1247
+ var exports_api_topics = {};
1248
+ __export(exports_api_topics, {
1249
+ upsertTopic: () => upsertTopic,
1250
+ surfaceScopeStampStatus: () => surfaceScopeStampStatus,
1251
+ stampUnscopedOtiumTopics: () => stampUnscopedOtiumTopics,
1252
+ setTopicSurfaces: () => setTopicSurfaces,
1253
+ setTopicSurfaceScope: () => setTopicSurfaceScope,
1254
+ setTopicSessionId: () => setTopicSessionId,
1255
+ setSurfaceScopeRequired: () => setSurfaceScopeRequired,
1256
+ setMountedSurfaceScopeCount: () => setMountedSurfaceScopeCount,
1257
+ setDefaultSurfaceScope: () => setDefaultSurfaceScope,
1258
+ setApiTopicAgent: () => setApiTopicAgent,
1259
+ revokeSubagentTellTarget: () => revokeSubagentTellTarget,
1260
+ retryPendingSurfaceScopeStamp: () => retryPendingSurfaceScopeStamp,
1261
+ reparentTopicChildren: () => reparentTopicChildren,
1262
+ removeParticipantFromDB: () => removeParticipantFromDB,
1263
+ normalizeTopicVisibility: () => normalizeTopicVisibility,
1264
+ normalizeTopicSurface: () => normalizeTopicSurface,
1265
+ normalizeTopicState: () => normalizeTopicState,
1266
+ normalizeTopicKind: () => normalizeTopicKind,
1267
+ normalizeSurfaceScope: () => normalizeSurfaceScope,
1268
+ normalizeAiMode: () => normalizeAiMode,
1269
+ localSurfaceScopeStatus: () => localSurfaceScopeStatus,
1270
+ listTopics: () => listTopics,
1271
+ listSubagentTellTargetIds: () => listSubagentTellTargetIds,
1272
+ listSubagentChildTopicIds: () => listSubagentChildTopicIds,
1273
+ isTopicVisible: () => isTopicVisible,
1274
+ isSurfaceScopeStampPending: () => isSurfaceScopeStampPending,
1275
+ isSurfaceScopeRequired: () => isSurfaceScopeRequired,
1276
+ inferTopicKind: () => inferTopicKind,
1277
+ inferAiMode: () => inferAiMode,
1278
+ grantSubagentTellTarget: () => grantSubagentTellTarget,
1279
+ getTopicSessionId: () => getTopicSessionId,
1280
+ getTopicMemoryOrigin: () => getTopicMemoryOrigin,
1281
+ getTopicByNameForUser: () => getTopicByNameForUser,
1282
+ getTopicByNameAndKind: () => getTopicByNameAndKind,
1283
+ getTopicByName: () => getTopicByName,
1284
+ getTopic: () => getTopic,
1285
+ getManagerTopicForUser: () => getManagerTopicForUser,
1286
+ findTopicTitleConflict: () => findTopicTitleConflict,
1287
+ deleteTopic: () => deleteTopic,
1288
+ defaultTopicSurface: () => defaultTopicSurface,
1289
+ defaultSurfaceScope: () => defaultSurfaceScope,
1290
+ clearTopicSessionId: () => clearTopicSessionId,
1291
+ aiMentionFromMode: () => aiMentionFromMode,
1292
+ addParticipantToDB: () => addParticipantToDB,
1293
+ SURFACE_SCOPE_STAMP_RETRY_INTERVAL_MS: () => SURFACE_SCOPE_STAMP_RETRY_INTERVAL_MS
1294
+ });
1295
+
1483
1296
  // ../../packages/core/src/types.ts
1484
1297
  var SUPPORTED_AGENTS = ["maestro", "claude", "codex"];
1485
1298
  function isAgentKind(value) {
@@ -1575,7 +1388,7 @@ var SCHEMA_TRIGGERS = {
1575
1388
  };
1576
1389
  var OTIUM_TOPIC_SCOPE_IMMUTABLE_ERROR = "otium_topic_scope_immutable";
1577
1390
  function topicLinkSchemaIsCurrent(database, nodeId) {
1578
- const objects = new Map(database.query("SELECT name, sql FROM sqlite_master WHERE type IN ('table','index','trigger')").all().map((row) => [row.name, row.sql ?? ""]));
1391
+ const objects = new Map(database.query("SELECT name, sql FROM sqlite_master WHERE type IN ('table','index','trigger')").all().map((row2) => [row2.name, row2.sql ?? ""]));
1579
1392
  for (const name of [...SCHEMA_TABLES, ...SCHEMA_INDEXES, ...SCHEMA_INDEXES_TOMBSTONES]) {
1580
1393
  if (!objects.has(name))
1581
1394
  return false;
@@ -1592,7 +1405,7 @@ function topicLinkSchemaIsCurrent(database, nodeId) {
1592
1405
  return false;
1593
1406
  }
1594
1407
  const identity = database.query("SELECT node_id, epoch_id FROM api_node_identity WHERE singleton = 1").all();
1595
- if (identity.some((row) => row.epoch_id === null))
1408
+ if (identity.some((row2) => row2.epoch_id === null))
1596
1409
  return false;
1597
1410
  if (nodeId && identity[0]?.node_id !== nodeId)
1598
1411
  return false;
@@ -2042,6 +1855,7 @@ function initializeApiTopicsSchema() {
2042
1855
  surface_scope TEXT,
2043
1856
  browser_profile TEXT NOT NULL DEFAULT 'default',
2044
1857
  browser_profile_owner TEXT,
1858
+ browser_connect_port INTEGER,
2045
1859
  session_id TEXT,
2046
1860
  CHECK (
2047
1861
  (kind = 'channel' AND response_policy = 'off' AND agent IS NULL) OR
@@ -2159,6 +1973,9 @@ function initializeApiTopicsSchema() {
2159
1973
  if (!tableColumns2("api_topics").has("browser_profile_owner")) {
2160
1974
  db.exec("ALTER TABLE api_topics ADD COLUMN browser_profile_owner TEXT");
2161
1975
  }
1976
+ if (!tableColumns2("api_topics").has("browser_connect_port")) {
1977
+ db.exec("ALTER TABLE api_topics ADD COLUMN browser_connect_port INTEGER");
1978
+ }
2162
1979
  if (!tableColumns2("api_topics").has("subagent_report_mode")) {
2163
1980
  db.exec("ALTER TABLE api_topics ADD COLUMN subagent_report_mode TEXT NOT NULL DEFAULT 'auto'");
2164
1981
  }
@@ -2434,7 +2251,8 @@ function rowToDto2(r, participants = getTopicParticipants(r.id), tellTargets) {
2434
2251
  } : {},
2435
2252
  visibility: normalizeTopicVisibility(r.visibility),
2436
2253
  surface: normalizeTopicSurface(r.surface),
2437
- surfaceScope: normalizeSurfaceScope(r.surface_scope)
2254
+ surfaceScope: normalizeSurfaceScope(r.surface_scope),
2255
+ ...r.browser_connect_port != null ? { browserConnectPort: r.browser_connect_port } : {}
2438
2256
  };
2439
2257
  }
2440
2258
  function normalizeTopicVisibility(value) {
@@ -2774,6 +2592,12 @@ function removeParticipantFromDB(topicId, userId) {
2774
2592
  return true;
2775
2593
  }
2776
2594
  // ../../packages/core/src/storage/app-settings.ts
2595
+ var exports_app_settings = {};
2596
+ __export(exports_app_settings, {
2597
+ setGlobalAiName: () => setGlobalAiName,
2598
+ getGlobalAiName: () => getGlobalAiName,
2599
+ DEFAULT_AI_NAME: () => DEFAULT_AI_NAME
2600
+ });
2777
2601
  import { existsSync as existsSync2, mkdirSync as mkdirSync4, readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "fs";
2778
2602
  import { dirname as dirname3, join as join3 } from "path";
2779
2603
  var DEFAULT_AI_NAME = "Otium";
@@ -2802,6 +2626,14 @@ function setGlobalAiName(name) {
2802
2626
  return aiName;
2803
2627
  }
2804
2628
  // ../../packages/core/src/storage/ask-user-gates.ts
2629
+ var exports_ask_user_gates = {};
2630
+ __export(exports_ask_user_gates, {
2631
+ quarantineForeignAskUserGates: () => quarantineForeignAskUserGates,
2632
+ quarantineAskUserGate: () => quarantineAskUserGate,
2633
+ prepareAskUserGate: () => prepareAskUserGate,
2634
+ claimAskUserGateAndSelect: () => claimAskUserGateAndSelect,
2635
+ cancelAskUserGate: () => cancelAskUserGate
2636
+ });
2805
2637
  function initializeAskUserGateSchema() {
2806
2638
  db.exec(`
2807
2639
  CREATE TABLE IF NOT EXISTS ask_user_gates (
@@ -2991,6 +2823,22 @@ function cancelAskUserGate(topicId, messageId, ownerId, now = new Date().toISOSt
2991
2823
  }).immediate();
2992
2824
  }
2993
2825
  // ../../packages/core/src/storage/conversations.ts
2826
+ var exports_conversations = {};
2827
+ __export(exports_conversations, {
2828
+ replaceRawConversationStrict: () => replaceRawConversationStrict,
2829
+ replaceConversationStrict: () => replaceConversationStrict,
2830
+ readRawConversation: () => readRawConversation,
2831
+ readConversation: () => readConversation,
2832
+ hasActiveConversation: () => hasActiveConversation,
2833
+ getConversationPath: () => getConversationPath,
2834
+ getActiveConversationPath: () => getActiveConversationPath,
2835
+ findLastSessionIdForAgent: () => findLastSessionIdForAgent,
2836
+ cloneConversationLog: () => cloneConversationLog,
2837
+ appendRawConversationEventStrict: () => appendRawConversationEventStrict,
2838
+ appendConversationEventStrict: () => appendConversationEventStrict,
2839
+ appendConversationEvent: () => appendConversationEvent,
2840
+ ConversationLogDivergedError: () => ConversationLogDivergedError
2841
+ });
2994
2842
  import {
2995
2843
  existsSync as existsSync3,
2996
2844
  mkdirSync as mkdirSync5,
@@ -3157,6 +3005,21 @@ function findLastSessionIdForAgent(entries, agent) {
3157
3005
  return null;
3158
3006
  }
3159
3007
  // ../../packages/core/src/storage/decisions.ts
3008
+ var exports_decisions = {};
3009
+ __export(exports_decisions, {
3010
+ writeDecisions: () => writeDecisions,
3011
+ writeDecisionGraphSvg: () => writeDecisionGraphSvg,
3012
+ validateDecisionGraph: () => validateDecisionGraph,
3013
+ updateDecisions: () => updateDecisions,
3014
+ renderDecisionList: () => renderDecisionList,
3015
+ readDecisions: () => readDecisions,
3016
+ getDecisionGraphSvgPath: () => getDecisionGraphSvgPath,
3017
+ getDecisionFilePath: () => getDecisionFilePath,
3018
+ deleteDecisions: () => deleteDecisions,
3019
+ decisionScopeKey: () => decisionScopeKey,
3020
+ createDecisions: () => createDecisions,
3021
+ DECISION_STATUS_VALUES: () => DECISION_STATUS_VALUES
3022
+ });
3160
3023
  import { existsSync as existsSync4, mkdirSync as mkdirSync6, readFileSync as readFileSync4, renameSync as renameSync4, writeFileSync as writeFileSync5 } from "fs";
3161
3024
  import { dirname as dirname5, join as join5 } from "path";
3162
3025
  var DECISION_STATUS_VALUES = [
@@ -3333,6 +3196,39 @@ function renderDecisionList(decisions) {
3333
3196
  ].join(`
3334
3197
  `);
3335
3198
  }
3199
+ // ../../packages/core/src/storage/forum/index.ts
3200
+ var exports_forum = {};
3201
+ __export(exports_forum, {
3202
+ updateTopicThreadId: () => updateTopicThreadId,
3203
+ setTopicMcpExtra: () => setTopicMcpExtra,
3204
+ setTopicMcpEnabled: () => setTopicMcpEnabled,
3205
+ setTopicForkOrigin: () => setTopicForkOrigin,
3206
+ setTopicDescription: () => setTopicDescription,
3207
+ setTopicAgent: () => setTopicAgent,
3208
+ setSessionForTopic: () => setSessionForTopic,
3209
+ setLastShownConfig: () => setLastShownConfig,
3210
+ setDmSessionId: () => setDmSessionId,
3211
+ renameTopic: () => renameTopic,
3212
+ removeTopic: () => removeTopic,
3213
+ getUserConfig: () => getUserConfig,
3214
+ getTopicNames: () => getTopicNames,
3215
+ getTopicMcpConfig: () => getTopicMcpConfig,
3216
+ getTopicDescription: () => getTopicDescription,
3217
+ getTopicByName: () => getTopicByName2,
3218
+ getTopicAgent: () => getTopicAgent,
3219
+ getSessionForTopic: () => getSessionForTopic,
3220
+ getLastShownConfig: () => getLastShownConfig,
3221
+ getDmSessionId: () => getDmSessionId,
3222
+ getCommunicateThreadId: () => getCommunicateThreadId,
3223
+ getAllUserIds: () => getAllUserIds,
3224
+ getAllTopics: () => getAllTopics,
3225
+ flushSessionCache: () => flushSessionCache,
3226
+ findUserByThread: () => findUserByThread,
3227
+ clearSessionForTopic: () => clearSessionForTopic,
3228
+ clearDmSessionId: () => clearDmSessionId,
3229
+ addTopic: () => addTopic
3230
+ });
3231
+
3336
3232
  // ../../packages/core/src/platform/error.ts
3337
3233
  function errMsg(e, fallback) {
3338
3234
  if (e instanceof Error)
@@ -3696,6 +3592,22 @@ function setTopicMcpExtra(userId, topicName, extra) {
3696
3592
  const result = db.query("UPDATE topics SET mcp_extra = ? WHERE user_id = ? AND name = ?").run(JSON.stringify(extra), String(userId), topicName);
3697
3593
  return result.changes > 0;
3698
3594
  }
3595
+ // ../../packages/core/src/storage/runtime-process-leases.ts
3596
+ var exports_runtime_process_leases = {};
3597
+ __export(exports_runtime_process_leases, {
3598
+ waitForRuntimeProcessLease: () => waitForRuntimeProcessLease,
3599
+ waitForRequiredRuntimeProcessLease: () => waitForRequiredRuntimeProcessLease,
3600
+ removeDeadRuntimeProcessLeases: () => removeDeadRuntimeProcessLeases,
3601
+ releaseRuntimeProcessLease: () => releaseRuntimeProcessLease,
3602
+ listRuntimeProcessLeases: () => listRuntimeProcessLeases,
3603
+ isRuntimeProcessLeaseAlive: () => isRuntimeProcessLeaseAlive,
3604
+ heartbeatRuntimeProcessLease: () => heartbeatRuntimeProcessLease,
3605
+ getRuntimeProcessLease: () => getRuntimeProcessLease,
3606
+ acquireRuntimeProcessLease: () => acquireRuntimeProcessLease,
3607
+ PROCESS_LEASE_STALE_MS: () => PROCESS_LEASE_STALE_MS,
3608
+ PROCESS_LEASE_HEARTBEAT_MS: () => PROCESS_LEASE_HEARTBEAT_MS
3609
+ });
3610
+
3699
3611
  // ../../packages/core/src/storage/runtime-leases.ts
3700
3612
  import { randomUUID } from "crypto";
3701
3613
  var RUNTIME_INSTANCE_ID = `${process.pid}-${randomUUID()}`;
@@ -3876,7 +3788,7 @@ async function waitForRuntimeProcessLease(role, options = {}) {
3876
3788
  const remaining = deadline - Date.now();
3877
3789
  if (remaining <= 0)
3878
3790
  return null;
3879
- await new Promise((resolve) => setTimeout(resolve, Math.min(interval, remaining)));
3791
+ await new Promise((resolve2) => setTimeout(resolve2, Math.min(interval, remaining)));
3880
3792
  }
3881
3793
  }
3882
3794
  async function waitForRequiredRuntimeProcessLease(role, options = {}) {
@@ -3888,9 +3800,22 @@ async function waitForRequiredRuntimeProcessLease(role, options = {}) {
3888
3800
  throw new Error(`${workloadName} is already running${current ? ` (pid ${current.pid})` : ""}`);
3889
3801
  }
3890
3802
  // ../../packages/core/src/storage/session-asks.ts
3891
- import { createHash } from "crypto";
3892
- import {
3893
- closeSync as closeSync2,
3803
+ var exports_session_asks = {};
3804
+ __export(exports_session_asks, {
3805
+ releasePendingAsk: () => releasePendingAsk,
3806
+ markPendingAskState: () => markPendingAskState,
3807
+ markPendingAskSources: () => markPendingAskSources,
3808
+ listPendingAsksForCaller: () => listPendingAsksForCaller,
3809
+ describePendingAskState: () => describePendingAskState,
3810
+ deletePendingAsksForTopic: () => deletePendingAsksForTopic,
3811
+ createPendingAsk: () => createPendingAsk,
3812
+ clearPendingAskSources: () => clearPendingAskSources,
3813
+ clearPendingAsk: () => clearPendingAsk,
3814
+ PENDING_ASK_TTL_MS: () => PENDING_ASK_TTL_MS
3815
+ });
3816
+ import { createHash } from "crypto";
3817
+ import {
3818
+ closeSync as closeSync2,
3894
3819
  mkdirSync as mkdirSync7,
3895
3820
  openSync as openSync2,
3896
3821
  readdirSync as readdirSync2,
@@ -4248,6 +4173,19 @@ var configureStorageHost2 = configureStorageHost;
4248
4173
  var resetStorageHost2 = resetStorageHost;
4249
4174
  var db2 = storageDatabase;
4250
4175
  // ../../packages/core/src/storage/tasks.ts
4176
+ var exports_tasks = {};
4177
+ __export(exports_tasks, {
4178
+ writeTasks: () => writeTasks,
4179
+ updateTasks: () => updateTasks,
4180
+ taskScopeKey: () => taskScopeKey,
4181
+ taskFileMtimeNs: () => taskFileMtimeNs,
4182
+ renderTaskList: () => renderTaskList,
4183
+ readTasks: () => readTasks,
4184
+ getTaskFilePath: () => getTaskFilePath,
4185
+ deleteTasks: () => deleteTasks,
4186
+ createTasks: () => createTasks,
4187
+ TASK_STATUS_VALUES: () => TASK_STATUS_VALUES
4188
+ });
4251
4189
  import { existsSync as existsSync5, mkdirSync as mkdirSync8, readFileSync as readFileSync6, renameSync as renameSync5, statSync as statSync4, writeFileSync as writeFileSync7 } from "fs";
4252
4190
  import { dirname as dirname7, join as join7 } from "path";
4253
4191
  var TASK_STATUS_VALUES = ["pending", "in_progress", "completed"];
@@ -4374,6 +4312,15 @@ function renderTaskList(tasks) {
4374
4312
  `);
4375
4313
  }
4376
4314
  // ../../packages/core/src/storage/token-stats.ts
4315
+ var exports_token_stats = {};
4316
+ __export(exports_token_stats, {
4317
+ tokenStatsFileId: () => tokenStatsFileId,
4318
+ recordUsage: () => recordUsage,
4319
+ getTopicStats: () => getTopicStats,
4320
+ getStats: () => getStats,
4321
+ deleteTopicStats: () => deleteTopicStats,
4322
+ calcCost: () => calcCost
4323
+ });
4377
4324
  import { createHash as createHash2 } from "crypto";
4378
4325
  import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync8 } from "fs";
4379
4326
  import { join as join8 } from "path";
@@ -4618,6 +4565,11 @@ function getTopicStats(userId, topicId, activeProviderSessionId = getTopicSessio
4618
4565
  return { topicId, ...total, ...currentSession ? { currentSession } : {} };
4619
4566
  }
4620
4567
  // ../../packages/core/src/storage/topic-archive.ts
4568
+ var exports_topic_archive = {};
4569
+ __export(exports_topic_archive, {
4570
+ archiveTopicMessages: () => archiveTopicMessages,
4571
+ archiveConversationEvents: () => archiveConversationEvents
4572
+ });
4621
4573
  import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync9 } from "fs";
4622
4574
  import { join as join10 } from "path";
4623
4575
 
@@ -4641,6 +4593,10 @@ function countMemoryArchiveExchanges(rows) {
4641
4593
  }
4642
4594
 
4643
4595
  // ../../packages/core/src/storage/topic-transcript.ts
4596
+ var exports_topic_transcript = {};
4597
+ __export(exports_topic_transcript, {
4598
+ formatTopicArchiveTranscriptRecord: () => formatTopicArchiveTranscriptRecord
4599
+ });
4644
4600
  function parseJsonField(value) {
4645
4601
  if (!value)
4646
4602
  return;
@@ -4697,6 +4653,12 @@ function formatTopicArchiveTranscriptRecord(row, topicTitle, index) {
4697
4653
  }
4698
4654
 
4699
4655
  // ../../packages/core/src/storage/wiki.ts
4656
+ var exports_wiki = {};
4657
+ __export(exports_wiki, {
4658
+ getWikiDir: () => getWikiDir,
4659
+ getTopicMemoryFilePaths: () => getTopicMemoryFilePaths,
4660
+ getSharedWikiDir: () => getSharedWikiDir
4661
+ });
4700
4662
  import { existsSync as existsSync6, readdirSync as readdirSync3, statSync as statSync5 } from "fs";
4701
4663
  import { basename as basename2, dirname as dirname8, join as join9 } from "path";
4702
4664
  function getWikiDir(_userId, workspaceDir = resolveStorageWorkspaceDir()) {
@@ -4852,6 +4814,14 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
4852
4814
  }
4853
4815
  }
4854
4816
  // ../../packages/core/src/storage/topic-archive-state.ts
4817
+ var exports_topic_archive_state = {};
4818
+ __export(exports_topic_archive_state, {
4819
+ settleTopicArchiveJob: () => settleTopicArchiveJob,
4820
+ setTopicArchiveState: () => setTopicArchiveState,
4821
+ getTopicArchiveState: () => getTopicArchiveState,
4822
+ deleteTopicArchiveState: () => deleteTopicArchiveState,
4823
+ claimTopicArchiveJob: () => claimTopicArchiveJob
4824
+ });
4855
4825
  import { rmSync } from "fs";
4856
4826
  registerStorageSchemaInitializer((database) => {
4857
4827
  database.exec(`
@@ -4980,6 +4950,12 @@ function deleteTopicArchiveState(topicId) {
4980
4950
  })();
4981
4951
  }
4982
4952
  // ../../packages/core/src/storage/topic-settings.ts
4953
+ var exports_topic_settings = {};
4954
+ __export(exports_topic_settings, {
4955
+ setTopicAgentAndSession: () => setTopicAgentAndSession,
4956
+ setTopicAgentAndClearSession: () => setTopicAgentAndClearSession,
4957
+ getTopicAgentSwitchState: () => getTopicAgentSwitchState
4958
+ });
4983
4959
  function toTopicAgentSwitchState(row) {
4984
4960
  if (!isAgentKind(row.agent))
4985
4961
  throw new Error(`Invalid agent in DB: ${row.agent}`);
@@ -5011,203 +4987,203 @@ function setTopicAgentAndClearSession(opts) {
5011
4987
  return changed;
5012
4988
  }
5013
4989
  export {
5014
- ConversationLogDivergedError,
5015
- DECISION_STATUS_VALUES,
5016
- DEFAULT_AI_NAME,
5017
- PENDING_ASK_TTL_MS,
5018
- PROCESS_LEASE_HEARTBEAT_MS,
5019
- PROCESS_LEASE_STALE_MS,
5020
- SURFACE_SCOPE_STAMP_RETRY_INTERVAL_MS,
5021
- TASK_STATUS_VALUES,
5022
- acquireRuntimeProcessLease,
5023
- exports_activity_log as activityLog,
5024
- addParticipantToDB,
5025
- aiMentionFromMode,
5026
- anonymizeApiMessages,
5027
- exports_api_messages as apiMessages,
5028
- exports_api_topic_brief as apiTopicBrief,
5029
- exports_api_topic_config as apiTopicConfig,
5030
- exports_api_topics as apiTopics,
5031
- exports_app_settings as appSettings,
5032
- appendApiMessage,
5033
- appendConversationEvent,
5034
- appendConversationEventStrict,
5035
- appendRawConversationEventStrict,
5036
- archiveConversationEvents,
5037
- archiveTopicMessages,
5038
- exports_ask_user_gates as askUserGates,
5039
- calcCost,
5040
- cancelAskUserGate,
5041
- captureMessageSnapshotForTopic,
5042
- claimAskUserGateAndSelect,
5043
- claimTopicArchiveJob,
5044
- clearPendingAsk,
5045
- clearPendingAskSources,
5046
- clearTopicSessionId,
5047
- cloneConversationLog,
5048
- configureStorageHost2 as configureStorageHost,
5049
- exports_conversations as conversations,
5050
- copyMessageSnapshotToTopic,
5051
- copyMessagesForTopic,
5052
- countThreadReplies,
5053
- createDecisions,
5054
- createPendingAsk,
5055
- createTasks,
5056
- db2 as db,
5057
- decisionScopeKey,
5058
- exports_decisions as decisions,
5059
- defaultSurfaceScope,
5060
- defaultTopicSurface,
5061
- deleteApiTopicConfig,
5062
- deleteDecisions,
5063
- deleteMessagesForTopic,
5064
- deletePendingAsksForTopic,
5065
- deleteTasks,
5066
- deleteTopic,
5067
- deleteTopicArchiveState,
5068
- deleteTopicBrief,
5069
- deleteTopicStats,
5070
- describePendingAskState,
5071
- findLastSessionIdForAgent,
5072
- findRecentUserMessage,
5073
- findThreadRootsByPrefix,
5074
- findTopicTitleConflict,
5075
- formatTopicArchiveTranscriptRecord,
5076
- exports_forum as forum,
5077
- getActiveConversationPath,
5078
- getAllMessagesForTopic,
5079
- getApiMessage,
5080
- getApiTopicConfig,
5081
- getConversationPath,
5082
- getDecisionFilePath,
5083
- getDecisionGraphSvgPath,
5084
- getGlobalAiName,
5085
- getLastMessagePreviews,
5086
- getManagerTopicForUser,
5087
- getMessagesForTopicAfterRowid,
5088
- getRuntimeProcessLease,
5089
- getSharedWikiDir,
5090
- getStats,
5091
- getTaskFilePath,
5092
- getThreadSummaries,
5093
- getTopic,
5094
- getTopicArchiveState,
5095
- getTopicBrief,
5096
- getTopicByName,
5097
- getTopicByNameAndKind,
5098
- getTopicByNameForUser,
5099
- getTopicMemoryFilePaths,
5100
- getTopicMemoryOrigin,
5101
- getTopicSessionId,
5102
- getTopicStats,
5103
- getWikiDir,
5104
- grantSubagentTellTarget,
5105
- hasActiveConversation,
5106
- heartbeatRuntimeProcessLease,
5107
- inferAiMode,
5108
- inferTopicKind,
5109
- isRuntimeProcessLeaseAlive,
5110
- isSurfaceScopeRequired,
5111
- isSurfaceScopeStampPending,
5112
- isTopicBriefFile,
5113
- isTopicSummaryFile,
5114
- isTopicVisible,
5115
- listApiMessages,
5116
- listApiMessagesByKind,
5117
- listPendingAsksForCaller,
5118
- listRuntimeProcessLeases,
5119
- listSubagentChildTopicIds,
5120
- listSubagentTellTargetIds,
5121
- listThreadMessageRows,
5122
- listThreadMessages,
5123
- listTopicBriefs,
5124
- listTopicIdsForAttachment,
5125
- listTopicThreadRoots,
5126
- listTopics,
5127
- localSurfaceScopeStatus,
5128
- markPendingAskSources,
5129
- markPendingAskState,
5130
- normalizeAiMode,
5131
- normalizeSurfaceScope,
5132
- normalizeTopicKind,
5133
- normalizeTopicState,
5134
- normalizeTopicSurface,
5135
- normalizeTopicVisibility,
5136
- prepareAskUserGate,
5137
- quarantineAskUserGate,
5138
- quarantineForeignAskUserGates,
5139
- readConversation,
5140
- readDecisions,
5141
- readRawConversation,
5142
- readSentFilesForTopic,
5143
- readTasks,
5144
- recordUsage,
5145
- registerApiMessageAppendHook,
5146
- releasePendingAsk,
5147
- releaseRuntimeProcessLease,
5148
- removeDeadRuntimeProcessLeases,
5149
- removeParticipantFromDB,
5150
- removeSentFilesForTopic,
5151
- renderDecisionList,
5152
- renderTaskList,
5153
- reparentTopicChildren,
5154
- replaceConversationStrict,
5155
- replaceRawConversationStrict,
5156
- resetStorageHost2 as resetStorageHost,
5157
- resolveTopicBrief,
5158
- retryPendingSurfaceScopeStamp,
5159
- revokeSubagentTellTarget,
5160
- rotateOldLogs,
5161
- exports_runtime_process_leases as runtimeProcessLeases,
5162
- exports_session_asks as sessionAsks,
5163
- setApiMessageReactions,
5164
- setApiTopicAgent,
5165
- setApiTopicConfig,
5166
- setDefaultSurfaceScope,
5167
- setGlobalAiName,
5168
- setMountedSurfaceScopeCount,
5169
- setSurfaceScopeRequired,
5170
- setTopicArchiveState,
5171
- setTopicBrief,
5172
- setTopicSessionId,
5173
- setTopicSurfaceScope,
5174
- setTopicSurfaces,
5175
- settleTopicArchiveJob,
5176
- softDeleteApiMessage,
5177
- softDeleteApiMessagesByIdPrefix,
5178
- stampUnscopedOtiumTopics,
5179
- surfaceScopeStampStatus,
5180
- taskFileMtimeNs,
5181
- taskScopeKey,
5182
- exports_tasks as tasks,
5183
- exports_token_stats as tokenStats,
5184
- tokenStatsFileId,
5185
- exports_topic_archive as topicArchive,
5186
- exports_topic_archive_state as topicArchiveState,
5187
- topicHasAttachmentFileId,
5188
- exports_topic_settings as topicSettings,
5189
- exports_topic_transcript as topicTranscript,
5190
- updateApiMessageAskUserQuestion,
5191
- updateApiMessageSubagentCard,
5192
- updateApiMessageText,
5193
- updateApiMessageUsage,
5194
- updateDecisions,
5195
- updateTasks,
5196
- upsertTopic,
5197
- validateDecisionGraph,
5198
- waitForRequiredRuntimeProcessLease,
5199
- waitForRuntimeProcessLease,
5200
- exports_wiki as wiki,
5201
- wikiBriefStorageKey,
5202
- wikiSummaryFilename,
5203
- exports_wiki_summary_names as wikiSummaryNames,
5204
- wikiSummarySlug,
5205
- wikiSummaryStorageSlug,
5206
- writeDecisionGraphSvg,
5207
- writeDecisions,
5208
- writeLog,
4990
+ writeTasks,
5209
4991
  writeSentFileLog,
5210
- writeTasks
4992
+ writeLog,
4993
+ writeDecisions,
4994
+ writeDecisionGraphSvg,
4995
+ wikiSummaryStorageSlug,
4996
+ wikiSummarySlug,
4997
+ exports_wiki_summary_names as wikiSummaryNames,
4998
+ wikiSummaryFilename,
4999
+ wikiBriefStorageKey,
5000
+ exports_wiki as wiki,
5001
+ waitForRuntimeProcessLease,
5002
+ waitForRequiredRuntimeProcessLease,
5003
+ validateDecisionGraph,
5004
+ upsertTopic,
5005
+ updateTasks,
5006
+ updateDecisions,
5007
+ updateApiMessageUsage,
5008
+ updateApiMessageText,
5009
+ updateApiMessageSubagentCard,
5010
+ updateApiMessageAskUserQuestion,
5011
+ exports_topic_transcript as topicTranscript,
5012
+ exports_topic_settings as topicSettings,
5013
+ topicHasAttachmentFileId,
5014
+ exports_topic_archive_state as topicArchiveState,
5015
+ exports_topic_archive as topicArchive,
5016
+ tokenStatsFileId,
5017
+ exports_token_stats as tokenStats,
5018
+ exports_tasks as tasks,
5019
+ taskScopeKey,
5020
+ taskFileMtimeNs,
5021
+ surfaceScopeStampStatus,
5022
+ stampUnscopedOtiumTopics,
5023
+ softDeleteApiMessagesByIdPrefix,
5024
+ softDeleteApiMessage,
5025
+ settleTopicArchiveJob,
5026
+ setTopicSurfaces,
5027
+ setTopicSurfaceScope,
5028
+ setTopicSessionId,
5029
+ setTopicBrief,
5030
+ setTopicArchiveState,
5031
+ setSurfaceScopeRequired,
5032
+ setMountedSurfaceScopeCount,
5033
+ setGlobalAiName,
5034
+ setDefaultSurfaceScope,
5035
+ setApiTopicConfig,
5036
+ setApiTopicAgent,
5037
+ setApiMessageReactions,
5038
+ exports_session_asks as sessionAsks,
5039
+ exports_runtime_process_leases as runtimeProcessLeases,
5040
+ rotateOldLogs,
5041
+ revokeSubagentTellTarget,
5042
+ retryPendingSurfaceScopeStamp,
5043
+ resolveTopicBrief,
5044
+ resetStorageHost2 as resetStorageHost,
5045
+ replaceRawConversationStrict,
5046
+ replaceConversationStrict,
5047
+ reparentTopicChildren,
5048
+ renderTaskList,
5049
+ renderDecisionList,
5050
+ removeSentFilesForTopic,
5051
+ removeParticipantFromDB,
5052
+ removeDeadRuntimeProcessLeases,
5053
+ releaseRuntimeProcessLease,
5054
+ releasePendingAsk,
5055
+ registerApiMessageAppendHook,
5056
+ recordUsage,
5057
+ readTasks,
5058
+ readSentFilesForTopic,
5059
+ readRawConversation,
5060
+ readDecisions,
5061
+ readConversation,
5062
+ quarantineForeignAskUserGates,
5063
+ quarantineAskUserGate,
5064
+ prepareAskUserGate,
5065
+ normalizeTopicVisibility,
5066
+ normalizeTopicSurface,
5067
+ normalizeTopicState,
5068
+ normalizeTopicKind,
5069
+ normalizeSurfaceScope,
5070
+ normalizeAiMode,
5071
+ markPendingAskState,
5072
+ markPendingAskSources,
5073
+ localSurfaceScopeStatus,
5074
+ listTopics,
5075
+ listTopicThreadRoots,
5076
+ listTopicIdsForAttachment,
5077
+ listTopicBriefs,
5078
+ listThreadMessages,
5079
+ listThreadMessageRows,
5080
+ listSubagentTellTargetIds,
5081
+ listSubagentChildTopicIds,
5082
+ listRuntimeProcessLeases,
5083
+ listPendingAsksForCaller,
5084
+ listApiMessagesByKind,
5085
+ listApiMessages,
5086
+ isTopicVisible,
5087
+ isTopicSummaryFile,
5088
+ isTopicBriefFile,
5089
+ isSurfaceScopeStampPending,
5090
+ isSurfaceScopeRequired,
5091
+ isRuntimeProcessLeaseAlive,
5092
+ inferTopicKind,
5093
+ inferAiMode,
5094
+ heartbeatRuntimeProcessLease,
5095
+ hasActiveConversation,
5096
+ grantSubagentTellTarget,
5097
+ getWikiDir,
5098
+ getTopicStats,
5099
+ getTopicSessionId,
5100
+ getTopicMemoryOrigin,
5101
+ getTopicMemoryFilePaths,
5102
+ getTopicByNameForUser,
5103
+ getTopicByNameAndKind,
5104
+ getTopicByName,
5105
+ getTopicBrief,
5106
+ getTopicArchiveState,
5107
+ getTopic,
5108
+ getThreadSummaries,
5109
+ getTaskFilePath,
5110
+ getStats,
5111
+ getSharedWikiDir,
5112
+ getRuntimeProcessLease,
5113
+ getMessagesForTopicAfterRowid,
5114
+ getManagerTopicForUser,
5115
+ getLastMessagePreviews,
5116
+ getGlobalAiName,
5117
+ getDecisionGraphSvgPath,
5118
+ getDecisionFilePath,
5119
+ getConversationPath,
5120
+ getApiTopicConfig,
5121
+ getApiMessage,
5122
+ getAllMessagesForTopic,
5123
+ getActiveConversationPath,
5124
+ exports_forum as forum,
5125
+ formatTopicArchiveTranscriptRecord,
5126
+ findTopicTitleConflict,
5127
+ findThreadRootsByPrefix,
5128
+ findRecentUserMessage,
5129
+ findLastSessionIdForAgent,
5130
+ describePendingAskState,
5131
+ deleteTopicStats,
5132
+ deleteTopicBrief,
5133
+ deleteTopicArchiveState,
5134
+ deleteTopic,
5135
+ deleteTasks,
5136
+ deletePendingAsksForTopic,
5137
+ deleteMessagesForTopic,
5138
+ deleteDecisions,
5139
+ deleteApiTopicConfig,
5140
+ defaultTopicSurface,
5141
+ defaultSurfaceScope,
5142
+ exports_decisions as decisions,
5143
+ decisionScopeKey,
5144
+ db2 as db,
5145
+ createTasks,
5146
+ createPendingAsk,
5147
+ createDecisions,
5148
+ countThreadReplies,
5149
+ copyMessagesForTopic,
5150
+ copyMessageSnapshotToTopic,
5151
+ exports_conversations as conversations,
5152
+ configureStorageHost2 as configureStorageHost,
5153
+ cloneConversationLog,
5154
+ clearTopicSessionId,
5155
+ clearPendingAskSources,
5156
+ clearPendingAsk,
5157
+ claimTopicArchiveJob,
5158
+ claimAskUserGateAndSelect,
5159
+ captureMessageSnapshotForTopic,
5160
+ cancelAskUserGate,
5161
+ calcCost,
5162
+ exports_ask_user_gates as askUserGates,
5163
+ archiveTopicMessages,
5164
+ archiveConversationEvents,
5165
+ appendRawConversationEventStrict,
5166
+ appendConversationEventStrict,
5167
+ appendConversationEvent,
5168
+ appendApiMessage,
5169
+ exports_app_settings as appSettings,
5170
+ exports_api_topics as apiTopics,
5171
+ exports_api_topic_config as apiTopicConfig,
5172
+ exports_api_topic_brief as apiTopicBrief,
5173
+ exports_api_messages as apiMessages,
5174
+ anonymizeApiMessages,
5175
+ aiMentionFromMode,
5176
+ addParticipantToDB,
5177
+ exports_activity_log as activityLog,
5178
+ acquireRuntimeProcessLease,
5179
+ TASK_STATUS_VALUES,
5180
+ SURFACE_SCOPE_STAMP_RETRY_INTERVAL_MS,
5181
+ PROCESS_LEASE_STALE_MS,
5182
+ PROCESS_LEASE_HEARTBEAT_MS,
5183
+ PENDING_ASK_TTL_MS,
5184
+ DEFAULT_AI_NAME,
5185
+ DECISION_STATUS_VALUES,
5186
+ ConversationLogDivergedError
5211
5187
  };
5212
5188
 
5213
- //# debugId=E28A3BB82DB9FF4A64756E2164756E21
5189
+ //# debugId=0E6C4F3F0C7EF59464756E2164756E21