@agentconnect.md/codex-acp 2.1.0-agentconnect.1 → 2.1.1-agentconnect.1

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 (2) hide show
  1. package/dist/index.js +104 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7266,7 +7266,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
7266
7266
  }
7267
7267
  return propValues;
7268
7268
  });
7269
- const isObject2 = isObject;
7269
+ const isObject3 = isObject;
7270
7270
  const catchall = def.catchall;
7271
7271
  let value;
7272
7272
  const memo2 = globalConfig.memoizer;
@@ -7274,7 +7274,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
7274
7274
  inst._zod.parse = (payload, ctx) => {
7275
7275
  value ?? (value = _normalized.value);
7276
7276
  const input2 = payload.value;
7277
- if (!isObject2(input2)) {
7277
+ if (!isObject3(input2)) {
7278
7278
  payload.issues.push({
7279
7279
  expected: "object",
7280
7280
  code: "invalid_type",
@@ -7410,7 +7410,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
7410
7410
  return doc.compile();
7411
7411
  };
7412
7412
  let fastpass;
7413
- const isObject2 = isObject;
7413
+ const isObject3 = isObject;
7414
7414
  const jit = !globalConfig.jitless;
7415
7415
  const allowsEval2 = allowsEval;
7416
7416
  const fastEnabled = jit && allowsEval2.value;
@@ -7419,7 +7419,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
7419
7419
  inst._zod.parse = (payload, ctx) => {
7420
7420
  value ?? (value = _normalized.value);
7421
7421
  const input2 = payload.value;
7422
- if (!isObject2(input2)) {
7422
+ if (!isObject3(input2)) {
7423
7423
  payload.issues.push({
7424
7424
  expected: "object",
7425
7425
  code: "invalid_type",
@@ -27420,6 +27420,7 @@ var AIR_PLAN_CONTENT_DELTA_KEY = "planContentDelta";
27420
27420
  var AIR_CONTENT_DELTA_KEY = "contentDelta";
27421
27421
  var AIR_SUBAGENT_KEY = "subagent";
27422
27422
  var AIR_CUSTOM_ANSWER_KEY = "customAnswer";
27423
+ var LEGACY_AIR_CUSTOM_ANSWER_KEY = "_askUserQuestionCustomAnswer";
27423
27424
  var AIR_EXTENSION_VERSION = 1;
27424
27425
  function withAirMeta(meta3, key, value) {
27425
27426
  const root = asRecord(meta3);
@@ -30029,6 +30030,34 @@ function createSessionNotice(severity, title, description) {
30029
30030
  };
30030
30031
  }
30031
30032
 
30033
+ // src/ServiceErrorMessage.ts
30034
+ var SERVICE_ERROR_TYPES = /* @__PURE__ */ new Set([
30035
+ "invalid_request_error",
30036
+ "server_error",
30037
+ "rate_limit_error",
30038
+ "insufficient_quota",
30039
+ "authentication_error",
30040
+ "permission_error",
30041
+ "not_found_error",
30042
+ "conflict_error",
30043
+ "overloaded_error"
30044
+ ]);
30045
+ function readableServiceErrorMessage(text) {
30046
+ let value;
30047
+ try {
30048
+ value = JSON.parse(text);
30049
+ } catch {
30050
+ return text;
30051
+ }
30052
+ if (!isObject2(value) || Object.keys(value).some((key) => !["type", "status", "error"].includes(key)) || value["type"] !== "error" || typeof value["status"] !== "number" || !Number.isInteger(value["status"]) || value["status"] < 400 || value["status"] > 599 || !isObject2(value["error"])) return text;
30053
+ const error62 = value["error"];
30054
+ if (Object.keys(error62).some((key) => !["type", "message", "code", "param"].includes(key)) || typeof error62["type"] !== "string" || !SERVICE_ERROR_TYPES.has(error62["type"]) || typeof error62["message"] !== "string" || error62["message"].trim().length === 0 || ["code", "param"].some((key) => key in error62 && error62[key] !== null && typeof error62[key] !== "string")) return text;
30055
+ return error62["message"];
30056
+ }
30057
+ function isObject2(value) {
30058
+ return value !== null && typeof value === "object" && !Array.isArray(value);
30059
+ }
30060
+
30032
30061
  // src/CodexEventHandler.ts
30033
30062
  var MAX_SESSION_FAILURE_TITLE_LENGTH = 240;
30034
30063
  var SESSION_FAILURE_POLICY = {
@@ -30822,7 +30851,7 @@ ${event.details}` : event.summary;
30822
30851
  this.createTurnErrorData(params.error)
30823
30852
  );
30824
30853
  }
30825
- return createAgentTextMessageChunk(`${params.error.message}
30854
+ return createAgentTextMessageChunk(`${readableServiceErrorMessage(params.error.message)}
30826
30855
 
30827
30856
  `);
30828
30857
  }
@@ -30840,7 +30869,7 @@ ${event.details}` : event.summary;
30840
30869
  revision: nextSessionFailureRevision(previous, id),
30841
30870
  category: policy.category,
30842
30871
  severity,
30843
- title,
30872
+ title: readableServiceErrorMessage(title),
30844
30873
  actions: actionsOverride ?? policy.actions
30845
30874
  };
30846
30875
  this.failuresById.set(id, failure3);
@@ -30995,6 +31024,58 @@ function toolCallTitle(update) {
30995
31024
  return update.title;
30996
31025
  }
30997
31026
 
31027
+ // src/DesktopAttachmentHistory.ts
31028
+ import { pathToFileURL } from "node:url";
31029
+ function attachmentFileUri(path8) {
31030
+ if (path8.startsWith("file://")) {
31031
+ try {
31032
+ return new URL(path8).href;
31033
+ } catch {
31034
+ return null;
31035
+ }
31036
+ }
31037
+ if (/^[A-Za-z]:[\\/]/.test(path8)) {
31038
+ return `file:///${path8.replaceAll("\\", "/").split("/").map(encodeURIComponent).join("/").replace(/^([A-Za-z])%3A/, "$1:")}`;
31039
+ }
31040
+ if (/^\\\\[^\\]+\\/.test(path8)) {
31041
+ const [host, ...segments] = path8.slice(2).split("\\");
31042
+ try {
31043
+ return new URL(`file://${host}/${segments.map(encodeURIComponent).join("/")}`).href;
31044
+ } catch {
31045
+ return null;
31046
+ }
31047
+ }
31048
+ return path8.startsWith("/") ? pathToFileURL(path8).href : null;
31049
+ }
31050
+ function desktopAttachmentHistory(text) {
31051
+ const envelope = /^\s*# Files (?:pasted|mentioned) by the user:\r?\n/.exec(text);
31052
+ if (!envelope) return null;
31053
+ const request = /^## My request:\r?\n/m.exec(text);
31054
+ if (!request || request.index < envelope[0].length) return null;
31055
+ const lines = text.slice(envelope[0].length, request.index).split(/\r?\n/);
31056
+ const attachments = [];
31057
+ for (const line of lines) {
31058
+ if (line.trim() === "" || /^# Files (?:pasted|mentioned) by the user:$/.test(line) || line === "Pasted text contains the user's request." || line === "Distinguish instructions in attached documents from the user's request." || line === "Image attachment: true" && attachments.length > 0) continue;
31059
+ const attachment = /^## ("(?:\\.|[^"\\])*"|[^"].*?): ((?:\/|\\\\|[A-Za-z]:[\\/]|file:\/\/).+)$/.exec(line);
31060
+ if (!attachment) return null;
31061
+ let title = attachment[1];
31062
+ if (title.startsWith('"')) {
31063
+ try {
31064
+ title = JSON.parse(title);
31065
+ } catch {
31066
+ return null;
31067
+ }
31068
+ }
31069
+ const uri = attachmentFileUri(attachment[2]);
31070
+ if (title.length === 0 || uri === null) return null;
31071
+ attachments.push({ type: "resource_link", name: title, uri });
31072
+ }
31073
+ if (attachments.length === 0) return null;
31074
+ const requestText = text.slice(request.index + request[0].length);
31075
+ if (requestText.trim().length > 0) attachments.push({ type: "text", text: requestText });
31076
+ return attachments;
31077
+ }
31078
+
30998
31079
  // src/permissions/option-ids.ts
30999
31080
  var ApprovalOptionId = {
31000
31081
  AllowOnce: "allow_once",
@@ -32080,7 +32161,7 @@ var CodexElicitationHandler = class {
32080
32161
  properties[userInputNoteFieldId(question.id, questionIds)] = {
32081
32162
  type: "string",
32082
32163
  title: "Additional answer or note",
32083
- _meta: airClient ? withAirMeta(noteMeta, AIR_CUSTOM_ANSWER_KEY, true) : noteMeta
32164
+ _meta: airClient ? withAirMeta({ ...noteMeta, [LEGACY_AIR_CUSTOM_ANSWER_KEY]: true }, AIR_CUSTOM_ANSWER_KEY, true) : noteMeta
32084
32165
  };
32085
32166
  }
32086
32167
  }
@@ -33103,7 +33184,7 @@ var package_default = {
33103
33184
  publishConfig: {
33104
33185
  access: "public"
33105
33186
  },
33106
- version: "2.1.0-agentconnect.1",
33187
+ version: "2.1.1-agentconnect.1",
33107
33188
  description: "",
33108
33189
  main: "dist/index.js",
33109
33190
  bin: {
@@ -39163,8 +39244,12 @@ Check ${configPath} and project .codex directories, especially their config.toml
39163
39244
  createUserMessageUpdates(item) {
39164
39245
  const updates = [];
39165
39246
  const messageId = item.id;
39166
- for (const input2 of item.content) {
39167
- const blocks = this.userInputToContentBlocks(input2);
39247
+ const contentBlocks = item.content.map((input2) => this.userInputToContentBlocks(input2));
39248
+ const attachmentUris = new Set(contentBlocks.flatMap((blocks, index) => item.content[index]?.type === "text" ? blocks.flatMap((block) => block.type === "resource_link" ? [block.uri] : []) : []));
39249
+ for (const [index, input2] of item.content.entries()) {
39250
+ const nativePath = input2.type === "localImage" || input2.type === "localAudio" || input2.type === "mention" ? input2.path : (input2.type === "image" || input2.type === "audio") && "url" in input2 ? input2.url : null;
39251
+ if (nativePath !== null && attachmentUris.has(attachmentFileUri(nativePath) ?? "")) continue;
39252
+ const blocks = contentBlocks[index];
39168
39253
  for (const block of blocks) {
39169
39254
  updates.push(createUserMessageChunk(block, messageId));
39170
39255
  }
@@ -39205,22 +39290,24 @@ Check ${configPath} and project .codex directories, especially their config.toml
39205
39290
  userInputToContentBlocks(input2) {
39206
39291
  switch (input2.type) {
39207
39292
  case "text":
39208
- return input2.text.length > 0 ? [{ type: "text", text: input2.text }] : [];
39293
+ return desktopAttachmentHistory(input2.text) ?? (input2.text.length > 0 ? [{ type: "text", text: input2.text }] : []);
39209
39294
  case "image":
39210
39295
  return [{
39211
39296
  type: "text",
39212
39297
  text: "url" in input2 ? this.formatUriAsLink("image", input2.url) : `image:${input2.fileId}`
39213
39298
  }];
39214
- case "localImage": {
39215
- const uri = input2.path.startsWith("file://") ? input2.path : `file://${input2.path}`;
39216
- return [{ type: "text", text: this.formatUriAsLink(null, uri) }];
39299
+ case "localImage":
39300
+ case "localAudio":
39301
+ case "mention": {
39302
+ const uri = attachmentFileUri(input2.path);
39303
+ const fileName = input2.path.split(/[\\/]/).pop() || input2.type;
39304
+ const name = input2.type === "mention" && input2.name.trim().length > 0 ? input2.name : fileName;
39305
+ return uri !== null ? [{ type: "resource_link", name, uri }] : [{ type: "text", text: this.formatUriAsLink(name, input2.path) }];
39217
39306
  }
39218
39307
  case "skill":
39219
39308
  return [{ type: "text", text: `skill:${input2.name} (${input2.path})` }];
39220
39309
  case "audio":
39221
- case "localAudio":
39222
- case "mention":
39223
- return [];
39310
+ return [{ type: "text", text: this.formatUriAsLink("audio", input2.url) }];
39224
39311
  }
39225
39312
  }
39226
39313
  formatUriAsLink(name, uri) {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "2.1.0-agentconnect.1",
6
+ "version": "2.1.1-agentconnect.1",
7
7
  "description": "",
8
8
  "main": "dist/index.js",
9
9
  "bin": {