@narumitw/pi-sync 0.66.0 → 0.67.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 (94) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +11 -2
  3. package/dist/chunks/{chunk-BYVHABNR.ts → chunk-2MUAR5GH.ts} +2 -2
  4. package/dist/chunks/{chunk-5YOLQKNZ.ts → chunk-3CO7QIYB.ts} +14 -14
  5. package/dist/chunks/{chunk-DAZZ5BEJ.ts → chunk-3NS4PMCI.ts} +6 -2
  6. package/dist/chunks/{chunk-FI2F5JBS.ts → chunk-3Q3DMMID.ts} +8 -8
  7. package/dist/chunks/{chunk-BESRBKVO.ts → chunk-CQXGMESM.ts} +7 -7
  8. package/dist/chunks/{chunk-SZJOUVCL.ts → chunk-DGVZYS7T.ts} +5 -5
  9. package/dist/chunks/{chunk-WJQ4TGN5.ts → chunk-ECUCXF5Y.ts} +2 -2
  10. package/dist/chunks/{chunk-Z5JMOXJM.ts → chunk-JNTDIVP6.ts} +5 -5
  11. package/dist/chunks/{chunk-AYGMIMCV.ts → chunk-PUSMSKIM.ts} +11 -2
  12. package/dist/chunks/chunk-PUSMSKIM.ts.map +7 -0
  13. package/dist/chunks/{chunk-ASU3GZPW.ts → chunk-W7DSN33J.ts} +6 -6
  14. package/dist/chunks/{chunk-JQ5BAWW2.ts → chunk-XPKHWTGT.ts} +77 -16
  15. package/dist/chunks/chunk-XPKHWTGT.ts.map +7 -0
  16. package/dist/chunks/{command-handler-44EFGPWH.ts → command-handler-H5X3BX5D.ts} +40 -32
  17. package/dist/chunks/command-handler-H5X3BX5D.ts.map +7 -0
  18. package/dist/chunks/config-P54GGMXY.ts +39 -0
  19. package/dist/chunks/{conflict-review-J7L7S4AR.ts → conflict-review-SSY37F4P.ts} +2 -2
  20. package/dist/chunks/{file-selection-XWACUTAH.ts → file-selection-GASCVN45.ts} +6 -6
  21. package/dist/chunks/{ignore-file-ui-OHFISFVC.ts → ignore-file-ui-UY2TEK4C.ts} +5 -5
  22. package/dist/chunks/{manager-result-dispatcher-WXE2BAQO.ts → manager-result-dispatcher-PEVIGLOS.ts} +7 -7
  23. package/dist/chunks/{manager-ui-CVZLMXJ5.ts → manager-ui-R5XHYRXK.ts} +165 -34
  24. package/dist/chunks/manager-ui-R5XHYRXK.ts.map +7 -0
  25. package/dist/chunks/{merge-review-AAC674C6.ts → merge-review-C2KETZKY.ts} +3 -3
  26. package/dist/chunks/{remote-selection-ui-E4XZCQ7A.ts → remote-selection-ui-WFLX6MAJ.ts} +6 -6
  27. package/dist/chunks/{setup-switch-644T6KHG.ts → setup-switch-JZDFQPVW.ts} +4 -4
  28. package/dist/chunks/setup-switch-JZDFQPVW.ts.map +7 -0
  29. package/dist/chunks/{setup-wizard-IEW56AZE.ts → setup-wizard-5OMFSFPJ.ts} +9 -9
  30. package/dist/chunks/{sync-inspection-NBBTSMKR.ts → sync-inspection-S2GHDBAD.ts} +5 -5
  31. package/dist/chunks/{sync-operations-AIEM2KL2.ts → sync-operations-LQ63CU2T.ts} +2 -2
  32. package/dist/daemon/dist/client.js +32 -18
  33. package/dist/daemon/dist/daemon-recovery.js +5 -3
  34. package/dist/daemon/dist/engine/ignore/adoption-journal.js +6 -3
  35. package/dist/daemon/dist/engine/ignore/ignore-edit.js +2 -2
  36. package/dist/daemon/dist/engine/ignore/ignore-settings.js +2 -1
  37. package/dist/daemon/dist/engine/settings/config-file.js +3 -0
  38. package/dist/daemon/dist/engine/settings/config.js +5 -5
  39. package/dist/daemon/dist/engine/settings/settings-management.js +6 -1
  40. package/dist/daemon/dist/engine/settings/settings-validation.js +21 -2
  41. package/dist/daemon/dist/engine/sync/continuous-errors.js +6 -0
  42. package/dist/daemon/dist/engine/sync/continuous-sync.js +4 -2
  43. package/dist/daemon/dist/engine/sync/ignore-adoption.js +17 -2
  44. package/dist/daemon/dist/engine/sync/merge-apply.js +18 -1
  45. package/dist/daemon/dist/engine/sync/merged-sync.js +36 -4
  46. package/dist/daemon/dist/engine/sync/push-review.js +33 -0
  47. package/dist/daemon/dist/engine/sync/sync-mutations.js +42 -49
  48. package/dist/daemon/dist/engine/sync/sync-rollback.js +16 -2
  49. package/dist/daemon/dist/engine/sync/transfer-freshness.js +3 -2
  50. package/dist/daemon/dist/engine/sync/transfer-size-limits.js +92 -0
  51. package/dist/daemon/dist/engine-service.js +22 -6
  52. package/dist/daemon/dist/foreground-queue-outcome.js +4 -0
  53. package/dist/daemon/dist/server.js +2 -1
  54. package/dist/daemon/dist/service-host.js +7 -2
  55. package/dist/daemon/package.json +1 -1
  56. package/dist/index.ts +41 -32
  57. package/dist/index.ts.map +2 -2
  58. package/docs/daemon-migration.md +8 -0
  59. package/docs/tui-contract.md +4 -3
  60. package/package.json +2 -2
  61. package/skills/configure-pi-sync/SKILL.md +1 -1
  62. package/skills/configure-pi-sync/references/configuration.md +33 -6
  63. package/src/commands/command-execution.ts +10 -1
  64. package/src/commands/command-handler.ts +4 -0
  65. package/src/daemon/directional-recovery.ts +35 -5
  66. package/src/daemon/pi-client.ts +82 -12
  67. package/src/sync-extension.ts +17 -9
  68. package/src/ui/cancellable-operation.ts +13 -2
  69. package/src/ui/manager-state.ts +1 -0
  70. package/src/ui/manager-ui.ts +25 -4
  71. package/src/ui/settings-ui.ts +128 -4
  72. package/dist/chunks/chunk-AYGMIMCV.ts.map +0 -7
  73. package/dist/chunks/chunk-JQ5BAWW2.ts.map +0 -7
  74. package/dist/chunks/command-handler-44EFGPWH.ts.map +0 -7
  75. package/dist/chunks/manager-ui-CVZLMXJ5.ts.map +0 -7
  76. /package/dist/chunks/{chunk-BYVHABNR.ts.map → chunk-2MUAR5GH.ts.map} +0 -0
  77. /package/dist/chunks/{chunk-5YOLQKNZ.ts.map → chunk-3CO7QIYB.ts.map} +0 -0
  78. /package/dist/chunks/{chunk-DAZZ5BEJ.ts.map → chunk-3NS4PMCI.ts.map} +0 -0
  79. /package/dist/chunks/{chunk-FI2F5JBS.ts.map → chunk-3Q3DMMID.ts.map} +0 -0
  80. /package/dist/chunks/{chunk-BESRBKVO.ts.map → chunk-CQXGMESM.ts.map} +0 -0
  81. /package/dist/chunks/{chunk-SZJOUVCL.ts.map → chunk-DGVZYS7T.ts.map} +0 -0
  82. /package/dist/chunks/{chunk-WJQ4TGN5.ts.map → chunk-ECUCXF5Y.ts.map} +0 -0
  83. /package/dist/chunks/{chunk-Z5JMOXJM.ts.map → chunk-JNTDIVP6.ts.map} +0 -0
  84. /package/dist/chunks/{chunk-ASU3GZPW.ts.map → chunk-W7DSN33J.ts.map} +0 -0
  85. /package/dist/chunks/{ignore-file-ui-OHFISFVC.ts.map → config-P54GGMXY.ts.map} +0 -0
  86. /package/dist/chunks/{conflict-review-J7L7S4AR.ts.map → conflict-review-SSY37F4P.ts.map} +0 -0
  87. /package/dist/chunks/{file-selection-XWACUTAH.ts.map → file-selection-GASCVN45.ts.map} +0 -0
  88. /package/dist/chunks/{manager-result-dispatcher-WXE2BAQO.ts.map → ignore-file-ui-UY2TEK4C.ts.map} +0 -0
  89. /package/dist/chunks/{merge-review-AAC674C6.ts.map → manager-result-dispatcher-PEVIGLOS.ts.map} +0 -0
  90. /package/dist/chunks/{remote-selection-ui-E4XZCQ7A.ts.map → merge-review-C2KETZKY.ts.map} +0 -0
  91. /package/dist/chunks/{setup-switch-644T6KHG.ts.map → remote-selection-ui-WFLX6MAJ.ts.map} +0 -0
  92. /package/dist/chunks/{setup-wizard-IEW56AZE.ts.map → setup-wizard-5OMFSFPJ.ts.map} +0 -0
  93. /package/dist/chunks/{sync-inspection-NBBTSMKR.ts.map → sync-inspection-S2GHDBAD.ts.map} +0 -0
  94. /package/dist/chunks/{sync-operations-AIEM2KL2.ts.map → sync-operations-LQ63CU2T.ts.map} +0 -0
