@moxt-ai/mobius 0.0.354 → 0.0.355
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +407 -412
- package/dist/cli.js.map +4 -4
- package/dist/engine/agent/discovery/agent-discovery-context.d.ts +10 -0
- package/dist/engine/agent/discovery/agent-discovery-context.d.ts.map +1 -1
- package/dist/engine/agent/discovery/discover-agent.d.ts.map +1 -1
- package/dist/engine/agent/discovery/discover-agent.js +27 -6
- package/dist/engine/agent/discovery/discover-agent.js.map +1 -1
- package/dist/engine/agent/discovery/executable-discovery.d.ts.map +1 -1
- package/dist/engine/agent/discovery/executable-discovery.js +8 -1
- package/dist/engine/agent/discovery/executable-discovery.js.map +1 -1
- package/dist/engine/runtime/catalog/discover-agent-catalog.d.ts +4 -0
- package/dist/engine/runtime/catalog/discover-agent-catalog.d.ts.map +1 -0
- package/dist/engine/runtime/catalog/discover-agent-catalog.js +54 -0
- package/dist/engine/runtime/catalog/discover-agent-catalog.js.map +1 -0
- package/dist/engine/runtime/observability/diagnostic-log.d.ts.map +1 -1
- package/dist/engine/runtime/observability/diagnostic-log.js +6 -0
- package/dist/engine/runtime/observability/diagnostic-log.js.map +1 -1
- package/dist/engine/runtime/pairing.d.ts.map +1 -1
- package/dist/engine/runtime/pairing.js +6 -5
- package/dist/engine/runtime/pairing.js.map +1 -1
- package/dist/engine/runtime/runtime-loop.d.ts.map +1 -1
- package/dist/engine/runtime/runtime-loop.js +4 -3
- package/dist/engine/runtime/runtime-loop.js.map +1 -1
- package/dist/engine/util/process/executable.d.ts.map +1 -1
- package/dist/engine/util/process/executable.js +26 -8
- package/dist/engine/util/process/executable.js.map +1 -1
- package/dist/engine/util/process/process-error.d.ts +6 -1
- package/dist/engine/util/process/process-error.d.ts.map +1 -1
- package/dist/engine/util/process/process-error.js +2 -0
- package/dist/engine/util/process/process-error.js.map +1 -1
- package/dist/engine.js +376 -393
- package/dist/engine.js.map +4 -4
- package/package.json +2 -2
package/dist/engine.js
CHANGED
|
@@ -20794,38 +20794,6 @@ function isRecord2(value) {
|
|
|
20794
20794
|
}
|
|
20795
20795
|
var sessionEventBatchSchema = external_exports.array(sessionEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
20796
20796
|
var sessionLiveEventBatchSchema = external_exports.array(sessionLiveEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
20797
|
-
var sessionExportSchema = external_exports.object({
|
|
20798
|
-
binding: external_exports.object({
|
|
20799
|
-
bindingId: identifierStringSchema,
|
|
20800
|
-
runtimeId: identifierStringSchema
|
|
20801
|
-
}).readonly(),
|
|
20802
|
-
events: external_exports.array(sessionEventSchema).max(MAX_EVENT_COUNT).readonly(),
|
|
20803
|
-
sessionId: identifierStringSchema,
|
|
20804
|
-
truncated: external_exports.boolean()
|
|
20805
|
-
}).readonly().superRefine((session, context) => {
|
|
20806
|
-
const eventIds = /* @__PURE__ */ new Set();
|
|
20807
|
-
for (const [index2, event] of session.events.entries()) {
|
|
20808
|
-
if (event.sessionId !== session.sessionId) {
|
|
20809
|
-
context.addIssue({
|
|
20810
|
-
code: "custom",
|
|
20811
|
-
message: "Exported event belongs to a different Session",
|
|
20812
|
-
path: ["events", index2, "sessionId"]
|
|
20813
|
-
});
|
|
20814
|
-
}
|
|
20815
|
-
if (eventIds.has(event.eventId)) {
|
|
20816
|
-
context.addIssue({
|
|
20817
|
-
code: "custom",
|
|
20818
|
-
message: "Exported event identities are not unique",
|
|
20819
|
-
path: ["events", index2, "eventId"]
|
|
20820
|
-
});
|
|
20821
|
-
}
|
|
20822
|
-
eventIds.add(event.eventId);
|
|
20823
|
-
}
|
|
20824
|
-
});
|
|
20825
|
-
var mobiusSessionExportSchema = external_exports.object({
|
|
20826
|
-
formatVersion: external_exports.literal("2"),
|
|
20827
|
-
session: sessionExportSchema
|
|
20828
|
-
}).readonly();
|
|
20829
20797
|
var sessionEventEnvelopeSchema = external_exports.object({ events: sessionLiveEventBatchSchema, kind: external_exports.literal(SESSION_EVENT_KIND) }).readonly();
|
|
20830
20798
|
var sessionEventLogPageSchema = external_exports.object({
|
|
20831
20799
|
events: external_exports.array(sessionEventSchema).max(MAX_EVENT_COUNT).readonly(),
|
|
@@ -20838,12 +20806,9 @@ var sessionEventLogPageSchema = external_exports.object({
|
|
|
20838
20806
|
truncated: external_exports.boolean(),
|
|
20839
20807
|
version: external_exports.literal(2)
|
|
20840
20808
|
}).readonly();
|
|
20841
|
-
var sessionEventOmissionSchema = external_exports.literal("agent-reasoning");
|
|
20842
20809
|
var nativeEventPageRequestSchema = external_exports.object({
|
|
20843
20810
|
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
20844
|
-
eventLimit: external_exports.number().int().min(1).max(1e4)
|
|
20845
|
-
// Legacy callers may still send this option; readers must ignore it.
|
|
20846
|
-
omit: external_exports.array(sessionEventOmissionSchema).max(1).readonly().optional()
|
|
20811
|
+
eventLimit: external_exports.number().int().min(1).max(1e4)
|
|
20847
20812
|
}).readonly();
|
|
20848
20813
|
var queuedPromptRequestEventLogSchema = external_exports.object({
|
|
20849
20814
|
commandId: identifierStringSchema,
|
|
@@ -21522,8 +21487,6 @@ var SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND = "session.preview-history.page.loa
|
|
|
21522
21487
|
var pageRequestFields = {
|
|
21523
21488
|
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
21524
21489
|
eventLimit: external_exports.number().int().min(1).max(1e4),
|
|
21525
|
-
// Decode old clients without rejecting their request; omission has no effect.
|
|
21526
|
-
omit: external_exports.array(sessionEventOmissionSchema).max(1).readonly().optional(),
|
|
21527
21490
|
requestId: identifierStringSchema,
|
|
21528
21491
|
sessionId: identifierStringSchema
|
|
21529
21492
|
};
|
|
@@ -59518,7 +59481,6 @@ function backgroundTaskId(result) {
|
|
|
59518
59481
|
}
|
|
59519
59482
|
|
|
59520
59483
|
// src/engine/acp/harness/claude/upstream/dist/context-resources.js
|
|
59521
|
-
import { extname } from "node:path";
|
|
59522
59484
|
function formatUriAsLink(uri) {
|
|
59523
59485
|
if (uri.startsWith("file://")) {
|
|
59524
59486
|
const path7 = uri.slice(7);
|
|
@@ -59533,91 +59495,6 @@ var formatContextBlock = (uri, text2) => `
|
|
|
59533
59495
|
<context ref="${uri}">
|
|
59534
59496
|
${text2}
|
|
59535
59497
|
</context>`;
|
|
59536
|
-
function parseContextBlock(block) {
|
|
59537
|
-
if (block.type !== "text" || typeof block.text !== "string") {
|
|
59538
|
-
return null;
|
|
59539
|
-
}
|
|
59540
|
-
const match = /^\n<context ref="([^"\r\n]+)">\n([\s\S]*)\n<\/context>$/u.exec(block.text);
|
|
59541
|
-
const uri = match?.[1];
|
|
59542
|
-
const text2 = match?.[2];
|
|
59543
|
-
if (uri === void 0 || text2 === void 0 || formatContextBlock(uri, text2) !== block.text) {
|
|
59544
|
-
return null;
|
|
59545
|
-
}
|
|
59546
|
-
return { uri, text: text2 };
|
|
59547
|
-
}
|
|
59548
|
-
function contextMimeType(uri) {
|
|
59549
|
-
let pathname = uri;
|
|
59550
|
-
try {
|
|
59551
|
-
pathname = new URL(uri).pathname;
|
|
59552
|
-
} catch {
|
|
59553
|
-
}
|
|
59554
|
-
switch (extname(pathname).toLowerCase()) {
|
|
59555
|
-
case ".html":
|
|
59556
|
-
case ".htm":
|
|
59557
|
-
return "text/html";
|
|
59558
|
-
case ".js":
|
|
59559
|
-
case ".mjs":
|
|
59560
|
-
case ".cjs":
|
|
59561
|
-
return "text/javascript";
|
|
59562
|
-
case ".css":
|
|
59563
|
-
return "text/css";
|
|
59564
|
-
case ".json":
|
|
59565
|
-
return "application/json";
|
|
59566
|
-
case ".md":
|
|
59567
|
-
case ".markdown":
|
|
59568
|
-
return "text/markdown";
|
|
59569
|
-
case ".xml":
|
|
59570
|
-
return "application/xml";
|
|
59571
|
-
case ".svg":
|
|
59572
|
-
return "image/svg+xml";
|
|
59573
|
-
case ".csv":
|
|
59574
|
-
return "text/csv";
|
|
59575
|
-
default:
|
|
59576
|
-
return "text/plain";
|
|
59577
|
-
}
|
|
59578
|
-
}
|
|
59579
|
-
function replayContextResources(content) {
|
|
59580
|
-
const contexts = [];
|
|
59581
|
-
let contextStart = content.length;
|
|
59582
|
-
for (let index2 = content.length - 1; index2 >= 0; index2 -= 1) {
|
|
59583
|
-
const block = content[index2];
|
|
59584
|
-
const parsed = block === void 0 ? null : parseContextBlock(block);
|
|
59585
|
-
if (parsed === null) {
|
|
59586
|
-
break;
|
|
59587
|
-
}
|
|
59588
|
-
contexts.push(parsed);
|
|
59589
|
-
contextStart = index2;
|
|
59590
|
-
}
|
|
59591
|
-
if (contexts.length === 0) {
|
|
59592
|
-
return null;
|
|
59593
|
-
}
|
|
59594
|
-
contexts.reverse();
|
|
59595
|
-
const links = new Set(contexts.map(({ uri }) => formatUriAsLink(uri)));
|
|
59596
|
-
const resources = /* @__PURE__ */ new Map();
|
|
59597
|
-
let nextContext = 0;
|
|
59598
|
-
for (let index2 = 0; index2 < contextStart; index2 += 1) {
|
|
59599
|
-
const block = content[index2];
|
|
59600
|
-
if (block?.type !== "text" || typeof block.text !== "string") {
|
|
59601
|
-
continue;
|
|
59602
|
-
}
|
|
59603
|
-
if (block.text.startsWith('\n<context ref="')) {
|
|
59604
|
-
return null;
|
|
59605
|
-
}
|
|
59606
|
-
if (!links.has(block.text)) {
|
|
59607
|
-
continue;
|
|
59608
|
-
}
|
|
59609
|
-
const context = contexts[nextContext];
|
|
59610
|
-
if (context === void 0 || block.text !== formatUriAsLink(context.uri)) {
|
|
59611
|
-
return null;
|
|
59612
|
-
}
|
|
59613
|
-
resources.set(index2, {
|
|
59614
|
-
type: "resource",
|
|
59615
|
-
resource: { ...context, mimeType: contextMimeType(context.uri) }
|
|
59616
|
-
});
|
|
59617
|
-
nextContext += 1;
|
|
59618
|
-
}
|
|
59619
|
-
return nextContext === contexts.length ? { contextStart, resources } : null;
|
|
59620
|
-
}
|
|
59621
59498
|
|
|
59622
59499
|
// src/engine/acp/harness/claude/upstream/dist/elicitation.js
|
|
59623
59500
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
@@ -66932,13 +66809,8 @@ function toAcpNotifications(content, role, sessionId, toolUseCache, client2, log
|
|
|
66932
66809
|
const toolUseResult = options?.toolUseResult !== void 0 && content.filter((c) => typeof c === "object" && c !== null && c.type === "tool_result").length === 1 ? options.toolUseResult : void 0;
|
|
66933
66810
|
const toolResultMeta = parseToolResultMeta(options?.toolResultMeta);
|
|
66934
66811
|
const output2 = [];
|
|
66935
|
-
const
|
|
66936
|
-
for (const [index2, chunk] of content.entries()) {
|
|
66937
|
-
if (replayedResources !== null && index2 >= replayedResources.contextStart) {
|
|
66938
|
-
break;
|
|
66939
|
-
}
|
|
66812
|
+
for (const chunk of content) {
|
|
66940
66813
|
let update = null;
|
|
66941
|
-
const resource = replayedResources?.resources.get(index2);
|
|
66942
66814
|
switch (chunk.type) {
|
|
66943
66815
|
case "text":
|
|
66944
66816
|
case "text_delta": {
|
|
@@ -66947,7 +66819,7 @@ function toAcpNotifications(content, role, sessionId, toolUseCache, client2, log
|
|
|
66947
66819
|
update = {
|
|
66948
66820
|
sessionUpdate: role === "assistant" ? "agent_message_chunk" : "user_message_chunk",
|
|
66949
66821
|
messageId,
|
|
66950
|
-
content:
|
|
66822
|
+
content: {
|
|
66951
66823
|
type: "text",
|
|
66952
66824
|
text: chunk.text
|
|
66953
66825
|
}
|
|
@@ -67717,14 +67589,16 @@ var macosProcessPlatform = {
|
|
|
67717
67589
|
// src/engine/util/process/platform/windows.ts
|
|
67718
67590
|
import { execFile as execFile4 } from "node:child_process";
|
|
67719
67591
|
import { readFile as readFile5, realpath as realpath6 } from "node:fs/promises";
|
|
67720
|
-
import { dirname as dirname6, extname
|
|
67592
|
+
import { dirname as dirname6, extname, join as join14, resolve as resolve8 } from "node:path";
|
|
67721
67593
|
|
|
67722
67594
|
// src/engine/util/process/process-error.ts
|
|
67723
67595
|
var ProcessExecutionError = class extends Error {
|
|
67724
67596
|
code;
|
|
67597
|
+
diagnosticDetails;
|
|
67725
67598
|
constructor(code, message, options = {}) {
|
|
67726
67599
|
super(message, options);
|
|
67727
67600
|
this.code = code;
|
|
67601
|
+
this.diagnosticDetails = options.diagnosticDetails ?? {};
|
|
67728
67602
|
this.name = "ProcessExecutionError";
|
|
67729
67603
|
}
|
|
67730
67604
|
};
|
|
@@ -67744,14 +67618,14 @@ function executableExtensions(executableName, environment) {
|
|
|
67744
67618
|
async function resolveExecutableTarget(path7) {
|
|
67745
67619
|
let resolvedPath;
|
|
67746
67620
|
try {
|
|
67747
|
-
resolvedPath = await realpath6(
|
|
67621
|
+
resolvedPath = await realpath6(extname(path7) === "" ? `${path7}.cmd` : path7);
|
|
67748
67622
|
} catch (cause) {
|
|
67749
|
-
if (
|
|
67623
|
+
if (extname(path7) !== "" || !(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
|
|
67750
67624
|
throw cause;
|
|
67751
67625
|
}
|
|
67752
67626
|
resolvedPath = await realpath6(path7);
|
|
67753
67627
|
}
|
|
67754
|
-
if (
|
|
67628
|
+
if (extname(resolvedPath).toLowerCase() === ".cmd") {
|
|
67755
67629
|
const shim = await readFile5(resolvedPath, "utf8");
|
|
67756
67630
|
if (shim.includes('SET "NPM_CLI_JS=%~dp0\\node_modules\\npm\\bin\\npm-cli.js"') && shim.includes('"%NODE_EXE%" "%NPM_CLI_JS%" %*')) {
|
|
67757
67631
|
return await realpath6(resolve8(dirname6(resolvedPath), "node_modules/npm/bin/npm-cli.js"));
|
|
@@ -68135,11 +68009,16 @@ async function runBoundedProcess(options) {
|
|
|
68135
68009
|
abort();
|
|
68136
68010
|
}
|
|
68137
68011
|
try {
|
|
68138
|
-
const
|
|
68139
|
-
child.once("error",
|
|
68140
|
-
child.once("exit", (code) =>
|
|
68012
|
+
const completion = new Promise((resolveCompletion, rejectCompletion) => {
|
|
68013
|
+
child.once("error", rejectCompletion);
|
|
68014
|
+
child.once("exit", (code) => {
|
|
68015
|
+
if (code !== 0) {
|
|
68016
|
+
resolveCompletion(code ?? 1);
|
|
68017
|
+
}
|
|
68018
|
+
});
|
|
68019
|
+
child.once("close", (code) => resolveCompletion(code ?? 1));
|
|
68141
68020
|
});
|
|
68142
|
-
const exitCode = await Promise.race([
|
|
68021
|
+
const exitCode = await Promise.race([completion, interrupted.promise.then(() => -1)]);
|
|
68143
68022
|
if (interruptionCleanupFailure !== null) {
|
|
68144
68023
|
throw interruptionCleanupFailure;
|
|
68145
68024
|
}
|
|
@@ -68151,12 +68030,19 @@ async function runBoundedProcess(options) {
|
|
|
68151
68030
|
}
|
|
68152
68031
|
return new ProcessResult(Buffer.concat(stdout).toString("utf8"), Buffer.concat(stderr).toString("utf8"));
|
|
68153
68032
|
} catch (error62) {
|
|
68154
|
-
|
|
68155
|
-
throw error62;
|
|
68156
|
-
}
|
|
68157
|
-
throw new ProcessExecutionError("process_spawn_failed", "The executable could not be started", {
|
|
68033
|
+
const failure2 = error62 instanceof ProcessExecutionError ? error62 : new ProcessExecutionError("process_spawn_failed", "The executable could not be started", {
|
|
68158
68034
|
cause: error62
|
|
68159
68035
|
});
|
|
68036
|
+
throw new ProcessExecutionError(failure2.code, failure2.message, {
|
|
68037
|
+
cause: error62,
|
|
68038
|
+
diagnosticDetails: {
|
|
68039
|
+
stdoutBytes: stdoutBytes.toString(),
|
|
68040
|
+
stderrBytes: stderrBytes.toString(),
|
|
68041
|
+
outputLimitBytes: outputLimitBytes.toString(),
|
|
68042
|
+
...child.exitCode === null ? {} : { exitCode: child.exitCode.toString() },
|
|
68043
|
+
...child.signalCode === null ? {} : { signal: child.signalCode }
|
|
68044
|
+
}
|
|
68045
|
+
});
|
|
68160
68046
|
} finally {
|
|
68161
68047
|
clearTimeout(timeout);
|
|
68162
68048
|
options.signal.removeEventListener("abort", abort);
|
|
@@ -75623,7 +75509,14 @@ async function probeVersion(executable, arguments_, environment, defaultWorkspac
|
|
|
75623
75509
|
});
|
|
75624
75510
|
const version2 = normalize4(result.stdout || result.stderr);
|
|
75625
75511
|
if (version2.length === 0) {
|
|
75626
|
-
throw new ProcessExecutionError("process_exit_failed", "The executable did not report a version"
|
|
75512
|
+
throw new ProcessExecutionError("process_exit_failed", "The executable did not report a version", {
|
|
75513
|
+
diagnosticDetails: {
|
|
75514
|
+
probeReason: "empty_version_output",
|
|
75515
|
+
exitCode: "0",
|
|
75516
|
+
stdoutBytes: Buffer.byteLength(result.stdout).toString(),
|
|
75517
|
+
stderrBytes: Buffer.byteLength(result.stderr).toString()
|
|
75518
|
+
}
|
|
75519
|
+
});
|
|
75627
75520
|
}
|
|
75628
75521
|
return version2;
|
|
75629
75522
|
}
|
|
@@ -75645,9 +75538,27 @@ function isRetryableProbeFailure(error62) {
|
|
|
75645
75538
|
}
|
|
75646
75539
|
return error62 instanceof AgentProbeError && error62.code === "adapter_probe_timeout";
|
|
75647
75540
|
}
|
|
75648
|
-
async function probeWithRetry(
|
|
75541
|
+
async function probeWithRetry(context, specification, source, probe) {
|
|
75542
|
+
const signal = context.signal;
|
|
75543
|
+
const run = async (attempt) => {
|
|
75544
|
+
const startedAt = performance.now();
|
|
75545
|
+
try {
|
|
75546
|
+
return await probe();
|
|
75547
|
+
} catch (failure2) {
|
|
75548
|
+
context.onProbeDiagnostic?.({
|
|
75549
|
+
agentId: specification.id,
|
|
75550
|
+
source,
|
|
75551
|
+
event: signal.aborted ? "agent_probe_cancelled" : "agent_probe_failed",
|
|
75552
|
+
attempt,
|
|
75553
|
+
elapsedMilliseconds: Math.round(performance.now() - startedAt),
|
|
75554
|
+
timeoutMilliseconds: source === "acp_readiness" ? specification.acpProbeTimeoutMilliseconds : specification.versionProbeTimeoutMilliseconds,
|
|
75555
|
+
failure: failure2
|
|
75556
|
+
});
|
|
75557
|
+
throw failure2;
|
|
75558
|
+
}
|
|
75559
|
+
};
|
|
75649
75560
|
try {
|
|
75650
|
-
return await
|
|
75561
|
+
return await run(1);
|
|
75651
75562
|
} catch (error62) {
|
|
75652
75563
|
if (signal.aborted) {
|
|
75653
75564
|
signal.throwIfAborted();
|
|
@@ -75655,7 +75566,7 @@ async function probeWithRetry(signal, probe) {
|
|
|
75655
75566
|
if (!isRetryableProbeFailure(error62)) {
|
|
75656
75567
|
throw error62;
|
|
75657
75568
|
}
|
|
75658
|
-
return await
|
|
75569
|
+
return await run(2);
|
|
75659
75570
|
}
|
|
75660
75571
|
}
|
|
75661
75572
|
function integrationProbeFailure(specification, error62) {
|
|
@@ -75685,7 +75596,9 @@ async function discoverAgent(specification, context) {
|
|
|
75685
75596
|
let agentVersion = "";
|
|
75686
75597
|
try {
|
|
75687
75598
|
agentVersion = await probeWithRetry(
|
|
75688
|
-
context
|
|
75599
|
+
context,
|
|
75600
|
+
specification,
|
|
75601
|
+
"agent_version",
|
|
75689
75602
|
async () => await probeVersion(
|
|
75690
75603
|
agent,
|
|
75691
75604
|
specification.agentVersionArguments,
|
|
@@ -75733,7 +75646,9 @@ async function discoverAgent(specification, context) {
|
|
|
75733
75646
|
launchEnvironment = await specification.createLaunchEnvironment(agent, context);
|
|
75734
75647
|
if (specification.adapterVersionArguments.length > 0) {
|
|
75735
75648
|
adapterVersion = await probeWithRetry(
|
|
75736
|
-
context
|
|
75649
|
+
context,
|
|
75650
|
+
specification,
|
|
75651
|
+
"adapter_version",
|
|
75737
75652
|
async () => await probeVersion(
|
|
75738
75653
|
adapter,
|
|
75739
75654
|
specification.adapterVersionArguments,
|
|
@@ -75768,7 +75683,9 @@ async function discoverAgent(specification, context) {
|
|
|
75768
75683
|
);
|
|
75769
75684
|
try {
|
|
75770
75685
|
const readiness = await probeWithRetry(
|
|
75771
|
-
context
|
|
75686
|
+
context,
|
|
75687
|
+
specification,
|
|
75688
|
+
"acp_readiness",
|
|
75772
75689
|
async () => await probeAcpReadiness(
|
|
75773
75690
|
specification,
|
|
75774
75691
|
buildDefinition(adapterVersion, unsupportedSessionCapabilities()),
|
|
@@ -83471,6 +83388,266 @@ function describeEnvironmentProxyRoute(target) {
|
|
|
83471
83388
|
};
|
|
83472
83389
|
}
|
|
83473
83390
|
|
|
83391
|
+
// src/engine/runtime/observability/diagnostic-log.ts
|
|
83392
|
+
import { join as join26 } from "node:path";
|
|
83393
|
+
|
|
83394
|
+
// src/engine/storage/logs/bounded-log.ts
|
|
83395
|
+
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync4, readFileSync as readFileSync9, renameSync as renameSync2, statSync as statSync5, writeFileSync as writeFileSync2 } from "node:fs";
|
|
83396
|
+
import { join as join24 } from "node:path";
|
|
83397
|
+
var BoundedLineLog = class {
|
|
83398
|
+
#path;
|
|
83399
|
+
#maximumBytes;
|
|
83400
|
+
#directory;
|
|
83401
|
+
#reportedFailure = false;
|
|
83402
|
+
#onWriteFailure;
|
|
83403
|
+
constructor(directory, filename, maximumBytes, onWriteFailure = () => void 0) {
|
|
83404
|
+
this.#directory = directory;
|
|
83405
|
+
this.#path = join24(directory, filename);
|
|
83406
|
+
this.#maximumBytes = maximumBytes;
|
|
83407
|
+
this.#onWriteFailure = onWriteFailure;
|
|
83408
|
+
}
|
|
83409
|
+
record = (line) => {
|
|
83410
|
+
try {
|
|
83411
|
+
mkdirSync4(this.#directory, { mode: 448, recursive: true });
|
|
83412
|
+
this.#append(line);
|
|
83413
|
+
} catch (cause) {
|
|
83414
|
+
if (!this.#reportedFailure) {
|
|
83415
|
+
this.#reportedFailure = true;
|
|
83416
|
+
this.#onWriteFailure(cause);
|
|
83417
|
+
}
|
|
83418
|
+
}
|
|
83419
|
+
};
|
|
83420
|
+
#append = (line) => {
|
|
83421
|
+
const encoded = `${line.replace(/[\r\n]+/gu, " ").trim()}
|
|
83422
|
+
`;
|
|
83423
|
+
const encodedBytes = Buffer.byteLength(encoded);
|
|
83424
|
+
let existingBytes = 0;
|
|
83425
|
+
try {
|
|
83426
|
+
existingBytes = statSync5(this.#path).size;
|
|
83427
|
+
} catch (cause) {
|
|
83428
|
+
if (!(cause instanceof Error && Reflect.get(cause, "code") === "ENOENT")) {
|
|
83429
|
+
throw cause;
|
|
83430
|
+
}
|
|
83431
|
+
}
|
|
83432
|
+
if (existingBytes + encodedBytes <= this.#maximumBytes) {
|
|
83433
|
+
appendFileSync2(this.#path, encoded, { encoding: "utf8", mode: 384 });
|
|
83434
|
+
return;
|
|
83435
|
+
}
|
|
83436
|
+
const lines = `${existingBytes === 0 ? "" : readFileSync9(this.#path, "utf8")}${encoded}`.split("\n").filter((candidate) => candidate.length > 0);
|
|
83437
|
+
let totalBytes = lines.reduce((total, candidate) => total + Buffer.byteLength(candidate) + 1, 0);
|
|
83438
|
+
while (totalBytes > this.#maximumBytes && lines.length > 0) {
|
|
83439
|
+
const oldest = lines.shift();
|
|
83440
|
+
if (oldest !== void 0) {
|
|
83441
|
+
totalBytes -= Buffer.byteLength(oldest) + 1;
|
|
83442
|
+
}
|
|
83443
|
+
}
|
|
83444
|
+
const temporaryPath = `${this.#path}.tmp`;
|
|
83445
|
+
writeFileSync2(temporaryPath, lines.length === 0 ? "" : `${lines.join("\n")}
|
|
83446
|
+
`, {
|
|
83447
|
+
encoding: "utf8",
|
|
83448
|
+
mode: 384
|
|
83449
|
+
});
|
|
83450
|
+
renameSync2(temporaryPath, this.#path);
|
|
83451
|
+
};
|
|
83452
|
+
};
|
|
83453
|
+
|
|
83454
|
+
// src/engine/storage/logs/log-files.ts
|
|
83455
|
+
import { readFileSync as readFileSync10 } from "node:fs";
|
|
83456
|
+
import { join as join25 } from "node:path";
|
|
83457
|
+
var DAEMON_LOG_FILENAME = "daemon.log";
|
|
83458
|
+
var WORKER_LIFECYCLE_LOG_FILENAME = "worker-lifecycle.log";
|
|
83459
|
+
function unhandledRejectionLogFilename(role) {
|
|
83460
|
+
return `unhandled-rejections-${role}.log`;
|
|
83461
|
+
}
|
|
83462
|
+
function logDirectory(dataDirectory) {
|
|
83463
|
+
return join25(dataDirectory, "logs");
|
|
83464
|
+
}
|
|
83465
|
+
function processLogPaths(dataDirectory) {
|
|
83466
|
+
return [
|
|
83467
|
+
WORKER_LIFECYCLE_LOG_FILENAME,
|
|
83468
|
+
unhandledRejectionLogFilename("manager"),
|
|
83469
|
+
unhandledRejectionLogFilename("worker")
|
|
83470
|
+
].map((filename) => join25(logDirectory(dataDirectory), filename));
|
|
83471
|
+
}
|
|
83472
|
+
function readLogText(path7) {
|
|
83473
|
+
try {
|
|
83474
|
+
return readFileSync10(path7, "utf8");
|
|
83475
|
+
} catch {
|
|
83476
|
+
return null;
|
|
83477
|
+
}
|
|
83478
|
+
}
|
|
83479
|
+
|
|
83480
|
+
// src/engine/runtime/observability/diagnostic-log.ts
|
|
83481
|
+
var MAXIMUM_RUNTIME_LOG_BYTES = 1 * 1024 * 1024;
|
|
83482
|
+
var MAXIMUM_ENTRIES = 200;
|
|
83483
|
+
var MAXIMUM_REPORT_BYTES = 6e4;
|
|
83484
|
+
var REMOTE_DIAGNOSTIC_FIELDS = [
|
|
83485
|
+
"agentId",
|
|
83486
|
+
"operation",
|
|
83487
|
+
"runtimeId",
|
|
83488
|
+
"closeCode",
|
|
83489
|
+
"timeoutMilliseconds",
|
|
83490
|
+
"attempt",
|
|
83491
|
+
"elapsedMilliseconds",
|
|
83492
|
+
"stdoutBytes",
|
|
83493
|
+
"stderrBytes",
|
|
83494
|
+
"outputLimitBytes",
|
|
83495
|
+
"probeReason",
|
|
83496
|
+
"proxyRoute",
|
|
83497
|
+
"timestamp",
|
|
83498
|
+
"event",
|
|
83499
|
+
"channelId",
|
|
83500
|
+
"requestId",
|
|
83501
|
+
"commandId",
|
|
83502
|
+
"sessionId",
|
|
83503
|
+
"turnId",
|
|
83504
|
+
"connectionEpoch",
|
|
83505
|
+
"code",
|
|
83506
|
+
"source",
|
|
83507
|
+
"kind",
|
|
83508
|
+
"pid",
|
|
83509
|
+
"version",
|
|
83510
|
+
"exitCode",
|
|
83511
|
+
"signal",
|
|
83512
|
+
"failureName",
|
|
83513
|
+
"failureCode",
|
|
83514
|
+
"failureStatusCode",
|
|
83515
|
+
"cause1Name",
|
|
83516
|
+
"cause1Code",
|
|
83517
|
+
"cause2Name",
|
|
83518
|
+
"cause2Code"
|
|
83519
|
+
];
|
|
83520
|
+
var FIELD_VALUE_PATTERN = /^[a-zA-Z0-9_.: -]{1,256}$/u;
|
|
83521
|
+
var RuntimeDiagnosticLog = class {
|
|
83522
|
+
#log;
|
|
83523
|
+
#maximumBytes;
|
|
83524
|
+
#sources;
|
|
83525
|
+
constructor(stateDirectory, options = {}) {
|
|
83526
|
+
const maximumBytes = options.maximumBytes ?? MAXIMUM_RUNTIME_LOG_BYTES;
|
|
83527
|
+
const directory = logDirectory(stateDirectory);
|
|
83528
|
+
this.#log = new BoundedLineLog(directory, DAEMON_LOG_FILENAME, maximumBytes);
|
|
83529
|
+
this.#maximumBytes = maximumBytes;
|
|
83530
|
+
const processLogsDirectory = options.processLogsDirectory;
|
|
83531
|
+
this.#sources = [
|
|
83532
|
+
{ maximumBytes, path: join26(directory, DAEMON_LOG_FILENAME) },
|
|
83533
|
+
// The process logs a Runtime does not own, but must read to explain its own deaths.
|
|
83534
|
+
...processLogsDirectory === void 0 ? [] : processLogPaths(processLogsDirectory).map((path7) => ({ maximumBytes: null, path: path7 }))
|
|
83535
|
+
];
|
|
83536
|
+
}
|
|
83537
|
+
// Export only correlation and failure metadata. Local messages and paths stay local.
|
|
83538
|
+
snapshot = () => {
|
|
83539
|
+
const merged = [];
|
|
83540
|
+
let truncated = false;
|
|
83541
|
+
for (const source of this.#sources) {
|
|
83542
|
+
const collected = this.#read(source);
|
|
83543
|
+
merged.push(...collected.entries);
|
|
83544
|
+
truncated ||= collected.truncated;
|
|
83545
|
+
}
|
|
83546
|
+
merged.sort(compareTimestamp);
|
|
83547
|
+
const entries = merged.slice(-MAXIMUM_ENTRIES);
|
|
83548
|
+
truncated ||= entries.length < merged.length;
|
|
83549
|
+
while (JSON.stringify(entries).length > MAXIMUM_REPORT_BYTES && entries.length > 0) {
|
|
83550
|
+
entries.shift();
|
|
83551
|
+
truncated = true;
|
|
83552
|
+
}
|
|
83553
|
+
return { entries, truncated };
|
|
83554
|
+
};
|
|
83555
|
+
record = (diagnostic) => {
|
|
83556
|
+
this.#log.record(diagnostic);
|
|
83557
|
+
};
|
|
83558
|
+
#read = (source) => {
|
|
83559
|
+
const content = readLogText(source.path);
|
|
83560
|
+
if (content === null) {
|
|
83561
|
+
return { entries: [], truncated: false };
|
|
83562
|
+
}
|
|
83563
|
+
const lines = content.split("\n").filter((line) => line.length > 0);
|
|
83564
|
+
const entries = [];
|
|
83565
|
+
for (const line of lines.slice(-MAXIMUM_ENTRIES)) {
|
|
83566
|
+
const start = line.indexOf("{");
|
|
83567
|
+
if (start < 0) {
|
|
83568
|
+
continue;
|
|
83569
|
+
}
|
|
83570
|
+
let value;
|
|
83571
|
+
try {
|
|
83572
|
+
value = JSON.parse(line.slice(start));
|
|
83573
|
+
} catch {
|
|
83574
|
+
continue;
|
|
83575
|
+
}
|
|
83576
|
+
if (typeof value !== "object" || value === null) {
|
|
83577
|
+
continue;
|
|
83578
|
+
}
|
|
83579
|
+
entries.push(exportedFields(value));
|
|
83580
|
+
}
|
|
83581
|
+
const nearRotation = source.maximumBytes !== null && Buffer.byteLength(content) >= source.maximumBytes - 4096;
|
|
83582
|
+
return { entries, truncated: lines.length > MAXIMUM_ENTRIES || nearRotation };
|
|
83583
|
+
};
|
|
83584
|
+
};
|
|
83585
|
+
function exportedFields(value) {
|
|
83586
|
+
const entry = {};
|
|
83587
|
+
for (const field of REMOTE_DIAGNOSTIC_FIELDS) {
|
|
83588
|
+
const item = Reflect.get(value, field);
|
|
83589
|
+
if (typeof item === "string" && FIELD_VALUE_PATTERN.test(item)) {
|
|
83590
|
+
entry[field] = item;
|
|
83591
|
+
} else if (typeof item === "number" && Number.isFinite(item)) {
|
|
83592
|
+
entry[field] = String(item);
|
|
83593
|
+
}
|
|
83594
|
+
}
|
|
83595
|
+
return entry;
|
|
83596
|
+
}
|
|
83597
|
+
function compareTimestamp(left, right) {
|
|
83598
|
+
const leftAt = left["timestamp"] ?? "";
|
|
83599
|
+
const rightAt = right["timestamp"] ?? "";
|
|
83600
|
+
return leftAt < rightAt ? -1 : leftAt > rightAt ? 1 : 0;
|
|
83601
|
+
}
|
|
83602
|
+
|
|
83603
|
+
// src/engine/runtime/catalog/discover-agent-catalog.ts
|
|
83604
|
+
function failureDetails(failure2) {
|
|
83605
|
+
const fields = {};
|
|
83606
|
+
let current = failure2;
|
|
83607
|
+
for (let depth = 0; depth < 3 && current instanceof Error; depth += 1) {
|
|
83608
|
+
const prefix = depth === 0 ? "failure" : `cause${depth.toString()}`;
|
|
83609
|
+
if (current instanceof ProcessExecutionError || current instanceof AgentProbeError) {
|
|
83610
|
+
fields[`${prefix}Name`] = current instanceof ProcessExecutionError ? "ProcessExecutionError" : "AgentProbeError";
|
|
83611
|
+
fields[`${prefix}Code`] = current.code;
|
|
83612
|
+
} else {
|
|
83613
|
+
fields[`${prefix}Name`] = "Error";
|
|
83614
|
+
}
|
|
83615
|
+
if (depth === 0 && current instanceof ProcessExecutionError) {
|
|
83616
|
+
Object.assign(fields, current.diagnosticDetails);
|
|
83617
|
+
}
|
|
83618
|
+
current = current.cause;
|
|
83619
|
+
}
|
|
83620
|
+
return fields;
|
|
83621
|
+
}
|
|
83622
|
+
async function discoverRuntimeAgentInventory(options, channelId) {
|
|
83623
|
+
const log = new RuntimeDiagnosticLog(options.dataDirectory);
|
|
83624
|
+
const record2 = (details) => {
|
|
83625
|
+
log.record(
|
|
83626
|
+
`Mobius agent discovery diagnostic ${JSON.stringify({
|
|
83627
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
83628
|
+
channelId,
|
|
83629
|
+
...details
|
|
83630
|
+
})}`
|
|
83631
|
+
);
|
|
83632
|
+
};
|
|
83633
|
+
const inventory = await discoverLocalAgentInventory({
|
|
83634
|
+
...options,
|
|
83635
|
+
onProbeDiagnostic: ({ failure: failure2, ...diagnostic }) => {
|
|
83636
|
+
record2({ ...diagnostic, ...failureDetails(failure2) });
|
|
83637
|
+
}
|
|
83638
|
+
});
|
|
83639
|
+
for (const { discovery, detectionMilliseconds } of inventory.results) {
|
|
83640
|
+
record2({
|
|
83641
|
+
event: "agent_discovery_result",
|
|
83642
|
+
agentId: discovery.specification.id,
|
|
83643
|
+
code: discovery instanceof UnavailableAgent ? discovery.code : "ready",
|
|
83644
|
+
source: discovery.status,
|
|
83645
|
+
elapsedMilliseconds: detectionMilliseconds
|
|
83646
|
+
});
|
|
83647
|
+
}
|
|
83648
|
+
return inventory;
|
|
83649
|
+
}
|
|
83650
|
+
|
|
83474
83651
|
// src/engine/runtime/catalog/publish-agent-catalog.ts
|
|
83475
83652
|
import { fetch as fetch2 } from "undici";
|
|
83476
83653
|
|
|
@@ -83917,21 +84094,27 @@ function buildSavedRuntimeConfig(connection, defaultWorkspace, inventory, localC
|
|
|
83917
84094
|
localContext,
|
|
83918
84095
|
new OpaqueRuntimeReconnectTarget(connection.connectionId),
|
|
83919
84096
|
createCatalogAgentResolver(
|
|
83920
|
-
(refreshSignal) =>
|
|
84097
|
+
(refreshSignal) => discoverRuntimeAgentInventory(
|
|
84098
|
+
{
|
|
84099
|
+
defaultWorkspace,
|
|
84100
|
+
dataDirectory: localContext.stateDirectory,
|
|
84101
|
+
environment: localContext.agentLaunchEnvironment,
|
|
84102
|
+
signal: refreshSignal
|
|
84103
|
+
},
|
|
84104
|
+
connection.channelId
|
|
84105
|
+
),
|
|
84106
|
+
() => config2,
|
|
84107
|
+
publishAgentCatalog
|
|
84108
|
+
),
|
|
84109
|
+
(refreshSignal) => discoverRuntimeAgentInventory(
|
|
84110
|
+
{
|
|
83921
84111
|
defaultWorkspace,
|
|
83922
84112
|
dataDirectory: localContext.stateDirectory,
|
|
83923
84113
|
environment: localContext.agentLaunchEnvironment,
|
|
83924
84114
|
signal: refreshSignal
|
|
83925
|
-
}
|
|
83926
|
-
|
|
83927
|
-
|
|
83928
|
-
),
|
|
83929
|
-
(refreshSignal) => discoverLocalAgentInventory({
|
|
83930
|
-
defaultWorkspace,
|
|
83931
|
-
dataDirectory: localContext.stateDirectory,
|
|
83932
|
-
environment: localContext.agentLaunchEnvironment,
|
|
83933
|
-
signal: refreshSignal
|
|
83934
|
-
}).then((inventory2) => inventory2.readyAgents())
|
|
84115
|
+
},
|
|
84116
|
+
connection.channelId
|
|
84117
|
+
).then((inventory2) => inventory2.readyAgents())
|
|
83935
84118
|
);
|
|
83936
84119
|
return config2;
|
|
83937
84120
|
}
|
|
@@ -83975,12 +84158,15 @@ async function pairRuntimeConnection(installation, options, signal, environment)
|
|
|
83975
84158
|
async function prepareRuntimeConnection(installation, connection, signal, environment, maxAcpProcesses) {
|
|
83976
84159
|
const localContext = new RuntimeLocalContext(installation.stateDirectory, environment, maxAcpProcesses);
|
|
83977
84160
|
const defaultWorkspace = await resolveDefaultWorkspace(connection.defaultWorkspace);
|
|
83978
|
-
const inventory = await
|
|
83979
|
-
|
|
83980
|
-
|
|
83981
|
-
|
|
83982
|
-
|
|
83983
|
-
|
|
84161
|
+
const inventory = await discoverRuntimeAgentInventory(
|
|
84162
|
+
{
|
|
84163
|
+
defaultWorkspace,
|
|
84164
|
+
dataDirectory: localContext.stateDirectory,
|
|
84165
|
+
environment: localContext.agentLaunchEnvironment,
|
|
84166
|
+
signal
|
|
84167
|
+
},
|
|
84168
|
+
connection.channelId
|
|
84169
|
+
);
|
|
83984
84170
|
return buildSavedRuntimeConfig(connection, defaultWorkspace, inventory, localContext);
|
|
83985
84171
|
}
|
|
83986
84172
|
|
|
@@ -88069,7 +88255,7 @@ var SessionTurns = class {
|
|
|
88069
88255
|
|
|
88070
88256
|
// src/engine/session/workspace/workspace-directory.ts
|
|
88071
88257
|
import { homedir as homedir3 } from "node:os";
|
|
88072
|
-
import { basename as basename7, dirname as dirname10, isAbsolute as isAbsolute15, join as
|
|
88258
|
+
import { basename as basename7, dirname as dirname10, isAbsolute as isAbsolute15, join as join27, normalize as normalize2, relative as relative2 } from "node:path";
|
|
88073
88259
|
var WorkspaceDirectoryListing = class {
|
|
88074
88260
|
directoryId;
|
|
88075
88261
|
directoryLabel;
|
|
@@ -88192,7 +88378,7 @@ var WorkspaceDirectoryService = class {
|
|
|
88192
88378
|
continue;
|
|
88193
88379
|
}
|
|
88194
88380
|
try {
|
|
88195
|
-
const path7 = await this.resolvePath(
|
|
88381
|
+
const path7 = await this.resolvePath(join27(target, child.name), signal);
|
|
88196
88382
|
entries.push({ directoryId: encodePath(path7), name: child.name });
|
|
88197
88383
|
} catch (cause) {
|
|
88198
88384
|
signal.throwIfAborted();
|
|
@@ -88348,12 +88534,12 @@ function buildSessionLayer(options) {
|
|
|
88348
88534
|
|
|
88349
88535
|
// src/engine/session/content/external-content-store.ts
|
|
88350
88536
|
import { createHash as createHash8 } from "node:crypto";
|
|
88351
|
-
import { extname as
|
|
88537
|
+
import { extname as extname2, join as join29 } from "node:path";
|
|
88352
88538
|
|
|
88353
88539
|
// src/engine/storage/files/scratch-directory.ts
|
|
88354
88540
|
import { randomUUID as randomUUID17 } from "node:crypto";
|
|
88355
88541
|
import { lstat as lstat4, mkdir as mkdir5, readdir as readdir6, readFile as readFile6, realpath as realpath7, rename as rename4, rm as rm3, stat as stat6, utimes, writeFile as writeFile2 } from "node:fs/promises";
|
|
88356
|
-
import { dirname as dirname11, join as
|
|
88542
|
+
import { dirname as dirname11, join as join28 } from "node:path";
|
|
88357
88543
|
async function atomicWrite(path7, bytes, signal) {
|
|
88358
88544
|
const temporary = `${path7}.${randomUUID17()}.tmp`;
|
|
88359
88545
|
try {
|
|
@@ -88367,7 +88553,7 @@ async function atomicWrite(path7, bytes, signal) {
|
|
|
88367
88553
|
var ScratchDirectory = class {
|
|
88368
88554
|
#root;
|
|
88369
88555
|
constructor(parent) {
|
|
88370
|
-
this.#root =
|
|
88556
|
+
this.#root = join28(parent, randomUUID17());
|
|
88371
88557
|
}
|
|
88372
88558
|
/** Refreshes this directory's lease and removes sibling directories whose lease is older than `leaseMilliseconds`. */
|
|
88373
88559
|
refreshLease = async (leaseMilliseconds) => {
|
|
@@ -88378,7 +88564,7 @@ var ScratchDirectory = class {
|
|
|
88378
88564
|
if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
|
|
88379
88565
|
continue;
|
|
88380
88566
|
}
|
|
88381
|
-
const path7 =
|
|
88567
|
+
const path7 = join28(dirname11(this.#root), directory.name);
|
|
88382
88568
|
if (path7 === this.#root) {
|
|
88383
88569
|
continue;
|
|
88384
88570
|
}
|
|
@@ -88393,10 +88579,10 @@ var ScratchDirectory = class {
|
|
|
88393
88579
|
};
|
|
88394
88580
|
/** Writes `bytes` atomically to `<group>/<name>` with owner-only permissions and returns the path. */
|
|
88395
88581
|
write = async (group, name2, bytes, signal) => {
|
|
88396
|
-
const directory =
|
|
88582
|
+
const directory = join28(this.#root, group);
|
|
88397
88583
|
await mkdir5(directory, { mode: 448, recursive: true });
|
|
88398
88584
|
signal.throwIfAborted();
|
|
88399
|
-
const path7 =
|
|
88585
|
+
const path7 = join28(directory, name2);
|
|
88400
88586
|
await atomicWrite(path7, bytes, signal);
|
|
88401
88587
|
return path7;
|
|
88402
88588
|
};
|
|
@@ -88436,7 +88622,7 @@ var metadataSchema = external_exports.strictObject({
|
|
|
88436
88622
|
name: external_exports.string().min(1).max(500)
|
|
88437
88623
|
});
|
|
88438
88624
|
function contentFileName(key, name2) {
|
|
88439
|
-
const extension =
|
|
88625
|
+
const extension = extname2(name2).toLowerCase();
|
|
88440
88626
|
return /^\.[a-z0-9]{1,16}$/u.test(extension) ? `${key}${extension}` : key;
|
|
88441
88627
|
}
|
|
88442
88628
|
var LocalExternalContentStore = class {
|
|
@@ -88447,7 +88633,7 @@ var LocalExternalContentStore = class {
|
|
|
88447
88633
|
#expirationTimer;
|
|
88448
88634
|
#cleanup = Promise.resolve();
|
|
88449
88635
|
constructor(stateDirectory) {
|
|
88450
|
-
this.#scratch = new ScratchDirectory(
|
|
88636
|
+
this.#scratch = new ScratchDirectory(join29(stateDirectory, "tmp", "session-content"));
|
|
88451
88637
|
this.#expirationTimer = setInterval(() => {
|
|
88452
88638
|
void this.#expire().catch(() => void 0);
|
|
88453
88639
|
}, 6e4);
|
|
@@ -88821,212 +89007,6 @@ var AgentProcessPool = class {
|
|
|
88821
89007
|
};
|
|
88822
89008
|
};
|
|
88823
89009
|
|
|
88824
|
-
// src/engine/runtime/observability/diagnostic-log.ts
|
|
88825
|
-
import { join as join29 } from "node:path";
|
|
88826
|
-
|
|
88827
|
-
// src/engine/storage/logs/bounded-log.ts
|
|
88828
|
-
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync4, readFileSync as readFileSync9, renameSync as renameSync2, statSync as statSync5, writeFileSync as writeFileSync2 } from "node:fs";
|
|
88829
|
-
import { join as join27 } from "node:path";
|
|
88830
|
-
var BoundedLineLog = class {
|
|
88831
|
-
#path;
|
|
88832
|
-
#maximumBytes;
|
|
88833
|
-
#directory;
|
|
88834
|
-
#reportedFailure = false;
|
|
88835
|
-
#onWriteFailure;
|
|
88836
|
-
constructor(directory, filename, maximumBytes, onWriteFailure = () => void 0) {
|
|
88837
|
-
this.#directory = directory;
|
|
88838
|
-
this.#path = join27(directory, filename);
|
|
88839
|
-
this.#maximumBytes = maximumBytes;
|
|
88840
|
-
this.#onWriteFailure = onWriteFailure;
|
|
88841
|
-
}
|
|
88842
|
-
record = (line) => {
|
|
88843
|
-
try {
|
|
88844
|
-
mkdirSync4(this.#directory, { mode: 448, recursive: true });
|
|
88845
|
-
this.#append(line);
|
|
88846
|
-
} catch (cause) {
|
|
88847
|
-
if (!this.#reportedFailure) {
|
|
88848
|
-
this.#reportedFailure = true;
|
|
88849
|
-
this.#onWriteFailure(cause);
|
|
88850
|
-
}
|
|
88851
|
-
}
|
|
88852
|
-
};
|
|
88853
|
-
#append = (line) => {
|
|
88854
|
-
const encoded = `${line.replace(/[\r\n]+/gu, " ").trim()}
|
|
88855
|
-
`;
|
|
88856
|
-
const encodedBytes = Buffer.byteLength(encoded);
|
|
88857
|
-
let existingBytes = 0;
|
|
88858
|
-
try {
|
|
88859
|
-
existingBytes = statSync5(this.#path).size;
|
|
88860
|
-
} catch (cause) {
|
|
88861
|
-
if (!(cause instanceof Error && Reflect.get(cause, "code") === "ENOENT")) {
|
|
88862
|
-
throw cause;
|
|
88863
|
-
}
|
|
88864
|
-
}
|
|
88865
|
-
if (existingBytes + encodedBytes <= this.#maximumBytes) {
|
|
88866
|
-
appendFileSync2(this.#path, encoded, { encoding: "utf8", mode: 384 });
|
|
88867
|
-
return;
|
|
88868
|
-
}
|
|
88869
|
-
const lines = `${existingBytes === 0 ? "" : readFileSync9(this.#path, "utf8")}${encoded}`.split("\n").filter((candidate) => candidate.length > 0);
|
|
88870
|
-
let totalBytes = lines.reduce((total, candidate) => total + Buffer.byteLength(candidate) + 1, 0);
|
|
88871
|
-
while (totalBytes > this.#maximumBytes && lines.length > 0) {
|
|
88872
|
-
const oldest = lines.shift();
|
|
88873
|
-
if (oldest !== void 0) {
|
|
88874
|
-
totalBytes -= Buffer.byteLength(oldest) + 1;
|
|
88875
|
-
}
|
|
88876
|
-
}
|
|
88877
|
-
const temporaryPath = `${this.#path}.tmp`;
|
|
88878
|
-
writeFileSync2(temporaryPath, lines.length === 0 ? "" : `${lines.join("\n")}
|
|
88879
|
-
`, {
|
|
88880
|
-
encoding: "utf8",
|
|
88881
|
-
mode: 384
|
|
88882
|
-
});
|
|
88883
|
-
renameSync2(temporaryPath, this.#path);
|
|
88884
|
-
};
|
|
88885
|
-
};
|
|
88886
|
-
|
|
88887
|
-
// src/engine/storage/logs/log-files.ts
|
|
88888
|
-
import { readFileSync as readFileSync10 } from "node:fs";
|
|
88889
|
-
import { join as join28 } from "node:path";
|
|
88890
|
-
var DAEMON_LOG_FILENAME = "daemon.log";
|
|
88891
|
-
var WORKER_LIFECYCLE_LOG_FILENAME = "worker-lifecycle.log";
|
|
88892
|
-
function unhandledRejectionLogFilename(role) {
|
|
88893
|
-
return `unhandled-rejections-${role}.log`;
|
|
88894
|
-
}
|
|
88895
|
-
function logDirectory(dataDirectory) {
|
|
88896
|
-
return join28(dataDirectory, "logs");
|
|
88897
|
-
}
|
|
88898
|
-
function processLogPaths(dataDirectory) {
|
|
88899
|
-
return [
|
|
88900
|
-
WORKER_LIFECYCLE_LOG_FILENAME,
|
|
88901
|
-
unhandledRejectionLogFilename("manager"),
|
|
88902
|
-
unhandledRejectionLogFilename("worker")
|
|
88903
|
-
].map((filename) => join28(logDirectory(dataDirectory), filename));
|
|
88904
|
-
}
|
|
88905
|
-
function readLogText(path7) {
|
|
88906
|
-
try {
|
|
88907
|
-
return readFileSync10(path7, "utf8");
|
|
88908
|
-
} catch {
|
|
88909
|
-
return null;
|
|
88910
|
-
}
|
|
88911
|
-
}
|
|
88912
|
-
|
|
88913
|
-
// src/engine/runtime/observability/diagnostic-log.ts
|
|
88914
|
-
var MAXIMUM_RUNTIME_LOG_BYTES = 1 * 1024 * 1024;
|
|
88915
|
-
var MAXIMUM_ENTRIES = 200;
|
|
88916
|
-
var MAXIMUM_REPORT_BYTES = 6e4;
|
|
88917
|
-
var REMOTE_DIAGNOSTIC_FIELDS = [
|
|
88918
|
-
"agentId",
|
|
88919
|
-
"operation",
|
|
88920
|
-
"runtimeId",
|
|
88921
|
-
"closeCode",
|
|
88922
|
-
"timeoutMilliseconds",
|
|
88923
|
-
"proxyRoute",
|
|
88924
|
-
"timestamp",
|
|
88925
|
-
"event",
|
|
88926
|
-
"channelId",
|
|
88927
|
-
"requestId",
|
|
88928
|
-
"commandId",
|
|
88929
|
-
"sessionId",
|
|
88930
|
-
"turnId",
|
|
88931
|
-
"connectionEpoch",
|
|
88932
|
-
"code",
|
|
88933
|
-
"source",
|
|
88934
|
-
"kind",
|
|
88935
|
-
"pid",
|
|
88936
|
-
"version",
|
|
88937
|
-
"exitCode",
|
|
88938
|
-
"signal",
|
|
88939
|
-
"failureName",
|
|
88940
|
-
"failureCode",
|
|
88941
|
-
"failureStatusCode",
|
|
88942
|
-
"cause1Name",
|
|
88943
|
-
"cause1Code",
|
|
88944
|
-
"cause2Name",
|
|
88945
|
-
"cause2Code"
|
|
88946
|
-
];
|
|
88947
|
-
var FIELD_VALUE_PATTERN = /^[a-zA-Z0-9_.: -]{1,256}$/u;
|
|
88948
|
-
var RuntimeDiagnosticLog = class {
|
|
88949
|
-
#log;
|
|
88950
|
-
#maximumBytes;
|
|
88951
|
-
#sources;
|
|
88952
|
-
constructor(stateDirectory, options = {}) {
|
|
88953
|
-
const maximumBytes = options.maximumBytes ?? MAXIMUM_RUNTIME_LOG_BYTES;
|
|
88954
|
-
const directory = logDirectory(stateDirectory);
|
|
88955
|
-
this.#log = new BoundedLineLog(directory, DAEMON_LOG_FILENAME, maximumBytes);
|
|
88956
|
-
this.#maximumBytes = maximumBytes;
|
|
88957
|
-
const processLogsDirectory = options.processLogsDirectory;
|
|
88958
|
-
this.#sources = [
|
|
88959
|
-
{ maximumBytes, path: join29(directory, DAEMON_LOG_FILENAME) },
|
|
88960
|
-
// The process logs a Runtime does not own, but must read to explain its own deaths.
|
|
88961
|
-
...processLogsDirectory === void 0 ? [] : processLogPaths(processLogsDirectory).map((path7) => ({ maximumBytes: null, path: path7 }))
|
|
88962
|
-
];
|
|
88963
|
-
}
|
|
88964
|
-
// Export only correlation and failure metadata. Local messages and paths stay local.
|
|
88965
|
-
snapshot = () => {
|
|
88966
|
-
const merged = [];
|
|
88967
|
-
let truncated = false;
|
|
88968
|
-
for (const source of this.#sources) {
|
|
88969
|
-
const collected = this.#read(source);
|
|
88970
|
-
merged.push(...collected.entries);
|
|
88971
|
-
truncated ||= collected.truncated;
|
|
88972
|
-
}
|
|
88973
|
-
merged.sort(compareTimestamp);
|
|
88974
|
-
const entries = merged.slice(-MAXIMUM_ENTRIES);
|
|
88975
|
-
truncated ||= entries.length < merged.length;
|
|
88976
|
-
while (JSON.stringify(entries).length > MAXIMUM_REPORT_BYTES && entries.length > 0) {
|
|
88977
|
-
entries.shift();
|
|
88978
|
-
truncated = true;
|
|
88979
|
-
}
|
|
88980
|
-
return { entries, truncated };
|
|
88981
|
-
};
|
|
88982
|
-
record = (diagnostic) => {
|
|
88983
|
-
this.#log.record(diagnostic);
|
|
88984
|
-
};
|
|
88985
|
-
#read = (source) => {
|
|
88986
|
-
const content = readLogText(source.path);
|
|
88987
|
-
if (content === null) {
|
|
88988
|
-
return { entries: [], truncated: false };
|
|
88989
|
-
}
|
|
88990
|
-
const lines = content.split("\n").filter((line) => line.length > 0);
|
|
88991
|
-
const entries = [];
|
|
88992
|
-
for (const line of lines.slice(-MAXIMUM_ENTRIES)) {
|
|
88993
|
-
const start = line.indexOf("{");
|
|
88994
|
-
if (start < 0) {
|
|
88995
|
-
continue;
|
|
88996
|
-
}
|
|
88997
|
-
let value;
|
|
88998
|
-
try {
|
|
88999
|
-
value = JSON.parse(line.slice(start));
|
|
89000
|
-
} catch {
|
|
89001
|
-
continue;
|
|
89002
|
-
}
|
|
89003
|
-
if (typeof value !== "object" || value === null) {
|
|
89004
|
-
continue;
|
|
89005
|
-
}
|
|
89006
|
-
entries.push(exportedFields(value));
|
|
89007
|
-
}
|
|
89008
|
-
const nearRotation = source.maximumBytes !== null && Buffer.byteLength(content) >= source.maximumBytes - 4096;
|
|
89009
|
-
return { entries, truncated: lines.length > MAXIMUM_ENTRIES || nearRotation };
|
|
89010
|
-
};
|
|
89011
|
-
};
|
|
89012
|
-
function exportedFields(value) {
|
|
89013
|
-
const entry = {};
|
|
89014
|
-
for (const field of REMOTE_DIAGNOSTIC_FIELDS) {
|
|
89015
|
-
const item = Reflect.get(value, field);
|
|
89016
|
-
if (typeof item === "string" && FIELD_VALUE_PATTERN.test(item)) {
|
|
89017
|
-
entry[field] = item;
|
|
89018
|
-
} else if (typeof item === "number" && Number.isFinite(item)) {
|
|
89019
|
-
entry[field] = String(item);
|
|
89020
|
-
}
|
|
89021
|
-
}
|
|
89022
|
-
return entry;
|
|
89023
|
-
}
|
|
89024
|
-
function compareTimestamp(left, right) {
|
|
89025
|
-
const leftAt = left["timestamp"] ?? "";
|
|
89026
|
-
const rightAt = right["timestamp"] ?? "";
|
|
89027
|
-
return leftAt < rightAt ? -1 : leftAt > rightAt ? 1 : 0;
|
|
89028
|
-
}
|
|
89029
|
-
|
|
89030
89010
|
// src/engine/runtime/relay/diagnostics.ts
|
|
89031
89011
|
var MAX_DIAGNOSTIC_TEXT_LENGTH = 256;
|
|
89032
89012
|
function sanitizeDiagnosticText(value) {
|
|
@@ -89951,7 +89931,7 @@ function createContentWriteCommands(context) {
|
|
|
89951
89931
|
import { WebSocket as WebSocket5 } from "undici";
|
|
89952
89932
|
|
|
89953
89933
|
// src/engine/session/content/session-files.ts
|
|
89954
|
-
import { basename as basename8, extname as
|
|
89934
|
+
import { basename as basename8, extname as extname3, isAbsolute as isAbsolute16, join as join30, normalize as normalize3, resolve as resolve16 } from "node:path";
|
|
89955
89935
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
89956
89936
|
function requestedPath(value) {
|
|
89957
89937
|
if (value.includes("\0")) {
|
|
@@ -90007,7 +89987,7 @@ async function streamLocalFile(command, send2, sendChunk, signal, workingDirecto
|
|
|
90007
89987
|
send2({
|
|
90008
89988
|
byteLength: before.size,
|
|
90009
89989
|
kind: FILE_BEGIN_KIND,
|
|
90010
|
-
mediaType: external?.mediaType ?? raster?.mimeType ?? (
|
|
89990
|
+
mediaType: external?.mediaType ?? raster?.mimeType ?? (extname3(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
|
|
90011
89991
|
modifiedAt: before.modifiedAt.toISOString(),
|
|
90012
89992
|
name: external?.name ?? (basename8(target) || "file"),
|
|
90013
89993
|
requestId: command.requestId,
|
|
@@ -90969,7 +90949,7 @@ var sessionPromptCommand = {
|
|
|
90969
90949
|
// package.json
|
|
90970
90950
|
var package_default = {
|
|
90971
90951
|
name: "@moxt-ai/mobius",
|
|
90972
|
-
version: "0.0.
|
|
90952
|
+
version: "0.0.355",
|
|
90973
90953
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
90974
90954
|
type: "module",
|
|
90975
90955
|
bin: {
|
|
@@ -92426,13 +92406,16 @@ async function prepareProvidedRuntime({
|
|
|
92426
92406
|
const defaultWorkspace = await resolveWorkspace(connection.defaultWorkspace);
|
|
92427
92407
|
const specifications = supportedLocalAgentSpecifications();
|
|
92428
92408
|
const discoveryEnvironment = localContext.agentLaunchEnvironment;
|
|
92429
|
-
const discover = async (refreshSignal) => await
|
|
92430
|
-
|
|
92431
|
-
|
|
92432
|
-
|
|
92433
|
-
|
|
92434
|
-
|
|
92435
|
-
|
|
92409
|
+
const discover = async (refreshSignal) => await discoverRuntimeAgentInventory(
|
|
92410
|
+
{
|
|
92411
|
+
defaultWorkspace,
|
|
92412
|
+
dataDirectory: localContext.stateDirectory,
|
|
92413
|
+
environment: discoveryEnvironment,
|
|
92414
|
+
signal: refreshSignal,
|
|
92415
|
+
specifications
|
|
92416
|
+
},
|
|
92417
|
+
connection.channelId
|
|
92418
|
+
);
|
|
92436
92419
|
const inventory = await discover(signal);
|
|
92437
92420
|
const config2 = createRuntimeConfig(
|
|
92438
92421
|
{
|