@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/runtime.js
CHANGED
|
@@ -19765,6 +19765,8 @@ var SESSION_LIST_KIND = "session.list";
|
|
|
19765
19765
|
var SESSION_LISTED_KIND = "session.listed";
|
|
19766
19766
|
var SESSION_QUERY_KIND = "session.query";
|
|
19767
19767
|
var SESSION_QUERIED_KIND = "session.queried";
|
|
19768
|
+
var SESSION_RESTORE_KIND = "session.restore";
|
|
19769
|
+
var SESSION_RESTORED_KIND = "session.restored";
|
|
19768
19770
|
var SESSION_STATUS_CHANGED_KIND = "session.status.changed";
|
|
19769
19771
|
var SESSION_CONFIGURE_KIND = "session.configure";
|
|
19770
19772
|
var SESSION_CONFIG_UPDATED_KIND = "session.config.updated";
|
|
@@ -19845,6 +19847,11 @@ var sessionsQueriedEventSchema = external_exports.object({
|
|
|
19845
19847
|
kind: external_exports.literal(SESSION_QUERIED_KIND),
|
|
19846
19848
|
requestId: identifierStringSchema
|
|
19847
19849
|
}).readonly();
|
|
19850
|
+
var sessionRestoreCommandSchema = external_exports.object({
|
|
19851
|
+
kind: external_exports.literal(SESSION_RESTORE_KIND),
|
|
19852
|
+
requestId: identifierStringSchema,
|
|
19853
|
+
sessionId: identifierStringSchema
|
|
19854
|
+
}).readonly();
|
|
19848
19855
|
var fileReadCommandSchema = external_exports.object({
|
|
19849
19856
|
kind: external_exports.literal(FILE_READ_KIND),
|
|
19850
19857
|
maxBytes: external_exports.number().int().positive().max(128 * 1024 * 1024),
|
|
@@ -20159,6 +20166,12 @@ var sessionReadyEventSchema = external_exports.object({
|
|
|
20159
20166
|
runtimeTimings: runtimeTimingsSchema.optional(),
|
|
20160
20167
|
sessionId: identifierStringSchema
|
|
20161
20168
|
}).readonly();
|
|
20169
|
+
var sessionRestoredEventSchema = external_exports.object({
|
|
20170
|
+
entry: sessionMetadataSchema,
|
|
20171
|
+
kind: external_exports.literal(SESSION_RESTORED_KIND),
|
|
20172
|
+
ready: sessionReadyEventSchema,
|
|
20173
|
+
requestId: identifierStringSchema
|
|
20174
|
+
}).readonly();
|
|
20162
20175
|
var sessionConfigureCommandSchema = external_exports.object({
|
|
20163
20176
|
...sessionIdentityFields,
|
|
20164
20177
|
booleanValue: external_exports.boolean(),
|
|
@@ -20374,6 +20387,10 @@ var decodeSessionQueryCommand = (encoded) => decode3(encoded, sessionQueryComman
|
|
|
20374
20387
|
var encodeSessionQueryCommand = (message) => encode3(message, sessionQueryCommandSchema);
|
|
20375
20388
|
var decodeSessionsQueriedEvent = (encoded) => decode3(encoded, sessionsQueriedEventSchema);
|
|
20376
20389
|
var encodeSessionsQueriedEvent = (message) => encode3(message, sessionsQueriedEventSchema);
|
|
20390
|
+
var decodeSessionRestoreCommand = (encoded) => decode3(encoded, sessionRestoreCommandSchema);
|
|
20391
|
+
var encodeSessionRestoreCommand = (message) => encode3(message, sessionRestoreCommandSchema);
|
|
20392
|
+
var decodeSessionRestoredEvent = (encoded) => decode3(encoded, sessionRestoredEventSchema);
|
|
20393
|
+
var encodeSessionRestoredEvent = (message) => encode3(message, sessionRestoredEventSchema);
|
|
20377
20394
|
var decodeSessionStatusChangedEvent = (encoded) => decode3(encoded, sessionStatusChangedEventSchema);
|
|
20378
20395
|
var encodeSessionStatusChangedEvent = (message) => encode3(message, sessionStatusChangedEventSchema);
|
|
20379
20396
|
var decodeSessionPrepareCommand = (encoded) => decode3(encoded, sessionPrepareCommandSchema);
|
|
@@ -21456,6 +21473,11 @@ var serviceToDaemonSignatures = {
|
|
|
21456
21473
|
encodeSessionQueryCommand,
|
|
21457
21474
|
decodeSessionQueryCommand
|
|
21458
21475
|
),
|
|
21476
|
+
[SESSION_RESTORE_KIND]: defineMessageSignature(
|
|
21477
|
+
SESSION_RESTORE_KIND,
|
|
21478
|
+
encodeSessionRestoreCommand,
|
|
21479
|
+
decodeSessionRestoreCommand
|
|
21480
|
+
),
|
|
21459
21481
|
[NATIVE_SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
21460
21482
|
NATIVE_SESSION_CANCEL_KIND,
|
|
21461
21483
|
encodeNativeSessionCancel,
|
|
@@ -21587,6 +21609,11 @@ var daemonToServiceSignatures = {
|
|
|
21587
21609
|
encodeSessionsQueriedEvent,
|
|
21588
21610
|
decodeSessionsQueriedEvent
|
|
21589
21611
|
),
|
|
21612
|
+
[SESSION_RESTORED_KIND]: defineMessageSignature(
|
|
21613
|
+
SESSION_RESTORED_KIND,
|
|
21614
|
+
encodeSessionRestoredEvent,
|
|
21615
|
+
decodeSessionRestoredEvent
|
|
21616
|
+
),
|
|
21590
21617
|
[SESSION_STATUS_CHANGED_KIND]: defineMessageSignature(
|
|
21591
21618
|
SESSION_STATUS_CHANGED_KIND,
|
|
21592
21619
|
encodeSessionStatusChangedEvent,
|
|
@@ -35721,6 +35748,17 @@ var embeddedImageSchema = external_exports.looseObject({
|
|
|
35721
35748
|
data: external_exports.string(),
|
|
35722
35749
|
mimeType: external_exports.string()
|
|
35723
35750
|
});
|
|
35751
|
+
var toolImageSchema = external_exports.union([
|
|
35752
|
+
embeddedImageSchema,
|
|
35753
|
+
external_exports.object({
|
|
35754
|
+
type: external_exports.literal("image"),
|
|
35755
|
+
source: external_exports.object({ type: external_exports.literal("base64"), data: external_exports.string(), media_type: external_exports.string() })
|
|
35756
|
+
}).transform(({ source }) => ({ type: "image", data: source.data, mimeType: source.media_type })),
|
|
35757
|
+
external_exports.object({
|
|
35758
|
+
type: external_exports.literal("image"),
|
|
35759
|
+
file: external_exports.object({ base64: external_exports.string(), type: external_exports.string() })
|
|
35760
|
+
}).transform(({ file: file2 }) => ({ type: "image", data: file2.base64, mimeType: file2.type }))
|
|
35761
|
+
]);
|
|
35724
35762
|
function isRecord8(value) {
|
|
35725
35763
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
35726
35764
|
}
|
|
@@ -35840,7 +35878,7 @@ var AcpContentExternalizer = class {
|
|
|
35840
35878
|
if (!isRecord8(value)) {
|
|
35841
35879
|
return value;
|
|
35842
35880
|
}
|
|
35843
|
-
const image =
|
|
35881
|
+
const image = toolImageSchema.safeParse(value);
|
|
35844
35882
|
if (image.success && image.data.data.length > 0) {
|
|
35845
35883
|
const prepared = await this.#content(sessionId, image.data, signal);
|
|
35846
35884
|
if (isRecord8(prepared.event) && typeof prepared.event["imageKey"] === "string") {
|
|
@@ -35859,6 +35897,7 @@ var AcpContentExternalizer = class {
|
|
|
35859
35897
|
async #toolUpdate(sessionId, update, signal) {
|
|
35860
35898
|
const images = /* @__PURE__ */ new Map();
|
|
35861
35899
|
const rawOutput = update.rawOutput === void 0 ? void 0 : await this.#rawOutput(sessionId, update.rawOutput, images, signal);
|
|
35900
|
+
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));
|
|
35862
35901
|
const originalJson = images.size === 0 ? void 0 : JSON.stringify(update.rawOutput);
|
|
35863
35902
|
const rewrittenJson = images.size === 0 ? void 0 : JSON.stringify(rawOutput);
|
|
35864
35903
|
const agentContent = [];
|
|
@@ -35882,10 +35921,11 @@ var AcpContentExternalizer = class {
|
|
|
35882
35921
|
eventContent.push({ type: "content", content: prepared.event });
|
|
35883
35922
|
}
|
|
35884
35923
|
const output2 = update.rawOutput === void 0 ? {} : { rawOutput };
|
|
35924
|
+
const meta3 = metadata === void 0 ? {} : { _meta: metadata };
|
|
35885
35925
|
const hasContent = update.content !== void 0 && update.content !== null || agentContent.length > 0;
|
|
35886
35926
|
return {
|
|
35887
|
-
agent: { ...update, ...output2, ...hasContent ? { content: agentContent } : {} },
|
|
35888
|
-
event: { ...update, ...output2, ...hasContent ? { content: eventContent } : {} }
|
|
35927
|
+
agent: { ...update, ...meta3, ...output2, ...hasContent ? { content: agentContent } : {} },
|
|
35928
|
+
event: { ...update, ...meta3, ...output2, ...hasContent ? { content: eventContent } : {} }
|
|
35889
35929
|
};
|
|
35890
35930
|
}
|
|
35891
35931
|
update = async (sessionId, update, signal) => {
|
|
@@ -41251,6 +41291,72 @@ async function executePrompt({
|
|
|
41251
41291
|
}
|
|
41252
41292
|
|
|
41253
41293
|
// src/daemon-session-commands.ts
|
|
41294
|
+
async function prepareSession(command, config2, directories, audit, sessions, metrics, signal) {
|
|
41295
|
+
return await metrics.measure("prepare-total", async () => {
|
|
41296
|
+
const resolved = await metrics.measure(
|
|
41297
|
+
"workspace-resolve",
|
|
41298
|
+
async () => await resolveSessionDirectories(
|
|
41299
|
+
directories,
|
|
41300
|
+
config2.bindingId,
|
|
41301
|
+
command.directoryId,
|
|
41302
|
+
command.additionalDirectoryIds,
|
|
41303
|
+
signal
|
|
41304
|
+
)
|
|
41305
|
+
);
|
|
41306
|
+
const agent = config2.catalog.find(command.agentId);
|
|
41307
|
+
const preparation = {
|
|
41308
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
41309
|
+
agent,
|
|
41310
|
+
cwd: resolved.cwd,
|
|
41311
|
+
sessionId: command.sessionId,
|
|
41312
|
+
signal
|
|
41313
|
+
};
|
|
41314
|
+
const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
|
|
41315
|
+
const configuration = command.configuration;
|
|
41316
|
+
const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
|
|
41317
|
+
"configuration",
|
|
41318
|
+
async () => await sessions.configureSession({
|
|
41319
|
+
...preparation,
|
|
41320
|
+
booleanValue: configuration.booleanValue,
|
|
41321
|
+
configId: configuration.configId,
|
|
41322
|
+
requestId: command.requestId,
|
|
41323
|
+
value: configuration.value,
|
|
41324
|
+
valueType: configuration.valueType
|
|
41325
|
+
})
|
|
41326
|
+
);
|
|
41327
|
+
const listing = await metrics.measure(
|
|
41328
|
+
"workspace-list",
|
|
41329
|
+
async () => await directories.list(config2.bindingId, command.directoryId, signal)
|
|
41330
|
+
);
|
|
41331
|
+
audit.record({
|
|
41332
|
+
commandId: command.requestId,
|
|
41333
|
+
event: "session_prepared",
|
|
41334
|
+
sessionId: command.sessionId
|
|
41335
|
+
});
|
|
41336
|
+
if (command.configuration !== void 0) {
|
|
41337
|
+
audit.record({
|
|
41338
|
+
commandId: command.requestId,
|
|
41339
|
+
event: "session_configured",
|
|
41340
|
+
sessionId: command.sessionId
|
|
41341
|
+
});
|
|
41342
|
+
}
|
|
41343
|
+
return {
|
|
41344
|
+
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
41345
|
+
agentId: command.agentId,
|
|
41346
|
+
agentName: prepared.agentName,
|
|
41347
|
+
agentVersion: prepared.agentVersion,
|
|
41348
|
+
capabilities: prepared.capabilities,
|
|
41349
|
+
commands: prepared.commands,
|
|
41350
|
+
configOptions,
|
|
41351
|
+
directoryId: command.directoryId,
|
|
41352
|
+
directoryLabel: listing.directoryLabel,
|
|
41353
|
+
kind: "session.ready",
|
|
41354
|
+
requestId: command.requestId,
|
|
41355
|
+
restored: prepared.restored,
|
|
41356
|
+
sessionId: command.sessionId
|
|
41357
|
+
};
|
|
41358
|
+
});
|
|
41359
|
+
}
|
|
41254
41360
|
async function executeWorkspaceList(socket, command, directories, audit, signal) {
|
|
41255
41361
|
try {
|
|
41256
41362
|
const listing = await directories.list(command.bindingId, command.directoryId, signal);
|
|
@@ -41275,72 +41381,7 @@ async function executeWorkspaceList(socket, command, directories, audit, signal)
|
|
|
41275
41381
|
async function executeSessionPrepare(socket, command, config2, directories, audit, sessions, diagnostics, signal) {
|
|
41276
41382
|
const metrics = new AccumulatingOperationMetrics();
|
|
41277
41383
|
try {
|
|
41278
|
-
const readyEvent = await
|
|
41279
|
-
const resolved = await metrics.measure(
|
|
41280
|
-
"workspace-resolve",
|
|
41281
|
-
async () => await resolveSessionDirectories(
|
|
41282
|
-
directories,
|
|
41283
|
-
config2.bindingId,
|
|
41284
|
-
command.directoryId,
|
|
41285
|
-
command.additionalDirectoryIds,
|
|
41286
|
-
signal
|
|
41287
|
-
)
|
|
41288
|
-
);
|
|
41289
|
-
const agent = config2.catalog.find(command.agentId);
|
|
41290
|
-
const preparation = {
|
|
41291
|
-
additionalDirectories: resolved.additionalDirectories,
|
|
41292
|
-
agent,
|
|
41293
|
-
cwd: resolved.cwd,
|
|
41294
|
-
sessionId: command.sessionId,
|
|
41295
|
-
signal
|
|
41296
|
-
};
|
|
41297
|
-
const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
|
|
41298
|
-
const configuration = command.configuration;
|
|
41299
|
-
const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
|
|
41300
|
-
"configuration",
|
|
41301
|
-
async () => await sessions.configureSession({
|
|
41302
|
-
...preparation,
|
|
41303
|
-
booleanValue: configuration.booleanValue,
|
|
41304
|
-
configId: configuration.configId,
|
|
41305
|
-
requestId: command.requestId,
|
|
41306
|
-
value: configuration.value,
|
|
41307
|
-
valueType: configuration.valueType
|
|
41308
|
-
})
|
|
41309
|
-
);
|
|
41310
|
-
const listing = await metrics.measure(
|
|
41311
|
-
"workspace-list",
|
|
41312
|
-
async () => await directories.list(config2.bindingId, command.directoryId, signal)
|
|
41313
|
-
);
|
|
41314
|
-
audit.record({
|
|
41315
|
-
commandId: command.requestId,
|
|
41316
|
-
event: "session_prepared",
|
|
41317
|
-
sessionId: command.sessionId
|
|
41318
|
-
});
|
|
41319
|
-
if (command.configuration !== void 0) {
|
|
41320
|
-
audit.record({
|
|
41321
|
-
commandId: command.requestId,
|
|
41322
|
-
event: "session_configured",
|
|
41323
|
-
sessionId: command.sessionId
|
|
41324
|
-
});
|
|
41325
|
-
}
|
|
41326
|
-
const event = {
|
|
41327
|
-
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
41328
|
-
agentId: command.agentId,
|
|
41329
|
-
agentName: prepared.agentName,
|
|
41330
|
-
agentVersion: prepared.agentVersion,
|
|
41331
|
-
capabilities: prepared.capabilities,
|
|
41332
|
-
commands: prepared.commands,
|
|
41333
|
-
configOptions,
|
|
41334
|
-
directoryId: command.directoryId,
|
|
41335
|
-
directoryLabel: listing.directoryLabel,
|
|
41336
|
-
kind: "session.ready",
|
|
41337
|
-
requestId: command.requestId,
|
|
41338
|
-
restored: prepared.restored,
|
|
41339
|
-
sessionId: command.sessionId,
|
|
41340
|
-
runtimeTimings: metrics.snapshot()
|
|
41341
|
-
};
|
|
41342
|
-
return event;
|
|
41343
|
-
});
|
|
41384
|
+
const readyEvent = await prepareSession(command, config2, directories, audit, sessions, metrics, signal);
|
|
41344
41385
|
send(socket, {
|
|
41345
41386
|
...readyEvent,
|
|
41346
41387
|
runtimeTimings: metrics.snapshot()
|
|
@@ -41368,6 +41409,59 @@ async function executeSessionPrepare(socket, command, config2, directories, audi
|
|
|
41368
41409
|
reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
|
|
41369
41410
|
}
|
|
41370
41411
|
}
|
|
41412
|
+
async function executeSessionRestore(socket, command, config2, directories, audit, sessions, nativeSessions, diagnostics, signal) {
|
|
41413
|
+
const metrics = new AccumulatingOperationMetrics();
|
|
41414
|
+
try {
|
|
41415
|
+
const entry = await metrics.measure("session-lookup", async () => {
|
|
41416
|
+
const [found] = await nativeSessions.querySessions([command.sessionId], signal);
|
|
41417
|
+
if (found === void 0) {
|
|
41418
|
+
throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
|
|
41419
|
+
}
|
|
41420
|
+
return found;
|
|
41421
|
+
});
|
|
41422
|
+
const ready = await prepareSession(
|
|
41423
|
+
{
|
|
41424
|
+
additionalDirectoryIds: entry.additionalDirectories.map((directory) => directory.directoryId),
|
|
41425
|
+
agentId: entry.agentId,
|
|
41426
|
+
bindingId: config2.bindingId,
|
|
41427
|
+
directoryId: entry.directoryId,
|
|
41428
|
+
kind: "session.prepare",
|
|
41429
|
+
requestId: command.requestId,
|
|
41430
|
+
sessionId: command.sessionId,
|
|
41431
|
+
sessionState: "provisioned"
|
|
41432
|
+
},
|
|
41433
|
+
config2,
|
|
41434
|
+
directories,
|
|
41435
|
+
audit,
|
|
41436
|
+
sessions,
|
|
41437
|
+
metrics,
|
|
41438
|
+
signal
|
|
41439
|
+
);
|
|
41440
|
+
send(socket, {
|
|
41441
|
+
entry,
|
|
41442
|
+
kind: "session.restored",
|
|
41443
|
+
ready: { ...ready, runtimeTimings: metrics.snapshot() },
|
|
41444
|
+
requestId: command.requestId
|
|
41445
|
+
});
|
|
41446
|
+
} catch (error62) {
|
|
41447
|
+
diagnostics.daemonDiagnostic(
|
|
41448
|
+
"session_restore_failed",
|
|
41449
|
+
command.requestId,
|
|
41450
|
+
{
|
|
41451
|
+
code: operationErrorCode(error62),
|
|
41452
|
+
sessionId: command.sessionId
|
|
41453
|
+
},
|
|
41454
|
+
error62
|
|
41455
|
+
);
|
|
41456
|
+
audit.record({
|
|
41457
|
+
commandId: command.requestId,
|
|
41458
|
+
details: { code: operationErrorCode(error62) },
|
|
41459
|
+
event: "session_restore_failed",
|
|
41460
|
+
sessionId: command.sessionId
|
|
41461
|
+
});
|
|
41462
|
+
reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
|
|
41463
|
+
}
|
|
41464
|
+
}
|
|
41371
41465
|
async function executeSessionConfigure(socket, command, config2, directories, audit, sessions, signal) {
|
|
41372
41466
|
try {
|
|
41373
41467
|
const resolved = await resolveSessionDirectories(
|
|
@@ -41681,6 +41775,21 @@ function createDaemonCommandHandler({
|
|
|
41681
41775
|
});
|
|
41682
41776
|
return;
|
|
41683
41777
|
}
|
|
41778
|
+
if (kind === SESSION_RESTORE_KIND) {
|
|
41779
|
+
const command2 = message;
|
|
41780
|
+
void executeSessionRestore(
|
|
41781
|
+
socket,
|
|
41782
|
+
command2,
|
|
41783
|
+
config2,
|
|
41784
|
+
directories,
|
|
41785
|
+
audit,
|
|
41786
|
+
sessions,
|
|
41787
|
+
nativeSessions,
|
|
41788
|
+
diagnostics,
|
|
41789
|
+
signal
|
|
41790
|
+
);
|
|
41791
|
+
return;
|
|
41792
|
+
}
|
|
41684
41793
|
if (kind === SESSION_PERMISSION_RESPOND_KIND) {
|
|
41685
41794
|
const command2 = message;
|
|
41686
41795
|
void sessions.respondPermission(command2).then(() => {
|