motebit 1.11.1 → 1.11.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/index.js +393 -68
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -1718,9 +1718,17 @@ var init_models = __esm({
|
|
|
1718
1718
|
"use strict";
|
|
1719
1719
|
init_esm_shims();
|
|
1720
1720
|
ANTHROPIC_MODELS = [
|
|
1721
|
+
"claude-fable-5",
|
|
1722
|
+
"claude-opus-5",
|
|
1723
|
+
"claude-opus-4-8",
|
|
1721
1724
|
"claude-opus-4-7",
|
|
1725
|
+
"claude-opus-4-6",
|
|
1726
|
+
"claude-sonnet-5",
|
|
1722
1727
|
"claude-sonnet-4-6",
|
|
1723
|
-
"claude-haiku-4-5-20251001"
|
|
1728
|
+
"claude-haiku-4-5-20251001",
|
|
1729
|
+
"claude-opus-4-5-20251101",
|
|
1730
|
+
"claude-sonnet-4-5-20250929",
|
|
1731
|
+
"claude-opus-4-1-20250805"
|
|
1724
1732
|
];
|
|
1725
1733
|
OPENAI_MODELS = ["gpt-5.4", "gpt-5.4-mini", "gpt-5.4-nano"];
|
|
1726
1734
|
GOOGLE_MODELS = [
|
|
@@ -5696,7 +5704,6 @@ var init_core = __esm({
|
|
|
5696
5704
|
init_esm_shims();
|
|
5697
5705
|
init_dist2();
|
|
5698
5706
|
init_prompt();
|
|
5699
|
-
init_prompt();
|
|
5700
5707
|
init_context_window();
|
|
5701
5708
|
init_config();
|
|
5702
5709
|
init_summarizer();
|
|
@@ -6547,6 +6554,81 @@ var init_openai_provider = __esm({
|
|
|
6547
6554
|
}
|
|
6548
6555
|
});
|
|
6549
6556
|
|
|
6557
|
+
// ../../packages/ai-core/dist/model-catalog.js
|
|
6558
|
+
function fallbackFor(provider, reason) {
|
|
6559
|
+
const table = provider === "anthropic" ? ANTHROPIC_MODELS : provider === "openai" ? OPENAI_MODELS : provider === "local-server" || provider === "ollama" ? LOCAL_SERVER_SUGGESTED_MODELS : [];
|
|
6560
|
+
return {
|
|
6561
|
+
provider,
|
|
6562
|
+
source: "fallback",
|
|
6563
|
+
models: table.map((id) => ({ id })),
|
|
6564
|
+
fallbackReason: reason
|
|
6565
|
+
};
|
|
6566
|
+
}
|
|
6567
|
+
async function fetchJson(url, headers, timeoutMs, fetchFn) {
|
|
6568
|
+
const controller = new AbortController();
|
|
6569
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
6570
|
+
try {
|
|
6571
|
+
const resp = await fetchFn(url, { headers, signal: controller.signal });
|
|
6572
|
+
if (!resp.ok)
|
|
6573
|
+
throw new Error(`${resp.status} from ${url}`);
|
|
6574
|
+
return await resp.json();
|
|
6575
|
+
} finally {
|
|
6576
|
+
clearTimeout(timer);
|
|
6577
|
+
}
|
|
6578
|
+
}
|
|
6579
|
+
async function discoverModels(params) {
|
|
6580
|
+
const { provider } = params;
|
|
6581
|
+
const timeoutMs = params.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
6582
|
+
const fetchFn = params.fetchFn ?? fetch;
|
|
6583
|
+
try {
|
|
6584
|
+
if (provider === "anthropic") {
|
|
6585
|
+
if (!params.apiKey)
|
|
6586
|
+
return fallbackFor(provider, "no API key for live catalog");
|
|
6587
|
+
const body = await fetchJson("https://api.anthropic.com/v1/models?limit=100", { "x-api-key": params.apiKey, "anthropic-version": "2023-06-01" }, timeoutMs, fetchFn);
|
|
6588
|
+
const models = (body.data ?? []).filter((m4) => typeof m4.id === "string").map((m4) => ({ id: m4.id, ...m4.display_name ? { displayName: m4.display_name } : {} }));
|
|
6589
|
+
if (models.length === 0)
|
|
6590
|
+
return fallbackFor(provider, "live catalog came back empty");
|
|
6591
|
+
return { provider, source: "live", models };
|
|
6592
|
+
}
|
|
6593
|
+
if (provider === "openai") {
|
|
6594
|
+
if (!params.apiKey)
|
|
6595
|
+
return fallbackFor(provider, "no API key for live catalog");
|
|
6596
|
+
const body = await fetchJson("https://api.openai.com/v1/models", { Authorization: `Bearer ${params.apiKey}` }, timeoutMs, fetchFn);
|
|
6597
|
+
const models = (body.data ?? []).filter((m4) => typeof m4.id === "string").filter((m4) => /^(gpt-|o[0-9]|chatgpt)/.test(m4.id)).map((m4) => ({ id: m4.id }));
|
|
6598
|
+
if (models.length === 0)
|
|
6599
|
+
return fallbackFor(provider, "live catalog came back empty");
|
|
6600
|
+
return { provider, source: "live", models };
|
|
6601
|
+
}
|
|
6602
|
+
if (provider === "local-server" || provider === "ollama") {
|
|
6603
|
+
const base = (params.baseUrl ?? "http://localhost:11434").replace(/\/$/, "");
|
|
6604
|
+
try {
|
|
6605
|
+
const body2 = await fetchJson(`${base}/api/tags`, {}, timeoutMs, fetchFn);
|
|
6606
|
+
const models2 = (body2.models ?? []).filter((m4) => typeof m4.name === "string").map((m4) => ({ id: m4.name }));
|
|
6607
|
+
if (models2.length > 0)
|
|
6608
|
+
return { provider, source: "live", models: models2 };
|
|
6609
|
+
} catch {
|
|
6610
|
+
}
|
|
6611
|
+
const body = await fetchJson(`${base}/v1/models`, {}, timeoutMs, fetchFn);
|
|
6612
|
+
const models = (body.data ?? []).filter((m4) => typeof m4.id === "string").map((m4) => ({ id: m4.id }));
|
|
6613
|
+
if (models.length === 0)
|
|
6614
|
+
return fallbackFor(provider, "local server lists no models");
|
|
6615
|
+
return { provider, source: "live", models };
|
|
6616
|
+
}
|
|
6617
|
+
return fallbackFor(provider, `no live catalog adapter for ${provider}`);
|
|
6618
|
+
} catch (err2) {
|
|
6619
|
+
return fallbackFor(provider, err2 instanceof Error ? err2.message : String(err2));
|
|
6620
|
+
}
|
|
6621
|
+
}
|
|
6622
|
+
var DEFAULT_TIMEOUT_MS;
|
|
6623
|
+
var init_model_catalog = __esm({
|
|
6624
|
+
"../../packages/ai-core/dist/model-catalog.js"() {
|
|
6625
|
+
"use strict";
|
|
6626
|
+
init_esm_shims();
|
|
6627
|
+
init_dist2();
|
|
6628
|
+
DEFAULT_TIMEOUT_MS = 4e3;
|
|
6629
|
+
}
|
|
6630
|
+
});
|
|
6631
|
+
|
|
6550
6632
|
// ../../packages/memory-graph/dist/consolidation.js
|
|
6551
6633
|
function buildConsolidationPrompt(newContent, existing) {
|
|
6552
6634
|
const memoryList = existing.map((m4, i) => ` ${i + 1}. [id=${m4.node_id}] (confidence=${m4.confidence.toFixed(2)}) "${m4.content}"`).join("\n");
|
|
@@ -9299,6 +9381,7 @@ var init_dist4 = __esm({
|
|
|
9299
9381
|
init_esm_shims();
|
|
9300
9382
|
init_core();
|
|
9301
9383
|
init_openai_provider();
|
|
9384
|
+
init_model_catalog();
|
|
9302
9385
|
init_loop();
|
|
9303
9386
|
}
|
|
9304
9387
|
});
|
|
@@ -25504,7 +25587,7 @@ var init_config2 = __esm({
|
|
|
25504
25587
|
"src/config.ts"() {
|
|
25505
25588
|
"use strict";
|
|
25506
25589
|
init_esm_shims();
|
|
25507
|
-
VERSION = true ? "1.11.
|
|
25590
|
+
VERSION = true ? "1.11.2" : "0.0.0-dev";
|
|
25508
25591
|
CONFIG_DIR = process.env["MOTEBIT_CONFIG_DIR"] ?? path2.join(os.homedir(), ".motebit");
|
|
25509
25592
|
CONFIG_PATH = path2.join(CONFIG_DIR, "config.json");
|
|
25510
25593
|
RELAY_DIR = path2.join(CONFIG_DIR, "relay");
|
|
@@ -45374,7 +45457,7 @@ function classifyRelayError(status, body, retryAfterHeader) {
|
|
|
45374
45457
|
return { code: "unknown", message: message2, status };
|
|
45375
45458
|
}
|
|
45376
45459
|
async function submitAndPollDelegation(params) {
|
|
45377
|
-
const timeoutMs = params.timeoutMs ??
|
|
45460
|
+
const timeoutMs = params.timeoutMs ?? DEFAULT_TIMEOUT_MS2;
|
|
45378
45461
|
const startedAt = Date.now();
|
|
45379
45462
|
let submitHeader;
|
|
45380
45463
|
try {
|
|
@@ -45512,7 +45595,7 @@ async function pollForReceipt(args) {
|
|
|
45512
45595
|
};
|
|
45513
45596
|
}
|
|
45514
45597
|
async function submitP2pDelegation(params) {
|
|
45515
|
-
const timeoutMs = params.timeoutMs ??
|
|
45598
|
+
const timeoutMs = params.timeoutMs ?? DEFAULT_TIMEOUT_MS2;
|
|
45516
45599
|
const startedAt = Date.now();
|
|
45517
45600
|
let submitHeader;
|
|
45518
45601
|
try {
|
|
@@ -45968,14 +46051,14 @@ async function selectAndRunDelegation(params) {
|
|
|
45968
46051
|
...params.signal ? { signal: params.signal } : {}
|
|
45969
46052
|
});
|
|
45970
46053
|
}
|
|
45971
|
-
var
|
|
46054
|
+
var DEFAULT_TIMEOUT_MS2, POLL_INTERVAL_MS, fail;
|
|
45972
46055
|
var init_relay_delegation = __esm({
|
|
45973
46056
|
"../../packages/runtime/dist/relay-delegation.js"() {
|
|
45974
46057
|
"use strict";
|
|
45975
46058
|
init_esm_shims();
|
|
45976
46059
|
init_dist();
|
|
45977
46060
|
init_dist5();
|
|
45978
|
-
|
|
46061
|
+
DEFAULT_TIMEOUT_MS2 = 12e4;
|
|
45979
46062
|
POLL_INTERVAL_MS = 2e3;
|
|
45980
46063
|
fail = (code2, message2, status) => ({
|
|
45981
46064
|
ok: false,
|
|
@@ -57034,6 +57117,21 @@ ${footnotes}`
|
|
|
57034
57117
|
pushReceipt(receipt) {
|
|
57035
57118
|
this.receipts.push(receipt);
|
|
57036
57119
|
}
|
|
57120
|
+
/**
|
|
57121
|
+
* Non-draining view of the stash for the streaming layer's
|
|
57122
|
+
* `delegation_complete` emission (#493): mark the count before a
|
|
57123
|
+
* `delegate_to_agent` call, peek what arrived after it. MUST NOT drain —
|
|
57124
|
+
* `getAndResetReceipts` composes the same bucket into the parent
|
|
57125
|
+
* receipt's `delegation_receipts` chain, and a draining reader here
|
|
57126
|
+
* would silently sever that chain (composition-preserves-enforcement).
|
|
57127
|
+
*/
|
|
57128
|
+
get stashedReceiptCount() {
|
|
57129
|
+
return this.receipts.length;
|
|
57130
|
+
}
|
|
57131
|
+
/** See {@link stashedReceiptCount} — the peek half of the pair. */
|
|
57132
|
+
peekReceiptsSince(count2) {
|
|
57133
|
+
return this.receipts.slice(count2);
|
|
57134
|
+
}
|
|
57037
57135
|
};
|
|
57038
57136
|
}
|
|
57039
57137
|
});
|
|
@@ -57281,6 +57379,7 @@ var init_streaming = __esm({
|
|
|
57281
57379
|
let pendingStateUpdates = {};
|
|
57282
57380
|
const motebitToolServers = this.deps.getMotebitToolServers();
|
|
57283
57381
|
const pendingToolCalls = /* @__PURE__ */ new Map();
|
|
57382
|
+
let delegateStashMark = null;
|
|
57284
57383
|
for await (let chunk of stream) {
|
|
57285
57384
|
if (chunk.type === "memory_formation_deferred")
|
|
57286
57385
|
continue;
|
|
@@ -57306,6 +57405,9 @@ var init_streaming = __esm({
|
|
|
57306
57405
|
this.deps.setDelegating(true);
|
|
57307
57406
|
yield { type: "delegation_start", server: motebitServer, tool: chunk.name };
|
|
57308
57407
|
}
|
|
57408
|
+
if (chunk.name === "delegate_to_agent") {
|
|
57409
|
+
delegateStashMark = this.deps.delegationReceiptStash?.count() ?? null;
|
|
57410
|
+
}
|
|
57309
57411
|
} else if (chunk.status === "done") {
|
|
57310
57412
|
if (chunk.result != null && typeof chunk.result === "string") {
|
|
57311
57413
|
const redacted = this.deps.redactText(chunk.result);
|
|
@@ -57365,6 +57467,26 @@ var init_streaming = __esm({
|
|
|
57365
57467
|
full_receipt: fullReceipt
|
|
57366
57468
|
};
|
|
57367
57469
|
}
|
|
57470
|
+
if (chunk.name === "delegate_to_agent" && delegateStashMark != null) {
|
|
57471
|
+
const mark = delegateStashMark;
|
|
57472
|
+
delegateStashMark = null;
|
|
57473
|
+
const stashed = this.deps.delegationReceiptStash?.peekSince(mark) ?? [];
|
|
57474
|
+
for (const receipt of stashed) {
|
|
57475
|
+
yield {
|
|
57476
|
+
type: "delegation_complete",
|
|
57477
|
+
server: "relay",
|
|
57478
|
+
tool: receipt.tools_used?.[0] ?? "delegate_to_agent",
|
|
57479
|
+
...typeof receipt.task_id === "string" && typeof receipt.status === "string" ? {
|
|
57480
|
+
receipt: {
|
|
57481
|
+
task_id: receipt.task_id,
|
|
57482
|
+
status: receipt.status,
|
|
57483
|
+
tools_used: receipt.tools_used ?? []
|
|
57484
|
+
}
|
|
57485
|
+
} : {},
|
|
57486
|
+
full_receipt: receipt
|
|
57487
|
+
};
|
|
57488
|
+
}
|
|
57489
|
+
}
|
|
57368
57490
|
}
|
|
57369
57491
|
}
|
|
57370
57492
|
if (chunk.type === "approval_request" && this.deniedIntents.has(deniedIntentKey(chunk.name, chunk.args))) {
|
|
@@ -57478,6 +57600,7 @@ var init_streaming = __esm({
|
|
|
57478
57600
|
await this.signAndEmitApprovalDecision(pending, approved);
|
|
57479
57601
|
if (approved) {
|
|
57480
57602
|
yield { type: "tool_status", name: pending.toolName, status: "calling" };
|
|
57603
|
+
const approvedStashMark = pending.toolName === "delegate_to_agent" ? this.deps.delegationReceiptStash?.count() ?? null : null;
|
|
57481
57604
|
const toolRegistry = this.deps.getToolRegistry();
|
|
57482
57605
|
const result = await toolRegistry.execute(pending.toolName, pending.args);
|
|
57483
57606
|
const check = this.deps.sanitizeToolResult(result, pending.toolName);
|
|
@@ -57489,6 +57612,24 @@ var init_streaming = __esm({
|
|
|
57489
57612
|
patterns: check.injectionPatterns
|
|
57490
57613
|
};
|
|
57491
57614
|
}
|
|
57615
|
+
if (approvedStashMark != null) {
|
|
57616
|
+
const stashed = this.deps.delegationReceiptStash?.peekSince(approvedStashMark) ?? [];
|
|
57617
|
+
for (const receipt of stashed) {
|
|
57618
|
+
yield {
|
|
57619
|
+
type: "delegation_complete",
|
|
57620
|
+
server: "relay",
|
|
57621
|
+
tool: receipt.tools_used?.[0] ?? "delegate_to_agent",
|
|
57622
|
+
...typeof receipt.task_id === "string" && typeof receipt.status === "string" ? {
|
|
57623
|
+
receipt: {
|
|
57624
|
+
task_id: receipt.task_id,
|
|
57625
|
+
status: receipt.status,
|
|
57626
|
+
tools_used: receipt.tools_used ?? []
|
|
57627
|
+
}
|
|
57628
|
+
} : {},
|
|
57629
|
+
full_receipt: receipt
|
|
57630
|
+
};
|
|
57631
|
+
}
|
|
57632
|
+
}
|
|
57492
57633
|
yield {
|
|
57493
57634
|
type: "tool_status",
|
|
57494
57635
|
name: pending.toolName,
|
|
@@ -60023,6 +60164,14 @@ var init_motebit_runtime = __esm({
|
|
|
60023
60164
|
assertSensitivityPermitsAiCall: (entry, toolName) => this.assertSensitivityPermitsAiCall(entry, toolName),
|
|
60024
60165
|
getLatestCues: () => this.latestCues,
|
|
60025
60166
|
getApprovalStore: () => this.approvalStore,
|
|
60167
|
+
// #493: non-draining stash view for the delegate_to_agent receipt
|
|
60168
|
+
// beat. Lazy closures — interactiveDelegation is constructed before
|
|
60169
|
+
// the StreamingManager, but the indirection keeps that ordering a
|
|
60170
|
+
// non-constraint.
|
|
60171
|
+
delegationReceiptStash: {
|
|
60172
|
+
count: () => this.interactiveDelegation.stashedReceiptCount,
|
|
60173
|
+
peekSince: (n2) => this.interactiveDelegation.peekReceiptsSince(n2)
|
|
60174
|
+
},
|
|
60026
60175
|
redactText: (text) => {
|
|
60027
60176
|
if (typeof this.policy.redact === "function") {
|
|
60028
60177
|
return this.policy.redact(text);
|
|
@@ -86045,26 +86194,13 @@ function createTerminalRenderer(io) {
|
|
|
86045
86194
|
let inputRejecter = null;
|
|
86046
86195
|
let tail2 = "";
|
|
86047
86196
|
let statusRow = null;
|
|
86197
|
+
let modeRow = null;
|
|
86048
86198
|
let painted = { widths: [], cursorCol: 0 };
|
|
86049
|
-
function buildInputRow(
|
|
86050
|
-
const avail = Math.max(1, cols - 1 - inputState.promptWidth);
|
|
86051
|
-
if (inputState.line.length <= avail) {
|
|
86052
|
-
return {
|
|
86053
|
-
row: inputState.prompt + inputState.line,
|
|
86054
|
-
width: inputState.promptWidth + inputState.line.length,
|
|
86055
|
-
cursorCol: inputState.promptWidth + inputState.cursor
|
|
86056
|
-
};
|
|
86057
|
-
}
|
|
86058
|
-
const start = Math.max(
|
|
86059
|
-
0,
|
|
86060
|
-
Math.min(inputState.cursor - Math.floor(avail / 2), inputState.line.length - avail)
|
|
86061
|
-
);
|
|
86062
|
-
const windowText = inputState.line.slice(start, start + avail);
|
|
86063
|
-
const shown = start > 0 ? "\u2026" + windowText.slice(1) : windowText;
|
|
86199
|
+
function buildInputRow() {
|
|
86064
86200
|
return {
|
|
86065
|
-
row: inputState.prompt +
|
|
86066
|
-
width: inputState.promptWidth +
|
|
86067
|
-
cursorCol: inputState.promptWidth +
|
|
86201
|
+
row: inputState.prompt + inputState.line,
|
|
86202
|
+
width: inputState.promptWidth + inputState.line.length,
|
|
86203
|
+
cursorCol: inputState.promptWidth + inputState.cursor
|
|
86068
86204
|
};
|
|
86069
86205
|
}
|
|
86070
86206
|
function commit(scrollback) {
|
|
@@ -86090,9 +86226,14 @@ function createTerminalRenderer(io) {
|
|
|
86090
86226
|
rows.push(truncated + (io.isTTY ? RESET : ""));
|
|
86091
86227
|
widths.push(visibleLength(truncated));
|
|
86092
86228
|
}
|
|
86229
|
+
if (modeRow !== null) {
|
|
86230
|
+
const truncated = sliceVisible(modeRow, 0, cols - 1);
|
|
86231
|
+
rows.push(truncated + (io.isTTY ? RESET : ""));
|
|
86232
|
+
widths.push(visibleLength(truncated));
|
|
86233
|
+
}
|
|
86093
86234
|
let cursorCol = 0;
|
|
86094
86235
|
if (inputActive) {
|
|
86095
|
-
const built = buildInputRow(
|
|
86236
|
+
const built = buildInputRow();
|
|
86096
86237
|
rows.push(built.row);
|
|
86097
86238
|
widths.push(built.width);
|
|
86098
86239
|
cursorCol = built.cursorCol;
|
|
@@ -86101,8 +86242,12 @@ function createTerminalRenderer(io) {
|
|
|
86101
86242
|
}
|
|
86102
86243
|
if (rows.length > 0) {
|
|
86103
86244
|
out += rows.join("\n");
|
|
86245
|
+
const lastWidth = widths[widths.length - 1];
|
|
86246
|
+
const upWithin = cursorVisRow(lastWidth, cols) - cursorVisRow(cursorCol, cols);
|
|
86247
|
+
if (upWithin > 0) out += `\x1B[${upWithin}A`;
|
|
86104
86248
|
out += "\r";
|
|
86105
|
-
|
|
86249
|
+
const colInRow = cursorCol - cursorVisRow(cursorCol, cols) * cols;
|
|
86250
|
+
if (colInRow > 0) out += `\x1B[${colInRow}C`;
|
|
86106
86251
|
}
|
|
86107
86252
|
const hadOrHasRegion = painted.widths.length > 0 || rows.length > 0;
|
|
86108
86253
|
painted = { widths, cursorCol };
|
|
@@ -86110,9 +86255,21 @@ function createTerminalRenderer(io) {
|
|
|
86110
86255
|
io.write(io.isTTY && hadOrHasRegion ? SYNC_START + out + SYNC_END : out);
|
|
86111
86256
|
}
|
|
86112
86257
|
let atLineStart = true;
|
|
86258
|
+
let trailing = 2;
|
|
86259
|
+
function noteScrollback(flushed, tailAfter) {
|
|
86260
|
+
if (tailAfter !== "") {
|
|
86261
|
+
trailing = 0;
|
|
86262
|
+
return;
|
|
86263
|
+
}
|
|
86264
|
+
if (flushed === "") return;
|
|
86265
|
+
let n2 = 0;
|
|
86266
|
+
for (let i = flushed.length - 1; i >= 0 && flushed[i] === "\n" && n2 < 2; i--) n2++;
|
|
86267
|
+
trailing = n2 === flushed.length ? Math.min(2, trailing + n2) : n2;
|
|
86268
|
+
}
|
|
86113
86269
|
function writeOutput2(text) {
|
|
86114
86270
|
if (!io.isTTY && statusRow === null && !inputActive && tail2 === "") {
|
|
86115
86271
|
if (text.length > 0) atLineStart = text.endsWith("\n");
|
|
86272
|
+
noteScrollback(text, "");
|
|
86116
86273
|
io.write(text);
|
|
86117
86274
|
return;
|
|
86118
86275
|
}
|
|
@@ -86130,21 +86287,33 @@ function createTerminalRenderer(io) {
|
|
|
86130
86287
|
buffer = sliceVisible(buffer, cols, Number.MAX_SAFE_INTEGER);
|
|
86131
86288
|
}
|
|
86132
86289
|
tail2 = buffer;
|
|
86290
|
+
noteScrollback(scrollback, tail2);
|
|
86133
86291
|
commit(scrollback);
|
|
86134
86292
|
}
|
|
86135
86293
|
function writeLine2(text) {
|
|
86136
86294
|
const midLine = io.isTTY ? tail2 !== "" : !atLineStart;
|
|
86137
86295
|
writeOutput2((midLine ? "\n" : "") + text + "\n");
|
|
86138
86296
|
}
|
|
86297
|
+
function writeGap2() {
|
|
86298
|
+
const need = tail2 !== "" ? 2 : Math.max(0, 2 - trailing);
|
|
86299
|
+
if (need > 0) writeOutput2("\n".repeat(need));
|
|
86300
|
+
}
|
|
86139
86301
|
function setStatusRow2(row) {
|
|
86140
86302
|
if (!io.isTTY) return;
|
|
86141
86303
|
if (row === statusRow) return;
|
|
86142
86304
|
statusRow = row;
|
|
86143
86305
|
commit("");
|
|
86144
86306
|
}
|
|
86307
|
+
function setModeRow2(row) {
|
|
86308
|
+
if (!io.isTTY) return;
|
|
86309
|
+
if (row === modeRow) return;
|
|
86310
|
+
modeRow = row;
|
|
86311
|
+
commit("");
|
|
86312
|
+
}
|
|
86145
86313
|
function submit() {
|
|
86146
86314
|
const line = inputState.line;
|
|
86147
86315
|
inputActive = false;
|
|
86316
|
+
trailing = 1;
|
|
86148
86317
|
commit(inputState.prompt + line + "\n");
|
|
86149
86318
|
if (inputResolver) {
|
|
86150
86319
|
const resolve14 = inputResolver;
|
|
@@ -86202,8 +86371,10 @@ function createTerminalRenderer(io) {
|
|
|
86202
86371
|
return {
|
|
86203
86372
|
writeOutput: writeOutput2,
|
|
86204
86373
|
writeLine: writeLine2,
|
|
86374
|
+
writeGap: writeGap2,
|
|
86205
86375
|
readInput: readInput2,
|
|
86206
86376
|
setStatusRow: setStatusRow2,
|
|
86377
|
+
setModeRow: setModeRow2,
|
|
86207
86378
|
handleEvent,
|
|
86208
86379
|
repaint: () => commit(""),
|
|
86209
86380
|
detach
|
|
@@ -86443,9 +86614,15 @@ function readInput(promptText) {
|
|
|
86443
86614
|
function askQuestion(promptText) {
|
|
86444
86615
|
return readInput(promptText);
|
|
86445
86616
|
}
|
|
86617
|
+
function writeGap() {
|
|
86618
|
+
renderer.writeGap();
|
|
86619
|
+
}
|
|
86446
86620
|
function setStatusRow(row) {
|
|
86447
86621
|
renderer.setStatusRow(row);
|
|
86448
86622
|
}
|
|
86623
|
+
function setModeRow(row) {
|
|
86624
|
+
renderer.setModeRow(row);
|
|
86625
|
+
}
|
|
86449
86626
|
var ANSI_RE, RESET, SYNC_START, SYNC_END, PASTE_OPEN, PASTE_CLOSE, lastEscTime, pendingEscTimer, pasteBuffer, pasteSplitCarry, stdoutIO, renderer, initialized, resizeTimer;
|
|
86450
86627
|
var init_terminal = __esm({
|
|
86451
86628
|
"src/terminal.ts"() {
|
|
@@ -86478,6 +86655,7 @@ function spinnerFrame(frame) {
|
|
|
86478
86655
|
}
|
|
86479
86656
|
function formatElapsed(startedAt, nowMs) {
|
|
86480
86657
|
const totalSec = Math.max(0, Math.floor((nowMs - startedAt) / 1e3));
|
|
86658
|
+
if (totalSec === 0) return "<1s";
|
|
86481
86659
|
if (totalSec < 60) return `${totalSec}s`;
|
|
86482
86660
|
const min = Math.floor(totalSec / 60);
|
|
86483
86661
|
const sec = totalSec % 60;
|
|
@@ -86589,11 +86767,17 @@ function createCliLogger() {
|
|
|
86589
86767
|
}
|
|
86590
86768
|
return;
|
|
86591
86769
|
}
|
|
86592
|
-
|
|
86770
|
+
const indent2 = activeStatus() ? " " : " ";
|
|
86771
|
+
const designed = DESIGNED_SENTENCES[message2]?.(context);
|
|
86772
|
+
if (designed != null) {
|
|
86773
|
+
writeLine(`${indent2}${warn2("\xB7")} ${meta(designed)}`);
|
|
86774
|
+
return;
|
|
86775
|
+
}
|
|
86776
|
+
writeLine(`${indent2}${warn2("\xB7")} ${meta(message2 + formatContext(context))}`);
|
|
86593
86777
|
}
|
|
86594
86778
|
};
|
|
86595
86779
|
}
|
|
86596
|
-
var POLL_TROUBLE;
|
|
86780
|
+
var POLL_TROUBLE, DESIGNED_SENTENCES;
|
|
86597
86781
|
var init_cli_logger = __esm({
|
|
86598
86782
|
"src/cli-logger.ts"() {
|
|
86599
86783
|
"use strict";
|
|
@@ -86602,6 +86786,19 @@ var init_cli_logger = __esm({
|
|
|
86602
86786
|
init_statusline();
|
|
86603
86787
|
init_colors();
|
|
86604
86788
|
POLL_TROUBLE = /* @__PURE__ */ new Set(["delegation poll failed", "delegation poll token mint failed"]);
|
|
86789
|
+
DESIGNED_SENTENCES = {
|
|
86790
|
+
"delegation.route_degraded": (ctx) => {
|
|
86791
|
+
if (ctx?.from !== "p2p" || ctx?.to !== "relay") return null;
|
|
86792
|
+
const code2 = typeof ctx.code === "string" ? ` (${ctx.code})` : "";
|
|
86793
|
+
return `direct payment route unavailable${code2} \u2014 this task goes through the relay; no onchain payment leaves the wallet`;
|
|
86794
|
+
},
|
|
86795
|
+
"money_meter.volatile_spend_store": () => "grant spending is metered in memory this session \u2014 the lifetime ceiling re-arms on restart",
|
|
86796
|
+
"relay_key_pin.rotated": (ctx) => {
|
|
86797
|
+
const to = typeof ctx?.toKeyPrefix === "string" ? ` (now ${ctx.toKeyPrefix}\u2026)` : "";
|
|
86798
|
+
return `the relay's signing key rotated${to} \u2014 the new key is pinned`;
|
|
86799
|
+
},
|
|
86800
|
+
"relay_key_pin.mismatch": () => "the relay's signing key does not match the pinned key \u2014 refusing to trust it"
|
|
86801
|
+
};
|
|
86605
86802
|
}
|
|
86606
86803
|
});
|
|
86607
86804
|
|
|
@@ -90483,10 +90680,12 @@ function createTaskRouter(deps) {
|
|
|
90483
90680
|
const candidates = settled.filter((r2) => r2.status === "fulfilled").flatMap((r2) => r2.value).slice(0, MAX_TOTAL_FEDERATED);
|
|
90484
90681
|
return { candidates, federationEdges: allFederationEdges, peerRelayNodes };
|
|
90485
90682
|
}
|
|
90486
|
-
function queryLocalAgents(capability, motebitId, limit = 20, federatedOnly = false) {
|
|
90683
|
+
function queryLocalAgents(capability, motebitId, limit = 20, federatedOnly = false, includeDelisted = false) {
|
|
90487
90684
|
const now = Date.now();
|
|
90488
90685
|
const revokedFilter = " AND (revoked IS NULL OR revoked = 0)";
|
|
90489
90686
|
const fedFilter = federatedOnly ? " AND (federation_visible IS NULL OR federation_visible != 0)" : "";
|
|
90687
|
+
const delistCutoff = Math.floor(now - FRESHNESS_DELISTED_MS);
|
|
90688
|
+
const staleFilter = includeDelisted ? "" : ` AND COALESCE(NULLIF(last_heartbeat, 0), registered_at, 0) >= ${delistCutoff}`;
|
|
90490
90689
|
let rows;
|
|
90491
90690
|
if (capability && motebitId) {
|
|
90492
90691
|
rows = db.prepare(`
|
|
@@ -90498,7 +90697,7 @@ function createTaskRouter(deps) {
|
|
|
90498
90697
|
} else if (capability) {
|
|
90499
90698
|
rows = db.prepare(`
|
|
90500
90699
|
SELECT * FROM agent_registry
|
|
90501
|
-
WHERE EXISTS (SELECT 1 FROM json_each(capabilities) WHERE value = ?)${revokedFilter}${fedFilter}
|
|
90700
|
+
WHERE EXISTS (SELECT 1 FROM json_each(capabilities) WHERE value = ?)${revokedFilter}${fedFilter}${staleFilter}
|
|
90502
90701
|
LIMIT ?
|
|
90503
90702
|
`).all(capability, limit);
|
|
90504
90703
|
} else if (motebitId) {
|
|
@@ -90507,7 +90706,7 @@ function createTaskRouter(deps) {
|
|
|
90507
90706
|
`).all(motebitId, limit);
|
|
90508
90707
|
} else {
|
|
90509
90708
|
rows = db.prepare(`
|
|
90510
|
-
SELECT * FROM agent_registry WHERE 1=1${revokedFilter}${fedFilter} LIMIT ?
|
|
90709
|
+
SELECT * FROM agent_registry WHERE 1=1${revokedFilter}${fedFilter}${staleFilter} LIMIT ?
|
|
90511
90710
|
`).all(limit);
|
|
90512
90711
|
}
|
|
90513
90712
|
const ids = rows.map((r2) => r2.motebit_id);
|
|
@@ -90888,7 +91087,7 @@ async function evaluateSettlementEligibility(db, delegatorId, workerId, delegato
|
|
|
90888
91087
|
reason: trustRow ? `Trust ${score} / ${interactions} interactions below established-pair threshold (${P2P_MIN_TRUST_SCORE} / ${P2P_MIN_INTERACTIONS}); delegator did not acknowledge cold-start risk` : "No trust history between agents; delegator did not acknowledge cold-start risk"
|
|
90889
91088
|
};
|
|
90890
91089
|
}
|
|
90891
|
-
var logger13, circuitBreakerLogger, FRESHNESS_AWAKE_MS, FRESHNESS_RECENT_MS, FRESHNESS_DORMANT_MS, P2P_MIN_TRUST_SCORE, P2P_MIN_INTERACTIONS, P2P_SOVEREIGN_MIN_TRUST_SCORE, P2P_SOVEREIGN_MIN_INTERACTIONS, P2P_BONDED_MIN_TRUST_SCORE, P2P_BONDED_MIN_INTERACTIONS, REFERENCE_BOND_COVERAGE_MULTIPLE;
|
|
91090
|
+
var logger13, circuitBreakerLogger, FRESHNESS_AWAKE_MS, FRESHNESS_RECENT_MS, FRESHNESS_DORMANT_MS, FRESHNESS_DELISTED_MS, P2P_MIN_TRUST_SCORE, P2P_MIN_INTERACTIONS, P2P_SOVEREIGN_MIN_TRUST_SCORE, P2P_SOVEREIGN_MIN_INTERACTIONS, P2P_BONDED_MIN_TRUST_SCORE, P2P_BONDED_MIN_INTERACTIONS, REFERENCE_BOND_COVERAGE_MULTIPLE;
|
|
90892
91091
|
var init_task_routing = __esm({
|
|
90893
91092
|
"../../services/relay/dist/task-routing.js"() {
|
|
90894
91093
|
"use strict";
|
|
@@ -90907,6 +91106,7 @@ var init_task_routing = __esm({
|
|
|
90907
91106
|
FRESHNESS_AWAKE_MS = 6 * 60 * 1e3;
|
|
90908
91107
|
FRESHNESS_RECENT_MS = 30 * 60 * 1e3;
|
|
90909
91108
|
FRESHNESS_DORMANT_MS = 24 * 60 * 60 * 1e3;
|
|
91109
|
+
FRESHNESS_DELISTED_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
90910
91110
|
P2P_MIN_TRUST_SCORE = 0.6;
|
|
90911
91111
|
P2P_MIN_INTERACTIONS = 5;
|
|
90912
91112
|
P2P_SOVEREIGN_MIN_TRUST_SCORE = 0.3;
|
|
@@ -96315,9 +96515,13 @@ function registerAgentRoutes(deps) {
|
|
|
96315
96515
|
const motebitId = c5.req.query("motebit_id");
|
|
96316
96516
|
const limitParam = Number(c5.req.query("limit") ?? "20");
|
|
96317
96517
|
const limit = Math.min(Math.max(1, limitParam), 100);
|
|
96318
|
-
const
|
|
96518
|
+
const includeAll = c5.req.query("include") === "all";
|
|
96519
|
+
const localAgents = taskRouter.queryLocalAgents(capability ?? void 0, motebitId ?? void 0, limit, false, includeAll).filter((a4) => includeAll || a4.motebit_id !== relayIdentity.relayMotebitId);
|
|
96319
96520
|
const localResults = localAgents.map((a4) => ({
|
|
96320
96521
|
...a4,
|
|
96522
|
+
// The relay's own registration reads as a zero-capability ghost in the
|
|
96523
|
+
// agent listing — mark its role when the full view includes it.
|
|
96524
|
+
...a4.motebit_id === relayIdentity.relayMotebitId ? { role: "relay" } : {},
|
|
96321
96525
|
source_relay: relayIdentity.relayMotebitId,
|
|
96322
96526
|
relay_name: federationConfig?.displayName ?? null,
|
|
96323
96527
|
hop_distance: 0
|
|
@@ -101533,8 +101737,36 @@ init_esm_shims();
|
|
|
101533
101737
|
init_dist4();
|
|
101534
101738
|
init_dist6();
|
|
101535
101739
|
init_dist7();
|
|
101536
|
-
|
|
101740
|
+
|
|
101741
|
+
// src/model-admission.ts
|
|
101742
|
+
init_esm_shims();
|
|
101537
101743
|
init_dist2();
|
|
101744
|
+
var HOSTED_VENDORS = /* @__PURE__ */ new Set(["anthropic", "openai", "google", "deepseek"]);
|
|
101745
|
+
var VENDOR_PROVIDER_FLAG = {
|
|
101746
|
+
anthropic: "anthropic",
|
|
101747
|
+
openai: "openai",
|
|
101748
|
+
google: "google"
|
|
101749
|
+
};
|
|
101750
|
+
function admitModelForProvider(provider, model) {
|
|
101751
|
+
const hint = modelVendorHint(model);
|
|
101752
|
+
if ((provider === "local-server" || provider === "ollama") && HOSTED_VENDORS.has(hint)) {
|
|
101753
|
+
const flag = VENDOR_PROVIDER_FLAG[hint];
|
|
101754
|
+
return {
|
|
101755
|
+
admissible: false,
|
|
101756
|
+
teach: `${model} is a hosted ${hint} model \u2014 a local server can't serve it. ` + (flag != null ? `Restart with --provider ${flag}, or pick a local model (e.g. /model llama3.2).` : `Pick a local model instead (e.g. /model llama3.2).`)
|
|
101757
|
+
};
|
|
101758
|
+
}
|
|
101759
|
+
if (!providerAcceptsModel(provider, model)) {
|
|
101760
|
+
const flag = VENDOR_PROVIDER_FLAG[hint];
|
|
101761
|
+
return {
|
|
101762
|
+
admissible: false,
|
|
101763
|
+
teach: `${model} belongs to ${hint === "unknown" ? "another provider" : hint} \u2014 the active provider is ${provider}. ` + (flag != null ? `Restart with --provider ${flag} to use it.` : `Pick a ${provider} model instead.`)
|
|
101764
|
+
};
|
|
101765
|
+
}
|
|
101766
|
+
return { admissible: true };
|
|
101767
|
+
}
|
|
101768
|
+
|
|
101769
|
+
// src/index.ts
|
|
101538
101770
|
init_dist8();
|
|
101539
101771
|
|
|
101540
101772
|
// src/grant-preflight.ts
|
|
@@ -102479,7 +102711,6 @@ init_runtime_factory();
|
|
|
102479
102711
|
|
|
102480
102712
|
// src/stream.ts
|
|
102481
102713
|
init_esm_shims();
|
|
102482
|
-
init_dist4();
|
|
102483
102714
|
init_colors();
|
|
102484
102715
|
init_terminal();
|
|
102485
102716
|
init_statusline();
|
|
@@ -102563,7 +102794,6 @@ function renderReceiptLine(receipt, depth, last) {
|
|
|
102563
102794
|
async function renderReceipt(receipt, out = (s3) => console.log(s3), trustedAnchor) {
|
|
102564
102795
|
const lines = renderReceiptLine(receipt, 0, true);
|
|
102565
102796
|
const header = `${dim("\u2500 receipt ")}${dim("\xB7")} ${cyan(shortHash2(receipt.task_id))}`;
|
|
102566
|
-
out("");
|
|
102567
102797
|
out(header);
|
|
102568
102798
|
for (const line of lines) out(line);
|
|
102569
102799
|
let verifiedFlag = false;
|
|
@@ -102594,7 +102824,6 @@ async function renderReceipt(receipt, out = (s3) => console.log(s3), trustedAnch
|
|
|
102594
102824
|
)}${errorMsg ? dim(" \xB7 " + errorMsg) : ""}`
|
|
102595
102825
|
);
|
|
102596
102826
|
}
|
|
102597
|
-
out("");
|
|
102598
102827
|
const ret = { verified: verifiedFlag };
|
|
102599
102828
|
if (errorMsg !== void 0) ret.error = errorMsg;
|
|
102600
102829
|
return ret;
|
|
@@ -102732,11 +102961,18 @@ function toolDoneLine(name, elapsedMs) {
|
|
|
102732
102961
|
async function consumeStream(stream, runtime, opts) {
|
|
102733
102962
|
let pendingApproval = null;
|
|
102734
102963
|
let status = null;
|
|
102964
|
+
let thinking = null;
|
|
102965
|
+
const stopThinking = () => {
|
|
102966
|
+
thinking?.stop();
|
|
102967
|
+
thinking = null;
|
|
102968
|
+
};
|
|
102735
102969
|
const stopStatus = () => {
|
|
102970
|
+
stopThinking();
|
|
102736
102971
|
const elapsed = status?.stop() ?? 0;
|
|
102737
102972
|
status = null;
|
|
102738
102973
|
return elapsed;
|
|
102739
102974
|
};
|
|
102975
|
+
thinking = startStatus("thinking");
|
|
102740
102976
|
let lastCompletedReceiptResult = null;
|
|
102741
102977
|
let sawAnyChunk = false;
|
|
102742
102978
|
try {
|
|
@@ -102744,6 +102980,7 @@ async function consumeStream(stream, runtime, opts) {
|
|
|
102744
102980
|
sawAnyChunk = true;
|
|
102745
102981
|
switch (chunk.type) {
|
|
102746
102982
|
case "text":
|
|
102983
|
+
stopThinking();
|
|
102747
102984
|
writeOutput(chunk.text);
|
|
102748
102985
|
break;
|
|
102749
102986
|
case "tool_status":
|
|
@@ -102752,15 +102989,18 @@ async function consumeStream(stream, runtime, opts) {
|
|
|
102752
102989
|
for (const line of renderAuthorityDelta(chunk.name, chunk.missing_authority)) {
|
|
102753
102990
|
writeLine(meta(line));
|
|
102754
102991
|
}
|
|
102992
|
+
thinking = startStatus("thinking");
|
|
102755
102993
|
break;
|
|
102756
102994
|
}
|
|
102757
102995
|
if (chunk.name === "delegate_to_agent" && chunk.status === "calling" && status) {
|
|
102758
102996
|
break;
|
|
102759
102997
|
}
|
|
102760
102998
|
if (chunk.status === "calling") {
|
|
102999
|
+
stopThinking();
|
|
102761
103000
|
status = chunk.name === "delegate_to_agent" ? startStatus("delegating") : startStatus("running", chunk.name);
|
|
102762
103001
|
} else if (status) {
|
|
102763
103002
|
writeLine(toolDoneLine(chunk.name, stopStatus()));
|
|
103003
|
+
thinking = startStatus("thinking");
|
|
102764
103004
|
}
|
|
102765
103005
|
break;
|
|
102766
103006
|
case "approval_request":
|
|
@@ -102776,6 +103016,7 @@ async function consumeStream(stream, runtime, opts) {
|
|
|
102776
103016
|
break;
|
|
102777
103017
|
case "delegation_start":
|
|
102778
103018
|
if (status) break;
|
|
103019
|
+
stopThinking();
|
|
102779
103020
|
status = startStatus("delegating", chunk.tool);
|
|
102780
103021
|
break;
|
|
102781
103022
|
case "task_step_narration":
|
|
@@ -102783,10 +103024,15 @@ async function consumeStream(stream, runtime, opts) {
|
|
|
102783
103024
|
writeLine(` ${meta("\xB7 " + chunk.text.trim())}`);
|
|
102784
103025
|
break;
|
|
102785
103026
|
case "delegation_complete":
|
|
102786
|
-
if (status)
|
|
103027
|
+
if (status) {
|
|
103028
|
+
writeLine(toolDoneLine(chunk.tool, stopStatus()));
|
|
103029
|
+
thinking = startStatus("thinking");
|
|
103030
|
+
}
|
|
102787
103031
|
if (chunk.full_receipt) {
|
|
102788
103032
|
archiveReceipt(chunk.full_receipt);
|
|
103033
|
+
writeGap();
|
|
102789
103034
|
await renderReceipt(chunk.full_receipt, (line) => writeOutput(line + "\n"));
|
|
103035
|
+
writeGap();
|
|
102790
103036
|
if (chunk.full_receipt.status === "completed" && chunk.full_receipt.result) {
|
|
102791
103037
|
lastCompletedReceiptResult = chunk.full_receipt.result;
|
|
102792
103038
|
}
|
|
@@ -102817,23 +103063,15 @@ async function consumeStream(stream, runtime, opts) {
|
|
|
102817
103063
|
case "result": {
|
|
102818
103064
|
const result = chunk.result;
|
|
102819
103065
|
stopStatus();
|
|
102820
|
-
|
|
103066
|
+
writeGap();
|
|
102821
103067
|
if (result.memoriesFormed.length > 0) {
|
|
102822
|
-
|
|
103068
|
+
writeLine(
|
|
102823
103069
|
meta(
|
|
102824
103070
|
` [memories: ${result.memoriesFormed.map((m4) => m4.content).join(", ")}]`
|
|
102825
|
-
)
|
|
103071
|
+
)
|
|
102826
103072
|
);
|
|
103073
|
+
writeGap();
|
|
102827
103074
|
}
|
|
102828
|
-
const s3 = result.stateAfter;
|
|
102829
|
-
writeOutput(
|
|
102830
|
-
meta(
|
|
102831
|
-
` [state: attention=${s3.attention.toFixed(2)} confidence=${s3.confidence.toFixed(2)} valence=${s3.affect_valence.toFixed(2)} curiosity=${s3.curiosity.toFixed(2)}]`
|
|
102832
|
-
) + "\n"
|
|
102833
|
-
);
|
|
102834
|
-
const bodyLine = formatBodyAwareness(result.cues);
|
|
102835
|
-
if (bodyLine) writeOutput(meta(` ${bodyLine}`) + "\n");
|
|
102836
|
-
writeOutput("\n");
|
|
102837
103075
|
break;
|
|
102838
103076
|
}
|
|
102839
103077
|
}
|
|
@@ -102875,6 +103113,17 @@ async function consumeStream(stream, runtime, opts) {
|
|
|
102875
103113
|
// src/index.ts
|
|
102876
103114
|
init_terminal();
|
|
102877
103115
|
|
|
103116
|
+
// src/mode-render.ts
|
|
103117
|
+
init_esm_shims();
|
|
103118
|
+
init_colors();
|
|
103119
|
+
function renderModeRow(state) {
|
|
103120
|
+
const parts = [];
|
|
103121
|
+
if (state.attachedPid != null) parts.push(`attached \xB7 coordinator pid ${state.attachedPid}`);
|
|
103122
|
+
if (state.model) parts.push(state.model);
|
|
103123
|
+
if (state.provider) parts.push(state.provider);
|
|
103124
|
+
return meta(` \u2500\u2500 ${parts.join(" \xB7 ")}`);
|
|
103125
|
+
}
|
|
103126
|
+
|
|
102878
103127
|
// src/runtime-host.ts
|
|
102879
103128
|
init_esm_shims();
|
|
102880
103129
|
|
|
@@ -104242,27 +104491,37 @@ init_status_render();
|
|
|
104242
104491
|
async function renderStream(stream) {
|
|
104243
104492
|
let pendingApproval = null;
|
|
104244
104493
|
let status = null;
|
|
104494
|
+
let thinking = null;
|
|
104495
|
+
const stopThinking = () => {
|
|
104496
|
+
thinking?.stop();
|
|
104497
|
+
thinking = null;
|
|
104498
|
+
};
|
|
104245
104499
|
const stopStatus = () => {
|
|
104500
|
+
stopThinking();
|
|
104246
104501
|
const elapsed = status?.stop() ?? 0;
|
|
104247
104502
|
status = null;
|
|
104248
104503
|
return elapsed;
|
|
104249
104504
|
};
|
|
104505
|
+
thinking = startStatus("thinking");
|
|
104250
104506
|
try {
|
|
104251
104507
|
for await (const raw of stream) {
|
|
104252
104508
|
const chunk = raw;
|
|
104253
104509
|
switch (chunk.type) {
|
|
104254
104510
|
case "text":
|
|
104511
|
+
stopThinking();
|
|
104255
104512
|
if (typeof chunk.text === "string") writeOutput(chunk.text);
|
|
104256
104513
|
break;
|
|
104257
104514
|
case "tool_status": {
|
|
104258
104515
|
const name = chunk.name ?? "tool";
|
|
104259
104516
|
if (chunk.status === "calling") {
|
|
104260
104517
|
if (name === "delegate_to_agent" && status) break;
|
|
104518
|
+
stopThinking();
|
|
104261
104519
|
status = name === "delegate_to_agent" ? startStatus("delegating") : startStatus("running", name);
|
|
104262
104520
|
} else if (status) {
|
|
104263
104521
|
writeLine(
|
|
104264
104522
|
` ${action("\u25CF")} ${action(name)} ${meta(`\xB7 done \xB7 ${formatElapsed(0, stopStatus())}`)}`
|
|
104265
104523
|
);
|
|
104524
|
+
thinking = startStatus("thinking");
|
|
104266
104525
|
}
|
|
104267
104526
|
break;
|
|
104268
104527
|
}
|
|
@@ -104275,6 +104534,7 @@ async function renderStream(stream) {
|
|
|
104275
104534
|
break;
|
|
104276
104535
|
case "delegation_start":
|
|
104277
104536
|
if (status) break;
|
|
104537
|
+
stopThinking();
|
|
104278
104538
|
status = startStatus("delegating", chunk.tool ?? "task");
|
|
104279
104539
|
break;
|
|
104280
104540
|
case "delegation_complete":
|
|
@@ -104284,6 +104544,7 @@ async function renderStream(stream) {
|
|
|
104284
104544
|
dim(`[receipt ${chunk.receipt.task_id.slice(0, 8)} \xB7 ${chunk.receipt.status ?? ""}]`)
|
|
104285
104545
|
);
|
|
104286
104546
|
}
|
|
104547
|
+
thinking = startStatus("thinking");
|
|
104287
104548
|
break;
|
|
104288
104549
|
case "injection_warning":
|
|
104289
104550
|
writeLine(`${warn2("\u26A0")} suspicious content in ${chunk.tool_name ?? "tool"} output`);
|
|
@@ -104358,6 +104619,7 @@ async function runAttachedRepl(client, motebitId) {
|
|
|
104358
104619
|
|
|
104359
104620
|
`
|
|
104360
104621
|
);
|
|
104622
|
+
setModeRow(renderModeRow({ attachedPid: client.coordinatorPid }));
|
|
104361
104623
|
let closed = false;
|
|
104362
104624
|
client.onClose(() => {
|
|
104363
104625
|
closed = true;
|
|
@@ -104424,6 +104686,7 @@ init_colors();
|
|
|
104424
104686
|
// src/slash-commands.ts
|
|
104425
104687
|
init_esm_shims();
|
|
104426
104688
|
init_dist2();
|
|
104689
|
+
init_dist4();
|
|
104427
104690
|
init_dist8();
|
|
104428
104691
|
|
|
104429
104692
|
// src/subcommands/id.ts
|
|
@@ -106089,7 +106352,9 @@ async function handleReceiptCommand(args, deps) {
|
|
|
106089
106352
|
out(warn2(`No archived receipt for task_id=${taskId}`));
|
|
106090
106353
|
return;
|
|
106091
106354
|
}
|
|
106355
|
+
out("");
|
|
106092
106356
|
await renderReceipt(receipt, out);
|
|
106357
|
+
out("");
|
|
106093
106358
|
}
|
|
106094
106359
|
async function drainInvokeStream(stream, out, voice) {
|
|
106095
106360
|
let textBuf = "";
|
|
@@ -106105,7 +106370,9 @@ async function drainInvokeStream(stream, out, voice) {
|
|
|
106105
106370
|
if (textBuf.trim()) out(textBuf.trim());
|
|
106106
106371
|
if (chunk.full_receipt) {
|
|
106107
106372
|
archiveReceipt(chunk.full_receipt);
|
|
106373
|
+
out("");
|
|
106108
106374
|
await renderReceipt(chunk.full_receipt, out);
|
|
106375
|
+
out("");
|
|
106109
106376
|
if (voice && chunk.full_receipt.status === "completed") {
|
|
106110
106377
|
const spoken = chunk.full_receipt.result ?? "Task complete.";
|
|
106111
106378
|
void voice.speakIfEnabled(spoken);
|
|
@@ -106484,14 +106751,52 @@ ${summary}`);
|
|
|
106484
106751
|
"llama3.2": "llama3.2",
|
|
106485
106752
|
mistral: "mistral"
|
|
106486
106753
|
};
|
|
106754
|
+
const envKey = config.provider === "openai" ? process.env["OPENAI_API_KEY"] : process.env["ANTHROPIC_API_KEY"];
|
|
106755
|
+
const catalog = await discoverModels({
|
|
106756
|
+
provider: config.provider,
|
|
106757
|
+
...envKey != null && envKey !== "" ? { apiKey: envKey } : {},
|
|
106758
|
+
...config.provider === "local-server" ? { baseUrl: "http://127.0.0.1:11434" } : {}
|
|
106759
|
+
});
|
|
106760
|
+
const liveIds = catalog.source === "live" ? new Set(catalog.models.map((m4) => m4.id)) : null;
|
|
106761
|
+
const providerLabel = (modelId2) => {
|
|
106762
|
+
const hint = modelVendorHint(modelId2);
|
|
106763
|
+
return hint === "local" ? "local-server" : hint;
|
|
106764
|
+
};
|
|
106487
106765
|
const showModelList = (current2) => {
|
|
106766
|
+
if (catalog.source === "live") {
|
|
106767
|
+
const col2 = Math.max(...catalog.models.map((m4) => m4.id.length)) + 2;
|
|
106768
|
+
for (const m4 of catalog.models) {
|
|
106769
|
+
const active = m4.id === current2;
|
|
106770
|
+
const marker = active ? green(" \u25CF") : " ";
|
|
106771
|
+
const gap = " ".repeat(Math.max(1, col2 - m4.id.length));
|
|
106772
|
+
console.log(`${marker} ${cyan(m4.id)}${gap}${dim(m4.displayName ?? "")}`);
|
|
106773
|
+
}
|
|
106774
|
+
console.log(dim(`
|
|
106775
|
+
live from ${config.provider}`));
|
|
106776
|
+
return;
|
|
106777
|
+
}
|
|
106488
106778
|
const col = Math.max(...Object.keys(MODEL_ALIASES).map((k4) => k4.length)) + 2;
|
|
106489
106779
|
for (const [alias, modelId2] of Object.entries(MODEL_ALIASES)) {
|
|
106490
106780
|
const active = modelId2 === current2 || alias === current2;
|
|
106781
|
+
const servable = admitModelForProvider(config.provider, modelId2).admissible;
|
|
106491
106782
|
const marker = active ? green(" \u25CF") : " ";
|
|
106492
106783
|
const gap = " ".repeat(Math.max(1, col - alias.length));
|
|
106493
|
-
|
|
106784
|
+
if (servable) {
|
|
106785
|
+
console.log(
|
|
106786
|
+
`${marker} ${cyan(alias)}${gap}${dim(modelId2 + " \xB7 " + providerLabel(modelId2))}`
|
|
106787
|
+
);
|
|
106788
|
+
} else {
|
|
106789
|
+
console.log(
|
|
106790
|
+
dim(
|
|
106791
|
+
`${marker} ${alias}${gap}${modelId2} \xB7 needs --provider ${providerLabel(modelId2)}`
|
|
106792
|
+
)
|
|
106793
|
+
);
|
|
106794
|
+
}
|
|
106494
106795
|
}
|
|
106796
|
+
console.log(
|
|
106797
|
+
dim(`
|
|
106798
|
+
offline list \u2014 live catalog unavailable (${catalog.fallbackReason ?? "?"})`)
|
|
106799
|
+
);
|
|
106495
106800
|
};
|
|
106496
106801
|
if (!args) {
|
|
106497
106802
|
const current2 = runtime.currentModel ?? "unknown";
|
|
@@ -106506,7 +106811,7 @@ Current model: ${cyan(current2)}
|
|
|
106506
106811
|
}
|
|
106507
106812
|
const input = args.toLowerCase();
|
|
106508
106813
|
const resolved = MODEL_ALIASES[input];
|
|
106509
|
-
const isFullId = Object.values(MODEL_ALIASES).includes(args);
|
|
106814
|
+
const isFullId = Object.values(MODEL_ALIASES).includes(args) || (liveIds?.has(args) ?? false);
|
|
106510
106815
|
if (!resolved && !isFullId) {
|
|
106511
106816
|
console.log(`
|
|
106512
106817
|
Unknown model: ${cyan(args)}
|
|
@@ -106518,9 +106823,28 @@ Unknown model: ${cyan(args)}
|
|
|
106518
106823
|
break;
|
|
106519
106824
|
}
|
|
106520
106825
|
const modelId = resolved ?? args;
|
|
106826
|
+
if (liveIds != null && !liveIds.has(modelId)) {
|
|
106827
|
+
console.log(
|
|
106828
|
+
`
|
|
106829
|
+
${warn2(`${modelId} is not served by ${config.provider} right now \u2014 /model lists what is`)}
|
|
106830
|
+
`
|
|
106831
|
+
);
|
|
106832
|
+
break;
|
|
106833
|
+
}
|
|
106834
|
+
const admission = admitModelForProvider(config.provider, modelId);
|
|
106835
|
+
if (!admission.admissible) {
|
|
106836
|
+
console.log(`
|
|
106837
|
+
${warn2(admission.teach ?? "model not servable on this provider")}
|
|
106838
|
+
`);
|
|
106839
|
+
break;
|
|
106840
|
+
}
|
|
106521
106841
|
runtime.setModel(modelId);
|
|
106522
106842
|
if (fullConfig) {
|
|
106523
106843
|
fullConfig.default_model = modelId;
|
|
106844
|
+
const persistable = ["anthropic", "openai", "google", "local-server", "proxy"];
|
|
106845
|
+
if (persistable.includes(config.provider)) {
|
|
106846
|
+
fullConfig.default_provider = config.provider;
|
|
106847
|
+
}
|
|
106524
106848
|
saveFullConfig(fullConfig);
|
|
106525
106849
|
}
|
|
106526
106850
|
console.log();
|
|
@@ -125491,7 +125815,7 @@ async function main() {
|
|
|
125491
125815
|
}
|
|
125492
125816
|
}
|
|
125493
125817
|
if (personalityConfig.default_model != null && personalityConfig.default_model !== "" && !process.argv.includes("--model")) {
|
|
125494
|
-
if (
|
|
125818
|
+
if (admitModelForProvider(config.provider, personalityConfig.default_model).admissible) {
|
|
125495
125819
|
config.model = personalityConfig.default_model;
|
|
125496
125820
|
} else {
|
|
125497
125821
|
console.log(
|
|
@@ -125501,11 +125825,14 @@ async function main() {
|
|
|
125501
125825
|
);
|
|
125502
125826
|
}
|
|
125503
125827
|
}
|
|
125504
|
-
if (process.argv.includes("--model")
|
|
125505
|
-
|
|
125506
|
-
|
|
125507
|
-
|
|
125508
|
-
|
|
125828
|
+
if (process.argv.includes("--model")) {
|
|
125829
|
+
const admission = admitModelForProvider(config.provider, config.model);
|
|
125830
|
+
if (!admission.admissible) {
|
|
125831
|
+
console.error(
|
|
125832
|
+
`Model "${config.model}" does not belong to provider "${config.provider}" \u2014 ${admission.teach ?? "pick a matching pair, or drop --model to use the provider's default."}`
|
|
125833
|
+
);
|
|
125834
|
+
process.exit(1);
|
|
125835
|
+
}
|
|
125509
125836
|
}
|
|
125510
125837
|
if (fullConfig.max_tokens != null && !process.argv.includes("--max-tokens")) {
|
|
125511
125838
|
config.maxTokens = fullConfig.max_tokens;
|
|
@@ -125895,6 +126222,12 @@ async function main() {
|
|
|
125895
126222
|
}
|
|
125896
126223
|
}
|
|
125897
126224
|
const prompt2 = () => {
|
|
126225
|
+
setModeRow(
|
|
126226
|
+
renderModeRow({
|
|
126227
|
+
model: runtime.currentModel ?? config.model,
|
|
126228
|
+
provider: config.provider
|
|
126229
|
+
})
|
|
126230
|
+
);
|
|
125898
126231
|
readInput(prompt("you>") + " ").then(
|
|
125899
126232
|
(line) => void handleLine(line),
|
|
125900
126233
|
() => {
|
|
@@ -125941,16 +126274,8 @@ ${prompt("mote>")} ${result.response}
|
|
|
125941
126274
|
console.log(
|
|
125942
126275
|
meta(` [memories: ${result.memoriesFormed.map((m4) => m4.content).join(", ")}]`)
|
|
125943
126276
|
);
|
|
126277
|
+
console.log();
|
|
125944
126278
|
}
|
|
125945
|
-
const s3 = result.stateAfter;
|
|
125946
|
-
console.log(
|
|
125947
|
-
meta(
|
|
125948
|
-
` [state: attention=${s3.attention.toFixed(2)} confidence=${s3.confidence.toFixed(2)} valence=${s3.affect_valence.toFixed(2)} curiosity=${s3.curiosity.toFixed(2)}]`
|
|
125949
|
-
)
|
|
125950
|
-
);
|
|
125951
|
-
const bodyLine = formatBodyAwareness(result.cues);
|
|
125952
|
-
if (bodyLine) console.log(meta(` ${bodyLine}`));
|
|
125953
|
-
console.log();
|
|
125954
126279
|
} else {
|
|
125955
126280
|
writeOutput("\n" + prompt("mote>") + " ");
|
|
125956
126281
|
const grantOptions = grantPresenter?.delegationForTurn() ?? void 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motebit",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Reference runtime and operator console for sovereign AI agents — REPL, daemon, delegation, MCP server. Persistent Ed25519 identity, signed execution receipts, governance at the boundary.",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -76,35 +76,35 @@
|
|
|
76
76
|
"typescript": "^5.6.0",
|
|
77
77
|
"vitest": "^4.1.10",
|
|
78
78
|
"@motebit/ai-core": "0.0.0-private",
|
|
79
|
-
"@motebit/core-identity": "0.0.0-private",
|
|
80
79
|
"@motebit/crypto": "3.19.1",
|
|
80
|
+
"@motebit/core-identity": "0.0.0-private",
|
|
81
81
|
"@motebit/behavior-engine": "0.0.0-private",
|
|
82
82
|
"@motebit/encryption": "0.0.0-private",
|
|
83
|
-
"@motebit/event-log": "0.0.0-private",
|
|
84
83
|
"@motebit/identity-file": "0.0.0-private",
|
|
84
|
+
"@motebit/event-log": "0.0.0-private",
|
|
85
85
|
"@motebit/mcp-client": "0.0.0-private",
|
|
86
|
-
"@motebit/gradient": "0.0.0-private",
|
|
87
86
|
"@motebit/mcp-server": "0.0.0-private",
|
|
88
|
-
"@motebit/
|
|
87
|
+
"@motebit/gradient": "0.0.0-private",
|
|
89
88
|
"@motebit/memory-graph": "0.0.0-private",
|
|
90
89
|
"@motebit/protocol": "3.15.1",
|
|
91
90
|
"@motebit/planner": "0.0.0-private",
|
|
91
|
+
"@motebit/persistence": "0.0.0-private",
|
|
92
92
|
"@motebit/privacy-layer": "0.0.0-private",
|
|
93
93
|
"@motebit/policy": "0.0.0-private",
|
|
94
94
|
"@motebit/relay": "0.0.0-private",
|
|
95
|
-
"@motebit/
|
|
95
|
+
"@motebit/runtime": "0.0.0-private",
|
|
96
96
|
"@motebit/runtime-host": "0.0.0-private",
|
|
97
|
-
"@motebit/sdk": "2.
|
|
97
|
+
"@motebit/sdk": "2.6.0",
|
|
98
|
+
"@motebit/relay-client": "0.0.0-private",
|
|
99
|
+
"@motebit/skills": "0.0.0-private",
|
|
98
100
|
"@motebit/self-knowledge": "0.0.0-private",
|
|
99
|
-
"@motebit/runtime": "0.0.0-private",
|
|
100
|
-
"@motebit/state-vector": "0.0.0-private",
|
|
101
101
|
"@motebit/sync-engine": "0.0.0-private",
|
|
102
|
-
"@motebit/
|
|
102
|
+
"@motebit/state-vector": "0.0.0-private",
|
|
103
103
|
"@motebit/tools": "0.0.0-private",
|
|
104
104
|
"@motebit/verify": "1.8.12",
|
|
105
105
|
"@motebit/voice": "0.0.0-private",
|
|
106
|
-
"@motebit/
|
|
107
|
-
"@motebit/
|
|
106
|
+
"@motebit/wire-schemas": "0.0.0-private",
|
|
107
|
+
"@motebit/wallet-solana": "0.0.0-private"
|
|
108
108
|
},
|
|
109
109
|
"scripts": {
|
|
110
110
|
"start": "tsx src/index.ts",
|