@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 CHANGED
@@ -3381,7 +3381,7 @@ var program = new Command();
3381
3381
  // package.json
3382
3382
  var package_default = {
3383
3383
  name: "@moxt-ai/mobius",
3384
- version: "0.0.181",
3384
+ version: "0.0.182",
3385
3385
  description: "Mobius CLI for pairing and running local AI agent services.",
3386
3386
  type: "module",
3387
3387
  bin: {
@@ -28418,6 +28418,8 @@ var SESSION_LIST_KIND = "session.list";
28418
28418
  var SESSION_LISTED_KIND = "session.listed";
28419
28419
  var SESSION_QUERY_KIND = "session.query";
28420
28420
  var SESSION_QUERIED_KIND = "session.queried";
28421
+ var SESSION_RESTORE_KIND = "session.restore";
28422
+ var SESSION_RESTORED_KIND = "session.restored";
28421
28423
  var SESSION_STATUS_CHANGED_KIND = "session.status.changed";
28422
28424
  var SESSION_CONFIGURE_KIND = "session.configure";
28423
28425
  var SESSION_CONFIG_UPDATED_KIND = "session.config.updated";
@@ -28498,6 +28500,11 @@ var sessionsQueriedEventSchema = external_exports.object({
28498
28500
  kind: external_exports.literal(SESSION_QUERIED_KIND),
28499
28501
  requestId: identifierStringSchema
28500
28502
  }).readonly();
28503
+ var sessionRestoreCommandSchema = external_exports.object({
28504
+ kind: external_exports.literal(SESSION_RESTORE_KIND),
28505
+ requestId: identifierStringSchema,
28506
+ sessionId: identifierStringSchema
28507
+ }).readonly();
28501
28508
  var fileReadCommandSchema = external_exports.object({
28502
28509
  kind: external_exports.literal(FILE_READ_KIND),
28503
28510
  maxBytes: external_exports.number().int().positive().max(128 * 1024 * 1024),
@@ -28812,6 +28819,12 @@ var sessionReadyEventSchema = external_exports.object({
28812
28819
  runtimeTimings: runtimeTimingsSchema.optional(),
28813
28820
  sessionId: identifierStringSchema
28814
28821
  }).readonly();
28822
+ var sessionRestoredEventSchema = external_exports.object({
28823
+ entry: sessionMetadataSchema,
28824
+ kind: external_exports.literal(SESSION_RESTORED_KIND),
28825
+ ready: sessionReadyEventSchema,
28826
+ requestId: identifierStringSchema
28827
+ }).readonly();
28815
28828
  var sessionConfigureCommandSchema = external_exports.object({
28816
28829
  ...sessionIdentityFields,
28817
28830
  booleanValue: external_exports.boolean(),
@@ -29027,6 +29040,10 @@ var decodeSessionQueryCommand = (encoded) => decode3(encoded, sessionQueryComman
29027
29040
  var encodeSessionQueryCommand = (message) => encode3(message, sessionQueryCommandSchema);
29028
29041
  var decodeSessionsQueriedEvent = (encoded) => decode3(encoded, sessionsQueriedEventSchema);
29029
29042
  var encodeSessionsQueriedEvent = (message) => encode3(message, sessionsQueriedEventSchema);
29043
+ var decodeSessionRestoreCommand = (encoded) => decode3(encoded, sessionRestoreCommandSchema);
29044
+ var encodeSessionRestoreCommand = (message) => encode3(message, sessionRestoreCommandSchema);
29045
+ var decodeSessionRestoredEvent = (encoded) => decode3(encoded, sessionRestoredEventSchema);
29046
+ var encodeSessionRestoredEvent = (message) => encode3(message, sessionRestoredEventSchema);
29030
29047
  var decodeSessionStatusChangedEvent = (encoded) => decode3(encoded, sessionStatusChangedEventSchema);
29031
29048
  var encodeSessionStatusChangedEvent = (message) => encode3(message, sessionStatusChangedEventSchema);
29032
29049
  var decodeSessionPrepareCommand = (encoded) => decode3(encoded, sessionPrepareCommandSchema);
@@ -30109,6 +30126,11 @@ var serviceToDaemonSignatures = {
30109
30126
  encodeSessionQueryCommand,
30110
30127
  decodeSessionQueryCommand
30111
30128
  ),
30129
+ [SESSION_RESTORE_KIND]: defineMessageSignature(
30130
+ SESSION_RESTORE_KIND,
30131
+ encodeSessionRestoreCommand,
30132
+ decodeSessionRestoreCommand
30133
+ ),
30112
30134
  [NATIVE_SESSION_CANCEL_KIND]: defineMessageSignature(
30113
30135
  NATIVE_SESSION_CANCEL_KIND,
30114
30136
  encodeNativeSessionCancel,
@@ -30240,6 +30262,11 @@ var daemonToServiceSignatures = {
30240
30262
  encodeSessionsQueriedEvent,
30241
30263
  decodeSessionsQueriedEvent
30242
30264
  ),
30265
+ [SESSION_RESTORED_KIND]: defineMessageSignature(
30266
+ SESSION_RESTORED_KIND,
30267
+ encodeSessionRestoredEvent,
30268
+ decodeSessionRestoredEvent
30269
+ ),
30243
30270
  [SESSION_STATUS_CHANGED_KIND]: defineMessageSignature(
30244
30271
  SESSION_STATUS_CHANGED_KIND,
30245
30272
  encodeSessionStatusChangedEvent,
@@ -40087,6 +40114,17 @@ var embeddedImageSchema = external_exports.looseObject({
40087
40114
  data: external_exports.string(),
40088
40115
  mimeType: external_exports.string()
40089
40116
  });
40117
+ var toolImageSchema = external_exports.union([
40118
+ embeddedImageSchema,
40119
+ external_exports.object({
40120
+ type: external_exports.literal("image"),
40121
+ source: external_exports.object({ type: external_exports.literal("base64"), data: external_exports.string(), media_type: external_exports.string() })
40122
+ }).transform(({ source }) => ({ type: "image", data: source.data, mimeType: source.media_type })),
40123
+ external_exports.object({
40124
+ type: external_exports.literal("image"),
40125
+ file: external_exports.object({ base64: external_exports.string(), type: external_exports.string() })
40126
+ }).transform(({ file: file2 }) => ({ type: "image", data: file2.base64, mimeType: file2.type }))
40127
+ ]);
40090
40128
  function isRecord10(value) {
40091
40129
  return typeof value === "object" && value !== null && !Array.isArray(value);
40092
40130
  }
@@ -40206,7 +40244,7 @@ var AcpContentExternalizer = class {
40206
40244
  if (!isRecord10(value)) {
40207
40245
  return value;
40208
40246
  }
40209
- const image = embeddedImageSchema.safeParse(value);
40247
+ const image = toolImageSchema.safeParse(value);
40210
40248
  if (image.success && image.data.data.length > 0) {
40211
40249
  const prepared = await this.#content(sessionId, image.data, signal);
40212
40250
  if (isRecord10(prepared.event) && typeof prepared.event["imageKey"] === "string") {
@@ -40225,6 +40263,7 @@ var AcpContentExternalizer = class {
40225
40263
  async #toolUpdate(sessionId, update, signal) {
40226
40264
  const images = /* @__PURE__ */ new Map();
40227
40265
  const rawOutput = update.rawOutput === void 0 ? void 0 : await this.#rawOutput(sessionId, update.rawOutput, images, signal);
40266
+ 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));
40228
40267
  const originalJson = images.size === 0 ? void 0 : JSON.stringify(update.rawOutput);
40229
40268
  const rewrittenJson = images.size === 0 ? void 0 : JSON.stringify(rawOutput);
40230
40269
  const agentContent = [];
@@ -40248,10 +40287,11 @@ var AcpContentExternalizer = class {
40248
40287
  eventContent.push({ type: "content", content: prepared.event });
40249
40288
  }
40250
40289
  const output2 = update.rawOutput === void 0 ? {} : { rawOutput };
40290
+ const meta3 = metadata === void 0 ? {} : { _meta: metadata };
40251
40291
  const hasContent = update.content !== void 0 && update.content !== null || agentContent.length > 0;
40252
40292
  return {
40253
- agent: { ...update, ...output2, ...hasContent ? { content: agentContent } : {} },
40254
- event: { ...update, ...output2, ...hasContent ? { content: eventContent } : {} }
40293
+ agent: { ...update, ...meta3, ...output2, ...hasContent ? { content: agentContent } : {} },
40294
+ event: { ...update, ...meta3, ...output2, ...hasContent ? { content: eventContent } : {} }
40255
40295
  };
40256
40296
  }
40257
40297
  update = async (sessionId, update, signal) => {
@@ -45617,6 +45657,72 @@ async function executePrompt({
45617
45657
  }
45618
45658
 
45619
45659
  // src/daemon-session-commands.ts
45660
+ async function prepareSession(command, config2, directories, audit, sessions, metrics, signal) {
45661
+ return await metrics.measure("prepare-total", async () => {
45662
+ const resolved = await metrics.measure(
45663
+ "workspace-resolve",
45664
+ async () => await resolveSessionDirectories(
45665
+ directories,
45666
+ config2.bindingId,
45667
+ command.directoryId,
45668
+ command.additionalDirectoryIds,
45669
+ signal
45670
+ )
45671
+ );
45672
+ const agent = config2.catalog.find(command.agentId);
45673
+ const preparation = {
45674
+ additionalDirectories: resolved.additionalDirectories,
45675
+ agent,
45676
+ cwd: resolved.cwd,
45677
+ sessionId: command.sessionId,
45678
+ signal
45679
+ };
45680
+ const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
45681
+ const configuration = command.configuration;
45682
+ const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
45683
+ "configuration",
45684
+ async () => await sessions.configureSession({
45685
+ ...preparation,
45686
+ booleanValue: configuration.booleanValue,
45687
+ configId: configuration.configId,
45688
+ requestId: command.requestId,
45689
+ value: configuration.value,
45690
+ valueType: configuration.valueType
45691
+ })
45692
+ );
45693
+ const listing = await metrics.measure(
45694
+ "workspace-list",
45695
+ async () => await directories.list(config2.bindingId, command.directoryId, signal)
45696
+ );
45697
+ audit.record({
45698
+ commandId: command.requestId,
45699
+ event: "session_prepared",
45700
+ sessionId: command.sessionId
45701
+ });
45702
+ if (command.configuration !== void 0) {
45703
+ audit.record({
45704
+ commandId: command.requestId,
45705
+ event: "session_configured",
45706
+ sessionId: command.sessionId
45707
+ });
45708
+ }
45709
+ return {
45710
+ additionalDirectories: resolved.additionalDirectoryEntries,
45711
+ agentId: command.agentId,
45712
+ agentName: prepared.agentName,
45713
+ agentVersion: prepared.agentVersion,
45714
+ capabilities: prepared.capabilities,
45715
+ commands: prepared.commands,
45716
+ configOptions,
45717
+ directoryId: command.directoryId,
45718
+ directoryLabel: listing.directoryLabel,
45719
+ kind: "session.ready",
45720
+ requestId: command.requestId,
45721
+ restored: prepared.restored,
45722
+ sessionId: command.sessionId
45723
+ };
45724
+ });
45725
+ }
45620
45726
  async function executeWorkspaceList(socket, command, directories, audit, signal) {
45621
45727
  try {
45622
45728
  const listing = await directories.list(command.bindingId, command.directoryId, signal);
@@ -45641,72 +45747,7 @@ async function executeWorkspaceList(socket, command, directories, audit, signal)
45641
45747
  async function executeSessionPrepare(socket, command, config2, directories, audit, sessions, diagnostics, signal) {
45642
45748
  const metrics = new AccumulatingOperationMetrics();
45643
45749
  try {
45644
- const readyEvent = await metrics.measure("prepare-total", async () => {
45645
- const resolved = await metrics.measure(
45646
- "workspace-resolve",
45647
- async () => await resolveSessionDirectories(
45648
- directories,
45649
- config2.bindingId,
45650
- command.directoryId,
45651
- command.additionalDirectoryIds,
45652
- signal
45653
- )
45654
- );
45655
- const agent = config2.catalog.find(command.agentId);
45656
- const preparation = {
45657
- additionalDirectories: resolved.additionalDirectories,
45658
- agent,
45659
- cwd: resolved.cwd,
45660
- sessionId: command.sessionId,
45661
- signal
45662
- };
45663
- const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
45664
- const configuration = command.configuration;
45665
- const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
45666
- "configuration",
45667
- async () => await sessions.configureSession({
45668
- ...preparation,
45669
- booleanValue: configuration.booleanValue,
45670
- configId: configuration.configId,
45671
- requestId: command.requestId,
45672
- value: configuration.value,
45673
- valueType: configuration.valueType
45674
- })
45675
- );
45676
- const listing = await metrics.measure(
45677
- "workspace-list",
45678
- async () => await directories.list(config2.bindingId, command.directoryId, signal)
45679
- );
45680
- audit.record({
45681
- commandId: command.requestId,
45682
- event: "session_prepared",
45683
- sessionId: command.sessionId
45684
- });
45685
- if (command.configuration !== void 0) {
45686
- audit.record({
45687
- commandId: command.requestId,
45688
- event: "session_configured",
45689
- sessionId: command.sessionId
45690
- });
45691
- }
45692
- const event = {
45693
- additionalDirectories: resolved.additionalDirectoryEntries,
45694
- agentId: command.agentId,
45695
- agentName: prepared.agentName,
45696
- agentVersion: prepared.agentVersion,
45697
- capabilities: prepared.capabilities,
45698
- commands: prepared.commands,
45699
- configOptions,
45700
- directoryId: command.directoryId,
45701
- directoryLabel: listing.directoryLabel,
45702
- kind: "session.ready",
45703
- requestId: command.requestId,
45704
- restored: prepared.restored,
45705
- sessionId: command.sessionId,
45706
- runtimeTimings: metrics.snapshot()
45707
- };
45708
- return event;
45709
- });
45750
+ const readyEvent = await prepareSession(command, config2, directories, audit, sessions, metrics, signal);
45710
45751
  send(socket, {
45711
45752
  ...readyEvent,
45712
45753
  runtimeTimings: metrics.snapshot()
@@ -45734,6 +45775,59 @@ async function executeSessionPrepare(socket, command, config2, directories, audi
45734
45775
  reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
45735
45776
  }
45736
45777
  }
45778
+ async function executeSessionRestore(socket, command, config2, directories, audit, sessions, nativeSessions, diagnostics, signal) {
45779
+ const metrics = new AccumulatingOperationMetrics();
45780
+ try {
45781
+ const entry = await metrics.measure("session-lookup", async () => {
45782
+ const [found] = await nativeSessions.querySessions([command.sessionId], signal);
45783
+ if (found === void 0) {
45784
+ throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
45785
+ }
45786
+ return found;
45787
+ });
45788
+ const ready = await prepareSession(
45789
+ {
45790
+ additionalDirectoryIds: entry.additionalDirectories.map((directory) => directory.directoryId),
45791
+ agentId: entry.agentId,
45792
+ bindingId: config2.bindingId,
45793
+ directoryId: entry.directoryId,
45794
+ kind: "session.prepare",
45795
+ requestId: command.requestId,
45796
+ sessionId: command.sessionId,
45797
+ sessionState: "provisioned"
45798
+ },
45799
+ config2,
45800
+ directories,
45801
+ audit,
45802
+ sessions,
45803
+ metrics,
45804
+ signal
45805
+ );
45806
+ send(socket, {
45807
+ entry,
45808
+ kind: "session.restored",
45809
+ ready: { ...ready, runtimeTimings: metrics.snapshot() },
45810
+ requestId: command.requestId
45811
+ });
45812
+ } catch (error62) {
45813
+ diagnostics.daemonDiagnostic(
45814
+ "session_restore_failed",
45815
+ command.requestId,
45816
+ {
45817
+ code: operationErrorCode(error62),
45818
+ sessionId: command.sessionId
45819
+ },
45820
+ error62
45821
+ );
45822
+ audit.record({
45823
+ commandId: command.requestId,
45824
+ details: { code: operationErrorCode(error62) },
45825
+ event: "session_restore_failed",
45826
+ sessionId: command.sessionId
45827
+ });
45828
+ reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
45829
+ }
45830
+ }
45737
45831
  async function executeSessionConfigure(socket, command, config2, directories, audit, sessions, signal) {
45738
45832
  try {
45739
45833
  const resolved = await resolveSessionDirectories(
@@ -46047,6 +46141,21 @@ function createDaemonCommandHandler({
46047
46141
  });
46048
46142
  return;
46049
46143
  }
46144
+ if (kind === SESSION_RESTORE_KIND) {
46145
+ const command2 = message;
46146
+ void executeSessionRestore(
46147
+ socket,
46148
+ command2,
46149
+ config2,
46150
+ directories,
46151
+ audit,
46152
+ sessions,
46153
+ nativeSessions,
46154
+ diagnostics,
46155
+ signal
46156
+ );
46157
+ return;
46158
+ }
46050
46159
  if (kind === SESSION_PERMISSION_RESPOND_KIND) {
46051
46160
  const command2 = message;
46052
46161
  void sessions.respondPermission(command2).then(() => {