failproofai 1.0.0-beta.12 → 1.0.0-beta.13

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 (173) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +3 -3
  3. package/.next/standalone/.next/prerender-manifest.json +3 -3
  4. package/.next/standalone/.next/required-server-files.json +1 -1
  5. package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
  6. package/.next/standalone/.next/server/app/_global-error/page.js +2 -3
  7. package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
  8. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
  11. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +2 -2
  12. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
  13. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +3 -3
  14. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +3 -3
  15. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  16. package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
  17. package/.next/standalone/.next/server/app/_not-found/page.js +2 -3
  18. package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  19. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  20. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  21. package/.next/standalone/.next/server/app/_not-found.rsc +15 -15
  22. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +15 -15
  23. package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
  24. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +10 -10
  25. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  26. package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  27. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  28. package/.next/standalone/.next/server/app/api/audit/invite/route.js +2 -2
  29. package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
  30. package/.next/standalone/.next/server/app/api/audit/run/route.js +2 -2
  31. package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
  32. package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
  33. package/.next/standalone/.next/server/app/api/auth/login-request/route.js +3 -2
  34. package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
  35. package/.next/standalone/.next/server/app/api/auth/login-verify/route.js +2 -2
  36. package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
  37. package/.next/standalone/.next/server/app/api/auth/logout/route.js +2 -2
  38. package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
  39. package/.next/standalone/.next/server/app/api/auth/reminder/route.js +2 -2
  40. package/.next/standalone/.next/server/app/api/auth/reminder/route.js.nft.json +1 -1
  41. package/.next/standalone/.next/server/app/api/auth/status/route.js +2 -2
  42. package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
  43. package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
  44. package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
  45. package/.next/standalone/.next/server/app/audit/page.js +2 -3
  46. package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
  47. package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
  48. package/.next/standalone/.next/server/app/index.html +1 -1
  49. package/.next/standalone/.next/server/app/index.rsc +15 -15
  50. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  51. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +15 -15
  52. package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +4 -4
  53. package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +10 -10
  54. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  55. package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
  56. package/.next/standalone/.next/server/app/page.js +2 -3
  57. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  58. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  59. package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +10 -10
  60. package/.next/standalone/.next/server/app/policies/page.js +2 -3
  61. package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
  62. package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
  63. package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
  64. package/.next/standalone/.next/server/app/project/[name]/page.js +3 -4
  65. package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
  66. package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
  67. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
  68. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
  69. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js +3 -4
  70. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
  71. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
  72. package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
  73. package/.next/standalone/.next/server/app/projects/page.js +3 -4
  74. package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
  75. package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  76. package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +4 -4
  77. package/.next/standalone/.next/server/app/settings/page.js +2 -3
  78. package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
  79. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  80. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__1a7i2q4._.js → [root-of-the-server]__00ni9za._.js} +1 -1
  81. package/.next/standalone/.next/server/chunks/[root-of-the-server]__08y94xv._.js +3 -0
  82. package/.next/standalone/.next/server/chunks/[root-of-the-server]__094p1f1._.js +1 -1
  83. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0_0xu5z._.js +1 -1
  84. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0ed01_d._.js +1 -1
  85. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__1_ps0jw._.js → [root-of-the-server]__0effm9m._.js} +1 -1
  86. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0lk_935._.js → [root-of-the-server]__0ix8gm7._.js} +1 -1
  87. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0ky_n0r._.js → [root-of-the-server]__0ji11a-._.js} +1 -1
  88. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0v2fpxe._.js → [root-of-the-server]__0ojwjxl._.js} +1 -1
  89. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0vb5fl2._.js +3 -0
  90. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1ibjy5x._.js +1 -1
  91. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1tvn4wf._.js +1 -1
  92. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1uyc-z4._.js +3 -0
  93. package/.next/standalone/.next/server/chunks/[root-of-the-server]__20d06rh._.js +3 -0
  94. package/.next/standalone/.next/server/chunks/_0lxbzdq._.js +1 -3
  95. package/.next/standalone/.next/server/chunks/_1zuiiy3._.js +1 -3
  96. package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +1 -1
  97. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1rdruw4._.js → [root-of-the-server]__0_1tiya._.js} +1 -1
  98. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0ha3gul._.js → [root-of-the-server]__0eeipso._.js} +2 -2
  99. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0spkm68._.js +3 -3
  100. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1tyf0tc._.js → [root-of-the-server]__17itmx-._.js} +2 -2
  101. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1io8n-9._.js → [root-of-the-server]__1dx-a-c._.js} +2 -2
  102. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1mmefsr._.js +5 -0
  103. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1yw368c._.js → [root-of-the-server]__1n2vcv4._.js} +1 -1
  104. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1rv-sc9._.js +1 -1
  105. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1a2hcb_._.js → [root-of-the-server]__1tlvv9a._.js} +1 -1
  106. package/.next/standalone/.next/server/chunks/ssr/_0rjgfln._.js +1 -1
  107. package/.next/standalone/.next/server/chunks/ssr/{_1fahg9e._.js → _0vo2qyt._.js} +2 -2
  108. package/.next/standalone/.next/server/chunks/ssr/{_0uz7o9y._.js → _0xej-0e._.js} +2 -2
  109. package/.next/standalone/.next/server/chunks/ssr/{_04mekdy._.js → _10399ge._.js} +2 -2
  110. package/.next/standalone/.next/server/chunks/ssr/{_0se484m._.js → _149k9oy._.js} +2 -2
  111. package/.next/standalone/.next/server/chunks/ssr/{_1vsgpqt._.js → _166jvu8._.js} +1 -1
  112. package/.next/standalone/.next/server/chunks/ssr/{_0r-dsre._.js → _1_hwp06._.js} +2 -2
  113. package/.next/standalone/.next/server/chunks/ssr/{_1w8sola._.js → _1mnhi_r._.js} +2 -2
  114. package/.next/standalone/.next/server/chunks/ssr/{_1w_6p9g._.js → _1ror7k9._.js} +2 -2
  115. package/.next/standalone/.next/server/chunks/ssr/{_1gmzkwj._.js → _1sdgprl._.js} +1 -1
  116. package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +1 -1
  117. package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +1 -1
  118. package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +1 -1
  119. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  120. package/.next/standalone/.next/server/pages/404.html +1 -1
  121. package/.next/standalone/.next/server/pages/500.html +1 -1
  122. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  123. package/.next/standalone/.next/server/server-reference-manifest.json +15 -15
  124. package/.next/standalone/.next/static/chunks/{2_h--2ame3r83.js → 01s3vpzky_qew.js} +1 -1
  125. package/.next/standalone/.next/static/chunks/0km-jn9o5xyqs.css +2 -0
  126. package/.next/standalone/.next/static/chunks/{23hp7hekegpe5.js → 0zbcd_n8ku2ov.js} +1 -1
  127. package/.next/standalone/.next/static/chunks/{0cakk77ppmlo7.js → 1erji0ratofla.js} +1 -1
  128. package/.next/standalone/.next/static/chunks/{40-zk44qsg5y-.js → 23hnlzqx44vbe.js} +1 -1
  129. package/.next/standalone/.next/static/chunks/{1wb8cnmzx69rz.js → 2cwsiyhc7d2cw.js} +1 -1
  130. package/.next/standalone/.next/static/chunks/{0_rdbv_k5j51p.js → 2y42ebzynyxdv.js} +1 -1
  131. package/.next/standalone/.next/static/chunks/{1spk1bub0vd-h.js → 315lncj7dsp9c.js} +1 -1
  132. package/.next/standalone/.next/static/chunks/{0-zh1umoq6ppc.js → 31_px0dfgdg9j.js} +2 -2
  133. package/.next/standalone/.next/static/chunks/{2bie7ajv70p9b.js → 3l4-fu3xt75j8.js} +1 -1
  134. package/.next/standalone/.next/static/chunks/{298v78ypf8edl.js → 3poscoxn69x9g.js} +1 -1
  135. package/.next/standalone/app/policies/hooks-client.tsx +4 -4
  136. package/.next/standalone/ino.ujh3/.failproofai/VERSION +4 -0
  137. package/.next/standalone/ino.ujh3/.failproofai/state/last-version +1 -0
  138. package/.next/standalone/ino.ujh3/.failproofai/state/telemetry-id +1 -0
  139. package/.next/standalone/package.json +10 -10
  140. package/.next/standalone/server.js +1 -1
  141. package/bin/failproofai.mjs +186 -5
  142. package/dist/cli.mjs +1130 -1352
  143. package/dist/worker.mjs +107 -1000
  144. package/package.json +10 -10
  145. package/src/hooks/backfill-cli.ts +1 -1
  146. package/src/hooks/cloud-connection.ts +4 -4
  147. package/src/hooks/cloud-enrollment-cli.ts +1 -1
  148. package/src/hooks/cloud-enrollment.ts +3 -3
  149. package/src/hooks/cloud-managed-policies.ts +60 -22
  150. package/src/hooks/configure-wizard.ts +124 -53
  151. package/src/hooks/custom-hooks-loader.ts +57 -8
  152. package/src/hooks/daemon-service.ts +66 -11
  153. package/src/hooks/flush-cli.ts +180 -0
  154. package/src/hooks/fp-config.ts +242 -118
  155. package/src/hooks/fp-home.ts +138 -22
  156. package/src/hooks/fp-reset.ts +357 -43
  157. package/src/hooks/handler.ts +11 -11
  158. package/src/hooks/harness-cli.ts +309 -0
  159. package/src/hooks/hook-activity-store.ts +5 -5
  160. package/src/hooks/manager.ts +35 -0
  161. package/src/hooks/onboarding-attempt.ts +22 -6
  162. package/src/hooks/tui.ts +64 -7
  163. package/src/hooks/uninstall-cli.ts +1 -1
  164. package/.next/standalone/.next/server/chunks/[root-of-the-server]__06hexd0._.js +0 -3
  165. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1iny24d._.js +0 -3
  166. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1tyedjt._.js +0 -3
  167. package/.next/standalone/.next/server/chunks/lib_telemetry_ts_0dctyyw._.js +0 -5
  168. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1u-wx42._.js +0 -4
  169. package/.next/standalone/.next/server/chunks/ssr/src_hooks_fp-config_ts_04t589g._.js +0 -5
  170. package/.next/standalone/.next/static/chunks/13vrxdsdihqd_.css +0 -2
  171. /package/.next/standalone/.next/static/{-3gDrXYxNRTVwrFnqXAWd → ziAsXfNE0cH_S7LHK-Py3}/_buildManifest.js +0 -0
  172. /package/.next/standalone/.next/static/{-3gDrXYxNRTVwrFnqXAWd → ziAsXfNE0cH_S7LHK-Py3}/_clientMiddlewareManifest.js +0 -0
  173. /package/.next/standalone/.next/static/{-3gDrXYxNRTVwrFnqXAWd → ziAsXfNE0cH_S7LHK-Py3}/_ssgManifest.js +0 -0
