@otium-team/negotium 0.24.1 → 0.24.2
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 +43 -23
- package/dist/agent-helpers.js.map +8 -8
- package/dist/background-bash.js +3 -2
- package/dist/background-bash.js.map +3 -3
- package/dist/browser-runtime.js +21 -5
- package/dist/browser-runtime.js.map +5 -5
- package/dist/{chunk-fzfzskjq.js → chunk-7jdavm0e.js} +20 -4
- package/dist/{chunk-fzfzskjq.js.map → chunk-7jdavm0e.js.map} +4 -4
- package/dist/{chunk-kfckfff2.js → chunk-8nr3h475.js} +3 -3
- package/dist/{chunk-kfckfff2.js.map → chunk-8nr3h475.js.map} +2 -2
- package/dist/{chunk-hn2cqdd0.js → chunk-q701c7k3.js} +1 -1
- package/dist/{chunk-pesnv5zv.js → chunk-r3q0kjed.js} +4 -3
- package/dist/{chunk-pesnv5zv.js.map → chunk-r3q0kjed.js.map} +3 -3
- package/dist/{chunk-d1c2wt8q.js → chunk-wcs8ztpt.js} +4 -2
- package/dist/{chunk-d1c2wt8q.js.map → chunk-wcs8ztpt.js.map} +1 -1
- package/dist/hosted-agent.js +22 -6
- package/dist/hosted-agent.js.map +4 -4
- package/dist/main.js +83 -44
- package/dist/main.js.map +11 -11
- package/dist/mcp-factories.js +43 -23
- package/dist/mcp-factories.js.map +8 -8
- package/dist/media.js +3 -2
- package/dist/media.js.map +3 -3
- package/dist/prompts.js +3 -2
- package/dist/prompts.js.map +3 -3
- package/dist/query-runtime.js +3 -2
- package/dist/query-runtime.js.map +3 -3
- package/dist/registry.js +3 -3
- package/dist/rollout.js +2 -2
- package/dist/runtime/src/application/submit-runtime-gateway-turn.ts +15 -0
- package/dist/runtime/src/application/topic-service.ts +11 -1
- package/dist/runtime/src/platform/config.ts +9 -1
- package/dist/runtime/src/platform/playwright/vault-broker.ts +6 -2
- package/dist/runtime/src/runtime/turn-runner.ts +58 -23
- package/dist/runtime/src/storage/vault-public.ts +1 -0
- package/dist/runtime/src/storage/vault.ts +36 -4
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-helpers.js +3 -2
- package/dist/runtime-helpers.js.map +3 -3
- package/dist/types/packages/core/src/platform/config.d.ts +9 -1
- package/dist/types/packages/core/src/runtime/turn-runner.d.ts +12 -0
- package/dist/types/packages/core/src/storage/vault-public.d.ts +1 -1
- package/dist/types/packages/core/src/storage/vault.d.ts +10 -0
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/dist/vault.js +27 -5
- package/dist/vault.js.map +4 -4
- package/install-browser-rs.mjs +4 -4
- package/package.json +1 -1
- /package/dist/{chunk-hn2cqdd0.js.map → chunk-q701c7k3.js.map} +0 -0
|
@@ -1414,29 +1414,7 @@ export function startAiTurn(params: StartAiTurnParams): string | null {
|
|
|
1414
1414
|
}
|
|
1415
1415
|
// The preempted turn was itself a session-inject → re-queue it so the
|
|
1416
1416
|
// inter-session work isn't lost; it resumes after the user's turn.
|
|
1417
|
-
|
|
1418
|
-
const runningInject = running.injectParams;
|
|
1419
|
-
// A silent ask fork may already contain a partially-consumed provider
|
|
1420
|
-
// rollout. Requeue only its recipe, never that mutable rollout; the old
|
|
1421
|
-
// turn's finally block owns cleanup and the replay prepares a fresh fork.
|
|
1422
|
-
const requeuedInject = prepareInjectReplayAfterUserPreemption(runningInject);
|
|
1423
|
-
const queued = deferInject(requeuedInject);
|
|
1424
|
-
running.injectRequeued = queued;
|
|
1425
|
-
if (queued && runningInject.prepareSession) {
|
|
1426
|
-
// The queued copy retained requestId, so detach it from the dying
|
|
1427
|
-
// control. The async preparation may still publish an old fork after
|
|
1428
|
-
// this abort; finally must clean that fork instead of mistaking it for
|
|
1429
|
-
// the queued replay's resource.
|
|
1430
|
-
running.injectParams = { ...runningInject, requestId: undefined };
|
|
1431
|
-
} else if (!queued && runningInject.forkHandle) {
|
|
1432
|
-
cleanupAgentFork(runningInject.forkHandle);
|
|
1433
|
-
running.injectParams = {
|
|
1434
|
-
...runningInject,
|
|
1435
|
-
forkHandle: undefined,
|
|
1436
|
-
sessionId: undefined,
|
|
1437
|
-
};
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1417
|
+
requeueSessionInjectForUserPreemption(running);
|
|
1440
1418
|
running.abortReason = AbortReason.Internal;
|
|
1441
1419
|
running.abortController.abort();
|
|
1442
1420
|
logger.info(
|
|
@@ -2303,6 +2281,63 @@ export function startAiTurn(params: StartAiTurnParams): string | null {
|
|
|
2303
2281
|
return queryId;
|
|
2304
2282
|
}
|
|
2305
2283
|
|
|
2284
|
+
/**
|
|
2285
|
+
* Re-queue a running session-inject (tell, ask, delegated subagent task) that
|
|
2286
|
+
* a person's turn is about to preempt, so its work resumes after that turn.
|
|
2287
|
+
* Marks the control so the aborted run settles as requeued, not as a failure.
|
|
2288
|
+
* Returns whether the inject is now waiting in the inter-session queue.
|
|
2289
|
+
*/
|
|
2290
|
+
function requeueSessionInjectForUserPreemption(running: RoomQueryControl): boolean {
|
|
2291
|
+
const runningInject = running.injectParams;
|
|
2292
|
+
if (!runningInject) return false;
|
|
2293
|
+
// A silent ask fork may already contain a partially-consumed provider
|
|
2294
|
+
// rollout. Requeue only its recipe, never that mutable rollout; the old
|
|
2295
|
+
// turn's finally block owns cleanup and the replay prepares a fresh fork.
|
|
2296
|
+
const requeuedInject = prepareInjectReplayAfterUserPreemption(runningInject);
|
|
2297
|
+
const queued = deferInject(requeuedInject);
|
|
2298
|
+
running.injectRequeued = queued;
|
|
2299
|
+
if (queued && runningInject.prepareSession) {
|
|
2300
|
+
// The queued copy retained requestId, so detach it from the dying
|
|
2301
|
+
// control. The async preparation may still publish an old fork after
|
|
2302
|
+
// this abort; finally must clean that fork instead of mistaking it for
|
|
2303
|
+
// the queued replay's resource.
|
|
2304
|
+
running.injectParams = { ...runningInject, requestId: undefined };
|
|
2305
|
+
} else if (!queued && runningInject.forkHandle) {
|
|
2306
|
+
cleanupAgentFork(runningInject.forkHandle);
|
|
2307
|
+
running.injectParams = {
|
|
2308
|
+
...runningInject,
|
|
2309
|
+
forkHandle: undefined,
|
|
2310
|
+
sessionId: undefined,
|
|
2311
|
+
};
|
|
2312
|
+
}
|
|
2313
|
+
return queued;
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2316
|
+
/**
|
|
2317
|
+
* A person's steer arrived while this process runs a session-inject in the
|
|
2318
|
+
* topic room (a tell, an ask, or a delegated subagent task). Their durable
|
|
2319
|
+
* turn cannot be claimed while that inject holds the room lease, so the
|
|
2320
|
+
* abort-replace path in {@link startAiTurn} is never reached. Preempt it here
|
|
2321
|
+
* instead: re-queue the inject behind the person's turn and abort it, which
|
|
2322
|
+
* releases the lease so the durable worker starts the person's turn.
|
|
2323
|
+
*
|
|
2324
|
+
* Does nothing (returns false) when the room is idle, runs a person's turn,
|
|
2325
|
+
* or runs an inject that could not be re-queued, so no work is ever dropped.
|
|
2326
|
+
*/
|
|
2327
|
+
export function preemptSessionInjectForUserTurn(topicId: string): boolean {
|
|
2328
|
+
const running = getRoomQuery(topicId);
|
|
2329
|
+
if (!running || isUserOrigin(running.origin) || !running.injectParams) return false;
|
|
2330
|
+
if (running.abortController.signal.aborted) return false;
|
|
2331
|
+
if (!requeueSessionInjectForUserPreemption(running)) return false;
|
|
2332
|
+
running.abortReason = AbortReason.Internal;
|
|
2333
|
+
running.abortController.abort();
|
|
2334
|
+
logger.info(
|
|
2335
|
+
{ topicId, supersededQueryId: running.queryId, supersededOrigin: running.origin },
|
|
2336
|
+
"ai: user steer preempted running session-inject",
|
|
2337
|
+
);
|
|
2338
|
+
return true;
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2306
2341
|
export function wasLocallyRequeuedAfterUserPreemption(
|
|
2307
2342
|
outcomeKind: StreamAgentOutcome["kind"],
|
|
2308
2343
|
control: Pick<RoomQueryControl, "abortReason" | "injectParams" | "injectRequeued">,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { chmodSync, mkdirSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { VAULT_MASTER_KEY } from "#platform/config";
|
|
3
|
+
import { VAULT_MASTER_KEY, VAULT_SHARED_USER_ID } from "#platform/config";
|
|
4
4
|
import { closeDatabase, Database } from "#storage/sqlite";
|
|
5
5
|
import { resolveStorageDataDir } from "#storage/storage-host";
|
|
6
6
|
import { decryptVaultValue, encryptVaultValue, isEncryptedVaultValue } from "#storage/vault-crypto";
|
|
@@ -13,10 +13,21 @@ export interface VaultStorageOptions {
|
|
|
13
13
|
masterKey?: string;
|
|
14
14
|
/** Prior keys rows may still be encrypted under; migrated onto `masterKey`. */
|
|
15
15
|
legacyMasterKeys?: readonly string[];
|
|
16
|
+
/**
|
|
17
|
+
* Owner id of the rows every user may use (see `VAULT_SHARED_USER_ID`). Omitted keeps the
|
|
18
|
+
* process default; null turns sharing off.
|
|
19
|
+
*/
|
|
20
|
+
sharedUserId?: string | null;
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
let vaultDb: VaultDatabase | undefined;
|
|
19
24
|
let vaultMasterKey = VAULT_MASTER_KEY;
|
|
25
|
+
let vaultSharedUserId = VAULT_SHARED_USER_ID;
|
|
26
|
+
|
|
27
|
+
/** The shared owner whose rows `userId` may also use; none for that owner itself. */
|
|
28
|
+
function sharedOwnerFor(userId: string): string | undefined {
|
|
29
|
+
return vaultSharedUserId && vaultSharedUserId !== userId ? vaultSharedUserId : undefined;
|
|
30
|
+
}
|
|
20
31
|
|
|
21
32
|
function initializeVaultDatabase(database: VaultDatabase): void {
|
|
22
33
|
database.exec("PRAGMA journal_mode = WAL");
|
|
@@ -148,6 +159,7 @@ export function configureVaultStorage(options: VaultStorageOptions): () => void
|
|
|
148
159
|
}
|
|
149
160
|
const previousDb = vaultDb;
|
|
150
161
|
const previousMasterKey = vaultMasterKey;
|
|
162
|
+
const previousSharedUserId = vaultSharedUserId;
|
|
151
163
|
const configuredDb =
|
|
152
164
|
options.database ?? openVaultDatabase(options.dataDir ?? resolveStorageDataDir());
|
|
153
165
|
const targetKey = options.masterKey ?? VAULT_MASTER_KEY;
|
|
@@ -168,6 +180,7 @@ export function configureVaultStorage(options: VaultStorageOptions): () => void
|
|
|
168
180
|
}
|
|
169
181
|
vaultDb = configuredDb;
|
|
170
182
|
vaultMasterKey = targetKey;
|
|
183
|
+
if (options.sharedUserId !== undefined) vaultSharedUserId = options.sharedUserId ?? undefined;
|
|
171
184
|
let disposed = false;
|
|
172
185
|
return () => {
|
|
173
186
|
if (disposed) return;
|
|
@@ -177,6 +190,7 @@ export function configureVaultStorage(options: VaultStorageOptions): () => void
|
|
|
177
190
|
}
|
|
178
191
|
vaultDb = previousDb;
|
|
179
192
|
vaultMasterKey = previousMasterKey;
|
|
193
|
+
vaultSharedUserId = previousSharedUserId;
|
|
180
194
|
};
|
|
181
195
|
}
|
|
182
196
|
|
|
@@ -304,6 +318,17 @@ export function vaultGetValue(userId: string, key: string): string | undefined {
|
|
|
304
318
|
return row ? decryptRow(userId, row.key, row.value) : undefined;
|
|
305
319
|
}
|
|
306
320
|
|
|
321
|
+
/**
|
|
322
|
+
* The value `{{KEY}}` stands for in `userId`'s tool inputs: their own row, else the shared owner's.
|
|
323
|
+
* A user's own value wins, so a member can keep a personal credential under a shared name.
|
|
324
|
+
*/
|
|
325
|
+
export function vaultResolveValue(userId: string, key: string): string | undefined {
|
|
326
|
+
const own = vaultGetValue(userId, key);
|
|
327
|
+
if (own !== undefined) return own;
|
|
328
|
+
const shared = sharedOwnerFor(userId);
|
|
329
|
+
return shared ? vaultGetValue(shared, key) : undefined;
|
|
330
|
+
}
|
|
331
|
+
|
|
307
332
|
export interface VaultSubstitutionResult {
|
|
308
333
|
text: string;
|
|
309
334
|
usedKeys: string[];
|
|
@@ -315,7 +340,7 @@ export function vaultSubstituteDetailed(userId: string, text: string): VaultSubs
|
|
|
315
340
|
const usedKeys = new Set<string>();
|
|
316
341
|
const substituted = text.replace(/\{\{([^}]+)\}\}/g, (match, rawKey: string) => {
|
|
317
342
|
const key = normalizeVaultKey(rawKey);
|
|
318
|
-
if (!entries.has(key)) entries.set(key,
|
|
343
|
+
if (!entries.has(key)) entries.set(key, vaultResolveValue(userId, key));
|
|
319
344
|
const value = entries.get(key);
|
|
320
345
|
if (value === undefined) return match;
|
|
321
346
|
usedKeys.add(key);
|
|
@@ -326,7 +351,10 @@ export function vaultSubstituteDetailed(userId: string, text: string): VaultSubs
|
|
|
326
351
|
|
|
327
352
|
/** Detect real {{KEY}} references without decrypting any Vault values. */
|
|
328
353
|
export function valueReferencesVaultKey(userId: string, value: unknown): boolean {
|
|
329
|
-
const
|
|
354
|
+
const shared = sharedOwnerFor(userId);
|
|
355
|
+
const keys = new Set(
|
|
356
|
+
[...vaultList(userId), ...(shared ? vaultList(shared) : [])].map((entry) => entry.key),
|
|
357
|
+
);
|
|
330
358
|
const visit = (candidate: unknown): boolean => {
|
|
331
359
|
if (typeof candidate === "string") {
|
|
332
360
|
for (const match of candidate.matchAll(/\{\{([^}]+)\}\}/g)) {
|
|
@@ -357,7 +385,11 @@ function encodedSecretForms(value: string): string[] {
|
|
|
357
385
|
|
|
358
386
|
/** Scrub raw and common encoded forms before tool output reaches a model. */
|
|
359
387
|
export function redactVaultSecrets(userId: string, text: string): string {
|
|
360
|
-
const
|
|
388
|
+
const shared = sharedOwnerFor(userId);
|
|
389
|
+
const candidates = [
|
|
390
|
+
...vaultListDecryptableValues(userId),
|
|
391
|
+
...(shared ? vaultListDecryptableValues(shared) : []),
|
|
392
|
+
]
|
|
361
393
|
.flatMap((entry) => encodedSecretForms(entry.value).map((form) => ({ form, key: entry.key })))
|
|
362
394
|
.sort((a, b) => b.form.length - a.form.length || a.key.localeCompare(b.key));
|
|
363
395
|
if (candidates.length === 0) return text;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const NEGOTIUM_VERSION = "0.24.
|
|
1
|
+
export const NEGOTIUM_VERSION = "0.24.2";
|
package/dist/runtime-helpers.js
CHANGED
|
@@ -563,7 +563,7 @@ var SESSION_WORKSPACE_DIR = resolve(STATE_DIR, "data", "sessions");
|
|
|
563
563
|
var CLAUDE_EXECUTABLE_ENV = envText("NEGOTIUM_CLAUDE_EXECUTABLE");
|
|
564
564
|
var CLAUDE_EXECUTABLE = CLAUDE_EXECUTABLE_ENV ? resolve(CLAUDE_EXECUTABLE_ENV) : undefined;
|
|
565
565
|
var BINARY_EXTENSION = process.platform === "win32" ? ".exe" : "";
|
|
566
|
-
var BROWSER_RS_VERSION = "v0.
|
|
566
|
+
var BROWSER_RS_VERSION = "v0.8.1";
|
|
567
567
|
var BROWSER_RS_MIN_SECURE_VERSION = "0.2.1";
|
|
568
568
|
function versionAtLeast(actualVersion, minimumVersion) {
|
|
569
569
|
const actual = actualVersion.split(".").map(Number);
|
|
@@ -685,6 +685,7 @@ var NODE_CONTROL_TOKEN = loadOrCreateLocalSecret("NEGOTIUM_CONTROL_TOKEN", "node
|
|
|
685
685
|
var NODE_ID = loadOrCreateLocalSecret("NEGOTIUM_NODE_ID", "node-id");
|
|
686
686
|
var VAULT_MASTER_KEY = loadOrCreateLocalSecret("NEGOTIUM_VAULT_MASTER_KEY", "vault-master-key", { persistEnvValue: true });
|
|
687
687
|
delete process.env.NEGOTIUM_VAULT_MASTER_KEY;
|
|
688
|
+
var VAULT_SHARED_USER_ID = process.env.NEGOTIUM_VAULT_SHARED_USER?.trim() || undefined;
|
|
688
689
|
var NEGOTIUM_PORT = parseInt(process.env.NEGOTIUM_PORT || "7777", 10);
|
|
689
690
|
var hostname = process.env.HOSTNAME || "127.0.0.1";
|
|
690
691
|
var DATA_DIR = resolveLocalStateDir("NEGOTIUM_DATA_DIR", "data");
|
|
@@ -1818,4 +1819,4 @@ export {
|
|
|
1818
1819
|
writeJsonlFile
|
|
1819
1820
|
};
|
|
1820
1821
|
|
|
1821
|
-
//# debugId=
|
|
1822
|
+
//# debugId=109C75203D7173FC64756E2164756E21
|