@moxt-ai/mobius 0.0.390 → 0.0.392
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/{chunk-ZW763PCS.js → chunk-5CY7MW6G.js} +230 -56
- package/dist/{chunk-ZW763PCS.js.map → chunk-5CY7MW6G.js.map} +4 -4
- package/dist/{chunk-KWRP3J26.js → chunk-GM7DKNVA.js} +2 -2
- package/dist/{chunk-KWRP3J26.js.map → chunk-GM7DKNVA.js.map} +1 -1
- package/dist/{cli-K2JBHPL5.js → cli-SYSXXECN.js} +3 -3
- package/dist/cli.js +2 -2
- package/dist/engine/generated/command-cancellation-migrations.d.ts +5 -0
- package/dist/engine/generated/command-cancellation-migrations.d.ts.map +1 -0
- package/dist/engine/generated/command-cancellation-migrations.js +9 -0
- package/dist/engine/generated/command-cancellation-migrations.js.map +1 -0
- package/dist/engine/runtime/command/registry/runtime.d.ts.map +1 -1
- package/dist/engine/runtime/command/registry/runtime.js +3 -2
- package/dist/engine/runtime/command/registry/runtime.js.map +1 -1
- package/dist/engine/runtime/observability/diagnostic-log.d.ts +1 -1
- package/dist/engine/runtime/observability/diagnostic-log.d.ts.map +1 -1
- package/dist/engine/runtime/observability/diagnostic-log.js +16 -1
- package/dist/engine/runtime/observability/diagnostic-log.js.map +1 -1
- package/dist/engine/runtime/observability/environment-diagnostics.d.ts +4 -0
- package/dist/engine/runtime/observability/environment-diagnostics.d.ts.map +1 -0
- package/dist/engine/runtime/observability/environment-diagnostics.js +72 -0
- package/dist/engine/runtime/observability/environment-diagnostics.js.map +1 -0
- package/dist/engine/runtime/relay/diagnostics.d.ts +1 -1
- package/dist/engine/runtime/relay/diagnostics.d.ts.map +1 -1
- package/dist/engine/runtime/relay/diagnostics.js +1 -1
- package/dist/engine/runtime/relay/diagnostics.js.map +1 -1
- package/dist/engine/schema/command-cancellation/cancelled-command.d.ts +41 -0
- package/dist/engine/schema/command-cancellation/cancelled-command.d.ts.map +1 -0
- package/dist/engine/schema/command-cancellation/cancelled-command.js +7 -0
- package/dist/engine/schema/command-cancellation/cancelled-command.js.map +1 -0
- package/dist/engine/schema/command-cancellation/index.d.ts +2 -0
- package/dist/engine/schema/command-cancellation/index.d.ts.map +1 -0
- package/dist/engine/schema/command-cancellation/index.js +2 -0
- package/dist/engine/schema/command-cancellation/index.js.map +1 -0
- package/dist/engine/session/api/session-layer.d.ts.map +1 -1
- package/dist/engine/session/api/session-layer.js +6 -2
- package/dist/engine/session/api/session-layer.js.map +1 -1
- package/dist/engine/session/turn/execution-receipts.d.ts +2 -1
- package/dist/engine/session/turn/execution-receipts.d.ts.map +1 -1
- package/dist/engine/session/turn/execution-receipts.js +91 -33
- package/dist/engine/session/turn/execution-receipts.js.map +1 -1
- package/dist/engine/storage/session/command-cancellation-table.d.ts +17 -0
- package/dist/engine/storage/session/command-cancellation-table.d.ts.map +1 -0
- package/dist/engine/storage/session/command-cancellation-table.js +28 -0
- package/dist/engine/storage/session/command-cancellation-table.js.map +1 -0
- package/dist/engine/storage/sqlite/local-databases.d.ts +3 -0
- package/dist/engine/storage/sqlite/local-databases.d.ts.map +1 -1
- package/dist/engine/storage/sqlite/local-databases.js +4 -0
- package/dist/engine/storage/sqlite/local-databases.js.map +1 -1
- package/dist/engine.js +2 -2
- package/package.json +1 -1
- /package/dist/{cli-K2JBHPL5.js.map → cli-SYSXXECN.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
__export,
|
|
4
4
|
__using,
|
|
5
5
|
package_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-GM7DKNVA.js";
|
|
7
7
|
|
|
8
8
|
// src/engine/runtime/relay/runtime-revocation.ts
|
|
9
9
|
var runtimeRevocationCloseCode = 1008;
|
|
@@ -44,14 +44,14 @@ var RuntimeOperations = class {
|
|
|
44
44
|
this.#pending.delete(pending);
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
close = (
|
|
47
|
+
close = (release2) => {
|
|
48
48
|
if (this.#closing !== null) {
|
|
49
49
|
return this.#closing;
|
|
50
50
|
}
|
|
51
51
|
this.#shutdown.abort();
|
|
52
52
|
this.#closing = (async () => {
|
|
53
53
|
await Promise.allSettled([...this.#pending]);
|
|
54
|
-
await
|
|
54
|
+
await release2();
|
|
55
55
|
})();
|
|
56
56
|
return this.#closing;
|
|
57
57
|
};
|
|
@@ -2098,10 +2098,10 @@ function nanoidOfLength(length) {
|
|
|
2098
2098
|
var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
2099
2099
|
var extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
|
2100
2100
|
var guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
2101
|
-
var uuid = (
|
|
2102
|
-
if (!
|
|
2101
|
+
var uuid = (version3) => {
|
|
2102
|
+
if (!version3)
|
|
2103
2103
|
return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
|
|
2104
|
-
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${
|
|
2104
|
+
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version3}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
2105
2105
|
};
|
|
2106
2106
|
var uuid4 = /* @__PURE__ */ uuid(4);
|
|
2107
2107
|
var uuid6 = /* @__PURE__ */ uuid(6);
|
|
@@ -19590,10 +19590,10 @@ function fromJSONSchema(schema, params) {
|
|
|
19590
19590
|
} catch {
|
|
19591
19591
|
throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
|
|
19592
19592
|
}
|
|
19593
|
-
const
|
|
19593
|
+
const version3 = detectVersion(normalized, params?.defaultTarget);
|
|
19594
19594
|
const defs = normalized.$defs || normalized.definitions || {};
|
|
19595
19595
|
const ctx = {
|
|
19596
|
-
version:
|
|
19596
|
+
version: version3,
|
|
19597
19597
|
defs,
|
|
19598
19598
|
refs: /* @__PURE__ */ new Map(),
|
|
19599
19599
|
processing: /* @__PURE__ */ new Set(),
|
|
@@ -22199,9 +22199,9 @@ function installedDirectories(directory) {
|
|
|
22199
22199
|
function claudeDesktopExecutablePaths(roots, executablePaths) {
|
|
22200
22200
|
const paths = [];
|
|
22201
22201
|
for (const root of roots) {
|
|
22202
|
-
const versions = installedDirectories(root).filter((
|
|
22203
|
-
for (const
|
|
22204
|
-
const directory = join4(root,
|
|
22202
|
+
const versions = installedDirectories(root).filter((version3) => /^\d+\.\d+\.\d+$/.test(version3)).toSorted((left, right) => right.localeCompare(left, "en", { numeric: true }));
|
|
22203
|
+
for (const version3 of versions) {
|
|
22204
|
+
const directory = join4(root, version3);
|
|
22205
22205
|
const installations = [
|
|
22206
22206
|
directory,
|
|
22207
22207
|
...installedDirectories(directory).map((build) => join4(directory, build))
|
|
@@ -75730,8 +75730,8 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
|
|
|
75730
75730
|
|
|
75731
75731
|
// src/engine/agent/discovery/executable-discovery.ts
|
|
75732
75732
|
import { isAbsolute as isAbsolute13 } from "node:path";
|
|
75733
|
-
async function resolveSpecificationExecutables(executableName,
|
|
75734
|
-
const override = context.environment[
|
|
75733
|
+
async function resolveSpecificationExecutables(executableName, overrideVariable2, resolveInstalled, context) {
|
|
75734
|
+
const override = context.environment[overrideVariable2];
|
|
75735
75735
|
if (override !== void 0) {
|
|
75736
75736
|
if (override.length === 0 || !isAbsolute13(override)) {
|
|
75737
75737
|
return [];
|
|
@@ -75775,8 +75775,8 @@ async function probeVersion(executable, arguments_, environment, defaultWorkspac
|
|
|
75775
75775
|
signal,
|
|
75776
75776
|
timeoutMilliseconds
|
|
75777
75777
|
});
|
|
75778
|
-
const
|
|
75779
|
-
if (
|
|
75778
|
+
const version3 = normalize4(result.stdout || result.stderr);
|
|
75779
|
+
if (version3.length === 0) {
|
|
75780
75780
|
throw new ProcessExecutionError("process_exit_failed", "The executable did not report a version", {
|
|
75781
75781
|
diagnosticDetails: {
|
|
75782
75782
|
probeReason: "empty_version_output",
|
|
@@ -75786,7 +75786,7 @@ async function probeVersion(executable, arguments_, environment, defaultWorkspac
|
|
|
75786
75786
|
}
|
|
75787
75787
|
});
|
|
75788
75788
|
}
|
|
75789
|
-
return
|
|
75789
|
+
return version3;
|
|
75790
75790
|
}
|
|
75791
75791
|
|
|
75792
75792
|
// src/engine/agent/discovery/discover-agent.ts
|
|
@@ -78293,6 +78293,14 @@ var acpSessionStoreMigrations = [
|
|
|
78293
78293
|
}
|
|
78294
78294
|
];
|
|
78295
78295
|
|
|
78296
|
+
// src/engine/generated/command-cancellation-migrations.ts
|
|
78297
|
+
var commandCancellationMigrations = [
|
|
78298
|
+
{
|
|
78299
|
+
"name": "0000_tired_cardiac.sql",
|
|
78300
|
+
"sql": "CREATE TABLE `cancelled_command` (\n `command_id` text PRIMARY KEY NOT NULL,\n `session_id` text NOT NULL\n);\n"
|
|
78301
|
+
}
|
|
78302
|
+
];
|
|
78303
|
+
|
|
78296
78304
|
// src/engine/generated/session-event-cache-migrations.ts
|
|
78297
78305
|
var sessionEventCacheMigrations = [
|
|
78298
78306
|
{
|
|
@@ -83192,11 +83200,11 @@ var LocalSqliteDatabase = class {
|
|
|
83192
83200
|
}
|
|
83193
83201
|
}
|
|
83194
83202
|
#migrate = (label, migrations) => {
|
|
83195
|
-
const
|
|
83196
|
-
if (
|
|
83203
|
+
const version3 = external_exports.object({ user_version: external_exports.number().int().nonnegative() }).parse(this.#sqlite.prepare("PRAGMA user_version").get()).user_version;
|
|
83204
|
+
if (version3 > migrations.length) {
|
|
83197
83205
|
throw new Error(`The ${label} was created by a newer Mobius version`);
|
|
83198
83206
|
}
|
|
83199
|
-
for (let index2 =
|
|
83207
|
+
for (let index2 = version3; index2 < migrations.length; index2 += 1) {
|
|
83200
83208
|
const migration = migrations[index2];
|
|
83201
83209
|
if (migration === void 0) {
|
|
83202
83210
|
throw new Error(`The ${label} migration is unavailable`);
|
|
@@ -83232,6 +83240,7 @@ var LocalSqliteDatabase = class {
|
|
|
83232
83240
|
function channelSessionDatabasePaths(stateDirectory, channelId) {
|
|
83233
83241
|
const channelHash = createHash4("sha256").update(channelId).digest("hex");
|
|
83234
83242
|
return {
|
|
83243
|
+
cancellations: join22(stateDirectory, "sessions", `${channelHash}.cancellations.sqlite`),
|
|
83235
83244
|
events: join22(stateDirectory, "sessions", `${channelHash}.events.sqlite`),
|
|
83236
83245
|
sessions: join22(stateDirectory, "sessions", `${channelHash}.sqlite`)
|
|
83237
83246
|
};
|
|
@@ -83242,9 +83251,9 @@ function recordAppliedAdmissionOrder(path7) {
|
|
|
83242
83251
|
}
|
|
83243
83252
|
const database = new DatabaseSync3(path7);
|
|
83244
83253
|
try {
|
|
83245
|
-
const
|
|
83254
|
+
const version3 = database.prepare("PRAGMA user_version").get()?.["user_version"];
|
|
83246
83255
|
const column = database.prepare("SELECT name FROM pragma_table_info('execution_receipt') WHERE name = 'admission_order'").get();
|
|
83247
|
-
if (
|
|
83256
|
+
if (version3 === 9 && column !== void 0) {
|
|
83248
83257
|
database.exec("PRAGMA user_version = 10");
|
|
83249
83258
|
}
|
|
83250
83259
|
} finally {
|
|
@@ -83255,6 +83264,7 @@ var openAcpSessionDatabase = (path7) => {
|
|
|
83255
83264
|
recordAppliedAdmissionOrder(path7);
|
|
83256
83265
|
return new LocalSqliteDatabase(path7, "ACP Session database", acpSessionStoreMigrations);
|
|
83257
83266
|
};
|
|
83267
|
+
var openCommandCancellationDatabase = (path7) => new LocalSqliteDatabase(path7, "Command cancellation database", commandCancellationMigrations);
|
|
83258
83268
|
var openSessionEventCacheDatabase = (path7) => new LocalSqliteDatabase(path7, "V2 Session event cache", sessionEventCacheMigrations, [
|
|
83259
83269
|
"PRAGMA journal_mode = WAL",
|
|
83260
83270
|
"PRAGMA synchronous = OFF",
|
|
@@ -84315,7 +84325,20 @@ var REMOTE_DIAGNOSTIC_FIELDS = [
|
|
|
84315
84325
|
"cause1Name",
|
|
84316
84326
|
"cause1Code",
|
|
84317
84327
|
"cause2Name",
|
|
84318
|
-
"cause2Code"
|
|
84328
|
+
"cause2Code",
|
|
84329
|
+
"platform",
|
|
84330
|
+
"architecture",
|
|
84331
|
+
"osRelease",
|
|
84332
|
+
"nodeVersion",
|
|
84333
|
+
"uptimeSeconds",
|
|
84334
|
+
"agentCount",
|
|
84335
|
+
"omittedAgents",
|
|
84336
|
+
"agentVersion",
|
|
84337
|
+
"adapterVersion",
|
|
84338
|
+
"versionSource",
|
|
84339
|
+
"executableLocation",
|
|
84340
|
+
"executableOverride",
|
|
84341
|
+
"codexHome"
|
|
84319
84342
|
];
|
|
84320
84343
|
var FIELD_VALUE_PATTERN = /^[a-zA-Z0-9_.: -]{1,256}$/u;
|
|
84321
84344
|
var RuntimeDiagnosticLog = class {
|
|
@@ -84335,7 +84358,7 @@ var RuntimeDiagnosticLog = class {
|
|
|
84335
84358
|
];
|
|
84336
84359
|
}
|
|
84337
84360
|
// Export only correlation and failure metadata. Local messages and paths stay local.
|
|
84338
|
-
snapshot = () => {
|
|
84361
|
+
snapshot = (current = []) => {
|
|
84339
84362
|
const merged = [];
|
|
84340
84363
|
let truncated = false;
|
|
84341
84364
|
for (const source of this.#sources) {
|
|
@@ -84344,6 +84367,7 @@ var RuntimeDiagnosticLog = class {
|
|
|
84344
84367
|
truncated ||= collected.truncated;
|
|
84345
84368
|
}
|
|
84346
84369
|
merged.sort(compareTimestamp);
|
|
84370
|
+
merged.push(...current.map(exportedFields));
|
|
84347
84371
|
const entries = merged.slice(-MAXIMUM_ENTRIES);
|
|
84348
84372
|
truncated ||= entries.length < merged.length;
|
|
84349
84373
|
while (JSON.stringify(entries).length > MAXIMUM_REPORT_BYTES && entries.length > 0) {
|
|
@@ -84692,9 +84716,9 @@ function createCatalogAgentResolver(discover, readConfig, publish) {
|
|
|
84692
84716
|
await pending;
|
|
84693
84717
|
return config2.catalog.find(agent.id);
|
|
84694
84718
|
}
|
|
84695
|
-
let
|
|
84719
|
+
let release2 = () => void 0;
|
|
84696
84720
|
const gate = new Promise((resolveGate) => {
|
|
84697
|
-
|
|
84721
|
+
release2 = resolveGate;
|
|
84698
84722
|
});
|
|
84699
84723
|
swaps.set(agent.id, gate);
|
|
84700
84724
|
try {
|
|
@@ -84718,7 +84742,7 @@ function createCatalogAgentResolver(discover, readConfig, publish) {
|
|
|
84718
84742
|
return config2.catalog.find(agent.id);
|
|
84719
84743
|
} finally {
|
|
84720
84744
|
swaps.delete(agent.id);
|
|
84721
|
-
|
|
84745
|
+
release2();
|
|
84722
84746
|
}
|
|
84723
84747
|
};
|
|
84724
84748
|
}
|
|
@@ -85045,6 +85069,33 @@ var AcpSessionTable = class {
|
|
|
85045
85069
|
};
|
|
85046
85070
|
};
|
|
85047
85071
|
|
|
85072
|
+
// src/engine/schema/command-cancellation/cancelled-command.ts
|
|
85073
|
+
var cancelledCommand = sqliteTable("cancelled_command", {
|
|
85074
|
+
commandId: text("command_id").primaryKey(),
|
|
85075
|
+
sessionId: text("session_id").notNull()
|
|
85076
|
+
});
|
|
85077
|
+
|
|
85078
|
+
// src/engine/storage/session/command-cancellation-table.ts
|
|
85079
|
+
var cancellationSchema = external_exports.object({ commandId: external_exports.string(), sessionId: external_exports.string() }).readonly();
|
|
85080
|
+
var CommandCancellationTable = class {
|
|
85081
|
+
#database;
|
|
85082
|
+
constructor(database) {
|
|
85083
|
+
this.#database = database;
|
|
85084
|
+
}
|
|
85085
|
+
close = () => this.#database.close();
|
|
85086
|
+
read = (commandId) => {
|
|
85087
|
+
const row = this.#database.orm.select().from(cancelledCommand).where(eq2(cancelledCommand.commandId, commandId)).get();
|
|
85088
|
+
return row === void 0 ? void 0 : cancellationSchema.parse(row);
|
|
85089
|
+
};
|
|
85090
|
+
retain = (cancellations) => {
|
|
85091
|
+
this.#database.transaction(() => {
|
|
85092
|
+
for (const cancellation of cancellations) {
|
|
85093
|
+
this.#database.orm.insert(cancelledCommand).values(cancellation).onConflictDoNothing().run();
|
|
85094
|
+
}
|
|
85095
|
+
});
|
|
85096
|
+
};
|
|
85097
|
+
};
|
|
85098
|
+
|
|
85048
85099
|
// src/engine/storage/session/execution-receipt-table.ts
|
|
85049
85100
|
var receiptSchema = external_exports.object({
|
|
85050
85101
|
commandId: external_exports.string(),
|
|
@@ -87740,7 +87791,7 @@ var SessionManager2 = class {
|
|
|
87740
87791
|
return;
|
|
87741
87792
|
}
|
|
87742
87793
|
this.#announceClosed(options.sessionId, "This Session was closed on request.");
|
|
87743
|
-
const
|
|
87794
|
+
const release2 = (async () => {
|
|
87744
87795
|
const retiring = this.#sessionRetirements.get(options.sessionId);
|
|
87745
87796
|
if (retiring !== void 0) {
|
|
87746
87797
|
await retiring;
|
|
@@ -87762,14 +87813,14 @@ var SessionManager2 = class {
|
|
|
87762
87813
|
),
|
|
87763
87814
|
SESSION_CLOSE_TIMEOUT_MILLISECONDS
|
|
87764
87815
|
);
|
|
87765
|
-
const completion = Promise.race([
|
|
87816
|
+
const completion = Promise.race([release2, deadline.promise]).finally(timeout.cancel);
|
|
87766
87817
|
this.#sessionClosures.set(options.sessionId, completion);
|
|
87767
87818
|
const releaseFinished = () => {
|
|
87768
87819
|
if (this.#sessionClosures.get(options.sessionId) === completion) {
|
|
87769
87820
|
this.#sessionClosures.delete(options.sessionId);
|
|
87770
87821
|
}
|
|
87771
87822
|
};
|
|
87772
|
-
void
|
|
87823
|
+
void release2.then(releaseFinished, releaseFinished);
|
|
87773
87824
|
await waitForSharedOperation(completion, options.signal);
|
|
87774
87825
|
});
|
|
87775
87826
|
close = async () => {
|
|
@@ -88616,6 +88667,13 @@ function executionStarted(state) {
|
|
|
88616
88667
|
}
|
|
88617
88668
|
}
|
|
88618
88669
|
}
|
|
88670
|
+
function cancelledBeforeStart(state) {
|
|
88671
|
+
if (state.kind !== "settled-before-start") {
|
|
88672
|
+
return false;
|
|
88673
|
+
}
|
|
88674
|
+
const outcome = decodeKnownSessionEventPayload(JSON.parse(state.outcome));
|
|
88675
|
+
return outcome?.type === "lifecycle-metadata" && outcome.payload.kind === "prompt.completed" && outcome.payload.stopReason === "cancelled";
|
|
88676
|
+
}
|
|
88619
88677
|
function executionOutcome(state) {
|
|
88620
88678
|
switch (state.kind) {
|
|
88621
88679
|
case "pending":
|
|
@@ -88637,32 +88695,29 @@ var ExecutionReceipts = class {
|
|
|
88637
88695
|
#executions = /* @__PURE__ */ new Map();
|
|
88638
88696
|
#recoveredCommands = /* @__PURE__ */ new Set();
|
|
88639
88697
|
#table;
|
|
88698
|
+
#cancellations;
|
|
88640
88699
|
#closing = false;
|
|
88641
88700
|
#onCount;
|
|
88642
|
-
constructor(table, onCount = () => void 0) {
|
|
88701
|
+
constructor(table, cancellations, onCount = () => void 0) {
|
|
88643
88702
|
this.#onCount = onCount;
|
|
88644
88703
|
this.#table = table;
|
|
88704
|
+
this.#cancellations = cancellations;
|
|
88705
|
+
const retained = [];
|
|
88645
88706
|
for (const { commandId, started, outcome, updatedAt: _updatedAt, ...identity2 } of table.list()) {
|
|
88646
|
-
const
|
|
88707
|
+
const pending = { kind: started ? "started" : "pending" };
|
|
88708
|
+
const state = outcome === null ? pending : settledExecution(pending, outcome);
|
|
88647
88709
|
this.#executions.set(commandId, {
|
|
88648
88710
|
...identity2,
|
|
88649
|
-
state
|
|
88711
|
+
state
|
|
88650
88712
|
});
|
|
88713
|
+
if (cancelledBeforeStart(state)) {
|
|
88714
|
+
retained.push({ commandId, sessionId: identity2.sessionId });
|
|
88715
|
+
}
|
|
88651
88716
|
this.#recoveredCommands.add(commandId);
|
|
88652
88717
|
}
|
|
88718
|
+
cancellations.retain(retained);
|
|
88653
88719
|
}
|
|
88654
|
-
#
|
|
88655
|
-
const { state, ...identity2 } = receipt;
|
|
88656
|
-
const evicted = this.#closing ? [] : this.#table.save(
|
|
88657
|
-
{
|
|
88658
|
-
...identity2,
|
|
88659
|
-
commandId,
|
|
88660
|
-
started: executionStarted(state),
|
|
88661
|
-
outcome: durableOutcome,
|
|
88662
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
88663
|
-
},
|
|
88664
|
-
MAX_TERMINAL_RECEIPTS
|
|
88665
|
-
);
|
|
88720
|
+
#remember = (commandId, receipt, evicted) => {
|
|
88666
88721
|
this.#executions.set(commandId, receipt);
|
|
88667
88722
|
for (const evictedCommandId of evicted) {
|
|
88668
88723
|
this.#executions.delete(evictedCommandId);
|
|
@@ -88676,6 +88731,24 @@ var ExecutionReceipts = class {
|
|
|
88676
88731
|
}
|
|
88677
88732
|
this.#onCount(activeCount);
|
|
88678
88733
|
};
|
|
88734
|
+
#save = (commandId, receipt, durableOutcome = executionOutcome(receipt.state)) => {
|
|
88735
|
+
const { state, ...identity2 } = receipt;
|
|
88736
|
+
if (!this.#closing && cancelledBeforeStart(state)) {
|
|
88737
|
+
this.#cancellations.retain([{ commandId, sessionId: receipt.sessionId }]);
|
|
88738
|
+
this.#remember(commandId, receipt, []);
|
|
88739
|
+
}
|
|
88740
|
+
const evicted = this.#closing ? [] : this.#table.save(
|
|
88741
|
+
{
|
|
88742
|
+
...identity2,
|
|
88743
|
+
commandId,
|
|
88744
|
+
started: executionStarted(state),
|
|
88745
|
+
outcome: durableOutcome,
|
|
88746
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
88747
|
+
},
|
|
88748
|
+
MAX_TERMINAL_RECEIPTS
|
|
88749
|
+
);
|
|
88750
|
+
this.#remember(commandId, receipt, evicted);
|
|
88751
|
+
};
|
|
88679
88752
|
#nextAdmissionOrder = () => {
|
|
88680
88753
|
let latest = 0;
|
|
88681
88754
|
for (const receipt of this.#executions.values()) {
|
|
@@ -88695,7 +88768,7 @@ var ExecutionReceipts = class {
|
|
|
88695
88768
|
delivery = (commandId, sessionId) => {
|
|
88696
88769
|
const receipt = this.#executions.get(commandId);
|
|
88697
88770
|
if (receipt === void 0) {
|
|
88698
|
-
return this.#table.identity(commandId)?.sessionId === sessionId ? { state: "expired" } : { state: "unknown" };
|
|
88771
|
+
return this.#table.identity(commandId)?.sessionId === sessionId || this.#cancellations.read(commandId)?.sessionId === sessionId ? { state: "expired" } : { state: "unknown" };
|
|
88699
88772
|
}
|
|
88700
88773
|
if (receipt.sessionId !== sessionId) {
|
|
88701
88774
|
return { state: "unknown" };
|
|
@@ -88769,6 +88842,18 @@ var ExecutionReceipts = class {
|
|
|
88769
88842
|
payload: { kind: "prompt.completed", commandId, stopReason: "cancelled" }
|
|
88770
88843
|
} : void 0;
|
|
88771
88844
|
}
|
|
88845
|
+
const cancellation = this.#cancellations.read(commandId);
|
|
88846
|
+
if (cancellation !== void 0) {
|
|
88847
|
+
return cancellation.sessionId === sessionId ? {
|
|
88848
|
+
type: "lifecycle-metadata",
|
|
88849
|
+
payload: {
|
|
88850
|
+
kind: "prompt.completed",
|
|
88851
|
+
commandId,
|
|
88852
|
+
stopReason: "cancelled",
|
|
88853
|
+
execution: "not-started"
|
|
88854
|
+
}
|
|
88855
|
+
} : void 0;
|
|
88856
|
+
}
|
|
88772
88857
|
const outcome = {
|
|
88773
88858
|
type: "lifecycle-metadata",
|
|
88774
88859
|
payload: { kind: "prompt.completed", commandId, stopReason: "cancelled", execution: "not-started" }
|
|
@@ -88828,7 +88913,16 @@ var ExecutionReceipts = class {
|
|
|
88828
88913
|
const recovered = [];
|
|
88829
88914
|
for (const [commandId, receipt] of [...this.#executions]) {
|
|
88830
88915
|
const outcome = executionOutcome(receipt.state);
|
|
88831
|
-
const
|
|
88916
|
+
const restoreCancellation = !this.hasStarted(commandId, receipt.sessionId) && !cancelledBeforeStart(receipt.state) && this.#cancellations.read(commandId)?.sessionId === receipt.sessionId;
|
|
88917
|
+
const event = restoreCancellation ? {
|
|
88918
|
+
type: "lifecycle-metadata",
|
|
88919
|
+
payload: {
|
|
88920
|
+
kind: "prompt.completed",
|
|
88921
|
+
commandId,
|
|
88922
|
+
stopReason: "cancelled",
|
|
88923
|
+
execution: "not-started"
|
|
88924
|
+
}
|
|
88925
|
+
} : outcome === null ? {
|
|
88832
88926
|
type: "lifecycle-metadata",
|
|
88833
88927
|
payload: executionStarted(receipt.state) ? {
|
|
88834
88928
|
kind: "prompt.failed",
|
|
@@ -88846,9 +88940,9 @@ var ExecutionReceipts = class {
|
|
|
88846
88940
|
if (event === null) {
|
|
88847
88941
|
continue;
|
|
88848
88942
|
}
|
|
88849
|
-
const recordedAt = outcome === null ? (/* @__PURE__ */ new Date()).toISOString() : external_exports.object({ recordedAt: external_exports.string() }).parse(JSON.parse(outcome)).recordedAt;
|
|
88943
|
+
const recordedAt = restoreCancellation || outcome === null ? (/* @__PURE__ */ new Date()).toISOString() : external_exports.object({ recordedAt: external_exports.string() }).parse(JSON.parse(outcome)).recordedAt;
|
|
88850
88944
|
recovered.push({ sessionId: receipt.sessionId, event, recordedAt });
|
|
88851
|
-
if (outcome === null) {
|
|
88945
|
+
if (restoreCancellation || outcome === null) {
|
|
88852
88946
|
this.#save(commandId, {
|
|
88853
88947
|
...receipt,
|
|
88854
88948
|
state: settledExecution(receipt.state, JSON.stringify({ ...event, recordedAt }))
|
|
@@ -88882,6 +88976,9 @@ var ExecutionReceipts = class {
|
|
|
88882
88976
|
if (identity2 !== void 0) {
|
|
88883
88977
|
return identity2.sessionId === sessionId && identity2.commandHash === commandHash ? { kind: "expired" } : { kind: "conflict" };
|
|
88884
88978
|
}
|
|
88979
|
+
if (this.#cancellations.read(commandId) !== void 0) {
|
|
88980
|
+
return { kind: "conflict" };
|
|
88981
|
+
}
|
|
88885
88982
|
const attemptId = randomUUID15();
|
|
88886
88983
|
this.#save(commandId, {
|
|
88887
88984
|
admissionOrder: this.#nextAdmissionOrder(),
|
|
@@ -88904,6 +89001,7 @@ var ExecutionReceipts = class {
|
|
|
88904
89001
|
close = () => {
|
|
88905
89002
|
this.#executions.clear();
|
|
88906
89003
|
this.#recoveredCommands.clear();
|
|
89004
|
+
this.#cancellations.close();
|
|
88907
89005
|
};
|
|
88908
89006
|
};
|
|
88909
89007
|
|
|
@@ -89499,13 +89597,20 @@ function buildSessionLayer(options) {
|
|
|
89499
89597
|
const sessionDatabase = openAcpSessionDatabase(databases.sessions);
|
|
89500
89598
|
let events;
|
|
89501
89599
|
let operations;
|
|
89600
|
+
let cancellations;
|
|
89502
89601
|
try {
|
|
89503
|
-
|
|
89602
|
+
cancellations = new CommandCancellationTable(openCommandCancellationDatabase(databases.cancellations));
|
|
89603
|
+
operations = new ExecutionReceipts(
|
|
89604
|
+
new ExecutionReceiptTable(sessionDatabase),
|
|
89605
|
+
cancellations,
|
|
89606
|
+
options.onExecutionCountChange
|
|
89607
|
+
);
|
|
89504
89608
|
events = new CachedSessionEventStore(
|
|
89505
89609
|
new SessionEventCacheTable(openSessionEventCacheDatabase(databases.events)),
|
|
89506
89610
|
new SqliteSessionLiveEventPosition(new LiveEventPositionTable(sessionDatabase))
|
|
89507
89611
|
);
|
|
89508
89612
|
} catch (error62) {
|
|
89613
|
+
cancellations?.close();
|
|
89509
89614
|
sessionDatabase.close();
|
|
89510
89615
|
throw error62;
|
|
89511
89616
|
}
|
|
@@ -90171,7 +90276,7 @@ var RelayConnectionDiagnostics = class {
|
|
|
90171
90276
|
this.#relayOrigin = relayUrl.origin;
|
|
90172
90277
|
this.#route = describeEnvironmentProxyRoute(relayUrl);
|
|
90173
90278
|
}
|
|
90174
|
-
snapshot = () => this.#localLog.snapshot();
|
|
90279
|
+
snapshot = (current = []) => this.#localLog.snapshot(current);
|
|
90175
90280
|
catalogFailed = (failure2) => {
|
|
90176
90281
|
const details = { ...this.#route, relayOrigin: this.#relayOrigin };
|
|
90177
90282
|
addFailureDetails(details, failure2);
|
|
@@ -92065,10 +92170,79 @@ var sessionPromptCommand = {
|
|
|
92065
92170
|
}
|
|
92066
92171
|
};
|
|
92067
92172
|
|
|
92173
|
+
// src/engine/runtime/observability/environment-diagnostics.ts
|
|
92174
|
+
import { release } from "node:os";
|
|
92175
|
+
function version2(value) {
|
|
92176
|
+
return /(?:^|[\s(v])(\d{1,6}\.\d{1,6}\.\d{1,6}(?:-(?:alpha|beta|rc|dev|preview)(?:[.\d-]{0,24}))?(?:\+[a-f0-9]{1,16})?)(?=$|[\s)])/u.exec(
|
|
92177
|
+
value.slice(0, 128)
|
|
92178
|
+
)?.[1] ?? "unavailable";
|
|
92179
|
+
}
|
|
92180
|
+
function executableLocation(agent) {
|
|
92181
|
+
const path7 = agent.agentIdentity.realPath.replaceAll("\\", "/");
|
|
92182
|
+
if (/\/(?:ChatGPT|Codex)\.app\//u.test(path7)) {
|
|
92183
|
+
return "desktop_bundle";
|
|
92184
|
+
}
|
|
92185
|
+
if (path7.includes("/node_modules/")) {
|
|
92186
|
+
return "node_package";
|
|
92187
|
+
}
|
|
92188
|
+
if (path7.includes("/Cellar/") || path7.includes("/homebrew/")) {
|
|
92189
|
+
return "homebrew";
|
|
92190
|
+
}
|
|
92191
|
+
if (path7.startsWith("/usr/bin/") || path7.startsWith("/bin/")) {
|
|
92192
|
+
return "system";
|
|
92193
|
+
}
|
|
92194
|
+
return "other";
|
|
92195
|
+
}
|
|
92196
|
+
function overrideVariable(agentId) {
|
|
92197
|
+
switch (agentId) {
|
|
92198
|
+
case "codex":
|
|
92199
|
+
return "MOBIUS_CODEX_PATH";
|
|
92200
|
+
case "claude":
|
|
92201
|
+
return "MOBIUS_CLAUDE_PATH";
|
|
92202
|
+
case "pi":
|
|
92203
|
+
return "MOBIUS_PI_PATH";
|
|
92204
|
+
case "opencode":
|
|
92205
|
+
return "MOBIUS_OPENCODE_PATH";
|
|
92206
|
+
default:
|
|
92207
|
+
return null;
|
|
92208
|
+
}
|
|
92209
|
+
}
|
|
92210
|
+
function runtimeEnvironmentDiagnostics(config2) {
|
|
92211
|
+
const agents = config2.catalog.read().agents;
|
|
92212
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
92213
|
+
return [
|
|
92214
|
+
{
|
|
92215
|
+
event: "runtime_environment",
|
|
92216
|
+
timestamp,
|
|
92217
|
+
platform: process.platform,
|
|
92218
|
+
architecture: process.arch,
|
|
92219
|
+
osRelease: /^(\d+(?:\.\d+){1,3})/u.exec(release())?.[1] ?? "unavailable",
|
|
92220
|
+
nodeVersion: process.versions.node,
|
|
92221
|
+
uptimeSeconds: Math.floor(process.uptime()).toString(),
|
|
92222
|
+
agentCount: agents.length.toString(),
|
|
92223
|
+
omittedAgents: Math.max(0, agents.length - 16).toString()
|
|
92224
|
+
},
|
|
92225
|
+
...agents.slice(0, 16).map((agent) => {
|
|
92226
|
+
const override = overrideVariable(agent.id);
|
|
92227
|
+
return {
|
|
92228
|
+
event: "agent_inventory",
|
|
92229
|
+
timestamp,
|
|
92230
|
+
agentId: override === null ? "custom" : agent.id,
|
|
92231
|
+
agentVersion: version2(agent.agentVersion),
|
|
92232
|
+
adapterVersion: version2(agent.adapterVersion),
|
|
92233
|
+
versionSource: "runtime_catalog",
|
|
92234
|
+
executableLocation: executableLocation(agent),
|
|
92235
|
+
executableOverride: override === null ? "unknown" : agent.environment[override] === void 0 ? "unset" : "set",
|
|
92236
|
+
codexHome: agent.id !== "codex" ? "not_applicable" : agent.environment["CODEX_HOME"] === void 0 ? "default" : "custom"
|
|
92237
|
+
};
|
|
92238
|
+
})
|
|
92239
|
+
];
|
|
92240
|
+
}
|
|
92241
|
+
|
|
92068
92242
|
// src/engine/runtime/command/registry/runtime.ts
|
|
92069
92243
|
var runtimeDiagnosticsCommand = {
|
|
92070
92244
|
kind: "runtime.diagnostics.read",
|
|
92071
|
-
handle: ({ diagnostics, socket }, message) => {
|
|
92245
|
+
handle: ({ config: config2, diagnostics, socket }, message) => {
|
|
92072
92246
|
if (message.kind !== "runtime.diagnostics.read") {
|
|
92073
92247
|
throw new Error("Command kind mismatch");
|
|
92074
92248
|
}
|
|
@@ -92077,7 +92251,7 @@ var runtimeDiagnosticsCommand = {
|
|
|
92077
92251
|
kind: "runtime.diagnostics.result",
|
|
92078
92252
|
requestId: message.requestId,
|
|
92079
92253
|
version: package_default.version,
|
|
92080
|
-
...diagnostics.snapshot()
|
|
92254
|
+
...diagnostics.snapshot(runtimeEnvironmentDiagnostics(config2))
|
|
92081
92255
|
});
|
|
92082
92256
|
} catch {
|
|
92083
92257
|
send(socket, {
|
|
@@ -92616,7 +92790,7 @@ function connectRelay(url2, signal, transportFailed = () => void 0) {
|
|
|
92616
92790
|
headers
|
|
92617
92791
|
});
|
|
92618
92792
|
socket.binaryType = "arraybuffer";
|
|
92619
|
-
const
|
|
92793
|
+
const release2 = (reason) => {
|
|
92620
92794
|
if (released) {
|
|
92621
92795
|
return;
|
|
92622
92796
|
}
|
|
@@ -92640,7 +92814,7 @@ function connectRelay(url2, signal, transportFailed = () => void 0) {
|
|
|
92640
92814
|
finished = true;
|
|
92641
92815
|
cleanup();
|
|
92642
92816
|
socket.close();
|
|
92643
|
-
|
|
92817
|
+
release2(error62);
|
|
92644
92818
|
reject2(error62);
|
|
92645
92819
|
};
|
|
92646
92820
|
const onAbort = () => {
|
|
@@ -92684,7 +92858,7 @@ function connectRelay(url2, signal, transportFailed = () => void 0) {
|
|
|
92684
92858
|
}
|
|
92685
92859
|
finished = true;
|
|
92686
92860
|
cleanup();
|
|
92687
|
-
resolve19({ release, socket });
|
|
92861
|
+
resolve19({ release: release2, socket });
|
|
92688
92862
|
};
|
|
92689
92863
|
function onTimeout() {
|
|
92690
92864
|
fail(
|
|
@@ -93655,4 +93829,4 @@ export {
|
|
|
93655
93829
|
* MIT Licensed
|
|
93656
93830
|
*)
|
|
93657
93831
|
*/
|
|
93658
|
-
//# sourceMappingURL=chunk-
|
|
93832
|
+
//# sourceMappingURL=chunk-5CY7MW6G.js.map
|