@moxt-ai/mobius 0.0.182 → 0.0.184

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.
Files changed (34) hide show
  1. package/dist/acp/agent-connection.d.ts.map +1 -1
  2. package/dist/acp/agent-connection.js +14 -2
  3. package/dist/acp/agent-connection.js.map +1 -1
  4. package/dist/acp/agent-runtime-manager.d.ts +2 -1
  5. package/dist/acp/agent-runtime-manager.d.ts.map +1 -1
  6. package/dist/acp/agent-runtime-manager.js +46 -36
  7. package/dist/acp/agent-runtime-manager.js.map +1 -1
  8. package/dist/acp/agent-session.d.ts +4 -3
  9. package/dist/acp/agent-session.d.ts.map +1 -1
  10. package/dist/acp/agent-session.js +15 -3
  11. package/dist/acp/agent-session.js.map +1 -1
  12. package/dist/acp/codex/app-server-protocol.d.ts +4 -0
  13. package/dist/acp/codex/app-server-protocol.d.ts.map +1 -1
  14. package/dist/acp/codex/app-server-protocol.js +2 -0
  15. package/dist/acp/codex/app-server-protocol.js.map +1 -1
  16. package/dist/acp/codex/items.d.ts.map +1 -1
  17. package/dist/acp/codex/items.js +35 -11
  18. package/dist/acp/codex/items.js.map +1 -1
  19. package/dist/acp/session-contracts.d.ts +5 -0
  20. package/dist/acp/session-contracts.d.ts.map +1 -1
  21. package/dist/acp/session-contracts.js.map +1 -1
  22. package/dist/cli.js +177 -83
  23. package/dist/cli.js.map +4 -4
  24. package/dist/daemon-session-commands.d.ts.map +1 -1
  25. package/dist/daemon-session-commands.js +6 -4
  26. package/dist/daemon-session-commands.js.map +1 -1
  27. package/dist/external-content/acp-content-externalizer.d.ts.map +1 -1
  28. package/dist/external-content/acp-content-externalizer.js +13 -0
  29. package/dist/external-content/acp-content-externalizer.js.map +1 -1
  30. package/dist/index.js +171 -79
  31. package/dist/index.js.map +3 -3
  32. package/dist/runtime.js +174 -82
  33. package/dist/runtime.js.map +3 -3
  34. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -23242,6 +23242,18 @@ function readString2(value, fallback = "") {
23242
23242
  }
23243
23243
 
23244
23244
  // src/acp/agent-connection.ts
23245
+ function requestErrorMessage(error62) {
23246
+ const fallback = truncate2(error62.message, 500);
23247
+ if (error62.message !== "Internal error" || !isRecord4(error62.data)) {
23248
+ return fallback;
23249
+ }
23250
+ const agentError = error62.data["error"];
23251
+ if (!isRecord4(agentError) || agentError["code"] !== "invalid_prompt") {
23252
+ return fallback;
23253
+ }
23254
+ const message = agentError["message"];
23255
+ return typeof message === "string" && message.length > 0 ? truncate2(message, 500) : fallback;
23256
+ }
23245
23257
  function readableWebStream(input2) {
23246
23258
  let streamOpen = true;
23247
23259
  return new ReadableStream({
@@ -23413,7 +23425,7 @@ var AgentConnection = class {
23413
23425
  );
23414
23426
  }
23415
23427
  if (error62 instanceof RequestError) {
23416
- throw new AcpExecutionError(truncate2(error62.message, 500), { cause: error62 }, "acp_agent_error");
23428
+ throw new AcpExecutionError(requestErrorMessage(error62), { cause: error62 }, "acp_agent_error");
23417
23429
  }
23418
23430
  throw error62;
23419
23431
  }
@@ -30278,11 +30290,11 @@ var AgentSession = class _AgentSession {
30278
30290
  }
30279
30291
  throw new AcpExecutionError("ACP agent initialization failed");
30280
30292
  }
30281
- static start = async (options, getObserver, store, metrics, contentExternalizer) => await _AgentSession.#start(
30293
+ static start = async (options, recovery, getObserver, store, metrics, contentExternalizer) => await _AgentSession.#start(
30282
30294
  options,
30283
30295
  getObserver,
30284
30296
  store,
30285
- async (runtime) => await runtime.initialize(options.signal, options.origin),
30297
+ async (runtime) => await runtime.initialize(options.signal, recovery, options.origin),
30286
30298
  metrics,
30287
30299
  contentExternalizer
30288
30300
  );
@@ -30320,6 +30332,16 @@ var AgentSession = class _AgentSession {
30320
30332
  const history = await this.#completedHistory(signal, "ACP agent exited while loading history");
30321
30333
  return await embedLocalHistoryImages(await history.snapshot(), signal);
30322
30334
  };
