mobbdev 1.1.14 → 1.1.17
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/dist/args/commands/upload_ai_blame.d.mts +28 -28
- package/dist/args/commands/upload_ai_blame.mjs +223 -132
- package/dist/index.mjs +263 -154
- package/package.json +2 -3
|
@@ -51,26 +51,18 @@ declare const PromptItemZ: z.ZodObject<{
|
|
|
51
51
|
name: string;
|
|
52
52
|
parameters: string;
|
|
53
53
|
result: string;
|
|
54
|
-
accepted?: boolean | undefined;
|
|
55
54
|
rawArguments?: string | undefined;
|
|
55
|
+
accepted?: boolean | undefined;
|
|
56
56
|
}, {
|
|
57
57
|
name: string;
|
|
58
58
|
parameters: string;
|
|
59
59
|
result: string;
|
|
60
|
-
accepted?: boolean | undefined;
|
|
61
60
|
rawArguments?: string | undefined;
|
|
61
|
+
accepted?: boolean | undefined;
|
|
62
62
|
}>>;
|
|
63
63
|
}, "strip", z.ZodTypeAny, {
|
|
64
64
|
type: "USER_PROMPT" | "AI_RESPONSE" | "TOOL_EXECUTION" | "AI_THINKING";
|
|
65
|
-
tool?: {
|
|
66
|
-
name: string;
|
|
67
|
-
parameters: string;
|
|
68
|
-
result: string;
|
|
69
|
-
accepted?: boolean | undefined;
|
|
70
|
-
rawArguments?: string | undefined;
|
|
71
|
-
} | undefined;
|
|
72
65
|
date?: Date | undefined;
|
|
73
|
-
text?: string | undefined;
|
|
74
66
|
attachedFiles?: {
|
|
75
67
|
relativePath: string;
|
|
76
68
|
startLine?: number | undefined;
|
|
@@ -79,17 +71,17 @@ declare const PromptItemZ: z.ZodObject<{
|
|
|
79
71
|
inputCount: number;
|
|
80
72
|
outputCount: number;
|
|
81
73
|
} | undefined;
|
|
82
|
-
|
|
83
|
-
type: "USER_PROMPT" | "AI_RESPONSE" | "TOOL_EXECUTION" | "AI_THINKING";
|
|
74
|
+
text?: string | undefined;
|
|
84
75
|
tool?: {
|
|
85
76
|
name: string;
|
|
86
77
|
parameters: string;
|
|
87
78
|
result: string;
|
|
88
|
-
accepted?: boolean | undefined;
|
|
89
79
|
rawArguments?: string | undefined;
|
|
80
|
+
accepted?: boolean | undefined;
|
|
90
81
|
} | undefined;
|
|
82
|
+
}, {
|
|
83
|
+
type: "USER_PROMPT" | "AI_RESPONSE" | "TOOL_EXECUTION" | "AI_THINKING";
|
|
91
84
|
date?: Date | undefined;
|
|
92
|
-
text?: string | undefined;
|
|
93
85
|
attachedFiles?: {
|
|
94
86
|
relativePath: string;
|
|
95
87
|
startLine?: number | undefined;
|
|
@@ -98,6 +90,14 @@ declare const PromptItemZ: z.ZodObject<{
|
|
|
98
90
|
inputCount: number;
|
|
99
91
|
outputCount: number;
|
|
100
92
|
} | undefined;
|
|
93
|
+
text?: string | undefined;
|
|
94
|
+
tool?: {
|
|
95
|
+
name: string;
|
|
96
|
+
parameters: string;
|
|
97
|
+
result: string;
|
|
98
|
+
rawArguments?: string | undefined;
|
|
99
|
+
accepted?: boolean | undefined;
|
|
100
|
+
} | undefined;
|
|
101
101
|
}>;
|
|
102
102
|
type PromptItem = z.infer<typeof PromptItemZ>;
|
|
103
103
|
declare const PromptItemArrayZ: z.ZodArray<z.ZodObject<{
|
|
@@ -134,26 +134,18 @@ declare const PromptItemArrayZ: z.ZodArray<z.ZodObject<{
|
|
|
134
134
|
name: string;
|
|
135
135
|
parameters: string;
|
|
136
136
|
result: string;
|
|
137
|
-
accepted?: boolean | undefined;
|
|
138
137
|
rawArguments?: string | undefined;
|
|
138
|
+
accepted?: boolean | undefined;
|
|
139
139
|
}, {
|
|
140
140
|
name: string;
|
|
141
141
|
parameters: string;
|
|
142
142
|
result: string;
|
|
143
|
-
accepted?: boolean | undefined;
|
|
144
143
|
rawArguments?: string | undefined;
|
|
144
|
+
accepted?: boolean | undefined;
|
|
145
145
|
}>>;
|
|
146
146
|
}, "strip", z.ZodTypeAny, {
|
|
147
147
|
type: "USER_PROMPT" | "AI_RESPONSE" | "TOOL_EXECUTION" | "AI_THINKING";
|
|
148
|
-
tool?: {
|
|
149
|
-
name: string;
|
|
150
|
-
parameters: string;
|
|
151
|
-
result: string;
|
|
152
|
-
accepted?: boolean | undefined;
|
|
153
|
-
rawArguments?: string | undefined;
|
|
154
|
-
} | undefined;
|
|
155
148
|
date?: Date | undefined;
|
|
156
|
-
text?: string | undefined;
|
|
157
149
|
attachedFiles?: {
|
|
158
150
|
relativePath: string;
|
|
159
151
|
startLine?: number | undefined;
|
|
@@ -162,17 +154,17 @@ declare const PromptItemArrayZ: z.ZodArray<z.ZodObject<{
|
|
|
162
154
|
inputCount: number;
|
|
163
155
|
outputCount: number;
|
|
164
156
|
} | undefined;
|
|
165
|
-
|
|
166
|
-
type: "USER_PROMPT" | "AI_RESPONSE" | "TOOL_EXECUTION" | "AI_THINKING";
|
|
157
|
+
text?: string | undefined;
|
|
167
158
|
tool?: {
|
|
168
159
|
name: string;
|
|
169
160
|
parameters: string;
|
|
170
161
|
result: string;
|
|
171
|
-
accepted?: boolean | undefined;
|
|
172
162
|
rawArguments?: string | undefined;
|
|
163
|
+
accepted?: boolean | undefined;
|
|
173
164
|
} | undefined;
|
|
165
|
+
}, {
|
|
166
|
+
type: "USER_PROMPT" | "AI_RESPONSE" | "TOOL_EXECUTION" | "AI_THINKING";
|
|
174
167
|
date?: Date | undefined;
|
|
175
|
-
text?: string | undefined;
|
|
176
168
|
attachedFiles?: {
|
|
177
169
|
relativePath: string;
|
|
178
170
|
startLine?: number | undefined;
|
|
@@ -181,6 +173,14 @@ declare const PromptItemArrayZ: z.ZodArray<z.ZodObject<{
|
|
|
181
173
|
inputCount: number;
|
|
182
174
|
outputCount: number;
|
|
183
175
|
} | undefined;
|
|
176
|
+
text?: string | undefined;
|
|
177
|
+
tool?: {
|
|
178
|
+
name: string;
|
|
179
|
+
parameters: string;
|
|
180
|
+
result: string;
|
|
181
|
+
rawArguments?: string | undefined;
|
|
182
|
+
accepted?: boolean | undefined;
|
|
183
|
+
} | undefined;
|
|
184
184
|
}>, "many">;
|
|
185
185
|
type PromptItemArray = z.infer<typeof PromptItemArrayZ>;
|
|
186
186
|
type UploadAiBlameOptions = {
|
|
@@ -100,7 +100,7 @@ import z26 from "zod";
|
|
|
100
100
|
import crypto from "crypto";
|
|
101
101
|
import os from "os";
|
|
102
102
|
import chalk2 from "chalk";
|
|
103
|
-
import
|
|
103
|
+
import Debug6 from "debug";
|
|
104
104
|
import open from "open";
|
|
105
105
|
|
|
106
106
|
// src/constants.ts
|
|
@@ -816,6 +816,57 @@ var UploadS3BucketInfoDocument = `
|
|
|
816
816
|
}
|
|
817
817
|
}
|
|
818
818
|
`;
|
|
819
|
+
var AnalyzeCommitForExtensionAiBlameDocument = `
|
|
820
|
+
mutation AnalyzeCommitForExtensionAIBlame($repositoryURL: String!, $commitSha: String!, $organizationId: String!) {
|
|
821
|
+
analyzeCommitForAIBlame(
|
|
822
|
+
repositoryURL: $repositoryURL
|
|
823
|
+
commitSha: $commitSha
|
|
824
|
+
organizationId: $organizationId
|
|
825
|
+
) {
|
|
826
|
+
__typename
|
|
827
|
+
... on ProcessAIBlameFinalResult {
|
|
828
|
+
status
|
|
829
|
+
inferencesProcessed
|
|
830
|
+
attributionsCreated
|
|
831
|
+
attributions {
|
|
832
|
+
id
|
|
833
|
+
aiBlameCommitId
|
|
834
|
+
aiBlameInferenceId
|
|
835
|
+
filePath
|
|
836
|
+
lineNumber
|
|
837
|
+
model
|
|
838
|
+
toolName
|
|
839
|
+
commitSha
|
|
840
|
+
inferenceType
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
... on ProcessAIBlameErrorResult {
|
|
844
|
+
status
|
|
845
|
+
error
|
|
846
|
+
}
|
|
847
|
+
... on ProcessAIBlameRequestedResult {
|
|
848
|
+
status
|
|
849
|
+
requestIds
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
`;
|
|
854
|
+
var GetAiBlameInferenceDocument = `
|
|
855
|
+
query GetAIBlameInference($aiBlameInferenceIds: [uuid!]) {
|
|
856
|
+
ai_blame_inference(where: {id: {_in: $aiBlameInferenceIds}}) {
|
|
857
|
+
id
|
|
858
|
+
type
|
|
859
|
+
aiResponseAt
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
`;
|
|
863
|
+
var GetAiBlameAttributionPromptDocument = `
|
|
864
|
+
query GetAIBlameAttributionPrompt($aiBlameAttributionId: String!) {
|
|
865
|
+
getAIBlameInferenceData(aiBlameAttributionId: $aiBlameAttributionId) {
|
|
866
|
+
promptUrl
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
`;
|
|
819
870
|
var UploadAiBlameInferencesInitDocument = `
|
|
820
871
|
mutation UploadAIBlameInferencesInit($sessions: [AIBlameInferenceInitInput!]!) {
|
|
821
872
|
uploadAIBlameInferencesInit(sessions: $sessions) {
|
|
@@ -1109,6 +1160,15 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
1109
1160
|
uploadS3BucketInfo(variables, requestHeaders, signal) {
|
|
1110
1161
|
return withWrapper((wrappedRequestHeaders) => client.request({ document: UploadS3BucketInfoDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "uploadS3BucketInfo", "mutation", variables);
|
|
1111
1162
|
},
|
|
1163
|
+
AnalyzeCommitForExtensionAIBlame(variables, requestHeaders, signal) {
|
|
1164
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: AnalyzeCommitForExtensionAiBlameDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "AnalyzeCommitForExtensionAIBlame", "mutation", variables);
|
|
1165
|
+
},
|
|
1166
|
+
GetAIBlameInference(variables, requestHeaders, signal) {
|
|
1167
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetAiBlameInferenceDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetAIBlameInference", "query", variables);
|
|
1168
|
+
},
|
|
1169
|
+
GetAIBlameAttributionPrompt(variables, requestHeaders, signal) {
|
|
1170
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetAiBlameAttributionPromptDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetAIBlameAttributionPrompt", "query", variables);
|
|
1171
|
+
},
|
|
1112
1172
|
UploadAIBlameInferencesInit(variables, requestHeaders, signal) {
|
|
1113
1173
|
return withWrapper((wrappedRequestHeaders) => client.request({ document: UploadAiBlameInferencesInitDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "UploadAIBlameInferencesInit", "mutation", variables);
|
|
1114
1174
|
},
|
|
@@ -2171,10 +2231,9 @@ var VUL_REPORT_DIGEST_TIMEOUT_MS = 1e3 * 60 * 30;
|
|
|
2171
2231
|
|
|
2172
2232
|
// src/features/analysis/graphql/gql.ts
|
|
2173
2233
|
import fetchOrig from "cross-fetch";
|
|
2174
|
-
import
|
|
2234
|
+
import Debug5 from "debug";
|
|
2175
2235
|
import { GraphQLClient } from "graphql-request";
|
|
2176
|
-
import {
|
|
2177
|
-
import { HttpsProxyAgent as HttpsProxyAgent2 } from "https-proxy-agent";
|
|
2236
|
+
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
2178
2237
|
import { v4 as uuidv4 } from "uuid";
|
|
2179
2238
|
|
|
2180
2239
|
// src/mcp/core/Errors.ts
|
|
@@ -2286,6 +2345,131 @@ var sleep = (ms = 2e3) => new Promise((r) => setTimeout(r, ms));
|
|
|
2286
2345
|
var CliError = class extends Error {
|
|
2287
2346
|
};
|
|
2288
2347
|
|
|
2348
|
+
// src/utils/subscribe/subscribe.ts
|
|
2349
|
+
import { createClient } from "graphql-ws";
|
|
2350
|
+
import WebsocketNode from "isomorphic-ws";
|
|
2351
|
+
|
|
2352
|
+
// src/utils/subscribe/graphql.ts
|
|
2353
|
+
function getGraphQlHeaders(options) {
|
|
2354
|
+
const headers = {
|
|
2355
|
+
"Content-Type": "application/json"
|
|
2356
|
+
};
|
|
2357
|
+
if ("type" in options) {
|
|
2358
|
+
if (options.type === "apiKey") {
|
|
2359
|
+
headers["x-mobb-key"] = options.apiKey;
|
|
2360
|
+
} else if (options.type === "token") {
|
|
2361
|
+
headers["Authorization"] = `Bearer ${options.token}`;
|
|
2362
|
+
}
|
|
2363
|
+
return headers;
|
|
2364
|
+
}
|
|
2365
|
+
if ("isAdmin" in options && options.isAdmin) {
|
|
2366
|
+
headers["x-hasura-access-key"] = options.adminPassword;
|
|
2367
|
+
} else if ("isApiKey" in options && options.isApiKey) {
|
|
2368
|
+
headers["x-mobb-key"] = options.apiKey;
|
|
2369
|
+
} else if ("accessToken" in options) {
|
|
2370
|
+
headers["Authorization"] = `Bearer ${options.accessToken}`;
|
|
2371
|
+
}
|
|
2372
|
+
return headers;
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
// src/utils/subscribe/subscribe.ts
|
|
2376
|
+
var DEFAULT_API_URL2 = "https://api.mobb.ai/v1/graphql";
|
|
2377
|
+
var SUBSCRIPTION_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
2378
|
+
function createWSClient(options) {
|
|
2379
|
+
const url = options.url || (process.env["API_URL"] || DEFAULT_API_URL2).replace("http", "ws");
|
|
2380
|
+
const websocketImpl = options.websocket || (typeof WebSocket !== "undefined" ? WebSocket : WebsocketNode);
|
|
2381
|
+
const CustomWebSocket = options.proxyAgent ? (
|
|
2382
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic WebSocket extension requires any cast for cross-platform compatibility
|
|
2383
|
+
class extends websocketImpl {
|
|
2384
|
+
constructor(address, protocols) {
|
|
2385
|
+
super(address, protocols, { agent: options.proxyAgent });
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
) : websocketImpl;
|
|
2389
|
+
return createClient({
|
|
2390
|
+
//this is needed to prevent AWS from killing the connection
|
|
2391
|
+
//currently our load balancer has a 29s idle timeout
|
|
2392
|
+
keepAlive: 1e4,
|
|
2393
|
+
url,
|
|
2394
|
+
webSocketImpl: CustomWebSocket,
|
|
2395
|
+
connectionParams: () => {
|
|
2396
|
+
return {
|
|
2397
|
+
headers: getGraphQlHeaders(options)
|
|
2398
|
+
};
|
|
2399
|
+
}
|
|
2400
|
+
});
|
|
2401
|
+
}
|
|
2402
|
+
function subscribe(query, variables, callback, wsClientOptions) {
|
|
2403
|
+
return new Promise((resolve, reject) => {
|
|
2404
|
+
let timer = null;
|
|
2405
|
+
let settled = false;
|
|
2406
|
+
const { timeoutInMs = SUBSCRIPTION_TIMEOUT_MS } = wsClientOptions;
|
|
2407
|
+
const client = createWSClient(wsClientOptions);
|
|
2408
|
+
let unsubscribe = () => {
|
|
2409
|
+
return;
|
|
2410
|
+
};
|
|
2411
|
+
function cleanup() {
|
|
2412
|
+
try {
|
|
2413
|
+
unsubscribe();
|
|
2414
|
+
} catch {
|
|
2415
|
+
}
|
|
2416
|
+
if (timer) {
|
|
2417
|
+
clearTimeout(timer);
|
|
2418
|
+
timer = null;
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
function finalizeResolve(data) {
|
|
2422
|
+
if (settled) {
|
|
2423
|
+
return;
|
|
2424
|
+
}
|
|
2425
|
+
settled = true;
|
|
2426
|
+
cleanup();
|
|
2427
|
+
resolve(data);
|
|
2428
|
+
}
|
|
2429
|
+
function finalizeReject(error) {
|
|
2430
|
+
if (settled) {
|
|
2431
|
+
return;
|
|
2432
|
+
}
|
|
2433
|
+
settled = true;
|
|
2434
|
+
cleanup();
|
|
2435
|
+
reject(error);
|
|
2436
|
+
}
|
|
2437
|
+
unsubscribe = client.subscribe(
|
|
2438
|
+
{ query, variables },
|
|
2439
|
+
{
|
|
2440
|
+
next: (data) => {
|
|
2441
|
+
if (!data.data) {
|
|
2442
|
+
finalizeReject(
|
|
2443
|
+
new Error(
|
|
2444
|
+
`Broken data object from graphQL subscribe: ${JSON.stringify(
|
|
2445
|
+
data
|
|
2446
|
+
)} for query: ${query}`
|
|
2447
|
+
)
|
|
2448
|
+
);
|
|
2449
|
+
} else {
|
|
2450
|
+
callback(finalizeResolve, finalizeReject, data.data);
|
|
2451
|
+
}
|
|
2452
|
+
},
|
|
2453
|
+
error: (error) => {
|
|
2454
|
+
finalizeReject(error);
|
|
2455
|
+
},
|
|
2456
|
+
complete: () => {
|
|
2457
|
+
return;
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
);
|
|
2461
|
+
if (typeof timeoutInMs === "number") {
|
|
2462
|
+
timer = setTimeout(() => {
|
|
2463
|
+
finalizeReject(
|
|
2464
|
+
new Error(
|
|
2465
|
+
`Timeout expired for graphQL subscribe query: ${query} with timeout: ${timeoutInMs}`
|
|
2466
|
+
)
|
|
2467
|
+
);
|
|
2468
|
+
}, timeoutInMs);
|
|
2469
|
+
}
|
|
2470
|
+
});
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2289
2473
|
// src/features/analysis/scm/utils/index.ts
|
|
2290
2474
|
import { z as z15 } from "zod";
|
|
2291
2475
|
|
|
@@ -4404,107 +4588,6 @@ var debug5 = Debug4("scm:gitlab");
|
|
|
4404
4588
|
// src/features/analysis/scm/scmFactory.ts
|
|
4405
4589
|
import { z as z24 } from "zod";
|
|
4406
4590
|
|
|
4407
|
-
// src/features/analysis/graphql/subscribe.ts
|
|
4408
|
-
import Debug5 from "debug";
|
|
4409
|
-
import { createClient } from "graphql-ws";
|
|
4410
|
-
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
4411
|
-
import WebSocket from "ws";
|
|
4412
|
-
var DEFAULT_API_URL2 = "https://api.mobb.ai/v1/graphql";
|
|
4413
|
-
var debug6 = Debug5("mobbdev:subscribe");
|
|
4414
|
-
var SUBSCRIPTION_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
4415
|
-
function createWSClient(options) {
|
|
4416
|
-
const proxy = options.url.startsWith("wss://") && process.env["HTTPS_PROXY"] ? new HttpsProxyAgent(process.env["HTTPS_PROXY"]) : options.url.startsWith("ws://") && process.env["HTTP_PROXY"] ? new HttpsProxyAgent(process.env["HTTP_PROXY"]) : null;
|
|
4417
|
-
debug6(
|
|
4418
|
-
`Using proxy: ${proxy ? "yes" : "no"} with url: ${options.url} and with proxy: ${process.env["HTTP_PROXY"]} for the websocket connection`
|
|
4419
|
-
);
|
|
4420
|
-
const CustomWebSocket = class extends WebSocket {
|
|
4421
|
-
constructor(address, protocols) {
|
|
4422
|
-
super(
|
|
4423
|
-
address,
|
|
4424
|
-
protocols,
|
|
4425
|
-
proxy ? { agent: proxy } : void 0
|
|
4426
|
-
);
|
|
4427
|
-
}
|
|
4428
|
-
};
|
|
4429
|
-
return createClient({
|
|
4430
|
-
//this is needed to prevent AWS from killing the connection
|
|
4431
|
-
//currently our load balancer has a 29s idle timeout
|
|
4432
|
-
keepAlive: 1e4,
|
|
4433
|
-
url: options.url,
|
|
4434
|
-
webSocketImpl: proxy ? CustomWebSocket : options.websocket || WebSocket,
|
|
4435
|
-
connectionParams: () => {
|
|
4436
|
-
return {
|
|
4437
|
-
headers: options.type === "apiKey" ? {
|
|
4438
|
-
[API_KEY_HEADER_NAME]: options.apiKey
|
|
4439
|
-
} : { authorization: `Bearer ${options.token}` }
|
|
4440
|
-
};
|
|
4441
|
-
}
|
|
4442
|
-
});
|
|
4443
|
-
}
|
|
4444
|
-
function subscribe(query, variables, callback, wsClientOptions) {
|
|
4445
|
-
return new Promise((resolve, reject) => {
|
|
4446
|
-
let timer = null;
|
|
4447
|
-
const { timeoutInMs = SUBSCRIPTION_TIMEOUT_MS } = wsClientOptions;
|
|
4448
|
-
const API_URL2 = process.env["API_URL"] || DEFAULT_API_URL2;
|
|
4449
|
-
const client = createWSClient({
|
|
4450
|
-
...wsClientOptions,
|
|
4451
|
-
websocket: WebSocket,
|
|
4452
|
-
url: API_URL2.replace("http", "ws")
|
|
4453
|
-
});
|
|
4454
|
-
const unsubscribe = client.subscribe(
|
|
4455
|
-
{ query, variables },
|
|
4456
|
-
{
|
|
4457
|
-
next: (data) => {
|
|
4458
|
-
function callbackResolve(data2) {
|
|
4459
|
-
unsubscribe();
|
|
4460
|
-
if (timer) {
|
|
4461
|
-
clearTimeout(timer);
|
|
4462
|
-
}
|
|
4463
|
-
resolve(data2);
|
|
4464
|
-
}
|
|
4465
|
-
function callbackReject(data2) {
|
|
4466
|
-
unsubscribe();
|
|
4467
|
-
if (timer) {
|
|
4468
|
-
clearTimeout(timer);
|
|
4469
|
-
}
|
|
4470
|
-
reject(data2);
|
|
4471
|
-
}
|
|
4472
|
-
if (!data.data) {
|
|
4473
|
-
reject(
|
|
4474
|
-
new Error(
|
|
4475
|
-
`Broken data object from graphQL subscribe: ${JSON.stringify(
|
|
4476
|
-
data
|
|
4477
|
-
)} for query: ${query}`
|
|
4478
|
-
)
|
|
4479
|
-
);
|
|
4480
|
-
} else {
|
|
4481
|
-
callback(callbackResolve, callbackReject, data.data);
|
|
4482
|
-
}
|
|
4483
|
-
},
|
|
4484
|
-
error: (error) => {
|
|
4485
|
-
if (timer) {
|
|
4486
|
-
clearTimeout(timer);
|
|
4487
|
-
}
|
|
4488
|
-
reject(error);
|
|
4489
|
-
},
|
|
4490
|
-
complete: () => {
|
|
4491
|
-
return;
|
|
4492
|
-
}
|
|
4493
|
-
}
|
|
4494
|
-
);
|
|
4495
|
-
if (typeof timeoutInMs === "number") {
|
|
4496
|
-
timer = setTimeout(() => {
|
|
4497
|
-
unsubscribe();
|
|
4498
|
-
reject(
|
|
4499
|
-
new Error(
|
|
4500
|
-
`Timeout expired for graphQL subscribe query: ${query} with timeout: ${timeoutInMs}`
|
|
4501
|
-
)
|
|
4502
|
-
);
|
|
4503
|
-
}, timeoutInMs);
|
|
4504
|
-
}
|
|
4505
|
-
});
|
|
4506
|
-
}
|
|
4507
|
-
|
|
4508
4591
|
// src/features/analysis/graphql/types.ts
|
|
4509
4592
|
import { z as z25 } from "zod";
|
|
4510
4593
|
var VulnerabilityReportIssueCodeNodeZ = z25.object({
|
|
@@ -4567,7 +4650,7 @@ var GetVulByNodesMetadataZ = z25.object({
|
|
|
4567
4650
|
});
|
|
4568
4651
|
|
|
4569
4652
|
// src/features/analysis/graphql/gql.ts
|
|
4570
|
-
var
|
|
4653
|
+
var debug6 = Debug5("mobbdev:gql");
|
|
4571
4654
|
var API_KEY_HEADER_NAME = "x-mobb-key";
|
|
4572
4655
|
var REPORT_STATE_CHECK_DELAY = 5 * 1e3;
|
|
4573
4656
|
function getProxyAgent(url) {
|
|
@@ -4575,14 +4658,14 @@ function getProxyAgent(url) {
|
|
|
4575
4658
|
const parsedUrl = new URL(url);
|
|
4576
4659
|
const isHttp = parsedUrl.protocol === "http:";
|
|
4577
4660
|
const isHttps = parsedUrl.protocol === "https:";
|
|
4578
|
-
const proxy = isHttps ? HTTPS_PROXY : isHttp ? HTTP_PROXY : null;
|
|
4661
|
+
const proxy = isHttps ? HTTPS_PROXY || HTTP_PROXY : isHttp ? HTTP_PROXY : null;
|
|
4579
4662
|
if (proxy) {
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
return
|
|
4663
|
+
debug6("Using proxy %s", proxy);
|
|
4664
|
+
debug6("Proxy agent %o", proxy);
|
|
4665
|
+
return new HttpsProxyAgent(proxy);
|
|
4583
4666
|
}
|
|
4584
4667
|
} catch (err) {
|
|
4585
|
-
|
|
4668
|
+
debug6(`Skipping proxy for ${url}. Reason: ${err.message}`);
|
|
4586
4669
|
}
|
|
4587
4670
|
return void 0;
|
|
4588
4671
|
}
|
|
@@ -4597,7 +4680,7 @@ var fetchWithProxy = (url, options = {}) => {
|
|
|
4597
4680
|
});
|
|
4598
4681
|
}
|
|
4599
4682
|
} catch (err) {
|
|
4600
|
-
|
|
4683
|
+
debug6(`Skipping proxy for ${url}. Reason: ${err.message}`);
|
|
4601
4684
|
}
|
|
4602
4685
|
return fetchOrig(url, options);
|
|
4603
4686
|
};
|
|
@@ -4606,7 +4689,7 @@ var GQLClient = class {
|
|
|
4606
4689
|
__publicField(this, "_client");
|
|
4607
4690
|
__publicField(this, "_clientSdk");
|
|
4608
4691
|
__publicField(this, "_auth");
|
|
4609
|
-
|
|
4692
|
+
debug6(`init with ${args}`);
|
|
4610
4693
|
this._auth = args;
|
|
4611
4694
|
this._client = new GraphQLClient(API_URL, {
|
|
4612
4695
|
headers: args.type === "apiKey" ? { [API_KEY_HEADER_NAME]: args.apiKey || "" } : {
|
|
@@ -4615,7 +4698,7 @@ var GQLClient = class {
|
|
|
4615
4698
|
fetch: fetchWithProxy,
|
|
4616
4699
|
requestMiddleware: (request) => {
|
|
4617
4700
|
const requestId = uuidv4();
|
|
4618
|
-
|
|
4701
|
+
debug6(
|
|
4619
4702
|
`sending API request with id: ${requestId} and with request: ${request.body}`
|
|
4620
4703
|
);
|
|
4621
4704
|
return {
|
|
@@ -4652,7 +4735,7 @@ var GQLClient = class {
|
|
|
4652
4735
|
await this.getUserInfo();
|
|
4653
4736
|
} catch (e) {
|
|
4654
4737
|
if (e?.toString().startsWith("FetchError")) {
|
|
4655
|
-
|
|
4738
|
+
debug6("verify connection failed %o", e);
|
|
4656
4739
|
return false;
|
|
4657
4740
|
}
|
|
4658
4741
|
}
|
|
@@ -4664,7 +4747,7 @@ var GQLClient = class {
|
|
|
4664
4747
|
try {
|
|
4665
4748
|
info = await this.getUserInfo();
|
|
4666
4749
|
} catch (e) {
|
|
4667
|
-
|
|
4750
|
+
debug6("verify token failed %o", e);
|
|
4668
4751
|
return false;
|
|
4669
4752
|
}
|
|
4670
4753
|
return info?.email || true;
|
|
@@ -4725,7 +4808,7 @@ var GQLClient = class {
|
|
|
4725
4808
|
try {
|
|
4726
4809
|
await this._clientSdk.CreateCommunityUser();
|
|
4727
4810
|
} catch (e) {
|
|
4728
|
-
|
|
4811
|
+
debug6("create community user failed %o", e);
|
|
4729
4812
|
}
|
|
4730
4813
|
}
|
|
4731
4814
|
async updateScmToken(args) {
|
|
@@ -4892,11 +4975,13 @@ var GQLClient = class {
|
|
|
4892
4975
|
this._auth.type === "apiKey" ? {
|
|
4893
4976
|
apiKey: this._auth.apiKey,
|
|
4894
4977
|
type: "apiKey",
|
|
4895
|
-
timeoutInMs: params.timeoutInMs
|
|
4978
|
+
timeoutInMs: params.timeoutInMs,
|
|
4979
|
+
proxyAgent: getProxyAgent(API_URL)
|
|
4896
4980
|
} : {
|
|
4897
4981
|
token: this._auth.token,
|
|
4898
4982
|
type: "token",
|
|
4899
|
-
timeoutInMs: params.timeoutInMs
|
|
4983
|
+
timeoutInMs: params.timeoutInMs,
|
|
4984
|
+
proxyAgent: getProxyAgent(API_URL)
|
|
4900
4985
|
}
|
|
4901
4986
|
);
|
|
4902
4987
|
}
|
|
@@ -4949,6 +5034,12 @@ var GQLClient = class {
|
|
|
4949
5034
|
async finalizeAIBlameInferencesUploadRaw(variables) {
|
|
4950
5035
|
return await this._clientSdk.FinalizeAIBlameInferencesUpload(variables);
|
|
4951
5036
|
}
|
|
5037
|
+
async analyzeCommitForExtensionAIBlame(variables) {
|
|
5038
|
+
return await this._clientSdk.AnalyzeCommitForExtensionAIBlame(variables);
|
|
5039
|
+
}
|
|
5040
|
+
async getAIBlameAttributionPrompt(variables) {
|
|
5041
|
+
return await this._clientSdk.GetAIBlameAttributionPrompt(variables);
|
|
5042
|
+
}
|
|
4952
5043
|
};
|
|
4953
5044
|
|
|
4954
5045
|
// src/utils/ConfigStoreService.ts
|
|
@@ -4971,7 +5062,7 @@ function getConfigStore() {
|
|
|
4971
5062
|
var configStore = getConfigStore();
|
|
4972
5063
|
|
|
4973
5064
|
// src/commands/handleMobbLogin.ts
|
|
4974
|
-
var
|
|
5065
|
+
var debug7 = Debug6("mobbdev:commands");
|
|
4975
5066
|
var LOGIN_MAX_WAIT = 10 * 60 * 1e3;
|
|
4976
5067
|
var LOGIN_CHECK_DELAY = 5 * 1e3;
|
|
4977
5068
|
var webLoginUrl = `${WEB_APP_URL}/cli-login`;
|
|
@@ -5050,9 +5141,9 @@ async function handleMobbLogin({
|
|
|
5050
5141
|
});
|
|
5051
5142
|
loginSpinner.spin();
|
|
5052
5143
|
if (encryptedApiToken) {
|
|
5053
|
-
|
|
5144
|
+
debug7("encrypted API token received %s", encryptedApiToken);
|
|
5054
5145
|
newApiToken = crypto.privateDecrypt(privateKey, Buffer.from(encryptedApiToken, "base64")).toString("utf-8");
|
|
5055
|
-
|
|
5146
|
+
debug7("API token decrypted");
|
|
5056
5147
|
break;
|
|
5057
5148
|
}
|
|
5058
5149
|
await sleep(LOGIN_CHECK_DELAY);
|
|
@@ -5066,7 +5157,7 @@ async function handleMobbLogin({
|
|
|
5066
5157
|
const newGqlClient = new GQLClient({ apiKey: newApiToken, type: "apiKey" });
|
|
5067
5158
|
const loginSuccess = await newGqlClient.validateUserToken();
|
|
5068
5159
|
if (loginSuccess) {
|
|
5069
|
-
|
|
5160
|
+
debug7(`set api token ${newApiToken}`);
|
|
5070
5161
|
configStore.set("apiToken", newApiToken);
|
|
5071
5162
|
loginSpinner.success({
|
|
5072
5163
|
text: `\u{1F513} Login to Mobb successful! ${typeof loginSpinner === "string" ? `Logged in as ${loginSuccess}` : ""}`
|
|
@@ -5081,9 +5172,9 @@ async function handleMobbLogin({
|
|
|
5081
5172
|
}
|
|
5082
5173
|
|
|
5083
5174
|
// src/features/analysis/upload-file.ts
|
|
5084
|
-
import
|
|
5175
|
+
import Debug7 from "debug";
|
|
5085
5176
|
import fetch3, { File, fileFrom, FormData } from "node-fetch";
|
|
5086
|
-
var
|
|
5177
|
+
var debug8 = Debug7("mobbdev:upload-file");
|
|
5087
5178
|
async function uploadFile({
|
|
5088
5179
|
file,
|
|
5089
5180
|
url,
|
|
@@ -5096,9 +5187,9 @@ async function uploadFile({
|
|
|
5096
5187
|
logInfo(`FileUpload: upload file start ${url}`);
|
|
5097
5188
|
logInfo(`FileUpload: upload fields`, uploadFields);
|
|
5098
5189
|
logInfo(`FileUpload: upload key ${uploadKey}`);
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5190
|
+
debug8("upload file start %s", url);
|
|
5191
|
+
debug8("upload fields %o", uploadFields);
|
|
5192
|
+
debug8("upload key %s", uploadKey);
|
|
5102
5193
|
const form = new FormData();
|
|
5103
5194
|
Object.entries(uploadFields).forEach(([key, value]) => {
|
|
5104
5195
|
form.append(key, value);
|
|
@@ -5107,11 +5198,11 @@ async function uploadFile({
|
|
|
5107
5198
|
form.append("key", uploadKey);
|
|
5108
5199
|
}
|
|
5109
5200
|
if (typeof file === "string") {
|
|
5110
|
-
|
|
5201
|
+
debug8("upload file from path %s", file);
|
|
5111
5202
|
logInfo(`FileUpload: upload file from path ${file}`);
|
|
5112
5203
|
form.append("file", await fileFrom(file));
|
|
5113
5204
|
} else {
|
|
5114
|
-
|
|
5205
|
+
debug8("upload file from buffer");
|
|
5115
5206
|
logInfo(`FileUpload: upload file from buffer`);
|
|
5116
5207
|
form.append("file", new File([new Uint8Array(file)], "file"));
|
|
5117
5208
|
}
|
|
@@ -5122,11 +5213,11 @@ async function uploadFile({
|
|
|
5122
5213
|
agent
|
|
5123
5214
|
});
|
|
5124
5215
|
if (!response.ok) {
|
|
5125
|
-
|
|
5216
|
+
debug8("error from S3 %s %s", response.body, response.status);
|
|
5126
5217
|
logInfo(`FileUpload: error from S3 ${response.body} ${response.status}`);
|
|
5127
5218
|
throw new Error(`Failed to upload the file: ${response.status}`);
|
|
5128
5219
|
}
|
|
5129
|
-
|
|
5220
|
+
debug8("upload file done");
|
|
5130
5221
|
logInfo(`FileUpload: upload file done`);
|
|
5131
5222
|
}
|
|
5132
5223
|
|