deepline 0.3.508 → 0.3.510

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 (136) hide show
  1. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  2. package/dist/bundling-sources/shared_libs/monitors/org-monitor-limits.ts +7 -2
  3. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +1 -1
  4. package/dist/bundling-sources/shared_libs/play-runtime/db-session-plan.ts +47 -6
  5. package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-execution-relay.ts +94 -43
  6. package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-receipt-gateway.ts +111 -27
  7. package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/runtime-topology.ts +79 -6
  8. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +80 -6
  9. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-transient-retry.ts +571 -0
  10. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +1 -0
  11. package/dist/cli/auth-S2Z5YMU3.js +43 -0
  12. package/dist/cli/{auth-2URIN52G.mjs → auth-USS2W3UV.mjs} +5 -5
  13. package/dist/cli/{billing-IW23GSR5.mjs → billing-JCUWM5XB.mjs} +7 -7
  14. package/dist/cli/{billing-R2HY2ZVJ.js → billing-LQQHU443.js} +82 -82
  15. package/dist/cli/{chunk-7PELFO3C.js → chunk-2JXEZAJF.js} +21 -21
  16. package/dist/cli/chunk-3LXU22UZ.js +77 -0
  17. package/dist/cli/{chunk-74UO7THC.js → chunk-4NJK6P5T.js} +4 -4
  18. package/dist/cli/{chunk-FXKKFM7J.js → chunk-4ZIIS6KG.js} +9 -9
  19. package/dist/cli/{chunk-63MCLOR2.mjs → chunk-563HM4D2.mjs} +6 -6
  20. package/dist/cli/{chunk-XSOLA2ED.mjs → chunk-5DU7RXDW.mjs} +4 -4
  21. package/dist/cli/{chunk-OWH7SSBO.mjs → chunk-5MYXW6M6.mjs} +2 -2
  22. package/dist/cli/{chunk-3BZ74K27.js → chunk-5N2HFB3G.js} +16 -16
  23. package/dist/cli/{chunk-2YOM5J3G.js → chunk-63DHG7BM.js} +26 -26
  24. package/dist/cli/{chunk-P7GOQTUN.js → chunk-6AL2VF3E.js} +14 -14
  25. package/dist/cli/{chunk-QBZECLNG.mjs → chunk-7BF4R26M.mjs} +3 -3
  26. package/dist/cli/{chunk-JRHMPZJX.js → chunk-7VQKU6MS.js} +7 -7
  27. package/dist/cli/{chunk-3C6VBHNW.mjs → chunk-7VT7RMZ2.mjs} +2 -2
  28. package/dist/cli/{chunk-M37I4A2Z.js → chunk-ASBWPRBN.js} +16 -16
  29. package/dist/cli/{chunk-3ZNPIJX6.js → chunk-B2T7PBS6.js} +41 -41
  30. package/dist/cli/{chunk-NC2FIUPX.mjs → chunk-B2U3LVSO.mjs} +1 -1
  31. package/dist/cli/{chunk-RNZQ7RDW.mjs → chunk-B6Q6BHSY.mjs} +2 -2
  32. package/dist/cli/{chunk-IZZ7FFWP.js → chunk-BPGFNVH2.js} +44 -44
  33. package/dist/cli/{chunk-2PYFXXYA.mjs → chunk-CLV4T5FN.mjs} +2 -2
  34. package/dist/cli/{chunk-JEB6BNIU.mjs → chunk-DEPBCRKG.mjs} +15 -4
  35. package/dist/cli/{chunk-DZ7JCRAL.mjs → chunk-DMF56C6D.mjs} +2 -2
  36. package/dist/cli/{chunk-RWXHMG6F.js → chunk-EEQ2QQOH.js} +21 -10
  37. package/dist/cli/{chunk-UDH3YMBI.mjs → chunk-EJ57CA2L.mjs} +1 -1
  38. package/dist/cli/{chunk-JYNHHO3J.js → chunk-F6IXWFPF.js} +6 -6
  39. package/dist/cli/{chunk-DWV7KM6H.mjs → chunk-FFPLCSTZ.mjs} +10 -10
  40. package/dist/cli/{chunk-VXNL4HLE.mjs → chunk-FND6GZZ4.mjs} +5 -5
  41. package/dist/cli/{chunk-D73YB5NQ.js → chunk-HC27PYJM.js} +2 -2
  42. package/dist/cli/{chunk-FRT5MFLF.mjs → chunk-HOKOJGQW.mjs} +1 -1
  43. package/dist/cli/{chunk-AYNO4VFW.js → chunk-JNECQ5QF.js} +11 -11
  44. package/dist/cli/chunk-JVEU6MXD.mjs +77 -0
  45. package/dist/cli/{chunk-ZLIAUR2E.js → chunk-JY73USD7.js} +2 -2
  46. package/dist/cli/{chunk-K4RME7AV.mjs → chunk-KXSOZYCS.mjs} +1 -1
  47. package/dist/cli/{chunk-ESVK4Z7S.js → chunk-LF3FF2B2.js} +1 -1
  48. package/dist/cli/{chunk-63BGKU3A.js → chunk-N7FV7OM3.js} +96 -96
  49. package/dist/cli/{chunk-Q4I5YKN4.mjs → chunk-OEG6VCK4.mjs} +1 -1
  50. package/dist/cli/{chunk-2LY42EZJ.mjs → chunk-PQ56GE55.mjs} +1 -1
  51. package/dist/cli/{chunk-GRGZKXLL.mjs → chunk-Q5EJO4TE.mjs} +5 -5
  52. package/dist/cli/{chunk-N5HRBS4K.js → chunk-QRQBKLOM.js} +3 -3
  53. package/dist/cli/{chunk-4DAR2GYV.mjs → chunk-RHKFNEV2.mjs} +2 -2
  54. package/dist/cli/{chunk-C6TP4DR3.mjs → chunk-UV524JZ5.mjs} +1 -1
  55. package/dist/cli/{chunk-KSQO32L5.mjs → chunk-V6DLYRSO.mjs} +1 -1
  56. package/dist/cli/{chunk-J3LJ37WD.js → chunk-VPJSQMWQ.js} +3 -3
  57. package/dist/cli/{chunk-3XBI4KZM.mjs → chunk-WAOLTP6R.mjs} +2 -2
  58. package/dist/cli/{chunk-JXYVBF5L.mjs → chunk-WC5754QJ.mjs} +5 -5
  59. package/dist/cli/{chunk-RUD77W2Y.js → chunk-XJZU7KO4.js} +5 -5
  60. package/dist/cli/{chunk-GDHLL5EQ.js → chunk-XK3AJFYQ.js} +35 -10
  61. package/dist/cli/{chunk-JUYW6TSU.js → chunk-XL4FFVWL.js} +7 -7
  62. package/dist/cli/{chunk-ZL2ME3UT.js → chunk-XRLE2FPE.js} +6 -6
  63. package/dist/cli/{chunk-R4S2AK3Q.js → chunk-YDALHHUC.js} +53 -53
  64. package/dist/cli/{chunk-IF242BIJ.mjs → chunk-YYUVOUEH.mjs} +5 -5
  65. package/dist/cli/{chunk-TVADI7K5.js → chunk-ZCYV6MZH.js} +5 -5
  66. package/dist/cli/{chunk-AFSYNOG4.mjs → chunk-ZRACZKEE.mjs} +35 -10
  67. package/dist/cli/command-docs.js +2 -2
  68. package/dist/cli/command-docs.mjs +1 -1
  69. package/dist/cli/{csv-CMJSMC2I.mjs → csv-MTFVEDPU.mjs} +4 -4
  70. package/dist/cli/{csv-DPDO6BU6.js → csv-UXFQZLZM.js} +13 -13
  71. package/dist/cli/{db-SL3EFN6V.mjs → db-3WPUYCCI.mjs} +6 -6
  72. package/dist/cli/{db-PPPKNTT5.js → db-RGWT6B7K.js} +27 -27
  73. package/dist/cli/describe-LNCLA2LA.js +50 -0
  74. package/dist/cli/{describe-XLN33FJX.mjs → describe-XJY5654F.mjs} +18 -18
  75. package/dist/cli/{executions-6YDTV2J6.js → executions-IWTALFNB.js} +8 -8
  76. package/dist/cli/{executions-O6Z5B5NY.mjs → executions-PDE4V5YH.mjs} +6 -6
  77. package/dist/cli/{feedback-DP7LPWAD.mjs → feedback-BMOVTPC4.mjs} +11 -7
  78. package/dist/cli/{feedback-BZ434BN4.js → feedback-I72P4XZS.js} +15 -11
  79. package/dist/cli/{git-MI7E5WGL.mjs → git-QJG3EF4P.mjs} +5 -5
  80. package/dist/cli/git-QWH7SPGF.js +25 -0
  81. package/dist/cli/index.js +173 -156
  82. package/dist/cli/index.mjs +76 -59
  83. package/dist/cli/{legacy-noops-65WNPQVZ.js → legacy-noops-5P75CQC7.js} +9 -8
  84. package/dist/cli/{legacy-noops-6VYXF2MG.mjs → legacy-noops-MZ45GDMK.mjs} +6 -5
  85. package/dist/cli/{monitors-BYUCTVSC.js → monitors-5PHQZDZM.js} +100 -100
  86. package/dist/cli/{monitors-Y7I5ZVCN.mjs → monitors-VIOBUG2X.mjs} +7 -7
  87. package/dist/cli/{org-F2ASWTFY.js → org-B5LDVP2P.js} +72 -72
  88. package/dist/cli/{org-IW3YD6JZ.mjs → org-D5RTFJNY.mjs} +6 -6
  89. package/dist/cli/{pages-X6HLRQNV.js → pages-BUJYG3JL.js} +18 -18
  90. package/dist/cli/{pages-H2CXNIDB.mjs → pages-XWZL3YV2.mjs} +6 -6
  91. package/dist/cli/{play-LLEEDXRX.mjs → play-OSXLGCLZ.mjs} +93 -54
  92. package/dist/cli/{play-H2EM7DTI.js → play-SEC3EE7H.js} +468 -429
  93. package/dist/cli/{providers-BZR5JONN.mjs → providers-ENSURIW6.mjs} +6 -6
  94. package/dist/cli/{providers-6R2SPOEV.js → providers-RQPUASLI.js} +9 -9
  95. package/dist/cli/{quickstart-KVES7R6D.mjs → quickstart-HJTK6XWI.mjs} +4 -4
  96. package/dist/cli/{quickstart-PW7ONQUH.js → quickstart-XDTU4MAT.js} +6 -6
  97. package/dist/cli/{run-HVUQROBE.js → run-GX2SU5AT.js} +41 -41
  98. package/dist/cli/{run-RDI3Q6GO.mjs → run-ZMWSQAR2.mjs} +23 -23
  99. package/dist/cli/search-7WPABWYO.js +33 -0
  100. package/dist/cli/{search-3TJ24CUF.mjs → search-DZHZBHWT.mjs} +8 -8
  101. package/dist/cli/{search-output-JHT553SL.js → search-output-3JVZERNV.js} +6 -6
  102. package/dist/cli/{search-output-Y57OBQXX.mjs → search-output-MNHAR754.mjs} +4 -4
  103. package/dist/cli/{secrets-OZK7GRD5.mjs → secrets-VALVNVXB.mjs} +6 -6
  104. package/dist/cli/{secrets-U5JHWAXU.js → secrets-WO2LMDQ2.js} +15 -15
  105. package/dist/cli/sessions-2IA2DGWO.js +18 -0
  106. package/dist/cli/{sessions-D6DSEQ2T.mjs → sessions-EPYCH3AY.mjs} +6 -5
  107. package/dist/cli/{settings-DLPEHYGS.js → settings-OSF4O5HM.js} +109 -82
  108. package/dist/cli/{settings-ITLSLT2R.mjs → settings-W2ABZUD4.mjs} +39 -12
  109. package/dist/cli/{setup-Y5ZYEC6U.js → setup-DCXNQG6R.js} +50 -50
  110. package/dist/cli/{setup-XTYLF2CF.mjs → setup-XI2ERSMQ.mjs} +10 -10
  111. package/dist/cli/skills-QMD2WARJ.js +37 -0
  112. package/dist/cli/{skills-C4WCAVII.mjs → skills-ZO4AH2YR.mjs} +8 -8
  113. package/dist/cli/tools-53E6GBQU.js +57 -0
  114. package/dist/cli/{tools-ZESAPVOW.mjs → tools-FTECXZYA.mjs} +17 -17
  115. package/dist/cli/update-PPPNR6J5.js +35 -0
  116. package/dist/cli/{update-4PCKVDCS.mjs → update-WPFZO2JE.mjs} +10 -10
  117. package/dist/cli/{workflow-42CL4TVR.mjs → workflow-7X75IP3D.mjs} +7 -7
  118. package/dist/cli/{workflow-XXKXMPTI.js → workflow-PKMU33LV.js} +17 -17
  119. package/dist/index.js +9 -9
  120. package/dist/index.mjs +6 -6
  121. package/dist/install-integrity.json +105 -102
  122. package/dist/release.d.mts +1 -1
  123. package/dist/release.d.ts +1 -1
  124. package/dist/release.js +2 -2
  125. package/dist/release.mjs +1 -1
  126. package/dist/server.js +5 -5
  127. package/dist/server.mjs +3 -3
  128. package/package.json +1 -1
  129. package/dist/cli/auth-LFU77QDI.js +0 -43
  130. package/dist/cli/describe-JKZ67X3E.js +0 -50
  131. package/dist/cli/git-U5N6CTML.js +0 -25
  132. package/dist/cli/search-NKEEGLY6.js +0 -33
  133. package/dist/cli/sessions-PNMYAJNB.js +0 -17
  134. package/dist/cli/skills-K6FVG3BX.js +0 -37
  135. package/dist/cli/tools-LSALTN7I.js +0 -57
  136. package/dist/cli/update-P5KGNFNL.js +0 -35
