@superblocksteam/cli 2.0.141-next.0 → 2.0.141-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +1 -1
  2. package/dist/{acorn-DJYL2AMA.js → acorn-33PDNT4G.js} +3 -3
  3. package/dist/{angular-D4OXWSTQ.js → angular-JI4DJHZ6.js} +3 -3
  4. package/dist/{api-GRUZLVFH.js → api-4T55YEDE.js} +4 -4
  5. package/dist/{babel-E2YRPG6X.js → babel-O5SHO5HA.js} +3 -3
  6. package/dist/{chunk-O3ALZQID.js → chunk-2FCS5636.js} +1114 -591
  7. package/dist/{chunk-O3ALZQID.js.map → chunk-2FCS5636.js.map} +1 -1
  8. package/dist/{chunk-ZEBQBCML.js → chunk-46MHX4O3.js} +4 -4
  9. package/dist/{chunk-7OSMS4R5.js → chunk-7GFAYTXP.js} +3 -3
  10. package/dist/{chunk-R6FSVLFU.js → chunk-CHGQBSTI.js} +2 -2
  11. package/dist/{chunk-M2RX5AMC.js → chunk-EFA23U2C.js} +4 -4
  12. package/dist/{chunk-C7PV3A6E.js → chunk-IQDORFUA.js} +3 -3
  13. package/dist/{chunk-EJBBENJT.js → chunk-J3KPIS4P.js} +3 -3
  14. package/dist/{chunk-OZIJLVZ3.js → chunk-KT3EIWY2.js} +6 -6
  15. package/dist/{chunk-SH5H64FD.js → chunk-LJGZOL3F.js} +3 -3
  16. package/dist/{chunk-MXXEIC4T.js → chunk-M6VQ4H4Z.js} +3 -3
  17. package/dist/{chunk-PRNFDDTG.js → chunk-NEBLR6OX.js} +4 -4
  18. package/dist/{chunk-PRKEOD4X.js → chunk-NVHNBS53.js} +3 -3
  19. package/dist/{chunk-CQS2FXON.js → chunk-PTS6G4WB.js} +3 -3
  20. package/dist/{chunk-MZRCRXWK.js → chunk-SPJID2WQ.js} +3 -3
  21. package/dist/{chunk-B6BS2XGS.js → chunk-U4R6B26Z.js} +4 -4
  22. package/dist/{chunk-2VUSN3WK.js → chunk-URLVIGGG.js} +3 -3
  23. package/dist/{chunk-2VUSN3WK.js.map → chunk-URLVIGGG.js.map} +1 -1
  24. package/dist/{chunk-QEGSQXPR.js → chunk-WWPNIUK7.js} +3 -3
  25. package/dist/{chunk-UJJTMW6H.js → chunk-ZIYOVIBT.js} +6 -7
  26. package/dist/chunk-ZIYOVIBT.js.map +1 -0
  27. package/dist/{cli-truncate-C5T5XBVZ.js → cli-truncate-KD3IMGQZ.js} +5 -5
  28. package/dist/commands/dev-parent.js +3 -3
  29. package/dist/{dd-trace-OPBAOO5R.js → dd-trace-D7QUBO7I.js} +7 -7
  30. package/dist/{dist-PHICQ5XD.js → dist-YCS5SVAA.js} +14 -14
  31. package/dist/{embedded-playwright-mcp-server-6ZRCB7OJ.js → embedded-playwright-mcp-server-SWUZ5WRJ.js} +3 -3
  32. package/dist/{enquirer-2BLAYP5O.js → enquirer-WKKWAE7I.js} +4 -4
  33. package/dist/{estree-G6A3CLHM.js → estree-IGFHWX3W.js} +3 -3
  34. package/dist/{flow-SOAATWPH.js → flow-K6ENOKSA.js} +3 -3
  35. package/dist/{getMachineId-bsd-D3Z6NAGQ.js → getMachineId-bsd-R7FUZCBS.js} +5 -5
  36. package/dist/{getMachineId-darwin-GWGWAYUL.js → getMachineId-darwin-S365CT4C.js} +5 -5
  37. package/dist/{getMachineId-linux-EX6OHUV7.js → getMachineId-linux-WWEC3Y6J.js} +4 -4
  38. package/dist/{getMachineId-unsupported-G3KKCZOP.js → getMachineId-unsupported-WZBZKWFL.js} +4 -4
  39. package/dist/{getMachineId-win-P2APSGTL.js → getMachineId-win-35IZOALZ.js} +5 -5
  40. package/dist/{glimmer-AAPXV3KF.js → glimmer-J22DQNP7.js} +3 -3
  41. package/dist/{graphql-BLB7FCAN.js → graphql-PA3QKIAK.js} +3 -3
  42. package/dist/{html-QYMNEYJ4.js → html-IZ5VQFTA.js} +3 -3
  43. package/dist/{http-BKWKGNBB.js → http-MOESNR3Q.js} +13 -13
  44. package/dist/index.js +19 -19
  45. package/dist/{jiti-DGIIEVSP.js → jiti-ETYPYHSK.js} +3 -3
  46. package/dist/{log-update-BZXSYNP3.js → log-update-3SNRFLVP.js} +6 -6
  47. package/dist/{markdown-5A6WF6FY.js → markdown-FVGVAVL4.js} +3 -3
  48. package/dist/{meriyah-DTNGYWT2.js → meriyah-QEL5Q3O3.js} +3 -3
  49. package/dist/migration-templates/app-fullstack/package.json +1 -6
  50. package/dist/{postcss-KSVRPJLF.js → postcss-YBLMJPFI.js} +3 -3
  51. package/dist/{read-pkg-ANYNELJU.js → read-pkg-6TOKHW7I.js} +5 -5
  52. package/dist/{spans-DHM7DAAH.js → spans-DJ6DK2RF.js} +4 -4
  53. package/dist/{src-GNBOXZZ5.js → src-FHUWJFLE.js} +3 -3
  54. package/dist/{token-7SZNVNTK.js → token-DWAZ4JCJ.js} +5 -5
  55. package/dist/{token-util-KYTRKMAC.js → token-util-J6V5LCAN.js} +5 -5
  56. package/dist/{typescript-PQSNN2AA.js → typescript-3QAPWCSE.js} +3 -3
  57. package/dist/{wrap-ansi-BYUIA2LO.js → wrap-ansi-BSVZOHCT.js} +5 -5
  58. package/dist/{yaml-EU2JTNYQ.js → yaml-E452PT2S.js} +3 -3
  59. package/oclif.manifest.json +1 -1
  60. package/package.json +6 -6
  61. package/assets/custom-components/setup/.eslintrc.js +0 -32
  62. package/assets/custom-components/setup/components/scss.d.ts +0 -2
  63. package/dist/chunk-UJJTMW6H.js.map +0 -1
  64. /package/dist/{acorn-DJYL2AMA.js.map → acorn-33PDNT4G.js.map} +0 -0
  65. /package/dist/{angular-D4OXWSTQ.js.map → angular-JI4DJHZ6.js.map} +0 -0
  66. /package/dist/{api-GRUZLVFH.js.map → api-4T55YEDE.js.map} +0 -0
  67. /package/dist/{babel-E2YRPG6X.js.map → babel-O5SHO5HA.js.map} +0 -0
  68. /package/dist/{chunk-ZEBQBCML.js.map → chunk-46MHX4O3.js.map} +0 -0
  69. /package/dist/{chunk-7OSMS4R5.js.map → chunk-7GFAYTXP.js.map} +0 -0
  70. /package/dist/{chunk-R6FSVLFU.js.map → chunk-CHGQBSTI.js.map} +0 -0
  71. /package/dist/{chunk-M2RX5AMC.js.map → chunk-EFA23U2C.js.map} +0 -0
  72. /package/dist/{chunk-C7PV3A6E.js.map → chunk-IQDORFUA.js.map} +0 -0
  73. /package/dist/{chunk-EJBBENJT.js.map → chunk-J3KPIS4P.js.map} +0 -0
  74. /package/dist/{chunk-OZIJLVZ3.js.map → chunk-KT3EIWY2.js.map} +0 -0
  75. /package/dist/{chunk-SH5H64FD.js.map → chunk-LJGZOL3F.js.map} +0 -0
  76. /package/dist/{chunk-MXXEIC4T.js.map → chunk-M6VQ4H4Z.js.map} +0 -0
  77. /package/dist/{chunk-PRNFDDTG.js.map → chunk-NEBLR6OX.js.map} +0 -0
  78. /package/dist/{chunk-PRKEOD4X.js.map → chunk-NVHNBS53.js.map} +0 -0
  79. /package/dist/{chunk-CQS2FXON.js.map → chunk-PTS6G4WB.js.map} +0 -0
  80. /package/dist/{chunk-MZRCRXWK.js.map → chunk-SPJID2WQ.js.map} +0 -0
  81. /package/dist/{chunk-B6BS2XGS.js.map → chunk-U4R6B26Z.js.map} +0 -0
  82. /package/dist/{chunk-QEGSQXPR.js.map → chunk-WWPNIUK7.js.map} +0 -0
  83. /package/dist/{cli-truncate-C5T5XBVZ.js.map → cli-truncate-KD3IMGQZ.js.map} +0 -0
  84. /package/dist/{dd-trace-OPBAOO5R.js.map → dd-trace-D7QUBO7I.js.map} +0 -0
  85. /package/dist/{dist-PHICQ5XD.js.map → dist-YCS5SVAA.js.map} +0 -0
  86. /package/dist/{embedded-playwright-mcp-server-6ZRCB7OJ.js.map → embedded-playwright-mcp-server-SWUZ5WRJ.js.map} +0 -0
  87. /package/dist/{enquirer-2BLAYP5O.js.map → enquirer-WKKWAE7I.js.map} +0 -0
  88. /package/dist/{estree-G6A3CLHM.js.map → estree-IGFHWX3W.js.map} +0 -0
  89. /package/dist/{flow-SOAATWPH.js.map → flow-K6ENOKSA.js.map} +0 -0
  90. /package/dist/{getMachineId-bsd-D3Z6NAGQ.js.map → getMachineId-bsd-R7FUZCBS.js.map} +0 -0
  91. /package/dist/{getMachineId-darwin-GWGWAYUL.js.map → getMachineId-darwin-S365CT4C.js.map} +0 -0
  92. /package/dist/{getMachineId-linux-EX6OHUV7.js.map → getMachineId-linux-WWEC3Y6J.js.map} +0 -0
  93. /package/dist/{getMachineId-unsupported-G3KKCZOP.js.map → getMachineId-unsupported-WZBZKWFL.js.map} +0 -0
  94. /package/dist/{getMachineId-win-P2APSGTL.js.map → getMachineId-win-35IZOALZ.js.map} +0 -0
  95. /package/dist/{glimmer-AAPXV3KF.js.map → glimmer-J22DQNP7.js.map} +0 -0
  96. /package/dist/{graphql-BLB7FCAN.js.map → graphql-PA3QKIAK.js.map} +0 -0
  97. /package/dist/{html-QYMNEYJ4.js.map → html-IZ5VQFTA.js.map} +0 -0
  98. /package/dist/{http-BKWKGNBB.js.map → http-MOESNR3Q.js.map} +0 -0
  99. /package/dist/{jiti-DGIIEVSP.js.map → jiti-ETYPYHSK.js.map} +0 -0
  100. /package/dist/{log-update-BZXSYNP3.js.map → log-update-3SNRFLVP.js.map} +0 -0
  101. /package/dist/{markdown-5A6WF6FY.js.map → markdown-FVGVAVL4.js.map} +0 -0
  102. /package/dist/{meriyah-DTNGYWT2.js.map → meriyah-QEL5Q3O3.js.map} +0 -0
  103. /package/dist/{postcss-KSVRPJLF.js.map → postcss-YBLMJPFI.js.map} +0 -0
  104. /package/dist/{read-pkg-ANYNELJU.js.map → read-pkg-6TOKHW7I.js.map} +0 -0
  105. /package/dist/{spans-DHM7DAAH.js.map → spans-DJ6DK2RF.js.map} +0 -0
  106. /package/dist/{src-GNBOXZZ5.js.map → src-FHUWJFLE.js.map} +0 -0
  107. /package/dist/{token-7SZNVNTK.js.map → token-DWAZ4JCJ.js.map} +0 -0
  108. /package/dist/{token-util-KYTRKMAC.js.map → token-util-J6V5LCAN.js.map} +0 -0
  109. /package/dist/{typescript-PQSNN2AA.js.map → typescript-3QAPWCSE.js.map} +0 -0
  110. /package/dist/{wrap-ansi-BYUIA2LO.js.map → wrap-ansi-BSVZOHCT.js.map} +0 -0
  111. /package/dist/{yaml-EU2JTNYQ.js.map → yaml-E452PT2S.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  if (typeof process === 'object' && process !== null &&
2
2
  process.env !== null && typeof process.env === 'object') {
3
3
  process.env.DD_GIT_REPOSITORY_URL = 'https://token@github.com/superblocksteam/superblocks.git';
4
- process.env.DD_GIT_COMMIT_SHA = '504a48cde044242c00ff8d69f0c4479cebd5f6b7';
4
+ process.env.DD_GIT_COMMIT_SHA = '08c6a40ccc6547d3d6f805bdbf0a0be94c8e634d';
5
5
  }
6
6
  import { createRequire as $dd_createRequire } from 'module';
7
7
  import { fileURLToPath as $dd_fileURLToPath } from 'url';
@@ -15,7 +15,7 @@ import {
15
15
  require_lib as require_lib2,
16
16
  require_lib2 as require_lib3,
17
17
  require_picocolors
18
- } from "./chunk-CQS2FXON.js";
18
+ } from "./chunk-PTS6G4WB.js";
19
19
  import {
20
20
  debounce_default,
21
21
  get_default,
@@ -32,20 +32,20 @@ import {
32
32
  require_lib,
33
33
  require_slugify,
34
34
  throttle_default
35
- } from "./chunk-PRKEOD4X.js";
35
+ } from "./chunk-NVHNBS53.js";
36
36
  import {
37
37
  require_dd_trace,
38
38
  require_js_yaml,
39
39
  require_module_details_from_path,
40
40
  require_p_limit,
41
41
  require_path_to_regexp
42
- } from "./chunk-OZIJLVZ3.js";
42
+ } from "./chunk-KT3EIWY2.js";
43
43
  import {
44
44
  require_commonjs
45
- } from "./chunk-SH5H64FD.js";
45
+ } from "./chunk-LJGZOL3F.js";
46
46
  import {
47
47
  require_dc_polyfill
48
- } from "./chunk-7OSMS4R5.js";
48
+ } from "./chunk-7GFAYTXP.js";
49
49
  import {
50
50
  ATTR_SUPERBLOCKS_BASE_URL,
51
51
  ATTR_SUPERBLOCKS_CSB_ID,
@@ -54,10 +54,10 @@ import {
54
54
  SERVICE_NAME,
55
55
  getEnvironmentFromHostname,
56
56
  otlpBaseUrl
57
- } from "./chunk-2VUSN3WK.js";
57
+ } from "./chunk-URLVIGGG.js";
58
58
  import {
59
59
  require_token_error
60
- } from "./chunk-C7PV3A6E.js";
60
+ } from "./chunk-IQDORFUA.js";
61
61
  import {
62
62
  SpanKind,
63
63
  SpanStatusCode,
@@ -69,7 +69,7 @@ import {
69
69
  metrics,
70
70
  propagation,
71
71
  trace
72
- } from "./chunk-MXXEIC4T.js";
72
+ } from "./chunk-M6VQ4H4Z.js";
73
73
  import {
74
74
  __commonJS,
75
75
  __esm,
@@ -78,7 +78,7 @@ import {
78
78
  __toCommonJS,
79
79
  __toESM,
80
80
  init_cjs_shims
81
- } from "./chunk-R6FSVLFU.js";
81
+ } from "./chunk-CHGQBSTI.js";
82
82
 
83
83
  // ../../../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/constants.js
