negotium 0.21.2 → 0.22.0
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 +52 -6
- package/dist/agent-helpers.js.map +7 -7
- package/dist/background-bash.js.map +1 -1
- package/dist/browser-runtime.js.map +1 -1
- package/dist/{chunk-z3qhxy33.js → chunk-bbwa785m.js} +2 -2
- package/dist/{chunk-z3qhxy33.js.map → chunk-bbwa785m.js.map} +2 -2
- package/dist/chunk-pvp197f1.js.map +1 -1
- package/dist/chunk-zjz52hzq.js.map +1 -1
- package/dist/hosted-agent.js +2 -2
- package/dist/hosted-agent.js.map +2 -2
- package/dist/main.js +137 -41
- package/dist/main.js.map +12 -12
- package/dist/mcp-factories.js +52 -6
- package/dist/mcp-factories.js.map +7 -7
- package/dist/media.js.map +1 -1
- package/dist/prompts.js.map +1 -1
- package/dist/query-runtime.js +14 -2
- package/dist/query-runtime.js.map +4 -4
- package/dist/registry.js +1 -1
- package/dist/runtime/src/mcp/session-comm/server.ts +2 -2
- package/dist/runtime/src/query/active-rooms.ts +22 -2
- package/dist/runtime/src/runtime/inbox.ts +74 -41
- package/dist/runtime/src/runtime/turn-runner.ts +4 -2
- package/dist/runtime/src/storage/token-stats.ts +62 -1
- package/dist/runtime/src/types.ts +6 -1
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-helpers.js.map +1 -1
- package/dist/storage.js +36 -2
- package/dist/storage.js.map +4 -4
- package/dist/types/packages/core/src/query/active-rooms.d.ts +8 -2
- package/dist/types/packages/core/src/storage/token-stats.d.ts +9 -0
- package/dist/types/packages/core/src/types.d.ts +6 -1
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/dist/vault.js.map +1 -1
- package/package.json +2 -2
package/dist/agent-helpers.js
CHANGED
|
@@ -5199,7 +5199,7 @@ var init_codex = __esm(async () => {
|
|
|
5199
5199
|
});
|
|
5200
5200
|
|
|
5201
5201
|
// ../../packages/core/src/version.ts
|
|
5202
|
-
var NEGOTIUM_VERSION = "0.
|
|
5202
|
+
var NEGOTIUM_VERSION = "0.22.0";
|
|
5203
5203
|
|
|
5204
5204
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
5205
5205
|
import { spawn as spawn2 } from "child_process";
|
|
@@ -10999,8 +10999,20 @@ class InterSessionQueue {
|
|
|
10999
10999
|
keysForRoom() {
|
|
11000
11000
|
return Array.from(this.queue.keys());
|
|
11001
11001
|
}
|
|
11002
|
-
drop(topicId) {
|
|
11002
|
+
drop(topicId, reason = "target session was stopped before the request ran") {
|
|
11003
|
+
const bucket = this.queue.get(topicId);
|
|
11003
11004
|
this.queue.delete(topicId);
|
|
11005
|
+
if (!bucket)
|
|
11006
|
+
return 0;
|
|
11007
|
+
const dropped = bucket.items.slice(bucket.head);
|
|
11008
|
+
for (const inject of dropped) {
|
|
11009
|
+
try {
|
|
11010
|
+
inject.onSettled?.({ queryId: "", kind: "error", error: reason });
|
|
11011
|
+
} catch (err) {
|
|
11012
|
+
logger.warn({ err, topicId, requestId: inject.requestId }, "session inject drop settlement hook failed");
|
|
11013
|
+
}
|
|
11014
|
+
}
|
|
11015
|
+
return dropped.length;
|
|
11004
11016
|
}
|
|
11005
11017
|
size(topicId) {
|
|
11006
11018
|
const bucket = this.queue.get(topicId);
|
|
@@ -13940,6 +13952,30 @@ function isQueryRecord(value) {
|
|
|
13940
13952
|
const record = value;
|
|
13941
13953
|
return record.schemaVersion === 2 && typeof record.timestamp === "string" && typeof record.session === "string" && typeof record.topicId === "string" && typeof record.agent === "string" && typeof record.model === "string" && typeof record.inputTokens === "number" && typeof record.outputTokens === "number" && typeof record.cacheCreationInputTokens === "number" && typeof record.cacheReadInputTokens === "number" && typeof record.estimatedCostUsd === "number";
|
|
13942
13954
|
}
|
|
13955
|
+
function previousCumulativeCost(userId, providerSessionId) {
|
|
13956
|
+
let lines;
|
|
13957
|
+
try {
|
|
13958
|
+
lines = readJsonlLines(queriesPath(userId));
|
|
13959
|
+
} catch {
|
|
13960
|
+
return 0;
|
|
13961
|
+
}
|
|
13962
|
+
for (let i = lines.length - 1;i >= 0; i--) {
|
|
13963
|
+
let parsed;
|
|
13964
|
+
try {
|
|
13965
|
+
parsed = JSON.parse(lines[i]);
|
|
13966
|
+
} catch {
|
|
13967
|
+
continue;
|
|
13968
|
+
}
|
|
13969
|
+
if (parsed.providerSessionId !== providerSessionId)
|
|
13970
|
+
continue;
|
|
13971
|
+
if (typeof parsed.cumulativeCostUsd === "number")
|
|
13972
|
+
return parsed.cumulativeCostUsd;
|
|
13973
|
+
if (typeof parsed.estimatedCostUsd === "number")
|
|
13974
|
+
return parsed.estimatedCostUsd;
|
|
13975
|
+
return 0;
|
|
13976
|
+
}
|
|
13977
|
+
return 0;
|
|
13978
|
+
}
|
|
13943
13979
|
function recordUsage(userId, session, usage, context) {
|
|
13944
13980
|
const cacheReadInputTokens = usage.cacheReadInputTokens ?? 0;
|
|
13945
13981
|
const inputTokens = context.agent === "claude" ? usage.inputTokens : Math.max(0, usage.inputTokens - cacheReadInputTokens);
|
|
@@ -13949,6 +13985,15 @@ function recordUsage(userId, session, usage, context) {
|
|
|
13949
13985
|
cacheCreationInputTokens: usage.cacheCreationInputTokens ?? 0,
|
|
13950
13986
|
cacheReadInputTokens
|
|
13951
13987
|
};
|
|
13988
|
+
let estimatedCostUsd;
|
|
13989
|
+
let cumulativeCostUsd;
|
|
13990
|
+
if (usage.costUsd !== undefined) {
|
|
13991
|
+
const previous = context.providerSessionId ? previousCumulativeCost(userId, context.providerSessionId) : 0;
|
|
13992
|
+
estimatedCostUsd = Math.max(0, usage.costUsd - previous);
|
|
13993
|
+
cumulativeCostUsd = usage.costUsd;
|
|
13994
|
+
} else {
|
|
13995
|
+
estimatedCostUsd = estimateUsageCost(context.agent, context.model, normalized);
|
|
13996
|
+
}
|
|
13952
13997
|
const record = {
|
|
13953
13998
|
schemaVersion: 2,
|
|
13954
13999
|
timestamp: new Date().toISOString(),
|
|
@@ -13960,7 +14005,8 @@ function recordUsage(userId, session, usage, context) {
|
|
|
13960
14005
|
...normalized,
|
|
13961
14006
|
...usage.contextTokens !== undefined ? { contextTokens: usage.contextTokens } : {},
|
|
13962
14007
|
...usage.contextWindow !== undefined ? { contextWindow: usage.contextWindow } : {},
|
|
13963
|
-
estimatedCostUsd
|
|
14008
|
+
estimatedCostUsd,
|
|
14009
|
+
...cumulativeCostUsd !== undefined ? { cumulativeCostUsd } : {}
|
|
13964
14010
|
};
|
|
13965
14011
|
try {
|
|
13966
14012
|
appendJsonlEntry(queriesPath(userId), record);
|
|
@@ -20650,9 +20696,8 @@ function startAiTurn(params) {
|
|
|
20650
20696
|
contextWindow: outcome.usage.contextWindow
|
|
20651
20697
|
} : undefined, { agent: agentKind, model: resolvedModel, budgetReason: outcome.reason });
|
|
20652
20698
|
WsHub.get().broadcastTopicNotice(topicId, "warning", "\uC608\uC0B0 \uD55C\uB3C4 \uB3C4\uB2EC");
|
|
20653
|
-
} else {
|
|
20654
|
-
await deliverAskError(queryId, topic.title, error);
|
|
20655
20699
|
}
|
|
20700
|
+
await deliverAskError(queryId, topic.title, error);
|
|
20656
20701
|
await settleSubagentFailure(queryId, error);
|
|
20657
20702
|
try {
|
|
20658
20703
|
onSettled?.({ queryId, kind: "error", error });
|
|
@@ -20697,6 +20742,7 @@ function startAiTurn(params) {
|
|
|
20697
20742
|
WsHub.get().broadcastError(topicId, queryId, error);
|
|
20698
20743
|
WsHub.get().broadcastTopicNotice(topicId, "error", "\uC751\uB2F5 \uC2E4\uD328");
|
|
20699
20744
|
}
|
|
20745
|
+
await deliverAskError(queryId, topic.title, error);
|
|
20700
20746
|
await settleSubagentFailure(queryId, classifyAgentError(error, agentKind));
|
|
20701
20747
|
try {
|
|
20702
20748
|
onSettled?.({
|
|
@@ -22793,4 +22839,4 @@ export {
|
|
|
22793
22839
|
DEFAULT_SELF_CONFIG_PRODUCT
|
|
22794
22840
|
};
|
|
22795
22841
|
|
|
22796
|
-
//# debugId=
|
|
22842
|
+
//# debugId=15A62BAA7CA7894C64756E2164756E21
|