@@ -0,0 +1,571 @@
1
+ /**
2
+ * One bounded retry policy for transient Fly.io API failures in the
3
+ * Production runtime release path.
4
+ *
5
+ * On 2026-11-12 four Production releases failed on a single transient
6
+ * api.machines.dev error each (HTTP/2 `INTERNAL_ERROR` stream resets, a Fly
7
+ * 5xx surfaced by flyctl as `internal: internal server error`, and a 30 s
8
+ * Machines API read timeout) while Fly reported itself operational. Two of
9
+ * them left the gateway fleets in a mixed generation because the automatic
10
+ * rollback hit the same kind of error and stopped at the first Machine.
11
+ *
12
+ * Rules:
13
+ * - Retry only an operation that converges when repeated: reads, cordon,
14
+ * uncordon, start, stop, metadata writes, and staged secret writes of the
15
+ * same values. A create is never repeated blindly; its caller re-reads
16
+ * provider state first (see `createWithReadBeforeRetry`).
17
+ * - Retry only a failure classified as transient from structured data (HTTP
18
+ * status, Node/Bun error code, subprocess exit status) or from the stable
19
+ * transport text flyctl prints (`FLY_TRANSIENT_OUTPUT_PATTERNS`). Auth,
20
+ * validation, capacity, and every other 4xx stays a first-attempt failure.
21
+ * - At most `attempts` tries with jittered exponential backoff (1 s, 2 s,
22
+ * 4 s, plus up to 25% jitter) inside one wall-clock deadline. A 429
23
+ * Retry-After is honored when it still fits inside that deadline.
24
+ * - A subprocess killed by a signal or by its own deadline (exit 124 or
25
+ * >= 128) may have applied its effect; only a read may repeat it.
26
+ */
27
+
28
+ export const FLY_TRANSIENT_RETRY_ATTEMPTS = 4;
29
+ export const FLY_TRANSIENT_RETRY_BASE_DELAY_MS = 1_000;
30
+ /** Covers four 30 s Machines API attempts plus their backoff. */
31
+ export const FLY_TRANSIENT_RETRY_DEADLINE_MS = 150_000;
32
+ const FLY_TRANSIENT_RETRY_JITTER_RATIO = 0.25;
33
+
34
+ /**
35
+ * Stable transport text printed by flyctl (Go net/http, x/net/http2) and the
36
+ * Fly API when a request failed before or while Fly answered it. Each pattern
37
+ * names a transport or server-side failure, never a request the API refused.
38
+ *
39
+ * - `stream error: stream ID 1; INTERNAL_ERROR; received from peer` and
40
+ * `REFUSED_STREAM`: HTTP/2 stream reset by api.machines.dev.
41
+ * - `http2: server sent GOAWAY`: the API closed the connection mid-request.
42
+ * - `connection reset by peer`, `broken pipe`, `unexpected EOF`, a Go error
43
+ * ending in `: EOF`: the connection dropped.
44
+ * - `TLS handshake timeout`, `i/o timeout`, `Client.Timeout exceeded`,
45
+ * `context deadline exceeded`: a request or connection timed out.
46
+ * - `internal: internal server error`, `Internal Server Error`,
47
+ * `Bad Gateway`, `Service Unavailable`, `Gateway Timeout`: a Fly 5xx.
48
+ * - `Too Many Requests`, `rate limit`: a Fly 429.
49
+ */
50
+ export const FLY_TRANSIENT_OUTPUT_PATTERNS: readonly RegExp[] = [
51
+ /stream error: stream ID \d+; (?:INTERNAL_ERROR|REFUSED_STREAM)/,
52
+ /http2: server sent GOAWAY/,
53
+ /connection reset by peer/,
54
+ /\bbroken pipe\b/,
55
+ /\bunexpected EOF\b/,
56
+ /: EOF\s*$/m,
57
+ /TLS handshake timeout/,
58
+ /\bi\/o timeout\b/,
59
+ /Client\.Timeout exceeded/,
60
+ /context deadline exceeded/,
61
+ /\binternal server error\b/i,
62
+ /\b(?:502 )?Bad Gateway\b/,
63
+ /\b(?:503 )?Service Unavailable\b/,
64
+ /\b(?:504 )?Gateway Timeout\b/,
65
+ /\bToo Many Requests\b/,
66
+ /\brate limit(?:ed)?\b/i,
67
+ ];
68
+
69
+ /** Node/Bun network error codes for a request that never got an answer. */
70
+ const TRANSIENT_NETWORK_ERROR_CODES = new Set([
71
+ 'ECONNRESET',
72
+ 'ECONNREFUSED',
73
+ 'ECONNABORTED',
74
+ 'EPIPE',
75
+ 'ETIMEDOUT',
76
+ 'EAI_AGAIN',
77
+ 'ENETUNREACH',
78
+ 'EHOSTUNREACH',
79
+ 'UND_ERR_SOCKET',
80
+ 'UND_ERR_CONNECT_TIMEOUT',
81
+ 'UND_ERR_HEADERS_TIMEOUT',
82
+ 'UND_ERR_BODY_TIMEOUT',
83
+ 'UND_ERR_CLOSED',
84
+ 'ConnectionClosed',
85
+ 'ConnectionRefused',
86
+ 'ConnectionReset',
87
+ ]);
88
+
89
+ export type FlyTransientClassification =
90
+ | Readonly<{ transient: false }>
91
+ | Readonly<{ transient: true; reason: string; retryAfterMs?: number }>;
92
+
93
+ const PERMANENT: FlyTransientClassification = { transient: false };
94
+
95
+ /** True for statuses Fly documents as retryable server or rate-limit errors. */
96
+ export function isTransientFlyHttpStatus(status: number): boolean {
97
+ return status === 429 || (status >= 500 && status <= 599);
98
+ }
99
+
100
+ /** Parse a Retry-After header (delta-seconds or HTTP date) into milliseconds. */
101
+ export function parseRetryAfterMs(
102
+ value: string | null | undefined,
103
+ nowMs: number,
104
+ ): number | undefined {
105
+ if (typeof value !== 'string' || value.trim() === '') return undefined;
106
+ const seconds = Number(value.trim());
107
+ if (Number.isFinite(seconds)) return Math.max(0, seconds * 1_000);
108
+ const date = Date.parse(value);
109
+ return Number.isFinite(date) ? Math.max(0, date - nowMs) : undefined;
110
+ }
111
+
112
+ /** The first transport pattern flyctl output names, if any. */
113
+ export function transientFlyOutputReason(output: string): string | undefined {
114
+ for (const pattern of FLY_TRANSIENT_OUTPUT_PATTERNS) {
115
+ const match = pattern.exec(output);
116
+ if (match) return match[0].trim();
117
+ }
118
+ return undefined;
119
+ }
120
+
121
+ /**
122
+ * Classify one finished flyctl subprocess. `read` operations may repeat after
123
+ * a timeout or signal; any other operation may have applied its effect, so it
124
+ * is repeated only after a clean nonzero exit that names a transport error.
125
+ */
126
+ export function classifyFlyCommandFailure(input: {
127
+ status: number | null;
128
+ signal?: string | null;
129
+ timedOut?: boolean;
130
+ output: string;
131
+ operation: 'read' | 'idempotent-write';
132
+ }): FlyTransientClassification {
133
+ if (input.status === 0) return PERMANENT;
134
+ const killed =
135
+ input.timedOut === true ||
136
+ input.status === null ||
137
+ Boolean(input.signal) ||
138
+ input.status === 124 ||
139
+ input.status >= 128;
140
+ if (killed) {
141
+ return input.operation === 'read'
142
+ ? {
143
+ transient: true,
144
+ reason: input.timedOut
145
+ ? 'command timed out'
146
+ : `command ended by ${input.signal ?? `status ${input.status}`}`,
147
+ }
148
+ : PERMANENT;
149
+ }
150
+ const reason = transientFlyOutputReason(input.output);
151
+ return reason ? { transient: true, reason } : PERMANENT;
152
+ }
153
+
154
+ function errorCode(error: unknown): string | undefined {
155
+ if (!error || typeof error !== 'object') return undefined;
156
+ const code = (error as { code?: unknown }).code;
157
+ return typeof code === 'string' ? code : undefined;
158
+ }
159
+
160
+ /** Thrown by a Fly API request that received a transient HTTP status. */
161
+ export class FlyTransientHttpError extends Error {
162
+ readonly status: number;
163
+ readonly retryAfterMs: number | undefined;
164
+ constructor(message: string, status: number, retryAfterMs?: number) {
165
+ super(message);
166
+ this.name = 'FlyTransientHttpError';
167
+ this.status = status;
168
+ this.retryAfterMs = retryAfterMs;
169
+ }
170
+ }
171
+
172
+ /** Thrown by a Fly API request that Fly answered with a non-transient status. */
173
+ export class FlyPermanentHttpError extends Error {
174
+ readonly status: number;
175
+ constructor(message: string, status: number) {
176
+ super(message);
177
+ this.name = 'FlyPermanentHttpError';
178
+ this.status = status;
179
+ }
180
+ }
181
+
182
+ /** Thrown when one Fly API request exceeded its own timeout. */
183
+ export class FlyRequestTimeoutError extends Error {
184
+ constructor(message: string, options?: { cause?: unknown }) {
185
+ super(message, options);
186
+ this.name = 'FlyRequestTimeoutError';
187
+ }
188
+ }
189
+
190
+ /**
191
+ * Classify an error from a direct Fly API fetch. Structured types and codes
192
+ * first; transport text only for runtimes that report a reset as a message.
193
+ */
194
+ export function classifyFlyRequestError(
195
+ error: unknown,
196
+ ): FlyTransientClassification {
197
+ if (error instanceof FlyTransientHttpError) {
198
+ return {
199
+ transient: true,
200
+ reason: `HTTP ${error.status}`,
201
+ ...(error.retryAfterMs === undefined
202
+ ? {}
203
+ : { retryAfterMs: error.retryAfterMs }),
204
+ };
205
+ }
206
+ if (error instanceof FlyRequestTimeoutError) {
207
+ return { transient: true, reason: 'request timed out' };
208
+ }
209
+ // Fly answered with a non-transient status. Its body text (for example a
210
+ // 400 "unexpected EOF" parse error) must not be read as a transport error.
211
+ if (error instanceof FlyPermanentHttpError) return PERMANENT;
212
+ for (
213
+ let current: unknown = error, depth = 0;
214
+ current && depth < 4;
215
+ current = (current as { cause?: unknown }).cause, depth += 1
216
+ ) {
217
+ const code = errorCode(current);
218
+ if (code && TRANSIENT_NETWORK_ERROR_CODES.has(code)) {
219
+ return { transient: true, reason: code };
220
+ }
221
+ if (current instanceof Error) {
222
+ const reason = transientFlyOutputReason(current.message);
223
+ if (reason) return { transient: true, reason };
224
+ if (current.name === 'TimeoutError') {
225
+ return { transient: true, reason: 'request timed out' };
226
+ }
227
+ }
228
+ }
229
+ return PERMANENT;
230
+ }
231
+
232
+ export type FlyTransientRetryOptions = Readonly<{
233
+ /** Names the operation in retry diagnostics, e.g. `uncordon 82dd...`. */
234
+ label: string;
235
+ attempts?: number;
236
+ baseDelayMs?: number;
237
+ deadlineMs?: number;
238
+ now?: () => number;
239
+ random?: () => number;
240
+ log?: (line: string) => void;
241
+ }>;
242
+
243
+ export type FlyTransientRetryAsyncOptions = FlyTransientRetryOptions &
244
+ Readonly<{ sleep?: (ms: number) => Promise<void> }>;
245
+
246
+ export type FlyTransientRetrySyncOptions = FlyTransientRetryOptions &
247
+ Readonly<{ sleep?: (ms: number) => void }>;
248
+
249
+ /** Base * 2^(retry-1), plus up to 25% jitter: 1 s, 2 s, 4 s by default. */
250
+ export function flyTransientRetryDelayMs(input: {
251
+ retry: number;
252
+ baseDelayMs?: number;
253
+ random?: () => number;
254
+ }): number {
255
+ const base =
256
+ (input.baseDelayMs ?? FLY_TRANSIENT_RETRY_BASE_DELAY_MS) *
257
+ 2 ** (input.retry - 1);
258
+ const jitter = Math.min(1, Math.max(0, (input.random ?? Math.random)()));
259
+ return Math.round(base + base * FLY_TRANSIENT_RETRY_JITTER_RATIO * jitter);
260
+ }
261
+
262
+ /** Thrown when every permitted attempt failed transiently. */
263
+ export class FlyTransientRetryExhaustedError extends Error {
264
+ readonly attempts: number;
265
+ constructor(input: { label: string; attempts: number; cause: unknown }) {
266
+ const detail =
267
+ input.cause instanceof Error ? input.cause.message : String(input.cause);
268
+ super(
269
+ `${input.label} failed after ${input.attempts} attempt(s) on transient Fly API errors: ${detail}`,
270
+ { cause: input.cause },
271
+ );
272
+ this.name = 'FlyTransientRetryExhaustedError';
273
+ this.attempts = input.attempts;
274
+ }
275
+ }
276
+
277
+ type RetryDecision =
278
+ | Readonly<{ retry: false; error: unknown }>
279
+ | Readonly<{ retry: true; delayMs: number }>;
280
+
281
+ function decideRetry(input: {
282
+ options: FlyTransientRetryOptions;
283
+ attempt: number;
284
+ error: unknown;
285
+ classification: FlyTransientClassification;
286
+ startedAtMs: number;
287
+ }): RetryDecision {
288
+ const { options, attempt, error, classification } = input;
289
+ if (!classification.transient) return { retry: false, error };
290
+ const attempts = options.attempts ?? FLY_TRANSIENT_RETRY_ATTEMPTS;
291
+ const exhausted = (): RetryDecision => ({
292
+ retry: false,
293
+ error: new FlyTransientRetryExhaustedError({
294
+ label: options.label,
295
+ attempts: attempt,
296
+ cause: error,
297
+ }),
298
+ });
299
+ if (attempt >= attempts) return exhausted();
300
+ const backoff = flyTransientRetryDelayMs({
301
+ retry: attempt,
302
+ baseDelayMs: options.baseDelayMs,
303
+ random: options.random,
304
+ });
305
+ const delayMs = Math.max(backoff, classification.retryAfterMs ?? 0);
306
+ const now = (options.now ?? Date.now)();
307
+ const deadline =
308
+ input.startedAtMs + (options.deadlineMs ?? FLY_TRANSIENT_RETRY_DEADLINE_MS);
309
+ if (now + delayMs >= deadline) return exhausted();
310
+ (options.log ?? ((line: string) => console.warn(line)))(
311
+ `[fly-transient-retry] ${options.label} attempt ${attempt}/${attempts} hit a transient Fly API error (${classification.reason}); retrying in ${delayMs}ms.`,
312
+ );
313
+ return { retry: true, delayMs };
314
+ }
315
+
316
+ /**
317
+ * Run an idempotent Fly operation, repeating it only after a transient
318
+ * failure. A non-transient failure is rethrown unchanged on its first attempt.
319
+ */
320
+ export async function withFlyTransientRetry<T>(
321
+ operation: (attempt: number) => Promise<T>,
322
+ classify: (error: unknown) => FlyTransientClassification,
323
+ options: FlyTransientRetryAsyncOptions,
324
+ ): Promise<T> {
325
+ const startedAtMs = (options.now ?? Date.now)();
326
+ const sleep =
327
+ options.sleep ??
328
+ ((ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms)));
329
+ for (let attempt = 1; ; attempt += 1) {
330
+ try {
331
+ return await operation(attempt);
332
+ } catch (error) {
333
+ const decision = decideRetry({
334
+ options,
335
+ attempt,
336
+ error,
337
+ classification: classify(error),
338
+ startedAtMs,
339
+ });
340
+ if (!decision.retry) throw decision.error;
341
+ await sleep(decision.delayMs);
342
+ }
343
+ }
344
+ }
345
+
346
+ /** Blocks the thread for a synchronous caller that already blocks on spawnSync. */
347
+ function sleepSync(ms: number): void {
348
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
349
+ }
350
+
351
+ /** Synchronous form for callers built on spawnSync. */
352
+ export function withFlyTransientRetrySync<T>(
353
+ operation: (attempt: number) => T,
354
+ classify: (error: unknown) => FlyTransientClassification,
355
+ options: FlyTransientRetrySyncOptions,
356
+ ): T {
357
+ const startedAtMs = (options.now ?? Date.now)();
358
+ const sleep = options.sleep ?? sleepSync;
359
+ for (let attempt = 1; ; attempt += 1) {
360
+ try {
361
+ return operation(attempt);
362
+ } catch (error) {
363
+ const decision = decideRetry({
364
+ options,
365
+ attempt,
366
+ error,
367
+ classification: classify(error),
368
+ startedAtMs,
369
+ });
370
+ if (!decision.retry) throw decision.error;
371
+ sleep(decision.delayMs);
372
+ }
373
+ }
374
+ }
375
+
376
+ /** A finished flyctl attempt that failed, carrying its classification. */
377
+ export class FlyCommandError extends Error {
378
+ readonly classification: FlyTransientClassification;
379
+ readonly status: number | null;
380
+ constructor(input: {
381
+ message: string;
382
+ status: number | null;
383
+ classification: FlyTransientClassification;
384
+ cause?: unknown;
385
+ }) {
386
+ super(input.message, { cause: input.cause });
387
+ this.name = 'FlyCommandError';
388
+ this.status = input.status;
389
+ this.classification = input.classification;
390
+ }
391
+ }
392
+
393
+ export function classifyFlyCommandError(
394
+ error: unknown,
395
+ ): FlyTransientClassification {
396
+ return error instanceof FlyCommandError ? error.classification : PERMANENT;
397
+ }
398
+
399
+ export type FlyctlSpawnResult = Readonly<{
400
+ status: number | null;
401
+ signal?: NodeJS.Signals | null;
402
+ stdout?: string | null;
403
+ stderr?: string | null;
404
+ error?: (Error & { code?: string }) | undefined;
405
+ }>;
406
+
407
+ export type FlyctlSpawn = (
408
+ command: string,
409
+ args: readonly string[],
410
+ options: Readonly<{
411
+ encoding: 'utf8';
412
+ env: NodeJS.ProcessEnv;
413
+ stdio: ['ignore', 'pipe', 'pipe'];
414
+ timeout?: number;
415
+ }>,
416
+ ) => FlyctlSpawnResult;
417
+
418
+ export type RunFlyctlOptions = Readonly<{
419
+ operation: 'read' | 'idempotent-write';
420
+ /** Printed instead of the arguments, which may hold secret values. */
421
+ description?: string;
422
+ env?: NodeJS.ProcessEnv;
423
+ timeoutMs?: number;
424
+ echoStdout?: boolean;
425
+ spawn: FlyctlSpawn;
426
+ writeStdout?: (text: string) => void;
427
+ writeStderr?: (text: string) => void;
428
+ }>;
429
+
430
+ /**
431
+ * One flyctl attempt with captured output. stdout/stderr are forwarded after
432
+ * the attempt so retry diagnostics stay attached to the attempt that caused
433
+ * them; the classification reads both streams.
434
+ */
435
+ export function runFlyctlAttempt(
436
+ args: readonly string[],
437
+ options: RunFlyctlOptions,
438
+ ): string {
439
+ const description = options.description ?? `flyctl ${args.join(' ')}`;
440
+ const result = options.spawn('flyctl', args, {
441
+ encoding: 'utf8',
442
+ env: options.env ?? process.env,
443
+ stdio: ['ignore', 'pipe', 'pipe'],
444
+ ...(options.timeoutMs === undefined ? {} : { timeout: options.timeoutMs }),
445
+ });
446
+ const stdout = result.stdout ?? '';
447
+ const stderr = result.stderr ?? '';
448
+ if (stdout && options.echoStdout !== false)
449
+ (options.writeStdout ?? ((text) => process.stdout.write(text)))(stdout);
450
+ if (stderr)
451
+ (options.writeStderr ?? ((text) => process.stderr.write(text)))(stderr);
452
+ const timedOut = result.error?.code === 'ETIMEDOUT';
453
+ if (result.error && !timedOut) {
454
+ throw new FlyCommandError({
455
+ message: `${description} could not start: ${result.error.message}`,
456
+ status: null,
457
+ classification: PERMANENT,
458
+ cause: result.error,
459
+ });
460
+ }
461
+ if (result.status === 0 && !timedOut) return stdout;
462
+ const classification = classifyFlyCommandFailure({
463
+ status: result.status,
464
+ signal: result.signal ?? null,
465
+ timedOut,
466
+ output: `${stdout}\n${stderr}`,
467
+ operation: options.operation,
468
+ });
469
+ throw new FlyCommandError({
470
+ message: timedOut
471
+ ? `${description} timed out after ${options.timeoutMs}ms.`
472
+ : result.signal
473
+ ? `${description} was terminated by ${result.signal}.`
474
+ : `${description} failed with ${result.status}.`,
475
+ status: result.status,
476
+ classification,
477
+ });
478
+ }
479
+
480
+ /** Run an idempotent flyctl command with the shared transient retry. */
481
+ export function runFlyctlWithTransientRetrySync(
482
+ args: readonly string[],
483
+ options: RunFlyctlOptions &
484
+ Omit<FlyTransientRetrySyncOptions, 'label'> & { label?: string },
485
+ ): string {
486
+ return withFlyTransientRetrySync(
487
+ () => runFlyctlAttempt(args, options),
488
+ classifyFlyCommandError,
489
+ {
490
+ ...options,
491
+ label: options.label ?? options.description ?? `flyctl ${args.join(' ')}`,
492
+ },
493
+ );
494
+ }
495
+
496
+ /** Async form: the backoff yields the event loop instead of blocking it. */
497
+ export async function runFlyctlWithTransientRetry(
498
+ args: readonly string[],
499
+ options: RunFlyctlOptions &
500
+ Omit<FlyTransientRetryAsyncOptions, 'label'> & { label?: string },
501
+ ): Promise<string> {
502
+ return await withFlyTransientRetry(
503
+ async () => runFlyctlAttempt(args, options),
504
+ classifyFlyCommandError,
505
+ {
506
+ ...options,
507
+ label: options.label ?? options.description ?? `flyctl ${args.join(' ')}`,
508
+ },
509
+ );
510
+ }
511
+
512
+ /**
513
+ * Create a provider resource without ever issuing a second create for one
514
+ * that already exists. A transient create failure is ambiguous: Fly may have
515
+ * created it. Before each retry, re-read provider state and adopt the
516
+ * resource if it appeared.
517
+ */
518
+ export async function createWithReadBeforeRetry<T>(input: {
519
+ create: () => Promise<T>;
520
+ findExisting: () => Promise<T | undefined>;
521
+ classify: (error: unknown) => FlyTransientClassification;
522
+ options: FlyTransientRetryAsyncOptions;
523
+ }): Promise<T> {
524
+ return await withFlyTransientRetry(
525
+ async (attempt) => {
526
+ if (attempt > 1) {
527
+ const existing = await input.findExisting();
528
+ if (existing !== undefined) return existing;
529
+ }
530
+ return await input.create();
531
+ },
532
+ input.classify,
533
+ input.options,
534
+ );
535
+ }
536
+
537
+ /**
538
+ * Apply one routing transition to every Machine even when some fail, then
539
+ * fail loudly with every Machine that did not converge. Used by rollback and
540
+ * restore paths so one Machine's error cannot leave the rest unrestored.
541
+ */
542
+ export async function applyToEveryMachine(input: {
543
+ machineIds: readonly string[];
544
+ action: string;
545
+ apply: (machineId: string) => void | Promise<void>;
546
+ }): Promise<{ failed: ReadonlyArray<{ machineId: string; error: unknown }> }> {
547
+ const failed: Array<{ machineId: string; error: unknown }> = [];
548
+ for (const machineId of input.machineIds) {
549
+ try {
550
+ await input.apply(machineId);
551
+ } catch (error) {
552
+ console.error(
553
+ `[fly-transient-retry] ${input.action} ${machineId} failed; continuing with the remaining Machines: ${error instanceof Error ? error.message : String(error)}`,
554
+ );
555
+ failed.push({ machineId, error });
556
+ }
557
+ }
558
+ return { failed };
559
+ }
560
+
561
+ export function describeMachineFailures(
562
+ action: string,
563
+ failed: ReadonlyArray<{ machineId: string; error: unknown }>,
564
+ ): string {
565
+ return failed
566
+ .map(
567
+ ({ machineId, error }) =>
568
+ `${action} ${machineId}: ${error instanceof Error ? error.message : String(error)}`,
569
+ )
570
+ .join('; ');
571
+ }
@@ -221,6 +221,7 @@ export const PLAY_AUTHORING_CONTRACT_ISSUE_CODES = [
221
221
  'play_authoring_hitl_retry_loop_unsafe',
222
222
  'play_authoring_binding_invalid',
223
223
  'play_runtime_size_preview_only',
224
+ 'play_runtime_sheet_contract_incomplete',
224
225
  'play_authoring_input_schema_unresolved',
225
226
  'tool_response_raw_access',
226
227
  'check_error',
@@ -0,0 +1,43 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+ var _chunkYDALHHUCjs = require('./chunk-YDALHHUC.js');
18
+ require('./chunk-XL4FFVWL.js');
19
+ require('./chunk-VPJSQMWQ.js');
20
+ require('./chunk-4NJK6P5T.js');
21
+ require('./chunk-ALJJRZNJ.js');
22
+ require('./chunk-XNYIZMNQ.js');
23
+ require('./chunk-DIAWYWT5.js');
24
+ require('./chunk-LF3FF2B2.js');
25
+ require('./chunk-OG64RBAC.js');
26
+ require('./chunk-COGTRVWW.js');
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+ exports.EXIT_WORKSPACE_MISMATCH = _chunkYDALHHUCjs.EXIT_WORKSPACE_MISMATCH; exports.authStatusLine = _chunkYDALHHUCjs.authStatusLine; exports.clearPendingClaim = _chunkYDALHHUCjs.clearPendingClaim; exports.clearSatisfiedPendingClaim = _chunkYDALHHUCjs.clearSatisfiedPendingClaim; exports.handleRegister = _chunkYDALHHUCjs.handleRegister; exports.handleStatus = _chunkYDALHHUCjs.handleStatus; exports.handleWait = _chunkYDALHHUCjs.handleWait; exports.httpJson = _chunkYDALHHUCjs.httpJson; exports.readPendingAuthClaim = _chunkYDALHHUCjs.readPendingAuthClaim; exports.readStatusBanner = _chunkYDALHHUCjs.readStatusBanner; exports.registerAuthCommands = _chunkYDALHHUCjs.registerAuthCommands; exports.reportApprovalLinkShown = _chunkYDALHHUCjs.reportApprovalLinkShown; exports.reportSetupCompleted = _chunkYDALHHUCjs.reportSetupCompleted; exports.resolvePendingAuthClaimForResume = _chunkYDALHHUCjs.resolvePendingAuthClaimForResume; exports.statusBannerLine = _chunkYDALHHUCjs.statusBannerLine;
@@ -14,14 +14,14 @@ import {
14
14
  reportSetupCompleted,
15
15
  resolvePendingAuthClaimForResume,
16
16
  statusBannerLine
17
- } from "./chunk-QBZECLNG.mjs";
18
- import "./chunk-DZ7JCRAL.mjs";
19
- import "./chunk-FRT5MFLF.mjs";
20
- import "./chunk-2LY42EZJ.mjs";
17
+ } from "./chunk-7BF4R26M.mjs";
18
+ import "./chunk-DMF56C6D.mjs";
19
+ import "./chunk-HOKOJGQW.mjs";
20
+ import "./chunk-PQ56GE55.mjs";
21
21
  import "./chunk-4QF2K7TM.mjs";
