@shdwsdk/cli 0.0.0-stage → 1.2.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/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +11 -0
- package/dist/bin.js.map +1 -0
- package/dist/codegen.d.ts +21 -0
- package/dist/codegen.d.ts.map +1 -0
- package/dist/codegen.js +136 -0
- package/dist/codegen.js.map +1 -0
- package/dist/connectivity.d.ts +17 -0
- package/dist/connectivity.d.ts.map +1 -0
- package/dist/connectivity.js +103 -0
- package/dist/connectivity.js.map +1 -0
- package/dist/env.d.ts +36 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +105 -0
- package/dist/env.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/wizard.d.ts +25 -0
- package/dist/wizard.d.ts.map +1 -0
- package/dist/wizard.js +193 -0
- package/dist/wizard.js.map +1 -0
- package/package.json +45 -4
- package/src/bin.ts +12 -0
- package/src/codegen.ts +167 -0
- package/src/connectivity.ts +131 -0
- package/src/env.ts +144 -0
- package/src/index.ts +31 -0
- package/src/wizard.ts +267 -0
- package/README.md +0 -3
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// ============================================================================
|
|
3
|
+
// @shdwsdk/cli — Executable Bin Entrypoint (npx shdw-init / npx @shdwsdk/cli init)
|
|
4
|
+
// ============================================================================
|
|
5
|
+
import { runCliFromArgv } from "./wizard.js";
|
|
6
|
+
runCliFromArgv(process.argv.slice(2)).catch((err) => {
|
|
7
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
8
|
+
process.stderr.write(`SHDWsdk CLI Error: ${message}\n`);
|
|
9
|
+
process.exitCode = 1;
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,+EAA+E;AAC/E,mFAAmF;AACnF,+EAA+E;AAE/E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC3D,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,OAAO,IAAI,CAAC,CAAC;IACxD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface GenerateBoilerplateParams {
|
|
2
|
+
cwd: string;
|
|
3
|
+
outputPath?: string;
|
|
4
|
+
modelPattern: string;
|
|
5
|
+
gridRegion: string;
|
|
6
|
+
}
|
|
7
|
+
export interface GeneratedBoilerplateResult {
|
|
8
|
+
filePath: string;
|
|
9
|
+
relativePath: string;
|
|
10
|
+
overwroteExisting: boolean;
|
|
11
|
+
providerLabel: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function buildBoilerplateSource(params: {
|
|
14
|
+
modelPattern: string;
|
|
15
|
+
gridRegion: string;
|
|
16
|
+
}): {
|
|
17
|
+
source: string;
|
|
18
|
+
providerLabel: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function generateShdwBoilerplateFile(params: GenerateBoilerplateParams): GeneratedBoilerplateResult;
|
|
21
|
+
//# sourceMappingURL=codegen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../src/codegen.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,yBAAyB;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAC7C,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAiH5C;AAED,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,yBAAyB,GAChC,0BAA0B,CAkB5B"}
|
package/dist/codegen.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// @shdwsdk/cli — Boilerplate Integration Code Generator
|
|
3
|
+
// Generates a pre-configured `src/lib/shdw.ts` (or custom path) wired with
|
|
4
|
+
// `ShdwTelemetryClient` and `wrapClient` for the user's selected AI model
|
|
5
|
+
// provider and cloud datacenter grid region.
|
|
6
|
+
// ============================================================================
|
|
7
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { dirname, resolve } from "node:path";
|
|
9
|
+
import { resolveGridRegionFactor, resolveModelCoefficient, } from "@shdwsdk/sdk";
|
|
10
|
+
export function buildBoilerplateSource(params) {
|
|
11
|
+
const modelCoeff = resolveModelCoefficient(params.modelPattern);
|
|
12
|
+
const gridFactor = resolveGridRegionFactor(params.gridRegion);
|
|
13
|
+
const header = `// ============================================================================
|
|
14
|
+
// SHDWsdk Integration (${modelCoeff.displayName})
|
|
15
|
+
// Region: ${gridFactor.displayName} (${gridFactor.intensityGco2PerKwh} gCO2e/kWh)
|
|
16
|
+
// Strictly non-blocking: <=1500ms AbortController timeout & silent fallback.
|
|
17
|
+
// ============================================================================
|
|
18
|
+
|
|
19
|
+
`;
|
|
20
|
+
if (modelCoeff.provider === "anthropic") {
|
|
21
|
+
return {
|
|
22
|
+
providerLabel: "Anthropic",
|
|
23
|
+
source: `${header}import Anthropic from "@anthropic-ai/sdk";
|
|
24
|
+
import { ShdwTelemetryClient } from "@shdwsdk/sdk";
|
|
25
|
+
|
|
26
|
+
export const shdw = new ShdwTelemetryClient({
|
|
27
|
+
apiKey: process.env.SHDW_API_KEY ?? "",
|
|
28
|
+
endpoint: "https://shdwsdk.ai/api/v1/ingest-telemetry",
|
|
29
|
+
defaultGridRegion: process.env.SHDW_GRID_REGION ?? "${gridFactor.region}",
|
|
30
|
+
defaultWorkloadName: "Production Anthropic AI Service",
|
|
31
|
+
timeoutMs: 1500,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const anthropic = shdw.wrapClient(new Anthropic(), {
|
|
35
|
+
provider: "anthropic",
|
|
36
|
+
gridRegion: process.env.SHDW_GRID_REGION ?? "${gridFactor.region}",
|
|
37
|
+
defaultModel: "${params.modelPattern}",
|
|
38
|
+
});
|
|
39
|
+
`,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (modelCoeff.provider === "gemini") {
|
|
43
|
+
return {
|
|
44
|
+
providerLabel: "Google Gemini",
|
|
45
|
+
source: `${header}import { GoogleGenerativeAI } from "@google/generative-ai";
|
|
46
|
+
import { ShdwTelemetryClient } from "@shdwsdk/sdk";
|
|
47
|
+
|
|
48
|
+
export const shdw = new ShdwTelemetryClient({
|
|
49
|
+
apiKey: process.env.SHDW_API_KEY ?? "",
|
|
50
|
+
endpoint: "https://shdwsdk.ai/api/v1/ingest-telemetry",
|
|
51
|
+
defaultGridRegion: process.env.SHDW_GRID_REGION ?? "${gridFactor.region}",
|
|
52
|
+
defaultWorkloadName: "Production Google Gemini Service",
|
|
53
|
+
timeoutMs: 1500,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY ?? "");
|
|
57
|
+
|
|
58
|
+
export const geminiModel = shdw.wrapClient(
|
|
59
|
+
genAI.getGenerativeModel({ model: "${params.modelPattern}" }),
|
|
60
|
+
{
|
|
61
|
+
provider: "gemini",
|
|
62
|
+
gridRegion: process.env.SHDW_GRID_REGION ?? "${gridFactor.region}",
|
|
63
|
+
defaultModel: "${params.modelPattern}",
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
`,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (modelCoeff.provider === "openai") {
|
|
70
|
+
return {
|
|
71
|
+
providerLabel: "OpenAI",
|
|
72
|
+
source: `${header}import OpenAI from "openai";
|
|
73
|
+
import { ShdwTelemetryClient } from "@shdwsdk/sdk";
|
|
74
|
+
|
|
75
|
+
export const shdw = new ShdwTelemetryClient({
|
|
76
|
+
apiKey: process.env.SHDW_API_KEY ?? "",
|
|
77
|
+
endpoint: "https://shdwsdk.ai/api/v1/ingest-telemetry",
|
|
78
|
+
defaultGridRegion: process.env.SHDW_GRID_REGION ?? "${gridFactor.region}",
|
|
79
|
+
defaultWorkloadName: "Production OpenAI Service",
|
|
80
|
+
timeoutMs: 1500,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export const openai = shdw.wrapClient(new OpenAI(), {
|
|
84
|
+
provider: "openai",
|
|
85
|
+
gridRegion: process.env.SHDW_GRID_REGION ?? "${gridFactor.region}",
|
|
86
|
+
defaultModel: "${params.modelPattern}",
|
|
87
|
+
});
|
|
88
|
+
`,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
// Custom / OpenAI-compatible (Mistral, Llama, DeepSeek, Cohere)
|
|
92
|
+
return {
|
|
93
|
+
providerLabel: modelCoeff.vendorGroup,
|
|
94
|
+
source: `${header}import OpenAI from "openai";
|
|
95
|
+
import { ShdwTelemetryClient } from "@shdwsdk/sdk";
|
|
96
|
+
|
|
97
|
+
export const shdw = new ShdwTelemetryClient({
|
|
98
|
+
apiKey: process.env.SHDW_API_KEY ?? "",
|
|
99
|
+
endpoint: "https://shdwsdk.ai/api/v1/ingest-telemetry",
|
|
100
|
+
defaultGridRegion: process.env.SHDW_GRID_REGION ?? "${gridFactor.region}",
|
|
101
|
+
defaultWorkloadName: "Production ${modelCoeff.vendorGroup} Service",
|
|
102
|
+
timeoutMs: 1500,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Works with any OpenAI-compatible client (Mistral, vLLM, DeepSeek, Together, etc.)
|
|
106
|
+
export const aiClient = shdw.wrapClient(
|
|
107
|
+
new OpenAI({
|
|
108
|
+
apiKey: process.env.AI_PROVIDER_API_KEY ?? process.env.OPENAI_API_KEY ?? "",
|
|
109
|
+
}),
|
|
110
|
+
{
|
|
111
|
+
provider: "custom",
|
|
112
|
+
gridRegion: process.env.SHDW_GRID_REGION ?? "${gridFactor.region}",
|
|
113
|
+
defaultModel: "${params.modelPattern}",
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
`,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
export function generateShdwBoilerplateFile(params) {
|
|
120
|
+
const relativePath = params.outputPath?.trim() || "src/lib/shdw.ts";
|
|
121
|
+
const filePath = resolve(params.cwd, relativePath);
|
|
122
|
+
const overwroteExisting = existsSync(filePath);
|
|
123
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
124
|
+
const { source, providerLabel } = buildBoilerplateSource({
|
|
125
|
+
modelPattern: params.modelPattern,
|
|
126
|
+
gridRegion: params.gridRegion,
|
|
127
|
+
});
|
|
128
|
+
writeFileSync(filePath, source, "utf8");
|
|
129
|
+
return {
|
|
130
|
+
filePath,
|
|
131
|
+
relativePath,
|
|
132
|
+
overwroteExisting,
|
|
133
|
+
providerLabel,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=codegen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../src/codegen.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,wDAAwD;AACxD,2EAA2E;AAC3E,0EAA0E;AAC1E,6CAA6C;AAC7C,+EAA+E;AAE/E,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EACL,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAgBtB,MAAM,UAAU,sBAAsB,CAAC,MAGtC;IACC,MAAM,UAAU,GAAG,uBAAuB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAChE,MAAM,UAAU,GAAG,uBAAuB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAE9D,MAAM,MAAM,GAAG;0BACS,UAAU,CAAC,WAAW;aACnC,UAAU,CAAC,WAAW,KAAK,UAAU,CAAC,mBAAmB;;;;CAIrE,CAAC;IAEA,IAAI,UAAU,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;QACxC,OAAO;YACL,aAAa,EAAE,WAAW;YAC1B,MAAM,EAAE,GAAG,MAAM;;;;;;wDAMiC,UAAU,CAAC,MAAM;;;;;;;iDAOxB,UAAU,CAAC,MAAM;mBAC/C,MAAM,CAAC,YAAY;;CAErC;SACI,CAAC;IACJ,CAAC;IAED,IAAI,UAAU,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO;YACL,aAAa,EAAE,eAAe;YAC9B,MAAM,EAAE,GAAG,MAAM;;;;;;wDAMiC,UAAU,CAAC,MA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,aAAa;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const DEFAULT_SHDW_INGEST_ENDPOINT = "https://shdwsdk.ai/api/v1/ingest-telemetry";
|
|
2
|
+
export interface ConnectivityTestResult {
|
|
3
|
+
ok: boolean;
|
|
4
|
+
status: number | null;
|
|
5
|
+
latencyMs: number;
|
|
6
|
+
endpoint: string;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function testShdwConnectivity(params: {
|
|
10
|
+
apiKey: string;
|
|
11
|
+
modelPattern: string;
|
|
12
|
+
gridRegion: string;
|
|
13
|
+
endpoint?: string;
|
|
14
|
+
timeoutMs?: number;
|
|
15
|
+
customFetch?: typeof fetch;
|
|
16
|
+
}): Promise<ConnectivityTestResult>;
|
|
17
|
+
//# sourceMappingURL=connectivity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectivity.d.ts","sourceRoot":"","sources":["../src/connectivity.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,4BAA4B,+CACK,CAAC;AAG/C,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,oBAAoB,CAAC,MAAM,EAAE;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,KAAK,CAAC;CAC5B,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAuGlC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// @shdwsdk/cli — Live Connectivity Validation Ping
|
|
3
|
+
// Sends a lightweight validation ping to the SHDWsdk ingestion endpoint using
|
|
4
|
+
// an AbortController strictly clamped to <= 1500ms.
|
|
5
|
+
// ============================================================================
|
|
6
|
+
import { calculateFootprint, resolveModelCoefficient } from "@shdwsdk/sdk";
|
|
7
|
+
export const DEFAULT_SHDW_INGEST_ENDPOINT = "https://shdwsdk.ai/api/v1/ingest-telemetry";
|
|
8
|
+
const MAX_CONNECTIVITY_TIMEOUT_MS = 1500;
|
|
9
|
+
export async function testShdwConnectivity(params) {
|
|
10
|
+
const endpoint = params.endpoint ?? DEFAULT_SHDW_INGEST_ENDPOINT;
|
|
11
|
+
const timeoutMs = Math.min(MAX_CONNECTIVITY_TIMEOUT_MS, Math.max(100, params.timeoutMs ?? MAX_CONNECTIVITY_TIMEOUT_MS));
|
|
12
|
+
const fetchImpl = params.customFetch ?? globalThis.fetch.bind(globalThis);
|
|
13
|
+
const coeff = resolveModelCoefficient(params.modelPattern);
|
|
14
|
+
const footprint = calculateFootprint({
|
|
15
|
+
modelName: params.modelPattern,
|
|
16
|
+
promptTokens: 1,
|
|
17
|
+
completionTokens: 1,
|
|
18
|
+
gridRegion: params.gridRegion,
|
|
19
|
+
});
|
|
20
|
+
const controller = new AbortController();
|
|
21
|
+
const timeoutId = setTimeout(() => {
|
|
22
|
+
try {
|
|
23
|
+
controller.abort();
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// Ignore abort errors
|
|
27
|
+
}
|
|
28
|
+
}, timeoutMs);
|
|
29
|
+
const startedAt = Date.now();
|
|
30
|
+
try {
|
|
31
|
+
const res = await fetchImpl(endpoint, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: {
|
|
34
|
+
"Content-Type": "application/json",
|
|
35
|
+
"X-SHDW-Key": params.apiKey,
|
|
36
|
+
"X-SHDW-SDK-Version": "1.2.0-cli-init",
|
|
37
|
+
},
|
|
38
|
+
body: JSON.stringify({
|
|
39
|
+
events: [
|
|
40
|
+
{
|
|
41
|
+
model_name: params.modelPattern,
|
|
42
|
+
provider: coeff.provider,
|
|
43
|
+
prompt_tokens: 1,
|
|
44
|
+
completion_tokens: 1,
|
|
45
|
+
estimated_energy_kwh: footprint.estimatedEnergyKwh,
|
|
46
|
+
carbon_gco2e: footprint.carbonGco2e,
|
|
47
|
+
grid_region: footprint.gridRegion,
|
|
48
|
+
grid_intensity_gco2_kwh: footprint.gridIntensityGco2PerKwh,
|
|
49
|
+
is_streaming: false,
|
|
50
|
+
latency_ms: 1,
|
|
51
|
+
timestamp: new Date().toISOString(),
|
|
52
|
+
workload_name: "CLI Setup Verification Ping",
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
}),
|
|
56
|
+
signal: controller.signal,
|
|
57
|
+
});
|
|
58
|
+
const latencyMs = Math.max(1, Date.now() - startedAt);
|
|
59
|
+
if (res.ok || res.status === 202) {
|
|
60
|
+
return {
|
|
61
|
+
ok: true,
|
|
62
|
+
status: res.status,
|
|
63
|
+
latencyMs,
|
|
64
|
+
endpoint,
|
|
65
|
+
message: `Connected (${res.status}) in ${latencyMs}ms — API key and telemetry route verified.`,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (res.status === 401 || res.status === 403) {
|
|
69
|
+
return {
|
|
70
|
+
ok: false,
|
|
71
|
+
status: res.status,
|
|
72
|
+
latencyMs,
|
|
73
|
+
endpoint,
|
|
74
|
+
message: `Endpoint reachable (${res.status}), but API key was rejected. Verify your shdw_live_* key in the Dashboard.`,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
ok: false,
|
|
79
|
+
status: res.status,
|
|
80
|
+
latencyMs,
|
|
81
|
+
endpoint,
|
|
82
|
+
message: `Endpoint returned HTTP ${res.status} in ${latencyMs}ms. Local config was saved; telemetry will fail silently until the endpoint recovers.`,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
const latencyMs = Math.max(1, Date.now() - startedAt);
|
|
87
|
+
const isAbort = err instanceof Error &&
|
|
88
|
+
(err.name === "AbortError" || err.message.toLowerCase().includes("abort"));
|
|
89
|
+
return {
|
|
90
|
+
ok: false,
|
|
91
|
+
status: null,
|
|
92
|
+
latencyMs,
|
|
93
|
+
endpoint,
|
|
94
|
+
message: isAbort
|
|
95
|
+
? `Connectivity check timed out after ${timeoutMs}ms (non-blocking guard active). Local config was saved.`
|
|
96
|
+
: `Could not reach ${endpoint} (${err instanceof Error ? err.message : "network error"}). Local config was saved.`,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
clearTimeout(timeoutId);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=connectivity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectivity.js","sourceRoot":"","sources":["../src/connectivity.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,mDAAmD;AACnD,8EAA8E;AAC9E,oDAAoD;AACpD,+EAA+E;AAE/E,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE3E,MAAM,CAAC,MAAM,4BAA4B,GACvC,4CAA4C,CAAC;AAC/C,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAUzC,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAO1C;IACC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,4BAA4B,CAAC;IACjE,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CACxB,2BAA2B,EAC3B,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,SAAS,IAAI,2BAA2B,CAAC,CAC/D,CAAC;IACF,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAE1E,MAAM,KAAK,GAAG,uBAAuB,CAAC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M,EAAE,IAAI;YACZ,SAAS;YACT,QAAQ;YACR,OAAO,EAAE,OAAO;gBACd,CAAC,CAAC,sCAAsC,SAAS,yDAAyD;gBAC1G,CAAC,CAAC,mBAAmB,QAAQ,KAAK,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,4BAA4B;SACrH,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC"}
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface EnvInjectionResult {
|
|
2
|
+
filePath: string;
|
|
3
|
+
fileName: string;
|
|
4
|
+
createdNew: boolean;
|
|
5
|
+
updatedKeys: string[];
|
|
6
|
+
appendedKeys: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the target environment file in `cwd`.
|
|
10
|
+
* Prefers an existing `.env.local` or `.env`; if neither exists and a Next.js
|
|
11
|
+
* config is detected, defaults to `.env.local`, otherwise `.env`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveTargetEnvFile(cwd: string): {
|
|
14
|
+
filePath: string;
|
|
15
|
+
fileName: string;
|
|
16
|
+
exists: boolean;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Upserts a set of key-value pairs into an `.env`-formatted string while
|
|
20
|
+
* preserving all unrelated variables, comments, and blank lines.
|
|
21
|
+
*/
|
|
22
|
+
export declare function upsertEnvContent(existingContent: string, entries: Readonly<Record<string, string>>): {
|
|
23
|
+
content: string;
|
|
24
|
+
updatedKeys: string[];
|
|
25
|
+
appendedKeys: string[];
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Injects `SHDW_API_KEY` and `SHDW_GRID_REGION` into `.env` or `.env.local`
|
|
29
|
+
* in the target directory without disturbing unrelated variables.
|
|
30
|
+
*/
|
|
31
|
+
export declare function injectShdwEnvVariables(params: {
|
|
32
|
+
cwd: string;
|
|
33
|
+
apiKey: string;
|
|
34
|
+
gridRegion: string;
|
|
35
|
+
}): EnvInjectionResult;
|
|
36
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACjB,CAsBA;AAUD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACxC;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CA8CA;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,kBAAkB,CAkBrB"}
|
package/dist/env.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// @shdwsdk/cli — Safe Environment File Injection (.env / .env.local)
|
|
3
|
+
// Updates or appends SHDW_API_KEY and SHDW_GRID_REGION without overwriting
|
|
4
|
+
// unrelated environment variables or existing comments.
|
|
5
|
+
// ============================================================================
|
|
6
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { resolve } from "node:path";
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the target environment file in `cwd`.
|
|
10
|
+
* Prefers an existing `.env.local` or `.env`; if neither exists and a Next.js
|
|
11
|
+
* config is detected, defaults to `.env.local`, otherwise `.env`.
|
|
12
|
+
*/
|
|
13
|
+
export function resolveTargetEnvFile(cwd) {
|
|
14
|
+
const envLocalPath = resolve(cwd, ".env.local");
|
|
15
|
+
if (existsSync(envLocalPath)) {
|
|
16
|
+
return { filePath: envLocalPath, fileName: ".env.local", exists: true };
|
|
17
|
+
}
|
|
18
|
+
const envPath = resolve(cwd, ".env");
|
|
19
|
+
if (existsSync(envPath)) {
|
|
20
|
+
return { filePath: envPath, fileName: ".env", exists: true };
|
|
21
|
+
}
|
|
22
|
+
const isNextProject = existsSync(resolve(cwd, "next.config.ts")) ||
|
|
23
|
+
existsSync(resolve(cwd, "next.config.mjs")) ||
|
|
24
|
+
existsSync(resolve(cwd, "next.config.js"));
|
|
25
|
+
const fileName = isNextProject ? ".env.local" : ".env";
|
|
26
|
+
return {
|
|
27
|
+
filePath: resolve(cwd, fileName),
|
|
28
|
+
fileName,
|
|
29
|
+
exists: false,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function formatEnvValue(val) {
|
|
33
|
+
// Quote only if value contains spaces, hashes, or quotes
|
|
34
|
+
if (/[\s#"']/.test(val)) {
|
|
35
|
+
return `"${val.replace(/"/g, '\\"')}"`;
|
|
36
|
+
}
|
|
37
|
+
return val;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Upserts a set of key-value pairs into an `.env`-formatted string while
|
|
41
|
+
* preserving all unrelated variables, comments, and blank lines.
|
|
42
|
+
*/
|
|
43
|
+
export function upsertEnvContent(existingContent, entries) {
|
|
44
|
+
const eol = existingContent.includes("\r\n") ? "\r\n" : "\n";
|
|
45
|
+
const lines = existingContent.length > 0 ? existingContent.split(/\r?\n/) : [];
|
|
46
|
+
const remaining = new Map(Object.entries(entries));
|
|
47
|
+
const updatedKeys = [];
|
|
48
|
+
const appendedKeys = [];
|
|
49
|
+
const nextLines = lines.map((line) => {
|
|
50
|
+
const match = line.match(/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=/);
|
|
51
|
+
if (!match) {
|
|
52
|
+
return line;
|
|
53
|
+
}
|
|
54
|
+
const key = match[1];
|
|
55
|
+
if (!key || !remaining.has(key)) {
|
|
56
|
+
return line;
|
|
57
|
+
}
|
|
58
|
+
const nextValue = remaining.get(key) ?? "";
|
|
59
|
+
remaining.delete(key);
|
|
60
|
+
updatedKeys.push(key);
|
|
61
|
+
const hasExportPrefix = /^\s*export\s+/.test(line);
|
|
62
|
+
return `${hasExportPrefix ? "export " : ""}${key}=${formatEnvValue(nextValue)}`;
|
|
63
|
+
});
|
|
64
|
+
if (remaining.size > 0) {
|
|
65
|
+
// Trim trailing empty lines before appending a clean SHDWsdk block
|
|
66
|
+
while (nextLines.length > 0 &&
|
|
67
|
+
nextLines[nextLines.length - 1]?.trim() === "") {
|
|
68
|
+
nextLines.pop();
|
|
69
|
+
}
|
|
70
|
+
if (nextLines.length > 0) {
|
|
71
|
+
nextLines.push("");
|
|
72
|
+
}
|
|
73
|
+
nextLines.push("# SHDWsdk Scope 3 AI Carbon & AI-BOM Telemetry");
|
|
74
|
+
for (const [key, val] of remaining.entries()) {
|
|
75
|
+
nextLines.push(`${key}=${formatEnvValue(val)}`);
|
|
76
|
+
appendedKeys.push(key);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
content: nextLines.join(eol) + eol,
|
|
81
|
+
updatedKeys,
|
|
82
|
+
appendedKeys,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Injects `SHDW_API_KEY` and `SHDW_GRID_REGION` into `.env` or `.env.local`
|
|
87
|
+
* in the target directory without disturbing unrelated variables.
|
|
88
|
+
*/
|
|
89
|
+
export function injectShdwEnvVariables(params) {
|
|
90
|
+
const target = resolveTargetEnvFile(params.cwd);
|
|
91
|
+
const existing = target.exists ? readFileSync(target.filePath, "utf8") : "";
|
|
92
|
+
const { content, updatedKeys, appendedKeys } = upsertEnvContent(existing, {
|
|
93
|
+
SHDW_API_KEY: params.apiKey,
|
|
94
|
+
SHDW_GRID_REGION: params.gridRegion,
|
|
95
|
+
});
|
|
96
|
+
writeFileSync(target.filePath, content, "utf8");
|
|
97
|
+
return {
|
|
98
|
+
filePath: target.filePath,
|
|
99
|
+
fileName: target.fileName,
|
|
100
|
+
createdNew: !target.exists,
|
|
101
|
+
updatedKeys,
|
|
102
|
+
appendedKeys,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=env.js.map
|
package/dist/env.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,qEAAqE;AACrE,2EAA2E;AAC3E,wDAAwD;AACxD,+EAA+E;AAE/E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAK9C,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAChD,IAAI,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC1E,CAAC;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACrC,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;Q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C,GAAG,EAAE,GAAG,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;YAC7C,SAAS,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChD,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG;QAClC,WAAW;QACX,YAAY;KACb,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAItC;IACC,MAAM,MAAM,GAAG,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE5E,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,gBAAgB,CAAC,QAAQ,EAAE;QACxE,YAAY,EAAE,MAAM,CAAC,MAAM;QAC3B,gBAAgB,EAAE,MAAM,CAAC,UAAU;KACpC,CAAC,CAAC;IAEH,aAAa,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAEhD,OAAO;QACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,UAAU,EAAE,CAAC,MAAM,CAAC,MAAM;QAC1B,WAAW;QACX,YAAY;KACb,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { buildBoilerplateSource, generateShdwBoilerplateFile, type GenerateBoilerplateParams, type GeneratedBoilerplateResult, } from "./codegen.js";
|
|
2
|
+
export { DEFAULT_SHDW_INGEST_ENDPOINT, testShdwConnectivity, type ConnectivityTestResult, } from "./connectivity.js";
|
|
3
|
+
export { injectShdwEnvVariables, resolveTargetEnvFile, upsertEnvContent, type EnvInjectionResult, } from "./env.js";
|
|
4
|
+
export { parseCliArgs, runCliFromArgv, runInitWizard, type CliWizardOptions, type CliWizardResult, } from "./wizard.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,GAChC,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,KAAK,sBAAsB,GAC5B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,KAAK,kBAAkB,GACxB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// @shdwsdk/cli — Public Library Entrypoint
|
|
3
|
+
// ============================================================================
|
|
4
|
+
export { buildBoilerplateSource, generateShdwBoilerplateFile, } from "./codegen.js";
|
|
5
|
+
export { DEFAULT_SHDW_INGEST_ENDPOINT, testShdwConnectivity, } from "./connectivity.js";
|
|
6
|
+
export { injectShdwEnvVariables, resolveTargetEnvFile, upsertEnvContent, } from "./env.js";
|
|
7
|
+
export { parseCliArgs, runCliFromArgv, runInitWizard, } from "./wizard.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,2CAA2C;AAC3C,+EAA+E;AAE/E,OAAO,EACL,sBAAsB,EACtB,2BAA2B,GAG5B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,GAErB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,GAEjB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,GAGd,MAAM,aAAa,CAAC"}
|
package/dist/wizard.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ConnectivityTestResult } from "./connectivity.js";
|
|
2
|
+
export interface CliWizardOptions {
|
|
3
|
+
cwd?: string;
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
region?: string;
|
|
6
|
+
model?: string;
|
|
7
|
+
outputPath?: string;
|
|
8
|
+
endpoint?: string;
|
|
9
|
+
skipPing?: boolean;
|
|
10
|
+
customFetch?: typeof fetch;
|
|
11
|
+
}
|
|
12
|
+
export interface CliWizardResult {
|
|
13
|
+
apiKeyPrefix: string;
|
|
14
|
+
gridRegion: string;
|
|
15
|
+
modelPattern: string;
|
|
16
|
+
envFilePath: string;
|
|
17
|
+
boilerplateFilePath: string;
|
|
18
|
+
connectivity: ConnectivityTestResult | null;
|
|
19
|
+
}
|
|
20
|
+
export declare function parseCliArgs(argv: readonly string[]): CliWizardOptions & {
|
|
21
|
+
help?: boolean;
|
|
22
|
+
};
|
|
23
|
+
export declare function runInitWizard(options?: CliWizardOptions): Promise<CliWizardResult>;
|
|
24
|
+
export declare function runCliFromArgv(argv: readonly string[]): Promise<void>;
|
|
25
|
+
//# sourceMappingURL=wizard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wizard.d.ts","sourceRoot":"","sources":["../src/wizard.ts"],"names":[],"mappings":"AAaA,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,mBAAmB,CAAC;AAG3B,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,KAAK,CAAC;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,YAAY,EAAE,sBAAsB,GAAG,IAAI,CAAC;CAC7C;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,gBAAgB,GAAG;IACxE,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAqBA;AAqBD,wBAAsB,aAAa,CACjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,eAAe,CAAC,CA0K1B;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ3E"}
|