@chibitek/chibi 0.1.210 → 0.1.211
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-Dro3aeVy.js} +1 -1
- package/dist/assets/{abnfDiagram-O67JEVCF-Ds2qYdjS.js → abnfDiagram-O67JEVCF-kzAr7vQ8.js} +1 -1
- package/dist/assets/{arc-1O9tchZk.js → arc-DKMhcYud.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-CWuQ1x2F.js → architectureDiagram-NJMV4G6O-_XDnZ7Jz.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-CNcEkXEx.js → blockDiagram-BEXU5L5S-D5MoWro9.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-BKI_wi9I.js → c4Diagram-YGBWAQC7-CGvTMpGE.js} +1 -1
- package/dist/assets/channel-YcZdlysP.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-gO88emfN.js → chunk-2Q5K7J3B-pjTwr5y0.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-DbKNT_-r.js → chunk-3FUC2YCW-BR6zkd-l.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-BbJCoZVg.js → chunk-5VM5RSS4-CfVFFBeH.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-DXurSCcp.js → chunk-GTNCS2PH-TIoAkccw.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-BWyt0I_m.js → chunk-GWA4HPMP-BNFBgzbt.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-6iWSsogl.js → chunk-JWPE2WC7-B_3QFchU.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-CFoqO9Hw.js → chunk-NETBCI7D-Cj9q80P-.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-BZEzAlNi.js → chunk-WEXAMYUT-DFZPGo9K.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-W4hfC50f.js → chunk-XXDRQBXY-CekDrT9T.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-BsGmL9e7.js → classDiagram-v2-NBCMYWYE-C3R6Z4Qe.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-CYtTgIzk.js → cose-bilkent-JH36ORCC-C1CKyj0L.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-DLOi2Q2V.js → cynefin-OW5HDTMX-Deh9QGb0.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-BXcXJ3hv.js → cynefinDiagram-VND7K2PF-BIlWyG_M.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-BdBOiuzt.js → dagre-6A5THRUB-Dx4bWOog.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-DCf3M4WE.js → diagram-22UHCM2B-DPxb-FUO.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-CzdF-UXi.js → diagram-3UASUU5V-BLPCNc4m.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-_UmmlMOD.js → diagram-ATOU4E4O-DOCbp2Dw.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-DrQODVuX.js → diagram-CDSNMT55-62uSG-tn.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-CE16iJlJ.js → diagram-MLGK6HIB-De1ZAWVZ.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-DJuTbhbP.js → diagram-MPIPVDR6-CIGX9tku.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-f1VEI2Po.js → ebnfDiagram-ZINNZB2B-CegjStdk.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-BRbs9WzY.js → elk-276RUBZZ-ClI52Pqm.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-DvMp_cQr.js → erDiagram-OPXOYQCR-BQuzjt2-.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-CYS1A0fu.js → flowDiagram-KWPJA3E3-D1xbKgbB.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-qya_JE9x.js → ganttDiagram-FUAMR5RP-CH1jGSZz.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-ChMUJ3hH.js → gitGraphDiagram-X574FWY7-BvAUPEmQ.js} +1 -1
- package/dist/assets/{index-COH7BlyH.js → index-BcXDfnlQ.js} +157 -157
- package/dist/assets/{index-xE4Li_H2.js → index-DbkR_erP.js} +1 -1
- package/dist/assets/{infoDiagram-VRGFBTTK-B2VudqsE.js → infoDiagram-VRGFBTTK-CyMmMbMv.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-Bdk47y0t.js → ishikawaDiagram-OU5B5YK6-Uw-hE1tO.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-A4StgNQ9.js → journeyDiagram-ZHPQQLJL-ClEDnNRB.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-DZo45dQw.js → kanban-definition-PNTS6WVX-erx0BEal.js} +1 -1
- package/dist/assets/{linear-D_rK-Ord.js → linear-CSSxpyL0.js} +1 -1
- package/dist/assets/{mermaid.core-C7CvDDvz.js → mermaid.core-n13K6vlC.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-6fmVPMyc.js → mindmap-definition-NLK3R4M7-BcTEIqpD.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-CD4Qg24h.js → pegDiagram-GJSIUBJH-CJdsm3en.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-DmzQ883B.js → pieDiagram-5QR66LMP-C7rk-ash.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-BW37utPZ.js → quadrantDiagram-O4NWA36T-BSXOYov0.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-CWXiMlAb.js → railroadDiagram-XR7U4H2S-Cmg_FtZY.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-DHSfr9U3.js → requirementDiagram-PLB6GJNP-B_9aE6Mg.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-PebTt4eq.js → sankeyDiagram-IPEJSGJF-DyxaQPy3.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-DPwp8fia.js → sequenceDiagram-PO4LG4MO-D5CJeESq.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-BX_46o3S.js → sizeCapture-INFHLROL-9-Q4eosQ.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-W2e0RRrZ.js → stateDiagram-v2-GCMORJYK-jgsHnEQl.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-CkyXpQX9.js → swimlanes-2SLR337P-MIVacUbv.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-Dekwo1KL.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-BS-sCjlN.js → timeline-definition-EJHVYXUP-Ch8ins-D.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-BQre-k6x.js → usecaseDiagram-POWQR4AR-BDwBIuhZ.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-CEWCsi_s.js → vennDiagram-UO4OBE2U-BiiDxcHO.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-CXUxqghG.js → wardleyDiagram-VNRHLVJA-D79CK2__.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-DBgVMpwp.js → xychartDiagram-PMCCYNJV-CI7S0o-6.js} +1 -1
- package/dist/index.html +1 -1
- package/dist-server/container-mcp.js +81 -81
- package/dist-server/drivers/agents-proxy.js +81 -81
- package/dist-server/index.js +2533 -2147
- package/dist-server/openmausbot.js +625 -568
- package/dist-server/pair-cli.js +625 -568
- package/dist-server/server/auto-approve.js +12 -0
- 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/hermes-context-floor.js +68 -0
- 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 +33 -33
- package/dist-server/server/model-fallback-repair.js +20 -0
- 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/shared/god-mode-run.js +173 -0
- package/dist-server/shared/personal-goal.js +42 -0
- package/dist-server/vps-container-mcp.js +81 -81
- package/package.json +1 -1
- package/dist/assets/channel-CT5xRPK0.js +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-BH9Yry0J.js +0 -8
- package/dist-server/server/agents-token-file.js +0 -26
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
// Questions never come through here: a bot's question always reaches a human.
|
|
14
14
|
import { supportsApprovalMode } from "../shared/approval-mode.js";
|
|
15
15
|
import { isElicitationTool } from "./mcp-elicitation.js";
|
|
16
|
+
import { godModeHardLimit } from "../shared/god-mode-run.js";
|
|
16
17
|
/** A failed delivery is a runtime error, not another permission decision.
|
|
17
18
|
* An expired ask must never become a fresh Allow/Deny card. */
|
|
18
19
|
export async function deliverFullAccessApproval(adapter, threadId, requestId, turnId, isCurrent = () => false) {
|
|
@@ -75,6 +76,14 @@ export function autoVerdict(mode, tool, context) {
|
|
|
75
76
|
// request.opened caller invokes this for permissions only, never questions.
|
|
76
77
|
// GOD MODE is the same promise as Full, made for the whole workspace, so
|
|
77
78
|
// it answers on every engine, whether or not the engine implements Full.
|
|
79
|
+
// Its hard limits are the exception: no money, no deleting data outside
|
|
80
|
+
// the task, no production deploys or force pushes, no local Postgres. The
|
|
81
|
+
// card stays for the person, with the reason.
|
|
82
|
+
if (context?.godModeLimits && (context.godMode || mode === "full")) {
|
|
83
|
+
const limit = godModeHardLimit(tool, context.godModeLimits.summary ?? "", context.godModeLimits.workspace);
|
|
84
|
+
if (limit)
|
|
85
|
+
return { approve: null, source: "god-mode-limit", limit };
|
|
86
|
+
}
|
|
78
87
|
if (context?.godMode)
|
|
79
88
|
return { approve: `approved ${tool} (GOD MODE)`, source: "god-mode" };
|
|
80
89
|
if (mode === "full")
|
|
@@ -101,6 +110,7 @@ export const HELD_NOTE = {
|
|
|
101
110
|
"approval.held.sandbox": "This changes the provider sandbox, so only GOD MODE can approve it automatically.",
|
|
102
111
|
"approval.held.undeliveredFull": "GOD MODE couldn't deliver this approval.",
|
|
103
112
|
"approval.held.undelivered": "Approve for me couldn't answer this one.",
|
|
113
|
+
"approval.held.godModeLimit": "GOD MODE never does this on its own: it is one of its hard limits.",
|
|
104
114
|
};
|
|
105
115
|
/** Which note, as a key. approvalHeldReason is this plus the English text, so
|
|
106
116
|
* the branching that decides the note lives in exactly one place. */
|
|
@@ -109,6 +119,8 @@ export function approvalHeldNote(context) {
|
|
|
109
119
|
return undefined;
|
|
110
120
|
if (context.source === "explicit-approval-block")
|
|
111
121
|
return "approval.held.sandbox";
|
|
122
|
+
if (context.source === "god-mode-limit")
|
|
123
|
+
return "approval.held.godModeLimit";
|
|
112
124
|
if (context.source === "native-approval")
|
|
113
125
|
return "approval.held.native";
|
|
114
126
|
return undefined;
|
|
@@ -23,6 +23,7 @@ import { atomicEngineAsset } from "../../atomic-engine-release.js";
|
|
|
23
23
|
import { ATOMIC_ENGINE_MODULE_ARGS, installAtomicEngine, managedAtomicEngine } from "../../atomic-engine-runtime.js";
|
|
24
24
|
import { findCliCandidates } from "../../env-path.js";
|
|
25
25
|
import { execCli } from "../../procs.js";
|
|
26
|
+
import { withoutUnderSizedLocalModels } from "../hermes-context-floor.js";
|
|
26
27
|
import { decodeInjectId, mergeLocalInject } from "../local-inject.js";
|
|
27
28
|
import { createAcpDriver, versionFromProbe } from "./core.js";
|
|
28
29
|
import { lockHermesMemory } from "./hermes-memory-lock.js";
|
|
@@ -102,7 +103,8 @@ export async function customAcpModels(env, config, instanceId, fetchImpl = fetch
|
|
|
102
103
|
return PASSTHROUGH;
|
|
103
104
|
// One choice with Automatic (shared/atomic-auto.ts): picking it puts the bot on its tier's ladder.
|
|
104
105
|
const own = { default: ATOMIC_AUTO_MODEL, options: [{ id: ATOMIC_AUTO_MODEL, label: "Atomic Engine (Auto)", custom: true }] };
|
|
105
|
-
|
|
106
|
+
// Hermes underneath refuses a model under 64k context (drivers/hermes-context-floor.ts).
|
|
107
|
+
const catalog = await withoutUnderSizedLocalModels(await mergeLocalInject(own, env, fetchImpl), env, fetchImpl);
|
|
106
108
|
rememberLocalModels(catalog.options); // the engine's local fallbacks (server/atomic-engine-local.ts)
|
|
107
109
|
return catalog;
|
|
108
110
|
}
|
|
@@ -12,6 +12,7 @@ import { parse as parseYaml } from "yaml";
|
|
|
12
12
|
import { resolveCli } from "../../procs.js";
|
|
13
13
|
import { planOptions } from "../../spawn-command.js";
|
|
14
14
|
import { decodeInjectId, hostApiKey, INJECT_SEP, localHost, mergeLocalInject } from "../local-inject.js";
|
|
15
|
+
import { withoutUnderSizedLocalModels } from "../hermes-context-floor.js";
|
|
15
16
|
import { createAcpDriver } from "./core.js";
|
|
16
17
|
import { hermesOnlyHosts } from "./hermes-hosts.js";
|
|
17
18
|
import { lockHermesMemory } from "./hermes-memory-lock.js";
|
|
@@ -542,7 +543,7 @@ export async function fetchHermesAcpModels(cli, env) {
|
|
|
542
543
|
});
|
|
543
544
|
}
|
|
544
545
|
export async function resolveHermesModels(env, config) {
|
|
545
|
-
const catalog = await mergeLocalInject(EMPTY, env);
|
|
546
|
+
const catalog = await withoutUnderSizedLocalModels(await mergeLocalInject(EMPTY, env), env); // the engine refuses <64k
|
|
546
547
|
const configured = hermesConfiguredModel(env);
|
|
547
548
|
const hostDefault = hermesConfiguredHostModel(env);
|
|
548
549
|
const signedIn = hermesAuthStoreModels(env);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Hermes, and Atomic Engine built on it, refuses a model whose context
|
|
2
|
+
// window is under 64,000 tokens (agent/agent_init.py _enforce_minimum_context
|
|
3
|
+
// in the engine). A local Ollama model such as qwen3:8b (40,960) was still
|
|
4
|
+
// listed in their pickers, so a bot pinned to it hit the refusal on every
|
|
5
|
+
// turn and ran on the engine's default instead (Erick, 2026-11-22). Their
|
|
6
|
+
// catalogs leave such a model out, measured the way the engine measures it.
|
|
7
|
+
import { isOllamaCloudModel } from "../../shared/local-models.js";
|
|
8
|
+
import { anthropicBaseUrl, decodeInjectId, hostApiKey, localHost } from "./local-inject.js";
|
|
9
|
+
/** The engine's MINIMUM_CONTEXT_LENGTH (agent/model_metadata.py). */
|
|
10
|
+
export const HERMES_MIN_CONTEXT = 64_000;
|
|
11
|
+
const OLLAMA_HOSTS = new Set(["ollama", "local_ollama"]);
|
|
12
|
+
/** The window Ollama serves a model at, from its /api/show payload, read as
|
|
13
|
+
* the engine reads it for a local server: the Modelfile's num_ctx, else the
|
|
14
|
+
* model's own context_length. */
|
|
15
|
+
export function ollamaServedWindow(show) {
|
|
16
|
+
if (!show || typeof show !== "object")
|
|
17
|
+
return undefined;
|
|
18
|
+
const { parameters, model_info: info } = show;
|
|
19
|
+
if (typeof parameters === "string") {
|
|
20
|
+
for (const line of parameters.split("\n")) {
|
|
21
|
+
const parts = line.trim().split(/\s+/);
|
|
22
|
+
const value = Number(parts.at(-1));
|
|
23
|
+
if (parts[0] === "num_ctx" && Number.isInteger(value) && value > 0)
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (info && typeof info === "object") {
|
|
28
|
+
for (const [key, value] of Object.entries(info)) {
|
|
29
|
+
if (key.endsWith("context_length") && typeof value === "number" && value > 0)
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
async function ollamaShow(host, model, env, fetchImpl) {
|
|
36
|
+
try {
|
|
37
|
+
const response = await fetchImpl(`${anthropicBaseUrl(host)}/api/show`, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${hostApiKey(host, env)}` },
|
|
40
|
+
body: JSON.stringify({ model }),
|
|
41
|
+
signal: AbortSignal.timeout(1500),
|
|
42
|
+
});
|
|
43
|
+
return response.ok ? await response.json() : null;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** The window Hermes would see for a catalog row, when Atomic can tell: an
|
|
50
|
+
* Ollama model's /api/show (/api/ps's figure is only what is loaded now, and
|
|
51
|
+
* the engine asks Ollama for the larger window itself). */
|
|
52
|
+
async function hermesWindow(id, env, fetchImpl) {
|
|
53
|
+
const inject = decodeInjectId(id);
|
|
54
|
+
const host = inject ? localHost(inject.host) : undefined;
|
|
55
|
+
if (!inject || !host || !OLLAMA_HOSTS.has(host.id) || isOllamaCloudModel(inject.model))
|
|
56
|
+
return undefined;
|
|
57
|
+
return ollamaServedWindow(await ollamaShow(host, inject.model, env, fetchImpl));
|
|
58
|
+
}
|
|
59
|
+
/** A Hermes-family catalog without the local models the engine would refuse.
|
|
60
|
+
* A window Atomic cannot read keeps the row: the engine is the judge then. */
|
|
61
|
+
export async function withoutUnderSizedLocalModels(catalog, env = process.env, fetchImpl = fetch) {
|
|
62
|
+
const windows = await Promise.all(catalog.options.map((option) => hermesWindow(option.id, env, fetchImpl)));
|
|
63
|
+
const options = catalog.options.filter((_, index) => (windows[index] ?? HERMES_MIN_CONTEXT) >= HERMES_MIN_CONTEXT);
|
|
64
|
+
if (options.length === catalog.options.length)
|
|
65
|
+
return catalog;
|
|
66
|
+
const kept = new Set(options.map((option) => option.id));
|
|
67
|
+
return { default: kept.has(catalog.default) ? catalog.default : (options[0]?.id ?? ""), options };
|
|
68
|
+
}
|
|
@@ -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. */
|
|
@@ -330,7 +332,7 @@ import { createBoardRoutes } from "./routes/board.js";
|
|
|
330
332
|
import { readBoardFromNexus } from "./board/nexus-board.js";
|
|
331
333
|
import { LocalModelInventory, localModePlacement, machineMemory } from "./local-models-mode.js";
|
|
332
334
|
import { eventBase, restTime, FailoverGate, triesSpent, continuationNote, restingLine, restingOnRoute, sameRoute } from "./engine-failover.js";
|
|
333
|
-
import {
|
|
335
|
+
import { finalizeConnectionCapPick, finalizeNewTurnPlacement, pauseKeyBandForRunOut } from "./connection-cap-failover.js";
|
|
334
336
|
import { TURN_ERROR_CATEGORIES } from "../shared/runtime-events.js";
|
|
335
337
|
import { EngineProbes, PROBE_PROMPT, isProbeThread, probeThreadId } from "./engine-probe.js";
|
|
336
338
|
// [jev-verifier] opt-in Jev answer checks after a model switch (server/jev).
|
|
@@ -3081,9 +3083,8 @@ function turnEngineChoice(botId, threadId, needs, runOn) {
|
|
|
3081
3083
|
const task = store.taskByThread(botId, threadId);
|
|
3082
3084
|
if (hostedModels || !profile || !task)
|
|
3083
3085
|
return undefined;
|
|
3084
|
-
// A subscription bot runs only on its own provider
|
|
3085
|
-
|
|
3086
|
-
if (isSubscriptionBot(profile))
|
|
3086
|
+
// A subscription bot runs only on its own provider (Erick, 2026-11-13); a GOD MODE run may leave it when it is blocked.
|
|
3087
|
+
if (isSubscriptionBot(profile) && !godModeRunOverrides(personalGoals.goals, threadId, "provider-restriction", "left the bot's own provider for another engine."))
|
|
3087
3088
|
return subscriptionTurnEngineChoice(profile, threadId);
|
|
3088
3089
|
if (isPersonalBot(profile))
|
|
3089
3090
|
return personalTurnEngineChoice(profile, threadId, needs, runOn);
|
|
@@ -3137,7 +3138,7 @@ function ladderTurnEngineChoice(profile, projected, threadId, needs, runOn, subs
|
|
|
3137
3138
|
if (!resolution.choice && own && ownOut && !resolution.skipped.some((skip) => skip.reason === "paused")) {
|
|
3138
3139
|
throw restingStop(candidates, resolution.skipped, own.instanceId, computer);
|
|
3139
3140
|
}
|
|
3140
|
-
return placedTurn(local(resolution), true);
|
|
3141
|
+
return placedTurn(local(resolution), true, threadId);
|
|
3141
3142
|
}
|
|
3142
3143
|
// A pinned engine the last registry refresh reports signed out is treated
|
|
3143
3144
|
// as a failed sign-in up front, rather than spawned only to fail.
|
|
@@ -3167,7 +3168,7 @@ function ladderTurnEngineChoice(profile, projected, threadId, needs, runOn, subs
|
|
|
3167
3168
|
if (!resolution.choice && engineResting(own, projected.modelSelection.model) && !resolution.skipped.some((skip) => skip.reason === "paused")) {
|
|
3168
3169
|
throw restingStop(candidates, resolution.skipped, own.instanceId, computer);
|
|
3169
3170
|
}
|
|
3170
|
-
return placedTurn(local(resolution), false);
|
|
3171
|
+
return placedTurn(local(resolution), false, threadId);
|
|
3171
3172
|
}
|
|
3172
3173
|
/** An engine that is unavailable because its command-line program is not on
|
|
3173
3174
|
* this computer: Atomic Engine on a PC that never had `atomic`, a CLI since
|
|
@@ -3270,7 +3271,7 @@ function dictationSubscription() {
|
|
|
3270
3271
|
/** The key band is closed to a sweep unless the person chose "Keep going"
|
|
3271
3272
|
* (or local mode, which turns a key choice into a local model). */
|
|
3272
3273
|
function keyBandPausedFor(threadId) {
|
|
3273
|
-
return pauseKeyBandForRunOut({ policy:
|
|
3274
|
+
return pauseKeyBandForRunOut({ policy: runOutPolicy(threadId), paidApproved: Boolean(payPerUse.current()?.keptGoingAt),
|
|
3274
3275
|
pausedUntil: payPerUse.pausedUntil(), localUntil: payPerUse.localUntil(), sweep: isSweepTurn(threadId) });
|
|
3275
3276
|
}
|
|
3276
3277
|
/** The sweep turn's engine, or null when nothing it may use is free. `note`
|
|
@@ -3304,7 +3305,7 @@ function sweepEngineChoice(botId, threadId, note, runOn) {
|
|
|
3304
3305
|
return { selection: projected.modelSelection, persist: false };
|
|
3305
3306
|
}
|
|
3306
3307
|
// 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;
|
|
3308
|
+
const keysAllowed = (payPerUse.current()?.keptGoingAt !== undefined || godModeRunOn(personalGoals.goals, threadId)) && payPerUse.pausedUntil() === undefined;
|
|
3308
3309
|
if (payPerUse.localUntil() === undefined && !keysAllowed)
|
|
3309
3310
|
return null;
|
|
3310
3311
|
const context = { ...base, keyBandPaused: payPerUse.pausedUntil() !== undefined };
|
|
@@ -3317,16 +3318,17 @@ function sweepEngineChoice(botId, threadId, note, runOn) {
|
|
|
3317
3318
|
}
|
|
3318
3319
|
/** A turn start's ladder walk, as startTurn uses it: noted for pay-per-use,
|
|
3319
3320
|
* refused before an unapproved paid key, or when pay-per-use is paused. */
|
|
3320
|
-
function placedTurn(resolution, persist) {
|
|
3321
|
+
function placedTurn(resolution, persist, threadId) {
|
|
3321
3322
|
return finalizeNewTurnPlacement({
|
|
3322
|
-
policy:
|
|
3323
|
+
policy: runOutPolicy(threadId), paidApproved: Boolean(payPerUse.current()?.keptGoingAt),
|
|
3323
3324
|
local: resolution.local, choice: resolution.choice, skipped: resolution.skipped, pausedUntil: payPerUse.pausedUntil(),
|
|
3324
3325
|
currentLabel: "A subscription", formatTime: restTime, persist, pausedLine: payPerUsePausedLine,
|
|
3325
3326
|
announceWaiting: () => notePayPerUse({ skipped: resolution.skipped, local: true, choice: { band: "key", selection: { instanceId: "", model: "" }, candidate: { instanceId: "" }, step: 0 } }),
|
|
3326
3327
|
book: () => notePayPerUse(resolution),
|
|
3327
3328
|
});
|
|
3328
3329
|
}
|
|
3329
|
-
// ── pay-per-use (docs/chibitek/engine-tiers.md, "Pay-per-use notice")
|
|
3330
|
+
// ── pay-per-use (docs/chibitek/engine-tiers.md, "Pay-per-use notice"); a GOD MODE run is Keep going for its conversation ──
|
|
3331
|
+
const runOutPolicy = (threadId) => godModeRunOutPolicy(personalGoals.goals, threadId, cfg.engineTiers);
|
|
3330
3332
|
// The one thing about engines and billing the person hears of: a paid key is used only after stored approval
|
|
3331
3333
|
// when every subscription is resting, signed out or unavailable. That opens an episode, announced once;
|
|
3332
3334
|
// a turn a subscription answers ends it (noteEngineBack). Ollama Cloud is a subscription.
|
|
@@ -3619,8 +3621,8 @@ bus.setGate((published) => {
|
|
|
3619
3621
|
noteEngineBack(out);
|
|
3620
3622
|
return delivered;
|
|
3621
3623
|
});
|
|
3622
|
-
/** An engine finished a turn: a rest of it that has ended is marked back
|
|
3623
|
-
*
|
|
3624
|
+
/** An engine finished a turn: a rest of it that has ended is marked back (the rest history's `backAt`,
|
|
3625
|
+
* docs/chibitek/engine-tiers.md). A local-mode turn on a subscription engine is not that subscription back. */
|
|
3624
3626
|
function noteEngineBack(event) {
|
|
3625
3627
|
const instanceId = event.providerInstanceId;
|
|
3626
3628
|
if (!instanceId)
|
|
@@ -3630,7 +3632,7 @@ function noteEngineBack(event) {
|
|
|
3630
3632
|
const model = selection?.instanceId === instanceId ? selection.model : undefined;
|
|
3631
3633
|
for (const scope of new Set([candidate ? restScope(candidate, model) : undefined, modelScope(model)]))
|
|
3632
3634
|
engineRests.noteBack(instanceId, candidate ? engineAccount(candidate) : undefined, scope);
|
|
3633
|
-
if (candidate && !keyBased(candidate) && !freeCandidate(candidate) && !(model && (perTokenModel(candidate, model) || injectedModel(model))))
|
|
3635
|
+
if (candidate && !keyBased(candidate) && !freeCandidate(candidate) && !(model && (perTokenModel(candidate, model) || injectedModel(model) || isLocalModel(candidate, model))))
|
|
3634
3636
|
(instanceOwner(instanceId) === "personal" ? personalPayPerUse : payPerUse).subscriptionAnswered();
|
|
3635
3637
|
}
|
|
3636
3638
|
/** Rest a refused engine and continue on an eligible engine, or show an actionable line. */
|
|
@@ -3852,7 +3854,7 @@ function failoverPick(turn, profile, projected, candidates, failedCandidate, res
|
|
|
3852
3854
|
// A subscription bot fails over only to another account of its own
|
|
3853
3855
|
// provider on its side of the personal line; with none left it stops with
|
|
3854
3856
|
// its one line.
|
|
3855
|
-
const subscriptionMove = isSubscriptionBot(profile)
|
|
3857
|
+
const subscriptionMove = isSubscriptionBot(profile) && !godModeRunOverrides(personalGoals.goals, turn.threadId, "provider-restriction", "left the bot's own provider for another engine.")
|
|
3856
3858
|
? triesSpent(tried) || !projected
|
|
3857
3859
|
? { line: subscriptionLine(profile, candidates) }
|
|
3858
3860
|
: subscriptionPlacement({ profile, projected, candidates, tried: new Set([...tried, turn.instanceId]), auto: attempt.persist, modelClass: neededClass })
|
|
@@ -3900,7 +3902,7 @@ function failoverPick(turn, profile, projected, candidates, failedCandidate, res
|
|
|
3900
3902
|
pausedUntil: payPerUse.pausedUntil(), skipped: resolution.skipped, payPerUsePausedLine, restingNamed,
|
|
3901
3903
|
failedInstanceId: turn.instanceId, alreadyTried: attempt.tried, triedCount: tried.size,
|
|
3902
3904
|
cannotDrive: cannotDriveNamed(candidates, resolution.skipped, computer),
|
|
3903
|
-
policy:
|
|
3905
|
+
policy: runOutPolicy(turn.threadId), paidApproved: Boolean(payPerUse.current()?.keptGoingAt),
|
|
3904
3906
|
local: Boolean(placed.local), currentLabel: engineLabel(candidates, attempt.selection),
|
|
3905
3907
|
nextLabel: choice ? engineLabel(candidates, choice.selection) : undefined,
|
|
3906
3908
|
nextBand: choice && "band" in choice ? choice.band : undefined, resetAt: turn.failure?.resetAt, formatTime: restTime,
|
|
@@ -4076,7 +4078,7 @@ function engineTierRefusal(bot, options = {}) {
|
|
|
4076
4078
|
if (!options.ignoreOwner && !ownerAllows(bot, ownerCheck(candidate), false))
|
|
4077
4079
|
return "owner";
|
|
4078
4080
|
// A subscription bot never leaves its provider (server/subscription-bots.ts).
|
|
4079
|
-
if (!providerAllows(bot, candidate, subscriptionFacts))
|
|
4081
|
+
if (!providerAllows(bot, candidate, subscriptionFacts) && !godModeRunOn(personalGoals.goals, bot.threadId))
|
|
4080
4082
|
return "provider";
|
|
4081
4083
|
if (candidate.instanceId !== bot.modelSelection.instanceId && modelSwitchNeedsAsk(mode, from, candidate.driverKind, godModeCovers(bot)))
|
|
4082
4084
|
return "approval";
|
|
@@ -4500,13 +4502,13 @@ for (const id of botWorkModes.expired(id => sessions.isLive(id)))
|
|
|
4500
4502
|
const delegatedFull = new DelegatedFullAccess(join(DATA_DIR, "delegated-full-access.json"));
|
|
4501
4503
|
for (const stale of delegatedFull.reconcile(store.bots, id => store.messagesFor(id)))
|
|
4502
4504
|
store.patchTask(stale.botId, stale.threadId, { approvalMode: "ask", autoApprove: false, alwaysAllow: [] });
|
|
4503
|
-
const approvalModeForTurn = (bot, peerInitiated = false) => godModeElevates(bot) ? "full" : ownApprovalModeForTurn(bot, peerInitiated);
|
|
4505
|
+
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
4506
|
/** The bot's (or thread's) own level for a turn, GOD MODE aside. A thread a
|
|
4505
4507
|
* Chief delegated into is Full only while that Chief's conversation still is
|
|
4506
4508
|
* (`derived`); nothing is saved on the thread, so it ends when the source does. */
|
|
4507
4509
|
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
4510
|
function godModeCovers(bot) {
|
|
4509
|
-
return legacyGodModeCovers(bot, godModeActive() && botWorkModes.permits("full"), botWorkModes.selected(bot.id) !== undefined);
|
|
4511
|
+
return legacyGodModeCovers(bot, godModeActive() && botWorkModes.permits("full"), botWorkModes.selected(bot.id) !== undefined && !godModeRunOn(personalGoals.goals, bot.threadId));
|
|
4510
4512
|
}
|
|
4511
4513
|
/** GOD MODE runs this bot or thread at Full, whatever its own level says:
|
|
4512
4514
|
* it is covered (godModeCovers) and its engine implements Full. */
|
|
@@ -5052,7 +5054,7 @@ const personalGoals = new PersonalGoalRuntime(join(DATA_DIR, "personal-goals.jso
|
|
|
5052
5054
|
if (owns)
|
|
5053
5055
|
await interruptDirectThread(botId, threadId);
|
|
5054
5056
|
},
|
|
5055
|
-
changed: (goal) => updatePersonalGoalReceipt(goal, store),
|
|
5057
|
+
changed: (goal) => updatePersonalGoalReceipt(goal, store), godMode: (botId) => Boolean(store.bot(botId) && godModeActive() && botWorkModes.permits("full")),
|
|
5056
5058
|
run: (goal) => runPersonalGoalTurn(goal, { store, addGuard: addGroupGoalCoordinatorTurn, removeGuard: removeGroupGoalCoordinatorTurn,
|
|
5057
5059
|
subscribe: (listener) => bus.subscribe(listener), ignore: shouldIgnoreProviderEvent, busy: threadBusy, start: startTurn }),
|
|
5058
5060
|
});
|
|
@@ -7822,15 +7824,12 @@ bus.subscribe((event) => {
|
|
|
7822
7824
|
sessionModelByThread.set(event.threadId, event.model);
|
|
7823
7825
|
break;
|
|
7824
7826
|
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
|
-
});
|
|
7827
|
+
// The engine refused the thread's model and the turn went on with another (drivers/acp/core.ts); the
|
|
7828
|
+
// thread keeps the one that ran, so it is not refused every turn. One quiet line; the Chief hears of it.
|
|
7829
|
+
pushMessage({ role: "bot", kind: "activity", tool: { name: refusedModelLine(event), ok: true } });
|
|
7833
7830
|
if (bot) {
|
|
7831
|
+
if (event.providerInstanceId)
|
|
7832
|
+
repairRefusedModel(store, bot.id, event.threadId, { ...event, instanceId: event.providerInstanceId });
|
|
7834
7833
|
reportIncident({
|
|
7835
7834
|
kind: "model-fallback", bot, threadId: event.threadId,
|
|
7836
7835
|
detail: `asked for ${event.requested}, the engine answered "${event.reason.slice(0, 160)}"; the turn ran on ${event.model}`,
|
|
@@ -7939,7 +7938,7 @@ bus.subscribe((event) => {
|
|
|
7939
7938
|
// engine) whose turn therefore still runs at the bot's own level. It
|
|
7940
7939
|
// is logged as `god-mode` unless the bot's own level is Full anyway.
|
|
7941
7940
|
const godModeAnswers = !othersAsked && Boolean(permission && asker && godModeCovers(asker)) &&
|
|
7942
|
-
ownApprovalModeForTurn(asker, isInternalTurn(event.threadId)) !== "full";
|
|
7941
|
+
(ownApprovalModeForTurn(asker, isInternalTurn(event.threadId)) !== "full" || godModeRunOn(personalGoals.goals, event.threadId));
|
|
7943
7942
|
// A read-only tool of one of the person's own MCP servers, by that
|
|
7944
7943
|
// server's own annotation, on a server whose switch is on. Never for
|
|
7945
7944
|
// host-computer control, which stays one approval at a time.
|
|
@@ -7959,7 +7958,7 @@ bus.subscribe((event) => {
|
|
|
7959
7958
|
destructive: event.mcpTool?.annotations?.destructiveHint === true,
|
|
7960
7959
|
};
|
|
7961
7960
|
const ownVerdict = permission && asker && event.requestId
|
|
7962
|
-
? autoVerdict(effectiveApprovalMode, event.tool, { requiresExplicitApproval: event.requiresExplicitApproval, readOnlyMcpTool, godMode: godModeAnswers })
|
|
7961
|
+
? autoVerdict(effectiveApprovalMode, event.tool, { requiresExplicitApproval: event.requiresExplicitApproval, readOnlyMcpTool, godMode: godModeAnswers, godModeLimits: !othersAsked && godModeCovers(asker) ? { summary: event.summary } : undefined })
|
|
7963
7962
|
: null;
|
|
7964
7963
|
// An approval the person gave in the Chief of Staff's conversation,
|
|
7965
7964
|
// carried into this delegated turn. Only what the turn's own level
|
|
@@ -7976,8 +7975,7 @@ bus.subscribe((event) => {
|
|
|
7976
7975
|
source: "delegated-grant",
|
|
7977
7976
|
}
|
|
7978
7977
|
: 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).
|
|
7978
|
+
// The room shows "Waiting for <owner> to approve" while the owner's card is open (desktop or paired iPhone).
|
|
7981
7979
|
if (roomAsk && permission && event.requestId && !verdict?.approve) {
|
|
7982
7980
|
const actionHash = createHash("sha256").update(JSON.stringify([event.threadId, event.requestId, event.tool, event.summary])).digest("hex");
|
|
7983
7981
|
teamRoomsHost?.approvalOpened(event.threadId, event.requestId, event.summary || event.tool, actionHash);
|
|
@@ -8002,6 +8000,8 @@ bus.subscribe((event) => {
|
|
|
8002
8000
|
},
|
|
8003
8001
|
});
|
|
8004
8002
|
}
|
|
8003
|
+
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 } }) }))
|
|
8004
|
+
break;
|
|
8005
8005
|
if (verdict?.approve && asker && event.requestId) {
|
|
8006
8006
|
const settled = verdict.approve;
|
|
8007
8007
|
const instance = event.providerInstanceId
|
|
@@ -8244,7 +8244,7 @@ bus.subscribe((event) => {
|
|
|
8244
8244
|
// keeps the same failure from reporting a second incident.
|
|
8245
8245
|
const lazyClaimAlreadyReported = event.stopReason === "exit_before_result" &&
|
|
8246
8246
|
turnResourceOwners.get(event.threadId)?.lazyClaimFailureReported === true;
|
|
8247
|
-
if (!event.ok && event.stopReason !== "interrupted" && !lazyClaimAlreadyReported && !routines?.runForThread(event.threadId)) {
|
|
8247
|
+
if (!event.ok && event.stopReason !== "interrupted" && !lazyClaimAlreadyReported && !routines?.runForThread(event.threadId) && !godModeRunOn(personalGoals.goals, event.threadId)) {
|
|
8248
8248
|
const broken = bot ?? (speaker ? store.bot(speaker.botId) : undefined);
|
|
8249
8249
|
if (broken)
|
|
8250
8250
|
reportIncident({ kind: "failed", bot: broken, threadId: event.threadId, detail: failedRunDetail(event.stopReason, turnError), notifyChief: event.stopReason === "auth_required" });
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const names = (selection, refused) => selection?.instanceId === refused.instanceId && selection.model === refused.requested;
|
|
2
|
+
const replaced = (selection, model) => {
|
|
3
|
+
// A variant or effort belonged to the refused model.
|
|
4
|
+
const { variant: _variant, effort: _effort, ...rest } = selection;
|
|
5
|
+
return { ...rest, model };
|
|
6
|
+
};
|
|
7
|
+
/** Saves the model that ran over the refused one. Returns what changed. */
|
|
8
|
+
export function repairRefusedModel(store, botId, threadId, refused) {
|
|
9
|
+
const task = store.taskByThread(botId, threadId);
|
|
10
|
+
const thread = Boolean(task?.modelSelection && names(task.modelSelection, refused) &&
|
|
11
|
+
store.patchTask(botId, threadId, { modelSelection: replaced(task.modelSelection, refused.model) }));
|
|
12
|
+
const current = store.bot(botId);
|
|
13
|
+
const bot = Boolean(current && names(current.modelSelection, refused) &&
|
|
14
|
+
store.patchBot(botId, { modelSelection: replaced(current.modelSelection, refused.model) }));
|
|
15
|
+
return { thread, bot };
|
|
16
|
+
}
|
|
17
|
+
/** The thread's one line about it. */
|
|
18
|
+
export function refusedModelLine(refused) {
|
|
19
|
+
return `this engine cannot run ${refused.requested}: this thread now uses ${refused.model}`;
|
|
20
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { GOAL_HELP } from "../shared/personal-goal.js";
|
|
2
2
|
import { PersonalGoals } from "./personal-goals.js";
|
|
3
|
+
import { godModeNextAttemptDelay } from "./god-mode-goal.js";
|
|
4
|
+
import { formatGodModeCountdown } from "../shared/god-mode-run.js";
|
|
5
|
+
/** A restarted app gives its providers this long before a run's next attempt. */
|
|
6
|
+
const GOD_MODE_RESUME_DELAY_MS = 5_000;
|
|
3
7
|
/** Serial continuation per goal; every provider turn still passes normal admission. */
|
|
4
8
|
export class PersonalGoalRuntime {
|
|
5
9
|
goals;
|
|
@@ -9,6 +13,12 @@ export class PersonalGoalRuntime {
|
|
|
9
13
|
constructor(path, host) {
|
|
10
14
|
this.host = host;
|
|
11
15
|
this.goals = new PersonalGoals(path, (goal) => host.changed(goal));
|
|
16
|
+
// A GOD MODE run is non stop: one that was working when Atomic stopped
|
|
17
|
+
// carries on with its remaining time.
|
|
18
|
+
for (const goal of this.goals.liveGodModeRuns()) {
|
|
19
|
+
this.running.add(goal.id);
|
|
20
|
+
setTimeout(() => void this.run(goal), GOD_MODE_RESUME_DELAY_MS).unref?.();
|
|
21
|
+
}
|
|
12
22
|
}
|
|
13
23
|
async command(botId, threadId, command, trigger) {
|
|
14
24
|
if (command.action === "help")
|
|
@@ -21,6 +31,9 @@ export class PersonalGoalRuntime {
|
|
|
21
31
|
if (command.action === "start" || command.action === "resume") {
|
|
22
32
|
if (this.host.busy(botId, threadId) || (goal && this.running.has(goal.id)))
|
|
23
33
|
throw new Error("This conversation is still working. Wait for its turn to settle.");
|
|
34
|
+
if (command.action === "start" && command.godModeMs && !this.host.godMode?.(botId)) {
|
|
35
|
+
throw new Error("A GOD MODE run needs GOD MODE on for this bot. Turn it on in Settings, then start the run again.");
|
|
36
|
+
}
|
|
24
37
|
goal = command.action === "start" ? this.goals.start(botId, threadId, { ...command, ...(trigger?.kind === "user" || trigger?.kind === "owner" ? { trigger } : {}) }) : this.goals.resume(threadId, command);
|
|
25
38
|
// Persist the human command before provider setup reads the conversation.
|
|
26
39
|
this.running.add(goal.id);
|
|
@@ -40,6 +53,8 @@ export class PersonalGoalRuntime {
|
|
|
40
53
|
return this.describe(goal);
|
|
41
54
|
}
|
|
42
55
|
describe(goal) {
|
|
56
|
+
if (goal.godMode)
|
|
57
|
+
return `GOD MODE run ${goal.status}: ${goal.objective}\n${goal.detail}\nTime left: ${formatGodModeCountdown(goal.godMode.endsAt - Date.now())}. Attempts: ${goal.godMode.attempts + 1}.`;
|
|
43
58
|
return `${goal.status}: ${goal.objective}\n${goal.detail}\nTurns: ${goal.turnCount}/${goal.maxTurns}. Tokens: ${goal.tokensUsed}${goal.tokenBudget === undefined ? "" : `/${goal.tokenBudget}`}.`;
|
|
44
59
|
}
|
|
45
60
|
steer(threadId) {
|
|
@@ -54,10 +69,21 @@ export class PersonalGoalRuntime {
|
|
|
54
69
|
this.running.add(goal.id);
|
|
55
70
|
try {
|
|
56
71
|
while (this.goals.begin(goal.id)) {
|
|
57
|
-
|
|
72
|
+
if (goal.godMode && this.host.godMode && !this.host.godMode(goal.botId)) {
|
|
73
|
+
goal.status = "stopped";
|
|
74
|
+
goal.detail = "GOD MODE was turned off, so the run stopped.";
|
|
75
|
+
this.goals.touch(goal);
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
// A GOD MODE run treats a turn that could not start as a failed
|
|
79
|
+
// attempt (settle keeps it working); an ordinary goal pauses below.
|
|
80
|
+
const result = goal.godMode
|
|
81
|
+
? await this.host.run(goal).catch((error) => ({ ok: false, text: error instanceof Error ? error.message : String(error), tools: 0 }))
|
|
82
|
+
: await this.host.run(goal);
|
|
58
83
|
this.goals.settle(goal.id, result);
|
|
59
|
-
// Give queued human input priority before reserving another turn
|
|
60
|
-
|
|
84
|
+
// Give queued human input priority before reserving another turn; a
|
|
85
|
+
// GOD MODE run also pauses briefly after failed attempts.
|
|
86
|
+
await new Promise((resolve) => setTimeout(resolve, godModeNextAttemptDelay(goal)));
|
|
61
87
|
}
|
|
62
88
|
}
|
|
63
89
|
catch {
|
|
@@ -3,7 +3,8 @@ export function updatePersonalGoalReceipt(goal, store) {
|
|
|
3
3
|
return;
|
|
4
4
|
const goalRun = { runId: goal.id, goal: goal.objective, status: goal.status,
|
|
5
5
|
coordinatorBotId: goal.botId, coordinatorName: store.bot(goal.botId)?.name ?? "Bot",
|
|
6
|
-
turnCount: goal.turnCount, maxTurns: goal.maxTurns, detail: `${goal.detail} Tokens: ${goal.tokensUsed}${goal.tokenBudget === undefined ? "" : `/${goal.tokenBudget}`}.`, startedAt: goal.createdAt
|
|
6
|
+
turnCount: goal.turnCount, maxTurns: goal.maxTurns, detail: `${goal.detail} Tokens: ${goal.tokensUsed}${goal.tokenBudget === undefined ? "" : `/${goal.tokenBudget}`}.`, startedAt: goal.createdAt,
|
|
7
|
+
...(goal.godMode ? { godMode: { endsAt: goal.godMode.endsAt, attempts: goal.godMode.attempts, log: goal.godMode.log.slice(-100) } } : {}) };
|
|
7
8
|
if (goal.receiptMessageId)
|
|
8
9
|
store.patchMessage(goal.threadId, goal.receiptMessageId, { goalRun });
|
|
9
10
|
else
|