@moxxy/cli 0.43.0 → 0.44.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 +181 -102
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -8,7 +8,7 @@ import path3__default, { join, dirname, resolve, relative, isAbsolute, posix, se
|
|
|
8
8
|
import { utf8Locale, ensurePrivateDir, moxxyHome, pruneStaleTempFiles, moxxyPath, hasProxy, installEgressProxy, readProxyEnv, writeFileAtomic, ensurePrivateFile, resolveChannelToken, rotateChannelToken, liveChannelStatus, spawnDedicatedChannel, stopDedicatedChannel, clearChannelStatus, MOXXY_WS_SUBPROTOCOL, bearerTokenMatches, PRIVATE_FILE_MODE, findExecutable, bearerGuard, tokenFromWsProtocolHeader, resolveExecutableTarget, spawnExecutableTarget, resolveOsPrincipal, redactProxyUrl, listLiveChannelStatuses, writeSignedNetworkCacheAtomic, CrossProcessFireLock, writeChannelStatus, writeBoundedNetworkCacheAtomicSync, writeBoundedDataCacheAtomic, readRequestBody } from '@moxxy/sdk/server';
|
|
9
9
|
import { spawn, execFile, spawnSync } from 'child_process';
|
|
10
10
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
11
|
-
import { MoxxyError, createMutex, defineMode, definePlugin, defineChannel, defineViewRenderer, DEFAULT_VIEW_TAGS, defineTunnelProvider, defineAuditExporter, defineAuditSink, z as z$1, withAgentConduct, defineTool, defineCommand, defineEmbedder, asPluginId, computerControlSnapshotSchema, runReactLoop, createDeferredPermissionResolver, isSafeViewUrl, redactSecrets, asTurnId, waitFor, unfinishedWorkCheckpoint, unfinishedStepCheckpoint, defineCompactor, abortError, activeCompactionRanges, defineCacheStrategy, denyByDefaultResolver, runManualCompaction, assertDefined, defineWorkflowExecutor, MOXXY_PCM16_24KHZ_MIME, isFileDiffDisplay, summarizeWithProvider, toolResultBytes, wakeAfter, isSelectableMode, summarizeSessionTokensFromEvents, summarizeTokensByModel, getInstallHint, toDiffRows, diffGutterNo, fileDiffVerb, fileDiffSummary, computerControlCommandSchema, computeElisionState, toolResultStubbed, toolResultStubText, conversationalStubbed, conversationalStub, isFirstPartyPackage, REDACTED_PLACEHOLDER, isSecretKey, addModelTotals, skillFrontmatterSchema, asSkillId, parseFrontmatter, createCallbackResolver, createAllowListResolver, countNodes, autoAllowResolver, SESSION_SOURCES, startChannelWith, EXIT_AFTER_PAIR_FLAG, renderFrontmatter, formatPrincipal, aggregateCapabilitySpecs, hostCredentialName, mentionedSkills, skillAttachment, withoutTools, toolsForMode, moxxyPackageSchema, auditActionOf, asToolCallId, dispatchToolCall, matchLoadableTools, verifyEd25519, defineSecretProvider, encodeLoginAuthUrl, redactSecretText, encodeLoginPrompt, ISOLATION_RANK, sleepWithAbort, asSessionId, migrateModeName, autoApproveFromEvents, AUTO_APPROVE_SUBTYPE, AUTO_APPROVE_PLUGIN_ID, parseFrontmatterFile, createJsonFileStore, autoApproveSwitch, computerApprovalFocusSchema, workflowApprovalItemsSchema, evaluateToolRule, asEventId } from '@moxxy/sdk';
|
|
11
|
+
import { MoxxyError, createMutex, defineMode, definePlugin, defineChannel, defineViewRenderer, DEFAULT_VIEW_TAGS, defineTunnelProvider, defineAuditExporter, defineAuditSink, z as z$1, withAgentConduct, defineTool, defineCommand, defineEmbedder, asPluginId, computerControlSnapshotSchema, runReactLoop, createDeferredPermissionResolver, isSafeViewUrl, redactSecrets, asTurnId, waitFor, unfinishedWorkCheckpoint, unfinishedStepCheckpoint, defineCompactor, abortError, activeCompactionRanges, defineCacheStrategy, denyByDefaultResolver, runManualCompaction, assertDefined, defineWorkflowExecutor, MOXXY_PCM16_24KHZ_MIME, isFileDiffDisplay, findAttachment, listAttachments, summarizeWithProvider, toolResultBytes, wakeAfter, isSelectableMode, summarizeSessionTokensFromEvents, summarizeTokensByModel, getInstallHint, toDiffRows, diffGutterNo, fileDiffVerb, fileDiffSummary, computerControlCommandSchema, computeElisionState, toolResultStubbed, toolResultStubText, conversationalStubbed, conversationalStub, isFirstPartyPackage, REDACTED_PLACEHOLDER, isSecretKey, addModelTotals, skillFrontmatterSchema, asSkillId, parseFrontmatter, createCallbackResolver, createAllowListResolver, countNodes, autoAllowResolver, SESSION_SOURCES, startChannelWith, EXIT_AFTER_PAIR_FLAG, renderFrontmatter, formatPrincipal, aggregateCapabilitySpecs, hostCredentialName, mentionedSkills, skillAttachment, withoutTools, toolsForMode, moxxyPackageSchema, auditActionOf, asToolCallId, dispatchToolCall, matchLoadableTools, verifyEd25519, defineSecretProvider, encodeLoginAuthUrl, redactSecretText, encodeLoginPrompt, ISOLATION_RANK, sleepWithAbort, asSessionId, migrateModeName, autoApproveFromEvents, AUTO_APPROVE_SUBTYPE, AUTO_APPROVE_PLUGIN_ID, parseFrontmatterFile, createJsonFileStore, autoApproveSwitch, eventForClient, historyPageForClient, readAttachmentChunk, computerApprovalFocusSchema, workflowApprovalItemsSchema, evaluateToolRule, asEventId } from '@moxxy/sdk';
|
|
12
12
|
import { createRequire as createRequire$1 } from 'module';
|
|
13
13
|
import { z } from 'zod';
|
|
14
14
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
@@ -1820,39 +1820,41 @@ var LOGO_ART_RAW, LOGO_WIDTH, LOGO_LINES, COMPACT_LOGO_ART_RAW, COMPACT_LOGO_WID
|
|
|
1820
1820
|
var init_logo_data = __esm({
|
|
1821
1821
|
"../plugin-cli/dist/logo-data.js"() {
|
|
1822
1822
|
LOGO_ART_RAW = [
|
|
1823
|
-
"
|
|
1824
|
-
"
|
|
1825
|
-
"
|
|
1826
|
-
"
|
|
1827
|
-
"
|
|
1828
|
-
"
|
|
1829
|
-
"
|
|
1830
|
-
"
|
|
1831
|
-
"
|
|
1832
|
-
"
|
|
1833
|
-
"
|
|
1834
|
-
"
|
|
1835
|
-
"
|
|
1836
|
-
"
|
|
1837
|
-
"
|
|
1838
|
-
"
|
|
1839
|
-
"
|
|
1840
|
-
"
|
|
1841
|
-
"
|
|
1823
|
+
" .-=+++=-. .:---.",
|
|
1824
|
+
" -#@@@@@@@@@%*-.:-+*#%@@@@@@@%+.",
|
|
1825
|
+
" =%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+",
|
|
1826
|
+
" =%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%:",
|
|
1827
|
+
".#@@@@@@@@@%*#%@@@@@@@@@@@@@@@@@@@@@@@@@-",
|
|
1828
|
+
"*@@@@@%=:. .:=+*%@@@@@@@@@@@@@@@@@@@@-",
|
|
1829
|
+
"%@@@@@= .:-==+*##%%@@@@@@@@@",
|
|
1830
|
+
"%@@@@# .*@@@@@:",
|
|
1831
|
+
"%@@@@+ @@@ @@@ +@@@@@-",
|
|
1832
|
+
"#@@@@= @@@ @@@ +@@@@@-",
|
|
1833
|
+
"#@@@@# @@@ @@@ +@@@@@:",
|
|
1834
|
+
"*@@@@@. @@@ @@ #@@@@@.",
|
|
1835
|
+
"=@@@@@%###-:::. :#@@@@@*",
|
|
1836
|
+
" *@@@@@@@%#****+=-------=====+++*%@@@@@@#.",
|
|
1837
|
+
" -#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+",
|
|
1838
|
+
" .-=+*##%%@@@@@@@@@@@@@@@@@@@@@@@@+.",
|
|
1839
|
+
" .:-===--*@@@@@@@@@@@%+.",
|
|
1840
|
+
" .+%@@@@@@%=.",
|
|
1841
|
+
" =@@@@+.",
|
|
1842
|
+
" .=+:"
|
|
1842
1843
|
];
|
|
1843
1844
|
LOGO_WIDTH = LOGO_ART_RAW.reduce((m3, l2) => Math.max(m3, l2.length), 0);
|
|
1844
1845
|
LOGO_LINES = LOGO_ART_RAW.map((l2) => l2.padEnd(LOGO_WIDTH));
|
|
1845
1846
|
COMPACT_LOGO_ART_RAW = [
|
|
1846
|
-
"
|
|
1847
|
-
"
|
|
1848
|
-
"
|
|
1849
|
-
"
|
|
1850
|
-
"
|
|
1851
|
-
"
|
|
1852
|
-
"
|
|
1853
|
-
"
|
|
1854
|
-
"
|
|
1855
|
-
"
|
|
1847
|
+
" .:-:. ...",
|
|
1848
|
+
" -*@@@@@%+*#%@@@@#-",
|
|
1849
|
+
":#@@@@%@@@@@@@@@@@@@*.",
|
|
1850
|
+
"%@@*. .:=+**#%%@@@@#",
|
|
1851
|
+
"%@@ @ @ @@@.",
|
|
1852
|
+
"%@% @ @ @@@.",
|
|
1853
|
+
"#@@+-:.. -@@%",
|
|
1854
|
+
".#@@@%%##*****###%@@%:",
|
|
1855
|
+
" .:-==+***#@@@@@@#-",
|
|
1856
|
+
" .+@@#:",
|
|
1857
|
+
" .:"
|
|
1856
1858
|
];
|
|
1857
1859
|
COMPACT_LOGO_WIDTH = COMPACT_LOGO_ART_RAW.reduce((max, line) => Math.max(max, line.length), 0);
|
|
1858
1860
|
COMPACT_LOGO_LINES = COMPACT_LOGO_ART_RAW.map((line) => line.padEnd(COMPACT_LOGO_WIDTH));
|
|
@@ -39262,6 +39264,26 @@ var init_read = __esm({
|
|
|
39262
39264
|
});
|
|
39263
39265
|
}
|
|
39264
39266
|
});
|
|
39267
|
+
function recallAttachment(events, query, summarize) {
|
|
39268
|
+
const found = findAttachment(events, query);
|
|
39269
|
+
if (!found) {
|
|
39270
|
+
const known = listAttachments(events);
|
|
39271
|
+
throw new MoxxyError({
|
|
39272
|
+
code: "TOOL_ERROR",
|
|
39273
|
+
message: `recall: no attachment "${query}" in this conversation. ` + (known.length > 0 ? `Attached so far: ${known.join(", ")}.` : "Nothing has been attached yet.")
|
|
39274
|
+
});
|
|
39275
|
+
}
|
|
39276
|
+
const { seq, index, attachment: att } = found;
|
|
39277
|
+
const name = att.name ?? att.kind;
|
|
39278
|
+
if (att.kind !== "image" && att.kind !== "document") {
|
|
39279
|
+
return present(`[${att.kind} ${name}]
|
|
39280
|
+
${att.content}`, summarize);
|
|
39281
|
+
}
|
|
39282
|
+
return {
|
|
39283
|
+
forModel: `[${att.kind} "${name}" restored \u2014 it is attached to this result.]`,
|
|
39284
|
+
restoredAttachment: { seq, index }
|
|
39285
|
+
};
|
|
39286
|
+
}
|
|
39265
39287
|
function recallTargetMatches(input, target) {
|
|
39266
39288
|
if (!input || typeof input !== "object")
|
|
39267
39289
|
return false;
|
|
@@ -39317,11 +39339,12 @@ var init_recall = __esm({
|
|
|
39317
39339
|
recallTool = defineTool({
|
|
39318
39340
|
name: "recall",
|
|
39319
39341
|
icon: "search",
|
|
39320
|
-
description: 'Retrieve earlier content that was elided from context to save tokens. Pass the `callId` shown in an "[output elided \u2014 recall(...)]" stub to get a tool result back, or a `seq` / `turnId` to recall an earlier message or whole turn. Set `summarize: true` for a truncated preview instead of the full text. Only call this when you actually need the detail \u2014 the recent context is always present verbatim.',
|
|
39342
|
+
description: 'Retrieve earlier content that was elided from context to save tokens. Pass the `callId` shown in an "[output elided \u2014 recall(...)]" stub to get a tool result back, or a `seq` / `turnId` to recall an earlier message or whole turn. Pass `attachment` (a file name, or the key a "recall({ attachment })" note gives) to see a file attached earlier again, even one from a summarized turn. Set `summarize: true` for a truncated preview instead of the full text. Only call this when you actually need the detail \u2014 the recent context is always present verbatim.',
|
|
39321
39343
|
inputSchema: z$1.object({
|
|
39322
39344
|
callId: z$1.string().optional().describe("The callId from an elided tool-result stub."),
|
|
39323
39345
|
seq: z$1.number().int().nonnegative().optional().describe("Event sequence number to recall."),
|
|
39324
39346
|
turnId: z$1.string().optional().describe("Recall every message from this turn."),
|
|
39347
|
+
attachment: z$1.string().optional().describe('A file attached earlier: its name (e.g. "umowa.pdf") or its key (e.g. "12:0").'),
|
|
39325
39348
|
summarize: z$1.boolean().optional().describe("Return a truncated preview instead of the full content.")
|
|
39326
39349
|
}),
|
|
39327
39350
|
permission: { action: "allow" },
|
|
@@ -39329,7 +39352,9 @@ var init_recall = __esm({
|
|
|
39329
39352
|
required: "inproc",
|
|
39330
39353
|
capabilities: { net: { mode: "none" }, timeMs: 5e3 }
|
|
39331
39354
|
},
|
|
39332
|
-
handler: ({ callId, seq, turnId, summarize }, ctx) => {
|
|
39355
|
+
handler: ({ callId, seq, turnId, attachment, summarize }, ctx) => {
|
|
39356
|
+
if (attachment !== void 0)
|
|
39357
|
+
return recallAttachment(ctx.log.slice(), attachment, summarize);
|
|
39333
39358
|
const prior = ctx.log.slice(-40).find((e) => e.type === "tool_call_requested" && e.name === "recall" && e.callId !== ctx.callId && recallTargetMatches(e.input, { callId, seq, turnId }));
|
|
39334
39359
|
if (prior) {
|
|
39335
39360
|
return `[already recalled just above \u2014 not re-injecting to save context; scroll up for the full content]`;
|
|
@@ -39367,7 +39392,7 @@ var init_recall = __esm({
|
|
|
39367
39392
|
}
|
|
39368
39393
|
throw new MoxxyError({
|
|
39369
39394
|
code: "TOOL_ERROR",
|
|
39370
|
-
message: "recall: provide one of `callId`, `seq`, or `
|
|
39395
|
+
message: "recall: provide one of `callId`, `seq`, `turnId`, or `attachment`."
|
|
39371
39396
|
});
|
|
39372
39397
|
}
|
|
39373
39398
|
});
|
|
@@ -40095,6 +40120,44 @@ var init_jsonrpc = __esm({
|
|
|
40095
40120
|
};
|
|
40096
40121
|
}
|
|
40097
40122
|
});
|
|
40123
|
+
|
|
40124
|
+
// ../runner/dist/backlog-guard.js
|
|
40125
|
+
var OutboundBacklogGuard;
|
|
40126
|
+
var init_backlog_guard = __esm({
|
|
40127
|
+
"../runner/dist/backlog-guard.js"() {
|
|
40128
|
+
OutboundBacklogGuard = class {
|
|
40129
|
+
limitBytes;
|
|
40130
|
+
graceMs;
|
|
40131
|
+
hardLimitBytes;
|
|
40132
|
+
stalledSinceMs = null;
|
|
40133
|
+
sentBytes = 0;
|
|
40134
|
+
drainedAtStallStart = 0;
|
|
40135
|
+
constructor(limitBytes, graceMs, hardLimitBytes = limitBytes * 4) {
|
|
40136
|
+
this.limitBytes = limitBytes;
|
|
40137
|
+
this.graceMs = graceMs;
|
|
40138
|
+
this.hardLimitBytes = hardLimitBytes;
|
|
40139
|
+
}
|
|
40140
|
+
check(bufferedBytes, nowMs) {
|
|
40141
|
+
if (bufferedBytes > this.hardLimitBytes)
|
|
40142
|
+
return "terminate";
|
|
40143
|
+
if (bufferedBytes <= this.limitBytes) {
|
|
40144
|
+
this.stalledSinceMs = null;
|
|
40145
|
+
return "ok";
|
|
40146
|
+
}
|
|
40147
|
+
const drained = this.sentBytes - bufferedBytes;
|
|
40148
|
+
if (this.stalledSinceMs === null || drained > this.drainedAtStallStart) {
|
|
40149
|
+
this.stalledSinceMs = nowMs;
|
|
40150
|
+
this.drainedAtStallStart = drained;
|
|
40151
|
+
return "ok";
|
|
40152
|
+
}
|
|
40153
|
+
return nowMs - this.stalledSinceMs >= this.graceMs ? "terminate" : "ok";
|
|
40154
|
+
}
|
|
40155
|
+
recordSent(bytes) {
|
|
40156
|
+
this.sentBytes += bytes;
|
|
40157
|
+
}
|
|
40158
|
+
};
|
|
40159
|
+
}
|
|
40160
|
+
});
|
|
40098
40161
|
function platformSocket(name, posixPath, platform2 = process.platform) {
|
|
40099
40162
|
if (platform2 === "win32") {
|
|
40100
40163
|
return `\\\\.\\pipe\\moxxy-${name.replace(/[^A-Za-z0-9_-]/g, "_")}`;
|
|
@@ -40269,9 +40332,10 @@ async function reclaimStaleSocket(socketPath) {
|
|
|
40269
40332
|
} catch {
|
|
40270
40333
|
}
|
|
40271
40334
|
}
|
|
40272
|
-
var stderrLogger, DEFAULT_MAX_INBOUND_FRAME_BYTES, DEFAULT_MAX_OUTBOUND_BUFFER_BYTES, DEFAULT_OUTBOUND_STALL_GRACE_MS,
|
|
40335
|
+
var stderrLogger, DEFAULT_MAX_INBOUND_FRAME_BYTES, DEFAULT_MAX_OUTBOUND_BUFFER_BYTES, DEFAULT_OUTBOUND_STALL_GRACE_MS, DEFAULT_MAX_OUTBOUND_HARD_BYTES, NdjsonTransport, DEFAULT_CONNECT_TIMEOUT_MS, warnedWindowsPipeAcl;
|
|
40273
40336
|
var init_unix_socket = __esm({
|
|
40274
40337
|
"../runner/dist/unix-socket.js"() {
|
|
40338
|
+
init_backlog_guard();
|
|
40275
40339
|
init_socket_path();
|
|
40276
40340
|
stderrLogger = {
|
|
40277
40341
|
warn: (msg, meta) => process.stderr.write(`[moxxy-runner] WARN ${msg} ${meta ? JSON.stringify(meta) : ""}
|
|
@@ -40282,22 +40346,19 @@ var init_unix_socket = __esm({
|
|
|
40282
40346
|
DEFAULT_MAX_INBOUND_FRAME_BYTES = 64 * 1024 * 1024;
|
|
40283
40347
|
DEFAULT_MAX_OUTBOUND_BUFFER_BYTES = 4 * 1024 * 1024;
|
|
40284
40348
|
DEFAULT_OUTBOUND_STALL_GRACE_MS = 1e4;
|
|
40285
|
-
|
|
40349
|
+
DEFAULT_MAX_OUTBOUND_HARD_BYTES = 4 * DEFAULT_MAX_INBOUND_FRAME_BYTES;
|
|
40286
40350
|
NdjsonTransport = class {
|
|
40287
40351
|
socket;
|
|
40288
40352
|
maxInboundFrameBytes;
|
|
40289
|
-
maxOutboundBufferBytes;
|
|
40290
|
-
outboundStallGraceMs;
|
|
40291
40353
|
buffer = "";
|
|
40292
40354
|
frameHandler;
|
|
40293
40355
|
closeHandler;
|
|
40294
40356
|
closedEmitted = false;
|
|
40295
|
-
|
|
40357
|
+
outbound;
|
|
40296
40358
|
constructor(socket, maxInboundFrameBytes = DEFAULT_MAX_INBOUND_FRAME_BYTES, maxOutboundBufferBytes = DEFAULT_MAX_OUTBOUND_BUFFER_BYTES, outboundStallGraceMs = DEFAULT_OUTBOUND_STALL_GRACE_MS) {
|
|
40297
40359
|
this.socket = socket;
|
|
40298
40360
|
this.maxInboundFrameBytes = maxInboundFrameBytes;
|
|
40299
|
-
this.
|
|
40300
|
-
this.outboundStallGraceMs = outboundStallGraceMs;
|
|
40361
|
+
this.outbound = new OutboundBacklogGuard(maxOutboundBufferBytes, outboundStallGraceMs, Math.max(DEFAULT_MAX_OUTBOUND_HARD_BYTES, maxOutboundBufferBytes * 4));
|
|
40301
40362
|
socket.setEncoding("utf8");
|
|
40302
40363
|
socket.on("data", (chunk) => this.onData(chunk));
|
|
40303
40364
|
socket.on("close", () => this.emitClose());
|
|
@@ -40339,36 +40400,19 @@ var init_unix_socket = __esm({
|
|
|
40339
40400
|
send(frame) {
|
|
40340
40401
|
if (this.socket.destroyed)
|
|
40341
40402
|
return;
|
|
40342
|
-
if (this.
|
|
40403
|
+
if (this.outbound.check(this.socket.writableLength, Date.now()) === "terminate") {
|
|
40404
|
+
this.dropSlowReader(this.socket.writableLength);
|
|
40343
40405
|
return;
|
|
40344
|
-
this.socket.write(`${JSON.stringify(frame)}
|
|
40345
|
-
`);
|
|
40346
|
-
}
|
|
40347
|
-
/** Returns true and destroys the socket when the outbound backlog has stayed
|
|
40348
|
-
* over the limit too long. Draining below the limit resets the grace clock. */
|
|
40349
|
-
evictIfStalled() {
|
|
40350
|
-
const buffered = this.socket.writableLength;
|
|
40351
|
-
if (buffered > this.maxOutboundBufferBytes * OUTBOUND_HARD_MULTIPLIER) {
|
|
40352
|
-
return this.dropSlowReader(buffered);
|
|
40353
|
-
}
|
|
40354
|
-
if (buffered <= this.maxOutboundBufferBytes) {
|
|
40355
|
-
this.outboundStalledSinceMs = null;
|
|
40356
|
-
return false;
|
|
40357
|
-
}
|
|
40358
|
-
const now = Date.now();
|
|
40359
|
-
if (this.outboundStalledSinceMs === null) {
|
|
40360
|
-
this.outboundStalledSinceMs = now;
|
|
40361
|
-
return false;
|
|
40362
40406
|
}
|
|
40363
|
-
|
|
40364
|
-
|
|
40365
|
-
|
|
40407
|
+
const line = `${JSON.stringify(frame)}
|
|
40408
|
+
`;
|
|
40409
|
+
this.socket.write(line);
|
|
40410
|
+
this.outbound.recordSent(Buffer.byteLength(line));
|
|
40366
40411
|
}
|
|
40367
40412
|
dropSlowReader(buffered) {
|
|
40368
|
-
const err = new Error(`slow reader: ${buffered} bytes unsent
|
|
40413
|
+
const err = new Error(`slow reader: ${buffered} bytes unsent, none taken within the grace window`);
|
|
40369
40414
|
this.socket.destroy(err);
|
|
40370
40415
|
this.emitClose(err);
|
|
40371
|
-
return true;
|
|
40372
40416
|
}
|
|
40373
40417
|
onFrame(handler) {
|
|
40374
40418
|
this.frameHandler = handler;
|
|
@@ -40523,10 +40567,10 @@ function surfaceInputWithinCap(m3) {
|
|
|
40523
40567
|
return true;
|
|
40524
40568
|
return JSON.stringify(m3).length <= MAX_SURFACE_INPUT_BYTES;
|
|
40525
40569
|
}
|
|
40526
|
-
var RUNNER_PROTOCOL_VERSION, MIN_COMPATIBLE_PROTOCOL_VERSION, RunnerMethod, RunnerNotification, attachmentSchema, principalSchema, attachParamsSchema, runTurnParamsSchema, abortParamsSchema, setResolverParamsSchema, modeSetActiveParamsSchema, sessionSetReasoningParamsSchema, sessionSetFastParamsSchema, MAX_HISTORY_PAGE_LIMIT, sessionLoadHistoryParamsSchema, MAX_RECORDED_EXCHANGE_CHARS, recordedText, sessionRecordExchangeParamsSchema, sessionSetAutoApproveParamsSchema, providerSetActiveParamsSchema, providerSetEnabledParamsSchema, providerConfigureParamsSchema, permissionAddAllowParamsSchema, commandRunParamsSchema, MAX_TRANSCRIBE_AUDIO_B64_BYTES, MAX_SYNTHESIZE_TEXT_BYTES, MEDIA_DESCRIPTOR_MAX, transcribeParamsSchema, synthesizeParamsSchema, cancelSynthesizeParamsSchema, mcpEnableAndAttachParamsSchema, mcpDetachParamsSchema, workflowSetEnabledParamsSchema, workflowRunParamsSchema, workflowValidateDraftParamsSchema, workflowSaveParamsSchema, workflowGetRunParamsSchema, workflowResumeParamsSchema, surfaceOpenParamsSchema, MAX_SURFACE_INPUT_BYTES, surfaceInputParamsSchema, surfaceResizeParamsSchema, surfaceCloseParamsSchema;
|
|
40570
|
+
var RUNNER_PROTOCOL_VERSION, MIN_COMPATIBLE_PROTOCOL_VERSION, RunnerMethod, RunnerNotification, attachmentSchema, principalSchema, attachParamsSchema, runTurnParamsSchema, abortParamsSchema, setResolverParamsSchema, modeSetActiveParamsSchema, sessionSetReasoningParamsSchema, sessionSetFastParamsSchema, MAX_HISTORY_PAGE_LIMIT, sessionLoadHistoryParamsSchema, sessionReadAttachmentParamsSchema, MAX_RECORDED_EXCHANGE_CHARS, recordedText, sessionRecordExchangeParamsSchema, sessionSetAutoApproveParamsSchema, providerSetActiveParamsSchema, providerSetEnabledParamsSchema, providerConfigureParamsSchema, permissionAddAllowParamsSchema, commandRunParamsSchema, MAX_TRANSCRIBE_AUDIO_B64_BYTES, MAX_SYNTHESIZE_TEXT_BYTES, MEDIA_DESCRIPTOR_MAX, transcribeParamsSchema, synthesizeParamsSchema, cancelSynthesizeParamsSchema, mcpEnableAndAttachParamsSchema, mcpDetachParamsSchema, workflowSetEnabledParamsSchema, workflowRunParamsSchema, workflowValidateDraftParamsSchema, workflowSaveParamsSchema, workflowGetRunParamsSchema, workflowResumeParamsSchema, surfaceOpenParamsSchema, MAX_SURFACE_INPUT_BYTES, surfaceInputParamsSchema, surfaceResizeParamsSchema, surfaceCloseParamsSchema;
|
|
40527
40571
|
var init_protocol2 = __esm({
|
|
40528
40572
|
"../runner/dist/protocol.js"() {
|
|
40529
|
-
RUNNER_PROTOCOL_VERSION =
|
|
40573
|
+
RUNNER_PROTOCOL_VERSION = 26;
|
|
40530
40574
|
MIN_COMPATIBLE_PROTOCOL_VERSION = 1;
|
|
40531
40575
|
RunnerMethod = {
|
|
40532
40576
|
/** client->server: handshake; returns the initial info snapshot. */
|
|
@@ -40554,6 +40598,12 @@ var init_protocol2 = __esm({
|
|
|
40554
40598
|
* reported version and falls back to its NDJSON store against an older runner.
|
|
40555
40599
|
*/
|
|
40556
40600
|
SessionLoadHistory: "session.loadHistory",
|
|
40601
|
+
/**
|
|
40602
|
+
* client->server: read one slice of an attachment whose bytes were left out
|
|
40603
|
+
* of the client's copy of an event (v26). `{ seq, index, offset }` →
|
|
40604
|
+
* `{ data, total }`; repeat with `offset += data.length` until `total`.
|
|
40605
|
+
*/
|
|
40606
|
+
SessionReadAttachment: "session.readAttachment",
|
|
40557
40607
|
/**
|
|
40558
40608
|
* client->server: append a conversation exchange that happened outside the
|
|
40559
40609
|
* agent loop (v20) — e.g. a GPT-Live voice turn — as one ordinary turn, so
|
|
@@ -40720,6 +40770,11 @@ var init_protocol2 = __esm({
|
|
|
40720
40770
|
before: z.number().int().nonnegative().nullable(),
|
|
40721
40771
|
limit: z.number().int().positive().max(MAX_HISTORY_PAGE_LIMIT)
|
|
40722
40772
|
});
|
|
40773
|
+
sessionReadAttachmentParamsSchema = z.object({
|
|
40774
|
+
seq: z.number().int().nonnegative(),
|
|
40775
|
+
index: z.number().int().nonnegative().max(1e3),
|
|
40776
|
+
offset: z.number().int().nonnegative()
|
|
40777
|
+
}).strict();
|
|
40723
40778
|
MAX_RECORDED_EXCHANGE_CHARS = 1e5;
|
|
40724
40779
|
recordedText = z.string().max(MAX_RECORDED_EXCHANGE_CHARS).optional();
|
|
40725
40780
|
sessionRecordExchangeParamsSchema = z.object({ userText: recordedText, assistantText: recordedText }).strict().refine(({ userText, assistantText }) => Boolean(userText?.trim() || assistantText?.trim()), { message: "An exchange needs user or assistant text" });
|
|
@@ -41100,8 +41155,6 @@ var init_surface_handlers = __esm({
|
|
|
41100
41155
|
init_protocol2();
|
|
41101
41156
|
}
|
|
41102
41157
|
});
|
|
41103
|
-
|
|
41104
|
-
// ../runner/dist/handlers/session-handlers.js
|
|
41105
41158
|
function handleModeSetActive(ctx, raw) {
|
|
41106
41159
|
const { name } = modeSetActiveParamsSchema.parse(raw);
|
|
41107
41160
|
ctx.session.modes.setActive(name);
|
|
@@ -41121,10 +41174,26 @@ function handleSessionSetFast(ctx, raw) {
|
|
|
41121
41174
|
async function handleSessionLoadHistory(ctx, raw) {
|
|
41122
41175
|
const { before, limit } = sessionLoadHistoryParamsSchema.parse(raw);
|
|
41123
41176
|
const log2 = ctx.session.log;
|
|
41124
|
-
|
|
41125
|
-
|
|
41126
|
-
|
|
41127
|
-
|
|
41177
|
+
const page = log2.baseSeq === 0 ? pageEvents(log2.toJSON(), before, limit) : await readEventPage(String(ctx.session.id), { before, limit }, ctx.sessionsDir);
|
|
41178
|
+
return historyPageForClient(page);
|
|
41179
|
+
}
|
|
41180
|
+
async function handleSessionReadAttachment(ctx, raw) {
|
|
41181
|
+
const { seq, index, offset } = sessionReadAttachmentParamsSchema.parse(raw);
|
|
41182
|
+
return readAttachmentChunk(await eventAt(ctx, seq), index, offset);
|
|
41183
|
+
}
|
|
41184
|
+
async function eventAt(ctx, seq) {
|
|
41185
|
+
const log2 = ctx.session.log;
|
|
41186
|
+
if (seq >= log2.baseSeq) {
|
|
41187
|
+
const inMemory = log2.slice(seq, seq + 1)[0];
|
|
41188
|
+
if (inMemory)
|
|
41189
|
+
return inMemory;
|
|
41190
|
+
throw new Error(`no event ${seq} in this session`);
|
|
41191
|
+
}
|
|
41192
|
+
const { events } = await readEventPage(String(ctx.session.id), { before: seq + 1, limit: 1 }, ctx.sessionsDir);
|
|
41193
|
+
const onDisk = events[0];
|
|
41194
|
+
if (onDisk && onDisk.seq === seq)
|
|
41195
|
+
return onDisk;
|
|
41196
|
+
throw new Error(`no event ${seq} in this session`);
|
|
41128
41197
|
}
|
|
41129
41198
|
async function handleSessionRecordExchange(ctx, raw) {
|
|
41130
41199
|
const exchange = sessionRecordExchangeParamsSchema.parse(raw);
|
|
@@ -41313,6 +41382,7 @@ var init_server2 = __esm({
|
|
|
41313
41382
|
peer.handle(RunnerMethod.Abort, (raw) => this.handleAbort(client2, raw));
|
|
41314
41383
|
peer.handle(RunnerMethod.SessionReset, () => this.handleSessionReset());
|
|
41315
41384
|
peer.handle(RunnerMethod.SessionLoadHistory, (raw) => handleSessionLoadHistory(ctx, raw));
|
|
41385
|
+
peer.handle(RunnerMethod.SessionReadAttachment, (raw) => handleSessionReadAttachment(ctx, raw));
|
|
41316
41386
|
peer.handle(RunnerMethod.SessionRecordExchange, (raw) => handleSessionRecordExchange(ctx, raw));
|
|
41317
41387
|
peer.handle(RunnerMethod.SessionSetAutoApprove, (raw) => handleSessionSetAutoApprove(ctx, raw));
|
|
41318
41388
|
peer.handle(RunnerMethod.SetResolver, (raw) => this.handleSetResolver(client2, raw));
|
|
@@ -41346,7 +41416,11 @@ var init_server2 = __esm({
|
|
|
41346
41416
|
peer.handle(RunnerMethod.SurfaceInput, (raw) => handleSurfaceInput(ctx, raw));
|
|
41347
41417
|
peer.handle(RunnerMethod.SurfaceResize, (raw) => handleSurfaceResize(ctx, raw));
|
|
41348
41418
|
peer.handle(RunnerMethod.SurfaceClose, (raw) => handleSurfaceClose(ctx, raw));
|
|
41349
|
-
peer.onClose(() =>
|
|
41419
|
+
peer.onClose((err) => {
|
|
41420
|
+
if (err)
|
|
41421
|
+
this.session.logger.warn("runner: client dropped", { role: client2.role, reason: err.message });
|
|
41422
|
+
this.onDisconnect(client2);
|
|
41423
|
+
});
|
|
41350
41424
|
}
|
|
41351
41425
|
onDisconnect(client2) {
|
|
41352
41426
|
this.clients.delete(client2);
|
|
@@ -41372,7 +41446,7 @@ var init_server2 = __esm({
|
|
|
41372
41446
|
const start = replay === "full" ? baseSeq : replay === "none" ? endSeq : Math.max(baseSeq, endSeq - replay.tail);
|
|
41373
41447
|
client2.peer.notify(RunnerNotification.ReplayStart, { fromSeq: start });
|
|
41374
41448
|
for (const event of this.session.log.slice(start)) {
|
|
41375
|
-
client2.peer.notify(RunnerNotification.Event, { event });
|
|
41449
|
+
client2.peer.notify(RunnerNotification.Event, { event: eventForClient(event) });
|
|
41376
41450
|
}
|
|
41377
41451
|
return {
|
|
41378
41452
|
sessionId: this.session.id,
|
|
@@ -41618,7 +41692,7 @@ var init_server2 = __esm({
|
|
|
41618
41692
|
}
|
|
41619
41693
|
// --- fan-out -------------------------------------------------------------
|
|
41620
41694
|
broadcastEvent(event) {
|
|
41621
|
-
this.broadcast(RunnerNotification.Event, { event });
|
|
41695
|
+
this.broadcast(RunnerNotification.Event, { event: eventForClient(event) });
|
|
41622
41696
|
}
|
|
41623
41697
|
broadcast(method, params) {
|
|
41624
41698
|
for (const client2 of this.clients) {
|
|
@@ -42540,6 +42614,19 @@ var init_remote_session = __esm({
|
|
|
42540
42614
|
limit
|
|
42541
42615
|
});
|
|
42542
42616
|
}
|
|
42617
|
+
/**
|
|
42618
|
+
* Read one slice of attachment `index` of event `seq` (v26) — the bytes a
|
|
42619
|
+
* client's copy of the event left out (`omittedBytes`). Call again with
|
|
42620
|
+
* `offset += data.length` until it reaches `total`.
|
|
42621
|
+
*/
|
|
42622
|
+
async readAttachment(seq, index, offset) {
|
|
42623
|
+
this.requireServerProtocol(26, "Opening large attachments");
|
|
42624
|
+
return this.peer.request(RunnerMethod.SessionReadAttachment, {
|
|
42625
|
+
seq,
|
|
42626
|
+
index,
|
|
42627
|
+
offset
|
|
42628
|
+
});
|
|
42629
|
+
}
|
|
42543
42630
|
/**
|
|
42544
42631
|
* Record a conversation exchange that happened outside the agent loop (v20),
|
|
42545
42632
|
* e.g. a GPT-Live voice turn. The runner appends it as one ordinary turn:
|
|
@@ -42703,6 +42790,7 @@ var init_dist18 = __esm({
|
|
|
42703
42790
|
"../runner/dist/index.js"() {
|
|
42704
42791
|
init_jsonrpc();
|
|
42705
42792
|
init_unix_socket();
|
|
42793
|
+
init_backlog_guard();
|
|
42706
42794
|
init_socket_path();
|
|
42707
42795
|
init_channel_runner();
|
|
42708
42796
|
init_server2();
|
|
@@ -89887,10 +89975,11 @@ async function createWebSocketTransportServer(opts) {
|
|
|
89887
89975
|
reservations.delete(socket);
|
|
89888
89976
|
};
|
|
89889
89977
|
const liveTransports = /* @__PURE__ */ new Set();
|
|
89978
|
+
const maxPayload = opts.maxPayloadBytes ?? 64 * 1024 * 1024;
|
|
89890
89979
|
const wss = new import_websocket_server.default({
|
|
89891
89980
|
host,
|
|
89892
89981
|
port: opts.port,
|
|
89893
|
-
maxPayload
|
|
89982
|
+
maxPayload,
|
|
89894
89983
|
verifyClient: (info) => {
|
|
89895
89984
|
if (!checkWsOrigin(info.req, currentAllowedOrigins)) {
|
|
89896
89985
|
console.warn(`[moxxy] ws bridge: rejected browser-origin upgrade (Origin: ${sanitizeForLog(info.req.headers.origin)})`);
|
|
@@ -89921,7 +90010,7 @@ async function createWebSocketTransportServer(opts) {
|
|
|
89921
90010
|
releaseReservation(req.socket);
|
|
89922
90011
|
connections += 1;
|
|
89923
90012
|
opts.onClientCountChange?.(connections);
|
|
89924
|
-
const transport = new WsTransport(ws, new SlowReaderGuard(opts.maxBufferedBytes, opts.bufferStallGraceMs));
|
|
90013
|
+
const transport = new WsTransport(ws, new SlowReaderGuard(opts.maxBufferedBytes, opts.bufferStallGraceMs, 4 * maxPayload));
|
|
89925
90014
|
liveTransports.add(transport);
|
|
89926
90015
|
ws.once("close", () => {
|
|
89927
90016
|
connections -= 1;
|
|
@@ -89980,39 +90069,20 @@ async function createWebSocketTransportServer(opts) {
|
|
|
89980
90069
|
}
|
|
89981
90070
|
};
|
|
89982
90071
|
}
|
|
89983
|
-
var DEFAULT_MAX_CONNECTIONS, DEFAULT_MAX_BUFFERED_BYTES, DEFAULT_BUFFER_STALL_GRACE_MS, RESERVATION_RECONCILE_MS,
|
|
90072
|
+
var DEFAULT_MAX_CONNECTIONS, DEFAULT_MAX_BUFFERED_BYTES, DEFAULT_BUFFER_STALL_GRACE_MS, RESERVATION_RECONCILE_MS, MAX_LOGGED_ORIGIN_LEN, SlowReaderGuard, WsTransport;
|
|
89984
90073
|
var init_ws_transport = __esm({
|
|
89985
90074
|
"../ipc-server-ws/dist/ws-transport.js"() {
|
|
89986
90075
|
init_wrapper();
|
|
90076
|
+
init_dist18();
|
|
89987
90077
|
init_auth();
|
|
89988
90078
|
DEFAULT_MAX_CONNECTIONS = 8;
|
|
89989
90079
|
DEFAULT_MAX_BUFFERED_BYTES = 4 * 1024 * 1024;
|
|
89990
90080
|
DEFAULT_BUFFER_STALL_GRACE_MS = 1e4;
|
|
89991
90081
|
RESERVATION_RECONCILE_MS = 1e4;
|
|
89992
|
-
SLOW_READER_HARD_MULTIPLIER = 4;
|
|
89993
90082
|
MAX_LOGGED_ORIGIN_LEN = 128;
|
|
89994
|
-
SlowReaderGuard = class {
|
|
89995
|
-
limitBytes
|
|
89996
|
-
|
|
89997
|
-
stalledSinceMs = null;
|
|
89998
|
-
hardLimitBytes;
|
|
89999
|
-
constructor(limitBytes = DEFAULT_MAX_BUFFERED_BYTES, graceMs = DEFAULT_BUFFER_STALL_GRACE_MS) {
|
|
90000
|
-
this.limitBytes = limitBytes;
|
|
90001
|
-
this.graceMs = graceMs;
|
|
90002
|
-
this.hardLimitBytes = limitBytes * SLOW_READER_HARD_MULTIPLIER;
|
|
90003
|
-
}
|
|
90004
|
-
check(bufferedAmount, nowMs) {
|
|
90005
|
-
if (bufferedAmount > this.hardLimitBytes)
|
|
90006
|
-
return "terminate";
|
|
90007
|
-
if (bufferedAmount <= this.limitBytes) {
|
|
90008
|
-
this.stalledSinceMs = null;
|
|
90009
|
-
return "ok";
|
|
90010
|
-
}
|
|
90011
|
-
if (this.stalledSinceMs === null) {
|
|
90012
|
-
this.stalledSinceMs = nowMs;
|
|
90013
|
-
return "ok";
|
|
90014
|
-
}
|
|
90015
|
-
return nowMs - this.stalledSinceMs >= this.graceMs ? "terminate" : "ok";
|
|
90083
|
+
SlowReaderGuard = class extends OutboundBacklogGuard {
|
|
90084
|
+
constructor(limitBytes = DEFAULT_MAX_BUFFERED_BYTES, graceMs = DEFAULT_BUFFER_STALL_GRACE_MS, hardLimitBytes) {
|
|
90085
|
+
super(limitBytes, graceMs, hardLimitBytes);
|
|
90016
90086
|
}
|
|
90017
90087
|
};
|
|
90018
90088
|
WsTransport = class {
|
|
@@ -90041,7 +90111,9 @@ var init_ws_transport = __esm({
|
|
|
90041
90111
|
return;
|
|
90042
90112
|
if (this.evictIfStalled())
|
|
90043
90113
|
return;
|
|
90044
|
-
|
|
90114
|
+
const payload2 = JSON.stringify(frame);
|
|
90115
|
+
this.ws.send(payload2);
|
|
90116
|
+
this.guard.recordSent(Buffer.byteLength(payload2));
|
|
90045
90117
|
}
|
|
90046
90118
|
/**
|
|
90047
90119
|
* Re-consult the slow-reader guard out of band (a periodic sweep), so a peer
|
|
@@ -90646,6 +90718,13 @@ var init_validation = __esm({
|
|
|
90646
90718
|
before: z.number().int().nonnegative().nullable(),
|
|
90647
90719
|
limit: z.number().int().positive().max(2e3)
|
|
90648
90720
|
}),
|
|
90721
|
+
// Reads the session log (runner or the JSONL on disk) — bound every index.
|
|
90722
|
+
"chat.readAttachment": z.object({
|
|
90723
|
+
workspaceId: z.string().min(1).max(256),
|
|
90724
|
+
seq: z.number().int().nonnegative(),
|
|
90725
|
+
index: z.number().int().nonnegative().max(1e3),
|
|
90726
|
+
offset: z.number().int().nonnegative()
|
|
90727
|
+
}).strict(),
|
|
90649
90728
|
// Collaboration control. All three touch the on-disk collab store
|
|
90650
90729
|
// (~/.moxxy/collab/{active.lock,runs}) — a filesystem-touching surface — so
|
|
90651
90730
|
// each gets the boundary check the module header promises:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moxxy/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"description": "moxxy command-line agent: TUI, one-shot prompts, setup, services, and API-key or installed-CLI subscription providers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"moxxy",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"undici": "^8.11.2",
|
|
51
51
|
"zod": "^3.25.76",
|
|
52
|
-
"@moxxy/sdk": "0.
|
|
52
|
+
"@moxxy/sdk": "0.44.0"
|
|
53
53
|
},
|
|
54
54
|
"optionalDependencies": {
|
|
55
55
|
"@napi-rs/keyring": "^2.1.0"
|