@moxxy/cli 0.27.0 → 0.28.0
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/bin.js +431 -402
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import { z as z$1, definePlugin, defineProvider, defineTool, MoxxyError, asTurnId, defineMode, defineCommand, defineChannel, defineWorkflowExecutor, asPluginId, createMutex, defineTunnelProvider, classifyHttpStatus, estimateTextTokens, toFriendlyError,
|
|
3
|
+
import { z as z$1, definePlugin, defineProvider, defineTool, MoxxyError, asTurnId, defineMode, defineCommand, defineChannel, defineWorkflowExecutor, asPluginId, createMutex, defineTunnelProvider, classifyHttpStatus, estimateTextTokens, toFriendlyError, runReactLoop, defineCompactor, defineCacheStrategy, defineEmbedder, zodToJsonSchema, fileDiffSummary, toolResultBytes, denyByDefaultResolver, runManualCompaction, renderFrontmatter, createAllowListResolver, parseFrontmatterFile, aggregateCapabilitySpecs, EXIT_AFTER_PAIR_FLAG, isFirstPartyPackage, skillFrontmatterSchema, asSkillId, startChannelWith, SESSION_SOURCES, createDeferredPermissionResolver, getInstallHint, moxxyPackageSchema, encodeLoginPrompt, sleepWithAbort, createJsonFileStore, ISOLATION_RANK, isSelectableMode, parseFrontmatter, createCallbackResolver, countNodes, autoAllowResolver, addModelTotals, asSessionId, asToolCallId, migrateModeName, defineViewRenderer, DEFAULT_VIEW_TAGS, classifyNetworkError, isSafeViewUrl, evaluateToolRule, MOXXY_PCM16_24KHZ_MIME, isFileDiffDisplay, summarizeSessionTokensFromEvents, summarizeTokensByModel, toDiffRows, diffGutterNo, fileDiffVerb, computeElisionState, toolResultStubbed, toolResultStub, conversationalStubbed, conversationalStub, asEventId } from '@moxxy/sdk';
|
|
4
4
|
import * as fs32 from 'fs';
|
|
5
5
|
import fs32__default, { existsSync, promises, readFileSync, ReadStream, mkdirSync, writeFileSync, rmSync, statSync, readdirSync, openSync, closeSync, unlinkSync, renameSync, realpathSync, lstatSync, constants as constants$1, watch, createReadStream } from 'fs';
|
|
6
6
|
import * as path3 from 'path';
|
|
@@ -868,6 +868,10 @@ function buildChildContext(rt3, spec, model, childSessionId, childTurnId, toolRe
|
|
|
868
868
|
// child cancels when parent cancels
|
|
869
869
|
maxIterations: spec.maxIterations ?? 50,
|
|
870
870
|
subagents: spawner,
|
|
871
|
+
// Disarms turn-end checkpoints inside children (runReactLoop's recursion
|
|
872
|
+
// backstop) — a checkpoint spawning a child in a checkpoint-bearing mode
|
|
873
|
+
// must not gate the child's turn-end and recurse forever.
|
|
874
|
+
isSubagent: true,
|
|
871
875
|
emit: (event) => childLog.append(event)
|
|
872
876
|
};
|
|
873
877
|
}
|
|
@@ -979,6 +983,7 @@ async function* runTurn(session, prompt, opts = {}) {
|
|
|
979
983
|
}
|
|
980
984
|
session.lastResolvedModel = model;
|
|
981
985
|
const strategy = session.modes.getActive();
|
|
986
|
+
const previousModeName = session.modes.getPreviousActiveName();
|
|
982
987
|
const effectiveSignal = AbortSignal.any(opts.signal ? [session.signal, opts.signal, turnController.signal] : [session.signal, turnController.signal]);
|
|
983
988
|
const appCtx = session.appContext();
|
|
984
989
|
const ctx = {
|
|
@@ -1016,6 +1021,10 @@ async function* runTurn(session, prompt, opts = {}) {
|
|
|
1016
1021
|
requestModeSwitch: (modeName) => {
|
|
1017
1022
|
requestedModeSwitch = modeName;
|
|
1018
1023
|
},
|
|
1024
|
+
// Only surface a previous mode that is STILL registered — a transient
|
|
1025
|
+
// mode reverting to an since-unregistered name would throw in the
|
|
1026
|
+
// post-turn setActive and strand the session in the transient mode.
|
|
1027
|
+
...previousModeName && session.modes.has(previousModeName) ? { previousModeName } : {},
|
|
1019
1028
|
emit: (event) => session.log.append(event)
|
|
1020
1029
|
};
|
|
1021
1030
|
const turnStartCtx = { ...appCtx, turnId, iteration: 0 };
|
|
@@ -1918,6 +1927,7 @@ var init_modes = __esm({
|
|
|
1918
1927
|
ModeRegistry = class {
|
|
1919
1928
|
modes = /* @__PURE__ */ new Map();
|
|
1920
1929
|
active = null;
|
|
1930
|
+
previous = null;
|
|
1921
1931
|
changeListeners = /* @__PURE__ */ new Set();
|
|
1922
1932
|
/** Observe active-mode changes — used by the runner to broadcast
|
|
1923
1933
|
* InfoChanged so remote clients track a mode switch (whether it came from
|
|
@@ -1970,6 +1980,15 @@ var init_modes = __esm({
|
|
|
1970
1980
|
getActiveName() {
|
|
1971
1981
|
return this.active;
|
|
1972
1982
|
}
|
|
1983
|
+
/**
|
|
1984
|
+
* Name of the mode that was active before the current one, or null when
|
|
1985
|
+
* there is no history (session boot). Lets a transient mode (goal) revert
|
|
1986
|
+
* to whatever the user was in before arming it — carried onto the
|
|
1987
|
+
* ModeContext as `previousModeName` by run-turn.
|
|
1988
|
+
*/
|
|
1989
|
+
getPreviousActiveName() {
|
|
1990
|
+
return this.previous;
|
|
1991
|
+
}
|
|
1973
1992
|
setActive(name) {
|
|
1974
1993
|
const mode = this.modes.get(name) ?? this.modes.get(migrateModeName(name));
|
|
1975
1994
|
if (!mode)
|
|
@@ -1987,6 +2006,7 @@ var init_modes = __esm({
|
|
|
1987
2006
|
activate(mode) {
|
|
1988
2007
|
if (this.active === mode.name)
|
|
1989
2008
|
return;
|
|
2009
|
+
this.previous = this.active;
|
|
1990
2010
|
this.active = mode.name;
|
|
1991
2011
|
this.notifyChange();
|
|
1992
2012
|
}
|
|
@@ -6116,7 +6136,7 @@ var require_jiti = __commonJS({
|
|
|
6116
6136
|
function V4() {
|
|
6117
6137
|
return 10 !== n3.getToken() ? (k3(3, [], [2, 5]), false) : (P4(false), 6 === n3.getToken() ? (I4(":"), T2(), U4() || k3(4, [], [2, 5])) : k3(5, [], [2, 5]), a3.pop(), true);
|
|
6118
6138
|
}
|
|
6119
|
-
function
|
|
6139
|
+
function z70() {
|
|
6120
6140
|
l3(), T2();
|
|
6121
6141
|
let e6 = false;
|
|
6122
6142
|
for (; 2 !== n3.getToken() && 17 !== n3.getToken(); ) {
|
|
@@ -6143,14 +6163,14 @@ var require_jiti = __commonJS({
|
|
|
6143
6163
|
case 3:
|
|
6144
6164
|
return G3();
|
|
6145
6165
|
case 1:
|
|
6146
|
-
return
|
|
6166
|
+
return z70();
|
|
6147
6167
|
case 10:
|
|
6148
6168
|
return P4(true);
|
|
6149
6169
|
default:
|
|
6150
6170
|
return J3();
|
|
6151
6171
|
}
|
|
6152
6172
|
}
|
|
6153
|
-
return r2(T2, "scanNext"), r2(k3, "handleError"), r2(P4, "parseString"), r2(J3, "parseLiteral"), r2(V4, "parseProperty"), r2(
|
|
6173
|
+
return r2(T2, "scanNext"), r2(k3, "handleError"), r2(P4, "parseString"), r2(J3, "parseLiteral"), r2(V4, "parseProperty"), r2(z70, "parseObject"), r2(G3, "parseArray"), r2(U4, "parseValue"), T2(), 17 === n3.getToken() ? !!i4.allowEmptyContent || (k3(4, [], []), false) : U4() ? (17 !== n3.getToken() && k3(9, [], []), true) : (k3(4, [], []), false);
|
|
6154
6174
|
}
|
|
6155
6175
|
new Array(W3).fill(0).map((e5, t4) => "\n" + " ".repeat(t4)), new Array(W3).fill(0).map((e5, t4) => "\r" + " ".repeat(t4)), new Array(W3).fill(0).map((e5, t4) => "\r\n" + " ".repeat(t4)), new Array(W3).fill(0).map((e5, t4) => "\n" + " ".repeat(t4)), new Array(W3).fill(0).map((e5, t4) => "\r" + " ".repeat(t4)), new Array(W3).fill(0).map((e5, t4) => "\r\n" + " ".repeat(t4)), (function(e5) {
|
|
6156
6176
|
e5.DEFAULT = { allowTrailingComma: false };
|
|
@@ -16923,14 +16943,14 @@ var require_parser = __commonJS({
|
|
|
16923
16943
|
case "scalar":
|
|
16924
16944
|
case "single-quoted-scalar":
|
|
16925
16945
|
case "double-quoted-scalar": {
|
|
16926
|
-
const
|
|
16946
|
+
const fs48 = this.flowScalar(this.type);
|
|
16927
16947
|
if (atNextItem || it4.value) {
|
|
16928
|
-
map2.items.push({ start, key:
|
|
16948
|
+
map2.items.push({ start, key: fs48, sep: [] });
|
|
16929
16949
|
this.onKeyLine = true;
|
|
16930
16950
|
} else if (it4.sep) {
|
|
16931
|
-
this.stack.push(
|
|
16951
|
+
this.stack.push(fs48);
|
|
16932
16952
|
} else {
|
|
16933
|
-
Object.assign(it4, { key:
|
|
16953
|
+
Object.assign(it4, { key: fs48, sep: [] });
|
|
16934
16954
|
this.onKeyLine = true;
|
|
16935
16955
|
}
|
|
16936
16956
|
return;
|
|
@@ -17058,13 +17078,13 @@ var require_parser = __commonJS({
|
|
|
17058
17078
|
case "scalar":
|
|
17059
17079
|
case "single-quoted-scalar":
|
|
17060
17080
|
case "double-quoted-scalar": {
|
|
17061
|
-
const
|
|
17081
|
+
const fs48 = this.flowScalar(this.type);
|
|
17062
17082
|
if (!it4 || it4.value)
|
|
17063
|
-
fc.items.push({ start: [], key:
|
|
17083
|
+
fc.items.push({ start: [], key: fs48, sep: [] });
|
|
17064
17084
|
else if (it4.sep)
|
|
17065
|
-
this.stack.push(
|
|
17085
|
+
this.stack.push(fs48);
|
|
17066
17086
|
else
|
|
17067
|
-
Object.assign(it4, { key:
|
|
17087
|
+
Object.assign(it4, { key: fs48, sep: [] });
|
|
17068
17088
|
return;
|
|
17069
17089
|
}
|
|
17070
17090
|
case "flow-map-end":
|
|
@@ -18534,6 +18554,30 @@ var init_catalog = __esm({
|
|
|
18534
18554
|
installSpec: "@moxxy/plugin-tts-openai",
|
|
18535
18555
|
provides: [{ category: "synthesizer", name: "openai-tts" }]
|
|
18536
18556
|
},
|
|
18557
|
+
{
|
|
18558
|
+
id: "tts-elevenlabs",
|
|
18559
|
+
label: "ElevenLabs read-aloud",
|
|
18560
|
+
description: "Text-to-speech via the ElevenLabs /v1/text-to-speech API (needs ELEVENLABS_API_KEY).",
|
|
18561
|
+
packageName: "@moxxy/plugin-tts-elevenlabs",
|
|
18562
|
+
installSpec: "@moxxy/plugin-tts-elevenlabs",
|
|
18563
|
+
provides: [{ category: "synthesizer", name: "elevenlabs" }]
|
|
18564
|
+
},
|
|
18565
|
+
{
|
|
18566
|
+
id: "tts-local",
|
|
18567
|
+
label: "Local voice (offline TTS)",
|
|
18568
|
+
description: "Fully on-device text-to-speech (English + Polish) via sherpa-onnx Piper voices. No API key; each voice is a one-time ~64 MB verified download.",
|
|
18569
|
+
packageName: "@moxxy/plugin-tts-local",
|
|
18570
|
+
installSpec: "@moxxy/plugin-tts-local",
|
|
18571
|
+
provides: [{ category: "synthesizer", name: "local-piper" }]
|
|
18572
|
+
},
|
|
18573
|
+
{
|
|
18574
|
+
id: "stt-local",
|
|
18575
|
+
label: "Local voice input (offline STT)",
|
|
18576
|
+
description: "Fully on-device speech-to-text via sherpa-onnx multilingual Whisper (English + Polish). No API key; the model is a one-time verified download (base ~198 MB by default; small ~610 MB recommended for Polish).",
|
|
18577
|
+
packageName: "@moxxy/plugin-stt-local",
|
|
18578
|
+
installSpec: "@moxxy/plugin-stt-local",
|
|
18579
|
+
provides: [{ category: "transcriber", name: "local-whisper" }]
|
|
18580
|
+
},
|
|
18537
18581
|
{
|
|
18538
18582
|
id: "provider-admin",
|
|
18539
18583
|
label: "Provider admin tools",
|
|
@@ -29212,25 +29256,25 @@ function kt(e3, t2, r2, o2, n2, a2) {
|
|
|
29212
29256
|
m(e4);
|
|
29213
29257
|
}
|
|
29214
29258
|
function B3() {
|
|
29215
|
-
return v3 = "closed", r2 ? L3() :
|
|
29259
|
+
return v3 = "closed", r2 ? L3() : z70((() => (Ge(t2) && (T2 = rt(t2), R4 = t2._state), T2 || "closed" === R4 ? c(void 0) : "erroring" === R4 || "errored" === R4 ? d(_2) : (T2 = true, l2.close()))), false, void 0), null;
|
|
29216
29260
|
}
|
|
29217
29261
|
function A3(e4) {
|
|
29218
|
-
return w4 || (v3 = "errored", s2 = e4, o2 ? L3(true, e4) :
|
|
29262
|
+
return w4 || (v3 = "errored", s2 = e4, o2 ? L3(true, e4) : z70((() => l2.abort(e4)), true, e4)), null;
|
|
29219
29263
|
}
|
|
29220
29264
|
function j3(e4) {
|
|
29221
|
-
return S3 || (R4 = "errored", _2 = e4, n2 ? L3(true, e4) :
|
|
29265
|
+
return S3 || (R4 = "errored", _2 = e4, n2 ? L3(true, e4) : z70((() => i2.cancel(e4)), true, e4)), null;
|
|
29222
29266
|
}
|
|
29223
29267
|
if (void 0 !== a2 && (k3 = () => {
|
|
29224
29268
|
const e4 = void 0 !== a2.reason ? a2.reason : new Wt("Aborted", "AbortError"), t3 = [];
|
|
29225
|
-
o2 || t3.push((() => "writable" === R4 ? l2.abort(e4) : c(void 0))), n2 || t3.push((() => "readable" === v3 ? i2.cancel(e4) : c(void 0))),
|
|
29269
|
+
o2 || t3.push((() => "writable" === R4 ? l2.abort(e4) : c(void 0))), n2 || t3.push((() => "readable" === v3 ? i2.cancel(e4) : c(void 0))), z70((() => Promise.all(t3.map(((e5) => e5())))), true, e4);
|
|
29226
29270
|
}, a2.aborted ? k3() : a2.addEventListener("abort", k3)), Vt(e3) && (v3 = e3._state, s2 = e3._storedError), Ge(t2) && (R4 = t2._state, _2 = t2._storedError, T2 = rt(t2)), Vt(e3) && Ge(t2) && (q4 = true, g2()), "errored" === v3) A3(s2);
|
|
29227
29271
|
else if ("erroring" === R4 || "errored" === R4) j3(_2);
|
|
29228
29272
|
else if ("closed" === v3) B3();
|
|
29229
29273
|
else if (T2 || "closed" === R4) {
|
|
29230
29274
|
const e4 = new TypeError("the destination writable stream closed before all data could be piped to it");
|
|
29231
|
-
n2 ? L3(true, e4) :
|
|
29275
|
+
n2 ? L3(true, e4) : z70((() => i2.cancel(e4)), true, e4);
|
|
29232
29276
|
}
|
|
29233
|
-
function
|
|
29277
|
+
function z70(e4, t3, r3) {
|
|
29234
29278
|
function o3() {
|
|
29235
29279
|
return "writable" !== R4 || T2 ? n3() : h((function() {
|
|
29236
29280
|
let e5;
|
|
@@ -29245,7 +29289,7 @@ function kt(e3, t2, r2, o2, n2, a2) {
|
|
|
29245
29289
|
w4 || (w4 = true, q4 ? o3() : h(C3, o3));
|
|
29246
29290
|
}
|
|
29247
29291
|
function L3(e4, t3) {
|
|
29248
|
-
|
|
29292
|
+
z70(void 0, e4, t3);
|
|
29249
29293
|
}
|
|
29250
29294
|
function F4(e4, t3) {
|
|
29251
29295
|
return S3 = true, l2.releaseLock(), i2.releaseLock(), void 0 !== a2 && a2.removeEventListener("abort", k3), e4 ? W3(t3) : P4(void 0), null;
|
|
@@ -32026,10 +32070,10 @@ var require_react_production_min = __commonJS({
|
|
|
32026
32070
|
var w4 = /* @__PURE__ */ Symbol.for("react.suspense");
|
|
32027
32071
|
var x4 = /* @__PURE__ */ Symbol.for("react.memo");
|
|
32028
32072
|
var y2 = /* @__PURE__ */ Symbol.for("react.lazy");
|
|
32029
|
-
var
|
|
32073
|
+
var z70 = Symbol.iterator;
|
|
32030
32074
|
function A3(a2) {
|
|
32031
32075
|
if (null === a2 || "object" !== typeof a2) return null;
|
|
32032
|
-
a2 =
|
|
32076
|
+
a2 = z70 && a2[z70] || a2["@@iterator"];
|
|
32033
32077
|
return "function" === typeof a2 ? a2 : null;
|
|
32034
32078
|
}
|
|
32035
32079
|
var B3 = { isMounted: function() {
|
|
@@ -34836,7 +34880,7 @@ var init_yoga_wasm_base64_esm = __esm({
|
|
|
34836
34880
|
h3.noExitRuntime || true;
|
|
34837
34881
|
"object" != typeof WebAssembly && x4("no native wasm support detected");
|
|
34838
34882
|
var fa, ha = false;
|
|
34839
|
-
function
|
|
34883
|
+
function z70(a2, b3, c2) {
|
|
34840
34884
|
c2 = b3 + c2;
|
|
34841
34885
|
for (var d2 = ""; !(b3 >= c2); ) {
|
|
34842
34886
|
var e3 = a2[b3++];
|
|
@@ -35486,7 +35530,7 @@ var init_yoga_wasm_base64_esm = __esm({
|
|
|
35486
35530
|
return b3;
|
|
35487
35531
|
}, Jb = {
|
|
35488
35532
|
l: function(a2, b3, c2, d2) {
|
|
35489
|
-
x4("Assertion failed: " + (a2 ?
|
|
35533
|
+
x4("Assertion failed: " + (a2 ? z70(A3, a2) : "") + ", at: " + [b3 ? b3 ? z70(A3, b3) : "" : "unknown filename", c2, d2 ? d2 ? z70(A3, d2) : "" : "unknown function"]);
|
|
35490
35534
|
},
|
|
35491
35535
|
q: function(a2, b3, c2) {
|
|
35492
35536
|
a2 = N3(a2);
|
|
@@ -35739,7 +35783,7 @@ var init_yoga_wasm_base64_esm = __esm({
|
|
|
35739
35783
|
if (c2) for (var g2 = f3, k3 = 0; k3 <= e3; ++k3) {
|
|
35740
35784
|
var m3 = f3 + k3;
|
|
35741
35785
|
if (k3 == e3 || 0 == A3[m3]) {
|
|
35742
|
-
g2 = g2 ?
|
|
35786
|
+
g2 = g2 ? z70(A3, g2, m3 - g2) : "";
|
|
35743
35787
|
if (void 0 === l2) var l2 = g2;
|
|
35744
35788
|
else l2 += String.fromCharCode(0), l2 += g2;
|
|
35745
35789
|
g2 = m3 + 1;
|
|
@@ -35936,7 +35980,7 @@ var init_yoga_wasm_base64_esm = __esm({
|
|
|
35936
35980
|
b3 += 8;
|
|
35937
35981
|
for (var m3 = 0; m3 < k3; m3++) {
|
|
35938
35982
|
var l2 = A3[g2 + m3], n2 = Fb[a2];
|
|
35939
|
-
0 === l2 || 10 === l2 ? ((1 === a2 ? ea : v3)(
|
|
35983
|
+
0 === l2 || 10 === l2 ? ((1 === a2 ? ea : v3)(z70(n2, 0)), n2.length = 0) : n2.push(l2);
|
|
35940
35984
|
}
|
|
35941
35985
|
e3 += k3;
|
|
35942
35986
|
}
|
|
@@ -36424,7 +36468,7 @@ var require_scheduler_production_min = __commonJS({
|
|
|
36424
36468
|
var u2 = 1;
|
|
36425
36469
|
var v3 = null;
|
|
36426
36470
|
var y2 = 3;
|
|
36427
|
-
var
|
|
36471
|
+
var z70 = false;
|
|
36428
36472
|
var A3 = false;
|
|
36429
36473
|
var B3 = false;
|
|
36430
36474
|
var D3 = "function" === typeof setTimeout ? setTimeout : null;
|
|
@@ -36451,7 +36495,7 @@ var require_scheduler_production_min = __commonJS({
|
|
|
36451
36495
|
function J3(a2, b3) {
|
|
36452
36496
|
A3 = false;
|
|
36453
36497
|
B3 && (B3 = false, E3(L3), L3 = -1);
|
|
36454
|
-
|
|
36498
|
+
z70 = true;
|
|
36455
36499
|
var c2 = y2;
|
|
36456
36500
|
try {
|
|
36457
36501
|
G3(b3);
|
|
@@ -36475,7 +36519,7 @@ var require_scheduler_production_min = __commonJS({
|
|
|
36475
36519
|
}
|
|
36476
36520
|
return w4;
|
|
36477
36521
|
} finally {
|
|
36478
|
-
v3 = null, y2 = c2,
|
|
36522
|
+
v3 = null, y2 = c2, z70 = false;
|
|
36479
36523
|
}
|
|
36480
36524
|
}
|
|
36481
36525
|
var N3 = false;
|
|
@@ -36532,7 +36576,7 @@ var require_scheduler_production_min = __commonJS({
|
|
|
36532
36576
|
a2.callback = null;
|
|
36533
36577
|
};
|
|
36534
36578
|
exports.unstable_continueExecution = function() {
|
|
36535
|
-
A3 ||
|
|
36579
|
+
A3 || z70 || (A3 = true, I3(J3));
|
|
36536
36580
|
};
|
|
36537
36581
|
exports.unstable_forceFrameRate = function(a2) {
|
|
36538
36582
|
0 > a2 || 125 < a2 ? console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported") : P4 = 0 < a2 ? Math.floor(1e3 / a2) : 5;
|
|
@@ -36605,7 +36649,7 @@ var require_scheduler_production_min = __commonJS({
|
|
|
36605
36649
|
}
|
|
36606
36650
|
e3 = c2 + e3;
|
|
36607
36651
|
a2 = { id: u2++, callback: b3, priorityLevel: a2, startTime: c2, expirationTime: e3, sortIndex: -1 };
|
|
36608
|
-
c2 > d2 ? (a2.sortIndex = c2, f3(t2, a2), null === h3(r2) && a2 === h3(t2) && (B3 ? (E3(L3), L3 = -1) : B3 = true, K4(H4, c2 - d2))) : (a2.sortIndex = e3, f3(r2, a2), A3 ||
|
|
36652
|
+
c2 > d2 ? (a2.sortIndex = c2, f3(t2, a2), null === h3(r2) && a2 === h3(t2) && (B3 ? (E3(L3), L3 = -1) : B3 = true, K4(H4, c2 - d2))) : (a2.sortIndex = e3, f3(r2, a2), A3 || z70 || (A3 = true, I3(J3)));
|
|
36609
36653
|
return a2;
|
|
36610
36654
|
};
|
|
36611
36655
|
exports.unstable_shouldYield = M2;
|
|
@@ -37362,7 +37406,7 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
37362
37406
|
gc[hc] = a2.current;
|
|
37363
37407
|
a2.current = b3;
|
|
37364
37408
|
}
|
|
37365
|
-
var jc = {}, x4 = ic(jc),
|
|
37409
|
+
var jc = {}, x4 = ic(jc), z70 = ic(false), kc = jc;
|
|
37366
37410
|
function mc(a2, b3) {
|
|
37367
37411
|
var c2 = a2.type.contextTypes;
|
|
37368
37412
|
if (!c2) return jc;
|
|
@@ -37378,13 +37422,13 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
37378
37422
|
return null !== a2 && void 0 !== a2;
|
|
37379
37423
|
}
|
|
37380
37424
|
function nc() {
|
|
37381
|
-
q4(
|
|
37425
|
+
q4(z70);
|
|
37382
37426
|
q4(x4);
|
|
37383
37427
|
}
|
|
37384
37428
|
function oc(a2, b3, c2) {
|
|
37385
37429
|
if (x4.current !== jc) throw Error(n2(168));
|
|
37386
37430
|
v3(x4, b3);
|
|
37387
|
-
v3(
|
|
37431
|
+
v3(z70, c2);
|
|
37388
37432
|
}
|
|
37389
37433
|
function pc(a2, b3, c2) {
|
|
37390
37434
|
var d2 = a2.stateNode;
|
|
@@ -37398,14 +37442,14 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
37398
37442
|
a2 = (a2 = a2.stateNode) && a2.__reactInternalMemoizedMergedChildContext || jc;
|
|
37399
37443
|
kc = x4.current;
|
|
37400
37444
|
v3(x4, a2);
|
|
37401
|
-
v3(
|
|
37445
|
+
v3(z70, z70.current);
|
|
37402
37446
|
return true;
|
|
37403
37447
|
}
|
|
37404
37448
|
function rc(a2, b3, c2) {
|
|
37405
37449
|
var d2 = a2.stateNode;
|
|
37406
37450
|
if (!d2) throw Error(n2(169));
|
|
37407
|
-
c2 ? (a2 = pc(a2, b3, kc), d2.__reactInternalMemoizedMergedChildContext = a2, q4(
|
|
37408
|
-
v3(
|
|
37451
|
+
c2 ? (a2 = pc(a2, b3, kc), d2.__reactInternalMemoizedMergedChildContext = a2, q4(z70), q4(x4), v3(x4, a2)) : q4(z70);
|
|
37452
|
+
v3(z70, c2);
|
|
37409
37453
|
}
|
|
37410
37454
|
var tc = Math.clz32 ? Math.clz32 : sc, uc = Math.log, vc = Math.LN2;
|
|
37411
37455
|
function sc(a2) {
|
|
@@ -39003,7 +39047,7 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
39003
39047
|
g2.state = p3;
|
|
39004
39048
|
ke2(b3, d2, g2, e3);
|
|
39005
39049
|
k3 = b3.memoizedState;
|
|
39006
|
-
h3 !== d2 || p3 !== k3 ||
|
|
39050
|
+
h3 !== d2 || p3 !== k3 || z70.current || de3 ? ("function" === typeof m3 && (yf(b3, c2, m3, d2), k3 = b3.memoizedState), (h3 = de3 || Af(b3, c2, h3, d2, p3, k3, l2)) ? (r2 || "function" !== typeof g2.UNSAFE_componentWillMount && "function" !== typeof g2.componentWillMount || ("function" === typeof g2.componentWillMount && g2.componentWillMount(), "function" === typeof g2.UNSAFE_componentWillMount && g2.UNSAFE_componentWillMount()), "function" === typeof g2.componentDidMount && (b3.flags |= 4194308)) : ("function" === typeof g2.componentDidMount && (b3.flags |= 4194308), b3.memoizedProps = d2, b3.memoizedState = k3), g2.props = d2, g2.state = k3, g2.context = l2, d2 = h3) : ("function" === typeof g2.componentDidMount && (b3.flags |= 4194308), d2 = false);
|
|
39007
39051
|
} else {
|
|
39008
39052
|
g2 = b3.stateNode;
|
|
39009
39053
|
fe3(a2, b3);
|
|
@@ -39021,7 +39065,7 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
39021
39065
|
g2.state = p3;
|
|
39022
39066
|
ke2(b3, d2, g2, e3);
|
|
39023
39067
|
var w4 = b3.memoizedState;
|
|
39024
|
-
h3 !== r2 || p3 !== w4 ||
|
|
39068
|
+
h3 !== r2 || p3 !== w4 || z70.current || de3 ? ("function" === typeof B3 && (yf(b3, c2, B3, d2), w4 = b3.memoizedState), (l2 = de3 || Af(b3, c2, l2, d2, p3, w4, k3) || false) ? (m3 || "function" !== typeof g2.UNSAFE_componentWillUpdate && "function" !== typeof g2.componentWillUpdate || ("function" === typeof g2.componentWillUpdate && g2.componentWillUpdate(d2, w4, k3), "function" === typeof g2.UNSAFE_componentWillUpdate && g2.UNSAFE_componentWillUpdate(d2, w4, k3)), "function" === typeof g2.componentDidUpdate && (b3.flags |= 4), "function" === typeof g2.getSnapshotBeforeUpdate && (b3.flags |= 1024)) : ("function" !== typeof g2.componentDidUpdate || h3 === a2.memoizedProps && p3 === a2.memoizedState || (b3.flags |= 4), "function" !== typeof g2.getSnapshotBeforeUpdate || h3 === a2.memoizedProps && p3 === a2.memoizedState || (b3.flags |= 1024), b3.memoizedProps = d2, b3.memoizedState = w4), g2.props = d2, g2.state = w4, g2.context = k3, d2 = l2) : ("function" !== typeof g2.componentDidUpdate || h3 === a2.memoizedProps && p3 === a2.memoizedState || (b3.flags |= 4), "function" !== typeof g2.getSnapshotBeforeUpdate || h3 === a2.memoizedProps && p3 === a2.memoizedState || (b3.flags |= 1024), d2 = false);
|
|
39025
39069
|
}
|
|
39026
39070
|
return dg(a2, b3, c2, d2, f3, e3);
|
|
39027
39071
|
}
|
|
@@ -39490,7 +39534,7 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
39490
39534
|
case 3:
|
|
39491
39535
|
c2 = b3.stateNode;
|
|
39492
39536
|
te3();
|
|
39493
|
-
q4(
|
|
39537
|
+
q4(z70);
|
|
39494
39538
|
q4(x4);
|
|
39495
39539
|
ye3();
|
|
39496
39540
|
c2.pendingContext && (c2.context = c2.pendingContext, c2.pendingContext = null);
|
|
@@ -39633,7 +39677,7 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
39633
39677
|
case 1:
|
|
39634
39678
|
return A3(b3.type) && nc(), a2 = b3.flags, a2 & 65536 ? (b3.flags = a2 & -65537 | 128, b3) : null;
|
|
39635
39679
|
case 3:
|
|
39636
|
-
return te3(), q4(
|
|
39680
|
+
return te3(), q4(z70), q4(x4), ye3(), a2 = b3.flags, 0 !== (a2 & 65536) && 0 === (a2 & 128) ? (b3.flags = a2 & -65537 | 128, b3) : null;
|
|
39637
39681
|
case 5:
|
|
39638
39682
|
return ve3(b3), null;
|
|
39639
39683
|
case 13:
|
|
@@ -40688,7 +40732,7 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
40688
40732
|
break;
|
|
40689
40733
|
case 3:
|
|
40690
40734
|
te3();
|
|
40691
|
-
q4(
|
|
40735
|
+
q4(z70);
|
|
40692
40736
|
q4(x4);
|
|
40693
40737
|
ye3();
|
|
40694
40738
|
break;
|
|
@@ -41165,7 +41209,7 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
41165
41209
|
}
|
|
41166
41210
|
var ai;
|
|
41167
41211
|
ai = function(a2, b3, c2) {
|
|
41168
|
-
if (null !== a2) if (a2.memoizedProps !== b3.pendingProps ||
|
|
41212
|
+
if (null !== a2) if (a2.memoizedProps !== b3.pendingProps || z70.current) G3 = true;
|
|
41169
41213
|
else {
|
|
41170
41214
|
if (0 === (a2.lanes & c2) && 0 === (b3.flags & 128)) return G3 = false, sg(a2, b3, c2);
|
|
41171
41215
|
G3 = 0 !== (a2.flags & 131072) ? true : false;
|
|
@@ -41274,7 +41318,7 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
41274
41318
|
g2 = e3.value;
|
|
41275
41319
|
Vd(b3, d2, g2);
|
|
41276
41320
|
if (null !== f3) if (Vc(f3.value, g2)) {
|
|
41277
|
-
if (f3.children === e3.children && !
|
|
41321
|
+
if (f3.children === e3.children && !z70.current) {
|
|
41278
41322
|
b3 = Tf(a2, b3, c2);
|
|
41279
41323
|
break a;
|
|
41280
41324
|
}
|
|
@@ -64082,6 +64126,10 @@ function stepFold(s2, e3) {
|
|
|
64082
64126
|
s2.callTargets.clear();
|
|
64083
64127
|
};
|
|
64084
64128
|
if (e3.type === "user_prompt") {
|
|
64129
|
+
if (e3.origin?.kind === "checkpoint") {
|
|
64130
|
+
pushBlock({ kind: "event", id: e3.id, event: e3 });
|
|
64131
|
+
return;
|
|
64132
|
+
}
|
|
64085
64133
|
closeOpenScope();
|
|
64086
64134
|
markOrphansAtTurnBoundary();
|
|
64087
64135
|
s2.pendingLoadSkillCallId = null;
|
|
@@ -76375,12 +76423,12 @@ var require_dist2 = __commonJS({
|
|
|
76375
76423
|
throw new Error(`Unknown format "${name}"`);
|
|
76376
76424
|
return f3;
|
|
76377
76425
|
};
|
|
76378
|
-
function addFormats(ajv, list,
|
|
76426
|
+
function addFormats(ajv, list, fs48, exportName) {
|
|
76379
76427
|
var _a3;
|
|
76380
76428
|
var _b;
|
|
76381
76429
|
(_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
76382
76430
|
for (const f3 of list)
|
|
76383
|
-
ajv.addFormat(f3,
|
|
76431
|
+
ajv.addFormat(f3, fs48[f3]);
|
|
76384
76432
|
}
|
|
76385
76433
|
module.exports = exports = formatsPlugin;
|
|
76386
76434
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -77185,7 +77233,7 @@ var require_windows = __commonJS({
|
|
|
77185
77233
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module) {
|
|
77186
77234
|
module.exports = isexe;
|
|
77187
77235
|
isexe.sync = sync;
|
|
77188
|
-
var
|
|
77236
|
+
var fs48 = __require("fs");
|
|
77189
77237
|
function checkPathExt(path61, options) {
|
|
77190
77238
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
77191
77239
|
if (!pathext) {
|
|
@@ -77210,12 +77258,12 @@ var require_windows = __commonJS({
|
|
|
77210
77258
|
return checkPathExt(path61, options);
|
|
77211
77259
|
}
|
|
77212
77260
|
function isexe(path61, options, cb) {
|
|
77213
|
-
|
|
77261
|
+
fs48.stat(path61, function(er2, stat3) {
|
|
77214
77262
|
cb(er2, er2 ? false : checkStat(stat3, path61, options));
|
|
77215
77263
|
});
|
|
77216
77264
|
}
|
|
77217
77265
|
function sync(path61, options) {
|
|
77218
|
-
return checkStat(
|
|
77266
|
+
return checkStat(fs48.statSync(path61), path61, options);
|
|
77219
77267
|
}
|
|
77220
77268
|
}
|
|
77221
77269
|
});
|
|
@@ -77225,14 +77273,14 @@ var require_mode = __commonJS({
|
|
|
77225
77273
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports, module) {
|
|
77226
77274
|
module.exports = isexe;
|
|
77227
77275
|
isexe.sync = sync;
|
|
77228
|
-
var
|
|
77276
|
+
var fs48 = __require("fs");
|
|
77229
77277
|
function isexe(path61, options, cb) {
|
|
77230
|
-
|
|
77278
|
+
fs48.stat(path61, function(er2, stat3) {
|
|
77231
77279
|
cb(er2, er2 ? false : checkStat(stat3, options));
|
|
77232
77280
|
});
|
|
77233
77281
|
}
|
|
77234
77282
|
function sync(path61, options) {
|
|
77235
|
-
return checkStat(
|
|
77283
|
+
return checkStat(fs48.statSync(path61), options);
|
|
77236
77284
|
}
|
|
77237
77285
|
function checkStat(stat3, options) {
|
|
77238
77286
|
return stat3.isFile() && checkMode(stat3, options);
|
|
@@ -77514,16 +77562,16 @@ var require_shebang_command = __commonJS({
|
|
|
77514
77562
|
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
|
|
77515
77563
|
var require_readShebang = __commonJS({
|
|
77516
77564
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
|
|
77517
|
-
var
|
|
77565
|
+
var fs48 = __require("fs");
|
|
77518
77566
|
var shebangCommand = require_shebang_command();
|
|
77519
77567
|
function readShebang(command) {
|
|
77520
77568
|
const size = 150;
|
|
77521
77569
|
const buffer = Buffer.alloc(size);
|
|
77522
77570
|
let fd;
|
|
77523
77571
|
try {
|
|
77524
|
-
fd =
|
|
77525
|
-
|
|
77526
|
-
|
|
77572
|
+
fd = fs48.openSync(command, "r");
|
|
77573
|
+
fs48.readSync(fd, buffer, 0, size, 0);
|
|
77574
|
+
fs48.closeSync(fd);
|
|
77527
77575
|
} catch (e3) {
|
|
77528
77576
|
}
|
|
77529
77577
|
return shebangCommand(buffer.toString());
|
|
@@ -81264,13 +81312,11 @@ function startGoal(deps, arg) {
|
|
|
81264
81312
|
}
|
|
81265
81313
|
try {
|
|
81266
81314
|
deps.session.modes.setActive(GOAL_MODE);
|
|
81267
|
-
void setCategoryDefault("mode", GOAL_MODE).catch(() => void 0);
|
|
81268
81315
|
} catch (err) {
|
|
81269
81316
|
deps.setSystemNotice(`failed to switch to goal mode: ${err instanceof Error ? err.message : String(err)}`);
|
|
81270
81317
|
return;
|
|
81271
81318
|
}
|
|
81272
|
-
deps.
|
|
81273
|
-
deps.setSystemNotice(objective ? "\u{1F3AF} goal mode \u2014 tools auto-approved; working until the objective is delivered. Press Esc to stop." : "\u{1F3AF} goal mode on \u2014 tools auto-approved. Send your objective as the next message (Esc stops).");
|
|
81319
|
+
deps.setSystemNotice(objective ? "\u{1F3AF} goal run \u2014 tools auto-approved until the objective is delivered, then back to normal chat. Press Esc to stop." : "\u{1F3AF} goal mode armed \u2014 tools auto-approved for the run. Send your objective as the next message (Esc stops).");
|
|
81274
81320
|
if (objective)
|
|
81275
81321
|
deps.submitPrompt(objective);
|
|
81276
81322
|
}
|
|
@@ -81308,7 +81354,8 @@ function openModePicker(deps, arg = "") {
|
|
|
81308
81354
|
try {
|
|
81309
81355
|
deps.session.modes.setActive(match.name);
|
|
81310
81356
|
deps.setSystemNotice(`mode \u2192 ${match.name}`);
|
|
81311
|
-
|
|
81357
|
+
if (!match.transient)
|
|
81358
|
+
void setCategoryDefault("mode", match.name).catch(() => void 0);
|
|
81312
81359
|
} catch (err) {
|
|
81313
81360
|
deps.setSystemNotice(`failed to switch mode: ${err instanceof Error ? err.message : String(err)}`);
|
|
81314
81361
|
}
|
|
@@ -81672,6 +81719,10 @@ function handlePluginAction(id, deps) {
|
|
|
81672
81719
|
const split2 = name.indexOf("::");
|
|
81673
81720
|
const category = split2 >= 0 ? name.slice(0, split2) : name;
|
|
81674
81721
|
const contribution = split2 >= 0 ? name.slice(split2 + 2) : "";
|
|
81722
|
+
if (category === "mode" && deps.session.modes.list().find((m3) => m3.name === contribution)?.transient) {
|
|
81723
|
+
deps.setSystemNotice(`"${contribution}" is a transient mode (armed per objective) and can't be the standing default`);
|
|
81724
|
+
return;
|
|
81725
|
+
}
|
|
81675
81726
|
void (async () => {
|
|
81676
81727
|
try {
|
|
81677
81728
|
await admin.setCategoryDefault(category, contribution);
|
|
@@ -81824,7 +81875,9 @@ function handleModeSelected(id, deps) {
|
|
|
81824
81875
|
try {
|
|
81825
81876
|
deps.session.modes.setActive(id);
|
|
81826
81877
|
deps.setSystemNotice(`mode \u2192 ${id}`);
|
|
81827
|
-
|
|
81878
|
+
const def = deps.session.modes.list().find((m3) => m3.name === id);
|
|
81879
|
+
if (!def?.transient)
|
|
81880
|
+
void setCategoryDefault("mode", id).catch(() => void 0);
|
|
81828
81881
|
} catch (err) {
|
|
81829
81882
|
deps.setSystemNotice(`failed to switch mode: ${err instanceof Error ? err.message : String(err)}`);
|
|
81830
81883
|
}
|
|
@@ -88463,7 +88516,7 @@ var require_utils4 = __commonJS({
|
|
|
88463
88516
|
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/png.js
|
|
88464
88517
|
var require_png2 = __commonJS({
|
|
88465
88518
|
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/png.js"(exports) {
|
|
88466
|
-
var
|
|
88519
|
+
var fs48 = __require("fs");
|
|
88467
88520
|
var PNG = require_png().PNG;
|
|
88468
88521
|
var Utils = require_utils4();
|
|
88469
88522
|
exports.render = function render2(qrData, options) {
|
|
@@ -88515,7 +88568,7 @@ var require_png2 = __commonJS({
|
|
|
88515
88568
|
called = true;
|
|
88516
88569
|
cb.apply(null, args);
|
|
88517
88570
|
};
|
|
88518
|
-
const stream =
|
|
88571
|
+
const stream = fs48.createWriteStream(path61);
|
|
88519
88572
|
stream.on("error", done);
|
|
88520
88573
|
stream.on("close", done);
|
|
88521
88574
|
exports.renderToFileStream(stream, qrData, options);
|
|
@@ -88582,9 +88635,9 @@ var require_utf8 = __commonJS({
|
|
|
88582
88635
|
cb = options;
|
|
88583
88636
|
options = void 0;
|
|
88584
88637
|
}
|
|
88585
|
-
const
|
|
88638
|
+
const fs48 = __require("fs");
|
|
88586
88639
|
const utf82 = exports.render(qrData, options);
|
|
88587
|
-
|
|
88640
|
+
fs48.writeFile(path61, utf82, cb);
|
|
88588
88641
|
};
|
|
88589
88642
|
}
|
|
88590
88643
|
});
|
|
@@ -88758,10 +88811,10 @@ var require_svg = __commonJS({
|
|
|
88758
88811
|
cb = options;
|
|
88759
88812
|
options = void 0;
|
|
88760
88813
|
}
|
|
88761
|
-
const
|
|
88814
|
+
const fs48 = __require("fs");
|
|
88762
88815
|
const svgTag = exports.render(qrData, options);
|
|
88763
88816
|
const xmlStr = '<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">' + svgTag;
|
|
88764
|
-
|
|
88817
|
+
fs48.writeFile(path61, xmlStr, cb);
|
|
88765
88818
|
};
|
|
88766
88819
|
}
|
|
88767
88820
|
});
|
|
@@ -111303,189 +111356,8 @@ var builtinToolsPlugin = definePlugin({
|
|
|
111303
111356
|
tools: [...builtinTools]
|
|
111304
111357
|
});
|
|
111305
111358
|
var DEFAULT_MODE_NAME = "default";
|
|
111306
|
-
|
|
111307
|
-
|
|
111308
|
-
var RETRY_BACKOFF_CAP_MS = 3e4;
|
|
111309
|
-
var sleepImpl2 = (ms, signal) => sleepWithAbort(ms, signal);
|
|
111310
|
-
async function* runDefaultMode(ctx) {
|
|
111311
|
-
const requestedMaxIterations = ctx.maxIterations;
|
|
111312
|
-
const maxIterations = typeof requestedMaxIterations === "number" && Number.isFinite(requestedMaxIterations) ? Math.max(1, Math.floor(requestedMaxIterations)) : 500;
|
|
111313
|
-
const detector = createStuckLoopDetector(ctx.loopGuard);
|
|
111314
|
-
const MAX_REACTIVE_COMPACTIONS2 = 2;
|
|
111315
|
-
let reactiveCompactions = 0;
|
|
111316
|
-
let consecutiveRetries = 0;
|
|
111317
|
-
for (let iteration = 1; iteration <= maxIterations; iteration++) {
|
|
111318
|
-
if (ctx.signal.aborted) {
|
|
111319
|
-
yield await ctx.emit({
|
|
111320
|
-
type: "abort",
|
|
111321
|
-
sessionId: ctx.sessionId,
|
|
111322
|
-
turnId: ctx.turnId,
|
|
111323
|
-
source: "system",
|
|
111324
|
-
reason: "signal aborted"
|
|
111325
|
-
});
|
|
111326
|
-
return;
|
|
111327
|
-
}
|
|
111328
|
-
yield await ctx.emit({
|
|
111329
|
-
type: "mode_iteration",
|
|
111330
|
-
sessionId: ctx.sessionId,
|
|
111331
|
-
turnId: ctx.turnId,
|
|
111332
|
-
source: "system",
|
|
111333
|
-
strategy: DEFAULT_MODE_NAME,
|
|
111334
|
-
iteration
|
|
111335
|
-
});
|
|
111336
|
-
await runCompactionIfNeeded(ctx);
|
|
111337
|
-
await runElisionIfNeeded(ctx);
|
|
111338
|
-
const { messages, stablePrefixIndex } = buildMessages(ctx);
|
|
111339
|
-
yield await ctx.emit({
|
|
111340
|
-
type: "provider_request",
|
|
111341
|
-
sessionId: ctx.sessionId,
|
|
111342
|
-
turnId: ctx.turnId,
|
|
111343
|
-
source: "system",
|
|
111344
|
-
provider: ctx.provider.name,
|
|
111345
|
-
model: ctx.model
|
|
111346
|
-
});
|
|
111347
|
-
const { text, toolUses, stopReason, error: error2, usage, reasoning } = await collectProviderStream(ctx, messages, {
|
|
111348
|
-
iteration,
|
|
111349
|
-
stablePrefixIndex
|
|
111350
|
-
});
|
|
111351
|
-
if (ctx.signal.aborted) {
|
|
111352
|
-
yield await ctx.emit({
|
|
111353
|
-
type: "abort",
|
|
111354
|
-
sessionId: ctx.sessionId,
|
|
111355
|
-
turnId: ctx.turnId,
|
|
111356
|
-
source: "system",
|
|
111357
|
-
reason: "signal aborted during provider stream"
|
|
111358
|
-
});
|
|
111359
|
-
return;
|
|
111360
|
-
}
|
|
111361
|
-
yield await ctx.emit({
|
|
111362
|
-
type: "provider_response",
|
|
111363
|
-
sessionId: ctx.sessionId,
|
|
111364
|
-
turnId: ctx.turnId,
|
|
111365
|
-
source: "system",
|
|
111366
|
-
provider: ctx.provider.name,
|
|
111367
|
-
model: ctx.model,
|
|
111368
|
-
...usageEventFields(usage)
|
|
111369
|
-
});
|
|
111370
|
-
if (error2) {
|
|
111371
|
-
if (isContextOverflowError(error2.message) && reactiveCompactions < MAX_REACTIVE_COMPACTIONS2) {
|
|
111372
|
-
const compacted = await runCompactionIfNeeded(ctx, { force: true });
|
|
111373
|
-
if (compacted) {
|
|
111374
|
-
reactiveCompactions += 1;
|
|
111375
|
-
yield await ctx.emit({
|
|
111376
|
-
type: "error",
|
|
111377
|
-
sessionId: ctx.sessionId,
|
|
111378
|
-
turnId: ctx.turnId,
|
|
111379
|
-
source: "system",
|
|
111380
|
-
kind: "retryable",
|
|
111381
|
-
message: "context window exceeded \u2014 compacted older turns, retrying"
|
|
111382
|
-
});
|
|
111383
|
-
continue;
|
|
111384
|
-
}
|
|
111385
|
-
}
|
|
111386
|
-
if (!error2.retryable) {
|
|
111387
|
-
yield await ctx.emit({
|
|
111388
|
-
type: "error",
|
|
111389
|
-
sessionId: ctx.sessionId,
|
|
111390
|
-
turnId: ctx.turnId,
|
|
111391
|
-
source: "system",
|
|
111392
|
-
kind: "fatal",
|
|
111393
|
-
message: error2.message
|
|
111394
|
-
});
|
|
111395
|
-
return;
|
|
111396
|
-
}
|
|
111397
|
-
consecutiveRetries += 1;
|
|
111398
|
-
yield await ctx.emit({
|
|
111399
|
-
type: "error",
|
|
111400
|
-
sessionId: ctx.sessionId,
|
|
111401
|
-
turnId: ctx.turnId,
|
|
111402
|
-
source: "system",
|
|
111403
|
-
kind: "retryable",
|
|
111404
|
-
message: error2.message
|
|
111405
|
-
});
|
|
111406
|
-
if (consecutiveRetries >= MAX_CONSECUTIVE_RETRIES) {
|
|
111407
|
-
yield await ctx.emit({
|
|
111408
|
-
type: "error",
|
|
111409
|
-
sessionId: ctx.sessionId,
|
|
111410
|
-
turnId: ctx.turnId,
|
|
111411
|
-
source: "system",
|
|
111412
|
-
kind: "fatal",
|
|
111413
|
-
message: `provider kept returning a retryable error ${consecutiveRetries} times in a row (last: ${error2.message}); giving up rather than hammering the provider.`
|
|
111414
|
-
});
|
|
111415
|
-
return;
|
|
111416
|
-
}
|
|
111417
|
-
await sleepImpl2(nextBackoffMs(consecutiveRetries, RETRY_BACKOFF_BASE_MS, RETRY_BACKOFF_CAP_MS), ctx.signal);
|
|
111418
|
-
if (ctx.signal.aborted) {
|
|
111419
|
-
yield await ctx.emit({
|
|
111420
|
-
type: "abort",
|
|
111421
|
-
sessionId: ctx.sessionId,
|
|
111422
|
-
turnId: ctx.turnId,
|
|
111423
|
-
source: "system",
|
|
111424
|
-
reason: "signal aborted during retry back-off"
|
|
111425
|
-
});
|
|
111426
|
-
return;
|
|
111427
|
-
}
|
|
111428
|
-
continue;
|
|
111429
|
-
}
|
|
111430
|
-
reactiveCompactions = 0;
|
|
111431
|
-
consecutiveRetries = 0;
|
|
111432
|
-
if (reasoning) {
|
|
111433
|
-
yield await ctx.emit({
|
|
111434
|
-
type: "reasoning_message",
|
|
111435
|
-
sessionId: ctx.sessionId,
|
|
111436
|
-
turnId: ctx.turnId,
|
|
111437
|
-
source: "model",
|
|
111438
|
-
content: reasoning.text,
|
|
111439
|
-
...reasoning.signature ? { signature: reasoning.signature } : {},
|
|
111440
|
-
...reasoning.redacted ? { redacted: true } : {},
|
|
111441
|
-
...reasoning.encrypted ? { encrypted: reasoning.encrypted } : {}
|
|
111442
|
-
});
|
|
111443
|
-
}
|
|
111444
|
-
const stuck = yield* emitRequestsAndDetectStuck(ctx, toolUses, detector, {
|
|
111445
|
-
abortedResultMessage: "default mode loop aborted (stuck pattern) before this call ran",
|
|
111446
|
-
nearHint: "against the same target (only volatile args like maxBytes varied)",
|
|
111447
|
-
fatalMessage: ({ toolName, count, how }) => `default mode loop aborted \u2014 detected stuck pattern: tool "${toolName}" called ${count} times ${how}. The model is likely looping on the same call; reset or rephrase.`
|
|
111448
|
-
});
|
|
111449
|
-
if (stuck)
|
|
111450
|
-
return;
|
|
111451
|
-
if (text || stopReason === "end_turn" || toolUses.length === 0) {
|
|
111452
|
-
if (!text && toolUses.length === 0 && stopReason !== "end_turn") {
|
|
111453
|
-
yield await ctx.emit({
|
|
111454
|
-
type: "error",
|
|
111455
|
-
sessionId: ctx.sessionId,
|
|
111456
|
-
turnId: ctx.turnId,
|
|
111457
|
-
source: "system",
|
|
111458
|
-
kind: "retryable",
|
|
111459
|
-
message: `provider returned an empty completion (stopReason: ${stopReason ?? "unknown"})`
|
|
111460
|
-
});
|
|
111461
|
-
}
|
|
111462
|
-
yield await ctx.emit({
|
|
111463
|
-
type: "assistant_message",
|
|
111464
|
-
sessionId: ctx.sessionId,
|
|
111465
|
-
turnId: ctx.turnId,
|
|
111466
|
-
source: "model",
|
|
111467
|
-
content: text,
|
|
111468
|
-
stopReason
|
|
111469
|
-
});
|
|
111470
|
-
}
|
|
111471
|
-
if (toolUses.length === 0)
|
|
111472
|
-
return;
|
|
111473
|
-
const exited = yield* executeToolUses(ctx, toolUses, iteration);
|
|
111474
|
-
if (exited)
|
|
111475
|
-
return;
|
|
111476
|
-
}
|
|
111477
|
-
yield await ctx.emit({
|
|
111478
|
-
type: "error",
|
|
111479
|
-
sessionId: ctx.sessionId,
|
|
111480
|
-
turnId: ctx.turnId,
|
|
111481
|
-
source: "system",
|
|
111482
|
-
kind: "fatal",
|
|
111483
|
-
message: `default mode loop exceeded maxIterations (${maxIterations})`
|
|
111484
|
-
});
|
|
111485
|
-
}
|
|
111486
|
-
function buildMessages(ctx) {
|
|
111487
|
-
const systemPrompt = buildSystemPromptWithSkills(ctx.systemPrompt, ctx.skills.list());
|
|
111488
|
-
return projectMessages(ctx, { ...systemPrompt ? { systemPrompt } : {} });
|
|
111359
|
+
function runDefaultMode(ctx) {
|
|
111360
|
+
return runReactLoop(ctx, { strategyName: DEFAULT_MODE_NAME });
|
|
111489
111361
|
}
|
|
111490
111362
|
|
|
111491
111363
|
// ../mode-default/dist/index.js
|
|
@@ -113663,8 +113535,8 @@ function parsePids(out) {
|
|
|
113663
113535
|
}
|
|
113664
113536
|
async function unlinkSocket(socketPath) {
|
|
113665
113537
|
try {
|
|
113666
|
-
const
|
|
113667
|
-
|
|
113538
|
+
const fs48 = await import('fs');
|
|
113539
|
+
fs48.unlinkSync(socketPath);
|
|
113668
113540
|
} catch {
|
|
113669
113541
|
}
|
|
113670
113542
|
}
|
|
@@ -116228,7 +116100,6 @@ function peerMaxIterationsFromEnv() {
|
|
|
116228
116100
|
}
|
|
116229
116101
|
var MAX_NOOP_ITERATIONS = 3;
|
|
116230
116102
|
var PAUSE_POLL_MS = 1e3;
|
|
116231
|
-
var MAX_REACTIVE_COMPACTIONS = 2;
|
|
116232
116103
|
async function* runCollabAgentLoop(ctx, opts) {
|
|
116233
116104
|
if (ctx.signal.aborted) {
|
|
116234
116105
|
yield await ctx.emit(abort(ctx, "aborted before collaborative agent start"));
|
|
@@ -116252,172 +116123,86 @@ async function* runCollabAgentLoop(ctx, opts) {
|
|
|
116252
116123
|
const hub = await getProcessHubClient();
|
|
116253
116124
|
if (hub)
|
|
116254
116125
|
await hub.setStatus("working").catch(() => void 0);
|
|
116255
|
-
const detector = createStuckLoopDetector(ctx.loopGuard);
|
|
116256
|
-
const maxIterations = ctx.maxIterations ?? peerMaxIterationsFromEnv() ?? DEFAULT_MAX_ITERATIONS;
|
|
116257
|
-
let noop3 = 0;
|
|
116258
|
-
let reactiveCompactions = 0;
|
|
116259
116126
|
let lastInboxTs = 0;
|
|
116260
116127
|
let wasPaused = false;
|
|
116261
|
-
|
|
116262
|
-
|
|
116263
|
-
|
|
116264
|
-
|
|
116128
|
+
const idleStop = {
|
|
116129
|
+
name: "collab-idle",
|
|
116130
|
+
gateOn: "idle",
|
|
116131
|
+
run: async (check) => {
|
|
116132
|
+
if (check.consecutiveIdle >= MAX_NOOP_ITERATIONS) {
|
|
116133
|
+
await agentCtx.emit({
|
|
116134
|
+
type: "assistant_message",
|
|
116135
|
+
sessionId: ctx.sessionId,
|
|
116136
|
+
turnId: ctx.turnId,
|
|
116137
|
+
source: "system",
|
|
116138
|
+
content: "Collaborative agent went idle without calling collab_done. Stopping this agent; the coordinator will integrate whatever was completed.",
|
|
116139
|
+
stopReason: "end_turn"
|
|
116140
|
+
});
|
|
116141
|
+
return { action: "stop" };
|
|
116142
|
+
}
|
|
116143
|
+
return { action: "retry" };
|
|
116265
116144
|
}
|
|
116266
|
-
|
|
116145
|
+
};
|
|
116146
|
+
yield* runReactLoop(agentCtx, {
|
|
116147
|
+
strategyName: "collaborative",
|
|
116148
|
+
defaultMaxIterations: peerMaxIterationsFromEnv() ?? DEFAULT_MAX_ITERATIONS,
|
|
116149
|
+
errorPrefix: "collab agent: ",
|
|
116150
|
+
checkpoints: [idleStop],
|
|
116151
|
+
// idleStop stops itself at MAX_NOOP_ITERATIONS, before this backstop can
|
|
116152
|
+
// trip — it exists so a future checkpoint bug degrades loudly.
|
|
116153
|
+
maxInjections: MAX_NOOP_ITERATIONS,
|
|
116154
|
+
stuck: {
|
|
116155
|
+
abortedResultMessage: "collab agent aborted (stuck pattern) before this call ran",
|
|
116156
|
+
nearHint: "against the same target (only volatile args varied)",
|
|
116157
|
+
fatalMessage: ({ toolName, count, how }) => `collab agent aborted \u2014 stuck pattern: tool "${toolName}" called ${count} times ${how}.`
|
|
116158
|
+
},
|
|
116159
|
+
onIterationStart: async (loopCtx, iteration) => {
|
|
116160
|
+
if (!hub)
|
|
116161
|
+
return void 0;
|
|
116267
116162
|
let control = await hub.roster().then((r2) => r2.control).catch(() => void 0);
|
|
116268
|
-
while (control?.paused && !
|
|
116163
|
+
while (control?.paused && !loopCtx.signal.aborted) {
|
|
116269
116164
|
if (!wasPaused) {
|
|
116270
116165
|
wasPaused = true;
|
|
116271
|
-
|
|
116166
|
+
await loopCtx.emit(pluginEvent(ctx, "collab_peer_paused", { iteration }));
|
|
116272
116167
|
}
|
|
116273
|
-
await sleep5(PAUSE_POLL_MS,
|
|
116168
|
+
await sleep5(PAUSE_POLL_MS, loopCtx.signal);
|
|
116274
116169
|
control = await hub.roster().then((r2) => r2.control).catch(() => void 0);
|
|
116275
116170
|
}
|
|
116276
116171
|
if (wasPaused && !control?.paused) {
|
|
116277
116172
|
wasPaused = false;
|
|
116278
|
-
|
|
116279
|
-
}
|
|
116280
|
-
if (ctx.signal.aborted) {
|
|
116281
|
-
yield await ctx.emit(abort(ctx, "signal aborted"));
|
|
116282
|
-
return;
|
|
116173
|
+
await loopCtx.emit(pluginEvent(ctx, "collab_peer_resumed", { iteration }));
|
|
116283
116174
|
}
|
|
116284
|
-
|
|
116285
|
-
|
|
116286
|
-
type: "mode_iteration",
|
|
116287
|
-
sessionId: ctx.sessionId,
|
|
116288
|
-
turnId: ctx.turnId,
|
|
116289
|
-
source: "system",
|
|
116290
|
-
strategy: "collaborative",
|
|
116291
|
-
iteration
|
|
116292
|
-
});
|
|
116293
|
-
await runCompactionIfNeeded(agentCtx);
|
|
116294
|
-
await runElisionIfNeeded(agentCtx);
|
|
116295
|
-
let nudge;
|
|
116296
|
-
if (hub) {
|
|
116175
|
+
if (loopCtx.signal.aborted)
|
|
116176
|
+
return void 0;
|
|
116297
116177
|
const fresh = await hub.inbox(lastInboxTs).then((r2) => r2.messages).catch(() => []);
|
|
116298
|
-
if (fresh.length
|
|
116299
|
-
|
|
116300
|
-
|
|
116301
|
-
}
|
|
116302
|
-
}
|
|
116303
|
-
|
|
116304
|
-
|
|
116305
|
-
|
|
116306
|
-
|
|
116307
|
-
});
|
|
116308
|
-
yield await ctx.emit({
|
|
116309
|
-
type: "provider_request",
|
|
116310
|
-
sessionId: ctx.sessionId,
|
|
116311
|
-
turnId: ctx.turnId,
|
|
116312
|
-
source: "system",
|
|
116313
|
-
provider: agentCtx.provider.name,
|
|
116314
|
-
model: agentCtx.model
|
|
116315
|
-
});
|
|
116316
|
-
const { text, toolUses, stopReason, error: error2, usage, reasoning } = await collectProviderStream(agentCtx, messages, { iteration, stablePrefixIndex, ...nudge ? { volatileTailCount: 1 } : {} });
|
|
116317
|
-
yield await ctx.emit({
|
|
116318
|
-
type: "provider_response",
|
|
116319
|
-
sessionId: ctx.sessionId,
|
|
116320
|
-
turnId: ctx.turnId,
|
|
116321
|
-
source: "system",
|
|
116322
|
-
provider: agentCtx.provider.name,
|
|
116323
|
-
model: agentCtx.model,
|
|
116324
|
-
...usageEventFields(usage)
|
|
116325
|
-
});
|
|
116326
|
-
if (error2) {
|
|
116327
|
-
if (isContextOverflowError(error2.message) && reactiveCompactions < MAX_REACTIVE_COMPACTIONS) {
|
|
116328
|
-
reactiveCompactions += 1;
|
|
116329
|
-
if (await runCompactionIfNeeded(agentCtx, { force: true })) {
|
|
116330
|
-
yield await ctx.emit({
|
|
116331
|
-
type: "error",
|
|
116332
|
-
sessionId: ctx.sessionId,
|
|
116333
|
-
turnId: ctx.turnId,
|
|
116334
|
-
source: "system",
|
|
116335
|
-
kind: "retryable",
|
|
116336
|
-
message: "context window exceeded \u2014 compacted older turns, retrying"
|
|
116337
|
-
});
|
|
116338
|
-
continue;
|
|
116339
|
-
}
|
|
116340
|
-
}
|
|
116341
|
-
yield await ctx.emit({
|
|
116342
|
-
type: "error",
|
|
116343
|
-
sessionId: ctx.sessionId,
|
|
116344
|
-
turnId: ctx.turnId,
|
|
116345
|
-
source: "system",
|
|
116346
|
-
kind: error2.retryable ? "retryable" : "fatal",
|
|
116347
|
-
message: `collab agent: ${error2.message}`
|
|
116348
|
-
});
|
|
116349
|
-
if (!error2.retryable)
|
|
116350
|
-
return;
|
|
116351
|
-
continue;
|
|
116352
|
-
}
|
|
116353
|
-
reactiveCompactions = 0;
|
|
116354
|
-
if (reasoning) {
|
|
116355
|
-
yield await ctx.emit({
|
|
116356
|
-
type: "reasoning_message",
|
|
116357
|
-
sessionId: ctx.sessionId,
|
|
116358
|
-
turnId: ctx.turnId,
|
|
116359
|
-
source: "model",
|
|
116360
|
-
content: reasoning.text,
|
|
116361
|
-
...reasoning.signature ? { signature: reasoning.signature } : {},
|
|
116362
|
-
...reasoning.redacted ? { redacted: true } : {},
|
|
116363
|
-
...reasoning.encrypted ? { encrypted: reasoning.encrypted } : {}
|
|
116364
|
-
});
|
|
116365
|
-
}
|
|
116366
|
-
const stuck = yield* emitRequestsAndDetectStuck(ctx, toolUses, detector, {
|
|
116367
|
-
abortedResultMessage: "collab agent aborted (stuck pattern) before this call ran",
|
|
116368
|
-
nearHint: "against the same target (only volatile args varied)",
|
|
116369
|
-
fatalMessage: ({ toolName, count, how }) => `collab agent aborted \u2014 stuck pattern: tool "${toolName}" called ${count} times ${how}.`
|
|
116370
|
-
});
|
|
116371
|
-
if (stuck)
|
|
116372
|
-
return;
|
|
116373
|
-
if (text || stopReason === "end_turn" || toolUses.length === 0) {
|
|
116374
|
-
yield await ctx.emit({
|
|
116178
|
+
if (fresh.length === 0)
|
|
116179
|
+
return void 0;
|
|
116180
|
+
lastInboxTs = Math.max(lastInboxTs, ...fresh.map((m3) => m3.ts));
|
|
116181
|
+
return { volatileUserText: formatInboxNudge(fresh) };
|
|
116182
|
+
},
|
|
116183
|
+
onToolBatchEnd: async (loopCtx, { toolUses }) => {
|
|
116184
|
+
if (!toolUses.some((t2) => t2.name === COLLAB_DONE_TOOL))
|
|
116185
|
+
return void 0;
|
|
116186
|
+
await loopCtx.emit({
|
|
116375
116187
|
type: "assistant_message",
|
|
116376
116188
|
sessionId: ctx.sessionId,
|
|
116377
116189
|
turnId: ctx.turnId,
|
|
116378
|
-
source: "
|
|
116379
|
-
content:
|
|
116380
|
-
stopReason
|
|
116190
|
+
source: "system",
|
|
116191
|
+
content: "\u2713 Sub-task complete \u2014 reported to the team.",
|
|
116192
|
+
stopReason: "end_turn"
|
|
116381
116193
|
});
|
|
116382
|
-
|
|
116383
|
-
|
|
116384
|
-
|
|
116385
|
-
|
|
116386
|
-
|
|
116387
|
-
type: "assistant_message",
|
|
116388
|
-
sessionId: ctx.sessionId,
|
|
116389
|
-
turnId: ctx.turnId,
|
|
116390
|
-
source: "system",
|
|
116391
|
-
content: "Collaborative agent went idle without calling collab_done. Stopping this agent; the coordinator will integrate whatever was completed.",
|
|
116392
|
-
stopReason: "end_turn"
|
|
116393
|
-
});
|
|
116394
|
-
return;
|
|
116395
|
-
}
|
|
116396
|
-
continue;
|
|
116397
|
-
}
|
|
116398
|
-
noop3 = 0;
|
|
116399
|
-
const exited = yield* executeToolUses(agentCtx, toolUses, iteration);
|
|
116400
|
-
if (exited)
|
|
116401
|
-
return;
|
|
116402
|
-
if (toolUses.some((t2) => t2.name === COLLAB_DONE_TOOL)) {
|
|
116403
|
-
yield await ctx.emit({
|
|
116404
|
-
type: "assistant_message",
|
|
116194
|
+
return { action: "stop" };
|
|
116195
|
+
},
|
|
116196
|
+
onMaxIterations: async (loopCtx, maxIterations) => {
|
|
116197
|
+
await loopCtx.emit({
|
|
116198
|
+
type: "error",
|
|
116405
116199
|
sessionId: ctx.sessionId,
|
|
116406
116200
|
turnId: ctx.turnId,
|
|
116407
116201
|
source: "system",
|
|
116408
|
-
|
|
116409
|
-
|
|
116202
|
+
kind: "fatal",
|
|
116203
|
+
message: `collab agent reached the iteration cap (${maxIterations}) without calling collab_done.`
|
|
116410
116204
|
});
|
|
116411
|
-
return;
|
|
116412
116205
|
}
|
|
116413
|
-
}
|
|
116414
|
-
yield await ctx.emit({
|
|
116415
|
-
type: "error",
|
|
116416
|
-
sessionId: ctx.sessionId,
|
|
116417
|
-
turnId: ctx.turnId,
|
|
116418
|
-
source: "system",
|
|
116419
|
-
kind: "fatal",
|
|
116420
|
-
message: `collab agent reached the iteration cap (${maxIterations}) without calling collab_done.`
|
|
116421
116206
|
});
|
|
116422
116207
|
}
|
|
116423
116208
|
function compose(user, layer) {
|
|
@@ -130757,6 +130542,18 @@ function applyPluginsTree(session, config, logger) {
|
|
|
130757
130542
|
}
|
|
130758
130543
|
if (name === void 0) name = categoryDefault(config, key);
|
|
130759
130544
|
if (!name) continue;
|
|
130545
|
+
if (key === "mode") {
|
|
130546
|
+
const target = name;
|
|
130547
|
+
const def = session.modes.list().find((m3) => m3.name === target);
|
|
130548
|
+
if (def?.transient) {
|
|
130549
|
+
if (explicit) {
|
|
130550
|
+
logger.warn(
|
|
130551
|
+
`configured mode '${name}' is transient (armed per objective) and can't be the boot default; keeping '${reg.getActiveName()}'`
|
|
130552
|
+
);
|
|
130553
|
+
}
|
|
130554
|
+
continue;
|
|
130555
|
+
}
|
|
130556
|
+
}
|
|
130760
130557
|
if (reg.has(name)) {
|
|
130761
130558
|
try {
|
|
130762
130559
|
reg.setActive(name);
|
|
@@ -135552,6 +135349,207 @@ ${input.body.trimEnd()}
|
|
|
135552
135349
|
return writeIndex(this.dir, sorted);
|
|
135553
135350
|
}
|
|
135554
135351
|
};
|
|
135352
|
+
var USER_MODEL_OPEN = "<user-model>";
|
|
135353
|
+
var USER_MODEL_CLOSE = "</user-model>";
|
|
135354
|
+
var MAX_INJECTED_CHARS = 4e3;
|
|
135355
|
+
var FIXED_SECTIONS = ["Identity", "Preferences", "Workflows", "Context"];
|
|
135356
|
+
var SECTION_TITLES = {
|
|
135357
|
+
identity: "Identity",
|
|
135358
|
+
preferences: "Preferences",
|
|
135359
|
+
workflows: "Workflows",
|
|
135360
|
+
context: "Context"
|
|
135361
|
+
};
|
|
135362
|
+
var TEMPLATE_PREAMBLE = `<!-- moxxy user model \u2014 durable facts about who the user is and how they work.
|
|
135363
|
+
This file is ALWAYS injected into the system prompt and is updated ONLY via the
|
|
135364
|
+
permission-prompted memory_update_user_model tool. Keep entries terse and stable. -->`;
|
|
135365
|
+
function templateModel() {
|
|
135366
|
+
return {
|
|
135367
|
+
preamble: TEMPLATE_PREAMBLE,
|
|
135368
|
+
sections: FIXED_SECTIONS.map((title) => ({ title, content: "" }))
|
|
135369
|
+
};
|
|
135370
|
+
}
|
|
135371
|
+
var HEADING_RE = /^##\s+(.+?)\s*$/;
|
|
135372
|
+
function parseUserModel(text) {
|
|
135373
|
+
const preambleLines = [];
|
|
135374
|
+
const sections = [];
|
|
135375
|
+
let current = null;
|
|
135376
|
+
let seenHeading = false;
|
|
135377
|
+
for (const line of text.split("\n")) {
|
|
135378
|
+
const m3 = HEADING_RE.exec(line);
|
|
135379
|
+
if (m3) {
|
|
135380
|
+
seenHeading = true;
|
|
135381
|
+
if (current)
|
|
135382
|
+
sections.push({ title: current.title, content: current.body.join("\n").trim() });
|
|
135383
|
+
current = { title: m3[1].trim(), body: [] };
|
|
135384
|
+
} else if (!seenHeading) {
|
|
135385
|
+
preambleLines.push(line);
|
|
135386
|
+
} else if (current) {
|
|
135387
|
+
current.body.push(line);
|
|
135388
|
+
}
|
|
135389
|
+
}
|
|
135390
|
+
if (current)
|
|
135391
|
+
sections.push({ title: current.title, content: current.body.join("\n").trim() });
|
|
135392
|
+
return { preamble: preambleLines.join("\n").trim(), sections };
|
|
135393
|
+
}
|
|
135394
|
+
function serializeUserModel(model) {
|
|
135395
|
+
const parts = [];
|
|
135396
|
+
if (model.preamble.trim())
|
|
135397
|
+
parts.push(model.preamble.trim());
|
|
135398
|
+
for (const s2 of model.sections) {
|
|
135399
|
+
const content = s2.content.trim();
|
|
135400
|
+
parts.push(content ? `## ${s2.title}
|
|
135401
|
+
|
|
135402
|
+
${content}` : `## ${s2.title}`);
|
|
135403
|
+
}
|
|
135404
|
+
return parts.join("\n\n") + "\n";
|
|
135405
|
+
}
|
|
135406
|
+
function renderInjectionBody(model, max = MAX_INJECTED_CHARS) {
|
|
135407
|
+
const chunks = [];
|
|
135408
|
+
let used = 0;
|
|
135409
|
+
let truncated = false;
|
|
135410
|
+
for (const s2 of model.sections) {
|
|
135411
|
+
const content = s2.content.trim();
|
|
135412
|
+
if (!content)
|
|
135413
|
+
continue;
|
|
135414
|
+
const chunk = `## ${s2.title}
|
|
135415
|
+
${content}`;
|
|
135416
|
+
const cost = (chunks.length > 0 ? 2 : 0) + chunk.length;
|
|
135417
|
+
if (used + cost > max) {
|
|
135418
|
+
truncated = true;
|
|
135419
|
+
break;
|
|
135420
|
+
}
|
|
135421
|
+
chunks.push(chunk);
|
|
135422
|
+
used += cost;
|
|
135423
|
+
}
|
|
135424
|
+
if (chunks.length === 0)
|
|
135425
|
+
return "";
|
|
135426
|
+
return chunks.join("\n\n") + (truncated ? "\n\n(truncated)" : "");
|
|
135427
|
+
}
|
|
135428
|
+
function isEnoent4(err) {
|
|
135429
|
+
return typeof err === "object" && err !== null && err.code === "ENOENT";
|
|
135430
|
+
}
|
|
135431
|
+
var UserModelStore = class {
|
|
135432
|
+
path;
|
|
135433
|
+
mutex = createMutex();
|
|
135434
|
+
cached = null;
|
|
135435
|
+
/** @param dir the memory directory (defaults to `~/.moxxy/memory`). */
|
|
135436
|
+
constructor(dir) {
|
|
135437
|
+
this.path = join(dir ?? moxxyPath("memory"), "user-model.md");
|
|
135438
|
+
}
|
|
135439
|
+
/**
|
|
135440
|
+
* mtime-cached load. Returns `null` when the file is absent. On an unchanged
|
|
135441
|
+
* file this only `stat`s — no `readFile` — so it's cheap to call on every
|
|
135442
|
+
* provider request.
|
|
135443
|
+
*/
|
|
135444
|
+
async load() {
|
|
135445
|
+
let mtimeMs;
|
|
135446
|
+
try {
|
|
135447
|
+
mtimeMs = (await promises.stat(this.path)).mtimeMs;
|
|
135448
|
+
} catch (err) {
|
|
135449
|
+
if (isEnoent4(err)) {
|
|
135450
|
+
this.cached = null;
|
|
135451
|
+
return null;
|
|
135452
|
+
}
|
|
135453
|
+
throw err;
|
|
135454
|
+
}
|
|
135455
|
+
if (this.cached && this.cached.mtimeMs === mtimeMs)
|
|
135456
|
+
return this.cached.model;
|
|
135457
|
+
const model = parseUserModel(await promises.readFile(this.path, "utf8"));
|
|
135458
|
+
this.cached = { mtimeMs, model };
|
|
135459
|
+
return model;
|
|
135460
|
+
}
|
|
135461
|
+
/** Raw file text (or `null` when absent) — used by the CLI viewer. */
|
|
135462
|
+
async readRaw() {
|
|
135463
|
+
try {
|
|
135464
|
+
return await promises.readFile(this.path, "utf8");
|
|
135465
|
+
} catch (err) {
|
|
135466
|
+
if (isEnoent4(err))
|
|
135467
|
+
return null;
|
|
135468
|
+
throw err;
|
|
135469
|
+
}
|
|
135470
|
+
}
|
|
135471
|
+
/**
|
|
135472
|
+
* Set (`replace`) or extend (`append`) one section, atomically. Creates the
|
|
135473
|
+
* file with the commented template on first write. Bypasses the mtime cache
|
|
135474
|
+
* on read so a concurrent external edit is not clobbered, and invalidates the
|
|
135475
|
+
* cache after the write.
|
|
135476
|
+
*/
|
|
135477
|
+
async update(section, content, mode) {
|
|
135478
|
+
const title = SECTION_TITLES[section];
|
|
135479
|
+
return this.mutex.run(async () => {
|
|
135480
|
+
const model = await this.readDisk() ?? templateModel();
|
|
135481
|
+
let sec = model.sections.find((s2) => s2.title.toLowerCase() === title.toLowerCase());
|
|
135482
|
+
if (!sec) {
|
|
135483
|
+
sec = { title, content: "" };
|
|
135484
|
+
model.sections.push(sec);
|
|
135485
|
+
}
|
|
135486
|
+
const incoming = content.trim();
|
|
135487
|
+
const prior = sec.content.trim();
|
|
135488
|
+
sec.content = mode === "append" && prior ? `${prior}
|
|
135489
|
+
${incoming}`.trim() : incoming;
|
|
135490
|
+
await writeFileAtomic(this.path, serializeUserModel(model));
|
|
135491
|
+
this.cached = null;
|
|
135492
|
+
return model;
|
|
135493
|
+
});
|
|
135494
|
+
}
|
|
135495
|
+
/** Uncached disk read (used inside the update RMW). */
|
|
135496
|
+
async readDisk() {
|
|
135497
|
+
const raw = await this.readRaw();
|
|
135498
|
+
return raw === null ? null : parseUserModel(raw);
|
|
135499
|
+
}
|
|
135500
|
+
/**
|
|
135501
|
+
* The always-on injection: prepend a delimited `<user-model>` block to
|
|
135502
|
+
* `req.system`. Returns the request unchanged (void) when the file is absent
|
|
135503
|
+
* or has no non-empty content, when a `<user-model>` block is already present
|
|
135504
|
+
* (side-channel calls re-enter this hook — inject exactly once), or on ANY
|
|
135505
|
+
* error (injection must never break a provider call).
|
|
135506
|
+
*/
|
|
135507
|
+
async injectInto(req) {
|
|
135508
|
+
try {
|
|
135509
|
+
if ((req.system ?? "").includes(USER_MODEL_OPEN))
|
|
135510
|
+
return;
|
|
135511
|
+
const model = await this.load();
|
|
135512
|
+
if (!model)
|
|
135513
|
+
return;
|
|
135514
|
+
const body = renderInjectionBody(model);
|
|
135515
|
+
if (!body)
|
|
135516
|
+
return;
|
|
135517
|
+
const block = `${USER_MODEL_OPEN}
|
|
135518
|
+
${body}
|
|
135519
|
+
${USER_MODEL_CLOSE}
|
|
135520
|
+
The block above is durable context about the user, maintained across sessions via the \`memory_update_user_model\` tool. Treat it as reliable background on who the user is and how they work.`;
|
|
135521
|
+
return { ...req, system: `${block}
|
|
135522
|
+
|
|
135523
|
+
${req.system ?? ""}`.trimEnd() };
|
|
135524
|
+
} catch {
|
|
135525
|
+
return;
|
|
135526
|
+
}
|
|
135527
|
+
}
|
|
135528
|
+
};
|
|
135529
|
+
var sectionSchema = z$1.enum(["identity", "preferences", "workflows", "context"]);
|
|
135530
|
+
function userModelTool(store) {
|
|
135531
|
+
return defineTool({
|
|
135532
|
+
name: "memory_update_user_model",
|
|
135533
|
+
description: "Update the persistent USER MODEL (~/.moxxy/memory/user-model.md), which is ALWAYS injected into your system prompt. PREFER this over memory_save for durable facts about WHO THE USER IS and HOW THEY WORK \u2014 their identity, standing preferences, personal workflows, and lasting context \u2014 NOT for episodic facts (use memory_save for a one-off answer or project detail). mode 'replace' overwrites the section; 'append' adds to it. Keep each section terse.",
|
|
135534
|
+
inputSchema: z$1.object({
|
|
135535
|
+
section: sectionSchema,
|
|
135536
|
+
content: z$1.string().max(2e3),
|
|
135537
|
+
mode: z$1.enum(["replace", "append"]).default("replace")
|
|
135538
|
+
}),
|
|
135539
|
+
permission: { action: "prompt" },
|
|
135540
|
+
isolation: {
|
|
135541
|
+
capabilities: {
|
|
135542
|
+
fs: { read: ["~/.moxxy/memory/**"], write: ["~/.moxxy/memory/**"] },
|
|
135543
|
+
net: { mode: "none" },
|
|
135544
|
+
timeMs: 5e3
|
|
135545
|
+
}
|
|
135546
|
+
},
|
|
135547
|
+
handler: async ({ section, content, mode }) => {
|
|
135548
|
+
await store.update(section, content, mode);
|
|
135549
|
+
return { section, mode, path: store.path };
|
|
135550
|
+
}
|
|
135551
|
+
});
|
|
135552
|
+
}
|
|
135555
135553
|
var SYSTEM_PROMPT = `You are consolidating overlapping long-term memory entries.
|
|
135556
135554
|
|
|
135557
135555
|
You receive a cluster of 2 or more entries that touch the same topic. Produce a single canonical entry that:
|
|
@@ -135886,6 +135884,7 @@ function makeMemoryConsolidatePlugin(getStore, getProvider, opts = {}, extraOnIn
|
|
|
135886
135884
|
// ../plugin-memory/dist/index.js
|
|
135887
135885
|
function buildMemoryPlugin(opts = {}) {
|
|
135888
135886
|
const store = new MemoryStore(opts);
|
|
135887
|
+
const userModel = new UserModelStore(opts.dir);
|
|
135889
135888
|
const plugin5 = definePlugin({
|
|
135890
135889
|
name: "@moxxy/plugin-memory",
|
|
135891
135890
|
version: "0.0.0",
|
|
@@ -135897,7 +135896,11 @@ function buildMemoryPlugin(opts = {}) {
|
|
|
135897
135896
|
hooks: {
|
|
135898
135897
|
onInit: (ctx) => {
|
|
135899
135898
|
ctx.services.register("memory", store);
|
|
135900
|
-
}
|
|
135899
|
+
},
|
|
135900
|
+
// ALWAYS-ON: prepend the delimited <user-model> block to every provider
|
|
135901
|
+
// call when the file exists and has content. Idempotent (skips when the
|
|
135902
|
+
// block is already present) and error-swallowing (never breaks a call).
|
|
135903
|
+
onBeforeProviderCall: (req) => userModel.injectInto(req)
|
|
135901
135904
|
},
|
|
135902
135905
|
// The zero-dep TF-IDF embedder, contributed as a selectable embedder so it
|
|
135903
135906
|
// sits in the same registry as openai/transformers/custom ones.
|
|
@@ -136039,7 +136042,8 @@ function buildMemoryPlugin(opts = {}) {
|
|
|
136039
136042
|
throw new Error(`memory '${name}' not found`);
|
|
136040
136043
|
return { name: updated.frontmatter.name, updatedAt: updated.frontmatter.updatedAt };
|
|
136041
136044
|
}
|
|
136042
|
-
})
|
|
136045
|
+
}),
|
|
136046
|
+
userModelTool(userModel)
|
|
136043
136047
|
]
|
|
136044
136048
|
});
|
|
136045
136049
|
return { plugin: plugin5, store };
|
|
@@ -136058,11 +136062,24 @@ function buildMemoryPlugin(opts = {}) {
|
|
|
136058
136062
|
...base2.embedders ? { embedders: base2.embedders } : {},
|
|
136059
136063
|
tools: [...base2.tools ?? [], ...consolidate.tools ?? []],
|
|
136060
136064
|
hooks: {
|
|
136061
|
-
...consolidate.hooks,
|
|
136062
136065
|
onInit: async (ctx) => {
|
|
136063
136066
|
embeddersReg = ctx.services.get("embedders") ?? null;
|
|
136064
136067
|
await base2.hooks?.onInit?.(ctx);
|
|
136065
136068
|
await consolidate.hooks?.onInit?.(ctx);
|
|
136069
|
+
},
|
|
136070
|
+
// A Plugin has a single onBeforeProviderCall, but this composed plugin
|
|
136071
|
+
// carries TWO: base's always-on user-model injection and consolidate's
|
|
136072
|
+
// once-per-session nudge. Chain them so both run (injection prepends its
|
|
136073
|
+
// block, the nudge appends its hint); either may return void to pass through.
|
|
136074
|
+
onBeforeProviderCall: async (req, ctx) => {
|
|
136075
|
+
let out;
|
|
136076
|
+
const injected = await base2.hooks?.onBeforeProviderCall?.(out ?? req, ctx);
|
|
136077
|
+
if (injected)
|
|
136078
|
+
out = injected;
|
|
136079
|
+
const nudged = await consolidate.hooks?.onBeforeProviderCall?.(out ?? req, ctx);
|
|
136080
|
+
if (nudged)
|
|
136081
|
+
out = nudged;
|
|
136082
|
+
return out;
|
|
136066
136083
|
}
|
|
136067
136084
|
}
|
|
136068
136085
|
});
|
|
@@ -136081,6 +136098,7 @@ var HELP9 = formatHelp({
|
|
|
136081
136098
|
["show <name>", "print the body of a single entry"],
|
|
136082
136099
|
["revert <name>", "delete a single entry"],
|
|
136083
136100
|
["prune-stale --days <n>", "delete entries not updated in <n> days"],
|
|
136101
|
+
["user-model", "print the persistent user model"],
|
|
136084
136102
|
["path", "print the memory directory"]
|
|
136085
136103
|
]
|
|
136086
136104
|
}
|
|
@@ -136218,6 +136236,17 @@ ${entry.body}
|
|
|
136218
136236
|
`);
|
|
136219
136237
|
return 0;
|
|
136220
136238
|
}
|
|
136239
|
+
case "user-model": {
|
|
136240
|
+
const raw = await new UserModelStore().readRaw();
|
|
136241
|
+
if (!raw || !raw.trim()) {
|
|
136242
|
+
process.stdout.write(
|
|
136243
|
+
colors.dim("(none yet \u2014 the agent maintains this via memory_update_user_model)") + "\n"
|
|
136244
|
+
);
|
|
136245
|
+
return 0;
|
|
136246
|
+
}
|
|
136247
|
+
process.stdout.write(raw.endsWith("\n") ? raw : raw + "\n");
|
|
136248
|
+
return 0;
|
|
136249
|
+
}
|
|
136221
136250
|
case "path": {
|
|
136222
136251
|
process.stdout.write(defaultMemoryDir() + "\n");
|
|
136223
136252
|
return 0;
|
|
@@ -138122,9 +138151,9 @@ function renderByPackage(entries) {
|
|
|
138122
138151
|
function formatCapabilities(caps) {
|
|
138123
138152
|
if (!caps) return "";
|
|
138124
138153
|
const bits = [];
|
|
138125
|
-
const
|
|
138126
|
-
if (
|
|
138127
|
-
if (
|
|
138154
|
+
const fs48 = caps.fs;
|
|
138155
|
+
if (fs48?.read?.length) bits.push(`fs:read(${fs48.read.length})`);
|
|
138156
|
+
if (fs48?.write?.length) bits.push(`fs:write(${fs48.write.length})`);
|
|
138128
138157
|
const net3 = caps.net;
|
|
138129
138158
|
if (net3?.mode) bits.push(`net:${net3.mode}`);
|
|
138130
138159
|
const env3 = caps.env;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moxxy/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "moxxy command-line binary. Subcommand dispatcher consuming the moxxy SDK.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"moxxy",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"zod": "^3.24.0",
|
|
54
|
-
"@moxxy/sdk": "0.
|
|
54
|
+
"@moxxy/sdk": "0.28.0"
|
|
55
55
|
},
|
|
56
56
|
"optionalDependencies": {
|
|
57
57
|
"@napi-rs/keyring": "^1.3.0"
|