@moxxy/cli 0.49.0 → 0.49.1
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/README.md +3 -1
- package/dist/bin.js +404 -205
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ Desktop and interactive CLI setup can start sign-in. Headless runners/services g
|
|
|
91
91
|
|
|
92
92
|
1. Install the Codex CLI so `codex` is on `PATH` (or set `CODEX_EXECUTABLE=/absolute/path/to/codex`).
|
|
93
93
|
2. Run `codex login` or `moxxy login codex-agent`, then confirm with `codex login status` and `moxxy doctor`.
|
|
94
|
-
3. Select "ChatGPT — Codex agent" (`codex-agent`) in `moxxy init`.
|
|
94
|
+
3. Select "ChatGPT — Codex agent" (`codex-agent`) in `moxxy init`. A new conversation starts on `gpt-6-luna` by default. Choose a model per run with `--model` or save a default in `plugins.provider.items.codex-agent.model`.
|
|
95
95
|
|
|
96
96
|
Codex itself does each turn through `codex app-server`, with its own instructions, config, tools, skills and MCP servers. Moxxy shows Codex's approvals and questions, shows its plan in plan mode, ends goal mode when Codex's own goal is met, and lends Codex its own tools over a local MCP server. Auto-approve shows how your Codex really runs from the moment a conversation opens (Moxxy asks a short-lived `codex app-server` for the folder's config), gives only the current conversation's Codex full access, and stays as you set it; `~/.codex/config.toml` is never edited. Your reason for declining reaches Codex, fast mode runs it on its fast tier, and Stop interrupts its turn, tools included.
|
|
97
97
|
|
|
@@ -166,6 +166,8 @@ The CLI groups commands the same way `moxxy --help` does.
|
|
|
166
166
|
| `moxxy channels` | List registered channels and their subcommands. |
|
|
167
167
|
| `moxxy serve` | Start every channel together with the scheduler and webhooks in one process. |
|
|
168
168
|
|
|
169
|
+
When a runner is already serving the session, `moxxy tui` receives the selected conversation over its socket. The terminal opens after it has received the history in order. Other connected clients can continue working during this transfer.
|
|
170
|
+
|
|
169
171
|
### Manage
|
|
170
172
|
|
|
171
173
|
| Command | What it does |
|
package/dist/bin.js
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import crypto, { scrypt, createHash, randomUUID, randomBytes, createCipheriv, createDecipheriv, createHmac, timingSafeEqual } from 'crypto';
|
|
4
4
|
import * as fs43 from 'fs';
|
|
5
|
-
import fs43__default, { promises, readFileSync, existsSync, statSync, readdirSync, mkdirSync, writeFileSync, realpathSync, unlinkSync, lstatSync, constants as constants$1, watch as watch$1 } from 'fs';
|
|
5
|
+
import fs43__default, { promises, readFileSync, existsSync, statSync, readdirSync, mkdirSync, writeFileSync, realpathSync, unlinkSync, createReadStream, lstatSync, constants as constants$1, watch as watch$1 } from 'fs';
|
|
6
6
|
import * as path3 from 'path';
|
|
7
7
|
import path3__default, { dirname, join, posix, resolve, relative, sep, isAbsolute } from 'path';
|
|
8
8
|
import { utf8Locale, ensurePrivateDir, moxxyHome, pruneStaleTempFiles, moxxyPath, hasProxy, installEgressProxy, readProxyEnv, writeFileAtomic, ensurePrivateFile, killTree as killTree$1, liveChannelStatus, spawnDedicatedChannel, stopDedicatedChannel, clearChannelStatus, findExecutable, PRIVATE_FILE_MODE, resolveOsPrincipal, redactProxyUrl, resolveExecutableTarget, spawnExecutableTarget, listLiveChannelStatuses, rotateChannelToken, writeSignedNetworkCacheAtomic, CrossProcessFireLock, fetchNpmLatest, writeChannelStatus, withFileLock, writeBoundedNetworkCacheAtomicSync, writeBoundedDataCacheAtomic, readRequestBody, bearerTokenMatches } from '@moxxy/sdk/server';
|
|
9
9
|
import { spawn, spawnSync, execFile } from 'child_process';
|
|
10
10
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
11
|
-
import { MoxxyError, createMutex, defineChannel, definePlugin, defineViewRenderer, DEFAULT_VIEW_TAGS, defineTunnelProvider, defineAuditExporter, defineAuditSink, z as z$1, withAgentConduct, questionAnswersSchema, defineTool, defineEmbedder, defineMode, asPluginId, computerControlSnapshotSchema, createDeferredPermissionResolver, isSafeViewUrl, redactSecrets, questionAnswerDisplay, describeQuestionAnswers, searchConversation, conversationTurns, asTurnId, waitFor, unfinishedWorkCheckpoint, unfinishedStepCheckpoint, runReactLoop, defineCompactor, abortError, activeCompactionRanges, defineCacheStrategy, runManualCompaction, assertDefined, defineWorkflowExecutor, MOXXY_PCM16_24KHZ_MIME, isAgentNoReplyEvent, AGENT_NO_REPLY_TEXT, accountLimitOfEvent, isFileDiffDisplay, questionAnswerLines, stepListProgress, startingModel, fileDiffFromText, findAttachment, listAttachments, summarizeWithProvider, toolResultBytes, isSelectableMode, summarizeSessionTokensFromEvents, summarizeTokensByModel, getInstallHint, toDiffRows, diffGutterNo, fileDiffVerb, fileDiffSummary, openQuestionsFromEvents, emptyDraft, questionAnswersProblem, draftAnswers, computeElisionState, toolResultStubbed, toolResultStubText, conversationalStubbed, conversationalStub, chooseOption, typeOwnAnswer, isFirstPartyPackage, REDACTED_PLACEHOLDER, isSecretKey, addModelTotals, skillFrontmatterSchema, asSkillId, parseFrontmatter, denyByDefaultResolver, createCallbackResolver, createAllowListResolver, countNodes, autoAllowResolver, SESSION_SOURCES, startChannelWith, EXIT_AFTER_PAIR_FLAG, renderFrontmatter, formatPrincipal, aggregateCapabilitySpecs, hostCredentialName, verifyEd25519, mentionedSkills, skillAttachment, withoutTools, toolsForMode, moxxyPackageSchema, auditActionOf, asToolCallId, dispatchToolCall, matchLoadableTools, defineSecretProvider, encodeLoginAuthUrl, redactSecretText, encodeLoginPrompt, defineCommand, ISOLATION_RANK, sleepWithAbort, asSessionId, migrateModeName, autoApproveFromEvents, AUTO_APPROVE_SUBTYPE, AUTO_APPROVE_PLUGIN_ID, autoApproveFromAgent, autoApproveRecorded, agentActivityRecord, withRecordedContextWindows, recordedContextWindows, parseFrontmatterFile, createJsonFileStore,
|
|
11
|
+
import { MoxxyError, createMutex, defineChannel, definePlugin, defineViewRenderer, DEFAULT_VIEW_TAGS, defineTunnelProvider, defineAuditExporter, defineAuditSink, z as z$1, withAgentConduct, questionAnswersSchema, defineTool, defineEmbedder, defineMode, asPluginId, computerControlSnapshotSchema, createDeferredPermissionResolver, isSafeViewUrl, redactSecrets, questionAnswerDisplay, describeQuestionAnswers, searchConversation, conversationTurns, asTurnId, waitFor, unfinishedWorkCheckpoint, unfinishedStepCheckpoint, runReactLoop, defineCompactor, abortError, activeCompactionRanges, defineCacheStrategy, runManualCompaction, assertDefined, defineWorkflowExecutor, MOXXY_PCM16_24KHZ_MIME, isAgentNoReplyEvent, AGENT_NO_REPLY_TEXT, accountLimitOfEvent, isFileDiffDisplay, questionAnswerLines, stepListProgress, startingModel, fileDiffFromText, findAttachment, listAttachments, summarizeWithProvider, toolResultBytes, isSelectableMode, summarizeSessionTokensFromEvents, summarizeTokensByModel, getInstallHint, toDiffRows, diffGutterNo, fileDiffVerb, fileDiffSummary, openQuestionsFromEvents, emptyDraft, questionAnswersProblem, draftAnswers, computeElisionState, toolResultStubbed, toolResultStubText, conversationalStubbed, conversationalStub, chooseOption, typeOwnAnswer, isFirstPartyPackage, REDACTED_PLACEHOLDER, isSecretKey, addModelTotals, skillFrontmatterSchema, asSkillId, parseFrontmatter, denyByDefaultResolver, createCallbackResolver, createAllowListResolver, countNodes, autoAllowResolver, SESSION_SOURCES, startChannelWith, EXIT_AFTER_PAIR_FLAG, renderFrontmatter, formatPrincipal, aggregateCapabilitySpecs, hostCredentialName, verifyEd25519, mentionedSkills, skillAttachment, withoutTools, toolsForMode, moxxyPackageSchema, auditActionOf, asToolCallId, dispatchToolCall, matchLoadableTools, defineSecretProvider, encodeLoginAuthUrl, redactSecretText, encodeLoginPrompt, defineCommand, ISOLATION_RANK, sleepWithAbort, asSessionId, migrateModeName, autoApproveFromEvents, AUTO_APPROVE_SUBTYPE, AUTO_APPROVE_PLUGIN_ID, autoApproveFromAgent, autoApproveRecorded, agentActivityRecord, withRecordedContextWindows, recordedContextWindows, parseFrontmatterFile, createJsonFileStore, eventForClient, autoApproveSwitch, computerControlCommandSchema, historyPageForClient, readAttachmentChunk, computerApprovalFocusSchema, workflowApprovalItemsSchema, evaluateToolRule, asEventId, QUESTION_ASKED, questionCloseNote, QUESTION_RESOLVED, QUESTION_CLOSED_NEW_MESSAGE as QUESTION_CLOSED_NEW_MESSAGE$1, questionRecord as questionRecord$1, QUESTION_PLUGIN_ID } from '@moxxy/sdk';
|
|
12
12
|
import { createRequire as createRequire$1 } from 'module';
|
|
13
13
|
import { z } from 'zod/v3';
|
|
14
14
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
15
15
|
import { readFile, rm, mkdtemp, writeFile, mkdir, open, readdir, unlink, link, rename, stat, access, constants as constants$2, realpath } from 'fs/promises';
|
|
16
|
-
import { setTimeout as setTimeout$1 } from 'timers/promises';
|
|
16
|
+
import { setTimeout as setTimeout$1, setImmediate as setImmediate$1 } from 'timers/promises';
|
|
17
17
|
import { styleText, promisify, stripVTControlCharacters } from 'util';
|
|
18
18
|
import * as readline from 'readline/promises';
|
|
19
19
|
import { isValidCron, isValidTimeZone, firstFireBetween, nextFireTime } from '@moxxy/sdk/cron';
|
|
@@ -18941,6 +18941,29 @@ var init_event_shape = __esm({
|
|
|
18941
18941
|
]));
|
|
18942
18942
|
}
|
|
18943
18943
|
});
|
|
18944
|
+
async function* readLines(file, chunkBytes = DEFAULT_CHUNK_BYTES) {
|
|
18945
|
+
const stream2 = createReadStream(file, { highWaterMark: chunkBytes });
|
|
18946
|
+
let pending = [];
|
|
18947
|
+
for await (const chunk of stream2) {
|
|
18948
|
+
let start = 0;
|
|
18949
|
+
for (let end = chunk.indexOf(NEWLINE); end !== -1; end = chunk.indexOf(NEWLINE, start)) {
|
|
18950
|
+
pending.push(chunk.subarray(start, end));
|
|
18951
|
+
yield Buffer.concat(pending).toString("utf8");
|
|
18952
|
+
pending = [];
|
|
18953
|
+
start = end + 1;
|
|
18954
|
+
}
|
|
18955
|
+
if (start < chunk.length)
|
|
18956
|
+
pending.push(chunk.subarray(start));
|
|
18957
|
+
}
|
|
18958
|
+
yield Buffer.concat(pending).toString("utf8");
|
|
18959
|
+
}
|
|
18960
|
+
var NEWLINE, DEFAULT_CHUNK_BYTES;
|
|
18961
|
+
var init_jsonl_lines = __esm({
|
|
18962
|
+
"../core/dist/sessions/jsonl-lines.js"() {
|
|
18963
|
+
NEWLINE = 10;
|
|
18964
|
+
DEFAULT_CHUNK_BYTES = 1024 * 1024;
|
|
18965
|
+
}
|
|
18966
|
+
});
|
|
18944
18967
|
function defaultSessionsDir() {
|
|
18945
18968
|
return moxxyPath("sessions");
|
|
18946
18969
|
}
|
|
@@ -18969,6 +18992,13 @@ async function readIndex(dir = defaultSessionsDir()) {
|
|
|
18969
18992
|
const hydrated = await mapWithConcurrency2(present2, READ_INDEX_CONCURRENCY, (meta) => hydrateMetaFirstPrompt(meta, dir));
|
|
18970
18993
|
return hydrated.sort((a2, b3) => b3.lastActivity.localeCompare(a2.lastActivity));
|
|
18971
18994
|
}
|
|
18995
|
+
async function readSessionMeta(sessionId, dir = defaultSessionsDir()) {
|
|
18996
|
+
const { metas, logs } = await readSessionsDir(dir);
|
|
18997
|
+
const meta = metas.find((entry) => entry.id === sessionId);
|
|
18998
|
+
if (!meta || !logs.has(meta.id))
|
|
18999
|
+
return null;
|
|
19000
|
+
return hydrateMetaFirstPrompt(meta, dir);
|
|
19001
|
+
}
|
|
18972
19002
|
async function hydrateMetaFirstPrompt(meta, dir) {
|
|
18973
19003
|
const stats = await matchingSessionStatsFromLog(meta.id, path3.join(dir, `${meta.id}.jsonl`));
|
|
18974
19004
|
if (!stats)
|
|
@@ -18983,27 +19013,35 @@ async function hydrateMetaFirstPrompt(meta, dir) {
|
|
|
18983
19013
|
model: stats.model ?? meta.model
|
|
18984
19014
|
};
|
|
18985
19015
|
}
|
|
18986
|
-
function
|
|
19016
|
+
function sessionStatsFold(sessionId) {
|
|
18987
19017
|
let eventCount = 0;
|
|
18988
19018
|
let parsedEvents = 0;
|
|
18989
19019
|
let firstPrompt = null;
|
|
18990
19020
|
let provider = null;
|
|
18991
19021
|
let model = null;
|
|
18992
|
-
|
|
18993
|
-
|
|
18994
|
-
|
|
18995
|
-
|
|
18996
|
-
|
|
18997
|
-
|
|
18998
|
-
firstPrompt
|
|
18999
|
-
|
|
19000
|
-
|
|
19001
|
-
|
|
19002
|
-
|
|
19003
|
-
|
|
19004
|
-
|
|
19005
|
-
|
|
19006
|
-
|
|
19022
|
+
return {
|
|
19023
|
+
add(event) {
|
|
19024
|
+
parsedEvents += 1;
|
|
19025
|
+
if (!eventBelongsToSession(event, sessionId))
|
|
19026
|
+
return;
|
|
19027
|
+
eventCount += 1;
|
|
19028
|
+
if (firstPrompt === null && event.type === "user_prompt") {
|
|
19029
|
+
firstPrompt = firstPromptLabel(event.text);
|
|
19030
|
+
}
|
|
19031
|
+
const header = providerHeaderFromEvent(event);
|
|
19032
|
+
if (header.provider !== void 0)
|
|
19033
|
+
provider = header.provider;
|
|
19034
|
+
if (header.model !== void 0)
|
|
19035
|
+
model = header.model;
|
|
19036
|
+
},
|
|
19037
|
+
result: () => ({ eventCount, firstPrompt, parsedEvents, provider, model })
|
|
19038
|
+
};
|
|
19039
|
+
}
|
|
19040
|
+
function statsFromEvents(sessionId, events) {
|
|
19041
|
+
const fold = sessionStatsFold(sessionId);
|
|
19042
|
+
for (const event of events)
|
|
19043
|
+
fold.add(event);
|
|
19044
|
+
return fold.result();
|
|
19007
19045
|
}
|
|
19008
19046
|
function statsFromEventLogLike(sessionId, log2) {
|
|
19009
19047
|
const snapshot = log2;
|
|
@@ -19012,24 +19050,45 @@ function statsFromEventLogLike(sessionId, log2) {
|
|
|
19012
19050
|
return statsFromEvents(sessionId, snapshot.slice());
|
|
19013
19051
|
}
|
|
19014
19052
|
async function matchingSessionStatsFromLog(sessionId, logPath) {
|
|
19015
|
-
|
|
19053
|
+
const fold = sessionStatsFold(sessionId);
|
|
19016
19054
|
try {
|
|
19017
|
-
|
|
19055
|
+
for await (const line of readLines(logPath)) {
|
|
19056
|
+
const parsed = parseEventLine(line);
|
|
19057
|
+
if (isMoxxyEventShape(parsed))
|
|
19058
|
+
fold.add(parsed);
|
|
19059
|
+
}
|
|
19018
19060
|
} catch {
|
|
19019
19061
|
return null;
|
|
19020
19062
|
}
|
|
19021
|
-
|
|
19022
|
-
|
|
19023
|
-
|
|
19024
|
-
|
|
19025
|
-
|
|
19026
|
-
|
|
19027
|
-
|
|
19028
|
-
|
|
19029
|
-
|
|
19030
|
-
}
|
|
19063
|
+
return fold.result();
|
|
19064
|
+
}
|
|
19065
|
+
function parseEventLine(line) {
|
|
19066
|
+
if (!line.trim())
|
|
19067
|
+
return void 0;
|
|
19068
|
+
try {
|
|
19069
|
+
return JSON.parse(line);
|
|
19070
|
+
} catch {
|
|
19071
|
+
return void 0;
|
|
19031
19072
|
}
|
|
19032
|
-
|
|
19073
|
+
}
|
|
19074
|
+
function textDigest() {
|
|
19075
|
+
const hash = createHash("sha256");
|
|
19076
|
+
let first = true;
|
|
19077
|
+
return {
|
|
19078
|
+
add(line) {
|
|
19079
|
+
if (!first)
|
|
19080
|
+
hash.update("\n");
|
|
19081
|
+
hash.update(line);
|
|
19082
|
+
first = false;
|
|
19083
|
+
},
|
|
19084
|
+
digest: () => hash.digest("hex")
|
|
19085
|
+
};
|
|
19086
|
+
}
|
|
19087
|
+
async function logDigest(logPath) {
|
|
19088
|
+
const digest = textDigest();
|
|
19089
|
+
for await (const line of readLines(logPath))
|
|
19090
|
+
digest.add(line);
|
|
19091
|
+
return digest.digest();
|
|
19033
19092
|
}
|
|
19034
19093
|
function providerHeaderFromEvent(event) {
|
|
19035
19094
|
if (event.type !== "provider_request" && event.type !== "provider_response")
|
|
@@ -19042,22 +19101,24 @@ function providerHeaderFromEvent(event) {
|
|
|
19042
19101
|
async function restoreEvents(sessionId, dir = defaultSessionsDir(), logger = createLogger()) {
|
|
19043
19102
|
assertSafeSessionId(sessionId);
|
|
19044
19103
|
const logPath = path3.join(dir, `${sessionId}.jsonl`);
|
|
19045
|
-
let raw;
|
|
19046
|
-
try {
|
|
19047
|
-
raw = await promises.readFile(logPath, "utf8");
|
|
19048
|
-
} catch {
|
|
19049
|
-
throw new Error(`Session not found: ${sessionId}`);
|
|
19050
|
-
}
|
|
19051
19104
|
const events = [];
|
|
19052
19105
|
let corruptLines = 0;
|
|
19053
19106
|
let invalidShapeLines = 0;
|
|
19054
19107
|
let foreignEvents = 0;
|
|
19055
19108
|
let normalizedSessionIds = 0;
|
|
19056
|
-
|
|
19057
|
-
|
|
19058
|
-
|
|
19059
|
-
|
|
19060
|
-
|
|
19109
|
+
const readDigest = textDigest();
|
|
19110
|
+
try {
|
|
19111
|
+
for await (const line of readLines(logPath)) {
|
|
19112
|
+
readDigest.add(line);
|
|
19113
|
+
if (!line.trim())
|
|
19114
|
+
continue;
|
|
19115
|
+
let parsed;
|
|
19116
|
+
try {
|
|
19117
|
+
parsed = JSON.parse(line);
|
|
19118
|
+
} catch {
|
|
19119
|
+
corruptLines += 1;
|
|
19120
|
+
continue;
|
|
19121
|
+
}
|
|
19061
19122
|
if (!isMoxxyEventShape(parsed)) {
|
|
19062
19123
|
invalidShapeLines += 1;
|
|
19063
19124
|
continue;
|
|
@@ -19070,10 +19131,11 @@ async function restoreEvents(sessionId, dir = defaultSessionsDir(), logger = cre
|
|
|
19070
19131
|
} else {
|
|
19071
19132
|
foreignEvents += 1;
|
|
19072
19133
|
}
|
|
19073
|
-
} catch {
|
|
19074
|
-
corruptLines += 1;
|
|
19075
19134
|
}
|
|
19135
|
+
} catch {
|
|
19136
|
+
throw new Error(`Session not found: ${sessionId}`);
|
|
19076
19137
|
}
|
|
19138
|
+
const originalDigest = readDigest.digest();
|
|
19077
19139
|
let resequenced = 0;
|
|
19078
19140
|
for (let i2 = 0; i2 < events.length; i2 += 1) {
|
|
19079
19141
|
if (events[i2].seq !== i2) {
|
|
@@ -19107,16 +19169,19 @@ async function restoreEvents(sessionId, dir = defaultSessionsDir(), logger = cre
|
|
|
19107
19169
|
}
|
|
19108
19170
|
}
|
|
19109
19171
|
try {
|
|
19110
|
-
const current2 = await
|
|
19172
|
+
const current2 = await logDigest(logPath).catch(() => null);
|
|
19111
19173
|
if (!canRewrite) {
|
|
19112
|
-
} else if (current2 !==
|
|
19174
|
+
} else if (current2 !== originalDigest) {
|
|
19113
19175
|
logger.warn("skipped repaired-log rewrite \u2014 file changed under us (another process attached?)", {
|
|
19114
19176
|
sessionId,
|
|
19115
19177
|
path: logPath
|
|
19116
19178
|
});
|
|
19117
19179
|
} else {
|
|
19118
|
-
|
|
19119
|
-
|
|
19180
|
+
function* repairedLines() {
|
|
19181
|
+
for (const event of events)
|
|
19182
|
+
yield JSON.stringify(event) + "\n";
|
|
19183
|
+
}
|
|
19184
|
+
await writeFileAtomic(logPath, repairedLines(), { mode: PRIVATE_FILE_MODE });
|
|
19120
19185
|
}
|
|
19121
19186
|
} catch (err) {
|
|
19122
19187
|
logger.warn("failed to rewrite repaired session log on disk", {
|
|
@@ -19131,22 +19196,15 @@ async function restoreEvents(sessionId, dir = defaultSessionsDir(), logger = cre
|
|
|
19131
19196
|
async function readEventPage(sessionId, opts, dir = defaultSessionsDir()) {
|
|
19132
19197
|
assertSafeSessionId(sessionId);
|
|
19133
19198
|
const logPath = path3.join(dir, `${sessionId}.jsonl`);
|
|
19134
|
-
let raw;
|
|
19135
|
-
try {
|
|
19136
|
-
raw = await promises.readFile(logPath, "utf8");
|
|
19137
|
-
} catch {
|
|
19138
|
-
return { events: [], prevCursor: null };
|
|
19139
|
-
}
|
|
19140
19199
|
const all = [];
|
|
19141
|
-
|
|
19142
|
-
|
|
19143
|
-
|
|
19144
|
-
try {
|
|
19145
|
-
const parsed = JSON.parse(line);
|
|
19200
|
+
try {
|
|
19201
|
+
for await (const line of readLines(logPath)) {
|
|
19202
|
+
const parsed = parseEventLine(line);
|
|
19146
19203
|
if (isMoxxyEventShape(parsed))
|
|
19147
19204
|
all.push(parsed);
|
|
19148
|
-
} catch {
|
|
19149
19205
|
}
|
|
19206
|
+
} catch {
|
|
19207
|
+
return { events: [], prevCursor: null };
|
|
19150
19208
|
}
|
|
19151
19209
|
return pageEvents(all, opts.before, opts.limit);
|
|
19152
19210
|
}
|
|
@@ -19334,6 +19392,7 @@ var init_persistence = __esm({
|
|
|
19334
19392
|
"../core/dist/sessions/persistence.js"() {
|
|
19335
19393
|
init_logger();
|
|
19336
19394
|
init_event_shape();
|
|
19395
|
+
init_jsonl_lines();
|
|
19337
19396
|
SESSION_META_VERSION = 1;
|
|
19338
19397
|
SAFE_SESSION_ID = /^[A-Za-z0-9_-]+$/;
|
|
19339
19398
|
READ_INDEX_CONCURRENCY = 32;
|
|
@@ -22557,6 +22616,7 @@ __export(dist_exports2, {
|
|
|
22557
22616
|
readPackageMoxxyRequirements: () => readPackageMoxxyRequirements,
|
|
22558
22617
|
readSessionEventPage: () => readEventPage,
|
|
22559
22618
|
readSessionIndex: () => readIndex,
|
|
22619
|
+
readSessionMeta: () => readSessionMeta,
|
|
22560
22620
|
resetAuditHeadForTests: () => resetAuditHeadForTests,
|
|
22561
22621
|
resolveTurnModel: () => resolveTurnModel,
|
|
22562
22622
|
restoreSessionEvents: () => restoreEvents,
|
|
@@ -23702,8 +23762,7 @@ var init_provider_catalog_generated = __esm({
|
|
|
23702
23762
|
}
|
|
23703
23763
|
],
|
|
23704
23764
|
"provider": {
|
|
23705
|
-
"auth": "oauth"
|
|
23706
|
-
"defaultModel": "gpt-6-astra"
|
|
23765
|
+
"auth": "oauth"
|
|
23707
23766
|
}
|
|
23708
23767
|
},
|
|
23709
23768
|
{
|
|
@@ -32639,7 +32698,7 @@ var require_websocket = __commonJS({
|
|
|
32639
32698
|
var http = __require("http");
|
|
32640
32699
|
var net3 = __require("net");
|
|
32641
32700
|
var tls = __require("tls");
|
|
32642
|
-
var { randomBytes: randomBytes8, createHash:
|
|
32701
|
+
var { randomBytes: randomBytes8, createHash: createHash12 } = __require("crypto");
|
|
32643
32702
|
var { Duplex, Readable } = __require("stream");
|
|
32644
32703
|
var { URL: URL2 } = __require("url");
|
|
32645
32704
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -33320,7 +33379,7 @@ var require_websocket = __commonJS({
|
|
|
33320
33379
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
33321
33380
|
return;
|
|
33322
33381
|
}
|
|
33323
|
-
const digest =
|
|
33382
|
+
const digest = createHash12("sha1").update(key + GUID).digest("base64");
|
|
33324
33383
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
33325
33384
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
33326
33385
|
return;
|
|
@@ -33686,7 +33745,7 @@ var require_websocket_server = __commonJS({
|
|
|
33686
33745
|
var EventEmitter3 = __require("events");
|
|
33687
33746
|
var http = __require("http");
|
|
33688
33747
|
var { Duplex } = __require("stream");
|
|
33689
|
-
var { createHash:
|
|
33748
|
+
var { createHash: createHash12 } = __require("crypto");
|
|
33690
33749
|
var extension2 = require_extension();
|
|
33691
33750
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
33692
33751
|
var subprotocol2 = require_subprotocol();
|
|
@@ -33993,7 +34052,7 @@ var require_websocket_server = __commonJS({
|
|
|
33993
34052
|
);
|
|
33994
34053
|
}
|
|
33995
34054
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
33996
|
-
const digest =
|
|
34055
|
+
const digest = createHash12("sha1").update(key + GUID).digest("base64");
|
|
33997
34056
|
const headers = [
|
|
33998
34057
|
"HTTP/1.1 101 Switching Protocols",
|
|
33999
34058
|
"Upgrade: websocket",
|
|
@@ -87997,7 +88056,7 @@ async function applySessionHeaderPreferences(session, sessionId, credentialResol
|
|
|
87997
88056
|
if (!sessionId) return;
|
|
87998
88057
|
let meta = null;
|
|
87999
88058
|
try {
|
|
88000
|
-
meta =
|
|
88059
|
+
meta = await readSessionMeta(sessionId);
|
|
88001
88060
|
} catch (err) {
|
|
88002
88061
|
logger.warn("failed to load sticky session metadata", {
|
|
88003
88062
|
sessionId,
|
|
@@ -89067,6 +89126,10 @@ var init_jsonrpc = __esm({
|
|
|
89067
89126
|
}
|
|
89068
89127
|
/** Register a request handler. Last registration for a method wins. */
|
|
89069
89128
|
handle(method, handler) {
|
|
89129
|
+
this.handleWithReply(method, async (params, reply) => reply(await handler(params, this)));
|
|
89130
|
+
}
|
|
89131
|
+
/** Lets a streaming handler send its reply in the same turn as its final notification. */
|
|
89132
|
+
handleWithReply(method, handler) {
|
|
89070
89133
|
this.requestHandlers.set(method, handler);
|
|
89071
89134
|
}
|
|
89072
89135
|
/** Register a notification handler. */
|
|
@@ -89151,7 +89214,8 @@ var init_jsonrpc = __esm({
|
|
|
89151
89214
|
};
|
|
89152
89215
|
this.transport.send(frame);
|
|
89153
89216
|
}
|
|
89154
|
-
close() {
|
|
89217
|
+
close(reason) {
|
|
89218
|
+
this.handleClose(reason);
|
|
89155
89219
|
this.transport.close();
|
|
89156
89220
|
}
|
|
89157
89221
|
async handleFrame(frame) {
|
|
@@ -89188,10 +89252,17 @@ var init_jsonrpc = __esm({
|
|
|
89188
89252
|
this.transport.send({ id, error: { message: `unknown method: ${method}` } });
|
|
89189
89253
|
return;
|
|
89190
89254
|
}
|
|
89255
|
+
let replied = false;
|
|
89191
89256
|
try {
|
|
89192
|
-
|
|
89193
|
-
|
|
89257
|
+
await handler(params, (result) => {
|
|
89258
|
+
if (replied || this.closed)
|
|
89259
|
+
return;
|
|
89260
|
+
this.transport.send({ id, result: result === void 0 ? null : result });
|
|
89261
|
+
replied = true;
|
|
89262
|
+
});
|
|
89194
89263
|
} catch (err) {
|
|
89264
|
+
if (replied || this.closed)
|
|
89265
|
+
return;
|
|
89195
89266
|
const message = err instanceof Error ? err.message : String(err);
|
|
89196
89267
|
const data = err instanceof RpcError ? err.data : void 0;
|
|
89197
89268
|
this.transport.send({ id, error: { message, ...data !== void 0 ? { data } : {} } });
|
|
@@ -89218,9 +89289,10 @@ var init_jsonrpc = __esm({
|
|
|
89218
89289
|
});
|
|
89219
89290
|
|
|
89220
89291
|
// ../runner/dist/backlog-guard.js
|
|
89221
|
-
var OutboundBacklogGuard;
|
|
89292
|
+
var MAX_OUTBOUND_HARD_BYTES, OutboundBacklogGuard;
|
|
89222
89293
|
var init_backlog_guard = __esm({
|
|
89223
89294
|
"../runner/dist/backlog-guard.js"() {
|
|
89295
|
+
MAX_OUTBOUND_HARD_BYTES = 256 * 1024 * 1024;
|
|
89224
89296
|
OutboundBacklogGuard = class {
|
|
89225
89297
|
limitBytes;
|
|
89226
89298
|
graceMs;
|
|
@@ -89320,7 +89392,7 @@ async function createUnixSocketServer(socketPath, logger = stderrLogger, limits
|
|
|
89320
89392
|
}
|
|
89321
89393
|
let connectionHandler;
|
|
89322
89394
|
const server = net2.createServer((socket) => {
|
|
89323
|
-
const transport = new NdjsonTransport(socket, limits.maxInboundFrameBytes, limits.maxOutboundBufferBytes, limits.outboundStallGraceMs);
|
|
89395
|
+
const transport = new NdjsonTransport(socket, limits.maxInboundFrameBytes, limits.maxOutboundBufferBytes, limits.outboundStallGraceMs, limits.maxOutboundHardBytes);
|
|
89324
89396
|
connectionHandler?.(transport);
|
|
89325
89397
|
});
|
|
89326
89398
|
await new Promise((resolve20, reject) => {
|
|
@@ -89428,7 +89500,7 @@ async function reclaimStaleSocket(socketPath) {
|
|
|
89428
89500
|
} catch {
|
|
89429
89501
|
}
|
|
89430
89502
|
}
|
|
89431
|
-
var stderrLogger, DEFAULT_MAX_INBOUND_FRAME_BYTES, DEFAULT_MAX_OUTBOUND_BUFFER_BYTES, DEFAULT_OUTBOUND_STALL_GRACE_MS,
|
|
89503
|
+
var stderrLogger, DEFAULT_MAX_INBOUND_FRAME_BYTES, DEFAULT_MAX_OUTBOUND_BUFFER_BYTES, DEFAULT_OUTBOUND_STALL_GRACE_MS, NdjsonTransport, DEFAULT_CONNECT_TIMEOUT_MS, warnedWindowsPipeAcl;
|
|
89432
89504
|
var init_unix_socket = __esm({
|
|
89433
89505
|
"../runner/dist/unix-socket.js"() {
|
|
89434
89506
|
init_backlog_guard();
|
|
@@ -89442,19 +89514,21 @@ var init_unix_socket = __esm({
|
|
|
89442
89514
|
DEFAULT_MAX_INBOUND_FRAME_BYTES = 64 * 1024 * 1024;
|
|
89443
89515
|
DEFAULT_MAX_OUTBOUND_BUFFER_BYTES = 4 * 1024 * 1024;
|
|
89444
89516
|
DEFAULT_OUTBOUND_STALL_GRACE_MS = 1e4;
|
|
89445
|
-
DEFAULT_MAX_OUTBOUND_HARD_BYTES = 4 * DEFAULT_MAX_INBOUND_FRAME_BYTES;
|
|
89446
89517
|
NdjsonTransport = class {
|
|
89447
89518
|
socket;
|
|
89448
89519
|
maxInboundFrameBytes;
|
|
89520
|
+
outboundStallGraceMs;
|
|
89449
89521
|
buffer = "";
|
|
89450
89522
|
frameHandler;
|
|
89451
89523
|
closeHandler;
|
|
89452
89524
|
closedEmitted = false;
|
|
89525
|
+
waitingForDrain = false;
|
|
89453
89526
|
outbound;
|
|
89454
|
-
constructor(socket, maxInboundFrameBytes = DEFAULT_MAX_INBOUND_FRAME_BYTES, maxOutboundBufferBytes = DEFAULT_MAX_OUTBOUND_BUFFER_BYTES, outboundStallGraceMs = DEFAULT_OUTBOUND_STALL_GRACE_MS) {
|
|
89527
|
+
constructor(socket, maxInboundFrameBytes = DEFAULT_MAX_INBOUND_FRAME_BYTES, maxOutboundBufferBytes = DEFAULT_MAX_OUTBOUND_BUFFER_BYTES, outboundStallGraceMs = DEFAULT_OUTBOUND_STALL_GRACE_MS, maxOutboundHardBytes = Math.max(MAX_OUTBOUND_HARD_BYTES, maxOutboundBufferBytes * 4)) {
|
|
89455
89528
|
this.socket = socket;
|
|
89456
89529
|
this.maxInboundFrameBytes = maxInboundFrameBytes;
|
|
89457
|
-
this.
|
|
89530
|
+
this.outboundStallGraceMs = outboundStallGraceMs;
|
|
89531
|
+
this.outbound = new OutboundBacklogGuard(maxOutboundBufferBytes, outboundStallGraceMs, maxOutboundHardBytes);
|
|
89458
89532
|
socket.setEncoding("utf8");
|
|
89459
89533
|
socket.on("data", (chunk) => this.onData(chunk));
|
|
89460
89534
|
socket.on("close", () => this.emitClose());
|
|
@@ -89505,6 +89579,26 @@ var init_unix_socket = __esm({
|
|
|
89505
89579
|
this.socket.write(line);
|
|
89506
89580
|
this.outbound.recordSent(Buffer.byteLength(line));
|
|
89507
89581
|
}
|
|
89582
|
+
waitForDrain() {
|
|
89583
|
+
const socket = this.socket;
|
|
89584
|
+
if (socket.destroyed || !socket.writableNeedDrain)
|
|
89585
|
+
return;
|
|
89586
|
+
this.waitingForDrain = true;
|
|
89587
|
+
return new Promise((resolve20) => {
|
|
89588
|
+
const onTimeout = () => this.dropSlowReader(socket.writableLength);
|
|
89589
|
+
const finish = () => {
|
|
89590
|
+
this.waitingForDrain = false;
|
|
89591
|
+
socket.off("drain", finish);
|
|
89592
|
+
socket.off("close", finish);
|
|
89593
|
+
socket.off("timeout", onTimeout);
|
|
89594
|
+
socket.setTimeout(0);
|
|
89595
|
+
resolve20();
|
|
89596
|
+
};
|
|
89597
|
+
socket.once("drain", finish);
|
|
89598
|
+
socket.once("close", finish);
|
|
89599
|
+
socket.setTimeout(Math.max(1, this.outboundStallGraceMs), onTimeout);
|
|
89600
|
+
});
|
|
89601
|
+
}
|
|
89508
89602
|
dropSlowReader(buffered) {
|
|
89509
89603
|
const err = new Error(`slow reader: ${buffered} bytes unsent, none taken within the grace window`);
|
|
89510
89604
|
this.socket.destroy(err);
|
|
@@ -89517,7 +89611,10 @@ var init_unix_socket = __esm({
|
|
|
89517
89611
|
this.closeHandler = handler;
|
|
89518
89612
|
}
|
|
89519
89613
|
close() {
|
|
89520
|
-
this.
|
|
89614
|
+
if (this.waitingForDrain)
|
|
89615
|
+
this.socket.destroy();
|
|
89616
|
+
else
|
|
89617
|
+
this.socket.end();
|
|
89521
89618
|
}
|
|
89522
89619
|
};
|
|
89523
89620
|
DEFAULT_CONNECT_TIMEOUT_MS = 1e4;
|
|
@@ -89535,106 +89632,6 @@ var init_channel_runner = __esm({
|
|
|
89535
89632
|
init_socket_path();
|
|
89536
89633
|
}
|
|
89537
89634
|
});
|
|
89538
|
-
|
|
89539
|
-
// ../runner/dist/spoken-exchanges.js
|
|
89540
|
-
function voiceTranscript(exchanges) {
|
|
89541
|
-
const lines = exchanges.map(({ userText, assistantText }) => [
|
|
89542
|
-
userText?.trim() ? `User: ${userText.trim()}` : null,
|
|
89543
|
-
assistantText?.trim() ? `Moxxy Voice: ${assistantText.trim()}` : null
|
|
89544
|
-
].filter((line) => line !== null).join("\n"));
|
|
89545
|
-
return [
|
|
89546
|
-
"Voice conversation with Moxxy Voice while the agent was working (a record for context, not a request):",
|
|
89547
|
-
...lines
|
|
89548
|
-
].join("\n\n");
|
|
89549
|
-
}
|
|
89550
|
-
var SpokenExchanges;
|
|
89551
|
-
var init_spoken_exchanges = __esm({
|
|
89552
|
-
"../runner/dist/spoken-exchanges.js"() {
|
|
89553
|
-
init_dist3();
|
|
89554
|
-
SpokenExchanges = class {
|
|
89555
|
-
session;
|
|
89556
|
-
turnRunning;
|
|
89557
|
-
held = null;
|
|
89558
|
-
constructor(session, turnRunning) {
|
|
89559
|
-
this.session = session;
|
|
89560
|
-
this.turnRunning = turnRunning;
|
|
89561
|
-
}
|
|
89562
|
-
async record(exchange) {
|
|
89563
|
-
if (this.turnRunning()) {
|
|
89564
|
-
this.held ??= { turnId: newTurnId(), exchanges: [] };
|
|
89565
|
-
this.held.exchanges.push(exchange);
|
|
89566
|
-
return this.held.turnId;
|
|
89567
|
-
}
|
|
89568
|
-
await this.flush();
|
|
89569
|
-
const turnId = newTurnId();
|
|
89570
|
-
await this.appendExchange(turnId, exchange);
|
|
89571
|
-
return turnId;
|
|
89572
|
-
}
|
|
89573
|
-
/** Append the conversation held during the turn that just finished. */
|
|
89574
|
-
async flush() {
|
|
89575
|
-
const held = this.held;
|
|
89576
|
-
if (!held || this.turnRunning())
|
|
89577
|
-
return;
|
|
89578
|
-
this.held = null;
|
|
89579
|
-
const count = held.exchanges.length;
|
|
89580
|
-
await this.session.log.append({
|
|
89581
|
-
sessionId: this.session.id,
|
|
89582
|
-
turnId: held.turnId,
|
|
89583
|
-
type: "user_prompt",
|
|
89584
|
-
source: "user",
|
|
89585
|
-
text: voiceTranscript(held.exchanges),
|
|
89586
|
-
origin: { kind: "voice", name: `${count} ${count === 1 ? "exchange" : "exchanges"} while the agent worked` }
|
|
89587
|
-
});
|
|
89588
|
-
}
|
|
89589
|
-
async appendExchange(turnId, { userText, assistantText }) {
|
|
89590
|
-
const base = { sessionId: this.session.id, turnId };
|
|
89591
|
-
if (userText?.trim()) {
|
|
89592
|
-
await this.session.log.append({ ...base, type: "user_prompt", source: "user", text: userText });
|
|
89593
|
-
}
|
|
89594
|
-
if (assistantText?.trim()) {
|
|
89595
|
-
await this.session.log.append({
|
|
89596
|
-
...base,
|
|
89597
|
-
type: "assistant_message",
|
|
89598
|
-
source: "model",
|
|
89599
|
-
content: assistantText,
|
|
89600
|
-
stopReason: "end_turn"
|
|
89601
|
-
});
|
|
89602
|
-
}
|
|
89603
|
-
}
|
|
89604
|
-
};
|
|
89605
|
-
}
|
|
89606
|
-
});
|
|
89607
|
-
async function handleComputerApprovalFocus({ session }, raw) {
|
|
89608
|
-
const command = computerApprovalFocusSchema.parse(raw);
|
|
89609
|
-
if (command.sessionId !== session.id)
|
|
89610
|
-
throw new Error("Computer Use session mismatch");
|
|
89611
|
-
const service = session.computerControl;
|
|
89612
|
-
if (service?.approvalFocus)
|
|
89613
|
-
await service.approvalFocus(command);
|
|
89614
|
-
}
|
|
89615
|
-
async function handleComputerSnapshot({ session }, raw) {
|
|
89616
|
-
z$1.object({}).strict().parse(raw);
|
|
89617
|
-
const service = session.computerControl;
|
|
89618
|
-
if (!service)
|
|
89619
|
-
return [];
|
|
89620
|
-
const snapshots = z$1.array(computerControlSnapshotSchema).max(256).parse(await service.snapshot());
|
|
89621
|
-
if (snapshots.some((snapshot) => snapshot.sessionId !== session.id))
|
|
89622
|
-
throw new Error("Computer Use session mismatch");
|
|
89623
|
-
return snapshots;
|
|
89624
|
-
}
|
|
89625
|
-
async function handleComputerControl({ session }, raw) {
|
|
89626
|
-
const command = computerControlCommandSchema.parse(raw);
|
|
89627
|
-
if (command.sessionId !== session.id)
|
|
89628
|
-
throw new Error("Computer Use session mismatch");
|
|
89629
|
-
const service = session.computerControl;
|
|
89630
|
-
if (!service)
|
|
89631
|
-
throw new Error("Computer Use control is not supported by this session");
|
|
89632
|
-
await service.control(command);
|
|
89633
|
-
}
|
|
89634
|
-
var init_computer_handlers = __esm({
|
|
89635
|
-
"../runner/dist/handlers/computer-handlers.js"() {
|
|
89636
|
-
}
|
|
89637
|
-
});
|
|
89638
89635
|
function surfaceInputWithinCap(m3) {
|
|
89639
89636
|
let upper = 2;
|
|
89640
89637
|
let primitiveOnly = true;
|
|
@@ -89983,6 +89980,203 @@ var init_protocol2 = __esm({
|
|
|
89983
89980
|
});
|
|
89984
89981
|
}
|
|
89985
89982
|
});
|
|
89983
|
+
var EVENTS_PER_BATCH, ClientHistory;
|
|
89984
|
+
var init_history_replay = __esm({
|
|
89985
|
+
"../runner/dist/history-replay.js"() {
|
|
89986
|
+
init_backlog_guard();
|
|
89987
|
+
init_protocol2();
|
|
89988
|
+
EVENTS_PER_BATCH = 256;
|
|
89989
|
+
ClientHistory = class {
|
|
89990
|
+
log;
|
|
89991
|
+
peer;
|
|
89992
|
+
transport;
|
|
89993
|
+
nextSeq = 0;
|
|
89994
|
+
replaying = false;
|
|
89995
|
+
// Only turn endings need a fence. Events themselves always live in the log.
|
|
89996
|
+
completions = /* @__PURE__ */ new Set();
|
|
89997
|
+
completionBytes = 0;
|
|
89998
|
+
constructor(log2, peer, transport) {
|
|
89999
|
+
this.log = log2;
|
|
90000
|
+
this.peer = peer;
|
|
90001
|
+
this.transport = transport;
|
|
90002
|
+
}
|
|
90003
|
+
get catchingUp() {
|
|
90004
|
+
return this.replaying;
|
|
90005
|
+
}
|
|
90006
|
+
async attach(replay, ready) {
|
|
90007
|
+
this.replaying = true;
|
|
90008
|
+
const base = this.log.baseSeq;
|
|
90009
|
+
const end = base + this.log.length;
|
|
90010
|
+
this.nextSeq = replay === "full" ? base : replay === "none" ? end : Math.max(base, end - replay.tail);
|
|
90011
|
+
this.peer.notify(RunnerNotification.ReplayStart, { fromSeq: this.nextSeq });
|
|
90012
|
+
try {
|
|
90013
|
+
let batch = 0;
|
|
90014
|
+
while (!this.peer.isClosed) {
|
|
90015
|
+
const completion = this.completions.values().next().value;
|
|
90016
|
+
if (completion && completion.afterSeq <= this.nextSeq) {
|
|
90017
|
+
this.completions.delete(completion);
|
|
90018
|
+
this.completionBytes -= completion.bytes;
|
|
90019
|
+
this.peer.notify(RunnerNotification.TurnComplete, completion.params);
|
|
90020
|
+
} else {
|
|
90021
|
+
const event = this.log.at(this.nextSeq);
|
|
90022
|
+
if (!event) {
|
|
90023
|
+
ready();
|
|
90024
|
+
return;
|
|
90025
|
+
}
|
|
90026
|
+
this.sendEvent(eventForClient(event));
|
|
90027
|
+
}
|
|
90028
|
+
const drain = this.transport.waitForDrain?.();
|
|
90029
|
+
if (drain) {
|
|
90030
|
+
await drain;
|
|
90031
|
+
batch = 0;
|
|
90032
|
+
} else if (this.transport.waitForDrain && ++batch >= EVENTS_PER_BATCH) {
|
|
90033
|
+
await setImmediate$1();
|
|
90034
|
+
batch = 0;
|
|
90035
|
+
}
|
|
90036
|
+
}
|
|
90037
|
+
} finally {
|
|
90038
|
+
this.replaying = false;
|
|
90039
|
+
this.completions.clear();
|
|
90040
|
+
this.completionBytes = 0;
|
|
90041
|
+
}
|
|
90042
|
+
}
|
|
90043
|
+
live(event, projected) {
|
|
90044
|
+
if (this.replaying || this.log.at(event.seq) !== event)
|
|
90045
|
+
return;
|
|
90046
|
+
while (this.nextSeq <= event.seq && !this.peer.isClosed) {
|
|
90047
|
+
const next = this.log.at(this.nextSeq);
|
|
90048
|
+
if (!next)
|
|
90049
|
+
return;
|
|
90050
|
+
this.sendEvent(next === event ? projected : eventForClient(next));
|
|
90051
|
+
}
|
|
90052
|
+
}
|
|
90053
|
+
reset() {
|
|
90054
|
+
this.nextSeq = 0;
|
|
90055
|
+
this.peer.notify(RunnerNotification.SessionReset, {});
|
|
90056
|
+
for (const completion of this.completions)
|
|
90057
|
+
completion.afterSeq = 0;
|
|
90058
|
+
}
|
|
90059
|
+
turnComplete(params) {
|
|
90060
|
+
const end = this.log.baseSeq + this.log.length;
|
|
90061
|
+
if (this.replaying && (this.nextSeq < end || this.completions.size > 0)) {
|
|
90062
|
+
const bytes = 128 + 2 * (params.turnId.length + (params.error?.length ?? 0));
|
|
90063
|
+
if (this.completionBytes + bytes > MAX_OUTBOUND_HARD_BYTES) {
|
|
90064
|
+
this.peer.close(new Error("slow reader: pending turn completions exceeded the outbound limit"));
|
|
90065
|
+
return;
|
|
90066
|
+
}
|
|
90067
|
+
this.completionBytes += bytes;
|
|
90068
|
+
this.completions.add({ afterSeq: end, params, bytes });
|
|
90069
|
+
} else {
|
|
90070
|
+
this.peer.notify(RunnerNotification.TurnComplete, params);
|
|
90071
|
+
}
|
|
90072
|
+
}
|
|
90073
|
+
sendEvent(event) {
|
|
90074
|
+
this.nextSeq++;
|
|
90075
|
+
this.peer.notify(RunnerNotification.Event, { event });
|
|
90076
|
+
}
|
|
90077
|
+
};
|
|
90078
|
+
}
|
|
90079
|
+
});
|
|
90080
|
+
|
|
90081
|
+
// ../runner/dist/spoken-exchanges.js
|
|
90082
|
+
function voiceTranscript(exchanges) {
|
|
90083
|
+
const lines = exchanges.map(({ userText, assistantText }) => [
|
|
90084
|
+
userText?.trim() ? `User: ${userText.trim()}` : null,
|
|
90085
|
+
assistantText?.trim() ? `Moxxy Voice: ${assistantText.trim()}` : null
|
|
90086
|
+
].filter((line) => line !== null).join("\n"));
|
|
90087
|
+
return [
|
|
90088
|
+
"Voice conversation with Moxxy Voice while the agent was working (a record for context, not a request):",
|
|
90089
|
+
...lines
|
|
90090
|
+
].join("\n\n");
|
|
90091
|
+
}
|
|
90092
|
+
var SpokenExchanges;
|
|
90093
|
+
var init_spoken_exchanges = __esm({
|
|
90094
|
+
"../runner/dist/spoken-exchanges.js"() {
|
|
90095
|
+
init_dist3();
|
|
90096
|
+
SpokenExchanges = class {
|
|
90097
|
+
session;
|
|
90098
|
+
turnRunning;
|
|
90099
|
+
held = null;
|
|
90100
|
+
constructor(session, turnRunning) {
|
|
90101
|
+
this.session = session;
|
|
90102
|
+
this.turnRunning = turnRunning;
|
|
90103
|
+
}
|
|
90104
|
+
async record(exchange) {
|
|
90105
|
+
if (this.turnRunning()) {
|
|
90106
|
+
this.held ??= { turnId: newTurnId(), exchanges: [] };
|
|
90107
|
+
this.held.exchanges.push(exchange);
|
|
90108
|
+
return this.held.turnId;
|
|
90109
|
+
}
|
|
90110
|
+
await this.flush();
|
|
90111
|
+
const turnId = newTurnId();
|
|
90112
|
+
await this.appendExchange(turnId, exchange);
|
|
90113
|
+
return turnId;
|
|
90114
|
+
}
|
|
90115
|
+
/** Append the conversation held during the turn that just finished. */
|
|
90116
|
+
async flush() {
|
|
90117
|
+
const held = this.held;
|
|
90118
|
+
if (!held || this.turnRunning())
|
|
90119
|
+
return;
|
|
90120
|
+
this.held = null;
|
|
90121
|
+
const count = held.exchanges.length;
|
|
90122
|
+
await this.session.log.append({
|
|
90123
|
+
sessionId: this.session.id,
|
|
90124
|
+
turnId: held.turnId,
|
|
90125
|
+
type: "user_prompt",
|
|
90126
|
+
source: "user",
|
|
90127
|
+
text: voiceTranscript(held.exchanges),
|
|
90128
|
+
origin: { kind: "voice", name: `${count} ${count === 1 ? "exchange" : "exchanges"} while the agent worked` }
|
|
90129
|
+
});
|
|
90130
|
+
}
|
|
90131
|
+
async appendExchange(turnId, { userText, assistantText }) {
|
|
90132
|
+
const base = { sessionId: this.session.id, turnId };
|
|
90133
|
+
if (userText?.trim()) {
|
|
90134
|
+
await this.session.log.append({ ...base, type: "user_prompt", source: "user", text: userText });
|
|
90135
|
+
}
|
|
90136
|
+
if (assistantText?.trim()) {
|
|
90137
|
+
await this.session.log.append({
|
|
90138
|
+
...base,
|
|
90139
|
+
type: "assistant_message",
|
|
90140
|
+
source: "model",
|
|
90141
|
+
content: assistantText,
|
|
90142
|
+
stopReason: "end_turn"
|
|
90143
|
+
});
|
|
90144
|
+
}
|
|
90145
|
+
}
|
|
90146
|
+
};
|
|
90147
|
+
}
|
|
90148
|
+
});
|
|
90149
|
+
async function handleComputerApprovalFocus({ session }, raw) {
|
|
90150
|
+
const command = computerApprovalFocusSchema.parse(raw);
|
|
90151
|
+
if (command.sessionId !== session.id)
|
|
90152
|
+
throw new Error("Computer Use session mismatch");
|
|
90153
|
+
const service = session.computerControl;
|
|
90154
|
+
if (service?.approvalFocus)
|
|
90155
|
+
await service.approvalFocus(command);
|
|
90156
|
+
}
|
|
90157
|
+
async function handleComputerSnapshot({ session }, raw) {
|
|
90158
|
+
z$1.object({}).strict().parse(raw);
|
|
90159
|
+
const service = session.computerControl;
|
|
90160
|
+
if (!service)
|
|
90161
|
+
return [];
|
|
90162
|
+
const snapshots = z$1.array(computerControlSnapshotSchema).max(256).parse(await service.snapshot());
|
|
90163
|
+
if (snapshots.some((snapshot) => snapshot.sessionId !== session.id))
|
|
90164
|
+
throw new Error("Computer Use session mismatch");
|
|
90165
|
+
return snapshots;
|
|
90166
|
+
}
|
|
90167
|
+
async function handleComputerControl({ session }, raw) {
|
|
90168
|
+
const command = computerControlCommandSchema.parse(raw);
|
|
90169
|
+
if (command.sessionId !== session.id)
|
|
90170
|
+
throw new Error("Computer Use session mismatch");
|
|
90171
|
+
const service = session.computerControl;
|
|
90172
|
+
if (!service)
|
|
90173
|
+
throw new Error("Computer Use control is not supported by this session");
|
|
90174
|
+
await service.control(command);
|
|
90175
|
+
}
|
|
90176
|
+
var init_computer_handlers = __esm({
|
|
90177
|
+
"../runner/dist/handlers/computer-handlers.js"() {
|
|
90178
|
+
}
|
|
90179
|
+
});
|
|
89986
90180
|
async function handleWorkflowDelete(ctx, raw) {
|
|
89987
90181
|
const { name } = z.object({ name: z.string().min(1).max(120) }).strict().parse(raw);
|
|
89988
90182
|
const view = ctx.session.workflows;
|
|
@@ -90379,6 +90573,7 @@ var CLIENT_REQUEST_TIMEOUT_MS, RunnerServer;
|
|
|
90379
90573
|
var init_server2 = __esm({
|
|
90380
90574
|
"../runner/dist/server.js"() {
|
|
90381
90575
|
init_dist3();
|
|
90576
|
+
init_history_replay();
|
|
90382
90577
|
init_jsonrpc();
|
|
90383
90578
|
init_unix_socket();
|
|
90384
90579
|
init_spoken_exchanges();
|
|
@@ -90445,12 +90640,19 @@ var init_server2 = __esm({
|
|
|
90445
90640
|
this.trackLocalTurns();
|
|
90446
90641
|
this.transport.onConnection((t2) => this.onConnection(t2));
|
|
90447
90642
|
this.logUnsub = session.log.subscribe((event) => {
|
|
90448
|
-
|
|
90643
|
+
const projected = eventForClient(event);
|
|
90644
|
+
for (const client of this.clients) {
|
|
90645
|
+
if (client.attached)
|
|
90646
|
+
client.history.live(event, projected);
|
|
90647
|
+
}
|
|
90449
90648
|
if (autoApproveSwitch(event) !== null)
|
|
90450
90649
|
this.broadcastInfo();
|
|
90451
90650
|
});
|
|
90452
90651
|
this.logClearUnsub = session.log.onClear(() => {
|
|
90453
|
-
this.
|
|
90652
|
+
for (const client of this.clients) {
|
|
90653
|
+
if (client.attached)
|
|
90654
|
+
client.history.reset();
|
|
90655
|
+
}
|
|
90454
90656
|
this.broadcastInfo();
|
|
90455
90657
|
});
|
|
90456
90658
|
this.modesUnsub = session.modes.onActiveChange(() => this.broadcastInfo());
|
|
@@ -90495,6 +90697,7 @@ var init_server2 = __esm({
|
|
|
90495
90697
|
const peer = new JsonRpcPeer(transport);
|
|
90496
90698
|
const client = {
|
|
90497
90699
|
peer,
|
|
90700
|
+
history: new ClientHistory(this.session.log, peer, transport),
|
|
90498
90701
|
role: "unknown",
|
|
90499
90702
|
attached: false,
|
|
90500
90703
|
handlesPermission: false,
|
|
@@ -90503,7 +90706,8 @@ var init_server2 = __esm({
|
|
|
90503
90706
|
};
|
|
90504
90707
|
this.clients.add(client);
|
|
90505
90708
|
const ctx = this.handlerCtx;
|
|
90506
|
-
|
|
90709
|
+
const attaches = createMutex();
|
|
90710
|
+
peer.handleWithReply(RunnerMethod.Attach, (raw, reply) => attaches.run(() => this.handleAttach(client, raw, reply)));
|
|
90507
90711
|
peer.handle(RunnerMethod.GetInfo, () => this.info());
|
|
90508
90712
|
peer.handle(RunnerMethod.ComputerSnapshot, (raw) => handleComputerSnapshot(ctx, raw));
|
|
90509
90713
|
peer.handle(RunnerMethod.ComputerControl, (raw) => handleComputerControl(ctx, raw));
|
|
@@ -90563,30 +90767,24 @@ var init_server2 = __esm({
|
|
|
90563
90767
|
}
|
|
90564
90768
|
}
|
|
90565
90769
|
// --- request handlers ----------------------------------------------------
|
|
90566
|
-
handleAttach(client, raw) {
|
|
90770
|
+
handleAttach(client, raw, reply) {
|
|
90567
90771
|
const params = attachParamsSchema.parse(raw);
|
|
90568
90772
|
if (params.protocolVersion < MIN_COMPATIBLE_PROTOCOL_VERSION) {
|
|
90569
90773
|
throw new Error(`runner protocol mismatch: server v${RUNNER_PROTOCOL_VERSION}, client v${params.protocolVersion}`);
|
|
90570
90774
|
}
|
|
90775
|
+
if (client.peer.isClosed)
|
|
90776
|
+
throw new Error("connection closed");
|
|
90571
90777
|
client.role = params.role;
|
|
90572
90778
|
client.attached = true;
|
|
90573
90779
|
if (params.principal) {
|
|
90574
90780
|
client.principal = params.principal;
|
|
90575
90781
|
this.session.setPrincipal(params.principal);
|
|
90576
90782
|
}
|
|
90577
|
-
|
|
90578
|
-
const baseSeq = this.session.log.baseSeq;
|
|
90579
|
-
const endSeq = baseSeq + this.session.log.length;
|
|
90580
|
-
const start = replay === "full" ? baseSeq : replay === "none" ? endSeq : Math.max(baseSeq, endSeq - replay.tail);
|
|
90581
|
-
client.peer.notify(RunnerNotification.ReplayStart, { fromSeq: start });
|
|
90582
|
-
for (const event of this.session.log.slice(start)) {
|
|
90583
|
-
client.peer.notify(RunnerNotification.Event, { event: eventForClient(event) });
|
|
90584
|
-
}
|
|
90585
|
-
return {
|
|
90783
|
+
return client.history.attach(params.replay ?? "full", () => reply({
|
|
90586
90784
|
sessionId: this.session.id,
|
|
90587
90785
|
protocolVersion: RUNNER_PROTOCOL_VERSION,
|
|
90588
90786
|
info: this.info()
|
|
90589
|
-
};
|
|
90787
|
+
}));
|
|
90590
90788
|
}
|
|
90591
90789
|
handleRunTurn(client, raw) {
|
|
90592
90790
|
const params = runTurnParamsSchema.parse(raw);
|
|
@@ -90621,10 +90819,11 @@ var init_server2 = __esm({
|
|
|
90621
90819
|
try {
|
|
90622
90820
|
await this.sealUnsealedStreamedText(turnId);
|
|
90623
90821
|
await this.handlerCtx.spokenExchanges.flush();
|
|
90624
|
-
|
|
90625
|
-
|
|
90626
|
-
|
|
90627
|
-
|
|
90822
|
+
const completed = { turnId, ...error ? { error } : {} };
|
|
90823
|
+
for (const observer of this.clients) {
|
|
90824
|
+
if (observer.attached)
|
|
90825
|
+
observer.history.turnComplete(completed);
|
|
90826
|
+
}
|
|
90628
90827
|
this.broadcastInfo();
|
|
90629
90828
|
} catch (postErr) {
|
|
90630
90829
|
this.session.logger.error("runner: post-turn finalization failed", {
|
|
@@ -90749,7 +90948,11 @@ var init_server2 = __esm({
|
|
|
90749
90948
|
}
|
|
90750
90949
|
broadcastInfo() {
|
|
90751
90950
|
this.watchComputerControl();
|
|
90752
|
-
|
|
90951
|
+
const params = { info: this.info() };
|
|
90952
|
+
for (const client of this.clients) {
|
|
90953
|
+
if (client.attached && !client.history.catchingUp)
|
|
90954
|
+
client.peer.notify(RunnerNotification.InfoChanged, params);
|
|
90955
|
+
}
|
|
90753
90956
|
}
|
|
90754
90957
|
/**
|
|
90755
90958
|
* A turn run inside the runner — a channel bot hosting it calls
|
|
@@ -90846,9 +91049,6 @@ var init_server2 = __esm({
|
|
|
90846
91049
|
return defaultApproval(request);
|
|
90847
91050
|
}
|
|
90848
91051
|
// --- fan-out -------------------------------------------------------------
|
|
90849
|
-
broadcastEvent(event) {
|
|
90850
|
-
this.broadcast(RunnerNotification.Event, { event: eventForClient(event) });
|
|
90851
|
-
}
|
|
90852
91052
|
broadcast(method, params) {
|
|
90853
91053
|
for (const client of this.clients) {
|
|
90854
91054
|
if (client.attached && !client.peer.isClosed)
|
|
@@ -92436,7 +92636,7 @@ async function runAttachedTui(argv, tuiOpts) {
|
|
|
92436
92636
|
return 0;
|
|
92437
92637
|
}
|
|
92438
92638
|
async function runSelfHostedTui(argv, tuiOpts, standalone) {
|
|
92439
|
-
const firstRun = await readIndex().then((runs) => shouldShowFirstRunWelcome(runs
|
|
92639
|
+
const firstRun = tuiOpts.resumeSessionId ? false : await readIndex().then((runs) => shouldShowFirstRunWelcome(runs)).catch(() => false);
|
|
92440
92640
|
if (process.stdin.isTTY) {
|
|
92441
92641
|
const { sources } = await loadConfig({
|
|
92442
92642
|
cwd: process.cwd(),
|
|
@@ -92582,7 +92782,7 @@ async function runSelfHostedTui(argv, tuiOpts, standalone) {
|
|
|
92582
92782
|
return 0;
|
|
92583
92783
|
}
|
|
92584
92784
|
function shouldShowFirstRunWelcome(runs, resumed) {
|
|
92585
|
-
return
|
|
92785
|
+
return true && runs.every((run2) => run2.eventCount === 0);
|
|
92586
92786
|
}
|
|
92587
92787
|
function errMsg2(err) {
|
|
92588
92788
|
return err instanceof Error ? err.message : String(err);
|
|
@@ -99596,8 +99796,7 @@ async function runResumeCommand(argv) {
|
|
|
99596
99796
|
}
|
|
99597
99797
|
const id = await pickSessionToResume(argv);
|
|
99598
99798
|
if (!id) return 0;
|
|
99599
|
-
const
|
|
99600
|
-
const meta = index.find((m3) => m3.id === id);
|
|
99799
|
+
const meta = await readSessionMeta(id);
|
|
99601
99800
|
const label3 = meta?.firstPrompt ?? colors.dim("(empty)");
|
|
99602
99801
|
process.stdout.write(colors.dim("continuing run \u2014 ") + label3 + "\n");
|
|
99603
99802
|
return runTuiWithBootstrap(argv, {
|
|
@@ -99606,7 +99805,7 @@ async function runResumeCommand(argv) {
|
|
|
99606
99805
|
});
|
|
99607
99806
|
}
|
|
99608
99807
|
async function cwdForResumeSession(id, fallback2) {
|
|
99609
|
-
const meta =
|
|
99808
|
+
const meta = await readSessionMeta(id);
|
|
99610
99809
|
return meta?.cwd ?? fallback2;
|
|
99611
99810
|
}
|
|
99612
99811
|
var HELP17;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moxxy/cli",
|
|
3
|
-
"version": "0.49.
|
|
3
|
+
"version": "0.49.1",
|
|
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.12.2",
|
|
51
51
|
"zod": "^4.6.7",
|
|
52
|
-
"@moxxy/sdk": "0.49.
|
|
52
|
+
"@moxxy/sdk": "0.49.1"
|
|
53
53
|
},
|
|
54
54
|
"optionalDependencies": {
|
|
55
55
|
"@napi-rs/keyring": "^2.1.2"
|