@evident-ai/runner-synchroniser 0.1.1-dev.e4d9a44 → 3.1.1-dev.297b927

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 (3) hide show
  1. package/README.md +187 -12
  2. package/dist/cli.js +687 -211
  3. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -10,8 +10,6 @@ var __export = (target, all) => {
10
10
  };
11
11
 
12
12
  // ../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.10_jiti@2.7.0_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.9.0/node_modules/tsup/assets/esm_shims.js
13
- import path from "path";
14
- import { fileURLToPath } from "url";
15
13
  var init_esm_shims = __esm({
16
14
  "../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.10_jiti@2.7.0_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.9.0/node_modules/tsup/assets/esm_shims.js"() {
17
15
  "use strict";
@@ -19,7 +17,7 @@ var init_esm_shims = __esm({
19
17
  });
20
18
 
21
19
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/retry/middleware-retry/isStreamingPayload/isStreamingPayload.js
22
- import { Readable } from "stream";
20
+ import { Readable } from "node:stream";
23
21
  var isStreamingPayload;
24
22
  var init_isStreamingPayload = __esm({
25
23
  "../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/retry/middleware-retry/isStreamingPayload/isStreamingPayload.js"() {
@@ -2567,7 +2565,7 @@ var init_hex_encoding = __esm({
2567
2565
  });
2568
2566
 
2569
2567
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/serde/util-body-length/calculateBodyLength.js
2570
- import { ReadStream, fstatSync, lstatSync } from "fs";
2568
+ import { ReadStream, fstatSync, lstatSync } from "node:fs";
2571
2569
  var calculateBodyLength;
2572
2570
  var init_calculateBodyLength = __esm({
2573
2571
  "../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/serde/util-body-length/calculateBodyLength.js"() {
@@ -2831,8 +2829,8 @@ var init_types = __esm({
2831
2829
  });
2832
2830
 
2833
2831
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getHomeDir.js
2834
- import { homedir } from "os";
2835
- import { sep } from "path";
2832
+ import { homedir } from "node:os";
2833
+ import { sep } from "node:path";
2836
2834
  var homeDirCache, getHomeDirCacheKey, getHomeDir;
2837
2835
  var init_getHomeDir = __esm({
2838
2836
  "../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getHomeDir.js"() {
@@ -2874,8 +2872,8 @@ var init_getProfileName = __esm({
2874
2872
  });
2875
2873
 
2876
2874
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getSSOTokenFilepath.js
2877
- import { createHash } from "crypto";
2878
- import { join } from "path";
2875
+ import { createHash } from "node:crypto";
2876
+ import { join } from "node:path";
2879
2877
  var getSSOTokenFilepath;
2880
2878
  var init_getSSOTokenFilepath = __esm({
2881
2879
  "../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getSSOTokenFilepath.js"() {
@@ -2891,7 +2889,7 @@ var init_getSSOTokenFilepath = __esm({
2891
2889
  });
2892
2890
 
2893
2891
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getSSOTokenFromFile.js
2894
- import { readFile } from "fs/promises";
2892
+ import { readFile } from "node:fs/promises";
2895
2893
  var tokenIntercept, getSSOTokenFromFile;
2896
2894
  var init_getSSOTokenFromFile = __esm({
2897
2895
  "../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getSSOTokenFromFile.js"() {
@@ -2946,7 +2944,7 @@ var init_getConfigData = __esm({
2946
2944
  });
2947
2945
 
2948
2946
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getConfigFilepath.js
2949
- import { join as join2 } from "path";
2947
+ import { join as join2 } from "node:path";
2950
2948
  var ENV_CONFIG_PATH, getConfigFilepath;
2951
2949
  var init_getConfigFilepath = __esm({
2952
2950
  "../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getConfigFilepath.js"() {
@@ -2959,7 +2957,7 @@ var init_getConfigFilepath = __esm({
2959
2957
  });
2960
2958
 
2961
2959
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getCredentialsFilepath.js
2962
- import { join as join3 } from "path";
2960
+ import { join as join3 } from "node:path";
2963
2961
  var ENV_CREDENTIALS_PATH, getCredentialsFilepath;
2964
2962
  var init_getCredentialsFilepath = __esm({
2965
2963
  "../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getCredentialsFilepath.js"() {
@@ -3030,7 +3028,7 @@ var init_parseIni = __esm({
3030
3028
  });
3031
3029
 
3032
3030
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/readFile.js
3033
- import { readFile as fsReadFile } from "fs/promises";
3031
+ import { readFile as fsReadFile } from "node:fs/promises";
3034
3032
  var filePromises, fileIntercept, readFile2;
3035
3033
  var init_readFile = __esm({
3036
3034
  "../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/readFile.js"() {
@@ -3038,20 +3036,20 @@ var init_readFile = __esm({
3038
3036
  init_esm_shims();
3039
3037
  filePromises = {};
3040
3038
  fileIntercept = {};
3041
- readFile2 = (path2, options) => {
3042
- if (fileIntercept[path2] !== void 0) {
3043
- return fileIntercept[path2];
3039
+ readFile2 = (path, options) => {
3040
+ if (fileIntercept[path] !== void 0) {
3041
+ return fileIntercept[path];
3044
3042
  }
3045
- if (!filePromises[path2] || options?.ignoreCache) {
3046
- filePromises[path2] = fsReadFile(path2, "utf8");
3043
+ if (!filePromises[path] || options?.ignoreCache) {
3044
+ filePromises[path] = fsReadFile(path, "utf8");
3047
3045
  }
3048
- return filePromises[path2];
3046
+ return filePromises[path];
3049
3047
  };
3050
3048
  }
3051
3049
  });
3052
3050
 
3053
3051
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/loadSharedConfigFiles.js
3054
- import { join as join4 } from "path";
3052
+ import { join as join4 } from "node:path";
3055
3053
  var swallowError, loadSharedConfigFiles;
3056
3054
  var init_loadSharedConfigFiles = __esm({
3057
3055
  "../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/loadSharedConfigFiles.js"() {
@@ -3169,8 +3167,8 @@ var init_externalDataInterceptor = __esm({
3169
3167
  getFileRecord() {
3170
3168
  return fileIntercept;
3171
3169
  },
3172
- interceptFile(path2, contents) {
3173
- fileIntercept[path2] = Promise.resolve(contents);
3170
+ interceptFile(path, contents) {
3171
+ fileIntercept[path] = Promise.resolve(contents);
3174
3172
  },
3175
3173
  getTokenRecord() {
3176
3174
  return tokenIntercept;
@@ -3397,7 +3395,7 @@ var init_getInstanceMetadataRegion = __esm({
3397
3395
  return { hostname: "169.254.169.254" };
3398
3396
  };
3399
3397
  imdsRequest = async (options) => {
3400
- const { request } = await import("http");
3398
+ const { request } = await import("node:http");
3401
3399
  return new Promise((resolve, reject) => {
3402
3400
  const req = request({
3403
3401
  hostname: options.hostname,
@@ -3812,8 +3810,8 @@ var init_createConfigValueProvider = __esm({
3812
3810
  return endpoint.url.href;
3813
3811
  }
3814
3812
  if ("hostname" in endpoint) {
3815
- const { protocol, hostname, port, path: path2 } = endpoint;
3816
- return `${protocol}//${hostname}${port ? ":" + port : ""}${path2}`;
3813
+ const { protocol, hostname, port, path } = endpoint;
3814
+ return `${protocol}//${hostname}${port ? ":" + port : ""}${path}`;
3817
3815
  }
3818
3816
  }
3819
3817
  return endpoint;
@@ -4220,18 +4218,18 @@ var init_getAttrPathList = __esm({
4220
4218
  "use strict";
4221
4219
  init_esm_shims();
4222
4220
  init_types2();
4223
- getAttrPathList = (path2) => {
4224
- const parts = path2.split(".");
4221
+ getAttrPathList = (path) => {
4222
+ const parts = path.split(".");
4225
4223
  const pathList = [];
4226
4224
  for (const part of parts) {
4227
4225
  const squareBracketIndex = part.indexOf("[");
4228
4226
  if (squareBracketIndex !== -1) {
4229
4227
  if (part.indexOf("]") !== part.length - 1) {
4230
- throw new EndpointError(`Path: '${path2}' does not end with ']'`);
4228
+ throw new EndpointError(`Path: '${path}' does not end with ']'`);
4231
4229
  }
4232
4230
  const arrayIndex = part.slice(squareBracketIndex + 1, -1);
4233
4231
  if (Number.isNaN(parseInt(arrayIndex))) {
4234
- throw new EndpointError(`Invalid array index: '${arrayIndex}' in path: '${path2}'`);
4232
+ throw new EndpointError(`Invalid array index: '${arrayIndex}' in path: '${path}'`);
4235
4233
  }
4236
4234
  if (squareBracketIndex !== 0) {
4237
4235
  pathList.push(part.slice(0, squareBracketIndex));
@@ -4254,9 +4252,9 @@ var init_getAttr = __esm({
4254
4252
  init_esm_shims();
4255
4253
  init_types2();
4256
4254
  init_getAttrPathList();
4257
- getAttr = (value, path2) => getAttrPathList(path2).reduce((acc, index) => {
4255
+ getAttr = (value, path) => getAttrPathList(path).reduce((acc, index) => {
4258
4256
  if (typeof acc !== "object") {
4259
- throw new EndpointError(`Index '${index}' in '${path2}' not found in '${JSON.stringify(value)}'`);
4257
+ throw new EndpointError(`Index '${index}' in '${path}' not found in '${JSON.stringify(value)}'`);
4260
4258
  } else if (Array.isArray(acc)) {
4261
4259
  const i12 = parseInt(index);
4262
4260
  return acc[i12 < 0 ? acc.length + i12 : i12];
@@ -4327,8 +4325,8 @@ var init_parseURL = __esm({
4327
4325
  return value;
4328
4326
  }
4329
4327
  if (typeof value === "object" && "hostname" in value) {
4330
- const { hostname: hostname2, port, protocol: protocol2 = "", path: path2 = "", query = {} } = value;
4331
- const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path2}`);
4328
+ const { hostname: hostname2, port, protocol: protocol2 = "", path = "", query = {} } = value;
4329
+ const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path}`);
4332
4330
  url.search = Object.entries(query).map(([k12, v2]) => `${k12}=${v2}`).join("&");
4333
4331
  return url;
4334
4332
  }
@@ -4764,7 +4762,7 @@ var init_endpoints = __esm({
4764
4762
  });
4765
4763
 
4766
4764
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/checksum/ChecksumStream.js
4767
- import { Readable as Readable2 } from "stream";
4765
+ import { Readable as Readable2 } from "node:stream";
4768
4766
  var ChecksumStream;
4769
4767
  var init_ChecksumStream = __esm({
4770
4768
  "../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/checksum/ChecksumStream.js"() {
@@ -5142,7 +5140,7 @@ var init_createBufferedReadable_browser = __esm({
5142
5140
  });
5143
5141
 
5144
5142
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/createBufferedReadable.js
5145
- import { Readable as Readable3 } from "stream";
5143
+ import { Readable as Readable3 } from "node:stream";
5146
5144
  function createBufferedReadable(upstream, size, logger3) {
5147
5145
  if (isReadableStream(upstream)) {
5148
5146
  return createBufferedReadableStream(upstream, size, logger3);
@@ -5243,7 +5241,7 @@ ${value}\r
5243
5241
  });
5244
5242
 
5245
5243
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/getAwsChunkedEncodingStream.js
5246
- import { Readable as Readable4 } from "stream";
5244
+ import { Readable as Readable4 } from "node:stream";
5247
5245
  function getAwsChunkedEncodingStream2(stream, options) {
5248
5246
  const readable = stream;
5249
5247
  const readableStream = stream;
@@ -5411,7 +5409,7 @@ var init_sdk_stream_mixin_browser = __esm({
5411
5409
  });
5412
5410
 
5413
5411
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/stream-collector.js
5414
- import { Writable } from "stream";
5412
+ import { Writable } from "node:stream";
5415
5413
  var streamCollector2, Collector;
5416
5414
  var init_stream_collector = __esm({
5417
5415
  "../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/stream-collector.js"() {
@@ -5453,7 +5451,7 @@ var init_stream_collector = __esm({
5453
5451
  });
5454
5452
 
5455
5453
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/sdk-stream-mixin.js
5456
- import { Readable as Readable5 } from "stream";
5454
+ import { Readable as Readable5 } from "node:stream";
5457
5455
  var ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED2, sdkStreamMixin2;
5458
5456
  var init_sdk_stream_mixin = __esm({
5459
5457
  "../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/sdk-stream-mixin.js"() {
@@ -5510,7 +5508,7 @@ var init_sdk_stream_mixin = __esm({
5510
5508
  });
5511
5509
 
5512
5510
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/serde/index.js
5513
- import { getRandomValues } from "crypto";
5511
+ import { getRandomValues } from "node:crypto";
5514
5512
  var Uint8ArrayBlobAdapter, _getRandomValues, v4, generateIdempotencyToken;
5515
5513
  var init_serde = __esm({
5516
5514
  "../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/serde/index.js"() {
@@ -5595,7 +5593,7 @@ var init_SerdeContext = __esm({
5595
5593
  });
5596
5594
 
5597
5595
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/checksum/hash-stream-node/HashCalculator.js
5598
- import { Writable as Writable2 } from "stream";
5596
+ import { Writable as Writable2 } from "node:stream";
5599
5597
  var HashCalculator;
5600
5598
  var init_HashCalculator = __esm({
5601
5599
  "../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/checksum/hash-stream-node/HashCalculator.js"() {
@@ -5747,7 +5745,7 @@ var init_Md5Js = __esm({
5747
5745
  });
5748
5746
 
5749
5747
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/checksum/md5/Md5Node.js
5750
- import { createHash as createHash2 } from "crypto";
5748
+ import { createHash as createHash2 } from "node:crypto";
5751
5749
  function buildNativeClass() {
5752
5750
  return class Md5Node {
5753
5751
  digestLength = 16;
@@ -5823,7 +5821,7 @@ var init_Crc32Js = __esm({
5823
5821
  });
5824
5822
 
5825
5823
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/checksum/crc32/Crc32Node.js
5826
- import * as zlib from "zlib";
5824
+ import * as zlib from "node:zlib";
5827
5825
  function buildNativeClass2(nativeCrc32) {
5828
5826
  return class Crc32Node {
5829
5827
  digestLength = 4;
@@ -6096,7 +6094,7 @@ var init_Sha256Js = __esm({
6096
6094
  });
6097
6095
 
6098
6096
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256Node.js
6099
- import { createHash as createHash3, createHmac } from "crypto";
6097
+ import { createHash as createHash3, createHmac } from "node:crypto";
6100
6098
  function buildNativeClass3() {
6101
6099
  return class Sha256Node {
6102
6100
  digestLength = 32;
@@ -6799,7 +6797,7 @@ var init_EventStreamMarshaller = __esm({
6799
6797
  });
6800
6798
 
6801
6799
  // ../../node_modules/.pnpm/@smithy+core@3.30.0/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/EventStreamMarshaller.js
6802
- import { Readable as Readable6 } from "stream";
6800
+ import { Readable as Readable6 } from "node:stream";
6803
6801
  async function* readableToIterable(readStream) {
6804
6802
  let streamEnded = false;
6805
6803
  let generationEnded = false;
@@ -7416,11 +7414,11 @@ var init_HttpBindingProtocol = __esm({
7416
7414
  const opTraits = translateTraits(operationSchema.traits);
7417
7415
  if (opTraits.http) {
7418
7416
  request.method = opTraits.http[0];
7419
- const [path2, search] = opTraits.http[1].split("?");
7417
+ const [path, search] = opTraits.http[1].split("?");
7420
7418
  if (request.path == "/") {
7421
- request.path = path2;
7419
+ request.path = path;
7422
7420
  } else {
7423
- request.path += path2;
7421
+ request.path += path;
7424
7422
  }
7425
7423
  const traitSearchParams = new URLSearchParams(search ?? "");
7426
7424
  for (const [key, value] of traitSearchParams) {
@@ -8953,7 +8951,7 @@ var init_invoke_store = __esm({
8953
8951
  als;
8954
8952
  static async create() {
8955
8953
  const instance = new _InvokeStoreMulti();
8956
- const asyncHooks = await import("async_hooks");
8954
+ const asyncHooks = await import("node:async_hooks");
8957
8955
  instance.als = new asyncHooks.AsyncLocalStorage();
8958
8956
  return instance;
8959
8957
  }
@@ -9945,7 +9943,7 @@ var init_date_utils2 = __esm({
9945
9943
  });
9946
9944
 
9947
9945
  // ../../node_modules/.pnpm/@smithy+core@3.29.5/node_modules/@smithy/core/dist-es/submodules/serde/util-body-length/calculateBodyLength.js
9948
- import { ReadStream as ReadStream2, fstatSync as fstatSync2, lstatSync as lstatSync2 } from "fs";
9946
+ import { ReadStream as ReadStream2, fstatSync as fstatSync2, lstatSync as lstatSync2 } from "node:fs";
9949
9947
  var calculateBodyLength2;
9950
9948
  var init_calculateBodyLength2 = __esm({
9951
9949
  "../../node_modules/.pnpm/@smithy+core@3.29.5/node_modules/@smithy/core/dist-es/submodules/serde/util-body-length/calculateBodyLength.js"() {
@@ -10169,8 +10167,8 @@ var init_types3 = __esm({
10169
10167
  });
10170
10168
 
10171
10169
  // ../../node_modules/.pnpm/@smithy+core@3.29.5/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getHomeDir.js
10172
- import { homedir as homedir2 } from "os";
10173
- import { sep as sep2 } from "path";
10170
+ import { homedir as homedir2 } from "node:os";
10171
+ import { sep as sep2 } from "node:path";
10174
10172
  var homeDirCache2, getHomeDirCacheKey2, getHomeDir2;
10175
10173
  var init_getHomeDir2 = __esm({
10176
10174
  "../../node_modules/.pnpm/@smithy+core@3.29.5/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getHomeDir.js"() {
@@ -10247,7 +10245,7 @@ var init_getConfigData2 = __esm({
10247
10245
  });
10248
10246
 
10249
10247
  // ../../node_modules/.pnpm/@smithy+core@3.29.5/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getConfigFilepath.js
10250
- import { join as join5 } from "path";
10248
+ import { join as join5 } from "node:path";
10251
10249
  var ENV_CONFIG_PATH2, getConfigFilepath2;
10252
10250
  var init_getConfigFilepath2 = __esm({
10253
10251
  "../../node_modules/.pnpm/@smithy+core@3.29.5/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getConfigFilepath.js"() {
@@ -10260,7 +10258,7 @@ var init_getConfigFilepath2 = __esm({
10260
10258
  });
10261
10259
 
10262
10260
  // ../../node_modules/.pnpm/@smithy+core@3.29.5/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getCredentialsFilepath.js
10263
- import { join as join6 } from "path";
10261
+ import { join as join6 } from "node:path";
10264
10262
  var ENV_CREDENTIALS_PATH2, getCredentialsFilepath2;
10265
10263
  var init_getCredentialsFilepath2 = __esm({
10266
10264
  "../../node_modules/.pnpm/@smithy+core@3.29.5/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getCredentialsFilepath.js"() {
@@ -10331,7 +10329,7 @@ var init_parseIni2 = __esm({
10331
10329
  });
10332
10330
 
10333
10331
  // ../../node_modules/.pnpm/@smithy+core@3.29.5/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/readFile.js
10334
- import { readFile as fsReadFile2 } from "fs/promises";
10332
+ import { readFile as fsReadFile2 } from "node:fs/promises";
10335
10333
  var filePromises2, fileIntercept2, readFile3;
10336
10334
  var init_readFile2 = __esm({
10337
10335
  "../../node_modules/.pnpm/@smithy+core@3.29.5/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/readFile.js"() {
@@ -10339,20 +10337,20 @@ var init_readFile2 = __esm({
10339
10337
  init_esm_shims();
10340
10338
  filePromises2 = {};
10341
10339
  fileIntercept2 = {};
10342
- readFile3 = (path2, options) => {
10343
- if (fileIntercept2[path2] !== void 0) {
10344
- return fileIntercept2[path2];
10340
+ readFile3 = (path, options) => {
10341
+ if (fileIntercept2[path] !== void 0) {
10342
+ return fileIntercept2[path];
10345
10343
  }
10346
- if (!filePromises2[path2] || options?.ignoreCache) {
10347
- filePromises2[path2] = fsReadFile2(path2, "utf8");
10344
+ if (!filePromises2[path] || options?.ignoreCache) {
10345
+ filePromises2[path] = fsReadFile2(path, "utf8");
10348
10346
  }
10349
- return filePromises2[path2];
10347
+ return filePromises2[path];
10350
10348
  };
10351
10349
  }
10352
10350
  });
10353
10351
 
10354
10352
  // ../../node_modules/.pnpm/@smithy+core@3.29.5/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/loadSharedConfigFiles.js
10355
- import { join as join7 } from "path";
10353
+ import { join as join7 } from "node:path";
10356
10354
  var swallowError3, loadSharedConfigFiles2;
10357
10355
  var init_loadSharedConfigFiles2 = __esm({
10358
10356
  "../../node_modules/.pnpm/@smithy+core@3.29.5/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/loadSharedConfigFiles.js"() {
@@ -11969,7 +11967,7 @@ var init_getInstanceMetadataRegion2 = __esm({
11969
11967
  return { hostname: "169.254.169.254" };
11970
11968
  };
11971
11969
  imdsRequest2 = async (options) => {
11972
- const { request } = await import("http");
11970
+ const { request } = await import("node:http");
11973
11971
  return new Promise((resolve, reject) => {
11974
11972
  const req = request({
11975
11973
  hostname: options.hostname,
@@ -12345,8 +12343,8 @@ var init_createConfigValueProvider2 = __esm({
12345
12343
  return endpoint.url.href;
12346
12344
  }
12347
12345
  if ("hostname" in endpoint) {
12348
- const { protocol, hostname, port, path: path2 } = endpoint;
12349
- return `${protocol}//${hostname}${port ? ":" + port : ""}${path2}`;
12346
+ const { protocol, hostname, port, path } = endpoint;
12347
+ return `${protocol}//${hostname}${port ? ":" + port : ""}${path}`;
12350
12348
  }
12351
12349
  }
12352
12350
  return endpoint;
@@ -12751,18 +12749,18 @@ var init_getAttrPathList2 = __esm({
12751
12749
  "use strict";
12752
12750
  init_esm_shims();
12753
12751
  init_types4();
12754
- getAttrPathList2 = (path2) => {
12755
- const parts = path2.split(".");
12752
+ getAttrPathList2 = (path) => {
12753
+ const parts = path.split(".");
12756
12754
  const pathList = [];
12757
12755
  for (const part of parts) {
12758
12756
  const squareBracketIndex = part.indexOf("[");
12759
12757
  if (squareBracketIndex !== -1) {
12760
12758
  if (part.indexOf("]") !== part.length - 1) {
12761
- throw new EndpointError2(`Path: '${path2}' does not end with ']'`);
12759
+ throw new EndpointError2(`Path: '${path}' does not end with ']'`);
12762
12760
  }
12763
12761
  const arrayIndex = part.slice(squareBracketIndex + 1, -1);
12764
12762
  if (Number.isNaN(parseInt(arrayIndex))) {
12765
- throw new EndpointError2(`Invalid array index: '${arrayIndex}' in path: '${path2}'`);
12763
+ throw new EndpointError2(`Invalid array index: '${arrayIndex}' in path: '${path}'`);
12766
12764
  }
12767
12765
  if (squareBracketIndex !== 0) {
12768
12766
  pathList.push(part.slice(0, squareBracketIndex));
@@ -12785,9 +12783,9 @@ var init_getAttr2 = __esm({
12785
12783
  init_esm_shims();
12786
12784
  init_types4();
12787
12785
  init_getAttrPathList2();
12788
- getAttr2 = (value, path2) => getAttrPathList2(path2).reduce((acc, index) => {
12786
+ getAttr2 = (value, path) => getAttrPathList2(path).reduce((acc, index) => {
12789
12787
  if (typeof acc !== "object") {
12790
- throw new EndpointError2(`Index '${index}' in '${path2}' not found in '${JSON.stringify(value)}'`);
12788
+ throw new EndpointError2(`Index '${index}' in '${path}' not found in '${JSON.stringify(value)}'`);
12791
12789
  } else if (Array.isArray(acc)) {
12792
12790
  const i12 = parseInt(index);
12793
12791
  return acc[i12 < 0 ? acc.length + i12 : i12];
@@ -12858,8 +12856,8 @@ var init_parseURL2 = __esm({
12858
12856
  return value;
12859
12857
  }
12860
12858
  if (typeof value === "object" && "hostname" in value) {
12861
- const { hostname: hostname2, port, protocol: protocol2 = "", path: path2 = "", query = {} } = value;
12862
- const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path2}`);
12859
+ const { hostname: hostname2, port, protocol: protocol2 = "", path = "", query = {} } = value;
12860
+ const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path}`);
12863
12861
  url.search = Object.entries(query).map(([k12, v2]) => `${k12}=${v2}`).join("&");
12864
12862
  return url;
12865
12863
  }
@@ -13292,7 +13290,7 @@ var init_endpoints2 = __esm({
13292
13290
  });
13293
13291
 
13294
13292
  // ../../node_modules/.pnpm/@smithy+core@3.29.5/node_modules/@smithy/core/dist-es/submodules/serde/index.js
13295
- import { getRandomValues as getRandomValues2 } from "crypto";
13293
+ import { getRandomValues as getRandomValues2 } from "node:crypto";
13296
13294
  var Uint8ArrayBlobAdapter2, _getRandomValues2, v42;
13297
13295
  var init_serde2 = __esm({
13298
13296
  "../../node_modules/.pnpm/@smithy+core@3.29.5/node_modules/@smithy/core/dist-es/submodules/serde/index.js"() {
@@ -14116,7 +14114,7 @@ var init_user_agent_middleware = __esm({
14116
14114
  });
14117
14115
 
14118
14116
  // ../../node_modules/.pnpm/@aws-sdk+core@3.977.1/node_modules/@aws-sdk/core/dist-es/submodules/client/util-user-agent-node/getRuntimeUserAgentPair.js
14119
- import { versions as versions2 } from "process";
14117
+ import { versions as versions2 } from "node:process";
14120
14118
  var getRuntimeUserAgentPair2;
14121
14119
  var init_getRuntimeUserAgentPair = __esm({
14122
14120
  "../../node_modules/.pnpm/@aws-sdk+core@3.977.1/node_modules/@aws-sdk/core/dist-es/submodules/client/util-user-agent-node/getRuntimeUserAgentPair.js"() {
@@ -14163,8 +14161,8 @@ var init_is_crt_available = __esm({
14163
14161
  });
14164
14162
 
14165
14163
  // ../../node_modules/.pnpm/@aws-sdk+core@3.977.1/node_modules/@aws-sdk/core/dist-es/submodules/client/util-user-agent-node/defaultUserAgent.js
14166
- import { platform as platform2, release as release2 } from "os";
14167
- import { env as env2 } from "process";
14164
+ import { platform as platform2, release as release2 } from "node:os";
14165
+ import { env as env2 } from "node:process";
14168
14166
  var createDefaultUserAgentProvider2;
14169
14167
  var init_defaultUserAgent = __esm({
14170
14168
  "../../node_modules/.pnpm/@aws-sdk+core@3.977.1/node_modules/@aws-sdk/core/dist-es/submodules/client/util-user-agent-node/defaultUserAgent.js"() {
@@ -14464,7 +14462,7 @@ var init_RemoteProviderInit = __esm({
14464
14462
  });
14465
14463
 
14466
14464
  // ../../node_modules/.pnpm/@smithy+credential-provider-imds@4.4.10/node_modules/@smithy/credential-provider-imds/dist-es/remoteProvider/node-http.js
14467
- import node_http from "http";
14465
+ import node_http from "node:http";
14468
14466
  var init_node_http = __esm({
14469
14467
  "../../node_modules/.pnpm/@smithy+credential-provider-imds@4.4.10/node_modules/@smithy/credential-provider-imds/dist-es/remoteProvider/node-http.js"() {
14470
14468
  "use strict";
@@ -14995,7 +14993,7 @@ var init_get_transformed_headers = __esm({
14995
14993
  });
14996
14994
 
14997
14995
  // ../../node_modules/.pnpm/@smithy+node-http-handler@4.9.11/node_modules/@smithy/node-http-handler/dist-es/node-https.js
14998
- import node_https from "https";
14996
+ import node_https from "node:https";
14999
14997
  var init_node_https = __esm({
15000
14998
  "../../node_modules/.pnpm/@smithy+node-http-handler@4.9.11/node_modules/@smithy/node-http-handler/dist-es/node-https.js"() {
15001
14999
  "use strict";
@@ -15150,7 +15148,7 @@ var init_set_socket_timeout = __esm({
15150
15148
  });
15151
15149
 
15152
15150
  // ../../node_modules/.pnpm/@smithy+node-http-handler@4.9.11/node_modules/@smithy/node-http-handler/dist-es/write-request-body.js
15153
- import { Readable as Readable8 } from "stream";
15151
+ import { Readable as Readable8 } from "node:stream";
15154
15152
  async function writeRequestBody(httpRequest3, request, maxContinueTimeoutMs = MIN_WAIT_TIME, externalAgent = false) {
15155
15153
  const headers = request.headers;
15156
15154
  const expect = headers ? headers.Expect || headers.expect : void 0;
@@ -15343,12 +15341,12 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
15343
15341
  const password = request.password ?? "";
15344
15342
  auth = `${username}:${password}`;
15345
15343
  }
15346
- let path2 = request.path;
15344
+ let path = request.path;
15347
15345
  if (queryString) {
15348
- path2 += `?${queryString}`;
15346
+ path += `?${queryString}`;
15349
15347
  }
15350
15348
  if (request.fragment) {
15351
- path2 += `#${request.fragment}`;
15349
+ path += `#${request.fragment}`;
15352
15350
  }
15353
15351
  let hostname = request.hostname ?? "";
15354
15352
  if (hostname[0] === "[" && hostname.endsWith("]")) {
@@ -15360,7 +15358,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
15360
15358
  headers: request.headers,
15361
15359
  host: hostname,
15362
15360
  method: request.method,
15363
- path: path2,
15361
+ path,
15364
15362
  port: request.port,
15365
15363
  agent,
15366
15364
  auth
@@ -15436,7 +15434,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
15436
15434
  socketAcquisitionWarningTimeout,
15437
15435
  throwOnRequestTimeout,
15438
15436
  httpAgentProvider: async () => {
15439
- const node_http3 = await import("http");
15437
+ const node_http3 = await import("node:http");
15440
15438
  const { Agent, request } = node_http3.default ?? node_http3;
15441
15439
  hRequest = request;
15442
15440
  hAgent = Agent;
@@ -15587,7 +15585,7 @@ var init_retry_wrapper = __esm({
15587
15585
  });
15588
15586
 
15589
15587
  // ../../node_modules/.pnpm/@aws-sdk+credential-provider-http@3.972.61/node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/fromHttp.js
15590
- import fs from "fs/promises";
15588
+ import fs from "node:fs/promises";
15591
15589
  var AWS_CONTAINER_CREDENTIALS_RELATIVE_URI, DEFAULT_LINK_LOCAL_HOST, AWS_CONTAINER_CREDENTIALS_FULL_URI, AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE, AWS_CONTAINER_AUTHORIZATION_TOKEN, fromHttp, validateToken;
15592
15590
  var init_fromHttp = __esm({
15593
15591
  "../../node_modules/.pnpm/@aws-sdk+credential-provider-http@3.972.61/node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/fromHttp.js"() {
@@ -16235,10 +16233,10 @@ ${longDate}
16235
16233
  ${credentialScope}
16236
16234
  ${toHex(hashedRequest)}`;
16237
16235
  }
16238
- getCanonicalPath({ path: path2 }) {
16236
+ getCanonicalPath({ path }) {
16239
16237
  if (this.uriEscapePath) {
16240
16238
  const normalizedPathSegments = [];
16241
- for (const pathSegment of path2.split("/")) {
16239
+ for (const pathSegment of path.split("/")) {
16242
16240
  if (pathSegment?.length === 0)
16243
16241
  continue;
16244
16242
  if (pathSegment === ".")
@@ -16249,11 +16247,11 @@ ${toHex(hashedRequest)}`;
16249
16247
  normalizedPathSegments.push(pathSegment);
16250
16248
  }
16251
16249
  }
16252
- const normalizedPath = `${path2?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path2?.endsWith("/") ? "/" : ""}`;
16250
+ const normalizedPath = `${path?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path?.endsWith("/") ? "/" : ""}`;
16253
16251
  const doubleEncoded = escapeUri(normalizedPath);
16254
16252
  return doubleEncoded.replace(/%2F/g, "/");
16255
16253
  }
16256
- return path2;
16254
+ return path;
16257
16255
  }
16258
16256
  validateResolvedCredentials(credentials) {
16259
16257
  if (typeof credentials !== "object" || typeof credentials.accessKeyId !== "string" || typeof credentials.secretAccessKey !== "string") {
@@ -20245,7 +20243,7 @@ var init_validateTokenKey = __esm({
20245
20243
  });
20246
20244
 
20247
20245
  // ../../node_modules/.pnpm/@aws-sdk+token-providers@3.1088.0/node_modules/@aws-sdk/token-providers/dist-es/writeSSOTokenToFile.js
20248
- import { promises as fsPromises } from "fs";
20246
+ import { promises as fsPromises } from "node:fs";
20249
20247
  var writeFile, writeSSOTokenToFile;
20250
20248
  var init_writeSSOTokenToFile = __esm({
20251
20249
  "../../node_modules/.pnpm/@aws-sdk+token-providers@3.1088.0/node_modules/@aws-sdk/token-providers/dist-es/writeSSOTokenToFile.js"() {
@@ -23767,10 +23765,10 @@ var init_signin = __esm({
23767
23765
  });
23768
23766
 
23769
23767
  // ../../node_modules/.pnpm/@aws-sdk+credential-provider-login@3.972.66/node_modules/@aws-sdk/credential-provider-login/dist-es/LoginCredentialsFetcher.js
23770
- import { createHash as createHash4, createPrivateKey, createPublicKey, sign } from "crypto";
23771
- import { promises as fs2 } from "fs";
23772
- import { homedir as homedir3 } from "os";
23773
- import { dirname, join as join8 } from "path";
23768
+ import { createHash as createHash4, createPrivateKey, createPublicKey, sign } from "node:crypto";
23769
+ import { promises as fs2 } from "node:fs";
23770
+ import { homedir as homedir3 } from "node:os";
23771
+ import { dirname, join as join8 } from "node:path";
23774
23772
  var LoginCredentialsFetcher;
23775
23773
  var init_LoginCredentialsFetcher = __esm({
23776
23774
  "../../node_modules/.pnpm/@aws-sdk+credential-provider-login@3.972.66/node_modules/@aws-sdk/credential-provider-login/dist-es/LoginCredentialsFetcher.js"() {
@@ -24130,8 +24128,8 @@ var init_getValidatedProcessCredentials = __esm({
24130
24128
  });
24131
24129
 
24132
24130
  // ../../node_modules/.pnpm/@aws-sdk+credential-provider-process@3.972.59/node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js
24133
- import { exec } from "child_process";
24134
- import { promisify } from "util";
24131
+ import { exec } from "node:child_process";
24132
+ import { promisify } from "node:util";
24135
24133
  var resolveProcessCredentials;
24136
24134
  var init_resolveProcessCredentials = __esm({
24137
24135
  "../../node_modules/.pnpm/@aws-sdk+credential-provider-process@3.972.59/node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js"() {
@@ -24304,7 +24302,7 @@ var init_fromWebToken = __esm({
24304
24302
  });
24305
24303
 
24306
24304
  // ../../node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.972.65/node_modules/@aws-sdk/credential-provider-web-identity/dist-es/fromTokenFile.js
24307
- import { readFileSync } from "fs";
24305
+ import { readFileSync } from "node:fs";
24308
24306
  var ENV_TOKEN_FILE, ENV_ROLE_ARN, ENV_ROLE_SESSION_NAME, fromTokenFile;
24309
24307
  var init_fromTokenFile = __esm({
24310
24308
  "../../node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.972.65/node_modules/@aws-sdk/credential-provider-web-identity/dist-es/fromTokenFile.js"() {
@@ -24693,7 +24691,7 @@ var init_Sha256Js2 = __esm({
24693
24691
  });
24694
24692
 
24695
24693
  // ../../node_modules/.pnpm/@smithy+core@3.29.5/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256Node.js
24696
- import { createHash as createHash5, createHmac as createHmac2 } from "crypto";
24694
+ import { createHash as createHash5, createHmac as createHmac2 } from "node:crypto";
24697
24695
  function buildNativeClass4() {
24698
24696
  return class Sha256Node {
24699
24697
  digestLength = 32;
@@ -24855,7 +24853,7 @@ var init_RemoteProviderInit2 = __esm({
24855
24853
  });
24856
24854
 
24857
24855
  // ../../node_modules/.pnpm/@smithy+credential-provider-imds@4.4.14/node_modules/@smithy/credential-provider-imds/dist-es/remoteProvider/node-http.js
24858
- import node_http2 from "http";
24856
+ import node_http2 from "node:http";
24859
24857
  var init_node_http2 = __esm({
24860
24858
  "../../node_modules/.pnpm/@smithy+credential-provider-imds@4.4.14/node_modules/@smithy/credential-provider-imds/dist-es/remoteProvider/node-http.js"() {
24861
24859
  "use strict";
@@ -25450,7 +25448,7 @@ var init_retry_wrapper2 = __esm({
25450
25448
  });
25451
25449
 
25452
25450
  // ../../node_modules/.pnpm/@aws-sdk+credential-provider-http@3.972.63/node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/fromHttp.js
25453
- import fs3 from "fs/promises";
25451
+ import fs3 from "node:fs/promises";
25454
25452
  var AWS_CONTAINER_CREDENTIALS_RELATIVE_URI2, DEFAULT_LINK_LOCAL_HOST2, AWS_CONTAINER_CREDENTIALS_FULL_URI2, AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE2, AWS_CONTAINER_AUTHORIZATION_TOKEN2, fromHttp2, validateToken2;
25455
25453
  var init_fromHttp2 = __esm({
25456
25454
  "../../node_modules/.pnpm/@aws-sdk+credential-provider-http@3.972.63/node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/fromHttp.js"() {
@@ -26716,7 +26714,7 @@ var init_validateTokenKey2 = __esm({
26716
26714
  });
26717
26715
 
26718
26716
  // ../../node_modules/.pnpm/@aws-sdk+token-providers@3.1095.0/node_modules/@aws-sdk/token-providers/dist-es/writeSSOTokenToFile.js
26719
- import { promises as fsPromises2 } from "fs";
26717
+ import { promises as fsPromises2 } from "node:fs";
26720
26718
  var writeFile2, writeSSOTokenToFile2;
26721
26719
  var init_writeSSOTokenToFile2 = __esm({
26722
26720
  "../../node_modules/.pnpm/@aws-sdk+token-providers@3.1095.0/node_modules/@aws-sdk/token-providers/dist-es/writeSSOTokenToFile.js"() {
@@ -30076,10 +30074,10 @@ var init_signin2 = __esm({
30076
30074
  });
30077
30075
 
30078
30076
  // ../../node_modules/.pnpm/@aws-sdk+credential-provider-login@3.972.68/node_modules/@aws-sdk/credential-provider-login/dist-es/LoginCredentialsFetcher.js
30079
- import { createHash as createHash6, createPrivateKey as createPrivateKey2, createPublicKey as createPublicKey2, sign as sign2 } from "crypto";
30080
- import { promises as fs4 } from "fs";
30081
- import { homedir as homedir4 } from "os";
30082
- import { dirname as dirname2, join as join9 } from "path";
30077
+ import { createHash as createHash6, createPrivateKey as createPrivateKey2, createPublicKey as createPublicKey2, sign as sign2 } from "node:crypto";
30078
+ import { promises as fs4 } from "node:fs";
30079
+ import { homedir as homedir4 } from "node:os";
30080
+ import { dirname as dirname2, join as join9 } from "node:path";
30083
30081
  var LoginCredentialsFetcher2;
30084
30082
  var init_LoginCredentialsFetcher2 = __esm({
30085
30083
  "../../node_modules/.pnpm/@aws-sdk+credential-provider-login@3.972.68/node_modules/@aws-sdk/credential-provider-login/dist-es/LoginCredentialsFetcher.js"() {
@@ -30439,8 +30437,8 @@ var init_getValidatedProcessCredentials2 = __esm({
30439
30437
  });
30440
30438
 
30441
30439
  // ../../node_modules/.pnpm/@aws-sdk+credential-provider-process@3.972.61/node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js
30442
- import { exec as exec2 } from "child_process";
30443
- import { promisify as promisify2 } from "util";
30440
+ import { exec as exec2 } from "node:child_process";
30441
+ import { promisify as promisify2 } from "node:util";
30444
30442
  var resolveProcessCredentials3;
30445
30443
  var init_resolveProcessCredentials3 = __esm({
30446
30444
  "../../node_modules/.pnpm/@aws-sdk+credential-provider-process@3.972.61/node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js"() {
@@ -30613,7 +30611,7 @@ var init_fromWebToken2 = __esm({
30613
30611
  });
30614
30612
 
30615
30613
  // ../../node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.972.67/node_modules/@aws-sdk/credential-provider-web-identity/dist-es/fromTokenFile.js
30616
- import { readFileSync as readFileSync2 } from "fs";
30614
+ import { readFileSync as readFileSync2 } from "node:fs";
30617
30615
  var ENV_TOKEN_FILE2, ENV_ROLE_ARN2, ENV_ROLE_SESSION_NAME2, fromTokenFile2;
30618
30616
  var init_fromTokenFile2 = __esm({
30619
30617
  "../../node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.972.67/node_modules/@aws-sdk/credential-provider-web-identity/dist-es/fromTokenFile.js"() {
@@ -30763,8 +30761,8 @@ var init_dist_es24 = __esm({
30763
30761
 
30764
30762
  // src/cli.ts
30765
30763
  init_esm_shims();
30766
- import { realpathSync } from "fs";
30767
- import { fileURLToPath as fileURLToPath2 } from "url";
30764
+ import { realpathSync } from "node:fs";
30765
+ import { fileURLToPath } from "node:url";
30768
30766
 
30769
30767
  // src/aws-self-stop.ts
30770
30768
  init_esm_shims();
@@ -31488,12 +31486,12 @@ var getUserAgentPlugin = (config) => ({
31488
31486
 
31489
31487
  // ../../node_modules/.pnpm/@aws-sdk+core@3.975.3/node_modules/@aws-sdk/core/dist-es/submodules/client/util-user-agent-node/defaultUserAgent.js
31490
31488
  init_esm_shims();
31491
- import { platform, release } from "os";
31492
- import { env } from "process";
31489
+ import { platform, release } from "node:os";
31490
+ import { env } from "node:process";
31493
31491
 
31494
31492
  // ../../node_modules/.pnpm/@aws-sdk+core@3.975.3/node_modules/@aws-sdk/core/dist-es/submodules/client/util-user-agent-node/getRuntimeUserAgentPair.js
31495
31493
  init_esm_shims();
31496
- import { versions } from "process";
31494
+ import { versions } from "node:process";
31497
31495
  var getRuntimeUserAgentPair = () => {
31498
31496
  const runtimesToCheck = ["deno", "bun", "llrt"];
31499
31497
  for (const runtime of runtimesToCheck) {
@@ -31885,7 +31883,7 @@ init_esm_shims();
31885
31883
 
31886
31884
  // ../../node_modules/.pnpm/@smithy+core@3.29.5/node_modules/@smithy/core/dist-es/submodules/retry/middleware-retry/isStreamingPayload/isStreamingPayload.js
31887
31885
  init_esm_shims();
31888
- import { Readable as Readable7 } from "stream";
31886
+ import { Readable as Readable7 } from "node:stream";
31889
31887
  var isStreamingPayload2 = (request) => request?.body instanceof Readable7 || typeof ReadableStream !== "undefined" && request?.body instanceof ReadableStream;
31890
31888
 
31891
31889
  // ../../node_modules/.pnpm/@smithy+core@3.29.5/node_modules/@smithy/core/dist-es/submodules/retry/middleware-retry/retryMiddleware.js
@@ -32911,10 +32909,10 @@ ${longDate}
32911
32909
  ${credentialScope}
32912
32910
  ${toHex(hashedRequest)}`;
32913
32911
  }
32914
- getCanonicalPath({ path: path2 }) {
32912
+ getCanonicalPath({ path }) {
32915
32913
  if (this.uriEscapePath) {
32916
32914
  const normalizedPathSegments = [];
32917
- for (const pathSegment of path2.split("/")) {
32915
+ for (const pathSegment of path.split("/")) {
32918
32916
  if (pathSegment?.length === 0)
32919
32917
  continue;
32920
32918
  if (pathSegment === ".")
@@ -32925,11 +32923,11 @@ ${toHex(hashedRequest)}`;
32925
32923
  normalizedPathSegments.push(pathSegment);
32926
32924
  }
32927
32925
  }
32928
- const normalizedPath = `${path2?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path2?.endsWith("/") ? "/" : ""}`;
32926
+ const normalizedPath = `${path?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path?.endsWith("/") ? "/" : ""}`;
32929
32927
  const doubleEncoded = escapeUri(normalizedPath);
32930
32928
  return doubleEncoded.replace(/%2F/g, "/");
32931
32929
  }
32932
- return path2;
32930
+ return path;
32933
32931
  }
32934
32932
  validateResolvedCredentials(credentials) {
32935
32933
  if (typeof credentials !== "object" || typeof credentials.accessKeyId !== "string" || typeof credentials.secretAccessKey !== "string") {
@@ -33654,7 +33652,7 @@ var getTransformedHeaders2 = (headers) => {
33654
33652
 
33655
33653
  // ../../node_modules/.pnpm/@smithy+node-http-handler@4.9.7/node_modules/@smithy/node-http-handler/dist-es/node-https.js
33656
33654
  init_esm_shims();
33657
- import node_https2 from "https";
33655
+ import node_https2 from "node:https";
33658
33656
 
33659
33657
  // ../../node_modules/.pnpm/@smithy+node-http-handler@4.9.7/node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js
33660
33658
  init_esm_shims();
@@ -33772,7 +33770,7 @@ var setSocketTimeout2 = (request, reject, timeoutInMs = 0) => {
33772
33770
 
33773
33771
  // ../../node_modules/.pnpm/@smithy+node-http-handler@4.9.7/node_modules/@smithy/node-http-handler/dist-es/write-request-body.js
33774
33772
  init_esm_shims();
33775
- import { Readable as Readable9 } from "stream";
33773
+ import { Readable as Readable9 } from "node:stream";
33776
33774
  var MIN_WAIT_TIME2 = 6e3;
33777
33775
  async function writeRequestBody2(httpRequest3, request, maxContinueTimeoutMs = MIN_WAIT_TIME2, externalAgent = false) {
33778
33776
  const headers = request.headers;
@@ -33941,12 +33939,12 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
33941
33939
  const password = request.password ?? "";
33942
33940
  auth = `${username}:${password}`;
33943
33941
  }
33944
- let path2 = request.path;
33942
+ let path = request.path;
33945
33943
  if (queryString) {
33946
- path2 += `?${queryString}`;
33944
+ path += `?${queryString}`;
33947
33945
  }
33948
33946
  if (request.fragment) {
33949
- path2 += `#${request.fragment}`;
33947
+ path += `#${request.fragment}`;
33950
33948
  }
33951
33949
  let hostname = request.hostname ?? "";
33952
33950
  if (hostname[0] === "[" && hostname.endsWith("]")) {
@@ -33958,7 +33956,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
33958
33956
  headers: request.headers,
33959
33957
  host: hostname,
33960
33958
  method: request.method,
33961
- path: path2,
33959
+ path,
33962
33960
  port: request.port,
33963
33961
  agent,
33964
33962
  auth
@@ -34034,7 +34032,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
34034
34032
  socketAcquisitionWarningTimeout,
34035
34033
  throwOnRequestTimeout,
34036
34034
  httpAgentProvider: async () => {
34037
- const node_http3 = await import("http");
34035
+ const node_http3 = await import("node:http");
34038
34036
  const { Agent, request } = node_http3.default ?? node_http3;
34039
34037
  hRequest2 = request;
34040
34038
  hAgent2 = Agent;
@@ -39545,6 +39543,12 @@ var AwsSelfStopAccess = class {
39545
39543
  // src/config.ts
39546
39544
  init_esm_shims();
39547
39545
  var DEFAULT_SYNC_INTERVAL_SECONDS = 60;
39546
+ var DEFAULT_WALKBACK_MAX_POINTS = 10;
39547
+ var DEFAULT_WALKBACK_BUDGET_SECONDS = 180;
39548
+ function positiveIntOr(value, defaultValue) {
39549
+ const parsed = Number.parseInt(value ?? "", 10);
39550
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : defaultValue;
39551
+ }
39548
39552
  function nonEmpty(value) {
39549
39553
  return value !== void 0 && value !== "" ? value : null;
39550
39554
  }
@@ -39556,7 +39560,6 @@ function resolveConfig(env3) {
39556
39560
  const bucket = nonEmpty(env3.LITESTREAM_BUCKET);
39557
39561
  const prefix = nonEmpty(env3.LITESTREAM_PREFIX);
39558
39562
  const persistenceEnabled = bucket !== null && prefix !== null;
39559
- const interval = Number.parseInt(env3.CREDS_SYNC_INTERVAL ?? "", 10);
39560
39563
  return {
39561
39564
  homeDir,
39562
39565
  claude: {
@@ -39573,7 +39576,15 @@ function resolveConfig(env3) {
39573
39576
  bucket: persistenceEnabled ? bucket : null,
39574
39577
  prefix: persistenceEnabled ? prefix : null,
39575
39578
  region: nonEmpty(env3.AWS_REGION),
39576
- syncIntervalSeconds: Number.isFinite(interval) && interval > 0 ? interval : DEFAULT_SYNC_INTERVAL_SECONDS,
39579
+ syncIntervalSeconds: positiveIntOr(env3.CREDS_SYNC_INTERVAL, DEFAULT_SYNC_INTERVAL_SECONDS),
39580
+ walkbackMaxPoints: positiveIntOr(
39581
+ env3.EVIDENT_SESSION_DB_WALKBACK_MAX_POINTS,
39582
+ DEFAULT_WALKBACK_MAX_POINTS
39583
+ ),
39584
+ walkbackBudgetSeconds: positiveIntOr(
39585
+ env3.EVIDENT_SESSION_DB_WALKBACK_BUDGET_SECONDS,
39586
+ DEFAULT_WALKBACK_BUDGET_SECONDS
39587
+ ),
39577
39588
  hasModelApiKey: nonEmpty(env3.ANTHROPIC_API_KEY) !== null || nonEmpty(env3.OPENAI_API_KEY) !== null
39578
39589
  };
39579
39590
  }
@@ -39586,22 +39597,22 @@ init_esm_shims();
39586
39597
  function assertNever(value) {
39587
39598
  throw new Error(`Unhandled restore outcome: ${JSON.stringify(value)}`);
39588
39599
  }
39589
- function describeRestoreOutcome(label, path2, outcome) {
39600
+ function describeRestoreOutcome(label, path, outcome) {
39590
39601
  switch (outcome.kind) {
39591
39602
  case "local":
39592
- return `Found valid ${label} credentials at ${path2}.`;
39603
+ return `Found valid ${label} credentials at ${path}.`;
39593
39604
  case "restored":
39594
- return `Found valid ${label} credentials at ${path2} (restored from the object store).`;
39605
+ return `Found valid ${label} credentials at ${path} (restored from the object store).`;
39595
39606
  case "failed":
39596
39607
  return `WARNING: ${label} credentials could not be restored from S3 (${outcome.reason}). Check the earlier S3 error for IAM/network details before bootstrapping again; the existing persisted credentials may still be recoverable.`;
39597
39608
  case "invalid":
39598
39609
  return `WARNING: a persisted ${label} credentials object was found in S3 but was invalid/corrupt and was discarded (see the warning above) \u2014 nothing usable was restored. Re-bootstrap auth, or check what wrote that S3 object.`;
39599
39610
  case "localInvalid":
39600
- return `WARNING: local ${label} credentials at ${path2} are invalid/unreadable and were kept in place (see the warning above), which blocks restoring a good S3 object over them. Fix or remove the local file so a valid persisted copy (if any) can restore. If they were written by root during an SSM-Exec bootstrap they are simply unreadable by the runner user: 'chown -R 10001:10001' them from the exec shell.`;
39611
+ return `WARNING: local ${label} credentials at ${path} are invalid/unreadable and were kept in place (see the warning above), which blocks restoring a good S3 object over them. Fix or remove the local file so a valid persisted copy (if any) can restore. If they were written by root during an SSM-Exec bootstrap they are simply unreadable by the runner user: 'chown -R 10001:10001' them from the exec shell.`;
39601
39612
  case "missing":
39602
- return `No ${label} credentials at ${path2} (and none persisted in S3).`;
39613
+ return `No ${label} credentials at ${path} (and none persisted in S3).`;
39603
39614
  case "disabled":
39604
- return `No ${label} credentials at ${path2}; credential persistence is disabled (LITESTREAM_BUCKET/LITESTREAM_PREFIX unset), so nothing could be restored.`;
39615
+ return `No ${label} credentials at ${path}; credential persistence is disabled (LITESTREAM_BUCKET/LITESTREAM_PREFIX unset), so nothing could be restored.`;
39605
39616
  default:
39606
39617
  return assertNever(outcome);
39607
39618
  }
@@ -39615,6 +39626,9 @@ function assertNeverUnusableReplicaReason(value) {
39615
39626
  function assertNeverFatalCause(value) {
39616
39627
  throw new Error(`Unhandled fatal cause: ${JSON.stringify(value)}`);
39617
39628
  }
39629
+ function assertNeverNoReplicaLocalDb(value) {
39630
+ throw new Error(`Unhandled noReplica local-DB state: ${JSON.stringify(value)}`);
39631
+ }
39618
39632
  function sessionDbExitCode(outcome) {
39619
39633
  switch (outcome.kind) {
39620
39634
  case "disabled":
@@ -39627,7 +39641,7 @@ function sessionDbExitCode(outcome) {
39627
39641
  // re-run `litestream restore` and ask again
39628
39642
  case "unusableReplica":
39629
39643
  return 31;
39630
- // booted with a fresh DB; the shell must skip `litestream replicate`
39644
+ // booted with a fresh DB; the shell still starts a fresh backup chain (#1106)
39631
39645
  case "fatal":
39632
39646
  return 30;
39633
39647
  // shared by a genuine misconfig and a deliberate `crash` choice
@@ -39643,7 +39657,9 @@ function describeUnusableReplica(reason) {
39643
39657
  case "attemptsExhausted":
39644
39658
  return `${base} (recovery did not make the replica usable after retrying; giving up.)`;
39645
39659
  case "layoutMismatch":
39646
- return `${base} (no level-0 LTX object was found under the replica prefix, so --on-unusable-replica=prune had nothing matching its expected layout to delete.)`;
39660
+ return `${base} (objects exist under the replica prefix but NONE of them match the LTX key layout --on-unusable-replica=prune expects \u2014 see the SESSION-DB-REPLICA-LAYOUT-MISMATCH warning above for a sample key. This means our key parsing is wrong, or litestream's on-disk layout changed.)`;
39661
+ case "noL0Present":
39662
+ return `${base} (--on-unusable-replica=prune found no level-0 object to prune. This is expected: litestream expires level-0 objects itself after a few minutes, so at boot the newest one is normally absent. prune only ever targets level 0, so it cannot repair corruption at a higher compaction level.)`;
39647
39663
  case "recoveryFailed":
39648
39664
  return `${base} (the recovery delete itself failed; see the warning above for the S3 error.)`;
39649
39665
  case "targetHealthy":
@@ -39665,18 +39681,31 @@ function describeSessionDbFatal(outcome, config) {
39665
39681
  return assertNeverFatalCause(outcome.cause);
39666
39682
  }
39667
39683
  }
39684
+ function describeNoReplica(localDb) {
39685
+ switch (localDb) {
39686
+ case "absent":
39687
+ return "No opencode.db replica found in the object store; opencode will create a fresh session DB.";
39688
+ case "empty":
39689
+ return "litestream restore succeeded but left a zero-byte opencode.db; opencode will create a fresh session DB.";
39690
+ default:
39691
+ return assertNeverNoReplicaLocalDb(localDb);
39692
+ }
39693
+ }
39668
39694
  function describeSessionDbClassification(outcome, config) {
39669
39695
  switch (outcome.kind) {
39670
39696
  case "disabled":
39671
39697
  return "No opencode.db restore attempted; credential persistence is disabled (LITESTREAM_BUCKET/LITESTREAM_PREFIX unset).";
39672
39698
  case "restored":
39673
- return "opencode.db restored from the object store.";
39699
+ return `SESSION-DB-SIZE: opencode.db restored from the object store. state=restored bytes=${outcome.bytes}`;
39674
39700
  case "noReplica":
39675
- return "No opencode.db replica found in the object store; opencode will create a fresh session DB.";
39701
+ return `SESSION-DB-SIZE: ${describeNoReplica(outcome.localDb)} state=${outcome.localDb} bytes=0`;
39676
39702
  case "retryTransient":
39677
39703
  return "opencode.db replica restore failed (transient); retrying.";
39678
39704
  case "recovered": {
39679
39705
  const objects = outcome.deleted.length === 0 ? "no objects (see the warnings above for what failed)" : `${outcome.deleted.length} object${outcome.deleted.length === 1 ? "" : "s"} (${outcome.deleted.join(", ")})`;
39706
+ if (outcome.strategy === "quarantine") {
39707
+ return `Escalated opencode.db replica recovery to quarantine: --on-unusable-replica=prune found nothing at level 0 to delete, so the corruption is deeper than prune can reach. Moved ${objects} aside; retrying the restore. Prior session history is set aside, NOT deleted \u2014 see the SESSION-DB-REPLICA-QUARANTINED warning above for where.`;
39708
+ }
39680
39709
  return `Attempted opencode.db replica recovery via --on-unusable-replica=${outcome.strategy}, deleting ${objects}; retrying the restore.` + (outcome.strategy === "clear" ? " Prior session history is lost." : "");
39681
39710
  }
39682
39711
  case "unusableReplica":
@@ -39687,40 +39716,173 @@ function describeSessionDbClassification(outcome, config) {
39687
39716
  return assertNeverSessionDb(outcome);
39688
39717
  }
39689
39718
  }
39719
+ function assertNeverSessionDbVerify(value) {
39720
+ throw new Error(`Unhandled session-DB verify outcome: ${JSON.stringify(value)}`);
39721
+ }
39722
+ function assertNeverSessionDbVerifySkippedLocalDb(value) {
39723
+ throw new Error(`Unhandled session-DB verify skipped local-DB state: ${JSON.stringify(value)}`);
39724
+ }
39725
+ function assertNeverSessionDbVerifyExhaustedReason(value) {
39726
+ throw new Error(`Unhandled session-DB verify exhausted reason: ${JSON.stringify(value)}`);
39727
+ }
39728
+ function sessionDbVerifyExitCode(outcome) {
39729
+ switch (outcome.kind) {
39730
+ case "skipped":
39731
+ case "healthy":
39732
+ case "walkedBack":
39733
+ return 0;
39734
+ case "exhausted":
39735
+ return 33;
39736
+ // booted with a fresh DB; the shell still starts a fresh backup chain
39737
+ default:
39738
+ return assertNeverSessionDbVerify(outcome);
39739
+ }
39740
+ }
39741
+ function describeSessionDbVerifySkipped(localDb) {
39742
+ switch (localDb) {
39743
+ case "absent":
39744
+ return "No opencode.db found; nothing to verify at boot.";
39745
+ case "empty":
39746
+ return "opencode.db is zero bytes; nothing to verify at boot.";
39747
+ default:
39748
+ return assertNeverSessionDbVerifySkippedLocalDb(localDb);
39749
+ }
39750
+ }
39751
+ function describeSessionDbVerifyExhausted(outcome) {
39752
+ const tried = `tried ${outcome.candidatesTried} restore point${outcome.candidatesTried === 1 ? "" : "s"}`;
39753
+ switch (outcome.reason) {
39754
+ case "enumerationFailed":
39755
+ return `SESSION-DB-INTEGRITY-EXHAUSTED: opencode.db failed its integrity check and litestream's restore-point listing could not be read (${tried}); booting with a FRESH opencode.db.`;
39756
+ case "noCandidates":
39757
+ return `SESSION-DB-INTEGRITY-EXHAUSTED: opencode.db failed its integrity check and no older restore point is retained (${tried}); booting with a FRESH opencode.db.`;
39758
+ case "allFailed":
39759
+ return `SESSION-DB-INTEGRITY-EXHAUSTED: opencode.db failed its integrity check and every retained restore point also failed (${tried}); booting with a FRESH opencode.db.`;
39760
+ case "budgetExhausted":
39761
+ return `SESSION-DB-INTEGRITY-EXHAUSTED: opencode.db failed its integrity check; the walkback search budget ran out before every retained restore point was tried (${tried}) \u2014 widen it with EVIDENT_SESSION_DB_WALKBACK_MAX_POINTS/EVIDENT_SESSION_DB_WALKBACK_BUDGET_SECONDS if there was more to try; booting with a FRESH opencode.db.`;
39762
+ default:
39763
+ return assertNeverSessionDbVerifyExhaustedReason(outcome.reason);
39764
+ }
39765
+ }
39766
+ function describeSessionDbVerification(outcome) {
39767
+ switch (outcome.kind) {
39768
+ case "skipped":
39769
+ return describeSessionDbVerifySkipped(outcome.localDb);
39770
+ case "healthy":
39771
+ return `SESSION-DB-INTEGRITY: ok bytes=${outcome.bytes}`;
39772
+ case "walkedBack":
39773
+ return `SESSION-DB-INTEGRITY-WALKBACK: opencode.db failed its integrity check; adopted an older litestream restore point after trying ${outcome.candidatesTried} candidate${outcome.candidatesTried === 1 ? "" : "s"}. Everything after this transaction is lost. txid=${outcome.txid} candidates=${outcome.candidatesTried} bytes=${outcome.bytes}`;
39774
+ case "exhausted":
39775
+ return describeSessionDbVerifyExhausted(outcome);
39776
+ default:
39777
+ return assertNeverSessionDbVerify(outcome);
39778
+ }
39779
+ }
39690
39780
 
39691
39781
  // src/file-ops.ts
39692
39782
  init_esm_shims();
39693
- import { createHash as createHash7 } from "crypto";
39694
- import { chmod, mkdir, open, readFile as readFile4, rename, rm, stat, writeFile as writeFile3 } from "fs/promises";
39783
+ import { createHash as createHash7 } from "node:crypto";
39784
+ import { chmod, mkdir, open, readFile as readFile4, rename, rm, stat, writeFile as writeFile3 } from "node:fs/promises";
39695
39785
  var nodeFileOps = {
39696
39786
  async mkdirp(dir) {
39697
39787
  await mkdir(dir, { recursive: true });
39698
39788
  },
39699
- async chmod(path2, mode) {
39700
- await chmod(path2, mode);
39789
+ async chmod(path, mode) {
39790
+ await chmod(path, mode);
39701
39791
  },
39702
- async stat(path2) {
39792
+ async stat(path) {
39703
39793
  try {
39704
- const stats = await stat(path2);
39794
+ const stats = await stat(path);
39705
39795
  return { size: stats.size };
39706
39796
  } catch {
39707
39797
  return null;
39708
39798
  }
39709
39799
  },
39710
39800
  readFile: readFile4,
39711
- async writeFile(path2, data) {
39712
- await writeFile3(path2, data);
39801
+ async writeFile(path, data) {
39802
+ await writeFile3(path, data);
39713
39803
  },
39714
- async createExclusive(path2) {
39715
- const handle = await open(path2, "wx", 384);
39804
+ async createExclusive(path) {
39805
+ const handle = await open(path, "wx", 384);
39716
39806
  await handle.close();
39717
39807
  },
39718
39808
  rename,
39719
- async remove(path2) {
39720
- await rm(path2, { force: true });
39809
+ async remove(path) {
39810
+ await rm(path, { force: true });
39721
39811
  },
39722
- async hashFile(path2) {
39723
- return createHash7("sha256").update(await readFile4(path2)).digest("hex");
39812
+ async hashFile(path) {
39813
+ return createHash7("sha256").update(await readFile4(path)).digest("hex");
39814
+ }
39815
+ };
39816
+
39817
+ // src/litestream-cli.ts
39818
+ init_esm_shims();
39819
+ import { execFile } from "node:child_process";
39820
+ import { promisify as promisify3 } from "node:util";
39821
+
39822
+ // src/logger.ts
39823
+ init_esm_shims();
39824
+ var LOG_PREFIX = "[auth-persistence]";
39825
+ var consoleLogger = (message) => {
39826
+ process.stderr.write(`${LOG_PREFIX} ${message}
39827
+ `);
39828
+ };
39829
+ function describeError(error) {
39830
+ return error instanceof Error ? error.message : String(error);
39831
+ }
39832
+
39833
+ // src/litestream-cli.ts
39834
+ var execFileAsync = promisify3(execFile);
39835
+ function stderrOf(error) {
39836
+ if (typeof error === "object" && error !== null && "stderr" in error) {
39837
+ const stderr = error.stderr;
39838
+ if (typeof stderr === "string" && stderr.length > 0) return stderr;
39839
+ }
39840
+ return describeError(error);
39841
+ }
39842
+ var LitestreamCli = class {
39843
+ constructor(configPath, dbPath) {
39844
+ this.configPath = configPath;
39845
+ this.dbPath = dbPath;
39846
+ }
39847
+ async listRestorePoints() {
39848
+ try {
39849
+ const { stdout, stderr } = await execFileAsync("litestream", [
39850
+ "ltx",
39851
+ "-config",
39852
+ this.configPath,
39853
+ // MEASURED: `-level` defaults to 0, which only shows L0 — `all` is
39854
+ // required to see the L1/L2/L9 compaction levels too (plan §2.3).
39855
+ "-level",
39856
+ "all",
39857
+ "-json",
39858
+ this.dbPath
39859
+ ]);
39860
+ return { stdout, detail: stderr };
39861
+ } catch (error) {
39862
+ return { stdout: null, detail: stderrOf(error) };
39863
+ }
39864
+ }
39865
+ async restoreAt(txid, outputPath) {
39866
+ try {
39867
+ const { stderr } = await execFileAsync("litestream", [
39868
+ "restore",
39869
+ "-config",
39870
+ this.configPath,
39871
+ "-txid",
39872
+ txid,
39873
+ // MEASURED: without `-force`, restoring into a path that already
39874
+ // exists exits 1 with "output path already exists and is not
39875
+ // empty" (plan §2.4) — the caller always restores into a scratch
39876
+ // path it just cleared, so overwriting it is always intended.
39877
+ "-force",
39878
+ "-o",
39879
+ outputPath,
39880
+ this.dbPath
39881
+ ]);
39882
+ return { ok: true, detail: stderr };
39883
+ } catch (error) {
39884
+ return { ok: false, detail: stderrOf(error) };
39885
+ }
39724
39886
  }
39725
39887
  };
39726
39888
 
@@ -39750,26 +39912,15 @@ dbs:
39750
39912
  `;
39751
39913
  }
39752
39914
 
39753
- // src/logger.ts
39754
- init_esm_shims();
39755
- var LOG_PREFIX = "[auth-persistence]";
39756
- var consoleLogger = (message) => {
39757
- process.stderr.write(`${LOG_PREFIX} ${message}
39758
- `);
39759
- };
39760
- function describeError(error) {
39761
- return error instanceof Error ? error.message : String(error);
39762
- }
39763
-
39764
39915
  // src/model-auth.ts
39765
39916
  init_esm_shims();
39766
39917
 
39767
39918
  // src/valid-json.ts
39768
39919
  init_esm_shims();
39769
- async function isValidJson(fileOps, path2) {
39920
+ async function isValidJson(fileOps, path) {
39770
39921
  let contents;
39771
39922
  try {
39772
- contents = await fileOps.readFile(path2);
39923
+ contents = await fileOps.readFile(path);
39773
39924
  } catch {
39774
39925
  return false;
39775
39926
  }
@@ -39803,7 +39954,7 @@ function replicaDbPrefix(prefix) {
39803
39954
  var LTX_FILENAME = /^([0-9a-fA-F]+)-([0-9a-fA-F]+)\.ltx$/;
39804
39955
  function parseLtxKey(prefix, key) {
39805
39956
  if (key.split("/").includes("..")) return null;
39806
- const root12 = `${replicaDbPrefix(prefix)}ltx/`;
39957
+ const root12 = replicaDbPrefix(prefix);
39807
39958
  if (!key.startsWith(root12)) return null;
39808
39959
  const [levelPart, filename, ...rest] = key.slice(root12.length).split("/");
39809
39960
  if (rest.length > 0 || filename === void 0 || !/^\d+$/.test(levelPart)) return null;
@@ -39826,6 +39977,9 @@ function newestL0Key(prefix, keys) {
39826
39977
  }
39827
39978
  return newest?.key ?? null;
39828
39979
  }
39980
+ function hasParsableLtxKey(prefix, keys) {
39981
+ return keys.some((key) => parseLtxKey(prefix, key) !== null);
39982
+ }
39829
39983
  function isDeletableReplicaKey(prefix, key) {
39830
39984
  if (!key.startsWith(replicaDbPrefix(prefix))) return false;
39831
39985
  return !key.split("/").includes("..");
@@ -39833,10 +39987,10 @@ function isDeletableReplicaKey(prefix, key) {
39833
39987
 
39834
39988
  // src/restore.ts
39835
39989
  init_esm_shims();
39836
- import { dirname as dirname3 } from "path";
39990
+ import { dirname as dirname3 } from "node:path";
39837
39991
  async function restore(params) {
39838
- const { label, path: path2, bucket, key, store, fileOps, log } = params;
39839
- const dir = dirname3(path2);
39992
+ const { label, path, bucket, key, store, fileOps, log } = params;
39993
+ const dir = dirname3(path);
39840
39994
  try {
39841
39995
  await fileOps.mkdirp(dir);
39842
39996
  } catch {
@@ -39848,21 +40002,21 @@ async function restore(params) {
39848
40002
  } catch {
39849
40003
  log(`WARNING: could not restrict ${label} credential directory ${dir}.`);
39850
40004
  }
39851
- const local = await fileOps.stat(path2);
39852
- if (local !== null && local.size > 0 && !await isValidJson(fileOps, path2)) {
40005
+ const local = await fileOps.stat(path);
40006
+ if (local !== null && local.size > 0 && !await isValidJson(fileOps, path)) {
39853
40007
  log(
39854
- `WARNING: local ${label} credentials at ${path2} are invalid or unreadable; keeping them and skipping restore.`
40008
+ `WARNING: local ${label} credentials at ${path} are invalid or unreadable; keeping them and skipping restore.`
39855
40009
  );
39856
40010
  return { kind: "localInvalid" };
39857
40011
  }
39858
40012
  if (local !== null && local.size === 0) {
39859
40013
  log(
39860
- `Local ${label} credentials at ${path2} are empty; will attempt to restore from S3 instead of protecting them.`
40014
+ `Local ${label} credentials at ${path} are empty; will attempt to restore from S3 instead of protecting them.`
39861
40015
  );
39862
40016
  }
39863
- if (await isValidJson(fileOps, path2)) {
39864
- await chmodOrWarn(fileOps, log, path2, `local ${label} credentials at ${path2}`);
39865
- log(`Keeping valid local ${label} credentials at ${path2}; no restore.`);
40017
+ if (await isValidJson(fileOps, path)) {
40018
+ await chmodOrWarn(fileOps, log, path, `local ${label} credentials at ${path}`);
40019
+ log(`Keeping valid local ${label} credentials at ${path}; no restore.`);
39866
40020
  return { kind: "local" };
39867
40021
  }
39868
40022
  if (store === null || bucket === null || key === null) {
@@ -39907,19 +40061,19 @@ async function restore(params) {
39907
40061
  return { kind: "invalid" };
39908
40062
  }
39909
40063
  try {
39910
- await fileOps.rename(temp, path2);
40064
+ await fileOps.rename(temp, path);
39911
40065
  } catch {
39912
40066
  await fileOps.remove(temp);
39913
- log(`WARNING: could not install restored ${label} credentials at ${path2}.`);
39914
- return { kind: "failed", reason: `could not install ${path2}` };
40067
+ log(`WARNING: could not install restored ${label} credentials at ${path}.`);
40068
+ return { kind: "failed", reason: `could not install ${path}` };
39915
40069
  }
39916
- await chmodOrWarn(fileOps, log, path2, `restored ${label} credentials at ${path2}`);
39917
- log(`Restored ${label} credentials from ${location} to ${path2}.`);
40070
+ await chmodOrWarn(fileOps, log, path, `restored ${label} credentials at ${path}`);
40071
+ log(`Restored ${label} credentials from ${location} to ${path}.`);
39918
40072
  return { kind: "restored" };
39919
40073
  }
39920
- async function chmodOrWarn(fileOps, log, path2, subject) {
40074
+ async function chmodOrWarn(fileOps, log, path, subject) {
39921
40075
  try {
39922
- await fileOps.chmod(path2, 384);
40076
+ await fileOps.chmod(path, 384);
39923
40077
  } catch {
39924
40078
  log(`WARNING: could not restrict ${subject}.`);
39925
40079
  }
@@ -40970,7 +41124,7 @@ init_protocols();
40970
41124
 
40971
41125
  // ../../node_modules/.pnpm/@aws-sdk+middleware-sdk-s3@3.972.66/node_modules/@aws-sdk/middleware-sdk-s3/dist-es/submodules/s3/to-stream/toStream.js
40972
41126
  init_esm_shims();
40973
- import { Readable as Readable10 } from "stream";
41127
+ import { Readable as Readable10 } from "node:stream";
40974
41128
  function toStream(bytes) {
40975
41129
  return Readable10.from(Buffer.from(bytes));
40976
41130
  }
@@ -43392,6 +43546,12 @@ var _ep011 = {
43392
43546
  Bucket: { type: "contextParams", name: "Bucket" },
43393
43547
  Key: { type: "contextParams", name: "Key" }
43394
43548
  };
43549
+ var _ep13 = {
43550
+ DisableS3ExpressSessionAuth: { type: "staticContextParams", value: true },
43551
+ Bucket: { type: "contextParams", name: "Bucket" },
43552
+ Key: { type: "contextParams", name: "Key" },
43553
+ CopySource: { type: "contextParams", name: "CopySource" }
43554
+ };
43395
43555
  var _ep4 = {
43396
43556
  DisableS3ExpressSessionAuth: { type: "staticContextParams", value: true },
43397
43557
  Bucket: { type: "contextParams", name: "Bucket" }
@@ -43403,6 +43563,10 @@ var _ep8 = {
43403
43563
  var _mw011 = (Command3, cs, config, o7) => [
43404
43564
  getThrow200ExceptionsPlugin(config)
43405
43565
  ];
43566
+ var _mw1 = (Command3, cs, config, o7) => [
43567
+ getThrow200ExceptionsPlugin(config),
43568
+ getSsecPlugin(config)
43569
+ ];
43406
43570
  var _mw7 = (Command3, cs, config, o7) => [
43407
43571
  getFlexibleChecksumsPlugin(config, {
43408
43572
  requestChecksumRequired: false,
@@ -49428,7 +49592,7 @@ var Sha1Js = class _Sha1Js {
49428
49592
 
49429
49593
  // ../../node_modules/.pnpm/@aws-sdk+checksums@3.1000.20/node_modules/@aws-sdk/checksums/dist-es/submodules/sha/sha1/Sha1Node.js
49430
49594
  init_esm_shims();
49431
- import { createHash as createHash8, createHmac as createHmac3 } from "crypto";
49595
+ import { createHash as createHash8, createHmac as createHmac3 } from "node:crypto";
49432
49596
  var hasNativeCrypto4 = (() => {
49433
49597
  try {
49434
49598
  createHash8("sha1");
@@ -49676,6 +49840,11 @@ var S3Client = class extends Client {
49676
49840
  }
49677
49841
  };
49678
49842
 
49843
+ // ../../node_modules/.pnpm/@aws-sdk+client-s3@3.1095.0/node_modules/@aws-sdk/client-s3/dist-es/commands/CopyObjectCommand.js
49844
+ init_esm_shims();
49845
+ var CopyObjectCommand = class extends command11(_ep13, _mw1, "CopyObject", CopyObject$) {
49846
+ };
49847
+
49679
49848
  // ../../node_modules/.pnpm/@aws-sdk+client-s3@3.1095.0/node_modules/@aws-sdk/client-s3/dist-es/commands/DeleteObjectCommand.js
49680
49849
  init_esm_shims();
49681
49850
  var DeleteObjectCommand = class extends command11(_ep011, _mw011, "DeleteObject", DeleteObject$) {
@@ -49726,7 +49895,7 @@ var S3ObjectStore = class {
49726
49895
  await this.client.send(new PutObjectCommand({ Bucket: this.bucket, Key: key, Body: body }));
49727
49896
  }
49728
49897
  async list(prefix) {
49729
- const keys = [];
49898
+ const objects = [];
49730
49899
  let continuationToken;
49731
49900
  do {
49732
49901
  const response = await this.client.send(
@@ -49737,11 +49906,11 @@ var S3ObjectStore = class {
49737
49906
  })
49738
49907
  );
49739
49908
  for (const object of response.Contents ?? []) {
49740
- if (object.Key) keys.push(object.Key);
49909
+ if (object.Key) objects.push({ key: object.Key, size: object.Size ?? 0 });
49741
49910
  }
49742
49911
  continuationToken = response.NextContinuationToken;
49743
49912
  } while (continuationToken);
49744
- return keys;
49913
+ return objects;
49745
49914
  }
49746
49915
  async delete(key) {
49747
49916
  try {
@@ -49751,6 +49920,30 @@ var S3ObjectStore = class {
49751
49920
  throw error;
49752
49921
  }
49753
49922
  }
49923
+ /**
49924
+ * `CopyObject` — S3 copies the bytes server-side, so a 545 MB snapshot never
49925
+ * enters this process (see `ObjectStore.copy`).
49926
+ *
49927
+ * `CopySource` is `<bucket>/<key>` and S3 expects it URL-encoded. `encodeURI`
49928
+ * (not `encodeURIComponent`) is the right one here: it leaves the `/`
49929
+ * separators intact, which S3 needs, while still escaping anything exotic.
49930
+ * Every key this is called with has already passed `isDeletableReplicaKey`,
49931
+ * so it is `<prefix>/opencode.db/…` with no `..` segment and no `%` to
49932
+ * double-encode.
49933
+ *
49934
+ * Deliberately does NOT swallow a not-found the way `delete` does: the only
49935
+ * caller deletes the source immediately afterwards, so a copy that quietly
49936
+ * did nothing would destroy the object it was meant to preserve.
49937
+ */
49938
+ async copy(fromKey, toKey) {
49939
+ await this.client.send(
49940
+ new CopyObjectCommand({
49941
+ Bucket: this.bucket,
49942
+ CopySource: encodeURI(`${this.bucket}/${fromKey}`),
49943
+ Key: toKey
49944
+ })
49945
+ );
49946
+ }
49754
49947
  };
49755
49948
 
49756
49949
  // src/session-db.ts
@@ -49772,20 +49965,38 @@ function isStructurallySoundLtxObject(bytes) {
49772
49965
  async function probeReplica(store, prefix, log) {
49773
49966
  const root12 = replicaDbPrefix(prefix);
49774
49967
  try {
49775
- const keys = await store.list(root12);
49776
- return { ok: true, keys };
49968
+ const objects = await store.list(root12);
49969
+ const objectCount = objects.length;
49970
+ const totalBytes = objects.reduce((sum, object) => sum + object.size, 0);
49971
+ logReplicaSize(root12, objectCount, totalBytes, log);
49972
+ return { ok: true, keys: objects.map((object) => object.key) };
49777
49973
  } catch (error) {
49778
49974
  const detail = describeError(error);
49779
49975
  log(`WARNING: could not list the replica prefix ${root12}: ${detail}`);
49780
49976
  return { ok: false, detail };
49781
49977
  }
49782
49978
  }
49979
+ function logReplicaSize(root12, objectCount, totalBytes, log) {
49980
+ log(
49981
+ `INFO: SESSION-DB-REPLICA-SIZE: the opencode.db replica under ${root12} objects=${objectCount} bytes=${totalBytes}`
49982
+ );
49983
+ }
49984
+ function logLayoutMismatch(prefix, keys, log) {
49985
+ log(
49986
+ `WARNING: SESSION-DB-REPLICA-LAYOUT-MISMATCH: listed ${keys.length} object(s) under the replica prefix ${replicaDbPrefix(prefix)} but none of them match the expected LTX key layout (<prefix>/opencode.db/<level>/<minTxid>-<maxTxid>.ltx). Sample key: ${keys[0]}. --on-unusable-replica=prune cannot select anything to delete until this is fixed.`
49987
+ );
49988
+ }
49783
49989
  async function pruneNewestL0(store, prefix, keys, log) {
49784
49990
  const target = newestL0Key(prefix, keys);
49785
- if (target === null || !isDeletableReplicaKey(prefix, target)) {
49786
- if (target !== null) {
49787
- log(`WARNING: refusing to prune ${target}: failed the replica-key guard.`);
49991
+ if (target === null) {
49992
+ if (keys.length > 0 && !hasParsableLtxKey(prefix, keys)) {
49993
+ logLayoutMismatch(prefix, keys, log);
49994
+ return { deleted: null, reason: "layoutMismatch" };
49788
49995
  }
49996
+ return { deleted: null, reason: "noL0Present" };
49997
+ }
49998
+ if (!isDeletableReplicaKey(prefix, target)) {
49999
+ log(`WARNING: refusing to prune ${target}: failed the replica-key guard.`);
49789
50000
  return { deleted: null, reason: "layoutMismatch" };
49790
50001
  }
49791
50002
  let bytes;
@@ -49795,7 +50006,7 @@ async function pruneNewestL0(store, prefix, keys, log) {
49795
50006
  log(
49796
50007
  `WARNING: could not re-read ${target} to check whether it is actually corrupt before pruning it: ${describeError(error)}. Declining to prune without positive evidence.`
49797
50008
  );
49798
- return { deleted: null, reason: "targetHealthy" };
50009
+ return { deleted: null, reason: "unreadable" };
49799
50010
  }
49800
50011
  if (bytes === null || isStructurallySoundLtxObject(bytes)) {
49801
50012
  log(
@@ -49812,6 +50023,48 @@ async function pruneNewestL0(store, prefix, keys, log) {
49812
50023
  }
49813
50024
  return { deleted: target };
49814
50025
  }
50026
+ function quarantineRoot(prefix, stamp) {
50027
+ return `${prefix}/quarantine/opencode.db/${stamp}/`;
50028
+ }
50029
+ async function quarantineReplica(store, prefix, keys, log, stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")) {
50030
+ const destination = quarantineRoot(prefix, stamp);
50031
+ const root12 = replicaDbPrefix(prefix);
50032
+ const moved = [];
50033
+ const failed = [];
50034
+ for (const key of keys) {
50035
+ if (!isDeletableReplicaKey(prefix, key)) {
50036
+ log(`WARNING: refusing to quarantine ${key}: outside the replica prefix.`);
50037
+ continue;
50038
+ }
50039
+ const target = `${destination}${key.slice(root12.length)}`;
50040
+ try {
50041
+ await store.copy(key, target);
50042
+ } catch (error) {
50043
+ log(
50044
+ `WARNING: could not copy ${key} to ${target}: ${describeError(error)}. Leaving the original in place \u2014 never deleting an object the quarantine did not preserve.`
50045
+ );
50046
+ failed.push(key);
50047
+ continue;
50048
+ }
50049
+ try {
50050
+ await store.delete(key);
50051
+ } catch (error) {
50052
+ log(
50053
+ `WARNING: quarantined ${key} to ${target} but could not delete the original: ${describeError(error)}`
50054
+ );
50055
+ failed.push(key);
50056
+ continue;
50057
+ }
50058
+ moved.push(key);
50059
+ }
50060
+ logQuarantined(destination, moved, failed, log);
50061
+ return { destination, moved, failed };
50062
+ }
50063
+ function logQuarantined(destination, moved, failed, log) {
50064
+ log(
50065
+ `WARNING: SESSION-DB-REPLICA-QUARANTINED: moved ${moved.length} unusable replica object(s) aside to ${destination} (${failed.length} could not be moved) so this boot can start a fresh backup chain. The bytes are NOT deleted \u2014 copy them back from there to investigate. See SESSION-DB-REPLICA-SIZE above for how much was set aside.`
50066
+ );
50067
+ }
49815
50068
  async function clearReplica(store, prefix, keys, log) {
49816
50069
  const deleted = [];
49817
50070
  const failed = [];
@@ -49850,7 +50103,7 @@ async function decideSessionDbRestore(params) {
49850
50103
  const prefix = config.prefix;
49851
50104
  if (exitCode === 0) {
49852
50105
  const stat2 = await fileOps.stat(config.opencodeDbPath);
49853
- return stat2 !== null && stat2.size > 0 ? { kind: "restored" } : { kind: "noReplica" };
50106
+ return stat2 !== null && stat2.size > 0 ? { kind: "restored", bytes: stat2.size } : { kind: "noReplica", localDb: stat2 === null ? "absent" : "empty" };
49854
50107
  }
49855
50108
  if (store === null) {
49856
50109
  return {
@@ -49886,8 +50139,20 @@ async function decideSessionDbRestore(params) {
49886
50139
  case "prune": {
49887
50140
  const result = await pruneNewestL0(store, prefix, keys, log);
49888
50141
  if (result.deleted === null) {
49889
- const reason = result.reason === "deleteFailed" ? "recoveryFailed" : result.reason;
49890
- return { kind: "unusableReplica", reason };
50142
+ if (shouldEscalateToQuarantine(result.reason, prefix, keys)) {
50143
+ const quarantined = await quarantineReplica(store, prefix, keys, log);
50144
+ if (quarantined.moved.length === 0) {
50145
+ return { kind: "unusableReplica", reason: "recoveryFailed" };
50146
+ }
50147
+ return { kind: "recovered", strategy: "quarantine", deleted: quarantined.moved };
50148
+ }
50149
+ if (result.reason === "deleteFailed") {
50150
+ return { kind: "unusableReplica", reason: "recoveryFailed" };
50151
+ }
50152
+ if (result.reason === "unreadable") {
50153
+ return { kind: "unusableReplica", reason: "targetHealthy" };
50154
+ }
50155
+ return { kind: "unusableReplica", reason: result.reason };
49891
50156
  }
49892
50157
  return { kind: "recovered", strategy: "prune", deleted: [result.deleted] };
49893
50158
  }
@@ -49899,15 +50164,154 @@ async function decideSessionDbRestore(params) {
49899
50164
  return assertNeverStrategy(strategy);
49900
50165
  }
49901
50166
  }
50167
+ function shouldEscalateToQuarantine(reason, prefix, keys) {
50168
+ if (reason !== "targetHealthy" && reason !== "noL0Present") return false;
50169
+ return hasParsableLtxKey(prefix, keys);
50170
+ }
49902
50171
  async function discardLocalDebris(fileOps, dbPath, log) {
49903
- for (const path2 of [dbPath, `${dbPath}-wal`, `${dbPath}-shm`]) {
50172
+ for (const path of [dbPath, `${dbPath}-wal`, `${dbPath}-shm`]) {
50173
+ try {
50174
+ await fileOps.remove(path);
50175
+ } catch (error) {
50176
+ log(`WARNING: could not remove local session-DB debris at ${path}: ${describeError(error)}`);
50177
+ }
50178
+ }
50179
+ }
50180
+
50181
+ // src/session-db-verify.ts
50182
+ init_esm_shims();
50183
+
50184
+ // src/restore-points.ts
50185
+ init_esm_shims();
50186
+ function isRestorePointShaped(value) {
50187
+ if (typeof value !== "object" || value === null) return false;
50188
+ const candidate = value;
50189
+ return typeof candidate.level === "number" && typeof candidate.max_txid === "string";
50190
+ }
50191
+ function parseLtxListing(stdout) {
50192
+ let parsed;
50193
+ try {
50194
+ parsed = JSON.parse(stdout);
50195
+ } catch {
50196
+ return null;
50197
+ }
50198
+ if (!Array.isArray(parsed)) return null;
50199
+ const points = [];
50200
+ for (const element of parsed) {
50201
+ if (!isRestorePointShaped(element)) return null;
50202
+ points.push({
50203
+ level: element.level,
50204
+ minTxid: typeof element.min_txid === "string" ? element.min_txid : "",
50205
+ maxTxid: element.max_txid,
50206
+ size: typeof element.size === "number" ? element.size : 0,
50207
+ timestamp: typeof element.timestamp === "string" ? element.timestamp : null
50208
+ });
50209
+ }
50210
+ return points;
50211
+ }
50212
+ function walkbackCandidates(points) {
50213
+ const distinct = /* @__PURE__ */ new Map();
50214
+ for (const point of points) {
50215
+ if (!distinct.has(point.maxTxid)) {
50216
+ distinct.set(point.maxTxid, BigInt(`0x${point.maxTxid}`));
50217
+ }
50218
+ }
50219
+ return [...distinct.entries()].sort((a12, b12) => a12[1] > b12[1] ? -1 : a12[1] < b12[1] ? 1 : 0).slice(1).map(([maxTxid]) => maxTxid);
50220
+ }
50221
+
50222
+ // src/session-db-verify.ts
50223
+ async function verifySessionDb(params) {
50224
+ const { config, fileOps, sqlite, log } = params;
50225
+ const dbPath = config.opencodeDbPath;
50226
+ const stat2 = await fileOps.stat(dbPath);
50227
+ if (stat2 === null) return { kind: "skipped", localDb: "absent" };
50228
+ if (stat2.size === 0) return { kind: "skipped", localDb: "empty" };
50229
+ const result = await sqlite.check(dbPath);
50230
+ if (result.ok) return { kind: "healthy", bytes: stat2.size };
50231
+ log(
50232
+ `WARNING: SESSION-DB-INTEGRITY-FAILED: opencode.db at ${dbPath} failed its integrity check: ${result.detail}`
50233
+ );
50234
+ return walkBack(params);
50235
+ }
50236
+ async function clearScratch(fileOps, scratch) {
50237
+ await fileOps.remove(scratch);
50238
+ await fileOps.remove(`${scratch}-wal`);
50239
+ await fileOps.remove(`${scratch}-shm`);
50240
+ }
50241
+ async function discardCorruptDb(fileOps, dbPath, log) {
50242
+ for (const path of [dbPath, `${dbPath}-wal`, `${dbPath}-shm`]) {
49904
50243
  try {
49905
- await fileOps.remove(path2);
50244
+ await fileOps.remove(path);
49906
50245
  } catch (error) {
49907
- log(`WARNING: could not remove local session-DB debris at ${path2}: ${describeError(error)}`);
50246
+ log(
50247
+ `WARNING: could not remove corrupt local session-DB debris at ${path}: ${describeError(error)}`
50248
+ );
49908
50249
  }
49909
50250
  }
49910
50251
  }
50252
+ async function adopt(fileOps, scratch, dbPath, log, txid, candidatesTried, bytes) {
50253
+ await fileOps.remove(`${dbPath}-wal`);
50254
+ await fileOps.remove(`${dbPath}-shm`);
50255
+ await fileOps.remove(dbPath);
50256
+ await fileOps.rename(scratch, dbPath);
50257
+ log(
50258
+ `INFO: SESSION-DB-WALKBACK-ADOPTED: adopted an older litestream restore point txid=${txid} candidates=${candidatesTried} bytes=${bytes}`
50259
+ );
50260
+ }
50261
+ async function walkBack(params) {
50262
+ const { config, fileOps, sqlite, litestream, log, maxPoints, budgetSeconds } = params;
50263
+ const dbPath = config.opencodeDbPath;
50264
+ const now = params.now ?? Date.now;
50265
+ const scratch = `${dbPath}.walkback`;
50266
+ const listing = await litestream.listRestorePoints();
50267
+ const points = listing.stdout === null ? null : parseLtxListing(listing.stdout);
50268
+ if (points === null) {
50269
+ log(
50270
+ `WARNING: SESSION-DB-WALKBACK-ENUMERATION-FAILED: ${listing.stdout === null ? `litestream ltx exited non-zero: ${listing.detail}` : "litestream ltx succeeded but its listing could not be parsed"}`
50271
+ );
50272
+ await discardCorruptDb(fileOps, dbPath, log);
50273
+ return { kind: "exhausted", reason: "enumerationFailed", candidatesTried: 0 };
50274
+ }
50275
+ const candidates = walkbackCandidates(points);
50276
+ if (candidates.length === 0) {
50277
+ await discardCorruptDb(fileOps, dbPath, log);
50278
+ return { kind: "exhausted", reason: "noCandidates", candidatesTried: 0 };
50279
+ }
50280
+ const deadline = now() + budgetSeconds * 1e3;
50281
+ let candidatesTried = 0;
50282
+ let index = 0;
50283
+ for (; index < candidates.length; index++) {
50284
+ if (candidatesTried >= maxPoints || now() >= deadline) break;
50285
+ const txid = candidates[index];
50286
+ candidatesTried++;
50287
+ await clearScratch(fileOps, scratch);
50288
+ const restoreResult = await litestream.restoreAt(txid, scratch);
50289
+ if (!restoreResult.ok) {
50290
+ log(
50291
+ `WARNING: SESSION-DB-WALKBACK-CANDIDATE-FAILED: restoring txid=${txid} failed: ${restoreResult.detail}`
50292
+ );
50293
+ continue;
50294
+ }
50295
+ const check = await sqlite.check(scratch);
50296
+ if (!check.ok) {
50297
+ log(
50298
+ `WARNING: SESSION-DB-WALKBACK-CANDIDATE-FAILED: txid=${txid} restored but failed its integrity check: ${check.detail}`
50299
+ );
50300
+ continue;
50301
+ }
50302
+ const scratchStat = await fileOps.stat(scratch);
50303
+ const bytes = scratchStat?.size ?? 0;
50304
+ await adopt(fileOps, scratch, dbPath, log, txid, candidatesTried, bytes);
50305
+ return { kind: "walkedBack", txid, bytes, candidatesTried };
50306
+ }
50307
+ await clearScratch(fileOps, scratch);
50308
+ await discardCorruptDb(fileOps, dbPath, log);
50309
+ return {
50310
+ kind: "exhausted",
50311
+ reason: index < candidates.length ? "budgetExhausted" : "allFailed",
50312
+ candidatesTried
50313
+ };
50314
+ }
49911
50315
 
49912
50316
  // src/self-stop.ts
49913
50317
  init_esm_shims();
@@ -49992,22 +50396,55 @@ var shell_contract_default = {
49992
50396
  "sync-once",
49993
50397
  "model-auth-ready",
49994
50398
  "self-stop",
49995
- "session-db-classify"
50399
+ "session-db-classify",
50400
+ "session-db-verify"
49996
50401
  ]
49997
50402
  };
49998
50403
 
50404
+ // src/sqlite-integrity.ts
50405
+ init_esm_shims();
50406
+ import { DatabaseSync } from "node:sqlite";
50407
+ import { rm as rm2 } from "node:fs/promises";
50408
+ var MAX_DETAIL_LENGTH = 500;
50409
+ function truncate(text) {
50410
+ return text.length > MAX_DETAIL_LENGTH ? `${text.slice(0, MAX_DETAIL_LENGTH)}\u2026` : text;
50411
+ }
50412
+ var nodeSqliteIntegrity = {
50413
+ async check(path) {
50414
+ let db;
50415
+ try {
50416
+ db = new DatabaseSync(path, { readOnly: true });
50417
+ const row = db.prepare("PRAGMA integrity_check").get();
50418
+ const value = row?.integrity_check;
50419
+ if (value === "ok") {
50420
+ return { ok: true };
50421
+ }
50422
+ return { ok: false, detail: truncate(String(value ?? "no result row")) };
50423
+ } catch (err) {
50424
+ return {
50425
+ ok: false,
50426
+ detail: truncate(err instanceof Error ? err.message : String(err))
50427
+ };
50428
+ } finally {
50429
+ db?.close();
50430
+ await rm2(`${path}-shm`, { force: true });
50431
+ await rm2(`${path}-wal`, { force: true });
50432
+ }
50433
+ }
50434
+ };
50435
+
49999
50436
  // src/sync.ts
50000
50437
  init_esm_shims();
50001
50438
  async function sync(params) {
50002
- const { label, path: path2, bucket, key, store, lastHash, fileOps, log } = params;
50439
+ const { label, path, bucket, key, store, lastHash, fileOps, log } = params;
50003
50440
  if (store === null || bucket === null || key === null) {
50004
50441
  return { outcome: { kind: "disabled" }, hash: lastHash };
50005
50442
  }
50006
- const exists = await fileOps.stat(path2) !== null;
50007
- const valid = await isValidJson(fileOps, path2);
50443
+ const exists = await fileOps.stat(path) !== null;
50444
+ const valid = await isValidJson(fileOps, path);
50008
50445
  if (exists && !valid) {
50009
50446
  log(
50010
- `WARNING: local ${label} credentials at ${path2} are invalid or unreadable; keeping them and skipping sync.`
50447
+ `WARNING: local ${label} credentials at ${path} are invalid or unreadable; keeping them and skipping sync.`
50011
50448
  );
50012
50449
  return { outcome: { kind: "localInvalid" }, hash: lastHash };
50013
50450
  }
@@ -50015,15 +50452,15 @@ async function sync(params) {
50015
50452
  return { outcome: { kind: "absent" }, hash: lastHash };
50016
50453
  }
50017
50454
  try {
50018
- await fileOps.chmod(path2, 384);
50455
+ await fileOps.chmod(path, 384);
50019
50456
  } catch {
50020
- log(`WARNING: could not restrict local ${label} credentials at ${path2}.`);
50457
+ log(`WARNING: could not restrict local ${label} credentials at ${path}.`);
50021
50458
  }
50022
50459
  let hash;
50023
50460
  try {
50024
- hash = await fileOps.hashFile(path2);
50461
+ hash = await fileOps.hashFile(path);
50025
50462
  } catch {
50026
- log(`WARNING: could not hash local ${label} credentials at ${path2}; skipping this sync tick.`);
50463
+ log(`WARNING: could not hash local ${label} credentials at ${path}; skipping this sync tick.`);
50027
50464
  return { outcome: { kind: "hashFailed" }, hash: lastHash };
50028
50465
  }
50029
50466
  if (hash === lastHash) {
@@ -50031,12 +50468,12 @@ async function sync(params) {
50031
50468
  }
50032
50469
  const location = `s3://${bucket}/${key}`;
50033
50470
  try {
50034
- await store.put(key, await fileOps.readFile(path2));
50471
+ await store.put(key, await fileOps.readFile(path));
50035
50472
  } catch (error) {
50036
50473
  log(`WARNING: ${label} credentials upload failed to ${location}: ${describeError(error)}`);
50037
50474
  return { outcome: { kind: "failed", reason: describeError(error) }, hash: lastHash };
50038
50475
  }
50039
- log(`Uploaded ${label} credentials from ${path2} to ${location}.`);
50476
+ log(`Uploaded ${label} credentials from ${path} to ${location}.`);
50040
50477
  return { outcome: { kind: "uploaded" }, hash };
50041
50478
  }
50042
50479
 
@@ -50048,6 +50485,7 @@ var EXIT_BROKEN = 1;
50048
50485
  var EXIT_SESSION_DB_FATAL = 30;
50049
50486
  var EXIT_SESSION_DB_UNUSABLE = 31;
50050
50487
  var EXIT_SESSION_DB_RETRY = 32;
50488
+ var EXIT_SESSION_DB_UNVERIFIABLE = 33;
50051
50489
  var STATE_SUFFIX = ".synchash";
50052
50490
  var COMMANDS = shell_contract_default.commands;
50053
50491
  var USAGE = `Usage: runner-synchroniser <command> [args]
@@ -50064,7 +50502,12 @@ var USAGE = `Usage: runner-synchroniser <command> [args]
50064
50502
  classify a just-run \`litestream restore\` of opencode.db;
50065
50503
  exit 0 restored/no-replica/disabled, ${EXIT_SESSION_DB_RETRY} re-run
50066
50504
  and ask again, ${EXIT_SESSION_DB_UNUSABLE} unusable (booted fresh,
50067
- skip replicate), ${EXIT_SESSION_DB_FATAL} fatal
50505
+ fresh backup chain), ${EXIT_SESSION_DB_FATAL} fatal
50506
+ session-db-verify <litestream-config-path>
50507
+ verify opencode.db's integrity at boot, walking back through
50508
+ litestream's retained restore points if it's corrupt; exit 0
50509
+ healthy/skipped/walked-back, ${EXIT_SESSION_DB_UNVERIFIABLE} every
50510
+ candidate was exhausted (booted fresh)
50068
50511
  `;
50069
50512
  function shellQuote(value) {
50070
50513
  return `'${value.replaceAll("'", `'\\''`)}'`;
@@ -50075,6 +50518,12 @@ function s3ObjectStoreFor(config) {
50075
50518
  function awsSelfStopAccessFor(config) {
50076
50519
  return new AwsSelfStopAccess(config.region);
50077
50520
  }
50521
+ function nodeSqliteIntegrityFor() {
50522
+ return nodeSqliteIntegrity;
50523
+ }
50524
+ function litestreamCliFor(configPath, dbPath) {
50525
+ return new LitestreamCli(configPath, dbPath);
50526
+ }
50078
50527
  function parseStoreName(value) {
50079
50528
  return value === "claude" || value === "opencode" ? value : null;
50080
50529
  }
@@ -50190,6 +50639,24 @@ async function commandSessionDbClassify(args, config, deps) {
50190
50639
  log(describeSessionDbClassification(outcome, { bucket: config.bucket, region: config.region }));
50191
50640
  return sessionDbExitCode(outcome);
50192
50641
  }
50642
+ async function commandSessionDbVerify(litestreamConfigPath, config, deps) {
50643
+ const { fileOps, log } = deps;
50644
+ const litestream = (deps.litestreamFor ?? litestreamCliFor)(
50645
+ litestreamConfigPath,
50646
+ config.opencodeDbPath
50647
+ );
50648
+ const outcome = await verifySessionDb({
50649
+ config: { opencodeDbPath: config.opencodeDbPath },
50650
+ fileOps,
50651
+ sqlite: (deps.sqliteIntegrityFor ?? nodeSqliteIntegrityFor)(),
50652
+ litestream,
50653
+ log,
50654
+ maxPoints: config.walkbackMaxPoints,
50655
+ budgetSeconds: config.walkbackBudgetSeconds
50656
+ });
50657
+ log(describeSessionDbVerification(outcome));
50658
+ return sessionDbVerifyExitCode(outcome);
50659
+ }
50193
50660
  async function main(argv, deps) {
50194
50661
  const { env: env3, fileOps, log, out } = deps;
50195
50662
  const [command12, ...rest] = argv;
@@ -50236,6 +50703,14 @@ ${USAGE}`
50236
50703
  }
50237
50704
  return commandSessionDbClassify(args, config, deps);
50238
50705
  }
50706
+ if (command12 === "session-db-verify") {
50707
+ if (rest.length !== 1) {
50708
+ log(`'session-db-verify' needs exactly one argument: the litestream config path.
50709
+ ${USAGE}`);
50710
+ return EXIT_USAGE;
50711
+ }
50712
+ return commandSessionDbVerify(rest[0], config, deps);
50713
+ }
50239
50714
  const name = parseStoreName(rest[0]);
50240
50715
  if (name === null) {
50241
50716
  log(`'${command12}' needs a store name: claude or opencode.
@@ -50253,7 +50728,7 @@ function isEntryPoint() {
50253
50728
  const entry = process.argv[1];
50254
50729
  if (entry === void 0) return false;
50255
50730
  try {
50256
- return realpathSync(entry) === realpathSync(fileURLToPath2(import.meta.url));
50731
+ return realpathSync(entry) === realpathSync(fileURLToPath(import.meta.url));
50257
50732
  } catch {
50258
50733
  return false;
50259
50734
  }
@@ -50278,6 +50753,7 @@ export {
50278
50753
  EXIT_SESSION_DB_FATAL,
50279
50754
  EXIT_SESSION_DB_RETRY,
50280
50755
  EXIT_SESSION_DB_UNUSABLE,
50756
+ EXIT_SESSION_DB_UNVERIFIABLE,
50281
50757
  EXIT_USAGE,
50282
50758
  main
50283
50759
  };