package/dist/worker.mjs CHANGED
@@ -370,10 +370,15 @@ function failproofaiHome(home) {
370
370
  return resolve(home, ".failproofai");
371
371
  return process.env.FAILPROOFAI_HOME || resolve(homedir(), ".failproofai");
372
372
  }
373
- var LAYOUT_VERSION = 2, at = (...parts) => resolve(failproofaiHome(), ...parts), atHome = (home, ...parts) => home ? resolve(failproofaiHome(home), ...parts) : at(...parts), versionFile = (home) => atHome(home, "VERSION"), configFile = (home) => atHome(home, "config.toml"), policiesDir = (home) => atHome(home, "policies"), localPoliciesDir = (home) => atHome(home, "policies", "local-policies"), globalPolicyConfigFile = (home) => resolve(localPoliciesDir(home), "policies-config.json"), cloudPoliciesDir = (home) => resolve(policiesDir(home), "cloud-policies"), customPoliciesDir = (home) => resolve(policiesDir(home), "custom-policies"), hookActivityDir = (home) => atHome(home, "hook-activity"), stateDir = (home) => atHome(home, "state"), shimsDir = (home) => resolve(stateDir(home), "shims"), sessionPauseDir = () => resolve(stateDir(), "sessions"), telemetryIdFile = (home) => resolve(stateDir(home), "telemetry-id"), codexSessionPathsFile = (home) => resolve(stateDir(home), "codex-session-paths.json"), logsDir = (home) => atHome(home, "logs"), legacy;
373
+ var LAYOUT_VERSION = 3, at = (...parts) => resolve(failproofaiHome(), ...parts), atHome = (home, ...parts) => home ? resolve(failproofaiHome(home), ...parts) : at(...parts), versionFile = (home) => atHome(home, "VERSION"), configFile = (home) => atHome(home, "config.json"), policiesDir = (home) => atHome(home, "policies"), customPoliciesDir, globalPolicyConfigFile = (home) => atHome(home, "policies-config.json"), cloudPoliciesDir = (home) => resolve(policiesDir(home), "cloud-policies"), hookActivityDir = (home) => atHome(home, "hook-activity"), stateDir = (home) => atHome(home, "state"), shimsDir = (home) => resolve(stateDir(home), "shims"), sessionPauseDir = () => resolve(stateDir(), "sessions"), telemetryIdFile = (home) => resolve(stateDir(home), "telemetry-id"), codexSessionPathsFile = (home) => resolve(stateDir(home), "codex-session-paths.json"), logsDir = (home) => atHome(home, "logs"), legacy;
374
374
  var init_fp_home = __esm(() => {
375
+ customPoliciesDir = policiesDir;
375
376
  legacy = {
376
377
  policyConfig: () => at("policies-config.json"),
378
+ configToml: () => at("config.toml"),
379
+ credentialsToml: () => at("credentials.toml"),
380
+ localPoliciesDir: () => at("policies", "local-policies"),
381
+ customPoliciesDir: () => at("policies", "custom-policies"),
377
382
  policyConfigLocal: () => at("policies-config.local.json"),
378
383
  cloudCredentials: () => at("cloud.json"),
379
384
  ingestCredentials: () => at("ingest.json"),
@@ -2505,977 +2510,12 @@ var init_builtin_policies = __esm(() => {
2505
2510
  });
2506
2511
 
2507
2512
  // package.json
2508
- var version = "1.0.0-beta.12";
2513
+ var version = "1.0.0-beta.13";
2509
2514
  var init_package = () => {};
2510
2515
 
2511
2516
  // src/posthog-key.ts
2512
2517
  var POSTHOG_API_KEY = "phc_Ac1Ww1GqKc0z1SyrRWbmatEeQdlOQIsDEEdP8l8JRgX", POSTHOG_PRODUCT = "failproofai-oss";
2513
2518
 
2514
- // node_modules/smol-toml/dist/date.js
2515
- var DATE_TIME_RE, TomlDate;
2516
- var init_date = __esm(() => {
2517
- /*!
2518
- * Copyright (c) Squirrel Chat et al., All rights reserved.
2519
- * SPDX-License-Identifier: BSD-3-Clause
2520
- *
2521
- * Redistribution and use in source and binary forms, with or without
2522
- * modification, are permitted provided that the following conditions are met:
2523
- *
2524
- * 1. Redistributions of source code must retain the above copyright notice, this
2525
- * list of conditions and the following disclaimer.
2526
- * 2. Redistributions in binary form must reproduce the above copyright notice,
2527
- * this list of conditions and the following disclaimer in the
2528
- * documentation and/or other materials provided with the distribution.
2529
- * 3. Neither the name of the copyright holder nor the names of its contributors
2530
- * may be used to endorse or promote products derived from this software without
2531
- * specific prior written permission.
2532
- *
2533
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
2534
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2535
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2536
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
2537
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2538
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2539
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2540
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2541
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2542
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2543
- */
2544
- DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
2545
- TomlDate = class TomlDate extends Date {
2546
- #hasDate = false;
2547
- #hasTime = false;
2548
- #offset = null;
2549
- constructor(date) {
2550
- let hasDate = true;
2551
- let hasTime = true;
2552
- let offset = "Z";
2553
- if (typeof date === "string") {
2554
- let match = date.match(DATE_TIME_RE);
2555
- if (match) {
2556
- if (!match[1]) {
2557
- hasDate = false;
2558
- date = `0000-01-01T${date}`;
2559
- }
2560
- hasTime = !!match[2];
2561
- hasTime && date[10] === " " && (date = date.replace(" ", "T"));
2562
- if (match[2] && +match[2] > 23) {
2563
- date = "";
2564
- } else {
2565
- offset = match[3] || null;
2566
- date = date.toUpperCase();
2567
- if (!offset && hasTime)
2568
- date += "Z";
2569
- }
2570
- } else {
2571
- date = "";
2572
- }
2573
- }
2574
- super(date);
2575
- if (!isNaN(this.getTime())) {
2576
- this.#hasDate = hasDate;
2577
- this.#hasTime = hasTime;
2578
- this.#offset = offset;
2579
- }
2580
- }
2581
- isDateTime() {
2582
- return this.#hasDate && this.#hasTime;
2583
- }
2584
- isLocal() {
2585
- return !this.#hasDate || !this.#hasTime || !this.#offset;
2586
- }
2587
- isDate() {
2588
- return this.#hasDate && !this.#hasTime;
2589
- }
2590
- isTime() {
2591
- return this.#hasTime && !this.#hasDate;
2592
- }
2593
- isValid() {
2594
- return this.#hasDate || this.#hasTime;
2595
- }
2596
- toISOString() {
2597
- let iso = super.toISOString();
2598
- if (this.isDate())
2599
- return iso.slice(0, 10);
2600
- if (this.isTime())
2601
- return iso.slice(11, 23);
2602
- if (this.#offset === null)
2603
- return iso.slice(0, -1);
2604
- if (this.#offset === "Z")
2605
- return iso;
2606
- let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
2607
- offset = this.#offset[0] === "-" ? offset : -offset;
2608
- let offsetDate = new Date(this.getTime() - offset * 60000);
2609
- return offsetDate.toISOString().slice(0, -1) + this.#offset;
2610
- }
2611
- static wrapAsOffsetDateTime(jsDate, offset = "Z") {
2612
- let date = new TomlDate(jsDate);
2613
- date.#offset = offset;
2614
- return date;
2615
- }
2616
- static wrapAsLocalDateTime(jsDate) {
2617
- let date = new TomlDate(jsDate);
2618
- date.#offset = null;
2619
- return date;
2620
- }
2621
- static wrapAsLocalDate(jsDate) {
2622
- let date = new TomlDate(jsDate);
2623
- date.#hasTime = false;
2624
- date.#offset = null;
2625
- return date;
2626
- }
2627
- static wrapAsLocalTime(jsDate) {
2628
- let date = new TomlDate(jsDate);
2629
- date.#hasDate = false;
2630
- date.#offset = null;
2631
- return date;
2632
- }
2633
- };
2634
- });
2635
-
2636
- // node_modules/smol-toml/dist/error.js
2637
- function getLineColFromPtr(string, ptr) {
2638
- let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
2639
- return [lines.length, lines.pop().length + 1];
2640
- }
2641
- function makeCodeBlock(string, line, column) {
2642
- let lines = string.split(/\r\n|\n|\r/g);
2643
- let codeblock = "";
2644
- let numberLen = (Math.log10(line + 1) | 0) + 1;
2645
- for (let i = line - 1;i <= line + 1; i++) {
2646
- let l = lines[i - 1];
2647
- if (!l)
2648
- continue;
2649
- codeblock += i.toString().padEnd(numberLen, " ");
2650
- codeblock += ": ";
2651
- codeblock += l;
2652
- codeblock += `
2653
- `;
2654
- if (i === line) {
2655
- codeblock += " ".repeat(numberLen + column + 2);
2656
- codeblock += `^
2657
- `;
2658
- }
2659
- }
2660
- return codeblock;
2661
- }
2662
- var TomlError;
2663
- var init_error = __esm(() => {
2664
- /*!
2665
- * Copyright (c) Squirrel Chat et al., All rights reserved.
2666
- * SPDX-License-Identifier: BSD-3-Clause
2667
- *
2668
- * Redistribution and use in source and binary forms, with or without
2669
- * modification, are permitted provided that the following conditions are met:
2670
- *
2671
- * 1. Redistributions of source code must retain the above copyright notice, this
2672
- * list of conditions and the following disclaimer.
2673
- * 2. Redistributions in binary form must reproduce the above copyright notice,
2674
- * this list of conditions and the following disclaimer in the
2675
- * documentation and/or other materials provided with the distribution.
2676
- * 3. Neither the name of the copyright holder nor the names of its contributors
2677
- * may be used to endorse or promote products derived from this software without
2678
- * specific prior written permission.
2679
- *
2680
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
2681
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2682
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2683
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
2684
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2685
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2686
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2687
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2688
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2689
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2690
- */
2691
- TomlError = class TomlError extends Error {
2692
- line;
2693
- column;
2694
- codeblock;
2695
- constructor(message, options) {
2696
- const [line, column] = getLineColFromPtr(options.toml, options.ptr);
2697
- const codeblock = makeCodeBlock(options.toml, line, column);
2698
- super(`Invalid TOML document: ${message}
2699
-
2700
- ${codeblock}`, options);
2701
- this.line = line;
2702
- this.column = column;
2703
- this.codeblock = codeblock;
2704
- }
2705
- };
2706
- });
2707
-
2708
- // node_modules/smol-toml/dist/primitive.js
2709
- function parseString(str, ptr) {
2710
- let c = str[ptr++];
2711
- let first = c;
2712
- let isLiteral = c === "'";
2713
- let isMultiline = c === str[ptr] && c === str[ptr + 1];
2714
- if (isMultiline) {
2715
- if (str[ptr += 2] === `
2716
- `)
2717
- ptr++;
2718
- else if (str[ptr] === "\r" && str[ptr + 1] === `
2719
- `)
2720
- ptr += 2;
2721
- }
2722
- let parsed = "";
2723
- let sliceStart = ptr;
2724
- let state = 0;
2725
- for (let i = ptr;i < str.length; i++) {
2726
- c = str[i];
2727
- if (isMultiline && (c === `
2728
- ` || c === "\r" && str[i + 1] === `
2729
- `)) {
2730
- state = state && 3;
2731
- } else if (c < " " && c !== "\t" || c === "") {
2732
- throw new TomlError("control characters are not allowed in strings", {
2733
- toml: str,
2734
- ptr: i
2735
- });
2736
- } else if ((!state || state === 3) && c === first && (!isMultiline || str[i + 1] === first && str[i + 2] === first)) {
2737
- if (isMultiline) {
2738
- if (str[i + 3] === first)
2739
- i++;
2740
- if (str[i + 3] === first)
2741
- i++;
2742
- }
2743
- return [
2744
- state ? parsed : parsed + str.slice(sliceStart, i),
2745
- i + (isMultiline ? 3 : 1)
2746
- ];
2747
- } else if (!state) {
2748
- if (!isLiteral && c === "\\") {
2749
- parsed += str.slice(sliceStart, sliceStart = i);
2750
- state = 1;
2751
- }
2752
- } else if (state === 1) {
2753
- if (c === "x" || c === "u" || c === "U") {
2754
- let value = 0;
2755
- let len = c === "x" ? 2 : c === "u" ? 4 : 8;
2756
- for (let j = 0;j < len; j++, i++) {
2757
- let hex = str.charCodeAt(i + 1);
2758
- let digit = hex >= 48 && hex <= 57 ? hex - 48 : hex >= 65 && hex <= 70 ? hex - 65 + 10 : hex >= 97 && hex <= 102 ? hex - 97 + 10 : -1;
2759
- if (digit < 0)
2760
- throw new TomlError("invalid non-hex character in unicode escape", { toml: str, ptr: i + 1 });
2761
- value = value << 4 | digit;
2762
- }
2763
- if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
2764
- throw new TomlError("invalid unicode escape", { toml: str, ptr: i });
2765
- }
2766
- parsed += String.fromCodePoint(value);
2767
- sliceStart = i + 1;
2768
- state = 0;
2769
- } else if (c === " " || c === "\t") {
2770
- state = 2;
2771
- } else {
2772
- if (c === "b")
2773
- parsed += "\b";
2774
- else if (c === "t")
2775
- parsed += "\t";
2776
- else if (c === "n")
2777
- parsed += `
2778
- `;
2779
- else if (c === "f")
2780
- parsed += "\f";
2781
- else if (c === "r")
2782
- parsed += "\r";
2783
- else if (c === "e")
2784
- parsed += "\x1B";
2785
- else if (c === '"')
2786
- parsed += '"';
2787
- else if (c === "\\")
2788
- parsed += "\\";
2789
- else
2790
- throw new TomlError("unrecognized escape sequence", { toml: str, ptr: i });
2791
- sliceStart = i + 1;
2792
- state = 0;
2793
- }
2794
- } else if (c !== " " && c !== "\t") {
2795
- if (state === 2) {
2796
- throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
2797
- toml: str,
2798
- ptr: sliceStart
2799
- });
2800
- }
2801
- state = !isLiteral && c === "\\" ? 1 : 0;
2802
- sliceStart = i;
2803
- }
2804
- }
2805
- throw new TomlError("unfinished string", { toml: str, ptr });
2806
- }
2807
- function parseValue(value, toml, ptr, integersAsBigInt) {
2808
- if (value === "true")
2809
- return true;
2810
- if (value === "false")
2811
- return false;
2812
- if (value === "-inf")
2813
- return -Infinity;
2814
- if (value === "inf" || value === "+inf")
2815
- return Infinity;
2816
- if (value === "nan" || value === "+nan" || value === "-nan")
2817
- return NaN;
2818
- if (value === "-0")
2819
- return integersAsBigInt ? 0n : 0;
2820
- let isInt = INT_REGEX.test(value);
2821
- if (isInt || FLOAT_REGEX.test(value)) {
2822
- if (LEADING_ZERO.test(value)) {
2823
- throw new TomlError("leading zeroes are not allowed", {
2824
- toml,
2825
- ptr
2826
- });
2827
- }
2828
- value = value.replace(/_/g, "");
2829
- let numeric = +value;
2830
- if (isNaN(numeric)) {
2831
- throw new TomlError("invalid number", {
2832
- toml,
2833
- ptr
2834
- });
2835
- }
2836
- if (isInt) {
2837
- if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
2838
- throw new TomlError("integer value cannot be represented losslessly", {
2839
- toml,
2840
- ptr
2841
- });
2842
- }
2843
- if (isInt || integersAsBigInt === true)
2844
- numeric = BigInt(value);
2845
- }
2846
- return numeric;
2847
- }
2848
- const date = new TomlDate(value);
2849
- if (!date.isValid()) {
2850
- throw new TomlError("invalid value", {
2851
- toml,
2852
- ptr
2853
- });
2854
- }
2855
- return date;
2856
- }
2857
- var INT_REGEX, FLOAT_REGEX, LEADING_ZERO;
2858
- var init_primitive = __esm(() => {
2859
- init_date();
2860
- init_error();
2861
- /*!
2862
- * Copyright (c) Squirrel Chat et al., All rights reserved.
2863
- * SPDX-License-Identifier: BSD-3-Clause
2864
- *
2865
- * Redistribution and use in source and binary forms, with or without
2866
- * modification, are permitted provided that the following conditions are met:
2867
- *
2868
- * 1. Redistributions of source code must retain the above copyright notice, this
2869
- * list of conditions and the following disclaimer.
2870
- * 2. Redistributions in binary form must reproduce the above copyright notice,
2871
- * this list of conditions and the following disclaimer in the
2872
- * documentation and/or other materials provided with the distribution.
2873
- * 3. Neither the name of the copyright holder nor the names of its contributors
2874
- * may be used to endorse or promote products derived from this software without
2875
- * specific prior written permission.
2876
- *
2877
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
2878
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2879
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2880
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
2881
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2882
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2883
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2884
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2885
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2886
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2887
- */
2888
- INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
2889
- FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
2890
- LEADING_ZERO = /^[+-]?0[0-9_]/;
2891
- });
2892
-
2893
- // node_modules/smol-toml/dist/util.js
2894
- function indexOfNewline(str, start = 0, end = str.length) {
2895
- let idx = str.indexOf(`
2896
- `, start);
2897
- if (str[idx - 1] === "\r")
2898
- idx--;
2899
- return idx <= end ? idx : -1;
2900
- }
2901
- function skipComment(str, ptr) {
2902
- for (let i = ptr;i < str.length; i++) {
2903
- let c = str[i];
2904
- if (c === `
2905
- `)
2906
- return i;
2907
- if (c === "\r" && str[i + 1] === `
2908
- `)
2909
- return i + 1;
2910
- if (c < " " && c !== "\t" || c === "") {
2911
- throw new TomlError("control characters are not allowed in comments", {
2912
- toml: str,
2913
- ptr
2914
- });
2915
- }
2916
- }
2917
- return str.length;
2918
- }
2919
- function skipVoid(str, ptr, banNewLines, banComments) {
2920
- let c;
2921
- while (true) {
2922
- while ((c = str[ptr]) === " " || c === "\t" || !banNewLines && (c === `
2923
- ` || c === "\r" && str[ptr + 1] === `
2924
- `))
2925
- ptr++;
2926
- if (banComments || c !== "#")
2927
- break;
2928
- ptr = skipComment(str, ptr);
2929
- }
2930
- return ptr;
2931
- }
2932
- function skipUntil(str, ptr, sep, end, banNewLines = false) {
2933
- if (!end) {
2934
- ptr = indexOfNewline(str, ptr);
2935
- return ptr < 0 ? str.length : ptr;
2936
- }
2937
- for (let i = ptr;i < str.length; i++) {
2938
- let c = str[i];
2939
- if (c === "#") {
2940
- i = indexOfNewline(str, i);
2941
- if (i < 0)
2942
- break;
2943
- } else if (c === sep) {
2944
- return i + 1;
2945
- } else if (c === end || banNewLines && (c === `
2946
- ` || c === "\r" && str[i + 1] === `
2947
- `)) {
2948
- return i;
2949
- }
2950
- }
2951
- throw new TomlError("cannot find end of structure", {
2952
- toml: str,
2953
- ptr
2954
- });
2955
- }
2956
- var init_util = __esm(() => {
2957
- init_error();
2958
- /*!
2959
- * Copyright (c) Squirrel Chat et al., All rights reserved.
2960
- * SPDX-License-Identifier: BSD-3-Clause
2961
- *
2962
- * Redistribution and use in source and binary forms, with or without
2963
- * modification, are permitted provided that the following conditions are met:
2964
- *
2965
- * 1. Redistributions of source code must retain the above copyright notice, this
2966
- * list of conditions and the following disclaimer.
2967
- * 2. Redistributions in binary form must reproduce the above copyright notice,
2968
- * this list of conditions and the following disclaimer in the
2969
- * documentation and/or other materials provided with the distribution.
2970
- * 3. Neither the name of the copyright holder nor the names of its contributors
2971
- * may be used to endorse or promote products derived from this software without
2972
- * specific prior written permission.
2973
- *
2974
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
2975
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2976
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2977
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
2978
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2979
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2980
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2981
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2982
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2983
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2984
- */
2985
- });
2986
-
2987
- // node_modules/smol-toml/dist/extract.js
2988
- function sliceAndTrimEndOf(str, startPtr, endPtr) {
2989
- let value = str.slice(startPtr, endPtr);
2990
- let commentIdx = value.indexOf("#");
2991
- if (commentIdx > -1) {
2992
- skipComment(str, commentIdx);
2993
- value = value.slice(0, commentIdx);
2994
- }
2995
- return [value.trimEnd(), commentIdx];
2996
- }
2997
- function extractValue(str, ptr, end, depth, integersAsBigInt) {
2998
- if (depth === 0) {
2999
- throw new TomlError("document contains excessively nested structures. aborting.", {
3000
- toml: str,
3001
- ptr
3002
- });
3003
- }
3004
- let c = str[ptr];
3005
- if (c === "[" || c === "{") {
3006
- let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
3007
- if (end) {
3008
- endPtr2 = skipVoid(str, endPtr2);
3009
- if (str[endPtr2] === ",")
3010
- endPtr2++;
3011
- else if (str[endPtr2] !== end) {
3012
- throw new TomlError("expected comma or end of structure", {
3013
- toml: str,
3014
- ptr: endPtr2
3015
- });
3016
- }
3017
- }
3018
- return [value, endPtr2];
3019
- }
3020
- if (c === '"' || c === "'") {
3021
- let [parsed, endPtr2] = parseString(str, ptr);
3022
- if (end) {
3023
- endPtr2 = skipVoid(str, endPtr2);
3024
- if (str[endPtr2] && str[endPtr2] !== "," && str[endPtr2] !== end && str[endPtr2] !== `
3025
- ` && str[endPtr2] !== "\r") {
3026
- throw new TomlError("unexpected character encountered", {
3027
- toml: str,
3028
- ptr: endPtr2
3029
- });
3030
- }
3031
- if (str[endPtr2] === ",")
3032
- endPtr2++;
3033
- }
3034
- return [parsed, endPtr2];
3035
- }
3036
- let endPtr = skipUntil(str, ptr, ",", end);
3037
- let slice = sliceAndTrimEndOf(str, ptr, endPtr - (str[endPtr - 1] === "," ? 1 : 0));
3038
- if (!slice[0]) {
3039
- throw new TomlError("incomplete key-value declaration: no value specified", {
3040
- toml: str,
3041
- ptr
3042
- });
3043
- }
3044
- if (end && slice[1] > -1) {
3045
- endPtr = skipVoid(str, ptr + slice[1]);
3046
- if (str[endPtr] === ",")
3047
- endPtr++;
3048
- }
3049
- return [
3050
- parseValue(slice[0], str, ptr, integersAsBigInt),
3051
- endPtr
3052
- ];
3053
- }
3054
- var init_extract = __esm(() => {
3055
- init_primitive();
3056
- init_struct();
3057
- init_util();
3058
- init_error();
3059
- /*!
3060
- * Copyright (c) Squirrel Chat et al., All rights reserved.
3061
- * SPDX-License-Identifier: BSD-3-Clause
3062
- *
3063
- * Redistribution and use in source and binary forms, with or without
3064
- * modification, are permitted provided that the following conditions are met:
3065
- *
3066
- * 1. Redistributions of source code must retain the above copyright notice, this
3067
- * list of conditions and the following disclaimer.
3068
- * 2. Redistributions in binary form must reproduce the above copyright notice,
3069
- * this list of conditions and the following disclaimer in the
3070
- * documentation and/or other materials provided with the distribution.
3071
- * 3. Neither the name of the copyright holder nor the names of its contributors
3072
- * may be used to endorse or promote products derived from this software without
3073
- * specific prior written permission.
3074
- *
3075
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
3076
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
3077
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3078
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
3079
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3080
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
3081
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
3082
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
3083
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3084
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3085
- */
3086
- });
3087
-
3088
- // node_modules/smol-toml/dist/struct.js
3089
- function parseKey(str, ptr, end = "=") {
3090
- let dot = ptr - 1;
3091
- let parsed = [];
3092
- let endPtr = str.indexOf(end, ptr);
3093
- if (endPtr < 0) {
3094
- throw new TomlError("incomplete key-value: cannot find end of key", {
3095
- toml: str,
3096
- ptr
3097
- });
3098
- }
3099
- do {
3100
- let c = str[ptr = ++dot];
3101
- if (c !== " " && c !== "\t") {
3102
- if (c === '"' || c === "'") {
3103
- if (c === str[ptr + 1] && c === str[ptr + 2]) {
3104
- throw new TomlError("multiline strings are not allowed in keys", {
3105
- toml: str,
3106
- ptr
3107
- });
3108
- }
3109
- let [part, eos] = parseString(str, ptr);
3110
- dot = str.indexOf(".", eos);
3111
- let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
3112
- let newLine = indexOfNewline(strEnd);
3113
- if (newLine > -1) {
3114
- throw new TomlError("newlines are not allowed in keys", {
3115
- toml: str,
3116
- ptr: ptr + dot + newLine
3117
- });
3118
- }
3119
- if (strEnd.trimStart()) {
3120
- throw new TomlError("found extra tokens after the string part", {
3121
- toml: str,
3122
- ptr: eos
3123
- });
3124
- }
3125
- if (endPtr < eos) {
3126
- endPtr = str.indexOf(end, eos);
3127
- if (endPtr < 0) {
3128
- throw new TomlError("incomplete key-value: cannot find end of key", {
3129
- toml: str,
3130
- ptr
3131
- });
3132
- }
3133
- }
3134
- parsed.push(part);
3135
- } else {
3136
- dot = str.indexOf(".", ptr);
3137
- let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
3138
- if (!KEY_PART_RE.test(part)) {
3139
- throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
3140
- toml: str,
3141
- ptr
3142
- });
3143
- }
3144
- parsed.push(part.trimEnd());
3145
- }
3146
- }
3147
- } while (dot + 1 && dot < endPtr);
3148
- return [parsed, skipVoid(str, endPtr + 1, true, true)];
3149
- }
3150
- function parseInlineTable(str, ptr, depth, integersAsBigInt) {
3151
- let res = {};
3152
- let seen = new Set;
3153
- let c;
3154
- ptr++;
3155
- while ((c = str[ptr++]) !== "}" && c) {
3156
- if (c === ",") {
3157
- throw new TomlError("expected value, found comma", {
3158
- toml: str,
3159
- ptr: ptr - 1
3160
- });
3161
- } else if (c === "#")
3162
- ptr = skipComment(str, ptr);
3163
- else if (c !== " " && c !== "\t" && c !== `
3164
- ` && c !== "\r") {
3165
- let k;
3166
- let t = res;
3167
- let hasOwn = false;
3168
- let [key, keyEndPtr] = parseKey(str, ptr - 1);
3169
- for (let i = 0;i < key.length; i++) {
3170
- if (i)
3171
- t = hasOwn ? t[k] : t[k] = {};
3172
- k = key[i];
3173
- if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
3174
- throw new TomlError("trying to redefine an already defined value", {
3175
- toml: str,
3176
- ptr
3177
- });
3178
- }
3179
- if (!hasOwn && k === "__proto__") {
3180
- Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
3181
- }
3182
- }
3183
- if (hasOwn) {
3184
- throw new TomlError("trying to redefine an already defined value", {
3185
- toml: str,
3186
- ptr
3187
- });
3188
- }
3189
- let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
3190
- seen.add(value);
3191
- t[k] = value;
3192
- ptr = valueEndPtr;
3193
- }
3194
- }
3195
- if (!c) {
3196
- throw new TomlError("unfinished table encountered", {
3197
- toml: str,
3198
- ptr
3199
- });
3200
- }
3201
- return [res, ptr];
3202
- }
3203
- function parseArray(str, ptr, depth, integersAsBigInt) {
3204
- let res = [];
3205
- let c;
3206
- ptr++;
3207
- while ((c = str[ptr++]) !== "]" && c) {
3208
- if (c === ",") {
3209
- throw new TomlError("expected value, found comma", {
3210
- toml: str,
3211
- ptr: ptr - 1
3212
- });
3213
- } else if (c === "#")
3214
- ptr = skipComment(str, ptr);
3215
- else if (c !== " " && c !== "\t" && c !== `
3216
- ` && c !== "\r") {
3217
- let e = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
3218
- res.push(e[0]);
3219
- ptr = e[1];
3220
- }
3221
- }
3222
- if (!c) {
3223
- throw new TomlError("unfinished array encountered", {
3224
- toml: str,
3225
- ptr
3226
- });
3227
- }
3228
- return [res, ptr];
3229
- }
3230
- var KEY_PART_RE;
3231
- var init_struct = __esm(() => {
3232
- init_primitive();
3233
- init_extract();
3234
- init_util();
3235
- init_error();
3236
- /*!
3237
- * Copyright (c) Squirrel Chat et al., All rights reserved.
3238
- * SPDX-License-Identifier: BSD-3-Clause
3239
- *
3240
- * Redistribution and use in source and binary forms, with or without
3241
- * modification, are permitted provided that the following conditions are met:
3242
- *
3243
- * 1. Redistributions of source code must retain the above copyright notice, this
3244
- * list of conditions and the following disclaimer.
3245
- * 2. Redistributions in binary form must reproduce the above copyright notice,
3246
- * this list of conditions and the following disclaimer in the
3247
- * documentation and/or other materials provided with the distribution.
3248
- * 3. Neither the name of the copyright holder nor the names of its contributors
3249
- * may be used to endorse or promote products derived from this software without
3250
- * specific prior written permission.
3251
- *
3252
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
3253
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
3254
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3255
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
3256
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3257
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
3258
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
3259
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
3260
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3261
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3262
- */
3263
- KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
3264
- });
3265
-
3266
- // node_modules/smol-toml/dist/parse.js
3267
- function peekTable(key, table, meta, type) {
3268
- let t = table;
3269
- let m = meta;
3270
- let k;
3271
- let hasOwn = false;
3272
- let state;
3273
- for (let i = 0;i < key.length; i++) {
3274
- if (i) {
3275
- t = hasOwn ? t[k] : t[k] = {};
3276
- m = (state = m[k]).c;
3277
- if (type === 0 && (state.t === 1 || state.t === 2)) {
3278
- return null;
3279
- }
3280
- if (state.t === 2) {
3281
- let l = t.length - 1;
3282
- t = t[l];
3283
- m = m[l].c;
3284
- }
3285
- }
3286
- k = key[i];
3287
- if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) {
3288
- return null;
3289
- }
3290
- if (!hasOwn) {
3291
- if (k === "__proto__") {
3292
- Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
3293
- Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
3294
- }
3295
- m[k] = {
3296
- t: i < key.length - 1 && type === 2 ? 3 : type,
3297
- d: false,
3298
- i: 0,
3299
- c: {}
3300
- };
3301
- }
3302
- }
3303
- state = m[k];
3304
- if (state.t !== type && !(type === 1 && state.t === 3)) {
3305
- return null;
3306
- }
3307
- if (type === 2) {
3308
- if (!state.d) {
3309
- state.d = true;
3310
- t[k] = [];
3311
- }
3312
- t[k].push(t = {});
3313
- state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
3314
- }
3315
- if (state.d) {
3316
- return null;
3317
- }
3318
- state.d = true;
3319
- if (type === 1) {
3320
- t = hasOwn ? t[k] : t[k] = {};
3321
- } else if (type === 0 && hasOwn) {
3322
- return null;
3323
- }
3324
- return [k, t, state.c];
3325
- }
3326
- function parse(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
3327
- let res = {};
3328
- let meta = {};
3329
- let tbl = res;
3330
- let m = meta;
3331
- for (let ptr = skipVoid(toml, 0);ptr < toml.length; ) {
3332
- if (toml[ptr] === "[") {
3333
- let isTableArray = toml[++ptr] === "[";
3334
- let k = parseKey(toml, ptr += +isTableArray, "]");
3335
- if (isTableArray) {
3336
- if (toml[k[1] - 1] !== "]") {
3337
- throw new TomlError("expected end of table declaration", {
3338
- toml,
3339
- ptr: k[1] - 1
3340
- });
3341
- }
3342
- k[1]++;
3343
- }
3344
- let p = peekTable(k[0], res, meta, isTableArray ? 2 : 1);
3345
- if (!p) {
3346
- throw new TomlError("trying to redefine an already defined table or value", {
3347
- toml,
3348
- ptr
3349
- });
3350
- }
3351
- m = p[2];
3352
- tbl = p[1];
3353
- ptr = k[1];
3354
- } else {
3355
- let k = parseKey(toml, ptr);
3356
- let p = peekTable(k[0], tbl, m, 0);
3357
- if (!p) {
3358
- throw new TomlError("trying to redefine an already defined table or value", {
3359
- toml,
3360
- ptr
3361
- });
3362
- }
3363
- let v = extractValue(toml, k[1], undefined, maxDepth, integersAsBigInt);
3364
- p[1][p[0]] = v[0];
3365
- ptr = v[1];
3366
- }
3367
- ptr = skipVoid(toml, ptr, true);
3368
- if (toml[ptr] && toml[ptr] !== `
3369
- ` && toml[ptr] !== "\r") {
3370
- throw new TomlError("each key-value declaration must be followed by an end-of-line", {
3371
- toml,
3372
- ptr
3373
- });
3374
- }
3375
- ptr = skipVoid(toml, ptr);
3376
- }
3377
- return res;
3378
- }
3379
- var init_parse = __esm(() => {
3380
- init_struct();
3381
- init_extract();
3382
- init_util();
3383
- init_error();
3384
- /*!
3385
- * Copyright (c) Squirrel Chat et al., All rights reserved.
3386
- * SPDX-License-Identifier: BSD-3-Clause
3387
- *
3388
- * Redistribution and use in source and binary forms, with or without
3389
- * modification, are permitted provided that the following conditions are met:
3390
- *
3391
- * 1. Redistributions of source code must retain the above copyright notice, this
3392
- * list of conditions and the following disclaimer.
3393
- * 2. Redistributions in binary form must reproduce the above copyright notice,
3394
- * this list of conditions and the following disclaimer in the
3395
- * documentation and/or other materials provided with the distribution.
3396
- * 3. Neither the name of the copyright holder nor the names of its contributors
3397
- * may be used to endorse or promote products derived from this software without
3398
- * specific prior written permission.
3399
- *
3400
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
3401
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
3402
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3403
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
3404
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3405
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
3406
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
3407
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
3408
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3409
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3410
- */
3411
- });
3412
-
3413
- // node_modules/smol-toml/dist/stringify.js
3414
- var init_stringify = __esm(() => {
3415
- /*!
3416
- * Copyright (c) Squirrel Chat et al., All rights reserved.
3417
- * SPDX-License-Identifier: BSD-3-Clause
3418
- *
3419
- * Redistribution and use in source and binary forms, with or without
3420
- * modification, are permitted provided that the following conditions are met:
3421
- *
3422
- * 1. Redistributions of source code must retain the above copyright notice, this
3423
- * list of conditions and the following disclaimer.
3424
- * 2. Redistributions in binary form must reproduce the above copyright notice,
3425
- * this list of conditions and the following disclaimer in the
3426
- * documentation and/or other materials provided with the distribution.
3427
- * 3. Neither the name of the copyright holder nor the names of its contributors
3428
- * may be used to endorse or promote products derived from this software without
3429
- * specific prior written permission.
3430
- *
3431
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
3432
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
3433
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3434
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
3435
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3436
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
3437
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
3438
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
3439
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3440
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3441
- */
3442
- });
3443
-
3444
- // node_modules/smol-toml/dist/index.js
3445
- var init_dist = __esm(() => {
3446
- init_parse();
3447
- init_stringify();
3448
- init_date();
3449
- init_error();
3450
- /*!
3451
- * Copyright (c) Squirrel Chat et al., All rights reserved.
3452
- * SPDX-License-Identifier: BSD-3-Clause
3453
- *
3454
- * Redistribution and use in source and binary forms, with or without
3455
- * modification, are permitted provided that the following conditions are met:
3456
- *
3457
- * 1. Redistributions of source code must retain the above copyright notice, this
3458
- * list of conditions and the following disclaimer.
3459
- * 2. Redistributions in binary form must reproduce the above copyright notice,
3460
- * this list of conditions and the following disclaimer in the
3461
- * documentation and/or other materials provided with the distribution.
3462
- * 3. Neither the name of the copyright holder nor the names of its contributors
3463
- * may be used to endorse or promote products derived from this software without
3464
- * specific prior written permission.
3465
- *
3466
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
3467
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
3468
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3469
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
3470
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3471
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
3472
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
3473
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
3474
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3475
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3476
- */
3477
- });
3478
-
3479
2519
  // src/hooks/fp-config.ts
