@moxt-ai/mobius 0.0.181 → 0.0.182
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 +179 -70
- package/dist/cli.js.map +3 -3
- package/dist/daemon-command-handler.d.ts.map +1 -1
- package/dist/daemon-command-handler.js +7 -2
- package/dist/daemon-command-handler.js.map +1 -1
- package/dist/daemon-session-commands.d.ts +3 -1
- package/dist/daemon-session-commands.d.ts.map +1 -1
- package/dist/daemon-session-commands.js +98 -55
- package/dist/daemon-session-commands.js.map +1 -1
- package/dist/external-content/acp-content-externalizer.d.ts.map +1 -1
- package/dist/external-content/acp-content-externalizer.js +24 -3
- package/dist/external-content/acp-content-externalizer.js.map +1 -1
- package/dist/index.js +178 -69
- package/dist/index.js.map +3 -3
- package/dist/runtime.js +178 -69
- package/dist/runtime.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19791,6 +19791,8 @@ var SESSION_LIST_KIND = "session.list";
|
|
|
19791
19791
|
var SESSION_LISTED_KIND = "session.listed";
|
|
19792
19792
|
var SESSION_QUERY_KIND = "session.query";
|
|
19793
19793
|
var SESSION_QUERIED_KIND = "session.queried";
|
|
19794
|
+
var SESSION_RESTORE_KIND = "session.restore";
|
|
19795
|
+
var SESSION_RESTORED_KIND = "session.restored";
|
|
19794
19796
|
var SESSION_STATUS_CHANGED_KIND = "session.status.changed";
|
|
19795
19797
|
var SESSION_CONFIGURE_KIND = "session.configure";
|
|
19796
19798
|
var SESSION_CONFIG_UPDATED_KIND = "session.config.updated";
|
|
@@ -19871,6 +19873,11 @@ var sessionsQueriedEventSchema = external_exports.object({
|
|
|
19871
19873
|
kind: external_exports.literal(SESSION_QUERIED_KIND),
|
|
19872
19874
|
requestId: identifierStringSchema
|
|
19873
19875
|
}).readonly();
|
|
19876
|
+
var sessionRestoreCommandSchema = external_exports.object({
|
|
19877
|
+
kind: external_exports.literal(SESSION_RESTORE_KIND),
|
|
19878
|
+
requestId: identifierStringSchema,
|
|
19879
|
+
sessionId: identifierStringSchema
|
|
19880
|
+
}).readonly();
|
|
19874
19881
|
var fileReadCommandSchema = external_exports.object({
|
|
19875
19882
|
kind: external_exports.literal(FILE_READ_KIND),
|
|
19876
19883
|
maxBytes: external_exports.number().int().positive().max(128 * 1024 * 1024),
|
|
@@ -20185,6 +20192,12 @@ var sessionReadyEventSchema = external_exports.object({
|
|
|
20185
20192
|
runtimeTimings: runtimeTimingsSchema.optional(),
|
|
20186
20193
|
sessionId: identifierStringSchema
|
|
20187
20194
|
}).readonly();
|
|
20195
|
+
var sessionRestoredEventSchema = external_exports.object({
|
|
20196
|
+
entry: sessionMetadataSchema,
|
|
20197
|
+
kind: external_exports.literal(SESSION_RESTORED_KIND),
|
|
20198
|
+
ready: sessionReadyEventSchema,
|
|
20199
|
+
requestId: identifierStringSchema
|
|
20200
|
+
}).readonly();
|
|
20188
20201
|
var sessionConfigureCommandSchema = external_exports.object({
|
|
20189
20202
|
...sessionIdentityFields,
|
|
20190
20203
|
booleanValue: external_exports.boolean(),
|
|
@@ -20400,6 +20413,10 @@ var decodeSessionQueryCommand = (encoded) => decode3(encoded, sessionQueryComman
|
|
|
20400
20413
|
var encodeSessionQueryCommand = (message) => encode3(message, sessionQueryCommandSchema);
|
|
20401
20414
|
var decodeSessionsQueriedEvent = (encoded) => decode3(encoded, sessionsQueriedEventSchema);
|
|
20402
20415
|
var encodeSessionsQueriedEvent = (message) => encode3(message, sessionsQueriedEventSchema);
|
|
20416
|
+
var decodeSessionRestoreCommand = (encoded) => decode3(encoded, sessionRestoreCommandSchema);
|
|
20417
|
+
var encodeSessionRestoreCommand = (message) => encode3(message, sessionRestoreCommandSchema);
|
|
20418
|
+
var decodeSessionRestoredEvent = (encoded) => decode3(encoded, sessionRestoredEventSchema);
|
|
20419
|
+
var encodeSessionRestoredEvent = (message) => encode3(message, sessionRestoredEventSchema);
|
|
20403
20420
|
var decodeSessionStatusChangedEvent = (encoded) => decode3(encoded, sessionStatusChangedEventSchema);
|
|
20404
20421
|
var encodeSessionStatusChangedEvent = (message) => encode3(message, sessionStatusChangedEventSchema);
|
|
20405
20422
|
var decodeSessionPrepareCommand = (encoded) => decode3(encoded, sessionPrepareCommandSchema);
|
|
@@ -21482,6 +21499,11 @@ var serviceToDaemonSignatures = {
|
|
|
21482
21499
|
encodeSessionQueryCommand,
|
|
21483
21500
|
decodeSessionQueryCommand
|
|
21484
21501
|
),
|
|
21502
|
+
[SESSION_RESTORE_KIND]: defineMessageSignature(
|
|
21503
|
+
SESSION_RESTORE_KIND,
|
|
21504
|
+
encodeSessionRestoreCommand,
|
|
21505
|
+
decodeSessionRestoreCommand
|
|
21506
|
+
),
|
|
21485
21507
|
[NATIVE_SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
21486
21508
|
NATIVE_SESSION_CANCEL_KIND,
|
|
21487
21509
|
encodeNativeSessionCancel,
|
|
@@ -21613,6 +21635,11 @@ var daemonToServiceSignatures = {
|
|
|
21613
21635
|
encodeSessionsQueriedEvent,
|
|
21614
21636
|
decodeSessionsQueriedEvent
|
|
21615
21637
|
),
|
|
21638
|
+
[SESSION_RESTORED_KIND]: defineMessageSignature(
|
|
21639
|
+
SESSION_RESTORED_KIND,
|
|
21640
|
+
encodeSessionRestoredEvent,
|
|
21641
|
+
decodeSessionRestoredEvent
|
|
21642
|
+
),
|
|
21616
21643
|
[SESSION_STATUS_CHANGED_KIND]: defineMessageSignature(
|
|
21617
21644
|
SESSION_STATUS_CHANGED_KIND,
|
|
21618
21645
|
encodeSessionStatusChangedEvent,
|
|
@@ -31492,6 +31519,17 @@ var embeddedImageSchema = external_exports.looseObject({
|
|
|
31492
31519
|
data: external_exports.string(),
|
|
31493
31520
|
mimeType: external_exports.string()
|
|
31494
31521
|
});
|
|
31522
|
+
var toolImageSchema = external_exports.union([
|
|
31523
|
+
embeddedImageSchema,
|
|
31524
|
+
external_exports.object({
|
|
31525
|
+
type: external_exports.literal("image"),
|
|
31526
|
+
source: external_exports.object({ type: external_exports.literal("base64"), data: external_exports.string(), media_type: external_exports.string() })
|
|
31527
|
+
}).transform(({ source }) => ({ type: "image", data: source.data, mimeType: source.media_type })),
|
|
31528
|
+
external_exports.object({
|
|
31529
|
+
type: external_exports.literal("image"),
|
|
31530
|
+
file: external_exports.object({ base64: external_exports.string(), type: external_exports.string() })
|
|
31531
|
+
}).transform(({ file: file2 }) => ({ type: "image", data: file2.base64, mimeType: file2.type }))
|
|
31532
|
+
]);
|
|
31495
31533
|
function isRecord6(value) {
|
|
31496
31534
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31497
31535
|
}
|
|
@@ -31611,7 +31649,7 @@ var AcpContentExternalizer = class {
|
|
|
31611
31649
|
if (!isRecord6(value)) {
|
|
31612
31650
|
return value;
|
|
31613
31651
|
}
|
|
31614
|
-
const image =
|
|
31652
|
+
const image = toolImageSchema.safeParse(value);
|
|
31615
31653
|
if (image.success && image.data.data.length > 0) {
|
|
31616
31654
|
const prepared = await this.#content(sessionId, image.data, signal);
|
|
31617
31655
|
if (isRecord6(prepared.event) && typeof prepared.event["imageKey"] === "string") {
|
|
@@ -31630,6 +31668,7 @@ var AcpContentExternalizer = class {
|
|
|
31630
31668
|
async #toolUpdate(sessionId, update, signal) {
|
|
31631
31669
|
const images = /* @__PURE__ */ new Map();
|
|
31632
31670
|
const rawOutput = update.rawOutput === void 0 ? void 0 : await this.#rawOutput(sessionId, update.rawOutput, images, signal);
|
|
31671
|
+
const metadata = update._meta === void 0 || update._meta === null ? update._meta : external_exports.record(external_exports.string(), external_exports.unknown()).parse(await this.#rawOutput(sessionId, update._meta, images, signal));
|
|
31633
31672
|
const originalJson = images.size === 0 ? void 0 : JSON.stringify(update.rawOutput);
|
|
31634
31673
|
const rewrittenJson = images.size === 0 ? void 0 : JSON.stringify(rawOutput);
|
|
31635
31674
|
const agentContent = [];
|
|
@@ -31653,10 +31692,11 @@ var AcpContentExternalizer = class {
|
|
|
31653
31692
|
eventContent.push({ type: "content", content: prepared.event });
|
|
31654
31693
|
}
|
|
31655
31694
|
const output2 = update.rawOutput === void 0 ? {} : { rawOutput };
|
|
31695
|
+
const meta3 = metadata === void 0 ? {} : { _meta: metadata };
|
|
31656
31696
|
const hasContent = update.content !== void 0 && update.content !== null || agentContent.length > 0;
|
|
31657
31697
|
return {
|
|
31658
|
-
agent: { ...update, ...output2, ...hasContent ? { content: agentContent } : {} },
|
|
31659
|
-
event: { ...update, ...output2, ...hasContent ? { content: eventContent } : {} }
|
|
31698
|
+
agent: { ...update, ...meta3, ...output2, ...hasContent ? { content: agentContent } : {} },
|
|
31699
|
+
event: { ...update, ...meta3, ...output2, ...hasContent ? { content: eventContent } : {} }
|
|
31660
31700
|
};
|
|
31661
31701
|
}
|
|
31662
31702
|
update = async (sessionId, update, signal) => {
|
|
@@ -42135,6 +42175,72 @@ async function executePrompt({
|
|
|
42135
42175
|
}
|
|
42136
42176
|
|
|
42137
42177
|
// src/daemon-session-commands.ts
|
|
42178
|
+
async function prepareSession(command, config2, directories, audit, sessions, metrics, signal) {
|
|
42179
|
+
return await metrics.measure("prepare-total", async () => {
|
|
42180
|
+
const resolved = await metrics.measure(
|
|
42181
|
+
"workspace-resolve",
|
|
42182
|
+
async () => await resolveSessionDirectories(
|
|
42183
|
+
directories,
|
|
42184
|
+
config2.bindingId,
|
|
42185
|
+
command.directoryId,
|
|
42186
|
+
command.additionalDirectoryIds,
|
|
42187
|
+
signal
|
|
42188
|
+
)
|
|
42189
|
+
);
|
|
42190
|
+
const agent = config2.catalog.find(command.agentId);
|
|
42191
|
+
const preparation = {
|
|
42192
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
42193
|
+
agent,
|
|
42194
|
+
cwd: resolved.cwd,
|
|
42195
|
+
sessionId: command.sessionId,
|
|
42196
|
+
signal
|
|
42197
|
+
};
|
|
42198
|
+
const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
|
|
42199
|
+
const configuration = command.configuration;
|
|
42200
|
+
const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
|
|
42201
|
+
"configuration",
|
|
42202
|
+
async () => await sessions.configureSession({
|
|
42203
|
+
...preparation,
|
|
42204
|
+
booleanValue: configuration.booleanValue,
|
|
42205
|
+
configId: configuration.configId,
|
|
42206
|
+
requestId: command.requestId,
|
|
42207
|
+
value: configuration.value,
|
|
42208
|
+
valueType: configuration.valueType
|
|
42209
|
+
})
|
|
42210
|
+
);
|
|
42211
|
+
const listing = await metrics.measure(
|
|
42212
|
+
"workspace-list",
|
|
42213
|
+
async () => await directories.list(config2.bindingId, command.directoryId, signal)
|
|
42214
|
+
);
|
|
42215
|
+
audit.record({
|
|
42216
|
+
commandId: command.requestId,
|
|
42217
|
+
event: "session_prepared",
|
|
42218
|
+
sessionId: command.sessionId
|
|
42219
|
+
});
|
|
42220
|
+
if (command.configuration !== void 0) {
|
|
42221
|
+
audit.record({
|
|
42222
|
+
commandId: command.requestId,
|
|
42223
|
+
event: "session_configured",
|
|
42224
|
+
sessionId: command.sessionId
|
|
42225
|
+
});
|
|
42226
|
+
}
|
|
42227
|
+
return {
|
|
42228
|
+
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
42229
|
+
agentId: command.agentId,
|
|
42230
|
+
agentName: prepared.agentName,
|
|
42231
|
+
agentVersion: prepared.agentVersion,
|
|
42232
|
+
capabilities: prepared.capabilities,
|
|
42233
|
+
commands: prepared.commands,
|
|
42234
|
+
configOptions,
|
|
42235
|
+
directoryId: command.directoryId,
|
|
42236
|
+
directoryLabel: listing.directoryLabel,
|
|
42237
|
+
kind: "session.ready",
|
|
42238
|
+
requestId: command.requestId,
|
|
42239
|
+
restored: prepared.restored,
|
|
42240
|
+
sessionId: command.sessionId
|
|
42241
|
+
};
|
|
42242
|
+
});
|
|
42243
|
+
}
|
|
42138
42244
|
async function executeWorkspaceList(socket, command, directories, audit, signal) {
|
|
42139
42245
|
try {
|
|
42140
42246
|
const listing = await directories.list(command.bindingId, command.directoryId, signal);
|
|
@@ -42159,72 +42265,7 @@ async function executeWorkspaceList(socket, command, directories, audit, signal)
|
|
|
42159
42265
|
async function executeSessionPrepare(socket, command, config2, directories, audit, sessions, diagnostics, signal) {
|
|
42160
42266
|
const metrics = new AccumulatingOperationMetrics();
|
|
42161
42267
|
try {
|
|
42162
|
-
const readyEvent = await
|
|
42163
|
-
const resolved = await metrics.measure(
|
|
42164
|
-
"workspace-resolve",
|
|
42165
|
-
async () => await resolveSessionDirectories(
|
|
42166
|
-
directories,
|
|
42167
|
-
config2.bindingId,
|
|
42168
|
-
command.directoryId,
|
|
42169
|
-
command.additionalDirectoryIds,
|
|
42170
|
-
signal
|
|
42171
|
-
)
|
|
42172
|
-
);
|
|
42173
|
-
const agent = config2.catalog.find(command.agentId);
|
|
42174
|
-
const preparation = {
|
|
42175
|
-
additionalDirectories: resolved.additionalDirectories,
|
|
42176
|
-
agent,
|
|
42177
|
-
cwd: resolved.cwd,
|
|
42178
|
-
sessionId: command.sessionId,
|
|
42179
|
-
signal
|
|
42180
|
-
};
|
|
42181
|
-
const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
|
|
42182
|
-
const configuration = command.configuration;
|
|
42183
|
-
const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
|
|
42184
|
-
"configuration",
|
|
42185
|
-
async () => await sessions.configureSession({
|
|
42186
|
-
...preparation,
|
|
42187
|
-
booleanValue: configuration.booleanValue,
|
|
42188
|
-
configId: configuration.configId,
|
|
42189
|
-
requestId: command.requestId,
|
|
42190
|
-
value: configuration.value,
|
|
42191
|
-
valueType: configuration.valueType
|
|
42192
|
-
})
|
|
42193
|
-
);
|
|
42194
|
-
const listing = await metrics.measure(
|
|
42195
|
-
"workspace-list",
|
|
42196
|
-
async () => await directories.list(config2.bindingId, command.directoryId, signal)
|
|
42197
|
-
);
|
|
42198
|
-
audit.record({
|
|
42199
|
-
commandId: command.requestId,
|
|
42200
|
-
event: "session_prepared",
|
|
42201
|
-
sessionId: command.sessionId
|
|
42202
|
-
});
|
|
42203
|
-
if (command.configuration !== void 0) {
|
|
42204
|
-
audit.record({
|
|
42205
|
-
commandId: command.requestId,
|
|
42206
|
-
event: "session_configured",
|
|
42207
|
-
sessionId: command.sessionId
|
|
42208
|
-
});
|
|
42209
|
-
}
|
|
42210
|
-
const event = {
|
|
42211
|
-
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
42212
|
-
agentId: command.agentId,
|
|
42213
|
-
agentName: prepared.agentName,
|
|
42214
|
-
agentVersion: prepared.agentVersion,
|
|
42215
|
-
capabilities: prepared.capabilities,
|
|
42216
|
-
commands: prepared.commands,
|
|
42217
|
-
configOptions,
|
|
42218
|
-
directoryId: command.directoryId,
|
|
42219
|
-
directoryLabel: listing.directoryLabel,
|
|
42220
|
-
kind: "session.ready",
|
|
42221
|
-
requestId: command.requestId,
|
|
42222
|
-
restored: prepared.restored,
|
|
42223
|
-
sessionId: command.sessionId,
|
|
42224
|
-
runtimeTimings: metrics.snapshot()
|
|
42225
|
-
};
|
|
42226
|
-
return event;
|
|
42227
|
-
});
|
|
42268
|
+
const readyEvent = await prepareSession(command, config2, directories, audit, sessions, metrics, signal);
|
|
42228
42269
|
send(socket, {
|
|
42229
42270
|
...readyEvent,
|
|
42230
42271
|
runtimeTimings: metrics.snapshot()
|
|
@@ -42252,6 +42293,59 @@ async function executeSessionPrepare(socket, command, config2, directories, audi
|
|
|
42252
42293
|
reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
|
|
42253
42294
|
}
|
|
42254
42295
|
}
|
|
42296
|
+
async function executeSessionRestore(socket, command, config2, directories, audit, sessions, nativeSessions, diagnostics, signal) {
|
|
42297
|
+
const metrics = new AccumulatingOperationMetrics();
|
|
42298
|
+
try {
|
|
42299
|
+
const entry = await metrics.measure("session-lookup", async () => {
|
|
42300
|
+
const [found] = await nativeSessions.querySessions([command.sessionId], signal);
|
|
42301
|
+
if (found === void 0) {
|
|
42302
|
+
throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
|
|
42303
|
+
}
|
|
42304
|
+
return found;
|
|
42305
|
+
});
|
|
42306
|
+
const ready = await prepareSession(
|
|
42307
|
+
{
|
|
42308
|
+
additionalDirectoryIds: entry.additionalDirectories.map((directory) => directory.directoryId),
|
|
42309
|
+
agentId: entry.agentId,
|
|
42310
|
+
bindingId: config2.bindingId,
|
|
42311
|
+
directoryId: entry.directoryId,
|
|
42312
|
+
kind: "session.prepare",
|
|
42313
|
+
requestId: command.requestId,
|
|
42314
|
+
sessionId: command.sessionId,
|
|
42315
|
+
sessionState: "provisioned"
|
|
42316
|
+
},
|
|
42317
|
+
config2,
|
|
42318
|
+
directories,
|
|
42319
|
+
audit,
|
|
42320
|
+
sessions,
|
|
42321
|
+
metrics,
|
|
42322
|
+
signal
|
|
42323
|
+
);
|
|
42324
|
+
send(socket, {
|
|
42325
|
+
entry,
|
|
42326
|
+
kind: "session.restored",
|
|
42327
|
+
ready: { ...ready, runtimeTimings: metrics.snapshot() },
|
|
42328
|
+
requestId: command.requestId
|
|
42329
|
+
});
|
|
42330
|
+
} catch (error62) {
|
|
42331
|
+
diagnostics.daemonDiagnostic(
|
|
42332
|
+
"session_restore_failed",
|
|
42333
|
+
command.requestId,
|
|
42334
|
+
{
|
|
42335
|
+
code: operationErrorCode(error62),
|
|
42336
|
+
sessionId: command.sessionId
|
|
42337
|
+
},
|
|
42338
|
+
error62
|
|
42339
|
+
);
|
|
42340
|
+
audit.record({
|
|
42341
|
+
commandId: command.requestId,
|
|
42342
|
+
details: { code: operationErrorCode(error62) },
|
|
42343
|
+
event: "session_restore_failed",
|
|
42344
|
+
sessionId: command.sessionId
|
|
42345
|
+
});
|
|
42346
|
+
reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
|
|
42347
|
+
}
|
|
42348
|
+
}
|
|
42255
42349
|
async function executeSessionConfigure(socket, command, config2, directories, audit, sessions, signal) {
|
|
42256
42350
|
try {
|
|
42257
42351
|
const resolved = await resolveSessionDirectories(
|
|
@@ -42565,6 +42659,21 @@ function createDaemonCommandHandler({
|
|
|
42565
42659
|
});
|
|
42566
42660
|
return;
|
|
42567
42661
|
}
|
|
42662
|
+
if (kind === SESSION_RESTORE_KIND) {
|
|
42663
|
+
const command2 = message;
|
|
42664
|
+
void executeSessionRestore(
|
|
42665
|
+
socket,
|
|
42666
|
+
command2,
|
|
42667
|
+
config2,
|
|
42668
|
+
directories,
|
|
42669
|
+
audit,
|
|
42670
|
+
sessions,
|
|
42671
|
+
nativeSessions,
|
|
42672
|
+
diagnostics,
|
|
42673
|
+
signal
|
|
42674
|
+
);
|
|
42675
|
+
return;
|
|
42676
|
+
}
|
|
42568
42677
|
if (kind === SESSION_PERMISSION_RESPOND_KIND) {
|
|
42569
42678
|
const command2 = message;
|
|
42570
42679
|
void sessions.respondPermission(command2).then(() => {
|