@wirecat/mail-cli 0.23.1 → 0.24.0

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 (114) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/bin/mail.js +2 -2
  3. package/dist/bundle/{all-profiles-FJHJCGRU.js → all-profiles-VS7P6DJY.js} +11 -11
  4. package/dist/bundle/{anthropic-AFL7NKVZ.js → anthropic-C5JXKGBS.js} +16 -7
  5. package/dist/bundle/{app-server-WKCBJMHI.js → app-server-HU3LVU42.js} +51 -50
  6. package/dist/bundle/{bun-HQATAQJQ.js → bun-QLFX47WZ.js} +2 -2
  7. package/dist/bundle/{bun-sqlite-4ECAV7OU.js → bun-sqlite-W4PGAKVY.js} +5 -5
  8. package/dist/bundle/{chunk-3UFD76IR.js → chunk-3FD3IATT.js} +6 -6
  9. package/dist/bundle/{chunk-R554W7ZO.js → chunk-3KSK5BBB.js} +2 -2
  10. package/dist/bundle/{chunk-AGNAT7CM.js → chunk-4QNHAM3J.js} +2 -2
  11. package/dist/bundle/{chunk-7SWWVDEZ.js → chunk-4W4EVVL4.js} +61 -21
  12. package/dist/bundle/{chunk-NMGF3UOZ.js → chunk-5NLHDK7P.js} +50 -46
  13. package/dist/bundle/{chunk-VFKX5UMJ.js → chunk-5X3GU5LI.js} +6 -6
  14. package/dist/bundle/{chunk-NKBAZ4VC.js → chunk-64ZG5ERD.js} +2 -2
  15. package/dist/bundle/{chunk-WN4HP7IZ.js → chunk-6PWCQKMD.js} +12 -12
  16. package/dist/bundle/{chunk-V3TDQUXD.js → chunk-6VV7J2TN.js} +36 -57
  17. package/dist/bundle/{chunk-SNTLN2QT.js → chunk-A6J4MPTI.js} +3 -1
  18. package/dist/bundle/{chunk-CUOCDJFI.js → chunk-AUTX2MLF.js} +11 -9
  19. package/dist/bundle/{chunk-5UKBUI4I.js → chunk-B72343TK.js} +2 -2
  20. package/dist/bundle/{chunk-4IWJARFA.js → chunk-BFQQV22T.js} +1 -1
  21. package/dist/bundle/chunk-C3NYJW6B.js +1542 -0
  22. package/dist/bundle/{chunk-OJCUSHZG.js → chunk-C5BMCLCQ.js} +4 -4
  23. package/dist/bundle/{chunk-OU5CWCG2.js → chunk-DW3F6DUW.js} +1 -1
  24. package/dist/bundle/chunk-EKGRNFYQ.js +18 -0
  25. package/dist/bundle/{chunk-B6QMMRIM.js → chunk-FKWUUCX2.js} +1340 -1542
  26. package/dist/bundle/{chunk-LLYVBO3R.js → chunk-FNLUKODV.js} +19 -19
  27. package/dist/bundle/{chunk-KKGX7JMX.js → chunk-H5FJTHVA.js} +2 -2
  28. package/dist/bundle/{chunk-3QVGB2CI.js → chunk-HBZAJINU.js} +4 -4
  29. package/dist/bundle/{chunk-V7CFZ773.js → chunk-IRUN4XOV.js} +2 -2
  30. package/dist/bundle/{chunk-VAMCRP47.js → chunk-JMLIKXFO.js} +2 -2
  31. package/dist/bundle/{chunk-QR7JZM3D.js → chunk-JOQGJUFT.js} +1 -1
  32. package/dist/bundle/{chunk-CBWA2T3N.js → chunk-JWMLMAHP.js} +4 -4
  33. package/dist/bundle/{chunk-S5OTP7XS.js → chunk-KGOVFEWZ.js} +3 -3
  34. package/dist/bundle/{chunk-PMIKRELC.js → chunk-KV4VTKF3.js} +3 -3
  35. package/dist/bundle/chunk-LVGX7VTD.js +138 -0
  36. package/dist/bundle/{chunk-3DQYO7FB.js → chunk-MCPOZNWG.js} +1 -1
  37. package/dist/bundle/{chunk-E7ZVKQHG.js → chunk-MTO6YVMN.js} +3 -3
  38. package/dist/bundle/{chunk-CCYHBNRL.js → chunk-NCRSE647.js} +286 -48
  39. package/dist/bundle/{chunk-GJNFNC76.js → chunk-NSIN5IM4.js} +8 -8
  40. package/dist/bundle/{chunk-ZXIPJF3Y.js → chunk-NWKKPDZV.js} +2 -2
  41. package/dist/bundle/chunk-O373QEAJ.js +1243 -0
  42. package/dist/bundle/{chunk-VYIIX6VN.js → chunk-OQW6GHUA.js} +1 -1
  43. package/dist/bundle/{chunk-2HXHAFRP.js → chunk-PRQ2U7HF.js} +2 -2
  44. package/dist/bundle/{chunk-MBKNL5TX.js → chunk-PT6MF2VU.js} +87 -77
  45. package/dist/bundle/{chunk-SBGXKM4U.js → chunk-Q4OKEN3B.js} +7 -7
  46. package/dist/bundle/{chunk-ROKTS7WM.js → chunk-Q6K2XUGU.js} +1 -1
  47. package/dist/bundle/{chunk-VYHIX3OP.js → chunk-QI3PXUOJ.js} +43 -595
  48. package/dist/bundle/{chunk-UMXVQIGD.js → chunk-QVMOEB3I.js} +377 -12
  49. package/dist/bundle/{chunk-HOKGIYUO.js → chunk-RLQZFZLK.js} +62 -7
  50. package/dist/bundle/{chunk-3OZKDC6Y.js → chunk-RN7OI5KL.js} +8 -8
  51. package/dist/bundle/{chunk-BVJQBAGL.js → chunk-RNZKQMFY.js} +14 -14
  52. package/dist/bundle/{chunk-4YJJQNNJ.js → chunk-RUASZW3M.js} +5 -5
  53. package/dist/bundle/{chunk-UHC5I3JV.js → chunk-RX5CJ55S.js} +1 -1
  54. package/dist/bundle/{chunk-SR3ADLGX.js → chunk-SWKQ6IAR.js} +3 -3
  55. package/dist/bundle/{chunk-QUKD5SO2.js → chunk-TI7ZIPA2.js} +4 -4
  56. package/dist/bundle/{chunk-LQDMUMA2.js → chunk-TLEBSMC7.js} +1997 -768
  57. package/dist/bundle/{chunk-MUDHCYN4.js → chunk-U6MMQNNK.js} +6 -6
  58. package/dist/bundle/{chunk-CYQVWITQ.js → chunk-VNKWSCN7.js} +99 -42
  59. package/dist/bundle/{chunk-DALBYUPC.js → chunk-VUBZFMGP.js} +2 -2
  60. package/dist/bundle/{chunk-34743C4C.js → chunk-VVL4MKYH.js} +1 -1
  61. package/dist/bundle/{chunk-7YRKUEYE.js → chunk-WOX7FZJP.js} +667 -222
  62. package/dist/bundle/{chunk-R5MYOLQP.js → chunk-X47BL4M5.js} +13 -13
  63. package/dist/bundle/{chunk-GOMJNH56.js → chunk-X7J3TTDO.js} +8 -8
  64. package/dist/bundle/{chunk-NOA6E6MM.js → chunk-XBEO472U.js} +29202 -16302
  65. package/dist/bundle/{chunk-4IFX4HV2.js → chunk-YA45XV6G.js} +4 -4
  66. package/dist/bundle/{chunk-M7RGG3UU.js → chunk-YBQ5AYLZ.js} +3 -3
  67. package/dist/bundle/{chunk-QV3M2MHG.js → chunk-YI544LHI.js} +13 -136
  68. package/dist/bundle/chunk-ZO4MQWIK.js +188 -0
  69. package/dist/bundle/{chunk-76RTQYJQ.js → chunk-ZR2BDNGG.js} +1 -1
  70. package/dist/bundle/command-contract-ERYYPAD2.js +35 -0
  71. package/dist/bundle/command-server-entry-5E3PPDE5.js +164 -0
  72. package/dist/bundle/{decode-QXKTMOTH.js → decode-AVWV7SVZ.js} +5 -5
  73. package/dist/bundle/{dispatch-G4CYFWQ2.js → dispatch-BXPHSNK5.js} +10 -10
  74. package/dist/bundle/{dist-5FX36DAW.js → dist-PIOOKBWT.js} +70 -44
  75. package/dist/bundle/{echarts-HHUM43TU.js → echarts-7K6YQV52.js} +2 -2
  76. package/dist/bundle/{embed-SRZSDZVI.js → embed-4NT76GJK.js} +6 -6
  77. package/dist/bundle/{embedder-WZIZCWLX.js → embedder-ITQFF7EN.js} +9 -9
  78. package/dist/bundle/{failure-FFPK2WYB.js → failure-3Q65JOPD.js} +2 -2
  79. package/dist/bundle/{first-run-6DVWZ3JQ.js → first-run-PM74YU4X.js} +11 -11
  80. package/dist/bundle/first-screen-WBVGVSMY.js +33 -0
  81. package/dist/bundle/{instructions-UWONE6UT.js → instructions-JDSITYHV.js} +1 -1
  82. package/dist/bundle/mail.js +37 -13
  83. package/dist/bundle/{mcp-CFVG2OUS.js → mcp-7KQUJNFN.js} +2 -2
  84. package/dist/bundle/{node-HLAOYJDB.js → node-D6YIJOJI.js} +2 -2
  85. package/dist/bundle/{node-sqlite-RO66I7W6.js → node-sqlite-PJOHHB4X.js} +6 -6
  86. package/dist/bundle/{oauth-VNLB2TET.js → oauth-BOWJ3IBT.js} +7 -7
  87. package/dist/bundle/{open-QQSG343L.js → open-FIAKKZMW.js} +5 -5
  88. package/dist/bundle/{openai-JTFC7OGF.js → openai-QL54VVLC.js} +16 -37
  89. package/dist/bundle/{process-3CZAXR6P.js → process-AYHK7WRC.js} +1 -1
  90. package/dist/bundle/{program-XTOS4RAM.js → program-6FKWOTBK.js} +2267 -1351
  91. package/dist/bundle/{prompt-HGQ6GPYL.js → prompt-XJZCBELC.js} +5 -5
  92. package/dist/bundle/{recognize-2SHMNEIZ.js → recognize-OQKWAHBY.js} +4 -4
  93. package/dist/bundle/{remote-GBQC3433.js → remote-NLVUZ5WK.js} +7 -7
  94. package/dist/bundle/{rerank-FQHQXFNR.js → rerank-NRPZDTJ7.js} +7 -7
  95. package/dist/bundle/{serve-THU67QUZ.js → serve-O4YUI7F6.js} +9 -9
  96. package/dist/bundle/server-6OT5ZEWL.js +66 -0
  97. package/dist/bundle/{server-LOT3CLYX.js → server-WAL3M4OO.js} +40 -40
  98. package/dist/bundle/{sqlite-runtime-NOOUMBC4.js → sqlite-runtime-5YHGI4D4.js} +6 -6
  99. package/dist/bundle/{state-KSKZCV2U.js → state-WYYOJ7KK.js} +6 -6
  100. package/dist/bundle/{store-BAKSHTKF.js → store-6BJO3F2J.js} +16 -16
  101. package/dist/bundle/{store-OHNZOQ7U.js → store-X72GOJHD.js} +44 -20
  102. package/dist/bundle/store-maintenance-command-ASS7RBYC.js +54 -0
  103. package/dist/config.d.ts +4 -0
  104. package/dist/config.d.ts.map +1 -1
  105. package/dist/version.d.ts +1 -1
  106. package/dist/version.js +1 -1
  107. package/package.json +3 -3
  108. package/dist/bundle/chunk-EXPR6QAX.js +0 -394
  109. package/dist/bundle/chunk-FWFNUJQD.js +0 -12172
  110. package/dist/bundle/command-contract-IIHBNF7J.js +0 -35
  111. package/dist/bundle/first-screen-SRZ7NYHZ.js +0 -33
  112. package/dist/bundle/server-VKMUX7ZT.js +0 -65
  113. package/dist/bundle/store-maintenance-command-ROQHJVEA.js +0 -54
  114. /package/dist/bundle/{chunk-QZLK2ISN.js → chunk-YVNHQFLC.js} +0 -0
