negotium 0.2.18 → 0.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-helpers.js +367 -313
- package/dist/agent-helpers.js.map +18 -18
- package/dist/background-bash.js +3 -2
- package/dist/background-bash.js.map +3 -3
- package/dist/browser-runtime.js +60 -36
- package/dist/browser-runtime.js.map +6 -6
- package/dist/{chunk-fc58cqry.js → chunk-g2kqfdwm.js} +154 -24
- package/dist/{chunk-fc58cqry.js.map → chunk-g2kqfdwm.js.map} +7 -6
- package/dist/hosted-agent.js +183 -53
- package/dist/hosted-agent.js.map +8 -7
- package/dist/main.js +1395 -626
- package/dist/main.js.map +27 -26
- package/dist/mcp-factories.js +1204 -624
- package/dist/mcp-factories.js.map +21 -20
- package/dist/prompts.js +3 -2
- package/dist/prompts.js.map +3 -3
- package/dist/query-runtime.js +47 -26
- package/dist/query-runtime.js.map +4 -4
- package/dist/registry.js +3 -3
- package/dist/registry.js.map +2 -2
- package/dist/rollout.js +1 -1
- package/dist/runtime/src/agents/archiver.ts +4 -3
- package/dist/runtime/src/application/switch-topic-access-mode.ts +81 -8
- package/dist/runtime/src/bus.ts +19 -2
- package/dist/runtime/src/mcp/canonical-proxy-server.ts +13 -14
- package/dist/runtime/src/mcp/session-comm/runtime.ts +16 -0
- package/dist/runtime/src/mcp/wiki-search-index.ts +359 -0
- package/dist/runtime/src/mcp/wiki-server.ts +559 -98
- package/dist/runtime/src/platform/config.ts +13 -1
- package/dist/runtime/src/platform/mcp-config.ts +1 -1
- package/dist/runtime/src/prompts/agents/wiki-archiver.md +62 -47
- package/dist/runtime/src/runtime/ask-callbacks.ts +19 -11
- package/dist/runtime/src/runtime/background-sessions.ts +9 -7
- package/dist/runtime/src/runtime/visual-store.ts +31 -23
- package/dist/runtime/src/storage/api-topics.ts +26 -0
- package/dist/runtime/src/storage/browser-profiles.ts +16 -8
- package/dist/runtime/src/storage/runtime-events.ts +30 -20
- package/dist/runtime/src/storage/runtime-gateway-submissions.ts +24 -16
- package/dist/runtime/src/storage/runtime-turn-requests.ts +9 -1
- package/dist/runtime/src/storage/self-schedules.ts +32 -24
- package/dist/runtime/src/storage/storage-host.ts +105 -43
- package/dist/runtime/src/storage/vault.ts +12 -3
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-helpers.js +47 -26
- package/dist/runtime-helpers.js.map +4 -4
- package/dist/storage.js +76 -41
- package/dist/storage.js.map +4 -4
- package/dist/types/packages/core/src/agents/archiver.d.ts +1 -1
- package/dist/types/packages/core/src/mcp/wiki-search-index.d.ts +59 -0
- package/dist/types/packages/core/src/storage/api-topics.d.ts +15 -0
- package/dist/types/packages/core/src/storage/storage-host.d.ts +10 -0
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/dist/vault.js +140 -10
- package/dist/vault.js.map +6 -5
- package/package.json +1 -1
package/dist/storage.js
CHANGED
|
@@ -245,13 +245,29 @@ if (isBun) {
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
// ../../packages/core/src/storage/storage-host.ts
|
|
248
|
-
var
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
248
|
+
var STORAGE_HOST_STATE = Symbol.for("negotium.storage-host.state.v1");
|
|
249
|
+
function storageState() {
|
|
250
|
+
const holder = globalThis;
|
|
251
|
+
const existing = holder[STORAGE_HOST_STATE];
|
|
252
|
+
if (existing)
|
|
253
|
+
return existing;
|
|
254
|
+
const created = {
|
|
255
|
+
configuredHost: {},
|
|
256
|
+
fallbackDatabase: null,
|
|
257
|
+
fallbackDatabasePath: null,
|
|
258
|
+
frames: [],
|
|
259
|
+
schemaInitializers: [],
|
|
260
|
+
initializedSchemas: new WeakMap,
|
|
261
|
+
initializingDatabases: new WeakSet
|
|
262
|
+
};
|
|
263
|
+
Object.defineProperty(holder, STORAGE_HOST_STATE, {
|
|
264
|
+
value: created,
|
|
265
|
+
enumerable: false,
|
|
266
|
+
writable: false,
|
|
267
|
+
configurable: false
|
|
268
|
+
});
|
|
269
|
+
return created;
|
|
270
|
+
}
|
|
255
271
|
function envPath(name, fallback) {
|
|
256
272
|
const value = process.env[name]?.trim();
|
|
257
273
|
return resolve(value || fallback);
|
|
@@ -306,36 +322,37 @@ function initializeDatabase(database) {
|
|
|
306
322
|
}
|
|
307
323
|
function defaultDatabase() {
|
|
308
324
|
const path = defaultSessionsDatabasePath();
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
325
|
+
const state = storageState();
|
|
326
|
+
if (state.fallbackDatabase && state.fallbackDatabasePath === path)
|
|
327
|
+
return state.fallbackDatabase;
|
|
328
|
+
if (state.fallbackDatabase)
|
|
329
|
+
state.fallbackDatabase.close();
|
|
313
330
|
mkdirSync2(dirname2(path), { recursive: true });
|
|
314
|
-
fallbackDatabase = new Database(path, { create: true });
|
|
315
|
-
fallbackDatabasePath = path;
|
|
316
|
-
initializeDatabase(fallbackDatabase);
|
|
317
|
-
return fallbackDatabase;
|
|
331
|
+
state.fallbackDatabase = new Database(path, { create: true });
|
|
332
|
+
state.fallbackDatabasePath = path;
|
|
333
|
+
initializeDatabase(state.fallbackDatabase);
|
|
334
|
+
return state.fallbackDatabase;
|
|
318
335
|
}
|
|
319
336
|
function resolveStorageDatabase() {
|
|
320
|
-
return configuredHost.database ?? defaultDatabase();
|
|
337
|
+
return storageState().configuredHost.database ?? defaultDatabase();
|
|
321
338
|
}
|
|
322
339
|
function resolveStorageDataDir() {
|
|
323
|
-
return configuredHost.dataDir ?? defaultDataDir();
|
|
340
|
+
return storageState().configuredHost.dataDir ?? defaultDataDir();
|
|
324
341
|
}
|
|
325
342
|
function resolveStorageLogDir() {
|
|
326
|
-
return configuredHost.logDir ?? defaultLogDir();
|
|
343
|
+
return storageState().configuredHost.logDir ?? defaultLogDir();
|
|
327
344
|
}
|
|
328
345
|
function resolveStorageSessionAsksDir() {
|
|
329
|
-
return configuredHost.sessionAsksDir ?? defaultSessionAsksDir();
|
|
346
|
+
return storageState().configuredHost.sessionAsksDir ?? defaultSessionAsksDir();
|
|
330
347
|
}
|
|
331
348
|
function resolveStorageWorkspaceDir() {
|
|
332
|
-
return configuredHost.workspaceDir ?? defaultWorkspaceDir();
|
|
349
|
+
return storageState().configuredHost.workspaceDir ?? defaultWorkspaceDir();
|
|
333
350
|
}
|
|
334
351
|
function resolveStorageSharedWikiDir() {
|
|
335
|
-
return configuredHost.sharedWikiDir ?? join(resolveStorageWorkspaceDir(), "wiki");
|
|
352
|
+
return storageState().configuredHost.sharedWikiDir ?? join(resolveStorageWorkspaceDir(), "wiki");
|
|
336
353
|
}
|
|
337
354
|
function resolveStorageUsersLogDir() {
|
|
338
|
-
return configuredHost.usersLogDir ?? join(resolveStorageDataDir(), "users");
|
|
355
|
+
return storageState().configuredHost.usersLogDir ?? join(resolveStorageDataDir(), "users");
|
|
339
356
|
}
|
|
340
357
|
var STORAGE_PATH_KEYS = [
|
|
341
358
|
"dataDir",
|
|
@@ -362,50 +379,56 @@ function normalizeStorageHostPatch(options) {
|
|
|
362
379
|
return Object.freeze(patch);
|
|
363
380
|
}
|
|
364
381
|
function refreshConfiguredHost() {
|
|
365
|
-
|
|
382
|
+
const state = storageState();
|
|
383
|
+
state.configuredHost = Object.freeze(Object.assign({}, ...state.frames.filter((frame) => frame.active).map((frame) => frame.patch)));
|
|
366
384
|
}
|
|
367
385
|
function configureStorageHost(options) {
|
|
368
386
|
const frame = { active: true, patch: normalizeStorageHostPatch(options) };
|
|
369
|
-
|
|
387
|
+
storageState().frames.push(frame);
|
|
370
388
|
refreshConfiguredHost();
|
|
371
389
|
return () => {
|
|
372
390
|
if (!frame.active)
|
|
373
391
|
return;
|
|
374
392
|
frame.active = false;
|
|
375
|
-
const
|
|
393
|
+
const frames = storageState().frames;
|
|
394
|
+
const index = frames.indexOf(frame);
|
|
376
395
|
if (index >= 0)
|
|
377
|
-
|
|
396
|
+
frames.splice(index, 1);
|
|
378
397
|
refreshConfiguredHost();
|
|
379
398
|
};
|
|
380
399
|
}
|
|
381
400
|
function resetStorageHost() {
|
|
382
|
-
|
|
401
|
+
const frames = storageState().frames;
|
|
402
|
+
for (const frame of frames)
|
|
383
403
|
frame.active = false;
|
|
384
|
-
|
|
404
|
+
frames.length = 0;
|
|
385
405
|
refreshConfiguredHost();
|
|
386
406
|
}
|
|
387
407
|
function closeStorageDatabase() {
|
|
388
|
-
|
|
408
|
+
const state = storageState();
|
|
409
|
+
if (!state.fallbackDatabase)
|
|
389
410
|
return;
|
|
390
|
-
fallbackDatabase.close();
|
|
391
|
-
fallbackDatabase = null;
|
|
392
|
-
fallbackDatabasePath = null;
|
|
411
|
+
state.fallbackDatabase.close();
|
|
412
|
+
state.fallbackDatabase = null;
|
|
413
|
+
state.fallbackDatabasePath = null;
|
|
393
414
|
}
|
|
394
415
|
function registerStorageSchemaInitializer(initialize, priority = 100) {
|
|
395
|
-
|
|
396
|
-
|
|
416
|
+
const initializers = storageState().schemaInitializers;
|
|
417
|
+
initializers.push({ initialize, priority });
|
|
418
|
+
initializers.sort((a, b) => a.priority - b.priority);
|
|
397
419
|
}
|
|
398
420
|
function ensureStorageSchemas(database = resolveStorageDatabase()) {
|
|
399
|
-
|
|
421
|
+
const state = storageState();
|
|
422
|
+
if (state.initializingDatabases.has(database))
|
|
400
423
|
return;
|
|
401
|
-
let initialized = initializedSchemas.get(database);
|
|
424
|
+
let initialized = state.initializedSchemas.get(database);
|
|
402
425
|
if (!initialized) {
|
|
403
426
|
initialized = new Set;
|
|
404
|
-
initializedSchemas.set(database, initialized);
|
|
427
|
+
state.initializedSchemas.set(database, initialized);
|
|
405
428
|
}
|
|
406
|
-
initializingDatabases.add(database);
|
|
429
|
+
state.initializingDatabases.add(database);
|
|
407
430
|
try {
|
|
408
|
-
for (const entry of schemaInitializers) {
|
|
431
|
+
for (const entry of state.schemaInitializers) {
|
|
409
432
|
if (initialized.has(entry.initialize))
|
|
410
433
|
continue;
|
|
411
434
|
initialized.add(entry.initialize);
|
|
@@ -417,7 +440,7 @@ function ensureStorageSchemas(database = resolveStorageDatabase()) {
|
|
|
417
440
|
}
|
|
418
441
|
}
|
|
419
442
|
} finally {
|
|
420
|
-
initializingDatabases.delete(database);
|
|
443
|
+
state.initializingDatabases.delete(database);
|
|
421
444
|
}
|
|
422
445
|
}
|
|
423
446
|
var internalStorageDatabase = new Proxy({}, {
|
|
@@ -1171,6 +1194,7 @@ var exports_api_topics = {};
|
|
|
1171
1194
|
__export(exports_api_topics, {
|
|
1172
1195
|
upsertTopic: () => upsertTopic,
|
|
1173
1196
|
setTopicSessionId: () => setTopicSessionId,
|
|
1197
|
+
setTopicAccessModes: () => setTopicAccessModes,
|
|
1174
1198
|
setApiTopicAgent: () => setApiTopicAgent,
|
|
1175
1199
|
revokeSubagentTellTarget: () => revokeSubagentTellTarget,
|
|
1176
1200
|
reparentTopicChildren: () => reparentTopicChildren,
|
|
@@ -1651,6 +1675,16 @@ function upsertTopic(t) {
|
|
|
1651
1675
|
}
|
|
1652
1676
|
})();
|
|
1653
1677
|
}
|
|
1678
|
+
function setTopicAccessModes(topicIds, accessMode) {
|
|
1679
|
+
if (topicIds.length === 0)
|
|
1680
|
+
return;
|
|
1681
|
+
const normalized = normalizeTopicAccessMode(accessMode);
|
|
1682
|
+
db.transaction(() => {
|
|
1683
|
+
const update = db.query("UPDATE api_topics SET access_mode = ? WHERE id = ?");
|
|
1684
|
+
for (const topicId of topicIds)
|
|
1685
|
+
update.run(normalized, topicId);
|
|
1686
|
+
})();
|
|
1687
|
+
}
|
|
1654
1688
|
function listTopics() {
|
|
1655
1689
|
const rows = db.query("SELECT * FROM api_topics ORDER BY last_message_at DESC").all();
|
|
1656
1690
|
const participants = getAllTopicParticipants();
|
|
@@ -4017,6 +4051,7 @@ export {
|
|
|
4017
4051
|
setTopicAgentAndSession,
|
|
4018
4052
|
setTopicAgentAndClearSession,
|
|
4019
4053
|
setTopicAgent,
|
|
4054
|
+
setTopicAccessModes,
|
|
4020
4055
|
setSessionForTopic,
|
|
4021
4056
|
setLastShownConfig,
|
|
4022
4057
|
setGlobalAiName,
|
|
@@ -4172,4 +4207,4 @@ export {
|
|
|
4172
4207
|
ConversationLogDivergedError
|
|
4173
4208
|
};
|
|
4174
4209
|
|
|
4175
|
-
//# debugId=
|
|
4210
|
+
//# debugId=65DADDA00971848764756E2164756E21
|