@netgreener/runtime 0.1.8 → 0.1.9
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/TUTORIAL.md +120 -29
- package/dist/aggregator.d.ts +12 -2
- package/dist/aggregator.js +135 -8
- package/dist/analyze/buildResourceFindings.d.ts +4 -0
- package/dist/analyze/buildResourceFindings.js +17 -0
- package/dist/analyze/cli.d.ts +1 -0
- package/dist/analyze/cli.js +22 -1
- package/dist/analyze/declaredExternalApis.d.ts +31 -0
- package/dist/analyze/declaredExternalApis.js +174 -0
- package/dist/analyze/index.d.ts +1 -0
- package/dist/analyze/index.js +1 -0
- package/dist/auto.d.ts +7 -0
- package/dist/auto.js +8 -0
- package/dist/bullmq.d.ts +2 -2
- package/dist/bullmq.js +28 -58
- package/dist/carbonLedger.d.ts +28 -0
- package/dist/carbonLedger.js +52 -0
- package/dist/cgroupV2.d.ts +44 -0
- package/dist/cgroupV2.js +174 -0
- package/dist/cli/helpText.d.ts +3 -3
- package/dist/cli/helpText.js +42 -35
- package/dist/cli/netgreener.d.ts +7 -7
- package/dist/cli/netgreener.js +23 -16
- package/dist/cli/runCli.d.ts +20 -0
- package/dist/cli/runCli.js +249 -0
- package/dist/cli/runPreload.d.ts +5 -0
- package/dist/cli/runPreload.js +43 -0
- package/dist/collectorMetadata.d.ts +1 -1
- package/dist/collectorMetadata.js +2 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +6 -2
- package/dist/exporter.d.ts +7 -2
- package/dist/exporter.js +12 -6
- package/dist/express.js +17 -6
- package/dist/externalApiMeter.d.ts +43 -1
- package/dist/externalApiMeter.js +267 -5
- package/dist/fastify.js +17 -6
- package/dist/index.d.ts +10 -2
- package/dist/index.js +9 -1
- package/dist/init.d.ts +30 -0
- package/dist/init.js +31 -0
- package/dist/lifecycle.d.ts +45 -0
- package/dist/lifecycle.js +112 -0
- package/dist/managedCollectorLauncher.d.ts +37 -0
- package/dist/managedCollectorLauncher.js +162 -0
- package/dist/n4/deploymentMatrix.d.ts +9 -5
- package/dist/n4/deploymentMatrix.js +13 -9
- package/dist/n4/missingnessInventory.js +3 -3
- package/dist/next.d.ts +61 -0
- package/dist/next.js +195 -0
- package/dist/occupancyTracker.d.ts +27 -0
- package/dist/occupancyTracker.js +87 -0
- package/dist/optimize/apply.d.ts +38 -0
- package/dist/optimize/apply.js +173 -0
- package/dist/optimize/cli.d.ts +26 -0
- package/dist/optimize/cli.js +323 -0
- package/dist/optimize/index.d.ts +6 -0
- package/dist/optimize/index.js +5 -0
- package/dist/optimize/llmApply.d.ts +22 -0
- package/dist/optimize/llmApply.js +80 -0
- package/dist/optimize/llmSession.d.ts +88 -0
- package/dist/optimize/llmSession.js +135 -0
- package/dist/optimize/provider.d.ts +17 -0
- package/dist/optimize/provider.js +119 -0
- package/dist/optimize/safePatches.d.ts +18 -0
- package/dist/optimize/safePatches.js +247 -0
- package/dist/optimize/types.d.ts +79 -0
- package/dist/optimize/types.js +6 -0
- package/dist/optimize/verification.d.ts +16 -0
- package/dist/optimize/verification.js +165 -0
- package/dist/processResources.d.ts +5 -0
- package/dist/processResources.js +28 -4
- package/dist/processRuntime.js +7 -28
- package/dist/processTree.d.ts +47 -0
- package/dist/processTree.js +148 -0
- package/dist/runContextEnrichment.d.ts +11 -0
- package/dist/runContextEnrichment.js +92 -0
- package/dist/runtime.d.ts +29 -1
- package/dist/runtime.js +94 -16
- package/dist/sdk/client.d.ts +152 -0
- package/dist/sdk/client.js +396 -0
- package/dist/sdk/gitUrl.d.ts +6 -0
- package/dist/sdk/gitUrl.js +87 -0
- package/dist/sdk/index.d.ts +5 -0
- package/dist/sdk/index.js +5 -0
- package/dist/serverlessHints.d.ts +9 -6
- package/dist/serverlessHints.js +10 -7
- package/dist/taskMeter.d.ts +14 -0
- package/dist/taskMeter.js +53 -0
- package/dist/types.d.ts +35 -0
- package/examples/aca-container-gate/Dockerfile +20 -0
- package/examples/aca-container-gate/azure-container-app.yaml +27 -0
- package/examples/aca-container-gate/gate.env +7 -0
- package/examples/aca-container-gate/server.mjs +117 -0
- package/examples/express-local-live-smoke.mjs +127 -0
- package/examples/extractRunId.mjs +11 -0
- package/examples/next-pilot-dry-run.mjs +32 -0
- package/examples/serverless-thin-gate.mjs +89 -0
- package/fixtures/run-smoke/hello.mjs +4 -0
- package/package.json +23 -2
package/dist/runtime.js
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { hostname } from 'node:os';
|
|
2
2
|
import { ServiceRuntimeAggregator } from './aggregator.js';
|
|
3
|
+
import { carbonFactorDict } from './carbonLedger.js';
|
|
3
4
|
import { configReady, loadRuntimeConfig, } from './config.js';
|
|
4
5
|
import { resolveObservationExporter, } from './exporter.js';
|
|
5
6
|
import { newRuntimeWindowId } from './windowId.js';
|
|
6
7
|
import { attachWindowTenantToRunContext, getTenantContext, tenantConfigFromRuntime, } from './tenantContext.js';
|
|
8
|
+
import { enrichRunContextForAnomaly } from './runContextEnrichment.js';
|
|
9
|
+
import { getOccupancyTracker } from './occupancyTracker.js';
|
|
7
10
|
import { getExternalAggregator, getOriginalFetch, installOutboundInstrumentation, } from './externalApiMeter.js';
|
|
8
11
|
import { CPU_SOURCE_PROCESS, MEMORY_SOURCE_PROCESS, } from './processResources.js';
|
|
9
12
|
import { CPU_SOURCE_DURATION_PROXY } from './n4/missingnessInventory.js';
|
|
10
13
|
import { buildRuntimeHealthV0, markHooksActive, mergeHealthIntoMetadata, noteExportAttempt, noteExportMode, noteExportResult, noteFlushSkippedInFlight, _resetRuntimeHealthForTests, } from './runtimeHealth.js';
|
|
14
|
+
import { resolveLifecycle, } from './lifecycle.js';
|
|
11
15
|
/**
|
|
12
16
|
* Process-wide runtime controller: record samples, periodic flush, shutdown flush.
|
|
17
|
+
* Ephemeral lifecycle skips the periodic timer and flushes at invoke/request idle.
|
|
13
18
|
*/
|
|
14
19
|
export class NetGreenerRuntime {
|
|
15
20
|
config;
|
|
21
|
+
lifecycleInfo;
|
|
16
22
|
aggregator = new ServiceRuntimeAggregator();
|
|
17
23
|
collector;
|
|
18
24
|
framework;
|
|
@@ -23,14 +29,30 @@ export class NetGreenerRuntime {
|
|
|
23
29
|
flushing = false;
|
|
24
30
|
started = false;
|
|
25
31
|
outboundInstalled = false;
|
|
32
|
+
/** In-flight HTTP/task units — gates ephemeral idle flush. */
|
|
33
|
+
inFlight = 0;
|
|
34
|
+
invokeFlushScheduled = false;
|
|
35
|
+
/**
|
|
36
|
+
* Sticky window id until a successful export — preserves idempotency across
|
|
37
|
+
* retry of the same in-memory snapshot (serverless / network retry).
|
|
38
|
+
*/
|
|
39
|
+
stickyWindowId = null;
|
|
26
40
|
constructor(opts = {}) {
|
|
27
41
|
this.config = opts.config ?? loadRuntimeConfig();
|
|
28
42
|
this.collector = opts.collector ?? 'express_middleware';
|
|
29
43
|
this.framework = opts.framework ?? 'express';
|
|
30
44
|
this.fetchImpl = opts.fetchImpl ?? fetch;
|
|
31
|
-
this.
|
|
45
|
+
this.lifecycleInfo = resolveLifecycle({ mode: opts.runtimeMode });
|
|
46
|
+
this.exporter =
|
|
47
|
+
opts.exporter ??
|
|
48
|
+
resolveObservationExporter(undefined, {
|
|
49
|
+
lifecycle: this.lifecycleInfo.lifecycle,
|
|
50
|
+
});
|
|
32
51
|
this.onFlush = opts.onFlush;
|
|
33
52
|
}
|
|
53
|
+
get lifecycle() {
|
|
54
|
+
return this.lifecycleInfo.lifecycle;
|
|
55
|
+
}
|
|
34
56
|
get enabled() {
|
|
35
57
|
return configReady(this.config).ok;
|
|
36
58
|
}
|
|
@@ -38,14 +60,21 @@ export class NetGreenerRuntime {
|
|
|
38
60
|
if (this.outboundInstalled || !this.enabled)
|
|
39
61
|
return;
|
|
40
62
|
this.outboundInstalled = true;
|
|
63
|
+
const firstPartyHosts = String(process.env.NETGREENER_FIRST_PARTY_HOSTS || '')
|
|
64
|
+
.split(',')
|
|
65
|
+
.map((h) => h.trim().toLowerCase().replace(/^\*\./, '').replace(/^www\./, ''))
|
|
66
|
+
.filter(Boolean);
|
|
41
67
|
try {
|
|
42
68
|
const apiHost = new URL(this.config.apiUrl).hostname;
|
|
69
|
+
const excluded = [...(apiHost ? [apiHost] : []), ...firstPartyHosts];
|
|
43
70
|
installOutboundInstrumentation({
|
|
44
|
-
excludedHosts:
|
|
71
|
+
excludedHosts: excluded,
|
|
45
72
|
});
|
|
46
73
|
}
|
|
47
74
|
catch {
|
|
48
|
-
installOutboundInstrumentation(
|
|
75
|
+
installOutboundInstrumentation({
|
|
76
|
+
excludedHosts: firstPartyHosts,
|
|
77
|
+
});
|
|
49
78
|
}
|
|
50
79
|
}
|
|
51
80
|
/** Prefer unwrapped fetch so telemetry uploads are never metered. */
|
|
@@ -64,11 +93,45 @@ export class NetGreenerRuntime {
|
|
|
64
93
|
});
|
|
65
94
|
noteExportMode(this.exporter.mode);
|
|
66
95
|
this.ensureOutboundMeter();
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
96
|
+
// Persistent path unchanged: periodic flush. Ephemeral must not depend on it.
|
|
97
|
+
if (this.lifecycle === 'persistent' && this.lifecycleInfo.capabilities.periodic_flush) {
|
|
98
|
+
this.timer = setInterval(() => {
|
|
99
|
+
void this.flush('periodic');
|
|
100
|
+
}, this.config.flushIntervalMs);
|
|
101
|
+
// Do not keep the process alive solely for the timer.
|
|
102
|
+
this.timer.unref?.();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** Mark start of an inbound request/task (ephemeral idle-flush accounting). */
|
|
106
|
+
beginRequest() {
|
|
107
|
+
this.inFlight += 1;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Mark end of an inbound request/task. In ephemeral mode, schedules a flush
|
|
111
|
+
* when no requests remain in flight (safe under concurrency).
|
|
112
|
+
*/
|
|
113
|
+
endRequest() {
|
|
114
|
+
if (this.inFlight > 0)
|
|
115
|
+
this.inFlight -= 1;
|
|
116
|
+
if (this.lifecycle !== 'ephemeral')
|
|
117
|
+
return;
|
|
118
|
+
if (this.invokeFlushScheduled)
|
|
119
|
+
return;
|
|
120
|
+
this.invokeFlushScheduled = true;
|
|
121
|
+
void Promise.resolve().then(() => {
|
|
122
|
+
this.invokeFlushScheduled = false;
|
|
123
|
+
if (this.inFlight === 0) {
|
|
124
|
+
void this.flush('invoke_end');
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/** Explicit serverless invoke-end flush (Lambda finally / platform adapter). */
|
|
129
|
+
async flushForInvokeEnd() {
|
|
130
|
+
return this.flush('invoke_end');
|
|
131
|
+
}
|
|
132
|
+
/** Test helper: in-flight request counter. */
|
|
133
|
+
_inFlightForTests() {
|
|
134
|
+
return this.inFlight;
|
|
72
135
|
}
|
|
73
136
|
stop() {
|
|
74
137
|
if (this.timer) {
|
|
@@ -144,12 +207,20 @@ export class NetGreenerRuntime {
|
|
|
144
207
|
: 0;
|
|
145
208
|
const util = Math.min(1, busySeconds / Math.max(windowSeconds, 0.001));
|
|
146
209
|
const windowEnergyKwh = (this.config.estimateTdpWatts * util * windowSeconds) / 1000 / 3600;
|
|
210
|
+
const occupancy = getOccupancyTracker().takeWindowSnapshot();
|
|
211
|
+
// Crude window RAM (GiB·h) from peak RSS — allocated by occupancy when present.
|
|
212
|
+
const peakRssKb = snapshot ? snapshot.maxPeakRssKb() : 0;
|
|
213
|
+
const windowRamGbHours = peakRssKb > 0
|
|
214
|
+
? (peakRssKb / 1024 / 1024) * (windowSeconds / 3600)
|
|
215
|
+
: null;
|
|
147
216
|
const runtimeV0 = snapshot
|
|
148
217
|
? snapshot.buildV0({
|
|
149
218
|
collector: this.collector,
|
|
150
219
|
framework: this.framework,
|
|
151
220
|
windowEnergyKwh,
|
|
152
221
|
windowSeconds,
|
|
222
|
+
windowRamGbHours,
|
|
223
|
+
occupancy,
|
|
153
224
|
})
|
|
154
225
|
: null;
|
|
155
226
|
if (snapshot && !runtimeV0) {
|
|
@@ -161,7 +232,9 @@ export class NetGreenerRuntime {
|
|
|
161
232
|
const externalV0 = externalSnapshot ? externalSnapshot.buildV0() : null;
|
|
162
233
|
const end = new Date();
|
|
163
234
|
const start = new Date(end.getTime() - windowSeconds * 1000);
|
|
164
|
-
|
|
235
|
+
// Reuse sticky id until success so retries do not mint a new window.
|
|
236
|
+
const windowId = this.stickyWindowId ?? newRuntimeWindowId();
|
|
237
|
+
this.stickyWindowId = windowId;
|
|
165
238
|
// Prefer effective RuntimeConfig over ambient process.env.
|
|
166
239
|
const tenantConfig = tenantConfigFromRuntime(this.config);
|
|
167
240
|
const runContext = {
|
|
@@ -169,11 +242,15 @@ export class NetGreenerRuntime {
|
|
|
169
242
|
runtime_flush_kind: kind,
|
|
170
243
|
measured_scope: 'process',
|
|
171
244
|
resource_scope: 'process',
|
|
245
|
+
runtime_lifecycle: this.lifecycleInfo.lifecycle,
|
|
246
|
+
runtime_platform: this.lifecycleInfo.platform,
|
|
247
|
+
runtime_capabilities: this.lifecycleInfo.capabilities,
|
|
172
248
|
...(this.config.deployEnvironment
|
|
173
249
|
? { deploy_environment: this.config.deployEnvironment }
|
|
174
250
|
: {}),
|
|
175
251
|
...(this.config.releaseTag ? { release_tag: this.config.releaseTag } : {}),
|
|
176
252
|
};
|
|
253
|
+
enrichRunContextForAnomaly(runContext);
|
|
177
254
|
attachWindowTenantToRunContext(runContext, {
|
|
178
255
|
runtimeV0: runtimeV0 ?? undefined,
|
|
179
256
|
externalV0: externalV0 ?? undefined,
|
|
@@ -182,6 +259,7 @@ export class NetGreenerRuntime {
|
|
|
182
259
|
});
|
|
183
260
|
const measuredCpu = snapshot?.hasMeasuredCpu() ?? false;
|
|
184
261
|
const measuredRss = snapshot?.hasMeasuredRss() ?? false;
|
|
262
|
+
const carbonFactor = carbonFactorDict();
|
|
185
263
|
const session_metadata = {
|
|
186
264
|
run_context: runContext,
|
|
187
265
|
...(runtimeV0 ? { service_runtime_v0: runtimeV0 } : {}),
|
|
@@ -196,11 +274,7 @@ export class NetGreenerRuntime {
|
|
|
196
274
|
energy_model: runtimeV0 ? 'tdp_utilization_estimate' : 'unavailable',
|
|
197
275
|
gpu_scope: 'none',
|
|
198
276
|
gpu_source: 'unavailable',
|
|
199
|
-
carbon_factor:
|
|
200
|
-
value: 0.4,
|
|
201
|
-
unit: 'kg_co2e_per_kwh',
|
|
202
|
-
source: 'default_grid_factor',
|
|
203
|
-
},
|
|
277
|
+
carbon_factor: carbonFactor,
|
|
204
278
|
evidence_grades: {
|
|
205
279
|
schema_version: 1,
|
|
206
280
|
policy_version: 'r9_v0',
|
|
@@ -214,7 +288,7 @@ export class NetGreenerRuntime {
|
|
|
214
288
|
metric: 'local_carbon',
|
|
215
289
|
grade: runtimeV0 ? 'G1' : 'G0',
|
|
216
290
|
reasons: runtimeV0
|
|
217
|
-
? ['estimated_power_tdp',
|
|
291
|
+
? ['estimated_power_tdp', carbonFactor.source]
|
|
218
292
|
: ['no_runtime_units'],
|
|
219
293
|
},
|
|
220
294
|
},
|
|
@@ -242,6 +316,10 @@ export class NetGreenerRuntime {
|
|
|
242
316
|
this.aggregator.mergeSnapshot(snapshot);
|
|
243
317
|
if (externalSnapshot)
|
|
244
318
|
externalAgg.mergeSnapshot(externalSnapshot);
|
|
319
|
+
// Keep stickyWindowId so the next flush retries the same window id.
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
this.stickyWindowId = null;
|
|
245
323
|
}
|
|
246
324
|
this.onFlush?.(result, payload);
|
|
247
325
|
return result;
|
|
@@ -260,7 +338,7 @@ export class NetGreenerRuntime {
|
|
|
260
338
|
project_id: this.config.projectId,
|
|
261
339
|
start_time: new Date().toISOString(),
|
|
262
340
|
end_time: new Date().toISOString(),
|
|
263
|
-
runtime_window_id: newRuntimeWindowId(),
|
|
341
|
+
runtime_window_id: this.stickyWindowId ?? newRuntimeWindowId(),
|
|
264
342
|
session_metadata: {},
|
|
265
343
|
});
|
|
266
344
|
return result;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin Node HTTP client twin of Python ``netgreener_sdk.NetGreenerClient``.
|
|
3
|
+
*
|
|
4
|
+
* Same api_server brain — no Node server fork. Does not flip EXPORT_MODE.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ApiError extends Error {
|
|
7
|
+
readonly statusCode: number;
|
|
8
|
+
readonly detail: string;
|
|
9
|
+
constructor(statusCode: number, detail: string);
|
|
10
|
+
}
|
|
11
|
+
export type NetGreenerSdkOptions = {
|
|
12
|
+
token?: string;
|
|
13
|
+
/** API root including ``/api/v1`` */
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
orgId?: number;
|
|
16
|
+
environment?: string;
|
|
17
|
+
userId?: number;
|
|
18
|
+
fetchImpl?: typeof fetch;
|
|
19
|
+
};
|
|
20
|
+
type ProjectRow = Record<string, unknown> & {
|
|
21
|
+
project_id?: number;
|
|
22
|
+
name?: string;
|
|
23
|
+
directory?: string;
|
|
24
|
+
git_url?: string | null;
|
|
25
|
+
};
|
|
26
|
+
export declare class NetGreenerClient {
|
|
27
|
+
baseUrl: string;
|
|
28
|
+
private token;
|
|
29
|
+
private orgId;
|
|
30
|
+
private environment;
|
|
31
|
+
private userId;
|
|
32
|
+
private readonly fetchImpl;
|
|
33
|
+
constructor(opts?: NetGreenerSdkOptions);
|
|
34
|
+
setToken(token: string | undefined): void;
|
|
35
|
+
getAccessToken(): string | undefined;
|
|
36
|
+
setOrgContext(orgId: number | undefined, environment?: string): void;
|
|
37
|
+
getOrgContext(): {
|
|
38
|
+
orgId: number | undefined;
|
|
39
|
+
environment: string | undefined;
|
|
40
|
+
};
|
|
41
|
+
/** GET /organizations/by-slug/{slug} (OP2). */
|
|
42
|
+
getOrganizationBySlug(slug: string): Promise<Record<string, unknown>>;
|
|
43
|
+
/** Resolve slug → orgId and set client org context. */
|
|
44
|
+
resolveOrgSlug(slug: string): Promise<number>;
|
|
45
|
+
private headers;
|
|
46
|
+
private raise;
|
|
47
|
+
private request;
|
|
48
|
+
login(email: string, password: string): Promise<Record<string, unknown>>;
|
|
49
|
+
getMe(): Promise<Record<string, unknown>>;
|
|
50
|
+
postRunSession(payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
51
|
+
getRunSession(runId: number): Promise<Record<string, unknown>>;
|
|
52
|
+
getRunOutcome(runId: number): Promise<Record<string, unknown>>;
|
|
53
|
+
attachRunOutcome(runId: number, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
54
|
+
getRunSessions(opts?: {
|
|
55
|
+
projectId?: number;
|
|
56
|
+
ciOnly?: boolean;
|
|
57
|
+
branch?: string;
|
|
58
|
+
}): Promise<unknown[]>;
|
|
59
|
+
createServiceToken(orgId: number, scopes: string[], opts?: {
|
|
60
|
+
environment?: string;
|
|
61
|
+
expiresInHours?: number;
|
|
62
|
+
}): Promise<Record<string, unknown>>;
|
|
63
|
+
listServiceTokens(orgId: number): Promise<Record<string, unknown>>;
|
|
64
|
+
revokeServiceToken(orgId: number, tokenId: number): Promise<Record<string, unknown>>;
|
|
65
|
+
getProjects(opts?: {
|
|
66
|
+
isActive?: boolean;
|
|
67
|
+
}): Promise<ProjectRow[]>;
|
|
68
|
+
createProject(payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
69
|
+
updateProject(projectId: number, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
70
|
+
getProject(projectId: number): Promise<Record<string, unknown>>;
|
|
71
|
+
private ensureUserId;
|
|
72
|
+
private maybeSyncProject;
|
|
73
|
+
/**
|
|
74
|
+
* Match by git_url → directory → name; create when none match.
|
|
75
|
+
* Same order as Python SDK / CLI.
|
|
76
|
+
*/
|
|
77
|
+
getOrCreateProject(name: string, directory: string, opts?: {
|
|
78
|
+
gitUrl?: string | null;
|
|
79
|
+
userId?: number;
|
|
80
|
+
language?: string;
|
|
81
|
+
}): Promise<Record<string, unknown>>;
|
|
82
|
+
getReportSettings(orgId: number): Promise<Record<string, unknown>>;
|
|
83
|
+
updateReportSettings(orgId: number, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
84
|
+
previewReport(orgId: number, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
85
|
+
generateReport(orgId: number, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
86
|
+
getReportHistory(orgId: number, opts?: {
|
|
87
|
+
limit?: number;
|
|
88
|
+
}): Promise<unknown[]>;
|
|
89
|
+
getEnergyBaseline(projectId: number, opts?: {
|
|
90
|
+
branch?: string;
|
|
91
|
+
}): Promise<Record<string, unknown>>;
|
|
92
|
+
rotateServiceToken(orgId: number, tokenId: number, opts?: {
|
|
93
|
+
expiresInHours?: number;
|
|
94
|
+
}): Promise<Record<string, unknown>>;
|
|
95
|
+
quoteReportAiSummary(orgId: number, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
96
|
+
downloadReport(orgId: number, reportId: number, opts?: {
|
|
97
|
+
format?: string;
|
|
98
|
+
}): Promise<Record<string, unknown>>;
|
|
99
|
+
quoteCredits(orgId: number, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
100
|
+
estimateRun(payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
101
|
+
estimateProject(projectId: number, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
102
|
+
getRunEstimate(runId: number): Promise<Record<string, unknown>>;
|
|
103
|
+
analyzeProjectFiles(projectId: number, perFile: Array<{
|
|
104
|
+
rel_path: string;
|
|
105
|
+
features: unknown;
|
|
106
|
+
}>): Promise<unknown[]>;
|
|
107
|
+
getProjectFindings(projectId: number): Promise<unknown[]>;
|
|
108
|
+
/**
|
|
109
|
+
* POST /findings/batch — optional ``declared_external_apis`` seeds the org
|
|
110
|
+
* external-API catalog (Python analyze twin). Findings may be empty.
|
|
111
|
+
*/
|
|
112
|
+
postFindingsBatch(findings: Record<string, unknown>[], options?: {
|
|
113
|
+
projectId?: number;
|
|
114
|
+
replaceExisting?: boolean;
|
|
115
|
+
scopeFilePaths?: string[];
|
|
116
|
+
declaredExternalApis?: Array<{
|
|
117
|
+
provider_key: string;
|
|
118
|
+
detection_method?: string;
|
|
119
|
+
module_roots?: string[];
|
|
120
|
+
file_paths?: string[];
|
|
121
|
+
}>;
|
|
122
|
+
detectionContext?: Record<string, unknown>;
|
|
123
|
+
}): Promise<Record<string, unknown>>;
|
|
124
|
+
submitFindingFeedback(findingId: number, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
125
|
+
getProjectDataSources(projectId: number): Promise<unknown[]>;
|
|
126
|
+
createProjectDataSource(projectId: number, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
127
|
+
linkProjectDataSource(projectId: number, sourceId: number, opts?: {
|
|
128
|
+
isDefault?: boolean;
|
|
129
|
+
}): Promise<Record<string, unknown>>;
|
|
130
|
+
updateDataSource(sourceId: number, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
131
|
+
deleteDataSource(sourceId: number): Promise<Record<string, unknown>>;
|
|
132
|
+
getRunDataSources(runId: number): Promise<unknown[]>;
|
|
133
|
+
getProjectFeatureMetadata(projectId: number): Promise<Record<string, unknown>>;
|
|
134
|
+
postProjectFeatureMetadata(projectId: number, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
135
|
+
listFeatureDefinitions(): Promise<unknown[]>;
|
|
136
|
+
/** POST ``/optimize/function`` — shared LLM optimize brain (Python/VSCE twin). */
|
|
137
|
+
optimizeFunction(payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
138
|
+
/** POST ``/optimize/plan`` — ranked optimization plan. */
|
|
139
|
+
createOptimizationPlan(payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
140
|
+
getOptimizationPlan(planId: number): Promise<Record<string, unknown>>;
|
|
141
|
+
listOptimizationPlans(projectId: number, opts?: {
|
|
142
|
+
limit?: number;
|
|
143
|
+
}): Promise<unknown[]>;
|
|
144
|
+
/** GET ``/developer/me/anomaly-briefs/pending`` — same brain as VSCE poll. */
|
|
145
|
+
listPendingAnomalyBriefs(): Promise<unknown[]>;
|
|
146
|
+
getAnomalyBrief(briefId: string): Promise<Record<string, unknown>>;
|
|
147
|
+
claimAnomalyBrief(briefId: string, opts?: {
|
|
148
|
+
claimedByDevice?: string;
|
|
149
|
+
}): Promise<Record<string, unknown>>;
|
|
150
|
+
updateAnomalyBrief(briefId: string, status: 'completed' | 'cancelled'): Promise<Record<string, unknown>>;
|
|
151
|
+
}
|
|
152
|
+
export {};
|