30335
+ ensureHistoryLoaded = async (signal) => {
30336
+ if (!this.#capabilities.loadSession) {
30337
+ throw new AcpExecutionError(
30338
+ "This Agent restores context but does not provide message history.",
30339
+ {},
30340
+ "native_history_unsupported"
30341
+ );
30342
+ }
30343
+ await this.#completedHistory(signal, "ACP agent exited while loading history");
30344
+ };
30323
30345
  loadHistoryEventsV2 = async (eventLimit, cursor, signal) => {
30324
30346
  if (!this.#capabilities.loadSession) {
30325
30347
  throw new AcpExecutionError(
@@ -30492,7 +30514,7 @@ var AgentSession = class _AgentSession {
30492
30514
  128
30493
30515
  );
30494
30516
  }
30495
- initialize = async (signal, origin) => {
30517
+ initialize = async (signal, recovery, origin) => {
30496
30518
  await this.#initializeAgent(signal);
30497
30519
  let stored = this.#metrics.measureSync(
30498
30520
  "session-state-read",
@@ -30561,7 +30583,19 @@ var AgentSession = class _AgentSession {
30561
30583
  this.#prompted = stored.session.prompted;
30562
30584
  this.#sessionTitle = stored.session.title;
30563
30585
  this.#restored = true;
30564
- if (this.#capabilities.resumeSession) {
30586
+ if (recovery.kind === "history-required") {
30587
+ if (!this.#capabilities.loadSession) {
30588
+ throw new AcpExecutionError(
30589
+ "This Agent restores context but does not provide message history.",
30590
+ {},
30591
+ "native_history_unsupported"
30592
+ );
30593
+ }
30594
+ lifecycleResponse = await this.#metrics.measure(
30595
+ "session-load",
30596
+ async () => (await this.#loadSession(signal, "ACP agent exited while loading a session")).response
30597
+ );
30598
+ } else if (this.#capabilities.resumeSession) {
30565
30599
  lifecycleResponse = await this.#metrics.measure(
30566
30600
  "session-resume",
30567
30601
  async () => await this.race(
@@ -31519,8 +31553,15 @@ var embeddedImageSchema = external_exports.looseObject({
31519
31553
  data: external_exports.string(),
31520
31554
  mimeType: external_exports.string()
31521
31555
  });
31556
+ var inlineImageUrlSchema = external_exports.string().regex(/^data:image\/(?:png|jpeg|gif|webp);base64,/u).transform((url2) => ({
31557
+ type: "image",
31558
+ data: url2.slice(url2.indexOf(",") + 1),
31559
+ mimeType: url2.slice(5, url2.indexOf(";"))
31560
+ }));
31522
31561
  var toolImageSchema = external_exports.union([
31523
31562
  embeddedImageSchema,
31563
+ external_exports.object({ type: external_exports.literal("file"), mime: external_exports.string(), url: inlineImageUrlSchema }).refine(({ mime, url: url2 }) => mime === url2.mimeType).transform(({ url: url2 }) => url2),
31564
+ external_exports.object({ type: external_exports.literal("inputImage"), imageUrl: inlineImageUrlSchema }).transform(({ imageUrl }) => imageUrl),
31524
31565
  external_exports.object({
31525
31566
  type: external_exports.literal("image"),
31526
31567
  source: external_exports.object({ type: external_exports.literal("base64"), data: external_exports.string(), media_type: external_exports.string() })
@@ -32172,12 +32213,13 @@ var AgentRuntimeManager = class {
32172
32213
  this.#executionProcesses.retain(options.sessionId, runtime);
32173
32214
  return runtime;
32174
32215
  }
32175
- async #startPreparation(options, metrics = unmeasuredOperationMetrics) {
32216
+ async #startPreparation(options, recovery, metrics = unmeasuredOperationMetrics) {
32176
32217
  return await this.#executionProcesses.prepare(options.sessionId, async () => {
32177
32218
  return await this.#startRetainedSessionProcess(
32178
32219
  options,
32179
32220
  async () => await AgentSession.start(
32180
32221
  options.origin === void 0 && this.#sessionIdentity === "native" && isNativeChatSessionId(options.agent.id, options.sessionId) && this.#store.read(options.sessionId) instanceof MissingAcpStoredSession ? { ...options, origin: { kind: "import", nativeSessionId: options.sessionId } } : options,
32222
+ recovery,
32181
32223
  () => this.#observer,
32182
32224
  this.#store,
32183
32225
  metrics,
@@ -32186,7 +32228,7 @@ var AgentRuntimeManager = class {
32186
32228
  );
32187
32229
  });
32188
32230
  }
32189
- async #replacePreparation(existing, options, metrics) {
32231
+ async #replacePreparation(existing, options, recovery, metrics) {
32190
32232
  return await this.#executionProcesses.prepare(options.sessionId, async () => {
32191
32233
  await this.#retireSessionProcess(
32192
32234
  options.sessionId,
@@ -32198,6 +32240,7 @@ var AgentRuntimeManager = class {
32198
32240
  options,
32199
32241
  async () => await AgentSession.start(
32200
32242
  options,
32243
+ recovery,
32201
32244
  () => this.#observer,
32202
32245
  this.#store,
32203
32246
  metrics,
@@ -32214,6 +32257,7 @@ var AgentRuntimeManager = class {
32214
32257
  options,
32215
32258
  async () => await AgentSession.start(
32216
32259
  options,
32260
+ { kind: "interactive-only" },
32217
32261
  () => this.#observer,
32218
32262
  this.#store,
32219
32263
  unmeasuredOperationMetrics,
@@ -32257,42 +32301,58 @@ var AgentRuntimeManager = class {
32257
32301
  return runtime;
32258
32302
  });
32259
32303
  }
32260
- prepareSession = async (options, metrics = unmeasuredOperationMetrics) => this.#operations.run(options, async (options2) => {
32261
- const stored = metrics.measureSync("session-state-read", () => this.#store.read(options2.sessionId));
32262
- if (stored instanceof FoundAcpStoredSession && this.#nativeOperations.has(`${stored.session.agentId}:${stored.session.nativeSessionId}`)) {
32263
- throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
32264
- }
32265
- const pending = this.#executionProcesses.pending(options2.sessionId);
32266
- if (pending !== void 0) {
32267
- const runtime2 = await metrics.measure(
32268
- "session-preparation-wait",
32269
- async () => await waitForSharedOperation(pending, options2.signal)
32270
- );
32271
- if (runtime2.belongsTo(options2.agent.id, options2.cwd, options2.additionalDirectories)) {
32272
- this.#executionProcesses.touch(options2.sessionId, runtime2);
32273
- return runtime2.prepared();
32274
- }
32275
- return await this.prepareSession(options2, metrics);
32276
- }
32277
- const existing = this.#executionProcesses.get(options2.sessionId);
32278
- if (existing !== void 0) {
32279
- if (existing.belongsTo(options2.agent.id, options2.cwd, options2.additionalDirectories)) {
32280
- this.#executionProcesses.touch(options2.sessionId, existing);
32281
- return existing.prepared();
32304
+ async #prepareSession(options, recovery, metrics = unmeasuredOperationMetrics) {
32305
+ return await this.#operations.run(options, async (options2) => {
32306
+ const stored = metrics.measureSync("session-state-read", () => this.#store.read(options2.sessionId));
32307
+ if (stored instanceof FoundAcpStoredSession && this.#nativeOperations.has(`${stored.session.agentId}:${stored.session.nativeSessionId}`)) {
32308
+ throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
32282
32309
  }
32283
- if (!existing.canRebind()) {
32284
- throw new AcpExecutionError(
32285
- "The agent or workspace cannot change after a conversation has started",
32286
- {},
32287
- "session_identity_mismatch"
32310
+ const pending = this.#executionProcesses.pending(options2.sessionId);
32311
+ if (pending !== void 0) {
32312
+ const runtime2 = await metrics.measure(
32313
+ "session-preparation-wait",
32314
+ async () => await waitForSharedOperation(pending, options2.signal)
32288
32315
  );
32316
+ if (runtime2.belongsTo(options2.agent.id, options2.cwd, options2.additionalDirectories)) {
32317
+ this.#executionProcesses.touch(options2.sessionId, runtime2);
32318
+ if (recovery.kind === "history-required") {
32319
+ await metrics.measure(
32320
+ "session-load",
32321
+ async () => await runtime2.ensureHistoryLoaded(options2.signal)
32322
+ );
32323
+ }
32324
+ return runtime2.prepared();
32325
+ }
32326
+ return await this.#prepareSession(options2, recovery, metrics);
32327
+ }
32328
+ const existing = this.#executionProcesses.get(options2.sessionId);
32329
+ if (existing !== void 0) {
32330
+ if (existing.belongsTo(options2.agent.id, options2.cwd, options2.additionalDirectories)) {
32331
+ this.#executionProcesses.touch(options2.sessionId, existing);
32332
+ if (recovery.kind === "history-required") {
32333
+ await metrics.measure(
32334
+ "session-load",
32335
+ async () => await existing.ensureHistoryLoaded(options2.signal)
32336
+ );
32337
+ }
32338
+ return existing.prepared();
32339
+ }
32340
+ if (!existing.canRebind()) {
32341
+ throw new AcpExecutionError(
32342
+ "The agent or workspace cannot change after a conversation has started",
32343
+ {},
32344
+ "session_identity_mismatch"
32345
+ );
32346
+ }
32347
+ const runtime2 = await this.#replacePreparation(existing, options2, recovery, metrics);
32348
+ return runtime2.prepared();
32289
32349
  }
32290
- const runtime2 = await this.#replacePreparation(existing, options2, metrics);
32291
- return runtime2.prepared();
32292
- }
32293
- const runtime = await this.#startPreparation(options2, metrics);
32294
- return runtime.prepared();
32295
- });
32350
+ const runtime = await this.#startPreparation(options2, recovery, metrics);
32351
+ return runtime.prepared();
32352
+ });
32353
+ }
32354
+ prepareSession = async (options, metrics = unmeasuredOperationMetrics) => await this.#prepareSession(options, { kind: "interactive-only" }, metrics);
32355
+ restoreSession = async (options, metrics = unmeasuredOperationMetrics) => await this.#prepareSession(options, { kind: "history-required" }, metrics);
32296
32356
  /**
32297
32357
  * Opens a short-lived native ACP session only to read the local Agent's
32298
32358
  * authoritative settings. Its identity and store are private to this
@@ -32306,6 +32366,7 @@ var AgentRuntimeManager = class {
32306
32366
  ...options2,
32307
32367
  sessionId: `agent-settings-${crypto.randomUUID()}`
32308
32368
  },
32369
+ { kind: "interactive-only" },
32309
32370
  () => this.#agentSettingsObserver,
32310
32371
  new MemoryAcpSessionStore(),
32311
32372
  unmeasuredOperationMetrics,
@@ -32343,7 +32404,7 @@ var AgentRuntimeManager = class {
32343
32404
  );
32344
32405
  }
32345
32406
  return await this.#executionProcesses.use(options2.sessionId, async () => {
32346
- const runtime = await this.#startPreparation(options2, metrics);
32407
+ const runtime = await this.#startPreparation(options2, { kind: "interactive-only" }, metrics);
32347
32408
  try {
32348
32409
  return runtime.prepared();
32349
32410
  } finally {
@@ -32363,7 +32424,7 @@ var AgentRuntimeManager = class {
32363
32424
  }
32364
32425
  const existing = this.#executionProcesses.get(options2.sessionId);
32365
32426
  if (existing === void 0) {
32366
- return (await this.#startPreparation(options2)).prepared();
32427
+ return (await this.#startPreparation(options2, { kind: "interactive-only" })).prepared();
32367
32428
  }
32368
32429
  if (!existing.belongsTo(options2.agent.id, options2.cwd, options2.additionalDirectories)) {
32369
32430
  throw new AcpExecutionError(
@@ -32548,7 +32609,7 @@ var AgentRuntimeManager = class {
32548
32609
  const temporaryOptions = { ...options2, sessionId: temporarySessionId };
32549
32610
  return await this.#executionProcesses.use(temporarySessionId, async () => {
32550
32611
  try {
32551
- const runtime = await this.#startPreparation(temporaryOptions);
32612
+ const runtime = await this.#startPreparation(temporaryOptions, { kind: "interactive-only" });
32552
32613
  let adopted = false;
32553
32614
  try {
32554
32615
  const nativeSessionId = runtime.nativeSessionId();
@@ -32714,7 +32775,7 @@ var AgentRuntimeManager = class {
32714
32775
  return await this.#executionProcesses.use(options2.sessionId, async () => {
32715
32776
  this.#nativeOperations.add(key);
32716
32777
  try {
32717
- const runtime = await this.#startPreparation({ ...options2, origin });
32778
+ const runtime = await this.#startPreparation({ ...options2, origin }, { kind: "interactive-only" });
32718
32779
  const openedKey = `${options2.agent.id}:${runtime.nativeSessionId()}`;
32719
32780
  this.#nativeOperations.add(openedKey);
32720
32781
  try {
@@ -33394,6 +33455,7 @@ import {
33394
33455
  import { spawn as spawn3 } from "node:child_process";
33395
33456
 
33396
33457
  // src/acp/codex/app-server-protocol.ts
33458
+ import { isAbsolute as isAbsolute3 } from "node:path";
33397
33459
  var boundedText = (maximum) => external_exports.string().max(maximum);
33398
33460
  var jsonValue = external_exports.lazy(() => external_exports.unknown());
33399
33461
  var requestIdSchema = external_exports.union([external_exports.number(), external_exports.string()]).refine((value) => typeof value === "number" || value.length <= 256);
@@ -33464,6 +33526,7 @@ var imageGenerationItemSchema = external_exports.object({
33464
33526
  });
33465
33527
  var threadItemSchema = external_exports.discriminatedUnion("type", [
33466
33528
  imageGenerationItemSchema,
33529
+ external_exports.object({ type: external_exports.literal("imageView"), id: boundedText(256), path: boundedText(32768).refine(isAbsolute3) }),
33467
33530
  external_exports.object({
33468
33531
  id: boundedText(256),
33469
33532
  text: boundedText(1e6),
@@ -33888,6 +33951,7 @@ var CodexAppServerClient = class {
33888
33951
  };
33889
33952
 
33890
33953
  // src/acp/codex/items.ts
33954
+ import { pathToFileURL } from "node:url";
33891
33955
  var TOOL_OUTPUT_CHARACTER_LIMIT = 32768;
33892
33956
  var TITLE_CHARACTER_LIMIT = 500;
33893
33957
  function truncate4(value, limit) {
@@ -33909,6 +33973,14 @@ function textContent(text2) {
33909
33973
  const block = { text: truncate4(text2, TOOL_OUTPUT_CHARACTER_LIMIT), type: "text" };
33910
33974
  return { content: block, type: "content" };
33911
33975
  }
33976
+ function structuredToolText(value) {
33977
+ const result = external_exports.object({ content: external_exports.array(external_exports.unknown()) }).safeParse(value);
33978
+ const items = Array.isArray(value) ? value : result.success ? result.data.content : [];
33979
+ return items.flatMap((item) => {
33980
+ const text2 = external_exports.object({ type: external_exports.enum(["text", "inputText"]), text: external_exports.string() }).safeParse(item);
33981
+ return text2.success ? [textContent(text2.data.text)] : [];
33982
+ });
33983
+ }
33912
33984
  function firstLine(value) {
33913
33985
  const line = value.split("\n", 1)[0] ?? "";
33914
33986
  return line.trim().length > 0 ? line.trim() : value.trim();
@@ -33929,6 +34001,22 @@ function mcpStatus(status) {
33929
34001
  return status === "inProgress" ? "in_progress" : status === "completed" ? "completed" : "failed";
33930
34002
  }
33931
34003
  function presentToolItem(item) {
34004
+ if (item.type === "imageView") {
34005
+ return {
34006
+ content: [
34007
+ {
34008
+ type: "content",
34009
+ content: { type: "image", data: "", mimeType: "", uri: pathToFileURL(item.path).href }
34010
+ }
34011
+ ],
34012
+ kind: "read",
34013
+ locations: [{ path: item.path }],
34014
+ rawInput: { path: item.path },
34015
+ rawOutput: null,
34016
+ status: "completed",
34017
+ title: "View image"
34018
+ };
34019
+ }
33932
34020
  if (item.type === "imageGeneration") {
33933
34021
  const failed = item.failure != null || item.status === "failed";
33934
34022
  const content = [];
@@ -33993,13 +34081,7 @@ function presentToolItem(item) {
33993
34081
  }
33994
34082
  if (item.type === "mcpToolCall") {
33995
34083
  const label = `${item.server}/${item.tool}`;
33996
- const content = [];
33997
- if (item.result != null) {
33998
- content.push(textContent(JSON.stringify(item.result)));
33999
- }
34000
- if (item.error != null) {
34001
- content.push(textContent(JSON.stringify(item.error)));
34002
- }
34084
+ const content = structuredToolText(item.error ?? item.result);
34003
34085
  return {
34004
34086
  content,
34005
34087
  kind: "other",
@@ -34012,13 +34094,13 @@ function presentToolItem(item) {
34012
34094
  }
34013
34095
  if (item.type === "dynamicToolCall") {
34014
34096
  const label = item.namespace == null ? item.tool : `${item.namespace}/${item.tool}`;
34015
- const content = (item.contentItems ?? []).map((entry) => textContent(JSON.stringify(entry)));
34097
+ const content = structuredToolText(item.contentItems);
34016
34098
  return {
34017
34099
  content,
34018
34100
  kind: "other",
34019
34101
  locations: [],
34020
34102
  rawInput: item.arguments ?? null,
34021
- rawOutput: item.success === true ? null : item.contentItems ?? null,
34103
+ rawOutput: item.contentItems ?? null,
34022
34104
  status: mcpStatus(item.status),
34023
34105
  title: truncate4(label, TITLE_CHARACTER_LIMIT)
34024
34106
  };
@@ -34031,12 +34113,12 @@ function toolCallUpdate(item, lifecycle) {
34031
34113
  return null;
34032
34114
  }
34033
34115
  return {
34034
- content: [...presentation.content],
34116
+ content: item.type === "imageView" && lifecycle === "started" ? [] : [...presentation.content],
34035
34117
  kind: presentation.kind,
34036
34118
  locations: [...presentation.locations],
34037
34119
  rawInput: presentation.rawInput,
34038
34120
  rawOutput: presentation.rawOutput,
34039
- status: lifecycle === "completed" && presentation.status === "in_progress" ? "completed" : presentation.status,
34121
+ status: item.type === "imageView" && lifecycle === "started" ? "in_progress" : lifecycle === "completed" && presentation.status === "in_progress" ? "completed" : presentation.status,
34040
34122
  title: presentation.title,
34041
34123
  toolCallId: item.id
34042
34124
  };
@@ -35260,12 +35342,12 @@ var AgentProbeError = class extends Error {
35260
35342
  };
35261
35343
 
35262
35344
  // src/agent-catalog/agents/resolve-user-local-executable.ts
35263
- import { isAbsolute as isAbsolute3, join as join7 } from "node:path";
35345
+ import { isAbsolute as isAbsolute4, join as join7 } from "node:path";
35264
35346
  async function resolveUserLocalExecutable(executableName, context) {
35265
35347
  context.signal.throwIfAborted();
35266
35348
  const platform = context.platform ?? process.platform;
35267
35349
  const homeDirectory = context.environment["HOME"];
35268
- if (platform === "win32" || homeDirectory === void 0 || !isAbsolute3(homeDirectory)) {
35350
+ if (platform === "win32" || homeDirectory === void 0 || !isAbsolute4(homeDirectory)) {
35269
35351
  return [];
35270
35352
  }
35271
35353
  const executable = await resolveExecutablePath(join7(homeDirectory, ".local", "bin", executableName), platform);
@@ -35358,7 +35440,7 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
35358
35440
 
35359
35441
  // src/agent-catalog/agents/deepseek-harness-agent.ts
35360
35442
  import { mkdir as mkdir3, realpath as realpath5, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
35361
- import { isAbsolute as isAbsolute4, join as join8, normalize as normalize2 } from "node:path";
35443
+ import { isAbsolute as isAbsolute5, join as join8, normalize as normalize2 } from "node:path";
35362
35444
 
35363
35445
  // src/agent-installation/deepseek-managed-package.ts
35364
35446
  var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
@@ -35382,7 +35464,7 @@ var DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH = `# Managed by Mobius: pin the ACP brid
35382
35464
  model: deepseek-v4-flash-vision-exp
35383
35465
  `;
35384
35466
  async function prepareAgentHome(path2, imagePrompts) {
35385
- if (!isAbsolute4(path2) || normalize2(path2) !== path2) {
35467
+ if (!isAbsolute5(path2) || normalize2(path2) !== path2) {
35386
35468
  throw new AgentProbeError("agent_environment_invalid", "The configured Agent home is invalid");
35387
35469
  }
35388
35470
  try {
@@ -35514,7 +35596,7 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
35514
35596
 
35515
35597
  // src/agent-catalog/agents/grok-build-agent.ts
35516
35598
  import { realpath as realpath6 } from "node:fs/promises";
35517
- import { isAbsolute as isAbsolute5, join as join9, relative as relative2, sep as sep2 } from "node:path";
35599
+ import { isAbsolute as isAbsolute6, join as join9, relative as relative2, sep as sep2 } from "node:path";
35518
35600
  import {
35519
35601
  RequestError as RequestError2
35520
35602
  } from "@agentclientprotocol/sdk";
@@ -35580,7 +35662,7 @@ function grokBuildManagedPackage(platform, architecture) {
35580
35662
  // src/agent-catalog/agents/grok-build-agent.ts
35581
35663
  function isContainedPath2(root, candidate) {
35582
35664
  const difference = relative2(root, candidate);
35583
- return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !isAbsolute5(difference);
35665
+ return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !isAbsolute6(difference);
35584
35666
  }
35585
35667
  var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
35586
35668
  adapterVersion = GROK_BUILD_MANAGED_VERSION;
@@ -35729,7 +35811,7 @@ import { join as join11 } from "node:path";
35729
35811
  import { createHash as createHash2 } from "node:crypto";
35730
35812
  import { createReadStream } from "node:fs";
35731
35813
  import { chmod, copyFile, mkdir as mkdir4, mkdtemp as mkdtemp2, open as open4, realpath as realpath7, rename as rename3, rm as rm3, stat as stat6, writeFile as writeFile3 } from "node:fs/promises";
35732
- import { delimiter as delimiter2, dirname as dirname3, isAbsolute as isAbsolute6, join as join10, relative as relative3, sep as sep3 } from "node:path";
35814
+ import { delimiter as delimiter2, dirname as dirname3, isAbsolute as isAbsolute7, join as join10, relative as relative3, sep as sep3 } from "node:path";
35733
35815
 
35734
35816
  // src/agent-installation/verified-download.ts
35735
35817
  import { fetch } from "undici";
@@ -35835,7 +35917,7 @@ function isRecord8(value) {
35835
35917
  }
35836
35918
  function isContainedPath3(root, candidate) {
35837
35919
  const difference = relative3(root, candidate);
35838
- return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !isAbsolute6(difference);
35920
+ return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !isAbsolute7(difference);
35839
35921
  }
35840
35922
  async function hashFile(path2, signal) {
35841
35923
  signal.throwIfAborted();
@@ -36225,7 +36307,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
36225
36307
  };
36226
36308
 
36227
36309
  // src/agent-catalog/agents/workbuddy-agent.ts
36228
- import { isAbsolute as isAbsolute7, join as join13 } from "node:path";
36310
+ import { isAbsolute as isAbsolute8, join as join13 } from "node:path";
36229
36311
 
36230
36312
  // src/agent-installation/workbuddy-managed-package.ts
36231
36313
  var WORKBUDDY_MANAGED_VERSION = "2.146.0";
@@ -36293,7 +36375,7 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
36293
36375
  }
36294
36376
  const requestedPaths = [join13("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
36295
36377
  const homeDirectory = context.environment["HOME"];
36296
- if (homeDirectory !== void 0 && isAbsolute7(homeDirectory)) {
36378
+ if (homeDirectory !== void 0 && isAbsolute8(homeDirectory)) {
36297
36379
  requestedPaths.unshift(join13(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
36298
36380
  }
36299
36381
  const executables = [];
@@ -36629,7 +36711,7 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
36629
36711
  }
36630
36712
 
36631
36713
  // src/agent-catalog/executable-discovery.ts
36632
- import { isAbsolute as isAbsolute8, join as join15 } from "node:path";
36714
+ import { isAbsolute as isAbsolute9, join as join15 } from "node:path";
36633
36715
 
36634
36716
  // src/agent-installation/managed-adapter-installer.ts
36635
36717
  import { join as join14 } from "node:path";
@@ -36734,7 +36816,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
36734
36816
  async function resolveSpecificationExecutables(executableName, overrideVariable, resolveInstalled, resolveManaged, context) {
36735
36817
  const override = context.environment[overrideVariable];
36736
36818
  if (override !== void 0) {
36737
- if (override.length === 0 || !isAbsolute8(override)) {
36819
+ if (override.length === 0 || !isAbsolute9(override)) {
36738
36820
  return [];
36739
36821
  }
36740
36822
  const executable = await resolveExecutablePath(override, context.platform);
@@ -38451,7 +38533,7 @@ var FixedInstallationExecutor = class {
38451
38533
  // src/authorization/workspace-directory.ts
38452
38534
  import { readdir as readdir4, realpath as realpath9, stat as stat8 } from "node:fs/promises";
38453
38535
  import { homedir as homedir2 } from "node:os";
38454
- import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute9, join as join17, normalize as normalize3, relative as relative4 } from "node:path";
38536
+ import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute10, join as join17, normalize as normalize3, relative as relative4 } from "node:path";
38455
38537
  var WorkspaceDirectoryListing = class {
38456
38538
  directoryId;
38457
38539
  directoryLabel;
@@ -38507,7 +38589,7 @@ var WorkspaceDirectoryService = class {
38507
38589
  }
38508
38590
  if (id.startsWith("path-")) {
38509
38591
  const path2 = expandCurrentUserHome(decodePath(id, "path-"));
38510
- if (isAbsolute9(path2)) {
38592
+ if (isAbsolute10(path2)) {
38511
38593
  return path2;
38512
38594
  }
38513
38595
  }
@@ -38515,7 +38597,7 @@ var WorkspaceDirectoryService = class {
38515
38597
  };
38516
38598
  resolvePath = async (requested, signal) => {
38517
38599
  signal.throwIfAborted();
38518
- if (!isAbsolute9(requested) || requested.includes("\0") || normalize3(requested) !== requested) {
38600
+ if (!isAbsolute10(requested) || requested.includes("\0") || normalize3(requested) !== requested) {
38519
38601
  throw new LocalAuthorizationError("The local directory path is invalid");
38520
38602
  }
38521
38603
  try {
@@ -38523,7 +38605,7 @@ var WorkspaceDirectoryService = class {
38523
38605
  signal.throwIfAborted();
38524
38606
  const metadata = await stat8(target);
38525
38607
  signal.throwIfAborted();
38526
- if (!isAbsolute9(target) || normalize3(target) !== target || !metadata.isDirectory()) {
38608
+ if (!isAbsolute10(target) || normalize3(target) !== target || !metadata.isDirectory()) {
38527
38609
  throw new LocalAuthorizationError("The selected location is not a directory");
38528
38610
  }
38529
38611
  return target;
@@ -38539,7 +38621,7 @@ var WorkspaceDirectoryService = class {
38539
38621
  };
38540
38622
  label = (path2) => {
38541
38623
  const suffix = relative4(homedir2(), path2);
38542
- return suffix === "" ? "~" : !isAbsolute9(suffix) && suffix !== ".." && !suffix.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) ? `~/${suffix.replaceAll("\\", "/")}` : path2;
38624
+ return suffix === "" ? "~" : !isAbsolute10(suffix) && suffix !== ".." && !suffix.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) ? `~/${suffix.replaceAll("\\", "/")}` : path2;
38543
38625
  };
38544
38626
  identify = async (bindingId, requestedPath2, signal) => {
38545
38627
  this.authorizeMachine(bindingId);
@@ -41617,7 +41699,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
41617
41699
  // src/artifacts/local-file-streamer.ts
41618
41700
  import { createReadStream as createReadStream2 } from "node:fs";
41619
41701
  import { realpath as realpath10, stat as stat9 } from "node:fs/promises";
41620
- import { basename as basename5, isAbsolute as isAbsolute10, normalize as normalize4, resolve as resolve7 } from "node:path";
41702
+ import { basename as basename5, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve7 } from "node:path";
41621
41703
  import { fileURLToPath as fileURLToPath2 } from "node:url";
41622
41704
  var CHUNK_BYTES = 192 * 1024;
41623
41705
  function requestedPath(value) {
@@ -41636,17 +41718,17 @@ function requestedPath(value) {
41636
41718
  }
41637
41719
  async function resolveFile(value, workingDirectory, signal) {
41638
41720
  const path2 = requestedPath(value);
41639
- if (path2 === null || !isAbsolute10(path2) && workingDirectory === null) {
41721
+ if (path2 === null || !isAbsolute11(path2) && workingDirectory === null) {
41640
41722
  return null;
41641
41723
  }
41642
41724
  const requested = workingDirectory === null ? path2 : resolve7(workingDirectory, path2);
41643
- if (!isAbsolute10(requested) || isAbsolute10(path2) && normalize4(path2) !== path2) {
41725
+ if (!isAbsolute11(requested) || isAbsolute11(path2) && normalize4(path2) !== path2) {
41644
41726
  return null;
41645
41727
  }
41646
41728
  try {
41647
41729
  const target = await realpath10(requested);
41648
41730
  signal.throwIfAborted();
41649
- return isAbsolute10(target) && normalize4(target) === target ? target : null;
41731
+ return isAbsolute11(target) && normalize4(target) === target ? target : null;
41650
41732
  } catch {
41651
41733
  signal.throwIfAborted();
41652
41734
  return null;
@@ -42175,7 +42257,7 @@ async function executePrompt({
42175
42257
  }
42176
42258
 
42177
42259
  // src/daemon-session-commands.ts
42178
- async function prepareSession(command, config2, directories, audit, sessions, metrics, signal) {
42260
+ async function prepareSession(command, recovery, config2, directories, audit, sessions, metrics, signal) {
42179
42261
  return await metrics.measure("prepare-total", async () => {
42180
42262
  const resolved = await metrics.measure(
42181
42263
  "workspace-resolve",
@@ -42195,7 +42277,7 @@ async function prepareSession(command, config2, directories, audit, sessions, me
42195
42277
  sessionId: command.sessionId,
42196
42278
  signal
42197
42279
  };
42198
- const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
42280
+ const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : recovery.kind === "history-required" ? await sessions.restoreSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
42199
42281
  const configuration = command.configuration;
42200
42282
  const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
42201
42283
  "configuration",
@@ -42265,7 +42347,16 @@ async function executeWorkspaceList(socket, command, directories, audit, signal)
42265
42347
  async function executeSessionPrepare(socket, command, config2, directories, audit, sessions, diagnostics, signal) {
42266
42348
  const metrics = new AccumulatingOperationMetrics();
42267
42349
  try {
42268
- const readyEvent = await prepareSession(command, config2, directories, audit, sessions, metrics, signal);
42350
+ const readyEvent = await prepareSession(
42351
+ command,
42352
+ { kind: "interactive-only" },
42353
+ config2,
42354
+ directories,
42355
+ audit,
42356
+ sessions,
42357
+ metrics,
42358
+ signal
42359
+ );
42269
42360
  send(socket, {
42270
42361
  ...readyEvent,
42271
42362
  runtimeTimings: metrics.snapshot()
@@ -42314,6 +42405,7 @@ async function executeSessionRestore(socket, command, config2, directories, audi
42314
42405
  sessionId: command.sessionId,
42315
42406
  sessionState: "provisioned"
42316
42407
  },
42408
+ { kind: "history-required" },
42317
42409
  config2,
42318
42410
  directories,
42319
42411
  audit,