@moxt-ai/mobius 0.0.181 → 0.0.183

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/index.js CHANGED
@@ -19791,6 +19791,8 @@ var SESSION_LIST_KIND = "session.list";
19791
19791
  var SESSION_LISTED_KIND = "session.listed";
19792
19792
  var SESSION_QUERY_KIND = "session.query";
19793
19793
  var SESSION_QUERIED_KIND = "session.queried";
19794
+ var SESSION_RESTORE_KIND = "session.restore";
19795
+ var SESSION_RESTORED_KIND = "session.restored";
19794
19796
  var SESSION_STATUS_CHANGED_KIND = "session.status.changed";
19795
19797
  var SESSION_CONFIGURE_KIND = "session.configure";
19796
19798
  var SESSION_CONFIG_UPDATED_KIND = "session.config.updated";
@@ -19871,6 +19873,11 @@ var sessionsQueriedEventSchema = external_exports.object({
19871
19873
  kind: external_exports.literal(SESSION_QUERIED_KIND),
19872
19874
  requestId: identifierStringSchema
19873
19875
  }).readonly();
19876
+ var sessionRestoreCommandSchema = external_exports.object({
19877
+ kind: external_exports.literal(SESSION_RESTORE_KIND),
19878
+ requestId: identifierStringSchema,
19879
+ sessionId: identifierStringSchema
19880
+ }).readonly();
19874
19881
  var fileReadCommandSchema = external_exports.object({
19875
19882
  kind: external_exports.literal(FILE_READ_KIND),
19876
19883
  maxBytes: external_exports.number().int().positive().max(128 * 1024 * 1024),
@@ -20185,6 +20192,12 @@ var sessionReadyEventSchema = external_exports.object({
20185
20192
  runtimeTimings: runtimeTimingsSchema.optional(),
20186
20193
  sessionId: identifierStringSchema
20187
20194
  }).readonly();
20195
+ var sessionRestoredEventSchema = external_exports.object({
20196
+ entry: sessionMetadataSchema,
20197
+ kind: external_exports.literal(SESSION_RESTORED_KIND),
20198
+ ready: sessionReadyEventSchema,
20199
+ requestId: identifierStringSchema
20200
+ }).readonly();
20188
20201
  var sessionConfigureCommandSchema = external_exports.object({
20189
20202
  ...sessionIdentityFields,
20190
20203
  booleanValue: external_exports.boolean(),
@@ -20400,6 +20413,10 @@ var decodeSessionQueryCommand = (encoded) => decode3(encoded, sessionQueryComman
20400
20413
  var encodeSessionQueryCommand = (message) => encode3(message, sessionQueryCommandSchema);
20401
20414
  var decodeSessionsQueriedEvent = (encoded) => decode3(encoded, sessionsQueriedEventSchema);
20402
20415
  var encodeSessionsQueriedEvent = (message) => encode3(message, sessionsQueriedEventSchema);
20416
+ var decodeSessionRestoreCommand = (encoded) => decode3(encoded, sessionRestoreCommandSchema);
20417
+ var encodeSessionRestoreCommand = (message) => encode3(message, sessionRestoreCommandSchema);
20418
+ var decodeSessionRestoredEvent = (encoded) => decode3(encoded, sessionRestoredEventSchema);
20419
+ var encodeSessionRestoredEvent = (message) => encode3(message, sessionRestoredEventSchema);
20403
20420
  var decodeSessionStatusChangedEvent = (encoded) => decode3(encoded, sessionStatusChangedEventSchema);
20404
20421
  var encodeSessionStatusChangedEvent = (message) => encode3(message, sessionStatusChangedEventSchema);
20405
20422
  var decodeSessionPrepareCommand = (encoded) => decode3(encoded, sessionPrepareCommandSchema);
@@ -21482,6 +21499,11 @@ var serviceToDaemonSignatures = {
21482
21499
  encodeSessionQueryCommand,
21483
21500
  decodeSessionQueryCommand
21484
21501
  ),
21502
+ [SESSION_RESTORE_KIND]: defineMessageSignature(
21503
+ SESSION_RESTORE_KIND,
21504
+ encodeSessionRestoreCommand,
21505
+ decodeSessionRestoreCommand
21506
+ ),
21485
21507
  [NATIVE_SESSION_CANCEL_KIND]: defineMessageSignature(
21486
21508
  NATIVE_SESSION_CANCEL_KIND,
21487
21509
  encodeNativeSessionCancel,
@@ -21613,6 +21635,11 @@ var daemonToServiceSignatures = {
21613
21635
  encodeSessionsQueriedEvent,
21614
21636
  decodeSessionsQueriedEvent
21615
21637
  ),
21638
+ [SESSION_RESTORED_KIND]: defineMessageSignature(
21639
+ SESSION_RESTORED_KIND,
21640
+ encodeSessionRestoredEvent,
21641
+ decodeSessionRestoredEvent
21642
+ ),
21616
21643
  [SESSION_STATUS_CHANGED_KIND]: defineMessageSignature(
21617
21644
  SESSION_STATUS_CHANGED_KIND,
21618
21645
  encodeSessionStatusChangedEvent,
@@ -31492,6 +31519,24 @@ var embeddedImageSchema = external_exports.looseObject({
31492
31519
  data: external_exports.string(),
31493
31520
  mimeType: external_exports.string()
31494
31521
  });
31522
+ var inlineImageUrlSchema = external_exports.string().regex(/^data:image\/(?:png|jpeg|gif|webp);base64,/u).transform((url2) => ({
31523
+ type: "image",
31524
+ data: url2.slice(url2.indexOf(",") + 1),
31525
+ mimeType: url2.slice(5, url2.indexOf(";"))
31526
+ }));
31527
+ var toolImageSchema = external_exports.union([
31528
+ embeddedImageSchema,
31529
+ 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),
31530
+ external_exports.object({ type: external_exports.literal("inputImage"), imageUrl: inlineImageUrlSchema }).transform(({ imageUrl }) => imageUrl),
31531
+ external_exports.object({
31532
+ type: external_exports.literal("image"),
31533
+ source: external_exports.object({ type: external_exports.literal("base64"), data: external_exports.string(), media_type: external_exports.string() })
31534
+ }).transform(({ source }) => ({ type: "image", data: source.data, mimeType: source.media_type })),
31535
+ external_exports.object({
31536
+ type: external_exports.literal("image"),
31537
+ file: external_exports.object({ base64: external_exports.string(), type: external_exports.string() })
31538
+ }).transform(({ file: file2 }) => ({ type: "image", data: file2.base64, mimeType: file2.type }))
31539
+ ]);
31495
31540
  function isRecord6(value) {
31496
31541
  return typeof value === "object" && value !== null && !Array.isArray(value);
31497
31542
  }
@@ -31611,7 +31656,7 @@ var AcpContentExternalizer = class {
31611
31656
  if (!isRecord6(value)) {
31612
31657
  return value;
31613
31658
  }
31614
- const image = embeddedImageSchema.safeParse(value);
31659
+ const image = toolImageSchema.safeParse(value);
31615
31660
  if (image.success && image.data.data.length > 0) {
31616
31661
  const prepared = await this.#content(sessionId, image.data, signal);
31617
31662
  if (isRecord6(prepared.event) && typeof prepared.event["imageKey"] === "string") {
@@ -31630,6 +31675,7 @@ var AcpContentExternalizer = class {
31630
31675
  async #toolUpdate(sessionId, update, signal) {
31631
31676
  const images = /* @__PURE__ */ new Map();
31632
31677
  const rawOutput = update.rawOutput === void 0 ? void 0 : await this.#rawOutput(sessionId, update.rawOutput, images, signal);
31678
+ 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));
31633
31679
  const originalJson = images.size === 0 ? void 0 : JSON.stringify(update.rawOutput);
31634
31680
  const rewrittenJson = images.size === 0 ? void 0 : JSON.stringify(rawOutput);
31635
31681
  const agentContent = [];
@@ -31653,10 +31699,11 @@ var AcpContentExternalizer = class {
31653
31699
  eventContent.push({ type: "content", content: prepared.event });
31654
31700
  }
31655
31701
  const output2 = update.rawOutput === void 0 ? {} : { rawOutput };
31702
+ const meta3 = metadata === void 0 ? {} : { _meta: metadata };
31656
31703
  const hasContent = update.content !== void 0 && update.content !== null || agentContent.length > 0;
31657
31704
  return {
31658
- agent: { ...update, ...output2, ...hasContent ? { content: agentContent } : {} },
31659
- event: { ...update, ...output2, ...hasContent ? { content: eventContent } : {} }
31705
+ agent: { ...update, ...meta3, ...output2, ...hasContent ? { content: agentContent } : {} },
31706
+ event: { ...update, ...meta3, ...output2, ...hasContent ? { content: eventContent } : {} }
31660
31707
  };
31661
31708
  }
31662
31709
  update = async (sessionId, update, signal) => {
@@ -33354,6 +33401,7 @@ import {
33354
33401
  import { spawn as spawn3 } from "node:child_process";
33355
33402
 
33356
33403
  // src/acp/codex/app-server-protocol.ts
33404
+ import { isAbsolute as isAbsolute3 } from "node:path";
33357
33405
  var boundedText = (maximum) => external_exports.string().max(maximum);
33358
33406
  var jsonValue = external_exports.lazy(() => external_exports.unknown());
33359
33407
  var requestIdSchema = external_exports.union([external_exports.number(), external_exports.string()]).refine((value) => typeof value === "number" || value.length <= 256);
@@ -33424,6 +33472,7 @@ var imageGenerationItemSchema = external_exports.object({
33424
33472
  });
33425
33473
  var threadItemSchema = external_exports.discriminatedUnion("type", [
33426
33474
  imageGenerationItemSchema,
33475
+ external_exports.object({ type: external_exports.literal("imageView"), id: boundedText(256), path: boundedText(32768).refine(isAbsolute3) }),
33427
33476
  external_exports.object({
33428
33477
  id: boundedText(256),
33429
33478
  text: boundedText(1e6),
@@ -33848,6 +33897,7 @@ var CodexAppServerClient = class {
33848
33897
  };
33849
33898
 
33850
33899
  // src/acp/codex/items.ts
33900
+ import { pathToFileURL } from "node:url";
33851
33901
  var TOOL_OUTPUT_CHARACTER_LIMIT = 32768;
33852
33902
  var TITLE_CHARACTER_LIMIT = 500;
33853
33903
  function truncate4(value, limit) {
@@ -33869,6 +33919,14 @@ function textContent(text2) {
33869
33919
  const block = { text: truncate4(text2, TOOL_OUTPUT_CHARACTER_LIMIT), type: "text" };
33870
33920
  return { content: block, type: "content" };
33871
33921
  }
33922
+ function structuredToolText(value) {
33923
+ const result = external_exports.object({ content: external_exports.array(external_exports.unknown()) }).safeParse(value);
33924
+ const items = Array.isArray(value) ? value : result.success ? result.data.content : [];
33925
+ return items.flatMap((item) => {
33926
+ const text2 = external_exports.object({ type: external_exports.enum(["text", "inputText"]), text: external_exports.string() }).safeParse(item);
33927
+ return text2.success ? [textContent(text2.data.text)] : [];
33928
+ });
33929
+ }
33872
33930
  function firstLine(value) {
33873
33931
  const line = value.split("\n", 1)[0] ?? "";
33874
33932
  return line.trim().length > 0 ? line.trim() : value.trim();
@@ -33889,6 +33947,22 @@ function mcpStatus(status) {
33889
33947
  return status === "inProgress" ? "in_progress" : status === "completed" ? "completed" : "failed";
33890
33948
  }
33891
33949
  function presentToolItem(item) {
33950
+ if (item.type === "imageView") {
33951
+ return {
33952
+ content: [
33953
+ {
33954
+ type: "content",
33955
+ content: { type: "image", data: "", mimeType: "", uri: pathToFileURL(item.path).href }
33956
+ }
33957
+ ],
33958
+ kind: "read",
33959
+ locations: [{ path: item.path }],
33960
+ rawInput: { path: item.path },
33961
+ rawOutput: null,
33962
+ status: "completed",
33963
+ title: "View image"
33964
+ };
33965
+ }
33892
33966
  if (item.type === "imageGeneration") {
33893
33967
  const failed = item.failure != null || item.status === "failed";
33894
33968
  const content = [];
@@ -33953,13 +34027,7 @@ function presentToolItem(item) {
33953
34027
  }
33954
34028
  if (item.type === "mcpToolCall") {
33955
34029
  const label = `${item.server}/${item.tool}`;
33956
- const content = [];
33957
- if (item.result != null) {
33958
- content.push(textContent(JSON.stringify(item.result)));
33959
- }
33960
- if (item.error != null) {
33961
- content.push(textContent(JSON.stringify(item.error)));
33962
- }
34030
+ const content = structuredToolText(item.error ?? item.result);
33963
34031
  return {
33964
34032
  content,
33965
34033
  kind: "other",
@@ -33972,13 +34040,13 @@ function presentToolItem(item) {
33972
34040
  }
33973
34041
  if (item.type === "dynamicToolCall") {
33974
34042
  const label = item.namespace == null ? item.tool : `${item.namespace}/${item.tool}`;
33975
- const content = (item.contentItems ?? []).map((entry) => textContent(JSON.stringify(entry)));
34043
+ const content = structuredToolText(item.contentItems);
33976
34044
  return {
33977
34045
  content,
33978
34046
  kind: "other",
33979
34047
  locations: [],
33980
34048
  rawInput: item.arguments ?? null,
33981
- rawOutput: item.success === true ? null : item.contentItems ?? null,
34049
+ rawOutput: item.contentItems ?? null,
33982
34050
  status: mcpStatus(item.status),
33983
34051
  title: truncate4(label, TITLE_CHARACTER_LIMIT)
33984
34052
  };
@@ -33991,12 +34059,12 @@ function toolCallUpdate(item, lifecycle) {
33991
34059
  return null;
33992
34060
  }
33993
34061
  return {
33994
- content: [...presentation.content],
34062
+ content: item.type === "imageView" && lifecycle === "started" ? [] : [...presentation.content],
33995
34063
  kind: presentation.kind,
33996
34064
  locations: [...presentation.locations],
33997
34065
  rawInput: presentation.rawInput,
33998
34066
  rawOutput: presentation.rawOutput,
33999
- status: lifecycle === "completed" && presentation.status === "in_progress" ? "completed" : presentation.status,
34067
+ status: item.type === "imageView" && lifecycle === "started" ? "in_progress" : lifecycle === "completed" && presentation.status === "in_progress" ? "completed" : presentation.status,
34000
34068
  title: presentation.title,
34001
34069
  toolCallId: item.id
34002
34070
  };
@@ -35220,12 +35288,12 @@ var AgentProbeError = class extends Error {
35220
35288
  };
35221
35289
 
35222
35290
  // src/agent-catalog/agents/resolve-user-local-executable.ts
35223
- import { isAbsolute as isAbsolute3, join as join7 } from "node:path";
35291
+ import { isAbsolute as isAbsolute4, join as join7 } from "node:path";
35224
35292
  async function resolveUserLocalExecutable(executableName, context) {
35225
35293
  context.signal.throwIfAborted();
35226
35294
  const platform = context.platform ?? process.platform;
35227
35295
  const homeDirectory = context.environment["HOME"];
35228
- if (platform === "win32" || homeDirectory === void 0 || !isAbsolute3(homeDirectory)) {
35296
+ if (platform === "win32" || homeDirectory === void 0 || !isAbsolute4(homeDirectory)) {
35229
35297
  return [];
35230
35298
  }
35231
35299
  const executable = await resolveExecutablePath(join7(homeDirectory, ".local", "bin", executableName), platform);
@@ -35318,7 +35386,7 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
35318
35386
 
35319
35387
  // src/agent-catalog/agents/deepseek-harness-agent.ts
35320
35388
  import { mkdir as mkdir3, realpath as realpath5, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
35321
- import { isAbsolute as isAbsolute4, join as join8, normalize as normalize2 } from "node:path";
35389
+ import { isAbsolute as isAbsolute5, join as join8, normalize as normalize2 } from "node:path";
35322
35390
 
35323
35391
  // src/agent-installation/deepseek-managed-package.ts
35324
35392
  var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
@@ -35342,7 +35410,7 @@ var DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH = `# Managed by Mobius: pin the ACP brid
35342
35410
  model: deepseek-v4-flash-vision-exp
35343
35411
  `;
35344
35412
  async function prepareAgentHome(path2, imagePrompts) {
35345
- if (!isAbsolute4(path2) || normalize2(path2) !== path2) {
35413
+ if (!isAbsolute5(path2) || normalize2(path2) !== path2) {
35346
35414
  throw new AgentProbeError("agent_environment_invalid", "The configured Agent home is invalid");
35347
35415
  }
35348
35416
  try {
@@ -35474,7 +35542,7 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
35474
35542
 
35475
35543
  // src/agent-catalog/agents/grok-build-agent.ts
35476
35544
  import { realpath as realpath6 } from "node:fs/promises";
35477
- import { isAbsolute as isAbsolute5, join as join9, relative as relative2, sep as sep2 } from "node:path";
35545
+ import { isAbsolute as isAbsolute6, join as join9, relative as relative2, sep as sep2 } from "node:path";
35478
35546
  import {
35479
35547
  RequestError as RequestError2
35480
35548
  } from "@agentclientprotocol/sdk";
@@ -35540,7 +35608,7 @@ function grokBuildManagedPackage(platform, architecture) {
35540
35608
  // src/agent-catalog/agents/grok-build-agent.ts
35541
35609
  function isContainedPath2(root, candidate) {
35542
35610
  const difference = relative2(root, candidate);
35543
- return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !isAbsolute5(difference);
35611
+ return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !isAbsolute6(difference);
35544
35612
  }
35545
35613
  var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
35546
35614
  adapterVersion = GROK_BUILD_MANAGED_VERSION;
@@ -35689,7 +35757,7 @@ import { join as join11 } from "node:path";
35689
35757
  import { createHash as createHash2 } from "node:crypto";
35690
35758
  import { createReadStream } from "node:fs";
35691
35759
  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";
35692
- import { delimiter as delimiter2, dirname as dirname3, isAbsolute as isAbsolute6, join as join10, relative as relative3, sep as sep3 } from "node:path";
35760
+ import { delimiter as delimiter2, dirname as dirname3, isAbsolute as isAbsolute7, join as join10, relative as relative3, sep as sep3 } from "node:path";
35693
35761
 
35694
35762
  // src/agent-installation/verified-download.ts
35695
35763
  import { fetch } from "undici";
@@ -35795,7 +35863,7 @@ function isRecord8(value) {
35795
35863
  }
35796
35864
  function isContainedPath3(root, candidate) {
35797
35865
  const difference = relative3(root, candidate);
35798
- return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !isAbsolute6(difference);
35866
+ return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !isAbsolute7(difference);
35799
35867
  }
35800
35868
  async function hashFile(path2, signal) {
35801
35869
  signal.throwIfAborted();
@@ -36185,7 +36253,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
36185
36253
  };
36186
36254
 
36187
36255
  // src/agent-catalog/agents/workbuddy-agent.ts
36188
- import { isAbsolute as isAbsolute7, join as join13 } from "node:path";
36256
+ import { isAbsolute as isAbsolute8, join as join13 } from "node:path";
36189
36257
 
36190
36258
  // src/agent-installation/workbuddy-managed-package.ts
36191
36259
  var WORKBUDDY_MANAGED_VERSION = "2.146.0";
@@ -36253,7 +36321,7 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
36253
36321
  }
36254
36322
  const requestedPaths = [join13("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
36255
36323
  const homeDirectory = context.environment["HOME"];
36256
- if (homeDirectory !== void 0 && isAbsolute7(homeDirectory)) {
36324
+ if (homeDirectory !== void 0 && isAbsolute8(homeDirectory)) {
36257
36325
  requestedPaths.unshift(join13(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
36258
36326
  }
36259
36327
  const executables = [];
@@ -36589,7 +36657,7 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
36589
36657
  }
36590
36658
 
36591
36659
  // src/agent-catalog/executable-discovery.ts
36592
- import { isAbsolute as isAbsolute8, join as join15 } from "node:path";
36660
+ import { isAbsolute as isAbsolute9, join as join15 } from "node:path";
36593
36661
 
36594
36662
  // src/agent-installation/managed-adapter-installer.ts
36595
36663
  import { join as join14 } from "node:path";
@@ -36694,7 +36762,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
36694
36762
  async function resolveSpecificationExecutables(executableName, overrideVariable, resolveInstalled, resolveManaged, context) {
36695
36763
  const override = context.environment[overrideVariable];
36696
36764
  if (override !== void 0) {
36697
- if (override.length === 0 || !isAbsolute8(override)) {
36765
+ if (override.length === 0 || !isAbsolute9(override)) {
36698
36766
  return [];
36699
36767
  }
36700
36768
  const executable = await resolveExecutablePath(override, context.platform);
@@ -38411,7 +38479,7 @@ var FixedInstallationExecutor = class {
38411
38479
  // src/authorization/workspace-directory.ts
38412
38480
  import { readdir as readdir4, realpath as realpath9, stat as stat8 } from "node:fs/promises";
38413
38481
  import { homedir as homedir2 } from "node:os";
38414
- import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute9, join as join17, normalize as normalize3, relative as relative4 } from "node:path";
38482
+ import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute10, join as join17, normalize as normalize3, relative as relative4 } from "node:path";
38415
38483
  var WorkspaceDirectoryListing = class {
38416
38484
  directoryId;
38417
38485
  directoryLabel;
@@ -38467,7 +38535,7 @@ var WorkspaceDirectoryService = class {
38467
38535
  }
38468
38536
  if (id.startsWith("path-")) {
38469
38537
  const path2 = expandCurrentUserHome(decodePath(id, "path-"));
38470
- if (isAbsolute9(path2)) {
38538
+ if (isAbsolute10(path2)) {
38471
38539
  return path2;
38472
38540
  }
38473
38541
  }
@@ -38475,7 +38543,7 @@ var WorkspaceDirectoryService = class {
38475
38543
  };
38476
38544
  resolvePath = async (requested, signal) => {
38477
38545
  signal.throwIfAborted();
38478
- if (!isAbsolute9(requested) || requested.includes("\0") || normalize3(requested) !== requested) {
38546
+ if (!isAbsolute10(requested) || requested.includes("\0") || normalize3(requested) !== requested) {
38479
38547
  throw new LocalAuthorizationError("The local directory path is invalid");
38480
38548
  }
38481
38549
  try {
@@ -38483,7 +38551,7 @@ var WorkspaceDirectoryService = class {
38483
38551
  signal.throwIfAborted();
38484
38552
  const metadata = await stat8(target);
38485
38553
  signal.throwIfAborted();
38486
- if (!isAbsolute9(target) || normalize3(target) !== target || !metadata.isDirectory()) {
38554
+ if (!isAbsolute10(target) || normalize3(target) !== target || !metadata.isDirectory()) {
38487
38555
  throw new LocalAuthorizationError("The selected location is not a directory");
38488
38556
  }
38489
38557
  return target;
@@ -38499,7 +38567,7 @@ var WorkspaceDirectoryService = class {
38499
38567
  };
38500
38568
  label = (path2) => {
38501
38569
  const suffix = relative4(homedir2(), path2);
38502
- return suffix === "" ? "~" : !isAbsolute9(suffix) && suffix !== ".." && !suffix.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) ? `~/${suffix.replaceAll("\\", "/")}` : path2;
38570
+ return suffix === "" ? "~" : !isAbsolute10(suffix) && suffix !== ".." && !suffix.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) ? `~/${suffix.replaceAll("\\", "/")}` : path2;
38503
38571
  };
38504
38572
  identify = async (bindingId, requestedPath2, signal) => {
38505
38573
  this.authorizeMachine(bindingId);
@@ -41577,7 +41645,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
41577
41645
  // src/artifacts/local-file-streamer.ts
41578
41646
  import { createReadStream as createReadStream2 } from "node:fs";
41579
41647
  import { realpath as realpath10, stat as stat9 } from "node:fs/promises";
41580
- import { basename as basename5, isAbsolute as isAbsolute10, normalize as normalize4, resolve as resolve7 } from "node:path";
41648
+ import { basename as basename5, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve7 } from "node:path";
41581
41649
  import { fileURLToPath as fileURLToPath2 } from "node:url";
41582
41650
  var CHUNK_BYTES = 192 * 1024;
41583
41651
  function requestedPath(value) {
@@ -41596,17 +41664,17 @@ function requestedPath(value) {
41596
41664
  }
41597
41665
  async function resolveFile(value, workingDirectory, signal) {
41598
41666
  const path2 = requestedPath(value);
41599
- if (path2 === null || !isAbsolute10(path2) && workingDirectory === null) {
41667
+ if (path2 === null || !isAbsolute11(path2) && workingDirectory === null) {
41600
41668
  return null;
41601
41669
  }
41602
41670
  const requested = workingDirectory === null ? path2 : resolve7(workingDirectory, path2);
41603
- if (!isAbsolute10(requested) || isAbsolute10(path2) && normalize4(path2) !== path2) {
41671
+ if (!isAbsolute11(requested) || isAbsolute11(path2) && normalize4(path2) !== path2) {
41604
41672
  return null;
41605
41673
  }
41606
41674
  try {
41607
41675
  const target = await realpath10(requested);
41608
41676
  signal.throwIfAborted();
41609
- return isAbsolute10(target) && normalize4(target) === target ? target : null;
41677
+ return isAbsolute11(target) && normalize4(target) === target ? target : null;
41610
41678
  } catch {
41611
41679
  signal.throwIfAborted();
41612
41680
  return null;
@@ -42135,6 +42203,72 @@ async function executePrompt({
42135
42203
  }
42136
42204
 
42137
42205
  // src/daemon-session-commands.ts
42206
+ async function prepareSession(command, config2, directories, audit, sessions, metrics, signal) {
42207
+ return await metrics.measure("prepare-total", async () => {
42208
+ const resolved = await metrics.measure(
42209
+ "workspace-resolve",
42210
+ async () => await resolveSessionDirectories(
42211
+ directories,
42212
+ config2.bindingId,
42213
+ command.directoryId,
42214
+ command.additionalDirectoryIds,
42215
+ signal
42216
+ )
42217
+ );
42218
+ const agent = config2.catalog.find(command.agentId);
42219
+ const preparation = {
42220
+ additionalDirectories: resolved.additionalDirectories,
42221
+ agent,
42222
+ cwd: resolved.cwd,
42223
+ sessionId: command.sessionId,
42224
+ signal
42225
+ };
42226
+ const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
42227
+ const configuration = command.configuration;
42228
+ const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
42229
+ "configuration",
42230
+ async () => await sessions.configureSession({
42231
+ ...preparation,
42232
+ booleanValue: configuration.booleanValue,
42233
+ configId: configuration.configId,
42234
+ requestId: command.requestId,
42235
+ value: configuration.value,
42236
+ valueType: configuration.valueType
42237
+ })
42238
+ );
42239
+ const listing = await metrics.measure(
42240
+ "workspace-list",
42241
+ async () => await directories.list(config2.bindingId, command.directoryId, signal)
42242
+ );
42243
+ audit.record({
42244
+ commandId: command.requestId,
42245
+ event: "session_prepared",
42246
+ sessionId: command.sessionId
42247
+ });
42248
+ if (command.configuration !== void 0) {
42249
+ audit.record({
42250
+ commandId: command.requestId,
42251
+ event: "session_configured",
42252
+ sessionId: command.sessionId
42253
+ });
42254
+ }
42255
+ return {
42256
+ additionalDirectories: resolved.additionalDirectoryEntries,
42257
+ agentId: command.agentId,
42258
+ agentName: prepared.agentName,
42259
+ agentVersion: prepared.agentVersion,
42260
+ capabilities: prepared.capabilities,
42261
+ commands: prepared.commands,
42262
+ configOptions,
42263
+ directoryId: command.directoryId,
42264
+ directoryLabel: listing.directoryLabel,
42265
+ kind: "session.ready",
42266
+ requestId: command.requestId,
42267
+ restored: prepared.restored,
42268
+ sessionId: command.sessionId
42269
+ };
42270
+ });
42271
+ }
42138
42272
  async function executeWorkspaceList(socket, command, directories, audit, signal) {
42139
42273
  try {
42140
42274
  const listing = await directories.list(command.bindingId, command.directoryId, signal);
@@ -42159,72 +42293,7 @@ async function executeWorkspaceList(socket, command, directories, audit, signal)
42159
42293
  async function executeSessionPrepare(socket, command, config2, directories, audit, sessions, diagnostics, signal) {
42160
42294
  const metrics = new AccumulatingOperationMetrics();
42161
42295
  try {
42162
- const readyEvent = await metrics.measure("prepare-total", async () => {
42163
- const resolved = await metrics.measure(
42164
- "workspace-resolve",
42165
- async () => await resolveSessionDirectories(
42166
- directories,
42167
- config2.bindingId,
42168
- command.directoryId,
42169
- command.additionalDirectoryIds,
42170
- signal
42171
- )
42172
- );
42173
- const agent = config2.catalog.find(command.agentId);
42174
- const preparation = {
42175
- additionalDirectories: resolved.additionalDirectories,
42176
- agent,
42177
- cwd: resolved.cwd,
42178
- sessionId: command.sessionId,
42179
- signal
42180
- };
42181
- const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
42182
- const configuration = command.configuration;
42183
- const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
42184
- "configuration",
42185
- async () => await sessions.configureSession({
42186
- ...preparation,
42187
- booleanValue: configuration.booleanValue,
42188
- configId: configuration.configId,
42189
- requestId: command.requestId,
42190
- value: configuration.value,
42191
- valueType: configuration.valueType
42192
- })
42193
- );
42194
- const listing = await metrics.measure(
42195
- "workspace-list",
42196
- async () => await directories.list(config2.bindingId, command.directoryId, signal)
42197
- );
42198
- audit.record({
42199
- commandId: command.requestId,
42200
- event: "session_prepared",
42201
- sessionId: command.sessionId
42202
- });
42203
- if (command.configuration !== void 0) {
42204
- audit.record({
42205
- commandId: command.requestId,
42206
- event: "session_configured",
42207
- sessionId: command.sessionId
42208
- });
42209
- }
42210
- const event = {
42211
- additionalDirectories: resolved.additionalDirectoryEntries,
42212
- agentId: command.agentId,
42213
- agentName: prepared.agentName,
42214
- agentVersion: prepared.agentVersion,
42215
- capabilities: prepared.capabilities,
42216
- commands: prepared.commands,
42217
- configOptions,
42218
- directoryId: command.directoryId,
42219
- directoryLabel: listing.directoryLabel,
42220
- kind: "session.ready",
42221
- requestId: command.requestId,
42222
- restored: prepared.restored,
42223
- sessionId: command.sessionId,
42224
- runtimeTimings: metrics.snapshot()
42225
- };
42226
- return event;
42227
- });
42296
+ const readyEvent = await prepareSession(command, config2, directories, audit, sessions, metrics, signal);
42228
42297
  send(socket, {
42229
42298
  ...readyEvent,
42230
42299
  runtimeTimings: metrics.snapshot()
@@ -42252,6 +42321,59 @@ async function executeSessionPrepare(socket, command, config2, directories, audi
42252
42321
  reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
42253
42322
  }
42254
42323
  }
42324
+ async function executeSessionRestore(socket, command, config2, directories, audit, sessions, nativeSessions, diagnostics, signal) {
42325
+ const metrics = new AccumulatingOperationMetrics();
42326
+ try {
42327
+ const entry = await metrics.measure("session-lookup", async () => {
42328
+ const [found] = await nativeSessions.querySessions([command.sessionId], signal);
42329
+ if (found === void 0) {
42330
+ throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
42331
+ }
42332
+ return found;
42333
+ });
42334
+ const ready = await prepareSession(
42335
+ {
42336
+ additionalDirectoryIds: entry.additionalDirectories.map((directory) => directory.directoryId),
42337
+ agentId: entry.agentId,
42338
+ bindingId: config2.bindingId,
42339
+ directoryId: entry.directoryId,
42340
+ kind: "session.prepare",
42341
+ requestId: command.requestId,
42342
+ sessionId: command.sessionId,
42343
+ sessionState: "provisioned"
42344
+ },
42345
+ config2,
42346
+ directories,
42347
+ audit,
42348
+ sessions,
42349
+ metrics,
42350
+ signal
42351
+ );
42352
+ send(socket, {
42353
+ entry,
42354
+ kind: "session.restored",
42355
+ ready: { ...ready, runtimeTimings: metrics.snapshot() },
42356
+ requestId: command.requestId
42357
+ });
42358
+ } catch (error62) {
42359
+ diagnostics.daemonDiagnostic(
42360
+ "session_restore_failed",
42361
+ command.requestId,
42362
+ {
42363
+ code: operationErrorCode(error62),
42364
+ sessionId: command.sessionId
42365
+ },
42366
+ error62
42367
+ );
42368
+ audit.record({
42369
+ commandId: command.requestId,
42370
+ details: { code: operationErrorCode(error62) },
42371
+ event: "session_restore_failed",
42372
+ sessionId: command.sessionId
42373
+ });
42374
+ reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
42375
+ }
42376
+ }
42255
42377
  async function executeSessionConfigure(socket, command, config2, directories, audit, sessions, signal) {
42256
42378
  try {
42257
42379
  const resolved = await resolveSessionDirectories(
@@ -42565,6 +42687,21 @@ function createDaemonCommandHandler({
42565
42687
  });
42566
42688
  return;
42567
42689
  }
42690
+ if (kind === SESSION_RESTORE_KIND) {
42691
+ const command2 = message;
42692
+ void executeSessionRestore(
42693
+ socket,
42694
+ command2,
42695
+ config2,
42696
+ directories,
42697
+ audit,
42698
+ sessions,
42699
+ nativeSessions,
42700
+ diagnostics,
42701
+ signal
42702
+ );
42703
+ return;
42704
+ }
42568
42705
  if (kind === SESSION_PERMISSION_RESPOND_KIND) {
42569
42706
  const command2 = message;
42570
42707
  void sessions.respondPermission(command2).then(() => {