@@ -32,6 +32,11 @@ export class DirectionalCheckpoint {
32
32
  function recoveryOutcome(value: unknown) {
33
33
  if (!value || typeof value !== "object" || !("foregroundQueueCleanup" in value)) return;
34
34
  if (value.foregroundQueueCleanup === "before-mutation") return { phase: "unchanged" as const };
35
+ if (value.foregroundQueueCleanup === "resume-adoption") {
36
+ if (!("journal" in value) || typeof value.journal !== "string" || !/^[a-f0-9]{64}$/u.test(value.journal))
37
+ throw new Error("The recorded Pull could not be verified. Use /sync daemon recover.");
38
+ return { phase: "adoption" as const, journal: value.journal };
39
+ }
35
40
  if (value.foregroundQueueCleanup === "verified-result" && "result" in value)
36
41
  return { phase: "completed" as const, result: value.result };
37
42
  }
@@ -53,16 +58,26 @@ function cancelledAfterCompletion(result: unknown, cause: unknown) {
53
58
  return error;
54
59
  }
55
60
 
61
+ export interface PendingAdoptionRecovery {
62
+ owner: DaemonConnection;
63
+ job: string;
64
+ journal: string;
65
+ }
66
+
56
67
  export async function runDirectionalRecovery(
57
68
  connection: DaemonConnection,
58
69
  signal: AbortSignal,
59
- run: (checkpoint: DirectionalCheckpoint, retryCheckpoint?: string) => Promise<unknown>,
70
+ run: (checkpoint: DirectionalCheckpoint, retryCheckpoint?: string, retryAdoptionJournal?: string) => Promise<unknown>,
60
71
  recover: (connection: DaemonConnection, job: string, signal: AbortSignal) => Promise<DaemonConnection>,
61
72
  markCleanupRequired: () => void,
73
+ adoption?: { pending?: PendingAdoptionRecovery; retain(value: PendingAdoptionRecovery | undefined): void },
62
74
  ) {
63
75
  signal.throwIfAborted();
76
+ const pending = adoption?.pending;
77
+ if (pending && pending.owner !== connection) throw new Error("The daemon changed before Pull recovery.");
64
78
  const attempt = new DirectionalCheckpoint(connection);
65
- const result = await run(attempt);
79
+ attempt.job = pending?.job;
80
+ const result = pending ? { foregroundQueueCleanup: "resume-adoption", journal: pending.journal } : await run(attempt);
66
81
  const primary = recoveryOutcome(result);
67
82
  if (!primary) return result;
68
83
  markCleanupRequired();
@@ -70,9 +85,16 @@ export async function runDirectionalRecovery(
70
85
  const bounded = AbortSignal.any([signal, AbortSignal.timeout(45_000)]);
71
86
  try {
72
87
  bounded.throwIfAborted();
73
- if (!attempt.job || (primary.phase === "unchanged" && !attempt.fingerprint))
88
+ if (
89
+ !attempt.job ||
90
+ (primary.phase === "unchanged" && !attempt.fingerprint) ||
91
+ (primary.phase === "adoption" && (!adoption || (!pending && !attempt.fingerprint)))
92
+ )
74
93
  throw new Error("The original transfer scope could not be verified.");
94
+ if (primary.phase === "adoption")
95
+ adoption?.retain({ owner: connection, job: attempt.job, journal: primary.journal });
75
96
  replacement = await recover(connection, attempt.job, bounded);
97
+ if (primary.phase === "adoption") adoption?.retain(undefined);
76
98
  bounded.throwIfAborted();
77
99
  } catch (error) {
78
100
  if (signal.aborted) {
@@ -85,11 +107,14 @@ export async function runDirectionalRecovery(
85
107
  `The transfer finished, but file-queue recovery stopped. ${detail}${restoreMessage(primary.result)}`,
86
108
  { cause: error },
87
109
  );
110
+ if (primary.phase === "adoption")
111
+ throw new Error(`Pull recovery stopped. The adoption journal was kept. ${detail}`, { cause: error });
88
112
  throw new Error(`No transfer was applied, but file-queue recovery stopped. ${detail}`, { cause: error });
89
113
  }
90
114
  if (primary.phase === "completed") return primary.result;
91
- const retry = new DirectionalCheckpoint(replacement, attempt.fingerprint);
92
- const retried = await run(retry, attempt.fingerprint);
115
+ const retryCheckpoint = primary.phase === "unchanged" ? attempt.fingerprint : undefined;
116
+ const retry = new DirectionalCheckpoint(replacement, retryCheckpoint);
117
+ const retried = await run(retry, retryCheckpoint, primary.phase === "adoption" ? primary.journal : undefined);
93
118
  const remaining = recoveryOutcome(retried);
94
119
  if (!remaining) return retried;
95
120
  markCleanupRequired();
@@ -99,5 +124,10 @@ export async function runDirectionalRecovery(
99
124
  `Transfer finished, but file-queue cleanup is still uncertain after one recovery attempt.${restoreMessage(remaining.result)}`,
100
125
  );
101
126
  }
127
+ if (remaining.phase === "adoption") {
128
+ if (retry.job && retry.fingerprint)
129
+ adoption?.retain({ owner: replacement, job: retry.job, journal: remaining.journal });
130
+ throw new Error("File-queue cleanup is still uncertain after one recovery attempt. The adoption journal was kept.");
131
+ }
102
132
  throw new Error("File-queue release could not be verified after one recovery attempt. No transfer was applied.");
103
133
  }
@@ -42,7 +42,12 @@ import {
42
42
  import { safeTerminalText } from "../ui/terminal-text.js";
43
43
  import { PiApplyGate } from "./apply-gate.js";
44
44
  import { observeDebugJob } from "./client-debug.js";
45
- import { type DirectionalCheckpoint, isForegroundDirection, runDirectionalRecovery } from "./directional-recovery.js";
45
+ import {
46
+ type DirectionalCheckpoint,
47
+ isForegroundDirection,
48
+ type PendingAdoptionRecovery,
49
+ runDirectionalRecovery,
50
+ } from "./directional-recovery.js";
46
51
  import { createQueueReleaseUI, type QueueReleaseEvent } from "./queue-release-ui.js";
47
52
  import { quarantineClient, recoverDetachedClients } from "./recovery.js";
48
53
  import { requestStartupBootstrap } from "./startup-bootstrap-client.js";
@@ -268,6 +273,11 @@ export class PiDaemonClient {
268
273
  private reloadRequest?: { received: boolean };
269
274
  private pendingReload?: AbortController;
270
275
  private directionalCheckpoint?: DirectionalCheckpoint;
276
+ private adoptionRecovery?: {
277
+ pending: PendingAdoptionRecovery;
278
+ review: { setupName: string; fingerprint: string };
279
+ assertRoot(): void;
280
+ };
271
281
  private recoveringDirectionalOwner = false;
272
282
  private readonly busy = new Set<string>();
273
283
  private initialized = false;
@@ -754,7 +764,20 @@ export class PiDaemonClient {
754
764
  get ownershipCleanupRequired() {
755
765
  return this.cleanupRequired;
756
766
  }
767
+ get pendingPullReview() {
768
+ const recovery = this.adoptionRecovery;
769
+ if (
770
+ !this.cleanupRequired ||
771
+ !recovery ||
772
+ this.paused ||
773
+ recovery.pending.owner !== this.connection ||
774
+ !recovery.pending.owner.canRecoverForeground(recovery.pending.job)
775
+ )
776
+ return undefined;
777
+ return recovery.review;
778
+ }
757
779
  confirmRecoveryExit(owner: DaemonRecoveryTarget) {
780
+ this.adoptionRecovery = undefined;
758
781
  this.cleanupRequired = true;
759
782
  this.recoveredOwner = owner;
760
783
  }
@@ -777,10 +800,17 @@ export class PiDaemonClient {
777
800
  ctx = this.ctx,
778
801
  onCommit?: () => void,
779
802
  reload?: AbortController,
803
+ requirePendingAdoption = false,
780
804
  ) {
781
805
  const diagnostics = this.debug ? observeDebugJob(operation, (event) => this.recordDebug(event)) : undefined;
806
+ const adoptionRecovery =
807
+ operation === "pull.foreground" && this.pendingPullReview ? this.adoptionRecovery : undefined;
782
808
  const result = this.work
783
- .then(() => this.runCurrent(operation, payload, signal, ctx, onCommit, reload, diagnostics))
809
+ .then(() => {
810
+ if (requirePendingAdoption && !adoptionRecovery)
811
+ throw new Error("The original Pull is no longer available for automatic recovery.");
812
+ return this.runCurrent(operation, payload, signal, ctx, onCommit, reload, diagnostics, adoptionRecovery);
813
+ })
784
814
  .catch((error: unknown) => {
785
815
  diagnostics?.rejected(error, Boolean(signal?.aborted || reload?.signal.aborted));
786
816
  this.recordOwnershipFailure(error);
@@ -832,8 +862,11 @@ export class PiDaemonClient {
832
862
  onCommit?: () => void,
833
863
  reload?: AbortController,
834
864
  diagnostics?: ReturnType<typeof observeDebugJob>,
865
+ adoptionRecovery?: PiDaemonClient["adoptionRecovery"],
835
866
  ) {
836
867
  this.validate();
868
+ if (adoptionRecovery && (this.adoptionRecovery !== adoptionRecovery || !this.pendingPullReview))
869
+ throw new Error("The original Pull is no longer available for automatic recovery.");
837
870
  signal?.throwIfAborted();
838
871
  reload?.signal.throwIfAborted();
839
872
  if (this.pendingReload) throw new Error("Pi resources are about to reload.");
@@ -862,17 +895,39 @@ export class PiDaemonClient {
862
895
  runSignal.addEventListener("abort", clearForeground, { once: true });
863
896
  try {
864
897
  const root = isForegroundDirection(operation) ? lstatSync(this.root) : undefined;
865
- const assertRoot = () => {
866
- const current = lstatSync(this.root);
867
- if (!root || !current.isDirectory() || current.dev !== root.dev || current.ino !== root.ino)
868
- throw new Error("The agent directory changed during the transfer.");
869
- };
898
+ const assertRoot =
899
+ adoptionRecovery?.assertRoot ??
900
+ (() => {
901
+ const current = lstatSync(this.root);
902
+ if (!root || !current.isDirectory() || current.dev !== root.dev || current.ino !== root.ino)
903
+ throw new Error("The agent directory changed during the transfer.");
904
+ });
870
905
  const intent = root ? structuredClone(payload) : payload;
906
+ const pull = operation === "pull.foreground" ? (intent as { setup: string; fingerprint: string }) : undefined;
907
+ if (
908
+ adoptionRecovery &&
909
+ (!pull ||
910
+ pull.setup !== adoptionRecovery.review.setupName ||
911
+ pull.fingerprint !== adoptionRecovery.review.fingerprint)
912
+ )
913
+ throw new Error("The sync setup changed before Pull recovery.");
914
+ if (adoptionRecovery) {
915
+ assertRoot();
916
+ const { createSettingsConfigView, syncCheckConfigFingerprint } = await import("../settings/config.js");
917
+ this.validateFactsScope(connection, runSignal);
918
+ const document = await peekLocalConfigDocument();
919
+ this.validateFactsScope(connection, runSignal);
920
+ const config = document && (await createSettingsConfigView(document).observe(undefined, runSignal));
921
+ this.validateFactsScope(connection, runSignal);
922
+ assertRoot();
923
+ if (!config || syncCheckConfigFingerprint(config) !== adoptionRecovery.review.fingerprint)
924
+ throw new Error("The sync setup changed before Pull recovery.");
925
+ }
871
926
  const result = root
872
927
  ? await runDirectionalRecovery(
873
928
  connection,
874
929
  runSignal,
875
- async (checkpoint, retryCheckpoint) => {
930
+ async (checkpoint, retryCheckpoint, retryAdoptionJournal) => {
876
931
  const current = checkpoint.connection;
877
932
  this.validateFactsScope(current, runSignal);
878
933
  assertRoot();
@@ -880,7 +935,11 @@ export class PiDaemonClient {
880
935
  try {
881
936
  return await current.run(
882
937
  operation,
883
- retryCheckpoint === undefined ? intent : { ...(intent as object), retryCheckpoint },
938
+ retryAdoptionJournal !== undefined
939
+ ? { ...pull, retryAdoptionJournal }
940
+ : retryCheckpoint === undefined
941
+ ? intent
942
+ : { ...(intent as object), retryCheckpoint },
884
943
  runSignal,
885
944
  onCommit,
886
945
  (id) => {
@@ -896,6 +955,16 @@ export class PiDaemonClient {
896
955
  () => {
897
956
  this.cleanupRequired = true;
898
957
  },
958
+ pull && {
959
+ pending: adoptionRecovery?.pending,
960
+ retain: (pending) => {
961
+ this.adoptionRecovery = pending && {
962
+ pending,
963
+ review: { setupName: pull.setup, fingerprint: pull.fingerprint },
964
+ assertRoot,
965
+ };
966
+ },
967
+ },
899
968
  )
900
969
  : await connection.run(operation, payload, runSignal, onCommit, diagnostics?.onSubmit);
901
970
  if (runSignal.aborted || reload?.signal.aborted) diagnostics?.rejected(undefined, true);
@@ -1081,6 +1150,7 @@ export class PiDaemonClient {
1081
1150
  helpText?: string;
1082
1151
  background?: boolean;
1083
1152
  fingerprint?: string;
1153
+ adoptionRecovery?: number;
1084
1154
  };
1085
1155
  if (callback.kind === "queue-release") {
1086
1156
  if (typeof payload?.reservation !== "string") throw new Error("Invalid queue release.");
@@ -1092,9 +1162,9 @@ export class PiDaemonClient {
1092
1162
  if (this.paused) throw new Error("Pi session is changing; no new work is authorized.");
1093
1163
  if (callback.kind === "directional-checkpoint") {
1094
1164
  this.validateFactsScope(connection, this.runSignal);
1095
- return (
1096
- !protectionOnly && this.directionalCheckpoint?.accept(connection, callback.job, payload?.fingerprint) === true
1097
- );
1165
+ if (protectionOnly || this.directionalCheckpoint?.accept(connection, callback.job, payload?.fingerprint) !== true)
1166
+ return false;
1167
+ return payload.adoptionRecovery === 1 ? { adoptionRecovery: 1 } : true;
1098
1168
  }
1099
1169
  if (callback.kind === "queue-acquire") {
1100
1170
  if (this.pendingReload) throw new Error("Pi resources are about to reload.");
@@ -65,15 +65,23 @@ export default function sync(pi: ExtensionAPI, dependencies: Partial<SyncDepende
65
65
  }
66
66
  const commands = await loaders.commands();
67
67
  if (signal.aborted || owner !== client) return;
68
- await commands.handleCommand(
69
- args,
70
- ctx,
71
- commandSignal,
72
- loaders,
73
- attention,
74
- undefined,
75
- needsDaemonRecovery,
76
- );
68
+ const recoveryMenu = !command && client.pendingPullReview;
69
+ if (recoveryMenu) await client.setBusy("command", true, false);
70
+ try {
71
+ if (signal.aborted || owner !== client) return;
72
+ await commands.handleCommand(
73
+ args,
74
+ ctx,
75
+ commandSignal,
76
+ loaders,
77
+ attention,
78
+ undefined,
79
+ needsDaemonRecovery,
80
+ );
81
+ } finally {
82
+ if (recoveryMenu && !signal.aborted && owner === client)
83
+ await client.setBusy("command", false, !needsDaemonRecovery()).catch(() => {});
84
+ }
77
85
  return;
78
86
  }
79
87
  const requiresContact = !["help", "unlock", "migrate-state"].includes(command ?? "");
@@ -19,6 +19,7 @@ export type RunRoute = (
19
19
  onDialog?: (active: boolean) => void,
20
20
  retryRefusal?: boolean,
21
21
  directionalFingerprint?: string,
22
+ requirePendingAdoption?: boolean,
22
23
  ) => Promise<RunRouteResult | undefined>;
23
24
 
24
25
  export type CancellableOperationResult = RunRouteResult | { kind: "closed" } | { kind: "cancelled" };
@@ -29,6 +30,7 @@ interface CancellableOperationOptions {
29
30
  cancelledMessage?: string | null;
30
31
  target?: string;
31
32
  directionalFingerprint?: string;
33
+ requirePendingAdoption?: boolean;
32
34
  signal?: AbortSignal;
33
35
  isCurrent?: () => boolean;
34
36
  }
@@ -44,7 +46,16 @@ export async function runCancellableOperation(
44
46
  ctx,
45
47
  message,
46
48
  (signal, onCommit, onDialog) =>
47
- runRoute(route, signal, onCommit, options.target, onDialog, undefined, options.directionalFingerprint),
49
+ runRoute(
50
+ route,
51
+ signal,
52
+ onCommit,
53
+ options.target,
54
+ onDialog,
55
+ undefined,
56
+ options.directionalFingerprint,
57
+ options.requirePendingAdoption,
58
+ ),
48
59
  options,
49
60
  );
50
61
  return result.kind === "completed" ? (result.value ?? { kind: "failed" }) : result;
@@ -64,7 +75,7 @@ export async function runCancellableTask<Value>(
64
75
  onCommit?: () => void,
65
76
  onDialog?: (active: boolean) => void,
66
77
  ) => Promise<Value>,
67
- options: Omit<CancellableOperationOptions, "target" | "directionalFingerprint"> = {},
78
+ options: Omit<CancellableOperationOptions, "target" | "directionalFingerprint" | "requirePendingAdoption"> = {},
68
79
  ): Promise<CancellableTaskResult<Value>> {
69
80
  const {
70
81
  commitAware = false,
@@ -38,6 +38,7 @@ export interface ManagerDescription {
38
38
  title: string;
39
39
  actions: string[];
40
40
  configReview?: { setupName: string; fingerprint: string };
41
+ recoveryPull?: true;
41
42
  settingsReview?: { setupName: string; fingerprint: string };
42
43
  operation?: OperationAvailability;
43
44
  attention?: SyncAttentionState;
@@ -27,7 +27,10 @@ export async function showSyncManager(
27
27
  ctx: ExtensionCommandContext,
28
28
  runRoute: RunRoute,
29
29
  sessionSignal?: AbortSignal,
30
- options: SyncManagerAttentionOptions & { needsDaemonRecovery?: () => boolean } = {},
30
+ options: SyncManagerAttentionOptions & {
31
+ needsDaemonRecovery?: () => boolean;
32
+ getPendingPullReview?: () => { setupName: string; fingerprint: string } | undefined;
33
+ } = {},
31
34
  ): Promise<void> {
32
35
  if (!ctx.hasUI) {
33
36
  await runRoute("help");
@@ -80,6 +83,7 @@ export async function showSyncManager(
80
83
  cancelledMessage: direction === "push" ? "Push cancellation requested." : "Pull cancellation requested.",
81
84
  target: review.setupName,
82
85
  directionalFingerprint: review.fingerprint,
86
+ requirePendingAdoption: state.manager.recoveryPull,
83
87
  signal,
84
88
  isCurrent,
85
89
  },
@@ -347,7 +351,14 @@ export async function showSyncManager(
347
351
  const activate = menu.actions[action];
348
352
  menu.actions[action] = async (invocation) => {
349
353
  validateOwner();
350
- const { configReview, settingsReview } = invocation.state.manager;
354
+ const { configReview, settingsReview, recoveryPull } = invocation.state.manager;
355
+ if (action === "pull" && recoveryPull) {
356
+ if (options.getPendingPullReview?.() !== configReview) {
357
+ ctx.ui.notify("The original Pull is no longer available for automatic recovery.", "warning");
358
+ return { kind: "stay" };
359
+ }
360
+ return activate(invocation);
361
+ }
351
362
  const review = action === "settings" ? (settingsReview ?? configReview) : configReview;
352
363
  let current = false;
353
364
  try {
@@ -392,15 +403,25 @@ export async function showSyncManager(
392
403
  "Pi Sync recovery required\nDaemon cleanup could not be confirmed. Stop the daemon before retrying a transfer.",
393
404
  actions: ["Stop daemon for recovery…", "Help"],
394
405
  };
406
+ const describeRecovery = (): State["manager"] => {
407
+ const configReview = options.getPendingPullReview?.();
408
+ if (!configReview) return recovery;
409
+ return {
410
+ title: "Pi Sync recovery required\nPull can try to recover the daemon and review the pending transfer.",
411
+ actions: ["Pull from remote", ...recovery.actions],
412
+ configReview,
413
+ recoveryPull: true,
414
+ };
415
+ };
395
416
  const describe = async (signal: AbortSignal) => {
396
- if (options.needsDaemonRecovery?.()) return recovery;
417
+ if (options.needsDaemonRecovery?.()) return describeRecovery();
397
418
  const pendingAttention = options.getAttention?.();
398
419
  const observation = options.getObservation?.();
399
420
  const manager = await describeManagerState(signal, pendingAttention, undefined, observation, () =>
400
421
  ignoreFileSettingsAvailable(ctx, signal),
401
422
  );
402
423
  if (signal.aborted || !isCurrent()) return manager;
403
- if (options.needsDaemonRecovery?.()) return recovery;
424
+ if (options.needsDaemonRecovery?.()) return describeRecovery();
404
425
  // A busy operation suppresses baseline reads, not the stored check-time hint.
405
426
  if (
406
427
  observation &&
@@ -1,4 +1,5 @@
1
1
  import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
2
+ import { isKeyRelease, Key, matchesKey } from "@earendil-works/pi-tui";
2
3
  import { defineMenu, type MenuSettingItem, runMenu } from "@narumitw/pi-tui-kit";
3
4
  import { piDaemonClient } from "../daemon/pi-client.js";
4
5
  import { configFromSettings, loadSettingsConfig, syncCheckConfigFingerprint } from "../settings/config.js";
@@ -37,6 +38,22 @@ import { safeTerminalText } from "./terminal-text.js";
37
38
 
38
39
  export type SyncSettingsRoute = RunRoute;
39
40
 
41
+ type SettingsState = Awaited<ReturnType<typeof loadSettingsConfig>>;
42
+ const transferSizeLimits = [
43
+ {
44
+ field: "maxFileSizeMiB",
45
+ label: "Max file size",
46
+ description: "Block a transfer when an included file exceeds this uncompressed size.",
47
+ },
48
+ {
49
+ field: "maxDirectorySizeMiB",
50
+ label: "Max directory size",
51
+ description:
52
+ "Block a transfer when a directory below the sync root exceeds this total uncompressed size, counting included files in its subdirectories too.",
53
+ },
54
+ ] as const;
55
+ type TransferSizeLimit = (typeof transferSizeLimits)[number];
56
+
40
57
  export async function showSyncSettings(
41
58
  ctx: ExtensionCommandContext,
42
59
  runRoute: SyncSettingsRoute,
@@ -63,7 +80,7 @@ export async function showSyncSettings(
63
80
  const document = await readActiveLocalConfigDocumentForRepair().catch(() => null);
64
81
  if (!isCurrent()) return disposition;
65
82
  const settingsPath = document?.path ?? localConfigPath();
66
- let config: Awaited<ReturnType<typeof loadSettingsConfig>> | undefined;
83
+ let config: ReturnType<typeof configFromSettings> | undefined;
67
84
  try {
68
85
  if (document) config = configFromSettings(validateSettingsDocument(document.parsed), reviewedSetup);
69
86
  } catch {
@@ -77,6 +94,12 @@ export async function showSyncSettings(
77
94
  ? "Could not read the active pi-sync settings file. Check file access or repair the JSON before reopening /sync."
78
95
  : `Edit pi-sync settings manually: ${safeTerminalText(settingsPath)}`,
79
96
  ...(limited ? [IGNORE_SETUP_MANAGEMENT_LIMIT, ...ignoreSetupRecovery(settingsPath)] : []),
97
+ ...(!limited && config
98
+ ? [
99
+ "In the active entry in syncSetups, set sync.maxFileSizeMiB or sync.maxDirectorySizeMiB to a positive whole number of MiB with a safe byte count. Remove a field to turn that limit Off.",
100
+ "A limit requires settings version 9. Upgrade all Pi Sync clients and daemons that share this agent directory before enabling a limit. Keep version 9 even if both limits are later Off.",
101
+ ]
102
+ : []),
80
103
  ...(!limited && config?.reservedIgnoreNames !== undefined
81
104
  ? ["Use TUI Settings → Review automatic transfers to approve the current setup separately."]
82
105
  : []),
@@ -120,8 +143,8 @@ export async function showSyncSettings(
120
143
  const ignoreAvailable = await ignoreFileSettingsAvailable(ctx, signal);
121
144
  if (!isCurrent()) return disposition;
122
145
  const setupName = initial.setupName;
123
- type SettingsState = Awaited<ReturnType<typeof loadSettingsConfig>>;
124
146
  type Action =
147
+ | TransferSizeLimit["field"]
125
148
  | "automatic"
126
149
  | "automatic-transfer"
127
150
  | "agent-mode"
@@ -238,6 +261,13 @@ export async function showSyncSettings(
238
261
  currentValue: `${state.localFields?.length ?? 0} fields · Edit`,
239
262
  action: "local-fields",
240
263
  },
264
+ ...transferSizeLimits.map(({ field, label, description }) => ({
265
+ id: field,
266
+ label,
267
+ description: `This setup: ${description} Also applies to automatic transfers. Saving starts no transfer.`,
268
+ currentValue: transferSizeLimitLabel(state[field]),
269
+ action: field,
270
+ })),
241
271
  {
242
272
  id: "storageLocation",
243
273
  label: "Storage location",
@@ -386,6 +416,8 @@ export async function showSyncSettings(
386
416
  }),
387
417
  },
388
418
  actions: {
419
+ maxFileSizeMiB: transferSizeLimitAction(transferSizeLimits[0]),
420
+ maxDirectorySizeMiB: transferSizeLimitAction(transferSizeLimits[1]),
389
421
  "storage-location": async ({ signal: actionSignal }) => {
390
422
  const editorSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
391
423
  await showEditSyncSetupStorage(ctx, setupName, editorSignal);
@@ -412,7 +444,7 @@ export async function showSyncSettings(
412
444
  if (
413
445
  !(await ctx.ui.confirm(
414
446
  "Save content policy?",
415
- `${previous.pathPolicy === "ignore-file" ? "Ignore-file policy keeps settings version 8 and publishes snapshot version 7; upgrade older clients first." : previous.scope === "agent-directory" ? "Agent directory scope uses snapshot version 5; older clients must refuse it." : "This explicitly upgrades settings to at least version 5; partial snapshots use version 3, or version 4 with exclusions, and older clients must refuse them."} Text/session merge is conservative. Partial sync preserves withheld versions and old baselines. Disabling does not clear unresolved groups or recovery evidence. Review a directional migration first if portable policy changes.`,
447
+ `${previous.pathPolicy === "ignore-file" ? `Ignore-file policy keeps settings version ${previous.settingsVersion} and publishes snapshot version 7; upgrade older clients first.` : previous.scope === "agent-directory" ? "Agent directory scope uses snapshot version 5; older clients must refuse it." : "This explicitly upgrades settings to at least version 5; partial snapshots use version 3, or version 4 with exclusions, and older clients must refuse them."} Text/session merge is conservative. Partial sync preserves withheld versions and old baselines. Disabling does not clear unresolved groups or recovery evidence. Review a directional migration first if portable policy changes.`,
416
448
  { signal: mutationSignal },
417
449
  ))
418
450
  )
@@ -488,7 +520,7 @@ export async function showSyncSettings(
488
520
  if (sameLocalFields(previous.localFields, fields)) return { kind: "stay" };
489
521
  const confirmed = await ctx.ui.confirm(
490
522
  "Save portable field policy?",
491
- `${previous.pathPolicy === "ignore-file" ? "Ignore-file policy keeps settings version 8 and publishes snapshot version 7." : previous.scope === "agent-directory" ? "Agent directory scope uses snapshot version 5." : "This opts into at least settings/snapshot version 4/2; exclude-enabled setups retain snapshot version 4."} Older clients must refuse unsupported formats. Future snapshots omit these fields, but old remote history is NOT erased. Review an explicit force push/pull migration before further sync. Removed rules can expose or replace local-only values.`,
523
+ `${previous.pathPolicy === "ignore-file" ? `Ignore-file policy keeps settings version ${previous.settingsVersion} and publishes snapshot version 7.` : previous.scope === "agent-directory" ? "Agent directory scope uses snapshot version 5." : "This opts into at least settings/snapshot version 4/2; exclude-enabled setups retain snapshot version 4."} Older clients must refuse unsupported formats. Future snapshots omit these fields, but old remote history is NOT erased. Review an explicit force push/pull migration before further sync. Removed rules can expose or replace local-only values.`,
492
524
  { signal: mutationSignal },
493
525
  );
494
526
  validate();
@@ -768,6 +800,84 @@ export async function showSyncSettings(
768
800
  return result;
769
801
  };
770
802
  }
803
+ function transferSizeLimitAction({ field, label }: TransferSizeLimit) {
804
+ return async ({ state, signal: actionSignal }: { state: SettingsState; signal: AbortSignal }) => {
805
+ const cancel = new AbortController();
806
+ const mutationSignal = AbortSignal.any([actionSignal, cancel.signal, ...(signal ? [signal] : [])]);
807
+ const validate = captureMutationOwner(ctx, mutationSignal);
808
+ const rejected = { kind: "rejected" } as const;
809
+ const stay = { kind: "stay" } as const;
810
+ const setupLabel = safeTerminalText(setupName);
811
+ let limit: number | undefined;
812
+ try {
813
+ const expectedConfigFingerprint = syncCheckConfigFingerprint(state);
814
+ const active = await loadSettingsConfig();
815
+ validate();
816
+ if (active.setupName !== setupName || syncCheckConfigFingerprint(active) !== expectedConfigFingerprint) {
817
+ throw new Error("Current sync setup changed while Settings was open; reopen Settings.");
818
+ }
819
+ const stop = ctx.ui.onTerminalInput((data) => {
820
+ if (!isKeyRelease(data) && matchesKey(data, Key.ctrl("c"))) {
821
+ cancel.abort();
822
+ return { consume: true };
823
+ }
824
+ });
825
+ try {
826
+ const input = await ctx.ui.input(
827
+ `${label} for “${setupLabel}” (current: ${transferSizeLimitLabel(state[field])})\nEnter Off or a positive whole number of MiB.`,
828
+ undefined,
829
+ { signal: mutationSignal },
830
+ );
831
+ validate();
832
+ if (input === undefined) return rejected;
833
+ limit = parseTransferSizeLimit(input);
834
+ if (limit === state[field]) return stay;
835
+ if (limit !== undefined && active.settingsVersion < 9) {
836
+ const confirmed = await ctx.ui.confirm(
837
+ "Upgrade Pi Sync settings to version 9?",
838
+ `${label} for “${setupLabel}”: ${transferSizeLimitLabel(limit)}. Older Pi Sync clients and daemons cannot read this settings file for any setup. Upgrade all processes that share this agent directory before continuing. Turning both limits Off later does not downgrade the file. Remote snapshots are unchanged.`,
839
+ { signal: mutationSignal },
840
+ );
841
+ validate();
842
+ if (!confirmed) return rejected;
843
+ }
844
+ } finally {
845
+ stop();
846
+ }
847
+ validate();
848
+ ctx.ui.notify("Saving Pi Sync setting…", "info");
849
+ await updateSyncSetup(
850
+ setupName,
851
+ (setup) => {
852
+ validate();
853
+ if (limit === undefined) delete setup.sync[field];
854
+ else setup.sync[field] = limit;
855
+ return setup;
856
+ },
857
+ { expectedActiveSetup: true, expectedConfigFingerprint, signal: mutationSignal },
858
+ );
859
+ } catch (error) {
860
+ if (cancel.signal.aborted) return exitSettings();
861
+ if (!mutationSignal.aborted && isCurrent()) notifySaveFailure(ctx, error);
862
+ return rejected;
863
+ }
864
+ try {
865
+ validate();
866
+ const approval =
867
+ state.reservedIgnoreNames !== undefined &&
868
+ (startupTransferEnabled(state) || (state.automatic && syncSessionsSelected(state)))
869
+ ? " Use Review automatic transfers to approve this policy separately."
870
+ : "";
871
+ ctx.ui.notify(
872
+ `Saved. ${label} for “${setupLabel}”: ${transferSizeLimitLabel(limit)}. Applies to subsequent transfers; no transfer started.${approval}`,
873
+ "info",
874
+ );
875
+ } catch {
876
+ return stay;
877
+ }
878
+ return stay;
879
+ };
880
+ }
771
881
  function ignoreAction(action: Parameters<typeof showIgnoreFileAction>[2]) {
772
882
  return async ({ state, signal: actionSignal }: { state: SettingsState; signal: AbortSignal }) => {
773
883
  if (!ignoreAvailable || (state.pathPolicy === "ignore-file") === (action === "migrate"))
@@ -802,6 +912,20 @@ export async function showSyncSettings(
802
912
  return disposition;
803
913
  }
804
914
 
915
+ function transferSizeLimitLabel(limit: number | undefined) {
916
+ return limit === undefined ? "Off" : `${limit} MiB`;
917
+ }
918
+
919
+ function parseTransferSizeLimit(input: string) {
920
+ const value = input.trim();
921
+ if (value.toLowerCase() === "off") return undefined;
922
+ const limit = Number(value);
923
+ if (!/^[0-9]+$/u.test(value) || limit <= 0 || !Number.isSafeInteger(limit * 1_048_576)) {
924
+ throw new Error("Enter Off or a positive whole number of MiB that fits in a safe byte count.");
925
+ }
926
+ return limit;
927
+ }
928
+
805
929
  function notifySaveFailure(ctx: ExtensionCommandContext, error: unknown) {
806
930
  ctx.ui.notify(
807
931
  `Pi Sync settings save failed: ${safeTerminalText(error instanceof Error ? error.message : String(error))}`,
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/ui/cancellable-operation.ts"],
4
- "sourcesContent": ["import { BorderedLoader, type ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { isKeyRelease, Key, matchesKey, truncateToWidth } from \"@earendil-works/pi-tui\";\nimport { formatInteractionHints, runCustomInteraction } from \"@narumitw/pi-tui-kit\";\nimport type { SetupPullOutcome } from \"../sync/setup-switch.js\";\nimport type { SyncDecision } from \"../sync/sync-decision.js\";\nimport type { RemoteSelectionDecision } from \"../sync/sync-policy.js\";\n\nexport type RunRouteResult =\n | { kind: \"completed\"; outcome?: SetupPullOutcome }\n | { kind: \"decision-required\"; decision: SyncDecision }\n | { kind: \"remote-selection-required\"; decision: RemoteSelectionDecision }\n | { kind: \"failed\" };\n\nexport type RunRoute = (\n route: string,\n signal?: AbortSignal,\n onCommit?: () => void,\n target?: string,\n onDialog?: (active: boolean) => void,\n retryRefusal?: boolean,\n directionalFingerprint?: string,\n) => Promise<RunRouteResult | undefined>;\n\nexport type CancellableOperationResult = RunRouteResult | { kind: \"closed\" } | { kind: \"cancelled\" };\n\ninterface CancellableOperationOptions {\n commitAware?: boolean;\n cancelAcrossDialogs?: boolean;\n cancelledMessage?: string | null;\n target?: string;\n directionalFingerprint?: string;\n signal?: AbortSignal;\n isCurrent?: () => boolean;\n}\n\nexport async function runCancellableOperation(\n ctx: ExtensionContext,\n message: string,\n route: string,\n runRoute: RunRoute,\n options: CancellableOperationOptions = {},\n): Promise<CancellableOperationResult> {\n const result = await runCancellableTask(\n ctx,\n message,\n (signal, onCommit, onDialog) =>\n runRoute(route, signal, onCommit, options.target, onDialog, undefined, options.directionalFingerprint),\n options,\n );\n return result.kind === \"completed\" ? (result.value ?? { kind: \"failed\" }) : result;\n}\n\nexport type CancellableTaskResult<Value> =\n | { kind: \"completed\"; value: Value }\n | { kind: \"closed\" }\n | { kind: \"cancelled\" };\n\n/** Keep non-route work under the same cancellation and drain owner as transfers. */\nexport async function runCancellableTask<Value>(\n ctx: ExtensionContext,\n message: string,\n task: (\n signal: AbortSignal | undefined,\n onCommit?: () => void,\n onDialog?: (active: boolean) => void,\n ) => Promise<Value>,\n options: Omit<CancellableOperationOptions, \"target\" | \"directionalFingerprint\"> = {},\n): Promise<CancellableTaskResult<Value>> {\n const {\n commitAware = false,\n cancelAcrossDialogs = false,\n cancelledMessage = \"Check cancelled; no settings or files were changed.\",\n signal,\n isCurrent = () => true,\n } = options;\n if (signal?.aborted || !isCurrent()) return { kind: \"closed\" };\n if (ctx.mode !== \"tui\") return { kind: \"completed\", value: await task(signal) };\n let commitStarted = false;\n let taskResult!: Value;\n const interaction = await runCustomInteraction<{ cancelled?: boolean; error?: unknown }, ExtensionContext>(ctx, {\n signal,\n isCurrent: () => !signal?.aborted && isCurrent(),\n create: ({ tui, theme, keybindings, signal: interactionSignal, complete }) => {\n const loader = new BorderedLoader(tui, theme, message, { cancellable: false });\n const cancelHint = formatInteractionHints(keybindings, [\n {\n keys: [...keybindings.getKeys(\"tui.select.cancel\").filter((key) => !hasControlCharacter(key)), \"ctrl+c\"],\n label: \"cancel\",\n },\n ]);\n const cancel = (data: string) => {\n // Raw terminal listeners run before Pi filters Kitty key releases.\n if (isKeyRelease(data)) return false;\n if (!matchesKey(data, Key.ctrl(\"c\")) && !keybindings.matches(data, \"tui.select.cancel\")) return false;\n if (commitStarted) {\n ctx.ui.notify(\"Applying or publishing has started and cannot be cancelled safely.\", \"warning\");\n } else complete({ cancelled: true });\n return true;\n };\n // Pi dialogs replace this loader and restore the normal editor. Defer\n // ordinary keys while they are open; retain raw cancellation afterward.\n // Ctrl+C remains the root flow's hard-cancel path regardless of focus.\n let activeDialogs = 0;\n const unsubscribe = cancelAcrossDialogs\n ? ctx.ui.onTerminalInput((data) => {\n if (isKeyRelease(data)) return;\n if (activeDialogs > 0 && !matchesKey(data, Key.ctrl(\"c\"))) return;\n return cancel(data) ? { consume: true } : undefined;\n })\n : undefined;\n let pendingTask: Promise<Value>;\n try {\n pendingTask = task(\n interactionSignal,\n commitAware ? () => (commitStarted = true) : undefined,\n cancelAcrossDialogs\n ? (active) => {\n activeDialogs += active ? 1 : -1;\n }\n : undefined,\n );\n } catch (error) {\n unsubscribe?.();\n loader.dispose();\n throw error;\n }\n const operation = pendingTask.then(\n (result) => {\n taskResult = result;\n complete({});\n },\n (error: unknown) => complete({ error }),\n );\n return {\n render(width: number) {\n if (width <= 0) return [];\n const safeWidth = Math.max(1, width);\n const lines = loader.render(safeWidth);\n const bottomBorder = lines.at(-1);\n return [\n ...lines.slice(0, -1),\n truncateToWidth(theme.fg(\"dim\", cancelHint), safeWidth, \"\"),\n ...(bottomBorder === undefined ? [] : [bottomBorder]),\n ];\n },\n invalidate: () => loader.invalidate(),\n handleInput: cancel,\n dispose() {\n unsubscribe?.();\n loader.dispose();\n },\n waitForPending: () => operation,\n };\n },\n });\n if (interaction.kind === \"error\") throw interaction.error;\n if (interaction.kind !== \"completed\") return { kind: \"closed\" };\n if (interaction.value.cancelled) {\n if (cancelledMessage) ctx.ui.notify(cancelledMessage, \"info\");\n return { kind: \"cancelled\" };\n }\n if (interaction.value.error) throw interaction.value.error;\n return { kind: \"completed\", value: taskResult };\n}\n\nfunction hasControlCharacter(value: string) {\n // biome-ignore lint/suspicious/noControlCharactersInRegex: Unsafe key labels must be omitted.\n return /[\\u0000-\\u001f\\u007f-\\u009f]/u.test(value);\n}\n"],
5
- "mappings": "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",
6
- "names": []
7
- }