@debugbundle/cli 1.19.3 → 1.20.0
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 +9 -0
- package/dist/main.cjs +405 -250
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -54373,6 +54373,25 @@ var PublicStatusOptionsSchema = external_exports.object({
|
|
|
54373
54373
|
next_cursor: external_exports.string().guid().nullable()
|
|
54374
54374
|
}).strict();
|
|
54375
54375
|
|
|
54376
|
+
// ../../packages/shared-types/src/alert-scope.ts
|
|
54377
|
+
var ALERT_SCOPE_SERVICE_LIMIT = 100;
|
|
54378
|
+
var ScopeServiceSchema = external_exports.object({
|
|
54379
|
+
service_definition_id: external_exports.string().guid(),
|
|
54380
|
+
name: external_exports.string().min(1)
|
|
54381
|
+
}).strict();
|
|
54382
|
+
var AlertScopeSchema = external_exports.object({
|
|
54383
|
+
origin_project_ids: external_exports.array(external_exports.string().guid()).min(1).max(1e3),
|
|
54384
|
+
covers_current_project: external_exports.boolean(),
|
|
54385
|
+
services: external_exports.array(ScopeServiceSchema).max(ALERT_SCOPE_SERVICE_LIMIT),
|
|
54386
|
+
service_count: external_exports.number().int().min(0),
|
|
54387
|
+
service_filter: ScopeServiceSchema.extend({
|
|
54388
|
+
service_id: external_exports.string().guid(),
|
|
54389
|
+
environment: external_exports.string().min(1)
|
|
54390
|
+
}).nullable()
|
|
54391
|
+
}).strict().refine((scope) => scope.service_count >= scope.services.length, {
|
|
54392
|
+
message: "scope_service_count_invalid"
|
|
54393
|
+
});
|
|
54394
|
+
|
|
54376
54395
|
// ../../packages/shared-types/src/index.ts
|
|
54377
54396
|
var SeveritySchema = external_exports.enum(["low", "medium", "high", "critical"]);
|
|
54378
54397
|
var BundleSdkSchema = external_exports.object({
|
|
@@ -54914,12 +54933,15 @@ var RetrievalApiError = class extends Error {
|
|
|
54914
54933
|
this.code = code;
|
|
54915
54934
|
}
|
|
54916
54935
|
};
|
|
54917
|
-
var
|
|
54918
|
-
function
|
|
54919
|
-
const parsed =
|
|
54920
|
-
if (!parsed.success) throw new RetrievalApiError(400,
|
|
54936
|
+
var ResourceIdSchema = external_exports.string().max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
|
|
54937
|
+
function parseResourceId(value, code) {
|
|
54938
|
+
const parsed = ResourceIdSchema.safeParse(value);
|
|
54939
|
+
if (!parsed.success) throw new RetrievalApiError(400, code);
|
|
54921
54940
|
return parsed.data;
|
|
54922
54941
|
}
|
|
54942
|
+
function parseIncidentId(value) {
|
|
54943
|
+
return parseResourceId(value, "invalid_incident_id");
|
|
54944
|
+
}
|
|
54923
54945
|
function parseApiError(status, body) {
|
|
54924
54946
|
const parsed = ApiErrorResponseSchema.safeParse(body);
|
|
54925
54947
|
if (!parsed.success) {
|
|
@@ -55195,7 +55217,7 @@ function createRetrievalApi(client) {
|
|
|
55195
55217
|
const parsed = await expectParsed(
|
|
55196
55218
|
client.request({
|
|
55197
55219
|
method: "GET",
|
|
55198
|
-
path: `/v1/improvements/${input3.improvementId}`,
|
|
55220
|
+
path: `/v1/improvements/${encodeURIComponent(parseResourceId(input3.improvementId, "invalid_improvement_id"))}`,
|
|
55199
55221
|
bearerToken: input3.bearerToken
|
|
55200
55222
|
}),
|
|
55201
55223
|
ImprovementResponseSchema
|
|
@@ -55206,7 +55228,7 @@ function createRetrievalApi(client) {
|
|
|
55206
55228
|
const parsed = await expectMutation(
|
|
55207
55229
|
client.request({
|
|
55208
55230
|
method: "POST",
|
|
55209
|
-
path: `/v1/improvements/${input3.improvementId}/resolve`,
|
|
55231
|
+
path: `/v1/improvements/${encodeURIComponent(parseResourceId(input3.improvementId, "invalid_improvement_id"))}/resolve`,
|
|
55210
55232
|
bearerToken: input3.bearerToken
|
|
55211
55233
|
}),
|
|
55212
55234
|
ImprovementResponseSchema
|
|
@@ -55217,7 +55239,7 @@ function createRetrievalApi(client) {
|
|
|
55217
55239
|
const parsed = await expectMutation(
|
|
55218
55240
|
client.request({
|
|
55219
55241
|
method: "POST",
|
|
55220
|
-
path: `/v1/improvements/${input3.improvementId}/reopen`,
|
|
55242
|
+
path: `/v1/improvements/${encodeURIComponent(parseResourceId(input3.improvementId, "invalid_improvement_id"))}/reopen`,
|
|
55221
55243
|
bearerToken: input3.bearerToken
|
|
55222
55244
|
}),
|
|
55223
55245
|
ImprovementResponseSchema
|
|
@@ -55228,7 +55250,7 @@ function createRetrievalApi(client) {
|
|
|
55228
55250
|
const parsed = await expectMutation(
|
|
55229
55251
|
client.request({
|
|
55230
55252
|
method: "POST",
|
|
55231
|
-
path: `/v1/improvements/${input3.improvementId}/snooze`,
|
|
55253
|
+
path: `/v1/improvements/${encodeURIComponent(parseResourceId(input3.improvementId, "invalid_improvement_id"))}/snooze`,
|
|
55232
55254
|
bearerToken: input3.bearerToken,
|
|
55233
55255
|
body: { snoozed_until: input3.snoozedUntil }
|
|
55234
55256
|
}),
|
|
@@ -55240,7 +55262,7 @@ function createRetrievalApi(client) {
|
|
|
55240
55262
|
return await expectParsed(
|
|
55241
55263
|
client.request({
|
|
55242
55264
|
method: "GET",
|
|
55243
|
-
path: `/v1/projects/${input3.projectId}/improvements/${input3.improvementId}/bundle`,
|
|
55265
|
+
path: `/v1/projects/${encodeURIComponent(parseResourceId(input3.projectId, "invalid_project_id"))}/improvements/${encodeURIComponent(parseResourceId(input3.improvementId, "invalid_improvement_id"))}/bundle`,
|
|
55244
55266
|
bearerToken: input3.bearerToken
|
|
55245
55267
|
}),
|
|
55246
55268
|
external_exports.union([
|
|
@@ -55472,7 +55494,8 @@ var AlertSchema = external_exports.object({
|
|
|
55472
55494
|
signing_secret: external_exports.string().optional(),
|
|
55473
55495
|
is_enabled: external_exports.boolean(),
|
|
55474
55496
|
created_at: external_exports.string(),
|
|
55475
|
-
updated_at: external_exports.string()
|
|
55497
|
+
updated_at: external_exports.string(),
|
|
55498
|
+
scope: AlertScopeSchema.nullable().optional()
|
|
55476
55499
|
}).strict();
|
|
55477
55500
|
var AlertListResponseSchema = external_exports.object({
|
|
55478
55501
|
alerts: external_exports.array(AlertSchema.omit({ signing_secret: true }).strict())
|
|
@@ -55525,6 +55548,10 @@ function parseApiError3(status, body) {
|
|
|
55525
55548
|
}
|
|
55526
55549
|
throw new AlertApiError(status, parsed.data.error);
|
|
55527
55550
|
}
|
|
55551
|
+
function shouldRetryWithoutAlertScope(status, body) {
|
|
55552
|
+
const error62 = ApiErrorResponseSchema3.safeParse(body);
|
|
55553
|
+
return status === 400 && error62.success && error62.data.error === "invalid_query";
|
|
55554
|
+
}
|
|
55528
55555
|
function buildQuery(input3) {
|
|
55529
55556
|
const params = new URLSearchParams();
|
|
55530
55557
|
for (const [key, value] of Object.entries(input3)) {
|
|
@@ -55560,13 +55587,20 @@ async function expectAlert(responsePromise) {
|
|
|
55560
55587
|
function createAlertApi(client) {
|
|
55561
55588
|
return {
|
|
55562
55589
|
async listAlerts(input3) {
|
|
55563
|
-
|
|
55564
|
-
|
|
55590
|
+
const query = { project_id: input3.projectId, limit: input3.limit };
|
|
55591
|
+
let response = await client.request({
|
|
55592
|
+
method: "GET",
|
|
55593
|
+
path: `/v1/alerts${buildQuery({ ...query, ...input3.includeScope === true ? { include_scope: "true" } : {} })}`,
|
|
55594
|
+
bearerToken: input3.bearerToken
|
|
55595
|
+
});
|
|
55596
|
+
if (input3.includeScope === true && shouldRetryWithoutAlertScope(response.status, response.body)) {
|
|
55597
|
+
response = await client.request({
|
|
55565
55598
|
method: "GET",
|
|
55566
|
-
path: `/v1/alerts${buildQuery(
|
|
55599
|
+
path: `/v1/alerts${buildQuery(query)}`,
|
|
55567
55600
|
bearerToken: input3.bearerToken
|
|
55568
|
-
})
|
|
55569
|
-
|
|
55601
|
+
});
|
|
55602
|
+
}
|
|
55603
|
+
return expectAlertList(Promise.resolve(response));
|
|
55570
55604
|
},
|
|
55571
55605
|
async listAlertGroups(input3) {
|
|
55572
55606
|
const response = await client.request({
|
|
@@ -57678,11 +57712,11 @@ async function safePath(root, file2, allowLeafLink = false) {
|
|
|
57678
57712
|
}
|
|
57679
57713
|
return target;
|
|
57680
57714
|
}
|
|
57681
|
-
async function readManaged(root, file2) {
|
|
57715
|
+
async function readManaged(root, file2, maxBytes = 1024 * 1024) {
|
|
57682
57716
|
const path = await safePath(root, file2);
|
|
57683
57717
|
try {
|
|
57684
57718
|
const initial = await (0, import_promises2.lstat)(path);
|
|
57685
|
-
if (!initial.isFile() || initial.size >
|
|
57719
|
+
if (!initial.isFile() || initial.size > maxBytes)
|
|
57686
57720
|
throw new Error(`Invalid or oversized managed file: ${file2}`);
|
|
57687
57721
|
const handle = await (0, import_promises2.open)(
|
|
57688
57722
|
path,
|
|
@@ -57690,16 +57724,17 @@ async function readManaged(root, file2) {
|
|
|
57690
57724
|
);
|
|
57691
57725
|
try {
|
|
57692
57726
|
const info = await handle.stat();
|
|
57693
|
-
if (!info.isFile() || info.size >
|
|
57727
|
+
if (!info.isFile() || info.size > maxBytes)
|
|
57694
57728
|
throw new Error(`Invalid or oversized managed file: ${file2}`);
|
|
57695
|
-
const
|
|
57729
|
+
const limit = Math.min(maxBytes, info.size);
|
|
57730
|
+
const buffer = Buffer.alloc(limit + 1);
|
|
57696
57731
|
let total = 0;
|
|
57697
57732
|
while (total < buffer.length) {
|
|
57698
57733
|
const { bytesRead } = await handle.read(buffer, total, buffer.length - total, total);
|
|
57699
57734
|
if (bytesRead === 0) break;
|
|
57700
57735
|
total += bytesRead;
|
|
57701
57736
|
}
|
|
57702
|
-
if (total >
|
|
57737
|
+
if (total > limit) throw new Error(`Oversized or growing managed file: ${file2}`);
|
|
57703
57738
|
try {
|
|
57704
57739
|
return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(
|
|
57705
57740
|
buffer.subarray(0, total)
|
|
@@ -57715,7 +57750,7 @@ async function readManaged(root, file2) {
|
|
|
57715
57750
|
throw error62;
|
|
57716
57751
|
}
|
|
57717
57752
|
}
|
|
57718
|
-
async function writeManaged(root, file2, value, expected) {
|
|
57753
|
+
async function writeManaged(root, file2, value, expected, maxBytes = 1024 * 1024) {
|
|
57719
57754
|
const path = await safePath(root, file2);
|
|
57720
57755
|
await (0, import_promises2.mkdir)((0, import_node_path2.dirname)(path), { recursive: true });
|
|
57721
57756
|
await safePath(root, file2);
|
|
@@ -57733,7 +57768,7 @@ async function writeManaged(root, file2, value, expected) {
|
|
|
57733
57768
|
await handle.writeFile(value, "utf8");
|
|
57734
57769
|
if (previousMode !== void 0) await handle.chmod(previousMode);
|
|
57735
57770
|
await handle.close();
|
|
57736
|
-
if (await readManaged(root, file2) !== expected)
|
|
57771
|
+
if (await readManaged(root, file2, maxBytes) !== expected)
|
|
57737
57772
|
throw new Error(`File changed during setup: ${file2}`);
|
|
57738
57773
|
await safePath(root, file2);
|
|
57739
57774
|
await (0, import_promises2.rename)(temporary, path);
|
|
@@ -58525,7 +58560,7 @@ function buildSkill() {
|
|
|
58525
58560
|
"",
|
|
58526
58561
|
"When notification or automation delivery is the reported failure, inspect configuration and delivery records before changing incident logic.",
|
|
58527
58562
|
"",
|
|
58528
|
-
"- Alerts route incident notifications to configured channels. Start with `debugbundle alert list --project-id <id> --json` and confirm condition, severity,
|
|
58563
|
+
"- Alerts route incident notifications to configured channels. Start with `debugbundle alert list --project-id <id> --include-scope true --json` and confirm saved scope, selected service/environment, condition, severity, cooldown, channel, and enabled state.",
|
|
58529
58564
|
"- Webhooks deliver signed lifecycle events to external systems. Start with `debugbundle webhook list --project-id <id> --json`, then inspect `debugbundle webhook deliveries <webhook-id> --project-id <id> --json` before retrying or testing.",
|
|
58530
58565
|
"- Webhook tests and retries are side-effecting delivery actions. Use them only when validating a destination or replaying an explicit failed delivery.",
|
|
58531
58566
|
"",
|
|
@@ -58645,7 +58680,7 @@ function buildCliReference() {
|
|
|
58645
58680
|
"",
|
|
58646
58681
|
"## Notifications",
|
|
58647
58682
|
"",
|
|
58648
|
-
"- `debugbundle alert list --project-id <id> [--limit <n>] [--auth-file <path>] [--json]`",
|
|
58683
|
+
"- `debugbundle alert list --project-id <id> [--limit <n>] [--include-scope <true|false>] [--auth-file <path>] [--json]`",
|
|
58649
58684
|
"- `debugbundle alert groups --project-id <id> [--limit <n>] [--cursor <cursor>] [--auth-file <path>] [--json]` lists safe alert delivery and email digest groups; `debugbundle alert group <direct|email_digest> <group-id> --project-id <id> [--cursor <cursor>] --json` pages their incident IDs.",
|
|
58650
58685
|
"- `debugbundle alert create --project-id <id> --channel <channel> --condition <condition> [--service-id <id>] [--severity-min <level>] [--cooldown <seconds>] --config-json <json> [--is-enabled <true|false>] [--auth-file <path>] [--json]`",
|
|
58651
58686
|
"- `debugbundle alert update <alert-id> --project-id <id> [--service-id <id|null>] [--channel <channel>] [--condition <condition>] [--severity-min <level|null>] [--cooldown <seconds>] [--config-json <json|null>] [--is-enabled <true|false>] [--project-scope current_project] [--auth-file <path>] [--json]`",
|
|
@@ -61945,23 +61980,57 @@ async function agentReadCommand(input3, dependencies = {}) {
|
|
|
61945
61980
|
}
|
|
61946
61981
|
|
|
61947
61982
|
// src/clean-command.ts
|
|
61948
|
-
var
|
|
61983
|
+
var import_promises10 = require("node:fs/promises");
|
|
61949
61984
|
var import_node_path12 = require("node:path");
|
|
61950
61985
|
|
|
61951
|
-
// src/
|
|
61986
|
+
// src/local-artifact-paths.ts
|
|
61952
61987
|
var import_node_path9 = require("node:path");
|
|
61988
|
+
var paths = {
|
|
61989
|
+
bundle: external_exports.string().regex(/^\.debugbundle\/bundles\/local\/[A-Za-z0-9][A-Za-z0-9._-]*\.bundle\.json$/),
|
|
61990
|
+
reproduction: external_exports.string().regex(
|
|
61991
|
+
/^\.debugbundle\/bundles\/local\/reproductions\/[A-Za-z0-9][A-Za-z0-9._-]*\.reproduction\.json$/
|
|
61992
|
+
)
|
|
61993
|
+
};
|
|
61994
|
+
function validateLocalArtifactPath(value, kind) {
|
|
61995
|
+
const result = paths[kind].safeParse(value);
|
|
61996
|
+
if (!result.success) throw new RetrievalApiError(400, "invalid_local_artifact_path");
|
|
61997
|
+
return result.data;
|
|
61998
|
+
}
|
|
61999
|
+
async function resolveLocalArtifactPath(root, value, kind) {
|
|
62000
|
+
const path = validateLocalArtifactPath(value, kind);
|
|
62001
|
+
try {
|
|
62002
|
+
return await safePath(root, path);
|
|
62003
|
+
} catch {
|
|
62004
|
+
throw new RetrievalApiError(400, "invalid_local_artifact_path");
|
|
62005
|
+
}
|
|
62006
|
+
}
|
|
62007
|
+
var LOCAL_FILE_LIMIT = 2 ** 31 - 1;
|
|
62008
|
+
async function readWorkspaceFile(root, path, reader, maxBytes = LOCAL_FILE_LIMIT) {
|
|
62009
|
+
const file2 = (0, import_node_path9.relative)(root, path);
|
|
62010
|
+
await safePath(root, file2);
|
|
62011
|
+
const raw = reader ? await reader(path) : await readManaged(root, file2, maxBytes);
|
|
62012
|
+
if (raw === void 0)
|
|
62013
|
+
throw Object.assign(new Error("Local file not found."), { code: "ENOENT" });
|
|
62014
|
+
if (Buffer.byteLength(raw, "utf8") > maxBytes) throw new Error("Oversized local file.");
|
|
62015
|
+
return raw;
|
|
62016
|
+
}
|
|
62017
|
+
async function writeWorkspaceFile(root, path, contents, writer) {
|
|
62018
|
+
const file2 = (0, import_node_path9.relative)(root, path);
|
|
62019
|
+
await safePath(root, file2);
|
|
62020
|
+
if (writer) return writer(path, contents);
|
|
62021
|
+
const previous = await readManaged(root, file2, LOCAL_FILE_LIMIT);
|
|
62022
|
+
await writeManaged(root, file2, contents, previous, LOCAL_FILE_LIMIT);
|
|
62023
|
+
}
|
|
62024
|
+
|
|
62025
|
+
// src/cli-fs-helpers.ts
|
|
61953
62026
|
function isRecord2(value) {
|
|
61954
62027
|
return typeof value === "object" && value !== null;
|
|
61955
62028
|
}
|
|
61956
62029
|
function isMissingPathError(error62) {
|
|
61957
62030
|
return typeof error62 === "object" && error62 !== null && "code" in error62 && error62.code === "ENOENT";
|
|
61958
62031
|
}
|
|
61959
|
-
function resolveWorkspacePath(rootDirectory, targetPath) {
|
|
61960
|
-
return (0, import_node_path9.isAbsolute)(targetPath) ? targetPath : (0, import_node_path9.join)(rootDirectory, targetPath);
|
|
61961
|
-
}
|
|
61962
62032
|
|
|
61963
62033
|
// src/local-retrieval-store.ts
|
|
61964
|
-
var import_promises9 = require("node:fs/promises");
|
|
61965
62034
|
var import_node_path10 = require("node:path");
|
|
61966
62035
|
|
|
61967
62036
|
// ../../packages/event-normalizer/src/local-correlation-scope.ts
|
|
@@ -62053,8 +62122,17 @@ function projectLocalEvidence(value) {
|
|
|
62053
62122
|
return projected.value;
|
|
62054
62123
|
}
|
|
62055
62124
|
async function readLocalArtifact(path, dependencies) {
|
|
62056
|
-
const
|
|
62057
|
-
const raw = await
|
|
62125
|
+
const reader = dependencies?.readFile;
|
|
62126
|
+
const raw = await readWorkspaceFile(
|
|
62127
|
+
getWorkspaceRoot(dependencies),
|
|
62128
|
+
path,
|
|
62129
|
+
reader ? (file2) => reader(file2, "utf8") : void 0,
|
|
62130
|
+
MAX_ARTIFACT_BYTES
|
|
62131
|
+
).catch((error62) => {
|
|
62132
|
+
if (error62 instanceof Error && /oversized/i.test(error62.message))
|
|
62133
|
+
throw createReadError(503, "privacy_projection_unavailable");
|
|
62134
|
+
throw error62;
|
|
62135
|
+
});
|
|
62058
62136
|
if (Buffer.byteLength(raw, "utf8") > MAX_ARTIFACT_BYTES) {
|
|
62059
62137
|
throw createReadError(503, "privacy_projection_unavailable");
|
|
62060
62138
|
}
|
|
@@ -62072,9 +62150,15 @@ function createReadError(status, code) {
|
|
|
62072
62150
|
return new RetrievalApiError(status, code);
|
|
62073
62151
|
}
|
|
62074
62152
|
async function readJsonFile(path, dependencies) {
|
|
62075
|
-
const
|
|
62153
|
+
const reader = dependencies?.readFile;
|
|
62076
62154
|
try {
|
|
62077
|
-
return JSON.parse(
|
|
62155
|
+
return JSON.parse(
|
|
62156
|
+
await readWorkspaceFile(
|
|
62157
|
+
getWorkspaceRoot(dependencies),
|
|
62158
|
+
path,
|
|
62159
|
+
reader ? (file2) => reader(file2, "utf8") : void 0
|
|
62160
|
+
)
|
|
62161
|
+
);
|
|
62078
62162
|
} catch (error62) {
|
|
62079
62163
|
if (isRecord2(error62) && error62["code"] === "ENOENT") {
|
|
62080
62164
|
throw error62;
|
|
@@ -62144,6 +62228,8 @@ function parseLocalIncident(candidate) {
|
|
|
62144
62228
|
if (!isStringArray(candidate["source_event_types"]) || !isStringArray(candidate["matched_fields"])) {
|
|
62145
62229
|
throw createReadError(400, "invalid_local_state");
|
|
62146
62230
|
}
|
|
62231
|
+
validateLocalArtifactPath(candidate["bundle_path"], "bundle");
|
|
62232
|
+
validateLocalArtifactPath(candidate["reproduction_path"], "reproduction");
|
|
62147
62233
|
const serviceRuntime = candidate["service_runtime"];
|
|
62148
62234
|
const serviceFramework = candidate["service_framework"];
|
|
62149
62235
|
const incidentReason = candidate["matched_fields"].includes("request_anomaly") ? deriveIncidentReasonFromSignal({
|
|
@@ -62268,9 +62354,15 @@ async function readLocalState(dependencies) {
|
|
|
62268
62354
|
}
|
|
62269
62355
|
async function writeLocalState(state2, dependencies) {
|
|
62270
62356
|
const rootDirectory = getWorkspaceRoot(dependencies);
|
|
62271
|
-
|
|
62272
|
-
|
|
62273
|
-
|
|
62357
|
+
parseLocalState(state2);
|
|
62358
|
+
const writer = dependencies?.writeFile;
|
|
62359
|
+
await writeWorkspaceFile(
|
|
62360
|
+
rootDirectory,
|
|
62361
|
+
getStateFilePath(rootDirectory),
|
|
62362
|
+
`${JSON.stringify(state2, null, 2)}
|
|
62363
|
+
`,
|
|
62364
|
+
writer ? (path, contents) => writer(path, contents, "utf8") : void 0
|
|
62365
|
+
);
|
|
62274
62366
|
}
|
|
62275
62367
|
async function updateLocalIncidentStatus(input3, dependencies) {
|
|
62276
62368
|
const state2 = await readLocalState(dependencies);
|
|
@@ -62333,7 +62425,7 @@ async function getLocalBundle(input3, dependencies) {
|
|
|
62333
62425
|
if (incident === void 0) throw createReadError(404, "incident_not_found");
|
|
62334
62426
|
try {
|
|
62335
62427
|
return await readLocalArtifact(
|
|
62336
|
-
|
|
62428
|
+
await resolveLocalArtifactPath(rootDirectory, incident.bundle_path, "bundle"),
|
|
62337
62429
|
dependencies
|
|
62338
62430
|
);
|
|
62339
62431
|
} catch (error62) {
|
|
@@ -62352,7 +62444,7 @@ async function getLocalReproduction(input3, dependencies) {
|
|
|
62352
62444
|
if (incident === void 0) throw createReadError(404, "incident_not_found");
|
|
62353
62445
|
try {
|
|
62354
62446
|
return await readLocalArtifact(
|
|
62355
|
-
|
|
62447
|
+
await resolveLocalArtifactPath(rootDirectory, incident.reproduction_path, "reproduction"),
|
|
62356
62448
|
dependencies
|
|
62357
62449
|
);
|
|
62358
62450
|
} catch (error62) {
|
|
@@ -62376,7 +62468,7 @@ async function reopenLocalIncident(input3, dependencies) {
|
|
|
62376
62468
|
}
|
|
62377
62469
|
|
|
62378
62470
|
// src/cloud-artifact-cache.ts
|
|
62379
|
-
var
|
|
62471
|
+
var import_promises9 = require("node:fs/promises");
|
|
62380
62472
|
var import_node_path11 = require("node:path");
|
|
62381
62473
|
|
|
62382
62474
|
// src/retrieval-source.ts
|
|
@@ -62529,9 +62621,9 @@ async function pruneCloudArtifactCache(input3, dependencies) {
|
|
|
62529
62621
|
}
|
|
62530
62622
|
async function pruneExpiredArtifactsInDirectory(directoryPath, now, olderThanMs, dependencies) {
|
|
62531
62623
|
await checkedCachePath(directoryPath, dependencies);
|
|
62532
|
-
const readdir = dependencies?.readdir ??
|
|
62533
|
-
const rm = dependencies?.rm ??
|
|
62534
|
-
const stat = dependencies?.stat ??
|
|
62624
|
+
const readdir = dependencies?.readdir ?? import_promises9.readdir;
|
|
62625
|
+
const rm = dependencies?.rm ?? import_promises9.rm;
|
|
62626
|
+
const stat = dependencies?.stat ?? import_promises9.lstat;
|
|
62535
62627
|
let fileNames;
|
|
62536
62628
|
try {
|
|
62537
62629
|
fileNames = await readdir(directoryPath);
|
|
@@ -62685,9 +62777,9 @@ function parseOlderThan(value) {
|
|
|
62685
62777
|
return Number.parseInt(match[1], 10) * 24 * 60 * 60 * 1e3;
|
|
62686
62778
|
}
|
|
62687
62779
|
async function cleanProcessedEventFiles(input3, dependencies) {
|
|
62688
|
-
const readdir = dependencies.readdir ??
|
|
62689
|
-
const rm = dependencies.rm ??
|
|
62690
|
-
const stat = dependencies.stat ??
|
|
62780
|
+
const readdir = dependencies.readdir ?? import_promises10.readdir;
|
|
62781
|
+
const rm = dependencies.rm ?? import_promises10.rm;
|
|
62782
|
+
const stat = dependencies.stat ?? import_promises10.stat;
|
|
62691
62783
|
const rootDirectory = (dependencies.cwd ?? process.cwd)();
|
|
62692
62784
|
const eventsDirectoryPath = (0, import_node_path12.join)(rootDirectory, LOCAL_EVENTS_DIRECTORY_PATH);
|
|
62693
62785
|
const state2 = await readLocalState(dependencies);
|
|
@@ -62722,9 +62814,9 @@ async function cleanProcessedEventFiles(input3, dependencies) {
|
|
|
62722
62814
|
return { removed, retained };
|
|
62723
62815
|
}
|
|
62724
62816
|
async function cleanRelaySpoolFiles(input3, dependencies) {
|
|
62725
|
-
const readdir = dependencies.readdir ??
|
|
62726
|
-
const rm = dependencies.rm ??
|
|
62727
|
-
const stat = dependencies.stat ??
|
|
62817
|
+
const readdir = dependencies.readdir ?? import_promises10.readdir;
|
|
62818
|
+
const rm = dependencies.rm ?? import_promises10.rm;
|
|
62819
|
+
const stat = dependencies.stat ?? import_promises10.stat;
|
|
62728
62820
|
const rootDirectory = (dependencies.cwd ?? process.cwd)();
|
|
62729
62821
|
const spoolDirectoryPath = (0, import_node_path12.join)(rootDirectory, LOCAL_RELAY_SPOOL_DIRECTORY_PATH);
|
|
62730
62822
|
let spoolFileNames;
|
|
@@ -62775,7 +62867,7 @@ function sortLocalIncidentRemovalPriority(left, right) {
|
|
|
62775
62867
|
return left.incident_id.localeCompare(right.incident_id);
|
|
62776
62868
|
}
|
|
62777
62869
|
async function applyLocalIncidentRetention(dependencies) {
|
|
62778
|
-
const rm = dependencies.rm ??
|
|
62870
|
+
const rm = dependencies.rm ?? import_promises10.rm;
|
|
62779
62871
|
const rootDirectory = (dependencies.cwd ?? process.cwd)();
|
|
62780
62872
|
const state2 = await readLocalState(dependencies);
|
|
62781
62873
|
const incidents = Object.values(state2.incidents);
|
|
@@ -62789,8 +62881,13 @@ async function applyLocalIncidentRetention(dependencies) {
|
|
|
62789
62881
|
const nextIncidents = { ...state2.incidents };
|
|
62790
62882
|
for (const incident of incidentsToRemove) {
|
|
62791
62883
|
delete nextIncidents[incident.incident_id];
|
|
62792
|
-
await rm(
|
|
62793
|
-
|
|
62884
|
+
await rm(await resolveLocalArtifactPath(rootDirectory, incident.bundle_path, "bundle"), {
|
|
62885
|
+
force: true
|
|
62886
|
+
});
|
|
62887
|
+
await rm(
|
|
62888
|
+
await resolveLocalArtifactPath(rootDirectory, incident.reproduction_path, "reproduction"),
|
|
62889
|
+
{ force: true }
|
|
62890
|
+
);
|
|
62794
62891
|
}
|
|
62795
62892
|
await writeLocalState(
|
|
62796
62893
|
{
|
|
@@ -62808,10 +62905,12 @@ async function countLocalIncidents(dependencies) {
|
|
|
62808
62905
|
return Object.keys((await readLocalState(dependencies)).incidents).length;
|
|
62809
62906
|
}
|
|
62810
62907
|
async function countDirectoryFiles(directoryPath, dependencies, extension) {
|
|
62811
|
-
const readdir = dependencies.readdir ??
|
|
62908
|
+
const readdir = dependencies.readdir ?? import_promises10.readdir;
|
|
62812
62909
|
const rootDirectory = (dependencies.cwd ?? process.cwd)();
|
|
62813
62910
|
try {
|
|
62814
|
-
return (await readdir((0, import_node_path12.join)(rootDirectory, directoryPath))).filter(
|
|
62911
|
+
return (await readdir((0, import_node_path12.join)(rootDirectory, directoryPath))).filter(
|
|
62912
|
+
(fileName) => fileName.endsWith(extension)
|
|
62913
|
+
).length;
|
|
62815
62914
|
} catch (error62) {
|
|
62816
62915
|
if (isMissingPathError(error62)) {
|
|
62817
62916
|
return 0;
|
|
@@ -62826,10 +62925,15 @@ async function countRelaySpoolEventFiles(dependencies) {
|
|
|
62826
62925
|
return countDirectoryFiles(LOCAL_RELAY_SPOOL_DIRECTORY_PATH, dependencies, ".events.json");
|
|
62827
62926
|
}
|
|
62828
62927
|
async function resetRuntimeData(dependencies) {
|
|
62829
|
-
const mkdir5 = dependencies.mkdir ??
|
|
62830
|
-
const rm = dependencies.rm ??
|
|
62928
|
+
const mkdir5 = dependencies.mkdir ?? import_promises10.mkdir;
|
|
62929
|
+
const rm = dependencies.rm ?? import_promises10.rm;
|
|
62831
62930
|
const rootDirectory = (dependencies.cwd ?? process.cwd)();
|
|
62832
|
-
const [
|
|
62931
|
+
const [
|
|
62932
|
+
processedEventFilesRemoved,
|
|
62933
|
+
relaySpoolFilesRemoved,
|
|
62934
|
+
cloudCacheFilesRemoved,
|
|
62935
|
+
localIncidentCount
|
|
62936
|
+
] = await Promise.all([
|
|
62833
62937
|
countProcessedAndUnprocessedEventFiles(dependencies),
|
|
62834
62938
|
countRelaySpoolEventFiles(dependencies),
|
|
62835
62939
|
countCloudArtifactFiles(dependencies),
|
|
@@ -62872,6 +62976,17 @@ async function cleanCommand(input3, dependencies = {}) {
|
|
|
62872
62976
|
output: "Invalid value for --older-than."
|
|
62873
62977
|
};
|
|
62874
62978
|
}
|
|
62979
|
+
const root = (dependencies.cwd ?? process.cwd)();
|
|
62980
|
+
for (const path of [
|
|
62981
|
+
".debugbundle/local/state.json",
|
|
62982
|
+
LOCAL_EVENTS_DIRECTORY_PATH,
|
|
62983
|
+
LOCAL_RELAY_SPOOL_DIRECTORY_PATH,
|
|
62984
|
+
LOCAL_BUNDLE_DIRECTORY_PATH2,
|
|
62985
|
+
LOCAL_REPRODUCTION_DIRECTORY_PATH,
|
|
62986
|
+
CLOUD_BUNDLE_DIRECTORY_PATH2,
|
|
62987
|
+
CLOUD_REPRODUCTION_DIRECTORY_PATH2
|
|
62988
|
+
])
|
|
62989
|
+
await safePath(root, path);
|
|
62875
62990
|
const hasEventsFlag = input3.events === true;
|
|
62876
62991
|
const hasBundlesFlag = input3.bundles === true;
|
|
62877
62992
|
const hasAllFlag = input3.all === true;
|
|
@@ -62898,9 +63013,15 @@ async function cleanCommand(input3, dependencies = {}) {
|
|
|
62898
63013
|
output: input3.json ? JSON.stringify(summary2) : formatCleanOutput(summary2)
|
|
62899
63014
|
};
|
|
62900
63015
|
}
|
|
62901
|
-
const processedEvents = runEventsCleanup ? await cleanProcessedEventFiles(
|
|
63016
|
+
const processedEvents = runEventsCleanup ? await cleanProcessedEventFiles(
|
|
63017
|
+
{ removeAllProcessed: input3.events === true, now },
|
|
63018
|
+
dependencies
|
|
63019
|
+
) : { removed: 0, retained: await countProcessedAndUnprocessedEventFiles(dependencies) };
|
|
62902
63020
|
const relaySpool = await cleanRelaySpoolFiles({ now }, dependencies);
|
|
62903
|
-
const cloudCache = runBundleCleanup ? await pruneCloudArtifactCache(
|
|
63021
|
+
const cloudCache = runBundleCleanup ? await pruneCloudArtifactCache(
|
|
63022
|
+
{ olderThanMs: bundleRetentionMs ?? DEFAULT_CLOUD_CACHE_RETENTION_MS },
|
|
63023
|
+
{ ...dependencies, now: () => now }
|
|
63024
|
+
) : await countCloudArtifactCache(dependencies);
|
|
62904
63025
|
const localIncidents = runLocalIncidentCleanup ? await applyLocalIncidentRetention(dependencies) : { removed: 0, retained: await countLocalIncidents(dependencies) };
|
|
62905
63026
|
const summary = {
|
|
62906
63027
|
status: "ok",
|
|
@@ -62919,10 +63040,12 @@ async function cleanCommand(input3, dependencies = {}) {
|
|
|
62919
63040
|
};
|
|
62920
63041
|
}
|
|
62921
63042
|
async function countProcessedAndUnprocessedEventFiles(dependencies) {
|
|
62922
|
-
const readdir = dependencies.readdir ??
|
|
63043
|
+
const readdir = dependencies.readdir ?? import_promises10.readdir;
|
|
62923
63044
|
const rootDirectory = (dependencies.cwd ?? process.cwd)();
|
|
62924
63045
|
try {
|
|
62925
|
-
return (await readdir((0, import_node_path12.join)(rootDirectory, LOCAL_EVENTS_DIRECTORY_PATH))).filter(
|
|
63046
|
+
return (await readdir((0, import_node_path12.join)(rootDirectory, LOCAL_EVENTS_DIRECTORY_PATH))).filter(
|
|
63047
|
+
(fileName) => fileName.endsWith(".events.json")
|
|
63048
|
+
).length;
|
|
62926
63049
|
} catch (error62) {
|
|
62927
63050
|
if (isMissingPathError(error62)) {
|
|
62928
63051
|
return 0;
|
|
@@ -62931,11 +63054,14 @@ async function countProcessedAndUnprocessedEventFiles(dependencies) {
|
|
|
62931
63054
|
}
|
|
62932
63055
|
}
|
|
62933
63056
|
async function countCloudArtifactCache(dependencies) {
|
|
62934
|
-
return pruneCloudArtifactCache(
|
|
63057
|
+
return pruneCloudArtifactCache(
|
|
63058
|
+
{ olderThanMs: Number.MAX_SAFE_INTEGER },
|
|
63059
|
+
{ ...dependencies, now: () => /* @__PURE__ */ new Date(0) }
|
|
63060
|
+
);
|
|
62935
63061
|
}
|
|
62936
63062
|
|
|
62937
63063
|
// src/connect-command.ts
|
|
62938
|
-
var
|
|
63064
|
+
var import_promises12 = require("node:fs/promises");
|
|
62939
63065
|
var import_node_path14 = require("node:path");
|
|
62940
63066
|
|
|
62941
63067
|
// src/connection-config.ts
|
|
@@ -62974,12 +63100,12 @@ async function readConnectionConfig(rootDirectory, readFile) {
|
|
|
62974
63100
|
|
|
62975
63101
|
// src/interactive-auth.ts
|
|
62976
63102
|
var import_node_process = require("node:process");
|
|
62977
|
-
var
|
|
63103
|
+
var import_promises11 = require("node:readline/promises");
|
|
62978
63104
|
function isInteractiveTerminal() {
|
|
62979
63105
|
return import_node_process.stdin.isTTY === true && import_node_process.stdout.isTTY === true;
|
|
62980
63106
|
}
|
|
62981
63107
|
async function promptForInteractiveLoginSelection() {
|
|
62982
|
-
const readlineInterface = (0,
|
|
63108
|
+
const readlineInterface = (0, import_promises11.createInterface)({
|
|
62983
63109
|
input: import_node_process.stdin,
|
|
62984
63110
|
output: import_node_process.stdout
|
|
62985
63111
|
});
|
|
@@ -63584,9 +63710,9 @@ function buildValidationFailureResult(input3) {
|
|
|
63584
63710
|
}
|
|
63585
63711
|
async function connectCommand(input3, dependencies = {}) {
|
|
63586
63712
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
63587
|
-
const readFile = dependencies.readFile ?? ((path) => (0,
|
|
63588
|
-
const stat = dependencies.stat ??
|
|
63589
|
-
const writeFile = dependencies.writeFile ??
|
|
63713
|
+
const readFile = dependencies.readFile ?? ((path) => (0, import_promises12.readFile)(path, "utf8"));
|
|
63714
|
+
const stat = dependencies.stat ?? import_promises12.stat;
|
|
63715
|
+
const writeFile = dependencies.writeFile ?? import_promises12.writeFile;
|
|
63590
63716
|
const readAuthState = dependencies.readAuthState ?? ((authInput) => readCliAuthState(authInput));
|
|
63591
63717
|
const createHttpClient = dependencies.createHttpClient ?? ((clientInput) => {
|
|
63592
63718
|
const httpClientDependencies = {};
|
|
@@ -63793,7 +63919,7 @@ var legacy_skill_hashes_default = {
|
|
|
63793
63919
|
};
|
|
63794
63920
|
|
|
63795
63921
|
// src/agent-setup.ts
|
|
63796
|
-
var
|
|
63922
|
+
var import_promises13 = require("node:readline/promises");
|
|
63797
63923
|
var import_node_process2 = require("node:process");
|
|
63798
63924
|
var MANAGED_AGENTS_START = "<!-- debugbundle:start -->";
|
|
63799
63925
|
var MANAGED_AGENTS_END = "<!-- debugbundle:end -->";
|
|
@@ -63831,7 +63957,7 @@ async function chooseAgents(root, input3, dependencies) {
|
|
|
63831
63957
|
let answer;
|
|
63832
63958
|
if (dependencies.promptUser) answer = await dependencies.promptUser(prompt);
|
|
63833
63959
|
else {
|
|
63834
|
-
const terminal = (0,
|
|
63960
|
+
const terminal = (0, import_promises13.createInterface)({ input: import_node_process2.stdin, output: import_node_process2.stdout });
|
|
63835
63961
|
try {
|
|
63836
63962
|
answer = await terminal.question(prompt);
|
|
63837
63963
|
} finally {
|
|
@@ -63883,7 +64009,7 @@ function localScaffoldFailure(error62, json2 = false) {
|
|
|
63883
64009
|
}
|
|
63884
64010
|
|
|
63885
64011
|
// src/doctor-command.ts
|
|
63886
|
-
var
|
|
64012
|
+
var import_promises14 = require("node:fs/promises");
|
|
63887
64013
|
var import_node_path15 = require("node:path");
|
|
63888
64014
|
|
|
63889
64015
|
// ../../packages/event-normalizer/src/fingerprints.ts
|
|
@@ -65589,13 +65715,13 @@ async function runDoctorCommand(input3, dependencies = {}) {
|
|
|
65589
65715
|
const now = dependencies.now ?? (() => /* @__PURE__ */ new Date());
|
|
65590
65716
|
const fetchImpl = dependencies.fetchImpl ?? nodeFetch;
|
|
65591
65717
|
const readAuthStateImpl = dependencies.readAuthState ?? readCliAuthState;
|
|
65592
|
-
const readdir = dependencies.readdir ??
|
|
65718
|
+
const readdir = dependencies.readdir ?? import_promises14.readdir;
|
|
65593
65719
|
const readFile = dependencies.readFile ?? (async (filePath) => {
|
|
65594
65720
|
const content = await readManaged(rootDirectory, (0, import_node_path15.relative)(rootDirectory, filePath));
|
|
65595
65721
|
if (content === void 0) throw Object.assign(new Error("Missing local scaffold file."), { code: "ENOENT" });
|
|
65596
65722
|
return content;
|
|
65597
65723
|
});
|
|
65598
|
-
const stat = dependencies.stat ??
|
|
65724
|
+
const stat = dependencies.stat ?? import_promises14.stat;
|
|
65599
65725
|
const rootDirectory = await projectRoot(cwd());
|
|
65600
65726
|
const currentTime = now();
|
|
65601
65727
|
const { check: profileCheck, profile, validationErrors } = await loadProfile(rootDirectory, { readFile, stat });
|
|
@@ -65641,8 +65767,8 @@ async function doctorCommand(input3, dependencies = {}) {
|
|
|
65641
65767
|
|
|
65642
65768
|
// src/ingest-command.ts
|
|
65643
65769
|
var import_node_crypto8 = require("node:crypto");
|
|
65644
|
-
var
|
|
65645
|
-
var
|
|
65770
|
+
var import_promises16 = require("node:fs/promises");
|
|
65771
|
+
var import_node_path18 = require("node:path");
|
|
65646
65772
|
|
|
65647
65773
|
// ../../packages/log-parser/src/project-id.ts
|
|
65648
65774
|
var import_node_crypto5 = require("node:crypto");
|
|
@@ -66130,6 +66256,10 @@ function parseIncidentState(candidate) {
|
|
|
66130
66256
|
if (!isRecord2(candidate)) {
|
|
66131
66257
|
return null;
|
|
66132
66258
|
}
|
|
66259
|
+
if (typeof candidate["bundle_path"] === "string")
|
|
66260
|
+
validateLocalArtifactPath(candidate["bundle_path"], "bundle");
|
|
66261
|
+
if (typeof candidate["reproduction_path"] === "string")
|
|
66262
|
+
validateLocalArtifactPath(candidate["reproduction_path"], "reproduction");
|
|
66133
66263
|
if (candidate["source"] !== "local" || candidate["status"] !== "open" && candidate["status"] !== "resolved") {
|
|
66134
66264
|
return null;
|
|
66135
66265
|
}
|
|
@@ -66206,8 +66336,11 @@ function parseIncidentState(candidate) {
|
|
|
66206
66336
|
const occurrenceCount = candidate["occurrence_count"];
|
|
66207
66337
|
const sourceEventId = candidate["source_event_id"];
|
|
66208
66338
|
const sourceOccurredAt = candidate["source_occurred_at"];
|
|
66209
|
-
const bundlePath = candidate["bundle_path"];
|
|
66210
|
-
const reproductionPath =
|
|
66339
|
+
const bundlePath = validateLocalArtifactPath(candidate["bundle_path"], "bundle");
|
|
66340
|
+
const reproductionPath = validateLocalArtifactPath(
|
|
66341
|
+
candidate["reproduction_path"],
|
|
66342
|
+
"reproduction"
|
|
66343
|
+
);
|
|
66211
66344
|
const generationNumber = candidate["generation_number"];
|
|
66212
66345
|
const normalizedSourceEventTypes = [...sourceEventTypes].sort();
|
|
66213
66346
|
return {
|
|
@@ -66301,8 +66434,9 @@ async function readState(statePath, readFile, stat) {
|
|
|
66301
66434
|
}
|
|
66302
66435
|
try {
|
|
66303
66436
|
return parseState(await readFile(statePath));
|
|
66304
|
-
} catch {
|
|
66305
|
-
return null;
|
|
66437
|
+
} catch (error62) {
|
|
66438
|
+
if (error62 instanceof SyntaxError) return null;
|
|
66439
|
+
throw error62;
|
|
66306
66440
|
}
|
|
66307
66441
|
}
|
|
66308
66442
|
async function readEventBatches(eventDirectoryPath, fileNames, readFile) {
|
|
@@ -66362,9 +66496,6 @@ function serializeState(state2) {
|
|
|
66362
66496
|
`;
|
|
66363
66497
|
}
|
|
66364
66498
|
|
|
66365
|
-
// src/local-bundle-artifacts.ts
|
|
66366
|
-
var import_node_path17 = require("node:path");
|
|
66367
|
-
|
|
66368
66499
|
// ../../packages/bundle-engine/src/envelope-selection.ts
|
|
66369
66500
|
function selectLatestEnvelope(envelopes, predicate) {
|
|
66370
66501
|
for (let index = envelopes.length - 1; index >= 0; index -= 1) {
|
|
@@ -68003,12 +68134,20 @@ function localBundle(input3) {
|
|
|
68003
68134
|
});
|
|
68004
68135
|
}
|
|
68005
68136
|
async function writeLocalBundleArtifacts(input3) {
|
|
68137
|
+
const bundlePath = await resolveLocalArtifactPath(
|
|
68138
|
+
input3.rootDirectory,
|
|
68139
|
+
input3.incident.bundle_path,
|
|
68140
|
+
"bundle"
|
|
68141
|
+
);
|
|
68142
|
+
const reproductionPath = await resolveLocalArtifactPath(
|
|
68143
|
+
input3.rootDirectory,
|
|
68144
|
+
input3.incident.reproduction_path,
|
|
68145
|
+
"reproduction"
|
|
68146
|
+
);
|
|
68006
68147
|
let previous = null;
|
|
68007
68148
|
if (input3.readFile) {
|
|
68008
68149
|
try {
|
|
68009
|
-
previous = BundleV1Schema.parse(
|
|
68010
|
-
JSON.parse(await input3.readFile((0, import_node_path17.join)(input3.rootDirectory, input3.incident.bundle_path)))
|
|
68011
|
-
);
|
|
68150
|
+
previous = BundleV1Schema.parse(JSON.parse(await input3.readFile(bundlePath)));
|
|
68012
68151
|
} catch {
|
|
68013
68152
|
}
|
|
68014
68153
|
}
|
|
@@ -68018,19 +68157,19 @@ async function writeLocalBundleArtifacts(input3) {
|
|
|
68018
68157
|
});
|
|
68019
68158
|
if (previous && JSON.stringify({ ...bundle, metadata: previous.metadata }) === JSON.stringify(previous))
|
|
68020
68159
|
return;
|
|
68021
|
-
await input3.writeFile(
|
|
68022
|
-
|
|
68023
|
-
|
|
68024
|
-
`
|
|
68025
|
-
);
|
|
68026
|
-
await input3.writeFile(
|
|
68027
|
-
(0, import_node_path17.join)(input3.rootDirectory, input3.incident.reproduction_path),
|
|
68028
|
-
`${JSON.stringify(bundle.reproduction, null, 2)}
|
|
68029
|
-
`
|
|
68030
|
-
);
|
|
68160
|
+
await input3.writeFile(bundlePath, `${JSON.stringify(bundle, null, 2)}
|
|
68161
|
+
`);
|
|
68162
|
+
await input3.writeFile(reproductionPath, `${JSON.stringify(bundle.reproduction, null, 2)}
|
|
68163
|
+
`);
|
|
68031
68164
|
}
|
|
68032
68165
|
async function rebuildLocalDiagnosticArtifacts(input3) {
|
|
68033
68166
|
const { incident } = input3;
|
|
68167
|
+
const bundlePath = await resolveLocalArtifactPath(
|
|
68168
|
+
input3.rootDirectory,
|
|
68169
|
+
incident.bundle_path,
|
|
68170
|
+
"bundle"
|
|
68171
|
+
);
|
|
68172
|
+
await resolveLocalArtifactPath(input3.rootDirectory, incident.reproduction_path, "reproduction");
|
|
68034
68173
|
const primary = incident.source_events.find((event) => event.event_id === incident.source_event_id) ?? null;
|
|
68035
68174
|
const association = associateDiagnosticEvidence({
|
|
68036
68175
|
failure: primary,
|
|
@@ -68039,9 +68178,7 @@ async function rebuildLocalDiagnosticArtifacts(input3) {
|
|
|
68039
68178
|
});
|
|
68040
68179
|
let previous = null;
|
|
68041
68180
|
try {
|
|
68042
|
-
previous = BundleV1Schema.parse(
|
|
68043
|
-
JSON.parse(await input3.readFile((0, import_node_path17.join)(input3.rootDirectory, incident.bundle_path)))
|
|
68044
|
-
);
|
|
68181
|
+
previous = BundleV1Schema.parse(JSON.parse(await input3.readFile(bundlePath)));
|
|
68045
68182
|
} catch {
|
|
68046
68183
|
}
|
|
68047
68184
|
if (association.events.length === 0 && previous?.context.recovery === void 0 && previous?.context.resource_observations === void 0)
|
|
@@ -68066,8 +68203,8 @@ async function rebuildLocalDiagnosticArtifacts(input3) {
|
|
|
68066
68203
|
|
|
68067
68204
|
// src/process-command.ts
|
|
68068
68205
|
var import_node_crypto7 = require("node:crypto");
|
|
68069
|
-
var
|
|
68070
|
-
var
|
|
68206
|
+
var import_promises15 = require("node:fs/promises");
|
|
68207
|
+
var import_node_path17 = require("node:path");
|
|
68071
68208
|
var LOCAL_EVENTS_DIRECTORY_PATH3 = ".debugbundle/local/events";
|
|
68072
68209
|
var LOCAL_STATE_FILE_PATH = ".debugbundle/local/state.json";
|
|
68073
68210
|
var LOCAL_BUNDLE_DIRECTORY_PATH3 = ".debugbundle/bundles/local";
|
|
@@ -68330,18 +68467,26 @@ function requireProjectId(event) {
|
|
|
68330
68467
|
}
|
|
68331
68468
|
async function processCommand(input3, dependencies = {}) {
|
|
68332
68469
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
68333
|
-
const mkdir5 = dependencies.mkdir ?? import_promises16.mkdir;
|
|
68334
|
-
const readFile = dependencies.readFile ?? ((filePath) => (0, import_promises16.readFile)(filePath, "utf8"));
|
|
68335
|
-
const readdir = dependencies.readdir ?? import_promises16.readdir;
|
|
68336
|
-
const stat = dependencies.stat ?? import_promises16.stat;
|
|
68337
|
-
const writeFile = dependencies.writeFile ?? ((filePath, content) => (0, import_promises16.writeFile)(filePath, content, "utf8"));
|
|
68338
68470
|
const rootDirectory = cwd();
|
|
68339
|
-
const
|
|
68340
|
-
const
|
|
68341
|
-
const
|
|
68342
|
-
const
|
|
68471
|
+
const mkdir5 = dependencies.mkdir ?? import_promises15.mkdir;
|
|
68472
|
+
const readFile = (filePath) => readWorkspaceFile(rootDirectory, filePath, dependencies.readFile);
|
|
68473
|
+
const readdir = dependencies.readdir ?? import_promises15.readdir;
|
|
68474
|
+
const stat = dependencies.stat ?? import_promises15.stat;
|
|
68475
|
+
const writeFile = (filePath, content) => writeWorkspaceFile(rootDirectory, filePath, content, dependencies.writeFile);
|
|
68476
|
+
const eventsDirectoryPath = (0, import_node_path17.join)(rootDirectory, LOCAL_EVENTS_DIRECTORY_PATH3);
|
|
68477
|
+
const statePath = (0, import_node_path17.join)(rootDirectory, LOCAL_STATE_FILE_PATH);
|
|
68478
|
+
const bundleDirectoryPath = (0, import_node_path17.join)(rootDirectory, LOCAL_BUNDLE_DIRECTORY_PATH3);
|
|
68479
|
+
const reproductionDirectoryPath = (0, import_node_path17.join)(rootDirectory, LOCAL_REPRODUCTION_DIRECTORY_PATH2);
|
|
68343
68480
|
const capturePreset = input3.preset ?? "minimal";
|
|
68344
|
-
|
|
68481
|
+
for (const path of [
|
|
68482
|
+
".debugbundle/local",
|
|
68483
|
+
LOCAL_STATE_FILE_PATH,
|
|
68484
|
+
LOCAL_EVENTS_DIRECTORY_PATH3,
|
|
68485
|
+
LOCAL_BUNDLE_DIRECTORY_PATH3,
|
|
68486
|
+
LOCAL_REPRODUCTION_DIRECTORY_PATH2
|
|
68487
|
+
])
|
|
68488
|
+
await safePath(rootDirectory, path);
|
|
68489
|
+
await mkdir5((0, import_node_path17.join)(rootDirectory, ".debugbundle", "local"), { recursive: true });
|
|
68345
68490
|
await mkdir5(bundleDirectoryPath, { recursive: true });
|
|
68346
68491
|
await mkdir5(reproductionDirectoryPath, { recursive: true });
|
|
68347
68492
|
const previousState = await readState(statePath, readFile, stat);
|
|
@@ -68374,7 +68519,7 @@ async function processCommand(input3, dependencies = {}) {
|
|
|
68374
68519
|
};
|
|
68375
68520
|
}
|
|
68376
68521
|
const batches = await readEventBatches(eventsDirectoryPath, targetEventFileNames, readFile);
|
|
68377
|
-
const diagnosticReceiptPath = (0,
|
|
68522
|
+
const diagnosticReceiptPath = (0, import_node_path17.join)(rootDirectory, ".debugbundle/local/evidence-receipts.json");
|
|
68378
68523
|
const ledger = await pathExists4(diagnosticReceiptPath, stat) ? parseDiagnosticReceipts(JSON.parse(await readFile(diagnosticReceiptPath))) : { diagnostic_receipts: {}, diagnostic_payload_hashes: {} };
|
|
68379
68524
|
const receipts = ledger.diagnostic_receipts;
|
|
68380
68525
|
for (const [id, at] of Object.entries(previousState?.diagnostic_receipts ?? {})) {
|
|
@@ -68639,7 +68784,7 @@ function buildEventFileName(events, filePath) {
|
|
|
68639
68784
|
return Number.isFinite(candidate) && candidate > latest ? candidate : latest;
|
|
68640
68785
|
}, 0);
|
|
68641
68786
|
const digest4 = (0, import_node_crypto8.createHash)("sha256").update([filePath, ...events.map((event) => event.event_id)].join("\0")).digest("hex").slice(0, 8);
|
|
68642
|
-
return `${lastOccurredAt}-${digest4}-${slugify3(events[0]?.service.name ?? (0,
|
|
68787
|
+
return `${lastOccurredAt}-${digest4}-${slugify3(events[0]?.service.name ?? (0, import_node_path18.basename)(filePath))}.events.json`;
|
|
68643
68788
|
}
|
|
68644
68789
|
function formatHumanOutput(summary) {
|
|
68645
68790
|
return [
|
|
@@ -68649,7 +68794,7 @@ function formatHumanOutput(summary) {
|
|
|
68649
68794
|
].join("\n");
|
|
68650
68795
|
}
|
|
68651
68796
|
async function readProfile(rootDirectory, readFile) {
|
|
68652
|
-
const parsedProfile = ProfileSchema2.safeParse(JSON.parse(await readFile((0,
|
|
68797
|
+
const parsedProfile = ProfileSchema2.safeParse(JSON.parse(await readFile((0, import_node_path18.join)(rootDirectory, PROFILE_FILE_PATH))));
|
|
68653
68798
|
if (!parsedProfile.success) {
|
|
68654
68799
|
throw new Error(`Invalid ${PROFILE_FILE_PATH}`);
|
|
68655
68800
|
}
|
|
@@ -68664,11 +68809,11 @@ async function ingestCommand(input3, dependencies = {}) {
|
|
|
68664
68809
|
};
|
|
68665
68810
|
}
|
|
68666
68811
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
68667
|
-
const mkdir5 = dependencies.mkdir ?? (async (path, options) => (0,
|
|
68812
|
+
const mkdir5 = dependencies.mkdir ?? (async (path, options) => (0, import_promises16.mkdir)(path, options));
|
|
68668
68813
|
const processLocalEvents = dependencies.processCommand ?? processCommand;
|
|
68669
|
-
const readFile = dependencies.readFile ?? (async (path) => (0,
|
|
68670
|
-
const rename4 = dependencies.rename ?? (async (sourcePath, destinationPath) => (0,
|
|
68671
|
-
const writeFile = dependencies.writeFile ?? (async (path, content) => (0,
|
|
68814
|
+
const readFile = dependencies.readFile ?? (async (path) => (0, import_promises16.readFile)(path, "utf8"));
|
|
68815
|
+
const rename4 = dependencies.rename ?? (async (sourcePath, destinationPath) => (0, import_promises16.rename)(sourcePath, destinationPath));
|
|
68816
|
+
const writeFile = dependencies.writeFile ?? (async (path, content) => (0, import_promises16.writeFile)(path, content, "utf8"));
|
|
68672
68817
|
try {
|
|
68673
68818
|
const rootDirectory = cwd();
|
|
68674
68819
|
const profile = await readProfile(rootDirectory, readFile);
|
|
@@ -68684,9 +68829,9 @@ async function ingestCommand(input3, dependencies = {}) {
|
|
|
68684
68829
|
output: "No supported events were found in the input file."
|
|
68685
68830
|
};
|
|
68686
68831
|
}
|
|
68687
|
-
const eventDirectory = (0,
|
|
68832
|
+
const eventDirectory = (0, import_node_path18.join)(rootDirectory, LOCAL_EVENTS_DIRECTORY_PATH4);
|
|
68688
68833
|
const eventFile = buildEventFileName(events, input3.filePath);
|
|
68689
|
-
const destinationPath = (0,
|
|
68834
|
+
const destinationPath = (0, import_node_path18.join)(eventDirectory, eventFile);
|
|
68690
68835
|
const temporaryPath = `${destinationPath}.tmp`;
|
|
68691
68836
|
await mkdir5(eventDirectory, { recursive: true });
|
|
68692
68837
|
await writeFile(temporaryPath, `${JSON.stringify(events, null, 2)}
|
|
@@ -68725,8 +68870,8 @@ async function ingestCommand(input3, dependencies = {}) {
|
|
|
68725
68870
|
}
|
|
68726
68871
|
|
|
68727
68872
|
// src/watch-command.ts
|
|
68728
|
-
var
|
|
68729
|
-
var
|
|
68873
|
+
var import_promises17 = require("node:fs/promises");
|
|
68874
|
+
var import_node_path19 = require("node:path");
|
|
68730
68875
|
function normalizeBaseUrl5(baseUrl) {
|
|
68731
68876
|
return baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
|
|
68732
68877
|
}
|
|
@@ -68771,25 +68916,25 @@ async function watchCommand(input3, dependencies = {}) {
|
|
|
68771
68916
|
};
|
|
68772
68917
|
}
|
|
68773
68918
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
68774
|
-
const mkdir5 = dependencies.mkdir ?? (async (path, options) => (0,
|
|
68919
|
+
const mkdir5 = dependencies.mkdir ?? (async (path, options) => (0, import_promises17.mkdir)(path, options));
|
|
68775
68920
|
const pollIntervalMs = dependencies.pollIntervalMs ?? 1e3;
|
|
68776
68921
|
const processLocalEvents = dependencies.processCommand ?? processCommand;
|
|
68777
|
-
const readFile = dependencies.readFile ?? (async (path) => (0,
|
|
68922
|
+
const readFile = dependencies.readFile ?? (async (path) => (0, import_promises17.readFile)(path));
|
|
68778
68923
|
const readEnv = dependencies.readEnv ?? ((name) => process.env[name]);
|
|
68779
|
-
const rename4 = dependencies.rename ?? (async (sourcePath, destinationPath) => (0,
|
|
68924
|
+
const rename4 = dependencies.rename ?? (async (sourcePath, destinationPath) => (0, import_promises17.rename)(sourcePath, destinationPath));
|
|
68780
68925
|
const fetchDependencies = dependencies.fetchImpl === void 0 ? void 0 : { fetchImpl: dependencies.fetchImpl };
|
|
68781
68926
|
const sendEvents = dependencies.sendEvents ?? ((requestInput) => sendEventsToApi(requestInput, fetchDependencies));
|
|
68782
68927
|
const signal = dependencies.signal;
|
|
68783
68928
|
const sleep = dependencies.sleep ?? (async (milliseconds) => new Promise((resolve5) => setTimeout(resolve5, milliseconds)));
|
|
68784
|
-
const stat = dependencies.stat ??
|
|
68785
|
-
const writeFile = dependencies.writeFile ?? (async (path, content) => (0,
|
|
68929
|
+
const stat = dependencies.stat ?? import_promises17.stat;
|
|
68930
|
+
const writeFile = dependencies.writeFile ?? (async (path, content) => (0, import_promises17.writeFile)(path, content, "utf8"));
|
|
68786
68931
|
try {
|
|
68787
68932
|
const rootDirectory = cwd();
|
|
68788
68933
|
const profile = await readProfile(
|
|
68789
68934
|
rootDirectory,
|
|
68790
68935
|
async (path) => (await readFile(path)).toString("utf8")
|
|
68791
68936
|
);
|
|
68792
|
-
const eventDirectory = (0,
|
|
68937
|
+
const eventDirectory = (0, import_node_path19.join)(rootDirectory, LOCAL_EVENTS_DIRECTORY_PATH4);
|
|
68793
68938
|
const useCloudDelivery = input3.cloud === true;
|
|
68794
68939
|
const connectionConfig = useCloudDelivery ? await readConnectionConfig(
|
|
68795
68940
|
rootDirectory,
|
|
@@ -68870,7 +69015,7 @@ async function watchCommand(input3, dependencies = {}) {
|
|
|
68870
69015
|
events,
|
|
68871
69016
|
`${input3.logPath}:${batchesWritten + 1}`
|
|
68872
69017
|
);
|
|
68873
|
-
const destinationPath = (0,
|
|
69018
|
+
const destinationPath = (0, import_node_path19.join)(eventDirectory, eventFile);
|
|
68874
69019
|
const temporaryPath = `${destinationPath}.tmp`;
|
|
68875
69020
|
await writeFile(temporaryPath, `${JSON.stringify(events, null, 2)}
|
|
68876
69021
|
`);
|
|
@@ -68921,11 +69066,11 @@ async function watchCommand(input3, dependencies = {}) {
|
|
|
68921
69066
|
}
|
|
68922
69067
|
|
|
68923
69068
|
// src/setup-command.ts
|
|
68924
|
-
var
|
|
68925
|
-
var
|
|
69069
|
+
var import_promises19 = require("node:fs/promises");
|
|
69070
|
+
var import_node_path22 = require("node:path");
|
|
68926
69071
|
|
|
68927
69072
|
// src/setup-service-discovery.ts
|
|
68928
|
-
var
|
|
69073
|
+
var import_node_path20 = require("node:path");
|
|
68929
69074
|
var IGNORED_ROOT_DIRECTORIES = /* @__PURE__ */ new Set([
|
|
68930
69075
|
"apps",
|
|
68931
69076
|
"contracts",
|
|
@@ -69021,36 +69166,36 @@ async function inferRuntime(rootDirectory, servicePath, packageJson, stat, prima
|
|
|
69021
69166
|
return "Node.js";
|
|
69022
69167
|
}
|
|
69023
69168
|
for (const fileName of ["tsconfig.json", "tsconfig.base.json"]) {
|
|
69024
|
-
if (await pathExists5((0,
|
|
69169
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, fileName), stat)) {
|
|
69025
69170
|
return "Node.js";
|
|
69026
69171
|
}
|
|
69027
69172
|
}
|
|
69028
|
-
if (await pathExists5((0,
|
|
69173
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "requirements.txt"), stat) || await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "pyproject.toml"), stat) || await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "manage.py"), stat)) {
|
|
69029
69174
|
return "Python";
|
|
69030
69175
|
}
|
|
69031
|
-
if (await pathExists5((0,
|
|
69176
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "composer.json"), stat) || await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "artisan"), stat) || await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "wp-config.php"), stat)) {
|
|
69032
69177
|
return "PHP";
|
|
69033
69178
|
}
|
|
69034
|
-
if (await pathExists5((0,
|
|
69179
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "go.mod"), stat)) {
|
|
69035
69180
|
return "Go";
|
|
69036
69181
|
}
|
|
69037
|
-
if (await pathExists5((0,
|
|
69182
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "Gemfile"), stat) || await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "Gemfile.lock"), stat)) {
|
|
69038
69183
|
return "Ruby";
|
|
69039
69184
|
}
|
|
69040
|
-
if (await pathExists5((0,
|
|
69185
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "pom.xml"), stat) || await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "build.gradle"), stat) || await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "build.gradle.kts"), stat)) {
|
|
69041
69186
|
return "Java";
|
|
69042
69187
|
}
|
|
69043
|
-
if (await pathExists5((0,
|
|
69188
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "Cargo.toml"), stat)) {
|
|
69044
69189
|
return "Rust";
|
|
69045
69190
|
}
|
|
69046
69191
|
return allowFallback ? inferRuntimeFromLanguages(primaryLanguages) : "unknown";
|
|
69047
69192
|
}
|
|
69048
69193
|
async function inferPythonFramework(rootDirectory, servicePath, readFile, stat) {
|
|
69049
|
-
if (await pathExists5((0,
|
|
69194
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "manage.py"), stat)) {
|
|
69050
69195
|
return "Django";
|
|
69051
69196
|
}
|
|
69052
69197
|
for (const fileName of ["requirements.txt", "pyproject.toml"]) {
|
|
69053
|
-
const filePath = (0,
|
|
69198
|
+
const filePath = (0, import_node_path20.join)(rootDirectory, servicePath, fileName);
|
|
69054
69199
|
try {
|
|
69055
69200
|
const contents = await readFile(filePath);
|
|
69056
69201
|
if (/fastapi/iu.test(contents)) {
|
|
@@ -69068,39 +69213,39 @@ async function inferPythonFramework(rootDirectory, servicePath, readFile, stat)
|
|
|
69068
69213
|
return "unknown";
|
|
69069
69214
|
}
|
|
69070
69215
|
async function inferPhpFramework(rootDirectory, servicePath, readFile, stat) {
|
|
69071
|
-
if (await pathExists5((0,
|
|
69216
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "artisan"), stat)) {
|
|
69072
69217
|
return "Laravel";
|
|
69073
69218
|
}
|
|
69074
|
-
if (await pathExists5((0,
|
|
69219
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "wp-config.php"), stat)) {
|
|
69075
69220
|
return "WordPress";
|
|
69076
69221
|
}
|
|
69077
|
-
if (await fileContains((0,
|
|
69222
|
+
if (await fileContains((0, import_node_path20.join)(rootDirectory, servicePath, "composer.json"), /laravel\/framework/iu, readFile)) {
|
|
69078
69223
|
return "Laravel";
|
|
69079
69224
|
}
|
|
69080
|
-
if (await fileContains((0,
|
|
69225
|
+
if (await fileContains((0, import_node_path20.join)(rootDirectory, servicePath, "composer.json"), /symfony\/(framework-bundle|http-kernel)/iu, readFile)) {
|
|
69081
69226
|
return "Symfony";
|
|
69082
69227
|
}
|
|
69083
69228
|
return "unknown";
|
|
69084
69229
|
}
|
|
69085
69230
|
async function inferRubyFramework(rootDirectory, servicePath, readFile, stat) {
|
|
69086
|
-
if (await pathExists5((0,
|
|
69231
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "config", "application.rb"), stat)) {
|
|
69087
69232
|
return "Rails";
|
|
69088
69233
|
}
|
|
69089
|
-
if (await fileContains((0,
|
|
69234
|
+
if (await fileContains((0, import_node_path20.join)(rootDirectory, servicePath, "Gemfile"), /gem\s+["']rails["']/iu, readFile)) {
|
|
69090
69235
|
return "Rails";
|
|
69091
69236
|
}
|
|
69092
|
-
if (await pathExists5((0,
|
|
69237
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "config.ru"), stat) || await fileContains((0, import_node_path20.join)(rootDirectory, servicePath, "Gemfile"), /gem\s+["']rack["']/iu, readFile)) {
|
|
69093
69238
|
return "Rack";
|
|
69094
69239
|
}
|
|
69095
69240
|
return "unknown";
|
|
69096
69241
|
}
|
|
69097
69242
|
async function inferJavaFramework(rootDirectory, servicePath, readFile, stat) {
|
|
69098
69243
|
for (const fileName of ["pom.xml", "build.gradle", "build.gradle.kts"]) {
|
|
69099
|
-
if (await fileContains((0,
|
|
69244
|
+
if (await fileContains((0, import_node_path20.join)(rootDirectory, servicePath, fileName), /spring-boot/iu, readFile)) {
|
|
69100
69245
|
return "Spring Boot";
|
|
69101
69246
|
}
|
|
69102
69247
|
}
|
|
69103
|
-
if (await pathExists5((0,
|
|
69248
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "src", "main", "webapp"), stat) || await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "src", "main", "webapp", "WEB-INF", "web.xml"), stat)) {
|
|
69104
69249
|
return "Servlet";
|
|
69105
69250
|
}
|
|
69106
69251
|
return "unknown";
|
|
@@ -69148,13 +69293,13 @@ function inferServiceKind(serviceName, servicePath, framework, packageJson) {
|
|
|
69148
69293
|
return "backend";
|
|
69149
69294
|
}
|
|
69150
69295
|
async function buildDetectedService(rootDirectory, servicePath, readFile, stat, fallbackPackageJson, primaryLanguages, allowFallback) {
|
|
69151
|
-
const packageJson = await readJsonFile2((0,
|
|
69296
|
+
const packageJson = await readJsonFile2((0, import_node_path20.join)(rootDirectory, servicePath, "package.json"), readFile);
|
|
69152
69297
|
const runtime = await inferRuntime(rootDirectory, servicePath, packageJson, stat, primaryLanguages, allowFallback);
|
|
69153
69298
|
if (runtime === "unknown" && !allowFallback) {
|
|
69154
69299
|
return null;
|
|
69155
69300
|
}
|
|
69156
69301
|
const framework = await inferServiceFramework(rootDirectory, servicePath, runtime, packageJson, readFile, stat, fallbackPackageJson, allowFallback);
|
|
69157
|
-
const name = packageJson?.name ?? (0,
|
|
69302
|
+
const name = packageJson?.name ?? (0, import_node_path20.basename)(servicePath);
|
|
69158
69303
|
return {
|
|
69159
69304
|
name,
|
|
69160
69305
|
kind: inferServiceKind(name, servicePath, framework, packageJson),
|
|
@@ -69172,12 +69317,12 @@ async function detectRootServicePaths(rootDirectory, readdir, stat) {
|
|
|
69172
69317
|
if (entry.startsWith(".") || IGNORED_ROOT_DIRECTORIES.has(entry)) {
|
|
69173
69318
|
continue;
|
|
69174
69319
|
}
|
|
69175
|
-
const entryPath = (0,
|
|
69320
|
+
const entryPath = (0, import_node_path20.join)(rootDirectory, entry);
|
|
69176
69321
|
const entryStats = await stat(entryPath);
|
|
69177
69322
|
if (!entryStats.isDirectory()) {
|
|
69178
69323
|
continue;
|
|
69179
69324
|
}
|
|
69180
|
-
if (await pathExists5((0,
|
|
69325
|
+
if (await pathExists5((0, import_node_path20.join)(entryPath, "package.json"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "requirements.txt"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "pyproject.toml"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "manage.py"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "composer.json"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "artisan"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "wp-config.php"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "go.mod"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "Gemfile"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "Gemfile.lock"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "pom.xml"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "build.gradle"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "build.gradle.kts"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "Cargo.toml"), stat)) {
|
|
69181
69326
|
servicePaths.push(entry);
|
|
69182
69327
|
}
|
|
69183
69328
|
}
|
|
@@ -69185,11 +69330,11 @@ async function detectRootServicePaths(rootDirectory, readdir, stat) {
|
|
|
69185
69330
|
}
|
|
69186
69331
|
async function detectServices(rootDirectory, readdir, readFile, stat, packageJson, primaryLanguages) {
|
|
69187
69332
|
const services = [];
|
|
69188
|
-
const appsDirectory = (0,
|
|
69333
|
+
const appsDirectory = (0, import_node_path20.join)(rootDirectory, "apps");
|
|
69189
69334
|
if (await pathExists5(appsDirectory, stat)) {
|
|
69190
69335
|
const entries2 = (await readdir(appsDirectory)).sort();
|
|
69191
69336
|
for (const entry of entries2) {
|
|
69192
|
-
const entryPath = (0,
|
|
69337
|
+
const entryPath = (0, import_node_path20.join)(appsDirectory, entry);
|
|
69193
69338
|
const entryStats = await stat(entryPath);
|
|
69194
69339
|
if (!entryStats.isDirectory()) {
|
|
69195
69340
|
continue;
|
|
@@ -69226,7 +69371,7 @@ async function detectServices(rootDirectory, readdir, readFile, stat, packageJso
|
|
|
69226
69371
|
}
|
|
69227
69372
|
|
|
69228
69373
|
// src/setup-relay-guidance.ts
|
|
69229
|
-
var
|
|
69374
|
+
var import_node_path21 = require("node:path");
|
|
69230
69375
|
var RELAY_ROUTE_PATH = "/debugbundle/browser";
|
|
69231
69376
|
var WORDPRESS_RELAY_ROUTE_PATH = "/wp-json/debugbundle/v1/browser";
|
|
69232
69377
|
async function pathExists6(filePath, stat) {
|
|
@@ -69252,7 +69397,7 @@ async function readJsonFile3(filePath, readFile) {
|
|
|
69252
69397
|
}
|
|
69253
69398
|
async function readPackageJsonForService(rootDirectory, servicePath, readFile) {
|
|
69254
69399
|
const normalizedServicePath = servicePath === "." ? "" : servicePath ?? "";
|
|
69255
|
-
return readJsonFile3((0,
|
|
69400
|
+
return readJsonFile3((0, import_node_path21.join)(rootDirectory, normalizedServicePath, "package.json"), readFile);
|
|
69256
69401
|
}
|
|
69257
69402
|
function collectDependencyNames2(packageJson) {
|
|
69258
69403
|
return /* @__PURE__ */ new Set([
|
|
@@ -69333,9 +69478,9 @@ function buildInstructionOnlyGuidance(backendService, frontendServices, runtimeI
|
|
|
69333
69478
|
}
|
|
69334
69479
|
async function scaffoldFastifyRelayRoute(rootDirectory, servicePath, dependencies, frontendServices, backendService) {
|
|
69335
69480
|
const candidatePath = await findFirstExistingPath([
|
|
69336
|
-
(0,
|
|
69337
|
-
(0,
|
|
69338
|
-
(0,
|
|
69481
|
+
(0, import_node_path21.join)(rootDirectory, servicePath, "src", "server.ts"),
|
|
69482
|
+
(0, import_node_path21.join)(rootDirectory, servicePath, "src", "main.ts"),
|
|
69483
|
+
(0, import_node_path21.join)(rootDirectory, servicePath, "server.ts")
|
|
69339
69484
|
], dependencies.stat);
|
|
69340
69485
|
if (candidatePath === null) {
|
|
69341
69486
|
return buildInstructionOnlyGuidance(
|
|
@@ -69375,9 +69520,9 @@ async function scaffoldFastifyRelayRoute(rootDirectory, servicePath, dependencie
|
|
|
69375
69520
|
}
|
|
69376
69521
|
async function scaffoldExpressRelayRoute(rootDirectory, servicePath, dependencies, frontendServices, backendService) {
|
|
69377
69522
|
const candidatePath = await findFirstExistingPath([
|
|
69378
|
-
(0,
|
|
69379
|
-
(0,
|
|
69380
|
-
(0,
|
|
69523
|
+
(0, import_node_path21.join)(rootDirectory, servicePath, "src", "server.ts"),
|
|
69524
|
+
(0, import_node_path21.join)(rootDirectory, servicePath, "src", "app.ts"),
|
|
69525
|
+
(0, import_node_path21.join)(rootDirectory, servicePath, "server.ts")
|
|
69381
69526
|
], dependencies.stat);
|
|
69382
69527
|
if (candidatePath === null) {
|
|
69383
69528
|
return buildInstructionOnlyGuidance(
|
|
@@ -69417,8 +69562,8 @@ async function scaffoldExpressRelayRoute(rootDirectory, servicePath, dependencie
|
|
|
69417
69562
|
}
|
|
69418
69563
|
async function scaffoldNextJsRelayRoute(rootDirectory, servicePath, dependencies, frontendServices, backendService) {
|
|
69419
69564
|
const candidateAppRoot = await findFirstExistingPath([
|
|
69420
|
-
(0,
|
|
69421
|
-
(0,
|
|
69565
|
+
(0, import_node_path21.join)(rootDirectory, servicePath, "app"),
|
|
69566
|
+
(0, import_node_path21.join)(rootDirectory, servicePath, "src", "app")
|
|
69422
69567
|
], dependencies.stat);
|
|
69423
69568
|
if (candidateAppRoot === null) {
|
|
69424
69569
|
return buildInstructionOnlyGuidance(
|
|
@@ -69427,8 +69572,8 @@ async function scaffoldNextJsRelayRoute(rootDirectory, servicePath, dependencies
|
|
|
69427
69572
|
`Add app/debugbundle/browser/route.ts in ${servicePath} and export debugBundleRelay as POST from @debugbundle/sdk-node/relay/nextjs.`
|
|
69428
69573
|
);
|
|
69429
69574
|
}
|
|
69430
|
-
const routeDirectory = (0,
|
|
69431
|
-
const routePath = (0,
|
|
69575
|
+
const routeDirectory = (0, import_node_path21.join)(candidateAppRoot, "debugbundle", "browser");
|
|
69576
|
+
const routePath = (0, import_node_path21.join)(routeDirectory, "route.ts");
|
|
69432
69577
|
await dependencies.mkdir(routeDirectory, { recursive: true });
|
|
69433
69578
|
await dependencies.writeFile(routePath, 'export { debugBundleRelay as POST } from "@debugbundle/sdk-node/relay/nextjs";\n');
|
|
69434
69579
|
return {
|
|
@@ -69597,10 +69742,10 @@ async function resolveRelaySetup(rootDirectory, services, selectedTargetNames, r
|
|
|
69597
69742
|
}
|
|
69598
69743
|
|
|
69599
69744
|
// src/setup-target-selection.ts
|
|
69600
|
-
var
|
|
69745
|
+
var import_promises18 = require("node:readline/promises");
|
|
69601
69746
|
var import_node_process3 = require("node:process");
|
|
69602
69747
|
function defaultPromptUser(prompt) {
|
|
69603
|
-
const terminal = (0,
|
|
69748
|
+
const terminal = (0, import_promises18.createInterface)({ input: import_node_process3.stdin, output: import_node_process3.stdout });
|
|
69604
69749
|
return terminal.question(prompt).finally(() => {
|
|
69605
69750
|
terminal.close();
|
|
69606
69751
|
});
|
|
@@ -69715,41 +69860,41 @@ function detectPackageManagers(rootDirectory, packageJson, existingPaths) {
|
|
|
69715
69860
|
if (declaredPackageManager === "yarn") {
|
|
69716
69861
|
packageManagers.add("yarn");
|
|
69717
69862
|
}
|
|
69718
|
-
if (existingPaths.has((0,
|
|
69863
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "pnpm-lock.yaml")) || existingPaths.has((0, import_node_path22.join)(rootDirectory, "pnpm-workspace.yaml"))) {
|
|
69719
69864
|
packageManagers.add("pnpm");
|
|
69720
69865
|
}
|
|
69721
|
-
if (existingPaths.has((0,
|
|
69866
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "package-lock.json"))) {
|
|
69722
69867
|
packageManagers.add("npm");
|
|
69723
69868
|
}
|
|
69724
|
-
if (existingPaths.has((0,
|
|
69869
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "yarn.lock"))) {
|
|
69725
69870
|
packageManagers.add("yarn");
|
|
69726
69871
|
}
|
|
69727
|
-
if (existingPaths.has((0,
|
|
69872
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "poetry.lock")) || existingPaths.has((0, import_node_path22.join)(rootDirectory, "pyproject.toml"))) {
|
|
69728
69873
|
packageManagers.add("poetry");
|
|
69729
69874
|
}
|
|
69730
|
-
if (existingPaths.has((0,
|
|
69875
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "composer.json"))) {
|
|
69731
69876
|
packageManagers.add("composer");
|
|
69732
69877
|
}
|
|
69733
69878
|
return [...packageManagers].sort();
|
|
69734
69879
|
}
|
|
69735
69880
|
function detectPrimaryLanguages(rootDirectory, existingPaths) {
|
|
69736
69881
|
const languages = /* @__PURE__ */ new Set();
|
|
69737
|
-
if (existingPaths.has((0,
|
|
69882
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "tsconfig.json")) || existingPaths.has((0, import_node_path22.join)(rootDirectory, "tsconfig.base.json"))) {
|
|
69738
69883
|
languages.add("TypeScript");
|
|
69739
|
-
} else if (existingPaths.has((0,
|
|
69884
|
+
} else if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "package.json"))) {
|
|
69740
69885
|
languages.add("JavaScript");
|
|
69741
69886
|
}
|
|
69742
|
-
if (existingPaths.has((0,
|
|
69887
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "pyproject.toml"))) {
|
|
69743
69888
|
languages.add("Python");
|
|
69744
69889
|
}
|
|
69745
|
-
if (existingPaths.has((0,
|
|
69890
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "composer.json"))) {
|
|
69746
69891
|
languages.add("PHP");
|
|
69747
69892
|
}
|
|
69748
69893
|
return [...languages].sort();
|
|
69749
69894
|
}
|
|
69750
69895
|
function detectDeploymentTargets(rootDirectory, existingPaths) {
|
|
69751
69896
|
const targets = /* @__PURE__ */ new Set();
|
|
69752
|
-
if (existingPaths.has((0,
|
|
69897
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "docker-compose.yml")) || existingPaths.has((0, import_node_path22.join)(rootDirectory, "deploy", "selfhost", "docker-compose.yml"))) {
|
|
69753
69898
|
targets.add("docker-compose");
|
|
69754
69899
|
}
|
|
69755
69900
|
return [...targets].sort();
|
|
@@ -69759,7 +69904,7 @@ function detectDeveloperWorkflow(packageJson, workflowName, existingPaths, rootD
|
|
|
69759
69904
|
if (typeof packageScript === "string" && packageScript.length > 0) {
|
|
69760
69905
|
return packageScript;
|
|
69761
69906
|
}
|
|
69762
|
-
if (existingPaths.has((0,
|
|
69907
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "Makefile"))) {
|
|
69763
69908
|
return `make ${workflowName}`;
|
|
69764
69909
|
}
|
|
69765
69910
|
return "manual";
|
|
@@ -69780,7 +69925,7 @@ function detectInstallWorkflow(packageManagers, existingPaths, rootDirectory) {
|
|
|
69780
69925
|
if (packageManagers.includes("composer")) {
|
|
69781
69926
|
return "composer install";
|
|
69782
69927
|
}
|
|
69783
|
-
if (existingPaths.has((0,
|
|
69928
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "Makefile"))) {
|
|
69784
69929
|
return "make install";
|
|
69785
69930
|
}
|
|
69786
69931
|
return "manual";
|
|
@@ -69813,7 +69958,7 @@ async function detectRootPaths(rootDirectory, readdir, stat) {
|
|
|
69813
69958
|
if (entry.startsWith(".") || entry === "node_modules") {
|
|
69814
69959
|
continue;
|
|
69815
69960
|
}
|
|
69816
|
-
const entryStats = await stat((0,
|
|
69961
|
+
const entryStats = await stat((0, import_node_path22.join)(rootDirectory, entry));
|
|
69817
69962
|
if (entryStats.isDirectory()) {
|
|
69818
69963
|
rootPaths.push(entry);
|
|
69819
69964
|
}
|
|
@@ -69823,8 +69968,8 @@ async function detectRootPaths(rootDirectory, readdir, stat) {
|
|
|
69823
69968
|
async function detectInfrastructure(rootDirectory, readFile) {
|
|
69824
69969
|
const composeContents = [];
|
|
69825
69970
|
for (const candidatePath of [
|
|
69826
|
-
(0,
|
|
69827
|
-
(0,
|
|
69971
|
+
(0, import_node_path22.join)(rootDirectory, "docker-compose.yml"),
|
|
69972
|
+
(0, import_node_path22.join)(rootDirectory, "deploy", "selfhost", "docker-compose.yml")
|
|
69828
69973
|
]) {
|
|
69829
69974
|
try {
|
|
69830
69975
|
composeContents.push(await readFile(candidatePath));
|
|
@@ -69856,21 +70001,21 @@ async function detectInfrastructure(rootDirectory, readFile) {
|
|
|
69856
70001
|
};
|
|
69857
70002
|
}
|
|
69858
70003
|
async function buildProfile(rootDirectory, dependencies) {
|
|
69859
|
-
const packageJson = await readJsonFile4((0,
|
|
70004
|
+
const packageJson = await readJsonFile4((0, import_node_path22.join)(rootDirectory, "package.json"), dependencies.readFile);
|
|
69860
70005
|
const existingPaths = /* @__PURE__ */ new Set([
|
|
69861
|
-
(0,
|
|
69862
|
-
(0,
|
|
69863
|
-
(0,
|
|
69864
|
-
(0,
|
|
69865
|
-
(0,
|
|
69866
|
-
(0,
|
|
69867
|
-
(0,
|
|
69868
|
-
(0,
|
|
69869
|
-
(0,
|
|
69870
|
-
(0,
|
|
69871
|
-
(0,
|
|
69872
|
-
(0,
|
|
69873
|
-
(0,
|
|
70006
|
+
(0, import_node_path22.join)(rootDirectory, "package.json"),
|
|
70007
|
+
(0, import_node_path22.join)(rootDirectory, "pnpm-lock.yaml"),
|
|
70008
|
+
(0, import_node_path22.join)(rootDirectory, "pnpm-workspace.yaml"),
|
|
70009
|
+
(0, import_node_path22.join)(rootDirectory, "package-lock.json"),
|
|
70010
|
+
(0, import_node_path22.join)(rootDirectory, "yarn.lock"),
|
|
70011
|
+
(0, import_node_path22.join)(rootDirectory, "poetry.lock"),
|
|
70012
|
+
(0, import_node_path22.join)(rootDirectory, "pyproject.toml"),
|
|
70013
|
+
(0, import_node_path22.join)(rootDirectory, "composer.json"),
|
|
70014
|
+
(0, import_node_path22.join)(rootDirectory, "docker-compose.yml"),
|
|
70015
|
+
(0, import_node_path22.join)(rootDirectory, "deploy", "selfhost", "docker-compose.yml"),
|
|
70016
|
+
(0, import_node_path22.join)(rootDirectory, "Makefile"),
|
|
70017
|
+
(0, import_node_path22.join)(rootDirectory, "tsconfig.json"),
|
|
70018
|
+
(0, import_node_path22.join)(rootDirectory, "tsconfig.base.json")
|
|
69874
70019
|
]);
|
|
69875
70020
|
const confirmedExistingPaths = /* @__PURE__ */ new Set();
|
|
69876
70021
|
for (const candidatePath of existingPaths) {
|
|
@@ -69920,21 +70065,21 @@ async function buildProfile(rootDirectory, dependencies) {
|
|
|
69920
70065
|
async function setupCommand(input3, dependencies = {}) {
|
|
69921
70066
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
69922
70067
|
const mkdir5 = dependencies.mkdir ?? (async (path, options) => {
|
|
69923
|
-
await (0,
|
|
70068
|
+
await (0, import_promises19.mkdir)(path, options);
|
|
69924
70069
|
});
|
|
69925
|
-
const readFile = dependencies.readFile ?? (async (path) => (0,
|
|
69926
|
-
const readdir = dependencies.readdir ?? (async (path) => (0,
|
|
69927
|
-
const stat = dependencies.stat ?? (async (path) => (0,
|
|
69928
|
-
const writeFile = dependencies.writeFile ?? (async (path, content) => (0,
|
|
70070
|
+
const readFile = dependencies.readFile ?? (async (path) => (0, import_promises19.readFile)(path, "utf8"));
|
|
70071
|
+
const readdir = dependencies.readdir ?? (async (path) => (0, import_promises19.readdir)(path));
|
|
70072
|
+
const stat = dependencies.stat ?? (async (path) => (0, import_promises19.stat)(path));
|
|
70073
|
+
const writeFile = dependencies.writeFile ?? (async (path, content) => (0, import_promises19.writeFile)(path, content, "utf8"));
|
|
69929
70074
|
const now = dependencies.now ?? (() => /* @__PURE__ */ new Date());
|
|
69930
70075
|
try {
|
|
69931
70076
|
const rootDirectory = await projectRoot(cwd());
|
|
69932
70077
|
const selectedAgents = await chooseAgents(rootDirectory, input3, dependencies);
|
|
69933
|
-
const packageJson = await readJsonFile4((0,
|
|
70078
|
+
const packageJson = await readJsonFile4((0, import_node_path22.join)(rootDirectory, "package.json"), readFile);
|
|
69934
70079
|
for (const filePath of [...GENERATED_FILE_PATHS, GITIGNORE_FILE_PATH]) await safePath(rootDirectory, filePath);
|
|
69935
70080
|
for (const directoryPath of ENSURED_DIRECTORY_PATHS) {
|
|
69936
70081
|
await safePath(rootDirectory, directoryPath);
|
|
69937
|
-
await mkdir5((0,
|
|
70082
|
+
await mkdir5((0, import_node_path22.join)(rootDirectory, directoryPath), { recursive: true });
|
|
69938
70083
|
}
|
|
69939
70084
|
const profile = await buildProfile(rootDirectory, {
|
|
69940
70085
|
now,
|
|
@@ -69952,11 +70097,11 @@ async function setupCommand(input3, dependencies = {}) {
|
|
|
69952
70097
|
if (!preservedProfile) {
|
|
69953
70098
|
const contents = `${JSON.stringify(profile, null, 2)}
|
|
69954
70099
|
`;
|
|
69955
|
-
if (dependencies.writeFile) await dependencies.writeFile((0,
|
|
70100
|
+
if (dependencies.writeFile) await dependencies.writeFile((0, import_node_path22.join)(rootDirectory, PROFILE_FILE_PATH), contents);
|
|
69956
70101
|
else await writeManaged(rootDirectory, PROFILE_FILE_PATH, contents, void 0);
|
|
69957
70102
|
}
|
|
69958
70103
|
if (!preservedConnection) {
|
|
69959
|
-
if (dependencies.writeFile) await dependencies.writeFile((0,
|
|
70104
|
+
if (dependencies.writeFile) await dependencies.writeFile((0, import_node_path22.join)(rootDirectory, CONNECTION_FILE_PATH), buildConnectionConfig());
|
|
69960
70105
|
else await writeManaged(rootDirectory, CONNECTION_FILE_PATH, buildConnectionConfig(), void 0);
|
|
69961
70106
|
}
|
|
69962
70107
|
const agentReport = await manageAgentSetup({ root: rootDirectory, files: canonicalFiles(), legacyHashes: legacy_skill_hashes_default, instruction: buildManagedAgentsSection(), fix: true, legacyInstructions: true, ...selectedAgents === void 0 ? {} : { selected: selectedAgents } });
|
|
@@ -71395,14 +71540,14 @@ async function listServicesWithAuthCommand(input3, dependencies) {
|
|
|
71395
71540
|
}
|
|
71396
71541
|
|
|
71397
71542
|
// src/project-adoption-commands.ts
|
|
71398
|
-
var
|
|
71543
|
+
var import_node_path24 = require("node:path");
|
|
71399
71544
|
|
|
71400
71545
|
// ../../packages/project-adoption/src/index.ts
|
|
71401
71546
|
var import_node_fs3 = require("node:fs");
|
|
71402
|
-
var
|
|
71547
|
+
var import_promises20 = require("node:fs/promises");
|
|
71403
71548
|
var import_node_crypto9 = require("node:crypto");
|
|
71404
|
-
var
|
|
71405
|
-
var
|
|
71549
|
+
var import_node_path23 = require("node:path");
|
|
71550
|
+
var paths2 = [".debugbundle/local/connection.json", ".debugbundle/profile.json"];
|
|
71406
71551
|
var digest3 = external_exports.string().regex(/^[a-f0-9]{64}$/);
|
|
71407
71552
|
var changeSchema = external_exports.object({ pointer: external_exports.string(), before: external_exports.string().nullable(), after: external_exports.string().nullable() }).strict();
|
|
71408
71553
|
var planBody = external_exports.object({
|
|
@@ -71414,7 +71559,7 @@ var planBody = external_exports.object({
|
|
|
71414
71559
|
manifest_digest: digest3,
|
|
71415
71560
|
files: external_exports.array(
|
|
71416
71561
|
external_exports.object({
|
|
71417
|
-
path: external_exports.enum(
|
|
71562
|
+
path: external_exports.enum(paths2),
|
|
71418
71563
|
before_sha256: digest3,
|
|
71419
71564
|
after_sha256: digest3,
|
|
71420
71565
|
changes: external_exports.array(changeSchema)
|
|
@@ -71441,20 +71586,20 @@ function manifestFor(input3) {
|
|
|
71441
71586
|
fail("adoption_manifest_stale");
|
|
71442
71587
|
return { operation, manifest };
|
|
71443
71588
|
}
|
|
71444
|
-
async function hierarchy(root,
|
|
71445
|
-
if ((0,
|
|
71589
|
+
async function hierarchy(root, relative8) {
|
|
71590
|
+
if ((0, import_node_path23.resolve)(root) !== root || await (0, import_promises20.realpath)(root) !== root) fail("adoption_unsafe_path");
|
|
71446
71591
|
try {
|
|
71447
|
-
await safePath(root,
|
|
71592
|
+
await safePath(root, relative8);
|
|
71448
71593
|
} catch {
|
|
71449
71594
|
fail("adoption_unsafe_path");
|
|
71450
71595
|
}
|
|
71451
71596
|
}
|
|
71452
71597
|
async function read(root, path) {
|
|
71453
71598
|
await hierarchy(root, path);
|
|
71454
|
-
const full = (0,
|
|
71599
|
+
const full = (0, import_node_path23.join)(root, path), before = await (0, import_promises20.lstat)(full);
|
|
71455
71600
|
if (!before.isFile() || before.isSymbolicLink() || before.nlink !== 1)
|
|
71456
71601
|
fail("adoption_unsafe_path");
|
|
71457
|
-
const file2 = await (0,
|
|
71602
|
+
const file2 = await (0, import_promises20.open)(full, import_node_fs3.constants.O_RDONLY | import_node_fs3.constants.O_NOFOLLOW | import_node_fs3.constants.O_NONBLOCK);
|
|
71458
71603
|
try {
|
|
71459
71604
|
const info = await file2.stat();
|
|
71460
71605
|
if (!info.isFile() || info.dev !== before.dev || info.ino !== before.ino || info.size > 1024 * 1024)
|
|
@@ -71494,7 +71639,7 @@ function child(parent, key) {
|
|
|
71494
71639
|
}
|
|
71495
71640
|
function render(file2, manifest, original, operationId) {
|
|
71496
71641
|
const document = structuredClone(file2.data), changes = [];
|
|
71497
|
-
if (file2.path ===
|
|
71642
|
+
if (file2.path === paths2[0]) {
|
|
71498
71643
|
const parsed = ConnectionConfigSchema.safeParse(document);
|
|
71499
71644
|
if (!parsed.success || parsed.data.mode !== "connected" || !manifest.origin_project_ids.includes(parsed.data.cloud_project_id ?? ""))
|
|
71500
71645
|
fail("adoption_workspace_not_in_merge");
|
|
@@ -71549,7 +71694,7 @@ function render(file2, manifest, original, operationId) {
|
|
|
71549
71694
|
}
|
|
71550
71695
|
async function previewProjectAdoption(input3) {
|
|
71551
71696
|
const { operation, manifest } = manifestFor(input3.operation);
|
|
71552
|
-
const files = await Promise.all(
|
|
71697
|
+
const files = await Promise.all(paths2.map((path) => read(input3.workspace_root, path)));
|
|
71553
71698
|
let original = files[0].data["cloud_project_id"];
|
|
71554
71699
|
if (typeof original !== "string" || !manifest.origin_project_ids.includes(original))
|
|
71555
71700
|
fail("adoption_workspace_not_in_merge");
|
|
@@ -71578,9 +71723,9 @@ async function previewProjectAdoption(input3) {
|
|
|
71578
71723
|
return { ...body, plan_digest: hash2(JSON.stringify(body)) };
|
|
71579
71724
|
}
|
|
71580
71725
|
async function replace(root, snapshot, bytes, expectedHash) {
|
|
71581
|
-
const path = (0,
|
|
71726
|
+
const path = (0, import_node_path23.join)(root, snapshot.path), temporary = (0, import_node_path23.join)((0, import_node_path23.dirname)(path), `.debugbundle-adoption-${(0, import_node_crypto9.randomBytes)(16).toString("hex")}.tmp`);
|
|
71582
71727
|
await hierarchy(root, snapshot.path);
|
|
71583
|
-
const handle = await (0,
|
|
71728
|
+
const handle = await (0, import_promises20.open)(
|
|
71584
71729
|
temporary,
|
|
71585
71730
|
import_node_fs3.constants.O_WRONLY | import_node_fs3.constants.O_CREAT | import_node_fs3.constants.O_EXCL | import_node_fs3.constants.O_NOFOLLOW,
|
|
71586
71731
|
384
|
|
@@ -71598,10 +71743,10 @@ async function replace(root, snapshot, bytes, expectedHash) {
|
|
|
71598
71743
|
if (hash2(current.bytes) !== expectedHash || current.dev !== snapshot.dev || current.ino !== snapshot.ino)
|
|
71599
71744
|
fail("adoption_file_changed");
|
|
71600
71745
|
await hierarchy(root, snapshot.path);
|
|
71601
|
-
await (0,
|
|
71746
|
+
await (0, import_promises20.rename)(temporary, path);
|
|
71602
71747
|
return { ...snapshot, bytes, dev: placed.dev, ino: placed.ino };
|
|
71603
71748
|
} finally {
|
|
71604
|
-
await (0,
|
|
71749
|
+
await (0, import_promises20.unlink)(temporary).catch(() => void 0);
|
|
71605
71750
|
}
|
|
71606
71751
|
}
|
|
71607
71752
|
async function applyProjectAdoption(input3, hooks = {}) {
|
|
@@ -71613,9 +71758,9 @@ async function applyProjectAdoption(input3, hooks = {}) {
|
|
|
71613
71758
|
const { operation, manifest } = manifestFor(input3.operation);
|
|
71614
71759
|
if (operation.operation_id !== plan.operation_id || operation.canonical_project_id !== plan.canonical_project_id || hash2(JSON.stringify(manifest)) !== plan.manifest_digest || !manifest.origin_project_ids.includes(plan.original_project_id))
|
|
71615
71760
|
fail("adoption_manifest_stale");
|
|
71616
|
-
await hierarchy(plan.workspace_root,
|
|
71617
|
-
const lockPath = (0,
|
|
71618
|
-
const lock = await (0,
|
|
71761
|
+
await hierarchy(plan.workspace_root, paths2[0]);
|
|
71762
|
+
const lockPath = (0, import_node_path23.join)(plan.workspace_root, ".debugbundle/adoption.lock");
|
|
71763
|
+
const lock = await (0, import_promises20.open)(
|
|
71619
71764
|
lockPath,
|
|
71620
71765
|
import_node_fs3.constants.O_WRONLY | import_node_fs3.constants.O_CREAT | import_node_fs3.constants.O_EXCL | import_node_fs3.constants.O_NOFOLLOW,
|
|
71621
71766
|
384
|
|
@@ -71678,10 +71823,10 @@ async function applyProjectAdoption(input3, hooks = {}) {
|
|
|
71678
71823
|
} finally {
|
|
71679
71824
|
await lock.close();
|
|
71680
71825
|
await hierarchy(plan.workspace_root, ".debugbundle/adoption.lock");
|
|
71681
|
-
const current = await (0,
|
|
71826
|
+
const current = await (0, import_promises20.lstat)(lockPath).catch(() => null);
|
|
71682
71827
|
if (!lockIdentity || !current?.isFile() || current.nlink !== 1 || current.dev !== lockIdentity.dev || current.ino !== lockIdentity.ino)
|
|
71683
71828
|
fail("adoption_lock_changed_review_required");
|
|
71684
|
-
await (0,
|
|
71829
|
+
await (0, import_promises20.unlink)(lockPath);
|
|
71685
71830
|
}
|
|
71686
71831
|
}
|
|
71687
71832
|
|
|
@@ -71771,7 +71916,7 @@ function createProjectMergesApi(client) {
|
|
|
71771
71916
|
}
|
|
71772
71917
|
|
|
71773
71918
|
// src/project-merge-commands.ts
|
|
71774
|
-
var
|
|
71919
|
+
var import_promises21 = require("node:fs/promises");
|
|
71775
71920
|
async function projectMergeWithAuthCommand(input3, dependencies = {}) {
|
|
71776
71921
|
try {
|
|
71777
71922
|
const auth2 = await (dependencies.readAuthState ?? readCliAuthState)(
|
|
@@ -71797,7 +71942,7 @@ async function projectMergeWithAuthCommand(input3, dependencies = {}) {
|
|
|
71797
71942
|
async function readProjectMergeJson(path, maximumBytes = 4 * 1024 * 1024) {
|
|
71798
71943
|
let file2;
|
|
71799
71944
|
try {
|
|
71800
|
-
file2 = await (0,
|
|
71945
|
+
file2 = await (0, import_promises21.open)(path, "r");
|
|
71801
71946
|
const info = await file2.stat();
|
|
71802
71947
|
if (!info.isFile() || info.size > maximumBytes) throw new Error("invalid");
|
|
71803
71948
|
const buffer = Buffer.alloc(maximumBytes + 1);
|
|
@@ -71915,7 +72060,7 @@ async function handleProjectAdoptionCommand(argv, run = projectAdoptionWithAuthC
|
|
|
71915
72060
|
if (action === "preview") {
|
|
71916
72061
|
expectNoUnknownOptions(argv, [...common, "operation-id", "workspace-root"]);
|
|
71917
72062
|
const operation_id = option("operation-id"), workspace_root = option("workspace-root");
|
|
71918
|
-
if (!external_exports.string().guid().safeParse(operation_id).success || !(0,
|
|
72063
|
+
if (!external_exports.string().guid().safeParse(operation_id).success || !(0, import_node_path24.isAbsolute)(workspace_root) || (0, import_node_path24.resolve)(workspace_root) !== workspace_root)
|
|
71919
72064
|
throw new CliInputError(
|
|
71920
72065
|
"Provide a valid operation ID and one canonical absolute workspace root."
|
|
71921
72066
|
);
|
|
@@ -72238,8 +72383,8 @@ function formatCloudResult(input3, exitCode, checks, errors, incidentId, verific
|
|
|
72238
72383
|
|
|
72239
72384
|
// src/verify-command.ts
|
|
72240
72385
|
var import_node_crypto10 = require("node:crypto");
|
|
72241
|
-
var
|
|
72242
|
-
var
|
|
72386
|
+
var import_promises22 = require("node:fs/promises");
|
|
72387
|
+
var import_node_path25 = require("node:path");
|
|
72243
72388
|
function localFailureStepName(checks) {
|
|
72244
72389
|
let hasLocalProcessing = false;
|
|
72245
72390
|
let hasIncidentRetrieval = false;
|
|
@@ -72442,10 +72587,10 @@ function buildVerificationEvent(now, projectId) {
|
|
|
72442
72587
|
};
|
|
72443
72588
|
}
|
|
72444
72589
|
async function writeVerificationEventBatch(input3, dependencies) {
|
|
72445
|
-
const eventDirectory = (0,
|
|
72590
|
+
const eventDirectory = (0, import_node_path25.join)(input3.rootDirectory, LOCAL_EVENTS_DIRECTORY_PATH4);
|
|
72446
72591
|
await dependencies.mkdir(eventDirectory, { recursive: true });
|
|
72447
72592
|
const fileName = buildEventFileName([input3.event], `debugbundle-verify-local-${input3.runId}`);
|
|
72448
|
-
const destinationPath = (0,
|
|
72593
|
+
const destinationPath = (0, import_node_path25.join)(eventDirectory, fileName);
|
|
72449
72594
|
const temporaryPath = `${destinationPath}.tmp`;
|
|
72450
72595
|
await dependencies.writeFile(temporaryPath, `${JSON.stringify([input3.event], null, 2)}
|
|
72451
72596
|
`);
|
|
@@ -72455,14 +72600,14 @@ async function writeVerificationEventBatch(input3, dependencies) {
|
|
|
72455
72600
|
async function verifyLocalCommand(input3, dependencies = {}) {
|
|
72456
72601
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
72457
72602
|
const mkdir5 = dependencies.mkdir ?? (async (path, options) => {
|
|
72458
|
-
await (0,
|
|
72603
|
+
await (0, import_promises22.mkdir)(path, options);
|
|
72459
72604
|
});
|
|
72460
72605
|
const now = dependencies.now ?? (() => /* @__PURE__ */ new Date());
|
|
72461
72606
|
const processLocal = dependencies.processCommand ?? processCommand;
|
|
72462
72607
|
const readVerifiedLocalState = dependencies.readLocalState ?? readLocalState;
|
|
72463
72608
|
const readVerifiedLocalBundle = dependencies.getLocalBundle ?? getLocalBundle;
|
|
72464
|
-
const rename4 = dependencies.rename ?? (async (sourcePath, destinationPath) => (0,
|
|
72465
|
-
const writeFile = dependencies.writeFile ?? (async (path, content) => (0,
|
|
72609
|
+
const rename4 = dependencies.rename ?? (async (sourcePath, destinationPath) => (0, import_promises22.rename)(sourcePath, destinationPath));
|
|
72610
|
+
const writeFile = dependencies.writeFile ?? (async (path, content) => (0, import_promises22.writeFile)(path, content, "utf8"));
|
|
72466
72611
|
const checks = [];
|
|
72467
72612
|
function finalize2(exitCode, errors, incidentId) {
|
|
72468
72613
|
return formatResult(input3, exitCode, checks, errors, incidentId);
|
|
@@ -72483,7 +72628,7 @@ async function verifyLocalCommand(input3, dependencies = {}) {
|
|
|
72483
72628
|
});
|
|
72484
72629
|
try {
|
|
72485
72630
|
const rootDirectory = cwd();
|
|
72486
|
-
const profile = await readProfile(rootDirectory, async (path) => (0,
|
|
72631
|
+
const profile = await readProfile(rootDirectory, async (path) => (0, import_promises22.readFile)(path, "utf8"));
|
|
72487
72632
|
const projectId = buildProjectId(profile);
|
|
72488
72633
|
const verificationNow = now();
|
|
72489
72634
|
const runId = verificationNow.toISOString().replace(/[-:.TZ]/g, "").slice(0, 14);
|
|
@@ -73169,7 +73314,7 @@ var CLI_USAGE_LINES = [
|
|
|
73169
73314
|
" debugbundle token member list [--limit <n>] [--auth-file <path>] [--json]",
|
|
73170
73315
|
" debugbundle token member create --label <label> [--auth-file <path>] [--json]",
|
|
73171
73316
|
" debugbundle token member revoke <token-id> [--auth-file <path>] [--json]",
|
|
73172
|
-
" debugbundle alert list --project-id <id> [--limit <n>] [--auth-file <path>] [--json]",
|
|
73317
|
+
" debugbundle alert list --project-id <id> [--limit <n>] [--include-scope <true|false>] [--auth-file <path>] [--json]",
|
|
73173
73318
|
" debugbundle alert groups --project-id <id> [--limit <n>] [--cursor <cursor>] [--auth-file <path>] [--json]",
|
|
73174
73319
|
" debugbundle alert group <direct|email_digest> <group-id> --project-id <id> [--limit <n>] [--cursor <cursor>] [--auth-file <path>] [--json]",
|
|
73175
73320
|
" debugbundle alert create --project-id <id> --channel <channel> --condition <condition> [--service-id <id>] [--severity-min <level>] [--severity-lifecycle-scope <new_incident|incident_regressed|both>] [--cooldown <seconds>] --config-json <json> [--is-enabled <true|false>] [--auth-file <path>] [--json]",
|
|
@@ -73238,8 +73383,8 @@ function formatUsage() {
|
|
|
73238
73383
|
}
|
|
73239
73384
|
|
|
73240
73385
|
// src/validate-command.ts
|
|
73241
|
-
var
|
|
73242
|
-
var
|
|
73386
|
+
var import_promises23 = require("node:fs/promises");
|
|
73387
|
+
var import_node_path26 = require("node:path");
|
|
73243
73388
|
var SUGGESTED_ACTIONS2 = [
|
|
73244
73389
|
"Run debugbundle setup if .debugbundle/profile.json is missing.",
|
|
73245
73390
|
"Run debugbundle profile validate for field-level profile errors.",
|
|
@@ -73345,22 +73490,22 @@ function buildValidateJsonOutput(checks, profileErrors, autoFixAvailable) {
|
|
|
73345
73490
|
});
|
|
73346
73491
|
}
|
|
73347
73492
|
async function fixMissingFile(rootDirectory, filePath, buildContent, dependencies) {
|
|
73348
|
-
const absoluteFilePath = (0,
|
|
73349
|
-
await dependencies.mkdir((0,
|
|
73493
|
+
const absoluteFilePath = (0, import_node_path26.join)(rootDirectory, filePath);
|
|
73494
|
+
await dependencies.mkdir((0, import_node_path26.dirname)(absoluteFilePath), { recursive: true });
|
|
73350
73495
|
if (dependencies.writeFile) await dependencies.writeFile(absoluteFilePath, buildContent());
|
|
73351
73496
|
else await writeManaged(rootDirectory, filePath, buildContent(), void 0);
|
|
73352
73497
|
}
|
|
73353
73498
|
async function runValidateCommand(input3, dependencies = {}) {
|
|
73354
73499
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
73355
73500
|
const mkdir5 = dependencies.mkdir ?? (async (path, options) => {
|
|
73356
|
-
await (0,
|
|
73501
|
+
await (0, import_promises23.mkdir)(path, options);
|
|
73357
73502
|
});
|
|
73358
73503
|
const readFile = dependencies.readFile ?? (async (filePath) => {
|
|
73359
|
-
const content = await readManaged(rootDirectory, (0,
|
|
73504
|
+
const content = await readManaged(rootDirectory, (0, import_node_path26.relative)(rootDirectory, filePath));
|
|
73360
73505
|
if (content === void 0) throw Object.assign(new Error("Missing local scaffold file."), { code: "ENOENT" });
|
|
73361
73506
|
return content;
|
|
73362
73507
|
});
|
|
73363
|
-
const stat = dependencies.stat ??
|
|
73508
|
+
const stat = dependencies.stat ?? import_promises23.stat;
|
|
73364
73509
|
const rootDirectory = await projectRoot(cwd());
|
|
73365
73510
|
for (const file2 of [PROFILE_FILE_PATH, CONNECTION_FILE_PATH, GITIGNORE_FILE_PATH]) await safePath(rootDirectory, file2);
|
|
73366
73511
|
const profileValidation = await validateProfile(rootDirectory, { readFile, stat });
|
|
@@ -73387,7 +73532,7 @@ async function runValidateCommand(input3, dependencies = {}) {
|
|
|
73387
73532
|
checks.push({ name: fixableFile.name, status: status2, message: file2.status === "ok" ? previous.status === "missing" ? `Wrote missing ${file2.path}` : previous.status === "stale" ? `Updated stale ${file2.path}` : `Found ${file2.path}` : file2.status === "missing" ? `Missing ${file2.path}` : file2.status === "stale" ? `Stale ${file2.path}; run debugbundle validate --fix to refresh it.` : file2.message });
|
|
73388
73533
|
continue;
|
|
73389
73534
|
}
|
|
73390
|
-
if (await pathExists8((0,
|
|
73535
|
+
if (await pathExists8((0, import_node_path26.join)(rootDirectory, fixableFile.filePath), stat)) {
|
|
73391
73536
|
checks.push({ name: fixableFile.name, status: "ok", message: `Found ${fixableFile.filePath}` });
|
|
73392
73537
|
} else if (input3.fix) {
|
|
73393
73538
|
await fixMissingFile(rootDirectory, fixableFile.filePath, fixableFile.buildContent, { mkdir: mkdir5, ...dependencies.writeFile ? { writeFile: dependencies.writeFile } : {} });
|
|
@@ -80754,6 +80899,7 @@ async function listAlertsCommand(input3, api) {
|
|
|
80754
80899
|
if (input3.limit !== void 0) {
|
|
80755
80900
|
requestInput.limit = input3.limit;
|
|
80756
80901
|
}
|
|
80902
|
+
if (input3.includeScope !== void 0) requestInput.includeScope = input3.includeScope;
|
|
80757
80903
|
const alerts = await api.listAlerts(requestInput);
|
|
80758
80904
|
return {
|
|
80759
80905
|
exitCode: 0,
|
|
@@ -80778,6 +80924,7 @@ async function listAlertsWithAuthCommand(input3, dependencies) {
|
|
|
80778
80924
|
if (input3.limit !== void 0) {
|
|
80779
80925
|
commandInput.limit = input3.limit;
|
|
80780
80926
|
}
|
|
80927
|
+
if (input3.includeScope !== void 0) commandInput.includeScope = input3.includeScope;
|
|
80781
80928
|
if (input3.json !== void 0) {
|
|
80782
80929
|
commandInput.json = input3.json;
|
|
80783
80930
|
}
|
|
@@ -81990,7 +82137,13 @@ async function handleAlertCommand(parsedArgv, dependencies) {
|
|
|
81990
82137
|
);
|
|
81991
82138
|
}
|
|
81992
82139
|
if (action === "list") {
|
|
81993
|
-
expectNoUnknownOptions(parsedArgv, [
|
|
82140
|
+
expectNoUnknownOptions(parsedArgv, [
|
|
82141
|
+
"auth-file",
|
|
82142
|
+
"json",
|
|
82143
|
+
"project-id",
|
|
82144
|
+
"limit",
|
|
82145
|
+
"include-scope"
|
|
82146
|
+
]);
|
|
81994
82147
|
ensureNoExtraPositionals(parsedArgv, 2);
|
|
81995
82148
|
const projectId = readStringOption(parsedArgv, "project-id");
|
|
81996
82149
|
if (projectId === void 0) {
|
|
@@ -82003,6 +82156,8 @@ async function handleAlertCommand(parsedArgv, dependencies) {
|
|
|
82003
82156
|
if (limit !== void 0) {
|
|
82004
82157
|
input3.limit = limit;
|
|
82005
82158
|
}
|
|
82159
|
+
const includeScope = readBooleanStringOption(parsedArgv, "include-scope");
|
|
82160
|
+
if (includeScope !== void 0) input3.includeScope = includeScope;
|
|
82006
82161
|
return await (dependencies.listAlertsCommand ?? listAlertsWithAuthCommand)(input3);
|
|
82007
82162
|
}
|
|
82008
82163
|
if (action === "create") {
|
|
@@ -82404,7 +82559,7 @@ async function handleCaptureRuleCommand2(parsedArgv, dependencies) {
|
|
|
82404
82559
|
// package.json
|
|
82405
82560
|
var package_default = {
|
|
82406
82561
|
name: "@debugbundle/cli",
|
|
82407
|
-
version: "1.
|
|
82562
|
+
version: "1.20.0",
|
|
82408
82563
|
private: false,
|
|
82409
82564
|
description: "Command-line interface for DebugBundle",
|
|
82410
82565
|
license: "Apache-2.0",
|