3480
2520
  import { chmodSync, existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync2, statSync as statSync4, writeFileSync as writeFileSync2 } from "node:fs";
3481
2521
  function detectLayout() {
@@ -3485,6 +2525,11 @@ function detectLayout() {
3485
2525
  return { kind: "current", version: raw };
3486
2526
  return raw.layout > LAYOUT_VERSION ? { kind: "future", found: raw.layout } : { kind: "stale", found: raw.layout };
3487
2527
  }
2528
+ if (existsSync3(configFile())) {
2529
+ return { kind: "current", version: { layout: LAYOUT_VERSION, cli: "" }, inferred: true };
2530
+ }
2531
+ if (existsSync3(legacy.configToml()))
2532
+ return { kind: "stale", found: LAYOUT_VERSION - 1 };
3488
2533
  const layoutOneMarkers = [
3489
2534
  legacy.policyConfig(),
3490
2535
  legacy.cacheDir(),
@@ -3496,9 +2541,22 @@ function detectLayout() {
3496
2541
  ];
3497
2542
  return layoutOneMarkers.some((p) => existsSync3(p)) ? { kind: "stale", found: 1 } : { kind: "absent" };
3498
2543
  }
2544
+ function readLegacyTomlVersion(text) {
2545
+ const layout = Number(/^\s*layout\s*=\s*(\d+)\s*$/m.exec(text)?.[1]);
2546
+ if (!Number.isFinite(layout))
2547
+ return null;
2548
+ const str = (key) => new RegExp(`^\\s*${key}\\s*=\\s*"([^"]*)"`, "m").exec(text)?.[1];
2549
+ return { layout, cli: str("cli") ?? "", daemon: str("daemon") };
2550
+ }
3499
2551
  function readVersionFile() {
2552
+ let text;
2553
+ try {
2554
+ text = readFileSync2(versionFile(), "utf8");
2555
+ } catch {
2556
+ return null;
2557
+ }
3500
2558
  try {
3501
- const parsed = parse(readFileSync2(versionFile(), "utf8"));
2559
+ const parsed = JSON.parse(text);
3502
2560
  const layout = Number(parsed.layout);
3503
2561
  if (!Number.isFinite(layout))
3504
2562
  return null;
@@ -3508,7 +2566,7 @@ function readVersionFile() {
3508
2566
  daemon: typeof parsed.daemon === "string" ? parsed.daemon : undefined
3509
2567
  };
3510
2568
  } catch {
3511
- return null;
2569
+ return readLegacyTomlVersion(text);
3512
2570
  }
3513
2571
  }
3514
2572
  function readIntervalDays(raw) {
@@ -3519,9 +2577,25 @@ function readIntervalDays(raw) {
3519
2577
  return DEFAULT_AUDIT_INTERVAL_DAYS;
3520
2578
  return Math.min(days, MAX_AUDIT_INTERVAL_DAYS);
3521
2579
  }
2580
+ function readSources(raw) {
2581
+ if (!raw || typeof raw !== "object" || Array.isArray(raw))
2582
+ return;
2583
+ const out = {};
2584
+ for (const [name, table] of Object.entries(raw)) {
2585
+ if (!table || typeof table !== "object" || Array.isArray(table))
2586
+ continue;
2587
+ const entries = table.extra_paths;
2588
+ if (!Array.isArray(entries))
2589
+ continue;
2590
+ const paths = entries.filter((e) => typeof e === "string" && e.trim() !== "");
2591
+ if (paths.length > 0)
2592
+ out[name] = { extraPaths: paths };
2593
+ }
2594
+ return Object.keys(out).length > 0 ? out : undefined;
2595
+ }
3522
2596
  function readConfig() {
3523
2597
  try {
3524
- const parsed = parse(readFileSync2(configFile(), "utf8"));
2598
+ const parsed = JSON.parse(readFileSync2(configFile(), "utf8"));
3525
2599
  const mode = parsed.mode?.kind;
3526
2600
  const daemon = parsed.daemon ?? {};
3527
2601
  const collector = parsed.collector ?? {};
@@ -3536,7 +2610,8 @@ function readConfig() {
3536
2610
  hooksVerbosity: collector.hooks_verbosity === "all" || collector.hooks_verbosity === "off" ? collector.hooks_verbosity : "decisions",
3537
2611
  redact: collector.redact === "off" ? "off" : "minimal",
3538
2612
  environment: typeof collector.environment === "string" ? collector.environment : "local",
3539
- machineId: typeof collector.machine_id === "string" ? collector.machine_id : undefined
2613
+ machineId: typeof collector.machine_id === "string" ? collector.machine_id : undefined,
2614
+ sources: readSources(collector.sources)
3540
2615
  },
3541
2616
  telemetry: { enabled: telemetry.enabled !== false },
3542
2617
  audit: { auto: audit.auto === true, intervalDays: readIntervalDays(audit.interval_days) }
@@ -3547,7 +2622,6 @@ function readConfig() {
3547
2622
  }
3548
2623
  var DEFAULT_AUDIT_INTERVAL_DAYS = 7, MIN_AUDIT_INTERVAL_DAYS = 1, MAX_AUDIT_INTERVAL_DAYS = 90, DEFAULT_CONFIG;
3549
2624
  var init_fp_config = __esm(() => {
3550
- init_dist();
3551
2625
  init_package();
3552
2626
  init_fp_home();
3553
2627
  DEFAULT_CONFIG = {
@@ -4781,7 +3855,19 @@ async function loadAllCustomHooks(customPoliciesPaths, opts) {
4781
3855
  const projectRoot = findProjectConfigDir(opts?.sessionCwd ?? process.cwd());
4782
3856
  const conventionEnabled = opts?.customPoliciesEnabled !== false;
4783
3857
  const loadedPaths = new Set;
4784
- const cloudManagedByPath = new Map((opts?.cloudManagedPolicies ?? []).map((policy) => [resolve5(policy.path), policy]));
3858
+ const cloudManagedByPath = new Map;
3859
+ for (const policy of opts?.cloudManagedPolicies ?? []) {
3860
+ const key = resolve5(policy.path);
3861
+ const existing = cloudManagedByPath.get(key);
3862
+ if (!existing) {
3863
+ cloudManagedByPath.set(key, policy);
3864
+ continue;
3865
+ }
3866
+ hookLogWarn(`cloud-managed policies ${existing.id} and ${policy.id} have identical source, so they share ` + `one artifact and load as one policy; enforcing it if either asks to enforce`);
3867
+ if (existing.effect !== "enforce" && policy.effect === "enforce") {
3868
+ cloudManagedByPath.set(key, policy);
3869
+ }
3870
+ }
4785
3871
  for (const customPoliciesPath of typeof customPoliciesPaths === "string" ? [customPoliciesPaths] : customPoliciesPaths ?? []) {
4786
3872
  const absPath = resolve5(projectRoot, customPoliciesPath);
4787
3873
  if (existsSync4(absPath)) {
@@ -4796,7 +3882,7 @@ async function loadAllCustomHooks(customPoliciesPaths, opts) {
4796
3882
  const tagged = hook;
4797
3883
  if (cloudManaged) {
4798
3884
  tagged.__cloudManaged = cloudManaged;
4799
- tagged.__policyId = `cloud:${cloudManaged.id}@${cloudManaged.revision}:${hook.name}`;
3885
+ tagged.__policyId = `cloud:${cloudManaged.id}@${cloudManaged.version}:${hook.name}`;
4800
3886
  } else {
4801
3887
  tagged.__policyId = customPolicyId(absPath, hook.name);
4802
3888
  }
@@ -4808,23 +3894,24 @@ async function loadAllCustomHooks(customPoliciesPaths, opts) {
4808
3894
  }
4809
3895
  const hooksBeforeConvention = getCustomHooks().length;
4810
3896
  const projectDir = resolve5(projectRoot, ".failproofai", "policies");
3897
+ const projectScope = projectDir === customPoliciesDir() ? "user" : "project";
4811
3898
  if (conventionEnabled) {
4812
3899
  sweepStaleTmpArtifacts(projectDir);
4813
- warnSkippedPolicyFiles(projectDir, "project");
3900
+ warnSkippedPolicyFiles(projectDir, projectScope);
4814
3901
  }
4815
3902
  sweepStaleTmpArtifacts(shimsDir());
4816
3903
  const projectFiles = conventionEnabled ? discoverPolicyFiles(projectDir).filter((f) => !loadedPaths.has(f)) : [];
4817
3904
  for (const file of projectFiles) {
4818
3905
  loadedPaths.add(file);
4819
3906
  const hooksBefore = getCustomHooks().length;
4820
- await loadSingleFile(file, { conventionScope: "project" });
3907
+ await loadSingleFile(file, { conventionScope: projectScope });
4821
3908
  const newHooks = getCustomHooks().slice(hooksBefore);
4822
3909
  for (const hook of newHooks) {
4823
- hook.__policyId = conventionPolicyId("project", basename(file), hook.name);
3910
+ hook.__policyId = conventionPolicyId(projectScope, basename(file), hook.name);
4824
3911
  }
4825
3912
  if (newHooks.length > 0) {
4826
3913
  conventionSources.push({
4827
- scope: "project",
3914
+ scope: projectScope,
4828
3915
  file: basename(file),
4829
3916
  hookNames: newHooks.map((h) => h.name)
4830
3917
  });
@@ -9581,16 +8668,21 @@ function cloudManagedPolicyRoot() {
9581
8668
  function parseManifest(value) {
9582
8669
  if (!value || typeof value !== "object")
9583
8670
  throw new Error("active manifest is not an object");
9584
- const manifest = value;
9585
- if (manifest.schemaVersion !== ACTIVE_SCHEMA_VERSION) {
9586
- throw new Error(`unsupported active manifest schema ${String(manifest.schemaVersion)}`);
8671
+ const raw = value;
8672
+ if (!ACCEPTED_ACTIVE_SCHEMA_VERSIONS.includes(raw.schemaVersion)) {
8673
+ throw new Error(`unsupported active manifest schema ${String(raw.schemaVersion)} ` + `(supported: ${ACCEPTED_ACTIVE_SCHEMA_VERSIONS.join(", ")})`);
9587
8674
  }
9588
- if (!Number.isSafeInteger(manifest.generation) || (manifest.generation ?? -1) < 0) {
9589
- throw new Error("active manifest generation is invalid");
8675
+ const deployment = raw.deployment ?? raw.generation;
8676
+ if (!Number.isSafeInteger(deployment) || (deployment ?? -1) < 0) {
8677
+ throw new Error("active manifest deployment is invalid");
9590
8678
  }
9591
- if (!Array.isArray(manifest.policies))
8679
+ if (!Array.isArray(raw.policies))
9592
8680
  throw new Error("active manifest policies is not an array");
9593
- return manifest;
8681
+ const policies = raw.policies.map((p) => {
8682
+ const entry = p;
8683
+ return { ...entry, version: entry.version ?? entry.revision };
8684
+ });
8685
+ return { schemaVersion: raw.schemaVersion, deployment, policies };
9594
8686
  }
9595
8687
  function resolveManagedPath(root, candidate) {
9596
8688
  if (!candidate || isAbsolute2(candidate))
@@ -9625,8 +8717,8 @@ function readActiveCloudManagedPolicies() {
9625
8717
  if (!POLICY_ID_RE.test(policy.id) || policy.id === "." || policy.id === "..") {
9626
8718
  throw new Error(`unsafe cloud-managed policy id ${JSON.stringify(policy.id)}`);
9627
8719
  }
9628
- if (!Number.isSafeInteger(policy.revision) || policy.revision < 0) {
9629
- throw new Error(`invalid revision for cloud-managed policy ${policy.id}`);
8720
+ if (!Number.isSafeInteger(policy.version) || policy.version < 0) {
8721
+ throw new Error(`invalid version for cloud-managed policy ${policy.id}`);
9630
8722
  }
9631
8723
  if (!SHA256_RE.test(policy.sha256)) {
9632
8724
  throw new Error(`invalid SHA-256 for cloud-managed policy ${policy.id}`);
@@ -9645,17 +8737,18 @@ function readActiveCloudManagedPolicies() {
9645
8737
  }
9646
8738
  return {
9647
8739
  id: policy.id,
9648
- revision: policy.revision,
8740
+ version: policy.version,
9649
8741
  effect: policy.effect ?? "enforce",
9650
8742
  sha256: policy.sha256,
9651
8743
  path: path2,
9652
- generation: manifest.generation
8744
+ deployment: manifest.deployment
9653
8745
  };
9654
8746
  });
9655
8747
  }
9656
- var ACTIVE_SCHEMA_VERSION = 1, SHA256_RE, POLICY_ID_RE;
8748
+ var ACCEPTED_ACTIVE_SCHEMA_VERSIONS, SHA256_RE, POLICY_ID_RE;
9657
8749
  var init_cloud_managed_policies = __esm(() => {
9658
8750
  init_fp_home();
8751
+ ACCEPTED_ACTIVE_SCHEMA_VERSIONS = [1, 2];
9659
8752
  SHA256_RE = /^[a-f0-9]{64}$/;
9660
8753
  POLICY_ID_RE = /^[A-Za-z0-9._-]{1,128}$/;
9661
8754
  });
@@ -9743,6 +8836,18 @@ var init_daemon_service = __esm(() => {
9743
8836
  });
9744
8837
 
9745
8838
  // src/hooks/fp-reset.ts
8839
+ import {
8840
+ copyFileSync,
8841
+ existsSync as existsSync13,
8842
+ mkdirSync as mkdirSync7,
8843
+ readFileSync as readFileSync13,
8844
+ readdirSync as readdirSync12,
8845
+ renameSync as renameSync3,
8846
+ rmSync as rmSync3,
8847
+ rmdirSync,
8848
+ statSync as statSync13,
8849
+ writeFileSync as writeFileSync5
8850
+ } from "node:fs";
9746
8851
  function layoutWarningForHook() {
9747
8852
  const state = detectLayout();
9748
8853
  if (state.kind === "current" || state.kind === "absent")
@@ -9750,6 +8855,8 @@ function layoutWarningForHook() {
9750
8855
  if (state.kind === "future") {
9751
8856
  return `[failproofai] this directory was written by a newer version ` + `(layout ${state.found} vs ${LAYOUT_VERSION}) — policies are NOT being enforced. ` + `Upgrade failproofai.`;
9752
8857
  }
8858
+ if (existsSync13(globalPolicyConfigFile()))
8859
+ return null;
9753
8860
  return `[failproofai] setup predates this version — global policies are NOT being enforced. ` + `Run \`failproofai config\` to re-create it.`;
9754
8861
  }
9755
8862
  var init_fp_reset = __esm(() => {
@@ -9856,7 +8963,7 @@ async function evaluateHookEvent(eventType, cli = "claude", stdinPayload, opts)
9856
8963
  let conventionHookNames = new Set;
9857
8964
  let activePause = null;
9858
8965
  const policyAttribution = new Map;
9859
- let cloudGeneration;
8966
+ let cloudDeployment;
9860
8967
  const observedResults = [];
9861
8968
  if (opts?.forceDecision) {
9862
8969
  config = { enabledPolicies: [] };
@@ -9879,7 +8986,7 @@ async function evaluateHookEvent(eventType, cli = "claude", stdinPayload, opts)
9879
8986
  cli
9880
8987
  });
9881
8988
  }
9882
- cloudGeneration = cloudManagedPolicies[0]?.generation;
8989
+ cloudDeployment = cloudManagedPolicies[0]?.deployment;
9883
8990
  const configuredCustomPaths = config.customPoliciesPaths ?? config.customPoliciesPath;
9884
8991
  const allExplicitPaths = cloudManagedPolicies.length === 0 ? configuredCustomPaths : [
9885
8992
  ...typeof configuredCustomPaths === "string" ? [configuredCustomPaths] : configuredCustomPaths ?? [],
@@ -9904,7 +9011,7 @@ async function evaluateHookEvent(eventType, cli = "claude", stdinPayload, opts)
9904
9011
  const hookName = hook.name;
9905
9012
  const conventionScope = hook.__conventionScope;
9906
9013
  const isConvention = !!conventionScope;
9907
- const prefix = cloudManaged ? `cloud/${cloudManaged.id}@${cloudManaged.revision}` : isConvention ? `.failproofai-${conventionScope}` : "custom";
9014
+ const prefix = cloudManaged ? `cloud/${cloudManaged.id}@${cloudManaged.version}` : isConvention ? `.failproofai-${conventionScope}` : "custom";
9908
9015
  const observeOnly = cloudManaged?.effect === "observe";
9909
9016
  const fn = async (ctx) => {
9910
9017
  if (observeOnly) {
@@ -9912,7 +9019,7 @@ async function evaluateHookEvent(eventType, cli = "claude", stdinPayload, opts)
9912
9019
  if (shadow.decision !== "allow") {
9913
9020
  observedResults.push({
9914
9021
  policyId: cloudManaged.id,
9915
- revision: cloudManaged.revision,
9022
+ version: cloudManaged.version,
9916
9023
  decision: shadow.decision,
9917
9024
  reason: shadow.reason ?? null
9918
9025
  });
@@ -9943,7 +9050,7 @@ async function evaluateHookEvent(eventType, cli = "claude", stdinPayload, opts)
9943
9050
  const registeredName = `${prefix}/${hookName}`;
9944
9051
  policyAttribution.set(registeredName, {
9945
9052
  source: cloudManaged ? "cloud" : isConvention ? "convention" : "custom",
9946
- ...cloudManaged ? { cloudPolicyId: cloudManaged.id, cloudRevision: cloudManaged.revision } : {}
9053
+ ...cloudManaged ? { cloudPolicyId: cloudManaged.id, cloudVersion: cloudManaged.version } : {}
9947
9054
  });
9948
9055
  registerPolicy(registeredName, hook.description ?? "", fn, hook.match ?? {}, -1);
9949
9056
  }
@@ -9992,10 +9099,10 @@ async function evaluateHookEvent(eventType, cli = "claude", stdinPayload, opts)
9992
9099
  return {
9993
9100
  policySource: attribution?.source ?? "builtin",
9994
9101
  ...attribution?.cloudPolicyId ? { cloudPolicyId: attribution.cloudPolicyId } : {},
9995
- ...attribution?.cloudRevision !== undefined ? { cloudRevision: attribution.cloudRevision } : {}
9102
+ ...attribution?.cloudVersion !== undefined ? { cloudVersion: attribution.cloudVersion } : {}
9996
9103
  };
9997
9104
  })() : {},
9998
- ...cloudGeneration !== undefined ? { cloudGeneration } : {},
9105
+ ...cloudDeployment !== undefined ? { cloudDeployment } : {},
9999
9106
  ...observedResults.length > 0 ? { observed: observedResults } : {},
10000
9107
  ...activePause ? { pausedBy: activePause.setBy, pauseExpiresAt: activePause.expiresAt } : {}
10001
9108
  };
@@ -10060,7 +9167,7 @@ __export(exports_worker_server, {
10060
9167
  startWorkerServer: () => startWorkerServer
10061
9168
  });
10062
9169
  import { createConnection, createServer } from "node:net";
10063
- import { existsSync as existsSync13, unlinkSync as unlinkSync2 } from "node:fs";
9170
+ import { existsSync as existsSync14, unlinkSync as unlinkSync2 } from "node:fs";
10064
9171
  function isWorkerHookRequest(msg) {
10065
9172
  if (!msg || typeof msg !== "object")
10066
9173
  return false;
@@ -10193,14 +9300,14 @@ function requestExistingWorkerShutdown(socketPath) {
10193
9300
  function startWorkerServer(socketPath, shutdown) {
10194
9301
  const server = createServer((socket) => handleConnection(socket, shutdown ?? (() => server.close())));
10195
9302
  const listen = () => {
10196
- if (existsSync13(socketPath)) {
9303
+ if (existsSync14(socketPath)) {
10197
9304
  try {
10198
9305
  unlinkSync2(socketPath);
10199
9306
  } catch {}
10200
9307
  }
10201
9308
  server.listen(socketPath);
10202
9309
  };
10203
- if (!existsSync13(socketPath))
9310
+ if (!existsSync14(socketPath))
10204
9311
  listen();
10205
9312
  else
10206
9313
  requestExistingWorkerShutdown(socketPath).then(listen, (err) => server.emit("error", err));