@chibitek/chibi 0.1.179 → 0.1.180
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/{abnfDiagram-O67JEVCF-BFpvXOmW.js → abnfDiagram-O67JEVCF-C91sfqR5.js} +1 -1
- package/dist/assets/{arc-0cz8QAA9.js → arc-ywHVvcgD.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-DxG1U8Tf.js → architectureDiagram-NJMV4G6O-BgUERWVi.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-DdpIUUid.js → blockDiagram-BEXU5L5S-CpeTJJap.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-CNB5U3O1.js → c4Diagram-YGBWAQC7-BgdM3M47.js} +1 -1
- package/dist/assets/channel-Ck_atLKb.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-DixTESOo.js → chunk-2Q5K7J3B-BcMR6SsJ.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-9KbkQg_1.js → chunk-3FUC2YCW-DNzXM7Mm.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-DMNRleww.js → chunk-5VM5RSS4-kVNi7GcP.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-kxGMXg9R.js → chunk-GTNCS2PH-B5bYzLKn.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-B7sa9Us9.js → chunk-GWA4HPMP-DiMuTVC6.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-BF65Wqy-.js → chunk-JWPE2WC7-Bl2yeh-K.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-Du36YO_k.js → chunk-NETBCI7D-Klel5WGa.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-BMTNPIkJ.js → chunk-WEXAMYUT-CPIykbsI.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-BqdQPY5v.js → chunk-XXDRQBXY-8cVOBFNO.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-DYSOprmY.js → classDiagram-v2-NBCMYWYE-DxDpAPju.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-DXKY6FnT.js → cose-bilkent-JH36ORCC-Bb935SMz.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-DamnOWMn.js → cynefin-OW5HDTMX-CxYWe3QR.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-Bb-wuGye.js → cynefinDiagram-VND7K2PF-CYhyAhYv.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-DVMvGhu7.js → dagre-6A5THRUB-Bb41Vmni.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-BX4_NJ2M.js → diagram-22UHCM2B-BNvUBpgi.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-4J3gjVZn.js → diagram-3UASUU5V-D9x2CdxS.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-Bbune_ll.js → diagram-ATOU4E4O-BXIrC_GF.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-EEDiwifm.js → diagram-CDSNMT55-OI4ao0qQ.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-D5lseSZO.js → diagram-MLGK6HIB-_zZZdxaC.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-isxlwvOO.js → diagram-MPIPVDR6-9k65oUfK.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-DXhf0QK8.js → ebnfDiagram-ZINNZB2B-Chvztd4J.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-rR6aJBHM.js → elk-276RUBZZ-CMWtKZmi.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-DRIV4t6Y.js → erDiagram-OPXOYQCR-2vqBM9HW.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-BT3z2JmZ.js → flowDiagram-KWPJA3E3-C6y9L478.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-CR0drs2s.js → ganttDiagram-FUAMR5RP-uWHpQwJY.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-BrjfMmlB.js → gitGraphDiagram-X574FWY7-BLM0_X6z.js} +1 -1
- package/dist/assets/{index-DAGHO7rw.js → index-CPnrJ6T1.js} +131 -131
- package/dist/assets/{index-BISPpSBx.js → index-YJUVFbCT.js} +1 -1
- package/dist/assets/{infoDiagram-VRGFBTTK-fIajbwUK.js → infoDiagram-VRGFBTTK-DWeJ1wdL.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-DlOC_sEC.js → ishikawaDiagram-OU5B5YK6-R28kPwvB.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-BY4NF3Iq.js → journeyDiagram-ZHPQQLJL-BHWE5-BX.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-CjcD7Qp-.js → kanban-definition-PNTS6WVX-M-Er9io8.js} +1 -1
- package/dist/assets/{linear-D2XvBjOb.js → linear-UI6pE8Wd.js} +1 -1
- package/dist/assets/{mermaid.core-DbXyvZNy.js → mermaid.core-B_hsjjFv.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-rjla1J-s.js → mindmap-definition-NLK3R4M7-C6u7tH0B.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-hvEPNypQ.js → pegDiagram-GJSIUBJH-HdJHW3kd.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-D-jjzmff.js → pieDiagram-5QR66LMP-DYm0T2vD.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-DJsTKR54.js → quadrantDiagram-O4NWA36T-CEqOPSKh.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-CgA8NcMY.js → railroadDiagram-XR7U4H2S-I8gLnKDm.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-D5BkeVLA.js → requirementDiagram-PLB6GJNP-0AbgBQwX.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-lEfgZleC.js → sankeyDiagram-IPEJSGJF-CELks0t3.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-iDpAQv2z.js → sequenceDiagram-PO4LG4MO-Lv5pg-Nj.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-hEJsAOhI.js → sizeCapture-INFHLROL-D13uYR-m.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-CKDZvZXj.js → stateDiagram-v2-GCMORJYK-C6ntlRJp.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-_dOmzve2.js → swimlanes-2SLR337P-BBMTJMbP.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-CN2rFhol.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-9GwS2a9Y.js → timeline-definition-EJHVYXUP-CQqiq_9n.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-CqJl0zf1.js → usecaseDiagram-POWQR4AR-CMdMUvua.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-CGQiSSZm.js → vennDiagram-UO4OBE2U-DwNRIC20.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-D4KBo3Q_.js → wardleyDiagram-VNRHLVJA-BDP4uswI.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-BgvRJLNL.js → xychartDiagram-PMCCYNJV-B9qFFRsi.js} +1 -1
- package/dist/index.html +1 -1
- package/dist-server/companion/src/routes.js +1 -0
- package/dist-server/index.js +1661 -965
- package/dist-server/server/connection-cap-failover.js +243 -0
- package/dist-server/server/engine-tiers-view.js +2 -0
- package/dist-server/server/index.js +54 -54
- package/dist-server/server/model-levels/chibitek-rankings.js +15 -5
- package/dist-server/server/paw/fill.js +342 -0
- package/dist-server/server/paw/http.js +66 -0
- package/dist-server/server/paw/loader.js +19 -2
- package/dist-server/server/paw/service.js +61 -4
- package/dist-server/server/paw/templates.js +15 -2
- package/dist-server/server/routes/engine-tiers.js +12 -1
- package/dist-server/server/skill-library.js +8 -0
- package/dist-server/shared/engine-tiers.js +9 -0
- package/dist-server/shared/paw.js +2 -2
- package/package.json +1 -1
- package/skills/build-paw/SKILL.md +212 -0
- package/skills/build-paw/VENDORED.md +5 -0
- package/skills/build-paw/manifest.json +19 -0
- package/skills/build-paw/paw-skeleton/AGENTS.md +9 -0
- package/skills/build-paw/paw-skeleton/CLAUDE.md +9 -0
- package/skills/build-paw/paw-skeleton/CONTEXT.md +10 -0
- package/skills/build-paw/paw-skeleton/README.md +5 -0
- package/skills/build-paw/paw-skeleton/departments/example-team/CONTEXT.md +5 -0
- package/skills/build-paw/paw-skeleton/departments/example-team/skills/README.md +1 -0
- package/skills/build-paw/paw-skeleton/departments/example-team/templates/README.md +1 -0
- package/skills/build-paw/paw-skeleton/departments/example-team/voice.md +3 -0
- package/skills/build-paw/paw-skeleton/me/CHANGELOG.md +7 -0
- package/skills/build-paw/paw-skeleton/me/about-me.md +7 -0
- package/skills/build-paw/paw-skeleton/me/personal/README.md +1 -0
- package/skills/build-paw/paw-skeleton/me/projects/.gitkeep +1 -0
- package/skills/build-paw/paw-skeleton/org/brand/voice.md +5 -0
- package/skills/build-paw/paw-skeleton/org/company.md +6 -0
- package/skills/build-paw/paw-skeleton/org/glossary.md +6 -0
- package/skills/build-paw/paw-skeleton/org/marketing/positioning.md +3 -0
- package/skills/build-paw/paw-skeleton/org/policies/ai-use.md +5 -0
- package/skills/build-paw/paw-skeleton/org/policies/engineering.md +5 -0
- package/skills/build-paw/paw-skeleton/org/policies/secrets.md +5 -0
- package/skills/build-paw/paw-skeleton/org/tools.md +3 -0
- package/skills/build-paw/paw-skeleton/paw.yaml +45 -0
- package/dist/assets/channel-DktfdxuU.js +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-BROCOsEt.js +0 -8
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { DEFAULT_CONNECTION_RUN_OUT, isConnectionRunOutPolicy, } from "../shared/engine-tiers.js";
|
|
2
|
+
import { redactSecretsInText } from "../shared/redact.js";
|
|
3
|
+
import { MAX_ENGINES_PER_TURN, restingLine } from "./engine-failover.js";
|
|
4
|
+
import { computeBackoff, interruptibleDelay, RETRY_MAX_RETRIES } from "./drivers/retry.js";
|
|
5
|
+
export { DEFAULT_CONNECTION_RUN_OUT, interruptibleDelay };
|
|
6
|
+
/** Matches the driver retry budget so harness policy and CLI retries agree. */
|
|
7
|
+
export const TRANSIENT_RETRY_LIMIT = RETRY_MAX_RETRIES;
|
|
8
|
+
export function parseConnectionRunOut(value) {
|
|
9
|
+
return isConnectionRunOutPolicy(value) ? value : DEFAULT_CONNECTION_RUN_OUT;
|
|
10
|
+
}
|
|
11
|
+
/** config.json engineTiers.connectionRunOut: ask-before-paid when absent. */
|
|
12
|
+
export function connectionRunOutPolicy(engineTiers) {
|
|
13
|
+
const record = engineTiers && typeof engineTiers === "object" && !Array.isArray(engineTiers)
|
|
14
|
+
? engineTiers : {};
|
|
15
|
+
return parseConnectionRunOut(record.connectionRunOut);
|
|
16
|
+
}
|
|
17
|
+
export function sameConnectionScope(a, b) {
|
|
18
|
+
return a.ownerId === b.ownerId && a.tenantId === b.tenantId;
|
|
19
|
+
}
|
|
20
|
+
/** Same provider on the same named account (or on none): not a way out. */
|
|
21
|
+
export function sameAccountTwin(a, b) {
|
|
22
|
+
return a.id !== b.id && a.driverKind === b.driverKind && a.accountKey === b.accountKey;
|
|
23
|
+
}
|
|
24
|
+
export function eligibleConnections(connections, scope) {
|
|
25
|
+
return connections.filter((connection) => connection.enabled && connection.approved && connection.supported
|
|
26
|
+
&& connection.modelCompatible && sameConnectionScope(connection, scope));
|
|
27
|
+
}
|
|
28
|
+
/** Stay on the thread's connection while it is still eligible; otherwise the first in order. */
|
|
29
|
+
export function pickStickyConnection(connections, scope, threadConnectionId) {
|
|
30
|
+
const usable = eligibleConnections(connections, scope);
|
|
31
|
+
if (threadConnectionId) {
|
|
32
|
+
const sticky = usable.find((connection) => connection.id === threadConnectionId);
|
|
33
|
+
if (sticky)
|
|
34
|
+
return sticky;
|
|
35
|
+
}
|
|
36
|
+
return usable[0];
|
|
37
|
+
}
|
|
38
|
+
export function nextCompatibleConnection(current, connections) {
|
|
39
|
+
return eligibleConnections(connections, current).find((connection) => connection.id !== current.id && !sameAccountTwin(connection, current));
|
|
40
|
+
}
|
|
41
|
+
export function isGenuineAllowanceExhaustion(kind) {
|
|
42
|
+
return kind === "usage_limited";
|
|
43
|
+
}
|
|
44
|
+
export function isTransientThrottle(kind) {
|
|
45
|
+
return kind === "rate_limited";
|
|
46
|
+
}
|
|
47
|
+
/** Delay before harness retry `attempt` (0-based), or undefined once the bound is reached. */
|
|
48
|
+
export function nextTransientBackoff(attempt, random = Math.random) {
|
|
49
|
+
if (!Number.isInteger(attempt) || attempt < 0 || attempt >= TRANSIENT_RETRY_LIMIT)
|
|
50
|
+
return undefined;
|
|
51
|
+
return computeBackoff(attempt, random);
|
|
52
|
+
}
|
|
53
|
+
/** Report the provider's own counts, or UNKNOWN. Never invent a missing figure. */
|
|
54
|
+
export function usageReport(usage) {
|
|
55
|
+
if (!usage || !Number.isFinite(usage.input) || !Number.isFinite(usage.output))
|
|
56
|
+
return { status: "unknown" };
|
|
57
|
+
if (usage.cachedInput !== undefined && usage.cachedInput !== null && !Number.isFinite(usage.cachedInput))
|
|
58
|
+
return { status: "unknown" };
|
|
59
|
+
return {
|
|
60
|
+
status: "accurate",
|
|
61
|
+
input: usage.input,
|
|
62
|
+
output: usage.output,
|
|
63
|
+
...(typeof usage.cachedInput === "number" ? { cachedInput: usage.cachedInput } : {}),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export function connectionSwitchNotice(input) {
|
|
67
|
+
const when = input.resetAt !== undefined ? ` until ${input.formatTime(input.resetAt)}` : "";
|
|
68
|
+
return `${input.fromLabel} is used up${when}. Running on ${input.toLabel}.`;
|
|
69
|
+
}
|
|
70
|
+
export function paidFallbackAskLine(input) {
|
|
71
|
+
const when = input.resetAt !== undefined ? ` until ${input.formatTime(input.resetAt)}` : "";
|
|
72
|
+
return `${input.fromLabel} is used up${when}. This turn stopped before using a pay-per-use API key, so nothing was charged. Allow pay-per-use (Keep going) or wait until a subscription is back.`;
|
|
73
|
+
}
|
|
74
|
+
export function askBeforeSwitchLine(input) {
|
|
75
|
+
const when = input.resetAt !== undefined ? ` until ${input.formatTime(input.resetAt)}` : "";
|
|
76
|
+
return `${input.fromLabel} is used up${when}. This turn stopped before switching to ${input.toLabel}.`;
|
|
77
|
+
}
|
|
78
|
+
export function transientThrottleStopLine(label) {
|
|
79
|
+
return `${label} is briefly rate-limited, so this turn stayed on it and stopped instead of switching connections.`;
|
|
80
|
+
}
|
|
81
|
+
export function unsupportedConnectionLine(label) {
|
|
82
|
+
return `${label} cannot be used: Atomic has no supported transport or stored credentials for that connection. This turn stopped.`;
|
|
83
|
+
}
|
|
84
|
+
export function exhaustedConnectionsLine(label, resetAt, formatTime) {
|
|
85
|
+
const when = resetAt !== undefined ? ` until ${formatTime(resetAt)}` : "";
|
|
86
|
+
return `${label} is used up${when}, and no other approved connection can serve this thread, so this turn stopped.`;
|
|
87
|
+
}
|
|
88
|
+
export function connectionCapAudit(entry) {
|
|
89
|
+
return {
|
|
90
|
+
threadId: entry.threadId,
|
|
91
|
+
action: entry.action,
|
|
92
|
+
...(entry.fromId ? { fromId: entry.fromId } : {}),
|
|
93
|
+
...(entry.toId ? { toId: entry.toId } : {}),
|
|
94
|
+
...(entry.detail ? { detail: redactSecretsInText(entry.detail) } : {}),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export function decideConnectionCapFailover(input) {
|
|
98
|
+
if (input.cancelled)
|
|
99
|
+
return { action: "stay-stop", line: transientThrottleStopLine(input.current.label) };
|
|
100
|
+
if (isTransientThrottle(input.failureKind)) {
|
|
101
|
+
const attempt = input.transientAttempt ?? 0;
|
|
102
|
+
const delayMs = nextTransientBackoff(attempt, () => 0.5);
|
|
103
|
+
if (delayMs !== undefined)
|
|
104
|
+
return { action: "backoff", delayMs, attempt };
|
|
105
|
+
return { action: "stay-stop", line: transientThrottleStopLine(input.current.label) };
|
|
106
|
+
}
|
|
107
|
+
if (!isGenuineAllowanceExhaustion(input.failureKind))
|
|
108
|
+
return { action: "passthrough" };
|
|
109
|
+
const remaining = input.connections.filter((connection) => connection.id !== input.current.id && !sameAccountTwin(connection, input.current)
|
|
110
|
+
&& sameConnectionScope(connection, input.current) && connection.modelCompatible);
|
|
111
|
+
const next = nextCompatibleConnection(input.current, input.connections);
|
|
112
|
+
if (!next) {
|
|
113
|
+
const blocked = remaining.find((connection) => !connection.supported);
|
|
114
|
+
if (blocked)
|
|
115
|
+
return { action: "unsupported", line: unsupportedConnectionLine(blocked.label) };
|
|
116
|
+
return { action: "stop", line: exhaustedConnectionsLine(input.current.label, input.resetAt, input.formatTime) };
|
|
117
|
+
}
|
|
118
|
+
if (input.policy === "ask") {
|
|
119
|
+
return { action: "ask", line: askBeforeSwitchLine({ fromLabel: input.current.label, toLabel: next.label, resetAt: input.resetAt, formatTime: input.formatTime }) };
|
|
120
|
+
}
|
|
121
|
+
if (next.billing === "payPerUse" && input.policy === "ask-before-paid" && !input.paidApproved) {
|
|
122
|
+
return { action: "ask", line: paidFallbackAskLine({ fromLabel: input.current.label, resetAt: input.resetAt, formatTime: input.formatTime }) };
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
action: "switch",
|
|
126
|
+
notice: connectionSwitchNotice({ fromLabel: input.current.label, toLabel: next.label, resetAt: input.resetAt, formatTime: input.formatTime }),
|
|
127
|
+
persistThreadDefault: false,
|
|
128
|
+
next,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/** Production hook used by failoverPick: keep existing stop lines, and gate cap switches. */
|
|
132
|
+
export function finalizeConnectionCapPick(input) {
|
|
133
|
+
if (input.failureKind === "rate_limited") {
|
|
134
|
+
return { line: transientThrottleStopLine(input.currentLabel), category: "failover_exhausted" };
|
|
135
|
+
}
|
|
136
|
+
const { choice } = input;
|
|
137
|
+
if (!choice && input.fallback)
|
|
138
|
+
return { line: input.subscriptionLine ?? "No engine is available for this turn, so it stopped." };
|
|
139
|
+
if (!choice && input.failureKind === "provider_error")
|
|
140
|
+
return { passthrough: true };
|
|
141
|
+
if (!choice) {
|
|
142
|
+
if (input.pausedUntil !== undefined && input.skipped.some((skip) => skip.reason === "paused")) {
|
|
143
|
+
return { line: input.payPerUsePausedLine(input.pausedUntil) };
|
|
144
|
+
}
|
|
145
|
+
const waiting = decideNewTurnPlacement({
|
|
146
|
+
policy: input.policy, paidApproved: input.paidApproved,
|
|
147
|
+
skippedPausedKey: input.skipped.some((skip) => skip.reason === "paused"),
|
|
148
|
+
currentLabel: input.currentLabel, resetAt: input.resetAt, formatTime: input.formatTime,
|
|
149
|
+
});
|
|
150
|
+
if (waiting.action === "ask") {
|
|
151
|
+
input.announceWaiting?.();
|
|
152
|
+
return { line: waiting.line, category: "failover_exhausted" };
|
|
153
|
+
}
|
|
154
|
+
const resting = input.skipped.filter((skip) => skip.reason === "resting" || skip.reason === "tried").map((skip) => skip.instanceId);
|
|
155
|
+
const named = input.restingNamed([input.failedInstanceId, ...input.alreadyTried, ...resting]);
|
|
156
|
+
return {
|
|
157
|
+
line: restingLine(named, input.formatTime, input.cannotDrive, { capped: input.triedCount >= MAX_ENGINES_PER_TURN }),
|
|
158
|
+
category: named.some((engine) => engine.needsSignIn || engine.keyExpired) ? "account" : "failover_exhausted",
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
if (input.failureKind === "usage_limited") {
|
|
162
|
+
const gated = gateUsageLimitedChoice({
|
|
163
|
+
policy: input.policy,
|
|
164
|
+
paidApproved: input.paidApproved,
|
|
165
|
+
local: input.local,
|
|
166
|
+
nextBand: input.nextBand ?? choice.band,
|
|
167
|
+
currentLabel: input.currentLabel,
|
|
168
|
+
nextLabel: input.nextLabel ?? choice.selection.instanceId,
|
|
169
|
+
resetAt: input.resetAt,
|
|
170
|
+
formatTime: input.formatTime,
|
|
171
|
+
});
|
|
172
|
+
if (gated) {
|
|
173
|
+
input.announceWaiting?.();
|
|
174
|
+
return gated;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
input.bookChoice();
|
|
178
|
+
return { choice };
|
|
179
|
+
}
|
|
180
|
+
export function gateUsageLimitedChoice(input) {
|
|
181
|
+
const paid = input.nextBand === "key" && !input.local;
|
|
182
|
+
if (input.policy === "ask") {
|
|
183
|
+
return { line: askBeforeSwitchLine({ fromLabel: input.currentLabel, toLabel: input.nextLabel, resetAt: input.resetAt, formatTime: input.formatTime }), category: "failover_exhausted" };
|
|
184
|
+
}
|
|
185
|
+
if (paid && input.policy === "ask-before-paid" && !input.paidApproved) {
|
|
186
|
+
return { line: paidFallbackAskLine({ fromLabel: input.currentLabel, resetAt: input.resetAt, formatTime: input.formatTime }), category: "failover_exhausted" };
|
|
187
|
+
}
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
/** Stored Keep going (`keptGoingAt`) or an explicit keep-going policy. A pause always wins. */
|
|
191
|
+
export function paidKeysApproved(input) {
|
|
192
|
+
if (input.pausedUntil !== undefined)
|
|
193
|
+
return false;
|
|
194
|
+
return input.policy === "keep-going" || input.paidApproved;
|
|
195
|
+
}
|
|
196
|
+
/** Close the key band so resolveLadder never selects a pay-per-use engine. */
|
|
197
|
+
export function pauseKeyBandForRunOut(input) {
|
|
198
|
+
if (input.subscriptionsOnly || input.pausedUntil !== undefined)
|
|
199
|
+
return true;
|
|
200
|
+
if (input.localUntil !== undefined)
|
|
201
|
+
return false;
|
|
202
|
+
if (input.sweep)
|
|
203
|
+
return !input.paidApproved;
|
|
204
|
+
return !paidKeysApproved(input);
|
|
205
|
+
}
|
|
206
|
+
/** New-turn, retry, and resume: stop before constructing a paid driver unless stored approval allows it. */
|
|
207
|
+
export function decideNewTurnPlacement(input) {
|
|
208
|
+
if (input.cancelled) {
|
|
209
|
+
return { action: "ask", line: paidFallbackAskLine({ fromLabel: input.currentLabel, resetAt: input.resetAt, formatTime: input.formatTime }), announceWaiting: false };
|
|
210
|
+
}
|
|
211
|
+
if (input.band === "subscription" || input.band === "free" || (input.band === "key" && input.local)) {
|
|
212
|
+
return { action: "place" };
|
|
213
|
+
}
|
|
214
|
+
if (!input.band && input.pausedUntil !== undefined && input.skippedPausedKey) {
|
|
215
|
+
return { action: "paused", until: input.pausedUntil };
|
|
216
|
+
}
|
|
217
|
+
const wouldUsePaid = input.band === "key" || Boolean(!input.band && input.skippedPausedKey);
|
|
218
|
+
if (wouldUsePaid && !paidKeysApproved(input)) {
|
|
219
|
+
return { action: "ask", line: paidFallbackAskLine({ fromLabel: input.currentLabel, resetAt: input.resetAt, formatTime: input.formatTime }), announceWaiting: true };
|
|
220
|
+
}
|
|
221
|
+
return input.band ? { action: "place" } : { action: "none" };
|
|
222
|
+
}
|
|
223
|
+
/** Production hook used by placedTurn: throw before booking an unapproved paid driver. */
|
|
224
|
+
export function finalizeNewTurnPlacement(input) {
|
|
225
|
+
const decision = decideNewTurnPlacement({
|
|
226
|
+
policy: input.policy, paidApproved: input.paidApproved, local: input.local, band: input.choice?.band,
|
|
227
|
+
skippedPausedKey: input.skipped.some((skip) => skip.reason === "paused"),
|
|
228
|
+
pausedUntil: input.pausedUntil, currentLabel: input.currentLabel, resetAt: input.resetAt,
|
|
229
|
+
formatTime: input.formatTime, cancelled: input.cancelled,
|
|
230
|
+
});
|
|
231
|
+
if (decision.action === "ask") {
|
|
232
|
+
if (decision.announceWaiting)
|
|
233
|
+
input.announceWaiting();
|
|
234
|
+
throw Object.assign(new Error(decision.line), { status: 409, code: "pay_per_use_ask", category: "failover_exhausted" });
|
|
235
|
+
}
|
|
236
|
+
if (decision.action === "paused") {
|
|
237
|
+
throw Object.assign(new Error(input.pausedLine(decision.until)), { status: 409, code: "pay_per_use_paused", category: "failover_exhausted" });
|
|
238
|
+
}
|
|
239
|
+
if (decision.action !== "place" || !input.choice)
|
|
240
|
+
return undefined;
|
|
241
|
+
input.book();
|
|
242
|
+
return { selection: input.choice.selection, persist: input.persist };
|
|
243
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// tier's ladder with health and rest, the installed engines, rest history,
|
|
3
3
|
// pay-per-use episodes and the "Include free models in Auto" setting.
|
|
4
4
|
import { BOT_TIERS, DEFAULT_LADDERS, DEFAULT_TIER_CLASSES } from "../shared/engine-tiers.js";
|
|
5
|
+
import { connectionRunOutPolicy } from "./connection-cap-failover.js";
|
|
5
6
|
import { engineHealth, engineTierClasses, engineTierLadders, engineTiersIncludeFree, keyBased, matchesEngine } from "./engine-tiers.js";
|
|
6
7
|
import { perTokenModel } from "./harness-import/engine-policy.js";
|
|
7
8
|
const DRIVER_NAMES = {
|
|
@@ -42,6 +43,7 @@ export function engineTiersView(engineTiers, candidates, rests, defaults = DEFAU
|
|
|
42
43
|
ladder: ladders[tier].map(rung), custom: JSON.stringify(ladders[tier]) !== JSON.stringify(defaults[tier]) })),
|
|
43
44
|
engines,
|
|
44
45
|
...(engineTiersIncludeFree(engineTiers) ? { includeFree: true } : {}),
|
|
46
|
+
connectionRunOut: connectionRunOutPolicy(engineTiers),
|
|
45
47
|
...(rests?.payPerUse ? { payPerUse: rests.payPerUse() } : {}),
|
|
46
48
|
...(rests ? { restHistory: rests.history().map((record) => ({ ...record,
|
|
47
49
|
label: record.scope ? `${label(record.instanceId)} (${record.scope})` : label(record.instanceId) })) } : {}),
|
|
@@ -214,10 +214,11 @@ import { installReticle, reticleInstallState } from "./reticle.js";
|
|
|
214
214
|
import { RTK_LAUNCHER_PATH, rtkLocalStatus } from "./rtk.js";
|
|
215
215
|
import { withoutRtkLauncher } from "./rtk-rewrite.js";
|
|
216
216
|
import { loadAddonSkillLibraries } from "./skill-addons.js";
|
|
217
|
-
import { browserSkillCapabilities, loadBundledSkills, loadUserSkills, mergeSkills, renderSkillInstructions, selectBundledSkills } from "./skill-library.js";
|
|
217
|
+
import { browserSkillCapabilities, loadBundledSkills, loadUserSkills, mergeSkills, renderSkillInstructions, selectBundledSkills, withBuildPawSkill } from "./skill-library.js";
|
|
218
218
|
import { AboutMeSync, nexusAboutMe } from "./about-me-sync.js";
|
|
219
219
|
import { icmAboutMeSummary, icmEnabled, icmStatus, icmSystemPrompt, resolveIcmPath } from "./icm-context.js";
|
|
220
220
|
import { PawService } from "./paw/service.js";
|
|
221
|
+
import { interviewCommitResponse, interviewPlanResponse, shortInterviewAnswers, shouldMountBuildPaw } from "./paw/http.js";
|
|
221
222
|
import { chibiFilingPrompt, parseFiledTaskId } from "./paw/change-requests.js";
|
|
222
223
|
import { installedPlaybookInstructions } from "./installed-playbooks.js";
|
|
223
224
|
import { createBotPackageExport } from "./package-export.js";
|
|
@@ -319,6 +320,7 @@ import { createBoardRoutes } from "./routes/board.js";
|
|
|
319
320
|
import { readBoardFromNexus } from "./board/nexus-board.js";
|
|
320
321
|
import { LocalModelInventory, localModePlacement, machineMemory } from "./local-models-mode.js";
|
|
321
322
|
import { eventBase, restTime, FailoverGate, MAX_ENGINES_PER_TURN, continuationNote, restingLine, restingOnRoute, sameRoute } from "./engine-failover.js";
|
|
323
|
+
import { connectionRunOutPolicy, finalizeConnectionCapPick, finalizeNewTurnPlacement, pauseKeyBandForRunOut } from "./connection-cap-failover.js";
|
|
322
324
|
import { enterSessionFallback, onSessionFallback, ownOrFallback, sessionFallbackSpentLine, withoutSubscription } from "./session-fallback.js";
|
|
323
325
|
import { TURN_ERROR_CATEGORIES } from "../shared/runtime-events.js";
|
|
324
326
|
import { EngineProbes, PROBE_PROMPT, isProbeThread, probeThreadId } from "./engine-probe.js";
|
|
@@ -2969,7 +2971,7 @@ function personalPlacement(input) {
|
|
|
2969
2971
|
// Own accounts and opted-in local compute come first. Company compute is
|
|
2970
2972
|
// separate from personal connections; the final dispatch gate confirms Mezcal.
|
|
2971
2973
|
const companyContext = {
|
|
2972
|
-
...context, keyBandPaused:
|
|
2974
|
+
...context, keyBandPaused: keyBandPausedFor(projected.threadId),
|
|
2973
2975
|
accept: (candidate, model) => tried.has(candidate.instanceId) ? "tried"
|
|
2974
2976
|
: ownerAllows(profile, ownerCheck(candidate, model), personalLocalAllowed()) ? undefined : "owner",
|
|
2975
2977
|
refuse: (candidate) => instanceOwner(candidate.instanceId) !== "company" ? "owner" : engineTierRefusal(projected)?.(candidate),
|
|
@@ -3094,7 +3096,7 @@ function ladderTurnEngineChoice(profile, projected, threadId, needs, runOn, subs
|
|
|
3094
3096
|
const { ladder } = plan;
|
|
3095
3097
|
const computer = turnComputer(projected, threadId, runOn);
|
|
3096
3098
|
const context = { candidates, needsDelegation: needsDelegation(tier, profile), computer, refuse: engineTierRefusal(projected), resting: engineResting,
|
|
3097
|
-
keyBandPaused: subscriptionsOnly ||
|
|
3099
|
+
keyBandPaused: subscriptionsOnly || keyBandPausedFor(threadId), includeFree: engineTiersIncludeFree(cfg.engineTiers), clientData: handlesClientData(profile) };
|
|
3098
3100
|
const local = (resolution) => localModeTurn(resolution, { tier, context, needs, prefer: [projected.modelSelection.instanceId] });
|
|
3099
3101
|
const wider = (tried, modelClass) => resolveFailover({
|
|
3100
3102
|
ladder, classLadder: (cls) => classLadder(classedModels(), cls), failed: projected.modelSelection, context, tried,
|
|
@@ -3253,9 +3255,8 @@ function dictationSubscription() {
|
|
|
3253
3255
|
/** The key band is closed to a sweep unless the person chose "Keep going"
|
|
3254
3256
|
* (or local mode, which turns a key choice into a local model). */
|
|
3255
3257
|
function keyBandPausedFor(threadId) {
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
return isSweepTurn(threadId) && payPerUse.current()?.keptGoingAt === undefined && payPerUse.localUntil() === undefined;
|
|
3258
|
+
return pauseKeyBandForRunOut({ policy: connectionRunOutPolicy(cfg.engineTiers), paidApproved: Boolean(payPerUse.current()?.keptGoingAt),
|
|
3259
|
+
pausedUntil: payPerUse.pausedUntil(), localUntil: payPerUse.localUntil(), sweep: isSweepTurn(threadId) });
|
|
3259
3260
|
}
|
|
3260
3261
|
/** The sweep turn's engine, or null when nothing it may use is free. `note`
|
|
3261
3262
|
* books the choice for pay-per-use; the sweeper's own probe does not. */
|
|
@@ -3300,23 +3301,20 @@ function sweepEngineChoice(botId, threadId, note, runOn) {
|
|
|
3300
3301
|
return { selection: placed.choice.selection, persist: true };
|
|
3301
3302
|
}
|
|
3302
3303
|
/** A turn start's ladder walk, as startTurn uses it: noted for pay-per-use,
|
|
3303
|
-
*
|
|
3304
|
-
* else is free. */
|
|
3304
|
+
* refused before an unapproved paid key, or when pay-per-use is paused. */
|
|
3305
3305
|
function placedTurn(resolution, persist) {
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
}
|
|
3314
|
-
return undefined;
|
|
3306
|
+
return finalizeNewTurnPlacement({
|
|
3307
|
+
policy: connectionRunOutPolicy(cfg.engineTiers), paidApproved: Boolean(payPerUse.current()?.keptGoingAt),
|
|
3308
|
+
local: resolution.local, choice: resolution.choice, skipped: resolution.skipped, pausedUntil: payPerUse.pausedUntil(),
|
|
3309
|
+
currentLabel: "A subscription", formatTime: restTime, persist, pausedLine: payPerUsePausedLine,
|
|
3310
|
+
announceWaiting: () => notePayPerUse({ skipped: resolution.skipped, local: true, choice: { band: "key", selection: { instanceId: "", model: "" }, candidate: { instanceId: "" }, step: 0 } }),
|
|
3311
|
+
book: () => notePayPerUse(resolution),
|
|
3312
|
+
});
|
|
3315
3313
|
}
|
|
3316
3314
|
// ── pay-per-use (docs/chibitek/engine-tiers.md, "Pay-per-use notice") ────
|
|
3317
|
-
// The one thing about engines and billing the person hears of: a
|
|
3318
|
-
//
|
|
3319
|
-
// out or unavailable opens an episode, announced once
|
|
3315
|
+
// The one thing about engines and billing the person hears of: a paid key
|
|
3316
|
+
// is used only after stored approval when every subscription is resting,
|
|
3317
|
+
// signed out or unavailable. That opens an episode, announced once; a turn
|
|
3320
3318
|
// placed on a subscription ends it. Ollama Cloud is a subscription.
|
|
3321
3319
|
const payPerUse = new PayPerUseEpisodes(DATA_DIR, (episode) => broadcast({ kind: "engines.pay_per_use", episode }, { adminOnly: true }));
|
|
3322
3320
|
const SUBSCRIPTION_OUT = new Set(["resting", "signed-out", "unavailable", "tried"]);
|
|
@@ -3342,7 +3340,7 @@ function notePayPerUse(resolution) {
|
|
|
3342
3340
|
// a turn Atomic would place on an API key runs on a model this machine
|
|
3343
3341
|
// serves, chosen for the job (server/local-models-mode.ts). It applies to
|
|
3344
3342
|
// every tier: it is the person's choice, not a silent stand-in. With no
|
|
3345
|
-
// suitable local model the turn
|
|
3343
|
+
// suitable local model the turn stops unless stored approval allows the key.
|
|
3346
3344
|
const localModels = new LocalModelInventory();
|
|
3347
3345
|
/** The turn carries images, so a local model must see them. */
|
|
3348
3346
|
const turnHasImages = (message) => Boolean(message?.attachments?.some((attachment) => attachment.kind === "image"));
|
|
@@ -3642,7 +3640,7 @@ function engineFailover(turn, completion) {
|
|
|
3642
3640
|
...(failure.permanent ? { permanent: true } : {}), ...(scope ? { scope } : {}), ...(ran?.model ? { model: ran.model } : {}),
|
|
3643
3641
|
...(failure.kind === "auth_failed" && failedCandidate ? { reportedSignedIn: failedCandidate.snapshot.state === "available" && failedCandidate.snapshot.authenticated === true } : {}) });
|
|
3644
3642
|
// Unknown failures rest only when the turn moves; otherwise preserve their report.
|
|
3645
|
-
const rest = failure.kind === "provider_error" ? undefined : restFailed();
|
|
3643
|
+
const rest = failure.kind === "provider_error" || failure.kind === "rate_limited" ? undefined : restFailed();
|
|
3646
3644
|
const label = (instanceId) => candidates.find((candidate) => candidate.instanceId === instanceId)?.displayName ?? instanceId;
|
|
3647
3645
|
// The one plain line, never the provider's own words: which account needs
|
|
3648
3646
|
// the person and where to fix it, or that every engine is resting.
|
|
@@ -3698,7 +3696,7 @@ function engineFailover(turn, completion) {
|
|
|
3698
3696
|
threadId: turn.threadId,
|
|
3699
3697
|
userMessage: record.userMessage,
|
|
3700
3698
|
excludeMessageIds: [...(record.opts.excludeMessageIds ?? []), ...said.map((message) => message.id)],
|
|
3701
|
-
failover: { selection: choice.selection, persist: record.persist, tried: [...tried], attempt, originalText: record.text },
|
|
3699
|
+
failover: { selection: choice.selection, persist: record.persist && failure.kind !== "usage_limited", tried: [...tried], attempt, originalText: record.text },
|
|
3702
3700
|
});
|
|
3703
3701
|
if (directTurnGenerationByThread.get(turn.threadId) === turn.generation) {
|
|
3704
3702
|
// Refused before it claimed the thread (a spend cap, settings being
|
|
@@ -3885,27 +3883,23 @@ function failoverPick(turn, profile, projected, candidates, failedCandidate, res
|
|
|
3885
3883
|
context: { candidates, needsDelegation: needsDelegation(tier, profile), computer, refuse: engineTierRefusal(projected), resting } })
|
|
3886
3884
|
: { ...resolution, local: false };
|
|
3887
3885
|
const choice = placed.choice && placed.local ? { ...placed.choice, modelClass: "Añejo" } : placed.choice;
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
notePersonalPayPerUse(personalMove);
|
|
3906
|
-
else
|
|
3907
|
-
notePayPerUse({ choice, skipped: resolution.skipped, local: placed.local });
|
|
3908
|
-
return { choice };
|
|
3886
|
+
return finalizeConnectionCapPick({
|
|
3887
|
+
choice, fallback, subscriptionLine: subscriptionMove?.line, failureKind: turn.failure?.kind,
|
|
3888
|
+
pausedUntil: payPerUse.pausedUntil(), skipped: resolution.skipped, payPerUsePausedLine, restingNamed,
|
|
3889
|
+
failedInstanceId: turn.instanceId, alreadyTried: attempt.tried, triedCount: tried.size,
|
|
3890
|
+
cannotDrive: cannotDriveNamed(candidates, resolution.skipped.map((skip) => skip.instanceId), computer),
|
|
3891
|
+
policy: connectionRunOutPolicy(cfg.engineTiers), paidApproved: Boolean(payPerUse.current()?.keptGoingAt),
|
|
3892
|
+
local: Boolean(placed.local), currentLabel: engineLabel(candidates, attempt.selection),
|
|
3893
|
+
nextLabel: choice ? engineLabel(candidates, choice.selection) : undefined,
|
|
3894
|
+
nextBand: choice && "band" in choice ? choice.band : undefined, resetAt: turn.failure?.resetAt, formatTime: restTime,
|
|
3895
|
+
announceWaiting: () => notePayPerUse({ skipped: resolution.skipped, local: true, choice: { band: "key", selection: { instanceId: "", model: "" }, candidate: { instanceId: "" }, step: 0 } }),
|
|
3896
|
+
bookChoice: () => { if (!(subscriptionMove || fallback)) {
|
|
3897
|
+
if (personalMove)
|
|
3898
|
+
notePersonalPayPerUse(personalMove);
|
|
3899
|
+
else
|
|
3900
|
+
notePayPerUse({ choice: choice, skipped: resolution.skipped, local: placed.local });
|
|
3901
|
+
} },
|
|
3902
|
+
});
|
|
3909
3903
|
}
|
|
3910
3904
|
/** Requests (their user message ids) already re-run once after a check. */
|
|
3911
3905
|
const jevRecheckedRequests = new Set();
|
|
@@ -10685,6 +10679,8 @@ async function startTurn(botId, text, opts) {
|
|
|
10685
10679
|
...browserSkillCapabilities({ browserMounted: true, tier: botTier(liveBot ?? bot) }),
|
|
10686
10680
|
], turnSkills);
|
|
10687
10681
|
}
|
|
10682
|
+
if (shouldMountBuildPaw({ runOn: opts?.runOn, personalBot: isPersonalBot(liveBot ?? bot), freeBilling: accountProvider(providerConfigs()[instance.instanceId]?.account)?.billing === "free", needsInterview: paw.needsInterview() }))
|
|
10683
|
+
selectedSkills = withBuildPawSkill(selectedSkills, turnSkills, true);
|
|
10688
10684
|
const skillInstructions = renderSkillInstructions(selectedSkills, {
|
|
10689
10685
|
includeRoot: worksInWorkspace && opts?.runOn !== "cloud",
|
|
10690
10686
|
});
|
|
@@ -12635,7 +12631,7 @@ failover) {
|
|
|
12635
12631
|
{ id: "memory", label: "Memory", text: roomMemory ? `\n${roomMemory.trim()}` : "" },
|
|
12636
12632
|
{ id: "nexus", label: "Nexus memory", text: roomNexusContext },
|
|
12637
12633
|
{ id: "skills", label: "Skills index", text: workspace ? skillsSystemPrompt(bot.id) : "" },
|
|
12638
|
-
{ id: "skill-instructions", label: "Skill instructions", text: renderSkillInstructions(selectedSkills, { includeRoot: Boolean(workspace) }) },
|
|
12634
|
+
{ id: "skill-instructions", label: "Skill instructions", text: renderSkillInstructions(shouldMountBuildPaw({ personalBot: isPersonalBot(bot), freeBilling: accountProvider(providerConfigs()[instance.instanceId]?.account)?.billing === "free", needsInterview: paw.needsInterview() }) ? withBuildPawSkill(selectedSkills, skills, true) : selectedSkills, { includeRoot: Boolean(workspace) }) },
|
|
12639
12635
|
{ id: "playbooks", label: "Playbooks", text: installedPlaybookInstructions(text, bot.playbooks) },
|
|
12640
12636
|
{ id: "addons", label: "Add-ons", text: roomAddons.instructions },
|
|
12641
12637
|
]);
|
|
@@ -24246,20 +24242,25 @@ const handleRequest = async (req, res) => {
|
|
|
24246
24242
|
if (path === "/api/paw" || path.startsWith("/api/paw/")) {
|
|
24247
24243
|
if (auth.kind === "session" && !auth.scopes.includes("admin"))
|
|
24248
24244
|
return json(res, 403, { error: "Only the owner of this computer can change PAW" });
|
|
24249
|
-
if (method === "GET" && path === "/api/paw")
|
|
24245
|
+
if (method === "GET" && path === "/api/paw")
|
|
24250
24246
|
return json(res, 200, { ...paw.status(), aboutMe: paw.aboutMe(), changes: paw.store.list().slice(0, 20).map(({ before: _b, after: _a, ...rest }) => rest) });
|
|
24251
|
-
}
|
|
24252
24247
|
if (method === "PUT" && path === "/api/paw/interview") {
|
|
24253
24248
|
const body = await readBody(req);
|
|
24254
|
-
const
|
|
24255
|
-
const status = await paw.interview({
|
|
24256
|
-
name: field("name", 80), role: field("role", 120), department: field("department", 80), company: field("company", 120),
|
|
24257
|
-
goals: field("goals", 2_000), workingStyle: field("workingStyle", 2_000),
|
|
24258
|
-
}, { chibitek: body?.chibitek === true });
|
|
24249
|
+
const status = await paw.interview(shortInterviewAnswers(body), { chibitek: body?.chibitek === true });
|
|
24259
24250
|
aboutMe.sync(0);
|
|
24260
24251
|
broadcast({ kind: "config", ...configStatus() });
|
|
24261
24252
|
return json(res, 200, { ...status, aboutMe: paw.aboutMe() });
|
|
24262
24253
|
}
|
|
24254
|
+
if (method === "POST" && path === "/api/paw/interview/plan")
|
|
24255
|
+
return json(res, 200, interviewPlanResponse(paw, await readBody(req, 64_000)));
|
|
24256
|
+
if (method === "POST" && path === "/api/paw/interview/commit") {
|
|
24257
|
+
const committed = await interviewCommitResponse(paw, await readBody(req, 64_000));
|
|
24258
|
+
if (committed.written.length) {
|
|
24259
|
+
aboutMe.sync(0);
|
|
24260
|
+
broadcast({ kind: "config", ...configStatus() });
|
|
24261
|
+
}
|
|
24262
|
+
return json(res, 200, { ...committed.status, aboutMe: paw.aboutMe(), plan: committed.plan, written: committed.written, rejected: committed.rejected, changelog: committed.changelog });
|
|
24263
|
+
}
|
|
24263
24264
|
if (method === "PUT" && path === "/api/paw/about-me") {
|
|
24264
24265
|
const body = await readBody(req);
|
|
24265
24266
|
if (typeof body?.text !== "string")
|
|
@@ -24275,9 +24276,8 @@ const handleRequest = async (req, res) => {
|
|
|
24275
24276
|
return await aboutMe.resolve(String(side)) ? json(res, 200, { ok: true }) : json(res, 409, { error: "Nothing to choose: About me already agrees." });
|
|
24276
24277
|
}
|
|
24277
24278
|
// Bot settings > Memory > Workspace knowledge
|
|
24278
|
-
if (method === "GET" && path === "/api/paw/suggestable")
|
|
24279
|
+
if (method === "GET" && path === "/api/paw/suggestable")
|
|
24279
24280
|
return json(res, 200, { files: paw.suggestable() });
|
|
24280
|
-
}
|
|
24281
24281
|
if (method === "POST" && path === "/api/paw/suggestions") {
|
|
24282
24282
|
const body = await readBody(req, 64_000);
|
|
24283
24283
|
const made = paw.suggestChange({
|
|
@@ -18,8 +18,11 @@ import { writeFileAtomic } from "../atomic.js";
|
|
|
18
18
|
import { normalizeName } from "./aliases.js";
|
|
19
19
|
export const CHIBITEK_RANKINGS_CACHE = "model-rankings-chibitek.json";
|
|
20
20
|
const CACHE_VERSION = 1;
|
|
21
|
-
/** Where the published document lives
|
|
22
|
-
|
|
21
|
+
/** Where the published document lives: beside the update feed in the public
|
|
22
|
+
* atomic-updates bucket (electron-builder.yml), so it rides the same hosting
|
|
23
|
+
* the releases already depend on. Overridable for staging and tests. */
|
|
24
|
+
export const CHIBITEK_RANKINGS_URL = process.env.CHIBITEK_RANKINGS_URL ??
|
|
25
|
+
"https://ugmbfkqvogfuvufzjxtb.supabase.co/storage/v1/object/public/atomic-updates/atomic/K_5FMcrZFZ5AE2K-Lydn-Tis/model-rankings.json";
|
|
23
26
|
const CLASS_SET = new Set(MODEL_CLASSES);
|
|
24
27
|
/** The document, validated and resolved against the catalog. Unknown ids
|
|
25
28
|
* are dropped and named in `unknown` so a typo never silently grades the
|
|
@@ -87,7 +90,14 @@ export async function fetchRankings(options) {
|
|
|
87
90
|
signal: AbortSignal.timeout(30_000),
|
|
88
91
|
headers: { accept: "application/json" },
|
|
89
92
|
});
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
if (response.ok)
|
|
94
|
+
return response.json();
|
|
95
|
+
// Supabase Storage answers a missing object with 400 and a NoSuchKey body,
|
|
96
|
+
// not 404; report it as the 404 the caller reads as "not published yet".
|
|
97
|
+
if (response.status === 400) {
|
|
98
|
+
const body = (await response.json().catch(() => null));
|
|
99
|
+
if (body?.code === "NoSuchKey")
|
|
100
|
+
throw new Error("chibitek-rankings: HTTP 404");
|
|
101
|
+
}
|
|
102
|
+
throw new Error(`chibitek-rankings: HTTP ${response.status}`);
|
|
93
103
|
}
|