84
84
  var require_constants2 = __commonJS({
@@ -43472,13 +43472,15 @@ var require_git2 = __commonJS({
43472
43472
  init_cjs_shims();
43473
43473
  Object.defineProperty(exports, "__esModule", { value: true });
43474
43474
  exports.GIT_PERMISSION_ERROR_PATTERNS = exports.GIT_AUTH_ERROR_PATTERNS = void 0;
43475
- exports.isGitAuthErrorMessage = isGitAuthErrorMessage;
43475
+ exports.isGitAuthErrorMessage = isGitAuthErrorMessage3;
43476
43476
  exports.isGitPermissionErrorMessage = isGitPermissionErrorMessage;
43477
43477
  exports.GIT_AUTH_ERROR_PATTERNS = [
43478
43478
  "authentication failed",
43479
43479
  "could not read username",
43480
43480
  "invalid credentials",
43481
+ "invalid username or token",
43481
43482
  "bad credentials",
43483
+ "password authentication is not supported",
43482
43484
  "401"
43483
43485
  ];
43484
43486
  exports.GIT_PERMISSION_ERROR_PATTERNS = [
@@ -43493,7 +43495,7 @@ var require_git2 = __commonJS({
43493
43495
  "does not have write access",
43494
43496
  '"contents" permission'
43495
43497
  ];
43496
- function isGitAuthErrorMessage(error40) {
43498
+ function isGitAuthErrorMessage3(error40) {
43497
43499
  const message = error40 instanceof Error ? error40.message : String(error40 ?? "");
43498
43500
  const lower = message.toLowerCase();
43499
43501
  return exports.GIT_AUTH_ERROR_PATTERNS.some((pattern) => lower.includes(pattern));
@@ -70636,6 +70638,7 @@ var require_socketWithClientAuth = __commonJS({
70636
70638
  var util_js_1 = require_util2();
70637
70639
  var ISocketWithClientAuth3 = class extends tracedSocket_js_1.TracedSocket {
70638
70640
  authorization;
70641
+ authorizationVersion = 0;
70639
70642
  hasSentAuth = false;
70640
70643
  constructor(ws2, authorization, requestHandlers, globalMiddlewares, tracer3, options8) {
70641
70644
  super(ws2, requestHandlers, globalMiddlewares, tracer3, options8);
@@ -70643,9 +70646,12 @@ var require_socketWithClientAuth = __commonJS({
70643
70646
  }
70644
70647
  // override `request` from the base class to send `authorization` when appropriate
70645
70648
  async request(method, params) {
70649
+ const authorizationVersion = this.authorizationVersion;
70646
70650
  const authorization = this.hasSentAuth ? void 0 : this.authorization;
70647
70651
  const result = await super.request(method, params, authorization);
70648
- this.hasSentAuth = true;
70652
+ if (this.authorizationVersion === authorizationVersion) {
70653
+ this.hasSentAuth = true;
70654
+ }
70649
70655
  return result;
70650
70656
  }
70651
70657
  /**
@@ -70656,6 +70662,7 @@ var require_socketWithClientAuth = __commonJS({
70656
70662
  */
70657
70663
  setAuthorization(newAuthorization) {
70658
70664
  this.authorization = newAuthorization;
70665
+ this.authorizationVersion++;
70659
70666
  this.hasSentAuth = false;
70660
70667
  }
70661
70668
  };
@@ -78080,12 +78087,11 @@ var require_constants7 = __commonJS({
78080
78087
  "use strict";
78081
78088
  init_cjs_shims();
78082
78089
  Object.defineProperty(exports, "__esModule", { value: true });
78083
- exports.ForbiddenError = exports.BadRequestError = exports.NotFoundError = exports.FileAccessError = exports.CUSTOM_COMPONENTS_PATH = exports.ROOT_CONFIG_RELATIVE_PATH = exports.DEV_ENVIRONMENT_CONFIG_PATH = exports.RESOURCE_CONFIG_PATH = exports.TOKEN_CONFIG_PATH = exports.SUPERBLOCKS_HOME_FOLDER_NAME = void 0;
78090
+ exports.ForbiddenError = exports.BadRequestError = exports.NotFoundError = exports.FileAccessError = exports.CUSTOM_COMPONENTS_PATH = exports.DEV_ENVIRONMENT_CONFIG_PATH = exports.RESOURCE_CONFIG_PATH = exports.TOKEN_CONFIG_PATH = exports.SUPERBLOCKS_HOME_FOLDER_NAME = void 0;
78084
78091
  exports.SUPERBLOCKS_HOME_FOLDER_NAME = ".superblocks";
78085
78092
  exports.TOKEN_CONFIG_PATH = ".superblocks/auth.json";
78086
78093
  exports.RESOURCE_CONFIG_PATH = ".superblocks/superblocks.json";
78087
78094
  exports.DEV_ENVIRONMENT_CONFIG_PATH = ".superblocks/dev-environment.json";
78088
- exports.ROOT_CONFIG_RELATIVE_PATH = "../..";
78089
78095
  exports.CUSTOM_COMPONENTS_PATH = "components";
78090
78096
  var FileAccessError = class extends Error {
78091
78097
  constructor(message) {
@@ -86748,14 +86754,7 @@ var require_data_types = __commonJS({
86748
86754
  "use strict";
86749
86755
  init_cjs_shims();
86750
86756
  Object.defineProperty(exports, "__esModule", { value: true });
86751
- exports.dataTypeDefinions = exports.supportedDataTypes = void 0;
86752
- exports.isValidDataType = isValidDataType;
86753
- exports.supportedDataTypes = [
86754
- "string",
86755
- "number",
86756
- "boolean",
86757
- "any"
86758
- ];
86757
+ exports.dataTypeDefinions = void 0;
86759
86758
  exports.dataTypeDefinions = {
86760
86759
  string: {
86761
86760
  tsType: "string",
@@ -86774,9 +86773,6 @@ var require_data_types = __commonJS({
86774
86773
  prompt: "any (raw js expression)"
86775
86774
  }
86776
86775
  };
86777
- function isValidDataType(input) {
86778
- return Object.prototype.hasOwnProperty.call(exports.dataTypeDefinions, input);
86779
- }
86780
86776
  }
86781
86777
  });
86782
86778
 
@@ -97580,7 +97576,6 @@ var require_resource_configs = __commonJS({
97580
97576
  exports.getSuperblocksApplicationConfigIfExists = getSuperblocksApplicationConfigIfExists2;
97581
97577
  exports.getSuperblocksApplicationV2ConfigJson = getSuperblocksApplicationV2ConfigJson2;
97582
97578
  exports.getSuperblocksBackendConfigIfExists = getSuperblocksBackendConfigIfExists2;
97583
- exports.getSuperblocksBackendConfigJson = getSuperblocksBackendConfigJson;
97584
97579
  exports.getSuperblocksResourceConfigIfExists = getSuperblocksResourceConfigIfExists2;
97585
97580
  exports.getResourceIdFromUrl = getResourceIdFromUrl;
97586
97581
  var path_1 = __importDefault(__require("path"));
@@ -97783,20 +97778,17 @@ var require_types10 = __commonJS({
97783
97778
  "use strict";
97784
97779
  init_cjs_shims();
97785
97780
  Object.defineProperty(exports, "__esModule", { value: true });
97786
- exports.WAIT_TYPE = exports.LoopType = void 0;
97781
+ exports.LoopType = void 0;
97787
97782
  var LoopType;
97788
97783
  (function(LoopType2) {
97789
- LoopType2["FOR"] = "TYPE_FOR";
97790
97784
  LoopType2["FOR_EACH"] = "TYPE_FOREACH";
97791
- LoopType2["WHILE"] = "TYPE_WHILE";
97792
- LoopType2["UNSPECIFIED"] = "TYPE_UNSPECIFIED";
97793
97785
  })(LoopType || (exports.LoopType = LoopType = {}));
97794
97786
  var WAIT_TYPE;
97795
97787
  (function(WAIT_TYPE2) {
97796
97788
  WAIT_TYPE2["ALL"] = "WAIT_ALL";
97797
97789
  WAIT_TYPE2["ANY"] = "WAIT_NONE";
97798
97790
  WAIT_TYPE2["UNSPECIFIED"] = "WAIT_UNSPECIFIED";
97799
- })(WAIT_TYPE || (exports.WAIT_TYPE = WAIT_TYPE = {}));
97791
+ })(WAIT_TYPE || (WAIT_TYPE = {}));
97800
97792
  }
97801
97793
  });
97802
97794
 
@@ -97810,15 +97802,15 @@ var require_api_files = __commonJS({
97810
97802
  exports.readAppApiYamlFile = readAppApiYamlFile4;
97811
97803
  exports.resolveLanguageSpecificStepContentFromBlocks = resolveLanguageSpecificStepContentFromBlocks2;
97812
97804
  async function writeApiFiles3(...args) {
97813
- const esmFunction = await import("./api-GRUZLVFH.js");
97805
+ const esmFunction = await import("./api-4T55YEDE.js");
97814
97806
  return esmFunction.writeApiFiles(...args);
97815
97807
  }
97816
97808
  async function readAppApiYamlFile4(...args) {
97817
- const esmFunction = await import("./api-GRUZLVFH.js");
97809
+ const esmFunction = await import("./api-4T55YEDE.js");
97818
97810
  return esmFunction.readAppApiYamlFile(...args);
97819
97811
  }
97820
97812
  async function resolveLanguageSpecificStepContentFromBlocks2(...args) {
97821
- const esmFunction = await import("./api-GRUZLVFH.js");
97813
+ const esmFunction = await import("./api-4T55YEDE.js");
97822
97814
  return esmFunction.resolveLanguageSpecificStepContentFromBlocks(...args);
97823
97815
  }
97824
97816
  }
@@ -104506,19 +104498,19 @@ var require_getMachineId = __commonJS({
104506
104498
  if (!getMachineIdImpl) {
104507
104499
  switch (process5.platform) {
104508
104500
  case "darwin":
104509
- getMachineIdImpl = (await import("./getMachineId-darwin-GWGWAYUL.js")).getMachineId;
104501
+ getMachineIdImpl = (await import("./getMachineId-darwin-S365CT4C.js")).getMachineId;
104510
104502
  break;
104511
104503
  case "linux":
104512
- getMachineIdImpl = (await import("./getMachineId-linux-EX6OHUV7.js")).getMachineId;
104504
+ getMachineIdImpl = (await import("./getMachineId-linux-WWEC3Y6J.js")).getMachineId;
104513
104505
  break;
104514
104506
  case "freebsd":
104515
- getMachineIdImpl = (await import("./getMachineId-bsd-D3Z6NAGQ.js")).getMachineId;
104507
+ getMachineIdImpl = (await import("./getMachineId-bsd-R7FUZCBS.js")).getMachineId;
104516
104508
  break;
104517
104509
  case "win32":
104518
- getMachineIdImpl = (await import("./getMachineId-win-P2APSGTL.js")).getMachineId;
104510
+ getMachineIdImpl = (await import("./getMachineId-win-35IZOALZ.js")).getMachineId;
104519
104511
  break;
104520
104512
  default:
104521
- getMachineIdImpl = (await import("./getMachineId-unsupported-G3KKCZOP.js")).getMachineId;
104513
+ getMachineIdImpl = (await import("./getMachineId-unsupported-WZBZKWFL.js")).getMachineId;
104522
104514
  break;
104523
104515
  }
104524
104516
  }
@@ -115863,9 +115855,9 @@ var require_error2 = __commonJS({
115863
115855
  "use strict";
115864
115856
  init_cjs_shims();
115865
115857
  Object.defineProperty(exports, "__esModule", { value: true });
115866
- exports.getErrorMessage = getErrorMessage3;
115858
+ exports.getErrorMessage = getErrorMessage4;
115867
115859
  exports.getErrorCode = getErrorCode;
115868
- function getErrorMessage3(error40) {
115860
+ function getErrorMessage4(error40) {
115869
115861
  if (error40 instanceof Error) {
115870
115862
  return error40.message;
115871
115863
  } else {
@@ -165148,7 +165140,7 @@ var require_dist4 = __commonJS({
165148
165140
  TooManyEmbeddingValuesForCallError: () => TooManyEmbeddingValuesForCallError3,
165149
165141
  TypeValidationError: () => TypeValidationError3,
165150
165142
  UnsupportedFunctionalityError: () => UnsupportedFunctionalityError3,
165151
- getErrorMessage: () => getErrorMessage3,
165143
+ getErrorMessage: () => getErrorMessage4,
165152
165144
  isJSONArray: () => isJSONArray,
165153
165145
  isJSONObject: () => isJSONObject,
165154
165146
  isJSONValue: () => isJSONValue
@@ -165240,7 +165232,7 @@ var require_dist4 = __commonJS({
165240
165232
  return AISDKError3.hasMarker(error40, marker32);
165241
165233
  }
165242
165234
  };
165243
- function getErrorMessage3(error40) {
165235
+ function getErrorMessage4(error40) {
165244
165236
  if (error40 == null) {
165245
165237
  return "unknown error";
165246
165238
  }
@@ -165318,7 +165310,7 @@ var require_dist4 = __commonJS({
165318
165310
  super({
165319
165311
  name: name62,
165320
165312
  message: `JSON parsing failed: Text: ${text3}.
165321
- Error message: ${getErrorMessage3(cause)}`,
165313
+ Error message: ${getErrorMessage4(cause)}`,
165322
165314
  cause
165323
165315
  });
165324
165316
  this[_a72] = true;
@@ -165447,7 +165439,7 @@ Error message: ${getErrorMessage3(cause)}`,
165447
165439
  super({
165448
165440
  name: name122,
165449
165441
  message: `${contextPrefix}: Value: ${JSON.stringify(value2)}.
165450
- Error message: ${getErrorMessage3(cause)}`,
165442
+ Error message: ${getErrorMessage4(cause)}`,
165451
165443
  cause
165452
165444
  });
165453
165445
  this[_a132] = true;
@@ -183164,7 +183156,7 @@ var require_dist6 = __commonJS({
183164
183156
  executeTool: () => executeTool,
183165
183157
  extractResponseHeaders: () => extractResponseHeaders2,
183166
183158
  generateId: () => generateId3,
183167
- getErrorMessage: () => getErrorMessage3,
183159
+ getErrorMessage: () => getErrorMessage4,
183168
183160
  getFromApi: () => getFromApi,
183169
183161
  getRuntimeEnvironmentUserAgent: () => getRuntimeEnvironmentUserAgent2,
183170
183162
  injectJsonInstructionIntoMessages: () => injectJsonInstructionIntoMessages,
@@ -183515,7 +183507,7 @@ var require_dist6 = __commonJS({
183515
183507
  return () => `${prefix}${separator}${generator()}`;
183516
183508
  };
183517
183509
  var generateId3 = createIdGenerator3();
183518
- function getErrorMessage3(error40) {
183510
+ function getErrorMessage4(error40) {
183519
183511
  if (error40 == null) {
183520
183512
  return "unknown error";
183521
183513
  }
@@ -185721,8 +185713,8 @@ var require_get_vercel_oidc_token = __commonJS({
185721
185713
  }
185722
185714
  try {
185723
185715
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
185724
- await import("./token-util-KYTRKMAC.js"),
185725
- await import("./token-7SZNVNTK.js")
185716
+ await import("./token-util-J6V5LCAN.js"),
185717
+ await import("./token-DWAZ4JCJ.js")
185726
185718
  ]);
185727
185719
  if (!token2 || isExpired(getTokenPayload(token2))) {
185728
185720
  await refreshToken();
@@ -187377,7 +187369,7 @@ var require_dist9 = __commonJS({
187377
187369
  smoothStream: () => smoothStream2,
187378
187370
  stepCountIs: () => stepCountIs2,
187379
187371
  streamObject: () => streamObject,
187380
- streamText: () => streamText3,
187372
+ streamText: () => streamText2,
187381
187373
  systemModelMessageSchema: () => systemModelMessageSchema,
187382
187374
  tool: () => import_provider_utils39.tool,
187383
187375
  toolModelMessageSchema: () => toolModelMessageSchema,
@@ -193306,7 +193298,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
193306
193298
  prefix: "aitxt",
193307
193299
  size: 24
193308
193300
  });
193309
- function streamText3({
193301
+ function streamText2({
193310
193302
  model,
193311
193303
  tools,
193312
193304
  toolChoice,
@@ -195096,7 +195088,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
195096
195088
  onFinish,
195097
195089
  ...options8
195098
195090
  }) {
195099
- return streamText3({
195091
+ return streamText2({
195100
195092
  ...await this.prepareCall(options8),
195101
195093
  abortSignal,
195102
195094
  timeout,
@@ -470482,7 +470474,7 @@ var require_config_loader = __commonJS({
470482
470474
  * @returns {Promise<{createJiti: Function|undefined, version: string;}>} A promise that fulfills with an object containing the jiti module's createJiti function and version.
470483
470475
  */
470484
470476
  static async loadJiti() {
470485
- const { createJiti } = await import("./jiti-DGIIEVSP.js");
470477
+ const { createJiti } = await import("./jiti-ETYPYHSK.js");
470486
470478
  const version3 = require_package5().version;
470487
470479
  return { createJiti, version: version3 };
470488
470480
  }
@@ -470811,7 +470803,7 @@ var require_eslint_helpers = __commonJS({
470811
470803
  }
470812
470804
  async function globMatch({ basePath, pattern }) {
470813
470805
  let found = false;
470814
- const { hfs } = await import("./src-GNBOXZZ5.js");
470806
+ const { hfs } = await import("./src-FHUWJFLE.js");
470815
470807
  const patternToUse = normalizeToPosix(path80.relative(basePath, pattern));
470816
470808
  const matcher = new Minimatch2(patternToUse, MINIMATCH_OPTIONS);
470817
470809
  const walkSettings = {
@@ -470851,7 +470843,7 @@ var require_eslint_helpers = __commonJS({
470851
470843
  return new Minimatch2(patternToUse, MINIMATCH_OPTIONS);
470852
470844
  });
470853
470845
  const unmatchedPatterns = /* @__PURE__ */ new Set([...relativeToPatterns.keys()]);
470854
- const { hfs } = await import("./src-GNBOXZZ5.js");
470846
+ const { hfs } = await import("./src-FHUWJFLE.js");
470855
470847
  const walk2 = hfs.walk(basePath, {
470856
470848
  async directoryFilter(entry) {
470857
470849
  if (!matchers.some((matcher) => matcher.match(entry.path, true))) {
@@ -486353,7 +486345,7 @@ var require_utils34 = __commonJS({
486353
486345
  overflowChannel.set(obj, maxIndex);
486354
486346
  return obj;
486355
486347
  };
486356
- var isOverflow2 = function isOverflow3(obj) {
486348
+ var isOverflow = function isOverflow2(obj) {
486357
486349
  return overflowChannel.has(obj);
486358
486350
  };
486359
486351
  var getMaxIndex = function getMaxIndex2(obj) {
@@ -486405,7 +486397,7 @@ var require_utils34 = __commonJS({
486405
486397
  }
486406
486398
  target[nextIndex2] = source2;
486407
486399
  } else if (target && typeof target === "object") {
486408
- if (isOverflow2(target)) {
486400
+ if (isOverflow(target)) {
486409
486401
  var newIndex = getMaxIndex(target) + 1;
486410
486402
  target[newIndex] = source2;
486411
486403
  setMaxIndex(target, newIndex);
@@ -486420,7 +486412,7 @@ var require_utils34 = __commonJS({
486420
486412
  return target;
486421
486413
  }
486422
486414
  if (!target || typeof target !== "object") {
486423
- if (isOverflow2(source2)) {
486415
+ if (isOverflow(source2)) {
486424
486416
  var sourceKeys = Object.keys(source2);
486425
486417
  var result = options8 && options8.plainObjects ? { __proto__: null, 0: target } : { 0: target };
486426
486418
  for (var m2 = 0; m2 < sourceKeys.length; m2++) {
@@ -486461,10 +486453,10 @@ var require_utils34 = __commonJS({
486461
486453
  } else {
486462
486454
  acc[key2] = value2;
486463
486455
  }
486464
- if (isOverflow2(source2) && !isOverflow2(acc)) {
486456
+ if (isOverflow(source2) && !isOverflow(acc)) {
486465
486457
  markOverflow(acc, getMaxIndex(source2));
486466
486458
  }
486467
- if (isOverflow2(acc)) {
486459
+ if (isOverflow(acc)) {
486468
486460
  var keyNum = parseInt(key2, 10);
486469
486461
  if (String(keyNum) === key2 && keyNum >= 0 && keyNum > getMaxIndex(acc)) {
486470
486462
  setMaxIndex(acc, keyNum);
@@ -486565,7 +486557,7 @@ var require_utils34 = __commonJS({
486565
486557
  return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
486566
486558
  };
486567
486559
  var combine = function combine2(a, b3, arrayLimit, plainObjects) {
486568
- if (isOverflow2(a)) {
486560
+ if (isOverflow(a)) {
486569
486561
  var newIndex = getMaxIndex(a) + 1;
486570
486562
  a[newIndex] = b3;
486571
486563
  setMaxIndex(a, newIndex);
@@ -486595,7 +486587,7 @@ var require_utils34 = __commonJS({
486595
486587
  decode,
486596
486588
  encode: encode3,
486597
486589
  isBuffer: isBuffer2,
486598
- isOverflow: isOverflow2,
486590
+ isOverflow,
486599
486591
  isRegExp: isRegExp2,
486600
486592
  markOverflow,
486601
486593
  maybeMap,
@@ -531355,7 +531347,7 @@ var require_finalhandler = __commonJS({
531355
531347
  } else {
531356
531348
  headers = getErrorHeaders(err);
531357
531349
  }
531358
- msg = getErrorMessage3(err, status, env2);
531350
+ msg = getErrorMessage4(err, status, env2);
531359
531351
  } else {
531360
531352
  status = 404;
531361
531353
  msg = "Cannot " + req.method + " " + encodeUrl(getResourceName(req));
@@ -531386,7 +531378,7 @@ var require_finalhandler = __commonJS({
531386
531378
  }
531387
531379
  return headers;
531388
531380
  }
531389
- function getErrorMessage3(err, status, env2) {
531381
+ function getErrorMessage4(err, status, env2) {
531390
531382
  var msg;
531391
531383
  if (env2 !== "production") {
531392
531384
  msg = err.stack;
@@ -539260,7 +539252,7 @@ init_cjs_shims();
539260
539252
  // ../sdk/package.json
539261
539253
  var package_default = {
539262
539254
  name: "@superblocksteam/sdk",
539263
- version: "2.0.141-next.0",
539255
+ version: "2.0.141-next.1",
539264
539256
  description: "Superblocks JS SDK",
539265
539257
  homepage: "https://www.superblocks.com",
539266
539258
  license: "Superblocks Community Software License",
@@ -539617,7 +539609,7 @@ var config = void 0;
539617
539609
  var configured = false;
539618
539610
  var ddTracePromise = void 0;
539619
539611
  async function getDdTrace() {
539620
- ddTracePromise ??= import("./dd-trace-OPBAOO5R.js").then((module) => module.default);
539612
+ ddTracePromise ??= import("./dd-trace-D7QUBO7I.js").then((module) => module.default);
539621
539613
  return await ddTracePromise;
539622
539614
  }
539623
539615
  var deploymentType = (() => {
@@ -544103,7 +544095,7 @@ import path65 from "node:path";
544103
544095
  var import_fast_glob3 = __toESM(require_out4(), 1);
544104
544096
  var import_fs_extra2 = __toESM(require_lib(), 1);
544105
544097
  var import_yaml13 = __toESM(require_dist(), 1);
544106
- var import_shared79 = __toESM(require_dist2(), 1);
544098
+ var import_shared80 = __toESM(require_dist2(), 1);
544107
544099
  var import_util42 = __toESM(require_dist3(), 1);
544108
544100
  import { createLogger as createLogger3 } from "vite";
544109
544101
 
@@ -544113,7 +544105,7 @@ init_cjs_shims();
544113
544105
  // ../../../vite-plugin-file-sync/dist/ai-service/index.js
544114
544106
  init_cjs_shims();
544115
544107
  init_esm();
544116
- var import_ai11 = __toESM(require_dist9(), 1);
544108
+ var import_ai10 = __toESM(require_dist9());
544117
544109
  import { createHash as createHash5, randomUUID as randomUUID5 } from "node:crypto";
544118
544110
  import os6 from "node:os";
544119
544111
  import path52 from "node:path";
@@ -548212,6 +548204,7 @@ var MODEL_CAPABILITIES = {
548212
548204
  "claude-opus-4-5": { maxOutputTokens: 64e3 },
548213
548205
  "claude-opus-4-6": { maxOutputTokens: 128e3 },
548214
548206
  "claude-opus-4-7": { maxOutputTokens: 128e3 },
548207
+ "claude-opus-4-8": { maxOutputTokens: 128e3 },
548215
548208
  "claude-sonnet-4-5": { maxOutputTokens: 64e3 },
548216
548209
  "claude-sonnet-4-6": { maxOutputTokens: 128e3 }
548217
548210
  };
@@ -548448,6 +548441,24 @@ var AiToolExecutionErrorCode;
548448
548441
  AiToolExecutionErrorCode2["INTERNAL_ERROR"] = "tool_internal_error";
548449
548442
  })(AiToolExecutionErrorCode || (AiToolExecutionErrorCode = {}));
548450
548443
 
548444
+ // ../../../library-shared/dist/types/tool-permission-response.js
548445
+ init_cjs_shims();
548446
+ var TOOL_PERMISSION_APPROVAL_PHRASES = [
548447
+ "ok",
548448
+ "sure",
548449
+ "ya",
548450
+ "yah",
548451
+ "yes",
548452
+ "yep",
548453
+ "yup"
548454
+ ];
548455
+ function isToolPermissionApprovalText(text3) {
548456
+ return TOOL_PERMISSION_APPROVAL_PHRASES.includes(text3.trim().toLowerCase());
548457
+ }
548458
+ function isToolPermissionClarification(approved, denyMessage) {
548459
+ return !approved && Boolean(denyMessage?.trim()) && !isToolPermissionApprovalText(denyMessage);
548460
+ }
548461
+
548451
548462
  // ../../../library-shared/dist/types/apis.js
548452
548463
  init_cjs_shims();
548453
548464
 
@@ -548552,7 +548563,7 @@ init_cjs_shims();
548552
548563
  init_cjs_shims();
548553
548564
 
548554
548565
  // ../../../vite-plugin-file-sync/dist/ai-service/index.js
548555
- var import_shared54 = __toESM(require_dist2(), 1);
548566
+ var import_shared55 = __toESM(require_dist2());
548556
548567
 
548557
548568
  // ../../../vite-plugin-file-sync/dist/migration/translation-prompt.js
548558
548569
  init_cjs_shims();
@@ -563563,7 +563574,7 @@ function createClark(options8 = {
563563
563574
  // ../../../clark/dist/thinking-options.js
563564
563575
  init_cjs_shims();
563565
563576
  var INTERLEAVED_THINKING_BETA = "interleaved-thinking-2025-05-14";
563566
- var ADAPTIVE_EFFORT_MODELS = /* @__PURE__ */ new Set(["claude-opus-4-7"]);
563577
+ var ADAPTIVE_EFFORT_MODELS = /* @__PURE__ */ new Set(["claude-opus-4-7", "claude-opus-4-8"]);
563567
563578
  var HARDCODED_EFFORT = "high";
563568
563579
  function usesAdaptiveEffort(coreModel) {
563569
563580
  return coreModel !== void 0 && ADAPTIVE_EFFORT_MODELS.has(coreModel);
@@ -564962,6 +564973,60 @@ var getEnclosingApiExportName = (path80) => {
564962
564973
  }
564963
564974
  return void 0;
564964
564975
  };
564976
+ var topLevelApiExportName = (node) => {
564977
+ if (t.isExportNamedDeclaration(node) && node.declaration && t.isVariableDeclaration(node.declaration)) {
564978
+ for (const declarator of node.declaration.declarations) {
564979
+ if (t.isIdentifier(declarator.id) && t.isCallExpression(declarator.init) && t.isIdentifier(declarator.init.callee) && declarator.init.callee.name === "api") {
564980
+ return declarator.id.name;
564981
+ }
564982
+ }
564983
+ }
564984
+ if (t.isExportDefaultDeclaration(node) && t.isCallExpression(node.declaration) && t.isIdentifier(node.declaration.callee) && node.declaration.callee.name === "api") {
564985
+ return "default";
564986
+ }
564987
+ return void 0;
564988
+ };
564989
+ var extractApiExportSources = (source2) => {
564990
+ let ast;
564991
+ try {
564992
+ ast = (0, import_parser2.parse)(source2, {
564993
+ sourceType: "module",
564994
+ plugins: ["typescript"],
564995
+ errorRecovery: true
564996
+ });
564997
+ } catch {
564998
+ return null;
564999
+ }
565000
+ const exportSources = /* @__PURE__ */ new Map();
565001
+ const sharedNodes = [];
565002
+ for (const node of ast.program.body) {
565003
+ const exportName = topLevelApiExportName(node);
565004
+ if (exportName) {
565005
+ exportSources.set(exportName, generate(node).code);
565006
+ } else {
565007
+ sharedNodes.push(node);
565008
+ }
565009
+ }
565010
+ const sharedSource = sharedNodes.map((node) => generate(node).code).join("\n");
565011
+ return { exportSources, sharedSource };
565012
+ };
565013
+ var detectChangedApiExports = (previousSource, nextSource) => {
565014
+ const previous = extractApiExportSources(previousSource);
565015
+ const next2 = extractApiExportSources(nextSource);
565016
+ if (!previous || !next2) {
565017
+ return { changedExportNames: /* @__PURE__ */ new Set(), canScope: false };
565018
+ }
565019
+ if (previous.sharedSource !== next2.sharedSource) {
565020
+ return { changedExportNames: /* @__PURE__ */ new Set(), canScope: false };
565021
+ }
565022
+ const changedExportNames = /* @__PURE__ */ new Set();
565023
+ for (const [exportName, code] of next2.exportSources) {
565024
+ if (previous.exportSources.get(exportName) !== code) {
565025
+ changedExportNames.add(exportName);
565026
+ }
565027
+ }
565028
+ return { changedExportNames, canScope: true };
565029
+ };
564965
565030
  var extractMutations = (source2, exportName) => {
564966
565031
  const mutations = [];
564967
565032
  const jsStepNames = extractStepNames(source2);
@@ -565696,7 +565761,7 @@ var MAX_ATTRIBUTE_LENGTH = 64e3;
565696
565761
  var LLMObsSpanWriter = null;
565697
565762
  async function loadLLMObsSpanWriter() {
565698
565763
  if (!LLMObsSpanWriter) {
565699
- const module = await import("./spans-DHM7DAAH.js");
565764
+ const module = await import("./spans-DJ6DK2RF.js");
565700
565765
  LLMObsSpanWriter = module.default;
565701
565766
  }
565702
565767
  return LLMObsSpanWriter;
@@ -574798,6 +574863,16 @@ var RESOLUTION_EXTENSIONS = [".ts", ".tsx", ".js"];
574798
574863
  async function parseSdkRegistryEntryPoints(registryContent, pathExists6) {
574799
574864
  return parseSdkRegistryFromContent(registryContent, (importPath) => resolveImportPath(importPath, pathExists6));
574800
574865
  }
574866
+ async function parseSdkRegistryExportNames(registryContent, pathExists6) {
574867
+ const entries = await parseSdkRegistryEntries(registryContent, (importPath) => resolveImportPath(importPath, pathExists6));
574868
+ const exportNames = /* @__PURE__ */ new Map();
574869
+ for (const [apiName, entry] of entries) {
574870
+ if (entry.exportName) {
574871
+ exportNames.set(apiName, entry.exportName);
574872
+ }
574873
+ }
574874
+ return exportNames;
574875
+ }
574801
574876
  async function readSdkRegistryEntryPoints(fs39) {
574802
574877
  try {
574803
574878
  if (!await fs39.pathExists(SDK_REGISTRY_PATH)) {
@@ -574862,10 +574937,14 @@ async function ensureRegistryCache(clark, services) {
574862
574937
  } catch {
574863
574938
  }
574864
574939
  const entryPoints = await parseSdkRegistryEntryPoints(content18, pathExists6);
574865
- clark.updateContext({ sdkApiRegistryEntryPoints: entryPoints });
574940
+ const exportNames = await parseSdkRegistryExportNames(content18, pathExists6);
574941
+ clark.updateContext({
574942
+ sdkApiRegistryEntryPoints: entryPoints,
574943
+ sdkApiRegistryExportNames: exportNames
574944
+ });
574866
574945
  return entryPoints;
574867
574946
  }
574868
- async function markSdkApiAsUntestedIfNeeded(filePath, clark, services) {
574947
+ async function markSdkApiAsUntestedIfNeeded(filePath, clark, services, editContents) {
574869
574948
  if (!services.features?.sdkApiEnabled) {
574870
574949
  return;
574871
574950
  }
@@ -574883,7 +574962,11 @@ async function markSdkApiAsUntestedIfNeeded(filePath, clark, services) {
574883
574962
  } catch {
574884
574963
  }
574885
574964
  const newEntryPoints = await parseSdkRegistryEntryPoints(newContent, pathExists6);
574886
- clark.updateContext({ sdkApiRegistryEntryPoints: newEntryPoints });
574965
+ const newExportNames = await parseSdkRegistryExportNames(newContent, pathExists6);
574966
+ clark.updateContext({
574967
+ sdkApiRegistryEntryPoints: newEntryPoints,
574968
+ sdkApiRegistryExportNames: newExportNames
574969
+ });
574887
574970
  const apiNamesToMark = Array.from(newEntryPoints.entries()).filter(([name16, ep]) => previousEntryPoints.get(name16) !== ep).map(([name16]) => name16);
574888
574971
  const apiNamesToRemove = Array.from(previousEntryPoints.keys()).filter((name16) => !newEntryPoints.has(name16));
574889
574972
  removeApis(clark, apiNamesToRemove);
@@ -574895,12 +574978,13 @@ async function markSdkApiAsUntestedIfNeeded(filePath, clark, services) {
574895
574978
  }
574896
574979
  const directlyAffected = Array.from(previousEntryPoints.entries()).filter(([, ep]) => ep === filePath).map(([name16]) => name16);
574897
574980
  if (directlyAffected.length > 0) {
574898
- markApis(clark, directlyAffected);
574981
+ const scoped = scopeToChangedApis(directlyAffected, clark.context.sdkApiRegistryExportNames, editContents);
574982
+ markApis(clark, scoped.apiNames, { forceRetest: scoped.forceRetest });
574899
574983
  return;
574900
574984
  }
574901
574985
  const scopedApis = Array.from(previousEntryPoints.entries()).filter(([, ep]) => filePath.startsWith(entryPointScope(ep))).map(([name16]) => name16);
574902
574986
  if (scopedApis.length > 0) {
574903
- markApis(clark, scopedApis);
574987
+ markApis(clark, scopedApis, { forceRetest: true });
574904
574988
  }
574905
574989
  }
574906
574990
  function entryPointScope(entryPoint) {
@@ -574910,6 +574994,23 @@ function entryPointScope(entryPoint) {
574910
574994
  }
574911
574995
  return withoutExt + "/";
574912
574996
  }
574997
+ function scopeToChangedApis(apiNames, exportNames, editContents) {
574998
+ if (!editContents || !exportNames) {
574999
+ return { apiNames, forceRetest: true };
575000
+ }
575001
+ const { changedExportNames, canScope } = detectChangedApiExports(editContents.previous, editContents.next);
575002
+ if (!canScope) {
575003
+ return { apiNames, forceRetest: true };
575004
+ }
575005
+ if (apiNames.some((apiName) => !exportNames.get(apiName))) {
575006
+ return { apiNames, forceRetest: true };
575007
+ }
575008
+ return {
575009
+ apiNames: apiNames.filter((apiName) => changedExportNames.has(exportNames.get(apiName))),
575010
+ // Attributed changes must retest even if the API already passed.
575011
+ forceRetest: true
575012
+ };
575013
+ }
574913
575014
  function markApis(clark, apiNames, options8) {
574914
575015
  if (apiNames.length === 0) {
574915
575016
  return;
@@ -574924,7 +575025,7 @@ function markApis(clark, apiNames, options8) {
574924
575025
  denied.delete(apiName);
574925
575026
  } else if (denied.has(apiName)) {
574926
575027
  continue;
574927
- } else if (passed.has(apiName)) {
575028
+ } else if (!options8?.forceRetest && passed.has(apiName)) {
574928
575029
  continue;
574929
575030
  }
574930
575031
  untested.add(apiName);
@@ -596816,9 +596917,11 @@ function selectContextManagementStrategy(options8) {
596816
596917
  }
596817
596918
  };
596818
596919
  }
596920
+ const { model, providerConfig } = options8.summarizeModel();
596819
596921
  return {
596820
596922
  type: "client",
596821
- summarizationModel: options8.summarizationModel()
596923
+ summarizationModel: model,
596924
+ summarizationProviderConfig: providerConfig
596822
596925
  };
596823
596926
  }
596824
596927
  var BEDROCK_CONTEXT_MANAGEMENT_BETAS = [
@@ -596933,14 +597036,6 @@ function getTotalInputTokens(usage) {
596933
597036
  function computeContextUsed(usage) {
596934
597037
  return getTotalInputTokens(usage);
596935
597038
  }
596936
- function getTotalTokens(usage) {
596937
- const recomputedTotal = getTotalInputTokens(usage) + (usage.outputTokens ?? 0);
596938
- const hasDetailedBreakdown = usage.inputTokenDetails?.noCacheTokens !== void 0 || usage.inputTokenDetails?.cacheReadTokens !== void 0 || usage.inputTokenDetails?.cacheWriteTokens !== void 0;
596939
- if (hasDetailedBreakdown) {
596940
- return recomputedTotal;
596941
- }
596942
- return usage.totalTokens ?? recomputedTotal;
596943
- }
596944
597039
 
596945
597040
  // ../../../vite-plugin-file-sync/dist/ai-service/util/llm-config-utils.js
596946
597041
  init_cjs_shims();
@@ -597664,6 +597759,9 @@ var Clark = class _Clark extends TracedFSM {
597664
597759
  // markSdkApiAsUntestedIfNeeded can diff against the previous state
597665
597760
  // instead of treating every API as newly added.
597666
597761
  sdkApiRegistryEntryPoints: ctx.sdkApiRegistryEntryPoints,
597762
+ // ENG-4547: preserve the cached export names so that edited-file diffs
597763
+ // can be attributed to the correct API across resets.
597764
+ sdkApiRegistryExportNames: ctx.sdkApiRegistryExportNames,
597667
597765
  // APPS-4080: preserve credit-paywall pause state across resets so
597668
597766
  // the resume hint can fire on the next user prompt. Without this,
597669
597767
  // the mid-stream paywall path (LLM_ERRORED -> AGENT_CANCELED ->
@@ -597776,7 +597874,7 @@ var Clark = class _Clark extends TracedFSM {
597776
597874
  const model = providedModel ?? services.llmProvider.modelForTask("generateBroadEdit").model;
597777
597875
  const contextManagement = selectContextManagementStrategy({
597778
597876
  serverContextManagementEnabled: this.context.llmConfig?.serverContextManagement?.enabled,
597779
- summarizationModel: () => services.llmProvider.modelForTask("summarizeMessages").model
597877
+ summarizeModel: () => services.llmProvider.modelForTask("summarizeMessages")
597780
597878
  });
597781
597879
  const { thinkingEnabled, thinkingBudgetTokens, interleavedThinking, maxOutputTokens, headers, providerOptions } = processLLMConfig(this.context.llmConfig, void 0, void 0, contextManagement);
597782
597880
  const thinking = streamOptions.thinking ?? {
@@ -600300,6 +600398,11 @@ var buildWriteFileToolFactory = createToolFactory("build_writeFile", ({ clark, s
600300
600398
  content: zod_default.string().describe("Content to write to the file")
600301
600399
  }),
600302
600400
  execute: async ({ filePath, content: content18 }) => {
600401
+ let previousContent = "";
600402
+ try {
600403
+ previousContent = await services.appShell.readFile(filePath);
600404
+ } catch {
600405
+ }
600303
600406
  await services.appShell.writeFile(filePath, content18);
600304
600407
  debugCache.invalidateTypeScript();
600305
600408
  clark.updateContext({
@@ -600308,7 +600411,10 @@ var buildWriteFileToolFactory = createToolFactory("build_writeFile", ({ clark, s
600308
600411
  });
600309
600412
  debugCache.invalidateContextErrors();
600310
600413
  try {
600311
- await markSdkApiAsUntestedIfNeeded(filePath, clark, services);
600414
+ await markSdkApiAsUntestedIfNeeded(filePath, clark, services, {
600415
+ previous: previousContent,
600416
+ next: content18
600417
+ });
600312
600418
  } catch {
600313
600419
  }
600314
600420
  const typeCheckFunction = createTypeScriptCheckFunction(services.appShell, clark.context.abortController?.signal);
@@ -601136,7 +601242,10 @@ var buildEditFileToolFactory = createToolFactory("build_editFile", ({ clark, ser
601136
601242
  });
601137
601243
  debugCache.invalidateContextErrors();
601138
601244
  try {
601139
- await markSdkApiAsUntestedIfNeeded(filePath, clark, services);
601245
+ await markSdkApiAsUntestedIfNeeded(filePath, clark, services, {
601246
+ previous: contentOld,
601247
+ next: contentNew
601248
+ });
601140
601249
  } catch {
601141
601250
  }
601142
601251
  const typeCheckFunction2 = createTypeScriptCheckFunction(services.appShell, clark.context.abortController?.signal);
@@ -601171,7 +601280,10 @@ var buildEditFileToolFactory = createToolFactory("build_editFile", ({ clark, ser
601171
601280
  });
601172
601281
  debugCache.invalidateContextErrors();
601173
601282
  try {
601174
- await markSdkApiAsUntestedIfNeeded(filePath, clark, services);
601283
+ await markSdkApiAsUntestedIfNeeded(filePath, clark, services, {
601284
+ previous: contentOld,
601285
+ next: contentNew
601286
+ });
601175
601287
  } catch {
601176
601288
  }
601177
601289
  const typeCheckFunction = createTypeScriptCheckFunction(services.appShell, clark.context.abortController?.signal);
@@ -601343,7 +601455,10 @@ var buildMultiEditFileToolFactory = createToolFactory("build_multiEditFile", ({
601343
601455
  });
601344
601456
  debugCache.invalidateContextErrors();
601345
601457
  try {
601346
- await markSdkApiAsUntestedIfNeeded(filePath, clark, services);
601458
+ await markSdkApiAsUntestedIfNeeded(filePath, clark, services, {
601459
+ previous: contentOriginal,
601460
+ next: contentCurrent
601461
+ });
601347
601462
  } catch {
601348
601463
  }
601349
601464
  const typeCheckFunction = createTypeScriptCheckFunction(services.appShell, clark.context.abortController?.signal);
@@ -609454,7 +609569,7 @@ function isTaskAccessibleTo(task, callerUserId) {
609454
609569
  // ../../../vite-plugin-file-sync/dist/ai-service/agent/tools2/tools/check-task.js
609455
609570
  var checkTaskToolFactory = createToolFactory("checkTask", ({ services }) => {
609456
609571
  return {
609457
- description: "PREFERRED way to inspect a background task. Returns the current state of the task by id INSTANTLY (no waiting). Use this whenever you started a background task earlier and want to know whether it's done before relying on its result \u2014 including the very next step where you need the result. If state='completed', the result is included. If state='running', keep doing other useful work and call checkTask again later. Use `waitForTask` ONLY when you've exhausted other useful work and are blocked.",
609572
+ description: "PREFERRED way to inspect a background task. Returns the current state of the task by id INSTANTLY (no waiting). Use this whenever you started a background task earlier and want to know whether it's done before relying on its result \u2014 including the very next step where you need the result. If state='completed', the result is included. If state='running', keep doing other useful work and call checkTask again later. Use `waitForTask` ONLY when you've exhausted other useful work and are blocked. If the result includes an integrationId, use it only for tool inputs or generated source code; do not repeat internal UUIDs in user-facing chat.",
609458
609573
  category: ToolCategory.GENERAL,
609459
609574
  defaultPermission: PermissionLevel.ALLOW,
609460
609575
  readOnly: true,
@@ -609469,10 +609584,9 @@ var checkTaskToolFactory = createToolFactory("checkTask", ({ services }) => {
609469
609584
  if (!isTaskAccessibleTo(task, services.getCurrentOwnerId?.())) {
609470
609585
  throw new Error(`unknown task: ${taskId}`);
609471
609586
  }
609472
- const summary = services.taskStore.summarize(task);
609473
609587
  return {
609474
- ...summary,
609475
- result: task.state === "completed" ? task.result : void 0
609588
+ ...services.taskStore.summarize(task),
609589
+ result: task.state === "completed" && task.result !== void 0 ? task.result : void 0
609476
609590
  };
609477
609591
  }
609478
609592
  };
@@ -609709,7 +609823,7 @@ function isTimeoutOrAbortError(err) {
609709
609823
  }
609710
609824
  var waitForTaskToolFactory = createToolFactory("waitForTask", ({ services }) => {
609711
609825
  return {
609712
- description: "LAST RESORT for background tasks. BLOCKS your current turn until the task leaves running or the timeout fires, defeating the whole point of running it in the background. Prefer `checkTask` (instant, non-blocking) and do other useful work in between. ONLY call waitForTask when (a) checkTask reports state='running', (b) you literally cannot make progress without the task's result, AND (c) there is no other useful work left to do this turn. On timeout, returns the latest running snapshot with `timedOut: true`.",
609826
+ description: "LAST RESORT for background tasks. BLOCKS your current turn until the task leaves running or the timeout fires, defeating the whole point of running it in the background. Prefer `checkTask` (instant, non-blocking) and do other useful work in between. ONLY call waitForTask when (a) checkTask reports state='running', (b) you literally cannot make progress without the task's result, AND (c) there is no other useful work left to do this turn. On timeout, returns the latest running snapshot with `timedOut: true`. If the result includes an integrationId, use it only for tool inputs or generated source code; do not repeat internal UUIDs in user-facing chat.",
609713
609827
  category: ToolCategory.GENERAL,
609714
609828
  defaultPermission: PermissionLevel.ALLOW,
609715
609829
  readOnly: true,
@@ -609734,10 +609848,12 @@ var waitForTaskToolFactory = createToolFactory("waitForTask", ({ services }) =>
609734
609848
  }
609735
609849
  try {
609736
609850
  const terminal = await services.taskStore.waitFor(taskId, timeoutMs, options8.abortSignal);
609737
- const snapshot = services.taskStore.summarize(services.taskStore.get(taskId));
609851
+ const task2 = services.taskStore.get(taskId);
609852
+ const snapshot = services.taskStore.summarize(task2);
609853
+ const terminalResult = terminal.result;
609738
609854
  return {
609739
609855
  ...snapshot,
609740
- result: terminal.state === "completed" ? terminal.result : void 0,
609856
+ result: terminal.state === "completed" && terminalResult !== void 0 ? terminalResult : void 0,
609741
609857
  timedOut: false
609742
609858
  };
609743
609859
  } catch (err) {
@@ -610600,7 +610716,7 @@ var provisionDevDatabaseTaskMetadata = {
610600
610716
  // dev environment name are platform-controlled, so they're not in the
610601
610717
  // input. BG wrapping (taskId, don't waitForTask, check first) is the
610602
610718
  // only behavioral delta from master.
610603
- description: "Create or reuse a lifecycle-managed dev database binding for this application on Amazon RDS as a BACKGROUND TASK. Clark provisions the database and returns lifecycle progress. Returns a taskId IMMEDIATELY while RDS provisioning runs in the background; the user already sees live progress in the chat's background-tasks indicator. DO NOT call waitForTask right after this \u2014 that defeats the whole point of a background task and blocks your turn for minutes while RDS spins up. Instead: keep working on whatever does NOT depend on the database (scaffold the UI, draft API code that will use the binding, write or read SQL migration files, plan next steps). When you reach a step that genuinely cannot proceed without the connection details, FIRST call checkTask({ taskId }) \u2014 it returns instantly. Only fall back to waitForTask if checkTask still reports state='running' AND you literally have no other useful work to do. On completion the result includes bindingKey, lifecycleState, integrationId, connectionMetadata, and credentialRefs. This task ONLY creates the database server + an integration; it does NOT apply SQL migrations \u2014 query attempts will fail with `relation \"X\" does not exist` until you call startApplyDevDatabaseMigrations. Cancellation only stops local polling; the underlying RDS provisioning continues on the server.",
610719
+ description: "Create or reuse a lifecycle-managed dev database binding for this application on Amazon RDS as a BACKGROUND TASK. Clark provisions the database and returns lifecycle progress. Returns a taskId IMMEDIATELY while RDS provisioning runs in the background; the user already sees live progress in the chat's background-tasks indicator. DO NOT call waitForTask right after this \u2014 that defeats the whole point of a background task and blocks your turn for minutes while RDS spins up. Instead: keep working on whatever does NOT depend on the database (scaffold the UI, draft API code that will use the binding, write or read SQL migration files, plan next steps). When you reach a step that genuinely cannot proceed without the connection details, FIRST call checkTask({ taskId }) \u2014 it returns instantly. Only fall back to waitForTask if checkTask still reports state='running' AND you literally have no other useful work to do. On completion the result includes bindingKey, integrationId, lifecycleState, connectionMetadata, and credentialRefs. Use integrationId only for tool inputs or generated source code such as postgres(...); do not repeat internal UUIDs in user-facing chat. This task ONLY creates the database server + an integration; it does NOT apply SQL migrations \u2014 query attempts will fail with `relation \"X\" does not exist` until you call startApplyDevDatabaseMigrations. Cancellation only stops local polling; the underlying RDS provisioning continues on the server.",
610604
610720
  externalHandleSchema: provisionHandleSchema,
610605
610721
  inputSchema: provisionInputSchema,
610606
610722
  name: "provisionDatabase",
@@ -626481,7 +626597,7 @@ Read existing knowledge before drafting new entries, and avoid duplicates unless
626481
626597
 
626482
626598
  // ../../../vite-plugin-file-sync/dist/ai-service/agent/tools2/tools/git.js
626483
626599
  init_cjs_shims();
626484
- var import_shared41 = __toESM(require_dist2());
626600
+ var import_shared42 = __toESM(require_dist2());
626485
626601
 
626486
626602
  // ../../../vite-plugin-file-sync/dist/git-operation-lock.js
626487
626603
  init_cjs_shims();
@@ -631561,6 +631677,7 @@ init_git_response_error();
631561
631677
  var simpleGit = gitInstanceFactory;
631562
631678
 
631563
631679
  // ../../../vite-plugin-file-sync/dist/git-service/index.js
631680
+ var import_shared41 = __toESM(require_dist2(), 1);
631564
631681
  function createGitService(cwd) {
631565
631682
  const git = simpleGit(cwd, {
631566
631683
  unsafe: { allowUnsafeCredentialHelper: true }
@@ -631691,7 +631808,7 @@ function createGitService(cwd) {
631691
631808
  function classifyGitError(error40) {
631692
631809
  const message = extractMessage(error40);
631693
631810
  const lower = message.toLowerCase();
631694
- if (lower.includes("authentication failed") || lower.includes("could not read username") || lower.includes("invalid credentials")) {
631811
+ if ((0, import_shared41.isGitAuthErrorMessage)(message)) {
631695
631812
  getLogger3().warn("[git] auth failure classified", {
631696
631813
  gitCategory: "setup",
631697
631814
  gitOperation: "classify-error",
@@ -631826,13 +631943,13 @@ var gitInputSchema = external_exports.object({
631826
631943
  }
631827
631944
  }
631828
631945
  });
631829
- var REMOTE_LIVE_BRANCH = `origin/${import_shared41.SUPERBLOCKS_LIVE_GIT_BRANCH}`;
631830
- var GIT_DESCRIPTION = `Run a git operation in the repository. All work happens on the ${import_shared41.SUPERBLOCKS_LIVE_GIT_BRANCH} branch. Use status for working tree and sync state; log for recent commits on ${import_shared41.SUPERBLOCKS_LIVE_GIT_BRANCH}; log_from_main to fetch and list commits on the default branch (origin/main) \u2014 use this to get commit SHAs for deploy; diff for changes (unstaged or staged); stage to stage paths; commit to stage all, commit with a message, and push to ${REMOTE_LIVE_BRANCH}; merge_abort to abort an in-progress merge; pull to fetch and merge ${REMOTE_LIVE_BRANCH} and sync; create_pr to generate a GitHub "new pull request" URL \u2014 always show the returned prUrl as a clickable markdown link so the user can open it (provide title and body you generate from the session context); deploy to build and deploy a specific commit from the main/default branch (requires the full SHA from log_from_main \u2014 the SHA MUST be a commit directly on main, not a commit from a feature branch; always use log_from_main first to get the correct SHA). If commit reports pushed=false with a non-fast-forward error, use pull to merge remote changes (resolving any conflicts), then commit again.`;
631946
+ var REMOTE_LIVE_BRANCH = `origin/${import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH}`;
631947
+ var GIT_DESCRIPTION = `Run a git operation in the repository. All work happens on the ${import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH} branch. Use status for working tree and sync state; log for recent commits on ${import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH}; log_from_main to fetch and list commits on the default branch (origin/main) \u2014 use this to get commit SHAs for deploy; diff for changes (unstaged or staged); stage to stage paths; commit to stage all, commit with a message, and push to ${REMOTE_LIVE_BRANCH}; merge_abort to abort an in-progress merge; pull to fetch and merge ${REMOTE_LIVE_BRANCH} and sync; create_pr to generate a GitHub "new pull request" URL \u2014 always show the returned prUrl as a clickable markdown link so the user can open it (provide title and body you generate from the session context); deploy to build and deploy a specific commit from the main/default branch (requires the full SHA from log_from_main \u2014 the SHA MUST be a commit directly on main, not a commit from a feature branch; always use log_from_main first to get the correct SHA). If commit reports pushed=false with a non-fast-forward error, use pull to merge remote changes (resolving any conflicts), then commit again.`;
631831
631948
  function getGitToolInputFields(input) {
631832
631949
  switch (input.operation) {
631833
631950
  case "commit":
631834
631951
  return {
631835
- gitBranch: import_shared41.SUPERBLOCKS_LIVE_GIT_BRANCH,
631952
+ gitBranch: import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH,
631836
631953
  gitMessageLength: input.message?.length ?? 0
631837
631954
  };
631838
631955
  case "diff":
@@ -631849,7 +631966,7 @@ function getGitToolInputFields(input) {
631849
631966
  };
631850
631967
  case "pull":
631851
631968
  return {
631852
- gitBranch: import_shared41.SUPERBLOCKS_LIVE_GIT_BRANCH,
631969
+ gitBranch: import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH,
631853
631970
  gitRemoteRef: REMOTE_LIVE_BRANCH
631854
631971
  };
631855
631972
  case "stage":
@@ -631858,7 +631975,7 @@ function getGitToolInputFields(input) {
631858
631975
  };
631859
631976
  case "create_pr":
631860
631977
  return {
631861
- gitBranch: import_shared41.SUPERBLOCKS_LIVE_GIT_BRANCH,
631978
+ gitBranch: import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH,
631862
631979
  gitHasTitle: !!input.title,
631863
631980
  gitHasBody: !!input.body
631864
631981
  };
@@ -631970,7 +632087,7 @@ function getActionNameForOp(input) {
631970
632087
  function formatInputForOp(input) {
631971
632088
  switch (input.operation) {
631972
632089
  case "commit":
631973
- return { targets: [import_shared41.SUPERBLOCKS_LIVE_GIT_BRANCH], details: input.message };
632090
+ return { targets: [import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH], details: input.message };
631974
632091
  case "stage":
631975
632092
  return { targets: input.paths ?? [] };
631976
632093
  case "pull":
@@ -631979,7 +632096,7 @@ function formatInputForOp(input) {
631979
632096
  return { targets: [] };
631980
632097
  case "create_pr":
631981
632098
  return {
631982
- targets: [import_shared41.SUPERBLOCKS_LIVE_GIT_BRANCH],
632099
+ targets: [import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH],
631983
632100
  summary: input.title
631984
632101
  };
631985
632102
  case "deploy":
@@ -631997,7 +632114,7 @@ async function getStatusSyncCounts(args) {
631997
632114
  const { gitService, logger: logger25 } = args;
631998
632115
  const syncCounts = await getSyncCountsAgainstDefaultBranch({
631999
632116
  gitService,
632000
- leftRef: import_shared41.SUPERBLOCKS_LIVE_GIT_BRANCH
632117
+ leftRef: import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH
632001
632118
  });
632002
632119
  if ("degraded" in syncCounts) {
632003
632120
  logger25.info("[git] tool status base ref missing; defaulting ahead/behind to 0", {
@@ -632005,7 +632122,7 @@ async function getStatusSyncCounts(args) {
632005
632122
  gitOperation: "status",
632006
632123
  gitOutcome: "degraded",
632007
632124
  gitErrorKind: "default_branch_ref_missing",
632008
- branch: import_shared41.SUPERBLOCKS_LIVE_GIT_BRANCH,
632125
+ branch: import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH,
632009
632126
  gitBaseRefCandidates: syncCounts.baseRefCandidates
632010
632127
  });
632011
632128
  }
@@ -632014,7 +632131,7 @@ async function getStatusSyncCounts(args) {
632014
632131
  async function getRepositoryWebUrl(gitService) {
632015
632132
  try {
632016
632133
  const remoteUrl = (await gitService.raw(["remote", "get-url", "origin"])).trim();
632017
- return (0, import_shared41.gitRemoteUrlToWeb)(remoteUrl) ?? void 0;
632134
+ return (0, import_shared42.gitRemoteUrlToWeb)(remoteUrl) ?? void 0;
632018
632135
  } catch {
632019
632136
  return void 0;
632020
632137
  }
@@ -632080,7 +632197,7 @@ var gitToolFactory = createToolFactory("git", (deps) => ({
632080
632197
  sha: entry.hash,
632081
632198
  message: entry.message,
632082
632199
  ...repositoryWebUrl ? {
632083
- url: (0, import_shared41.getCommitUrlForHash)({
632200
+ url: (0, import_shared42.getCommitUrlForHash)({
632084
632201
  hash: entry.hash,
632085
632202
  repositoryWebUrl
632086
632203
  }) ?? void 0
@@ -632110,7 +632227,7 @@ var gitToolFactory = createToolFactory("git", (deps) => ({
632110
632227
  sha: hash3,
632111
632228
  message,
632112
632229
  ...repositoryWebUrl ? {
632113
- url: (0, import_shared41.getCommitUrlForHash)({
632230
+ url: (0, import_shared42.getCommitUrlForHash)({
632114
632231
  hash: hash3,
632115
632232
  repositoryWebUrl
632116
632233
  }) ?? void 0
@@ -632157,19 +632274,19 @@ var gitToolFactory = createToolFactory("git", (deps) => ({
632157
632274
  "ls-remote",
632158
632275
  "--heads",
632159
632276
  "origin",
632160
- `refs/heads/${import_shared41.SUPERBLOCKS_LIVE_GIT_BRANCH}`
632277
+ `refs/heads/${import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH}`
632161
632278
  ]);
632162
- remoteExists = refs.includes(`refs/heads/${import_shared41.SUPERBLOCKS_LIVE_GIT_BRANCH}`);
632279
+ remoteExists = refs.includes(`refs/heads/${import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH}`);
632163
632280
  } catch {
632164
632281
  }
632165
632282
  try {
632166
- await gitService.push("origin", import_shared41.SUPERBLOCKS_LIVE_GIT_BRANCH);
632283
+ await gitService.push("origin", import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH);
632167
632284
  } catch (pushError) {
632168
632285
  if (remoteExists === false) {
632169
632286
  await gitService.raw([
632170
632287
  "push",
632171
632288
  "origin",
632172
- `HEAD:${import_shared41.SUPERBLOCKS_LIVE_GIT_BRANCH}`
632289
+ `HEAD:${import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH}`
632173
632290
  ]);
632174
632291
  return;
632175
632292
  }
@@ -632202,7 +632319,7 @@ var gitToolFactory = createToolFactory("git", (deps) => ({
632202
632319
  sha,
632203
632320
  pushed,
632204
632321
  ...repositoryWebUrl ? {
632205
- url: (0, import_shared41.getCommitUrlForHash)({
632322
+ url: (0, import_shared42.getCommitUrlForHash)({
632206
632323
  hash: sha,
632207
632324
  repositoryWebUrl
632208
632325
  }) ?? void 0
@@ -632254,7 +632371,7 @@ var gitToolFactory = createToolFactory("git", (deps) => ({
632254
632371
  }
632255
632372
  case "create_pr": {
632256
632373
  const remoteUrl = (await gitService.raw(["remote", "get-url", "origin"])).trim();
632257
- if (!(0, import_shared41.isGitHubUrl)(remoteUrl)) {
632374
+ if (!(0, import_shared42.isGitHubUrl)(remoteUrl)) {
632258
632375
  throw new ToolExecutionError("Cannot create a pull request URL: only GitHub repositories are supported.", {
632259
632376
  toolName: "git",
632260
632377
  input: { operation: "create_pr" },
@@ -632263,9 +632380,9 @@ var gitToolFactory = createToolFactory("git", (deps) => ({
632263
632380
  });
632264
632381
  }
632265
632382
  const defaultBranch = await gitService.getDefaultBranch();
632266
- const prUrl = (0, import_shared41.getGitHubCompareUrl)({
632383
+ const prUrl = (0, import_shared42.getGitHubCompareUrl)({
632267
632384
  gitRemoteUrl: remoteUrl,
632268
- fromBranch: import_shared41.SUPERBLOCKS_LIVE_GIT_BRANCH,
632385
+ fromBranch: import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH,
632269
632386
  toBranch: defaultBranch,
632270
632387
  title: input.title,
632271
632388
  body: input.body
@@ -632430,7 +632547,7 @@ var gitToolFactory = createToolFactory("git", (deps) => ({
632430
632547
  deployed: false,
632431
632548
  sha: fullSha,
632432
632549
  stage: "validation",
632433
- error: `Commit ${fullSha} is not a commit on the ${defaultBranch} branch. Use log_from_main to find valid commit SHAs. Deployments can only be made from commits directly on ${defaultBranch}. If your changes are only on ${import_shared41.SUPERBLOCKS_LIVE_GIT_BRANCH}, create a pull request to merge into ${defaultBranch} first.`
632550
+ error: `Commit ${fullSha} is not a commit on the ${defaultBranch} branch. Use log_from_main to find valid commit SHAs. Deployments can only be made from commits directly on ${defaultBranch}. If your changes are only on ${import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH}, create a pull request to merge into ${defaultBranch} first.`
632434
632551
  };
632435
632552
  }
632436
632553
  let commitMessage;
@@ -632572,7 +632689,7 @@ var gitToolFactory = createToolFactory("git", (deps) => ({
632572
632689
 
632573
632690
  // ../../../vite-plugin-file-sync/dist/ai-service/agent/tools2/tools/git-raw.js
632574
632691
  init_cjs_shims();
632575
- var import_shared42 = __toESM(require_dist2());
632692
+ var import_shared43 = __toESM(require_dist2());
632576
632693
  var READ_ONLY_GIT_SUBCOMMANDS = /* @__PURE__ */ new Set([
632577
632694
  "blame",
632578
632695
  "cat-file",
@@ -632763,8 +632880,8 @@ function isStashReadOnlyCommand(args) {
632763
632880
  }
632764
632881
  async function assertOnLiveBranch(gitService, input) {
632765
632882
  const currentBranch = (await gitService.raw(["rev-parse", "--abbrev-ref", "HEAD"])).trim();
632766
- if (currentBranch !== import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH) {
632767
- throw new ToolExecutionError(`Raw git write operations are only allowed on the ${import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH} branch.`, {
632883
+ if (currentBranch !== import_shared43.SUPERBLOCKS_LIVE_GIT_BRANCH) {
632884
+ throw new ToolExecutionError(`Raw git write operations are only allowed on the ${import_shared43.SUPERBLOCKS_LIVE_GIT_BRANCH} branch.`, {
632768
632885
  toolName: "git_raw",
632769
632886
  input,
632770
632887
  context: {},
@@ -632779,19 +632896,19 @@ async function pushLiveBranchWithAutoRecreate(gitService) {
632779
632896
  "ls-remote",
632780
632897
  "--heads",
632781
632898
  "origin",
632782
- `refs/heads/${import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH}`
632899
+ `refs/heads/${import_shared43.SUPERBLOCKS_LIVE_GIT_BRANCH}`
632783
632900
  ]);
632784
- remoteExists = refs.includes(`refs/heads/${import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH}`);
632901
+ remoteExists = refs.includes(`refs/heads/${import_shared43.SUPERBLOCKS_LIVE_GIT_BRANCH}`);
632785
632902
  } catch {
632786
632903
  }
632787
632904
  try {
632788
- await gitService.push("origin", import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH);
632905
+ await gitService.push("origin", import_shared43.SUPERBLOCKS_LIVE_GIT_BRANCH);
632789
632906
  } catch (pushError) {
632790
632907
  if (remoteExists === false) {
632791
632908
  await gitService.raw([
632792
632909
  "push",
632793
632910
  "origin",
632794
- `HEAD:${import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH}`
632911
+ `HEAD:${import_shared43.SUPERBLOCKS_LIVE_GIT_BRANCH}`
632795
632912
  ]);
632796
632913
  return;
632797
632914
  }
@@ -632815,7 +632932,7 @@ function isGitRawWriteCommand(args) {
632815
632932
  return !isGitRawReadOnlyCommand(args) && args[0] !== "fetch";
632816
632933
  }
632817
632934
  var gitRawToolFactory = createToolFactory("git_raw", ({ gitService, gitOperationLock, onGitOperationComplete, onGitSetupRequired }) => ({
632818
- description: `Run a raw git argv command for operations not covered by the structured git tool. Pass argv only without the leading 'git'. All mutating operations must happen on ${import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH}. Branch-changing commands and raw push are not allowed. Detached-HEAD workflows such as bisect are not allowed. If you run commit, the tool will automatically push to origin/${import_shared42.SUPERBLOCKS_LIVE_GIT_BRANCH}. `,
632935
+ description: `Run a raw git argv command for operations not covered by the structured git tool. Pass argv only without the leading 'git'. All mutating operations must happen on ${import_shared43.SUPERBLOCKS_LIVE_GIT_BRANCH}. Branch-changing commands and raw push are not allowed. Detached-HEAD workflows such as bisect are not allowed. If you run commit, the tool will automatically push to origin/${import_shared43.SUPERBLOCKS_LIVE_GIT_BRANCH}. `,
632819
632936
  category: ToolCategory.GIT,
632820
632937
  defaultPermission: PermissionLevel.ALLOW,
632821
632938
  readOnly: false,
@@ -647546,11 +647663,11 @@ var CsvJudgeStorage = class {
647546
647663
 
647547
647664
  // ../../../vite-plugin-file-sync/dist/ai-service/knowledge/knowledge-manager.js
647548
647665
  init_cjs_shims();
647549
- var import_shared45 = __toESM(require_dist2());
647666
+ var import_shared46 = __toESM(require_dist2());
647550
647667
 
647551
647668
  // ../../../vite-plugin-file-sync/dist/ai-service/knowledge/helpers.js
647552
647669
  init_cjs_shims();
647553
- var import_shared44 = __toESM(require_dist2());
647670
+ var import_shared45 = __toESM(require_dist2());
647554
647671
  function escapeXml3(str) {
647555
647672
  return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
647556
647673
  }
@@ -647562,10 +647679,10 @@ function formatFact(fact) {
647562
647679
  </fact>`;
647563
647680
  }
647564
647681
  function filterAlwaysInjectFacts(facts) {
647565
- return facts.filter((fact) => fact.accessType === import_shared44.FactAccessType.ALWAYS_INJECT);
647682
+ return facts.filter((fact) => fact.accessType === import_shared45.FactAccessType.ALWAYS_INJECT);
647566
647683
  }
647567
647684
  function filterOnDemandFacts(facts) {
647568
- return facts.filter((fact) => fact.accessType === import_shared44.FactAccessType.ON_DEMAND);
647685
+ return facts.filter((fact) => fact.accessType === import_shared45.FactAccessType.ON_DEMAND);
647569
647686
  }
647570
647687
  function formatIntegrationFrontmatter(integration) {
647571
647688
  const displayName = integration.displayName || integration.name;
@@ -647685,19 +647802,19 @@ ${entries.join("\n")}
647685
647802
  var orgFactLookup = (organizationId) => ({
647686
647803
  cacheKeyPrefix: "organization",
647687
647804
  entityId: organizationId,
647688
- entityScope: import_shared45.FactEntityScope.ORG,
647805
+ entityScope: import_shared46.FactEntityScope.ORG,
647689
647806
  label: "org"
647690
647807
  });
647691
647808
  var integrationFactLookup = (integrationId) => ({
647692
647809
  cacheKeyPrefix: "integration",
647693
647810
  entityId: integrationId,
647694
- entityScope: import_shared45.FactEntityScope.INTEGRATION,
647811
+ entityScope: import_shared46.FactEntityScope.INTEGRATION,
647695
647812
  label: "integration"
647696
647813
  });
647697
647814
  var userFactLookup = (userId) => ({
647698
647815
  cacheKeyPrefix: "user",
647699
647816
  entityId: userId,
647700
- entityScope: import_shared45.FactEntityScope.USER,
647817
+ entityScope: import_shared46.FactEntityScope.USER,
647701
647818
  label: "user"
647702
647819
  });
647703
647820
  var CACHE_TTL_MS2 = 1 * 60 * 1e3;
@@ -647740,9 +647857,9 @@ var KnowledgeManager = class {
647740
647857
  const alwaysInject = [];
647741
647858
  const onDemand = [];
647742
647859
  for (const fact of facts) {
647743
- if (fact.accessType === import_shared45.FactAccessType.ALWAYS_INJECT) {
647860
+ if (fact.accessType === import_shared46.FactAccessType.ALWAYS_INJECT) {
647744
647861
  alwaysInject.push(fact);
647745
- } else if (fact.accessType === import_shared45.FactAccessType.ON_DEMAND) {
647862
+ } else if (fact.accessType === import_shared46.FactAccessType.ON_DEMAND) {
647746
647863
  onDemand.push(fact);
647747
647864
  }
647748
647865
  }
@@ -647939,7 +648056,7 @@ var KnowledgeManager = class {
647939
648056
  */
647940
648057
  filterAlwaysInjectFacts(facts) {
647941
648058
  const filterAlwaysInject = (factList) => {
647942
- return factList.filter((fact) => fact.accessType === import_shared45.FactAccessType.ALWAYS_INJECT);
648059
+ return factList.filter((fact) => fact.accessType === import_shared46.FactAccessType.ALWAYS_INJECT);
647943
648060
  };
647944
648061
  const alwaysInjectIntegrations = {};
647945
648062
  for (const [integrationId, integrationFacts] of Object.entries(facts.integrations)) {
@@ -650242,7 +650359,6 @@ function estimateJsonTokens(value2) {
650242
650359
 
650243
650360
  // ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/phase2-session-summarizer.js
650244
650361
  init_cjs_shims();
650245
- var import_ai7 = __toESM(require_dist9());
650246
650362
 
650247
650363
  // ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/prompts/compaction.js
650248
650364
  init_cjs_shims();
@@ -650598,7 +650714,7 @@ function formatGroundedCompactionRequest(groundingFacts, messagesJson) {
650598
650714
  ${formatCompactionRequest(messagesJson)}`;
650599
650715
  }
650600
650716
  async function summarizeSession(options8) {
650601
- const { messages: messages3, groundingMessages = messages3, model, targetTokens, abortSignal, tracer: tracer3 = LLMObsTracer.instance } = options8;
650717
+ const { messages: messages3, groundingMessages = messages3, model, targetTokens, abortSignal, tracer: tracer3 = LLMObsTracer.instance, summarizeLLM, providerConfig } = options8;
650602
650718
  const cleanedGroundingMessages = groundingMessages.map(stripMedia).map(stripProviderOptions).map(stripSuperblocksMeta);
650603
650719
  const groundingFacts = buildGroundingFacts(cleanedGroundingMessages);
650604
650720
  return tracer3.trace({ name: "session.summarize", kind: "task" }, async (summarizeSpan) => {
@@ -650607,40 +650723,30 @@ async function summarizeSession(options8) {
650607
650723
  const cleanedMessages = msgs.map(stripMedia).map(stripProviderOptions).map(stripSuperblocksMeta);
650608
650724
  const messagesJson = JSON.stringify(cleanedMessages, null, 2);
650609
650725
  const userMessage = formatGroundedCompactionRequest(groundingFacts, messagesJson);
650610
- let capturedError = null;
650611
650726
  const inputMetadata = {
650612
650727
  messageCount: msgs.length,
650613
650728
  promptLength: userMessage.length
650614
650729
  };
650615
- const streamResult = (0, import_ai7.streamText)({
650616
- model,
650617
- system: COMPACTION_PROMPT,
650618
- messages: [{ role: "user", content: userMessage }],
650619
- maxOutputTokens: 16384,
650620
- abortSignal,
650621
- onError: (event) => {
650622
- capturedError = event.error;
650623
- }
650624
- });
650625
- let summary = "";
650626
- for await (const part of streamResult.textStream) {
650627
- summary += part;
650628
- }
650629
- if (capturedError) {
650730
+ let result2;
650731
+ try {
650732
+ result2 = await summarizeLLM({
650733
+ model,
650734
+ system: COMPACTION_PROMPT,
650735
+ messages: [{ role: "user", content: userMessage }],
650736
+ maxOutputTokens: 16384,
650737
+ abortSignal,
650738
+ providerConfig
650739
+ });
650740
+ } catch (err) {
650630
650741
  tracer3.annotate(llmSpan, {
650631
- metadata: {
650632
- input: inputMetadata
650633
- },
650634
- error: capturedError
650742
+ metadata: { input: inputMetadata },
650743
+ error: err
650635
650744
  });
650636
- throw capturedError;
650745
+ throw err;
650637
650746
  }
650638
- const [usage, finishReason, warnings, response] = await Promise.all([
650639
- streamResult.usage,
650640
- streamResult.finishReason,
650641
- streamResult.warnings,
650642
- streamResult.response
650643
- ]);
650747
+ const summary = result2.text ?? "";
650748
+ const usage = result2.usage;
650749
+ const finishReason = result2.finishReason;
650644
650750
  if (!summary) {
650645
650751
  const debugInfo = {
650646
650752
  model: {
@@ -650653,13 +650759,6 @@ async function summarizeSession(options8) {
650653
650759
  inputTokens: usage?.inputTokens,
650654
650760
  outputTokens: usage?.outputTokens,
650655
650761
  cachedInputTokens: usage?.cachedInputTokens
650656
- },
650657
- warnings,
650658
- response: {
650659
- id: response?.id,
650660
- modelId: response?.modelId,
650661
- timestamp: response?.timestamp,
650662
- headers: response?.headers
650663
650762
  }
650664
650763
  };
650665
650764
  logger12.warn("Summarization produced empty summary - debug info:", debugInfo);
@@ -650812,14 +650911,14 @@ function captureSession(data3, rootDir) {
650812
650911
  // ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/compactor.js
650813
650912
  var logger14 = getPrefixedLogger("[context-v2:compactor]");
650814
650913
  async function compact(options8) {
650815
- const { messages: messages3, usage, model, config: config4 = {}, callbacks, tracer: tracer3 = LLMObsTracer.instance, rootDir } = options8;
650914
+ const { messages: messages3, usage, model, summarizeLLM, providerConfig, config: config4 = {}, callbacks, tracer: tracer3 = LLMObsTracer.instance, rootDir } = options8;
650816
650915
  return tracer3.trace({ name: "context.compaction", kind: "task" }, async (compactionSpan) => {
650817
650916
  const mergedOptions = {
650818
650917
  ...DEFAULT_OPTIONS3,
650819
650918
  ...config4
650820
650919
  };
650821
650920
  const { contextLimit, maxOutputTokens, phase2TargetRatio, phase1Enabled, phase1MinPruneable, phase1ProtectedTokens, phase1ProtectedToolUseCount } = mergedOptions;
650822
- const initialTokens = getTotalTokens(usage);
650921
+ const inputContextTokens = computeContextUsed(usage);
650823
650922
  const availableForInput = contextLimit - maxOutputTokens;
650824
650923
  const targetTokens = Math.floor(availableForInput * phase2TargetRatio);
650825
650924
  let currentMessages = messages3;
@@ -650843,7 +650942,7 @@ async function compact(options8) {
650843
650942
  protectedTokens: phase1ProtectedTokens,
650844
650943
  protectedToolUseCount: phase1ProtectedToolUseCount
650845
650944
  });
650846
- const estimatedTokensAfter = initialTokens - phase1EstimatedSavings;
650945
+ const estimatedTokensAfter = inputContextTokens - phase1EstimatedSavings;
650847
650946
  tracer3.annotate(phase1Span, {
650848
650947
  metadata: {
650849
650948
  input: {
@@ -650870,14 +650969,19 @@ async function compact(options8) {
650870
650969
  phase1Applied = true;
650871
650970
  logger14.info(`Phase 1 complete: summarized ${result.summarizedCount} tool outputs`);
650872
650971
  callbacks?.onCompactionComplete?.("phase1", phase1MessageId);
650873
- const estimatedNewTokens = initialTokens - phase1EstimatedSavings;
650972
+ const estimatedNewTokens = inputContextTokens - phase1EstimatedSavings;
650874
650973
  if (estimatedNewTokens < targetTokens) {
650875
650974
  tokensSaved = phase1EstimatedSavings;
650876
650975
  tracer3.annotate(compactionSpan, {
650877
650976
  metadata: {
650878
650977
  input: {
650879
650978
  messageCount: messages3.length,
650880
- tokens: initialTokens
650979
+ tokens: inputContextTokens,
650980
+ // Discriminator: `tokens` reports input-only context (via
650981
+ // computeContextUsed). Earlier spans reported input+output, so
650982
+ // absolute-value dashboards/alerts step down at the deploy
650983
+ // boundary — filter/annotate on this field.
650984
+ tokensMetric: "inputContext"
650881
650985
  },
650882
650986
  config: {
650883
650987
  contextLimit,
@@ -650890,7 +650994,7 @@ async function compact(options8) {
650890
650994
  phase2TargetRatio
650891
650995
  },
650892
650996
  result: {
650893
- tokens: initialTokens - tokensSaved,
650997
+ tokens: inputContextTokens - tokensSaved,
650894
650998
  tokensSaved,
650895
650999
  tokensSavedIsEstimate: true,
650896
651000
  phase1Applied,
@@ -650909,14 +651013,16 @@ async function compact(options8) {
650909
651013
  logger14.info("Phase 2: generating session summary");
650910
651014
  const phase2MessageId = crypto.randomUUID();
650911
651015
  callbacks?.onCompactionStart?.("phase2", phase2MessageId);
650912
- const phase2SourceMessages = initialTokens <= availableForInput ? messages3 : currentMessages;
651016
+ const phase2SourceMessages = inputContextTokens <= availableForInput ? messages3 : currentMessages;
650913
651017
  const summaryResult = await tracer3.trace({ name: "context.compaction.phase2", kind: "task" }, async (phase2Span) => {
650914
651018
  const result = await summarizeSession({
650915
651019
  messages: phase2SourceMessages,
650916
651020
  groundingMessages: messages3,
650917
651021
  model,
650918
651022
  targetTokens,
650919
- tracer: tracer3
651023
+ tracer: tracer3,
651024
+ summarizeLLM,
651025
+ providerConfig
650920
651026
  });
650921
651027
  tracer3.annotate(phase2Span, {
650922
651028
  metadata: {
@@ -650935,14 +651041,18 @@ async function compact(options8) {
650935
651041
  phase2Applied = true;
650936
651042
  currentMessages = summaryResult.messages;
650937
651043
  const summaryTokens = summaryResult.messages.reduce((sum, msg) => sum + (msg._superblocks?.tokenCount ?? 100), 0);
650938
- tokensSaved = initialTokens - summaryTokens;
650939
- logger14.info(`Phase 2 complete: ${initialTokens}\u2192${summaryTokens} tokens (saved ${tokensSaved})`);
651044
+ tokensSaved = inputContextTokens - summaryTokens;
651045
+ logger14.info(`Phase 2 complete: ${inputContextTokens}\u2192${summaryTokens} tokens (saved ${tokensSaved})`);
650940
651046
  callbacks?.onCompactionComplete?.("phase2", phase2MessageId, summaryResult.summary);
650941
651047
  tracer3.annotate(compactionSpan, {
650942
651048
  metadata: {
650943
651049
  input: {
650944
651050
  messageCount: messages3.length,
650945
- tokens: initialTokens
651051
+ tokens: inputContextTokens,
651052
+ // Discriminator: `tokens` reports input-only context (via
651053
+ // computeContextUsed), not input+output — filter/annotate on this
651054
+ // field so absolute-value dashboards can account for the step down.
651055
+ tokensMetric: "inputContext"
650946
651056
  },
650947
651057
  config: {
650948
651058
  contextLimit,
@@ -650976,6 +651086,8 @@ async function compact(options8) {
650976
651086
  var logger15 = getPrefixedLogger("[compaction:client-side]");
650977
651087
  var ClientSideCompactionStrategy = class {
650978
651088
  summarizationModel;
651089
+ summarizeLLM;
651090
+ summarizationProviderConfig;
650979
651091
  config;
650980
651092
  getModeState;
650981
651093
  rootDir;
@@ -650986,6 +651098,8 @@ var ClientSideCompactionStrategy = class {
650986
651098
  callbacks;
650987
651099
  constructor(options8) {
650988
651100
  this.summarizationModel = options8.summarizationModel;
651101
+ this.summarizeLLM = options8.summarizeLLM;
651102
+ this.summarizationProviderConfig = options8.summarizationProviderConfig;
650989
651103
  this.config = { ...DEFAULT_OPTIONS3, ...options8.config };
650990
651104
  this.getModeState = options8.getModeState;
650991
651105
  this.rootDir = options8.rootDir;
@@ -651060,14 +651174,16 @@ var ClientSideCompactionStrategy = class {
651060
651174
  return {};
651061
651175
  }
651062
651176
  logger15.info(`Compaction triggered: ${inputContextUsed} tokens > ${threshold} threshold (${params.messages.length} messages)`);
651063
- if (!this.summarizationModel) {
651064
- logger15.warn("Client-side compaction is selected but no summarization model is configured; skipping compaction");
651177
+ if (!this.summarizationModel || !this.summarizeLLM || !this.summarizationProviderConfig) {
651178
+ logger15.warn("Client-side compaction is selected but no summarization model, summarizer callback, or provider config is configured; skipping compaction");
651065
651179
  return {};
651066
651180
  }
651067
651181
  const result = await compact({
651068
651182
  messages: params.messages,
651069
651183
  usage: params.usage,
651070
651184
  model: this.summarizationModel,
651185
+ summarizeLLM: this.summarizeLLM,
651186
+ providerConfig: this.summarizationProviderConfig,
651071
651187
  config: this.config,
651072
651188
  callbacks: this.callbacks,
651073
651189
  tracer: this.tracer,
@@ -651625,6 +651741,8 @@ var ContextManagerV2 = class {
651625
651741
  }
651626
651742
  return new ClientSideCompactionStrategy({
651627
651743
  summarizationModel: contextManagement?.summarizationModel,
651744
+ summarizationProviderConfig: contextManagement?.summarizationProviderConfig,
651745
+ summarizeLLM: contextManagement?.summarizeLLM,
651628
651746
  config: config4,
651629
651747
  getModeState: this.getModeState,
651630
651748
  rootDir: this.rootDir,
@@ -651738,7 +651856,7 @@ init_cjs_shims();
651738
651856
 
651739
651857
  // ../../../vite-plugin-file-sync/dist/ai-service/llm/interaction/adapters/vercel.js
651740
651858
  init_cjs_shims();
651741
- var import_ai8 = __toESM(require_dist9());
651859
+ var import_ai7 = __toESM(require_dist9());
651742
651860
 
651743
651861
  // ../../../vite-plugin-file-sync/dist/ai-service/llm/tool-context-integrity.js
651744
651862
  init_cjs_shims();
@@ -651952,7 +652070,7 @@ var VercelStreamTextAdapter = class {
651952
652070
  */
651953
652071
  async streamText(options8) {
651954
652072
  const { onFinally, user, ...rest } = options8;
651955
- const sdkOutput = rest.experimental_output ? import_ai8.Output.object({
652073
+ const sdkOutput = rest.experimental_output ? import_ai7.Output.object({
651956
652074
  schema: rest.experimental_output
651957
652075
  }) : void 0;
651958
652076
  const normalizeError = (error40) => error40 instanceof Error ? error40 : new Error(String(error40));
@@ -651978,7 +652096,7 @@ var VercelStreamTextAdapter = class {
651978
652096
  logProviderMessages(preparedStep?.messages ?? step.messages);
651979
652097
  return preparedStep;
651980
652098
  });
651981
- const rawResult = (0, import_ai8.streamText)({
652099
+ const rawResult = (0, import_ai7.streamText)({
651982
652100
  model: rest.model,
651983
652101
  messages: messagesForLLM,
651984
652102
  system: rest.system,
@@ -652730,7 +652848,7 @@ async function raceWithStallDetection(promise2, idleMonitor) {
652730
652848
 
652731
652849
  // ../../../vite-plugin-file-sync/dist/ai-service/llm/stream/retry-engine.js
652732
652850
  init_cjs_shims();
652733
- var import_ai9 = __toESM(require_dist9());
652851
+ var import_ai8 = __toESM(require_dist9());
652734
652852
  var RetryEngine = class {
652735
652853
  config;
652736
652854
  fallbackChain;
@@ -652758,7 +652876,7 @@ var RetryEngine = class {
652758
652876
  return { shouldRetry: false, delayMs: 0, reason: "aborted" };
652759
652877
  }
652760
652878
  if (!this.isRetryable(error40)) {
652761
- if (import_ai9.APICallError.isInstance(error40)) {
652879
+ if (import_ai8.APICallError.isInstance(error40)) {
652762
652880
  const statusCode = error40.statusCode;
652763
652881
  let cause = "non-retryable";
652764
652882
  if (statusCode === 401 || statusCode === 403) {
@@ -653549,6 +653667,10 @@ var StreamOrchestrator = class {
653549
653667
  tools: options8.tools
653550
653668
  });
653551
653669
  internalAbortController.signal.addEventListener("abort", () => {
653670
+ if (!session.isPending()) {
653671
+ this.logger.debug("[orchestrator] session:abort suppressed \u2014 session already finalized", { session_id: session.id, outcome: session.outcome });
653672
+ return;
653673
+ }
653552
653674
  void session.events.emit("session:abort", session);
653553
653675
  });
653554
653676
  const idleMonitor = new IdleMonitor({
@@ -653712,6 +653834,7 @@ var StreamOrchestrator = class {
653712
653834
  } finally {
653713
653835
  reader.releaseLock();
653714
653836
  if (!drained) {
653837
+ internalAbortController.abort();
653715
653838
  await branch.cancel().catch(() => {
653716
653839
  });
653717
653840
  }
@@ -654749,7 +654872,7 @@ ${from.name}/${from.model} -> ${to2.name}/${to2.model} reason=${reason}
654749
654872
 
654750
654873
  // ../../../vite-plugin-file-sync/dist/ai-service/llm/stream/observers/llmobs.js
654751
654874
  init_cjs_shims();
654752
- var import_ai10 = __toESM(require_dist9());
654875
+ var import_ai9 = __toESM(require_dist9());
654753
654876
 
654754
654877
  // ../../../vite-plugin-file-sync/dist/ai-service/llmobs/helpers.js
654755
654878
  init_cjs_shims();
@@ -654856,7 +654979,7 @@ function classifyError(error40, provider = "anthropic") {
654856
654979
  providerErrorType: error40.data?.type
654857
654980
  };
654858
654981
  }
654859
- if (import_ai10.APICallError.isInstance(error40) || isAPICallErrorLike(error40)) {
654982
+ if (import_ai9.APICallError.isInstance(error40) || isAPICallErrorLike(error40)) {
654860
654983
  const providerError = new LLMProviderError({
654861
654984
  provider,
654862
654985
  cause: error40
@@ -655269,10 +655392,11 @@ var LLMObsObserver = class {
655269
655392
  });
655270
655393
  }
655271
655394
  if (this.fullSpan) {
655395
+ const totalDurationMs = session.metrics.durationMs > 0 ? session.metrics.durationMs : session.getElapsedMs();
655272
655396
  this.tracer.annotate(this.fullSpan, {
655273
655397
  metadata: {
655274
655398
  outcome,
655275
- totalDurationMs: session.metrics.durationMs,
655399
+ totalDurationMs,
655276
655400
  totalChunks: session.metrics.chunkCount,
655277
655401
  totalRetries: session.metrics.retryCount,
655278
655402
  totalRetryDelayMs: session.metrics.totalRetryDelayMs,
@@ -655981,8 +656105,12 @@ var LLMClient = class {
655981
656105
  const managedContextConfig = usesManagedContext ? contextConfig : void 0;
655982
656106
  const contextId = managedContextConfig?.contextId;
655983
656107
  const effectiveLoggingConfig = loggingConfig === void 0 && !usesManagedContext ? false : loggingConfig;
656108
+ const contextManagement = managedContextConfig?.contextManagement?.type === "client" ? {
656109
+ ...managedContextConfig.contextManagement,
656110
+ summarizeLLM: this.summarizeViaClient
656111
+ } : managedContextConfig?.contextManagement;
655984
656112
  const contextSetupStartedAt = performance.now();
655985
- const managedContext = usesManagedContext ? await this.createContext(contextId, managedContextConfig?.contextOptionsV2, tracer3, managedContextConfig?.contextManagement, peer) : void 0;
656113
+ const managedContext = usesManagedContext ? await this.createContext(contextId, managedContextConfig?.contextOptionsV2, tracer3, contextManagement, peer) : void 0;
655986
656114
  const contextHandle = managedContext?.contextHandle;
655987
656115
  const ctx = managedContext?.ctx;
655988
656116
  if (ctx) {
@@ -656203,6 +656331,73 @@ var LLMClient = class {
656203
656331
  throw error40;
656204
656332
  }
656205
656333
  }
656334
+ /**
656335
+ * Runs the Phase-2 context-compaction summarization call through this client
656336
+ * so it inherits retry, idle-monitor stall handling, and the standardized
656337
+ * observer pipeline instead of calling the AI SDK's `streamText`
656338
+ * directly. Injected into the client-side compaction strategy via
656339
+ * `contextManagement.summarizeLLM`.
656340
+ *
656341
+ * - Runs `stateless`: summarization is a one-shot with no
656342
+ * conversation to attach to, so it skips the managed-context machinery
656343
+ * (ephemeral context, turn tracking, context observer) and — because
656344
+ * stateless defaults logging off — persists no `.superblocks/generations`
656345
+ * artifacts without a per-call-site `logging: false`.
656346
+ * - No `safety` object (reads as `safety: undefined`, like every other
656347
+ * non-user-prompt turn — subagent, judge, plan mode): the compaction prompt
656348
+ * is internally generated, not user content, so the migration adds only
656349
+ * retry/observability, never classification or redaction. The client skips
656350
+ * the safety pipeline whenever no safety feature is enabled.
656351
+ * - `recordObsContent: false` — the LLMObsObserver is always attached, and the
656352
+ * compaction input is the serialized prior session (which can carry secrets
656353
+ * and tool output). With redaction off, recording content would annotate the
656354
+ * span with that raw conversation, so redact it on the span (model, usage,
656355
+ * timing, and span structure are still recorded). Mirrors how the safety
656356
+ * classifier keeps its prompt content off LLMObs.
656357
+ * - `providerConfig` is threaded in via `args` from
656358
+ * `modelForTask("summarizeMessages")` (the `{ model, providerConfig }` pair
656359
+ * the other migrated call sites pass, see #20263), so it reflects the org's real
656360
+ * provider/core model instead of a hardcode. It only sets the retry-budget
656361
+ * profile + initial telemetry label; the real per-call model/provider are
656362
+ * recorded from the response headers on the obs span.
656363
+ *
656364
+ * Drains `fullStream` (not `textStream`) so the managed-stream wrapper fires
656365
+ * session finalization, and captures usage/finishReason from the terminal
656366
+ * `finish` part — emitted on the stream we already drain, so it is in-order
656367
+ * with the loop (unlike `onFinish`, which is the AI SDK's callback on the
656368
+ * inner provider stream and can fire *after* this loop exits, leaving the
656369
+ * counts undefined and silently zeroing the summary message's tokenCount).
656370
+ */
656371
+ summarizeViaClient = async (args) => {
656372
+ const user = args.messages[args.messages.length - 1];
656373
+ if (!args.providerConfig) {
656374
+ throw new Error("summarizeViaClient requires a providerConfig threaded from the compaction strategy (modelForTask). None was supplied.");
656375
+ }
656376
+ const result = await this.streamText({
656377
+ // The summarization model always resolves to a LanguageModelV3 (from
656378
+ // `modelForTask`), never a bare string, in the compaction path.
656379
+ model: args.model,
656380
+ user,
656381
+ system: args.system,
656382
+ maxOutputTokens: args.maxOutputTokens,
656383
+ abortSignal: args.abortSignal,
656384
+ providerConfig: args.providerConfig,
656385
+ context: { mode: "stateless" },
656386
+ recordObsContent: false
656387
+ });
656388
+ let text3 = "";
656389
+ let usage;
656390
+ let finishReason;
656391
+ for await (const part of result.fullStream) {
656392
+ if (part.type === "text-delta") {
656393
+ text3 += part.text;
656394
+ } else if (part.type === "finish") {
656395
+ usage = part.totalUsage;
656396
+ finishReason = part.finishReason;
656397
+ }
656398
+ }
656399
+ return { text: text3, usage, finishReason };
656400
+ };
656206
656401
  async createContext(contextId, contextOptionsV2, tracer3, contextManagement, peer) {
656207
656402
  const context2 = await this.contextManagerV2.getOrCreateContext(contextId, contextOptionsV2, tracer3, contextManagement, {
656208
656403
  ...this.applicationId ?? contextId?.appId ? { applicationId: this.applicationId ?? contextId?.appId } : {},
@@ -656803,7 +656998,7 @@ var PlaywrightMcpServerManager = class {
656803
656998
  this.logger.info(`Starting embedded Playwright MCP server: browser=${options8?.browser || "chromium"}, headless=${options8?.headless !== false}`);
656804
656999
  }
656805
657000
  try {
656806
- const { startEmbeddedPlaywrightMcpServer } = await import("./embedded-playwright-mcp-server-6ZRCB7OJ.js");
657001
+ const { startEmbeddedPlaywrightMcpServer } = await import("./embedded-playwright-mcp-server-SWUZ5WRJ.js");
656807
657002
  this.server = await startEmbeddedPlaywrightMcpServer({
656808
657003
  storageStatePath: options8?.storageStatePath,
656809
657004
  jwt: options8?.jwt,
@@ -657020,6 +657215,7 @@ var VALID_CORE_MODELS = [
657020
657215
  "claude-opus-4-5",
657021
657216
  "claude-opus-4-6",
657022
657217
  "claude-opus-4-7",
657218
+ "claude-opus-4-8",
657023
657219
  "claude-sonnet-4-5",
657024
657220
  "claude-sonnet-4-6"
657025
657221
  ];
@@ -657500,7 +657696,7 @@ function resolveGenerationStateForUi(input) {
657500
657696
 
657501
657697
  // ../../../vite-plugin-file-sync/dist/ai-service/state-machine/handlers/agent-planning.js
657502
657698
  init_cjs_shims();
657503
- var import_shared48 = __toESM(require_dist2());
657699
+ var import_shared49 = __toESM(require_dist2());
657504
657700
 
657505
657701
  // ../../../vite-plugin-file-sync/dist/ids.js
657506
657702
  init_cjs_shims();
@@ -657526,7 +657722,7 @@ var generateShortId = () => {
657526
657722
 
657527
657723
  // ../../../vite-plugin-file-sync/dist/ai-service/app-skills/helpers.js
657528
657724
  init_cjs_shims();
657529
- var import_shared46 = __toESM(require_dist2());
657725
+ var import_shared47 = __toESM(require_dist2());
657530
657726
 
657531
657727
  // ../../../vite-plugin-file-sync/dist/ai-service/state-machine/helpers/background-chat-record.js
657532
657728
  init_cjs_shims();
@@ -657662,12 +657858,12 @@ ${failedCount} ${failedCount === 1 ? "entry" : "entries"} failed to save.`);
657662
657858
  // ../../../vite-plugin-file-sync/dist/ai-service/app-skills/helpers.js
657663
657859
  function resolveFactScope(scope) {
657664
657860
  if (scope === "org") {
657665
- return import_shared46.FactEntityScope.ORG;
657861
+ return import_shared47.FactEntityScope.ORG;
657666
657862
  }
657667
657863
  if (scope === "user") {
657668
- return import_shared46.FactEntityScope.USER;
657864
+ return import_shared47.FactEntityScope.USER;
657669
657865
  }
657670
- return import_shared46.FactEntityScope.INTEGRATION;
657866
+ return import_shared47.FactEntityScope.INTEGRATION;
657671
657867
  }
657672
657868
  function resolveKnowledgeScopeSelection(selection) {
657673
657869
  if (selection) {
@@ -657751,8 +657947,8 @@ async function saveKnowledgeAndNotify(clark, params, chatSessionStore, appRootDi
657751
657947
  content: knowledgeEntry.content,
657752
657948
  entityScope: resolveFactScope(selection.scope),
657753
657949
  entityId,
657754
- accessType: import_shared46.FactAccessType.ALWAYS_INJECT,
657755
- createdSource: import_shared46.FactCreatedSource.AGENT
657950
+ accessType: import_shared47.FactAccessType.ALWAYS_INJECT,
657951
+ createdSource: import_shared47.FactCreatedSource.AGENT
657756
657952
  };
657757
657953
  const createdFact = await params.rpcClient.call(async (client) => {
657758
657954
  const rpcClient = client;
@@ -658380,6 +658576,23 @@ Address the errors and return the fixed code.`;
658380
658576
  if (clark.context.activeInteractiveMessage) {
658381
658577
  clark.updateContext({ activeInteractiveMessage: void 0 });
658382
658578
  }
658579
+ if (request.responseMetadata.clarification && request.prompt.trim()) {
658580
+ void clark.context.peer.call.aiPushMessage({
658581
+ role: "user",
658582
+ type: "text",
658583
+ content: request.prompt,
658584
+ id: crypto.randomUUID(),
658585
+ timestamp: Date.now()
658586
+ }).catch((err) => {
658587
+ getLogger3().warn("[agent-planning] Failed to echo tool-permission clarification to UI", err);
658588
+ });
658589
+ recordChatMessageInBackground({
658590
+ clark,
658591
+ record: () => params.chatSessionStore.recordUser(request.prompt, {
658592
+ attachments: request.promptContext?.attachments
658593
+ })
658594
+ });
658595
+ }
658383
658596
  } else {
658384
658597
  clark.updateContext({
658385
658598
  activeInteractiveMessage: void 0
@@ -658441,23 +658654,23 @@ Address the errors and return the fixed code.`;
658441
658654
  };
658442
658655
  const isTypedOverride = request.responseMetadata.type === "multi_choice_response" && request.responseMetadata.selectedChoiceIndices.length === 0 || request.responseMetadata.type === "plan_response" && !request.responseMetadata.approved;
658443
658656
  const responseMetadataType = request.responseMetadata.type;
658657
+ if (isTypedOverride) {
658658
+ void clark.context.peer.call.aiPushMessage({
658659
+ role: "user",
658660
+ type: "text",
658661
+ content: request.prompt,
658662
+ id: crypto.randomUUID(),
658663
+ timestamp: Date.now()
658664
+ }).catch((err) => {
658665
+ getLogger3().warn("[agent-planning] Failed to echo user response to UI", {
658666
+ promptId: clark.context.promptId,
658667
+ responseType: responseMetadataType
658668
+ }, err);
658669
+ });
658670
+ }
658444
658671
  recordChatMessageInBackground({
658445
658672
  clark,
658446
- record: () => params.chatSessionStore.recordUserResponse(request.prompt, responseMetadataType, metadata),
658447
- onRecorded: (chatmessageId) => {
658448
- if (!isTypedOverride) {
658449
- return;
658450
- }
658451
- void clark.context.peer.call.aiPushMessage({
658452
- role: "user",
658453
- type: "text",
658454
- content: request.prompt,
658455
- id: chatmessageId,
658456
- timestamp: Date.now()
658457
- }).catch((err) => {
658458
- getLogger3().warn("[agent-planning] Failed to echo user response to UI", err);
658459
- });
658460
- }
658673
+ record: () => params.chatSessionStore.recordUserResponse(request.prompt, responseMetadataType, metadata)
658461
658674
  });
658462
658675
  if (isIntegrationActionResponse) {
658463
658676
  const selectedResponseText = request.prompt.trim().toLowerCase();
@@ -658804,9 +659017,9 @@ ${request.prompt}`;
658804
659017
  const data3 = e.data;
658805
659018
  const responseMeta = data3?.responseMeta;
658806
659019
  const wireReason = responseMeta?.error?.reason;
658807
- if ((0, import_shared48.isAiQuotaPaywallReason)(wireReason))
659020
+ if ((0, import_shared49.isAiQuotaPaywallReason)(wireReason))
658808
659021
  return wireReason;
658809
- if ((0, import_shared48.isAiQuotaPaywallReason)(data3?.reason))
659022
+ if ((0, import_shared49.isAiQuotaPaywallReason)(data3?.reason))
658810
659023
  return data3.reason;
658811
659024
  if (data3?.type === "clark_quota_exceeded") {
658812
659025
  return "credit_limit_exceeded";
@@ -658817,13 +659030,13 @@ ${request.prompt}`;
658817
659030
  if (!err || typeof err !== "object" || depth > 5)
658818
659031
  return void 0;
658819
659032
  const e = err;
658820
- return reasonFromData(err) ?? (typeof e.message === "string" ? (0, import_shared48.getAiQuotaPaywallReasonFromMessage)(e.message) : void 0) ?? walkCause(e.cause, depth + 1);
659033
+ return reasonFromData(err) ?? (typeof e.message === "string" ? (0, import_shared49.getAiQuotaPaywallReasonFromMessage)(e.message) : void 0) ?? walkCause(e.cause, depth + 1);
658821
659034
  };
658822
659035
  const paywallReason = (
658823
659036
  // Prefer structured data over message text so we keep the specific
658824
659037
  // reason (`trial_expired`, `no_seat_assigned`, etc.) rather than
658825
659038
  // collapsing to whatever string the substring matcher hits first.
658826
- reasonFromData(error40) ?? (0, import_shared48.getAiQuotaPaywallReasonFromMessage)(error40.message) ?? (error40.type === "ai_quota_exceeded" ? "credit_limit_exceeded" : void 0) ?? walkCause(error40.cause)
659039
+ reasonFromData(error40) ?? (0, import_shared49.getAiQuotaPaywallReasonFromMessage)(error40.message) ?? (error40.type === "ai_quota_exceeded" ? "credit_limit_exceeded" : void 0) ?? walkCause(error40.cause)
658827
659040
  );
658828
659041
  if (paywallReason) {
658829
659042
  const multiChoiceCtx = clark.context.lastTurnMultiChoiceContext;
@@ -659428,11 +659641,11 @@ var doIdle = (clark, { chatSessionStore, clarkProfiler }) => {
659428
659641
  // ../../../vite-plugin-file-sync/dist/ai-service/state-machine/handlers/llm-generating.js
659429
659642
  init_cjs_shims();
659430
659643
  import path49 from "node:path";
659431
- var import_shared50 = __toESM(require_dist2());
659644
+ var import_shared51 = __toESM(require_dist2());
659432
659645
 
659433
659646
  // ../../../vite-plugin-file-sync/dist/ai-service/agent/prompts/build-base-system-prompt.js
659434
659647
  init_cjs_shims();
659435
- var import_shared49 = __toESM(require_dist2());
659648
+ var import_shared50 = __toESM(require_dist2());
659436
659649
 
659437
659650
  // ../../../vite-plugin-file-sync/dist/ai-service/agent/prompts/api-prompts.js
659438
659651
  init_cjs_shims();
@@ -660266,15 +660479,15 @@ When a pull results in merge conflicts, you will be told which files have confli
660266
660479
  ${config4.features.nativeGitRawEnabled ? `
660267
660480
 
660268
660481
  **Git Workflow:**
660269
- - This workspace uses a single live branch model: all mutating git work must stay on \`${import_shared49.SUPERBLOCKS_LIVE_GIT_BRANCH}\`.
660270
- - The **History** tab in the Versions panel shows all commits on \`${import_shared49.SUPERBLOCKS_LIVE_GIT_BRANCH}\`. Use it to review recent changes.
660271
- - Deployments can only be made from the main branch and must be triggered manually from the History tab's **\u22EF** menu. If changes are only on \`${import_shared49.SUPERBLOCKS_LIVE_GIT_BRANCH}\`, create a pull request first to merge into main.
660482
+ - This workspace uses a single live branch model: all mutating git work must stay on \`${import_shared50.SUPERBLOCKS_LIVE_GIT_BRANCH}\`.
660483
+ - The **History** tab in the Versions panel shows all commits on \`${import_shared50.SUPERBLOCKS_LIVE_GIT_BRANCH}\`. Use it to review recent changes.
660484
+ - Deployments can only be made from the main branch and must be triggered manually from the History tab's **\u22EF** menu. If changes are only on \`${import_shared50.SUPERBLOCKS_LIVE_GIT_BRANCH}\`, create a pull request first to merge into main.
660272
660485
  - Never try to create, switch, delete, or compare against other branches with git commands.
660273
660486
  - Never leave the repository in detached HEAD, and never use detached-head workflows such as bisect.
660274
- - Do not run raw push commands. If you run \`git_raw\` commit, it will automatically push to \`origin/${import_shared49.SUPERBLOCKS_LIVE_GIT_BRANCH}\` after the commit succeeds.
660487
+ - Do not run raw push commands. If you run \`git_raw\` commit, it will automatically push to \`origin/${import_shared50.SUPERBLOCKS_LIVE_GIT_BRANCH}\` after the commit succeeds.
660275
660488
  - Favor inspection commands first when debugging git state, and only use mutating git commands when they clearly preserve the single live-branch workflow.
660276
660489
  ` : `
660277
- - Deployments can only be made from the main branch. To deploy, first use \`git\` with \`operation: "log_from_main"\` to get commit SHAs from main, then use \`operation: "deploy"\` with the full SHA. NEVER use a SHA from \`git log\` (which shows \`${import_shared49.SUPERBLOCKS_LIVE_GIT_BRANCH}\` commits) for deploy. If the commit is only on \`${import_shared49.SUPERBLOCKS_LIVE_GIT_BRANCH}\`, create a pull request first to merge it into main.
660490
+ - Deployments can only be made from the main branch. To deploy, first use \`git\` with \`operation: "log_from_main"\` to get commit SHAs from main, then use \`operation: "deploy"\` with the full SHA. NEVER use a SHA from \`git log\` (which shows \`${import_shared50.SUPERBLOCKS_LIVE_GIT_BRANCH}\` commits) for deploy. If the commit is only on \`${import_shared50.SUPERBLOCKS_LIVE_GIT_BRANCH}\`, create a pull request first to merge it into main.
660278
660491
  `}
660279
660492
  ` : `**Version Control:**
660280
660493
  If the user asks about committing, deploying, publishing, or version-controlling their application, read the documentation at \`https://docs.superblocks.com/development-lifecycle/deploy/version-control\` using \`web_fetch\` and guide them based on its contents.
@@ -661510,7 +661723,7 @@ note: ${escapeAttachmentReferenceValue(getTextUploadFallbackNote(options8.attach
661510
661723
  }
661511
661724
  ];
661512
661725
  }
661513
- const delivery = (0, import_shared50.classifyAttachmentDelivery)({
661726
+ const delivery = (0, import_shared51.classifyAttachmentDelivery)({
661514
661727
  fileName: attachment.fileName,
661515
661728
  mimeType: attachment.mediaType
661516
661729
  });
@@ -664452,7 +664665,7 @@ var AiServiceFeatureFlags = {
664452
664665
 
664453
664666
  // ../../../vite-plugin-file-sync/dist/ai-service/sdk-api-templates.js
664454
664667
  init_cjs_shims();
664455
- var import_shared53 = __toESM(require_dist2());
664668
+ var import_shared54 = __toESM(require_dist2());
664456
664669
 
664457
664670
  // ../../../vite-plugin-file-sync/dist/ai-service/index.js
664458
664671
  function streamRetryOptionsFromConfig(retryOptions, streamTimeoutBudgets) {
@@ -664630,7 +664843,7 @@ var POLICY_GATE_USAGE_METADATA = {
664630
664843
  origin: "policy_gate",
664631
664844
  surface: "policy_gate"
664632
664845
  };
664633
- var AiService = class extends import_shared54.TracedEventEmitter {
664846
+ var AiService = class extends import_shared55.TracedEventEmitter {
664634
664847
  config;
664635
664848
  templateRenderer;
664636
664849
  appShell;
@@ -665091,7 +665304,7 @@ var AiService = class extends import_shared54.TracedEventEmitter {
665091
665304
  "handlePromptInterpretation",
665092
665305
  "handleJudgeEvaluation"
665093
665306
  ];
665094
- (0, import_shared54.addTracingToMethods)(this, handlerMethods, config4.tracer);
665307
+ (0, import_shared55.addTracingToMethods)(this, handlerMethods, config4.tracer);
665095
665308
  }
665096
665309
  /**
665097
665310
  * Initialize the AI service. Must be called after construction.
@@ -665524,7 +665737,7 @@ var AiService = class extends import_shared54.TracedEventEmitter {
665524
665737
  return selectContextManagementStrategy({
665525
665738
  serverContextManagementEnabled: llmConfig?.serverContextManagement?.enabled,
665526
665739
  thresholds: llmConfig?.serverContextManagement,
665527
- summarizationModel: () => createLLMProvider(this.getLLMProviderSettings(llmConfig), () => this.getInferenceJwt(), llmConfig, () => this.getLlmAiAttributes(this.clark), this.clark.context.traceHeaders).modelForTask("summarizeMessages").model
665740
+ summarizeModel: () => createLLMProvider(this.getLLMProviderSettings(llmConfig), () => this.getInferenceJwt(), llmConfig, () => this.getLlmAiAttributes(this.clark), this.clark.context.traceHeaders).modelForTask("summarizeMessages")
665528
665741
  });
665529
665742
  }
665530
665743
  getLlmAiAttributes(clark) {
@@ -665781,7 +665994,7 @@ var AiService = class extends import_shared54.TracedEventEmitter {
665781
665994
  return void 0;
665782
665995
  } catch (error40) {
665783
665996
  if (error40 instanceof Error) {
665784
- const reason = (0, import_shared54.getAiQuotaPaywallReasonFromMessage)(error40.message);
665997
+ const reason = (0, import_shared55.getAiQuotaPaywallReasonFromMessage)(error40.message);
665785
665998
  if (reason) {
665786
665999
  await this.handlePreCallPaywall(request, reason);
665787
666000
  return reason;
@@ -666301,7 +666514,7 @@ ${apiSourceCode.slice(0, 2e3)}
666301
666514
  type: attachment.type
666302
666515
  });
666303
666516
  const attachmentMimeType = attachment.type === "uploaded" ? attachment.mediaType : attachment.type === "pdf" ? attachment.data.match(/^data:([^;]+);base64,/)?.[1] ?? "application/pdf" : attachment.type === "archive" ? attachment.data.match(/^data:([^;]+);base64,/)?.[1] ?? "application/octet-stream" : attachment.type === "image" ? attachment.image.match(/^data:([^;]+);base64,/)?.[1] ?? "image/png" : attachment.mimeType;
666304
- const delivery = (0, import_shared54.classifyAttachmentDelivery)({
666517
+ const delivery = (0, import_shared55.classifyAttachmentDelivery)({
666305
666518
  fileName: attachment.fileName,
666306
666519
  mimeType: attachmentMimeType
666307
666520
  });
@@ -666904,8 +667117,14 @@ ${request.prompt}`;
666904
667117
  if (!this.clark.context.llmConfig) {
666905
667118
  throw new Error("Cannot continue after tool permission: llmConfig is missing from context");
666906
667119
  }
667120
+ const isClarification = isToolPermissionClarification(request.approved, request.denyMessage);
667121
+ logger25.info("[ai-service] tool_permission_response continuation", {
667122
+ approved: request.approved,
667123
+ clarification: isClarification
667124
+ });
667125
+ trace.getActiveSpan()?.setAttribute("clark.tool_permission.clarification", isClarification);
666907
667126
  const continueRequest = {
666908
- prompt: request.approved ? `` : this.buildDenialContinuationPrompt(toolName, rawInput),
667127
+ prompt: request.approved ? `` : isClarification ? request.denyMessage.trim() : this.buildDenialContinuationPrompt(toolName, rawInput),
666909
667128
  promptContext: {
666910
667129
  entities: [],
666911
667130
  integrations: []
@@ -666914,12 +667133,12 @@ ${request.prompt}`;
666914
667133
  llmConfig: this.clark.context.llmConfig,
666915
667134
  mode: this.clark.context.currentMode,
666916
667135
  browserContext: this.clark.context.browserContext,
666917
- // Mark as tool_permission_response to skip user message recording in agent-planning
666918
667136
  responseMetadata: {
666919
667137
  type: "tool_permission_response",
666920
667138
  responseToMessageId: request.messageId,
666921
667139
  approved: request.approved,
666922
- alwaysAllowPermissions: request.alwaysAllowPermissions
667140
+ alwaysAllowPermissions: request.alwaysAllowPermissions,
667141
+ ...isClarification ? { clarification: true } : {}
666923
667142
  }
666924
667143
  };
666925
667144
  const transitionTo = transitionFrom(this.clark);
@@ -667369,7 +667588,7 @@ ${request.prompt}`;
667369
667588
  llmProvider
667370
667589
  };
667371
667590
  const tools = await buildSecurityScanTools(this.clark, scanToolsDeps);
667372
- const result = (0, import_ai11.streamText)({
667591
+ const result = (0, import_ai10.streamText)({
667373
667592
  messages: [
667374
667593
  { content: systemPrompt, role: "system" },
667375
667594
  {
@@ -667379,7 +667598,7 @@ ${request.prompt}`;
667379
667598
  ],
667380
667599
  model,
667381
667600
  tools,
667382
- stopWhen: (0, import_ai11.stepCountIs)(30)
667601
+ stopWhen: (0, import_ai10.stepCountIs)(30)
667383
667602
  });
667384
667603
  const peer = this.clark.context.peer;
667385
667604
  const emitAgentStep = (part) => {
@@ -667578,7 +667797,7 @@ ${request.prompt}`;
667578
667797
  if (!entityId) {
667579
667798
  throw new Error(`Missing entity id for move scope '${payload.targetScope}'`);
667580
667799
  }
667581
- const entityScope = payload.targetScope === "org" ? import_shared54.FactEntityScope.ORG : payload.targetScope === "user" ? import_shared54.FactEntityScope.USER : import_shared54.FactEntityScope.INTEGRATION;
667800
+ const entityScope = payload.targetScope === "org" ? import_shared55.FactEntityScope.ORG : payload.targetScope === "user" ? import_shared55.FactEntityScope.USER : import_shared55.FactEntityScope.INTEGRATION;
667582
667801
  let createdFactId;
667583
667802
  try {
667584
667803
  const createdFact = await this.config.rpcClient.call(async (client) => {
@@ -667589,8 +667808,8 @@ ${request.prompt}`;
667589
667808
  content: sourceFact.content,
667590
667809
  entityScope,
667591
667810
  entityId,
667592
- accessType: import_shared54.FactAccessType.ALWAYS_INJECT,
667593
- createdSource: import_shared54.FactCreatedSource.AGENT
667811
+ accessType: import_shared55.FactAccessType.ALWAYS_INJECT,
667812
+ createdSource: import_shared55.FactCreatedSource.AGENT
667594
667813
  });
667595
667814
  });
667596
667815
  createdFactId = typeof createdFact?.id === "string" ? createdFact.id : typeof createdFact?.data?.id === "string" ? createdFact.data.id : void 0;
@@ -667763,9 +667982,9 @@ ${request.prompt}`;
667763
667982
  init_cjs_shims();
667764
667983
  import { randomUUID as randomUUID6 } from "node:crypto";
667765
667984
  import { normalizePath as normalizePath8 } from "vite";
667766
- var import_shared60 = __toESM(require_dist2(), 1);
667767
- var import_shared61 = __toESM(require_dist2(), 1);
667768
- var import_shared62 = __toESM(require_dist2(), 1);
667985
+ var import_shared61 = __toESM(require_dist2());
667986
+ var import_shared62 = __toESM(require_dist2());
667987
+ var import_shared63 = __toESM(require_dist2());
667769
667988
 
667770
667989
  // ../../../vite-plugin-file-sync/dist/errors/make-server-error.js
667771
667990
  init_cjs_shims();
@@ -667816,13 +668035,13 @@ function classifyCheckpointResult(commitId, checkpointSkipped) {
667816
668035
 
667817
668036
  // ../../../vite-plugin-file-sync/dist/sync-service/download.js
667818
668037
  init_cjs_shims();
667819
- var import_shared56 = __toESM(require_dist2());
667820
668038
  var import_shared57 = __toESM(require_dist2());
668039
+ var import_shared58 = __toESM(require_dist2());
667821
668040
  import * as fsp2 from "node:fs/promises";
667822
668041
 
667823
668042
  // ../../../vite-plugin-file-sync/dist/sync-service/hash-dir-tree.js
667824
668043
  init_cjs_shims();
667825
- var import_shared55 = __toESM(require_dist2());
668044
+ var import_shared56 = __toESM(require_dist2());
667826
668045
  var import_util20 = __toESM(require_dist3());
667827
668046
 
667828
668047
  // ../../../vite-plugin-file-sync/dist/sync-service/list-dir.js
@@ -667929,7 +668148,7 @@ async function hashLocalDirectory(localDirectoryPath, rootDirectoryPath = localD
667929
668148
  let entry;
667930
668149
  switch (localDirEntry.type) {
667931
668150
  case "-": {
667932
- const hash4 = await (0, import_shared55.hashFileContents)(localDirEntry.contents);
668151
+ const hash4 = await (0, import_shared56.hashFileContents)(localDirEntry.contents);
667933
668152
  entry = {
667934
668153
  type: "-",
667935
668154
  executable: localDirEntry.executable,
@@ -667961,7 +668180,7 @@ async function hashLocalDirectory(localDirectoryPath, rootDirectoryPath = localD
667961
668180
  }
667962
668181
  directoryContents.push(entry);
667963
668182
  }
667964
- const hash3 = await (0, import_shared55.hashDirectoryContents)(directoryContents);
668183
+ const hash3 = await (0, import_shared56.hashDirectoryContents)(directoryContents);
667965
668184
  return { contents: directoryContents, hash: hash3 };
667966
668185
  }
667967
668186
 
@@ -667988,16 +668207,17 @@ async function downloadApplicationDirectory({ rpcClient, applicationId, branch,
667988
668207
  return { directoryHash: serverDirectoryHash, latestNonDraftCommitId };
667989
668208
  }
667990
668209
  async function doDownloadApplicationDirectory(rpcClient, directoryHash, oldLocalDirState, localDirectoryPath) {
667991
- const hashesToGet = {};
667992
- const doRecursive = async (rpcClient2, directoryHash2, oldLocalDirState2, localDirectoryPath2, hashesToGet2) => {
668210
+ const filesToGet = [];
668211
+ const doRecursive = async (rpcClient2, directoryHash2, oldLocalDirState2, localDirectoryPath2, dbfsPath, filesToGet2) => {
667993
668212
  if (oldLocalDirState2?.hash === directoryHash2) {
667994
668213
  return oldLocalDirState2;
667995
668214
  }
667996
668215
  const newStateContents = [];
667997
- const directoryContentsResponse = await (0, import_shared56.unwrapResponseDto)(rpcClient2.call.v1.dbfs.directoryContents.get({ hash: directoryHash2 }));
668216
+ const directoryContentsResponse = await (0, import_shared57.unwrapResponseDto)(rpcClient2.call.v1.dbfs.directoryContents.get({ hash: directoryHash2 }));
667998
668217
  const localDirMap = new Map(oldLocalDirState2?.contents.map((entry) => [entry.name, entry]) ?? []);
667999
668218
  for (const entry of directoryContentsResponse.contents) {
668000
668219
  const localFilePath = `${localDirectoryPath2}/${entry.name}`;
668220
+ const entryDbfsPath = dbfsPath === "" ? entry.name : `${dbfsPath}/${entry.name}`;
668001
668221
  let localEntry = localDirMap.get(entry.name);
668002
668222
  localDirMap.delete(entry.name);
668003
668223
  if (localEntry !== void 0 && localEntry.type !== entry.type) {
@@ -668009,10 +668229,11 @@ async function doDownloadApplicationDirectory(rpcClient, directoryHash, oldLocal
668009
668229
  newStateContents.push(entry);
668010
668230
  const localEntryTyped = localEntry;
668011
668231
  if (localEntryTyped?.hash !== entry.hash) {
668012
- hashesToGet2[entry.hash] = { localFilePath };
668013
- const fileContentsResponse = await (0, import_shared56.unwrapResponseDto)(rpcClient2.call.v1.dbfs.fileContents.get({ hash: entry.hash }));
668014
- const fileContents = Buffer.from(fileContentsResponse.contents, "base64");
668015
- await fsp2.writeFile(localFilePath, fileContents);
668232
+ filesToGet2.push({
668233
+ dbfsPath: entryDbfsPath,
668234
+ hash: entry.hash,
668235
+ localFilePath
668236
+ });
668016
668237
  }
668017
668238
  break;
668018
668239
  }
@@ -668033,7 +668254,7 @@ async function doDownloadApplicationDirectory(rpcClient, directoryHash, oldLocal
668033
668254
  hash: localEntryTyped.hash,
668034
668255
  contents: localEntryTyped.contents
668035
668256
  };
668036
- const newSubDirState = await doRecursive(rpcClient2, entry.hash, localSubDirState, localFilePath, hashesToGet2);
668257
+ const newSubDirState = await doRecursive(rpcClient2, entry.hash, localSubDirState, localFilePath, entryDbfsPath, filesToGet2);
668037
668258
  newStateContents.push({
668038
668259
  ...entry,
668039
668260
  contents: newSubDirState.contents
@@ -668059,25 +668280,88 @@ async function doDownloadApplicationDirectory(rpcClient, directoryHash, oldLocal
668059
668280
  contents: newStateContents
668060
668281
  };
668061
668282
  };
668062
- const newLocalDirState = await doRecursive(rpcClient, directoryHash, oldLocalDirState, localDirectoryPath, hashesToGet);
668283
+ const newLocalDirState = await doRecursive(rpcClient, directoryHash, oldLocalDirState, localDirectoryPath, "", filesToGet);
668284
+ const downloadedWithGetMany = await tryDownloadFilesByPath(rpcClient, directoryHash, filesToGet);
668285
+ if (downloadedWithGetMany) {
668286
+ return newLocalDirState;
668287
+ }
668063
668288
  const DOWNLOAD_BATCH_SIZE = 50;
668064
- const entries = Object.entries(hashesToGet);
668065
- for (let i2 = 0; i2 < entries.length; i2 += DOWNLOAD_BATCH_SIZE) {
668066
- const batch = entries.slice(i2, i2 + DOWNLOAD_BATCH_SIZE);
668067
- await Promise.all(batch.map(async ([hash3, { localFilePath }]) => {
668068
- const fileContentsResponse = await (0, import_shared56.unwrapResponseDto)(rpcClient.call.v1.dbfs.fileContents.get({ hash: hash3 }));
668289
+ for (let i2 = 0; i2 < filesToGet.length; i2 += DOWNLOAD_BATCH_SIZE) {
668290
+ const batch = filesToGet.slice(i2, i2 + DOWNLOAD_BATCH_SIZE);
668291
+ await Promise.all(batch.map(async ({ hash: hash3, localFilePath }) => {
668292
+ const fileContentsResponse = await (0, import_shared57.unwrapResponseDto)(rpcClient.call.v1.dbfs.fileContents.get({ hash: hash3 }));
668069
668293
  const fileContents = Buffer.from(fileContentsResponse.contents, "base64");
668070
668294
  await fsp2.writeFile(localFilePath, fileContents);
668071
668295
  }));
668072
668296
  }
668073
668297
  return newLocalDirState;
668074
668298
  }
668299
+ async function tryDownloadFilesByPath(rpcClient, rootHash, filesToGet) {
668300
+ if (filesToGet.length === 0) {
668301
+ return true;
668302
+ }
668303
+ const getMany = rpcClient.call.v1.dbfs.getMany;
668304
+ if (getMany === void 0) {
668305
+ return false;
668306
+ }
668307
+ try {
668308
+ const response = await (0, import_shared57.unwrapResponseDto)(getMany({
668309
+ rootHash,
668310
+ paths: filesToGet.map((file2) => file2.dbfsPath)
668311
+ }));
668312
+ const itemByPath = new Map(response.items.map((item) => [item.path, item]));
668313
+ if (response.items.length !== filesToGet.length) {
668314
+ throw new InvalidGetManyResponseError(`DBFS getMany returned ${response.items.length} items for ${filesToGet.length} requested files`);
668315
+ }
668316
+ const filesWithContents = filesToGet.map((file2) => {
668317
+ const item = itemByPath.get(file2.dbfsPath);
668318
+ if (item?.type !== "fileContents") {
668319
+ throw new InvalidGetManyResponseError(`DBFS getMany did not return file contents for ${file2.dbfsPath}`);
668320
+ }
668321
+ if (item.hash !== file2.hash) {
668322
+ throw new InvalidGetManyResponseError(`DBFS getMany returned hash ${item.hash} for ${file2.dbfsPath}, expected ${file2.hash}`);
668323
+ }
668324
+ return {
668325
+ file: file2,
668326
+ contents: Buffer.from(item.contents, "base64")
668327
+ };
668328
+ });
668329
+ for (const { file: file2, contents: contents2 } of filesWithContents) {
668330
+ await fsp2.writeFile(file2.localFilePath, contents2);
668331
+ }
668332
+ return true;
668333
+ } catch (e) {
668334
+ if (e instanceof InvalidGetManyResponseError || isGetManyUnsupported(e) || isBulkReadLimitError(e)) {
668335
+ getLogger3().warn(`DBFS getMany unavailable, invalid, or exceeded bulk limits (${getErrorMessage3(e)}), falling back to per-file download`);
668336
+ return false;
668337
+ }
668338
+ throw e;
668339
+ }
668340
+ }
668341
+ var InvalidGetManyResponseError = class extends Error {
668342
+ };
668343
+ function isSocketError(e) {
668344
+ return typeof e === "object" && e !== null && "code" in e && typeof e.code === "number" && "message" in e && typeof e.message === "string";
668345
+ }
668346
+ function getErrorMessage3(e) {
668347
+ if (e instanceof Error || isSocketError(e)) {
668348
+ return e.message;
668349
+ }
668350
+ return String(e);
668351
+ }
668352
+ function isBulkReadLimitError(e) {
668353
+ const message = getErrorMessage3(e);
668354
+ return message.includes("maxObjects") || message.includes("maxBytes") || message.includes("bulk read");
668355
+ }
668356
+ function isGetManyUnsupported(e) {
668357
+ return isSocketError(e) && e.code === 2 || getErrorMessage3(e).includes("is not implemented");
668358
+ }
668075
668359
  async function getDraftOrLiveDirectoryHash(rpcClient, applicationId, branch) {
668076
668360
  try {
668077
- const response = await (0, import_shared56.unwrapResponseDto)(rpcClient.call.v3.application.directoryContents.get({
668361
+ const response = await (0, import_shared57.unwrapResponseDto)(rpcClient.call.v3.application.directoryContents.get({
668078
668362
  applicationId,
668079
668363
  branchName: branch,
668080
- viewMode: import_shared57.ExportViewMode.EXPORT_LIVE_EDIT
668364
+ viewMode: import_shared58.ExportViewMode.EXPORT_LIVE_EDIT
668081
668365
  }));
668082
668366
  const directoryHash = response;
668083
668367
  return {
@@ -668094,10 +668378,10 @@ async function getDraftOrLiveDirectoryHash(rpcClient, applicationId, branch) {
668094
668378
  }
668095
668379
  async function getDraftOrLiveCommitDirectoryHash(rpcClient, applicationId, branch) {
668096
668380
  try {
668097
- const response = await (0, import_shared56.unwrapResponseDto)(rpcClient.call.v3.application.directoryContents.get({
668381
+ const response = await (0, import_shared57.unwrapResponseDto)(rpcClient.call.v3.application.directoryContents.get({
668098
668382
  applicationId,
668099
668383
  branchName: branch,
668100
- viewMode: import_shared57.ExportViewMode.EXPORT_DRAFT
668384
+ viewMode: import_shared58.ExportViewMode.EXPORT_DRAFT
668101
668385
  }));
668102
668386
  const directoryHash = response;
668103
668387
  return {
@@ -668105,11 +668389,11 @@ async function getDraftOrLiveCommitDirectoryHash(rpcClient, applicationId, branc
668105
668389
  latestNonDraftCommitId: directoryHash.latestNonDraftCommitId
668106
668390
  };
668107
668391
  } catch (e) {
668108
- if (e instanceof import_shared56.NotFoundError) {
668109
- const response = await (0, import_shared56.unwrapResponseDto)(rpcClient.call.v3.application.directoryContents.get({
668392
+ if (e instanceof import_shared57.NotFoundError) {
668393
+ const response = await (0, import_shared57.unwrapResponseDto)(rpcClient.call.v3.application.directoryContents.get({
668110
668394
  applicationId,
668111
668395
  branchName: branch,
668112
- viewMode: import_shared57.ExportViewMode.EXPORT_LIVE
668396
+ viewMode: import_shared58.ExportViewMode.EXPORT_LIVE
668113
668397
  }));
668114
668398
  getLogger3().warn(`Draft commit not found, falling back to the latest live commit: ${response.hash}`);
668115
668399
  const directoryHash = response;
@@ -668122,7 +668406,7 @@ async function getDraftOrLiveCommitDirectoryHash(rpcClient, applicationId, branc
668122
668406
  }
668123
668407
  }
668124
668408
  function isMissingLiveEditOrUnsupportedViewMode(e) {
668125
- if (e instanceof import_shared56.NotFoundError) {
668409
+ if (e instanceof import_shared57.NotFoundError) {
668126
668410
  return true;
668127
668411
  }
668128
668412
  const message = e instanceof Error ? e.message : String(e);
@@ -668560,7 +668844,7 @@ var HashCache = class {
668560
668844
 
668561
668845
  // ../../../vite-plugin-file-sync/dist/sync-service/snapshot/take-snapshot.js
668562
668846
  init_cjs_shims();
668563
- var import_shared58 = __toESM(require_dist2());
668847
+ var import_shared59 = __toESM(require_dist2());
668564
668848
  var import_util21 = __toESM(require_dist3());
668565
668849
  async function snapshotLocalDirectory(localDirectoryPath, rootDirectoryPath = localDirectoryPath) {
668566
668850
  const directoryContents = [];
@@ -668569,7 +668853,7 @@ async function snapshotLocalDirectory(localDirectoryPath, rootDirectoryPath = lo
668569
668853
  let entry;
668570
668854
  switch (localDirEntry.type) {
668571
668855
  case "-": {
668572
- const hash3 = await (0, import_shared58.hashFileContents)(localDirEntry.contents);
668856
+ const hash3 = await (0, import_shared59.hashFileContents)(localDirEntry.contents);
668573
668857
  entry = {
668574
668858
  type: "-",
668575
668859
  name: localDirEntry.name,
@@ -668602,7 +668886,7 @@ async function snapshotLocalDirectory(localDirectoryPath, rootDirectoryPath = lo
668602
668886
  }
668603
668887
  directoryContents.push(entry);
668604
668888
  }
668605
- const directoryHash = await (0, import_shared58.hashDirectoryContents)(directoryContents);
668889
+ const directoryHash = await (0, import_shared59.hashDirectoryContents)(directoryContents);
668606
668890
  return {
668607
668891
  hash: directoryHash,
668608
668892
  contents: directoryContents
@@ -668614,7 +668898,7 @@ async function snapshotLocalDirectoryWithDrafts(localDirectoryPath) {
668614
668898
 
668615
668899
  // ../../../vite-plugin-file-sync/dist/sync-service/snapshot/upload-snapshot.js
668616
668900
  init_cjs_shims();
668617
- var import_shared59 = __toESM(require_dist2());
668901
+ var import_shared60 = __toESM(require_dist2());
668618
668902
  var BATCH_SIZE2 = 64;
668619
668903
  async function uploadDirectorySnapshot(rpcClient, directorySnapshot, hashCache) {
668620
668904
  const itemsToUpload = [];
@@ -668669,7 +668953,7 @@ async function uploadDirectorySnapshot(rpcClient, directorySnapshot, hashCache)
668669
668953
  await processRecursively(directorySnapshot);
668670
668954
  for (let idx = 0; idx < itemsToUpload.length; idx += BATCH_SIZE2) {
668671
668955
  const batch = itemsToUpload.slice(idx, idx + BATCH_SIZE2);
668672
- await (0, import_shared59.unwrapResponseDto)(rpcClient.call.v1.dbfs.putMany({
668956
+ await (0, import_shared60.unwrapResponseDto)(rpcClient.call.v1.dbfs.putMany({
668673
668957
  items: batch
668674
668958
  }));
668675
668959
  }
@@ -668717,7 +669001,7 @@ function isTransientAiAcceptUploadError(error40) {
668717
669001
  return msg.includes("Connection closed") || msg.includes("RPC client is shutting down") || msg.includes("RPC timeout") || msg.toLowerCase().includes("deadline exceeded");
668718
669002
  }
668719
669003
  var sleep = (ms2) => new Promise((resolve13) => setTimeout(resolve13, ms2));
668720
- var SyncService = class extends import_shared60.TracedEventEmitter {
669004
+ var SyncService = class extends import_shared61.TracedEventEmitter {
668721
669005
  appRootDirPath;
668722
669006
  applicationId;
668723
669007
  _branchName;
@@ -668776,7 +669060,7 @@ var SyncService = class extends import_shared60.TracedEventEmitter {
668776
669060
  "discardLocalDraftChanges",
668777
669061
  "commitLocalDraftChanges"
668778
669062
  ];
668779
- (0, import_shared60.addTracingToMethods)(this, methods, this._tracer);
669063
+ (0, import_shared61.addTracingToMethods)(this, methods, this._tracer);
668780
669064
  }
668781
669065
  getLogger() {
668782
669066
  return this._logger;
@@ -669053,7 +669337,7 @@ var SyncService = class extends import_shared60.TracedEventEmitter {
669053
669337
  await uploadDirectorySnapshot(rpcClient, directorySnapshot, this.hashCache);
669054
669338
  return;
669055
669339
  } catch (error40) {
669056
- if (error40 instanceof import_shared61.BadRequestError) {
669340
+ if (error40 instanceof import_shared62.BadRequestError) {
669057
669341
  retryCount++;
669058
669342
  logSyncError(this.getLogger(), error40, "[sync-service] Error synchronizing directory and server with error: " + error40.message);
669059
669343
  this.getLogger().warn("[sync-service] Retrying upload due to BadRequestError and clearing hash cache");
@@ -669102,7 +669386,7 @@ var SyncService = class extends import_shared60.TracedEventEmitter {
669102
669386
  payload.selfRestart = true;
669103
669387
  }
669104
669388
  this.getLogger().info(`[sync-service] setApplicationHash RPC start (source=${source2})`);
669105
- return (0, import_shared62.unwrapResponseDto)(rpcClient.call.v3.application.liveEditDirectoryContents.set(payload));
669389
+ return (0, import_shared63.unwrapResponseDto)(rpcClient.call.v3.application.liveEditDirectoryContents.set(payload));
669106
669390
  });
669107
669391
  if (degradedMode) {
669108
669392
  const errMsg = "There is an issue with the application and it was put in degraded mode: " + degradedMode.errors.map((e) => e.message).join("\n");
@@ -669151,7 +669435,7 @@ var SyncService = class extends import_shared60.TracedEventEmitter {
669151
669435
  */
669152
669436
  async flipTemplate({ targetTemplateName, migrationGeneration, selfRestart }) {
669153
669437
  if (!targetTemplateName) {
669154
- throw new import_shared61.BadRequestError("flipTemplate requires a non-empty targetTemplateName");
669438
+ throw new import_shared62.BadRequestError("flipTemplate requires a non-empty targetTemplateName");
669155
669439
  }
669156
669440
  this.getLogger().info(`[sync-service] Flipping template to ${targetTemplateName}`);
669157
669441
  return this.fsOperation(async () => {
@@ -669523,8 +669807,8 @@ var SyncService = class extends import_shared60.TracedEventEmitter {
669523
669807
 
669524
669808
  // ../../../vite-plugin-file-sync/dist/lock-service/index.js
669525
669809
  init_cjs_shims();
669526
- var import_shared63 = __toESM(require_dist2(), 1);
669527
- var import_shared64 = __toESM(require_dist2(), 1);
669810
+ var import_shared64 = __toESM(require_dist2());
669811
+ var import_shared65 = __toESM(require_dist2());
669528
669812
 
669529
669813
  // ../../../vite-plugin-file-sync/dist/lock-service/activity-tracker.js
669530
669814
  init_cjs_shims();
@@ -669650,7 +669934,7 @@ var ActivityTracker = class {
669650
669934
  // ../../../vite-plugin-file-sync/dist/lock-service/index.js
669651
669935
  var LOCK_HEARTBEAT_INTERVAL_MS = 30 * 1e3;
669652
669936
  var LOCK_BUFFER_MS = 30 * 1e3;
669653
- var STARTUP_CONNECTION_TIMEOUT_MS = 90 * 1e3;
669937
+ var STARTUP_CONNECTION_TIMEOUT_MS = 4 * 60 * 1e3;
669654
669938
  var LockServiceStatus;
669655
669939
  (function(LockServiceStatus2) {
669656
669940
  LockServiceStatus2["IDLE"] = "IDLE";
@@ -669666,7 +669950,7 @@ var LockType;
669666
669950
  LockType2["LOCAL"] = "local";
669667
669951
  LockType2["CSB"] = "csb";
669668
669952
  })(LockType || (LockType = {}));
669669
- var LockService = class extends import_shared63.TracedEventEmitter {
669953
+ var LockService = class extends import_shared64.TracedEventEmitter {
669670
669954
  applicationId;
669671
669955
  branchName;
669672
669956
  lockType;
@@ -669692,7 +669976,6 @@ var LockService = class extends import_shared63.TracedEventEmitter {
669692
669976
  _rpcClient;
669693
669977
  _inactivityThresholdMs;
669694
669978
  _lockBufferMs;
669695
- _startupConnectionTimeoutMs;
669696
669979
  _startupConnectionTimeout;
669697
669980
  _startupConnectionTimeoutStartedAt;
669698
669981
  _startupConnectionTimeoutExpired = false;
@@ -669705,7 +669988,6 @@ var LockService = class extends import_shared63.TracedEventEmitter {
669705
669988
  this._inactivityThresholdMs = config4.inactivityThresholdMs;
669706
669989
  this.heartbeatIntervalMs = config4.heartbeatIntervalMs || LOCK_HEARTBEAT_INTERVAL_MS;
669707
669990
  this._lockBufferMs = config4.lockBufferMs || LOCK_BUFFER_MS;
669708
- this._startupConnectionTimeoutMs = config4.startupConnectionTimeoutMs ?? STARTUP_CONNECTION_TIMEOUT_MS;
669709
669991
  this._rpcClient = config4.rpcClient;
669710
669992
  this._tracer = config4.tracer;
669711
669993
  this._logger = config4.logger;
@@ -669725,7 +670007,7 @@ var LockService = class extends import_shared63.TracedEventEmitter {
669725
670007
  "shutdownAndExit",
669726
670008
  "restartInactivityTimer"
669727
670009
  ];
669728
- (0, import_shared63.addTracingToMethods)(this, methods, this._tracer);
670010
+ (0, import_shared64.addTracingToMethods)(this, methods, this._tracer);
669729
670011
  void this.restartInactivityTimer();
669730
670012
  }
669731
670013
  getLogger() {
@@ -669784,7 +670066,7 @@ var LockService = class extends import_shared63.TracedEventEmitter {
669784
670066
  this.stopHeartbeat();
669785
670067
  try {
669786
670068
  const lockResponse = await this._rpcClient.call(async (client) => {
669787
- return (0, import_shared64.unwrapResponseDto)(client.call.v3.lock.transfer({
670069
+ return (0, import_shared65.unwrapResponseDto)(client.call.v3.lock.transfer({
669788
670070
  applicationId: this.applicationId,
669789
670071
  fromBranchName: previousBranchName,
669790
670072
  toBranchName: nextBranchName,
@@ -669831,7 +670113,7 @@ var LockService = class extends import_shared63.TracedEventEmitter {
669831
670113
  this.stopHeartbeat();
669832
670114
  try {
669833
670115
  const lockResponse = await this._rpcClient.call(async (client) => {
669834
- return (0, import_shared64.unwrapResponseDto)(client.call.v3.lock.acquire({
670116
+ return (0, import_shared65.unwrapResponseDto)(client.call.v3.lock.acquire({
669835
670117
  applicationId: this.applicationId,
669836
670118
  branchName: this.branchName,
669837
670119
  sessionType: this.lockType
@@ -669848,7 +670130,7 @@ var LockService = class extends import_shared63.TracedEventEmitter {
669848
670130
  return;
669849
670131
  }
669850
670132
  } catch (error40) {
669851
- if (error40 instanceof import_shared63.ConflictError) {
670133
+ if (error40 instanceof import_shared64.ConflictError) {
669852
670134
  this.getLogger().error(`[lock-service] ${error40.message}`);
669853
670135
  this.emit("statusChange", LockServiceStatus.FAILED_TO_ACQUIRE_LOCK);
669854
670136
  this.status = LockServiceStatus.FAILED_TO_ACQUIRE_LOCK;
@@ -669878,7 +670160,7 @@ var LockService = class extends import_shared63.TracedEventEmitter {
669878
670160
  return true;
669879
670161
  }
669880
670162
  await this._rpcClient.call(async (client) => {
669881
- await (0, import_shared64.unwrapResponseDto)(client.call.v3.lock.release({
670163
+ await (0, import_shared65.unwrapResponseDto)(client.call.v3.lock.release({
669882
670164
  applicationId: this.applicationId,
669883
670165
  branchName: this.branchName,
669884
670166
  lockId: lockIdToRelease
@@ -669889,7 +670171,7 @@ var LockService = class extends import_shared63.TracedEventEmitter {
669889
670171
  this.getLogger().info("[lock-service] lock released");
669890
670172
  return true;
669891
670173
  } catch (error40) {
669892
- if (error40 instanceof import_shared63.NotFoundError) {
670174
+ if (error40 instanceof import_shared64.NotFoundError) {
669893
670175
  this.status = LockServiceStatus.LOCK_RELEASED;
669894
670176
  this.emit("statusChange", LockServiceStatus.LOCK_RELEASED);
669895
670177
  this.getLogger().warn("[lock-service] lock already released on server");
@@ -669914,7 +670196,7 @@ var LockService = class extends import_shared63.TracedEventEmitter {
669914
670196
  async grabLockImpl() {
669915
670197
  if (this._lockId) {
669916
670198
  const lockResponse = await this._rpcClient.call(async (client) => {
669917
- return (0, import_shared64.unwrapResponseDto)(client.call.v3.lock.grab({
670199
+ return (0, import_shared65.unwrapResponseDto)(client.call.v3.lock.grab({
669918
670200
  applicationId: this.applicationId,
669919
670201
  branchName: this.branchName,
669920
670202
  lockId: this._lockId
@@ -669929,7 +670211,7 @@ var LockService = class extends import_shared63.TracedEventEmitter {
669929
670211
  */
669930
670212
  async inspectLock() {
669931
670213
  const lockInfo = await this._rpcClient.call(async (client) => {
669932
- return (0, import_shared64.unwrapResponseDto)(client.call.v3.lock.inspect({
670214
+ return (0, import_shared65.unwrapResponseDto)(client.call.v3.lock.inspect({
669933
670215
  applicationId: this.applicationId,
669934
670216
  branchName: this.branchName
669935
670217
  }));
@@ -669944,7 +670226,7 @@ var LockService = class extends import_shared63.TracedEventEmitter {
669944
670226
  this.status = LockServiceStatus.ACQUIRING;
669945
670227
  try {
669946
670228
  const lockResponse = await this._rpcClient.call(async (client) => {
669947
- return (0, import_shared64.unwrapResponseDto)(client.call.v3.lock.forceTake({
670229
+ return (0, import_shared65.unwrapResponseDto)(client.call.v3.lock.forceTake({
669948
670230
  applicationId: this.applicationId,
669949
670231
  branchName: this.branchName,
669950
670232
  sessionType: this.lockType
@@ -669976,7 +670258,7 @@ var LockService = class extends import_shared63.TracedEventEmitter {
669976
670258
  const returnedLock = response.appBranchLock[0];
669977
670259
  if (returnedLock.sessionType && returnedLock.sessionType !== this.lockType) {
669978
670260
  this.getLogger().warn(`[lock-service] lock fallback returned mismatched session type (${returnedLock.sessionType}) for expected ${this.lockType}; ignoring fallback lock`);
669979
- throw new import_shared63.NotFoundError("Lock not found");
670261
+ throw new import_shared64.NotFoundError("Lock not found");
669980
670262
  }
669981
670263
  if (returnedLock.lockId && returnedLock.lockId !== this._lockId) {
669982
670264
  this.getLogger().info(`[lock-service] lock ID changed from ${this._lockId} to ${returnedLock.lockId} (cross-branch transfer)`);
@@ -669986,7 +670268,7 @@ var LockService = class extends import_shared63.TracedEventEmitter {
669986
670268
  return true;
669987
670269
  }
669988
670270
  } catch (error40) {
669989
- if (error40 instanceof import_shared63.NotFoundError) {
670271
+ if (error40 instanceof import_shared64.NotFoundError) {
669990
670272
  this.getLogger().warn("[lock-service] lock not found during heartbeat grab, attempting to reacquire before shutdown");
669991
670273
  this.stopHeartbeat();
669992
670274
  this._lockId = void 0;
@@ -669996,7 +670278,7 @@ var LockService = class extends import_shared63.TracedEventEmitter {
669996
670278
  this.getLogger().info("[lock-service] lock reacquired after heartbeat grab miss");
669997
670279
  return true;
669998
670280
  } catch (reacquireError) {
669999
- if (reacquireError instanceof import_shared63.ConflictError) {
670281
+ if (reacquireError instanceof import_shared64.ConflictError) {
670000
670282
  const message = "\u26A0\uFE0F Edit access lost \u2013 another user has taken over this branch. Shutting down server.";
670001
670283
  if (process.env.SUPERBLOCKS_VSCODE === "true") {
670002
670284
  this.getLogger().error(`clierr: ${JSON.stringify({ message })}`);
@@ -670161,17 +670443,17 @@ var LockService = class extends import_shared63.TracedEventEmitter {
670161
670443
  this._startupConnectionTimeoutStartedAt = void 0;
670162
670444
  }
670163
670445
  startStartupConnectionTimeoutIfNeeded() {
670164
- if (this._startupConnectionTimeoutStartedAt !== void 0 || this._startupConnectionTimeoutMs === void 0 || this._startupConnectionTimeoutMs <= 0) {
670446
+ if (this._startupConnectionTimeoutStartedAt !== void 0) {
670165
670447
  return;
670166
670448
  }
670167
670449
  this.clearStartupConnectionTimeout();
670168
670450
  this._startupConnectionTimeoutStartedAt = Date.now();
670169
- this.getLogger().debug(`[lock-service] starting initial connection timeout window (${this._startupConnectionTimeoutMs}ms)`);
670451
+ this.getLogger().info(`[lock-service] starting initial connection timeout window (${STARTUP_CONNECTION_TIMEOUT_MS}ms)`);
670170
670452
  this._startupConnectionTimeout = setTimeout(() => {
670171
670453
  this._startupConnectionTimeout = void 0;
670172
670454
  this._startupConnectionTimeoutExpired = true;
670173
670455
  this.evaluateStartupConnectionTimeoutIfNeeded();
670174
- }, this._startupConnectionTimeoutMs);
670456
+ }, STARTUP_CONNECTION_TIMEOUT_MS);
670175
670457
  this._startupConnectionTimeout.unref();
670176
670458
  }
670177
670459
  evaluateStartupConnectionTimeoutIfNeeded() {
@@ -670184,10 +670466,10 @@ var LockService = class extends import_shared63.TracedEventEmitter {
670184
670466
  if (this._activityTracker.connectedUsers.length > 0) {
670185
670467
  return;
670186
670468
  }
670187
- this.getLogger().warn(`[lock-service] no socket connection detected within ${this._startupConnectionTimeoutMs}ms after initial lock acquisition, marking session inactive`);
670469
+ this.getLogger().warn(`[lock-service] no socket connection detected within ${STARTUP_CONNECTION_TIMEOUT_MS}ms after initial lock acquisition, marking session inactive (lockId=${this._lockId}, appId=${this.applicationId})`);
670188
670470
  this._activityTracker.markDisconnectedDueToStartupTimeout();
670189
670471
  void this.evaluateLockState().catch((error40) => {
670190
- this.getLogger().error("[lock-service] failed to evaluate lock state after startup connection timeout", getErrorMeta2(error40));
670472
+ this.getLogger().error(`[lock-service] failed to evaluate lock state after startup connection timeout (lockId=${this._lockId}, appId=${this.applicationId})`, getErrorMeta2(error40));
670191
670473
  });
670192
670474
  }
670193
670475
  /**
@@ -670279,12 +670561,12 @@ init_cjs_shims();
670279
670561
 
670280
670562
  // ../../../vite-plugin-file-sync/dist/server-rpc/client.js
670281
670563
  init_cjs_shims();
670282
- var import_shared66 = __toESM(require_dist2());
670564
+ var import_shared67 = __toESM(require_dist2());
670283
670565
 
670284
670566
  // ../../../vite-plugin-file-sync/package.json
670285
670567
  var package_default2 = {
670286
670568
  name: "@superblocksteam/vite-plugin-file-sync",
670287
- version: "2.0.141-next.0",
670569
+ version: "2.0.141-next.1",
670288
670570
  keywords: [
670289
670571
  "vite-plugin"
670290
670572
  ],
@@ -670486,9 +670768,9 @@ var package_default2 = {
670486
670768
 
670487
670769
  // ../../../vite-plugin-file-sync/dist/server-rpc/handlers.js
670488
670770
  init_cjs_shims();
670489
- var import_shared65 = __toESM(require_dist2());
670771
+ var import_shared66 = __toESM(require_dist2());
670490
670772
  async function notImplemented() {
670491
- throw new import_shared65.NotImplementedError("Signing methods are not implemented");
670773
+ throw new import_shared66.NotImplementedError("Signing methods are not implemented");
670492
670774
  }
670493
670775
  function createRequestHandlers() {
670494
670776
  const requestHandlers = {
@@ -670505,11 +670787,11 @@ function createRequestHandlers() {
670505
670787
  }
670506
670788
 
670507
670789
  // ../../../vite-plugin-file-sync/dist/server-rpc/client.js
670508
- var DEV_SERVER_USER_AGENT = (0, import_shared66.buildClientUserAgent)("superblocks-dev-server", package_default2.version);
670790
+ var DEV_SERVER_USER_AGENT = (0, import_shared67.buildClientUserAgent)("superblocks-dev-server", package_default2.version);
670509
670791
  async function connectToISocketRPCServer({ superblocksBaseUrl, token: token2, tracer: tracer3, onClose }) {
670510
670792
  const requestHandlers = createRequestHandlers();
670511
670793
  const authorization = `Bearer ${token2}`;
670512
- const wsUrl = new URL(`api/${import_shared66.serverWsPath}`, superblocksBaseUrl);
670794
+ const wsUrl = new URL(`api/${import_shared67.serverWsPath}`, superblocksBaseUrl);
670513
670795
  if (wsUrl.protocol === "http:") {
670514
670796
  wsUrl.protocol = "ws:";
670515
670797
  } else if (wsUrl.protocol === "https:") {
@@ -670520,11 +670802,11 @@ async function connectToISocketRPCServer({ superblocksBaseUrl, token: token2, tr
670520
670802
  } else if (wsUrl.hostname === "localhost") {
670521
670803
  wsUrl.hostname = "127.0.0.1";
670522
670804
  }
670523
- const ws2 = await (0, import_shared66.connectWebSocket)(wsUrl.href, {
670805
+ const ws2 = await (0, import_shared67.connectWebSocket)(wsUrl.href, {
670524
670806
  timeout: 5e3,
670525
670807
  headers: { "User-Agent": DEV_SERVER_USER_AGENT }
670526
670808
  });
670527
- const isocket = new import_shared66.ISocketWithClientAuth(ws2, authorization, requestHandlers, [], tracer3, {
670809
+ const isocket = new import_shared67.ISocketWithClientAuth(ws2, authorization, requestHandlers, [], tracer3, {
670528
670810
  onClose,
670529
670811
  timeouts: {
670530
670812
  connectionTimeoutInSeconds: 6 * 60,
@@ -670533,7 +670815,7 @@ async function connectToISocketRPCServer({ superblocksBaseUrl, token: token2, tr
670533
670815
  // 5 minutes (for judge evaluation)
670534
670816
  }
670535
670817
  });
670536
- const client = (0, import_shared66.createISocketClient)(isocket);
670818
+ const client = (0, import_shared67.createISocketClient)(isocket);
670537
670819
  return client;
670538
670820
  }
670539
670821
 
@@ -670649,7 +670931,7 @@ init_cjs_shims();
670649
670931
  var import_archiver2 = __toESM(require_archiver());
670650
670932
  var import_body_parser4 = __toESM(require_body_parser());
670651
670933
  init_lodash();
670652
- var import_shared78 = __toESM(require_dist2());
670934
+ var import_shared79 = __toESM(require_dist2());
670653
670935
  import { readFileSync as readFileSync4, writeFileSync as writeFileSync4, unlinkSync } from "node:fs";
670654
670936
  import path61 from "node:path";
670655
670937
  import { pipeline as pipeline5 } from "node:stream/promises";
@@ -670789,7 +671071,7 @@ init_cjs_shims();
670789
671071
  // ../../../vite-plugin-file-sync/dist/socket-manager.js
670790
671072
  init_cjs_shims();
670791
671073
  var import_ws = __toESM(require_ws());
670792
- var import_shared72 = __toESM(require_dist2());
671074
+ var import_shared73 = __toESM(require_dist2());
670793
671075
  import { cp as cp3, mkdir as mkdir19, mkdtemp as mkdtemp2, rm as rm15 } from "node:fs/promises";
670794
671076
  import { tmpdir as tmpdir3 } from "node:os";
670795
671077
  import { join as join26 } from "node:path";
@@ -670833,7 +671115,7 @@ function parseGitLog(raw) {
670833
671115
 
670834
671116
  // ../../../vite-plugin-file-sync/dist/git-service/azure-devops-workflow.js
670835
671117
  init_cjs_shims();
670836
- var import_shared67 = __toESM(require_dist2());
671118
+ var import_shared68 = __toESM(require_dist2());
670837
671119
 
670838
671120
  // ../../../vite-plugin-file-sync/dist/git-service/ensure-workflow-file.js
670839
671121
  init_cjs_shims();
@@ -670887,57 +671169,57 @@ function ensureAzureDevOpsWorkflowFile(gitService, superblocksBaseUrl) {
670887
671169
  return ensureWorkflowFile(gitService, {
670888
671170
  providerName: "azure-devops",
670889
671171
  workflowPath: AZURE_DEVOPS_PIPELINE_PATH,
670890
- isProviderRemoteUrl: import_shared67.isAzureDevOpsRemoteUrl,
670891
- buildWorkflowFromBaseUrl: import_shared67.buildAzureDevOpsSuperblocksSyncPipelineFromBaseUrl
671172
+ isProviderRemoteUrl: import_shared68.isAzureDevOpsRemoteUrl,
671173
+ buildWorkflowFromBaseUrl: import_shared68.buildAzureDevOpsSuperblocksSyncPipelineFromBaseUrl
670892
671174
  }, superblocksBaseUrl);
670893
671175
  }
670894
671176
 
670895
671177
  // ../../../vite-plugin-file-sync/dist/git-service/bitbucket-workflow.js
670896
671178
  init_cjs_shims();
670897
- var import_shared68 = __toESM(require_dist2());
671179
+ var import_shared69 = __toESM(require_dist2());
670898
671180
  var BITBUCKET_PIPELINE_PATH = "bitbucket-pipelines.yml";
670899
671181
  function ensureBitbucketWorkflowFile(gitService, superblocksBaseUrl) {
670900
671182
  return ensureWorkflowFile(gitService, {
670901
671183
  providerName: "bitbucket",
670902
671184
  workflowPath: BITBUCKET_PIPELINE_PATH,
670903
- isProviderRemoteUrl: import_shared68.isBitbucketRemoteUrl,
670904
- buildWorkflowFromBaseUrl: import_shared68.buildBitbucketSuperblocksSyncPipelineFromBaseUrl
671185
+ isProviderRemoteUrl: import_shared69.isBitbucketRemoteUrl,
671186
+ buildWorkflowFromBaseUrl: import_shared69.buildBitbucketSuperblocksSyncPipelineFromBaseUrl
670905
671187
  }, superblocksBaseUrl);
670906
671188
  }
670907
671189
 
670908
671190
  // ../../../vite-plugin-file-sync/dist/git-service/github-workflow.js
670909
671191
  init_cjs_shims();
670910
- var import_shared69 = __toESM(require_dist2());
671192
+ var import_shared70 = __toESM(require_dist2());
670911
671193
  var GITHUB_WORKFLOW_PATH = ".github/workflows/superblocks-sync.yml";
670912
671194
  function ensureGithubWorkflowFile(gitService, superblocksBaseUrl) {
670913
671195
  return ensureWorkflowFile(gitService, {
670914
671196
  providerName: "github",
670915
671197
  workflowPath: GITHUB_WORKFLOW_PATH,
670916
- isProviderRemoteUrl: import_shared69.isGitHubRemoteUrl,
670917
- buildWorkflowFromBaseUrl: import_shared69.buildGithubSuperblocksSyncWorkflowFromBaseUrl
671198
+ isProviderRemoteUrl: import_shared70.isGitHubRemoteUrl,
671199
+ buildWorkflowFromBaseUrl: import_shared70.buildGithubSuperblocksSyncWorkflowFromBaseUrl
670918
671200
  }, superblocksBaseUrl);
670919
671201
  }
670920
671202
 
670921
671203
  // ../../../vite-plugin-file-sync/dist/git-service/gitlab-workflow.js
670922
671204
  init_cjs_shims();
670923
- var import_shared70 = __toESM(require_dist2());
671205
+ var import_shared71 = __toESM(require_dist2());
670924
671206
  var GITLAB_WORKFLOW_PATH = ".gitlab-ci.yml";
670925
671207
  function ensureGitlabWorkflowFile(gitService, superblocksBaseUrl) {
670926
671208
  return ensureWorkflowFile(gitService, {
670927
671209
  providerName: "gitlab",
670928
671210
  workflowPath: GITLAB_WORKFLOW_PATH,
670929
- isProviderRemoteUrl: import_shared70.isGitLabRemoteUrl,
670930
- buildWorkflowFromBaseUrl: import_shared70.buildGitlabSuperblocksSyncWorkflowFromBaseUrl
671211
+ isProviderRemoteUrl: import_shared71.isGitLabRemoteUrl,
671212
+ buildWorkflowFromBaseUrl: import_shared71.buildGitlabSuperblocksSyncWorkflowFromBaseUrl
670931
671213
  }, superblocksBaseUrl);
670932
671214
  }
670933
671215
 
670934
671216
  // ../../../vite-plugin-file-sync/dist/git-service/live-branch.js
670935
671217
  init_cjs_shims();
670936
- var import_shared71 = __toESM(require_dist2());
671218
+ var import_shared72 = __toESM(require_dist2());
670937
671219
  async function ensureLiveBranchCheckedOut(gitService) {
670938
671220
  const logger25 = getLogger3();
670939
671221
  const currentBranch = await gitService.raw(["branch", "--show-current"]).then((branch) => branch.trim()).catch(() => "");
670940
- if (currentBranch === import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH) {
671222
+ if (currentBranch === import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH) {
670941
671223
  return;
670942
671224
  }
670943
671225
  logger25.warn("[git] live branch mismatch detected", {
@@ -670945,10 +671227,10 @@ async function ensureLiveBranchCheckedOut(gitService) {
670945
671227
  gitOperation: "checkout-live-branch",
670946
671228
  gitOutcome: "fallback",
670947
671229
  currentBranch: currentBranch || "(detached)",
670948
- targetBranch: import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH
671230
+ targetBranch: import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH
670949
671231
  });
670950
671232
  try {
670951
- await gitService.fetch("origin", import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH);
671233
+ await gitService.fetch("origin", import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH);
670952
671234
  } catch (fetchErr) {
670953
671235
  const classified = classifyGitError(fetchErr);
670954
671236
  if (classified instanceof GitAuthError || classified instanceof GitPermissionError) {
@@ -670958,27 +671240,27 @@ async function ensureLiveBranchCheckedOut(gitService) {
670958
671240
  gitCategory: "branch",
670959
671241
  gitOperation: "checkout-live-branch",
670960
671242
  gitOutcome: "fetch_failed",
670961
- branch: import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH,
671243
+ branch: import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH,
670962
671244
  ...getErrorMeta2(fetchErr)
670963
671245
  });
670964
671246
  }
670965
671247
  try {
670966
- await gitService.revparse(`origin/${import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH}`);
670967
- await gitService.checkoutOrCreate(import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH, `origin/${import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH}`);
671248
+ await gitService.revparse(`origin/${import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH}`);
671249
+ await gitService.checkoutOrCreate(import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH, `origin/${import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH}`);
670968
671250
  logger25.info("[git] live branch switched from remote", {
670969
671251
  gitCategory: "branch",
670970
671252
  gitOperation: "checkout-live-branch",
670971
671253
  gitOutcome: "succeeded",
670972
- targetBranch: import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH,
670973
- startPoint: `origin/${import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH}`
671254
+ targetBranch: import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH,
671255
+ startPoint: `origin/${import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH}`
670974
671256
  });
670975
671257
  } catch {
670976
- await gitService.checkoutOrCreate(import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH);
671258
+ await gitService.checkoutOrCreate(import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH);
670977
671259
  logger25.info("[git] live branch created locally", {
670978
671260
  gitCategory: "branch",
670979
671261
  gitOperation: "checkout-live-branch",
670980
671262
  gitOutcome: "fallback",
670981
- targetBranch: import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH
671263
+ targetBranch: import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH
670982
671264
  });
670983
671265
  }
670984
671266
  }
@@ -670988,15 +671270,15 @@ async function doesRemoteLiveBranchExist(gitService) {
670988
671270
  "ls-remote",
670989
671271
  "--heads",
670990
671272
  "origin",
670991
- `refs/heads/${import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH}`
671273
+ `refs/heads/${import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH}`
670992
671274
  ]);
670993
- return remoteRefs.includes(`refs/heads/${import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH}`);
671275
+ return remoteRefs.includes(`refs/heads/${import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH}`);
670994
671276
  } catch (error40) {
670995
671277
  getLogger3().warn("[git] live branch existence check failed", {
670996
671278
  gitCategory: "branch",
670997
671279
  gitOperation: "check-live-branch-exists",
670998
671280
  gitOutcome: "failed",
670999
- branch: import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH,
671281
+ branch: import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH,
671000
671282
  message: error40 instanceof Error ? error40.message : String(error40)
671001
671283
  });
671002
671284
  return null;
@@ -671009,7 +671291,7 @@ async function pushLiveBranchWithAutoRecreate2(gitService) {
671009
671291
  gitCategory: "branch",
671010
671292
  gitOperation: "check-live-branch-exists",
671011
671293
  gitOutcome: "failed",
671012
- branch: import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH
671294
+ branch: import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH
671013
671295
  });
671014
671296
  }
671015
671297
  try {
@@ -671017,14 +671299,14 @@ async function pushLiveBranchWithAutoRecreate2(gitService) {
671017
671299
  gitCategory: "commit",
671018
671300
  gitOperation: "push-live-branch",
671019
671301
  gitOutcome: "started",
671020
- branch: import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH
671302
+ branch: import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH
671021
671303
  });
671022
- await gitService.push("origin", import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH);
671304
+ await gitService.push("origin", import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH);
671023
671305
  getLogger3().info("[git] live branch push succeeded", {
671024
671306
  gitCategory: "commit",
671025
671307
  gitOperation: "push-live-branch",
671026
671308
  gitOutcome: "succeeded",
671027
- branch: import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH,
671309
+ branch: import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH,
671028
671310
  recreated: false
671029
671311
  });
671030
671312
  } catch (pushError) {
@@ -671036,7 +671318,7 @@ async function pushLiveBranchWithAutoRecreate2(gitService) {
671036
671318
  gitCategory: "branch",
671037
671319
  gitOperation: "push-live-branch",
671038
671320
  gitOutcome: "fallback",
671039
- branch: import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH,
671321
+ branch: import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH,
671040
671322
  fallback: "explicit-head-push",
671041
671323
  error: getErrorMeta2(pushError).error.message
671042
671324
  });
@@ -671044,13 +671326,13 @@ async function pushLiveBranchWithAutoRecreate2(gitService) {
671044
671326
  await gitService.raw([
671045
671327
  "push",
671046
671328
  "origin",
671047
- `HEAD:${import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH}`
671329
+ `HEAD:${import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH}`
671048
671330
  ]);
671049
671331
  getLogger3().info("[git] live branch recreated on remote", {
671050
671332
  gitCategory: "branch",
671051
671333
  gitOperation: "push-live-branch",
671052
671334
  gitOutcome: "succeeded",
671053
- branch: import_shared71.SUPERBLOCKS_LIVE_GIT_BRANCH,
671335
+ branch: import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH,
671054
671336
  recreated: true
671055
671337
  });
671056
671338
  }
@@ -671110,7 +671392,7 @@ function disposeSocketManager() {
671110
671392
  _socketManager?.dispose();
671111
671393
  _socketManager = void 0;
671112
671394
  }
671113
- var SocketManager = class extends import_shared72.TracedEventEmitter {
671395
+ var SocketManager = class extends import_shared73.TracedEventEmitter {
671114
671396
  peerIds = /* @__PURE__ */ new Map();
671115
671397
  editorSockets = /* @__PURE__ */ new Set();
671116
671398
  librarySockets = /* @__PURE__ */ new Set();
@@ -671120,7 +671402,7 @@ var SocketManager = class extends import_shared72.TracedEventEmitter {
671120
671402
  super(tracer3);
671121
671403
  }
671122
671404
  socketServer;
671123
- startSocketServer({ server, fileSyncManager, syncService, lockService, aiService, gitService, gitBootstrapFailed, activateGitService, checkAuthorization, path: path80, tracer: tracer3, gitOperationLock, superblocksBaseUrl, maxPayloadBytes = import_shared72.MAX_SOCKET_PAYLOAD_BYTES }) {
671405
+ startSocketServer({ server, fileSyncManager, syncService, lockService, aiService, gitService, gitBootstrapAuthFailed, gitBootstrapFailed, activateGitService, refreshGitCredentials, checkAuthorization, path: path80, tracer: tracer3, gitOperationLock, superblocksBaseUrl, maxPayloadBytes = import_shared73.MAX_SOCKET_PAYLOAD_BYTES }) {
671124
671406
  if (this.socketServer) {
671125
671407
  throw new Error("Socket server already started");
671126
671408
  }
@@ -671138,6 +671420,15 @@ var SocketManager = class extends import_shared72.TracedEventEmitter {
671138
671420
  });
671139
671421
  }
671140
671422
  let disconnectInProgress = false;
671423
+ let runtimeGitAuthFailed = false;
671424
+ const markRuntimeGitAuthFailed = (error40) => {
671425
+ if (classifyGitError(error40) instanceof GitAuthError) {
671426
+ runtimeGitAuthFailed = true;
671427
+ }
671428
+ };
671429
+ const clearRuntimeGitAuthFailed = () => {
671430
+ runtimeGitAuthFailed = false;
671431
+ };
671141
671432
  const getActiveGitService = async () => {
671142
671433
  if (disconnectInProgress) {
671143
671434
  return void 0;
@@ -671165,6 +671456,7 @@ var SocketManager = class extends import_shared72.TracedEventEmitter {
671165
671456
  }
671166
671457
  activeGitService = activated;
671167
671458
  if (activeGitService) {
671459
+ clearRuntimeGitAuthFailed();
671168
671460
  await ensureLiveBranchCheckedOut(activeGitService);
671169
671461
  if (disconnectInProgress) {
671170
671462
  return void 0;
@@ -671273,7 +671565,7 @@ var SocketManager = class extends import_shared72.TracedEventEmitter {
671273
671565
  };
671274
671566
  const recordingMiddleware = aiService ? createSocketRecordingMiddleware(aiService.getRecordingManager()) : void 0;
671275
671567
  const middlewares = [recordingMiddleware, authMiddleware].filter((m2) => m2 != null);
671276
- const socket = (0, import_shared72.createISocketClient)(new import_shared72.TracedSocket(ws2, {
671568
+ const socket = (0, import_shared73.createISocketClient)(new import_shared73.TracedSocket(ws2, {
671277
671569
  editor: {
671278
671570
  // Renames
671279
671571
  renameElement: [fileSyncManager.handleRenameElement],
@@ -671564,7 +671856,7 @@ var SocketManager = class extends import_shared72.TracedEventEmitter {
671564
671856
  if (!readyGitService) {
671565
671857
  throw new Error("Git is not configured for this application");
671566
671858
  }
671567
- await readyGitService.fetch("origin", import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH).catch((fetchErr) => {
671859
+ await readyGitService.fetch("origin", import_shared73.SUPERBLOCKS_LIVE_GIT_BRANCH).catch((fetchErr) => {
671568
671860
  const msg = fetchErr instanceof Error ? fetchErr.message : String(fetchErr);
671569
671861
  if (!msg.includes("couldn't find remote ref")) {
671570
671862
  throw fetchErr;
@@ -671608,6 +671900,7 @@ var SocketManager = class extends import_shared72.TracedEventEmitter {
671608
671900
  return { sha: result.commit };
671609
671901
  } catch (error40) {
671610
671902
  getLogger3().error("[git] gitCommitLocal failed", getErrorMeta2(error40));
671903
+ markRuntimeGitAuthFailed(error40);
671611
671904
  throw error40;
671612
671905
  }
671613
671906
  })
@@ -671620,8 +671913,10 @@ var SocketManager = class extends import_shared72.TracedEventEmitter {
671620
671913
  throw new Error("Git is not configured for this application");
671621
671914
  }
671622
671915
  await pushLiveBranchWithAutoRecreate2(readyGitService);
671916
+ clearRuntimeGitAuthFailed();
671623
671917
  } catch (error40) {
671624
671918
  getLogger3().error("[git] gitPushLiveBranch failed", getErrorMeta2(error40));
671919
+ markRuntimeGitAuthFailed(error40);
671625
671920
  throw error40;
671626
671921
  }
671627
671922
  })
@@ -671640,87 +671935,97 @@ var SocketManager = class extends import_shared72.TracedEventEmitter {
671640
671935
  ],
671641
671936
  gitPull: [
671642
671937
  async (_request, _context) => runWithGitLock(async () => {
671643
- const readyGitService = await getActiveGitService();
671644
- if (!readyGitService) {
671645
- throw new Error("Git is not configured for this application");
671646
- }
671647
- await readyGitService.fetch();
671648
- await assertIncomingLiveLayout(readyGitService);
671649
- const status = await readyGitService.status();
671650
- const hasLocalChanges = status.files.length > 0;
671651
- if (hasLocalChanges) {
671652
- await readyGitService.add(".");
671653
- await readyGitService.stash();
671654
- }
671655
- let hasConflicts = false;
671656
- let merged = false;
671657
671938
  try {
671658
- const mergeResult = await readyGitService.mergeRef(`origin/${import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH}`);
671659
- merged = !mergeResult.alreadyUpToDate;
671660
- if (merged) {
671661
- const unmerged = await readyGitService.getConflictedFiles();
671662
- if (unmerged.length > 0) {
671663
- hasConflicts = true;
671664
- }
671939
+ const readyGitService = await getActiveGitService();
671940
+ if (!readyGitService) {
671941
+ throw new Error("Git is not configured for this application");
671665
671942
  }
671666
- } catch (mergeError) {
671667
- if (!(mergeError instanceof GitConflictError)) {
671668
- getLogger3().error("[git] gitPull: merge failed (non-conflict), aborting", getErrorMeta2(mergeError));
671669
- try {
671670
- await readyGitService.raw(["merge", "--abort"]);
671671
- } catch (abortErr) {
671672
- getLogger3().warn(`[git] gitPull: merge --abort failed: ${abortErr instanceof Error ? abortErr.message : String(abortErr)}`);
671943
+ await readyGitService.fetch();
671944
+ await assertIncomingLiveLayout(readyGitService);
671945
+ const status = await readyGitService.status();
671946
+ const hasLocalChanges = status.files.length > 0;
671947
+ if (hasLocalChanges) {
671948
+ await readyGitService.add(".");
671949
+ await readyGitService.stash();
671950
+ }
671951
+ let hasConflicts = false;
671952
+ let merged = false;
671953
+ try {
671954
+ const mergeResult = await readyGitService.mergeRef(`origin/${import_shared73.SUPERBLOCKS_LIVE_GIT_BRANCH}`);
671955
+ merged = !mergeResult.alreadyUpToDate;
671956
+ if (merged) {
671957
+ const unmerged = await readyGitService.getConflictedFiles();
671958
+ if (unmerged.length > 0) {
671959
+ hasConflicts = true;
671960
+ }
671673
671961
  }
671674
- if (hasLocalChanges) {
671962
+ } catch (mergeError) {
671963
+ if (!(mergeError instanceof GitConflictError)) {
671964
+ getLogger3().error("[git] gitPull: merge failed (non-conflict), aborting", getErrorMeta2(mergeError));
671675
671965
  try {
671676
- await readyGitService.stashPop();
671677
- } catch (popErr) {
671678
- getLogger3().warn(`[git] gitPull: stash pop after merge abort failed: ${popErr instanceof Error ? popErr.message : String(popErr)}`);
671966
+ await readyGitService.raw(["merge", "--abort"]);
671967
+ } catch (abortErr) {
671968
+ getLogger3().warn(`[git] gitPull: merge --abort failed: ${abortErr instanceof Error ? abortErr.message : String(abortErr)}`);
671679
671969
  }
671970
+ if (hasLocalChanges) {
671971
+ try {
671972
+ await readyGitService.stashPop();
671973
+ } catch (popErr) {
671974
+ getLogger3().warn(`[git] gitPull: stash pop after merge abort failed: ${popErr instanceof Error ? popErr.message : String(popErr)}`);
671975
+ }
671976
+ }
671977
+ throw mergeError;
671680
671978
  }
671681
- throw mergeError;
671979
+ merged = true;
671980
+ hasConflicts = true;
671682
671981
  }
671683
- merged = true;
671684
- hasConflicts = true;
671685
- }
671686
- if (hasLocalChanges) {
671687
- try {
671688
- await readyGitService.stashPop();
671689
- } catch (popError) {
671690
- if (popError instanceof GitConflictError) {
671691
- hasConflicts = true;
671692
- } else {
671693
- getLogger3().error("[git] gitPull: stash pop failed (non-conflict)", getErrorMeta2(popError));
671694
- throw popError;
671982
+ if (hasLocalChanges) {
671983
+ try {
671984
+ await readyGitService.stashPop();
671985
+ } catch (popError) {
671986
+ if (popError instanceof GitConflictError) {
671987
+ hasConflicts = true;
671988
+ } else {
671989
+ getLogger3().error("[git] gitPull: stash pop failed (non-conflict)", getErrorMeta2(popError));
671990
+ throw popError;
671991
+ }
671695
671992
  }
671696
- }
671697
- if (!hasConflicts) {
671698
- const unmerged = await readyGitService.getConflictedFiles();
671699
- if (unmerged.length > 0) {
671700
- hasConflicts = true;
671993
+ if (!hasConflicts) {
671994
+ const unmerged = await readyGitService.getConflictedFiles();
671995
+ if (unmerged.length > 0) {
671996
+ hasConflicts = true;
671997
+ }
671701
671998
  }
671702
671999
  }
672000
+ if (hasConflicts) {
672001
+ const conflictedFiles = await readyGitService.getConflictedFiles();
672002
+ getLogger3().warn("[git] pull conflict detected", {
672003
+ gitCategory: "pull",
672004
+ gitOperation: "pull",
672005
+ gitOutcome: "conflict",
672006
+ branch: import_shared73.SUPERBLOCKS_LIVE_GIT_BRANCH,
672007
+ conflictedFileCount: conflictedFiles.length,
672008
+ conflictedFiles
672009
+ });
672010
+ clearRuntimeGitAuthFailed();
672011
+ return { merged: false, conflictedFiles };
672012
+ }
672013
+ clearRuntimeGitAuthFailed();
672014
+ return { merged };
672015
+ } catch (error40) {
672016
+ markRuntimeGitAuthFailed(error40);
672017
+ throw error40;
671703
672018
  }
671704
- if (hasConflicts) {
671705
- const conflictedFiles = await readyGitService.getConflictedFiles();
671706
- getLogger3().warn("[git] pull conflict detected", {
671707
- gitCategory: "pull",
671708
- gitOperation: "pull",
671709
- gitOutcome: "conflict",
671710
- branch: import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH,
671711
- conflictedFileCount: conflictedFiles.length,
671712
- conflictedFiles
671713
- });
671714
- return { merged: false, conflictedFiles };
671715
- }
671716
- return { merged };
671717
672019
  })
671718
672020
  ],
671719
672021
  gitSyncStatus: [
671720
672022
  async () => {
671721
672023
  const readyGitService = await getActiveGitService();
671722
672024
  if (!readyGitService) {
671723
- return gitBootstrapFailed ? { bootstrapFailed: true } : null;
672025
+ return gitBootstrapFailed ? {
672026
+ authFailed: gitBootstrapAuthFailed,
672027
+ bootstrapFailed: true
672028
+ } : null;
671724
672029
  }
671725
672030
  let hasUncommittedChanges = false;
671726
672031
  try {
@@ -671739,17 +672044,29 @@ var SocketManager = class extends import_shared72.TracedEventEmitter {
671739
672044
  let ahead = 0;
671740
672045
  let behind = 0;
671741
672046
  try {
671742
- await readyGitService.fetch("origin", import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH);
671743
- const counts = await readyGitService.revList("HEAD", `origin/${import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH}`);
671744
- ahead = counts.ahead;
671745
- behind = counts.behind;
672047
+ let missingRemoteLiveBranch = false;
672048
+ await readyGitService.fetch("origin", import_shared73.SUPERBLOCKS_LIVE_GIT_BRANCH).catch((fetchErr) => {
672049
+ const msg = fetchErr instanceof Error ? fetchErr.message : String(fetchErr);
672050
+ if (msg.includes("couldn't find remote ref")) {
672051
+ missingRemoteLiveBranch = true;
672052
+ return;
672053
+ }
672054
+ throw fetchErr;
672055
+ });
672056
+ if (!missingRemoteLiveBranch) {
672057
+ const counts = await readyGitService.revList("HEAD", `origin/${import_shared73.SUPERBLOCKS_LIVE_GIT_BRANCH}`);
672058
+ ahead = counts.ahead;
672059
+ behind = counts.behind;
672060
+ }
672061
+ clearRuntimeGitAuthFailed();
671746
672062
  } catch (fetchErr) {
672063
+ markRuntimeGitAuthFailed(fetchErr);
671747
672064
  getLogger3().warn("[git] gitSyncStatus fetch/revList failed", {
671748
672065
  gitCategory: "status",
671749
672066
  gitOperation: "syncStatus",
671750
672067
  gitOutcome: "failed",
671751
672068
  gitErrorKind: "fetch_or_rev_list_failed",
671752
- branch: import_shared72.SUPERBLOCKS_LIVE_GIT_BRANCH,
672069
+ branch: import_shared73.SUPERBLOCKS_LIVE_GIT_BRANCH,
671753
672070
  remote: "origin",
671754
672071
  ...getErrorMeta2(fetchErr)
671755
672072
  });
@@ -671770,7 +672087,8 @@ var SocketManager = class extends import_shared72.TracedEventEmitter {
671770
672087
  behind,
671771
672088
  hasUncommittedChanges,
671772
672089
  aheadOfDefaultBranch,
671773
- isLiveBranchMissing
672090
+ isLiveBranchMissing,
672091
+ remoteAuthFailed: runtimeGitAuthFailed
671774
672092
  };
671775
672093
  }
671776
672094
  ],
@@ -671800,20 +672118,37 @@ var SocketManager = class extends import_shared72.TracedEventEmitter {
671800
672118
  gitActivate: [
671801
672119
  async () => runWithGitLock(async () => {
671802
672120
  disconnectInProgress = false;
672121
+ clearRuntimeGitAuthFailed();
671803
672122
  const service = await getActiveGitService();
671804
672123
  return { activated: !!service };
671805
672124
  })
671806
672125
  ],
672126
+ gitRefreshCredentials: [
672127
+ async () => runWithGitLock(async () => {
672128
+ if (!refreshGitCredentials) {
672129
+ return { refreshed: false };
672130
+ }
672131
+ const service = await refreshGitCredentials();
672132
+ if (!service) {
672133
+ return { refreshed: false };
672134
+ }
672135
+ activeGitService = service;
672136
+ clearRuntimeGitAuthFailed();
672137
+ aiService?.setRuntimeGitServices(service, syncService, gitOperationLock);
672138
+ return { refreshed: true };
672139
+ })
672140
+ ],
671807
672141
  gitDisconnect: [
671808
672142
  async () => runWithGitLock(async () => {
671809
672143
  const serviceToDisconnect = activeGitService;
671810
672144
  activeGitService = void 0;
671811
672145
  disconnectInProgress = true;
671812
- syncService?.setBranchName(import_shared72.DEFAULT_NON_GIT_BRANCH);
672146
+ clearRuntimeGitAuthFailed();
672147
+ syncService?.setBranchName(import_shared73.DEFAULT_NON_GIT_BRANCH);
671813
672148
  if (lockService) {
671814
672149
  const wasLockedBeforeDisconnect = lockService.isLocked;
671815
672150
  try {
671816
- await lockService.switchBranch(import_shared72.DEFAULT_NON_GIT_BRANCH, {
672151
+ await lockService.switchBranch(import_shared73.DEFAULT_NON_GIT_BRANCH, {
671817
672152
  reacquireLock: wasLockedBeforeDisconnect
671818
672153
  });
671819
672154
  } catch (err) {
@@ -671825,7 +672160,7 @@ var SocketManager = class extends import_shared72.TracedEventEmitter {
671825
672160
  ...getErrorMeta2(err)
671826
672161
  });
671827
672162
  try {
671828
- await lockService.switchBranch(import_shared72.DEFAULT_NON_GIT_BRANCH, {
672163
+ await lockService.switchBranch(import_shared73.DEFAULT_NON_GIT_BRANCH, {
671829
672164
  reacquireLock: false
671830
672165
  });
671831
672166
  if (wasLockedBeforeDisconnect) {
@@ -671844,7 +672179,7 @@ var SocketManager = class extends import_shared72.TracedEventEmitter {
671844
672179
  }
671845
672180
  if (serviceToDisconnect) {
671846
672181
  const gitDir = join26(serviceToDisconnect.workDir, ".git");
671847
- let checkoutBranchBeforeDisconnect = import_shared72.DEFAULT_NON_GIT_BRANCH;
672182
+ let checkoutBranchBeforeDisconnect = import_shared73.DEFAULT_NON_GIT_BRANCH;
671848
672183
  try {
671849
672184
  checkoutBranchBeforeDisconnect = await serviceToDisconnect.getDefaultBranch();
671850
672185
  } catch (defaultBranchErr) {
@@ -672244,7 +672579,7 @@ import nodePath from "node:path";
672244
672579
  init_lodash();
672245
672580
  var import_yaml9 = __toESM(require_dist());
672246
672581
  import { normalizePath as normalizePath11 } from "vite";
672247
- var import_shared75 = __toESM(require_dist2());
672582
+ var import_shared76 = __toESM(require_dist2());
672248
672583
  var import_util37 = __toESM(require_dist3());
672249
672584
 
672250
672585
  // ../../../vite-plugin-file-sync/dist/codegen.js
@@ -673612,21 +673947,21 @@ var t13 = __toESM(require_lib10());
673612
673947
  init_cjs_shims();
673613
673948
  var import_esprima2 = __toESM(require_esprima());
673614
673949
  init_lodash();
673615
- var import_shared73 = __toESM(require_dist2());
673950
+ var import_shared74 = __toESM(require_dist2());
673616
673951
  var extractPythonEvaluationPairs2 = async (code, entities, dataTree, namespacedEntitiesToExtract) => {
673617
- return (0, import_shared73.extractPythonEvaluationPairsWithParser)(code, entities, dataTree, parser, namespacedEntitiesToExtract);
673952
+ return (0, import_shared74.extractPythonEvaluationPairsWithParser)(code, entities, dataTree, parser, namespacedEntitiesToExtract);
673618
673953
  };
673619
673954
  var extractJsEvaluationPairs2 = async (jsSnippet, entitiesToExtract, dataTree, namespacedEntitiesToExtract) => {
673620
- return (0, import_shared73.extractJsEvaluationPairsWithTokenizer)(jsSnippet, entitiesToExtract, dataTree, import_esprima2.tokenize, namespacedEntitiesToExtract);
673955
+ return (0, import_shared74.extractJsEvaluationPairsWithTokenizer)(jsSnippet, entitiesToExtract, dataTree, import_esprima2.tokenize, namespacedEntitiesToExtract);
673621
673956
  };
673622
673957
  function getExtractorByPluginId(pluginId) {
673623
673958
  if (!pluginId) {
673624
673959
  return extractJsEvaluationPairs2;
673625
673960
  }
673626
673961
  switch (pluginId.trim().toLowerCase()) {
673627
- case import_shared73.LanguagePluginID.Python:
673962
+ case import_shared74.LanguagePluginID.Python:
673628
673963
  return extractPythonEvaluationPairs2;
673629
- case import_shared73.LanguagePluginID.JavaScript:
673964
+ case import_shared74.LanguagePluginID.JavaScript:
673630
673965
  default:
673631
673966
  return extractJsEvaluationPairs2;
673632
673967
  }
@@ -673635,14 +673970,14 @@ async function refactorNameInBlocks(params) {
673635
673970
  const { blocks, oldName, newName, namespace } = params;
673636
673971
  const flattenedBlocks = flattenBlocks(blocks);
673637
673972
  for (const block of flattenedBlocks) {
673638
- const pluginType = (0, import_shared73.getPluginType)(block) ?? void 0;
673973
+ const pluginType = (0, import_shared74.getPluginType)(block) ?? void 0;
673639
673974
  const extractor = getExtractorByPluginId(pluginType);
673640
- if ((0, import_shared73.isStepBlock)(block) && pluginType) {
673975
+ if ((0, import_shared74.isStepBlock)(block) && pluginType) {
673641
673976
  const configuration = block.config[pluginType];
673642
673977
  if (typeof configuration !== "object" || configuration == null) {
673643
673978
  continue;
673644
673979
  }
673645
- await (0, import_shared73.refactorNameInStep)({
673980
+ await (0, import_shared74.refactorNameInStep)({
673646
673981
  ...params,
673647
673982
  dataTree: {
673648
673983
  [newName]: {},
@@ -673652,9 +673987,9 @@ async function refactorNameInBlocks(params) {
673652
673987
  configuration,
673653
673988
  extractor
673654
673989
  });
673655
- } else if ((0, import_shared73.isControlBlock)(block)) {
673990
+ } else if ((0, import_shared74.isControlBlock)(block)) {
673656
673991
  for (const [value2, setValue] of getSetControlBlockExpressions2(block)) {
673657
- const newValue = await (0, import_shared73.refactorNameInString)({
673992
+ const newValue = await (0, import_shared74.refactorNameInString)({
673658
673993
  value: value2,
673659
673994
  oldName,
673660
673995
  newName,
@@ -673684,34 +674019,34 @@ function getSetControlBlockExpressions2(block) {
673684
674019
  const { config: config4, type } = block;
673685
674020
  const results = [];
673686
674021
  switch (type) {
673687
- case import_shared73.BlockType.BREAK: {
674022
+ case import_shared74.BlockType.BREAK: {
673688
674023
  const controlConfig = config4;
673689
674024
  results.push(makeGetSet2(controlConfig, "condition"));
673690
674025
  break;
673691
674026
  }
673692
- case import_shared73.BlockType.THROW: {
674027
+ case import_shared74.BlockType.THROW: {
673693
674028
  const controlConfig = config4;
673694
674029
  results.push(makeGetSet2(controlConfig, "error"));
673695
674030
  break;
673696
674031
  }
673697
- case import_shared73.BlockType.RETURN: {
674032
+ case import_shared74.BlockType.RETURN: {
673698
674033
  const controlConfig = config4;
673699
674034
  results.push(makeGetSet2(controlConfig, "data"));
673700
674035
  break;
673701
674036
  }
673702
- case import_shared73.BlockType.WAIT: {
674037
+ case import_shared74.BlockType.WAIT: {
673703
674038
  const controlConfig = config4;
673704
674039
  results.push(makeGetSet2(controlConfig, "condition"));
673705
674040
  break;
673706
674041
  }
673707
- case import_shared73.BlockType.PARALLEL: {
674042
+ case import_shared74.BlockType.PARALLEL: {
673708
674043
  const controlConfig = config4;
673709
674044
  if (controlConfig.dynamic) {
673710
674045
  results.push(makeGetSet2(controlConfig.dynamic, "paths"));
673711
674046
  }
673712
674047
  break;
673713
674048
  }
673714
- case import_shared73.BlockType.CONDITION: {
674049
+ case import_shared74.BlockType.CONDITION: {
673715
674050
  const controlConfig = config4;
673716
674051
  if (controlConfig.if) {
673717
674052
  results.push(makeGetSet2(controlConfig.if, "condition"));
@@ -673721,15 +674056,15 @@ function getSetControlBlockExpressions2(block) {
673721
674056
  }
673722
674057
  break;
673723
674058
  }
673724
- case import_shared73.BlockType.LOOP: {
674059
+ case import_shared74.BlockType.LOOP: {
673725
674060
  const controlConfig = config4;
673726
674061
  results.push(makeGetSet2(controlConfig, "range"));
673727
674062
  break;
673728
674063
  }
673729
- case import_shared73.BlockType.TRY_CATCH: {
674064
+ case import_shared74.BlockType.TRY_CATCH: {
673730
674065
  break;
673731
674066
  }
673732
- case import_shared73.BlockType.VARIABLES: {
674067
+ case import_shared74.BlockType.VARIABLES: {
673733
674068
  const controlConfig = config4;
673734
674069
  for (const variable of controlConfig.items) {
673735
674070
  if (variable.value) {
@@ -673738,12 +674073,12 @@ function getSetControlBlockExpressions2(block) {
673738
674073
  }
673739
674074
  break;
673740
674075
  }
673741
- case import_shared73.BlockType.SEND: {
674076
+ case import_shared74.BlockType.SEND: {
673742
674077
  const controlConfig = config4;
673743
674078
  results.push(makeGetSet2(controlConfig, "message"));
673744
674079
  break;
673745
674080
  }
673746
- case import_shared73.BlockType.STREAM: {
674081
+ case import_shared74.BlockType.STREAM: {
673747
674082
  break;
673748
674083
  }
673749
674084
  default: {
@@ -673757,7 +674092,7 @@ function getSetControlBlockExpressions2(block) {
673757
674092
  // ../../../vite-plugin-file-sync/dist/refactor/javascript.js
673758
674093
  init_cjs_shims();
673759
674094
  var t12 = __toESM(require_lib10());
673760
- var import_shared74 = __toESM(require_dist2());
674095
+ var import_shared75 = __toESM(require_dist2());
673761
674096
  function renameEntityInJavascript({ oldName, newName, nodePath: nodePath2, parentBinding, checkFunctionBinding = false }) {
673762
674097
  const functionVisitor = checkFunctionBinding ? {
673763
674098
  Function(path80) {
@@ -694488,7 +694823,7 @@ var parseYaml3;
694488
694823
  async function loadYaml(file2) {
694489
694824
  const content18 = await read_file_default(file2);
694490
694825
  if (!parseYaml3) {
694491
- ({ __parsePrettierYamlConfig: parseYaml3 } = await import("./yaml-EU2JTNYQ.js"));
694826
+ ({ __parsePrettierYamlConfig: parseYaml3 } = await import("./yaml-E452PT2S.js"));
694492
694827
  }
694493
694828
  try {
694494
694829
  return parseYaml3(content18);
@@ -699882,7 +700217,7 @@ function createParsersAndPrinters(modules) {
699882
700217
  }
699883
700218
  var estreePlugin = createParsersAndPrinters([
699884
700219
  {
699885
- importPlugin: () => import("./estree-G6A3CLHM.js"),
700220
+ importPlugin: () => import("./estree-IGFHWX3W.js"),
699886
700221
  printers: ["estree", "estree-json"]
699887
700222
  }
699888
700223
  ]);
@@ -699906,11 +700241,11 @@ var languages = [
699906
700241
  ];
699907
700242
  var { parsers: parsers12, printers } = createParsersAndPrinters([
699908
700243
  {
699909
- importPlugin: () => import("./acorn-DJYL2AMA.js"),
700244
+ importPlugin: () => import("./acorn-33PDNT4G.js"),
699910
700245
  parsers: ["acorn", "espree"]
699911
700246
  },
699912
700247
  {
699913
- importPlugin: () => import("./angular-D4OXWSTQ.js"),
700248
+ importPlugin: () => import("./angular-JI4DJHZ6.js"),
699914
700249
  parsers: [
699915
700250
  "__ng_action",
699916
700251
  "__ng_binding",
@@ -699919,7 +700254,7 @@ var { parsers: parsers12, printers } = createParsersAndPrinters([
699919
700254
  ]
699920
700255
  },
699921
700256
  {
699922
- importPlugin: () => import("./babel-E2YRPG6X.js"),
700257
+ importPlugin: () => import("./babel-O5SHO5HA.js"),
699923
700258
  parsers: [
699924
700259
  "babel",
699925
700260
  "babel-flow",
@@ -699938,44 +700273,44 @@ var { parsers: parsers12, printers } = createParsersAndPrinters([
699938
700273
  ]
699939
700274
  },
699940
700275
  {
699941
- importPlugin: () => import("./flow-SOAATWPH.js"),
700276
+ importPlugin: () => import("./flow-K6ENOKSA.js"),
699942
700277
  parsers: ["flow"]
699943
700278
  },
699944
700279
  {
699945
- importPlugin: () => import("./glimmer-AAPXV3KF.js"),
700280
+ importPlugin: () => import("./glimmer-J22DQNP7.js"),
699946
700281
  parsers: ["glimmer"],
699947
700282
  printers: ["glimmer"]
699948
700283
  },
699949
700284
  {
699950
- importPlugin: () => import("./graphql-BLB7FCAN.js"),
700285
+ importPlugin: () => import("./graphql-PA3QKIAK.js"),
699951
700286
  parsers: ["graphql"],
699952
700287
  printers: ["graphql"]
699953
700288
  },
699954
700289
  {
699955
- importPlugin: () => import("./html-QYMNEYJ4.js"),
700290
+ importPlugin: () => import("./html-IZ5VQFTA.js"),
699956
700291
  parsers: ["html", "angular", "vue", "lwc", "mjml"],
699957
700292
  printers: ["html"]
699958
700293
  },
699959
700294
  {
699960
- importPlugin: () => import("./markdown-5A6WF6FY.js"),
700295
+ importPlugin: () => import("./markdown-FVGVAVL4.js"),
699961
700296
  parsers: ["markdown", "mdx", "remark"],
699962
700297
  printers: ["mdast"]
699963
700298
  },
699964
700299
  {
699965
- importPlugin: () => import("./meriyah-DTNGYWT2.js"),
700300
+ importPlugin: () => import("./meriyah-QEL5Q3O3.js"),
699966
700301
  parsers: ["meriyah"]
699967
700302
  },
699968
700303
  {
699969
- importPlugin: () => import("./postcss-KSVRPJLF.js"),
700304
+ importPlugin: () => import("./postcss-YBLMJPFI.js"),
699970
700305
  parsers: ["css", "less", "scss"],
699971
700306
  printers: ["postcss"]
699972
700307
  },
699973
700308
  {
699974
- importPlugin: () => import("./typescript-PQSNN2AA.js"),
700309
+ importPlugin: () => import("./typescript-3QAPWCSE.js"),
699975
700310
  parsers: ["typescript"]
699976
700311
  },
699977
700312
  {
699978
- importPlugin: () => import("./yaml-EU2JTNYQ.js"),
700313
+ importPlugin: () => import("./yaml-E452PT2S.js"),
699979
700314
  parsers: ["yaml"],
699980
700315
  printers: ["yaml"]
699981
700316
  }
@@ -700635,7 +700970,7 @@ var SUPPORTED_FILETYPES = [
700635
700970
  extension: ".md"
700636
700971
  }
700637
700972
  ];
700638
- var FileSystemManager = class extends import_shared75.TracedEventEmitter {
700973
+ var FileSystemManager = class extends import_shared76.TracedEventEmitter {
700639
700974
  rootDir;
700640
700975
  tsFiles = {};
700641
700976
  apiFiles = {};
@@ -700676,7 +701011,7 @@ var FileSystemManager = class extends import_shared75.TracedEventEmitter {
700676
701011
  "handleRenameApi",
700677
701012
  "handleRenameElement"
700678
701013
  ];
700679
- (0, import_shared75.addTracingToMethods)(this, methods, tracer3);
701014
+ (0, import_shared76.addTracingToMethods)(this, methods, tracer3);
700680
701015
  }
700681
701016
  get appFilePath() {
700682
701017
  if (!this.rootDir) {
@@ -701854,7 +702189,7 @@ var import_body_parser = __toESM(require_body_parser());
701854
702189
  var import_yaml12 = __toESM(require_dist());
701855
702190
  import { access as access9, mkdir as mkdir21, readFile as readFile23, readdir as readdir16, rm as rm17, writeFile as writeFile18 } from "node:fs/promises";
701856
702191
  import { dirname as dirname22, join as join37 } from "node:path";
701857
- var import_shared77 = __toESM(require_dist2());
702192
+ var import_shared78 = __toESM(require_dist2());
701858
702193
 
701859
702194
  // ../../../vite-plugin-file-sync/dist/migration/get-fullstack-template-dir.js
701860
702195
  init_cjs_shims();
@@ -703415,9 +703750,9 @@ init_cjs_shims();
703415
703750
  init_cjs_shims();
703416
703751
 
703417
703752
  // ../../../vite-plugin-file-sync/dist/migration/unsupported-integrations.js
703418
- var import_shared76 = __toESM(require_dist2());
703753
+ var import_shared77 = __toESM(require_dist2());
703419
703754
  var SUPPORTED_PLUGIN_ID_SET = new Set(SUPPORTED_PLUGIN_IDS);
703420
- var CODE_EXECUTION_PLUGIN_ID_SET = new Set(Object.values(import_shared76.LanguagePluginID));
703755
+ var CODE_EXECUTION_PLUGIN_ID_SET = new Set(Object.values(import_shared77.LanguagePluginID));
703421
703756
  var IGNORED_ROOT_DIRS = /* @__PURE__ */ new Set([".git", "node_modules", "scratch"]);
703422
703757
  var IGNORED_DIRS_ANY_DEPTH = /* @__PURE__ */ new Set([
703423
703758
  ".git",
@@ -703685,7 +704020,7 @@ async function findLiveApiYamls(rootDir) {
703685
704020
  }
703686
704021
  return results.sort();
703687
704022
  }
703688
- var LANGUAGE_PLUGIN_IDS3 = new Set(Object.values(import_shared77.LanguagePluginID));
704023
+ var LANGUAGE_PLUGIN_IDS3 = new Set(Object.values(import_shared78.LanguagePluginID));
703689
704024
  async function extractIntegrationsFromYamls(yamlPaths) {
703690
704025
  const integrationSteps = /* @__PURE__ */ new Map();
703691
704026
  for (const yamlPath of yamlPaths) {
@@ -705241,6 +705576,28 @@ function createGenerationFreshnessTracker() {
705241
705576
  isLatest: (generationId) => generationId === latestGenerationId
705242
705577
  };
705243
705578
  }
705579
+ async function handleTokenUpdateRequest({ authorization, checkAuthorization, logger: logger25, tokenManager }) {
705580
+ if (!authorization?.startsWith("Bearer ")) {
705581
+ return {
705582
+ statusCode: 401,
705583
+ body: JSON.stringify({ error: "Invalid authorization header" })
705584
+ };
705585
+ }
705586
+ const result = await checkAuthorization(authorization);
705587
+ if (!result.success) {
705588
+ return {
705589
+ statusCode: result.status,
705590
+ body: JSON.stringify({ error: result.error })
705591
+ };
705592
+ }
705593
+ if (!tokenManager) {
705594
+ logger25.warn("[auth] token refresh received without a tokenManager");
705595
+ return { statusCode: 204 };
705596
+ }
705597
+ tokenManager.updateToken(authorization.substring("Bearer ".length));
705598
+ logger25.info("[auth] updated tokenManager from editor token refresh");
705599
+ return { statusCode: 204 };
705600
+ }
705244
705601
  async function handleGenerationCompletedFileSync({ aiService, contextFlushScheduler, hasHadAnyDrafts, isFirstContentfulGeneration, isLatestGeneration = () => true, logger: logger25, producedDraft, server, syncService }) {
705245
705602
  logger25.info("[file-sync] generationCompleted event received", {
705246
705603
  applicationId: syncService.applicationId,
@@ -705312,6 +705669,7 @@ function fileSyncVitePlugin(pluginParams, options8) {
705312
705669
  const aiService = pluginParams.aiService;
705313
705670
  const gitService = pluginParams.gitService;
705314
705671
  const activateGitService = pluginParams.activateGitService;
705672
+ const refreshGitCredentials = pluginParams.refreshGitCredentials;
705315
705673
  const gitOperationLock = createGitOperationLock();
705316
705674
  const fsOperationQueue = pluginParams.fsOperationQueue;
705317
705675
  const httpServer2 = pluginParams.httpServer;
@@ -705432,6 +705790,40 @@ function fileSyncVitePlugin(pluginParams, options8) {
705432
705790
  aiService.setViteServer(server);
705433
705791
  aiService.setRuntimeGitServices(gitService, syncService, gitOperationLock);
705434
705792
  }
705793
+ server.middlewares.use("/_sb_update_token", (req, res) => {
705794
+ void (async () => {
705795
+ if (req.method !== "POST" && req.method !== "OPTIONS") {
705796
+ res.statusCode = 405;
705797
+ res.end("Method not allowed");
705798
+ return;
705799
+ }
705800
+ if (req.method === "OPTIONS") {
705801
+ res.statusCode = 204;
705802
+ res.end();
705803
+ return;
705804
+ }
705805
+ const result = await handleTokenUpdateRequest({
705806
+ authorization: req.headers.authorization,
705807
+ checkAuthorization: pluginParams.checkAuthorization,
705808
+ logger: logger25,
705809
+ tokenManager: pluginParams.tokenManager
705810
+ });
705811
+ res.statusCode = result.statusCode;
705812
+ if (result.body) {
705813
+ res.setHeader("Content-Type", "application/json");
705814
+ res.end(result.body);
705815
+ } else {
705816
+ res.end();
705817
+ }
705818
+ })().catch((error40) => {
705819
+ logger25.error("Error updating auth token", getErrorMeta2(error40));
705820
+ if (!res.headersSent) {
705821
+ res.statusCode = 500;
705822
+ res.setHeader("Content-Type", "application/json");
705823
+ res.end(JSON.stringify({ error: "Failed to update auth token" }));
705824
+ }
705825
+ });
705826
+ });
705435
705827
  server.middlewares.use((req, res, next2) => {
705436
705828
  void indexHtmlMiddleware(server, pluginParams?.features)(req, res, next2);
705437
705829
  });
@@ -705676,8 +706068,10 @@ function fileSyncVitePlugin(pluginParams, options8) {
705676
706068
  syncService,
705677
706069
  aiService,
705678
706070
  gitService,
706071
+ gitBootstrapAuthFailed: pluginParams.gitBootstrapAuthFailed,
705679
706072
  gitBootstrapFailed: pluginParams.gitBootstrapFailed,
705680
706073
  activateGitService,
706074
+ refreshGitCredentials,
705681
706075
  checkAuthorization: pluginParams.checkAuthorization,
705682
706076
  tracer: pluginParams.tracer,
705683
706077
  path: "/sb-updates",
@@ -705744,7 +706138,7 @@ function fileSyncVitePlugin(pluginParams, options8) {
705744
706138
  pageId: apiPb.trigger?.application?.pageId,
705745
706139
  organizationId: apiPb.metadata?.organization,
705746
706140
  updated: apiPb.metadata?.timestamps?.updated ? new Date(apiPb.metadata?.timestamps?.updated) : void 0,
705747
- triggerType: import_shared78.ApiTriggerType.UI,
706141
+ triggerType: import_shared79.ApiTriggerType.UI,
705748
706142
  apiPb
705749
706143
  };
705750
706144
  };
@@ -706422,7 +706816,7 @@ async function getAppScope(fileSyncManager) {
706422
706816
  pageId: apiPb.trigger?.application?.pageId,
706423
706817
  organizationId: apiPb.metadata.organization,
706424
706818
  updated: apiPb.metadata?.timestamps?.updated ? new Date(apiPb.metadata?.timestamps?.updated) : void 0,
706425
- triggerType: import_shared78.ApiTriggerType.UI,
706819
+ triggerType: import_shared79.ApiTriggerType.UI,
706426
706820
  apiPb,
706427
706821
  scopeId
706428
706822
  }));
@@ -706517,7 +706911,7 @@ function generateApiBuildManifestPlugin(root3) {
706517
706911
  };
706518
706912
  viteLogger.clearScreen = () => {
706519
706913
  };
706520
- const sdkApiEnabled = (0, import_shared79.isSdkApiTemplate)(process.env.SUPERBLOCKS_APP_TEMPLATE_NAME);
706914
+ const sdkApiEnabled = (0, import_shared80.isSdkApiTemplate)(process.env.SUPERBLOCKS_APP_TEMPLATE_NAME);
706521
706915
  const apiFiles = {};
706522
706916
  let manifestCode = "export default {};";
706523
706917
  return {
@@ -711410,7 +711804,7 @@ init_lodash();
711410
711804
  var import_semver3 = __toESM(require_semver2(), 1);
711411
711805
  var import_slugify = __toESM(require_slugify(), 1);
711412
711806
  var import_yaml14 = __toESM(require_dist(), 1);
711413
- var import_shared80 = __toESM(require_dist2(), 1);
711807
+ var import_shared81 = __toESM(require_dist2(), 1);
711414
711808
  var import_util45 = __toESM(require_dist3(), 1);
711415
711809
  var LATEST_EDITS_MODE = "latest-edits";
711416
711810
  var DRAFT_MODE = "draft";
@@ -711430,13 +711824,13 @@ var FileStructureType;
711430
711824
  function modeFlagToViewMode(modeFlag) {
711431
711825
  switch (modeFlag) {
711432
711826
  case LATEST_EDITS_MODE:
711433
- return import_shared80.ExportViewMode.EXPORT_LIVE;
711827
+ return import_shared81.ExportViewMode.EXPORT_LIVE;
711434
711828
  case MOST_RECENT_COMMIT_MODE:
711435
- return import_shared80.ExportViewMode.EXPORT_LATEST;
711829
+ return import_shared81.ExportViewMode.EXPORT_LATEST;
711436
711830
  case DEPLOYED_MODE:
711437
- return import_shared80.ExportViewMode.EXPORT_DEPLOYED;
711831
+ return import_shared81.ExportViewMode.EXPORT_DEPLOYED;
711438
711832
  case DRAFT_MODE:
711439
- return import_shared80.ExportViewMode.EXPORT_DRAFT;
711833
+ return import_shared81.ExportViewMode.EXPORT_DRAFT;
711440
711834
  default:
711441
711835
  throw new Error(`Unsupported mode flag: ${modeFlag}`);
711442
711836
  }
@@ -711856,7 +712250,7 @@ async function writeCodeModeApplicationToDisk(sdk, resource, appDirName, directo
711856
712250
  } else {
711857
712251
  await sdk.dbfsGetApplication({
711858
712252
  applicationId: resource.application.id,
711859
- branch: branch ?? import_shared80.DEFAULT_BRANCH,
712253
+ branch: branch ?? import_shared81.DEFAULT_BRANCH,
711860
712254
  localDirectoryPath: appDirName
711861
712255
  });
711862
712256
  }
@@ -712200,12 +712594,12 @@ import path70 from "node:path";
712200
712594
  var import_form_data2 = __toESM(require_form_data());
712201
712595
  init_lodash();
712202
712596
  var import_bucketeer_sdk = __toESM(require_dist15());
712203
- var import_shared83 = __toESM(require_dist2());
712597
+ var import_shared84 = __toESM(require_dist2());
712204
712598
  var import_util48 = __toESM(require_dist3());
712205
712599
 
712206
712600
  // ../sdk/dist/dbfs/local.js
712207
712601
  init_cjs_shims();
712208
- var import_shared81 = __toESM(require_dist2());
712602
+ var import_shared82 = __toESM(require_dist2());
712209
712603
  var import_util46 = __toESM(require_dist3());
712210
712604
  import * as fsp4 from "node:fs/promises";
712211
712605
  async function doDownloadDirectoryToLocal(rpcClient, directoryHash, localDirectoryPath) {
@@ -712250,7 +712644,7 @@ async function hashLocalDirectory2(localDirectoryPath) {
712250
712644
  let entry;
712251
712645
  switch (localDirEntry.type) {
712252
712646
  case "-": {
712253
- const hash4 = await (0, import_shared81.hashFileContents)(new Uint8Array(localDirEntry.contents));
712647
+ const hash4 = await (0, import_shared82.hashFileContents)(new Uint8Array(localDirEntry.contents));
712254
712648
  entry = {
712255
712649
  type: "-",
712256
712650
  executable: localDirEntry.executable,
@@ -712282,7 +712676,7 @@ async function hashLocalDirectory2(localDirectoryPath) {
712282
712676
  }
712283
712677
  directoryContents.push(entry);
712284
712678
  }
712285
- const hash3 = await (0, import_shared81.hashDirectoryContents)(directoryContents);
712679
+ const hash3 = await (0, import_shared82.hashDirectoryContents)(directoryContents);
712286
712680
  return { contents: directoryContents, hash: hash3 };
712287
712681
  }
712288
712682
  async function doUploadLocalDirectory(rpcClient, localDirectoryPath) {
@@ -712372,7 +712766,7 @@ var FeatureFlags = class {
712372
712766
 
712373
712767
  // ../sdk/dist/socket/index.js
712374
712768
  init_cjs_shims();
712375
- var import_shared82 = __toESM(require_dist2());
712769
+ var import_shared83 = __toESM(require_dist2());
712376
712770
 
712377
712771
  // ../sdk/dist/socket/handlers.js
712378
712772
  init_cjs_shims();
@@ -712628,7 +713022,7 @@ function createRequestHandlers2({ agentUrl, token: token2 }) {
712628
713022
  }
712629
713023
 
712630
713024
  // ../sdk/dist/socket/index.js
712631
- var CLI_USER_AGENT = (0, import_shared82.buildClientUserAgent)("superblocks-cli", package_default.version);
713025
+ var CLI_USER_AGENT = (0, import_shared83.buildClientUserAgent)("superblocks-cli", package_default.version);
712632
713026
  async function connectToISocketRPCServer2({ superblocksBaseUrl, agentUrl, token: token2 }) {
712633
713027
  const requestHandlers = createRequestHandlers2({
712634
713028
  agentUrl,
@@ -712646,10 +713040,10 @@ async function connectToISocketRPCServer2({ superblocksBaseUrl, agentUrl, token:
712646
713040
  } else if (wsUrl.hostname === "localhost") {
712647
713041
  wsUrl.hostname = "127.0.0.1";
712648
713042
  }
712649
- const ws2 = await (0, import_shared82.connectWebSocket)(wsUrl.href, {
713043
+ const ws2 = await (0, import_shared83.connectWebSocket)(wsUrl.href, {
712650
713044
  headers: { "User-Agent": CLI_USER_AGENT }
712651
713045
  });
712652
- const isocket = new import_shared82.ISocketWithClientAuth(ws2, authorization, requestHandlers, [], getTracer(), {
713046
+ const isocket = new import_shared83.ISocketWithClientAuth(ws2, authorization, requestHandlers, [], getTracer(), {
712653
713047
  timeouts: {
712654
713048
  connectionTimeoutInSeconds: 6 * 60,
712655
713049
  // 6 minutes
@@ -712659,7 +713053,7 @@ async function connectToISocketRPCServer2({ superblocksBaseUrl, agentUrl, token:
712659
713053
  onClose: () => {
712660
713054
  }
712661
713055
  });
712662
- return (0, import_shared82.createISocketClient)(isocket);
713056
+ return (0, import_shared83.createISocketClient)(isocket);
712663
713057
  }
712664
713058
 
712665
713059
  // ../sdk/dist/client.js
@@ -712737,13 +713131,13 @@ async function getCurrentBranchInfo(userSpecifiedBranch, pathPrefix) {
712737
713131
  });
712738
713132
  }
712739
713133
  return new CurrentBranch({
712740
- branchName: import_shared80.DEFAULT_BRANCH,
713134
+ branchName: import_shared81.DEFAULT_BRANCH,
712741
713135
  source: BranchSource.DEFAULT,
712742
713136
  userSpecifiedBranch
712743
713137
  });
712744
713138
  }
712745
713139
  async function fetchApplication({ cliVersion, applicationId, branch, token: token2, superblocksBaseUrl, viewMode, commitId, skipSigningVerification = false, injectedHeaders = {}, keepOriginalNotFoundError = false }) {
712746
- if (commitId && viewMode !== import_shared83.ExportViewMode.EXPORT_COMMIT) {
713140
+ if (commitId && viewMode !== import_shared84.ExportViewMode.EXPORT_COMMIT) {
712747
713141
  throw new Error(`If commitId ${commitId} is provided, viewMode cannot be ${viewMode}`);
712748
713142
  }
712749
713143
  try {
@@ -713442,7 +713836,7 @@ async function pushApi({ cliVersion, apiId, token: token2, superblocksBaseUrl, a
713442
713836
  throw new Error(`Could not push api ${e.message ? "\n" + e.message : ""}`);
713443
713837
  }
713444
713838
  }
713445
- async function fetchApplicationCommits({ cliVersion, applicationId, branch, commitType = import_shared83.CommitType.COMMIT, token: token2, superblocksBaseUrl, injectedHeaders = {}, limit, offset: offset2 }) {
713839
+ async function fetchApplicationCommits({ cliVersion, applicationId, branch, commitType = import_shared84.CommitType.COMMIT, token: token2, superblocksBaseUrl, injectedHeaders = {}, limit, offset: offset2 }) {
713446
713840
  try {
713447
713841
  const serverURL = branch ? new URL(`${BASE_SERVER_API_URL_V2}/applications/${applicationId}/branches/${encodeURIComponent(branch)}/commits`, superblocksBaseUrl) : new URL(`${BASE_SERVER_API_URL_V2}/applications/${applicationId}/commits`, superblocksBaseUrl);
713448
713842
  serverURL.search = new URLSearchParams({
@@ -713468,7 +713862,7 @@ async function fetchApplicationCommits({ cliVersion, applicationId, branch, comm
713468
713862
  throw new Error("Could not fetch application");
713469
713863
  }
713470
713864
  }
713471
- async function fetchApiCommits({ cliVersion, applicationId, branch, commitType = import_shared83.CommitType.COMMIT, token: token2, superblocksBaseUrl, injectedHeaders = {}, limit, offset: offset2 }) {
713865
+ async function fetchApiCommits({ cliVersion, applicationId, branch, commitType = import_shared84.CommitType.COMMIT, token: token2, superblocksBaseUrl, injectedHeaders = {}, limit, offset: offset2 }) {
713472
713866
  try {
713473
713867
  const serverURL = branch ? new URL(`${BASE_SERVER_API_URL_V3}/apis/${applicationId}/branches/${encodeURIComponent(branch)}/commits`, superblocksBaseUrl) : new URL(`${BASE_SERVER_API_URL_V3}/apis/${applicationId}/commits`, superblocksBaseUrl);
713474
713868
  serverURL.search = new URLSearchParams({
@@ -714369,11 +714763,11 @@ function filesToFileDescriptors(files, appRoot) {
714369
714763
 
714370
714764
  // ../sdk/dist/sdk.js
714371
714765
  init_cjs_shims();
714372
- var import_shared85 = __toESM(require_dist2());
714766
+ var import_shared86 = __toESM(require_dist2());
714373
714767
 
714374
714768
  // ../sdk/dist/dbfs/client.js
714375
714769
  init_cjs_shims();
714376
- var import_shared84 = __toESM(require_dist2());
714770
+ var import_shared85 = __toESM(require_dist2());
714377
714771
  var import_util49 = __toESM(require_dist3());
714378
714772
  async function getApplicationDirectoryHash2(token2, superblocksBaseUrl, applicationId, branch, options8) {
714379
714773
  const rpcClient = await connectToISocketRPCServer2({
@@ -714382,10 +714776,10 @@ async function getApplicationDirectoryHash2(token2, superblocksBaseUrl, applicat
714382
714776
  });
714383
714777
  try {
714384
714778
  if (options8?.commitId) {
714385
- const response = await (0, import_shared84.unwrapResponseDto)(rpcClient.call.v3.application.directoryContents.get({
714779
+ const response = await (0, import_shared85.unwrapResponseDto)(rpcClient.call.v3.application.directoryContents.get({
714386
714780
  applicationId,
714387
714781
  commitId: options8.commitId,
714388
- viewMode: import_shared84.ExportViewMode.EXPORT_COMMIT
714782
+ viewMode: import_shared85.ExportViewMode.EXPORT_COMMIT
714389
714783
  }));
714390
714784
  const commitHash = response.hash;
714391
714785
  if (!commitHash) {
@@ -714394,10 +714788,10 @@ async function getApplicationDirectoryHash2(token2, superblocksBaseUrl, applicat
714394
714788
  return commitHash;
714395
714789
  }
714396
714790
  try {
714397
- const response = await (0, import_shared84.unwrapResponseDto)(rpcClient.call.v3.application.directoryContents.get({
714791
+ const response = await (0, import_shared85.unwrapResponseDto)(rpcClient.call.v3.application.directoryContents.get({
714398
714792
  applicationId,
714399
714793
  branchName: branch,
714400
- viewMode: import_shared84.ExportViewMode.EXPORT_LIVE_EDIT
714794
+ viewMode: import_shared85.ExportViewMode.EXPORT_LIVE_EDIT
714401
714795
  }));
714402
714796
  if (response.hash) {
714403
714797
  return response.hash;
@@ -714417,22 +714811,22 @@ async function getApplicationDirectoryHash2(token2, superblocksBaseUrl, applicat
714417
714811
  }
714418
714812
  async function getDraftOrLiveCommitHash(rpcClient, applicationId, branch, options8) {
714419
714813
  try {
714420
- const response = await (0, import_shared84.unwrapResponseDto)(rpcClient.call.v3.application.directoryContents.get({
714814
+ const response = await (0, import_shared85.unwrapResponseDto)(rpcClient.call.v3.application.directoryContents.get({
714421
714815
  applicationId,
714422
714816
  branchName: branch,
714423
- viewMode: import_shared84.ExportViewMode.EXPORT_DRAFT
714817
+ viewMode: import_shared85.ExportViewMode.EXPORT_DRAFT
714424
714818
  }));
714425
714819
  const hash3 = response.hash;
714426
714820
  if (!hash3) {
714427
- throw new Error(`No directory contents hash found for the view mode ${import_shared84.ExportViewMode.EXPORT_DRAFT}`);
714821
+ throw new Error(`No directory contents hash found for the view mode ${import_shared85.ExportViewMode.EXPORT_DRAFT}`);
714428
714822
  }
714429
714823
  return hash3;
714430
714824
  } catch (e) {
714431
- if (e instanceof import_shared84.NotFoundError) {
714432
- const response = await (0, import_shared84.unwrapResponseDto)(rpcClient.call.v3.application.directoryContents.get({
714825
+ if (e instanceof import_shared85.NotFoundError) {
714826
+ const response = await (0, import_shared85.unwrapResponseDto)(rpcClient.call.v3.application.directoryContents.get({
714433
714827
  applicationId,
714434
714828
  branchName: branch,
714435
- viewMode: import_shared84.ExportViewMode.EXPORT_LIVE
714829
+ viewMode: import_shared85.ExportViewMode.EXPORT_LIVE
714436
714830
  }));
714437
714831
  if (!options8?.silent) {
714438
714832
  getLogger2().warn(`Draft commit not found, falling back to the latest live commit: ${response.hash}`);
@@ -714443,7 +714837,7 @@ async function getDraftOrLiveCommitHash(rpcClient, applicationId, branch, option
714443
714837
  }
714444
714838
  }
714445
714839
  function isMissingLiveEditOrUnsupportedViewMode2(e) {
714446
- if (e instanceof import_shared84.NotFoundError) {
714840
+ if (e instanceof import_shared85.NotFoundError) {
714447
714841
  return true;
714448
714842
  }
714449
714843
  const message = e instanceof Error ? e.message : String(e);
@@ -714581,7 +714975,7 @@ var SuperblocksSdk = class {
714581
714975
  async getGitFreshToken(host, applicationId) {
714582
714976
  return getGitFreshToken(this.token, this.superblocksBaseUrl, host, applicationId);
714583
714977
  }
714584
- async fetchApplication({ applicationId, branch, headers = {}, viewMode = import_shared85.ExportViewMode.EXPORT_LIVE, skipSigningVerification = false }) {
714978
+ async fetchApplication({ applicationId, branch, headers = {}, viewMode = import_shared86.ExportViewMode.EXPORT_LIVE, skipSigningVerification = false }) {
714585
714979
  return fetchApplication({
714586
714980
  cliVersion: this.cliVersion,
714587
714981
  applicationId,
@@ -714602,7 +714996,7 @@ var SuperblocksSdk = class {
714602
714996
  injectedHeaders: headers
714603
714997
  });
714604
714998
  }
714605
- async fetchApplicationWithComponents({ applicationId, branch, headers = {}, viewMode = import_shared85.ExportViewMode.EXPORT_LIVE, commitId, skipSigningVerification = false, keepOriginalNotFoundError = false }) {
714999
+ async fetchApplicationWithComponents({ applicationId, branch, headers = {}, viewMode = import_shared86.ExportViewMode.EXPORT_LIVE, commitId, skipSigningVerification = false, keepOriginalNotFoundError = false }) {
714606
715000
  return fetchApplicationWithComponents({
714607
715001
  cliVersion: this.cliVersion,
714608
715002
  applicationId,
@@ -714616,7 +715010,7 @@ var SuperblocksSdk = class {
714616
715010
  keepOriginalNotFoundError
714617
715011
  });
714618
715012
  }
714619
- async fetchApplicationCommits({ applicationId, branch, commitType = import_shared85.CommitType.COMMIT, headers = {}, limit, offset: offset2 }) {
715013
+ async fetchApplicationCommits({ applicationId, branch, commitType = import_shared86.CommitType.COMMIT, headers = {}, limit, offset: offset2 }) {
714620
715014
  return fetchApplicationCommits({
714621
715015
  cliVersion: this.cliVersion,
714622
715016
  applicationId,
@@ -714809,7 +715203,7 @@ var SuperblocksSdk = class {
714809
715203
  folderId
714810
715204
  });
714811
715205
  }
714812
- async fetchApi({ apiId, branch, viewMode = import_shared85.ExportViewMode.EXPORT_LIVE, commitId, skipSigningVerification = false }) {
715206
+ async fetchApi({ apiId, branch, viewMode = import_shared86.ExportViewMode.EXPORT_LIVE, commitId, skipSigningVerification = false }) {
714813
715207
  return fetchApi(this.cliVersion, apiId, this.token, this.superblocksBaseUrl, viewMode, branch, commitId, skipSigningVerification);
714814
715208
  }
714815
715209
  async fetchApis() {
@@ -714993,7 +715387,7 @@ import { promisify as promisify8 } from "node:util";
714993
715387
  import { isNativeError as isNativeError2 } from "node:util/types";
714994
715388
  var import_gt = __toESM(require_gt());
714995
715389
  var import_valid = __toESM(require_valid());
714996
- var import_shared86 = __toESM(require_dist2());
715390
+ var import_shared87 = __toESM(require_dist2());
714997
715391
 
714998
715392
  // ../sdk/dist/cli-replacement/dependency-install-classifier.mjs
714999
715393
  init_cjs_shims();
@@ -715593,7 +715987,7 @@ async function getRemoteVersions(config4) {
715593
715987
  } else {
715594
715988
  const error40 = await response.json();
715595
715989
  const msg = `Could not get latest CLI version: ${error40.responseMeta.message}`;
715596
- if (error40.responseMeta.message?.includes(import_shared86.NON_SB_ORG_UPDATE_ERROR)) {
715990
+ if (error40.responseMeta.message?.includes(import_shared87.NON_SB_ORG_UPDATE_ERROR)) {
715597
715991
  logger23.warn(msg);
715598
715992
  } else {
715599
715993
  logger23.error(msg);
@@ -715725,11 +716119,11 @@ async function checkVersionsAndWritePackageJson(lockService, config4, forceUpgra
715725
716119
  let cliUpdated = false;
715726
716120
  let hasFailedToUpgrade = false;
715727
716121
  const upgradePromises = [];
715728
- await (0, import_shared86.traceFunction)({
716122
+ await (0, import_shared87.traceFunction)({
715729
716123
  name: "checkVersionsAndUpgrade",
715730
716124
  tracer: tracer2,
715731
716125
  fn: async () => {
715732
- const packageManager = await (0, import_shared86.traceFunction)({
716126
+ const packageManager = await (0, import_shared87.traceFunction)({
715733
716127
  name: "detectPackageManager",
715734
716128
  tracer: tracer2,
715735
716129
  fn: async () => {
@@ -715749,14 +716143,14 @@ async function checkVersionsAndWritePackageJson(lockService, config4, forceUpgra
715749
716143
  hasFailedToUpgrade = true;
715750
716144
  return;
715751
716145
  }
715752
- const currentCliInfo = await (0, import_shared86.traceFunction)({
716146
+ const currentCliInfo = await (0, import_shared87.traceFunction)({
715753
716147
  name: "getCurrentCliVersion",
715754
716148
  tracer: tracer2,
715755
716149
  fn: async () => {
715756
716150
  return await getCurrentCliVersion();
715757
716151
  }
715758
716152
  });
715759
- const targetVersions = await (0, import_shared86.traceFunction)({
716153
+ const targetVersions = await (0, import_shared87.traceFunction)({
715760
716154
  name: "getRemoteVersions",
715761
716155
  tracer: tracer2,
715762
716156
  fn: async () => {
@@ -715770,7 +716164,7 @@ async function checkVersionsAndWritePackageJson(lockService, config4, forceUpgra
715770
716164
  cliNeedsUpgrade = Boolean(currentCliInfo && (0, import_valid.default)(currentCliInfo.version) && !(currentCliInfo.version.startsWith("file:") || currentCliInfo.version.startsWith("link:")) && targetVersions.cli && (currentCliInfo.version.toLowerCase().includes("snapshot") ? targetVersions.cli !== currentCliInfo.version : (0, import_gt.default)(targetVersions.cli, currentCliInfo.version)));
715771
716165
  } catch (error40) {
715772
716166
  logger23.error("Error checking versions to upgrade, releasing lock and exiting", getErrorMeta(error40));
715773
- await (0, import_shared86.traceFunction)({
716167
+ await (0, import_shared87.traceFunction)({
715774
716168
  name: "shutdownLockService",
715775
716169
  tracer: tracer2,
715776
716170
  fn: async () => {
@@ -715784,7 +716178,7 @@ async function checkVersionsAndWritePackageJson(lockService, config4, forceUpgra
715784
716178
  }
715785
716179
  try {
715786
716180
  if (!skipCliUpgrade && (cliNeedsUpgrade || forceUpgrade) && currentCliInfo) {
715787
- const cliUpgradePromise = (0, import_shared86.traceFunction)({
716181
+ const cliUpgradePromise = (0, import_shared87.traceFunction)({
715788
716182
  name: "upgradeCli",
715789
716183
  tracer: tracer2,
715790
716184
  // APPS-4544: capture the span so the `outcome` attribute can be
@@ -715798,7 +716192,7 @@ async function checkVersionsAndWritePackageJson(lockService, config4, forceUpgra
715798
716192
  try {
715799
716193
  logger23.info(`Beginning CLI upgrade from ${currentCliInfo.version} to ${targetVersions.cli}`);
715800
716194
  const oclifStart = Date.now();
715801
- const oclifUpgradeSucceeded = await (0, import_shared86.traceFunction)({
716195
+ const oclifUpgradeSucceeded = await (0, import_shared87.traceFunction)({
715802
716196
  name: "upgradeCliWithOclif",
715803
716197
  tracer: tracer2,
715804
716198
  fn: async () => {
@@ -715827,7 +716221,7 @@ async function checkVersionsAndWritePackageJson(lockService, config4, forceUpgra
715827
716221
  logger23.info(`Successfully upgraded CLI to ${targetVersions.cli} via oclif`);
715828
716222
  } else {
715829
716223
  logger23.info(`Falling back to package manager upgrade for CLI`);
715830
- await (0, import_shared86.traceFunction)({
716224
+ await (0, import_shared87.traceFunction)({
715831
716225
  name: "upgradePackageWithPackageManager - cli",
715832
716226
  tracer: tracer2,
715833
716227
  fn: async () => {
@@ -715836,7 +716230,7 @@ async function checkVersionsAndWritePackageJson(lockService, config4, forceUpgra
715836
716230
  });
715837
716231
  }
715838
716232
  try {
715839
- await (0, import_shared86.traceFunction)({
716233
+ await (0, import_shared87.traceFunction)({
715840
716234
  name: "stripUpgradedCliLockfiles",
715841
716235
  tracer: tracer2,
715842
716236
  fn: async () => {
@@ -716206,9 +716600,8 @@ import os8 from "node:os";
716206
716600
  import path76 from "node:path";
716207
716601
  import react3 from "@vitejs/plugin-react";
716208
716602
  import { createLogger as createLogger6, createServer, loadEnv } from "vite";
716209
- var import_shared87 = __toESM(require_dist2(), 1);
716603
+ var import_shared88 = __toESM(require_dist2(), 1);
716210
716604
  var import_util50 = __toESM(require_dist3(), 1);
716211
- var import_util51 = __toESM(require_dist3(), 1);
716212
716605
 
716213
716606
  // ../sdk/dist/telemetry/memory-metrics.js
716214
716607
  init_cjs_shims();
@@ -716492,6 +716885,90 @@ function isRecoverableShutdownError(reason) {
716492
716885
  return RECOVERABLE_SHUTDOWN_CODES.has(code);
716493
716886
  }
716494
716887
 
716888
+ // ../sdk/dist/dev-utils/optimize-deps-config.mjs
716889
+ init_cjs_shims();
716890
+ var OPTIMIZE_DEPS_CONFIG = {
716891
+ // Crawl app source (not just the HTML entry graph) during the cold-start dep
716892
+ // scan so lazily/dynamically imported deps (`@radix-ui/*`, `lucide-react/*`
716893
+ // icons behind route/code-splits) are pre-bundled up front. Without this,
716894
+ // Vite discovers them at runtime and forces an "optimized dependencies
716895
+ // changed. reloading" full-page reload that drops the editor websocket
716896
+ // (close 1001) mid Clark generation (APPS-4576).
716897
+ //
716898
+ // `entries` is NOT part of Vite's optimizeDeps config hash (verified against
716899
+ // Vite 6.4.2: `getConfigHash` in `dist/node/chunks/dep-*.js` hashes only
716900
+ // `optimizeDeps.{include,exclude,esbuildOptions}`, never `entries`), so adding
716901
+ // it cannot desync the pre-warm vs activation dep cache. Re-verify after a
716902
+ // Vite upgrade: if `entries` ever enters the hash, the pre-warm cache would be
716903
+ // discarded on activation whenever the two servers scan different source trees.
716904
+ // `node_modules`/`outDir` are always excluded by Vite.
716905
+ //
716906
+ // The source globs cover every extension a generated app can import a heavy
716907
+ // dep from (`.ts` utilities, not just `.tsx`/`.jsx` components), so a future
716908
+ // `.ts` module importing a tree-shakeable dep is still pre-bundled. `**/*.html`
716909
+ // preserves the default HTML-entry discovery; the `!` patterns keep the scan
716910
+ // off the externalized custom-component dir and the drafts dir (both
716911
+ // watch-ignored elsewhere) so churny user content can't slow or fail the
716912
+ // cold-start scan.
716913
+ //
716914
+ // Node-side files must never become browser dep-scan entries. A generated
716915
+ // app's `vite.config.ts` imports `@tailwindcss/vite`, and a fullstack app's
716916
+ // `server/**` imports Node/native packages; when those files are scan entries
716917
+ // esbuild follows their imports into build-time-only packages and aborts the
716918
+ // whole browser optimize — `@tailwindcss/oxide` has no `.node` loader (see
716919
+ // esbuildOptions below) and `lightningcss` fails to resolve its generated
716920
+ // `../pkg` binding ("Could not resolve \"../pkg\""). Either crashes cold-start
716921
+ // pre-warm for *every* tailwind-v4 app, so exclude config files and the server
716922
+ // tree up front rather than trying to make esbuild tolerate every native dep.
716923
+ entries: [
716924
+ "**/*.html",
716925
+ "**/*.{js,ts,jsx,tsx}",
716926
+ "!custom/**",
716927
+ "!.superblocks/**",
716928
+ "!**/*.config.{js,ts,mjs,mts,cjs,cts}",
716929
+ "!server/**"
716930
+ ],
716931
+ // Force-bundle deps the cold-start scan structurally cannot discover, so they
716932
+ // aren't found at runtime and don't trigger their own reload (verified on an
716933
+ // EE warm-pool box: without this, a freshly-generated app still reloads once
716934
+ // on first render for the JSX runtime — APPS-4576).
716935
+ //
716936
+ // The scan's esbuild uses the DEFAULT (react) JSX runtime, so it emits
716937
+ // `react/jsx-runtime` imports and pre-bundles those — but never
716938
+ // `@superblocksteam/library/jsx-dev-runtime`, even though every generated app
716939
+ // sets `jsxImportSource: "@superblocksteam/library"` and pulls that runtime in
716940
+ // at serve time. Force-including it pre-bundles it up front. An unresolvable
716941
+ // `include` entry is a no-op (Vite warns and skips), so an app that somehow
716942
+ // lacks the library never fails cold-start over this.
716943
+ include: ["@superblocksteam/library/jsx-dev-runtime"],
716944
+ // `@superblocksteam/sdk-api` is a VIRTUAL module the `sb-sdk-api-entry-point`
716945
+ // plugin serves (not a real package), imported by generated app code. Left to
716946
+ // the optimizer it gets discovered as a "new dependency" on first import and
716947
+ // forces a reload; excluding it keeps the dep optimizer from ever trying to
716948
+ // pre-bundle or re-optimize it (the plugin serves it as-is). `include` cannot
716949
+ // fix this one — there is no real file for esbuild to pre-bundle.
716950
+ exclude: ["@superblocksteam/sdk-api"],
716951
+ esbuildOptions: {
716952
+ supported: {
716953
+ destructuring: true
716954
+ },
716955
+ // Tolerate native `.node` addons reached during the cold-start scan. The
716956
+ // widened `entries` glob crawls Node-side app files too (a fullstack app's
716957
+ // `vite.config.ts` imports `@tailwindcss/vite`, which pulls in the native
716958
+ // `@tailwindcss/oxide` `tailwindcss-oxide.<platform>.node`). esbuild has no
716959
+ // loader for `.node`, so bundling such a dep aborts the whole optimize with
716960
+ // "Build failed ... No loader is configured for \".node\" files", which
716961
+ // stops the dev server from serving and leaves the editor websocket stuck
716962
+ // "released" after a respawn (APPS-4576, PR #19858 CI). A native addon
716963
+ // reached during the *browser* dep optimize is always build-time-only and
716964
+ // never executed in the browser, so emptying it is safe and keeps the
716965
+ // cold-start scan from crashing on any native dependency, not just oxide.
716966
+ loader: {
716967
+ ".node": "empty"
716968
+ }
716969
+ }
716970
+ };
716971
+
716495
716972
  // ../sdk/dist/dev-utils/prepare-in-place-restart.mjs
716496
716973
  init_cjs_shims();
716497
716974
  var RESTART_REASON_IPC_TIMEOUT_MS = 1e3;
@@ -716709,6 +717186,8 @@ function endpointForUrl(url4) {
716709
717186
  return "_sb_status";
716710
717187
  case "/_sb_activity":
716711
717188
  return "_sb_activity";
717189
+ case "/_sb_update_token":
717190
+ return "_sb_update_token";
716712
717191
  case "/_sb_persist":
716713
717192
  return "_sb_persist";
716714
717193
  case "/_sb_ready":
@@ -716744,13 +717223,6 @@ function reactPlugin() {
716744
717223
  }
716745
717224
  });
716746
717225
  }
716747
- var OPTIMIZE_DEPS_CONFIG = {
716748
- esbuildOptions: {
716749
- supported: {
716750
- destructuring: true
716751
- }
716752
- }
716753
- };
716754
717226
  function buildResolveConfig() {
716755
717227
  const alias = reactCompilerRuntimeAlias();
716756
717228
  return {
@@ -716946,7 +717418,7 @@ function buildHealthResponse(args) {
716946
717418
  startedAt: DEV_SERVER_STARTED_AT
716947
717419
  };
716948
717420
  }
716949
- async function createDevServer({ root: root3, mode, fsOperationQueue, syncService, lockService, aiService, gitService, gitBootstrapFailed, activateGitService, snapshotManager, logger: loggerOverride, port, sdk, superblocksBaseUrl: explicitBaseUrl, existingServer, warmActivationStart, devServerStatus }) {
717421
+ async function createDevServer({ root: root3, mode, fsOperationQueue, syncService, lockService, tokenManager, aiService, gitService, gitBootstrapAuthFailed, gitBootstrapFailed, activateGitService, refreshGitCredentials, snapshotManager, logger: loggerOverride, port, sdk, superblocksBaseUrl: explicitBaseUrl, existingServer, warmActivationStart, devServerStatus }) {
716950
717422
  const logger25 = getLogger2(loggerOverride);
716951
717423
  if (httpServer) {
716952
717424
  logger25.debug("Dev server already running");
@@ -717084,8 +717556,8 @@ async function createDevServer({ root: root3, mode, fsOperationQueue, syncServic
717084
717556
  res.status(500).send("Error holding request");
717085
717557
  });
717086
717558
  });
717087
- const localToken = await (0, import_util51.getLocalTokenWithUrlIfExists)();
717088
- const jwtVerifier = new import_shared87.JwtVerifier({
717559
+ const localToken = await (0, import_util50.getLocalTokenWithUrlIfExists)();
717560
+ const jwtVerifier = new import_shared88.JwtVerifier({
717089
717561
  jwksUri: getJwksUriWithBaseUrl(localToken?.superblocksBaseUrl),
717090
717562
  cache: true,
717091
717563
  cacheMaxAge: 24 * 60 * 60 * 1e3
@@ -717174,7 +717646,7 @@ async function createDevServer({ root: root3, mode, fsOperationQueue, syncServic
717174
717646
  return;
717175
717647
  }
717176
717648
  const incomingBranch = req.headers["x-superblocks-branch"];
717177
- if (currentBranch && incomingBranch !== currentBranch && incomingBranch !== import_shared87.SUPERBLOCKS_LIVE_GIT_BRANCH) {
717649
+ if (currentBranch && incomingBranch !== currentBranch && incomingBranch !== import_shared88.SUPERBLOCKS_LIVE_GIT_BRANCH) {
717178
717650
  logger25.error(`Dev server expects branch ${currentBranch}, but received ${incomingBranch}. Check your current branch with 'git branch' and try again.`);
717179
717651
  logger25.info(`[dev-server-runtime] _sb_connect branch mismatch: expected ${currentBranch}, got ${incomingBranch}`);
717180
717652
  res.locals.sbFailureType = "branch_mismatch";
@@ -717377,10 +717849,13 @@ async function createDevServer({ root: root3, mode, fsOperationQueue, syncServic
717377
717849
  fsOperationQueue,
717378
717850
  syncService,
717379
717851
  lockService,
717852
+ tokenManager,
717380
717853
  aiService,
717381
717854
  gitService,
717855
+ gitBootstrapAuthFailed,
717382
717856
  gitBootstrapFailed,
717383
717857
  activateGitService,
717858
+ refreshGitCredentials,
717384
717859
  snapshotManager,
717385
717860
  checkAuthorization,
717386
717861
  logger: loggerOverride,
@@ -717411,7 +717886,7 @@ async function createDevServer({ root: root3, mode, fsOperationQueue, syncServic
717411
717886
  }
717412
717887
  return httpServer;
717413
717888
  }
717414
- async function startVite({ app, httpServer: httpServer2, root: root3, mode, port, fsOperationQueue, syncService, lockService, aiService, gitService, gitBootstrapFailed, activateGitService, snapshotManager, checkAuthorization, logger: loggerOverride, superblocksBaseUrl, features, prepareInPlaceRestart: prepareInPlaceRestart2 }) {
717889
+ async function startVite({ app, httpServer: httpServer2, root: root3, mode, port, fsOperationQueue, syncService, lockService, tokenManager, aiService, gitService, gitBootstrapAuthFailed, gitBootstrapFailed, activateGitService, refreshGitCredentials, snapshotManager, checkAuthorization, logger: loggerOverride, superblocksBaseUrl, features, prepareInPlaceRestart: prepareInPlaceRestart2 }) {
717415
717890
  const tracer3 = getDevServerTracer();
717416
717891
  return tracer3.startActiveSpan("startVite", async (startViteSpan) => {
717417
717892
  try {
@@ -717462,10 +717937,13 @@ async function startVite({ app, httpServer: httpServer2, root: root3, mode, port
717462
717937
  fsOperationQueue,
717463
717938
  syncService,
717464
717939
  lockService,
717940
+ tokenManager,
717465
717941
  aiService,
717466
717942
  gitService,
717943
+ gitBootstrapAuthFailed,
717467
717944
  gitBootstrapFailed,
717468
717945
  activateGitService,
717946
+ refreshGitCredentials,
717469
717947
  snapshotManager,
717470
717948
  httpServer: httpServer2,
717471
717949
  checkAuthorization,
@@ -717691,15 +718169,15 @@ function tryDecodeJwtToken(token2) {
717691
718169
 
717692
718170
  // ../sdk/dist/cli-replacement/init.js
717693
718171
  init_cjs_shims();
717694
- var import_shared88 = __toESM(require_dist2());
717695
- var import_util52 = __toESM(require_dist3());
718172
+ var import_shared89 = __toESM(require_dist2());
718173
+ var import_util51 = __toESM(require_dist3());
717696
718174
  async function fetchAndWriteApplication({ resourceId, viewMode, featureFlags, projectRootFolder, appRelativePath, sdk, skipSigningVerification, keepOriginalNotFoundError = false }) {
717697
718175
  const headers = {
717698
- [import_util52.COMPONENT_EVENT_HEADER]: import_shared88.ComponentEvent.INIT
718176
+ [import_util51.COMPONENT_EVENT_HEADER]: import_shared89.ComponentEvent.INIT
717699
718177
  };
717700
718178
  const application = await sdk.fetchApplicationWithComponents({
717701
718179
  applicationId: resourceId,
717702
- branch: import_shared80.DEFAULT_BRANCH,
718180
+ branch: import_shared81.DEFAULT_BRANCH,
717703
718181
  viewMode,
717704
718182
  headers,
717705
718183
  skipSigningVerification,
@@ -717711,7 +718189,7 @@ async function fetchAndWriteApplication({ resourceId, viewMode, featureFlags, pr
717711
718189
  resource: application,
717712
718190
  projectRootFolder,
717713
718191
  appRelativePath,
717714
- branch: import_shared80.DEFAULT_BRANCH,
718192
+ branch: import_shared81.DEFAULT_BRANCH,
717715
718193
  featureFlags
717716
718194
  });
717717
718195
  }
@@ -718053,12 +718531,12 @@ import path79 from "node:path";
718053
718531
  import * as readline2 from "node:readline";
718054
718532
  import { promisify as promisify9 } from "node:util";
718055
718533
  var import_fs_extra5 = __toESM(require_lib(), 1);
718056
- var import_shared90 = __toESM(require_dist2(), 1);
718057
- var import_util53 = __toESM(require_dist3(), 1);
718534
+ var import_shared91 = __toESM(require_dist2(), 1);
718535
+ var import_util52 = __toESM(require_dist3(), 1);
718058
718536
 
718059
718537
  // ../sdk/dist/index.js
718060
718538
  init_cjs_shims();
718061
- var import_shared89 = __toESM(require_dist2(), 1);
718539
+ var import_shared90 = __toESM(require_dist2(), 1);
718062
718540
 
718063
718541
  // ../sdk/dist/cli-replacement/auth-hot-reload.mjs
718064
718542
  init_cjs_shims();
@@ -718372,7 +718850,7 @@ async function handleLockConflict(error40, lockSvc, span, logger25) {
718372
718850
  }
718373
718851
  async function readPkgJson(cwd) {
718374
718852
  try {
718375
- const { readPackage } = await import("./read-pkg-ANYNELJU.js");
718853
+ const { readPackage } = await import("./read-pkg-6TOKHW7I.js");
718376
718854
  return await readPackage({ cwd });
718377
718855
  } catch {
718378
718856
  return null;
@@ -718733,6 +719211,7 @@ async function dev(options8) {
718733
719211
  const port = devServerPort ?? 5173;
718734
719212
  const fsOperationQueue = new OperationQueue();
718735
719213
  let activeDbfsBranchName = applicationConfig?.branchName ?? "main";
719214
+ let devStartupGitBootstrapAuthFailed = false;
718736
719215
  let devStartupGitOutcome = "skipped_no_remote";
718737
719216
  if (applicationConfig && !skipSync) {
718738
719217
  const rpcClient = new AutoConnectingRpcClient(tokenConfig.superblocksBaseUrl, tokenConfig.token, tracer3, tokenManager, logger25);
@@ -718770,7 +719249,7 @@ async function dev(options8) {
718770
719249
  });
718771
719250
  logger25.info("Checking if local files are synced with the server");
718772
719251
  try {
718773
- await (0, import_util53.maskUnixSignals)(async () => {
719252
+ await (0, import_util52.maskUnixSignals)(async () => {
718774
719253
  if (lockService) {
718775
719254
  const lockSvc = lockService;
718776
719255
  await tracer3.startActiveSpan("acquiringInitialLock", async (span) => {
@@ -718783,7 +719262,7 @@ async function dev(options8) {
718783
719262
  await lockSvc.acquireLock();
718784
719263
  }
718785
719264
  } catch (error40) {
718786
- if (error40 instanceof import_shared90.ConflictError) {
719265
+ if (error40 instanceof import_shared91.ConflictError) {
718787
719266
  await handleLockConflict(error40, lockSvc, span, logger25);
718788
719267
  return;
718789
719268
  }
@@ -718823,7 +719302,7 @@ async function dev(options8) {
718823
719302
  downloadFirst = false;
718824
719303
  }
718825
719304
  const templateName = process.env.SUPERBLOCKS_APP_TEMPLATE_NAME ?? options8.prefetchedApplication?.application?.templateName;
718826
- const sdkApiEnabled = (0, import_shared53.isSdkApiTemplate)(templateName);
719305
+ const sdkApiEnabled = (0, import_shared54.isSdkApiTemplate)(templateName);
718827
719306
  const rawFlagBootstrap = currentUser.flagBootstrap;
718828
719307
  const flagBootstrap = {
718829
719308
  ...rawFlagBootstrap,
@@ -718904,6 +719383,7 @@ async function dev(options8) {
718904
719383
  }
718905
719384
  } catch (gitError) {
718906
719385
  devStartupGitOutcome = "bootstrap_failed";
719386
+ devStartupGitBootstrapAuthFailed = (0, import_shared91.isGitAuthErrorMessage)(gitError);
718907
719387
  gitService = void 0;
718908
719388
  logger25.warn("[git] startup git setup failed, continuing without git", {
718909
719389
  gitCategory: "setup",
@@ -719276,6 +719756,26 @@ async function dev(options8) {
719276
719756
  return void 0;
719277
719757
  }
719278
719758
  };
719759
+ const refreshRuntimeGitCredentials = async () => {
719760
+ const gitConfigSdk = sdk;
719761
+ const gitConfig = await gitConfigSdk.getApplicationGitConfig(applicationConfig.id);
719762
+ if (!gitConfig?.gitRemoteUrl) {
719763
+ return void 0;
719764
+ }
719765
+ if (gitService) {
719766
+ const refreshed = await refreshGitServiceCredentials({
719767
+ applicationId: applicationConfig.id,
719768
+ gitRemoteUrl: gitConfig.gitRemoteUrl,
719769
+ logger: logger25,
719770
+ sdk,
719771
+ service: gitService,
719772
+ userEmail: gitUserEmail,
719773
+ userName: gitUserName
719774
+ });
719775
+ return refreshed ? gitService : void 0;
719776
+ }
719777
+ return activateRuntimeGitService();
719778
+ };
719279
719779
  const httpServer2 = await tracer3.startActiveSpan("createDevServer", async (span) => {
719280
719780
  const createDevServerOptions = {
719281
719781
  root: options8.cwd,
@@ -719284,10 +719784,13 @@ async function dev(options8) {
719284
719784
  fsOperationQueue,
719285
719785
  syncService,
719286
719786
  lockService,
719787
+ tokenManager,
719287
719788
  aiService,
719288
719789
  gitService,
719790
+ gitBootstrapAuthFailed: devStartupGitBootstrapAuthFailed,
719289
719791
  gitBootstrapFailed: devStartupGitOutcome === "bootstrap_failed",
719290
719792
  activateGitService: activateRuntimeGitService,
719793
+ refreshGitCredentials: refreshRuntimeGitCredentials,
719291
719794
  snapshotManager,
719292
719795
  logger: options8.logger,
719293
719796
  sdk,
@@ -719332,6 +719835,42 @@ async function dev(options8) {
719332
719835
  }
719333
719836
  });
719334
719837
  }
719838
+ async function fetchGitCredentials({ applicationId, gitRemoteUrl, logger: logger25, sdk }) {
719839
+ const gitConfigSdk = sdk;
719840
+ try {
719841
+ const host = new URL(gitRemoteUrl).hostname;
719842
+ const freshToken = await gitConfigSdk.getGitFreshToken(host, applicationId);
719843
+ return freshToken ?? void 0;
719844
+ } catch (error40) {
719845
+ let gitRemoteHost;
719846
+ try {
719847
+ gitRemoteHost = new URL(gitRemoteUrl).hostname;
719848
+ } catch {
719849
+ }
719850
+ logger25.warn("[git] credential fetch failed, continuing without auth", {
719851
+ gitCategory: "setup",
719852
+ gitOperation: "fetch-credentials",
719853
+ gitOutcome: "failed",
719854
+ applicationId,
719855
+ gitRemoteHost,
719856
+ ...getGitErrorFields(error40)
719857
+ });
719858
+ return void 0;
719859
+ }
719860
+ }
719861
+ async function refreshGitServiceCredentials({ applicationId, gitRemoteUrl, logger: logger25, sdk, service, userEmail, userName }) {
719862
+ const credentials = await fetchGitCredentials({
719863
+ applicationId,
719864
+ gitRemoteUrl,
719865
+ logger: logger25,
719866
+ sdk
719867
+ });
719868
+ if (!credentials) {
719869
+ return false;
719870
+ }
719871
+ await service.configure({ credentials, userEmail, userName });
719872
+ return true;
719873
+ }
719335
719874
  async function bootstrapGitService({ sdk, applicationId, cwd, logger: logger25, userName, userEmail, superblocksBaseUrl }) {
719336
719875
  const gitConfigSdk = sdk;
719337
719876
  const gitConfig = await gitConfigSdk.getApplicationGitConfig(applicationId);
@@ -719339,28 +719878,12 @@ async function bootstrapGitService({ sdk, applicationId, cwd, logger: logger25,
719339
719878
  return void 0;
719340
719879
  }
719341
719880
  const service = createGitService(cwd);
719342
- let credentials;
719343
- let gitRemoteHost;
719344
- if (gitConfig.hasCredential) {
719345
- try {
719346
- const host = new URL(gitConfig.gitRemoteUrl).hostname;
719347
- gitRemoteHost = host;
719348
- const freshToken = await gitConfigSdk.getGitFreshToken(host, applicationId);
719349
- if (freshToken) {
719350
- credentials = freshToken;
719351
- }
719352
- } catch (error40) {
719353
- logger25.warn("[git] credential fetch failed, continuing without auth", {
719354
- gitCategory: "setup",
719355
- gitOperation: "fetch-credentials",
719356
- gitOutcome: "failed",
719357
- applicationId,
719358
- gitRemoteHost,
719359
- gitRemoteUrl: gitConfig.gitRemoteUrl,
719360
- ...getGitErrorFields(error40)
719361
- });
719362
- }
719363
- }
719881
+ const credentials = gitConfig.hasCredential ? await fetchGitCredentials({
719882
+ applicationId,
719883
+ gitRemoteUrl: gitConfig.gitRemoteUrl,
719884
+ logger: logger25,
719885
+ sdk
719886
+ }) : void 0;
719364
719887
  await service.configure({ credentials, userName, userEmail });
719365
719888
  logger25.info("[git] configure complete, proceeding to ensureGitRepo", {
719366
719889
  gitCategory: "setup",
@@ -719407,20 +719930,20 @@ async function ensureGitRepo(git, remoteUrl, superblocksBaseUrl) {
719407
719930
  "ls-remote",
719408
719931
  "--heads",
719409
719932
  "origin",
719410
- `refs/heads/${import_shared90.SUPERBLOCKS_LIVE_GIT_BRANCH}`
719933
+ `refs/heads/${import_shared91.SUPERBLOCKS_LIVE_GIT_BRANCH}`
719411
719934
  ]).catch((err) => {
719412
719935
  getLogger2().warn("[git] ensure repo ls-remote failed", {
719413
719936
  gitCategory: "setup",
719414
719937
  gitOperation: "ensure-repo",
719415
719938
  gitOutcome: "failed",
719416
719939
  gitRemote: "origin",
719417
- gitBranch: import_shared90.SUPERBLOCKS_LIVE_GIT_BRANCH,
719940
+ gitBranch: import_shared91.SUPERBLOCKS_LIVE_GIT_BRANCH,
719418
719941
  gitRemoteUrl: remoteUrl,
719419
719942
  ...getGitErrorFields(err)
719420
719943
  });
719421
719944
  return "";
719422
719945
  });
719423
- if (!remoteRefs.includes(`refs/heads/${import_shared90.SUPERBLOCKS_LIVE_GIT_BRANCH}`)) {
719946
+ if (!remoteRefs.includes(`refs/heads/${import_shared91.SUPERBLOCKS_LIVE_GIT_BRANCH}`)) {
719424
719947
  await seedGithubWorkflowIfNeeded(git.workDir, remoteUrl, superblocksBaseUrl);
719425
719948
  let defaultBranch;
719426
719949
  try {
@@ -719450,9 +719973,9 @@ async function ensureGitRepo(git, remoteUrl, superblocksBaseUrl) {
719450
719973
  await git.raw([
719451
719974
  "symbolic-ref",
719452
719975
  "HEAD",
719453
- `refs/heads/${import_shared90.SUPERBLOCKS_LIVE_GIT_BRANCH}`
719976
+ `refs/heads/${import_shared91.SUPERBLOCKS_LIVE_GIT_BRANCH}`
719454
719977
  ]);
719455
- await git.raw(["reset", `origin/${import_shared90.SUPERBLOCKS_LIVE_GIT_BRANCH}`]);
719978
+ await git.raw(["reset", `origin/${import_shared91.SUPERBLOCKS_LIVE_GIT_BRANCH}`]);
719456
719979
  }
719457
719980
  } else {
719458
719981
  try {
@@ -719498,7 +720021,7 @@ async function ensureGitRepo(git, remoteUrl, superblocksBaseUrl) {
719498
720021
  await seedGithubWorkflowIfNeeded(git.workDir, remoteUrl, superblocksBaseUrl);
719499
720022
  }
719500
720023
  async function seedGithubWorkflowIfNeeded(workDir, remoteUrl, superblocksBaseUrl) {
719501
- if (!(0, import_shared90.isGitHubRemoteUrl)(remoteUrl)) {
720024
+ if (!(0, import_shared91.isGitHubRemoteUrl)(remoteUrl)) {
719502
720025
  return;
719503
720026
  }
719504
720027
  const workflowDir = path79.join(workDir, ".github", "workflows");
@@ -719509,7 +720032,7 @@ async function seedGithubWorkflowIfNeeded(workDir, remoteUrl, superblocksBaseUrl
719509
720032
  }
719510
720033
  await nodeFs2.mkdir(workflowDir, { recursive: true });
719511
720034
  const baseUrl = superblocksBaseUrl || process.env.SUPERBLOCKS_BASE_URL || "";
719512
- await nodeFs2.writeFile(workflowFile, baseUrl ? (0, import_shared90.buildGithubSuperblocksSyncWorkflowFromBaseUrl)(baseUrl) : (0, import_shared90.buildGithubSuperblocksSyncWorkflow)(), "utf-8");
720035
+ await nodeFs2.writeFile(workflowFile, baseUrl ? (0, import_shared91.buildGithubSuperblocksSyncWorkflowFromBaseUrl)(baseUrl) : (0, import_shared91.buildGithubSuperblocksSyncWorkflow)(), "utf-8");
719513
720036
  }
719514
720037
  async function canResolveRef(git, ref2) {
719515
720038
  try {
@@ -719520,13 +720043,13 @@ async function canResolveRef(git, ref2) {
719520
720043
  }
719521
720044
  }
719522
720045
  async function ensureLiveBranchCheckedOutAfterFetch(git) {
719523
- if (await canResolveRef(git, `origin/${import_shared90.SUPERBLOCKS_LIVE_GIT_BRANCH}`)) {
719524
- await git.checkoutOrCreate(import_shared90.SUPERBLOCKS_LIVE_GIT_BRANCH, `origin/${import_shared90.SUPERBLOCKS_LIVE_GIT_BRANCH}`);
720046
+ if (await canResolveRef(git, `origin/${import_shared91.SUPERBLOCKS_LIVE_GIT_BRANCH}`)) {
720047
+ await git.checkoutOrCreate(import_shared91.SUPERBLOCKS_LIVE_GIT_BRANCH, `origin/${import_shared91.SUPERBLOCKS_LIVE_GIT_BRANCH}`);
719525
720048
  return;
719526
720049
  }
719527
720050
  const branch = await git.raw(["branch", "--show-current"]).then((b3) => b3.trim()).catch(() => "");
719528
- if (branch !== import_shared90.SUPERBLOCKS_LIVE_GIT_BRANCH) {
719529
- await git.checkoutOrCreate(import_shared90.SUPERBLOCKS_LIVE_GIT_BRANCH);
720051
+ if (branch !== import_shared91.SUPERBLOCKS_LIVE_GIT_BRANCH) {
720052
+ await git.checkoutOrCreate(import_shared91.SUPERBLOCKS_LIVE_GIT_BRANCH);
719530
720053
  }
719531
720054
  }
719532
720055
  async function ensureRuntimeDbfsBranchConsistency({ sdk, applicationConfig, logger: logger25, lockService, syncService, currentBranchName }) {
@@ -719574,15 +720097,15 @@ async function resolveDbfsBranchName(sdk, applicationConfig, logger25) {
719574
720097
  const fallbackBranchName = applicationConfig.branchName;
719575
720098
  const gitAwareSdk = sdk;
719576
720099
  const normalizeNonGitBranchFallback = (branchName) => {
719577
- if (branchName !== import_shared90.SUPERBLOCKS_LIVE_GIT_BRANCH) {
720100
+ if (branchName !== import_shared91.SUPERBLOCKS_LIVE_GIT_BRANCH) {
719578
720101
  return branchName;
719579
720102
  }
719580
- logger25.warn(`[git] stale '${import_shared90.SUPERBLOCKS_LIVE_GIT_BRANCH}' branch context detected after git disconnect; falling back to '${import_shared90.DEFAULT_NON_GIT_BRANCH}'`);
719581
- return import_shared90.DEFAULT_NON_GIT_BRANCH;
720103
+ logger25.warn(`[git] stale '${import_shared91.SUPERBLOCKS_LIVE_GIT_BRANCH}' branch context detected after git disconnect; falling back to '${import_shared91.DEFAULT_NON_GIT_BRANCH}'`);
720104
+ return import_shared91.DEFAULT_NON_GIT_BRANCH;
719582
720105
  };
719583
720106
  try {
719584
720107
  const gitConfig = await gitAwareSdk.getApplicationGitConfig(applicationConfig.id);
719585
- return gitConfig?.gitRemoteUrl ? import_shared90.SUPERBLOCKS_LIVE_GIT_BRANCH : normalizeNonGitBranchFallback(fallbackBranchName);
720108
+ return gitConfig?.gitRemoteUrl ? import_shared91.SUPERBLOCKS_LIVE_GIT_BRANCH : normalizeNonGitBranchFallback(fallbackBranchName);
719586
720109
  } catch (error40) {
719587
720110
  const normalizedFallbackBranchName = normalizeNonGitBranchFallback(fallbackBranchName);
719588
720111
  logger25.warn(`Could not resolve DBFS branch selection; falling back to '${normalizedFallbackBranchName}': ${error40 instanceof Error ? error40.message : String(error40)}`);
@@ -719613,7 +720136,7 @@ export {
719613
720136
  BranchNotCheckedOutError,
719614
720137
  CommitAlreadyExistsError,
719615
720138
  ValidateGitSetupError,
719616
- import_shared80 as import_shared,
720139
+ import_shared81 as import_shared,
719617
720140
  DRAFT_MODE,
719618
720141
  modeFlagValuesMap,
719619
720142
  FileStructureType,
@@ -719661,7 +720184,7 @@ export {
719661
720184
  dev,
719662
720185
  AuthHotReloadServer,
719663
720186
  isAuthHotReloadEnabled,
719664
- import_shared89 as import_shared2
720187
+ import_shared90 as import_shared2
719665
720188
  };
719666
720189
  /*! Bundled license information:
719667
720190
 
@@ -720199,4 +720722,4 @@ serve-static/index.js:
720199
720722
  chokidar/esm/index.js:
720200
720723
  (*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) *)
720201
720724
  */
720202
- //# sourceMappingURL=chunk-O3ALZQID.js.map
720725
+ //# sourceMappingURL=chunk-2FCS5636.js.map