@moldea.ai/cli 13.0.4 → 14.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,170 @@
1
+ import { n as e } from "./chunk-2cc3bf5c.mjs";
2
+ import { u as t } from "./chunk-8f198616.mjs";
3
+ import { i as n } from "./chunk-98d84174.mjs";
4
+ import { a as r, c as i, i as a, l as o, o as s, s as c, t as l } from "./chunk-24ea7c23.mjs";
5
+ import { a as u, i as d, n as f, r as p } from "./chunk-2e9d4c63.mjs";
6
+ import { parentPort as m, workerData as h } from "node:worker_threads";
7
+ import { getHeapStatistics as g } from "node:v8";
8
+ //#region ../core/dist/analysis-worker.js
9
+ var _ = m;
10
+ if (_ === null) throw r();
11
+ var v = s(h);
12
+ if (v.kind !== "start") throw r();
13
+ var y = v.attemptId, b = g().heap_size_limit, x, S = !1, C = !1, w = 0, T = new Map(), E = (e) => {
14
+ _.postMessage(i(e));
15
+ }, D = (t) => {
16
+ if (T.size >= 4) return Promise.reject(new e({
17
+ code: "RESOURCE_LIMIT_EXCEEDED",
18
+ operation: "create-project-inspection",
19
+ limit: "maxReaderRequests",
20
+ limitMaximum: 4,
21
+ observedUsage: T.size + 1,
22
+ nextAction: null
23
+ }));
24
+ let n = w++;
25
+ return new Promise((e, i) => {
26
+ T.set(n, {
27
+ resolve: e,
28
+ reject: i
29
+ });
30
+ try {
31
+ E({
32
+ attemptId: y,
33
+ kind: "reader-request",
34
+ requestId: n,
35
+ request: t
36
+ });
37
+ } catch (e) {
38
+ T.delete(n), i(e instanceof Error ? e : r(e));
39
+ }
40
+ });
41
+ }, O = (e, t) => ({
42
+ snapshot: t,
43
+ getEntry: async (t) => f(await D({
44
+ method: "getEntry",
45
+ path: t,
46
+ source: e
47
+ })),
48
+ listEntriesPage: async (t) => e === "repository" ? p(await D({
49
+ method: "listEntriesPage",
50
+ maxEntries: Math.min(128, t.maxEntries),
51
+ ...t.cursor === void 0 ? {} : { cursor: t.cursor },
52
+ ...t.prefix === void 0 ? {} : { prefix: t.prefix }
53
+ })) : Promise.reject(new n({
54
+ code: "SOURCE_UNAVAILABLE",
55
+ operation: "list-entries-page",
56
+ path: null,
57
+ retryable: !1
58
+ })),
59
+ readFilePage: async (t, n) => d(await D({
60
+ method: "readFilePage",
61
+ path: t,
62
+ offset: n.offset,
63
+ maxBytes: Math.min(l, n.maxBytes),
64
+ source: e
65
+ })),
66
+ readLinkText: async (t) => u(await D({
67
+ method: "readLinkText",
68
+ path: t,
69
+ source: e
70
+ })),
71
+ compare: () => Promise.reject(new n({
72
+ code: "SOURCE_UNAVAILABLE",
73
+ operation: "create-comparison",
74
+ path: null,
75
+ retryable: !1
76
+ }))
77
+ }), k = O("repository", v.snapshot), A = v.instructions === null ? null : O("instructions", v.instructions.snapshot), j = async () => {
78
+ let { createCore: e } = await import("./chunk-1306b995.mjs").then((e) => e.t);
79
+ x = await e(t({ limits: {
80
+ ...v.limits,
81
+ maxRetainedBytes: v.limits.maxRetainedBytes - a
82
+ } })).createProjectInspection({
83
+ repository: k,
84
+ ...A === null ? {} : { instructions: A }
85
+ });
86
+ let n = {
87
+ source: x.source,
88
+ formatVersion: x.formatVersion,
89
+ valid: x.valid,
90
+ counts: x.counts,
91
+ coverageCounts: x.coverageCounts,
92
+ summary: x.summary,
93
+ resourceUsage: x.resourceUsage,
94
+ inspectionDigest: x.inspectionDigest
95
+ };
96
+ E({
97
+ attemptId: y,
98
+ kind: "prepared",
99
+ inspection: {
100
+ ...n,
101
+ maxAnalysisHeapBytes: b,
102
+ resourceUsage: {
103
+ ...n.resourceUsage,
104
+ retainedBytes: n.resourceUsage.retainedBytes + a,
105
+ peakRetainedBytes: n.resourceUsage.peakRetainedBytes + a
106
+ }
107
+ }
108
+ });
109
+ }, M = (t) => {
110
+ try {
111
+ let n = o(t);
112
+ t instanceof e && t.code === "RESOURCE_LIMIT_EXCEEDED" && t.limit === "maxRetainedBytes" && t.observedUsage !== null && (n.options.limitMaximum = v.limits.maxRetainedBytes, n.options.observedUsage = t.observedUsage + a), E({
113
+ attemptId: y,
114
+ kind: "failure",
115
+ failure: n
116
+ });
117
+ } catch {
118
+ _.close();
119
+ }
120
+ };
121
+ _.on("message", (t) => {
122
+ try {
123
+ let n = s(t);
124
+ if (n.attemptId !== y) throw r();
125
+ if (n.kind === "run") {
126
+ if (S) throw r();
127
+ S = !0, j().catch(M);
128
+ } else if (n.kind === "reader-response" || n.kind === "reader-failure") {
129
+ let e = T.get(n.requestId);
130
+ if (e === void 0) throw r();
131
+ T.delete(n.requestId), n.kind === "reader-failure" ? e.reject(c(n.failure)) : e.resolve(n.result);
132
+ } else if (n.kind === "read-page") {
133
+ if (x === void 0 || C) throw r();
134
+ C = !0;
135
+ try {
136
+ if (n.input.maxItems > v.limits.maxEntries) throw new e({
137
+ code: "INVALID_ARGUMENT",
138
+ operation: "create-project-inspection"
139
+ });
140
+ let t = Math.min(256, n.input.maxItems);
141
+ for (;;) try {
142
+ let e = i({
143
+ attemptId: y,
144
+ kind: "page",
145
+ requestId: n.requestId,
146
+ result: x.readPage({
147
+ ...n.input,
148
+ maxItems: t
149
+ })
150
+ });
151
+ _.postMessage(e);
152
+ break;
153
+ } catch (n) {
154
+ if (!(n instanceof e) || n.code !== "RESOURCE_LIMIT_EXCEEDED" || n.limit !== "maxInspectionMessageBytes" || t === 1) throw n;
155
+ t = Math.max(1, Math.floor(t / 2));
156
+ }
157
+ } finally {
158
+ C = !1;
159
+ }
160
+ } else throw r();
161
+ } catch (e) {
162
+ M(e);
163
+ }
164
+ }), _.on("messageerror", M), E({
165
+ attemptId: y,
166
+ kind: "ready",
167
+ maxAnalysisHeapBytes: b
168
+ });
169
+ //#endregion
170
+ export {};
@@ -0,0 +1,2 @@
1
+ import { t as e } from "./chunk-9e42770a.mjs";
2
+ export { e as t };
@@ -0,0 +1,328 @@
1
+ import { a as e, i as t, n, o as r, r as i, t as a, u as o } from "./chunk-2cc3bf5c.mjs";
2
+ import { c as s, i as c, r as l } from "./chunk-98d84174.mjs";
3
+ import { Buffer as u } from "node:buffer";
4
+ //#region ../core/dist/chunks/errors-C5qcq3E0.js
5
+ var d = 12e4, f = 1e3, p = 65536, m = 1048576, h = 32768, g = 4 * m * 2 * 2 * 3;
6
+ Object.freeze({
7
+ lifetimeMs: d,
8
+ terminationGraceMs: f,
9
+ maxReaderRequests: 4,
10
+ maxFilePageBytes: p,
11
+ maxMessageBytes: m,
12
+ maxStdioBytes: h,
13
+ transportBytes: g,
14
+ oldGenerationMiB: 512,
15
+ youngGenerationMiB: 24
16
+ });
17
+ var _ = (e) => new n({
18
+ code: "INSPECTION_PROCESS_FAILED",
19
+ operation: "create-project-inspection",
20
+ ...e === void 0 ? {} : { cause: e }
21
+ }), v = (e) => typeof e == "number" && Number.isSafeInteger(e) && e >= 0, y = (e, t, n = []) => t.every((t) => Object.hasOwn(e, t)) && Object.keys(e).every((e) => t.includes(e) || n.includes(e)), b = (e) => o(e, !0) && y(e, ["id", "sourceKind"]) && typeof e.id == "string" && e.id.length > 0 && typeof e.sourceKind == "string" && e.sourceKind.length > 0, x = (e, t) => !Object.hasOwn(e, t) || typeof e[t] == "string", S = (e) => o(e, !0) && y(e, ["maxItems", "view"], ["cursor"]) && v(e.maxItems) && e.maxItems > 0 && [
22
+ "all",
23
+ "diagnostics",
24
+ "coverage",
25
+ "metadata"
26
+ ].includes(String(e.view)) && x(e, "cursor"), C = (e) => o(e, !0) && y(e, [
27
+ "maxEntries",
28
+ "maxTotalBytesRead",
29
+ "maxFileBytes",
30
+ "maxManifestBytes",
31
+ "maxRetainedBytes",
32
+ "maxDiagnostics",
33
+ "maxCoverage",
34
+ "maxAcceptedWarnings"
35
+ ]) && Object.values(e).every((e) => v(e) && e > 0), w = (e) => o(e, !0) && y(e, [
36
+ "agents",
37
+ "context",
38
+ "decisions",
39
+ "mirrors",
40
+ "diagnostics",
41
+ "errors",
42
+ "warnings",
43
+ "acceptedWarnings",
44
+ "coverage",
45
+ "metadata"
46
+ ]) && Object.values(e).every(v), T = (e) => e === null || o(e, !0) && y(e, [
47
+ "counts",
48
+ "manifestDigest",
49
+ "manifestPath",
50
+ "projectDigest",
51
+ "projectPath"
52
+ ]) && o(e.counts, !0) && y(e.counts, [
53
+ "agents",
54
+ "context",
55
+ "decisions",
56
+ "mirrors"
57
+ ]) && Object.values(e.counts).every(v) && typeof e.manifestDigest == "string" && typeof e.projectDigest == "string" && s(e.manifestPath) && s(e.projectPath), E = (e) => w(e.counts) && o(e.coverageCounts, !0) && y(e.coverageCounts, [
58
+ "bindings",
59
+ "exportsPassed",
60
+ "exportsFailed",
61
+ "exportsNotChecked"
62
+ ]) && Object.values(e.coverageCounts).every(v) && typeof e.valid == "boolean" && (e.formatVersion === null || e.formatVersion === 1) && typeof e.inspectionDigest == "string" && b(e.source) && T(e.summary), D = [
63
+ "counts",
64
+ "coverageCounts",
65
+ "valid",
66
+ "formatVersion",
67
+ "inspectionDigest",
68
+ "source",
69
+ "summary"
70
+ ], O = (e) => o(e, !0) && y(e, [
71
+ ...D,
72
+ "resourceUsage",
73
+ "maxAnalysisHeapBytes"
74
+ ]) && E(e) && v(e.maxAnalysisHeapBytes) && e.maxAnalysisHeapBytes > 0 && o(e.resourceUsage, !0) && y(e.resourceUsage, [
75
+ "canonicalBytes",
76
+ "peakRetainedBytes",
77
+ "preparedBytes",
78
+ "retainedBytes",
79
+ "totalBytesRead"
80
+ ]) && Object.values(e.resourceUsage).every(v), k = (e) => o(e, !0) && y(e, [
81
+ ...D,
82
+ "page",
83
+ "view"
84
+ ]) && E(e) && [
85
+ "all",
86
+ "diagnostics",
87
+ "coverage",
88
+ "metadata"
89
+ ].includes(String(e.view)) && o(e.page, !0) && y(e.page, [
90
+ "isComplete",
91
+ "records",
92
+ "nextCursor",
93
+ "totalItems"
94
+ ]) && typeof e.page.isComplete == "boolean" && v(e.page.totalItems) && (e.page.nextCursor === null || typeof e.page.nextCursor == "string") && Array.isArray(e.page.records) && e.page.records.every((e) => o(e, !0) && y(e, ["item", "nextCursor"]) && (e.nextCursor === null || typeof e.nextCursor == "string") && o(e.item, !0) && typeof e.item.kind == "string" && [
95
+ "agent",
96
+ "diagnostic",
97
+ "coverage",
98
+ "metadata"
99
+ ].includes(e.item.kind) && y(e.item, ["kind", e.item.kind]) && o(e.item[e.item.kind], !0)), A = (e) => e === "instructions" || e === "repository", j = (e) => s(e.path) && v(e.offset) && v(e.maxBytes) && e.maxBytes > 0 && e.maxBytes <= 65536, M = (e) => e === null || o(e, !0) && y(e, ["snapshot"]) && b(e.snapshot), N = (e) => {
100
+ if (!o(e, !0)) return !1;
101
+ switch (e.method) {
102
+ case "getEntry":
103
+ case "readLinkText": return y(e, [
104
+ "method",
105
+ "path",
106
+ "source"
107
+ ]) && s(e.path) && A(e.source);
108
+ case "listEntriesPage": return y(e, ["method", "maxEntries"], ["cursor", "prefix"]) && v(e.maxEntries) && e.maxEntries > 0 && e.maxEntries <= 128 && x(e, "cursor") && (!Object.hasOwn(e, "prefix") || s(e.prefix));
109
+ case "readFilePage": return y(e, [
110
+ "method",
111
+ "path",
112
+ "maxBytes",
113
+ "offset",
114
+ "source"
115
+ ]) && A(e.source) && j(e);
116
+ default: return !1;
117
+ }
118
+ }, P = (e) => {
119
+ if (!o(e, !0) || typeof e.attemptId != "string" || !/^[a-f0-9]{32}$/.test(e.attemptId)) return !1;
120
+ let t = ["attemptId", "kind"];
121
+ switch (e.kind) {
122
+ case "start": return y(e, [
123
+ ...t,
124
+ "snapshot",
125
+ "instructions",
126
+ "limits",
127
+ "deadline"
128
+ ]) && b(e.snapshot) && M(e.instructions) && C(e.limits) && v(e.deadline);
129
+ case "ready": return y(e, [...t, "maxAnalysisHeapBytes"]) && v(e.maxAnalysisHeapBytes) && e.maxAnalysisHeapBytes > 0;
130
+ case "run":
131
+ case "dispose": return y(e, t);
132
+ case "prepared": return y(e, [...t, "inspection"]) && O(e.inspection);
133
+ case "read-page": return y(e, [
134
+ ...t,
135
+ "requestId",
136
+ "input"
137
+ ]) && v(e.requestId) && S(e.input);
138
+ case "page": return y(e, [
139
+ ...t,
140
+ "requestId",
141
+ "result"
142
+ ]) && v(e.requestId) && k(e.result);
143
+ case "reader-request": return y(e, [
144
+ ...t,
145
+ "requestId",
146
+ "request"
147
+ ]) && v(e.requestId) && N(e.request);
148
+ case "reader-response": return y(e, [
149
+ ...t,
150
+ "requestId",
151
+ "result"
152
+ ]) && v(e.requestId);
153
+ case "reader-failure":
154
+ case "failure": return y(e, [
155
+ ...t,
156
+ "failure",
157
+ ...e.kind === "reader-failure" ? ["requestId"] : []
158
+ ]) && (e.kind !== "reader-failure" || v(e.requestId)) && o(e.failure, !0) && y(e.failure, ["family", "options"]) && [
159
+ "configuration",
160
+ "operation",
161
+ "repository",
162
+ "path"
163
+ ].includes(String(e.failure.family)) && o(e.failure.options, !0);
164
+ default: return !1;
165
+ }
166
+ }, F = (e) => {
167
+ let t;
168
+ try {
169
+ t = r(e, m);
170
+ } catch (e) {
171
+ throw _(e);
172
+ }
173
+ if (t > 1048576) throw new n({
174
+ code: "RESOURCE_LIMIT_EXCEEDED",
175
+ limit: "maxInspectionMessageBytes",
176
+ limitMaximum: m,
177
+ observedUsage: t,
178
+ nextAction: null,
179
+ operation: "create-project-inspection"
180
+ });
181
+ if (!P(e)) throw _();
182
+ return JSON.stringify(e);
183
+ }, I = (e) => {
184
+ if (typeof e != "string" || u.byteLength(e) > 1048576) throw _();
185
+ let t;
186
+ try {
187
+ t = JSON.parse(e);
188
+ } catch (e) {
189
+ throw _(e);
190
+ }
191
+ if (!P(t)) throw _();
192
+ return t;
193
+ }, L = (e) => e instanceof a ? {
194
+ family: "configuration",
195
+ options: {
196
+ code: e.code,
197
+ operation: e.operation
198
+ }
199
+ } : e instanceof n ? {
200
+ family: "operation",
201
+ options: {
202
+ code: e.code,
203
+ operation: e.operation,
204
+ ...e.code === "RESOURCE_LIMIT_EXCEEDED" ? {
205
+ limit: e.limit,
206
+ limitMaximum: e.limitMaximum,
207
+ nextAction: e.nextAction,
208
+ observedUsage: e.observedUsage
209
+ } : {}
210
+ }
211
+ } : e instanceof l ? {
212
+ family: "path",
213
+ options: {}
214
+ } : e instanceof c ? {
215
+ family: "repository",
216
+ options: {
217
+ code: e.code,
218
+ operation: e.operation,
219
+ path: e.path,
220
+ retryable: e.retryable,
221
+ ...e.resource === null ? {} : { resource: e.resource }
222
+ }
223
+ } : {
224
+ family: "operation",
225
+ options: {
226
+ code: "INSPECTION_PROCESS_FAILED",
227
+ operation: "create-project-inspection"
228
+ }
229
+ }, R = [
230
+ "ENTRY_NOT_FOUND",
231
+ "ENTRY_NOT_FILE",
232
+ "ENTRY_NOT_DIRECTORY",
233
+ "INVALID_PAGE_REQUEST",
234
+ "ACCESS_DENIED",
235
+ "SOURCE_UNAVAILABLE",
236
+ "SNAPSHOT_CHANGED",
237
+ "PROVIDER_INCOMPLETE",
238
+ "INVALID_SOURCE_DATA",
239
+ "RESOURCE_LIMIT_EXCEEDED",
240
+ "ABORTED"
241
+ ], z = [
242
+ "create-reader",
243
+ "create-comparison",
244
+ "get-entry",
245
+ "read-file-page",
246
+ "list-entries-page",
247
+ "list-changes-page"
248
+ ], B = (e) => typeof e == "number" && Number.isSafeInteger(e) && e >= 0, V = (r) => {
249
+ let o = r.options, u = r.family === "configuration" ? ["code", "operation"] : r.family === "operation" ? [
250
+ "code",
251
+ "operation",
252
+ "limit",
253
+ "limitMaximum",
254
+ "nextAction",
255
+ "observedUsage"
256
+ ] : r.family === "repository" ? [
257
+ "code",
258
+ "operation",
259
+ "path",
260
+ "retryable",
261
+ "resource"
262
+ ] : [];
263
+ if (Object.keys(o).some((e) => !u.includes(e)) || (r.family === "operation" || r.family === "configuration") && !t(o.operation)) throw _();
264
+ let d = { operation: t(o.operation) ? o.operation : "create-project-inspection" };
265
+ if (r.family === "path" && Object.keys(o).length === 0) return new l();
266
+ if (r.family === "configuration") {
267
+ let e = o.code;
268
+ if (i(e)) return new a({
269
+ ...d,
270
+ code: e
271
+ });
272
+ }
273
+ if (r.family === "operation") {
274
+ let t = o.code;
275
+ if (e(t) && t !== "RESOURCE_LIMIT_EXCEEDED" && ![
276
+ "limit",
277
+ "limitMaximum",
278
+ "nextAction",
279
+ "observedUsage"
280
+ ].some((e) => Object.hasOwn(o, e))) return new n({
281
+ ...d,
282
+ code: t
283
+ });
284
+ if (o.code === "RESOURCE_LIMIT_EXCEEDED" && B(o.limitMaximum) && o.limitMaximum > 0) {
285
+ if (o.limit === "maxAnalysisHeapBytes" && o.nextAction === "review-inspection-capacity" && o.observedUsage === null) return new n({
286
+ ...d,
287
+ code: "RESOURCE_LIMIT_EXCEEDED",
288
+ limit: "maxAnalysisHeapBytes",
289
+ limitMaximum: o.limitMaximum,
290
+ observedUsage: null,
291
+ nextAction: "review-inspection-capacity"
292
+ });
293
+ if ((o.limit === "maxInspectionMessageBytes" || o.limit === "maxReaderRequests") && o.nextAction === null && B(o.observedUsage)) return new n({
294
+ ...d,
295
+ code: "RESOURCE_LIMIT_EXCEEDED",
296
+ limit: o.limit,
297
+ limitMaximum: o.limitMaximum,
298
+ nextAction: null,
299
+ observedUsage: o.observedUsage
300
+ });
301
+ if (typeof o.limit == "string" && ![
302
+ "maxAnalysisHeapBytes",
303
+ "maxInspectionMessageBytes",
304
+ "maxReaderRequests"
305
+ ].includes(o.limit) && o.nextAction === "reduce-input-or-increase-limit" && B(o.observedUsage)) return new n({
306
+ ...d,
307
+ code: "RESOURCE_LIMIT_EXCEEDED",
308
+ limit: o.limit,
309
+ limitMaximum: o.limitMaximum,
310
+ nextAction: "reduce-input-or-increase-limit",
311
+ observedUsage: o.observedUsage
312
+ });
313
+ }
314
+ }
315
+ if (r.family === "repository") {
316
+ let e = R.find((e) => e === o.code), t = z.find((e) => e === o.operation), n = o.resource;
317
+ if (e !== void 0 && t !== void 0 && typeof o.retryable == "boolean" && (o.path === null || s(o.path)) && (n === void 0 || typeof n == "object" && n && Object.keys(n).length === 3 && "dimension" in n && typeof n.dimension == "string" && "limit" in n && B(n.limit) && "observed" in n && B(n.observed))) return new c({
318
+ code: e,
319
+ operation: t,
320
+ path: o.path,
321
+ retryable: o.retryable,
322
+ ...n === void 0 ? {} : { resource: n }
323
+ });
324
+ }
325
+ throw _();
326
+ };
327
+ //#endregion
328
+ export { _ as a, F as c, g as i, L as l, d as n, I as o, f as r, V as s, p as t };