@chibitek/chibi 0.1.210 → 0.1.213
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/assets/{TerminalPanel-DxQoOfkY.js → TerminalPanel-mkQO42zG.js} +1 -1
- package/dist/assets/{abnfDiagram-O67JEVCF-Ds2qYdjS.js → abnfDiagram-O67JEVCF-D_YvZb12.js} +1 -1
- package/dist/assets/{arc-1O9tchZk.js → arc-u7NcCAzn.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-CWuQ1x2F.js → architectureDiagram-NJMV4G6O-CvoIt_0y.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-CNcEkXEx.js → blockDiagram-BEXU5L5S-B0Ry3uOJ.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-BKI_wi9I.js → c4Diagram-YGBWAQC7-DQQBHqDt.js} +1 -1
- package/dist/assets/channel-BG3AR6Y6.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-gO88emfN.js → chunk-2Q5K7J3B-B4IxGiPz.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-DbKNT_-r.js → chunk-3FUC2YCW-BxR5i6Mq.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-BbJCoZVg.js → chunk-5VM5RSS4-CqmFQLrB.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-DXurSCcp.js → chunk-GTNCS2PH-C9lKwjYE.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-BWyt0I_m.js → chunk-GWA4HPMP-DKAnucqk.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-6iWSsogl.js → chunk-JWPE2WC7-CE4DRhto.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-CFoqO9Hw.js → chunk-NETBCI7D-UziBzgi9.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-BZEzAlNi.js → chunk-WEXAMYUT-DVo_P12S.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-W4hfC50f.js → chunk-XXDRQBXY-CBwStBk5.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-BsGmL9e7.js → classDiagram-v2-NBCMYWYE-D4xfjrAt.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-CYtTgIzk.js → cose-bilkent-JH36ORCC-DNpZWduJ.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-DLOi2Q2V.js → cynefin-OW5HDTMX-CMegK4fD.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-BXcXJ3hv.js → cynefinDiagram-VND7K2PF-BBRJHq6u.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-BdBOiuzt.js → dagre-6A5THRUB-BwneJkAI.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-DCf3M4WE.js → diagram-22UHCM2B-p4tq7l1f.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-CzdF-UXi.js → diagram-3UASUU5V-C8BCnB5c.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-_UmmlMOD.js → diagram-ATOU4E4O-Da-Fc2pA.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-DrQODVuX.js → diagram-CDSNMT55-CH7l4Als.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-CE16iJlJ.js → diagram-MLGK6HIB-xO-efOVl.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-DJuTbhbP.js → diagram-MPIPVDR6-CjWQ4FpH.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-f1VEI2Po.js → ebnfDiagram-ZINNZB2B-DbyEj47I.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-BRbs9WzY.js → elk-276RUBZZ-B0uak8Gs.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-DvMp_cQr.js → erDiagram-OPXOYQCR-DHYzl46p.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-CYS1A0fu.js → flowDiagram-KWPJA3E3-CjUIIif9.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-qya_JE9x.js → ganttDiagram-FUAMR5RP-CPjVOkNO.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-ChMUJ3hH.js → gitGraphDiagram-X574FWY7-DnI_xNjh.js} +1 -1
- package/dist/assets/{index-COH7BlyH.js → index-C8wABnWu.js} +177 -177
- package/dist/assets/{index-xE4Li_H2.js → index-kYL6p_po.js} +1 -1
- package/dist/assets/{infoDiagram-VRGFBTTK-B2VudqsE.js → infoDiagram-VRGFBTTK-SXQSkFFT.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-Bdk47y0t.js → ishikawaDiagram-OU5B5YK6-DF3AQU1D.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-A4StgNQ9.js → journeyDiagram-ZHPQQLJL-IWRv1Evh.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-DZo45dQw.js → kanban-definition-PNTS6WVX-BKpuGZmD.js} +1 -1
- package/dist/assets/{linear-D_rK-Ord.js → linear-S9gqQWWc.js} +1 -1
- package/dist/assets/{mermaid.core-C7CvDDvz.js → mermaid.core-BHRIdye5.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-6fmVPMyc.js → mindmap-definition-NLK3R4M7-BTD52Pxv.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-CD4Qg24h.js → pegDiagram-GJSIUBJH-C91CNvYA.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-DmzQ883B.js → pieDiagram-5QR66LMP-0aP3PVSg.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-BW37utPZ.js → quadrantDiagram-O4NWA36T-CN-CB1dj.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-CWXiMlAb.js → railroadDiagram-XR7U4H2S-DUwKNVqn.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-DHSfr9U3.js → requirementDiagram-PLB6GJNP-BwiKCqXR.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-PebTt4eq.js → sankeyDiagram-IPEJSGJF-DK2nk983.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-DPwp8fia.js → sequenceDiagram-PO4LG4MO-DGQaL2CK.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-BX_46o3S.js → sizeCapture-INFHLROL-DjxAs07q.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-W2e0RRrZ.js → stateDiagram-v2-GCMORJYK-DfhvmAHx.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-CkyXpQX9.js → swimlanes-2SLR337P-g4YraApj.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-BnxrvDBt.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-BS-sCjlN.js → timeline-definition-EJHVYXUP-Bh6Ow15M.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-BQre-k6x.js → usecaseDiagram-POWQR4AR-wRtBj8_e.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-CEWCsi_s.js → vennDiagram-UO4OBE2U-D4QR4Odj.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-CXUxqghG.js → wardleyDiagram-VNRHLVJA-DthL_SDi.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-DBgVMpwp.js → xychartDiagram-PMCCYNJV-CK-QrbHO.js} +1 -1
- package/dist/handbook/atomic-handbook.html +1 -1
- package/dist/index.html +1 -1
- package/dist-server/drivers/agents-proxy.js +2 -3
- package/dist-server/index.js +2405 -1990
- package/dist-server/openmausbot.js +180 -95
- package/dist-server/pair-cli.js +180 -95
- package/dist-server/server/auto-approve.js +12 -0
- package/dist-server/server/drivers/acp/core.js +4 -6
- package/dist-server/server/drivers/acp/custom.js +3 -1
- package/dist-server/server/drivers/acp/hermes.js +2 -1
- package/dist-server/server/drivers/agents-catalog.js +2 -2
- package/dist-server/server/drivers/chat-mcp-tools.js +1 -21
- package/dist-server/server/drivers/claude.js +69 -66
- package/dist-server/server/drivers/codex.js +4 -3
- package/dist-server/server/drivers/hermes-context-floor.js +68 -0
- package/dist-server/server/drivers/openai-chat.js +1 -1
- package/dist-server/server/drivers/session-allow-key.js +22 -5
- package/dist-server/server/engine-tiers.js +3 -7
- package/dist-server/server/god-mode-goal.js +78 -0
- package/dist-server/server/god-mode-run-host.js +69 -0
- package/dist-server/server/index.js +70 -73
- package/dist-server/server/model-fallback-repair.js +20 -0
- package/dist-server/server/new-bot-defaults.js +3 -1
- package/dist-server/server/personal-goal-runtime.js +29 -3
- package/dist-server/server/personal-goal-turn.js +2 -1
- package/dist-server/server/personal-goals.js +20 -2
- package/dist-server/server/routes/thread-stop.js +15 -2
- package/dist-server/server/surface.js +1 -1
- package/dist-server/shared/god-mode-run.js +173 -0
- package/dist-server/shared/personal-goal.js +42 -0
- package/package.json +1 -1
- package/dist/assets/channel-CT5xRPK0.js +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-BH9Yry0J.js +0 -8
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// A GOD MODE run is a personal goal with a deadline (shared/god-mode-run.ts).
|
|
2
|
+
// This module is what differs from an ordinary goal: the clock instead of a
|
|
3
|
+
// turn budget, and every outcome that would stop an ordinary goal (a failed
|
|
4
|
+
// turn, a question, a blocker, no progress) turned into the next attempt.
|
|
5
|
+
import { godModeRetryDelayMs, godModeRunStop, GOD_MODE_QUESTION_ANSWER, } from "../shared/god-mode-run.js";
|
|
6
|
+
const LOG_LIMIT = 500;
|
|
7
|
+
export function newGodModeRun(now, durationMs) {
|
|
8
|
+
return {
|
|
9
|
+
startedAt: now,
|
|
10
|
+
endsAt: now + durationMs,
|
|
11
|
+
attempts: 0,
|
|
12
|
+
failures: 0,
|
|
13
|
+
log: [{ at: now, stop: "paid-key", action: "approved", detail: "pay-per-use keys are approved for this run (Keep going)." }],
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** Whether this goal is a GOD MODE run still inside its time. */
|
|
17
|
+
export function godModeRunLive(goal, now) {
|
|
18
|
+
return Boolean(goal?.godMode && goal.status === "working" && now < goal.godMode.endsAt);
|
|
19
|
+
}
|
|
20
|
+
/** Record what the run did in the person's place. */
|
|
21
|
+
export function logGodModeRun(goal, now, entry) {
|
|
22
|
+
goal.godMode.log.push({ at: now, ...entry, detail: entry.detail.slice(0, 400) });
|
|
23
|
+
if (goal.godMode.log.length > LOG_LIMIT)
|
|
24
|
+
goal.godMode.log.splice(0, goal.godMode.log.length - LOG_LIMIT);
|
|
25
|
+
}
|
|
26
|
+
/** Decide a stop for a live run and log it. Undefined when the goal is not a
|
|
27
|
+
* live run: the ordinary behavior applies. */
|
|
28
|
+
export function decideGodModeStop(goal, now, stop) {
|
|
29
|
+
if (!godModeRunLive(goal, now))
|
|
30
|
+
return undefined;
|
|
31
|
+
const decision = godModeRunStop(stop);
|
|
32
|
+
const subject = [stop.tool, stop.question ?? stop.detail].filter(Boolean).join(": ");
|
|
33
|
+
logGodModeRun(goal, now, { stop: stop.kind, action: decision.action, detail: subject ? `${decision.note} [${subject}]` : decision.note });
|
|
34
|
+
return decision;
|
|
35
|
+
}
|
|
36
|
+
/** Before a run's turn: false when its time is up (the goal is closed). */
|
|
37
|
+
export function beginGodModeTurn(goal, now) {
|
|
38
|
+
if (now < goal.godMode.endsAt)
|
|
39
|
+
return true;
|
|
40
|
+
goal.status = "limit-reached";
|
|
41
|
+
goal.detail = "GOD MODE time is up. Start another run to keep going.";
|
|
42
|
+
logGodModeRun(goal, now, { stop: "turn-ended", action: "continued", detail: "time is up; the run ended." });
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
/** After a run's turn, for every outcome but a verified completion: keep the
|
|
46
|
+
* goal working and say how the next attempt should go. */
|
|
47
|
+
export function settleGodModeTurn(goal, now, result, decision) {
|
|
48
|
+
const run = goal.godMode;
|
|
49
|
+
goal.status = "working";
|
|
50
|
+
if (!result.ok) {
|
|
51
|
+
run.failures += 1;
|
|
52
|
+
run.attempts += 1;
|
|
53
|
+
goal.detail = "The last attempt failed before it finished. Check what is already done, then continue another way (another tool or approach).";
|
|
54
|
+
logGodModeRun(goal, now, { stop: "turn-failed", action: "continued", detail: `started attempt ${run.attempts + 1}.` });
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
run.failures = 0;
|
|
58
|
+
if (decision?.status === "needs-input") {
|
|
59
|
+
goal.detail = `${GOD_MODE_QUESTION_ANSWER} You asked: ${decision.detail}`;
|
|
60
|
+
logGodModeRun(goal, now, { stop: "question", action: "answered", detail: decision.detail });
|
|
61
|
+
}
|
|
62
|
+
else if (decision?.status === "blocked") {
|
|
63
|
+
goal.blockers = 0;
|
|
64
|
+
goal.lastBlocker = "";
|
|
65
|
+
goal.detail = `Blocked: ${decision.detail}. Do not stop: work around it another way, or skip that step and finish everything else.`;
|
|
66
|
+
logGodModeRun(goal, now, { stop: "check-in", action: "continued", detail: decision.detail });
|
|
67
|
+
}
|
|
68
|
+
// No measurable progress is a nudge, never a pause.
|
|
69
|
+
if (goal.missing >= 3 || goal.noProgress >= 3 || goal.repeated >= 3) {
|
|
70
|
+
goal.missing = goal.noProgress = goal.repeated = 0;
|
|
71
|
+
goal.detail = "Three turns without measurable progress. Change approach: inspect the current state, pick a different next step, and act with tools.";
|
|
72
|
+
logGodModeRun(goal, now, { stop: "turn-ended", action: "continued", detail: "no progress; changed approach." });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** How long the runtime waits before the run's next attempt. */
|
|
76
|
+
export function godModeNextAttemptDelay(goal) {
|
|
77
|
+
return goal.godMode && goal.status === "working" ? godModeRetryDelayMs(goal.godMode.failures) : 0;
|
|
78
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Where server/index.ts asks "is a GOD MODE run working here?", and what it
|
|
2
|
+
// does then with a card that would wait for the person.
|
|
3
|
+
import { HARD_LIMIT_TEXT } from "../shared/god-mode-run.js";
|
|
4
|
+
import { connectionRunOutPolicy } from "./connection-cap-failover.js";
|
|
5
|
+
import { appendDecision } from "./decision-log.js";
|
|
6
|
+
import { decideGodModeStop, godModeRunLive, logGodModeRun } from "./god-mode-goal.js";
|
|
7
|
+
/** Whether a GOD MODE run is working on this conversation now. */
|
|
8
|
+
export function godModeRunOn(goals, threadId) {
|
|
9
|
+
return Boolean(threadId) && godModeRunLive(goals.get(threadId), Date.now());
|
|
10
|
+
}
|
|
11
|
+
/** The pay-per-use policy for a conversation: a GOD MODE run is the
|
|
12
|
+
* person's "Keep going" for its whole time, so it never stops at the paid-key
|
|
13
|
+
* ask. An explicit pause the person chose still wins (paidKeysApproved). */
|
|
14
|
+
export function godModeRunOutPolicy(goals, threadId, engineTiers) {
|
|
15
|
+
return godModeRunOn(goals, threadId) ? "keep-going" : connectionRunOutPolicy(engineTiers);
|
|
16
|
+
}
|
|
17
|
+
/** A run-only override of an ordinary refusal (a subscription bot's provider
|
|
18
|
+
* lock, the paid-key ask): true when a run is working on the conversation.
|
|
19
|
+
* Logged once a minute per kind, because ladder walks ask many times. */
|
|
20
|
+
export function godModeRunOverrides(goals, threadId, stop, detail) {
|
|
21
|
+
if (!threadId)
|
|
22
|
+
return false;
|
|
23
|
+
const goal = goals.get(threadId);
|
|
24
|
+
const now = Date.now();
|
|
25
|
+
if (!godModeRunLive(goal, now))
|
|
26
|
+
return false;
|
|
27
|
+
const last = goal.godMode.log.findLast((entry) => entry.stop === stop);
|
|
28
|
+
if (!last || now - last.at > 60_000) {
|
|
29
|
+
logGodModeRun(goal, now, { stop, action: "switched", detail });
|
|
30
|
+
goals.touch(goal);
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
/** A card that reached this point would wait for the person. On a running
|
|
35
|
+
* GOD MODE run it does not: an approval is logged and goes ahead as usual
|
|
36
|
+
* (false), a question is answered for the absent person and a hard limit is
|
|
37
|
+
* refused to the bot, which keeps working another way (true: handled, no
|
|
38
|
+
* card). False whenever no run is working here. */
|
|
39
|
+
export function handleGodModeRunRequest(request) {
|
|
40
|
+
const goal = request.goals.get(request.threadId);
|
|
41
|
+
const now = Date.now();
|
|
42
|
+
if (!request.requestId || !godModeRunLive(goal, now))
|
|
43
|
+
return false;
|
|
44
|
+
const { verdict, permission, tool, summary } = request;
|
|
45
|
+
if (permission && verdict?.approve) {
|
|
46
|
+
decideGodModeStop(goal, now, { kind: "tool-permission", tool, input: summary, detail: summary });
|
|
47
|
+
request.goals.touch(goal);
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
const limit = permission ? verdict?.limit : undefined;
|
|
51
|
+
if (permission && !limit)
|
|
52
|
+
return false;
|
|
53
|
+
const decision = decideGodModeStop(goal, now, permission
|
|
54
|
+
? { kind: "tool-permission", tool, input: summary, detail: summary }
|
|
55
|
+
: { kind: "question", tool, question: summary });
|
|
56
|
+
request.goals.touch(goal);
|
|
57
|
+
if (!decision || !request.adapter)
|
|
58
|
+
return false;
|
|
59
|
+
const message = limit ? `${HARD_LIMIT_TEXT[limit]} Do not retry it; skip that step, say so, and finish the rest of the goal.` : decision.note;
|
|
60
|
+
const behavior = limit ? "deny" : "answer";
|
|
61
|
+
void request.adapter.respondToRequest(request.threadId, request.requestId, { behavior, message }).then((outcome) => {
|
|
62
|
+
request.note(limit ? `GOD MODE refused ${tool}: ${HARD_LIMIT_TEXT[limit]}` : `GOD MODE answered for you: ${summary || tool}`, outcome !== "unavailable");
|
|
63
|
+
}, () => request.note(`GOD MODE could not answer ${tool}.`, false));
|
|
64
|
+
appendDecision(request.dataDir, {
|
|
65
|
+
threadId: request.threadId, requestId: request.requestId, botId: request.bot?.id, botName: request.bot?.name,
|
|
66
|
+
tool, summary, decision: limit ? "auto-denied" : "auto-answered", source: "god-mode-run", rule: limit,
|
|
67
|
+
});
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
@@ -9,6 +9,7 @@ import { createModelExpectation, ModelEvidenceLedger, standInReason } from "./mo
|
|
|
9
9
|
import { reactToMessage } from "./message-reactions.js";
|
|
10
10
|
import { hasUnboundGoalGuard, goalGuardForEvent, addGoalGuard, removeGoalGuard, runPersonalGoalTurn, updatePersonalGoalReceipt } from "./personal-goal-turn.js";
|
|
11
11
|
import { PersonalGoalRuntime, receiveGoalCommand } from "./personal-goal-runtime.js";
|
|
12
|
+
import { godModeRunOn, godModeRunOutPolicy, godModeRunOverrides, handleGodModeRunRequest } from "./god-mode-run-host.js";
|
|
12
13
|
import { personalGoalInstructions } from "./personal-goals.js";
|
|
13
14
|
import { parseGoalCommand } from "../shared/personal-goal.js";
|
|
14
15
|
// OpenMausBot server — the harness host. Clients hold no transports
|
|
@@ -118,6 +119,7 @@ import { exchangeChannel, mirrorActivity, mirrorExchange, mirrorReply } from "./
|
|
|
118
119
|
import { findMessageInThreads, readMessageText, recallMessages, recentMessages, searchMessages, closeMessageDb, chatFollowups, cancelledChatFollowup, settleChatFollowups, threadsReferencing, readCommandReceipt, withCommandReceipt } from "./message-db.js";
|
|
119
120
|
import { briefCrossingLabel, claimRecallCrossings, recallCrossingLabel } from "./recall-disclosure.js";
|
|
120
121
|
import { parseSince, parseUntil, recentWork, recentWorkPrompt, turnOutcomeLine } from "./recent-work.js";
|
|
122
|
+
import { refusedModelLine, repairRefusedModel } from "./model-fallback-repair.js";
|
|
121
123
|
import { chiefForBot, INCIDENTS_THREAD_TITLE, IncidentLedger, incidentChip, incidentText, runWentOn } from "./incidents.js";
|
|
122
124
|
/** A session_read answer competes with the transcript for the context
|
|
123
125
|
* window; a computer-use turn's output can run to hundreds of KB. */
|
|
@@ -134,7 +136,6 @@ import { computerKindForResource, ManagedDesktopPolicy } from "./managed-policy.
|
|
|
134
136
|
import { hostedModelPolicy, HOSTED_MODEL_POLICY_HEADER, HOSTED_PROVIDER_SETTINGS_ERROR } from "./hosted-models.js";
|
|
135
137
|
import { newEventId } from "./contracts.js";
|
|
136
138
|
import { canTitle, routedThreadTitle } from "./thread-title.js";
|
|
137
|
-
import { freeTurnNexusRefusal, guardFreeTurn } from "./free-turn-guard.js";
|
|
138
139
|
import { createSummaryScheduler } from "./bot-summary.js";
|
|
139
140
|
import { BOT_SUMMARY_MAX, sanitizeBotSummary } from "../shared/bot-summary.js";
|
|
140
141
|
import { selectDefaultModelSelection, withNewBotEffort } from "./default-model-selection.js";
|
|
@@ -302,7 +303,7 @@ import { createEngineTierRoutes } from "./routes/engine-tiers.js";
|
|
|
302
303
|
import { createModelGatewayRoutes } from "./model-gateway/route.js";
|
|
303
304
|
import { applyChibiDefaults, chibiDefaultSelection } from "./chibi-defaults.js";
|
|
304
305
|
import { createPrimaryBotRoutes } from "./routes/primary-bot.js";
|
|
305
|
-
import { EngineSnapshotCache, botTier, canDriveComputer, classLadder, engineAccount, engineHealth, engineLabel, engineTierClasses, engineTierLadders, failoverClassOrder, engineTiersIncludeFree, generateLadders,
|
|
306
|
+
import { EngineSnapshotCache, botTier, canDriveComputer, classLadder, engineAccount, engineHealth, engineLabel, engineTierClasses, engineTierLadders, failoverClassOrder, engineTiersIncludeFree, generateLadders, ladderForClass, keyBased, needsDelegation, needsWiderWalk, resolveFailover, takeWider, resolveLadder } from "./engine-tiers.js";
|
|
306
307
|
import { PRIMARY_BOT_THREAD_TITLE, PRIMARY_BOT_TRIGGER, PrimaryBotStore, routesAsSweep, PrimaryBotSweeper } from "./primary-bot.js";
|
|
307
308
|
import { PRIMARY_BOT_LOCKED, primaryBotChoiceField, isPrimaryBot } from "../shared/primary-bot.js";
|
|
308
309
|
import { moveIntoChibi } from "./move-into-chibi.js";
|
|
@@ -330,7 +331,7 @@ import { createBoardRoutes } from "./routes/board.js";
|
|
|
330
331
|
import { readBoardFromNexus } from "./board/nexus-board.js";
|
|
331
332
|
import { LocalModelInventory, localModePlacement, machineMemory } from "./local-models-mode.js";
|
|
332
333
|
import { eventBase, restTime, FailoverGate, triesSpent, continuationNote, restingLine, restingOnRoute, sameRoute } from "./engine-failover.js";
|
|
333
|
-
import {
|
|
334
|
+
import { finalizeConnectionCapPick, finalizeNewTurnPlacement, pauseKeyBandForRunOut } from "./connection-cap-failover.js";
|
|
334
335
|
import { TURN_ERROR_CATEGORIES } from "../shared/runtime-events.js";
|
|
335
336
|
import { EngineProbes, PROBE_PROMPT, isProbeThread, probeThreadId } from "./engine-probe.js";
|
|
336
337
|
// [jev-verifier] opt-in Jev answer checks after a model switch (server/jev).
|
|
@@ -3081,9 +3082,8 @@ function turnEngineChoice(botId, threadId, needs, runOn) {
|
|
|
3081
3082
|
const task = store.taskByThread(botId, threadId);
|
|
3082
3083
|
if (hostedModels || !profile || !task)
|
|
3083
3084
|
return undefined;
|
|
3084
|
-
// A subscription bot runs only on its own provider
|
|
3085
|
-
|
|
3086
|
-
if (isSubscriptionBot(profile))
|
|
3085
|
+
// A subscription bot runs only on its own provider (Erick, 2026-11-13); a GOD MODE run may leave it when it is blocked.
|
|
3086
|
+
if (isSubscriptionBot(profile) && !godModeRunOverrides(personalGoals.goals, threadId, "provider-restriction", "left the bot's own provider for another engine."))
|
|
3087
3087
|
return subscriptionTurnEngineChoice(profile, threadId);
|
|
3088
3088
|
if (isPersonalBot(profile))
|
|
3089
3089
|
return personalTurnEngineChoice(profile, threadId, needs, runOn);
|
|
@@ -3114,7 +3114,7 @@ function ladderTurnEngineChoice(profile, projected, threadId, needs, runOn, subs
|
|
|
3114
3114
|
const { ladder } = plan;
|
|
3115
3115
|
const computer = turnComputer(projected, threadId, runOn);
|
|
3116
3116
|
const context = { candidates, needsDelegation: needsDelegation(tier, profile), computer, refuse: engineTierRefusal(projected), resting: engineResting, own: profile.modelSelection.instanceId,
|
|
3117
|
-
keyBandPaused: subscriptionsOnly || keyBandPausedFor(threadId), includeFree: engineTiersIncludeFree(cfg.engineTiers)
|
|
3117
|
+
keyBandPaused: subscriptionsOnly || keyBandPausedFor(threadId), includeFree: engineTiersIncludeFree(cfg.engineTiers) };
|
|
3118
3118
|
const local = (resolution) => localModeTurn(resolution, { tier, context, needs, prefer: [projected.modelSelection.instanceId] });
|
|
3119
3119
|
const wider = (tried, modelClass) => resolveFailover({
|
|
3120
3120
|
ladder, classLadder: (cls) => classLadder(classedModels(), cls), failed: projected.modelSelection, context, tried,
|
|
@@ -3137,7 +3137,7 @@ function ladderTurnEngineChoice(profile, projected, threadId, needs, runOn, subs
|
|
|
3137
3137
|
if (!resolution.choice && own && ownOut && !resolution.skipped.some((skip) => skip.reason === "paused")) {
|
|
3138
3138
|
throw restingStop(candidates, resolution.skipped, own.instanceId, computer);
|
|
3139
3139
|
}
|
|
3140
|
-
return placedTurn(local(resolution), true);
|
|
3140
|
+
return placedTurn(local(resolution), true, threadId);
|
|
3141
3141
|
}
|
|
3142
3142
|
// A pinned engine the last registry refresh reports signed out is treated
|
|
3143
3143
|
// as a failed sign-in up front, rather than spawned only to fail.
|
|
@@ -3167,7 +3167,7 @@ function ladderTurnEngineChoice(profile, projected, threadId, needs, runOn, subs
|
|
|
3167
3167
|
if (!resolution.choice && engineResting(own, projected.modelSelection.model) && !resolution.skipped.some((skip) => skip.reason === "paused")) {
|
|
3168
3168
|
throw restingStop(candidates, resolution.skipped, own.instanceId, computer);
|
|
3169
3169
|
}
|
|
3170
|
-
return placedTurn(local(resolution), false);
|
|
3170
|
+
return placedTurn(local(resolution), false, threadId);
|
|
3171
3171
|
}
|
|
3172
3172
|
/** An engine that is unavailable because its command-line program is not on
|
|
3173
3173
|
* this computer: Atomic Engine on a PC that never had `atomic`, a CLI since
|
|
@@ -3270,7 +3270,7 @@ function dictationSubscription() {
|
|
|
3270
3270
|
/** The key band is closed to a sweep unless the person chose "Keep going"
|
|
3271
3271
|
* (or local mode, which turns a key choice into a local model). */
|
|
3272
3272
|
function keyBandPausedFor(threadId) {
|
|
3273
|
-
return pauseKeyBandForRunOut({ policy:
|
|
3273
|
+
return pauseKeyBandForRunOut({ policy: runOutPolicy(threadId), paidApproved: Boolean(payPerUse.current()?.keptGoingAt),
|
|
3274
3274
|
pausedUntil: payPerUse.pausedUntil(), localUntil: payPerUse.localUntil(), sweep: isSweepTurn(threadId) });
|
|
3275
3275
|
}
|
|
3276
3276
|
/** The sweep turn's engine, or null when nothing it may use is free. `note`
|
|
@@ -3304,7 +3304,7 @@ function sweepEngineChoice(botId, threadId, note, runOn) {
|
|
|
3304
3304
|
return { selection: projected.modelSelection, persist: false };
|
|
3305
3305
|
}
|
|
3306
3306
|
// Nothing on a subscription: a local model in local mode, a key only after "Keep going".
|
|
3307
|
-
const keysAllowed = payPerUse.current()?.keptGoingAt !== undefined && payPerUse.pausedUntil() === undefined;
|
|
3307
|
+
const keysAllowed = (payPerUse.current()?.keptGoingAt !== undefined || godModeRunOn(personalGoals.goals, threadId)) && payPerUse.pausedUntil() === undefined;
|
|
3308
3308
|
if (payPerUse.localUntil() === undefined && !keysAllowed)
|
|
3309
3309
|
return null;
|
|
3310
3310
|
const context = { ...base, keyBandPaused: payPerUse.pausedUntil() !== undefined };
|
|
@@ -3317,16 +3317,17 @@ function sweepEngineChoice(botId, threadId, note, runOn) {
|
|
|
3317
3317
|
}
|
|
3318
3318
|
/** A turn start's ladder walk, as startTurn uses it: noted for pay-per-use,
|
|
3319
3319
|
* refused before an unapproved paid key, or when pay-per-use is paused. */
|
|
3320
|
-
function placedTurn(resolution, persist) {
|
|
3320
|
+
function placedTurn(resolution, persist, threadId) {
|
|
3321
3321
|
return finalizeNewTurnPlacement({
|
|
3322
|
-
policy:
|
|
3322
|
+
policy: runOutPolicy(threadId), paidApproved: Boolean(payPerUse.current()?.keptGoingAt),
|
|
3323
3323
|
local: resolution.local, choice: resolution.choice, skipped: resolution.skipped, pausedUntil: payPerUse.pausedUntil(),
|
|
3324
3324
|
currentLabel: "A subscription", formatTime: restTime, persist, pausedLine: payPerUsePausedLine,
|
|
3325
3325
|
announceWaiting: () => notePayPerUse({ skipped: resolution.skipped, local: true, choice: { band: "key", selection: { instanceId: "", model: "" }, candidate: { instanceId: "" }, step: 0 } }),
|
|
3326
3326
|
book: () => notePayPerUse(resolution),
|
|
3327
3327
|
});
|
|
3328
3328
|
}
|
|
3329
|
-
// ── pay-per-use (docs/chibitek/engine-tiers.md, "Pay-per-use notice")
|
|
3329
|
+
// ── pay-per-use (docs/chibitek/engine-tiers.md, "Pay-per-use notice"); a GOD MODE run is Keep going for its conversation ──
|
|
3330
|
+
const runOutPolicy = (threadId) => godModeRunOutPolicy(personalGoals.goals, threadId, cfg.engineTiers);
|
|
3330
3331
|
// The one thing about engines and billing the person hears of: a paid key is used only after stored approval
|
|
3331
3332
|
// when every subscription is resting, signed out or unavailable. That opens an episode, announced once;
|
|
3332
3333
|
// a turn a subscription answers ends it (noteEngineBack). Ollama Cloud is a subscription.
|
|
@@ -3619,8 +3620,8 @@ bus.setGate((published) => {
|
|
|
3619
3620
|
noteEngineBack(out);
|
|
3620
3621
|
return delivered;
|
|
3621
3622
|
});
|
|
3622
|
-
/** An engine finished a turn: a rest of it that has ended is marked back
|
|
3623
|
-
*
|
|
3623
|
+
/** An engine finished a turn: a rest of it that has ended is marked back (the rest history's `backAt`,
|
|
3624
|
+
* docs/chibitek/engine-tiers.md). A local-mode turn on a subscription engine is not that subscription back. */
|
|
3624
3625
|
function noteEngineBack(event) {
|
|
3625
3626
|
const instanceId = event.providerInstanceId;
|
|
3626
3627
|
if (!instanceId)
|
|
@@ -3630,7 +3631,7 @@ function noteEngineBack(event) {
|
|
|
3630
3631
|
const model = selection?.instanceId === instanceId ? selection.model : undefined;
|
|
3631
3632
|
for (const scope of new Set([candidate ? restScope(candidate, model) : undefined, modelScope(model)]))
|
|
3632
3633
|
engineRests.noteBack(instanceId, candidate ? engineAccount(candidate) : undefined, scope);
|
|
3633
|
-
if (candidate && !keyBased(candidate) && !freeCandidate(candidate) && !(model && (perTokenModel(candidate, model) || injectedModel(model))))
|
|
3634
|
+
if (candidate && !keyBased(candidate) && !freeCandidate(candidate) && !(model && (perTokenModel(candidate, model) || injectedModel(model) || isLocalModel(candidate, model))))
|
|
3634
3635
|
(instanceOwner(instanceId) === "personal" ? personalPayPerUse : payPerUse).subscriptionAnswered();
|
|
3635
3636
|
}
|
|
3636
3637
|
/** Rest a refused engine and continue on an eligible engine, or show an actionable line. */
|
|
@@ -3852,7 +3853,7 @@ function failoverPick(turn, profile, projected, candidates, failedCandidate, res
|
|
|
3852
3853
|
// A subscription bot fails over only to another account of its own
|
|
3853
3854
|
// provider on its side of the personal line; with none left it stops with
|
|
3854
3855
|
// its one line.
|
|
3855
|
-
const subscriptionMove = isSubscriptionBot(profile)
|
|
3856
|
+
const subscriptionMove = isSubscriptionBot(profile) && !godModeRunOverrides(personalGoals.goals, turn.threadId, "provider-restriction", "left the bot's own provider for another engine.")
|
|
3856
3857
|
? triesSpent(tried) || !projected
|
|
3857
3858
|
? { line: subscriptionLine(profile, candidates) }
|
|
3858
3859
|
: subscriptionPlacement({ profile, projected, candidates, tried: new Set([...tried, turn.instanceId]), auto: attempt.persist, modelClass: neededClass })
|
|
@@ -3879,7 +3880,7 @@ function failoverPick(turn, profile, projected, candidates, failedCandidate, res
|
|
|
3879
3880
|
classLadder: (modelClass) => classLadder(classedModels(), modelClass),
|
|
3880
3881
|
failed: attempt.selection,
|
|
3881
3882
|
context: { candidates, needsDelegation: needsDelegation(tier, profile), computer, refuse: engineTierRefusal(projected), resting, own: profile.modelSelection.instanceId,
|
|
3882
|
-
keyBandPaused: keyBandPausedFor(turn.threadId), includeFree: engineTiersIncludeFree(cfg.engineTiers)
|
|
3883
|
+
keyBandPaused: keyBandPausedFor(turn.threadId), includeFree: engineTiersIncludeFree(cfg.engineTiers) },
|
|
3883
3884
|
tried,
|
|
3884
3885
|
modelClass: neededClass,
|
|
3885
3886
|
mayDrop: true,
|
|
@@ -3900,7 +3901,7 @@ function failoverPick(turn, profile, projected, candidates, failedCandidate, res
|
|
|
3900
3901
|
pausedUntil: payPerUse.pausedUntil(), skipped: resolution.skipped, payPerUsePausedLine, restingNamed,
|
|
3901
3902
|
failedInstanceId: turn.instanceId, alreadyTried: attempt.tried, triedCount: tried.size,
|
|
3902
3903
|
cannotDrive: cannotDriveNamed(candidates, resolution.skipped, computer),
|
|
3903
|
-
policy:
|
|
3904
|
+
policy: runOutPolicy(turn.threadId), paidApproved: Boolean(payPerUse.current()?.keptGoingAt),
|
|
3904
3905
|
local: Boolean(placed.local), currentLabel: engineLabel(candidates, attempt.selection),
|
|
3905
3906
|
nextLabel: choice ? engineLabel(candidates, choice.selection) : undefined,
|
|
3906
3907
|
nextBand: choice && "band" in choice ? choice.band : undefined, resetAt: turn.failure?.resetAt, formatTime: restTime,
|
|
@@ -4076,7 +4077,7 @@ function engineTierRefusal(bot, options = {}) {
|
|
|
4076
4077
|
if (!options.ignoreOwner && !ownerAllows(bot, ownerCheck(candidate), false))
|
|
4077
4078
|
return "owner";
|
|
4078
4079
|
// A subscription bot never leaves its provider (server/subscription-bots.ts).
|
|
4079
|
-
if (!providerAllows(bot, candidate, subscriptionFacts))
|
|
4080
|
+
if (!providerAllows(bot, candidate, subscriptionFacts) && !godModeRunOn(personalGoals.goals, bot.threadId))
|
|
4080
4081
|
return "provider";
|
|
4081
4082
|
if (candidate.instanceId !== bot.modelSelection.instanceId && modelSwitchNeedsAsk(mode, from, candidate.driverKind, godModeCovers(bot)))
|
|
4082
4083
|
return "approval";
|
|
@@ -4500,13 +4501,13 @@ for (const id of botWorkModes.expired(id => sessions.isLive(id)))
|
|
|
4500
4501
|
const delegatedFull = new DelegatedFullAccess(join(DATA_DIR, "delegated-full-access.json"));
|
|
4501
4502
|
for (const stale of delegatedFull.reconcile(store.bots, id => store.messagesFor(id)))
|
|
4502
4503
|
store.patchTask(stale.botId, stale.threadId, { approvalMode: "ask", autoApprove: false, alwaysAllow: [] });
|
|
4503
|
-
const approvalModeForTurn = (bot, peerInitiated = false) => godModeElevates(bot) ? "full" : ownApprovalModeForTurn(bot, peerInitiated);
|
|
4504
|
+
const approvalModeForTurn = (bot, peerInitiated = false) => godModeRunOn(personalGoals.goals, bot.threadId) ? "ask" : godModeElevates(bot) ? "full" : ownApprovalModeForTurn(bot, peerInitiated); // a run's every call reaches the harness, which approves it unless a hard limit applies
|
|
4504
4505
|
/** The bot's (or thread's) own level for a turn, GOD MODE aside. A thread a
|
|
4505
4506
|
* Chief delegated into is Full only while that Chief's conversation still is
|
|
4506
4507
|
* (`derived`); nothing is saved on the thread, so it ends when the source does. */
|
|
4507
4508
|
const ownApprovalModeForTurn = (bot, peerInitiated = false, derived = true) => derived && botWorkModes.permits("full") && delegatedFullAccessActive(bot.threadId, { source: id => delegatedFull.source(id), stillGrants: source => Boolean(store.bot(source.botId) && delegatedFullAccess(store.bot(source.botId), source.threadId, bot)) }) ? "full" : ownBotApprovalMode(bot, registry.cliTarget(bot.modelSelection.instanceId)?.driverKind, peerInitiated, botWorkModes.permits(approvalModeFor(bot)));
|
|
4508
4509
|
function godModeCovers(bot) {
|
|
4509
|
-
return legacyGodModeCovers(bot, godModeActive() && botWorkModes.permits("full"), botWorkModes.selected(bot.id) !== undefined);
|
|
4510
|
+
return legacyGodModeCovers(bot, godModeActive() && botWorkModes.permits("full"), botWorkModes.selected(bot.id) !== undefined && !godModeRunOn(personalGoals.goals, bot.threadId));
|
|
4510
4511
|
}
|
|
4511
4512
|
/** GOD MODE runs this bot or thread at Full, whatever its own level says:
|
|
4512
4513
|
* it is covered (godModeCovers) and its engine implements Full. */
|
|
@@ -5052,7 +5053,7 @@ const personalGoals = new PersonalGoalRuntime(join(DATA_DIR, "personal-goals.jso
|
|
|
5052
5053
|
if (owns)
|
|
5053
5054
|
await interruptDirectThread(botId, threadId);
|
|
5054
5055
|
},
|
|
5055
|
-
changed: (goal) => updatePersonalGoalReceipt(goal, store),
|
|
5056
|
+
changed: (goal) => updatePersonalGoalReceipt(goal, store), godMode: (botId) => Boolean(store.bot(botId) && godModeActive() && botWorkModes.permits("full")),
|
|
5056
5057
|
run: (goal) => runPersonalGoalTurn(goal, { store, addGuard: addGroupGoalCoordinatorTurn, removeGuard: removeGroupGoalCoordinatorTurn,
|
|
5057
5058
|
subscribe: (listener) => bus.subscribe(listener), ignore: shouldIgnoreProviderEvent, busy: threadBusy, start: startTurn }),
|
|
5058
5059
|
});
|
|
@@ -7551,7 +7552,7 @@ function continueComputerSelection(threadId, generation, succeeded) {
|
|
|
7551
7552
|
// machine's record, so a later Works on change may sweep it.
|
|
7552
7553
|
store.patchTask(bot.id, threadId, { surface, surfaceSource: "auto" });
|
|
7553
7554
|
const text = `The computer selection is now ${surfaceLabel(surface)}. Continue the user's original request using the tools mounted for this turn; verify the result before claiming success.\n\n${selection.text}`;
|
|
7554
|
-
void startTurn(bot.id, text, { threadId, userMessage: selection.source, computerSelectionContinuation:
|
|
7555
|
+
void startTurn(bot.id, text, { threadId, userMessage: selection.source, computerSelectionContinuation: selection.text }).catch(error => {
|
|
7555
7556
|
if (store.taskByThread(bot.id, threadId))
|
|
7556
7557
|
store.appendMessage(threadId, { role: "bot", kind: "activity",
|
|
7557
7558
|
tool: { name: `Could not continue on ${surfaceLabel(surface)}: ${error instanceof Error ? error.message : String(error)}`, ok: false } });
|
|
@@ -7822,15 +7823,12 @@ bus.subscribe((event) => {
|
|
|
7822
7823
|
sessionModelByThread.set(event.threadId, event.model);
|
|
7823
7824
|
break;
|
|
7824
7825
|
case "session.model-fallback":
|
|
7825
|
-
// The engine refused the thread's model and the turn went on with
|
|
7826
|
-
//
|
|
7827
|
-
|
|
7828
|
-
pushMessage({
|
|
7829
|
-
role: "bot",
|
|
7830
|
-
kind: "activity",
|
|
7831
|
-
tool: { name: `model ${event.requested} is not offered by this engine any more: continuing on ${event.model}`, ok: true },
|
|
7832
|
-
});
|
|
7826
|
+
// The engine refused the thread's model and the turn went on with another (drivers/acp/core.ts); the
|
|
7827
|
+
// thread keeps the one that ran, so it is not refused every turn. One quiet line; the Chief hears of it.
|
|
7828
|
+
pushMessage({ role: "bot", kind: "activity", tool: { name: refusedModelLine(event), ok: true } });
|
|
7833
7829
|
if (bot) {
|
|
7830
|
+
if (event.providerInstanceId)
|
|
7831
|
+
repairRefusedModel(store, bot.id, event.threadId, { ...event, instanceId: event.providerInstanceId });
|
|
7834
7832
|
reportIncident({
|
|
7835
7833
|
kind: "model-fallback", bot, threadId: event.threadId,
|
|
7836
7834
|
detail: `asked for ${event.requested}, the engine answered "${event.reason.slice(0, 160)}"; the turn ran on ${event.model}`,
|
|
@@ -7939,7 +7937,7 @@ bus.subscribe((event) => {
|
|
|
7939
7937
|
// engine) whose turn therefore still runs at the bot's own level. It
|
|
7940
7938
|
// is logged as `god-mode` unless the bot's own level is Full anyway.
|
|
7941
7939
|
const godModeAnswers = !othersAsked && Boolean(permission && asker && godModeCovers(asker)) &&
|
|
7942
|
-
ownApprovalModeForTurn(asker, isInternalTurn(event.threadId)) !== "full";
|
|
7940
|
+
(ownApprovalModeForTurn(asker, isInternalTurn(event.threadId)) !== "full" || godModeRunOn(personalGoals.goals, event.threadId));
|
|
7943
7941
|
// A read-only tool of one of the person's own MCP servers, by that
|
|
7944
7942
|
// server's own annotation, on a server whose switch is on. Never for
|
|
7945
7943
|
// host-computer control, which stays one approval at a time.
|
|
@@ -7959,7 +7957,7 @@ bus.subscribe((event) => {
|
|
|
7959
7957
|
destructive: event.mcpTool?.annotations?.destructiveHint === true,
|
|
7960
7958
|
};
|
|
7961
7959
|
const ownVerdict = permission && asker && event.requestId
|
|
7962
|
-
? autoVerdict(effectiveApprovalMode, event.tool, { requiresExplicitApproval: event.requiresExplicitApproval, readOnlyMcpTool, godMode: godModeAnswers })
|
|
7960
|
+
? autoVerdict(effectiveApprovalMode, event.tool, { requiresExplicitApproval: event.requiresExplicitApproval, readOnlyMcpTool, godMode: godModeAnswers, godModeLimits: !othersAsked && godModeCovers(asker) ? { summary: event.summary } : undefined })
|
|
7963
7961
|
: null;
|
|
7964
7962
|
// An approval the person gave in the Chief of Staff's conversation,
|
|
7965
7963
|
// carried into this delegated turn. Only what the turn's own level
|
|
@@ -7976,8 +7974,7 @@ bus.subscribe((event) => {
|
|
|
7976
7974
|
source: "delegated-grant",
|
|
7977
7975
|
}
|
|
7978
7976
|
: ownVerdict;
|
|
7979
|
-
// The room shows "Waiting for <owner> to approve" while the owner's
|
|
7980
|
-
// card is open (on this desktop or the paired iPhone).
|
|
7977
|
+
// The room shows "Waiting for <owner> to approve" while the owner's card is open (desktop or paired iPhone).
|
|
7981
7978
|
if (roomAsk && permission && event.requestId && !verdict?.approve) {
|
|
7982
7979
|
const actionHash = createHash("sha256").update(JSON.stringify([event.threadId, event.requestId, event.tool, event.summary])).digest("hex");
|
|
7983
7980
|
teamRoomsHost?.approvalOpened(event.threadId, event.requestId, event.summary || event.tool, actionHash);
|
|
@@ -8002,6 +7999,8 @@ bus.subscribe((event) => {
|
|
|
8002
7999
|
},
|
|
8003
8000
|
});
|
|
8004
8001
|
}
|
|
8002
|
+
if (!othersAsked && handleGodModeRunRequest({ goals: personalGoals.goals, dataDir: DATA_DIR, threadId: event.threadId, requestId: event.requestId, permission, tool: event.tool, summary: event.summary, verdict, bot: asker, adapter: (event.providerInstanceId ? registry.get(event.providerInstanceId) : asker && registry.get(asker.modelSelection.instanceId))?.adapter, note: (name, ok) => pushMessage({ role: "bot", kind: "activity", tool: { name, ok } }) }))
|
|
8003
|
+
break;
|
|
8005
8004
|
if (verdict?.approve && asker && event.requestId) {
|
|
8006
8005
|
const settled = verdict.approve;
|
|
8007
8006
|
const instance = event.providerInstanceId
|
|
@@ -8244,7 +8243,7 @@ bus.subscribe((event) => {
|
|
|
8244
8243
|
// keeps the same failure from reporting a second incident.
|
|
8245
8244
|
const lazyClaimAlreadyReported = event.stopReason === "exit_before_result" &&
|
|
8246
8245
|
turnResourceOwners.get(event.threadId)?.lazyClaimFailureReported === true;
|
|
8247
|
-
if (!event.ok && event.stopReason !== "interrupted" && !lazyClaimAlreadyReported && !routines?.runForThread(event.threadId)) {
|
|
8246
|
+
if (!event.ok && event.stopReason !== "interrupted" && !lazyClaimAlreadyReported && !routines?.runForThread(event.threadId) && !godModeRunOn(personalGoals.goals, event.threadId)) {
|
|
8248
8247
|
const broken = bot ?? (speaker ? store.bot(speaker.botId) : undefined);
|
|
8249
8248
|
if (broken)
|
|
8250
8249
|
reportIncident({ kind: "failed", bot: broken, threadId: event.threadId, detail: failedRunDetail(event.stopReason, turnError), notifyChief: event.stopReason === "auth_required" });
|
|
@@ -9922,11 +9921,11 @@ async function startTurn(botId, text, opts) {
|
|
|
9922
9921
|
directTurnDispatchClaims.set(threadId, { id: dispatchClaimId, botId, threadId, phase: "setup" });
|
|
9923
9922
|
directTurnBots.set(threadId, bot);
|
|
9924
9923
|
beginInternalCapabilityGeneration(threadId, dispatchClaimId);
|
|
9925
|
-
if (!opts?.
|
|
9924
|
+
if (!opts?.cardContinuation && !opts?.automationSource && !opts?.unattended &&
|
|
9926
9925
|
!opts?.commsDepth && !opts?.coordination && !inheritedTeamComputer(bot) && bot.computer !== "off" && agentsMounted) {
|
|
9927
9926
|
const source = store.activePath(threadId).findLast(message => message.id === userMessage?.id && message.role === "user" && !message.peerAsk);
|
|
9928
9927
|
if (source)
|
|
9929
|
-
computerSelectionTurns.set(threadId, { generation: dispatchClaimId, botId: bot.id, source, text });
|
|
9928
|
+
computerSelectionTurns.set(threadId, { generation: dispatchClaimId, botId: bot.id, source, text: opts?.computerSelectionContinuation ?? text });
|
|
9930
9929
|
}
|
|
9931
9930
|
store.setTaskActivity(bot.id, threadId, "working");
|
|
9932
9931
|
// A closed thread that gets a new turn is open again: the person (or the
|
|
@@ -10749,16 +10748,15 @@ async function startTurn(botId, text, opts) {
|
|
|
10749
10748
|
}
|
|
10750
10749
|
}
|
|
10751
10750
|
const addons = turnAddons(liveBot ?? bot, instance.driverKind, { local: opts?.runOn !== "cloud", fileTools: worksInWorkspace });
|
|
10752
|
-
const blockedPaths = guardFreeTurn(threadId, providerConfigs()[instance.instanceId]?.account, integrations, [paw.root, resolveIcmPath(cfg)]);
|
|
10753
10751
|
// What Nexus already knows for this person: read once per session and
|
|
10754
10752
|
// cached, bounded in size and time, never holding the turn up. A Team
|
|
10755
10753
|
// Room turn reads it only when its owner shares memories in that room.
|
|
10756
|
-
const nexusContext =
|
|
10754
|
+
const nexusContext = nexusOwnerThread(threadId) && (!roomTurn || roomTurn.share.memories)
|
|
10757
10755
|
? await nexusMemory.readBack({ bot: liveBot ?? bot, threadId, query: providerText })
|
|
10758
10756
|
: "";
|
|
10759
10757
|
const prompt = buildSystemPrompt(persona, liveBot?.soul ?? bot.soul ?? "", roomPromptSections(roomTurn, [
|
|
10760
10758
|
{ id: "personal-goal", label: "Active goal", text: personalGoals.goals.get(threadId)?.status === "working" ? personalGoalInstructions(personalGoals.goals.get(threadId)) : "" },
|
|
10761
|
-
{ id: "user-profile", label: "About the user", text:
|
|
10759
|
+
{ id: "user-profile", label: "About the user", text: userProfileSystemPrompt(cfg.profile) },
|
|
10762
10760
|
// the ICM folder is on this machine; a cloud run cannot reach it
|
|
10763
10761
|
// first after the soul: the block names agent tools, so it only goes
|
|
10764
10762
|
// to a turn whose engine actually mounted them (setupMode is already
|
|
@@ -10766,8 +10764,8 @@ async function startTurn(botId, text, opts) {
|
|
|
10766
10764
|
{ id: "setup", label: "Setup", text: setupSystemPrompt(setupMode, { skills: skillAuthoring, cwd: liveBot?.cwd ?? bot.cwd }) },
|
|
10767
10765
|
// after setup (which must follow the soul): PAW (Personal AI Workspace)
|
|
10768
10766
|
// first, then a legacy ICM folder; a cloud run cannot reach either
|
|
10769
|
-
{ id: "paw", label: "Shared context (PAW)", text:
|
|
10770
|
-
{ id: "icm", label: "Shared context (ICM)", text:
|
|
10767
|
+
{ id: "paw", label: "Shared context (PAW)", text: pawPrompt(liveBot ?? bot, text, opts?.runOn) },
|
|
10768
|
+
{ id: "icm", label: "Shared context (ICM)", text: opts?.runOn !== "cloud" ? icmSystemPrompt(cfg) : "" },
|
|
10771
10769
|
{ id: "private-bot", label: "Private Bot", text: isPersonalBot(liveBot ?? bot) ? privateBotPrompt(privateChibiLinkActive()) : chibiLinkPromptFor(liveBot ?? bot, threadId) },
|
|
10772
10770
|
{ id: "files", label: "File locations", text: worksInWorkspace && opts?.runOn !== "cloud" ? workspaceLocationsPrompt(bot.id, cwd, liveBot?.cwd ?? bot.cwd) : "" },
|
|
10773
10771
|
{ id: "repos", label: "Linked repos", text: repoPlan ? repoPromptSection(repoPlan, repoPlace(opts?.runOn, computerKind), cwd) : "" },
|
|
@@ -10842,7 +10840,7 @@ async function startTurn(botId, text, opts) {
|
|
|
10842
10840
|
systemStable: prompt.stable,
|
|
10843
10841
|
systemVolatile: prompt.volatile,
|
|
10844
10842
|
systemVolatileSections: prompt.volatileSections,
|
|
10845
|
-
integrations,
|
|
10843
|
+
integrations,
|
|
10846
10844
|
...userMcpForTurn(liveBot ?? bot, instance),
|
|
10847
10845
|
...(addons.pluginDirs.length ? { pluginDirs: addons.pluginDirs } : {}),
|
|
10848
10846
|
...(addons.rtk ? { rtk: addons.rtk } : {}),
|
|
@@ -12223,7 +12221,6 @@ failover) {
|
|
|
12223
12221
|
if (Object.keys(custom).length)
|
|
12224
12222
|
integrations.custom = custom;
|
|
12225
12223
|
}
|
|
12226
|
-
const blockedPaths = guardFreeTurn(threadId, providerConfigs()[instance.instanceId]?.account, integrations, [paw.root, resolveIcmPath(cfg)]);
|
|
12227
12224
|
// Turn setup can yield before a provider owns the bot. An interrupt
|
|
12228
12225
|
// during that setup window must still stop the queued
|
|
12229
12226
|
// room operation before it starts a process.
|
|
@@ -12618,13 +12615,13 @@ failover) {
|
|
|
12618
12615
|
}
|
|
12619
12616
|
}
|
|
12620
12617
|
const roomAddons = turnAddons(readyBot, instance.driverKind, { local: true, fileTools: worksInWorkspace });
|
|
12621
|
-
const roomNexusContext =
|
|
12618
|
+
const roomNexusContext = nexusOwnerThread(threadId)
|
|
12622
12619
|
? await nexusMemory.readBack({ bot, threadId, query: addressedRequest?.text ?? "" })
|
|
12623
12620
|
: "";
|
|
12624
12621
|
const roomSystem = buildSystemPrompt(system, store.bot(bot.id)?.soul ?? bot.soul ?? "", [
|
|
12625
|
-
{ id: "user-profile", label: "About the user", text:
|
|
12626
|
-
{ id: "paw", label: "Shared context (PAW)", text:
|
|
12627
|
-
{ id: "icm", label: "Shared context (ICM)", text:
|
|
12622
|
+
{ id: "user-profile", label: "About the user", text: userProfileSystemPrompt(cfg.profile) },
|
|
12623
|
+
{ id: "paw", label: "Shared context (PAW)", text: pawPrompt(bot, "") },
|
|
12624
|
+
{ id: "icm", label: "Shared context (ICM)", text: icmSystemPrompt(cfg) },
|
|
12628
12625
|
{ id: "private-bot", label: "Private Bot", text: isPersonalBot(bot) ? privateBotPrompt(false) : "" },
|
|
12629
12626
|
{ id: "files", label: "File locations", text: workspace ? workspaceLocationsPrompt(bot.id, cwd, readyBot.cwd) : "" },
|
|
12630
12627
|
{ id: "repos", label: "Linked repos", text: repoPlan ? repoPromptSection(repoPlan, repoPlace(undefined, roomTeamComputer || roomComputerKind === "box" ? "box" : roomVmMounted ? "vm" : roomComputerKind), cwd) : "" },
|
|
@@ -12788,7 +12785,7 @@ failover) {
|
|
|
12788
12785
|
systemVolatileSections: roomSystem.volatileSections,
|
|
12789
12786
|
cwd,
|
|
12790
12787
|
additionalDirs: turnAdditionalDirs(repoPlan, cwd),
|
|
12791
|
-
integrations,
|
|
12788
|
+
integrations,
|
|
12792
12789
|
...userMcpForTurn(readyBot, instance),
|
|
12793
12790
|
...(roomAddons.pluginDirs.length ? { pluginDirs: roomAddons.pluginDirs } : {}),
|
|
12794
12791
|
...(roomAddons.rtk ? { rtk: roomAddons.rtk } : {}),
|
|
@@ -16192,6 +16189,20 @@ ROUTES.push(createThreadStopRoutes({
|
|
|
16192
16189
|
working: (botId, threadId) => threadBusy(botId, threadId) || Boolean(roomHandoffs.activeDirect(threadId)) ||
|
|
16193
16190
|
routines?.activeBotRunForBot(botId)?.threadId === threadId,
|
|
16194
16191
|
stop: stopBotThread,
|
|
16192
|
+
hold: async (botId, threadId) => {
|
|
16193
|
+
const bot = store.bot(botId);
|
|
16194
|
+
if (!bot)
|
|
16195
|
+
return "unavailable";
|
|
16196
|
+
const instance = registry.get((botForThread(botId, threadId) ?? bot).modelSelection.instanceId);
|
|
16197
|
+
return (await instance?.adapter.holdTurn?.(threadId)) ?? "unavailable";
|
|
16198
|
+
},
|
|
16199
|
+
resume: async (botId, threadId) => {
|
|
16200
|
+
const bot = store.bot(botId);
|
|
16201
|
+
if (!bot)
|
|
16202
|
+
return "unavailable";
|
|
16203
|
+
const instance = registry.get((botForThread(botId, threadId) ?? bot).modelSelection.instanceId);
|
|
16204
|
+
return (await instance?.adapter.resumeTurn?.(threadId)) ?? "unavailable";
|
|
16205
|
+
},
|
|
16195
16206
|
}));
|
|
16196
16207
|
const sharedDeliverables = new SharedDeliverables(DATA_DIR);
|
|
16197
16208
|
const deliverableAccess = (senderId, auth) => sharedDeliverableAccess(sharedDeliverables, {
|
|
@@ -16202,8 +16213,6 @@ const deliverableAccess = (senderId, auth) => sharedDeliverableAccess(sharedDeli
|
|
|
16202
16213
|
ROUTES.push(createSharedDeliverablesRoutes(sharedDeliverables, () => deliverableAccess(undefined).sharedBlockedRoots ?? []));
|
|
16203
16214
|
ROUTES.push(createMessageFileRoutes({ store, attachments: ATTACHMENTS_DIR, workspaceDir, access: deliverableAccess }), createModelGatewayRoutes({ withinBudget: () => assertWithinBudget(cfg, DATA_DIR), book: bookTurnUsage }));
|
|
16204
16215
|
ROUTES.push(createPinOrderRoutes({ store, visible: (auth) => visibleTo(viewerFor(auth)), personalHidden: personalBotHidden, fromBot: (req) => authorizedInternalCapability(req.headers.authorization) !== null }));
|
|
16205
|
-
// Linked repos: Settings > Repos, per-thread links and worktrees. See
|
|
16206
|
-
// server/routes/repos.ts for the routes and docs/chibitek/README.md.
|
|
16207
16216
|
ROUTES.push(createRepoRoutes({
|
|
16208
16217
|
registry: repoRegistry,
|
|
16209
16218
|
github: new GitHubRepos(repoRegistry),
|
|
@@ -16283,10 +16292,7 @@ const handleRequest = async (req, res) => {
|
|
|
16283
16292
|
if (refusal)
|
|
16284
16293
|
return json(res, 403, { error: refusal, code: "managed_policy" });
|
|
16285
16294
|
}
|
|
16286
|
-
//
|
|
16287
|
-
// Two public routes come first: what this server is, and turning a pairing
|
|
16288
|
-
// code into a session. Everything else needs the loopback owner or a
|
|
16289
|
-
// paired session with the right scope.
|
|
16295
|
+
// Auth (server/request-auth.ts): /meta and /pair are public; everything else needs a session.
|
|
16290
16296
|
if (method === "GET" && !path.startsWith("/api/") && !path.startsWith("/.well-known/") && serveStatic(res, path))
|
|
16291
16297
|
return;
|
|
16292
16298
|
if (method === "GET" && path === "/.well-known/openmausbot/environment") {
|
|
@@ -16298,9 +16304,7 @@ const handleRequest = async (req, res) => {
|
|
|
16298
16304
|
const challenge = customDomainVerifier.challenge(domainCheck[1]);
|
|
16299
16305
|
return json(res, challenge ? 200 : 404, challenge ?? { error: "No active domain check." });
|
|
16300
16306
|
}
|
|
16301
|
-
//
|
|
16302
|
-
// /api/auth/pair, JSON-only for the same reason, and counted against the
|
|
16303
|
-
// same per-source lockout so a code cannot be guessed.
|
|
16307
|
+
// Emailed sign-in code (server/account-signin.ts): public, JSON-only, same lockout as /pair.
|
|
16304
16308
|
if (method === "POST" && (path === "/api/auth/email/start" || path === "/api/auth/email/verify")) {
|
|
16305
16309
|
if (!/^application\/json\b/i.test(String(req.headers["content-type"] ?? ""))) {
|
|
16306
16310
|
return json(res, 415, { error: "send the sign-in request as JSON (content-type: application/json)" });
|
|
@@ -16339,9 +16343,7 @@ const handleRequest = async (req, res) => {
|
|
|
16339
16343
|
return json(res, 200, { session: issued.session, environment });
|
|
16340
16344
|
}
|
|
16341
16345
|
if (method === "POST" && path === "/api/auth/pair") {
|
|
16342
|
-
// JSON only
|
|
16343
|
-
// without a preflight, so a stray unused code cannot be planted as a
|
|
16344
|
-
// session in someone else's browser.
|
|
16346
|
+
// JSON only, so a cross-site form cannot plant a session without a preflight.
|
|
16345
16347
|
if (!/^application\/json\b/i.test(String(req.headers["content-type"] ?? ""))) {
|
|
16346
16348
|
return json(res, 415, { error: "send the pairing code as JSON (content-type: application/json)" });
|
|
16347
16349
|
}
|
|
@@ -16890,7 +16892,7 @@ const handleRequest = async (req, res) => {
|
|
|
16890
16892
|
return json(res, 403, { error: "Computer selection belongs to a direct bot conversation." });
|
|
16891
16893
|
const requested = method === "POST" ? (await readInternalBody()).surface : undefined;
|
|
16892
16894
|
if (method === "POST" && !canSelect)
|
|
16893
|
-
return json(res, 403, { error: "Computer selection
|
|
16895
|
+
return json(res, 403, { error: "Computer selection requires an active direct user request with computer access enabled." });
|
|
16894
16896
|
if (method === "POST" && requested !== "auto" && !parseSurface(requested)) {
|
|
16895
16897
|
return json(res, 400, { error: "surface must be auto, cloud, vm, local, or browser" });
|
|
16896
16898
|
}
|
|
@@ -16963,9 +16965,8 @@ const handleRequest = async (req, res) => {
|
|
|
16963
16965
|
// only work items), and only when the person on the thread is the one
|
|
16964
16966
|
// signed in to Nexus here.
|
|
16965
16967
|
if (method === "POST" && (path === "/api/internal/nexus/recall" || path === "/api/internal/nexus/file")) {
|
|
16966
|
-
|
|
16967
|
-
|
|
16968
|
-
return json(res, 403, { error: refusal });
|
|
16968
|
+
if (!nexusOwnerThread(internalCapability.threadId))
|
|
16969
|
+
return json(res, 403, { error: "This conversation is with someone other than the person signed in to Nexus here, so their Nexus is not shared into it." });
|
|
16969
16970
|
const body = await readInternalBody();
|
|
16970
16971
|
const bot = { id: internalSender.id, name: internalSender.name, ...(internalSender.personal ? { personal: true } : {}) };
|
|
16971
16972
|
try {
|
|
@@ -20578,7 +20579,7 @@ const handleRequest = async (req, res) => {
|
|
|
20578
20579
|
// computer, MCP servers, skills, routines): a plain bot, set up by the person.
|
|
20579
20580
|
if (auth.kind === "assistant")
|
|
20580
20581
|
body = { ...body, useDefaults: false };
|
|
20581
|
-
const template = resolveBotCreationDefaults(cfg.newBotDefaults, body);
|
|
20582
|
+
const template = resolveBotCreationDefaults(cfg.newBotDefaults, body, auth.kind !== "assistant");
|
|
20582
20583
|
const settings = template.profile;
|
|
20583
20584
|
if (auth.kind === "session" && !auth.scopes.includes("admin")) {
|
|
20584
20585
|
const field = clientBotPatchViolation(settings);
|
|
@@ -22624,8 +22625,6 @@ const handleRequest = async (req, res) => {
|
|
|
22624
22625
|
if (expectedThreadId !== undefined && (typeof expectedThreadId !== "string" || !/^[\w-]+$/.test(expectedThreadId))) {
|
|
22625
22626
|
return json(res, 400, { error: "threadId must be a task id" });
|
|
22626
22627
|
}
|
|
22627
|
-
// Explicit thread targets never fall through to another routine or
|
|
22628
|
-
// channel just because it belongs to the same bot.
|
|
22629
22628
|
if (typeof expectedThreadId === "string" && store.taskByThread(bot.id, expectedThreadId)) {
|
|
22630
22629
|
await stopBotThread(bot.id, expectedThreadId);
|
|
22631
22630
|
return json(res, 200, { ok: true });
|
|
@@ -22644,8 +22643,6 @@ const handleRequest = async (req, res) => {
|
|
|
22644
22643
|
return json(res, 200, { ok: true });
|
|
22645
22644
|
}
|
|
22646
22645
|
const instance = registry.get((botForThread(bot.id, expectedThreadId ?? bot.threadId) ?? bot).modelSelection.instanceId);
|
|
22647
|
-
// a bot busy in a ROOM is running on the room's thread — stopping it
|
|
22648
|
-
// from its own chat must reach that turn, not just the 1:1 thread
|
|
22649
22646
|
const busyGroup = activeGroupTurnForBot(bot.id);
|
|
22650
22647
|
if (busyGroup) {
|
|
22651
22648
|
if (expectedThreadId !== undefined && busyGroup.threadId !== expectedThreadId) {
|