@@ -2,29 +2,34 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  validateFormattedText
5
- } from "./chunk-QV3M2MHG.js";
5
+ } from "./chunk-YI544LHI.js";
6
6
  import {
7
7
  inputPolicy
8
- } from "./chunk-ZXIPJF3Y.js";
8
+ } from "./chunk-NWKKPDZV.js";
9
+ import {
10
+ RECORDS_SCHEMA_VERSION,
11
+ RECORD_TYPES,
12
+ pointerOf
13
+ } from "./chunk-C3NYJW6B.js";
9
14
  import {
10
15
  parseReference
11
- } from "./chunk-FWFNUJQD.js";
16
+ } from "./chunk-WOX7FZJP.js";
12
17
  import {
13
18
  indent
14
- } from "./chunk-LLYVBO3R.js";
19
+ } from "./chunk-FNLUKODV.js";
15
20
  import {
16
21
  CliError
17
- } from "./chunk-DALBYUPC.js";
22
+ } from "./chunk-VUBZFMGP.js";
18
23
  import {
19
24
  __name
20
25
  } from "./chunk-ZVVMGPBJ.js";
21
26
 
22
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/domain/checks.js
27
+ // node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/domain/checks.js
23
28
  var spelled = /* @__PURE__ */ __name((check, args) => `${check.replaceAll(".", " ")}${args === void 0 ? "" : ` ${args}`}`, "spelled");
