@moxt-ai/mobius 0.0.343 → 0.0.344

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
@@ -2086,7 +2086,7 @@ var init_package = __esm({
2086
2086
  "package.json"() {
2087
2087
  package_default = {
2088
2088
  name: "@moxt-ai/mobius",
2089
- version: "0.0.343",
2089
+ version: "0.0.344",
2090
2090
  description: "Mobius CLI for pairing and running local AI agent services.",
2091
2091
  type: "module",
2092
2092
  bin: {
@@ -27874,7 +27874,7 @@ function decode4(schema, encoded) {
27874
27874
  throw new ProtocolMessageError("Invalid native session message", { cause });
27875
27875
  }
27876
27876
  }
27877
- var NATIVE_SESSION_REQUEST_KIND, NATIVE_SESSION_RESULT_KIND, NATIVE_SESSION_CANCEL_KIND, envelope, activeTurnSnapshotSchema, identity, nativeSessionRequestSchema, nativeSessionCommandSchema, nativeSessionEntrySchema, resultEnvelope, nativeSessionResultSchema, nativeSessionCancelSchema, decodeNativeSessionCommand, encodeNativeSessionCommand, decodeNativeSessionResult, encodeNativeSessionResult, decodeNativeSessionCancel, encodeNativeSessionCancel;
27877
+ var NATIVE_SESSION_REQUEST_KIND, NATIVE_SESSION_RESULT_KIND, NATIVE_SESSION_CANCEL_KIND, envelope, activeTurnSnapshotSchema, commandDeliverySchema, identity, nativeSessionRequestSchema, nativeSessionCommandSchema, nativeSessionEntrySchema, resultEnvelope, nativeSessionResultSchema, nativeSessionCancelSchema, decodeNativeSessionCommand, encodeNativeSessionCommand, decodeNativeSessionResult, encodeNativeSessionResult, decodeNativeSessionCancel, encodeNativeSessionCancel;
27878
27878
  var init_native = __esm({
27879
27879
  "../mobius-sdk/src/protocol/session/native/index.ts"() {
27880
27880
  "use strict";
@@ -27900,6 +27900,16 @@ var init_native = __esm({
27900
27900
  sequence: external_exports.number().int().nonnegative(),
27901
27901
  state: external_exports.literal("running")
27902
27902
  }).readonly();
27903
+ commandDeliverySchema = external_exports.discriminatedUnion("state", [
27904
+ // No receipt: the command has not arrived. A delayed submission may still arrive later.
27905
+ external_exports.object({ state: external_exports.literal("unknown") }).readonly(),
27906
+ // The Runtime holds the command and has not finished it; it may be waiting or running.
27907
+ external_exports.object({ state: external_exports.literal("accepted") }).readonly(),
27908
+ external_exports.object({ state: external_exports.literal("completed"), stopReason: external_exports.string().max(2048) }).readonly(),
27909
+ external_exports.object({ code: identifierStringSchema, state: external_exports.literal("failed") }).readonly(),
27910
+ // The command started, but the Runtime no longer retains its result.
27911
+ external_exports.object({ state: external_exports.literal("expired") }).readonly()
27912
+ ]);
27903
27913
  identity = {
27904
27914
  ...envelope,
27905
27915
  kind: external_exports.literal(NATIVE_SESSION_REQUEST_KIND),
@@ -27909,7 +27919,14 @@ var init_native = __esm({
27909
27919
  directoryId: DIRECTORY_IDENTIFIER
27910
27920
  };
27911
27921
  nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
27912
- external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
27922
+ external_exports.object({
27923
+ ...identity,
27924
+ action: external_exports.literal("active-turn"),
27925
+ // Asks the Runtime for this command's delivery alongside the execution snapshot. It is not
27926
+ // named `commandId`, which routes a request as the command it names.
27927
+ deliveryCommandId: identifierStringSchema.optional(),
27928
+ targetSessionId: identifierStringSchema
27929
+ }).readonly(),
27913
27930
  external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
27914
27931
  external_exports.object({
27915
27932
  ...identity,
@@ -27924,7 +27941,14 @@ var init_native = __esm({
27924
27941
  }).readonly()
27925
27942
  ]);
27926
27943
  nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
27927
- external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
27944
+ external_exports.object({
27945
+ ...identity,
27946
+ action: external_exports.literal("active-turn"),
27947
+ // Asks the Runtime for this command's delivery alongside the execution snapshot. It is not
27948
+ // named `commandId`, which routes a request as the command it names.
27949
+ deliveryCommandId: identifierStringSchema.optional(),
27950
+ targetSessionId: identifierStringSchema
27951
+ }).readonly(),
27928
27952
  external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
27929
27953
  external_exports.object({
27930
27954
  ...identity,
@@ -27964,7 +27988,10 @@ var init_native = __esm({
27964
27988
  attachments: external_exports.array(promptAttachmentSchema).max(16).readonly()
27965
27989
  }).readonly()
27966
27990
  ).readonly(),
27967
- turn: activeTurnSnapshotSchema.nullable()
27991
+ turn: activeTurnSnapshotSchema.nullable(),
27992
+ // Present only when the request named a command and every hop understands it. An
27993
+ // unrecognized delivery from a newer peer reads as absent instead of failing the snapshot.
27994
+ command: commandDeliverySchema.optional().catch(void 0)
27968
27995
  }).readonly(),
27969
27996
  external_exports.object({
27970
27997
  ...resultEnvelope,
@@ -97183,6 +97210,32 @@ var init_execution_receipts = __esm({
97183
97210
  const receipt = this.#executions.get(commandId);
97184
97211
  return receipt?.outcome === null || receipt === void 0 ? void 0 : decodeKnownSessionEventPayload(JSON.parse(receipt.outcome)) ?? void 0;
97185
97212
  };
97213
+ /** The command's delivery as these receipts know it; another Session's command reads as unknown. */
97214
+ delivery = (commandId, sessionId) => {
97215
+ const receipt = this.#executions.get(commandId);
97216
+ if (receipt === void 0) {
97217
+ return this.#table.identity(commandId)?.sessionId === sessionId ? { state: "expired" } : { state: "unknown" };
97218
+ }
97219
+ if (receipt.sessionId !== sessionId) {
97220
+ return { state: "unknown" };
97221
+ }
97222
+ if (receipt.outcome === null) {
97223
+ return { state: "accepted" };
97224
+ }
97225
+ const outcome = this.outcome(commandId);
97226
+ if (outcome?.type !== "lifecycle-metadata") {
97227
+ return { state: "expired" };
97228
+ }
97229
+ switch (outcome.payload.kind) {
97230
+ case "prompt.completed":
97231
+ return { state: "completed", stopReason: outcome.payload.stopReason };
97232
+ case "prompt.failed":
97233
+ case "prompt.failed-before-start":
97234
+ return { code: outcome.payload.code, state: "failed" };
97235
+ default:
97236
+ return { state: "expired" };
97237
+ }
97238
+ };
97186
97239
  /** Reserves an unseen command for cancellation before a delayed prompt can claim its identity. */
97187
97240
  recordCancellationBeforeAdmission = (commandId, sessionId) => {
97188
97241
  const existing = this.#executions.get(commandId);
@@ -97953,20 +98006,23 @@ function buildSessionLayer(options) {
97953
98006
  resolveAgent,
97954
98007
  directories,
97955
98008
  manager,
97956
- async (request, requestOptions) => await activeSessions.executionSnapshot(async (command) => {
97957
- if (command.sessionId !== request.targetSessionId || command.agentId !== request.agentId) {
97958
- return false;
97959
- }
97960
- const cwd = await directories.resolve(command.bindingId, command.directoryId, requestOptions.signal);
97961
- const additionalDirectories = await directories.resolveMany(
97962
- command.bindingId,
97963
- command.additionalDirectoryIds,
97964
- requestOptions.signal
97965
- );
97966
- return cwd === requestOptions.cwd && additionalDirectories.length === requestOptions.additionalDirectories.length && additionalDirectories.every(
97967
- (directory, index2) => directory === requestOptions.additionalDirectories[index2]
97968
- );
97969
- })
98009
+ async (request, requestOptions) => {
98010
+ const snapshot = await activeSessions.executionSnapshot(async (command) => {
98011
+ if (command.sessionId !== request.targetSessionId || command.agentId !== request.agentId) {
98012
+ return false;
98013
+ }
98014
+ const cwd = await directories.resolve(command.bindingId, command.directoryId, requestOptions.signal);
98015
+ const additionalDirectories = await directories.resolveMany(
98016
+ command.bindingId,
98017
+ command.additionalDirectoryIds,
98018
+ requestOptions.signal
98019
+ );
98020
+ return cwd === requestOptions.cwd && additionalDirectories.length === requestOptions.additionalDirectories.length && additionalDirectories.every(
98021
+ (directory, index2) => directory === requestOptions.additionalDirectories[index2]
98022
+ );
98023
+ });
98024
+ return request.deliveryCommandId === void 0 ? snapshot : { ...snapshot, command: operations.delivery(request.deliveryCommandId, request.targetSessionId) };
98025
+ }
97970
98026
  );
97971
98027
  const recoveredEvents = operations.recover().map(({ sessionId, event, recordedAt }) => events.append(sessionId, event, recordedAt));
97972
98028
  return {