@autohq/cli 0.1.421 → 0.1.422

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.
@@ -26873,11 +26873,16 @@ var ConversationToolCallContentPartSchema = external_exports.object({
26873
26873
  name: external_exports.string().min(1),
26874
26874
  input: JsonValueSchema
26875
26875
  });
26876
+ var ConversationToolErrorSchema = external_exports.object({
26877
+ message: external_exports.string(),
26878
+ details: JsonValueSchema.optional()
26879
+ });
26876
26880
  var ConversationToolResultContentPartSchema = external_exports.object({
26877
26881
  type: external_exports.literal("tool_result"),
26878
26882
  toolUseId: external_exports.string().min(1).nullable(),
26879
26883
  output: JsonValueSchema,
26880
- isError: external_exports.boolean()
26884
+ isError: external_exports.boolean(),
26885
+ error: ConversationToolErrorSchema.optional()
26881
26886
  });
26882
26887
  var ConversationQuestionSchema = external_exports.object({
26883
26888
  question: external_exports.string().min(1),
@@ -30820,7 +30825,7 @@ Object.assign(lookup, {
30820
30825
  // package.json
30821
30826
  var package_default = {
30822
30827
  name: "@autohq/cli",
30823
- version: "0.1.421",
30828
+ version: "0.1.422",
30824
30829
  license: "SEE LICENSE IN README.md",
30825
30830
  publishConfig: {
30826
30831
  access: "public"
@@ -31474,6 +31479,9 @@ function toJsonValue(value2) {
31474
31479
  return String(value2);
31475
31480
  }
31476
31481
  }
31482
+ function isJsonObject(value2) {
31483
+ return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
31484
+ }
31477
31485
  var IdempotencySchema = external_exports.discriminatedUnion("kind", [
31478
31486
  external_exports.object({ kind: external_exports.literal("none") }),
31479
31487
  external_exports.object({ kind: external_exports.literal("key"), key: external_exports.string().trim().min(1) })
@@ -32226,11 +32234,16 @@ var ConversationToolCallContentPartSchema2 = external_exports.object({
32226
32234
  name: external_exports.string().min(1),
32227
32235
  input: JsonValueSchema2
32228
32236
  });
32237
+ var ConversationToolErrorSchema2 = external_exports.object({
32238
+ message: external_exports.string(),
32239
+ details: JsonValueSchema2.optional()
32240
+ });
32229
32241
  var ConversationToolResultContentPartSchema2 = external_exports.object({
32230
32242
  type: external_exports.literal("tool_result"),
32231
32243
  toolUseId: external_exports.string().min(1).nullable(),
32232
32244
  output: JsonValueSchema2,
32233
- isError: external_exports.boolean()
32245
+ isError: external_exports.boolean(),
32246
+ error: ConversationToolErrorSchema2.optional()
32234
32247
  });
32235
32248
  var ConversationQuestionOptionSchema = external_exports.object({
32236
32249
  label: external_exports.string().min(1),
@@ -32313,6 +32326,134 @@ var ConversationRealtimeEventSchema = external_exports.discriminatedUnion("type"
32313
32326
  ConversationUiMessageChunkEventSchema
32314
32327
  ]);
32315
32328
 
32329
+ // ../../packages/schemas/src/tool-errors.ts
32330
+ function normalizeConversationToolError(value2) {
32331
+ if (value2 instanceof Error) {
32332
+ return {
32333
+ message: value2.message || value2.name,
32334
+ details: errorDetails(value2)
32335
+ };
32336
+ }
32337
+ const jsonValue = toJsonValue(value2);
32338
+ if (isCanonicalToolError(jsonValue)) {
32339
+ return {
32340
+ message: unwrapToolUseError(parseStringMessage(jsonValue.message)),
32341
+ ...jsonValue.details === void 0 ? {} : { details: jsonValue.details }
32342
+ };
32343
+ }
32344
+ const parsed = parseOneJsonStringLayer(jsonValue);
32345
+ const message = toolErrorMessage(parsed);
32346
+ const details = structuredDetails(parsed);
32347
+ return {
32348
+ message,
32349
+ ...details === void 0 ? {} : { details }
32350
+ };
32351
+ }
32352
+ function parseOneJsonStringLayer(value2) {
32353
+ if (typeof value2 !== "string") {
32354
+ return value2;
32355
+ }
32356
+ const trimmed = value2.trim();
32357
+ if (!trimmed.startsWith('"') || !trimmed.endsWith('"')) {
32358
+ return value2;
32359
+ }
32360
+ try {
32361
+ const parsed = JSON.parse(trimmed);
32362
+ return typeof parsed === "string" ? parsed : value2;
32363
+ } catch {
32364
+ return value2;
32365
+ }
32366
+ }
32367
+ function toolErrorMessage(value2) {
32368
+ if (typeof value2 === "string") {
32369
+ return unwrapToolUseError(value2);
32370
+ }
32371
+ if (Array.isArray(value2)) {
32372
+ const text2 = value2.filter(isTextContentBlock).map((block) => unwrapToolUseError(parseStringMessage(block.text))).filter(Boolean).join("\n");
32373
+ if (text2) {
32374
+ return text2;
32375
+ }
32376
+ }
32377
+ if (isJsonObject(value2)) {
32378
+ const message = stringField(value2, "message");
32379
+ if (message) {
32380
+ return unwrapToolUseError(parseStringMessage(message));
32381
+ }
32382
+ const nestedError = value2.error;
32383
+ if (typeof nestedError === "string") {
32384
+ const parsedNestedError = parseJsonValueString(nestedError);
32385
+ if (parsedNestedError !== null) {
32386
+ const nestedContentMessage = contentBlocksMessage(parsedNestedError);
32387
+ if (nestedContentMessage) {
32388
+ return nestedContentMessage;
32389
+ }
32390
+ }
32391
+ return unwrapToolUseError(parseStringMessage(nestedError));
32392
+ }
32393
+ if (isJsonObject(nestedError)) {
32394
+ const nestedMessage = stringField(nestedError, "message");
32395
+ if (nestedMessage) {
32396
+ return unwrapToolUseError(parseStringMessage(nestedMessage));
32397
+ }
32398
+ }
32399
+ }
32400
+ return JSON.stringify(value2) ?? String(value2);
32401
+ }
32402
+ function errorDetails(error51) {
32403
+ const enumerable = toJsonValue({ ...error51 });
32404
+ return {
32405
+ name: error51.name,
32406
+ ...error51.stack ? { stack: error51.stack } : {},
32407
+ ...isJsonObject(enumerable) ? enumerable : {}
32408
+ };
32409
+ }
32410
+ function parseStringMessage(value2) {
32411
+ const parsed = parseOneJsonStringLayer(value2);
32412
+ return typeof parsed === "string" ? parsed : value2;
32413
+ }
32414
+ function parseJsonValueString(value2) {
32415
+ const trimmed = value2.trim();
32416
+ if (!(trimmed.startsWith("{") && trimmed.endsWith("}")) && !(trimmed.startsWith("[") && trimmed.endsWith("]"))) {
32417
+ return null;
32418
+ }
32419
+ try {
32420
+ return toJsonValue(JSON.parse(trimmed));
32421
+ } catch {
32422
+ return null;
32423
+ }
32424
+ }
32425
+ function contentBlocksMessage(value2) {
32426
+ if (!isJsonObject(value2) || !Array.isArray(value2.content)) {
32427
+ return null;
32428
+ }
32429
+ const message = value2.content.filter(isTextContentBlock).map((block) => unwrapToolUseError(parseStringMessage(block.text))).filter(Boolean).join("\n");
32430
+ return message || null;
32431
+ }
32432
+ function structuredDetails(value2) {
32433
+ return typeof value2 === "string" ? void 0 : value2;
32434
+ }
32435
+ function unwrapToolUseError(value2) {
32436
+ const match = /^<tool_use_error>([\s\S]*)<\/tool_use_error>$/.exec(
32437
+ value2.trim()
32438
+ );
32439
+ return match ? match[1]?.trim() ?? "" : value2;
32440
+ }
32441
+ function stringField(value2, key) {
32442
+ const field = value2[key];
32443
+ return typeof field === "string" && field.trim() ? field : void 0;
32444
+ }
32445
+ function isTextContentBlock(value2) {
32446
+ return isJsonObject(value2) && value2.type === "text" && typeof value2.text === "string";
32447
+ }
32448
+ function isCanonicalToolError(value2) {
32449
+ if (!isJsonObject(value2) || typeof value2.message !== "string") {
32450
+ return false;
32451
+ }
32452
+ return Object.keys(value2).every(
32453
+ (key) => key === "message" || key === "details"
32454
+ );
32455
+ }
32456
+
32316
32457
  // ../../packages/schemas/src/claude-code.ts
32317
32458
  var ASK_USER_QUESTION_TOOL_NAME = "AskUserQuestion";
32318
32459
  var CLAUDE_CODE_INTERRUPT_MARKER_PREFIX = "[Request interrupted by user";
@@ -32637,7 +32778,8 @@ function userContentProjections(message) {
32637
32778
  type: "tool_result",
32638
32779
  toolUseId: block.tool_use_id ?? null,
32639
32780
  output: toJsonValue(block.content),
32640
- isError: block.is_error === true
32781
+ isError: block.is_error === true,
32782
+ ...block.is_error === true ? { error: normalizeConversationToolError(block.content) } : {}
32641
32783
  }
32642
32784
  ]
32643
32785
  }
package/dist/index.js CHANGED
@@ -15207,6 +15207,9 @@ function toJsonValue(value) {
15207
15207
  return String(value);
15208
15208
  }
15209
15209
  }
15210
+ function isJsonObject(value) {
15211
+ return typeof value === "object" && value !== null && !Array.isArray(value);
15212
+ }
15210
15213
  var JsonValueSchema, JsonObjectSchema, IdempotencySchema;
15211
15214
  var init_primitives = __esm({
15212
15215
  "../../packages/schemas/src/primitives.ts"() {
@@ -15976,7 +15979,7 @@ var init_chat = __esm({
15976
15979
  });
15977
15980
 
15978
15981
  // ../../packages/schemas/src/conversation.ts
15979
- var CONVERSATION_ROLES, CONVERSATION_ENTRY_KINDS, CONVERSATION_ENTRY_STATUSES, UNKNOWN_MESSAGE_ID, ConversationRoleSchema, ConversationEntryKindSchema, ConversationEntryStatusSchema, ConversationTextContentPartSchema, ConversationReasoningContentPartSchema, ConversationToolCallContentPartSchema, ConversationToolResultContentPartSchema, ConversationQuestionOptionSchema, ConversationQuestionSchema, ConversationQuestionContentPartSchema, ConversationUiMessageContentPartSchema, ConversationContentPartSchema, ConversationEntryContentSchema, ConversationEntryEventSchema, ConversationTextDeltaSchema, ConversationReasoningDeltaSchema, ConversationDeltaSchema, ConversationDeltaEventSchema, ConversationUiMessageChunkEventSchema, ConversationRealtimeEventSchema;
15982
+ var CONVERSATION_ROLES, CONVERSATION_ENTRY_KINDS, CONVERSATION_ENTRY_STATUSES, UNKNOWN_MESSAGE_ID, ConversationRoleSchema, ConversationEntryKindSchema, ConversationEntryStatusSchema, ConversationTextContentPartSchema, ConversationReasoningContentPartSchema, ConversationToolCallContentPartSchema, ConversationToolErrorSchema, ConversationToolResultContentPartSchema, ConversationQuestionOptionSchema, ConversationQuestionSchema, ConversationQuestionContentPartSchema, ConversationUiMessageContentPartSchema, ConversationContentPartSchema, ConversationEntryContentSchema, ConversationEntryEventSchema, ConversationTextDeltaSchema, ConversationReasoningDeltaSchema, ConversationDeltaSchema, ConversationDeltaEventSchema, ConversationUiMessageChunkEventSchema, ConversationRealtimeEventSchema;
15980
15983
  var init_conversation = __esm({
15981
15984
  "../../packages/schemas/src/conversation.ts"() {
15982
15985
  "use strict";
@@ -16021,11 +16024,16 @@ var init_conversation = __esm({
16021
16024
  name: external_exports.string().min(1),
16022
16025
  input: JsonValueSchema
16023
16026
  });
16027
+ ConversationToolErrorSchema = external_exports.object({
16028
+ message: external_exports.string(),
16029
+ details: JsonValueSchema.optional()
16030
+ });
16024
16031
  ConversationToolResultContentPartSchema = external_exports.object({
16025
16032
  type: external_exports.literal("tool_result"),
16026
16033
  toolUseId: external_exports.string().min(1).nullable(),
16027
16034
  output: JsonValueSchema,
16028
- isError: external_exports.boolean()
16035
+ isError: external_exports.boolean(),
16036
+ error: ConversationToolErrorSchema.optional()
16029
16037
  });
16030
16038
  ConversationQuestionOptionSchema = external_exports.object({
16031
16039
  label: external_exports.string().min(1),
@@ -16110,6 +16118,140 @@ var init_conversation = __esm({
16110
16118
  }
16111
16119
  });
16112
16120
 
16121
+ // ../../packages/schemas/src/tool-errors.ts
16122
+ function normalizeConversationToolError(value) {
16123
+ if (value instanceof Error) {
16124
+ return {
16125
+ message: value.message || value.name,
16126
+ details: errorDetails(value)
16127
+ };
16128
+ }
16129
+ const jsonValue = toJsonValue(value);
16130
+ if (isCanonicalToolError(jsonValue)) {
16131
+ return {
16132
+ message: unwrapToolUseError(parseStringMessage(jsonValue.message)),
16133
+ ...jsonValue.details === void 0 ? {} : { details: jsonValue.details }
16134
+ };
16135
+ }
16136
+ const parsed = parseOneJsonStringLayer(jsonValue);
16137
+ const message = toolErrorMessage(parsed);
16138
+ const details = structuredDetails(parsed);
16139
+ return {
16140
+ message,
16141
+ ...details === void 0 ? {} : { details }
16142
+ };
16143
+ }
16144
+ function parseOneJsonStringLayer(value) {
16145
+ if (typeof value !== "string") {
16146
+ return value;
16147
+ }
16148
+ const trimmed = value.trim();
16149
+ if (!trimmed.startsWith('"') || !trimmed.endsWith('"')) {
16150
+ return value;
16151
+ }
16152
+ try {
16153
+ const parsed = JSON.parse(trimmed);
16154
+ return typeof parsed === "string" ? parsed : value;
16155
+ } catch {
16156
+ return value;
16157
+ }
16158
+ }
16159
+ function toolErrorMessage(value) {
16160
+ if (typeof value === "string") {
16161
+ return unwrapToolUseError(value);
16162
+ }
16163
+ if (Array.isArray(value)) {
16164
+ const text = value.filter(isTextContentBlock).map((block) => unwrapToolUseError(parseStringMessage(block.text))).filter(Boolean).join("\n");
16165
+ if (text) {
16166
+ return text;
16167
+ }
16168
+ }
16169
+ if (isJsonObject(value)) {
16170
+ const message = stringField(value, "message");
16171
+ if (message) {
16172
+ return unwrapToolUseError(parseStringMessage(message));
16173
+ }
16174
+ const nestedError = value.error;
16175
+ if (typeof nestedError === "string") {
16176
+ const parsedNestedError = parseJsonValueString(nestedError);
16177
+ if (parsedNestedError !== null) {
16178
+ const nestedContentMessage = contentBlocksMessage(parsedNestedError);
16179
+ if (nestedContentMessage) {
16180
+ return nestedContentMessage;
16181
+ }
16182
+ }
16183
+ return unwrapToolUseError(parseStringMessage(nestedError));
16184
+ }
16185
+ if (isJsonObject(nestedError)) {
16186
+ const nestedMessage = stringField(nestedError, "message");
16187
+ if (nestedMessage) {
16188
+ return unwrapToolUseError(parseStringMessage(nestedMessage));
16189
+ }
16190
+ }
16191
+ }
16192
+ return JSON.stringify(value) ?? String(value);
16193
+ }
16194
+ function errorDetails(error51) {
16195
+ const enumerable = toJsonValue({ ...error51 });
16196
+ return {
16197
+ name: error51.name,
16198
+ ...error51.stack ? { stack: error51.stack } : {},
16199
+ ...isJsonObject(enumerable) ? enumerable : {}
16200
+ };
16201
+ }
16202
+ function parseStringMessage(value) {
16203
+ const parsed = parseOneJsonStringLayer(value);
16204
+ return typeof parsed === "string" ? parsed : value;
16205
+ }
16206
+ function parseJsonValueString(value) {
16207
+ const trimmed = value.trim();
16208
+ if (!(trimmed.startsWith("{") && trimmed.endsWith("}")) && !(trimmed.startsWith("[") && trimmed.endsWith("]"))) {
16209
+ return null;
16210
+ }
16211
+ try {
16212
+ return toJsonValue(JSON.parse(trimmed));
16213
+ } catch {
16214
+ return null;
16215
+ }
16216
+ }
16217
+ function contentBlocksMessage(value) {
16218
+ if (!isJsonObject(value) || !Array.isArray(value.content)) {
16219
+ return null;
16220
+ }
16221
+ const message = value.content.filter(isTextContentBlock).map((block) => unwrapToolUseError(parseStringMessage(block.text))).filter(Boolean).join("\n");
16222
+ return message || null;
16223
+ }
16224
+ function structuredDetails(value) {
16225
+ return typeof value === "string" ? void 0 : value;
16226
+ }
16227
+ function unwrapToolUseError(value) {
16228
+ const match = /^<tool_use_error>([\s\S]*)<\/tool_use_error>$/.exec(
16229
+ value.trim()
16230
+ );
16231
+ return match ? match[1]?.trim() ?? "" : value;
16232
+ }
16233
+ function stringField(value, key) {
16234
+ const field = value[key];
16235
+ return typeof field === "string" && field.trim() ? field : void 0;
16236
+ }
16237
+ function isTextContentBlock(value) {
16238
+ return isJsonObject(value) && value.type === "text" && typeof value.text === "string";
16239
+ }
16240
+ function isCanonicalToolError(value) {
16241
+ if (!isJsonObject(value) || typeof value.message !== "string") {
16242
+ return false;
16243
+ }
16244
+ return Object.keys(value).every(
16245
+ (key) => key === "message" || key === "details"
16246
+ );
16247
+ }
16248
+ var init_tool_errors = __esm({
16249
+ "../../packages/schemas/src/tool-errors.ts"() {
16250
+ "use strict";
16251
+ init_primitives();
16252
+ }
16253
+ });
16254
+
16113
16255
  // ../../packages/schemas/src/claude-code.ts
16114
16256
  function parseClaudeCodeStreamRecord(parsed) {
16115
16257
  const record2 = ClaudeCodeStreamRecordSchema.parse(parsed);
@@ -16309,7 +16451,8 @@ function userContentProjections(message) {
16309
16451
  type: "tool_result",
16310
16452
  toolUseId: block.tool_use_id ?? null,
16311
16453
  output: toJsonValue(block.content),
16312
- isError: block.is_error === true
16454
+ isError: block.is_error === true,
16455
+ ...block.is_error === true ? { error: normalizeConversationToolError(block.content) } : {}
16313
16456
  }
16314
16457
  ]
16315
16458
  }
@@ -16361,6 +16504,7 @@ var init_claude_code = __esm({
16361
16504
  init_zod();
16362
16505
  init_conversation();
16363
16506
  init_primitives();
16507
+ init_tool_errors();
16364
16508
  ASK_USER_QUESTION_TOOL_NAME = "AskUserQuestion";
16365
16509
  CLAUDE_CODE_INTERRUPT_MARKER_PREFIX = "[Request interrupted by user";
16366
16510
  CLAUDE_CODE_EDE_DIAGNOSTIC_PREFIX = "[ede_diagnostic]";
@@ -16639,6 +16783,7 @@ var init_codex = __esm({
16639
16783
  "use strict";
16640
16784
  init_zod();
16641
16785
  init_primitives();
16786
+ init_tool_errors();
16642
16787
  CodexRequestIdSchema = external_exports.union([external_exports.string(), external_exports.number()]);
16643
16788
  CodexTurnStatusSchema = external_exports.enum([
16644
16789
  "completed",
@@ -35987,6 +36132,7 @@ var init_src = __esm({
35987
36132
  init_templates();
35988
36133
  init_temporal();
35989
36134
  init_tools();
36135
+ init_tool_errors();
35990
36136
  init_trigger_router();
35991
36137
  init_url_slugs();
35992
36138
  init_usage();
@@ -38747,7 +38893,7 @@ var init_package = __esm({
38747
38893
  "package.json"() {
38748
38894
  package_default = {
38749
38895
  name: "@autohq/cli",
38750
- version: "0.1.421",
38896
+ version: "0.1.422",
38751
38897
  license: "SEE LICENSE IN README.md",
38752
38898
  publishConfig: {
38753
38899
  access: "public"
@@ -49268,11 +49414,16 @@ var ConversationToolCallContentPartSchema2 = external_exports.object({
49268
49414
  name: external_exports.string().min(1),
49269
49415
  input: JsonValueSchema2
49270
49416
  });
49417
+ var ConversationToolErrorSchema2 = external_exports.object({
49418
+ message: external_exports.string(),
49419
+ details: JsonValueSchema2.optional()
49420
+ });
49271
49421
  var ConversationToolResultContentPartSchema2 = external_exports.object({
49272
49422
  type: external_exports.literal("tool_result"),
49273
49423
  toolUseId: external_exports.string().min(1).nullable(),
49274
49424
  output: JsonValueSchema2,
49275
- isError: external_exports.boolean()
49425
+ isError: external_exports.boolean(),
49426
+ error: ConversationToolErrorSchema2.optional()
49276
49427
  });
49277
49428
  var ConversationQuestionSchema2 = external_exports.object({
49278
49429
  question: external_exports.string().min(1),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.421",
3
+ "version": "0.1.422",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"