@moxt-ai/mobius 0.0.345 → 0.0.346

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.345",
2089
+ version: "0.0.346",
2090
2090
  description: "Mobius CLI for pairing and running local AI agent services.",
2091
2091
  type: "module",
2092
2092
  bin: {
@@ -27870,7 +27870,7 @@ function decode4(schema, encoded) {
27870
27870
  throw new ProtocolMessageError("Invalid native session message", { cause });
27871
27871
  }
27872
27872
  }
27873
- 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;
27873
+ var NATIVE_SESSION_REQUEST_KIND, NATIVE_SESSION_RESULT_KIND, NATIVE_SESSION_CANCEL_KIND, envelope, activeTurnSnapshotSchema, commandDeliverySchema, lastTurnOutcomeSchema, identity, nativeSessionRequestSchema, nativeSessionCommandSchema, nativeSessionEntrySchema, resultEnvelope, nativeSessionResultSchema, nativeSessionCancelSchema, decodeNativeSessionCommand, encodeNativeSessionCommand, decodeNativeSessionResult, encodeNativeSessionResult, decodeNativeSessionCancel, encodeNativeSessionCancel;
27874
27874
  var init_native = __esm({
27875
27875
  "../mobius-sdk/src/protocol/session/native/index.ts"() {
27876
27876
  "use strict";
@@ -27906,6 +27906,15 @@ var init_native = __esm({
27906
27906
  // The command started, but the Runtime no longer retains its result.
27907
27907
  external_exports.object({ state: external_exports.literal("expired") }).readonly()
27908
27908
  ]);
27909
+ lastTurnOutcomeSchema = external_exports.discriminatedUnion("state", [
27910
+ external_exports.object({ commandId: identifierStringSchema, state: external_exports.literal("completed"), stopReason: external_exports.string().max(2048) }).readonly(),
27911
+ external_exports.object({
27912
+ code: identifierStringSchema,
27913
+ commandId: identifierStringSchema,
27914
+ message: external_exports.string().min(1).max(500),
27915
+ state: external_exports.literal("failed")
27916
+ }).readonly()
27917
+ ]);
27909
27918
  identity = {
27910
27919
  ...envelope,
27911
27920
  kind: external_exports.literal(NATIVE_SESSION_REQUEST_KIND),
@@ -27987,7 +27996,9 @@ var init_native = __esm({
27987
27996
  turn: activeTurnSnapshotSchema.nullable(),
27988
27997
  // Present only when the request named a command and every hop understands it. An
27989
27998
  // unrecognized delivery from a newer peer reads as absent instead of failing the snapshot.
27990
- command: commandDeliverySchema.optional().catch(void 0)
27999
+ command: commandDeliverySchema.optional().catch(void 0),
28000
+ // Absent from older Runtimes and while the last started command is still running.
28001
+ lastTurn: lastTurnOutcomeSchema.optional().catch(void 0)
27991
28002
  }).readonly(),
27992
28003
  external_exports.object({
27993
28004
  ...resultEnvelope,
@@ -95254,6 +95265,43 @@ var init_execution_receipts = __esm({
95254
95265
  return { state: "expired" };
95255
95266
  }
95256
95267
  };
95268
+ /**
95269
+ * How the Session's most recent started command ended. Receipts keep admission order, or the
95270
+ * order they last changed after a restart; commands that never started (queued, or reserved for
95271
+ * cancellation) are not turns, unless a restart failed them before they could start. Undefined
95272
+ * while that command still runs, or when no turn is retained.
95273
+ */
95274
+ lastTurn = (sessionId) => {
95275
+ let last;
95276
+ for (const [commandId, receipt] of this.#executions) {
95277
+ if (receipt.sessionId !== sessionId) {
95278
+ continue;
95279
+ }
95280
+ const outcome2 = receipt.outcome === null ? void 0 : this.outcome(commandId);
95281
+ const failedBeforeStart = outcome2?.type === "lifecycle-metadata" && outcome2.payload.kind === "prompt.failed-before-start";
95282
+ if (receipt.started || failedBeforeStart) {
95283
+ last = commandId;
95284
+ }
95285
+ }
95286
+ const outcome = last === void 0 ? void 0 : this.outcome(last);
95287
+ if (last === void 0 || outcome?.type !== "lifecycle-metadata") {
95288
+ return void 0;
95289
+ }
95290
+ switch (outcome.payload.kind) {
95291
+ case "prompt.completed":
95292
+ return { commandId: last, state: "completed", stopReason: outcome.payload.stopReason };
95293
+ case "prompt.failed":
95294
+ case "prompt.failed-before-start":
95295
+ return {
95296
+ code: outcome.payload.code,
95297
+ commandId: last,
95298
+ message: outcome.payload.message,
95299
+ state: "failed"
95300
+ };
95301
+ default:
95302
+ return void 0;
95303
+ }
95304
+ };
95257
95305
  /** Reserves an unseen command for cancellation before a delayed prompt can claim its identity. */
95258
95306
  recordCancellationBeforeAdmission = (commandId, sessionId) => {
95259
95307
  const existing = this.#executions.get(commandId);
@@ -96039,7 +96087,12 @@ function buildSessionLayer(options) {
96039
96087
  (directory, index2) => directory === requestOptions.additionalDirectories[index2]
96040
96088
  );
96041
96089
  });
96042
- return request.deliveryCommandId === void 0 ? snapshot : { ...snapshot, command: operations.delivery(request.deliveryCommandId, request.targetSessionId) };
96090
+ const lastTurn = snapshot.turn === null ? operations.lastTurn(request.targetSessionId) : void 0;
96091
+ return {
96092
+ ...snapshot,
96093
+ ...request.deliveryCommandId === void 0 ? {} : { command: operations.delivery(request.deliveryCommandId, request.targetSessionId) },
96094
+ ...lastTurn === void 0 ? {} : { lastTurn }
96095
+ };
96043
96096
  }
96044
96097
  );
96045
96098
  const recoveredEvents = operations.recover().map(({ sessionId, event, recordedAt }) => events.append(sessionId, event, recordedAt));