@workbench-ai/workbench 0.0.65 → 0.0.66
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/dev-open/client.js +100 -100
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -79
- package/dist/local-archive.d.ts.map +1 -1
- package/dist/local-archive.js +4 -90
- package/package.json +9 -4
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgJA,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;CAC/B;AA8BD,UAAU,iBAAiB;CAAG;AA2M9B,wBAAsB,MAAM,CAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,EAAE,GAAE,KAIH,EACD,cAAc,GAAE,iBAAsB,GACrC,OAAO,CAAC,MAAM,CAAC,CA4HjB"}
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { createRequire } from "node:module";
|
|
|
5
5
|
import os from "node:os";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { Writable } from "node:stream";
|
|
8
|
-
import { createBaselineCandidateJob as createRuntimeBaselineCandidateJob, evaluationScorecardId, evaluationMeanMetrics, executeWorkbenchExecutionJob, engineResolveBindingForSpec, filterOptimizerTraceJobsForCaseIds, filterCandidateSourceFiles, formatWorkbenchCaseSelector, formatWorkbenchSelectionPolicy, workbenchCaseSelectorUsesAllCases, workbenchExecutionPurpose, workbenchRunExecutionFingerprint, createWorkbenchAdapterAuthBundle, createOptimizerTraceInputFiles, DOCKER_SANDBOX_BACKEND, localWorkbenchAdapterAuthStore, materializeWorkbenchRunResult, normalizeSurfaceFiles, planWorkbenchExecutionJobsForPurpose, runWorkbenchExecutionDag, resolveEngineCaseExecutionConfig, resolveWorkbenchResolvedSourceYaml, runtimeResources, validateWorkbenchRunEnvelope, parseWorkbenchAdapterAuthTarget, workbenchEngineCaseIdsForImproveEvaluation, workbenchEngineCaseIdsForSelector, workbenchImproveOptimizeSelector, workbenchImproveSelectionPolicy, workbenchProjectSourceFingerprint, workbenchRuntimeBundleFingerprint, workbenchRuntimeExplicitActiveId, } from "@workbench-ai/workbench-core";
|
|
8
|
+
import { createBaselineCandidateJob as createRuntimeBaselineCandidateJob, evaluationScorecardId, evaluationMeanMetrics, executeWorkbenchExecutionJob, engineResolveBindingForSpec, filterOptimizerTraceJobsForCaseIds, filterCandidateSourceFiles, formatWorkbenchCaseSelector, formatWorkbenchSelectionPolicy, workbenchCaseSelectorUsesAllCases, workbenchExecutionPurpose, workbenchRunExecutionFingerprint, createWorkbenchAdapterAuthBundle, createOptimizerTraceInputFiles, DOCKER_SANDBOX_BACKEND, localWorkbenchAdapterAuthStore, materializeWorkbenchRunResult, normalizeSurfaceFiles, isSurfaceSnapshotFile, jsonRecord, planWorkbenchExecutionJobsForPurpose, runWorkbenchExecutionDag, resolveEngineCaseExecutionConfig, resolveWorkbenchResolvedSourceYaml, runtimeResources, validateWorkbenchRunEnvelope, parseWorkbenchAdapterAuthTarget, workbenchEngineCaseIdsForImproveEvaluation, workbenchEngineCaseIdsForSelector, workbenchImproveOptimizeSelector, workbenchImproveSelectionPolicy, workbenchProjectSourceFingerprint, workbenchRuntimeBundleFingerprint, workbenchRuntimeExplicitActiveId, } from "@workbench-ai/workbench-core";
|
|
9
9
|
import { assertWorkbenchAdapterOperationResultOk, collectWorkbenchAdapterAuthRequirements, normalizeWorkbenchAdapterOperationRequest, readWorkbenchAdapterOperationResult, workbenchAdapterOperationCommand, workbenchAdapterOperationResultPath, withDefaultWorkbenchAdapterAuthProfiles as applyDefaultWorkbenchAdapterAuthProfiles, } from "@workbench-ai/workbench-protocol";
|
|
10
10
|
import { builtinLocalTraceAdapter, builtinLocalTraceAdapters, sortLocalTraceRefs, } from "@workbench-ai/workbench-built-in-adapters/local-traces";
|
|
11
11
|
import { commandUsage, REMOTE_WATCH_LIFECYCLE_NOTE, LOCAL_DEV_OPEN_LIFECYCLE_NOTE, rootUsage, } from "./command-model.js";
|
|
@@ -35,6 +35,30 @@ class WorkbenchApiRequestError extends Error {
|
|
|
35
35
|
}
|
|
36
36
|
const API_REQUEST_MAX_ATTEMPTS = 3;
|
|
37
37
|
const DEFAULT_BASE_URL = "https://v2.workbench.ai";
|
|
38
|
+
const AUTH_COMMAND_HANDLERS = {
|
|
39
|
+
connect: authConnect,
|
|
40
|
+
disconnect: authDisconnect,
|
|
41
|
+
};
|
|
42
|
+
const ADAPTERS_COMMAND_HANDLERS = {
|
|
43
|
+
create: adaptersCreate,
|
|
44
|
+
inspect: adaptersInspect,
|
|
45
|
+
list: adaptersList,
|
|
46
|
+
test: adaptersTest,
|
|
47
|
+
};
|
|
48
|
+
const TRACES_COMMAND_HANDLERS = {
|
|
49
|
+
collect: localTraceCollect,
|
|
50
|
+
list: localTraceList,
|
|
51
|
+
show: localTraceShow,
|
|
52
|
+
};
|
|
53
|
+
const TWO_SEGMENT_HELP_COMMANDS = {
|
|
54
|
+
adapters: ["create", "list", "inspect", "test"],
|
|
55
|
+
auth: [],
|
|
56
|
+
candidates: ["list", "show", "files", "preview"],
|
|
57
|
+
evaluations: ["list", "show"],
|
|
58
|
+
executions: ["trace"],
|
|
59
|
+
runs: ["list", "show"],
|
|
60
|
+
traces: ["collect", "list", "show"],
|
|
61
|
+
};
|
|
38
62
|
export async function runCli(argv, io = {
|
|
39
63
|
stdin: process.stdin,
|
|
40
64
|
stdout: process.stdout,
|
|
@@ -162,34 +186,12 @@ export async function runCli(argv, io = {
|
|
|
162
186
|
}
|
|
163
187
|
function commandPathForHelp(argv) {
|
|
164
188
|
const positionals = argv.filter((arg) => arg !== "--help" && arg !== "-h" && !arg.startsWith("--"));
|
|
165
|
-
|
|
166
|
-
|
|
189
|
+
const command = positionals[0] ?? "";
|
|
190
|
+
const subcommands = TWO_SEGMENT_HELP_COMMANDS[command];
|
|
191
|
+
if (subcommands && (subcommands.length === 0 || subcommands.includes(positionals[1] ?? ""))) {
|
|
167
192
|
return positionals.slice(0, 2).join(" ");
|
|
168
193
|
}
|
|
169
|
-
|
|
170
|
-
["collect", "list", "show"].includes(positionals[1] ?? "")) {
|
|
171
|
-
return positionals.slice(0, 2).join(" ");
|
|
172
|
-
}
|
|
173
|
-
if (positionals[0] === "auth") {
|
|
174
|
-
return positionals.slice(0, 2).join(" ");
|
|
175
|
-
}
|
|
176
|
-
if (positionals[0] === "runs" &&
|
|
177
|
-
["list", "show"].includes(positionals[1] ?? "")) {
|
|
178
|
-
return positionals.slice(0, 2).join(" ");
|
|
179
|
-
}
|
|
180
|
-
if (positionals[0] === "evaluations" &&
|
|
181
|
-
["list", "show"].includes(positionals[1] ?? "")) {
|
|
182
|
-
return positionals.slice(0, 2).join(" ");
|
|
183
|
-
}
|
|
184
|
-
if (positionals[0] === "executions" &&
|
|
185
|
-
["trace"].includes(positionals[1] ?? "")) {
|
|
186
|
-
return positionals.slice(0, 2).join(" ");
|
|
187
|
-
}
|
|
188
|
-
if (positionals[0] === "candidates" &&
|
|
189
|
-
["list", "show", "files", "preview"].includes(positionals[1] ?? "")) {
|
|
190
|
-
return positionals.slice(0, 2).join(" ");
|
|
191
|
-
}
|
|
192
|
-
return positionals[0] ?? "";
|
|
194
|
+
return command;
|
|
193
195
|
}
|
|
194
196
|
function extractRemoteFlag(argv) {
|
|
195
197
|
let enabled = false;
|
|
@@ -2010,46 +2012,21 @@ async function localDiagnose(argv, io) {
|
|
|
2010
2012
|
return 0;
|
|
2011
2013
|
}
|
|
2012
2014
|
async function runAuthCommand(argv, io) {
|
|
2013
|
-
|
|
2014
|
-
const rest = argv.slice(1);
|
|
2015
|
-
switch (command) {
|
|
2016
|
-
case "connect":
|
|
2017
|
-
return await authConnect(rest, io);
|
|
2018
|
-
case "disconnect":
|
|
2019
|
-
return await authDisconnect(rest, io);
|
|
2020
|
-
default:
|
|
2021
|
-
throw new UsageError(`Unknown command: auth ${argv.join(" ")}`);
|
|
2022
|
-
}
|
|
2015
|
+
return await runSubCommand("auth", AUTH_COMMAND_HANDLERS, argv, io);
|
|
2023
2016
|
}
|
|
2024
2017
|
async function runAdaptersCommand(argv, io) {
|
|
2025
|
-
|
|
2026
|
-
const rest = argv.slice(1);
|
|
2027
|
-
switch (command) {
|
|
2028
|
-
case "create":
|
|
2029
|
-
return await adaptersCreate(rest, io);
|
|
2030
|
-
case "list":
|
|
2031
|
-
return await adaptersList(rest, io);
|
|
2032
|
-
case "inspect":
|
|
2033
|
-
return await adaptersInspect(rest, io);
|
|
2034
|
-
case "test":
|
|
2035
|
-
return await adaptersTest(rest, io);
|
|
2036
|
-
default:
|
|
2037
|
-
throw new UsageError(`Unknown command: adapters ${argv.join(" ")}`);
|
|
2038
|
-
}
|
|
2018
|
+
return await runSubCommand("adapters", ADAPTERS_COMMAND_HANDLERS, argv, io);
|
|
2039
2019
|
}
|
|
2040
2020
|
async function runTracesCommand(argv, io) {
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
case "show":
|
|
2049
|
-
return await localTraceShow(rest, io);
|
|
2050
|
-
default:
|
|
2051
|
-
throw new UsageError(`Unknown command: traces ${argv.join(" ")}`);
|
|
2021
|
+
return await runSubCommand("traces", TRACES_COMMAND_HANDLERS, argv, io);
|
|
2022
|
+
}
|
|
2023
|
+
async function runSubCommand(group, handlers, argv, io) {
|
|
2024
|
+
const command = argv[0] ?? "";
|
|
2025
|
+
const handler = handlers[command];
|
|
2026
|
+
if (!handler) {
|
|
2027
|
+
throw new UsageError(`Unknown command: ${group} ${argv.join(" ")}`);
|
|
2052
2028
|
}
|
|
2029
|
+
return await handler(argv.slice(1), io);
|
|
2053
2030
|
}
|
|
2054
2031
|
const DEFAULT_LOCAL_TRACE_LIMIT = 3;
|
|
2055
2032
|
const LOCAL_TRACE_WINDOW_FLAGS = new Set(["providers", "since", "workspace", "limit", "json"]);
|
|
@@ -5068,28 +5045,12 @@ async function resolveLocalProjectForExecution(workspace, source) {
|
|
|
5068
5045
|
};
|
|
5069
5046
|
}
|
|
5070
5047
|
function completedJobOutputFiles(job) {
|
|
5071
|
-
const output =
|
|
5048
|
+
const output = jsonRecord(job.output);
|
|
5072
5049
|
const files = Array.isArray(output.files)
|
|
5073
5050
|
? output.files.filter(isSurfaceSnapshotFile)
|
|
5074
5051
|
: [];
|
|
5075
5052
|
return normalizeSurfaceFiles(files);
|
|
5076
5053
|
}
|
|
5077
|
-
function asJsonRecord(value) {
|
|
5078
|
-
return value && typeof value === "object" && !Array.isArray(value)
|
|
5079
|
-
? value
|
|
5080
|
-
: {};
|
|
5081
|
-
}
|
|
5082
|
-
function isSurfaceSnapshotFile(value) {
|
|
5083
|
-
const record = asJsonRecord(value);
|
|
5084
|
-
return (typeof record.path === "string" &&
|
|
5085
|
-
typeof record.content === "string" &&
|
|
5086
|
-
(record.kind === undefined ||
|
|
5087
|
-
record.kind === "text" ||
|
|
5088
|
-
record.kind === "binary") &&
|
|
5089
|
-
(record.encoding === undefined ||
|
|
5090
|
-
record.encoding === "utf8" ||
|
|
5091
|
-
record.encoding === "base64"));
|
|
5092
|
-
}
|
|
5093
5054
|
function createLocalEvent(type, at, event) {
|
|
5094
5055
|
return {
|
|
5095
5056
|
id: `evt_${Math.random().toString(36).slice(2, 10)}_${Date.now().toString(36)}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-archive.d.ts","sourceRoot":"","sources":["../src/local-archive.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"local-archive.d.ts","sourceRoot":"","sources":["../src/local-archive.ts"],"names":[],"mappings":"A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 -1,6 +1,6 @@
|
|
|
1
1
|
import { promises as fs } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { buildWorkbenchTraceSessionsFromFiles, candidateRecordWithoutDerivedFields, compactWorkbenchRuntimeJobForExchange, mergeWorkbenchRuntimeCandidateForExchange, sanitizeWorkbenchRuntimeCandidateForExchange, sanitizeWorkbenchRuntimeJobForExchange, selectExecutionOutputFilesForInspection, workbenchRuntimeExplicitActiveId, workbenchRuntimeBundleStats, workbenchRuntimeCandidateIdentityForExchange, workbenchSurfaceFilesEqualForExchange, } from "@workbench-ai/workbench-core";
|
|
3
|
+
import { buildWorkbenchTraceSessionsFromFiles, candidateRecordWithoutDerivedFields, compactWorkbenchRuntimeJobForExchange, mergeWorkbenchRuntimeCandidateForExchange, sanitizeWorkbenchRuntimeCandidateForExchange, sanitizeWorkbenchRuntimeJobForExchange, selectExecutionOutputFilesForInspection, isSurfaceSnapshotFile, jsonRecord, normalizeRelativePath, readSurfaceFiles, workbenchRuntimeExplicitActiveId, workbenchRuntimeBundleStats, workbenchRuntimeCandidateIdentityForExchange, workbenchSurfaceFilesEqualForExchange, writeSurfaceFiles, } from "@workbench-ai/workbench-core";
|
|
4
4
|
const RUNTIME_DIR = ".workbench/runtime";
|
|
5
5
|
const CANDIDATE_RECORDS_DIR = "candidates";
|
|
6
6
|
export function localRuntimeDir(workspace) {
|
|
@@ -682,14 +682,6 @@ function completedJobOutputFiles(job) {
|
|
|
682
682
|
}
|
|
683
683
|
return output.files.filter(isSurfaceSnapshotFile).map((file) => ({ ...file }));
|
|
684
684
|
}
|
|
685
|
-
function isSurfaceSnapshotFile(value) {
|
|
686
|
-
const record = jsonRecord(value);
|
|
687
|
-
return (typeof record.path === "string" &&
|
|
688
|
-
(record.kind === "text" || record.kind === "binary") &&
|
|
689
|
-
(record.encoding === "utf8" || record.encoding === "base64") &&
|
|
690
|
-
typeof record.content === "string" &&
|
|
691
|
-
typeof record.executable === "boolean");
|
|
692
|
-
}
|
|
693
685
|
function readExecutionPurpose(job) {
|
|
694
686
|
const input = jsonRecord(job.input);
|
|
695
687
|
return stringValue(jsonRecord(input.execution).purpose);
|
|
@@ -751,15 +743,9 @@ function traceEvent(args) {
|
|
|
751
743
|
}
|
|
752
744
|
function traceUsageSummary(value) {
|
|
753
745
|
const record = jsonRecord(value);
|
|
754
|
-
const usage =
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
? jsonRecord(record.improver)
|
|
758
|
-
: Object.keys(jsonRecord(record.runner)).length > 0
|
|
759
|
-
? jsonRecord(record.runner)
|
|
760
|
-
: Object.keys(jsonRecord(record.engine)).length > 0
|
|
761
|
-
? jsonRecord(record.engine)
|
|
762
|
-
: record;
|
|
746
|
+
const usage = ["total", "improver", "runner", "engine"]
|
|
747
|
+
.map((key) => jsonRecord(record[key]))
|
|
748
|
+
.find((entry) => Object.keys(entry).length > 0) ?? record;
|
|
763
749
|
if (Object.keys(usage).length === 0) {
|
|
764
750
|
return null;
|
|
765
751
|
}
|
|
@@ -779,11 +765,6 @@ function traceUsageSummary(value) {
|
|
|
779
765
|
pricing_source: stringValue(usage.pricingSource) ?? stringValue(usage.pricing_source),
|
|
780
766
|
};
|
|
781
767
|
}
|
|
782
|
-
function jsonRecord(value) {
|
|
783
|
-
return value && typeof value === "object" && !Array.isArray(value)
|
|
784
|
-
? value
|
|
785
|
-
: {};
|
|
786
|
-
}
|
|
787
768
|
function stringValue(value) {
|
|
788
769
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
789
770
|
}
|
|
@@ -850,70 +831,3 @@ async function writeJson(filePath, value) {
|
|
|
850
831
|
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
851
832
|
await fs.writeFile(filePath, `${JSON.stringify(value, null, 2)}\n`);
|
|
852
833
|
}
|
|
853
|
-
async function writeSurfaceFiles(root, files) {
|
|
854
|
-
await fs.mkdir(root, { recursive: true });
|
|
855
|
-
for (const file of files) {
|
|
856
|
-
const target = path.join(root, normalizeRelativePath(file.path));
|
|
857
|
-
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
858
|
-
const body = file.encoding === "base64" ? Buffer.from(file.content, "base64") : Buffer.from(file.content, "utf8");
|
|
859
|
-
await fs.writeFile(target, body);
|
|
860
|
-
if (file.executable) {
|
|
861
|
-
await fs.chmod(target, 0o755).catch(() => undefined);
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
async function readSurfaceFiles(root) {
|
|
866
|
-
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
867
|
-
const files = [];
|
|
868
|
-
async function walk(directory) {
|
|
869
|
-
const entries = await fs.readdir(directory, { withFileTypes: true }).catch(() => []);
|
|
870
|
-
for (const entry of entries) {
|
|
871
|
-
const absolutePath = path.join(directory, entry.name);
|
|
872
|
-
if (entry.isDirectory()) {
|
|
873
|
-
await walk(absolutePath);
|
|
874
|
-
continue;
|
|
875
|
-
}
|
|
876
|
-
if (!entry.isFile()) {
|
|
877
|
-
continue;
|
|
878
|
-
}
|
|
879
|
-
const body = await fs.readFile(absolutePath);
|
|
880
|
-
const relativePath = normalizeRelativePath(path.relative(root, absolutePath).replace(/\\/gu, "/"));
|
|
881
|
-
const stats = await fs.stat(absolutePath);
|
|
882
|
-
const content = encodeContent(body, decoder);
|
|
883
|
-
files.push({
|
|
884
|
-
path: relativePath,
|
|
885
|
-
kind: content.encoding === "base64" ? "binary" : "text",
|
|
886
|
-
encoding: content.encoding,
|
|
887
|
-
content: content.content,
|
|
888
|
-
executable: (stats.mode & 0o111) !== 0,
|
|
889
|
-
});
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
await walk(root);
|
|
893
|
-
return files.sort((left, right) => left.path.localeCompare(right.path));
|
|
894
|
-
}
|
|
895
|
-
function encodeContent(body, decoder) {
|
|
896
|
-
try {
|
|
897
|
-
return {
|
|
898
|
-
encoding: "utf8",
|
|
899
|
-
content: decoder.decode(body),
|
|
900
|
-
};
|
|
901
|
-
}
|
|
902
|
-
catch {
|
|
903
|
-
return {
|
|
904
|
-
encoding: "base64",
|
|
905
|
-
content: body.toString("base64"),
|
|
906
|
-
};
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
function normalizeRelativePath(filePath) {
|
|
910
|
-
const normalized = filePath.replace(/\\/gu, "/").replace(/^\/+/u, "");
|
|
911
|
-
if (!normalized || normalized.includes("\0")) {
|
|
912
|
-
throw new Error("File paths must be non-empty relative paths.");
|
|
913
|
-
}
|
|
914
|
-
const parts = normalized.split("/");
|
|
915
|
-
if (parts.some((part) => part === ".." || part === "." || part === "")) {
|
|
916
|
-
throw new Error(`Unsafe relative file path: ${filePath}`);
|
|
917
|
-
}
|
|
918
|
-
return normalized;
|
|
919
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workbench-ai/workbench",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.66",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/workbench-ai/workbench.git",
|
|
7
|
+
"directory": "packages/cli"
|
|
8
|
+
},
|
|
4
9
|
"type": "module",
|
|
5
10
|
"publishConfig": {
|
|
6
11
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -16,9 +21,9 @@
|
|
|
16
21
|
],
|
|
17
22
|
"dependencies": {
|
|
18
23
|
"yaml": "^2.8.2",
|
|
19
|
-
"@workbench-ai/workbench-built-in-adapters": "0.0.
|
|
20
|
-
"@workbench-ai/workbench-protocol": "0.0.
|
|
21
|
-
"@workbench-ai/workbench-core": "0.0.
|
|
24
|
+
"@workbench-ai/workbench-built-in-adapters": "0.0.66",
|
|
25
|
+
"@workbench-ai/workbench-protocol": "0.0.66",
|
|
26
|
+
"@workbench-ai/workbench-core": "0.0.66"
|
|
22
27
|
},
|
|
23
28
|
"devDependencies": {
|
|
24
29
|
"@tailwindcss/postcss": "^4.2.2",
|