24
29
  var bareCheck = /* @__PURE__ */ __name((check, args) => `\`${spelled(check, args)}\``, "bareCheck");
25
30
  var checkWords = /* @__PURE__ */ __name((command, profile) => (check, args) => `\`${command} ${profile === void 0 ? "" : `${profile} `}${spelled(check, args)}\``, "checkWords");
26
31
 
27
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/domain/links.js
32
+ // node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/domain/links.js
28
33
  var LINK_VERSION = "v1";
29
34
  var DEFAULT_LINK_CONFIG = { base: "https://wirecat.dev/o", enabled: true };
30
35
  var APP_PREFIX = "wirecat://open";
@@ -141,7 +146,7 @@ var linkFor = /* @__PURE__ */ __name((ref, { form, config = DEFAULT_LINK_CONFIG,
141
146
  return form === "app" ? `${APP_PREFIX}${path}` : `${config.base}#${path}`;
142
147
  }, "linkFor");
143
148
 
144
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/domain/markdown.js
149
+ // node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/domain/markdown.js
145
150
  var MARKERS = [
146
151
  ["**", "bold"],
147
152
  ["~~", "strike"],
@@ -187,7 +192,7 @@ var closing = /* @__PURE__ */ __name((input, open, marker) => {
187
192
  return end;
188
193
  }, "closing");
189
194
 
190
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/domain/markdown-spans.js
195
+ // node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/domain/markdown-spans.js
191
196
  var STYLES = [
192
197
  ["**", "bold"],
193
198
  ["__", "underline"],
@@ -347,7 +352,7 @@ var parseMarkdownSpans = /* @__PURE__ */ __name((input) => {
347
352
  return validateFormattedText(result);
348
353
  }, "parseMarkdownSpans");
349
354
 
350
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/domain/polls.js
355
+ // node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/domain/polls.js
351
356
  var countedPoll = /* @__PURE__ */ __name((poll, votes, self) => {
352
357
  const cast = votes.filter((vote) => vote.answers.length > 0);
353
358
  const mine = self === null ? void 0 : votes.find((vote) => vote.person.id === self);
@@ -362,6 +367,361 @@ var countedPoll = /* @__PURE__ */ __name((poll, votes, self) => {
362
367
  };
363
368
  }, "countedPoll");
364
369
 
370
+ // node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/domain/records-table.js
371
+ var TABLE_RECORD_TYPES = Object.keys(RECORD_TYPES).filter((type) => !RECORD_TYPES[type].importOnly);
372
+ var TableError = class extends Error {
373
+ static {
374
+ __name(this, "TableError");
375
+ }
376
+ errors;
377
+ constructor(errors) {
378
+ super(errors.map((e) => e.message).join("; "));
379
+ this.errors = errors;
380
+ }
381
+ };
382
+ var LIST_SEPARATOR = "|";
383
+ var BOM = "\uFEFF";
384
+ var specOf = /* @__PURE__ */ __name((type) => RECORD_TYPES[type], "specOf");
385
+ var typesOf = /* @__PURE__ */ __name((schema) => schema.type === void 0 ? [] : typeof schema.type === "string" ? [schema.type] : [...schema.type], "typesOf");
386
+ var shapeOf = /* @__PURE__ */ __name((schema) => {
387
+ const types = typesOf(schema);
388
+ if (types.includes("integer"))
389
+ return "integer";
390
+ if (types.includes("boolean"))
391
+ return "boolean";
392
+ if (types.includes("array"))
393
+ return "list";
394
+ if (schema.pattern?.includes("T[0-9]{2}"))
395
+ return "instant";
396
+ if (schema.pattern?.startsWith("^[0-9]{4}-"))
397
+ return "day";
398
+ if (schema.pattern?.includes("[A-Za-z]{3}"))
399
+ return "currency";
400
+ if (schema.pattern?.includes("(\\.[0-9]"))
401
+ return "decimal";
402
+ return "text";
403
+ }, "shapeOf");
404
+ var valuesOf = /* @__PURE__ */ __name((schema) => schema.enum?.filter((v) => v !== null), "valuesOf");
405
+ var flat = /* @__PURE__ */ __name((schema) => {
406
+ const types = typesOf(schema);
407
+ return !types.includes("object") && !(types.includes("array") && schema.items?.type === "object");
408
+ }, "flat");
409
+ var fieldColumn = /* @__PURE__ */ __name((name, schema, required, kind) => {
410
+ const values = valuesOf(schema);
411
+ const shape = shapeOf(schema);
412
+ return {
413
+ name,
414
+ kind,
415
+ required,
416
+ shape,
417
+ description: schema.description ?? "",
418
+ ...values ? { values } : {},
419
+ ...shape === "list" ? { many: true } : {}
420
+ };
421
+ }, "fieldColumn");
422
+ var roleColumn = /* @__PURE__ */ __name((name, role) => ({
423
+ name,
424
+ kind: "role",
425
+ required: role.required === true,
426
+ shape: "text",
427
+ description: role.targets.length === 1 ? `The ${role.targets[0]}'s external id` : `<type>:<external id>, the type one of ${role.targets.join(", ")}`,
428
+ targets: role.targets,
429
+ ...role.many ? { many: true } : {}
430
+ }), "roleColumn");
431
+ var recordColumns = /* @__PURE__ */ __name((type) => {
432
+ const spec = specOf(type);
433
+ if (!spec || spec.importOnly)
434
+ return [];
435
+ const fields = spec.fields.properties ?? {};
436
+ const required = spec.fields.required ?? [];
437
+ const lists = Object.entries(fields).filter(([, schema]) => !flat(schema));
438
+ return [
439
+ { name: "external_id", kind: "id", required: true, shape: "text", description: "Its id in your system" },
440
+ ...Object.entries(fields).filter(([, schema]) => flat(schema)).map(([name, schema]) => fieldColumn(name, schema, required.includes(name), "field")),
441
+ ...Object.entries(spec.roles).filter(([, role]) => !role.linked).map(([name, role]) => roleColumn(name, role)),
442
+ ...lists.flatMap(([list, schema]) => {
443
+ const item = schema.items ?? {};
444
+ const own = item.required ?? [];
445
+ return Object.entries(item.properties ?? {}).map(([key, s]) => fieldColumn(`${list}.${key}`, s, required.includes(list) && own.includes(key), "item"));
446
+ })
447
+ ];
448
+ }, "recordColumns");
449
+ var csvCell = /* @__PURE__ */ __name((value, separator) => /["\r\n]/.test(value) || value.includes(separator) ? `"${value.replaceAll('"', '""')}"` : value, "csvCell");
450
+ var example = /* @__PURE__ */ __name((column) => {
451
+ if (column.values?.[0])
452
+ return column.values[0];
453
+ switch (column.shape) {
454
+ case "decimal":
455
+ return "100.00";
456
+ case "day":
457
+ return "2026-01-31";
458
+ case "instant":
459
+ return "2026-01-31T09:00:00Z";
460
+ case "currency":
461
+ return "EUR";
462
+ case "integer":
463
+ return 1;
464
+ case "boolean":
465
+ return true;
466
+ case "list":
467
+ return ["\u2026"];
468
+ default:
469
+ return column.description || "\u2026";
470
+ }
471
+ }, "example");
472
+ var exampleRef = /* @__PURE__ */ __name((column) => ({
473
+ role: column.name,
474
+ type: column.targets?.[0] ?? "",
475
+ external_id: `${column.targets?.[0] ?? "record"}-1`
476
+ }), "exampleRef");
477
+ var recordTemplate = /* @__PURE__ */ __name((type, format, { source, separator = "," } = {}) => {
478
+ const columns = recordColumns(type);
479
+ if (columns.length === 0)
480
+ throw new TableError([unknownType(type)]);
481
+ if (format === "csv")
482
+ return `${BOM}${columns.map((c) => csvCell(c.name, separator)).join(separator)}\r
483
+ `;
484
+ const fields = {};
485
+ for (const c of columns.filter((c2) => c2.kind === "field"))
486
+ fields[c.name] = example(c);
487
+ for (const c of columns.filter((c2) => c2.kind === "item")) {
488
+ const [list = "", key = ""] = c.name.split(".");
489
+ fields[list] ??= [{}];
490
+ const [first] = fields[list];
491
+ if (first)
492
+ first[key] = example(c);
493
+ }
494
+ const envelope = {
495
+ schema_version: RECORDS_SCHEMA_VERSION,
496
+ source: {
497
+ provider: source?.provider ?? "sheet",
498
+ account: source?.account ?? "main",
499
+ batch_id: source?.batch_id ?? "first-import"
500
+ },
501
+ records: [
502
+ {
503
+ key: `${type}-1`,
504
+ type,
505
+ external_id: `${type}-1`,
506
+ operation: "upsert",
507
+ fields,
508
+ relations: columns.filter((c) => c.kind === "role").map(exampleRef)
509
+ }
510
+ ]
511
+ };
512
+ return `${JSON.stringify(envelope, null, 2)}
513
+ `;
514
+ }, "recordTemplate");
515
+ var csvRows = /* @__PURE__ */ __name((text, separator) => {
516
+ const rows = [];
517
+ let cells = [];
518
+ let cell = "";
519
+ let quoted = false;
520
+ let line = 1;
521
+ let start = 1;
522
+ const end = /* @__PURE__ */ __name(() => {
523
+ cells.push(cell);
524
+ cell = "";
525
+ }, "end");
526
+ for (let i = 0; i < text.length; i++) {
527
+ const c = text[i];
528
+ if (quoted) {
529
+ if (c === '"' && text[i + 1] === '"') {
530
+ cell += '"';
531
+ i++;
532
+ } else if (c === '"')
533
+ quoted = false;
534
+ else {
535
+ if (c === "\n")
536
+ line++;
537
+ cell += c;
538
+ }
539
+ } else if (c === '"' && cell === "")
540
+ quoted = true;
541
+ else if (c === separator)
542
+ end();
543
+ else if (c === "\n" || c === "\r") {
544
+ if (c === "\r" && text[i + 1] === "\n")
545
+ i++;
546
+ end();
547
+ rows.push({ cells, line: start });
548
+ cells = [];
549
+ line++;
550
+ start = line;
551
+ } else
552
+ cell += c;
553
+ }
554
+ if (cell !== "" || cells.length > 0) {
555
+ end();
556
+ rows.push({ cells, line: start });
557
+ }
558
+ return rows.filter((r) => r.cells.some((c) => c.trim() !== ""));
559
+ }, "csvRows");
560
+ var csvSeparator = /* @__PURE__ */ __name((header) => {
561
+ const count = /* @__PURE__ */ __name((s) => header.split(s).length - 1, "count");
562
+ return [";", " ", ","].reduce((best, s) => count(s) > count(best) ? s : best, ",");
563
+ }, "csvSeparator");
564
+ var DAY_DOTTED = /^(\d{1,2})[./](\d{1,2})[./](\d{4})$/;
565
+ var normalized = /* @__PURE__ */ __name((column, raw) => {
566
+ const value = raw.trim();
567
+ switch (column.shape) {
568
+ case "decimal": {
569
+ const plain = value.replace(/[\s  ]/g, "");
570
+ return /^\d+,\d+$/.test(plain) ? plain.replace(",", ".") : plain;
571
+ }
572
+ case "day": {
573
+ const dotted = DAY_DOTTED.exec(value);
574
+ return dotted ? `${dotted[3]}-${dotted[2]?.padStart(2, "0")}-${dotted[1]?.padStart(2, "0")}` : value;
575
+ }
576
+ case "currency":
577
+ return value.toUpperCase();
578
+ case "integer":
579
+ return /^-?\d+$/.test(value) ? Number(value) : value;
580
+ case "boolean":
581
+ return /^(true|yes|1|да|sí|si)$/i.test(value) ? true : /^(false|no|0|нет)$/i.test(value) ? false : value;
582
+ case "list":
583
+ return value.split(LIST_SEPARATOR).map((v) => v.trim()).filter(Boolean);
584
+ default:
585
+ return column.many ? value.split(LIST_SEPARATOR).map((v) => v.trim()).filter(Boolean) : value;
586
+ }
587
+ }, "normalized");
588
+ var unknownType = /* @__PURE__ */ __name((type) => ({
589
+ pointer: "",
590
+ code: "record.type",
591
+ message: `no table for ${type}: use one of ${TABLE_RECORD_TYPES.join(", ")}`
592
+ }), "unknownType");
593
+ var relationsOf = /* @__PURE__ */ __name((column, raw) => {
594
+ const targets = column.targets ?? [];
595
+ const values = column.many ? raw.split(LIST_SEPARATOR) : [raw];
596
+ const out = [];
597
+ for (const value of values.map((v) => v.trim()).filter(Boolean)) {
598
+ const at = value.indexOf(":");
599
+ const named = at > 0 ? value.slice(0, at) : "";
600
+ if (targets.length === 1 && !targets.includes(named)) {
601
+ out.push({ role: column.name, type: targets[0], external_id: value });
602
+ continue;
603
+ }
604
+ if (!targets.includes(named) || at === value.length - 1)
605
+ return {
606
+ pointer: "",
607
+ code: "record.invalid",
608
+ message: `${column.name} takes <type>:<external id>, the type one of ${targets.join(", ")}: not ${value}`
609
+ };
610
+ out.push({ role: column.name, type: named, external_id: value.slice(at + 1) });
611
+ }
612
+ return out;
613
+ }, "relationsOf");
614
+ var envelopeOfCsv = /* @__PURE__ */ __name((text, { type, source, options }) => {
615
+ const columns = recordColumns(type);
616
+ if (columns.length === 0)
617
+ throw new TableError([unknownType(type)]);
618
+ const body = text.startsWith(BOM) ? text.slice(1) : text;
619
+ const separator = csvSeparator(body.slice(0, body.search(/\r?\n|$/)));
620
+ const [head, ...rows] = csvRows(body, separator);
621
+ if (!head)
622
+ throw new TableError([{ pointer: "", code: "envelope.invalid", message: "the file has no header row" }]);
623
+ const byName = new Map(columns.map((c) => [c.name, c]));
624
+ const header = head.cells.map((name) => name.trim());
625
+ const unknown = header.filter((name) => name !== "" && !byName.has(name));
626
+ if (unknown.length > 0)
627
+ throw new TableError([
628
+ {
629
+ pointer: "",
630
+ code: "envelope.invalid",
631
+ message: `columns ${type} has no field for: ${unknown.join(", ")}. Download the ${type} template for the list`,
632
+ place: { line: 1, column: unknown[0] }
633
+ }
634
+ ]);
635
+ if (!header.includes("external_id"))
636
+ throw new TableError([
637
+ { pointer: "", code: "envelope.invalid", message: "the header has no external_id column", place: { line: 1 } }
638
+ ]);
639
+ const records = [];
640
+ const indexById = /* @__PURE__ */ new Map();
641
+ const places = /* @__PURE__ */ new Map();
642
+ const errors = [];
643
+ for (const row of rows) {
644
+ const cell = /* @__PURE__ */ __name((name) => row.cells[header.indexOf(name)] ?? "", "cell");
645
+ const id = cell("external_id").trim();
646
+ if (!id) {
647
+ errors.push({
648
+ pointer: "",
649
+ code: "record.invalid",
650
+ message: "a row has no external_id",
651
+ place: { line: row.line, column: "external_id" }
652
+ });
653
+ continue;
654
+ }
655
+ const known = indexById.get(id);
656
+ const index = known ?? records.length;
657
+ const record = records[index] ?? {
658
+ key: `${type}:${id}`,
659
+ type,
660
+ external_id: id,
661
+ operation: "upsert",
662
+ fields: {},
663
+ relations: []
664
+ };
665
+ if (known === void 0) {
666
+ records.push(record);
667
+ indexById.set(id, index);
668
+ places.set(pointerOf("records", index), { line: row.line });
669
+ }
670
+ const fields = record.fields;
671
+ const item = {};
672
+ let list = "";
673
+ header.forEach((name, i) => {
674
+ const column = byName.get(name);
675
+ const raw = row.cells[i] ?? "";
676
+ if (!column || column.kind === "id" || raw.trim() === "")
677
+ return;
678
+ const at = { line: row.line, column: name };
679
+ if (column.kind === "field") {
680
+ fields[name] = normalized(column, raw);
681
+ places.set(pointerOf("records", index, "fields", name), at);
682
+ } else if (column.kind === "role") {
683
+ const relations = relationsOf(column, raw);
684
+ if (!Array.isArray(relations)) {
685
+ errors.push({ ...relations, pointer: pointerOf("records", index, "relations"), key: record.key, place: at });
686
+ return;
687
+ }
688
+ record.relations = [...(record.relations ?? []).filter((r) => r.role !== name), ...relations];
689
+ places.set(pointerOf("records", index, "relations"), at);
690
+ } else {
691
+ const [of = "", key = ""] = name.split(".");
692
+ list = of;
693
+ item[key] = normalized(column, raw);
694
+ }
695
+ });
696
+ if (list) {
697
+ fields[list] ??= [];
698
+ const items = fields[list];
699
+ places.set(pointerOf("records", index, "fields", list, items.length), { line: row.line });
700
+ items.push(item);
701
+ }
702
+ }
703
+ if (errors.length > 0)
704
+ throw new TableError(errors);
705
+ const envelope = {
706
+ schema_version: RECORDS_SCHEMA_VERSION,
707
+ source,
708
+ ...options ? { options } : {},
709
+ records
710
+ };
711
+ return {
712
+ envelope,
713
+ placeOf(pointer) {
714
+ const item = /^\/records\/\d+\/fields\/([^/]+)\/\d+\/([^/]+)/.exec(pointer);
715
+ for (let at = pointer; at !== ""; at = at.slice(0, at.lastIndexOf("/"))) {
716
+ const place = places.get(at);
717
+ if (place)
718
+ return item && !place.column ? { ...place, column: `${item[1]}.${item[2]}` } : place;
719
+ }
720
+ return void 0;
721
+ }
722
+ };
723
+ }, "envelopeOfCsv");
724
+
365
725
  // node_modules/.pnpm/qrcode-generator@2.0.4/node_modules/qrcode-generator/dist/qrcode.mjs
366
726
  var qrcode = /* @__PURE__ */ __name(function(typeNumber, errorCorrectionLevel) {
367
727
  const PAD0 = 236;
@@ -1996,7 +2356,7 @@ var createDataURL = /* @__PURE__ */ __name(function(width, height, getPixel) {
1996
2356
  var qrcode_default = qrcode;
1997
2357
  var stringToBytes = qrcode.stringToBytes;
1998
2358
 
1999
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/terminal/qr.js
2359
+ // node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/terminal/qr.js
2000
2360
  var QUIET_ZONE = 4;
2001
2361
  var BLACK_ON_WHITE = "\x1B[30;107m";
2002
2362
  var RESET = "\x1B[0m";
@@ -2043,7 +2403,7 @@ var plainQr = /* @__PURE__ */ __name((link) => {
2043
2403
  return lines.join("\n");
2044
2404
  }, "plainQr");
2045
2405
 
2046
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/terminal/login-qr.js
2406
+ // node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/terminal/login-qr.js
2047
2407
  var MARGIN = 2;
2048
2408
  var atTerminal = /* @__PURE__ */ __name((input) => input.isTTY === true && !inputPolicy(input).noInput, "atTerminal");
2049
2409
  var PASTE_QR = "agents: paste the QR code above into the chat as a code block, exactly as printed; when a new one is printed, paste it and say the old one expired";
@@ -2092,6 +2452,11 @@ export {
2092
2452
  parseMarkdown,
2093
2453
  parseMarkdownSpans,
2094
2454
  countedPoll,
2455
+ TABLE_RECORD_TYPES,
2456
+ TableError,
2457
+ recordColumns,
2458
+ recordTemplate,
2459
+ envelopeOfCsv,
2095
2460
  terminalQr,
2096
2461
  plainQr,
2097
2462
  atTerminal,
@@ -2,15 +2,15 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  QUERY_REASONS
5
- } from "./chunk-7YRKUEYE.js";
5
+ } from "./chunk-WOX7FZJP.js";
6
6
  import {
7
7
  defineReasons
8
- } from "./chunk-GOMJNH56.js";
8
+ } from "./chunk-X7J3TTDO.js";
9
9
  import {
10
10
  __name
11
11
  } from "./chunk-ZVVMGPBJ.js";
12
12
 
13
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/errors/reasons.js
13
+ // node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/errors/reasons.js
14
14
  var validation = /* @__PURE__ */ __name((reason, message) => [reason, "validation_error", message], "validation");
15
15
  var QUERY = [
16
16
  ["query.aborted", "the search was stopped before it finished"],
@@ -68,7 +68,20 @@ var PROVIDER_API = [
68
68
  var OTHERS = [
69
69
  ["query.time-limit", "timeout", "the search took longer than its time limit; the query itself is valid"],
70
70
  ["enrichment.owner-only", "permission_error", "only the owner turns enrichment on, not an agent"],
71
+ ["search-harder.owner-only", "permission_error", "only the owner allows search all --harder, not an agent"],
71
72
  ["model.offline", "permission_error", "downloading a model needs the network; --offline was requested"],
73
+ ["model.key-rejected", "invalid_response", "the model provider refused the API key (401 or 403)"],
74
+ ["model.unreachable", "invalid_response", "the model provider could not be reached over the network"],
75
+ [
76
+ "ai.owner-only",
77
+ "permission_error",
78
+ "only the owner chooses, unsets, checks or removes the AI model and its key, or revokes its consent"
79
+ ],
80
+ ["ai.setting-invalid", "configuration_error", "the ai section or the model given is not one WireCat can use"],
81
+ validation("ai.address-refused", "the model address must be https, or http only on this computer"),
82
+ ["ai.not-set", "configuration_error", "no AI model is chosen; models ai set chooses one"],
83
+ ["ai.key-missing", "configuration_error", "no API key is stored for the AI model's address"],
84
+ ["ai.ok", "invalid_response", "models ai check: the model answered (a result, never raised)"],
72
85
  [
73
86
  "contract.unacknowledged-override",
74
87
  "configuration_error",
@@ -91,6 +104,7 @@ var OTHERS = [
91
104
  validation("mail-findings.invalid", "a checked mail findings batch would be refused; details.problems names why, finding by finding"),
92
105
  validation("mail-findings.key-used", "the findings batch key was already used for different input"),
93
106
  validation("finding.unknown-field", "a finding has a field its kind does not take"),
107
+ validation("finding.quote-not-found", "a finding's quote is not in the text it cites, word for word"),
94
108
  validation("finding.missing-field", "a finding leaves out a field its kind needs"),
95
109
  validation("document.changed", "the document changed while it was read; nothing was saved"),
96
110
  ["document.not-imported", "not_found", "the document is not imported in this source account"],
@@ -162,7 +176,7 @@ var OTHERS = [
162
176
  [
163
177
  "source.needs-sign-in",
164
178
  "authentication_error",
165
- "the page asks for a sign-in; a private Google document is read through Drive"
179
+ "the page asks for a sign-in; add a private Google document with drive documents add <url> --profiles <names|all>"
166
180
  ],
167
181
  validation("source.too-large", "the source is larger than one read takes"),
168
182
  validation("source.unsupported", "no reader takes this kind of source"),
@@ -203,6 +217,11 @@ var OTHERS = [
203
217
  "configuration_error",
204
218
  "the store file is damaged; store recover says what is lost and recovers it"
205
219
  ],
220
+ [
221
+ "store.journal-replaced",
222
+ "conflict",
223
+ "another program deleted or replaced the store's journal file while it was open; store recover says what to do"
224
+ ],
206
225
  validation("store.file-damaged", "the named store file is damaged or not a database"),
207
226
  [
208
227
  "store.unreadable",
@@ -291,8 +310,25 @@ var OTHERS = [
291
310
  validation("deal.closed", "a deleted deal or lead does not move or close"),
292
311
  validation("deal.copy", "a CRM's copy changes in the CRM; its next sync brings the change here"),
293
312
  validation("deal.field", "a field of the deal or lead is not valid"),
313
+ ["deal.denied", "permission_error", "the profile denies listing deals or leads, so none is answered"],
314
+ ["deal.out-of-scope", "not_found", "the deal or lead is a copy from an account outside the accounts asked for"],
294
315
  validation("deal.ref", "the reference names no deal or lead"),
295
316
  validation("deal.stage", "no stage of that name, or a stage name more than one pipeline has"),
317
+ validation("stage.base-field", "a base stage needs a name its set has once and a position within the set"),
318
+ validation("stage.base-outcome", "a base set keeps at least one stage of each outcome: open, won and lost"),
319
+ validation("stage.base-in-use", "the owner's own deals or leads stand or stood in that base stage"),
320
+ validation("stage.choice-required", "more than one stage of the row's pipeline maps to that base stage; move to one of the candidates"),
321
+ validation("stage.ref", "a stage is named by its stage:<id> reference"),
322
+ ["stage.owner-only", "permission_error", "only the owner confirms mappings and edits a base set, not an agent"],
323
+ validation("stage.unmapped", "no stage of the row's pipeline maps to that base stage; map one first"),
324
+ ["stage.not-found", "not_found", "no stored stage has that reference or name"],
325
+ validation("stage.answer-invalid", "the agent's answer to stages suggest is not the JSON stage map it asks for"),
326
+ ["stage.model-answer-invalid", "invalid_response", "the AI model's answer to stages suggest is not the stage map"],
327
+ [
328
+ "stage.model-agent",
329
+ "permission_error",
330
+ "an agent's run does not send stages to the AI model; it answers the task itself with --dry-run and --text-file"
331
+ ],
296
332
  validation("pipeline.ambiguous", "more than one pipeline has that name; name it by its pipeline: reference"),
297
333
  validation("pipeline.duplicate", "a pipeline of that name and kind is already stored"),
298
334
  validation("pipeline.field", "a pipeline needs a name and at least one stage, each named once"),
@@ -306,6 +342,8 @@ var OTHERS = [
306
342
  validation("field.unknown-kind", "fields are listed for deals, leads, people and organizations only"),
307
343
  validation("crm.write-unsupported", "the CRM does not take this write, or does not recognise a repeated one"),
308
344
  validation("crm.unlisted-held", "a list of every id would mark most of a kind deleted; nothing was, until --rescan"),
345
+ validation("crm.narrowing-held", "the default scope mine would mark most of a kind's stored rows deleted; none is, until the owner sets the scope"),
346
+ validation("crm.unassigned-dropped", "the CRM does not let this sign-in count a user in unassigned as nobody's; that user's deals are not copied"),
309
347
  validation("crm.not-reported", "the CRM did not list users or departments; what they would say is unknown, nothing withdrawn"),
310
348
  validation("crm.reference-unknown", "a CRM row names a contact, company or user the store does not hold; that link was not made"),
311
349
  validation("crm.pending-dropped", "relationships waited too long for an end that never came; they were dropped"),
@@ -352,12 +390,27 @@ var OTHERS = [
352
390
  "conflict",
353
391
  "the owner separated this identity from that person; only the owner links it again"
354
392
  ],
355
- ["identity.owner-only", "permission_error", "only the owner undoes a merge or splits a person"],
393
+ [
394
+ "identity.owner-only",
395
+ "permission_error",
396
+ "only the owner undoes a merge, splits a person, confirms or undoes a link, or links an identity to themselves"
397
+ ],
356
398
  [
357
399
  "identity.stale",
358
400
  "conflict",
359
- "an identity of the merge was merged on into another person since; undo that merge first"
401
+ "the people a merge or a proposed link names changed since; undo the later merge, or propose the link again"
402
+ ],
403
+ [
404
+ "identity.rejected",
405
+ "conflict",
406
+ "the owner rejected linking these people on this evidence; only a new signal or identity proposes them again"
360
407
  ],
408
+ validation("identity.same", "the two identities are one person already"),
409
+ validation("identity.shared-phone", "more than six people share the phone number, so it proposes no one"),
410
+ validation("identity.common-name", "more than six people have the name, so it proposes no one"),
411
+ validation("identity.owner", "one side is the owner's person, and only the owner joins anyone to themselves"),
412
+ validation("identity.shared-email", "more than six people share the address, so it proposes no one"),
413
+ validation("identity-link.dedicated-review", "an identity link is staged and decided through the people review"),
361
414
  ["transcription.no-key", "authentication_error", "no OpenAI key is set for transcription"],
362
415
  validation("transcription.too-large", "the audio is over the transcription provider's size limit"),
363
416
  [
@@ -372,8 +425,9 @@ var OTHERS = [
372
425
  validation("output.unknown-field", "the answer has no field by that name"),
373
426
  validation("name.taken", "the name is already used"),
374
427
  validation("period.ambiguous", "the period can be read more than one way"),
428
+ ["press.owner-hand-only", "permission_error", "this button decides something for the owner; only a hand presses it"],
375
429
  validation("proposal.wrong-state", "the proposal is not in a state that allows this"),
376
- validation("proposal.reason-required", "an agent deciding for the owner gives a reason"),
430
+ validation("proposal.reason-required", "an agent deciding for the owner, or proposing a link, gives a reason"),
377
431
  validation("decision.request-invalid", "a decision request needs its batch, message, owner and distinct known actions"),
378
432
  ["decision.token-unknown", "not_found", "no button has this token"],
379
433
  ["decision.token-used", "permission_error", "this button was already pressed"],
@@ -390,6 +444,7 @@ var OTHERS = [
390
444
  ],
391
445
  validation("proposal.decider-required", "a decision names who decides: the owner or an agent with a reason"),
392
446
  validation("proposal.ids", "the proposal ids cannot be read"),
447
+ ["group.outside", "permission_error", "the process is locked to a group, and this belongs to accounts outside it"],
393
448
  ["proposal.own", "permission_error", "an agent never decides its own proposal"],
394
449
  ["proposal.owner-only", "permission_error", "only the owner decides this proposal"],
395
450
  ["proposals.agent-decisions-off", "permission_error", "agent decisions are turned off; the owner decides"],