@moxxy/cli 0.48.4 → 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 +432 -211
- 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';
|
|
@@ -29,7 +29,8 @@ import { Stream, PassThrough } from 'stream';
|
|
|
29
29
|
import tty, { ReadStream } from 'tty';
|
|
30
30
|
import { EventEmitter } from 'events';
|
|
31
31
|
import { isAgentWorkEvent } from '@moxxy/sdk/agent-work';
|
|
32
|
-
import { isFileDiffDisplay as isFileDiffDisplay$1, isQuestionAnswerDisplay, toolImagesOf, isToolDisplayResult, isStepListDisplay } from '@moxxy/sdk/tool-display';
|
|
32
|
+
import { isFileDiffDisplay as isFileDiffDisplay$1, isQuestionAnswerDisplay, toolImagesOf, stepsAllDone, isToolDisplayResult, isStepListDisplay } from '@moxxy/sdk/tool-display';
|
|
33
|
+
import { isGoalMetEvent } from '@moxxy/sdk/agent-step';
|
|
33
34
|
import { agentComputerUseOf } from '@moxxy/sdk/agent-computer-use';
|
|
34
35
|
import { questionRecord, QUESTION_CLOSED_AGENT_WENT_ON, QUESTION_CLOSED_NEW_MESSAGE } from '@moxxy/sdk/questions';
|
|
35
36
|
import { accountLimitInForce, recordedAccountLimit } from '@moxxy/sdk/agent-account-limit';
|
|
@@ -18940,6 +18941,29 @@ var init_event_shape = __esm({
|
|
|
18940
18941
|
]));
|
|
18941
18942
|
}
|
|
18942
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
|
+
});
|
|
18943
18967
|
function defaultSessionsDir() {
|
|
18944
18968
|
return moxxyPath("sessions");
|
|
18945
18969
|
}
|
|
@@ -18968,6 +18992,13 @@ async function readIndex(dir = defaultSessionsDir()) {
|
|
|
18968
18992
|
const hydrated = await mapWithConcurrency2(present2, READ_INDEX_CONCURRENCY, (meta) => hydrateMetaFirstPrompt(meta, dir));
|
|
18969
18993
|
return hydrated.sort((a2, b3) => b3.lastActivity.localeCompare(a2.lastActivity));
|
|
18970
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
|
+
}
|
|
18971
19002
|
async function hydrateMetaFirstPrompt(meta, dir) {
|
|
18972
19003
|
const stats = await matchingSessionStatsFromLog(meta.id, path3.join(dir, `${meta.id}.jsonl`));
|
|
18973
19004
|
if (!stats)
|
|
@@ -18982,27 +19013,35 @@ async function hydrateMetaFirstPrompt(meta, dir) {
|
|
|
18982
19013
|
model: stats.model ?? meta.model
|
|
18983
19014
|
};
|
|
18984
19015
|
}
|
|
18985
|
-
function
|
|
19016
|
+
function sessionStatsFold(sessionId) {
|
|
18986
19017
|
let eventCount = 0;
|
|
18987
19018
|
let parsedEvents = 0;
|
|
18988
19019
|
let firstPrompt = null;
|
|
18989
19020
|
let provider = null;
|
|
18990
19021
|
let model = null;
|
|
18991
|
-
|
|
18992
|
-
|
|
18993
|
-
|
|
18994
|
-
|
|
18995
|
-
|
|
18996
|
-
|
|
18997
|
-
firstPrompt
|
|
18998
|
-
|
|
18999
|
-
|
|
19000
|
-
|
|
19001
|
-
|
|
19002
|
-
|
|
19003
|
-
|
|
19004
|
-
|
|
19005
|
-
|
|
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();
|
|
19006
19045
|
}
|
|
19007
19046
|
function statsFromEventLogLike(sessionId, log2) {
|
|
19008
19047
|
const snapshot = log2;
|
|
@@ -19011,24 +19050,45 @@ function statsFromEventLogLike(sessionId, log2) {
|
|
|
19011
19050
|
return statsFromEvents(sessionId, snapshot.slice());
|
|
19012
19051
|
}
|
|
19013
19052
|
async function matchingSessionStatsFromLog(sessionId, logPath) {
|
|
19014
|
-
|
|
19053
|
+
const fold = sessionStatsFold(sessionId);
|
|
19015
19054
|
try {
|
|
19016
|
-
|
|
19055
|
+
for await (const line of readLines(logPath)) {
|
|
19056
|
+
const parsed = parseEventLine(line);
|
|
19057
|
+
if (isMoxxyEventShape(parsed))
|
|
19058
|
+
fold.add(parsed);
|
|
19059
|
+
}
|
|
19017
19060
|
} catch {
|
|
19018
19061
|
return null;
|
|
19019
19062
|
}
|
|
19020
|
-
|
|
19021
|
-
|
|
19022
|
-
|
|
19023
|
-
|
|
19024
|
-
|
|
19025
|
-
|
|
19026
|
-
|
|
19027
|
-
|
|
19028
|
-
|
|
19029
|
-
}
|
|
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;
|
|
19030
19072
|
}
|
|
19031
|
-
|
|
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();
|
|
19032
19092
|
}
|
|
19033
19093
|
function providerHeaderFromEvent(event) {
|
|
19034
19094
|
if (event.type !== "provider_request" && event.type !== "provider_response")
|
|
@@ -19041,22 +19101,24 @@ function providerHeaderFromEvent(event) {
|
|
|
19041
19101
|
async function restoreEvents(sessionId, dir = defaultSessionsDir(), logger = createLogger()) {
|
|
19042
19102
|
assertSafeSessionId(sessionId);
|
|
19043
19103
|
const logPath = path3.join(dir, `${sessionId}.jsonl`);
|
|
19044
|
-
let raw;
|
|
19045
|
-
try {
|
|
19046
|
-
raw = await promises.readFile(logPath, "utf8");
|
|
19047
|
-
} catch {
|
|
19048
|
-
throw new Error(`Session not found: ${sessionId}`);
|
|
19049
|
-
}
|
|
19050
19104
|
const events = [];
|
|
19051
19105
|
let corruptLines = 0;
|
|
19052
19106
|
let invalidShapeLines = 0;
|
|
19053
19107
|
let foreignEvents = 0;
|
|
19054
19108
|
let normalizedSessionIds = 0;
|
|
19055
|
-
|
|
19056
|
-
|
|
19057
|
-
|
|
19058
|
-
|
|
19059
|
-
|
|
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
|
+
}
|
|
19060
19122
|
if (!isMoxxyEventShape(parsed)) {
|
|
19061
19123
|
invalidShapeLines += 1;
|
|
19062
19124
|
continue;
|
|
@@ -19069,10 +19131,11 @@ async function restoreEvents(sessionId, dir = defaultSessionsDir(), logger = cre
|
|
|
19069
19131
|
} else {
|
|
19070
19132
|
foreignEvents += 1;
|
|
19071
19133
|
}
|
|
19072
|
-
} catch {
|
|
19073
|
-
corruptLines += 1;
|
|
19074
19134
|
}
|
|
19135
|
+
} catch {
|
|
19136
|
+
throw new Error(`Session not found: ${sessionId}`);
|
|
19075
19137
|
}
|
|
19138
|
+
const originalDigest = readDigest.digest();
|
|
19076
19139
|
let resequenced = 0;
|
|
19077
19140
|
for (let i2 = 0; i2 < events.length; i2 += 1) {
|
|
19078
19141
|
if (events[i2].seq !== i2) {
|
|
@@ -19106,16 +19169,19 @@ async function restoreEvents(sessionId, dir = defaultSessionsDir(), logger = cre
|
|
|
19106
19169
|
}
|
|
19107
19170
|
}
|
|
19108
19171
|
try {
|
|
19109
|
-
const current2 = await
|
|
19172
|
+
const current2 = await logDigest(logPath).catch(() => null);
|
|
19110
19173
|
if (!canRewrite) {
|
|
19111
|
-
} else if (current2 !==
|
|
19174
|
+
} else if (current2 !== originalDigest) {
|
|
19112
19175
|
logger.warn("skipped repaired-log rewrite \u2014 file changed under us (another process attached?)", {
|
|
19113
19176
|
sessionId,
|
|
19114
19177
|
path: logPath
|
|
19115
19178
|
});
|
|
19116
19179
|
} else {
|
|
19117
|
-
|
|
19118
|
-
|
|
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 });
|
|
19119
19185
|
}
|
|
19120
19186
|
} catch (err) {
|
|
19121
19187
|
logger.warn("failed to rewrite repaired session log on disk", {
|
|
@@ -19130,22 +19196,15 @@ async function restoreEvents(sessionId, dir = defaultSessionsDir(), logger = cre
|
|
|
19130
19196
|
async function readEventPage(sessionId, opts, dir = defaultSessionsDir()) {
|
|
19131
19197
|
assertSafeSessionId(sessionId);
|
|
19132
19198
|
const logPath = path3.join(dir, `${sessionId}.jsonl`);
|
|
19133
|
-
let raw;
|
|
19134
|
-
try {
|
|
19135
|
-
raw = await promises.readFile(logPath, "utf8");
|
|
19136
|
-
} catch {
|
|
19137
|
-
return { events: [], prevCursor: null };
|
|
19138
|
-
}
|
|
19139
19199
|
const all = [];
|
|
19140
|
-
|
|
19141
|
-
|
|
19142
|
-
|
|
19143
|
-
try {
|
|
19144
|
-
const parsed = JSON.parse(line);
|
|
19200
|
+
try {
|
|
19201
|
+
for await (const line of readLines(logPath)) {
|
|
19202
|
+
const parsed = parseEventLine(line);
|
|
19145
19203
|
if (isMoxxyEventShape(parsed))
|
|
19146
19204
|
all.push(parsed);
|
|
19147
|
-
} catch {
|
|
19148
19205
|
}
|
|
19206
|
+
} catch {
|
|
19207
|
+
return { events: [], prevCursor: null };
|
|
19149
19208
|
}
|
|
19150
19209
|
return pageEvents(all, opts.before, opts.limit);
|
|
19151
19210
|
}
|
|
@@ -19333,6 +19392,7 @@ var init_persistence = __esm({
|
|
|
19333
19392
|
"../core/dist/sessions/persistence.js"() {
|
|
19334
19393
|
init_logger();
|
|
19335
19394
|
init_event_shape();
|
|
19395
|
+
init_jsonl_lines();
|
|
19336
19396
|
SESSION_META_VERSION = 1;
|
|
19337
19397
|
SAFE_SESSION_ID = /^[A-Za-z0-9_-]+$/;
|
|
19338
19398
|
READ_INDEX_CONCURRENCY = 32;
|
|
@@ -20154,6 +20214,11 @@ var init_agent_cli_watch = __esm({
|
|
|
20154
20214
|
models(name) {
|
|
20155
20215
|
return this.offered.get(name);
|
|
20156
20216
|
}
|
|
20217
|
+
/** End the live sessions of one agent connection (before a sign-out); a name with no agent is a no-op. */
|
|
20218
|
+
async closeSessions(name) {
|
|
20219
|
+
const def = this.providers().find((p3) => p3.name === name);
|
|
20220
|
+
await def?.agentCli?.closeSessions?.();
|
|
20221
|
+
}
|
|
20157
20222
|
/** Called when a CLI's state or version changed; returns the unsubscribe. */
|
|
20158
20223
|
onChange(listener) {
|
|
20159
20224
|
this.listeners.add(listener);
|
|
@@ -22551,6 +22616,7 @@ __export(dist_exports2, {
|
|
|
22551
22616
|
readPackageMoxxyRequirements: () => readPackageMoxxyRequirements,
|
|
22552
22617
|
readSessionEventPage: () => readEventPage,
|
|
22553
22618
|
readSessionIndex: () => readIndex,
|
|
22619
|
+
readSessionMeta: () => readSessionMeta,
|
|
22554
22620
|
resetAuditHeadForTests: () => resetAuditHeadForTests,
|
|
22555
22621
|
resolveTurnModel: () => resolveTurnModel,
|
|
22556
22622
|
restoreSessionEvents: () => restoreEvents,
|
|
@@ -23696,8 +23762,7 @@ var init_provider_catalog_generated = __esm({
|
|
|
23696
23762
|
}
|
|
23697
23763
|
],
|
|
23698
23764
|
"provider": {
|
|
23699
|
-
"auth": "oauth"
|
|
23700
|
-
"defaultModel": "gpt-6-astra"
|
|
23765
|
+
"auth": "oauth"
|
|
23701
23766
|
}
|
|
23702
23767
|
},
|
|
23703
23768
|
{
|
|
@@ -32633,7 +32698,7 @@ var require_websocket = __commonJS({
|
|
|
32633
32698
|
var http = __require("http");
|
|
32634
32699
|
var net3 = __require("net");
|
|
32635
32700
|
var tls = __require("tls");
|
|
32636
|
-
var { randomBytes: randomBytes8, createHash:
|
|
32701
|
+
var { randomBytes: randomBytes8, createHash: createHash12 } = __require("crypto");
|
|
32637
32702
|
var { Duplex, Readable } = __require("stream");
|
|
32638
32703
|
var { URL: URL2 } = __require("url");
|
|
32639
32704
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -33314,7 +33379,7 @@ var require_websocket = __commonJS({
|
|
|
33314
33379
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
33315
33380
|
return;
|
|
33316
33381
|
}
|
|
33317
|
-
const digest =
|
|
33382
|
+
const digest = createHash12("sha1").update(key + GUID).digest("base64");
|
|
33318
33383
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
33319
33384
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
33320
33385
|
return;
|
|
@@ -33680,7 +33745,7 @@ var require_websocket_server = __commonJS({
|
|
|
33680
33745
|
var EventEmitter3 = __require("events");
|
|
33681
33746
|
var http = __require("http");
|
|
33682
33747
|
var { Duplex } = __require("stream");
|
|
33683
|
-
var { createHash:
|
|
33748
|
+
var { createHash: createHash12 } = __require("crypto");
|
|
33684
33749
|
var extension2 = require_extension();
|
|
33685
33750
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
33686
33751
|
var subprotocol2 = require_subprotocol();
|
|
@@ -33987,7 +34052,7 @@ var require_websocket_server = __commonJS({
|
|
|
33987
34052
|
);
|
|
33988
34053
|
}
|
|
33989
34054
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
33990
|
-
const digest =
|
|
34055
|
+
const digest = createHash12("sha1").update(key + GUID).digest("base64");
|
|
33991
34056
|
const headers = [
|
|
33992
34057
|
"HTTP/1.1 101 Switching Protocols",
|
|
33993
34058
|
"Upgrade: websocket",
|
|
@@ -71778,6 +71843,8 @@ function createFoldState(compactByName = EMPTY_COMPACT_MAP) {
|
|
|
71778
71843
|
function stepFold(s, e) {
|
|
71779
71844
|
if (isAgentWorkEvent(e))
|
|
71780
71845
|
return;
|
|
71846
|
+
if (isGoalMetEvent(e) && s.openSteps)
|
|
71847
|
+
s.openSteps.goalMet = true;
|
|
71781
71848
|
const pushBlock = (block2) => {
|
|
71782
71849
|
s.subagentGroup.current = null;
|
|
71783
71850
|
if (s.openScope) {
|
|
@@ -71978,7 +72045,7 @@ function stepListOf(block2) {
|
|
|
71978
72045
|
const call = block2.calls[i2];
|
|
71979
72046
|
const list = call ? stepListOfCall(call) : null;
|
|
71980
72047
|
if (list)
|
|
71981
|
-
return list;
|
|
72048
|
+
return block2.goalMet ? stepsAllDone(list) : list;
|
|
71982
72049
|
}
|
|
71983
72050
|
return null;
|
|
71984
72051
|
}
|
|
@@ -71989,7 +72056,7 @@ function joinStepList(s, call) {
|
|
|
71989
72056
|
open3.calls.push(call);
|
|
71990
72057
|
return;
|
|
71991
72058
|
}
|
|
71992
|
-
const list = { kind: "step-list", id: call.id, calls: [call], closed: false };
|
|
72059
|
+
const list = { kind: "step-list", id: call.id, calls: [call], closed: false, goalMet: false };
|
|
71993
72060
|
if (replaceCallBlock(s.root, call.request.callId, list))
|
|
71994
72061
|
s.openSteps = list;
|
|
71995
72062
|
}
|
|
@@ -72093,7 +72160,7 @@ function blocksEquivalent(a2, b3) {
|
|
|
72093
72160
|
return true;
|
|
72094
72161
|
}
|
|
72095
72162
|
if (a2.kind === "step-list" && b3.kind === "step-list") {
|
|
72096
|
-
if (a2.closed !== b3.closed || a2.calls.length !== b3.calls.length)
|
|
72163
|
+
if (a2.closed !== b3.closed || a2.goalMet !== b3.goalMet || a2.calls.length !== b3.calls.length)
|
|
72097
72164
|
return false;
|
|
72098
72165
|
return a2.calls.every((call, i2) => {
|
|
72099
72166
|
const other = b3.calls[i2];
|
|
@@ -87989,7 +88056,7 @@ async function applySessionHeaderPreferences(session, sessionId, credentialResol
|
|
|
87989
88056
|
if (!sessionId) return;
|
|
87990
88057
|
let meta = null;
|
|
87991
88058
|
try {
|
|
87992
|
-
meta =
|
|
88059
|
+
meta = await readSessionMeta(sessionId);
|
|
87993
88060
|
} catch (err) {
|
|
87994
88061
|
logger.warn("failed to load sticky session metadata", {
|
|
87995
88062
|
sessionId,
|
|
@@ -89059,6 +89126,10 @@ var init_jsonrpc = __esm({
|
|
|
89059
89126
|
}
|
|
89060
89127
|
/** Register a request handler. Last registration for a method wins. */
|
|
89061
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) {
|
|
89062
89133
|
this.requestHandlers.set(method, handler);
|
|
89063
89134
|
}
|
|
89064
89135
|
/** Register a notification handler. */
|
|
@@ -89143,7 +89214,8 @@ var init_jsonrpc = __esm({
|
|
|
89143
89214
|
};
|
|
89144
89215
|
this.transport.send(frame);
|
|
89145
89216
|
}
|
|
89146
|
-
close() {
|
|
89217
|
+
close(reason) {
|
|
89218
|
+
this.handleClose(reason);
|
|
89147
89219
|
this.transport.close();
|
|
89148
89220
|
}
|
|
89149
89221
|
async handleFrame(frame) {
|
|
@@ -89180,10 +89252,17 @@ var init_jsonrpc = __esm({
|
|
|
89180
89252
|
this.transport.send({ id, error: { message: `unknown method: ${method}` } });
|
|
89181
89253
|
return;
|
|
89182
89254
|
}
|
|
89255
|
+
let replied = false;
|
|
89183
89256
|
try {
|
|
89184
|
-
|
|
89185
|
-
|
|
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
|
+
});
|
|
89186
89263
|
} catch (err) {
|
|
89264
|
+
if (replied || this.closed)
|
|
89265
|
+
return;
|
|
89187
89266
|
const message = err instanceof Error ? err.message : String(err);
|
|
89188
89267
|
const data = err instanceof RpcError ? err.data : void 0;
|
|
89189
89268
|
this.transport.send({ id, error: { message, ...data !== void 0 ? { data } : {} } });
|
|
@@ -89210,9 +89289,10 @@ var init_jsonrpc = __esm({
|
|
|
89210
89289
|
});
|
|
89211
89290
|
|
|
89212
89291
|
// ../runner/dist/backlog-guard.js
|
|
89213
|
-
var OutboundBacklogGuard;
|
|
89292
|
+
var MAX_OUTBOUND_HARD_BYTES, OutboundBacklogGuard;
|
|
89214
89293
|
var init_backlog_guard = __esm({
|
|
89215
89294
|
"../runner/dist/backlog-guard.js"() {
|
|
89295
|
+
MAX_OUTBOUND_HARD_BYTES = 256 * 1024 * 1024;
|
|
89216
89296
|
OutboundBacklogGuard = class {
|
|
89217
89297
|
limitBytes;
|
|
89218
89298
|
graceMs;
|
|
@@ -89312,7 +89392,7 @@ async function createUnixSocketServer(socketPath, logger = stderrLogger, limits
|
|
|
89312
89392
|
}
|
|
89313
89393
|
let connectionHandler;
|
|
89314
89394
|
const server = net2.createServer((socket) => {
|
|
89315
|
-
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);
|
|
89316
89396
|
connectionHandler?.(transport);
|
|
89317
89397
|
});
|
|
89318
89398
|
await new Promise((resolve20, reject) => {
|
|
@@ -89420,7 +89500,7 @@ async function reclaimStaleSocket(socketPath) {
|
|
|
89420
89500
|
} catch {
|
|
89421
89501
|
}
|
|
89422
89502
|
}
|
|
89423
|
-
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;
|
|
89424
89504
|
var init_unix_socket = __esm({
|
|
89425
89505
|
"../runner/dist/unix-socket.js"() {
|
|
89426
89506
|
init_backlog_guard();
|
|
@@ -89434,19 +89514,21 @@ var init_unix_socket = __esm({
|
|
|
89434
89514
|
DEFAULT_MAX_INBOUND_FRAME_BYTES = 64 * 1024 * 1024;
|
|
89435
89515
|
DEFAULT_MAX_OUTBOUND_BUFFER_BYTES = 4 * 1024 * 1024;
|
|
89436
89516
|
DEFAULT_OUTBOUND_STALL_GRACE_MS = 1e4;
|
|
89437
|
-
DEFAULT_MAX_OUTBOUND_HARD_BYTES = 4 * DEFAULT_MAX_INBOUND_FRAME_BYTES;
|
|
89438
89517
|
NdjsonTransport = class {
|
|
89439
89518
|
socket;
|
|
89440
89519
|
maxInboundFrameBytes;
|
|
89520
|
+
outboundStallGraceMs;
|
|
89441
89521
|
buffer = "";
|
|
89442
89522
|
frameHandler;
|
|
89443
89523
|
closeHandler;
|
|
89444
89524
|
closedEmitted = false;
|
|
89525
|
+
waitingForDrain = false;
|
|
89445
89526
|
outbound;
|
|
89446
|
-
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)) {
|
|
89447
89528
|
this.socket = socket;
|
|
89448
89529
|
this.maxInboundFrameBytes = maxInboundFrameBytes;
|
|
89449
|
-
this.
|
|
89530
|
+
this.outboundStallGraceMs = outboundStallGraceMs;
|
|
89531
|
+
this.outbound = new OutboundBacklogGuard(maxOutboundBufferBytes, outboundStallGraceMs, maxOutboundHardBytes);
|
|
89450
89532
|
socket.setEncoding("utf8");
|
|
89451
89533
|
socket.on("data", (chunk) => this.onData(chunk));
|
|
89452
89534
|
socket.on("close", () => this.emitClose());
|
|
@@ -89497,6 +89579,26 @@ var init_unix_socket = __esm({
|
|
|
89497
89579
|
this.socket.write(line);
|
|
89498
89580
|
this.outbound.recordSent(Buffer.byteLength(line));
|
|
89499
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
|
+
}
|
|
89500
89602
|
dropSlowReader(buffered) {
|
|
89501
89603
|
const err = new Error(`slow reader: ${buffered} bytes unsent, none taken within the grace window`);
|
|
89502
89604
|
this.socket.destroy(err);
|
|
@@ -89509,7 +89611,10 @@ var init_unix_socket = __esm({
|
|
|
89509
89611
|
this.closeHandler = handler;
|
|
89510
89612
|
}
|
|
89511
89613
|
close() {
|
|
89512
|
-
this.
|
|
89614
|
+
if (this.waitingForDrain)
|
|
89615
|
+
this.socket.destroy();
|
|
89616
|
+
else
|
|
89617
|
+
this.socket.end();
|
|
89513
89618
|
}
|
|
89514
89619
|
};
|
|
89515
89620
|
DEFAULT_CONNECT_TIMEOUT_MS = 1e4;
|
|
@@ -89527,106 +89632,6 @@ var init_channel_runner = __esm({
|
|
|
89527
89632
|
init_socket_path();
|
|
89528
89633
|
}
|
|
89529
89634
|
});
|
|
89530
|
-
|
|
89531
|
-
// ../runner/dist/spoken-exchanges.js
|
|
89532
|
-
function voiceTranscript(exchanges) {
|
|
89533
|
-
const lines = exchanges.map(({ userText, assistantText }) => [
|
|
89534
|
-
userText?.trim() ? `User: ${userText.trim()}` : null,
|
|
89535
|
-
assistantText?.trim() ? `Moxxy Voice: ${assistantText.trim()}` : null
|
|
89536
|
-
].filter((line) => line !== null).join("\n"));
|
|
89537
|
-
return [
|
|
89538
|
-
"Voice conversation with Moxxy Voice while the agent was working (a record for context, not a request):",
|
|
89539
|
-
...lines
|
|
89540
|
-
].join("\n\n");
|
|
89541
|
-
}
|
|
89542
|
-
var SpokenExchanges;
|
|
89543
|
-
var init_spoken_exchanges = __esm({
|
|
89544
|
-
"../runner/dist/spoken-exchanges.js"() {
|
|
89545
|
-
init_dist3();
|
|
89546
|
-
SpokenExchanges = class {
|
|
89547
|
-
session;
|
|
89548
|
-
turnRunning;
|
|
89549
|
-
held = null;
|
|
89550
|
-
constructor(session, turnRunning) {
|
|
89551
|
-
this.session = session;
|
|
89552
|
-
this.turnRunning = turnRunning;
|
|
89553
|
-
}
|
|
89554
|
-
async record(exchange) {
|
|
89555
|
-
if (this.turnRunning()) {
|
|
89556
|
-
this.held ??= { turnId: newTurnId(), exchanges: [] };
|
|
89557
|
-
this.held.exchanges.push(exchange);
|
|
89558
|
-
return this.held.turnId;
|
|
89559
|
-
}
|
|
89560
|
-
await this.flush();
|
|
89561
|
-
const turnId = newTurnId();
|
|
89562
|
-
await this.appendExchange(turnId, exchange);
|
|
89563
|
-
return turnId;
|
|
89564
|
-
}
|
|
89565
|
-
/** Append the conversation held during the turn that just finished. */
|
|
89566
|
-
async flush() {
|
|
89567
|
-
const held = this.held;
|
|
89568
|
-
if (!held || this.turnRunning())
|
|
89569
|
-
return;
|
|
89570
|
-
this.held = null;
|
|
89571
|
-
const count = held.exchanges.length;
|
|
89572
|
-
await this.session.log.append({
|
|
89573
|
-
sessionId: this.session.id,
|
|
89574
|
-
turnId: held.turnId,
|
|
89575
|
-
type: "user_prompt",
|
|
89576
|
-
source: "user",
|
|
89577
|
-
text: voiceTranscript(held.exchanges),
|
|
89578
|
-
origin: { kind: "voice", name: `${count} ${count === 1 ? "exchange" : "exchanges"} while the agent worked` }
|
|
89579
|
-
});
|
|
89580
|
-
}
|
|
89581
|
-
async appendExchange(turnId, { userText, assistantText }) {
|
|
89582
|
-
const base = { sessionId: this.session.id, turnId };
|
|
89583
|
-
if (userText?.trim()) {
|
|
89584
|
-
await this.session.log.append({ ...base, type: "user_prompt", source: "user", text: userText });
|
|
89585
|
-
}
|
|
89586
|
-
if (assistantText?.trim()) {
|
|
89587
|
-
await this.session.log.append({
|
|
89588
|
-
...base,
|
|
89589
|
-
type: "assistant_message",
|
|
89590
|
-
source: "model",
|
|
89591
|
-
content: assistantText,
|
|
89592
|
-
stopReason: "end_turn"
|
|
89593
|
-
});
|
|
89594
|
-
}
|
|
89595
|
-
}
|
|
89596
|
-
};
|
|
89597
|
-
}
|
|
89598
|
-
});
|
|
89599
|
-
async function handleComputerApprovalFocus({ session }, raw) {
|
|
89600
|
-
const command = computerApprovalFocusSchema.parse(raw);
|
|
89601
|
-
if (command.sessionId !== session.id)
|
|
89602
|
-
throw new Error("Computer Use session mismatch");
|
|
89603
|
-
const service = session.computerControl;
|
|
89604
|
-
if (service?.approvalFocus)
|
|
89605
|
-
await service.approvalFocus(command);
|
|
89606
|
-
}
|
|
89607
|
-
async function handleComputerSnapshot({ session }, raw) {
|
|
89608
|
-
z$1.object({}).strict().parse(raw);
|
|
89609
|
-
const service = session.computerControl;
|
|
89610
|
-
if (!service)
|
|
89611
|
-
return [];
|
|
89612
|
-
const snapshots = z$1.array(computerControlSnapshotSchema).max(256).parse(await service.snapshot());
|
|
89613
|
-
if (snapshots.some((snapshot) => snapshot.sessionId !== session.id))
|
|
89614
|
-
throw new Error("Computer Use session mismatch");
|
|
89615
|
-
return snapshots;
|
|
89616
|
-
}
|
|
89617
|
-
async function handleComputerControl({ session }, raw) {
|
|
89618
|
-
const command = computerControlCommandSchema.parse(raw);
|
|
89619
|
-
if (command.sessionId !== session.id)
|
|
89620
|
-
throw new Error("Computer Use session mismatch");
|
|
89621
|
-
const service = session.computerControl;
|
|
89622
|
-
if (!service)
|
|
89623
|
-
throw new Error("Computer Use control is not supported by this session");
|
|
89624
|
-
await service.control(command);
|
|
89625
|
-
}
|
|
89626
|
-
var init_computer_handlers = __esm({
|
|
89627
|
-
"../runner/dist/handlers/computer-handlers.js"() {
|
|
89628
|
-
}
|
|
89629
|
-
});
|
|
89630
89635
|
function surfaceInputWithinCap(m3) {
|
|
89631
89636
|
let upper = 2;
|
|
89632
89637
|
let primitiveOnly = true;
|
|
@@ -89655,10 +89660,10 @@ function surfaceInputWithinCap(m3) {
|
|
|
89655
89660
|
return true;
|
|
89656
89661
|
return JSON.stringify(m3).length <= MAX_SURFACE_INPUT_BYTES;
|
|
89657
89662
|
}
|
|
89658
|
-
var RUNNER_PROTOCOL_VERSION, MIN_COMPATIBLE_PROTOCOL_VERSION, RunnerMethod, RunnerNotification, attachmentSchema, principalSchema, attachParamsSchema, runTurnParamsSchema, abortParamsSchema, setResolverParamsSchema, questionAnswerParamsSchema, modeSetActiveParamsSchema, sessionSetReasoningParamsSchema, sessionSetFastParamsSchema, MAX_HISTORY_PAGE_LIMIT, sessionLoadHistoryParamsSchema, sessionReadAttachmentParamsSchema, MAX_RECORDED_EXCHANGE_CHARS, recordedText, sessionRecordExchangeParamsSchema, sessionSetAutoApproveParamsSchema, sessionStopBackgroundWorkParamsSchema, 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;
|
|
89663
|
+
var RUNNER_PROTOCOL_VERSION, MIN_COMPATIBLE_PROTOCOL_VERSION, RunnerMethod, RunnerNotification, attachmentSchema, principalSchema, attachParamsSchema, runTurnParamsSchema, abortParamsSchema, setResolverParamsSchema, questionAnswerParamsSchema, modeSetActiveParamsSchema, sessionSetReasoningParamsSchema, sessionSetFastParamsSchema, MAX_HISTORY_PAGE_LIMIT, sessionLoadHistoryParamsSchema, sessionReadAttachmentParamsSchema, MAX_RECORDED_EXCHANGE_CHARS, recordedText, sessionRecordExchangeParamsSchema, sessionSetAutoApproveParamsSchema, sessionStopBackgroundWorkParamsSchema, providerSetActiveParamsSchema, providerCloseAgentSessionsParamsSchema, 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;
|
|
89659
89664
|
var init_protocol2 = __esm({
|
|
89660
89665
|
"../runner/dist/protocol.js"() {
|
|
89661
|
-
RUNNER_PROTOCOL_VERSION =
|
|
89666
|
+
RUNNER_PROTOCOL_VERSION = 34;
|
|
89662
89667
|
MIN_COMPATIBLE_PROTOCOL_VERSION = 1;
|
|
89663
89668
|
RunnerMethod = {
|
|
89664
89669
|
/** client->server: handshake; returns the initial info snapshot. */
|
|
@@ -89729,6 +89734,7 @@ var init_protocol2 = __esm({
|
|
|
89729
89734
|
ProviderRefreshReady: "provider.refreshReady",
|
|
89730
89735
|
/** client->server: check every agent connection's CLI again, asking the vendors' registry anew (v28). */
|
|
89731
89736
|
ProviderCheckAgents: "provider.checkAgents",
|
|
89737
|
+
ProviderCloseAgentSessions: "provider.closeAgentSessions",
|
|
89732
89738
|
/** client->server: patch a stored (runtime-registered) provider's config (v7). */
|
|
89733
89739
|
ProviderConfigure: "provider.configure",
|
|
89734
89740
|
/** client->server: persist an allow-always permission rule. */
|
|
@@ -89883,6 +89889,9 @@ var init_protocol2 = __esm({
|
|
|
89883
89889
|
name: z.string(),
|
|
89884
89890
|
config: z.record(z.unknown()).optional()
|
|
89885
89891
|
});
|
|
89892
|
+
providerCloseAgentSessionsParamsSchema = z.object({
|
|
89893
|
+
name: z.string().min(1)
|
|
89894
|
+
});
|
|
89886
89895
|
providerSetEnabledParamsSchema = z.object({
|
|
89887
89896
|
name: z.string().min(1),
|
|
89888
89897
|
enabled: z.boolean()
|
|
@@ -89971,6 +89980,203 @@ var init_protocol2 = __esm({
|
|
|
89971
89980
|
});
|
|
89972
89981
|
}
|
|
89973
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
|
+
});
|
|
89974
90180
|
async function handleWorkflowDelete(ctx, raw) {
|
|
89975
90181
|
const { name } = z.object({ name: z.string().min(1).max(120) }).strict().parse(raw);
|
|
89976
90182
|
const view = ctx.session.workflows;
|
|
@@ -90111,6 +90317,11 @@ async function handleProviderConfigure(ctx, raw) {
|
|
|
90111
90317
|
broadcastInfo();
|
|
90112
90318
|
return {};
|
|
90113
90319
|
}
|
|
90320
|
+
async function handleProviderCloseAgentSessions(ctx, raw) {
|
|
90321
|
+
const { name } = providerCloseAgentSessionsParamsSchema.parse(raw);
|
|
90322
|
+
await ctx.session.agentClis.closeSessions(name);
|
|
90323
|
+
return {};
|
|
90324
|
+
}
|
|
90114
90325
|
async function handleProviderCheckAgents(ctx) {
|
|
90115
90326
|
await ctx.session.agentClis.check({ refresh: true });
|
|
90116
90327
|
return {};
|
|
@@ -90362,6 +90573,7 @@ var CLIENT_REQUEST_TIMEOUT_MS, RunnerServer;
|
|
|
90362
90573
|
var init_server2 = __esm({
|
|
90363
90574
|
"../runner/dist/server.js"() {
|
|
90364
90575
|
init_dist3();
|
|
90576
|
+
init_history_replay();
|
|
90365
90577
|
init_jsonrpc();
|
|
90366
90578
|
init_unix_socket();
|
|
90367
90579
|
init_spoken_exchanges();
|
|
@@ -90428,12 +90640,19 @@ var init_server2 = __esm({
|
|
|
90428
90640
|
this.trackLocalTurns();
|
|
90429
90641
|
this.transport.onConnection((t2) => this.onConnection(t2));
|
|
90430
90642
|
this.logUnsub = session.log.subscribe((event) => {
|
|
90431
|
-
|
|
90643
|
+
const projected = eventForClient(event);
|
|
90644
|
+
for (const client of this.clients) {
|
|
90645
|
+
if (client.attached)
|
|
90646
|
+
client.history.live(event, projected);
|
|
90647
|
+
}
|
|
90432
90648
|
if (autoApproveSwitch(event) !== null)
|
|
90433
90649
|
this.broadcastInfo();
|
|
90434
90650
|
});
|
|
90435
90651
|
this.logClearUnsub = session.log.onClear(() => {
|
|
90436
|
-
this.
|
|
90652
|
+
for (const client of this.clients) {
|
|
90653
|
+
if (client.attached)
|
|
90654
|
+
client.history.reset();
|
|
90655
|
+
}
|
|
90437
90656
|
this.broadcastInfo();
|
|
90438
90657
|
});
|
|
90439
90658
|
this.modesUnsub = session.modes.onActiveChange(() => this.broadcastInfo());
|
|
@@ -90478,6 +90697,7 @@ var init_server2 = __esm({
|
|
|
90478
90697
|
const peer = new JsonRpcPeer(transport);
|
|
90479
90698
|
const client = {
|
|
90480
90699
|
peer,
|
|
90700
|
+
history: new ClientHistory(this.session.log, peer, transport),
|
|
90481
90701
|
role: "unknown",
|
|
90482
90702
|
attached: false,
|
|
90483
90703
|
handlesPermission: false,
|
|
@@ -90486,7 +90706,8 @@ var init_server2 = __esm({
|
|
|
90486
90706
|
};
|
|
90487
90707
|
this.clients.add(client);
|
|
90488
90708
|
const ctx = this.handlerCtx;
|
|
90489
|
-
|
|
90709
|
+
const attaches = createMutex();
|
|
90710
|
+
peer.handleWithReply(RunnerMethod.Attach, (raw, reply) => attaches.run(() => this.handleAttach(client, raw, reply)));
|
|
90490
90711
|
peer.handle(RunnerMethod.GetInfo, () => this.info());
|
|
90491
90712
|
peer.handle(RunnerMethod.ComputerSnapshot, (raw) => handleComputerSnapshot(ctx, raw));
|
|
90492
90713
|
peer.handle(RunnerMethod.ComputerControl, (raw) => handleComputerControl(ctx, raw));
|
|
@@ -90507,6 +90728,7 @@ var init_server2 = __esm({
|
|
|
90507
90728
|
peer.handle(RunnerMethod.ProviderSetEnabled, (raw) => handleProviderSetEnabled(ctx, raw));
|
|
90508
90729
|
peer.handle(RunnerMethod.ProviderRefreshReady, () => handleProviderRefreshReady(ctx));
|
|
90509
90730
|
peer.handle(RunnerMethod.ProviderCheckAgents, () => handleProviderCheckAgents(ctx));
|
|
90731
|
+
peer.handle(RunnerMethod.ProviderCloseAgentSessions, (raw) => handleProviderCloseAgentSessions(ctx, raw));
|
|
90510
90732
|
peer.handle(RunnerMethod.ProviderConfigure, (raw) => handleProviderConfigure(ctx, raw));
|
|
90511
90733
|
peer.handle(RunnerMethod.PermissionAddAllow, (raw) => handlePermissionAddAllow(ctx, raw));
|
|
90512
90734
|
peer.handle(RunnerMethod.CommandRun, (raw) => handleCommandRun(ctx, raw));
|
|
@@ -90545,30 +90767,24 @@ var init_server2 = __esm({
|
|
|
90545
90767
|
}
|
|
90546
90768
|
}
|
|
90547
90769
|
// --- request handlers ----------------------------------------------------
|
|
90548
|
-
handleAttach(client, raw) {
|
|
90770
|
+
handleAttach(client, raw, reply) {
|
|
90549
90771
|
const params = attachParamsSchema.parse(raw);
|
|
90550
90772
|
if (params.protocolVersion < MIN_COMPATIBLE_PROTOCOL_VERSION) {
|
|
90551
90773
|
throw new Error(`runner protocol mismatch: server v${RUNNER_PROTOCOL_VERSION}, client v${params.protocolVersion}`);
|
|
90552
90774
|
}
|
|
90775
|
+
if (client.peer.isClosed)
|
|
90776
|
+
throw new Error("connection closed");
|
|
90553
90777
|
client.role = params.role;
|
|
90554
90778
|
client.attached = true;
|
|
90555
90779
|
if (params.principal) {
|
|
90556
90780
|
client.principal = params.principal;
|
|
90557
90781
|
this.session.setPrincipal(params.principal);
|
|
90558
90782
|
}
|
|
90559
|
-
|
|
90560
|
-
const baseSeq = this.session.log.baseSeq;
|
|
90561
|
-
const endSeq = baseSeq + this.session.log.length;
|
|
90562
|
-
const start = replay === "full" ? baseSeq : replay === "none" ? endSeq : Math.max(baseSeq, endSeq - replay.tail);
|
|
90563
|
-
client.peer.notify(RunnerNotification.ReplayStart, { fromSeq: start });
|
|
90564
|
-
for (const event of this.session.log.slice(start)) {
|
|
90565
|
-
client.peer.notify(RunnerNotification.Event, { event: eventForClient(event) });
|
|
90566
|
-
}
|
|
90567
|
-
return {
|
|
90783
|
+
return client.history.attach(params.replay ?? "full", () => reply({
|
|
90568
90784
|
sessionId: this.session.id,
|
|
90569
90785
|
protocolVersion: RUNNER_PROTOCOL_VERSION,
|
|
90570
90786
|
info: this.info()
|
|
90571
|
-
};
|
|
90787
|
+
}));
|
|
90572
90788
|
}
|
|
90573
90789
|
handleRunTurn(client, raw) {
|
|
90574
90790
|
const params = runTurnParamsSchema.parse(raw);
|
|
@@ -90603,10 +90819,11 @@ var init_server2 = __esm({
|
|
|
90603
90819
|
try {
|
|
90604
90820
|
await this.sealUnsealedStreamedText(turnId);
|
|
90605
90821
|
await this.handlerCtx.spokenExchanges.flush();
|
|
90606
|
-
|
|
90607
|
-
|
|
90608
|
-
|
|
90609
|
-
|
|
90822
|
+
const completed = { turnId, ...error ? { error } : {} };
|
|
90823
|
+
for (const observer of this.clients) {
|
|
90824
|
+
if (observer.attached)
|
|
90825
|
+
observer.history.turnComplete(completed);
|
|
90826
|
+
}
|
|
90610
90827
|
this.broadcastInfo();
|
|
90611
90828
|
} catch (postErr) {
|
|
90612
90829
|
this.session.logger.error("runner: post-turn finalization failed", {
|
|
@@ -90731,7 +90948,11 @@ var init_server2 = __esm({
|
|
|
90731
90948
|
}
|
|
90732
90949
|
broadcastInfo() {
|
|
90733
90950
|
this.watchComputerControl();
|
|
90734
|
-
|
|
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
|
+
}
|
|
90735
90956
|
}
|
|
90736
90957
|
/**
|
|
90737
90958
|
* A turn run inside the runner — a channel bot hosting it calls
|
|
@@ -90828,9 +91049,6 @@ var init_server2 = __esm({
|
|
|
90828
91049
|
return defaultApproval(request);
|
|
90829
91050
|
}
|
|
90830
91051
|
// --- fan-out -------------------------------------------------------------
|
|
90831
|
-
broadcastEvent(event) {
|
|
90832
|
-
this.broadcast(RunnerNotification.Event, { event: eventForClient(event) });
|
|
90833
|
-
}
|
|
90834
91052
|
broadcast(method, params) {
|
|
90835
91053
|
for (const client of this.clients) {
|
|
90836
91054
|
if (client.attached && !client.peer.isClosed)
|
|
@@ -91226,6 +91444,10 @@ function makeProviderAdminView(ctx) {
|
|
|
91226
91444
|
requireServerProtocol(28, "Checking agent CLIs for updates");
|
|
91227
91445
|
await peer.request(RunnerMethod.ProviderCheckAgents, {});
|
|
91228
91446
|
},
|
|
91447
|
+
closeAgentSessions: async (name) => {
|
|
91448
|
+
requireServerProtocol(34, "Signing out of an agent");
|
|
91449
|
+
await peer.request(RunnerMethod.ProviderCloseAgentSessions, { name });
|
|
91450
|
+
},
|
|
91229
91451
|
configure: async (name, patch) => {
|
|
91230
91452
|
requireServerProtocol(7, "Configuring a provider");
|
|
91231
91453
|
await peer.request(RunnerMethod.ProviderConfigure, { name, patch });
|
|
@@ -92414,7 +92636,7 @@ async function runAttachedTui(argv, tuiOpts) {
|
|
|
92414
92636
|
return 0;
|
|
92415
92637
|
}
|
|
92416
92638
|
async function runSelfHostedTui(argv, tuiOpts, standalone) {
|
|
92417
|
-
const firstRun = await readIndex().then((runs) => shouldShowFirstRunWelcome(runs
|
|
92639
|
+
const firstRun = tuiOpts.resumeSessionId ? false : await readIndex().then((runs) => shouldShowFirstRunWelcome(runs)).catch(() => false);
|
|
92418
92640
|
if (process.stdin.isTTY) {
|
|
92419
92641
|
const { sources } = await loadConfig({
|
|
92420
92642
|
cwd: process.cwd(),
|
|
@@ -92560,7 +92782,7 @@ async function runSelfHostedTui(argv, tuiOpts, standalone) {
|
|
|
92560
92782
|
return 0;
|
|
92561
92783
|
}
|
|
92562
92784
|
function shouldShowFirstRunWelcome(runs, resumed) {
|
|
92563
|
-
return
|
|
92785
|
+
return true && runs.every((run2) => run2.eventCount === 0);
|
|
92564
92786
|
}
|
|
92565
92787
|
function errMsg2(err) {
|
|
92566
92788
|
return err instanceof Error ? err.message : String(err);
|
|
@@ -99574,8 +99796,7 @@ async function runResumeCommand(argv) {
|
|
|
99574
99796
|
}
|
|
99575
99797
|
const id = await pickSessionToResume(argv);
|
|
99576
99798
|
if (!id) return 0;
|
|
99577
|
-
const
|
|
99578
|
-
const meta = index.find((m3) => m3.id === id);
|
|
99799
|
+
const meta = await readSessionMeta(id);
|
|
99579
99800
|
const label3 = meta?.firstPrompt ?? colors.dim("(empty)");
|
|
99580
99801
|
process.stdout.write(colors.dim("continuing run \u2014 ") + label3 + "\n");
|
|
99581
99802
|
return runTuiWithBootstrap(argv, {
|
|
@@ -99584,7 +99805,7 @@ async function runResumeCommand(argv) {
|
|
|
99584
99805
|
});
|
|
99585
99806
|
}
|
|
99586
99807
|
async function cwdForResumeSession(id, fallback2) {
|
|
99587
|
-
const meta =
|
|
99808
|
+
const meta = await readSessionMeta(id);
|
|
99588
99809
|
return meta?.cwd ?? fallback2;
|
|
99589
99810
|
}
|
|
99590
99811
|
var HELP17;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moxxy/cli",
|
|
3
|
-
"version": "0.
|
|
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.
|
|
52
|
+
"@moxxy/sdk": "0.49.1"
|
|
53
53
|
},
|
|
54
54
|
"optionalDependencies": {
|
|
55
55
|
"@napi-rs/keyring": "^2.1.2"
|