@superblocksteam/cli 2.0.130-next.2 → 2.0.130-next.3
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.
- package/README.md +1 -1
- package/dist/{acorn-PNDQIP6Z.js → acorn-OS63BTIP.js} +3 -3
- package/dist/{angular-46FTABOP.js → angular-XRJMPAT5.js} +3 -3
- package/dist/{api-GPW6H52S.js → api-HC4NYIUZ.js} +4 -4
- package/dist/{babel-ZHCYURNT.js → babel-KABIYOLI.js} +3 -3
- package/dist/{chunk-YL3MIXKM.js → chunk-262TJEPX.js} +4 -4
- package/dist/{chunk-SMOAL53W.js → chunk-43DIHC2U.js} +6 -6
- package/dist/{chunk-GGJKZH6S.js → chunk-7FMZSZA6.js} +3 -3
- package/dist/{chunk-4INX77NS.js → chunk-B56DITGN.js} +4 -4
- package/dist/{chunk-HKOWMZY5.js → chunk-BFITK36F.js} +3 -3
- package/dist/{chunk-J745UPDF.js → chunk-CANWOGVY.js} +3 -3
- package/dist/{chunk-CJCNHJUQ.js → chunk-DBRCJRC3.js} +2 -2
- package/dist/{chunk-UPH4O6RE.js → chunk-EKT3Z66O.js} +3 -3
- package/dist/{chunk-4HSCNKDX.js → chunk-I46WMOVI.js} +6 -6
- package/dist/{chunk-65336RGK.js → chunk-I4W6X4VH.js} +3 -3
- package/dist/{chunk-LEMT7T2E.js → chunk-IS2VPPQA.js} +3 -3
- package/dist/{chunk-KGKK6ZNP.js → chunk-J7WHG2MR.js} +3 -3
- package/dist/{chunk-72H2Q762.js → chunk-L4DHTBVN.js} +3 -3
- package/dist/{chunk-VK7ZESB7.js → chunk-NTV5GOFP.js} +4 -4
- package/dist/{chunk-2CF5BVZN.js → chunk-RLK4IGZE.js} +3 -3
- package/dist/{chunk-MRVVM4MF.js → chunk-TOZ7A6XG.js} +586 -355
- package/dist/{chunk-MRVVM4MF.js.map → chunk-TOZ7A6XG.js.map} +1 -1
- package/dist/{chunk-HALPXS3G.js → chunk-UY45BISH.js} +3 -3
- package/dist/{chunk-WRLY7XGY.js → chunk-Z6EHTVIV.js} +4 -4
- package/dist/{cli-truncate-UQWOLUW7.js → cli-truncate-HNIAB3G4.js} +5 -5
- package/dist/commands/dev-parent.js +2 -2
- package/dist/{dd-trace-HJUEFCMR.js → dd-trace-PISMQOM4.js} +7 -7
- package/dist/{dist-LFNGM5YE.js → dist-SYYYSUFH.js} +13 -13
- package/dist/{embedded-playwright-mcp-server-SWU2GROW.js → embedded-playwright-mcp-server-46UEH2AX.js} +3 -3
- package/dist/{enquirer-5R4RVNHQ.js → enquirer-FB4LRSFS.js} +4 -4
- package/dist/{estree-CVEVNMEY.js → estree-3ELOGBVO.js} +3 -3
- package/dist/{flow-IE3M4PY6.js → flow-WZSRVHZW.js} +3 -3
- package/dist/{getMachineId-bsd-ZHXGNGPP.js → getMachineId-bsd-FLOEJRVI.js} +5 -5
- package/dist/{getMachineId-bsd-OESKFPYR.js → getMachineId-bsd-KFFBZDSI.js} +5 -5
- package/dist/{getMachineId-darwin-X3L75J64.js → getMachineId-darwin-2LECXTWI.js} +5 -5
- package/dist/{getMachineId-darwin-P4SBJXEE.js → getMachineId-darwin-O42KXLBH.js} +5 -5
- package/dist/{getMachineId-linux-BP2YOBNV.js → getMachineId-linux-GDN6VP2A.js} +4 -4
- package/dist/{getMachineId-linux-GYKYU2VS.js → getMachineId-linux-HL4T6PK6.js} +4 -4
- package/dist/{getMachineId-unsupported-GCZD7ZNO.js → getMachineId-unsupported-F2DRQ7QH.js} +4 -4
- package/dist/{getMachineId-unsupported-OM76MT2H.js → getMachineId-unsupported-LYCZROMT.js} +4 -4
- package/dist/{getMachineId-win-BIGOASIM.js → getMachineId-win-2PYSOPWA.js} +5 -5
- package/dist/{getMachineId-win-MATQAJM5.js → getMachineId-win-BRBRRUXE.js} +5 -5
- package/dist/{glimmer-AL4JQT4P.js → glimmer-IMKJRXNH.js} +3 -3
- package/dist/{graphql-OYPRAJ2F.js → graphql-NXAASEI3.js} +3 -3
- package/dist/{html-Z2OPZK7Y.js → html-73R3X3I4.js} +3 -3
- package/dist/{http-7SJNGYX5.js → http-QJ5HORFH.js} +12 -12
- package/dist/index.js +18 -18
- package/dist/{jiti-WLQLO77Q.js → jiti-PKH2TSAU.js} +3 -3
- package/dist/{log-update-UG66HQWH.js → log-update-Z3A77OMM.js} +6 -6
- package/dist/{markdown-MXQ2FGWR.js → markdown-5NVT32YM.js} +3 -3
- package/dist/{meriyah-D5WHB4VG.js → meriyah-5HLBX7QE.js} +3 -3
- package/dist/{postcss-C56PS4TK.js → postcss-RGXOH323.js} +3 -3
- package/dist/{read-pkg-LA7GFWSK.js → read-pkg-BUJFLEXQ.js} +5 -5
- package/dist/{spans-XFMNVHJD.js → spans-GFS66UKZ.js} +4 -4
- package/dist/{src-M4SCGEDI.js → src-VSJSPJHE.js} +3 -3
- package/dist/{token-VF4NE2R7.js → token-VXC2MKCH.js} +5 -5
- package/dist/{token-util-CL2OLF7I.js → token-util-POAWM4EX.js} +5 -5
- package/dist/{typescript-R4PX3DN5.js → typescript-HJJCNM6Y.js} +3 -3
- package/dist/{wrap-ansi-CB65FWB5.js → wrap-ansi-KHBLLIJ6.js} +5 -5
- package/dist/{yaml-HVUWODPN.js → yaml-RNXURET6.js} +3 -3
- package/oclif.manifest.json +1 -1
- package/package.json +6 -6
- /package/dist/{acorn-PNDQIP6Z.js.map → acorn-OS63BTIP.js.map} +0 -0
- /package/dist/{angular-46FTABOP.js.map → angular-XRJMPAT5.js.map} +0 -0
- /package/dist/{api-GPW6H52S.js.map → api-HC4NYIUZ.js.map} +0 -0
- /package/dist/{babel-ZHCYURNT.js.map → babel-KABIYOLI.js.map} +0 -0
- /package/dist/{chunk-YL3MIXKM.js.map → chunk-262TJEPX.js.map} +0 -0
- /package/dist/{chunk-SMOAL53W.js.map → chunk-43DIHC2U.js.map} +0 -0
- /package/dist/{chunk-GGJKZH6S.js.map → chunk-7FMZSZA6.js.map} +0 -0
- /package/dist/{chunk-4INX77NS.js.map → chunk-B56DITGN.js.map} +0 -0
- /package/dist/{chunk-HKOWMZY5.js.map → chunk-BFITK36F.js.map} +0 -0
- /package/dist/{chunk-J745UPDF.js.map → chunk-CANWOGVY.js.map} +0 -0
- /package/dist/{chunk-CJCNHJUQ.js.map → chunk-DBRCJRC3.js.map} +0 -0
- /package/dist/{chunk-UPH4O6RE.js.map → chunk-EKT3Z66O.js.map} +0 -0
- /package/dist/{chunk-4HSCNKDX.js.map → chunk-I46WMOVI.js.map} +0 -0
- /package/dist/{chunk-65336RGK.js.map → chunk-I4W6X4VH.js.map} +0 -0
- /package/dist/{chunk-LEMT7T2E.js.map → chunk-IS2VPPQA.js.map} +0 -0
- /package/dist/{chunk-KGKK6ZNP.js.map → chunk-J7WHG2MR.js.map} +0 -0
- /package/dist/{chunk-72H2Q762.js.map → chunk-L4DHTBVN.js.map} +0 -0
- /package/dist/{chunk-VK7ZESB7.js.map → chunk-NTV5GOFP.js.map} +0 -0
- /package/dist/{chunk-2CF5BVZN.js.map → chunk-RLK4IGZE.js.map} +0 -0
- /package/dist/{chunk-HALPXS3G.js.map → chunk-UY45BISH.js.map} +0 -0
- /package/dist/{chunk-WRLY7XGY.js.map → chunk-Z6EHTVIV.js.map} +0 -0
- /package/dist/{cli-truncate-UQWOLUW7.js.map → cli-truncate-HNIAB3G4.js.map} +0 -0
- /package/dist/{dd-trace-HJUEFCMR.js.map → dd-trace-PISMQOM4.js.map} +0 -0
- /package/dist/{dist-LFNGM5YE.js.map → dist-SYYYSUFH.js.map} +0 -0
- /package/dist/{embedded-playwright-mcp-server-SWU2GROW.js.map → embedded-playwright-mcp-server-46UEH2AX.js.map} +0 -0
- /package/dist/{enquirer-5R4RVNHQ.js.map → enquirer-FB4LRSFS.js.map} +0 -0
- /package/dist/{estree-CVEVNMEY.js.map → estree-3ELOGBVO.js.map} +0 -0
- /package/dist/{flow-IE3M4PY6.js.map → flow-WZSRVHZW.js.map} +0 -0
- /package/dist/{getMachineId-bsd-ZHXGNGPP.js.map → getMachineId-bsd-FLOEJRVI.js.map} +0 -0
- /package/dist/{getMachineId-bsd-OESKFPYR.js.map → getMachineId-bsd-KFFBZDSI.js.map} +0 -0
- /package/dist/{getMachineId-darwin-X3L75J64.js.map → getMachineId-darwin-2LECXTWI.js.map} +0 -0
- /package/dist/{getMachineId-darwin-P4SBJXEE.js.map → getMachineId-darwin-O42KXLBH.js.map} +0 -0
- /package/dist/{getMachineId-linux-BP2YOBNV.js.map → getMachineId-linux-GDN6VP2A.js.map} +0 -0
- /package/dist/{getMachineId-linux-GYKYU2VS.js.map → getMachineId-linux-HL4T6PK6.js.map} +0 -0
- /package/dist/{getMachineId-unsupported-GCZD7ZNO.js.map → getMachineId-unsupported-F2DRQ7QH.js.map} +0 -0
- /package/dist/{getMachineId-unsupported-OM76MT2H.js.map → getMachineId-unsupported-LYCZROMT.js.map} +0 -0
- /package/dist/{getMachineId-win-BIGOASIM.js.map → getMachineId-win-2PYSOPWA.js.map} +0 -0
- /package/dist/{getMachineId-win-MATQAJM5.js.map → getMachineId-win-BRBRRUXE.js.map} +0 -0
- /package/dist/{glimmer-AL4JQT4P.js.map → glimmer-IMKJRXNH.js.map} +0 -0
- /package/dist/{graphql-OYPRAJ2F.js.map → graphql-NXAASEI3.js.map} +0 -0
- /package/dist/{html-Z2OPZK7Y.js.map → html-73R3X3I4.js.map} +0 -0
- /package/dist/{http-7SJNGYX5.js.map → http-QJ5HORFH.js.map} +0 -0
- /package/dist/{jiti-WLQLO77Q.js.map → jiti-PKH2TSAU.js.map} +0 -0
- /package/dist/{log-update-UG66HQWH.js.map → log-update-Z3A77OMM.js.map} +0 -0
- /package/dist/{markdown-MXQ2FGWR.js.map → markdown-5NVT32YM.js.map} +0 -0
- /package/dist/{meriyah-D5WHB4VG.js.map → meriyah-5HLBX7QE.js.map} +0 -0
- /package/dist/{postcss-C56PS4TK.js.map → postcss-RGXOH323.js.map} +0 -0
- /package/dist/{read-pkg-LA7GFWSK.js.map → read-pkg-BUJFLEXQ.js.map} +0 -0
- /package/dist/{spans-XFMNVHJD.js.map → spans-GFS66UKZ.js.map} +0 -0
- /package/dist/{src-M4SCGEDI.js.map → src-VSJSPJHE.js.map} +0 -0
- /package/dist/{token-VF4NE2R7.js.map → token-VXC2MKCH.js.map} +0 -0
- /package/dist/{token-util-CL2OLF7I.js.map → token-util-POAWM4EX.js.map} +0 -0
- /package/dist/{typescript-R4PX3DN5.js.map → typescript-HJJCNM6Y.js.map} +0 -0
- /package/dist/{wrap-ansi-CB65FWB5.js.map → wrap-ansi-KHBLLIJ6.js.map} +0 -0
- /package/dist/{yaml-HVUWODPN.js.map → yaml-RNXURET6.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 = '
|
|
4
|
+
process.env.DD_GIT_COMMIT_SHA = 'a3b0270c89c725582637135fe235efbb7e4e8d80';
|
|
5
5
|
}
|
|
6
6
|
import { createRequire as $dd_createRequire } from 'module';
|
|
7
7
|
import { fileURLToPath as $dd_fileURLToPath } from 'url';
|
|
@@ -22,17 +22,17 @@ import {
|
|
|
22
22
|
require_re,
|
|
23
23
|
require_semver,
|
|
24
24
|
require_valid
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-RLK4IGZE.js";
|
|
26
26
|
import {
|
|
27
27
|
require_dd_trace,
|
|
28
28
|
require_js_yaml,
|
|
29
29
|
require_module_details_from_path,
|
|
30
30
|
require_p_limit,
|
|
31
31
|
require_path_to_regexp
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-I46WMOVI.js";
|
|
33
33
|
import {
|
|
34
34
|
require_commonjs
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-I4W6X4VH.js";
|
|
36
36
|
import {
|
|
37
37
|
debounce_default,
|
|
38
38
|
get_default,
|
|
@@ -49,13 +49,13 @@ import {
|
|
|
49
49
|
require_lib,
|
|
50
50
|
require_slugify,
|
|
51
51
|
throttle_default
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-IS2VPPQA.js";
|
|
53
53
|
import {
|
|
54
54
|
require_dc_polyfill
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-L4DHTBVN.js";
|
|
56
56
|
import {
|
|
57
57
|
require_token_error
|
|
58
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-J7WHG2MR.js";
|
|
59
59
|
import {
|
|
60
60
|
SpanKind,
|
|
61
61
|
SpanStatusCode,
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
init_esm,
|
|
66
66
|
metrics,
|
|
67
67
|
trace
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-BFITK36F.js";
|
|
69
69
|
import {
|
|
70
70
|
__commonJS,
|
|
71
71
|
__esm,
|
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
__toCommonJS,
|
|
75
75
|
__toESM,
|
|
76
76
|
init_cjs_shims
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-DBRCJRC3.js";
|
|
78
78
|
|
|
79
79
|
// ../../../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/constants.js
|
|
80
80
|
var require_constants3 = __commonJS({
|
|
@@ -97073,15 +97073,15 @@ var require_api_files = __commonJS({
|
|
|
97073
97073
|
exports.readAppApiYamlFile = readAppApiYamlFile4;
|
|
97074
97074
|
exports.resolveLanguageSpecificStepContentFromBlocks = resolveLanguageSpecificStepContentFromBlocks2;
|
|
97075
97075
|
async function writeApiFiles3(...args) {
|
|
97076
|
-
const esmFunction = await import("./api-
|
|
97076
|
+
const esmFunction = await import("./api-HC4NYIUZ.js");
|
|
97077
97077
|
return esmFunction.writeApiFiles(...args);
|
|
97078
97078
|
}
|
|
97079
97079
|
async function readAppApiYamlFile4(...args) {
|
|
97080
|
-
const esmFunction = await import("./api-
|
|
97080
|
+
const esmFunction = await import("./api-HC4NYIUZ.js");
|
|
97081
97081
|
return esmFunction.readAppApiYamlFile(...args);
|
|
97082
97082
|
}
|
|
97083
97083
|
async function resolveLanguageSpecificStepContentFromBlocks2(...args) {
|
|
97084
|
-
const esmFunction = await import("./api-
|
|
97084
|
+
const esmFunction = await import("./api-HC4NYIUZ.js");
|
|
97085
97085
|
return esmFunction.resolveLanguageSpecificStepContentFromBlocks(...args);
|
|
97086
97086
|
}
|
|
97087
97087
|
}
|
|
@@ -106717,19 +106717,19 @@ var require_getMachineId = __commonJS({
|
|
|
106717
106717
|
if (!getMachineIdImpl) {
|
|
106718
106718
|
switch (process5.platform) {
|
|
106719
106719
|
case "darwin":
|
|
106720
|
-
getMachineIdImpl = (await import("./getMachineId-darwin-
|
|
106720
|
+
getMachineIdImpl = (await import("./getMachineId-darwin-O42KXLBH.js")).getMachineId;
|
|
106721
106721
|
break;
|
|
106722
106722
|
case "linux":
|
|
106723
|
-
getMachineIdImpl = (await import("./getMachineId-linux-
|
|
106723
|
+
getMachineIdImpl = (await import("./getMachineId-linux-GDN6VP2A.js")).getMachineId;
|
|
106724
106724
|
break;
|
|
106725
106725
|
case "freebsd":
|
|
106726
|
-
getMachineIdImpl = (await import("./getMachineId-bsd-
|
|
106726
|
+
getMachineIdImpl = (await import("./getMachineId-bsd-KFFBZDSI.js")).getMachineId;
|
|
106727
106727
|
break;
|
|
106728
106728
|
case "win32":
|
|
106729
|
-
getMachineIdImpl = (await import("./getMachineId-win-
|
|
106729
|
+
getMachineIdImpl = (await import("./getMachineId-win-BRBRRUXE.js")).getMachineId;
|
|
106730
106730
|
break;
|
|
106731
106731
|
default:
|
|
106732
|
-
getMachineIdImpl = (await import("./getMachineId-unsupported-
|
|
106732
|
+
getMachineIdImpl = (await import("./getMachineId-unsupported-LYCZROMT.js")).getMachineId;
|
|
106733
106733
|
break;
|
|
106734
106734
|
}
|
|
106735
106735
|
}
|
|
@@ -115721,19 +115721,19 @@ var require_getMachineId2 = __commonJS({
|
|
|
115721
115721
|
if (!getMachineIdImpl) {
|
|
115722
115722
|
switch (process5.platform) {
|
|
115723
115723
|
case "darwin":
|
|
115724
|
-
getMachineIdImpl = (await import("./getMachineId-darwin-
|
|
115724
|
+
getMachineIdImpl = (await import("./getMachineId-darwin-2LECXTWI.js")).getMachineId;
|
|
115725
115725
|
break;
|
|
115726
115726
|
case "linux":
|
|
115727
|
-
getMachineIdImpl = (await import("./getMachineId-linux-
|
|
115727
|
+
getMachineIdImpl = (await import("./getMachineId-linux-HL4T6PK6.js")).getMachineId;
|
|
115728
115728
|
break;
|
|
115729
115729
|
case "freebsd":
|
|
115730
|
-
getMachineIdImpl = (await import("./getMachineId-bsd-
|
|
115730
|
+
getMachineIdImpl = (await import("./getMachineId-bsd-FLOEJRVI.js")).getMachineId;
|
|
115731
115731
|
break;
|
|
115732
115732
|
case "win32":
|
|
115733
|
-
getMachineIdImpl = (await import("./getMachineId-win-
|
|
115733
|
+
getMachineIdImpl = (await import("./getMachineId-win-2PYSOPWA.js")).getMachineId;
|
|
115734
115734
|
break;
|
|
115735
115735
|
default:
|
|
115736
|
-
getMachineIdImpl = (await import("./getMachineId-unsupported-
|
|
115736
|
+
getMachineIdImpl = (await import("./getMachineId-unsupported-F2DRQ7QH.js")).getMachineId;
|
|
115737
115737
|
break;
|
|
115738
115738
|
}
|
|
115739
115739
|
}
|
|
@@ -197606,8 +197606,8 @@ var require_get_vercel_oidc_token = __commonJS({
|
|
|
197606
197606
|
}
|
|
197607
197607
|
try {
|
|
197608
197608
|
const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
|
|
197609
|
-
await import("./token-util-
|
|
197610
|
-
await import("./token-
|
|
197609
|
+
await import("./token-util-POAWM4EX.js"),
|
|
197610
|
+
await import("./token-VXC2MKCH.js")
|
|
197611
197611
|
]);
|
|
197612
197612
|
if (!token2 || isExpired(getTokenPayload(token2))) {
|
|
197613
197613
|
await refreshToken();
|
|
@@ -452998,7 +452998,7 @@ var require_config_loader = __commonJS({
|
|
|
452998
452998
|
* @returns {Promise<{createJiti: Function|undefined, version: string;}>} A promise that fulfills with an object containing the jiti module's createJiti function and version.
|
|
452999
452999
|
*/
|
|
453000
453000
|
static async loadJiti() {
|
|
453001
|
-
const { createJiti } = await import("./jiti-
|
|
453001
|
+
const { createJiti } = await import("./jiti-PKH2TSAU.js");
|
|
453002
453002
|
const version4 = require_package5().version;
|
|
453003
453003
|
return { createJiti, version: version4 };
|
|
453004
453004
|
}
|
|
@@ -453327,7 +453327,7 @@ var require_eslint_helpers = __commonJS({
|
|
|
453327
453327
|
}
|
|
453328
453328
|
async function globMatch({ basePath, pattern }) {
|
|
453329
453329
|
let found = false;
|
|
453330
|
-
const { hfs } = await import("./src-
|
|
453330
|
+
const { hfs } = await import("./src-VSJSPJHE.js");
|
|
453331
453331
|
const patternToUse = normalizeToPosix(path78.relative(basePath, pattern));
|
|
453332
453332
|
const matcher = new Minimatch2(patternToUse, MINIMATCH_OPTIONS);
|
|
453333
453333
|
const walkSettings = {
|
|
@@ -453367,7 +453367,7 @@ var require_eslint_helpers = __commonJS({
|
|
|
453367
453367
|
return new Minimatch2(patternToUse, MINIMATCH_OPTIONS);
|
|
453368
453368
|
});
|
|
453369
453369
|
const unmatchedPatterns = /* @__PURE__ */ new Set([...relativeToPatterns.keys()]);
|
|
453370
|
-
const { hfs } = await import("./src-
|
|
453370
|
+
const { hfs } = await import("./src-VSJSPJHE.js");
|
|
453371
453371
|
const walk2 = hfs.walk(basePath, {
|
|
453372
453372
|
async directoryFilter(entry) {
|
|
453373
453373
|
if (!matchers.some((matcher) => matcher.match(entry.path, true))) {
|
|
@@ -509972,7 +509972,7 @@ init_cjs_shims();
|
|
|
509972
509972
|
// ../sdk/package.json
|
|
509973
509973
|
var package_default = {
|
|
509974
509974
|
name: "@superblocksteam/sdk",
|
|
509975
|
-
version: "2.0.130-next.
|
|
509975
|
+
version: "2.0.130-next.3",
|
|
509976
509976
|
description: "Superblocks JS SDK",
|
|
509977
509977
|
homepage: "https://www.superblocks.com",
|
|
509978
509978
|
license: "Superblocks Community Software License",
|
|
@@ -510350,7 +510350,7 @@ var config = void 0;
|
|
|
510350
510350
|
var configured = false;
|
|
510351
510351
|
var ddTracePromise = void 0;
|
|
510352
510352
|
async function getDdTrace() {
|
|
510353
|
-
ddTracePromise ??= import("./dd-trace-
|
|
510353
|
+
ddTracePromise ??= import("./dd-trace-PISMQOM4.js").then((module) => module.default);
|
|
510354
510354
|
return await ddTracePromise;
|
|
510355
510355
|
}
|
|
510356
510356
|
var deploymentType = (() => {
|
|
@@ -514455,7 +514455,7 @@ init_cjs_shims();
|
|
|
514455
514455
|
|
|
514456
514456
|
// ../../../vite-plugin-file-sync/dist/ai-service/index.js
|
|
514457
514457
|
init_cjs_shims();
|
|
514458
|
-
var import_ai17 = __toESM(require_dist9()
|
|
514458
|
+
var import_ai17 = __toESM(require_dist9());
|
|
514459
514459
|
import { createHash as createHash5, randomUUID as randomUUID4 } from "node:crypto";
|
|
514460
514460
|
import os6 from "node:os";
|
|
514461
514461
|
import path50 from "node:path";
|
|
@@ -518893,7 +518893,7 @@ init_cjs_shims();
|
|
|
518893
518893
|
init_cjs_shims();
|
|
518894
518894
|
|
|
518895
518895
|
// ../../../vite-plugin-file-sync/dist/ai-service/index.js
|
|
518896
|
-
var import_shared52 = __toESM(require_dist2()
|
|
518896
|
+
var import_shared52 = __toESM(require_dist2());
|
|
518897
518897
|
|
|
518898
518898
|
// ../../../vite-plugin-file-sync/dist/migration/translation-prompt.js
|
|
518899
518899
|
init_cjs_shims();
|
|
@@ -536121,7 +536121,7 @@ var MAX_ATTRIBUTE_LENGTH = 64e3;
|
|
|
536121
536121
|
var LLMObsSpanWriter = null;
|
|
536122
536122
|
async function loadLLMObsSpanWriter() {
|
|
536123
536123
|
if (!LLMObsSpanWriter) {
|
|
536124
|
-
const module = await import("./spans-
|
|
536124
|
+
const module = await import("./spans-GFS66UKZ.js");
|
|
536125
536125
|
LLMObsSpanWriter = module.default;
|
|
536126
536126
|
}
|
|
536127
536127
|
return LLMObsSpanWriter;
|
|
@@ -566103,20 +566103,26 @@ function formatIntegrationForPlanPrompt(integration) {
|
|
|
566103
566103
|
type: ${type}`;
|
|
566104
566104
|
}
|
|
566105
566105
|
var exitPlanModeToolFactory = createToolFactory("exitPlanMode", ({ clark, services }) => {
|
|
566106
|
+
const managedNativeDbEnabled = services.features.managedNativeDbEnabled === true;
|
|
566107
|
+
const baseInputSchema = external_exports.object({
|
|
566108
|
+
complexity: external_exports.enum(PlanComplexityLevels).describe("Your best estimate of the plan complexity"),
|
|
566109
|
+
title: external_exports.string().min(1, "Plan title is required").max(160, "Plan title must be 160 characters or fewer").describe("Title to display for the plan. Should be the name of the feature or fix, eg 'Executive orders dashboard', 'User login page', 'Fix data sync bug'"),
|
|
566110
|
+
integrationIds: external_exports.array(external_exports.string()).describe("List of integration IDs that may be referenced in the plan."),
|
|
566111
|
+
attachmentIds: external_exports.array(external_exports.number()).min(0).max(MAX_PLAN_ATTACHMENTS).describe(`List of up to ${MAX_PLAN_ATTACHMENTS} attachment IDs that are relevant to the plan. Call listAttachments first to see available attachments with their IDs, types, and labels.`),
|
|
566112
|
+
entityIds: external_exports.array(external_exports.string()).min(0).describe(`List of targeted entity IDs (components) from the user's selection that are relevant to implementing this plan. Include entities that the plan will modify or depend on.`)
|
|
566113
|
+
});
|
|
566114
|
+
const inputSchema2 = managedNativeDbEnabled ? baseInputSchema.extend({
|
|
566115
|
+
includesFreshDatabase: external_exports.boolean().optional().describe("Set to true only when the plan explicitly calls provisionDatabase to create a new dev database. Do not set it for plans that query, migrate, or modify an existing database.")
|
|
566116
|
+
}) : baseInputSchema;
|
|
566117
|
+
const description = buildExitPlanModeDescription(managedNativeDbEnabled);
|
|
566106
566118
|
return {
|
|
566107
|
-
description
|
|
566119
|
+
description,
|
|
566108
566120
|
category: ToolCategory.PLAN,
|
|
566109
566121
|
defaultPermission: PermissionLevel.ALLOW,
|
|
566110
566122
|
readOnly: true,
|
|
566111
|
-
inputSchema:
|
|
566112
|
-
|
|
566113
|
-
|
|
566114
|
-
integrationIds: external_exports.array(external_exports.string()).describe("List of integration IDs that may be referenced in the plan."),
|
|
566115
|
-
attachmentIds: external_exports.array(external_exports.number()).min(0).max(MAX_PLAN_ATTACHMENTS).describe(`List of up to ${MAX_PLAN_ATTACHMENTS} attachment IDs that are relevant to the plan. Call listAttachments first to see available attachments with their IDs, types, and labels.`),
|
|
566116
|
-
entityIds: external_exports.array(external_exports.string()).min(0).describe(`List of targeted entity IDs (components) from the user's selection that are relevant to implementing this plan. Include entities that the plan will modify or depend on.`),
|
|
566117
|
-
includesFreshDatabase: external_exports.boolean().optional().describe("Set to true only when the plan explicitly calls provisionDatabase to create a new dev database. Do not set it for plans that query, migrate, or modify an existing database.")
|
|
566118
|
-
}),
|
|
566119
|
-
execute: async ({ complexity, title, integrationIds, attachmentIds, entityIds, includesFreshDatabase }, { messages: messages3 }) => {
|
|
566123
|
+
inputSchema: inputSchema2,
|
|
566124
|
+
execute: async (input, { messages: messages3 }) => {
|
|
566125
|
+
const { complexity, title, integrationIds, attachmentIds, entityIds, includesFreshDatabase } = input;
|
|
566120
566126
|
const { chatSessionStore } = services;
|
|
566121
566127
|
const sendUserMessage = sendUserMessageChannel(clark, chatSessionStore);
|
|
566122
566128
|
const sendInteractiveMessage = sendInteractiveMessageChannel(clark, chatSessionStore);
|
|
@@ -566474,7 +566480,7 @@ Navigation & Behavior
|
|
|
566474
566480
|
- Match dashboard styling and layout
|
|
566475
566481
|
</plan>
|
|
566476
566482
|
`;
|
|
566477
|
-
var
|
|
566483
|
+
var EXIT_PLAN_MODE_DESCRIPTION_INTRO = `
|
|
566478
566484
|
Use this tool to delegate to a planning expert who will generate a plan and present it to the user.
|
|
566479
566485
|
This tool presents a plan with a "Build It" button that allows the user to switch to Build mode.
|
|
566480
566486
|
NEVER output a plan directly as text - ALWAYS use this tool to present plans properly.
|
|
@@ -566490,12 +566496,14 @@ ENTITIES:
|
|
|
566490
566496
|
- If there are focused_entities in the context (components selected by the user), extract the "id" field from each entity
|
|
566491
566497
|
- Pass these IDs to the entityIds parameter - they will be displayed in the plan and preserved for build mode
|
|
566492
566498
|
- Include the relevant focused entity IDs unless they are clearly irrelevant to the plan
|
|
566493
|
-
|
|
566499
|
+
`;
|
|
566500
|
+
var EXIT_PLAN_MODE_DATABASE_SECTION = `
|
|
566494
566501
|
DATABASE:
|
|
566495
566502
|
- Set includesFreshDatabase to true ONLY when the plan explicitly calls the provisionDatabase tool to create a new dev database
|
|
566496
566503
|
- Do NOT set includesFreshDatabase for plans that merely query, migrate, or modify an existing database
|
|
566497
566504
|
- This shows a "Fresh Database" indicator on the plan card so the user knows a new database will be created
|
|
566498
|
-
|
|
566505
|
+
`;
|
|
566506
|
+
var EXIT_PLAN_MODE_DESCRIPTION_OUTRO = `
|
|
566499
566507
|
Before presenting a plan:
|
|
566500
566508
|
- If the user's request is ambiguous or has multiple interpretations, use askMultiChoice to clarify
|
|
566501
566509
|
- If there are unknowns about requirements, preferences, or approach, use askMultiChoice first
|
|
@@ -566541,6 +566549,12 @@ After calling this tool, the user will either:
|
|
|
566541
566549
|
Remember: Always use this tool to present plans - never output plans directly as text.
|
|
566542
566550
|
IF THE TOOL CALL FAILS, DO NOT ATTEMPT TO GENERATE THE PLAN YOURSELF. Call the tool again.
|
|
566543
566551
|
`;
|
|
566552
|
+
function buildExitPlanModeDescription(managedNativeDbEnabled) {
|
|
566553
|
+
if (managedNativeDbEnabled) {
|
|
566554
|
+
return EXIT_PLAN_MODE_DESCRIPTION_INTRO + EXIT_PLAN_MODE_DATABASE_SECTION + EXIT_PLAN_MODE_DESCRIPTION_OUTRO;
|
|
566555
|
+
}
|
|
566556
|
+
return EXIT_PLAN_MODE_DESCRIPTION_INTRO + EXIT_PLAN_MODE_DESCRIPTION_OUTRO;
|
|
566557
|
+
}
|
|
566544
566558
|
|
|
566545
566559
|
// ../../../vite-plugin-file-sync/dist/ai-service/agent/tools2/tools/ask-multi-choice.js
|
|
566546
566560
|
init_cjs_shims();
|
|
@@ -613463,8 +613477,8 @@ var ChatSessionStore = (() => {
|
|
|
613463
613477
|
// ../../../vite-plugin-file-sync/dist/ai-service/context-download.js
|
|
613464
613478
|
init_cjs_shims();
|
|
613465
613479
|
var import_util18 = __toESM(require_dist3());
|
|
613466
|
-
import { mkdir as
|
|
613467
|
-
import * as
|
|
613480
|
+
import { mkdir as mkdir13, rm as rm11, writeFile as writeFile11 } from "node:fs/promises";
|
|
613481
|
+
import * as path44 from "node:path";
|
|
613468
613482
|
|
|
613469
613483
|
// ../../../vite-plugin-file-sync/dist/ai-service/context-archive-paths.js
|
|
613470
613484
|
init_cjs_shims();
|
|
@@ -613493,10 +613507,151 @@ function safeJoinUnderRoot(root3, ...segments) {
|
|
|
613493
613507
|
return target;
|
|
613494
613508
|
}
|
|
613495
613509
|
|
|
613496
|
-
// ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/storage/
|
|
613510
|
+
// ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/storage/jsonl-event-store.js
|
|
613497
613511
|
init_cjs_shims();
|
|
613498
|
-
import { readFile as readFile11,
|
|
613512
|
+
import { readFile as readFile11, appendFile, mkdir as mkdir11, rm as rm9 } from "node:fs/promises";
|
|
613499
613513
|
import * as path42 from "node:path";
|
|
613514
|
+
var logger3 = getPrefixedLogger("[jsonl-event-store]");
|
|
613515
|
+
var JsonlEventStore = class _JsonlEventStore {
|
|
613516
|
+
rootDir;
|
|
613517
|
+
static SUPERBLOCKS_SYSTEM_DIR = ".superblocks";
|
|
613518
|
+
static EVENTS_SUBDIR = "events";
|
|
613519
|
+
constructor(rootDir) {
|
|
613520
|
+
this.rootDir = rootDir;
|
|
613521
|
+
}
|
|
613522
|
+
/**
|
|
613523
|
+
* Append a single event to the log for the given context.
|
|
613524
|
+
*
|
|
613525
|
+
* Creates parent directories if they do not exist. Each call
|
|
613526
|
+
* writes exactly one JSON line terminated by `\n`.
|
|
613527
|
+
*/
|
|
613528
|
+
async appendEvent(id2, event) {
|
|
613529
|
+
const filePath = this.getFilePath(id2);
|
|
613530
|
+
await mkdir11(path42.dirname(filePath), { recursive: true });
|
|
613531
|
+
await appendFile(filePath, JSON.stringify(event) + "\n");
|
|
613532
|
+
}
|
|
613533
|
+
/**
|
|
613534
|
+
* Check whether any events exist for the given context.
|
|
613535
|
+
*/
|
|
613536
|
+
async hasEvents(id2) {
|
|
613537
|
+
try {
|
|
613538
|
+
const content18 = await readFile11(this.getFilePath(id2), "utf-8");
|
|
613539
|
+
return content18.trimEnd().length > 0;
|
|
613540
|
+
} catch (err) {
|
|
613541
|
+
if (err.code === "ENOENT") {
|
|
613542
|
+
return false;
|
|
613543
|
+
}
|
|
613544
|
+
throw err;
|
|
613545
|
+
}
|
|
613546
|
+
}
|
|
613547
|
+
/**
|
|
613548
|
+
* Remove the event log for a single context. Missing files are
|
|
613549
|
+
* treated as success so callers can use this as a fire-and-forget
|
|
613550
|
+
* cleanup step.
|
|
613551
|
+
*/
|
|
613552
|
+
async deleteEvents(id2) {
|
|
613553
|
+
await rm9(this.getFilePath(id2), { force: true });
|
|
613554
|
+
}
|
|
613555
|
+
/**
|
|
613556
|
+
* Remove the entire `.superblocks/events/` tree under `rootDir`.
|
|
613557
|
+
*
|
|
613558
|
+
* Used by clear-all flows so a subsequent `getOrCreateContext` does
|
|
613559
|
+
* not silently restore a "deleted" conversation from disk.
|
|
613560
|
+
*/
|
|
613561
|
+
async deleteAllEvents() {
|
|
613562
|
+
await rm9(this.getEventsRoot(), { recursive: true, force: true });
|
|
613563
|
+
}
|
|
613564
|
+
/**
|
|
613565
|
+
* Load conversation messages by scanning backward for the last
|
|
613566
|
+
* compaction anchor, then reading forward from that point.
|
|
613567
|
+
*
|
|
613568
|
+
* A compaction anchor is either:
|
|
613569
|
+
* - An event with `type === "compaction_received"`
|
|
613570
|
+
* - An event with `_superblocks.isSummary === true` (migration seed)
|
|
613571
|
+
*
|
|
613572
|
+
* Each `EventLogEntry` is mapped to a `StoredMessage` so that
|
|
613573
|
+
* consumers receive the AI SDK `ModelMessage` shape.
|
|
613574
|
+
*/
|
|
613575
|
+
async loadMessages(id2) {
|
|
613576
|
+
const filePath = this.getFilePath(id2);
|
|
613577
|
+
let raw;
|
|
613578
|
+
try {
|
|
613579
|
+
raw = await readFile11(filePath, "utf-8");
|
|
613580
|
+
} catch (err) {
|
|
613581
|
+
if (err.code === "ENOENT") {
|
|
613582
|
+
return [];
|
|
613583
|
+
}
|
|
613584
|
+
throw err;
|
|
613585
|
+
}
|
|
613586
|
+
const lines = raw.split("\n").filter((line3) => line3.length > 0);
|
|
613587
|
+
if (lines.length === 0) {
|
|
613588
|
+
return [];
|
|
613589
|
+
}
|
|
613590
|
+
const contextLabel = `${id2.appId}/${id2.userId}/${id2.name}`;
|
|
613591
|
+
const events = [];
|
|
613592
|
+
let corruptedCount = 0;
|
|
613593
|
+
for (let i2 = 0; i2 < lines.length; i2++) {
|
|
613594
|
+
const line3 = lines[i2];
|
|
613595
|
+
try {
|
|
613596
|
+
events.push(JSON.parse(line3));
|
|
613597
|
+
} catch {
|
|
613598
|
+
corruptedCount++;
|
|
613599
|
+
logger3.warn(`Skipping corrupted JSONL line ${i2} for context '${contextLabel}' (length=${line3.length})`);
|
|
613600
|
+
}
|
|
613601
|
+
}
|
|
613602
|
+
if (corruptedCount > 0) {
|
|
613603
|
+
logger3.warn(`Encountered ${corruptedCount} corrupted line(s) in event log for context '${contextLabel}'; if any held a compaction anchor the loaded window may extend further back than expected.`);
|
|
613604
|
+
}
|
|
613605
|
+
let anchorIndex = -1;
|
|
613606
|
+
for (let i2 = events.length - 1; i2 >= 0; i2--) {
|
|
613607
|
+
const event = events[i2];
|
|
613608
|
+
if (event.type === "compaction_received" || event._superblocks?.isSummary === true) {
|
|
613609
|
+
anchorIndex = i2;
|
|
613610
|
+
break;
|
|
613611
|
+
}
|
|
613612
|
+
}
|
|
613613
|
+
if (anchorIndex < 0 && corruptedCount > 0) {
|
|
613614
|
+
logger3.error(`No compaction anchor found for context '${contextLabel}' but ${corruptedCount} corrupted line(s) were skipped; the loaded conversation window may be unbounded.`);
|
|
613615
|
+
}
|
|
613616
|
+
const window2 = anchorIndex >= 0 ? events.slice(anchorIndex) : events;
|
|
613617
|
+
return window2.map((event) => this.toStoredMessage(event));
|
|
613618
|
+
}
|
|
613619
|
+
/**
|
|
613620
|
+
* Map an EventLogEntry to a StoredMessage (AI SDK ModelMessage shape).
|
|
613621
|
+
*
|
|
613622
|
+
* The cast is required at this JSON deserialization boundary: `content`
|
|
613623
|
+
* is stored as `unknown` because AI SDK content shapes are polymorphic
|
|
613624
|
+
* (string, content part arrays, tool results). The role is type-safe
|
|
613625
|
+
* via `MessageRole`, but TypeScript cannot narrow the discriminated
|
|
613626
|
+
* union without runtime content validation — which would be fragile
|
|
613627
|
+
* against SDK version changes.
|
|
613628
|
+
*/
|
|
613629
|
+
toStoredMessage(event) {
|
|
613630
|
+
return {
|
|
613631
|
+
role: event.role,
|
|
613632
|
+
content: event.content,
|
|
613633
|
+
...event.providerMetadata && {
|
|
613634
|
+
providerMetadata: event.providerMetadata
|
|
613635
|
+
},
|
|
613636
|
+
_superblocks: {
|
|
613637
|
+
timestamp: event.timestamp,
|
|
613638
|
+
...event._superblocks
|
|
613639
|
+
}
|
|
613640
|
+
};
|
|
613641
|
+
}
|
|
613642
|
+
getEventsRoot() {
|
|
613643
|
+
return path42.join(this.rootDir, _JsonlEventStore.SUPERBLOCKS_SYSTEM_DIR, _JsonlEventStore.EVENTS_SUBDIR);
|
|
613644
|
+
}
|
|
613645
|
+
getFilePath(id2) {
|
|
613646
|
+
const root3 = this.getEventsRoot();
|
|
613647
|
+
return safeJoinUnderRoot(root3, encodeContextPathSegment(id2.userId, "userId"), `${encodeContextPathSegment(id2.name, "name")}.jsonl`);
|
|
613648
|
+
}
|
|
613649
|
+
};
|
|
613650
|
+
|
|
613651
|
+
// ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/storage/local.js
|
|
613652
|
+
init_cjs_shims();
|
|
613653
|
+
import { readFile as readFile12, writeFile as writeFile10, mkdir as mkdir12, unlink as unlink2, rm as rm10 } from "node:fs/promises";
|
|
613654
|
+
import * as path43 from "node:path";
|
|
613500
613655
|
|
|
613501
613656
|
// ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/context-metrics.js
|
|
613502
613657
|
init_cjs_shims();
|
|
@@ -613582,7 +613737,7 @@ function recordContextFileBytes(input) {
|
|
|
613582
613737
|
}
|
|
613583
613738
|
|
|
613584
613739
|
// ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/storage/local.js
|
|
613585
|
-
var
|
|
613740
|
+
var logger4 = getPrefixedLogger("[context-storage]");
|
|
613586
613741
|
var LARGE_CONTEXT_BYTES = 5 * 1024 * 1024;
|
|
613587
613742
|
var LARGE_CONTEXT_MESSAGES = 1e3;
|
|
613588
613743
|
var toMb = (bytes) => (bytes / 1024 / 1024).toFixed(1);
|
|
@@ -613595,11 +613750,11 @@ var LocalContextStorageV2 = class {
|
|
|
613595
613750
|
async loadContext(id2) {
|
|
613596
613751
|
const filePath = this.getFilePath(id2);
|
|
613597
613752
|
try {
|
|
613598
|
-
const content18 = await
|
|
613753
|
+
const content18 = await readFile12(filePath, "utf-8");
|
|
613599
613754
|
const contentBytes = Buffer.byteLength(content18);
|
|
613600
613755
|
recordContextFileBytes({ operation: "load", bytes: contentBytes });
|
|
613601
613756
|
if (contentBytes > LARGE_CONTEXT_BYTES) {
|
|
613602
|
-
|
|
613757
|
+
logger4.info(`Parsing large context file '${id2.name}' (${toMb(contentBytes)}MB)...`);
|
|
613603
613758
|
}
|
|
613604
613759
|
return JSON.parse(content18);
|
|
613605
613760
|
} catch (err) {
|
|
@@ -613613,13 +613768,13 @@ var LocalContextStorageV2 = class {
|
|
|
613613
613768
|
const filePath = this.getFilePath(id2);
|
|
613614
613769
|
await this.ensureBaseDirExists(filePath);
|
|
613615
613770
|
if (record2.messages.length >= LARGE_CONTEXT_MESSAGES) {
|
|
613616
|
-
|
|
613771
|
+
logger4.info(`Serializing large context '${id2.name}' (${record2.messages.length} messages)...`);
|
|
613617
613772
|
}
|
|
613618
613773
|
const serialized = JSON.stringify(record2);
|
|
613619
613774
|
const serializedBytes = Buffer.byteLength(serialized);
|
|
613620
613775
|
recordContextFileBytes({ operation: "persist", bytes: serializedBytes });
|
|
613621
613776
|
if (serializedBytes > LARGE_CONTEXT_BYTES) {
|
|
613622
|
-
|
|
613777
|
+
logger4.warn(`Context file '${id2.name}' is ${toMb(serializedBytes)}MB (${record2.messages.length} messages); save and reload costs scale with this size`);
|
|
613623
613778
|
}
|
|
613624
613779
|
await writeFile10(filePath, serialized);
|
|
613625
613780
|
}
|
|
@@ -613637,7 +613792,7 @@ var LocalContextStorageV2 = class {
|
|
|
613637
613792
|
async deleteAllContexts() {
|
|
613638
613793
|
const contextDir = this.getContextDir();
|
|
613639
613794
|
try {
|
|
613640
|
-
await
|
|
613795
|
+
await rm10(contextDir, { recursive: true, force: true });
|
|
613641
613796
|
} catch (err) {
|
|
613642
613797
|
if (err.code === "ENOENT") {
|
|
613643
613798
|
return;
|
|
@@ -613646,20 +613801,21 @@ var LocalContextStorageV2 = class {
|
|
|
613646
613801
|
}
|
|
613647
613802
|
}
|
|
613648
613803
|
getContextDir() {
|
|
613649
|
-
return
|
|
613804
|
+
return path43.join(this.rootDir, this.SUPERBLOCKS_SYSTEM_DIR, "context");
|
|
613650
613805
|
}
|
|
613651
613806
|
async ensureBaseDirExists(filePath) {
|
|
613652
|
-
await
|
|
613807
|
+
await mkdir12(path43.dirname(filePath), { recursive: true });
|
|
613653
613808
|
}
|
|
613654
613809
|
getFilePath(id2) {
|
|
613655
|
-
return
|
|
613810
|
+
return path43.join(this.rootDir, this.SUPERBLOCKS_SYSTEM_DIR, "context", id2.userId, `${id2.name}.json`);
|
|
613656
613811
|
}
|
|
613657
613812
|
};
|
|
613658
613813
|
|
|
613659
613814
|
// ../../../vite-plugin-file-sync/dist/ai-service/context-download.js
|
|
613660
613815
|
var EVENT_LOG_ARCHIVE_PREFIX = "events__";
|
|
613816
|
+
var CONTEXT_RECORD_VERSION = 2;
|
|
613661
613817
|
function isContextRecordV2(record2) {
|
|
613662
|
-
return typeof record2 === "object" && record2 !== null && "version" in record2 && record2.version ===
|
|
613818
|
+
return typeof record2 === "object" && record2 !== null && "version" in record2 && record2.version === CONTEXT_RECORD_VERSION;
|
|
613663
613819
|
}
|
|
613664
613820
|
async function downloadContextFromBucketeer({ applicationId, commitId, branchName, superblocksBaseUrl, logger: logger22, jwt: jwt2, contextId, appRootDirPath }) {
|
|
613665
613821
|
const bucketeerUrl = (0, import_util18.getBucketeerUrlFromSuperblocksUrl)(superblocksBaseUrl);
|
|
@@ -613742,10 +613898,13 @@ async function downloadAndParseContext({ url: url4, applicationId, superblocksBa
|
|
|
613742
613898
|
const formData = await response.formData();
|
|
613743
613899
|
const contextFiles = formData.getAll("context");
|
|
613744
613900
|
let contextRecord = null;
|
|
613901
|
+
const restoredEventLogFiles = [];
|
|
613902
|
+
const allFileNames = [];
|
|
613745
613903
|
for (const file2 of contextFiles) {
|
|
613746
613904
|
if (!(file2 instanceof File)) {
|
|
613747
613905
|
continue;
|
|
613748
613906
|
}
|
|
613907
|
+
allFileNames.push(file2.name);
|
|
613749
613908
|
const eventLogFileName = file2.name.startsWith(EVENT_LOG_ARCHIVE_PREFIX) ? safeArchiveFileName(file2.name.slice(EVENT_LOG_ARCHIVE_PREFIX.length)) : void 0;
|
|
613750
613909
|
if (file2.name === "main.json") {
|
|
613751
613910
|
const fileContent = await file2.text();
|
|
@@ -613762,6 +613921,25 @@ async function downloadAndParseContext({ url: url4, applicationId, superblocksBa
|
|
|
613762
613921
|
contextId,
|
|
613763
613922
|
appRootDirPath
|
|
613764
613923
|
});
|
|
613924
|
+
restoredEventLogFiles.push(eventLogFileName);
|
|
613925
|
+
}
|
|
613926
|
+
}
|
|
613927
|
+
if (!contextRecord && allFileNames.length > 0) {
|
|
613928
|
+
logger22.warn(`[${logLabel}] 200 multipart response contained no main.json (applicationId=${applicationId}, contextId=${contextId?.name ?? "unknown"}, files=${allFileNames.join(", ")}). The archive may have been flushed mid-generation before the context record was persisted.`);
|
|
613929
|
+
}
|
|
613930
|
+
if (!contextRecord && restoredEventLogFiles.length > 0 && contextId && appRootDirPath) {
|
|
613931
|
+
try {
|
|
613932
|
+
const eventStore = new JsonlEventStore(appRootDirPath);
|
|
613933
|
+
const messages3 = await eventStore.loadMessages(contextId);
|
|
613934
|
+
if (messages3.length > 0) {
|
|
613935
|
+
await eventStore.deleteEvents(contextId);
|
|
613936
|
+
contextRecord = { version: CONTEXT_RECORD_VERSION, messages: messages3 };
|
|
613937
|
+
logger22.info(`[${logLabel}] Rebuilt context record from event log (applicationId=${applicationId}, contextId=${contextId.name}, ${messages3.length} messages, files=${restoredEventLogFiles.join(", ")})`);
|
|
613938
|
+
} else {
|
|
613939
|
+
logger22.warn(`[${logLabel}] Event log restored but contained no loadable messages`);
|
|
613940
|
+
}
|
|
613941
|
+
} catch (err) {
|
|
613942
|
+
logger22.error(`[${logLabel}] Failed to rebuild context from event log`, getErrorMeta2(err));
|
|
613765
613943
|
}
|
|
613766
613944
|
}
|
|
613767
613945
|
return contextRecord;
|
|
@@ -613771,17 +613949,17 @@ async function downloadAndParseContext({ url: url4, applicationId, superblocksBa
|
|
|
613771
613949
|
return null;
|
|
613772
613950
|
}
|
|
613773
613951
|
async function restoreEventLogFile({ file: file2, fileName, contextId, appRootDirPath }) {
|
|
613774
|
-
const eventRoot =
|
|
613952
|
+
const eventRoot = path44.join(appRootDirPath, ".superblocks", "events");
|
|
613775
613953
|
const eventDir = safeJoinUnderRoot(eventRoot, encodeContextPathSegment(contextId.userId, "userId"));
|
|
613776
|
-
await
|
|
613954
|
+
await mkdir13(eventDir, { recursive: true });
|
|
613777
613955
|
const filePath = safeJoinUnderRoot(eventDir, fileName);
|
|
613778
613956
|
const fileContent = await file2.arrayBuffer();
|
|
613779
613957
|
await writeFile11(filePath, Buffer.from(fileContent));
|
|
613780
613958
|
}
|
|
613781
613959
|
async function clearLocalEventLog({ contextId, appRootDirPath }) {
|
|
613782
|
-
const eventRoot =
|
|
613960
|
+
const eventRoot = path44.join(appRootDirPath, ".superblocks", "events");
|
|
613783
613961
|
const eventDir = safeJoinUnderRoot(eventRoot, encodeContextPathSegment(contextId.userId, "userId"));
|
|
613784
|
-
await
|
|
613962
|
+
await rm11(eventDir, { recursive: true, force: true });
|
|
613785
613963
|
}
|
|
613786
613964
|
async function restoreContextFromCheckpoint({ applicationId, commitId, branchName, contextId, appRootDirPath, superblocksBaseUrl, logger: logger22, jwt: jwt2, contextManagerV2 }) {
|
|
613787
613965
|
const contextStorageV2 = new LocalContextStorageV2(appRootDirPath);
|
|
@@ -613877,9 +614055,9 @@ async function restoreContextFromCheckpoint({ applicationId, commitId, branchNam
|
|
|
613877
614055
|
});
|
|
613878
614056
|
savedFiles.push(fileName);
|
|
613879
614057
|
} else {
|
|
613880
|
-
const contextRoot =
|
|
614058
|
+
const contextRoot = path44.join(appRootDirPath, ".superblocks", "context");
|
|
613881
614059
|
const contextDir = safeJoinUnderRoot(contextRoot, contextId.userId);
|
|
613882
|
-
await
|
|
614060
|
+
await mkdir13(contextDir, { recursive: true });
|
|
613883
614061
|
const filePath = safeJoinUnderRoot(contextDir, safeArchiveFileName(fileName));
|
|
613884
614062
|
const fileContent = await file2.arrayBuffer();
|
|
613885
614063
|
await writeFile11(filePath, Buffer.from(fileContent));
|
|
@@ -613914,15 +614092,15 @@ async function restoreContextFromCheckpoint({ applicationId, commitId, branchNam
|
|
|
613914
614092
|
// ../../../vite-plugin-file-sync/dist/ai-service/context-upload.js
|
|
613915
614093
|
init_cjs_shims();
|
|
613916
614094
|
var import_util19 = __toESM(require_dist3());
|
|
613917
|
-
import { readdir as readdir9, readFile as
|
|
613918
|
-
import * as
|
|
614095
|
+
import { readdir as readdir9, readFile as readFile13 } from "node:fs/promises";
|
|
614096
|
+
import * as path45 from "node:path";
|
|
613919
614097
|
var EVENT_LOG_ARCHIVE_PREFIX2 = "events__";
|
|
613920
614098
|
async function readDirectoryFiles({ dir, archiveName, onMissing }) {
|
|
613921
614099
|
try {
|
|
613922
614100
|
const entries = await readdir9(dir, { withFileTypes: true });
|
|
613923
614101
|
return entries.filter((entry) => entry.isFile()).map((entry) => ({
|
|
613924
614102
|
archiveName: archiveName(entry.name),
|
|
613925
|
-
filePath:
|
|
614103
|
+
filePath: path45.join(dir, entry.name)
|
|
613926
614104
|
}));
|
|
613927
614105
|
} catch (err) {
|
|
613928
614106
|
if (err.code === "ENOENT") {
|
|
@@ -613933,8 +614111,8 @@ async function readDirectoryFiles({ dir, archiveName, onMissing }) {
|
|
|
613933
614111
|
}
|
|
613934
614112
|
}
|
|
613935
614113
|
async function uploadContextToBucketeer({ applicationId, commitId, branchName, appRootDirPath, userId, useServerUpload = false, superblocksBaseUrl, logger: logger22, jwt: jwt2 }) {
|
|
613936
|
-
const contextRoot =
|
|
613937
|
-
const eventsRoot =
|
|
614114
|
+
const contextRoot = path45.join(appRootDirPath, ".superblocks", "context");
|
|
614115
|
+
const eventsRoot = path45.join(appRootDirPath, ".superblocks", "events");
|
|
613938
614116
|
const contextDir = safeJoinUnderRoot(contextRoot, userId);
|
|
613939
614117
|
const eventDir = safeJoinUnderRoot(eventsRoot, encodeContextPathSegment(userId, "userId"));
|
|
613940
614118
|
const filesToUpload = [
|
|
@@ -613957,7 +614135,7 @@ async function uploadContextToBucketeer({ applicationId, commitId, branchName, a
|
|
|
613957
614135
|
const uploadedFiles = [];
|
|
613958
614136
|
for (const file2 of filesToUpload) {
|
|
613959
614137
|
try {
|
|
613960
|
-
const fileBuffer = await
|
|
614138
|
+
const fileBuffer = await readFile13(file2.filePath);
|
|
613961
614139
|
contextFileData.push({ data: fileBuffer, archiveName: file2.archiveName });
|
|
613962
614140
|
uploadedFiles.push(file2.archiveName);
|
|
613963
614141
|
} catch (err) {
|
|
@@ -613968,6 +614146,10 @@ async function uploadContextToBucketeer({ applicationId, commitId, branchName, a
|
|
|
613968
614146
|
logger22.warn(`[uploadContextToBucketeer] No files were successfully read for upload`);
|
|
613969
614147
|
return { rawContextBytes: 0, fileCount: 0 };
|
|
613970
614148
|
}
|
|
614149
|
+
if (!uploadedFiles.includes("main.json")) {
|
|
614150
|
+
logger22.warn(`[uploadContextToBucketeer] Skipping upload: archive has no main.json (applicationId=${applicationId}, userId=${userId}, files=${uploadedFiles.join(", ")}). This flush was likely triggered mid-generation before the context record was persisted.`);
|
|
614151
|
+
return { rawContextBytes: 0, fileCount: 0 };
|
|
614152
|
+
}
|
|
613971
614153
|
const rawContextBytes = contextFileData.reduce((total, file2) => total + file2.data.length, 0);
|
|
613972
614154
|
const buildFormData = () => {
|
|
613973
614155
|
const formData = new FormData();
|
|
@@ -615517,7 +615699,7 @@ var JudgeService = class {
|
|
|
615517
615699
|
// ../../../vite-plugin-file-sync/dist/ai-service/judge/storage/csv-storage.js
|
|
615518
615700
|
init_cjs_shims();
|
|
615519
615701
|
import { promises as fs19 } from "fs";
|
|
615520
|
-
import
|
|
615702
|
+
import path46 from "path";
|
|
615521
615703
|
var DEFAULT_STORAGE_DIR = ".superblocks/judge-evaluations";
|
|
615522
615704
|
var CSV_HEADER = "timestamp,promptId,branchName,commitSha,appId,prompt,passed,score,feedback\n";
|
|
615523
615705
|
var CsvJudgeStorage = class {
|
|
@@ -615529,7 +615711,7 @@ var CsvJudgeStorage = class {
|
|
|
615529
615711
|
* @param filename - CSV filename (default: evaluations.csv)
|
|
615530
615712
|
*/
|
|
615531
615713
|
constructor(storageDir = DEFAULT_STORAGE_DIR, filename = "evaluations.csv") {
|
|
615532
|
-
this.filePath =
|
|
615714
|
+
this.filePath = path46.join(storageDir, filename);
|
|
615533
615715
|
}
|
|
615534
615716
|
/**
|
|
615535
615717
|
* Ensures the storage directory and file exist.
|
|
@@ -615537,7 +615719,7 @@ var CsvJudgeStorage = class {
|
|
|
615537
615719
|
* Creates directory if needed and initializes CSV with header row.
|
|
615538
615720
|
*/
|
|
615539
615721
|
async ensureStorageExists() {
|
|
615540
|
-
const dir =
|
|
615722
|
+
const dir = path46.dirname(this.filePath);
|
|
615541
615723
|
await fs19.mkdir(dir, { recursive: true });
|
|
615542
615724
|
try {
|
|
615543
615725
|
await fs19.access(this.filePath);
|
|
@@ -616355,7 +616537,7 @@ init_cjs_shims();
|
|
|
616355
616537
|
|
|
616356
616538
|
// ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/compaction/server-side.js
|
|
616357
616539
|
init_cjs_shims();
|
|
616358
|
-
var
|
|
616540
|
+
var logger5 = getPrefixedLogger("[compaction:server-side]");
|
|
616359
616541
|
var SERVER_COMPACTION_SUMMARY = "Server-side compaction applied";
|
|
616360
616542
|
var SERVER_COMPACTION_INTERRUPTED_SUMMARY = "Server-side compaction interrupted before completion";
|
|
616361
616543
|
var ServerSideCompactionStrategy = class {
|
|
@@ -616398,7 +616580,7 @@ var ServerSideCompactionStrategy = class {
|
|
|
616398
616580
|
}
|
|
616399
616581
|
}
|
|
616400
616582
|
if (lastUserIndex < 0) {
|
|
616401
|
-
|
|
616583
|
+
logger5.warn("Server-side compaction detected but no user message present; skipping in-memory trim");
|
|
616402
616584
|
return { skillsNeedReload: true };
|
|
616403
616585
|
}
|
|
616404
616586
|
let lastSummaryIndex = -1;
|
|
@@ -616419,7 +616601,7 @@ var ServerSideCompactionStrategy = class {
|
|
|
616419
616601
|
...retainedPrefix,
|
|
616420
616602
|
...messages3.slice(lastUserIndex)
|
|
616421
616603
|
];
|
|
616422
|
-
|
|
616604
|
+
logger5.info(`Server-side compaction detected; trimmed in-memory history ${messages3.length} \u2192 ${trimmed2.length} messages`);
|
|
616423
616605
|
return { messages: trimmed2, skillsNeedReload: true };
|
|
616424
616606
|
}
|
|
616425
616607
|
getProtectedToolNames(messages3) {
|
|
@@ -616477,7 +616659,7 @@ var CACHE_BREAKPOINT_PROVIDER_OPTIONS = {
|
|
|
616477
616659
|
bedrock: { cachePoint: { type: "default" } },
|
|
616478
616660
|
anthropic: { cacheControl: { type: "ephemeral" } }
|
|
616479
616661
|
};
|
|
616480
|
-
var
|
|
616662
|
+
var logger6 = getPrefixedLogger("[context-v2:types]");
|
|
616481
616663
|
function toJsonValue2(value2) {
|
|
616482
616664
|
if (value2 === void 0) {
|
|
616483
616665
|
return null;
|
|
@@ -616535,7 +616717,7 @@ function normalizeToolResultOutput(output) {
|
|
|
616535
616717
|
];
|
|
616536
616718
|
const type = outputObj.type;
|
|
616537
616719
|
if (!validTypes.includes(type)) {
|
|
616538
|
-
|
|
616720
|
+
logger6.warn(`Invalid tool result output type: ${type}. Normalizing to json type.`);
|
|
616539
616721
|
return toJsonOutput(output);
|
|
616540
616722
|
}
|
|
616541
616723
|
const valueRequiredTypes = /* @__PURE__ */ new Set([
|
|
@@ -616546,7 +616728,7 @@ function normalizeToolResultOutput(output) {
|
|
|
616546
616728
|
"content"
|
|
616547
616729
|
]);
|
|
616548
616730
|
if (valueRequiredTypes.has(type) && !("value" in outputObj)) {
|
|
616549
|
-
|
|
616731
|
+
logger6.warn(`Tool result output missing required value for type=${outputObj.type}. Normalizing to json type.`);
|
|
616550
616732
|
return toJsonOutput(output);
|
|
616551
616733
|
}
|
|
616552
616734
|
return toJsonOutput(output);
|
|
@@ -616560,7 +616742,7 @@ function normalizeToolMessage(msg) {
|
|
|
616560
616742
|
const toolResult = part;
|
|
616561
616743
|
const normalizedOutput = normalizeToolResultOutput(toolResult.output);
|
|
616562
616744
|
if (normalizedOutput !== toolResult.output) {
|
|
616563
|
-
|
|
616745
|
+
logger6.debug(`Normalized tool result output for ${toolResult.toolName} (callId: ${toolResult.toolCallId})`);
|
|
616564
616746
|
}
|
|
616565
616747
|
return { ...toolResult, output: normalizedOutput };
|
|
616566
616748
|
}
|
|
@@ -616659,7 +616841,7 @@ function repairBrokenToolCalls(msg, index2, messages3) {
|
|
|
616659
616841
|
return part;
|
|
616660
616842
|
});
|
|
616661
616843
|
if (inputsFixed > 0) {
|
|
616662
|
-
|
|
616844
|
+
logger6.debug(`Fixed ${inputsFixed} tool call(s) with non-object input at index ${index2}`);
|
|
616663
616845
|
}
|
|
616664
616846
|
const toolResultIds = collectToolResultIds(messages3[index2 + 1]);
|
|
616665
616847
|
const hasToolCalls = content18.some((part) => typeof part === "object" && part !== null && "type" in part && part.type === "tool-call");
|
|
@@ -616678,7 +616860,7 @@ function repairBrokenToolCalls(msg, index2, messages3) {
|
|
|
616678
616860
|
});
|
|
616679
616861
|
const removed = before2 - content18.length;
|
|
616680
616862
|
if (removed > 0) {
|
|
616681
|
-
|
|
616863
|
+
logger6.debug(`Removed ${removed} orphaned tool call(s) from assistant message at index ${index2}`);
|
|
616682
616864
|
}
|
|
616683
616865
|
return { ...msg, content: content18 };
|
|
616684
616866
|
}
|
|
@@ -616704,7 +616886,7 @@ function repairOrphanedToolResults(msg, index2, messages3) {
|
|
|
616704
616886
|
});
|
|
616705
616887
|
const removed = before2 - content18.length;
|
|
616706
616888
|
if (removed > 0) {
|
|
616707
|
-
|
|
616889
|
+
logger6.debug(`Removed ${removed} orphaned tool result(s) from tool message at index ${index2}`);
|
|
616708
616890
|
}
|
|
616709
616891
|
return { ...msg, content: content18 };
|
|
616710
616892
|
}
|
|
@@ -616730,7 +616912,7 @@ function enforceToolUsePairing(messages3) {
|
|
|
616730
616912
|
});
|
|
616731
616913
|
if (strippedToolUses.length === 0)
|
|
616732
616914
|
return msg;
|
|
616733
|
-
|
|
616915
|
+
logger6.warn(`enforceToolUsePairing: stripped ${strippedToolUses.length} orphan tool_use part(s) [${strippedToolUses.join(", ")}] from assistant message at input index ${i2}`);
|
|
616734
616916
|
return { ...msg, content: content18 };
|
|
616735
616917
|
});
|
|
616736
616918
|
return stripped.filter((msg) => {
|
|
@@ -616740,7 +616922,7 @@ function enforceToolUsePairing(messages3) {
|
|
|
616740
616922
|
return true;
|
|
616741
616923
|
if (Array.isArray(msg.content) && msg.content.length > 0)
|
|
616742
616924
|
return true;
|
|
616743
|
-
|
|
616925
|
+
logger6.debug(`enforceToolUsePairing: dropped empty ${msg.role} message after stripping`);
|
|
616744
616926
|
return false;
|
|
616745
616927
|
});
|
|
616746
616928
|
}
|
|
@@ -616935,7 +617117,7 @@ function uniquifyFilePartFilenames(messages3) {
|
|
|
616935
617117
|
}
|
|
616936
617118
|
|
|
616937
617119
|
// ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/context.js
|
|
616938
|
-
var
|
|
617120
|
+
var logger7 = getPrefixedLogger("[context-v2]");
|
|
616939
617121
|
var SLOW_PERSIST_WARN_MS = 500;
|
|
616940
617122
|
var REPLAY_YIELD_INTERVAL = 100;
|
|
616941
617123
|
var ZERO_USAGE = {
|
|
@@ -616988,7 +617170,7 @@ function stripScreenshotMediaFromToolMessage(msg) {
|
|
|
616988
617170
|
if (!modified) {
|
|
616989
617171
|
return msg;
|
|
616990
617172
|
}
|
|
616991
|
-
|
|
617173
|
+
logger7.info("Stripped screenshot media from tool message before storage");
|
|
616992
617174
|
return { ...msg, content: strippedContent };
|
|
616993
617175
|
}
|
|
616994
617176
|
var ContextV2 = class _ContextV2 {
|
|
@@ -617031,6 +617213,27 @@ var ContextV2 = class _ContextV2 {
|
|
|
617031
617213
|
this.contextId = options8.contextId;
|
|
617032
617214
|
this.compaction = options8.compaction ?? new ServerSideCompactionStrategy();
|
|
617033
617215
|
}
|
|
617216
|
+
// Cached result of getMessages() normalization. Avoids recomputing
|
|
617217
|
+
// 10+ repair/normalization passes when messages haven't changed.
|
|
617218
|
+
// Invalidated by any operation that modifies this.messages or systemPrompt.
|
|
617219
|
+
// NOTE: Returns a shallow copy of the cached array. Element references are
|
|
617220
|
+
// shared — callers must treat returned message objects as read-only.
|
|
617221
|
+
_cachedMessages = null;
|
|
617222
|
+
/**
|
|
617223
|
+
* Call this before AND after every operation that modifies `this.messages`
|
|
617224
|
+
* or `this.systemPrompt`. Pre-enqueue call prevents fast-path cache hits
|
|
617225
|
+
* while the mutation is queued; post-mutation call handles the scenario where
|
|
617226
|
+
* a `getMessages()` queue op ran and cached a result between enqueue and
|
|
617227
|
+
* execution.
|
|
617228
|
+
*
|
|
617229
|
+
* CHECKLIST for new mutation methods:
|
|
617230
|
+
* - Synchronous mutations: call once after the mutation.
|
|
617231
|
+
* - Async queue mutations: call once before enqueue, once after the mutation
|
|
617232
|
+
* inside the queue op.
|
|
617233
|
+
*/
|
|
617234
|
+
invalidateMessageCache() {
|
|
617235
|
+
this._cachedMessages = null;
|
|
617236
|
+
}
|
|
617034
617237
|
updateConfig(config4) {
|
|
617035
617238
|
this.config = { ...this.config, ...config4 };
|
|
617036
617239
|
this.compaction.updateConfig(config4);
|
|
@@ -617108,11 +617311,13 @@ var ContextV2 = class _ContextV2 {
|
|
|
617108
617311
|
return this.attachments;
|
|
617109
617312
|
}
|
|
617110
617313
|
truncateAfterTimestamp(timestamp) {
|
|
617314
|
+
this.invalidateMessageCache();
|
|
617111
617315
|
void this.queue.enqueue(async () => {
|
|
617112
617316
|
const initialCount = this.messages.length;
|
|
617113
617317
|
this.messages = this.messages.filter((msg) => !msg._superblocks?.timestamp || msg._superblocks.timestamp <= timestamp);
|
|
617318
|
+
this.invalidateMessageCache();
|
|
617114
617319
|
const removed = initialCount - this.messages.length;
|
|
617115
|
-
|
|
617320
|
+
logger7.info(`Truncated context after timestamp ${timestamp}. Removed ${removed} messages, ${this.messages.length} remaining.`);
|
|
617116
617321
|
await this.persist("truncate");
|
|
617117
617322
|
});
|
|
617118
617323
|
}
|
|
@@ -617132,12 +617337,15 @@ var ContextV2 = class _ContextV2 {
|
|
|
617132
617337
|
}
|
|
617133
617338
|
setSystemPrompt(prompt) {
|
|
617134
617339
|
this.systemPrompt = toStoredMessage(prompt);
|
|
617340
|
+
this.invalidateMessageCache();
|
|
617135
617341
|
}
|
|
617136
617342
|
async addUserMessage(message) {
|
|
617137
617343
|
this.serverCompactionCompletedBeforeStart = false;
|
|
617344
|
+
this.invalidateMessageCache();
|
|
617138
617345
|
return this.queue.enqueue(async () => {
|
|
617139
617346
|
const storedMessage = toStoredMessage(message);
|
|
617140
617347
|
this.messages.push(storedMessage);
|
|
617348
|
+
this.invalidateMessageCache();
|
|
617141
617349
|
await this.appendEvent("prompt_sent", storedMessage);
|
|
617142
617350
|
});
|
|
617143
617351
|
}
|
|
@@ -617153,6 +617361,7 @@ var ContextV2 = class _ContextV2 {
|
|
|
617153
617361
|
* persistent contexts, re-append every message to the event log).
|
|
617154
617362
|
*/
|
|
617155
617363
|
async initializeWith(messages3) {
|
|
617364
|
+
this.invalidateMessageCache();
|
|
617156
617365
|
const tracer4 = this.tracer ?? LLMObsTracer.instance;
|
|
617157
617366
|
return tracer4.trace({ kind: "task", name: "context.replay" }, (span) => this.replayMessages(messages3, tracer4, span));
|
|
617158
617367
|
}
|
|
@@ -617162,7 +617371,7 @@ var ContextV2 = class _ContextV2 {
|
|
|
617162
617371
|
await this.queue.enqueue(async () => {
|
|
617163
617372
|
const replayStartedAt = performance.now();
|
|
617164
617373
|
if (this.messages.length > 0) {
|
|
617165
|
-
|
|
617374
|
+
logger7.warn(`initializeWith called on a non-empty context (${this.messages.length} existing messages); appending \u2014 this likely duplicates history`);
|
|
617166
617375
|
}
|
|
617167
617376
|
for (let i2 = 0; i2 < messages3.length; i2++) {
|
|
617168
617377
|
if (i2 > 0 && i2 % REPLAY_YIELD_INTERVAL === 0) {
|
|
@@ -617189,6 +617398,7 @@ var ContextV2 = class _ContextV2 {
|
|
|
617189
617398
|
await this.appendEvent("response_received", storedResponse, eventUsage);
|
|
617190
617399
|
}
|
|
617191
617400
|
this.stripAllButLatestScreenshot();
|
|
617401
|
+
this.invalidateMessageCache();
|
|
617192
617402
|
await this.persist("replay");
|
|
617193
617403
|
replayMs = Math.round(performance.now() - replayStartedAt);
|
|
617194
617404
|
});
|
|
@@ -617196,13 +617406,15 @@ var ContextV2 = class _ContextV2 {
|
|
|
617196
617406
|
tracer4.annotate(span, {
|
|
617197
617407
|
metadata: { messageCount: messages3.length, queueWaitMs, replayMs }
|
|
617198
617408
|
});
|
|
617199
|
-
|
|
617409
|
+
logger7.info(`initializeWith: replayed ${messages3.length} messages in ${replayMs}ms (queueWaitMs=${queueWaitMs})`);
|
|
617200
617410
|
}
|
|
617201
617411
|
async addResponse(response, usage) {
|
|
617412
|
+
this.invalidateMessageCache();
|
|
617202
617413
|
await this.queue.enqueue(async () => {
|
|
617203
617414
|
const storedResponse = this.ingestResponse(response, usage, {
|
|
617204
617415
|
stripOlderScreenshots: true
|
|
617205
617416
|
});
|
|
617417
|
+
this.invalidateMessageCache();
|
|
617206
617418
|
if (response.role === "assistant" || response.role === "tool") {
|
|
617207
617419
|
const eventUsage = response.role === "assistant" ? extractTokenUsage(usage) : void 0;
|
|
617208
617420
|
await this.appendEvent("response_received", storedResponse, eventUsage);
|
|
@@ -617232,6 +617444,7 @@ var ContextV2 = class _ContextV2 {
|
|
|
617232
617444
|
if (responses.length === 0) {
|
|
617233
617445
|
return;
|
|
617234
617446
|
}
|
|
617447
|
+
this.invalidateMessageCache();
|
|
617235
617448
|
await this.queue.enqueue(async () => {
|
|
617236
617449
|
for (const response of responses) {
|
|
617237
617450
|
const storedResponse = this.ingestResponse(response, usage, {
|
|
@@ -617243,6 +617456,7 @@ var ContextV2 = class _ContextV2 {
|
|
|
617243
617456
|
}
|
|
617244
617457
|
}
|
|
617245
617458
|
this.stripAllButLatestScreenshot();
|
|
617459
|
+
this.invalidateMessageCache();
|
|
617246
617460
|
});
|
|
617247
617461
|
const lastResponse = responses[responses.length - 1];
|
|
617248
617462
|
if (lastResponse) {
|
|
@@ -617292,7 +617506,7 @@ var ContextV2 = class _ContextV2 {
|
|
|
617292
617506
|
}
|
|
617293
617507
|
}
|
|
617294
617508
|
if (strippedCount > 0) {
|
|
617295
|
-
|
|
617509
|
+
logger7.info(`Stripped media from ${strippedCount} older screenshot(s)`);
|
|
617296
617510
|
}
|
|
617297
617511
|
}
|
|
617298
617512
|
const extraMeta = this.compaction.collectToolMetadata(normalized) ?? {};
|
|
@@ -617324,7 +617538,7 @@ var ContextV2 = class _ContextV2 {
|
|
|
617324
617538
|
strippedCount++;
|
|
617325
617539
|
}
|
|
617326
617540
|
if (strippedCount > 0) {
|
|
617327
|
-
|
|
617541
|
+
logger7.info(`Stripped media from ${strippedCount} older screenshot(s)`);
|
|
617328
617542
|
}
|
|
617329
617543
|
}
|
|
617330
617544
|
/**
|
|
@@ -617364,6 +617578,7 @@ var ContextV2 = class _ContextV2 {
|
|
|
617364
617578
|
});
|
|
617365
617579
|
if (result.messages) {
|
|
617366
617580
|
this.messages = result.messages;
|
|
617581
|
+
this.invalidateMessageCache();
|
|
617367
617582
|
}
|
|
617368
617583
|
if (result.skillsNeedReload) {
|
|
617369
617584
|
this.skillsNeedReload = true;
|
|
@@ -617377,14 +617592,21 @@ var ContextV2 = class _ContextV2 {
|
|
|
617377
617592
|
});
|
|
617378
617593
|
}
|
|
617379
617594
|
async getMessages() {
|
|
617595
|
+
if (this._cachedMessages) {
|
|
617596
|
+
logger7.debug(`getMessages: cache hit (${this._cachedMessages.length} messages)`);
|
|
617597
|
+
return [...this._cachedMessages];
|
|
617598
|
+
}
|
|
617380
617599
|
return this.queue.enqueue(async () => {
|
|
617600
|
+
if (this._cachedMessages) {
|
|
617601
|
+
return [...this._cachedMessages];
|
|
617602
|
+
}
|
|
617381
617603
|
const conversationMessages = this.messages.filter((msg) => msg.role !== "system");
|
|
617382
617604
|
const allMessages = this.systemPrompt ? [this.systemPrompt, ...conversationMessages] : [...conversationMessages];
|
|
617383
617605
|
const sanitized = toSdkMessages(allMessages);
|
|
617384
617606
|
const normalized = sanitized.map((msg) => normalizeToolMessage(stripUndefinedFromToolOutputs(msg)));
|
|
617385
617607
|
const repaired = normalized.map(repairBrokenToolCalls).map(repairOrphanedToolResults).filter((msg) => {
|
|
617386
617608
|
if (msg.role !== "user" && Array.isArray(msg.content) && msg.content.length === 0) {
|
|
617387
|
-
|
|
617609
|
+
logger7.debug(`Filtered out empty ${msg.role} message after repair`);
|
|
617388
617610
|
return false;
|
|
617389
617611
|
}
|
|
617390
617612
|
return true;
|
|
@@ -617396,11 +617618,11 @@ var ContextV2 = class _ContextV2 {
|
|
|
617396
617618
|
}
|
|
617397
617619
|
const signatureSafe = stripUnsignedReasoning(repaired);
|
|
617398
617620
|
if (signatureSafe.length < repaired.length) {
|
|
617399
|
-
|
|
617621
|
+
logger7.debug(`Stripped ${repaired.length - signatureSafe.length} message(s) with unsigned reasoning`);
|
|
617400
617622
|
}
|
|
617401
617623
|
const prefillSafe = stripTrailingAssistantPrefill(signatureSafe);
|
|
617402
617624
|
if (prefillSafe.length < signatureSafe.length) {
|
|
617403
|
-
|
|
617625
|
+
logger7.debug(`Stripped ${signatureSafe.length - prefillSafe.length} trailing assistant prefill message(s)`);
|
|
617404
617626
|
}
|
|
617405
617627
|
const deduped = uniquifyFilePartFilenames(prefillSafe);
|
|
617406
617628
|
const enforced = enforceToolUsePairing(deduped);
|
|
@@ -617414,15 +617636,18 @@ var ContextV2 = class _ContextV2 {
|
|
|
617414
617636
|
enforced[idx].providerOptions = CACHE_BREAKPOINT_PROVIDER_OPTIONS;
|
|
617415
617637
|
}
|
|
617416
617638
|
}
|
|
617417
|
-
|
|
617639
|
+
this._cachedMessages = enforced;
|
|
617640
|
+
return [...enforced];
|
|
617418
617641
|
});
|
|
617419
617642
|
}
|
|
617420
617643
|
async onCompactionDetected() {
|
|
617421
617644
|
const detectedGeneration = this.activeServerCompactionGeneration;
|
|
617645
|
+
this.invalidateMessageCache();
|
|
617422
617646
|
await this.queue.enqueue(async () => {
|
|
617423
617647
|
const result = this.compaction.onCompactionDetected(this.messages);
|
|
617424
617648
|
if (result.messages) {
|
|
617425
617649
|
this.messages = result.messages;
|
|
617650
|
+
this.invalidateMessageCache();
|
|
617426
617651
|
}
|
|
617427
617652
|
if (result.skillsNeedReload) {
|
|
617428
617653
|
this.skillsNeedReload = true;
|
|
@@ -617431,7 +617656,7 @@ var ContextV2 = class _ContextV2 {
|
|
|
617431
617656
|
const summary = typeof marker17?.content === "string" ? marker17.content : SERVER_COMPACTION_SUMMARY;
|
|
617432
617657
|
this.completeServerCompactionMessage(summary, detectedGeneration);
|
|
617433
617658
|
if (!this.eventStore || !this.contextId) {
|
|
617434
|
-
|
|
617659
|
+
logger7.info("Server-side compaction detected (no event store configured)");
|
|
617435
617660
|
return;
|
|
617436
617661
|
}
|
|
617437
617662
|
const entry = {
|
|
@@ -617447,9 +617672,9 @@ var ContextV2 = class _ContextV2 {
|
|
|
617447
617672
|
await this.eventStore.appendEvent(this.contextId, this.toEventLogEntry(message));
|
|
617448
617673
|
}
|
|
617449
617674
|
} catch (err) {
|
|
617450
|
-
|
|
617675
|
+
logger7.error(`Failed to append compaction_received event: ${err}`);
|
|
617451
617676
|
}
|
|
617452
|
-
|
|
617677
|
+
logger7.info(`Server-side compaction detected, wrote compaction_received event and replayed ${retainedMessages.length} retained message(s)`);
|
|
617453
617678
|
});
|
|
617454
617679
|
}
|
|
617455
617680
|
ensureServerCompactionMessageStarted() {
|
|
@@ -617499,7 +617724,7 @@ var ContextV2 = class _ContextV2 {
|
|
|
617499
617724
|
try {
|
|
617500
617725
|
await this.eventStore.appendEvent(this.contextId, entry);
|
|
617501
617726
|
} catch (err) {
|
|
617502
|
-
|
|
617727
|
+
logger7.error(`Failed to append ${type} event: ${err}`);
|
|
617503
617728
|
}
|
|
617504
617729
|
}
|
|
617505
617730
|
async appendCompactionWindow(messages3) {
|
|
@@ -617508,7 +617733,7 @@ var ContextV2 = class _ContextV2 {
|
|
|
617508
617733
|
}
|
|
617509
617734
|
const windowMessages = messages3.filter((msg) => msg.role !== "system");
|
|
617510
617735
|
if (windowMessages.length === 0) {
|
|
617511
|
-
|
|
617736
|
+
logger7.warn("Compaction window is empty after system-role filtering; skipping event log write");
|
|
617512
617737
|
return;
|
|
617513
617738
|
}
|
|
617514
617739
|
const needsMarker = windowMessages[0]?._superblocks?.isSummary !== true;
|
|
@@ -617524,9 +617749,9 @@ var ContextV2 = class _ContextV2 {
|
|
|
617524
617749
|
for (const message of windowMessages) {
|
|
617525
617750
|
await this.eventStore.appendEvent(this.contextId, this.toEventLogEntry(message));
|
|
617526
617751
|
}
|
|
617527
|
-
|
|
617752
|
+
logger7.info(`Wrote ${windowMessages.length} client-side compaction message(s) to event log (anchor: ${needsMarker ? "phase-1 marker" : "isSummary message"})`);
|
|
617528
617753
|
} catch (err) {
|
|
617529
|
-
|
|
617754
|
+
logger7.error(`Failed to append client-side compaction window: ${err}`);
|
|
617530
617755
|
}
|
|
617531
617756
|
}
|
|
617532
617757
|
toEventLogEntry(message) {
|
|
@@ -617571,7 +617796,7 @@ var ContextV2 = class _ContextV2 {
|
|
|
617571
617796
|
await onPersist(this.toRecord());
|
|
617572
617797
|
} catch (err) {
|
|
617573
617798
|
persistError = err;
|
|
617574
|
-
|
|
617799
|
+
logger7.error(`Failed to persist context: ${err}`);
|
|
617575
617800
|
}
|
|
617576
617801
|
const elapsedMs = performance.now() - startedAt;
|
|
617577
617802
|
tracer4.annotate(span, {
|
|
@@ -617584,7 +617809,7 @@ var ContextV2 = class _ContextV2 {
|
|
|
617584
617809
|
});
|
|
617585
617810
|
recordContextPersist({ trigger, durationMs: elapsedMs });
|
|
617586
617811
|
if (elapsedMs > SLOW_PERSIST_WARN_MS) {
|
|
617587
|
-
|
|
617812
|
+
logger7.warn(`slow persist: ${Math.round(elapsedMs)}ms (messages=${this.messages.length})`);
|
|
617588
617813
|
}
|
|
617589
617814
|
});
|
|
617590
617815
|
}
|
|
@@ -617592,7 +617817,7 @@ var ContextV2 = class _ContextV2 {
|
|
|
617592
617817
|
|
|
617593
617818
|
// ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/adapter.js
|
|
617594
617819
|
init_cjs_shims();
|
|
617595
|
-
var
|
|
617820
|
+
var logger8 = getPrefixedLogger("[context-v2-adapter]");
|
|
617596
617821
|
var createUsage = (inputTokens = 0, outputTokens = 0) => ({
|
|
617597
617822
|
inputTokens,
|
|
617598
617823
|
outputTokens,
|
|
@@ -617633,7 +617858,7 @@ var ContextV2Adapter = class _ContextV2Adapter {
|
|
|
617633
617858
|
const newResponses = responses.slice(this.responseCount);
|
|
617634
617859
|
this.responseCount = responses.length;
|
|
617635
617860
|
if (!usage) {
|
|
617636
|
-
|
|
617861
|
+
logger8.warn("endStep called without usage data - compaction may not trigger");
|
|
617637
617862
|
}
|
|
617638
617863
|
this.lastUsage = usage ?? this.lastUsage;
|
|
617639
617864
|
const effectiveUsage = usage ?? this.lastUsage ?? createUsage();
|
|
@@ -618066,7 +618291,7 @@ function getProviderId(model) {
|
|
|
618066
618291
|
return "string-model";
|
|
618067
618292
|
return model.provider ?? "unknown";
|
|
618068
618293
|
}
|
|
618069
|
-
var
|
|
618294
|
+
var logger9 = getPrefixedLogger("[phase2-session-summarizer]");
|
|
618070
618295
|
function getMediaType(value2) {
|
|
618071
618296
|
if (value2.mediaType) {
|
|
618072
618297
|
return value2.mediaType;
|
|
@@ -618203,7 +618428,7 @@ async function summarizeSession(options8) {
|
|
|
618203
618428
|
headers: response?.headers
|
|
618204
618429
|
}
|
|
618205
618430
|
};
|
|
618206
|
-
|
|
618431
|
+
logger9.warn("Summarization produced empty summary - debug info:", debugInfo);
|
|
618207
618432
|
throw new Error(`Summarization produced empty summary. finishReason=${finishReason}, model=${getModelId(model)}, inputTokens=${usage?.inputTokens}, outputTokens=${usage?.outputTokens}`);
|
|
618208
618433
|
}
|
|
618209
618434
|
tracer4.annotate(llmSpan, {
|
|
@@ -618228,7 +618453,7 @@ async function summarizeSession(options8) {
|
|
|
618228
618453
|
const MAX_SPLIT_DEPTH = 10;
|
|
618229
618454
|
async function summarizeWithSplitting(msgs, depth = 0) {
|
|
618230
618455
|
if (depth >= MAX_SPLIT_DEPTH) {
|
|
618231
|
-
|
|
618456
|
+
logger9.warn(`Summarization split depth limit reached (${MAX_SPLIT_DEPTH}). Falling back to truncation.`);
|
|
618232
618457
|
return createTruncationFallback(messages3, tracer4);
|
|
618233
618458
|
}
|
|
618234
618459
|
if (msgs.length < 2) {
|
|
@@ -618236,10 +618461,10 @@ async function summarizeSession(options8) {
|
|
|
618236
618461
|
return await callLLM(msgs);
|
|
618237
618462
|
} catch (error40) {
|
|
618238
618463
|
if (isTokenLimitError(error40)) {
|
|
618239
|
-
|
|
618464
|
+
logger9.warn(`Token limit exceeded even with ${msgs.length} message(s). Falling back to truncation.`);
|
|
618240
618465
|
return createTruncationFallback(messages3, tracer4);
|
|
618241
618466
|
}
|
|
618242
|
-
|
|
618467
|
+
logger9.error(`LLM summarization failed. Falling back to truncation. Error: ${JSON.stringify(error40)}`, error40);
|
|
618243
618468
|
return createTruncationFallback(messages3, tracer4);
|
|
618244
618469
|
}
|
|
618245
618470
|
}
|
|
@@ -618248,13 +618473,13 @@ async function summarizeSession(options8) {
|
|
|
618248
618473
|
return result2;
|
|
618249
618474
|
} catch (error40) {
|
|
618250
618475
|
if (!isTokenLimitError(error40)) {
|
|
618251
|
-
|
|
618476
|
+
logger9.error(`LLM summarization failed. Falling back to truncation. Error: ${JSON.stringify(error40)}`, error40);
|
|
618252
618477
|
return createTruncationFallback(messages3, tracer4);
|
|
618253
618478
|
}
|
|
618254
618479
|
const midpoint = Math.floor(msgs.length / 2);
|
|
618255
618480
|
const firstHalf = msgs.slice(0, midpoint);
|
|
618256
618481
|
const secondHalf = msgs.slice(midpoint);
|
|
618257
|
-
|
|
618482
|
+
logger9.warn(`Token limit exceeded with ${msgs.length} messages (depth=${depth}). Splitting: first half (${firstHalf.length}), second half (${secondHalf.length})`);
|
|
618258
618483
|
const firstResult = await tracer4.trace({ name: "session.summarize.split", kind: "task" }, async (splitSpan) => {
|
|
618259
618484
|
tracer4.annotate(splitSpan, {
|
|
618260
618485
|
metadata: {
|
|
@@ -618304,8 +618529,8 @@ async function summarizeSession(options8) {
|
|
|
618304
618529
|
// ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/session-capture.js
|
|
618305
618530
|
init_cjs_shims();
|
|
618306
618531
|
import { writeFileSync as writeFileSync2, mkdirSync, existsSync as existsSync3 } from "node:fs";
|
|
618307
|
-
import { join as
|
|
618308
|
-
var
|
|
618532
|
+
import { join as join19 } from "node:path";
|
|
618533
|
+
var logger10 = getPrefixedLogger("[session-capture]");
|
|
618309
618534
|
var CAPTURE_ENABLED = false;
|
|
618310
618535
|
function isTestEnvironment() {
|
|
618311
618536
|
return process.env.VITEST === "true" || process.env.NODE_ENV === "test";
|
|
@@ -618317,7 +618542,7 @@ function isEnabled() {
|
|
|
618317
618542
|
return CAPTURE_ENABLED;
|
|
618318
618543
|
}
|
|
618319
618544
|
function getCaptureDir(rootDir) {
|
|
618320
|
-
return
|
|
618545
|
+
return join19(rootDir, ".superblocks", "captured-sessions");
|
|
618321
618546
|
}
|
|
618322
618547
|
function ensureDir(captureDir) {
|
|
618323
618548
|
if (!existsSync3(captureDir)) {
|
|
@@ -618340,18 +618565,18 @@ function captureSession(data3, rootDir) {
|
|
|
618340
618565
|
usage: data3.usage
|
|
618341
618566
|
};
|
|
618342
618567
|
const filename = generateFilename();
|
|
618343
|
-
const filepath =
|
|
618568
|
+
const filepath = join19(captureDir, filename);
|
|
618344
618569
|
writeFileSync2(filepath, JSON.stringify(session, null, 2));
|
|
618345
|
-
|
|
618570
|
+
logger10.info(`Captured session to ${filepath}`);
|
|
618346
618571
|
return filepath;
|
|
618347
618572
|
} catch (err) {
|
|
618348
|
-
|
|
618573
|
+
logger10.error(`Failed to capture session: ${err}`);
|
|
618349
618574
|
return null;
|
|
618350
618575
|
}
|
|
618351
618576
|
}
|
|
618352
618577
|
|
|
618353
618578
|
// ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/compactor.js
|
|
618354
|
-
var
|
|
618579
|
+
var logger11 = getPrefixedLogger("[context-v2:compactor]");
|
|
618355
618580
|
async function compact(options8) {
|
|
618356
618581
|
const { messages: messages3, usage, model, config: config4 = {}, callbacks, tracer: tracer4 = LLMObsTracer.instance, rootDir } = options8;
|
|
618357
618582
|
return tracer4.trace({ name: "context.compaction", kind: "task" }, async (compactionSpan) => {
|
|
@@ -618373,7 +618598,7 @@ async function compact(options8) {
|
|
|
618373
618598
|
}, rootDir);
|
|
618374
618599
|
const pruneableTokens = calculatePruneableTokens(messages3, phase1ProtectedTokens);
|
|
618375
618600
|
if (phase1Enabled && pruneableTokens >= phase1MinPruneable) {
|
|
618376
|
-
|
|
618601
|
+
logger11.info(`Phase 1: summarizing tool outputs (${pruneableTokens} pruneable tokens)`);
|
|
618377
618602
|
const phase1MessageId = crypto.randomUUID();
|
|
618378
618603
|
callbacks?.onCompactionStart?.("phase1", phase1MessageId);
|
|
618379
618604
|
const result = tracer4.trace({ name: "context.compaction.phase1", kind: "task" }, (phase1Span) => {
|
|
@@ -618402,7 +618627,7 @@ async function compact(options8) {
|
|
|
618402
618627
|
});
|
|
618403
618628
|
currentMessages = result.messages;
|
|
618404
618629
|
phase1Applied = true;
|
|
618405
|
-
|
|
618630
|
+
logger11.info(`Phase 1 complete: summarized ${result.summarizedCount} tool outputs`);
|
|
618406
618631
|
callbacks?.onCompactionComplete?.("phase1", phase1MessageId);
|
|
618407
618632
|
const estimatedNewTokens = initialTokens - pruneableTokens;
|
|
618408
618633
|
if (estimatedNewTokens < targetTokens) {
|
|
@@ -618439,7 +618664,7 @@ async function compact(options8) {
|
|
|
618439
618664
|
};
|
|
618440
618665
|
}
|
|
618441
618666
|
}
|
|
618442
|
-
|
|
618667
|
+
logger11.info("Phase 2: generating session summary");
|
|
618443
618668
|
const phase2MessageId = crypto.randomUUID();
|
|
618444
618669
|
callbacks?.onCompactionStart?.("phase2", phase2MessageId);
|
|
618445
618670
|
const summaryResult = await tracer4.trace({ name: "context.compaction.phase2", kind: "task" }, async (phase2Span) => {
|
|
@@ -618467,7 +618692,7 @@ async function compact(options8) {
|
|
|
618467
618692
|
currentMessages = summaryResult.messages;
|
|
618468
618693
|
const summaryTokens = summaryResult.messages.reduce((sum, msg) => sum + (msg._superblocks?.tokenCount ?? 100), 0);
|
|
618469
618694
|
tokensSaved = initialTokens - summaryTokens;
|
|
618470
|
-
|
|
618695
|
+
logger11.info(`Phase 2 complete: ${initialTokens}\u2192${summaryTokens} tokens (saved ${tokensSaved})`);
|
|
618471
618696
|
callbacks?.onCompactionComplete?.("phase2", phase2MessageId, summaryResult.summary);
|
|
618472
618697
|
tracer4.annotate(compactionSpan, {
|
|
618473
618698
|
metadata: {
|
|
@@ -618503,7 +618728,7 @@ async function compact(options8) {
|
|
|
618503
618728
|
}
|
|
618504
618729
|
|
|
618505
618730
|
// ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/compaction/client-side.js
|
|
618506
|
-
var
|
|
618731
|
+
var logger12 = getPrefixedLogger("[compaction:client-side]");
|
|
618507
618732
|
var ClientSideCompactionStrategy = class {
|
|
618508
618733
|
summarizationModel;
|
|
618509
618734
|
config;
|
|
@@ -618583,15 +618808,15 @@ var ClientSideCompactionStrategy = class {
|
|
|
618583
618808
|
const inputContextUsed = computeContextUsed(params.usage);
|
|
618584
618809
|
const threshold = this.config.contextLimit - this.config.maxOutputTokens - this.config.contextBufferTokens;
|
|
618585
618810
|
if (inputContextUsed === 0) {
|
|
618586
|
-
|
|
618811
|
+
logger12.warn("Compaction threshold check skipped because provider usage reported 0 input context tokens");
|
|
618587
618812
|
return {};
|
|
618588
618813
|
}
|
|
618589
618814
|
if (inputContextUsed <= threshold) {
|
|
618590
618815
|
return {};
|
|
618591
618816
|
}
|
|
618592
|
-
|
|
618817
|
+
logger12.info(`Compaction triggered: ${inputContextUsed} tokens > ${threshold} threshold (${params.messages.length} messages)`);
|
|
618593
618818
|
if (!this.summarizationModel) {
|
|
618594
|
-
|
|
618819
|
+
logger12.warn("Client-side compaction is selected but no summarization model is configured; skipping compaction");
|
|
618595
618820
|
return {};
|
|
618596
618821
|
}
|
|
618597
618822
|
const result = await compact({
|
|
@@ -618609,7 +618834,7 @@ var ClientSideCompactionStrategy = class {
|
|
|
618609
618834
|
} else if (result.phase1Applied) {
|
|
618610
618835
|
phase = "phase1";
|
|
618611
618836
|
}
|
|
618612
|
-
|
|
618837
|
+
logger12.info(`Compaction complete (${phase}): saved ${result.tokensSaved} tokens, ${params.messages.length}\u2192${result.messages.length} messages`);
|
|
618613
618838
|
const messages3 = result.messages.map((msg) => ({
|
|
618614
618839
|
...msg,
|
|
618615
618840
|
_superblocks: {
|
|
@@ -618627,12 +618852,12 @@ var ClientSideCompactionStrategy = class {
|
|
|
618627
618852
|
role: "user",
|
|
618628
618853
|
content: buildModeMessage(modeState.mode, modeState.planApproved)
|
|
618629
618854
|
}));
|
|
618630
|
-
|
|
618855
|
+
logger12.info(`Re-injected mode context after phase 2 compaction (mode=${modeState.mode})`);
|
|
618631
618856
|
} else if (this.getModeState) {
|
|
618632
|
-
|
|
618857
|
+
logger12.warn("Phase 2 compaction completed but getModeState() returned undefined; mode context will NOT be re-injected");
|
|
618633
618858
|
}
|
|
618634
618859
|
} catch (err) {
|
|
618635
|
-
|
|
618860
|
+
logger12.error(`Failed to re-inject mode state after phase 2 compaction: ${err}`);
|
|
618636
618861
|
}
|
|
618637
618862
|
}
|
|
618638
618863
|
return {
|
|
@@ -618763,11 +618988,11 @@ function hasMigrationPath(fromVersion, toVersion) {
|
|
|
618763
618988
|
|
|
618764
618989
|
// ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/migrations/runner.js
|
|
618765
618990
|
init_cjs_shims();
|
|
618766
|
-
var
|
|
618991
|
+
var logger13 = getPrefixedLogger("[context-migration]");
|
|
618767
618992
|
function migrateContext(record2, targetVersion) {
|
|
618768
618993
|
const currentVersion = detectVersion(record2);
|
|
618769
618994
|
if (currentVersion === 0) {
|
|
618770
|
-
|
|
618995
|
+
logger13.error(`Unrecognized context format, cannot determine version. Deleting context.`);
|
|
618771
618996
|
return {
|
|
618772
618997
|
success: false,
|
|
618773
618998
|
deleted: true,
|
|
@@ -618775,14 +619000,14 @@ function migrateContext(record2, targetVersion) {
|
|
|
618775
619000
|
};
|
|
618776
619001
|
}
|
|
618777
619002
|
if (currentVersion === targetVersion) {
|
|
618778
|
-
|
|
619003
|
+
logger13.debug(`Context already at version ${targetVersion}, no migration needed`);
|
|
618779
619004
|
return {
|
|
618780
619005
|
success: true,
|
|
618781
619006
|
record: record2
|
|
618782
619007
|
};
|
|
618783
619008
|
}
|
|
618784
619009
|
if (currentVersion > targetVersion) {
|
|
618785
|
-
|
|
619010
|
+
logger13.error(`Context version ${currentVersion} is newer than expected version ${targetVersion}. Downgrade is not supported. Deleting context.`);
|
|
618786
619011
|
return {
|
|
618787
619012
|
success: false,
|
|
618788
619013
|
deleted: true,
|
|
@@ -618790,21 +619015,21 @@ function migrateContext(record2, targetVersion) {
|
|
|
618790
619015
|
};
|
|
618791
619016
|
}
|
|
618792
619017
|
if (!hasMigrationPath(currentVersion, targetVersion)) {
|
|
618793
|
-
|
|
619018
|
+
logger13.error(`No migration path from version ${currentVersion} to ${targetVersion}. Deleting context.`);
|
|
618794
619019
|
return {
|
|
618795
619020
|
success: false,
|
|
618796
619021
|
deleted: true,
|
|
618797
619022
|
reason: `No migration path from ${currentVersion} to ${targetVersion}`
|
|
618798
619023
|
};
|
|
618799
619024
|
}
|
|
618800
|
-
|
|
619025
|
+
logger13.debug(`Migrating context from version ${currentVersion} to ${targetVersion}`);
|
|
618801
619026
|
let migrated = record2;
|
|
618802
619027
|
for (let v2 = currentVersion; v2 < targetVersion; v2++) {
|
|
618803
619028
|
const migration = getMigration(v2, v2 + 1);
|
|
618804
619029
|
try {
|
|
618805
619030
|
migrated = migration.migrate(migrated);
|
|
618806
619031
|
} catch (err) {
|
|
618807
|
-
|
|
619032
|
+
logger13.error(`Migration v${v2} \u2192 v${v2 + 1} failed: ${err}. Deleting context.`);
|
|
618808
619033
|
return {
|
|
618809
619034
|
success: false,
|
|
618810
619035
|
deleted: true,
|
|
@@ -618820,7 +619045,7 @@ function migrateContext(record2, targetVersion) {
|
|
|
618820
619045
|
|
|
618821
619046
|
// ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/storage/migration.js
|
|
618822
619047
|
init_cjs_shims();
|
|
618823
|
-
var
|
|
619048
|
+
var logger14 = getPrefixedLogger("[context-v2-migrator]");
|
|
618824
619049
|
var ContextV2Migrator = class {
|
|
618825
619050
|
legacyStorage;
|
|
618826
619051
|
eventStore;
|
|
@@ -618848,7 +619073,7 @@ var ContextV2Migrator = class {
|
|
|
618848
619073
|
}
|
|
618849
619074
|
const result = migrateContext(rawRecord, 2);
|
|
618850
619075
|
if (!result.success) {
|
|
618851
|
-
|
|
619076
|
+
logger14.warn(`Cannot migrate context '${contextId.name}': ${result.reason}`);
|
|
618852
619077
|
return false;
|
|
618853
619078
|
}
|
|
618854
619079
|
const { messages: messages3 } = result.record;
|
|
@@ -618870,15 +619095,15 @@ var ContextV2Migrator = class {
|
|
|
618870
619095
|
written++;
|
|
618871
619096
|
}
|
|
618872
619097
|
} catch (err) {
|
|
618873
|
-
|
|
619098
|
+
logger14.error(`Migration failed after writing ${written}/${slice2.length} events for context '${contextId.name}': ${err}`);
|
|
618874
619099
|
try {
|
|
618875
619100
|
await this.eventStore.deleteEvents(contextId);
|
|
618876
619101
|
} catch (cleanupErr) {
|
|
618877
|
-
|
|
619102
|
+
logger14.error(`Failed to clean up partial event log for context '${contextId.name}': ${cleanupErr}`);
|
|
618878
619103
|
}
|
|
618879
619104
|
throw err;
|
|
618880
619105
|
}
|
|
618881
|
-
|
|
619106
|
+
logger14.info(`Migrated ${slice2.length} messages from ContextV2 to event log for context '${contextId.name}'`);
|
|
618882
619107
|
return true;
|
|
618883
619108
|
}
|
|
618884
619109
|
/**
|
|
@@ -618917,7 +619142,7 @@ var ContextV2Migrator = class {
|
|
|
618917
619142
|
};
|
|
618918
619143
|
|
|
618919
619144
|
// ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/manager.js
|
|
618920
|
-
var
|
|
619145
|
+
var logger15 = getPrefixedLogger("[context-manager-v2]");
|
|
618921
619146
|
var ContextManagerV2 = class {
|
|
618922
619147
|
storage;
|
|
618923
619148
|
contexts = /* @__PURE__ */ new Map();
|
|
@@ -618982,10 +619207,10 @@ var ContextManagerV2 = class {
|
|
|
618982
619207
|
};
|
|
618983
619208
|
let context2;
|
|
618984
619209
|
if (record2) {
|
|
618985
|
-
|
|
619210
|
+
logger15.info(`Restored context '${id2?.name}' from storage in ${loadMs}ms (messages=${record2.messages.length})`);
|
|
618986
619211
|
context2 = ContextV2.fromRecord(record2, options8);
|
|
618987
619212
|
} else {
|
|
618988
|
-
|
|
619213
|
+
logger15.info(`Creating new context '${id2?.name ?? "ephemeral"}' (load took ${loadMs}ms)`);
|
|
618989
619214
|
context2 = new ContextV2(options8);
|
|
618990
619215
|
}
|
|
618991
619216
|
if (key2) {
|
|
@@ -619002,7 +619227,7 @@ var ContextManagerV2 = class {
|
|
|
619002
619227
|
*/
|
|
619003
619228
|
async loadRecordTraced(id2, tracer4) {
|
|
619004
619229
|
return tracer4.trace({ kind: "task", name: "context.load" }, async (span) => {
|
|
619005
|
-
|
|
619230
|
+
logger15.info(`Loading context '${id2.name}' from storage...`);
|
|
619006
619231
|
const loadStartedAt = performance.now();
|
|
619007
619232
|
try {
|
|
619008
619233
|
const { record: record2, source: source2, migrationRan, migrationFailed } = await this.loadRecord(id2);
|
|
@@ -619036,10 +619261,10 @@ var ContextManagerV2 = class {
|
|
|
619036
619261
|
try {
|
|
619037
619262
|
migrationRan = await this.migrator.migrateIfNeeded(id2);
|
|
619038
619263
|
if (migrationRan) {
|
|
619039
|
-
|
|
619264
|
+
logger15.info(`Migrated context '${id2.name}' from ContextV2 to event log`);
|
|
619040
619265
|
}
|
|
619041
619266
|
} catch (err) {
|
|
619042
|
-
|
|
619267
|
+
logger15.error(`Failed to migrate context '${id2.name}', falling back to legacy storage: ${err}`);
|
|
619043
619268
|
migrationFailed = true;
|
|
619044
619269
|
}
|
|
619045
619270
|
}
|
|
@@ -619049,11 +619274,11 @@ var ContextManagerV2 = class {
|
|
|
619049
619274
|
if (messages3.length > 0) {
|
|
619050
619275
|
const legacyRecord2 = await this.loadContext(id2);
|
|
619051
619276
|
const record2 = await this.reconcileEventAndLegacyRecord(id2, messages3, legacyRecord2);
|
|
619052
|
-
|
|
619277
|
+
logger15.info(`Loaded ${record2.messages.length} messages from event log for '${id2.name}'`);
|
|
619053
619278
|
return { record: record2, source: "event_log", migrationRan, migrationFailed };
|
|
619054
619279
|
}
|
|
619055
619280
|
} catch (err) {
|
|
619056
|
-
|
|
619281
|
+
logger15.error(`Failed to load from event log for '${id2.name}': ${err}`);
|
|
619057
619282
|
}
|
|
619058
619283
|
}
|
|
619059
619284
|
const legacyRecord = await this.loadContext(id2);
|
|
@@ -619069,7 +619294,7 @@ var ContextManagerV2 = class {
|
|
|
619069
619294
|
try {
|
|
619070
619295
|
const remoteRecord = await this.remoteRestoreFallback(id2);
|
|
619071
619296
|
if (remoteRecord) {
|
|
619072
|
-
|
|
619297
|
+
logger15.info(`Restored context '${id2.name}' from remote fallback`);
|
|
619073
619298
|
await this.saveContext(id2, remoteRecord);
|
|
619074
619299
|
await this.seedEventLogFromRecord(id2, remoteRecord);
|
|
619075
619300
|
return {
|
|
@@ -619080,7 +619305,7 @@ var ContextManagerV2 = class {
|
|
|
619080
619305
|
};
|
|
619081
619306
|
}
|
|
619082
619307
|
} catch (err) {
|
|
619083
|
-
|
|
619308
|
+
logger15.warn(`Remote restore fallback failed for '${id2.name}': ${err}`);
|
|
619084
619309
|
}
|
|
619085
619310
|
}
|
|
619086
619311
|
return { record: void 0, source: "new", migrationRan, migrationFailed };
|
|
@@ -619123,7 +619348,7 @@ var ContextManagerV2 = class {
|
|
|
619123
619348
|
try {
|
|
619124
619349
|
await this.eventStore.deleteAllEvents();
|
|
619125
619350
|
} catch (err) {
|
|
619126
|
-
|
|
619351
|
+
logger15.error(`Failed to delete event logs: ${err}`);
|
|
619127
619352
|
}
|
|
619128
619353
|
}
|
|
619129
619354
|
}
|
|
@@ -619143,7 +619368,7 @@ var ContextManagerV2 = class {
|
|
|
619143
619368
|
if (legacyRecord && this.hasNewerSummary(legacyRecord.messages, eventMessages)) {
|
|
619144
619369
|
await this.migrator?.appendRecordWindow(id2, legacyRecord);
|
|
619145
619370
|
const messages3 = this.messagesFromSummaryAnchor(legacyRecord.messages);
|
|
619146
|
-
|
|
619371
|
+
logger15.info(`Reconciled context '${id2.name}' from newer legacy summary into event log`);
|
|
619147
619372
|
return {
|
|
619148
619373
|
version: 2,
|
|
619149
619374
|
messages: messages3,
|
|
@@ -619162,7 +619387,7 @@ var ContextManagerV2 = class {
|
|
|
619162
619387
|
try {
|
|
619163
619388
|
await this.migrator.appendRecordWindow(id2, record2);
|
|
619164
619389
|
} catch (err) {
|
|
619165
|
-
|
|
619390
|
+
logger15.error(`Failed to seed event log after remote restore for '${id2.name}': ${err}`);
|
|
619166
619391
|
}
|
|
619167
619392
|
}
|
|
619168
619393
|
hasNewerSummary(candidate, current2) {
|
|
@@ -619211,17 +619436,17 @@ var ContextManagerV2 = class {
|
|
|
619211
619436
|
}
|
|
619212
619437
|
const result = migrateContext(rawRecord, 2);
|
|
619213
619438
|
if (!result.success) {
|
|
619214
|
-
|
|
619439
|
+
logger15.warn(`Context '${id2.name}' migration failed: ${result.reason}. Context will be deleted and a fresh conversation will start.`);
|
|
619215
619440
|
try {
|
|
619216
619441
|
await this.storage.deleteContext(id2);
|
|
619217
619442
|
} catch (deleteErr) {
|
|
619218
|
-
|
|
619443
|
+
logger15.error(`Failed to delete context '${id2.name}' after migration failure: ${deleteErr}`);
|
|
619219
619444
|
}
|
|
619220
619445
|
return null;
|
|
619221
619446
|
}
|
|
619222
619447
|
return result.record;
|
|
619223
619448
|
} catch (err) {
|
|
619224
|
-
|
|
619449
|
+
logger15.error(`Failed to load context for '${id2.name}': ${err}`);
|
|
619225
619450
|
return null;
|
|
619226
619451
|
}
|
|
619227
619452
|
}
|
|
@@ -619235,7 +619460,7 @@ var ContextManagerV2 = class {
|
|
|
619235
619460
|
await this.storage.saveContext(id2, record2);
|
|
619236
619461
|
return true;
|
|
619237
619462
|
} catch (err) {
|
|
619238
|
-
|
|
619463
|
+
logger15.error(`Failed to save context for '${id2.name}': ${err}`);
|
|
619239
619464
|
return false;
|
|
619240
619465
|
}
|
|
619241
619466
|
}
|
|
@@ -619676,11 +619901,16 @@ var IdleMonitor = class {
|
|
|
619676
619901
|
firstChunkTimeoutMs;
|
|
619677
619902
|
onStallCallback;
|
|
619678
619903
|
onServerCompactionStart;
|
|
619904
|
+
shouldPause;
|
|
619905
|
+
onPauseCallback;
|
|
619679
619906
|
timer = null;
|
|
619680
619907
|
stallError = null;
|
|
619681
619908
|
stallCallbacks = [];
|
|
619682
619909
|
subscribed = false;
|
|
619683
619910
|
hasReceivedChunk = false;
|
|
619911
|
+
// True once a local-wait suppression stretch has fired its onPause event;
|
|
619912
|
+
// reset by real activity (chunk/step/retry) so each stretch logs exactly once.
|
|
619913
|
+
pausedThisStretch = false;
|
|
619684
619914
|
compactionTextBlockIds = /* @__PURE__ */ new Set();
|
|
619685
619915
|
// The budget snapshot used when the live timer was armed. fireStall() reports
|
|
619686
619916
|
// this rather than re-resolving, so the logged budget always matches the timer
|
|
@@ -619695,6 +619925,8 @@ var IdleMonitor = class {
|
|
|
619695
619925
|
this.firstChunkTimeoutMs = options8.firstChunkTimeoutMs ?? options8.maxIdleTimeMs;
|
|
619696
619926
|
this.onStallCallback = options8.onStall;
|
|
619697
619927
|
this.onServerCompactionStart = options8.onServerCompactionStart;
|
|
619928
|
+
this.shouldPause = options8.shouldPause;
|
|
619929
|
+
this.onPauseCallback = options8.onPause;
|
|
619698
619930
|
}
|
|
619699
619931
|
resolveBudget(budget) {
|
|
619700
619932
|
return typeof budget === "function" ? budget() : budget;
|
|
@@ -619718,6 +619950,7 @@ var IdleMonitor = class {
|
|
|
619718
619950
|
start() {
|
|
619719
619951
|
this.stallError = null;
|
|
619720
619952
|
this.hasReceivedChunk = false;
|
|
619953
|
+
this.pausedThisStretch = false;
|
|
619721
619954
|
this.compactionTextBlockIds.clear();
|
|
619722
619955
|
this.session.resetActivityTimer();
|
|
619723
619956
|
this.subscribeToEvents();
|
|
@@ -619773,12 +620006,14 @@ var IdleMonitor = class {
|
|
|
619773
620006
|
}
|
|
619774
620007
|
this.stallError = null;
|
|
619775
620008
|
this.stallCallbacks = [];
|
|
620009
|
+
this.pausedThisStretch = false;
|
|
619776
620010
|
this.armTimer();
|
|
619777
620011
|
};
|
|
619778
620012
|
handleStepStart = () => {
|
|
619779
620013
|
this.hasReceivedChunk = false;
|
|
619780
620014
|
this.compactionTextBlockIds.clear();
|
|
619781
620015
|
this.stallError = null;
|
|
620016
|
+
this.pausedThisStretch = false;
|
|
619782
620017
|
this.session.resetActivityTimer();
|
|
619783
620018
|
this.armTimer();
|
|
619784
620019
|
};
|
|
@@ -619787,6 +620022,7 @@ var IdleMonitor = class {
|
|
|
619787
620022
|
this.compactionTextBlockIds.clear();
|
|
619788
620023
|
this.stallError = null;
|
|
619789
620024
|
this.stallCallbacks = [];
|
|
620025
|
+
this.pausedThisStretch = false;
|
|
619790
620026
|
this.session.resetActivityTimer();
|
|
619791
620027
|
this.armTimer();
|
|
619792
620028
|
};
|
|
@@ -619826,6 +620062,22 @@ var IdleMonitor = class {
|
|
|
619826
620062
|
if (!this.session.isPending()) {
|
|
619827
620063
|
return;
|
|
619828
620064
|
}
|
|
620065
|
+
let shouldPause = false;
|
|
620066
|
+
try {
|
|
620067
|
+
shouldPause = this.shouldPause?.() ?? false;
|
|
620068
|
+
} catch {
|
|
620069
|
+
}
|
|
620070
|
+
if (shouldPause) {
|
|
620071
|
+
if (!this.pausedThisStretch) {
|
|
620072
|
+
this.pausedThisStretch = true;
|
|
620073
|
+
try {
|
|
620074
|
+
this.onPauseCallback?.();
|
|
620075
|
+
} catch {
|
|
620076
|
+
}
|
|
620077
|
+
}
|
|
620078
|
+
this.armTimer();
|
|
620079
|
+
return;
|
|
620080
|
+
}
|
|
619829
620081
|
const idleTime = this.session.getTimeSinceLastActivity();
|
|
619830
620082
|
this.stallError = new StallTimeoutError(idleTime, this.armedBudget.timeoutMs, this.armedBudget.budgetKind);
|
|
619831
620083
|
try {
|
|
@@ -619851,10 +620103,12 @@ function createManagedStream(source2, session, idleMonitor) {
|
|
|
619851
620103
|
controller.close();
|
|
619852
620104
|
return;
|
|
619853
620105
|
}
|
|
619854
|
-
session.recordPull();
|
|
619855
620106
|
while (true) {
|
|
619856
620107
|
try {
|
|
620108
|
+
session.recordPull();
|
|
620109
|
+
session.setAwaitingUpstream(true);
|
|
619857
620110
|
const result = await raceWithStallDetection(iterator2.next(), idleMonitor);
|
|
620111
|
+
session.setAwaitingUpstream(false);
|
|
619858
620112
|
if (result.done) {
|
|
619859
620113
|
closed = true;
|
|
619860
620114
|
session.finalize("complete");
|
|
@@ -619894,6 +620148,7 @@ function createManagedStream(source2, session, idleMonitor) {
|
|
|
619894
620148
|
controller.enqueue(result.value);
|
|
619895
620149
|
return;
|
|
619896
620150
|
} catch (error40) {
|
|
620151
|
+
session.setAwaitingUpstream(false);
|
|
619897
620152
|
closed = true;
|
|
619898
620153
|
controller.error(error40);
|
|
619899
620154
|
return;
|
|
@@ -619945,7 +620200,7 @@ var RetryEngine = class {
|
|
|
619945
620200
|
}
|
|
619946
620201
|
return attemptsForProvider[provider.model] ?? 2;
|
|
619947
620202
|
}
|
|
619948
|
-
getRetryDecision(error40, session, abortSignal) {
|
|
620203
|
+
getRetryDecision(error40, session, abortSignal, currentWaitState) {
|
|
619949
620204
|
if (abortSignal?.aborted) {
|
|
619950
620205
|
return { shouldRetry: false, delayMs: 0, reason: "aborted" };
|
|
619951
620206
|
}
|
|
@@ -619974,6 +620229,13 @@ var RetryEngine = class {
|
|
|
619974
620229
|
return { shouldRetry: false, delayMs: 0, reason: "max-attempts" };
|
|
619975
620230
|
}
|
|
619976
620231
|
if (this.isStallTimeout(error40)) {
|
|
620232
|
+
if (currentWaitState?.state === "tool" || currentWaitState?.state === "step-boundary") {
|
|
620233
|
+
return {
|
|
620234
|
+
shouldRetry: true,
|
|
620235
|
+
delayMs: this.config.retry.initialDelayMs,
|
|
620236
|
+
reason: "local-wait"
|
|
620237
|
+
};
|
|
620238
|
+
}
|
|
619977
620239
|
const next2 = this.peekNextProvider();
|
|
619978
620240
|
if (next2 && next2.name !== session.provider.name) {
|
|
619979
620241
|
const newProvider = this.advanceFallback(error40);
|
|
@@ -620239,9 +620501,15 @@ var StreamSession = class {
|
|
|
620239
620501
|
// tracks when we last received a content chunk (NOT reset by keep-alives or retries).
|
|
620240
620502
|
lastContentTime;
|
|
620241
620503
|
// tracks when the downstream consumer last pulled from the managed stream.
|
|
620242
|
-
//
|
|
620243
|
-
// blocked" (stale pull) on stall logs (APPS-4729).
|
|
620504
|
+
// Emitted as ms_since_last_pull on stall logs for triage (APPS-4729).
|
|
620244
620505
|
lastPullTime;
|
|
620506
|
+
// true while the managed stream is suspended in `await iterator.next()`,
|
|
620507
|
+
// false once control returns to the downstream consumer. Discriminates a
|
|
620508
|
+
// "network dark" stall (timer fires while we're blocked on upstream) from a
|
|
620509
|
+
// "consumer blocked" stall (timer fires while the consumer holds the stream
|
|
620510
|
+
// and isn't pulling, e.g. awaiting a downstream RPC). A boolean, not a timing
|
|
620511
|
+
// comparison, so it doesn't degrade near the idle-budget boundary (APPS-4729).
|
|
620512
|
+
awaitingUpstream = false;
|
|
620245
620513
|
constructor(options8) {
|
|
620246
620514
|
this.id = crypto.randomUUID();
|
|
620247
620515
|
this.startTime = Date.now();
|
|
@@ -620337,6 +620605,15 @@ var StreamSession = class {
|
|
|
620337
620605
|
getTimeSinceLastPull() {
|
|
620338
620606
|
return this.lastPullTime === void 0 ? void 0 : Date.now() - this.lastPullTime;
|
|
620339
620607
|
}
|
|
620608
|
+
// Should only be called by createManagedStream's pull loop, symmetrically
|
|
620609
|
+
// around its `await raceWithStallDetection(iterator.next(), ...)`. Setting it
|
|
620610
|
+
// from anywhere else corrupts stall_reason classification for a live stream.
|
|
620611
|
+
setAwaitingUpstream(awaiting) {
|
|
620612
|
+
this.awaitingUpstream = awaiting;
|
|
620613
|
+
}
|
|
620614
|
+
isAwaitingUpstream() {
|
|
620615
|
+
return this.awaitingUpstream;
|
|
620616
|
+
}
|
|
620340
620617
|
// Advances both the liveness clock and the retry-budget content clock without
|
|
620341
620618
|
// touching content metrics (chunkCount / timeToFirstTokenMs). For upstream
|
|
620342
620619
|
// chunks that are real model output — proof of progress — but are filtered
|
|
@@ -620543,10 +620820,62 @@ var StreamOrchestrator = class {
|
|
|
620543
620820
|
firstChunkTimeoutMs: this.config.retry.budgetForModel(session.provider.model).firstChunkTimeoutMs
|
|
620544
620821
|
});
|
|
620545
620822
|
},
|
|
620823
|
+
shouldPause: () => {
|
|
620824
|
+
try {
|
|
620825
|
+
const waitState = waitStateTracker.getWaitState();
|
|
620826
|
+
if (waitState.state === "tool" || waitState.state === "step-boundary") {
|
|
620827
|
+
return true;
|
|
620828
|
+
}
|
|
620829
|
+
return !session.isAwaitingUpstream() && session.metrics.chunkCount > 0;
|
|
620830
|
+
} catch (err) {
|
|
620831
|
+
this.logger.error("[orchestrator] shouldPause check failed", {
|
|
620832
|
+
error: {
|
|
620833
|
+
kind: err instanceof Error ? err.name : "unknown",
|
|
620834
|
+
message: err instanceof Error ? err.message : String(err),
|
|
620835
|
+
stack: err instanceof Error ? err.stack : void 0
|
|
620836
|
+
}
|
|
620837
|
+
});
|
|
620838
|
+
return false;
|
|
620839
|
+
}
|
|
620840
|
+
},
|
|
620841
|
+
onPause: () => {
|
|
620842
|
+
const waitState = waitStateTracker.getWaitState();
|
|
620843
|
+
const message = `[orchestrator] Local wait suppressed idle stall`;
|
|
620844
|
+
const attributes2 = {
|
|
620845
|
+
event: "stream_local_wait",
|
|
620846
|
+
session_id: session.id,
|
|
620847
|
+
provider: session.provider.name,
|
|
620848
|
+
model: session.provider.model,
|
|
620849
|
+
attempt: session.attempt,
|
|
620850
|
+
elapsed_ms: session.getElapsedMs(),
|
|
620851
|
+
chunks_received: session.metrics.chunkCount,
|
|
620852
|
+
// "tool"/"step-boundary" come from the wait tracker; "consumer" is the
|
|
620853
|
+
// remaining case (consumer holding the stream), which the tracker
|
|
620854
|
+
// reports as "provider" since it does not track consumer-pull state.
|
|
620855
|
+
wait_state: waitState.state === "provider" ? "consumer" : waitState.state
|
|
620856
|
+
};
|
|
620857
|
+
if (waitState.state === "tool") {
|
|
620858
|
+
attributes2.tool_name = waitState.toolName;
|
|
620859
|
+
attributes2.tool_call_id = waitState.toolCallId;
|
|
620860
|
+
attributes2.pending_tool_count = waitState.pendingToolCount;
|
|
620861
|
+
}
|
|
620862
|
+
if (session.organizationId) {
|
|
620863
|
+
attributes2.organization_id = session.organizationId;
|
|
620864
|
+
}
|
|
620865
|
+
if (session.applicationId) {
|
|
620866
|
+
attributes2.application_id = session.applicationId;
|
|
620867
|
+
}
|
|
620868
|
+
if (this.logger.warnStructured) {
|
|
620869
|
+
this.logger.warnStructured(message, attributes2);
|
|
620870
|
+
} else {
|
|
620871
|
+
this.logger.warn(message, attributes2);
|
|
620872
|
+
}
|
|
620873
|
+
},
|
|
620546
620874
|
onStall: (error40) => {
|
|
620547
620875
|
const budgetKind = error40.budgetKind;
|
|
620548
|
-
const message = `[orchestrator] Idle timeout exceeded, triggering retry`;
|
|
620549
620876
|
const msSinceLastPull = session.getTimeSinceLastPull();
|
|
620877
|
+
const stallReason = budgetKind === "first-chunk" || session.isAwaitingUpstream() ? "network-dark" : "consumer-blocked";
|
|
620878
|
+
const message = `[orchestrator] Idle timeout exceeded, triggering retry`;
|
|
620550
620879
|
const waitState = waitStateTracker.getWaitState();
|
|
620551
620880
|
const attributes2 = {
|
|
620552
620881
|
event: "stream_stall",
|
|
@@ -620559,6 +620888,7 @@ var StreamOrchestrator = class {
|
|
|
620559
620888
|
budget_ms: error40.maxIdleTimeMs,
|
|
620560
620889
|
elapsed_ms: session.getElapsedMs(),
|
|
620561
620890
|
chunks_received: session.metrics.chunkCount,
|
|
620891
|
+
stall_reason: stallReason,
|
|
620562
620892
|
wait_state: waitState.state,
|
|
620563
620893
|
raw_reset_count: waitStateTracker.getRawResetCount()
|
|
620564
620894
|
};
|
|
@@ -620583,10 +620913,10 @@ var StreamOrchestrator = class {
|
|
|
620583
620913
|
}
|
|
620584
620914
|
}
|
|
620585
620915
|
});
|
|
620586
|
-
const result = await this.startStreamWithRetry(optionsWithAbort, session, retryEngine, attempts);
|
|
620916
|
+
const result = await this.startStreamWithRetry(optionsWithAbort, session, retryEngine, attempts, waitStateTracker);
|
|
620587
620917
|
idleMonitor.start();
|
|
620588
620918
|
const managedStream = createManagedStream(result.fullStream, session, idleMonitor);
|
|
620589
|
-
const retryableFullStream = this.wrapWithRetry(managedStream, (r3) => createManagedStream(r3.fullStream, session, idleMonitor), optionsWithAbort, session, retryEngine, internalAbortController, attempts);
|
|
620919
|
+
const retryableFullStream = this.wrapWithRetry(managedStream, (r3) => createManagedStream(r3.fullStream, session, idleMonitor), optionsWithAbort, session, retryEngine, internalAbortController, attempts, waitStateTracker);
|
|
620590
620920
|
const [fullStream, textSourceStream] = retryableFullStream.tee();
|
|
620591
620921
|
return {
|
|
620592
620922
|
...result,
|
|
@@ -620646,7 +620976,7 @@ var StreamOrchestrator = class {
|
|
|
620646
620976
|
* retries will silently fail (the new stream will close immediately because
|
|
620647
620977
|
* session.isPending() returns false).
|
|
620648
620978
|
*/
|
|
620649
|
-
wrapWithRetry(initialStream, getNewStream, options8, session, retryEngine, abortController, attempts) {
|
|
620979
|
+
wrapWithRetry(initialStream, getNewStream, options8, session, retryEngine, abortController, attempts, waitStateTracker) {
|
|
620650
620980
|
const handleRetry = this.handleRetryDecision.bind(this);
|
|
620651
620981
|
let currentStream = initialStream;
|
|
620652
620982
|
async function* createRetryIterator() {
|
|
@@ -620660,7 +620990,7 @@ var StreamOrchestrator = class {
|
|
|
620660
620990
|
}
|
|
620661
620991
|
return;
|
|
620662
620992
|
} catch (error40) {
|
|
620663
|
-
const retryResult = await handleRetry(error40, options8, session, retryEngine, attempts);
|
|
620993
|
+
const retryResult = await handleRetry(error40, options8, session, retryEngine, attempts, waitStateTracker);
|
|
620664
620994
|
if (!retryResult.shouldRetry) {
|
|
620665
620995
|
abortController.abort();
|
|
620666
620996
|
throw retryResult.error;
|
|
@@ -620693,8 +621023,8 @@ var StreamOrchestrator = class {
|
|
|
620693
621023
|
* Handle an error by making a retry decision. Returns either a new result to continue
|
|
620694
621024
|
* with, or the final error to throw.
|
|
620695
621025
|
*/
|
|
620696
|
-
async handleRetryDecision(error40, options8, session, retryEngine, attempts) {
|
|
620697
|
-
const decision = retryEngine.getRetryDecision(error40, session, options8.abortSignal);
|
|
621026
|
+
async handleRetryDecision(error40, options8, session, retryEngine, attempts, waitStateTracker) {
|
|
621027
|
+
const decision = retryEngine.getRetryDecision(error40, session, options8.abortSignal, waitStateTracker.getWaitState());
|
|
620698
621028
|
if (!decision.shouldRetry) {
|
|
620699
621029
|
this.logger.warn(`[orchestrator] Not retrying: reason=${decision.reason}`, getErrorMeta2(error40));
|
|
620700
621030
|
session.finalize("error", error40);
|
|
@@ -620709,17 +621039,17 @@ var StreamOrchestrator = class {
|
|
|
620709
621039
|
await this.switchProvider(session, decision.newProvider, decision.fastFallback === true, error40);
|
|
620710
621040
|
}
|
|
620711
621041
|
session.recordRetry(decision.delayMs);
|
|
620712
|
-
this.logger.warn(`[orchestrator] Retrying in ${decision.delayMs}ms (attempt ${session.attempt})`, getErrorMeta2(error40));
|
|
621042
|
+
this.logger.warn(`[orchestrator] Retrying in ${decision.delayMs}ms (attempt ${session.attempt}) reason=${decision.reason ?? "retry"}`, getErrorMeta2(error40));
|
|
620713
621043
|
await this.delay(decision.delayMs, options8.abortSignal);
|
|
620714
|
-
const newResult = await this.startStreamWithRetry(options8, session, retryEngine, attempts);
|
|
621044
|
+
const newResult = await this.startStreamWithRetry(options8, session, retryEngine, attempts, waitStateTracker);
|
|
620715
621045
|
return { shouldRetry: true, newResult };
|
|
620716
621046
|
}
|
|
620717
|
-
async startStreamWithRetry(options8, session, retryEngine, attempts) {
|
|
621047
|
+
async startStreamWithRetry(options8, session, retryEngine, attempts, waitStateTracker) {
|
|
620718
621048
|
while (true) {
|
|
620719
621049
|
try {
|
|
620720
621050
|
return await this.startStream(options8, session, attempts);
|
|
620721
621051
|
} catch (error40) {
|
|
620722
|
-
const decision = retryEngine.getRetryDecision(error40, session, options8.abortSignal);
|
|
621052
|
+
const decision = retryEngine.getRetryDecision(error40, session, options8.abortSignal, waitStateTracker.getWaitState());
|
|
620723
621053
|
if (!decision.shouldRetry) {
|
|
620724
621054
|
this.logger.error(`[orchestrator] Startup error, not retrying: reason=${decision.reason}`, {
|
|
620725
621055
|
error: {
|
|
@@ -620737,7 +621067,7 @@ var StreamOrchestrator = class {
|
|
|
620737
621067
|
await this.switchProvider(session, decision.newProvider, decision.fastFallback === true, error40);
|
|
620738
621068
|
}
|
|
620739
621069
|
session.recordRetry(decision.delayMs);
|
|
620740
|
-
this.logger.info(`[orchestrator] Startup retry in ${decision.delayMs}ms (attempt ${session.attempt})`);
|
|
621070
|
+
this.logger.info(`[orchestrator] Startup retry in ${decision.delayMs}ms (attempt ${session.attempt}) reason=${decision.reason ?? "retry"}`);
|
|
620741
621071
|
await this.delay(decision.delayMs, options8.abortSignal);
|
|
620742
621072
|
}
|
|
620743
621073
|
}
|
|
@@ -622140,7 +622470,7 @@ function wrapToolsForObservability(tools, tracer4) {
|
|
|
622140
622470
|
|
|
622141
622471
|
// ../../../vite-plugin-file-sync/dist/ai-service/llm/stream/observers/context.js
|
|
622142
622472
|
init_cjs_shims();
|
|
622143
|
-
var
|
|
622473
|
+
var logger16 = getPrefixedLogger("[context-observer]");
|
|
622144
622474
|
var ContextObserver = class {
|
|
622145
622475
|
contextHandle;
|
|
622146
622476
|
released = false;
|
|
@@ -622182,7 +622512,7 @@ var ContextObserver = class {
|
|
|
622182
622512
|
const normalizedMessages = step.response.messages.map((msg) => normalizeToolMessage(stripUndefinedFromToolOutputs(msg)));
|
|
622183
622513
|
const hasReasoning = normalizedMessages.some((msg) => msg.role === "assistant" && typeof msg.content !== "string" && msg.content.some((p3) => p3.type === "reasoning"));
|
|
622184
622514
|
if (hasReasoning && !step.content?.length) {
|
|
622185
|
-
|
|
622515
|
+
logger16.warn("Step has reasoning in response.messages but no step.content for signature backfill");
|
|
622186
622516
|
}
|
|
622187
622517
|
backfillReasoningSignatures(normalizedMessages, step.content ?? []);
|
|
622188
622518
|
await this.contextHandle.context.endStep(normalizedMessages, step.usage);
|
|
@@ -622191,7 +622521,7 @@ var ContextObserver = class {
|
|
|
622191
622521
|
try {
|
|
622192
622522
|
await this.detectCompaction(step);
|
|
622193
622523
|
} catch (err) {
|
|
622194
|
-
|
|
622524
|
+
logger16.error(`detectCompaction threw, ignoring: ${err instanceof Error ? err.message : String(err)}`);
|
|
622195
622525
|
}
|
|
622196
622526
|
}
|
|
622197
622527
|
async onChunk(chunk) {
|
|
@@ -622201,7 +622531,7 @@ var ContextObserver = class {
|
|
|
622201
622531
|
this.contextHandle.context.onServerCompactionStarted();
|
|
622202
622532
|
}
|
|
622203
622533
|
} catch (err) {
|
|
622204
|
-
|
|
622534
|
+
logger16.error(`detectCompactionStart threw, ignoring: ${err instanceof Error ? err.message : String(err)}`);
|
|
622205
622535
|
}
|
|
622206
622536
|
}
|
|
622207
622537
|
async onStreamFinish(result, _session) {
|
|
@@ -622238,7 +622568,7 @@ var ContextObserver = class {
|
|
|
622238
622568
|
const compactedViaIterations = iterations?.some((iter) => iter.type === "compaction");
|
|
622239
622569
|
const compactedViaEdits = appliedEdits?.some((edit) => edit.type === "compact_20260112");
|
|
622240
622570
|
if (compactedViaIterations || compactedViaEdits) {
|
|
622241
|
-
|
|
622571
|
+
logger16.info("Server-side compaction detected in response", {
|
|
622242
622572
|
iterations: iterations?.map((i2) => i2.type),
|
|
622243
622573
|
edits: appliedEdits?.map((e) => e.type)
|
|
622244
622574
|
});
|
|
@@ -622250,7 +622580,7 @@ var ContextObserver = class {
|
|
|
622250
622580
|
}
|
|
622251
622581
|
const clearEdit = appliedEdits?.find((edit) => edit.type === "clear_tool_uses_20250919");
|
|
622252
622582
|
if (clearEdit) {
|
|
622253
|
-
|
|
622583
|
+
logger16.info("Server-side clear_tool_uses applied", {
|
|
622254
622584
|
clearedToolUses: clearEdit.clearedToolUses,
|
|
622255
622585
|
clearedInputTokens: clearEdit.clearedInputTokens
|
|
622256
622586
|
});
|
|
@@ -622873,147 +623203,6 @@ var LLMClient = class {
|
|
|
622873
623203
|
}
|
|
622874
623204
|
};
|
|
622875
623205
|
|
|
622876
|
-
// ../../../vite-plugin-file-sync/dist/ai-service/llm/context-v2/storage/jsonl-event-store.js
|
|
622877
|
-
init_cjs_shims();
|
|
622878
|
-
import { readFile as readFile13, appendFile, mkdir as mkdir13, rm as rm11 } from "node:fs/promises";
|
|
622879
|
-
import * as path46 from "node:path";
|
|
622880
|
-
var logger16 = getPrefixedLogger("[jsonl-event-store]");
|
|
622881
|
-
var JsonlEventStore = class _JsonlEventStore {
|
|
622882
|
-
rootDir;
|
|
622883
|
-
static SUPERBLOCKS_SYSTEM_DIR = ".superblocks";
|
|
622884
|
-
static EVENTS_SUBDIR = "events";
|
|
622885
|
-
constructor(rootDir) {
|
|
622886
|
-
this.rootDir = rootDir;
|
|
622887
|
-
}
|
|
622888
|
-
/**
|
|
622889
|
-
* Append a single event to the log for the given context.
|
|
622890
|
-
*
|
|
622891
|
-
* Creates parent directories if they do not exist. Each call
|
|
622892
|
-
* writes exactly one JSON line terminated by `\n`.
|
|
622893
|
-
*/
|
|
622894
|
-
async appendEvent(id2, event) {
|
|
622895
|
-
const filePath = this.getFilePath(id2);
|
|
622896
|
-
await mkdir13(path46.dirname(filePath), { recursive: true });
|
|
622897
|
-
await appendFile(filePath, JSON.stringify(event) + "\n");
|
|
622898
|
-
}
|
|
622899
|
-
/**
|
|
622900
|
-
* Check whether any events exist for the given context.
|
|
622901
|
-
*/
|
|
622902
|
-
async hasEvents(id2) {
|
|
622903
|
-
try {
|
|
622904
|
-
const content18 = await readFile13(this.getFilePath(id2), "utf-8");
|
|
622905
|
-
return content18.trimEnd().length > 0;
|
|
622906
|
-
} catch (err) {
|
|
622907
|
-
if (err.code === "ENOENT") {
|
|
622908
|
-
return false;
|
|
622909
|
-
}
|
|
622910
|
-
throw err;
|
|
622911
|
-
}
|
|
622912
|
-
}
|
|
622913
|
-
/**
|
|
622914
|
-
* Remove the event log for a single context. Missing files are
|
|
622915
|
-
* treated as success so callers can use this as a fire-and-forget
|
|
622916
|
-
* cleanup step.
|
|
622917
|
-
*/
|
|
622918
|
-
async deleteEvents(id2) {
|
|
622919
|
-
await rm11(this.getFilePath(id2), { force: true });
|
|
622920
|
-
}
|
|
622921
|
-
/**
|
|
622922
|
-
* Remove the entire `.superblocks/events/` tree under `rootDir`.
|
|
622923
|
-
*
|
|
622924
|
-
* Used by clear-all flows so a subsequent `getOrCreateContext` does
|
|
622925
|
-
* not silently restore a "deleted" conversation from disk.
|
|
622926
|
-
*/
|
|
622927
|
-
async deleteAllEvents() {
|
|
622928
|
-
await rm11(this.getEventsRoot(), { recursive: true, force: true });
|
|
622929
|
-
}
|
|
622930
|
-
/**
|
|
622931
|
-
* Load conversation messages by scanning backward for the last
|
|
622932
|
-
* compaction anchor, then reading forward from that point.
|
|
622933
|
-
*
|
|
622934
|
-
* A compaction anchor is either:
|
|
622935
|
-
* - An event with `type === "compaction_received"`
|
|
622936
|
-
* - An event with `_superblocks.isSummary === true` (migration seed)
|
|
622937
|
-
*
|
|
622938
|
-
* Each `EventLogEntry` is mapped to a `StoredMessage` so that
|
|
622939
|
-
* consumers receive the AI SDK `ModelMessage` shape.
|
|
622940
|
-
*/
|
|
622941
|
-
async loadMessages(id2) {
|
|
622942
|
-
const filePath = this.getFilePath(id2);
|
|
622943
|
-
let raw;
|
|
622944
|
-
try {
|
|
622945
|
-
raw = await readFile13(filePath, "utf-8");
|
|
622946
|
-
} catch (err) {
|
|
622947
|
-
if (err.code === "ENOENT") {
|
|
622948
|
-
return [];
|
|
622949
|
-
}
|
|
622950
|
-
throw err;
|
|
622951
|
-
}
|
|
622952
|
-
const lines = raw.split("\n").filter((line3) => line3.length > 0);
|
|
622953
|
-
if (lines.length === 0) {
|
|
622954
|
-
return [];
|
|
622955
|
-
}
|
|
622956
|
-
const contextLabel = `${id2.appId}/${id2.userId}/${id2.name}`;
|
|
622957
|
-
const events = [];
|
|
622958
|
-
let corruptedCount = 0;
|
|
622959
|
-
for (let i2 = 0; i2 < lines.length; i2++) {
|
|
622960
|
-
const line3 = lines[i2];
|
|
622961
|
-
try {
|
|
622962
|
-
events.push(JSON.parse(line3));
|
|
622963
|
-
} catch {
|
|
622964
|
-
corruptedCount++;
|
|
622965
|
-
logger16.warn(`Skipping corrupted JSONL line ${i2} for context '${contextLabel}' (length=${line3.length})`);
|
|
622966
|
-
}
|
|
622967
|
-
}
|
|
622968
|
-
if (corruptedCount > 0) {
|
|
622969
|
-
logger16.warn(`Encountered ${corruptedCount} corrupted line(s) in event log for context '${contextLabel}'; if any held a compaction anchor the loaded window may extend further back than expected.`);
|
|
622970
|
-
}
|
|
622971
|
-
let anchorIndex = -1;
|
|
622972
|
-
for (let i2 = events.length - 1; i2 >= 0; i2--) {
|
|
622973
|
-
const event = events[i2];
|
|
622974
|
-
if (event.type === "compaction_received" || event._superblocks?.isSummary === true) {
|
|
622975
|
-
anchorIndex = i2;
|
|
622976
|
-
break;
|
|
622977
|
-
}
|
|
622978
|
-
}
|
|
622979
|
-
if (anchorIndex < 0 && corruptedCount > 0) {
|
|
622980
|
-
logger16.error(`No compaction anchor found for context '${contextLabel}' but ${corruptedCount} corrupted line(s) were skipped; the loaded conversation window may be unbounded.`);
|
|
622981
|
-
}
|
|
622982
|
-
const window2 = anchorIndex >= 0 ? events.slice(anchorIndex) : events;
|
|
622983
|
-
return window2.map((event) => this.toStoredMessage(event));
|
|
622984
|
-
}
|
|
622985
|
-
/**
|
|
622986
|
-
* Map an EventLogEntry to a StoredMessage (AI SDK ModelMessage shape).
|
|
622987
|
-
*
|
|
622988
|
-
* The cast is required at this JSON deserialization boundary: `content`
|
|
622989
|
-
* is stored as `unknown` because AI SDK content shapes are polymorphic
|
|
622990
|
-
* (string, content part arrays, tool results). The role is type-safe
|
|
622991
|
-
* via `MessageRole`, but TypeScript cannot narrow the discriminated
|
|
622992
|
-
* union without runtime content validation — which would be fragile
|
|
622993
|
-
* against SDK version changes.
|
|
622994
|
-
*/
|
|
622995
|
-
toStoredMessage(event) {
|
|
622996
|
-
return {
|
|
622997
|
-
role: event.role,
|
|
622998
|
-
content: event.content,
|
|
622999
|
-
...event.providerMetadata && {
|
|
623000
|
-
providerMetadata: event.providerMetadata
|
|
623001
|
-
},
|
|
623002
|
-
_superblocks: {
|
|
623003
|
-
timestamp: event.timestamp,
|
|
623004
|
-
...event._superblocks
|
|
623005
|
-
}
|
|
623006
|
-
};
|
|
623007
|
-
}
|
|
623008
|
-
getEventsRoot() {
|
|
623009
|
-
return path46.join(this.rootDir, _JsonlEventStore.SUPERBLOCKS_SYSTEM_DIR, _JsonlEventStore.EVENTS_SUBDIR);
|
|
623010
|
-
}
|
|
623011
|
-
getFilePath(id2) {
|
|
623012
|
-
const root3 = this.getEventsRoot();
|
|
623013
|
-
return safeJoinUnderRoot(root3, encodeContextPathSegment(id2.userId, "userId"), `${encodeContextPathSegment(id2.name, "name")}.jsonl`);
|
|
623014
|
-
}
|
|
623015
|
-
};
|
|
623016
|
-
|
|
623017
623206
|
// ../../../vite-plugin-file-sync/dist/ai-service/llm/provider.js
|
|
623018
623207
|
init_cjs_shims();
|
|
623019
623208
|
|
|
@@ -628249,7 +628438,7 @@ var PlaywrightMcpServerManager = class {
|
|
|
628249
628438
|
this.logger.info(`Starting embedded Playwright MCP server: browser=${options8?.browser || "chromium"}, headless=${options8?.headless !== false}`);
|
|
628250
628439
|
}
|
|
628251
628440
|
try {
|
|
628252
|
-
const { startEmbeddedPlaywrightMcpServer } = await import("./embedded-playwright-mcp-server-
|
|
628441
|
+
const { startEmbeddedPlaywrightMcpServer } = await import("./embedded-playwright-mcp-server-46UEH2AX.js");
|
|
628253
628442
|
this.server = await startEmbeddedPlaywrightMcpServer({
|
|
628254
628443
|
storageStatePath: options8?.storageStatePath,
|
|
628255
628444
|
jwt: options8?.jwt,
|
|
@@ -631555,7 +631744,7 @@ The current mode and plan approval status will be given to you in the <current_m
|
|
|
631555
631744
|
In 'Plan' mode, your goal is to help the user understand and interact with their application, and the data and integrations available to them.
|
|
631556
631745
|
|
|
631557
631746
|
**Plan Mode Behavior:**
|
|
631558
|
-
- **Without approved plan**: You can use read-only tools freely, plus a small set of product-scoped tools \u2014 notably ${config4.features.clarkAttachmentDownloadEnabled ? "`listAttachments` and `downloadAttachments` (which materialize uploaded attachments into a private scratch directory), " : ""}\`exitPlanMode\` (to propose a plan for approval)${config4.features.managedNativeDbEnabled ? ", and the read-only Native DB background-task companions `checkTask` and `waitForTask` (so you can observe progress of any tasks the user started before entering Plan mode)" : ""}, and debug/interactive tools the UI may expose. You cannot otherwise make changes to the user's application files or production data \u2014 including provisioning a dev database or applying SQL migrations, which require an approved plan. Answer questions, provide suggestions, inspect attachments, and when appropriate, present plans using the exitPlanMode tool.
|
|
631747
|
+
- **Without approved plan**: You can use read-only tools freely, plus a small set of product-scoped tools \u2014 notably ${config4.features.clarkAttachmentDownloadEnabled ? "`listAttachments` and `downloadAttachments` (which materialize uploaded attachments into a private scratch directory), " : ""}\`exitPlanMode\` (to propose a plan for approval)${config4.features.managedNativeDbEnabled ? ", and the read-only Native DB background-task companions `checkTask` and `waitForTask` (so you can observe progress of any tasks the user started before entering Plan mode)" : ""}, and debug/interactive tools the UI may expose. You cannot otherwise make changes to the user's application files or production data${config4.features.managedNativeDbEnabled ? " \u2014 including provisioning a dev database or applying SQL migrations, which require an approved plan" : ""}. Answer questions, provide suggestions, inspect attachments, and when appropriate, present plans using the exitPlanMode tool.
|
|
631559
631748
|
- **With approved plan**: When the user accepts one of your plans, you gain access to all tools and can execute the plan by making the necessary changes. You remain in Plan mode throughout execution.
|
|
631560
631749
|
|
|
631561
631750
|
**Integrations:**
|
|
@@ -638506,9 +638695,9 @@ ${request.prompt}`;
|
|
|
638506
638695
|
// ../../../vite-plugin-file-sync/dist/sync-service/index.js
|
|
638507
638696
|
init_cjs_shims();
|
|
638508
638697
|
import { normalizePath as normalizePath8 } from "vite";
|
|
638509
|
-
var import_shared58 = __toESM(require_dist2()
|
|
638510
|
-
var import_shared59 = __toESM(require_dist2()
|
|
638511
|
-
var import_shared60 = __toESM(require_dist2()
|
|
638698
|
+
var import_shared58 = __toESM(require_dist2());
|
|
638699
|
+
var import_shared59 = __toESM(require_dist2());
|
|
638700
|
+
var import_shared60 = __toESM(require_dist2());
|
|
638512
638701
|
|
|
638513
638702
|
// ../../../vite-plugin-file-sync/dist/errors/make-server-error.js
|
|
638514
638703
|
init_cjs_shims();
|
|
@@ -640102,8 +640291,8 @@ var SyncService = class extends import_shared58.TracedEventEmitter {
|
|
|
640102
640291
|
|
|
640103
640292
|
// ../../../vite-plugin-file-sync/dist/lock-service/index.js
|
|
640104
640293
|
init_cjs_shims();
|
|
640105
|
-
var import_shared61 = __toESM(require_dist2()
|
|
640106
|
-
var import_shared62 = __toESM(require_dist2()
|
|
640294
|
+
var import_shared61 = __toESM(require_dist2());
|
|
640295
|
+
var import_shared62 = __toESM(require_dist2());
|
|
640107
640296
|
|
|
640108
640297
|
// ../../../vite-plugin-file-sync/dist/lock-service/activity-tracker.js
|
|
640109
640298
|
init_cjs_shims();
|
|
@@ -664831,7 +665020,7 @@ var parseYaml3;
|
|
|
664831
665020
|
async function loadYaml(file2) {
|
|
664832
665021
|
const content18 = await read_file_default(file2);
|
|
664833
665022
|
if (!parseYaml3) {
|
|
664834
|
-
({ __parsePrettierYamlConfig: parseYaml3 } = await import("./yaml-
|
|
665023
|
+
({ __parsePrettierYamlConfig: parseYaml3 } = await import("./yaml-RNXURET6.js"));
|
|
664835
665024
|
}
|
|
664836
665025
|
try {
|
|
664837
665026
|
return parseYaml3(content18);
|
|
@@ -670225,7 +670414,7 @@ function createParsersAndPrinters(modules) {
|
|
|
670225
670414
|
}
|
|
670226
670415
|
var estreePlugin = createParsersAndPrinters([
|
|
670227
670416
|
{
|
|
670228
|
-
importPlugin: () => import("./estree-
|
|
670417
|
+
importPlugin: () => import("./estree-3ELOGBVO.js"),
|
|
670229
670418
|
printers: ["estree", "estree-json"]
|
|
670230
670419
|
}
|
|
670231
670420
|
]);
|
|
@@ -670249,11 +670438,11 @@ var languages = [
|
|
|
670249
670438
|
];
|
|
670250
670439
|
var { parsers: parsers12, printers } = createParsersAndPrinters([
|
|
670251
670440
|
{
|
|
670252
|
-
importPlugin: () => import("./acorn-
|
|
670441
|
+
importPlugin: () => import("./acorn-OS63BTIP.js"),
|
|
670253
670442
|
parsers: ["acorn", "espree"]
|
|
670254
670443
|
},
|
|
670255
670444
|
{
|
|
670256
|
-
importPlugin: () => import("./angular-
|
|
670445
|
+
importPlugin: () => import("./angular-XRJMPAT5.js"),
|
|
670257
670446
|
parsers: [
|
|
670258
670447
|
"__ng_action",
|
|
670259
670448
|
"__ng_binding",
|
|
@@ -670262,7 +670451,7 @@ var { parsers: parsers12, printers } = createParsersAndPrinters([
|
|
|
670262
670451
|
]
|
|
670263
670452
|
},
|
|
670264
670453
|
{
|
|
670265
|
-
importPlugin: () => import("./babel-
|
|
670454
|
+
importPlugin: () => import("./babel-KABIYOLI.js"),
|
|
670266
670455
|
parsers: [
|
|
670267
670456
|
"babel",
|
|
670268
670457
|
"babel-flow",
|
|
@@ -670281,44 +670470,44 @@ var { parsers: parsers12, printers } = createParsersAndPrinters([
|
|
|
670281
670470
|
]
|
|
670282
670471
|
},
|
|
670283
670472
|
{
|
|
670284
|
-
importPlugin: () => import("./flow-
|
|
670473
|
+
importPlugin: () => import("./flow-WZSRVHZW.js"),
|
|
670285
670474
|
parsers: ["flow"]
|
|
670286
670475
|
},
|
|
670287
670476
|
{
|
|
670288
|
-
importPlugin: () => import("./glimmer-
|
|
670477
|
+
importPlugin: () => import("./glimmer-IMKJRXNH.js"),
|
|
670289
670478
|
parsers: ["glimmer"],
|
|
670290
670479
|
printers: ["glimmer"]
|
|
670291
670480
|
},
|
|
670292
670481
|
{
|
|
670293
|
-
importPlugin: () => import("./graphql-
|
|
670482
|
+
importPlugin: () => import("./graphql-NXAASEI3.js"),
|
|
670294
670483
|
parsers: ["graphql"],
|
|
670295
670484
|
printers: ["graphql"]
|
|
670296
670485
|
},
|
|
670297
670486
|
{
|
|
670298
|
-
importPlugin: () => import("./html-
|
|
670487
|
+
importPlugin: () => import("./html-73R3X3I4.js"),
|
|
670299
670488
|
parsers: ["html", "angular", "vue", "lwc", "mjml"],
|
|
670300
670489
|
printers: ["html"]
|
|
670301
670490
|
},
|
|
670302
670491
|
{
|
|
670303
|
-
importPlugin: () => import("./markdown-
|
|
670492
|
+
importPlugin: () => import("./markdown-5NVT32YM.js"),
|
|
670304
670493
|
parsers: ["markdown", "mdx", "remark"],
|
|
670305
670494
|
printers: ["mdast"]
|
|
670306
670495
|
},
|
|
670307
670496
|
{
|
|
670308
|
-
importPlugin: () => import("./meriyah-
|
|
670497
|
+
importPlugin: () => import("./meriyah-5HLBX7QE.js"),
|
|
670309
670498
|
parsers: ["meriyah"]
|
|
670310
670499
|
},
|
|
670311
670500
|
{
|
|
670312
|
-
importPlugin: () => import("./postcss-
|
|
670501
|
+
importPlugin: () => import("./postcss-RGXOH323.js"),
|
|
670313
670502
|
parsers: ["css", "less", "scss"],
|
|
670314
670503
|
printers: ["postcss"]
|
|
670315
670504
|
},
|
|
670316
670505
|
{
|
|
670317
|
-
importPlugin: () => import("./typescript-
|
|
670506
|
+
importPlugin: () => import("./typescript-HJJCNM6Y.js"),
|
|
670318
670507
|
parsers: ["typescript"]
|
|
670319
670508
|
},
|
|
670320
670509
|
{
|
|
670321
|
-
importPlugin: () => import("./yaml-
|
|
670510
|
+
importPlugin: () => import("./yaml-RNXURET6.js"),
|
|
670322
670511
|
parsers: ["yaml"],
|
|
670323
670512
|
printers: ["yaml"]
|
|
670324
670513
|
}
|
|
@@ -676965,6 +677154,7 @@ var vite_plugin_optimize_lucide_imports_default = createLucideReactImportOptimiz
|
|
|
676965
677154
|
// ../sdk/dist/vite-plugin-sdk-api-entry-point.mjs
|
|
676966
677155
|
init_cjs_shims();
|
|
676967
677156
|
import path66 from "node:path";
|
|
677157
|
+
var SERVER_APIS_DIR = "server/apis";
|
|
676968
677158
|
function buildPrependMappings(prependLineCount, originalLineCount) {
|
|
676969
677159
|
const empty3 = ";".repeat(prependLineCount);
|
|
676970
677160
|
if (originalLineCount === 0)
|
|
@@ -676972,16 +677162,57 @@ function buildPrependMappings(prependLineCount, originalLineCount) {
|
|
|
676972
677162
|
const original = ["AAAA"].concat(Array(Math.max(0, originalLineCount - 1)).fill("AACA")).join(";");
|
|
676973
677163
|
return empty3 + original;
|
|
676974
677164
|
}
|
|
676975
|
-
function
|
|
677165
|
+
function qualifyAnchoredServerApisRelative(relative15) {
|
|
677166
|
+
if (relative15 === `${SERVER_APIS_DIR}/index.ts`) {
|
|
677167
|
+
return null;
|
|
677168
|
+
}
|
|
677169
|
+
const baseName = path66.posix.basename(relative15);
|
|
677170
|
+
if (baseName === "index.ts") {
|
|
677171
|
+
return null;
|
|
677172
|
+
}
|
|
677173
|
+
if (!relative15.endsWith(".ts") && !relative15.endsWith(".tsx")) {
|
|
677174
|
+
return null;
|
|
677175
|
+
}
|
|
677176
|
+
return relative15;
|
|
677177
|
+
}
|
|
677178
|
+
function qualifySegmentFallbackRelative(relative15) {
|
|
677179
|
+
if (!relative15.startsWith(`${SERVER_APIS_DIR}/`)) {
|
|
677180
|
+
return null;
|
|
677181
|
+
}
|
|
677182
|
+
if (relative15.includes("/client/")) {
|
|
677183
|
+
return null;
|
|
677184
|
+
}
|
|
677185
|
+
const baseName = path66.posix.basename(relative15);
|
|
677186
|
+
if (baseName !== "api.ts" && baseName !== "api.tsx") {
|
|
677187
|
+
return null;
|
|
677188
|
+
}
|
|
677189
|
+
return relative15;
|
|
677190
|
+
}
|
|
677191
|
+
function resolveSdkApiEntryPointRelativePath(appRootDir, moduleId) {
|
|
677192
|
+
const normalizedId = path66.normalize(moduleId);
|
|
677193
|
+
const normalizedRoot = path66.normalize(appRootDir);
|
|
677194
|
+
const relative15 = path66.relative(normalizedRoot, normalizedId).replace(/\\/g, "/");
|
|
677195
|
+
if (relative15.startsWith(`${SERVER_APIS_DIR}/`)) {
|
|
677196
|
+
return qualifyAnchoredServerApisRelative(relative15);
|
|
677197
|
+
}
|
|
677198
|
+
if (relative15.startsWith(`../${SERVER_APIS_DIR}/`)) {
|
|
677199
|
+
return qualifyAnchoredServerApisRelative(relative15.slice("../".length));
|
|
677200
|
+
}
|
|
677201
|
+
const posixId = normalizedId.replace(/\\/g, "/");
|
|
677202
|
+
const segment2 = `/${SERVER_APIS_DIR}/`;
|
|
677203
|
+
const segmentIndex = posixId.lastIndexOf(segment2);
|
|
677204
|
+
if (segmentIndex !== -1) {
|
|
677205
|
+
return qualifySegmentFallbackRelative(posixId.slice(segmentIndex + 1));
|
|
677206
|
+
}
|
|
677207
|
+
return null;
|
|
677208
|
+
}
|
|
677209
|
+
function sdkApiEntryPointPlugin(appRootDir) {
|
|
676976
677210
|
return {
|
|
676977
677211
|
name: "sb-sdk-api-entry-point",
|
|
676978
677212
|
enforce: "pre",
|
|
676979
677213
|
transform(code, id2) {
|
|
676980
|
-
const relative15 =
|
|
676981
|
-
if (!relative15
|
|
676982
|
-
return null;
|
|
676983
|
-
}
|
|
676984
|
-
if (!relative15.endsWith(".ts") && !relative15.endsWith(".tsx")) {
|
|
677214
|
+
const relative15 = resolveSdkApiEntryPointRelativePath(appRootDir, id2);
|
|
677215
|
+
if (!relative15) {
|
|
676985
677216
|
return null;
|
|
676986
677217
|
}
|
|
676987
677218
|
const prependLines = [
|
|
@@ -688060,7 +688291,7 @@ async function handleLockConflict(error40, lockSvc, span, logger22) {
|
|
|
688060
688291
|
}
|
|
688061
688292
|
async function readPkgJson(cwd) {
|
|
688062
688293
|
try {
|
|
688063
|
-
const { readPackage } = await import("./read-pkg-
|
|
688294
|
+
const { readPackage } = await import("./read-pkg-BUJFLEXQ.js");
|
|
688064
688295
|
return await readPackage({ cwd });
|
|
688065
688296
|
} catch {
|
|
688066
688297
|
return null;
|
|
@@ -689751,4 +689982,4 @@ serve-static/index.js:
|
|
|
689751
689982
|
chokidar/esm/index.js:
|
|
689752
689983
|
(*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) *)
|
|
689753
689984
|
*/
|
|
689754
|
-
//# sourceMappingURL=chunk-
|
|
689985
|
+
//# sourceMappingURL=chunk-TOZ7A6XG.js.map
|