22
22
  import "./chunk-DLIRSHV6.mjs";
23
23
  import "./chunk-HBL4PM5Q.mjs";
24
- import "./chunk-KSQO32L5.mjs";
24
+ import "./chunk-V6DLYRSO.mjs";
25
25
  import "./chunk-WZYKRD7T.mjs";
26
26
  import "./chunk-KRD6H754.mjs";
27
27
  export {
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  DeeplineClient
3
- } from "./chunk-OWH7SSBO.mjs";
3
+ } from "./chunk-5MYXW6M6.mjs";
4
4
  import {
5
5
  iterateCursorPages,
6
6
  requireBillingIdempotencyKey
7
- } from "./chunk-Q4I5YKN4.mjs";
7
+ } from "./chunk-OEG6VCK4.mjs";
8
8
  import "./chunk-L2VKAASU.mjs";
9
9
  import "./chunk-N4TR6QRI.mjs";
10
10
  import "./chunk-S3A4IXBQ.mjs";
11
11
  import "./chunk-BMCRTI6Z.mjs";
12
12
  import {
13
13
  PLAY_RUNTIME_PRICING_NOTE
14
- } from "./chunk-AFSYNOG4.mjs";
14
+ } from "./chunk-ZRACZKEE.mjs";
15
15
  import "./chunk-5LUF4LAR.mjs";
16
16
  import {
17
17
  PLAY_SANDBOX_SIZE_INPUTS
@@ -22,9 +22,9 @@ import {
22
22
  openInBrowser,
23
23
  printCommandEnvelope,
24
24
  shouldEmitJson
25
- } from "./chunk-DZ7JCRAL.mjs";
26
- import "./chunk-FRT5MFLF.mjs";
27
- import "./chunk-2LY42EZJ.mjs";
25
+ } from "./chunk-DMF56C6D.mjs";
26
+ import "./chunk-HOKOJGQW.mjs";
27
+ import "./chunk-PQ56GE55.mjs";
28
28
  import {
29
29
  AuthError,
30
30
  ConfigError
@@ -33,7 +33,7 @@ import "./chunk-DLIRSHV6.mjs";
33
33
  import {
34
34
  DeeplineError
35
35
  } from "./chunk-HBL4PM5Q.mjs";
36
- import "./chunk-KSQO32L5.mjs";
36
+ import "./chunk-V6DLYRSO.mjs";
37
37
  import "./chunk-WZYKRD7T.mjs";
38
38
  import "./chunk-KRD6H754.mjs";
39
39