negotium 0.5.14 → 0.5.16
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 +62 -10
- package/dist/agent-helpers.js.map +7 -7
- package/dist/hosted-agent.js +2 -2
- package/dist/hosted-agent.js.map +2 -2
- package/dist/main.js +114 -17
- package/dist/main.js.map +13 -13
- package/dist/mcp-factories.js +62 -10
- package/dist/mcp-factories.js.map +7 -7
- package/dist/registry.js +2 -2
- package/dist/registry.js.map +2 -2
- package/dist/runtime/src/bus.ts +21 -2
- package/dist/runtime/src/index.ts +1 -0
- package/dist/runtime/src/runtime/inbox.ts +34 -5
- package/dist/runtime/src/runtime/turn-event-stream.ts +5 -0
- package/dist/runtime/src/runtime/turn-runner.ts +61 -3
- package/dist/runtime/src/storage/api-messages.ts +11 -2
- package/dist/runtime/src/types/api.ts +11 -1
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-helpers.js +5 -1
- package/dist/runtime-helpers.js.map +3 -3
- package/dist/storage.js +9 -4
- package/dist/storage.js.map +3 -3
- package/dist/types/packages/core/src/bus.d.ts +4 -0
- package/dist/types/packages/core/src/runtime/turn-event-stream.d.ts +5 -1
- package/dist/types/packages/core/src/runtime/turn-runner.d.ts +4 -0
- package/dist/types/packages/core/src/storage/api-messages.d.ts +1 -0
- package/dist/types/packages/core/src/types/api.d.ts +10 -1
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/agent-helpers.js
CHANGED
|
@@ -2443,7 +2443,7 @@ var init_claude_registry = __esm(() => {
|
|
|
2443
2443
|
});
|
|
2444
2444
|
|
|
2445
2445
|
// ../../packages/core/src/version.ts
|
|
2446
|
-
var NEGOTIUM_VERSION = "0.5.
|
|
2446
|
+
var NEGOTIUM_VERSION = "0.5.16";
|
|
2447
2447
|
|
|
2448
2448
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
2449
2449
|
import { spawn as spawn2 } from "child_process";
|
|
@@ -6413,12 +6413,21 @@ class SqliteRuntimeBus {
|
|
|
6413
6413
|
queryId,
|
|
6414
6414
|
usage,
|
|
6415
6415
|
agent: meta?.agent,
|
|
6416
|
-
model: meta?.model
|
|
6416
|
+
model: meta?.model,
|
|
6417
|
+
budgetReason: meta?.budgetReason
|
|
6417
6418
|
});
|
|
6418
6419
|
}
|
|
6419
6420
|
broadcastError(topicId, queryId, error) {
|
|
6420
6421
|
this.broadcastAiStatus(topicId, { kind: "ai_error", queryId, error });
|
|
6421
6422
|
}
|
|
6423
|
+
broadcastTopicNotice(topicId, severity, label) {
|
|
6424
|
+
this.broadcastAiStatus(topicId, {
|
|
6425
|
+
kind: "topic_notice",
|
|
6426
|
+
severity,
|
|
6427
|
+
label,
|
|
6428
|
+
ts: new Date().toISOString()
|
|
6429
|
+
});
|
|
6430
|
+
}
|
|
6422
6431
|
broadcastAborted(topicId, queryId, reason) {
|
|
6423
6432
|
this.broadcastAiStatus(topicId, { kind: "ai_aborted", queryId, reason });
|
|
6424
6433
|
}
|
|
@@ -7112,6 +7121,7 @@ function initializeApiMessagesSchema() {
|
|
|
7112
7121
|
reactions TEXT,
|
|
7113
7122
|
kind TEXT,
|
|
7114
7123
|
ask_user_question TEXT,
|
|
7124
|
+
tell_card TEXT,
|
|
7115
7125
|
mentions TEXT,
|
|
7116
7126
|
thread_root_id TEXT,
|
|
7117
7127
|
created_at TEXT NOT NULL
|
|
@@ -7141,6 +7151,9 @@ function initializeApiMessagesSchema() {
|
|
|
7141
7151
|
try {
|
|
7142
7152
|
db.exec("ALTER TABLE api_messages ADD COLUMN ask_user_question TEXT");
|
|
7143
7153
|
} catch {}
|
|
7154
|
+
try {
|
|
7155
|
+
db.exec("ALTER TABLE api_messages ADD COLUMN tell_card TEXT");
|
|
7156
|
+
} catch {}
|
|
7144
7157
|
try {
|
|
7145
7158
|
db.exec("ALTER TABLE api_messages ADD COLUMN mentions TEXT");
|
|
7146
7159
|
} catch {}
|
|
@@ -7184,6 +7197,7 @@ function rowToDto(r) {
|
|
|
7184
7197
|
reactions: r.reactions ? JSON.parse(r.reactions) : undefined,
|
|
7185
7198
|
kind: r.kind ?? undefined,
|
|
7186
7199
|
askUserQuestion: r.ask_user_question ? JSON.parse(r.ask_user_question) : undefined,
|
|
7200
|
+
tellCard: r.tell_card ? JSON.parse(r.tell_card) : undefined,
|
|
7187
7201
|
subagentCard: r.subagent_card ? JSON.parse(r.subagent_card) : undefined,
|
|
7188
7202
|
mentions: r.mentions ? JSON.parse(r.mentions) : undefined,
|
|
7189
7203
|
threadRootId: r.thread_root_id ?? undefined,
|
|
@@ -7206,9 +7220,9 @@ function appendApiMessage(msg, options = {}) {
|
|
|
7206
7220
|
let inserted = false;
|
|
7207
7221
|
db.transaction(() => {
|
|
7208
7222
|
const result = db.query(`INSERT INTO api_messages
|
|
7209
|
-
(id, topic_id, parent_id, author_id, source_adapter, source_node, source_message_id, text, query_id, agent_type, model, attachments, usage, deleted, edited_at, reactions, kind, ask_user_question, subagent_card, mentions, thread_root_id, created_at)
|
|
7210
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
7211
|
-
ON CONFLICT(id) DO NOTHING`).run(msg.id, msg.topicId, msg.parentId ?? null, msg.authorId, msg.sourceAdapter ?? null, msg.sourceNode ?? null, msg.sourceMessageId ?? null, msg.text, msg.queryId ?? null, msg.agentType ?? null, msg.model ?? null, msg.attachments ? JSON.stringify(msg.attachments) : null, msg.usage ? JSON.stringify(msg.usage) : null, msg.deleted ? 1 : 0, msg.editedAt ?? null, msg.reactions?.length ? JSON.stringify(msg.reactions) : null, msg.kind ?? null, msg.askUserQuestion ? JSON.stringify(msg.askUserQuestion) : null, msg.subagentCard ? JSON.stringify(msg.subagentCard) : null, msg.mentions?.length ? JSON.stringify(msg.mentions) : null, msg.threadRootId ?? null, msg.createdAt);
|
|
7223
|
+
(id, topic_id, parent_id, author_id, source_adapter, source_node, source_message_id, text, query_id, agent_type, model, attachments, usage, deleted, edited_at, reactions, kind, ask_user_question, tell_card, subagent_card, mentions, thread_root_id, created_at)
|
|
7224
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
7225
|
+
ON CONFLICT(id) DO NOTHING`).run(msg.id, msg.topicId, msg.parentId ?? null, msg.authorId, msg.sourceAdapter ?? null, msg.sourceNode ?? null, msg.sourceMessageId ?? null, msg.text, msg.queryId ?? null, msg.agentType ?? null, msg.model ?? null, msg.attachments ? JSON.stringify(msg.attachments) : null, msg.usage ? JSON.stringify(msg.usage) : null, msg.deleted ? 1 : 0, msg.editedAt ?? null, msg.reactions?.length ? JSON.stringify(msg.reactions) : null, msg.kind ?? null, msg.askUserQuestion ? JSON.stringify(msg.askUserQuestion) : null, msg.tellCard ? JSON.stringify(msg.tellCard) : null, msg.subagentCard ? JSON.stringify(msg.subagentCard) : null, msg.mentions?.length ? JSON.stringify(msg.mentions) : null, msg.threadRootId ?? null, msg.createdAt);
|
|
7212
7226
|
inserted = Number(result.changes ?? 0) > 0;
|
|
7213
7227
|
if (inserted && updateTopicLastMessageAt && !msg.deleted) {
|
|
7214
7228
|
db.query(`UPDATE api_topics
|
|
@@ -15766,6 +15780,10 @@ ${JSON.stringify(event.input ?? {})}`);
|
|
|
15766
15780
|
logger.warn({ topicId, queryId, agentType, model, silent, error: event.content }, "ai: provider returned error");
|
|
15767
15781
|
terminalEmitted = true;
|
|
15768
15782
|
errorOccurred = true;
|
|
15783
|
+
if (event.code === "budget_exceeded") {
|
|
15784
|
+
outcome = { kind: "budget-capped", reason: "cost", usage: event.usage };
|
|
15785
|
+
return outcome;
|
|
15786
|
+
}
|
|
15769
15787
|
if (retryableSessionExpired && isSessionExpiredError(event.content)) {
|
|
15770
15788
|
outcome = { kind: "session-expired", error: event.content };
|
|
15771
15789
|
return outcome;
|
|
@@ -16106,13 +16124,20 @@ function notifyPlaywrightUnavailable(topicId) {
|
|
|
16106
16124
|
return;
|
|
16107
16125
|
playwrightUnavailableNoticeAt.set(topicId, now);
|
|
16108
16126
|
appendSystemMessage(topicId, "Playwright browser tools are unavailable this turn. Browser automation was removed from the tool catalog; retry shortly if browser interaction is required.");
|
|
16127
|
+
WsHub.get().broadcastTopicNotice(topicId, "info", "Playwright \uC0AC\uC6A9 \uBD88\uAC00");
|
|
16109
16128
|
}
|
|
16110
|
-
function appendAskReplyMessage(topicId, text2, agentType) {
|
|
16129
|
+
function appendAskReplyMessage(topicId, text2, sourceLabel, body, kind, agentType) {
|
|
16111
16130
|
const message = {
|
|
16112
16131
|
id: randomUUID16(),
|
|
16113
16132
|
topicId,
|
|
16114
16133
|
authorId: "ai",
|
|
16115
16134
|
text: text2,
|
|
16135
|
+
kind: "tell",
|
|
16136
|
+
tellCard: {
|
|
16137
|
+
fromLabel: sourceLabel,
|
|
16138
|
+
label: `${kind === "error" ? "Error" : "Reply"} from ${sourceLabel}`,
|
|
16139
|
+
message: body
|
|
16140
|
+
},
|
|
16116
16141
|
...agentType ? { agentType } : {},
|
|
16117
16142
|
createdAt: new Date().toISOString()
|
|
16118
16143
|
};
|
|
@@ -16255,7 +16280,7 @@ ${body}`;
|
|
|
16255
16280
|
await markPendingAskFile(pending, "reply_ready");
|
|
16256
16281
|
if (!callerTopic?.agent) {
|
|
16257
16282
|
try {
|
|
16258
|
-
appendAskReplyMessage(pending.callerTopicId, prompt);
|
|
16283
|
+
appendAskReplyMessage(pending.callerTopicId, prompt, sourceLabel, body, kind);
|
|
16259
16284
|
await clearPendingAskFile(pending);
|
|
16260
16285
|
return true;
|
|
16261
16286
|
} catch (err2) {
|
|
@@ -16285,7 +16310,7 @@ ${body}`;
|
|
|
16285
16310
|
}
|
|
16286
16311
|
});
|
|
16287
16312
|
if (queued) {
|
|
16288
|
-
appendAskReplyMessage(pending.callerTopicId, prompt, callerTopic.agent);
|
|
16313
|
+
appendAskReplyMessage(pending.callerTopicId, prompt, sourceLabel, body, kind, callerTopic.agent);
|
|
16289
16314
|
await markPendingAskFile(pending, "queued_for_caller");
|
|
16290
16315
|
return true;
|
|
16291
16316
|
}
|
|
@@ -16294,7 +16319,7 @@ ${body}`;
|
|
|
16294
16319
|
return true;
|
|
16295
16320
|
}
|
|
16296
16321
|
logger.warn({ requestId: pending.requestId, callerTopicId: pending.callerTopicId, source: sourceLabel }, "sessions: ask callback could not enter caller batch; appending direct fallback");
|
|
16297
|
-
appendAskReplyMessage(pending.callerTopicId, prompt, callerTopic.agent);
|
|
16322
|
+
appendAskReplyMessage(pending.callerTopicId, prompt, sourceLabel, body, kind, callerTopic.agent);
|
|
16298
16323
|
await clearPendingAskFile(pending);
|
|
16299
16324
|
return true;
|
|
16300
16325
|
}
|
|
@@ -17162,12 +17187,36 @@ function startAiTurn(params) {
|
|
|
17162
17187
|
return;
|
|
17163
17188
|
}
|
|
17164
17189
|
}
|
|
17190
|
+
if (outcome.kind === "budget-capped") {
|
|
17191
|
+
const error = "The job reached its cost limit";
|
|
17192
|
+
if (!silent) {
|
|
17193
|
+
appendSystemMessage(topicId, "\uC5EC\uAE30\uAE4C\uC9C0 \uC644\uB8CC\uD588\uC5B4\uC694. \uBE44\uC6A9 \uC608\uC0B0 \uD55C\uB3C4\uC5D0 \uB3C4\uB2EC\uD574 \uC791\uC5C5\uC744 \uBA48\uCDC4\uC2B5\uB2C8\uB2E4.");
|
|
17194
|
+
WsHub.get().broadcastDone(topicId, queryId, outcome.usage ? {
|
|
17195
|
+
input: outcome.usage.inputTokens,
|
|
17196
|
+
output: outcome.usage.outputTokens,
|
|
17197
|
+
cachedInput: outcome.usage.cacheReadInputTokens,
|
|
17198
|
+
context: outcome.usage.contextTokens,
|
|
17199
|
+
contextWindow: outcome.usage.contextWindow
|
|
17200
|
+
} : undefined, { agent: agentKind, model: resolvedModel, budgetReason: outcome.reason });
|
|
17201
|
+
WsHub.get().broadcastTopicNotice(topicId, "warning", "\uC608\uC0B0 \uD55C\uB3C4 \uB3C4\uB2EC");
|
|
17202
|
+
} else {
|
|
17203
|
+
await deliverAskError(queryId, topic.title, error);
|
|
17204
|
+
}
|
|
17205
|
+
await settleSubagentFailure(queryId, error);
|
|
17206
|
+
try {
|
|
17207
|
+
onSettled?.({ queryId, kind: "error", error });
|
|
17208
|
+
} catch (err2) {
|
|
17209
|
+
logger.warn({ err: err2, topicId, queryId }, "ai: turn settlement hook failed");
|
|
17210
|
+
}
|
|
17211
|
+
return;
|
|
17212
|
+
}
|
|
17165
17213
|
if (outcome.kind === "provider-error") {
|
|
17166
17214
|
if (!silent) {
|
|
17167
17215
|
appendSystemMessage(topicId, `${classifyAgentError(outcome.error, agentKind)}
|
|
17168
17216
|
|
|
17169
17217
|
\uB2E4\uB978 \uB4F1\uB85D\uB41C \uBAA8\uB378\uC744 \uC4F0\uB824\uBA74 /model <model>\uB85C \uBC14\uAFBC \uB4A4 \uB2E4\uC2DC \uBCF4\uB0B4\uC138\uC694.`);
|
|
17170
17218
|
WsHub.get().broadcastError(topicId, queryId, outcome.error);
|
|
17219
|
+
WsHub.get().broadcastTopicNotice(topicId, "error", "\uC751\uB2F5 \uC2E4\uD328");
|
|
17171
17220
|
}
|
|
17172
17221
|
await deliverAskError(queryId, topic.title, outcome.error);
|
|
17173
17222
|
await settleSubagentFailure(queryId, classifyAgentError(outcome.error, agentKind));
|
|
@@ -17195,6 +17244,7 @@ function startAiTurn(params) {
|
|
|
17195
17244
|
logger.warn({ err: err2, topicId, queryId, agent: agentKind, model: resolvedModel, silent }, "ai: background stream task failed");
|
|
17196
17245
|
if (!silent) {
|
|
17197
17246
|
WsHub.get().broadcastError(topicId, queryId, error);
|
|
17247
|
+
WsHub.get().broadcastTopicNotice(topicId, "error", "\uC751\uB2F5 \uC2E4\uD328");
|
|
17198
17248
|
}
|
|
17199
17249
|
await settleSubagentFailure(queryId, classifyAgentError(error, agentKind));
|
|
17200
17250
|
try {
|
|
@@ -17249,6 +17299,8 @@ function triggerTopicAiTurn(topicId, userId, prompt, agentType, opts) {
|
|
|
17249
17299
|
text: prompt,
|
|
17250
17300
|
agentType: execution.agent,
|
|
17251
17301
|
model: execution.model,
|
|
17302
|
+
kind: opts?.injectKind,
|
|
17303
|
+
tellCard: opts?.injectTellCard,
|
|
17252
17304
|
createdAt: now
|
|
17253
17305
|
};
|
|
17254
17306
|
try {
|
|
@@ -19230,4 +19282,4 @@ export {
|
|
|
19230
19282
|
DEFAULT_SELF_CONFIG_PRODUCT
|
|
19231
19283
|
};
|
|
19232
19284
|
|
|
19233
|
-
//# debugId=
|
|
19285
|
+
//# debugId=6C58B774CB0D906D64756E2164756E21
|