scoutline 0.1.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +394 -7
- package/bin/scoutline.js +36 -15
- package/dist/capabilities/diagnostics.d.ts +135 -0
- package/dist/capabilities/diagnostics.d.ts.map +1 -0
- package/dist/capabilities/diagnostics.js +139 -0
- package/dist/capabilities/diagnostics.js.map +1 -0
- package/dist/capabilities/quota.d.ts +99 -0
- package/dist/capabilities/quota.d.ts.map +1 -0
- package/dist/capabilities/quota.js +129 -0
- package/dist/capabilities/quota.js.map +1 -0
- package/dist/capabilities/reader.d.ts +227 -0
- package/dist/capabilities/reader.d.ts.map +1 -0
- package/dist/capabilities/reader.js +100 -0
- package/dist/capabilities/reader.js.map +1 -0
- package/dist/capabilities/repository.d.ts +221 -0
- package/dist/capabilities/repository.d.ts.map +1 -0
- package/dist/capabilities/repository.js +172 -0
- package/dist/capabilities/repository.js.map +1 -0
- package/dist/capabilities/search.d.ts +110 -0
- package/dist/capabilities/search.d.ts.map +1 -0
- package/dist/capabilities/search.js +21 -0
- package/dist/capabilities/search.js.map +1 -0
- package/dist/capabilities/vision.d.ts +156 -0
- package/dist/capabilities/vision.d.ts.map +1 -0
- package/dist/capabilities/vision.js +111 -0
- package/dist/capabilities/vision.js.map +1 -0
- package/dist/command-invocation.d.ts +58 -0
- package/dist/command-invocation.d.ts.map +1 -0
- package/dist/command-invocation.js +95 -0
- package/dist/command-invocation.js.map +1 -0
- package/dist/commands/cache.d.ts +106 -0
- package/dist/commands/cache.d.ts.map +1 -0
- package/dist/commands/cache.js +203 -0
- package/dist/commands/cache.js.map +1 -0
- package/dist/commands/code.d.ts +11 -4
- package/dist/commands/code.d.ts.map +1 -1
- package/dist/commands/code.js +16 -42
- package/dist/commands/code.js.map +1 -1
- package/dist/commands/doctor.d.ts +69 -3
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +179 -52
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/quota.d.ts +45 -3
- package/dist/commands/quota.d.ts.map +1 -1
- package/dist/commands/quota.js +116 -60
- package/dist/commands/quota.js.map +1 -1
- package/dist/commands/read.d.ts +76 -2
- package/dist/commands/read.d.ts.map +1 -1
- package/dist/commands/read.js +260 -121
- package/dist/commands/read.js.map +1 -1
- package/dist/commands/repo.d.ts +55 -4
- package/dist/commands/repo.d.ts.map +1 -1
- package/dist/commands/repo.js +115 -172
- package/dist/commands/repo.js.map +1 -1
- package/dist/commands/repository-explorer.d.ts +147 -0
- package/dist/commands/repository-explorer.d.ts.map +1 -0
- package/dist/commands/repository-explorer.js +550 -0
- package/dist/commands/repository-explorer.js.map +1 -0
- package/dist/commands/search.d.ts +27 -2
- package/dist/commands/search.d.ts.map +1 -1
- package/dist/commands/search.js +95 -103
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/tools.d.ts +9 -3
- package/dist/commands/tools.d.ts.map +1 -1
- package/dist/commands/tools.js +29 -59
- package/dist/commands/tools.js.map +1 -1
- package/dist/commands/vision.d.ts +35 -9
- package/dist/commands/vision.d.ts.map +1 -1
- package/dist/commands/vision.js +184 -131
- package/dist/commands/vision.js.map +1 -1
- package/dist/index.d.ts +62 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +580 -223
- package/dist/index.js.map +1 -1
- package/dist/lib/cache.d.ts +178 -12
- package/dist/lib/cache.d.ts.map +1 -1
- package/dist/lib/cache.js +377 -39
- package/dist/lib/cache.js.map +1 -1
- package/dist/lib/code-mode.d.ts +13 -0
- package/dist/lib/code-mode.d.ts.map +1 -1
- package/dist/lib/code-mode.js +26 -6
- package/dist/lib/code-mode.js.map +1 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +15 -18
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/errors.d.ts +89 -11
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +168 -21
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/execution.d.ts +190 -0
- package/dist/lib/execution.d.ts.map +1 -0
- package/dist/lib/execution.js +383 -0
- package/dist/lib/execution.js.map +1 -0
- package/dist/lib/index.d.ts +10 -2
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +10 -2
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/mcp-client.d.ts +75 -16
- package/dist/lib/mcp-client.d.ts.map +1 -1
- package/dist/lib/mcp-client.js +173 -108
- package/dist/lib/mcp-client.js.map +1 -1
- package/dist/lib/mcp-config.d.ts +17 -0
- package/dist/lib/mcp-config.d.ts.map +1 -1
- package/dist/lib/mcp-config.js +29 -0
- package/dist/lib/mcp-config.js.map +1 -1
- package/dist/lib/monitor-client.d.ts +17 -3
- package/dist/lib/monitor-client.d.ts.map +1 -1
- package/dist/lib/monitor-client.js +23 -69
- package/dist/lib/monitor-client.js.map +1 -1
- package/dist/lib/output.d.ts +53 -7
- package/dist/lib/output.d.ts.map +1 -1
- package/dist/lib/output.js +126 -39
- package/dist/lib/output.js.map +1 -1
- package/dist/lib/redact.d.ts +62 -3
- package/dist/lib/redact.d.ts.map +1 -1
- package/dist/lib/redact.js +165 -31
- package/dist/lib/redact.js.map +1 -1
- package/dist/lib/tool-cache.d.ts +86 -0
- package/dist/lib/tool-cache.d.ts.map +1 -0
- package/dist/lib/tool-cache.js +123 -0
- package/dist/lib/tool-cache.js.map +1 -0
- package/dist/lib/tty.d.ts +7 -20
- package/dist/lib/tty.d.ts.map +1 -1
- package/dist/lib/tty.js +51 -30
- package/dist/lib/tty.js.map +1 -1
- package/dist/node-command-invocation-adapter.d.ts +28 -0
- package/dist/node-command-invocation-adapter.d.ts.map +1 -0
- package/dist/node-command-invocation-adapter.js +88 -0
- package/dist/node-command-invocation-adapter.js.map +1 -0
- package/dist/providers/minimax/adapter.d.ts +49 -0
- package/dist/providers/minimax/adapter.d.ts.map +1 -0
- package/dist/providers/minimax/adapter.js +450 -0
- package/dist/providers/minimax/adapter.js.map +1 -0
- package/dist/providers/minimax/coding-plan-client.d.ts +60 -0
- package/dist/providers/minimax/coding-plan-client.d.ts.map +1 -0
- package/dist/providers/minimax/coding-plan-client.js +204 -0
- package/dist/providers/minimax/coding-plan-client.js.map +1 -0
- package/dist/providers/minimax/config.d.ts +32 -0
- package/dist/providers/minimax/config.d.ts.map +1 -0
- package/dist/providers/minimax/config.js +84 -0
- package/dist/providers/minimax/config.js.map +1 -0
- package/dist/providers/minimax/media.d.ts +88 -0
- package/dist/providers/minimax/media.d.ts.map +1 -0
- package/dist/providers/minimax/media.js +232 -0
- package/dist/providers/minimax/media.js.map +1 -0
- package/dist/providers/minimax/quota-client.d.ts +44 -0
- package/dist/providers/minimax/quota-client.d.ts.map +1 -0
- package/dist/providers/minimax/quota-client.js +83 -0
- package/dist/providers/minimax/quota-client.js.map +1 -0
- package/dist/providers/minimax/quota.d.ts +48 -0
- package/dist/providers/minimax/quota.d.ts.map +1 -0
- package/dist/providers/minimax/quota.js +120 -0
- package/dist/providers/minimax/quota.js.map +1 -0
- package/dist/providers/minimax/sdk-client.d.ts +29 -0
- package/dist/providers/minimax/sdk-client.d.ts.map +1 -0
- package/dist/providers/minimax/sdk-client.js +50 -0
- package/dist/providers/minimax/sdk-client.js.map +1 -0
- package/dist/providers/minimax/vision-attestations.d.ts +52 -0
- package/dist/providers/minimax/vision-attestations.d.ts.map +1 -0
- package/dist/providers/minimax/vision-attestations.js +79 -0
- package/dist/providers/minimax/vision-attestations.js.map +1 -0
- package/dist/providers/minimax/vision-conformance.d.ts +186 -0
- package/dist/providers/minimax/vision-conformance.d.ts.map +1 -0
- package/dist/providers/minimax/vision-conformance.js +371 -0
- package/dist/providers/minimax/vision-conformance.js.map +1 -0
- package/dist/providers/minimax/vision-mappings/chart.d.ts +35 -0
- package/dist/providers/minimax/vision-mappings/chart.d.ts.map +1 -0
- package/dist/providers/minimax/vision-mappings/chart.js +55 -0
- package/dist/providers/minimax/vision-mappings/chart.js.map +1 -0
- package/dist/providers/minimax/vision-mappings/common.d.ts +60 -0
- package/dist/providers/minimax/vision-mappings/common.d.ts.map +1 -0
- package/dist/providers/minimax/vision-mappings/common.js +75 -0
- package/dist/providers/minimax/vision-mappings/common.js.map +1 -0
- package/dist/providers/minimax/vision-mappings/diagnose-error.d.ts +35 -0
- package/dist/providers/minimax/vision-mappings/diagnose-error.d.ts.map +1 -0
- package/dist/providers/minimax/vision-mappings/diagnose-error.js +55 -0
- package/dist/providers/minimax/vision-mappings/diagnose-error.js.map +1 -0
- package/dist/providers/minimax/vision-mappings/diagram.d.ts +35 -0
- package/dist/providers/minimax/vision-mappings/diagram.d.ts.map +1 -0
- package/dist/providers/minimax/vision-mappings/diagram.js +55 -0
- package/dist/providers/minimax/vision-mappings/diagram.js.map +1 -0
- package/dist/providers/minimax/vision-mappings/extract-text.d.ts +35 -0
- package/dist/providers/minimax/vision-mappings/extract-text.d.ts.map +1 -0
- package/dist/providers/minimax/vision-mappings/extract-text.js +55 -0
- package/dist/providers/minimax/vision-mappings/extract-text.js.map +1 -0
- package/dist/providers/minimax/vision-mappings/ui-artifact.d.ts +35 -0
- package/dist/providers/minimax/vision-mappings/ui-artifact.d.ts.map +1 -0
- package/dist/providers/minimax/vision-mappings/ui-artifact.js +69 -0
- package/dist/providers/minimax/vision-mappings/ui-artifact.js.map +1 -0
- package/dist/providers/minimax/vision-mappings.generated.d.ts +29 -0
- package/dist/providers/minimax/vision-mappings.generated.d.ts.map +1 -0
- package/dist/providers/minimax/vision-mappings.generated.js +29 -0
- package/dist/providers/minimax/vision-mappings.generated.js.map +1 -0
- package/dist/providers/minimax/vision-revisions.d.ts +29 -0
- package/dist/providers/minimax/vision-revisions.d.ts.map +1 -0
- package/dist/providers/minimax/vision-revisions.js +34 -0
- package/dist/providers/minimax/vision-revisions.js.map +1 -0
- package/dist/providers/registry.d.ts +36 -0
- package/dist/providers/registry.d.ts.map +1 -0
- package/dist/providers/registry.js +45 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/providers/selection.d.ts +44 -0
- package/dist/providers/selection.d.ts.map +1 -0
- package/dist/providers/selection.js +85 -0
- package/dist/providers/selection.js.map +1 -0
- package/dist/providers/types.d.ts +281 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +127 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/providers/zai/adapter.d.ts +35 -0
- package/dist/providers/zai/adapter.d.ts.map +1 -0
- package/dist/providers/zai/adapter.js +685 -0
- package/dist/providers/zai/adapter.js.map +1 -0
- package/dist/providers/zai/credentials.d.ts +38 -0
- package/dist/providers/zai/credentials.d.ts.map +1 -0
- package/dist/providers/zai/credentials.js +60 -0
- package/dist/providers/zai/credentials.js.map +1 -0
- package/dist/providers/zai/encoded-error.d.ts +90 -0
- package/dist/providers/zai/encoded-error.d.ts.map +1 -0
- package/dist/providers/zai/encoded-error.js +169 -0
- package/dist/providers/zai/encoded-error.js.map +1 -0
- package/dist/providers/zai/media.d.ts +38 -0
- package/dist/providers/zai/media.d.ts.map +1 -0
- package/dist/providers/zai/media.js +107 -0
- package/dist/providers/zai/media.js.map +1 -0
- package/dist/providers/zai/monitor-client.d.ts +53 -0
- package/dist/providers/zai/monitor-client.d.ts.map +1 -0
- package/dist/providers/zai/monitor-client.js +117 -0
- package/dist/providers/zai/monitor-client.js.map +1 -0
- package/dist/providers/zai/quota.d.ts +47 -0
- package/dist/providers/zai/quota.d.ts.map +1 -0
- package/dist/providers/zai/quota.js +127 -0
- package/dist/providers/zai/quota.js.map +1 -0
- package/dist/providers/zai/reader.d.ts +82 -0
- package/dist/providers/zai/reader.d.ts.map +1 -0
- package/dist/providers/zai/reader.js +490 -0
- package/dist/providers/zai/reader.js.map +1 -0
- package/dist/providers/zai/repository.d.ts +76 -0
- package/dist/providers/zai/repository.d.ts.map +1 -0
- package/dist/providers/zai/repository.js +715 -0
- package/dist/providers/zai/repository.js.map +1 -0
- package/package.json +11 -6
|
@@ -1,87 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Z.AI Monitor API client —
|
|
2
|
+
* Z.AI Monitor API client — compatibility delegate (P4-02).
|
|
3
|
+
*
|
|
4
|
+
* The Z.AI fetch mechanics moved to
|
|
5
|
+
* {@link ../providers/zai/monitor-client.js} so the Provider Adapter owns
|
|
6
|
+
* its transport. This module retains every existing export as a thin
|
|
7
|
+
* delegate so current imports keep working while command Modules migrate
|
|
8
|
+
* to the normalized Provider-quota Interface (ADR-0001).
|
|
3
9
|
*
|
|
4
10
|
* Distinct from the MCP/coding endpoints:
|
|
5
11
|
* - Base: https://api.z.ai (no /api/coding/paas/v4 prefix)
|
|
6
12
|
* - Auth quirk: try `Authorization: <key>` first; on 401 retry with `Bearer <key>`
|
|
7
|
-
*
|
|
8
|
-
* Reference: /run/media/vikas/devdrive/glm-usage-indicator/API.md
|
|
9
13
|
*/
|
|
10
14
|
import { getApiKey } from "./config.js";
|
|
11
15
|
import { ApiError, AuthError, NetworkError, TimeoutError } from "./errors.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (params) {
|
|
18
|
-
for (const [k, v] of Object.entries(params))
|
|
19
|
-
url.searchParams.set(k, v);
|
|
20
|
-
}
|
|
21
|
-
// The monitor API accepts the key with OR without Bearer prefix.
|
|
22
|
-
// Try raw first; on 401, retry with Bearer.
|
|
23
|
-
for (const authValue of [apiKey, `Bearer ${apiKey}`]) {
|
|
24
|
-
const controller = new AbortController();
|
|
25
|
-
const timeoutId = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
26
|
-
try {
|
|
27
|
-
const res = await fetch(url, {
|
|
28
|
-
method: "GET",
|
|
29
|
-
headers: {
|
|
30
|
-
Authorization: authValue,
|
|
31
|
-
"Accept-Language": "en-US,en",
|
|
32
|
-
"Content-Type": "application/json",
|
|
33
|
-
},
|
|
34
|
-
signal: controller.signal,
|
|
35
|
-
});
|
|
36
|
-
clearTimeout(timeoutId);
|
|
37
|
-
if (res.status === 401 && authValue === apiKey) {
|
|
38
|
-
// Retry with Bearer prefix
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
if (!res.ok) {
|
|
42
|
-
const text = await res.text();
|
|
43
|
-
let msg = `HTTP ${res.status}: ${text}`;
|
|
44
|
-
try {
|
|
45
|
-
const j = JSON.parse(text);
|
|
46
|
-
msg = j.message || j.error?.message || msg;
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
// keep raw text
|
|
50
|
-
}
|
|
51
|
-
if (res.status === 401 || res.status === 403) {
|
|
52
|
-
throw new AuthError(`Monitor API auth failed: ${msg}`);
|
|
53
|
-
}
|
|
54
|
-
throw new ApiError(msg, res.status);
|
|
55
|
-
}
|
|
56
|
-
const body = (await res.json());
|
|
57
|
-
// Endpoint wraps responses in { data: {...} } — unwrap.
|
|
58
|
-
return body.data ?? body;
|
|
59
|
-
}
|
|
60
|
-
catch (err) {
|
|
61
|
-
clearTimeout(timeoutId);
|
|
62
|
-
if (err instanceof AuthError || err instanceof ApiError)
|
|
63
|
-
throw err;
|
|
64
|
-
if (err instanceof Error) {
|
|
65
|
-
if (err.name === "AbortError")
|
|
66
|
-
throw new TimeoutError(TIMEOUT_MS);
|
|
67
|
-
if (err.message.includes("fetch") || err.message.includes("ECONNREFUSED")) {
|
|
68
|
-
throw new NetworkError(err.message);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
throw err;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
throw new AuthError("Monitor API rejected both auth schemes");
|
|
75
|
-
}
|
|
16
|
+
import { fetchZaiMonitorPath } from "../providers/zai/monitor-client.js";
|
|
17
|
+
/**
|
|
18
|
+
* Back-compat delegate. Resolves the API key through the shared config
|
|
19
|
+
* accessor and delegates the fetch to the Provider-local monitor client.
|
|
20
|
+
*/
|
|
76
21
|
export async function getQuotaLimit() {
|
|
77
|
-
const
|
|
22
|
+
const apiKey = getApiKey();
|
|
23
|
+
const data = (await fetchZaiMonitorPath(apiKey, "/api/monitor/usage/quota/limit", undefined, {}));
|
|
78
24
|
return {
|
|
79
25
|
level: data.level || "unknown",
|
|
80
26
|
limits: data.limits || [],
|
|
81
27
|
};
|
|
82
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Back-compat delegate for the model-usage endpoint. Unused by commands
|
|
31
|
+
* today; preserved so the public export surface is unchanged.
|
|
32
|
+
*/
|
|
83
33
|
export async function getModelUsage(startTime, endTime) {
|
|
84
|
-
const
|
|
34
|
+
const apiKey = getApiKey();
|
|
35
|
+
const data = (await fetchZaiMonitorPath(apiKey, "/api/monitor/usage/model-usage", {
|
|
85
36
|
startTime,
|
|
86
37
|
endTime,
|
|
87
38
|
}));
|
|
@@ -112,4 +63,7 @@ export function formatResetTime(epochMs) {
|
|
|
112
63
|
const days = Math.floor(hours / 24);
|
|
113
64
|
return `${days}d`;
|
|
114
65
|
}
|
|
66
|
+
// Re-export the normalized error classes so existing imports from this
|
|
67
|
+
// module keep resolving.
|
|
68
|
+
export { ApiError, AuthError, NetworkError, TimeoutError };
|
|
115
69
|
//# sourceMappingURL=monitor-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor-client.js","sourceRoot":"","sources":["../../src/lib/monitor-client.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"monitor-client.js","sourceRoot":"","sources":["../../src/lib/monitor-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAsCzE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,IAAI,GAAG,CAAC,MAAM,mBAAmB,CACrC,MAAM,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ACvC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG,OAAO,GAAG,EAAE,CAAC;IAC1B,IAAI,KAAK,GAAG,EAAE;QAAE,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC;IACjE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;IACpC,OAAO,GAAG,IAAI,GAAG,CAAC;AACpB,CAAC;AAED,uEAAuE;AACvE,yBAAyB;AACzB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC"}
|
package/dist/lib/output.d.ts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Output formatting for Scoutline
|
|
2
|
+
* Output formatting for Scoutline.
|
|
3
|
+
*
|
|
4
|
+
* This Module exposes the pure, invocation-local output contract from
|
|
5
|
+
* DESIGN.md §3: OUTPUT_MODES, OutputMode, isOutputMode,
|
|
6
|
+
* formatSuccessOutput, and formatErrorOutput. The pure `success` and
|
|
7
|
+
* `error` response builders are retained as utility constructors.
|
|
8
|
+
*
|
|
9
|
+
* P1-10 removed the mutable output surface: there is no module-level output
|
|
10
|
+
* mode, no mode setter/getter, no side-effecting success/error writers, no
|
|
11
|
+
* output-mode environment mutation, and no console writes or process
|
|
12
|
+
* termination here. Command presentation and process writes flow through
|
|
13
|
+
* `invokeCommand` and the Node Adapter.
|
|
3
14
|
*/
|
|
15
|
+
export declare const OUTPUT_MODES: readonly ["data", "json", "pretty", "compact", "markdown", "refs", "tty"];
|
|
16
|
+
export type OutputMode = (typeof OUTPUT_MODES)[number];
|
|
4
17
|
export interface SuccessResponse<T = unknown> {
|
|
5
18
|
success: true;
|
|
6
19
|
data: T;
|
|
@@ -13,12 +26,45 @@ export interface ErrorResponse {
|
|
|
13
26
|
help?: string;
|
|
14
27
|
}
|
|
15
28
|
export type Response<T = unknown> = SuccessResponse<T> | ErrorResponse;
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
29
|
+
export declare function isOutputMode(value: unknown): value is OutputMode;
|
|
30
|
+
/**
|
|
31
|
+
* Pure success formatter.
|
|
32
|
+
*
|
|
33
|
+
* - `data` mode emits the raw JSON-encoded data (no success envelope).
|
|
34
|
+
* - `json` / `pretty` modes emit the success envelope with the timestamp
|
|
35
|
+
* taken from the injected `now` (defaults to `Date.now`). `pretty` uses
|
|
36
|
+
* 2-space indentation.
|
|
37
|
+
* - Text-oriented modes (`compact`, `markdown`, `refs`, `tty`) return the
|
|
38
|
+
* explicitly selected command presentation override when `data` carries
|
|
39
|
+
* one (i.e. `data.presentations[mode]` is a string). Otherwise they
|
|
40
|
+
* fall back to the JSON-encoded data.
|
|
41
|
+
*
|
|
42
|
+
* The function performs no I/O and mutates no shared state.
|
|
43
|
+
*/
|
|
44
|
+
export declare function formatSuccessOutput<T>(data: T, mode: OutputMode, now?: () => number): string;
|
|
45
|
+
/**
|
|
46
|
+
* Pure error formatter. Inspects the value through duck typing so this
|
|
47
|
+
* Module does not have to import from `./errors.js` (avoids a circular
|
|
48
|
+
* dependency with the error hierarchy).
|
|
49
|
+
*
|
|
50
|
+
* Recognises a ScoutlineError-shaped object (one carrying `message` and
|
|
51
|
+
* `code`) and surfaces `help` and `statusCode` when present. Plain
|
|
52
|
+
* `Error` instances and unknown values fall through to `UNKNOWN_ERROR`.
|
|
53
|
+
* `pretty` mode indents; all other modes emit compact JSON.
|
|
54
|
+
*
|
|
55
|
+
* The public envelope contains only the documented fields — `success`,
|
|
56
|
+
* `error`, `code`, optional `help`, optional `statusCode` — so stack,
|
|
57
|
+
* cause, raw response body, and any non-envelope property of the input
|
|
58
|
+
* are never serialised. Credential-shaped substrings inside `help` and
|
|
59
|
+
* `error` are redacted.
|
|
60
|
+
*
|
|
61
|
+
* The optional `secrets` argument lets a caller thread the credentials
|
|
62
|
+
* resolved from an injected environment (e.g. `MainDependencies.env`)
|
|
63
|
+
* into redaction, so a secret that exists only in the injected env —
|
|
64
|
+
* and not in ambient `process.env` — is still redacted (Fixup B — B3).
|
|
65
|
+
* When omitted, configured secrets are read from `process.env`.
|
|
66
|
+
*/
|
|
67
|
+
export declare function formatErrorOutput(value: unknown, mode: OutputMode, secrets?: string[]): string;
|
|
19
68
|
export declare function success<T>(data: T): SuccessResponse<T>;
|
|
20
69
|
export declare function error(message: string, code?: string, help?: string): ErrorResponse;
|
|
21
|
-
export declare function output<T>(response: Response<T>): void;
|
|
22
|
-
export declare function outputSuccess<T>(data: T): void;
|
|
23
|
-
export declare function outputError(message: string, code?: string, help?: string): void;
|
|
24
70
|
//# sourceMappingURL=output.d.ts.map
|
package/dist/lib/output.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/lib/output.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/lib/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,eAAO,MAAM,YAAY,YACvB,MAAM,EACN,MAAM,EACN,QAAQ,EACR,SAAS,EACT,UAAU,EACV,MAAM,EACN,KAAK,CACG,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC1C,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,CAAC,CAAC;IACR,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,OAAO,IAAI,eAAe,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC;AAEvE,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,UAAU,EAChB,GAAG,GAAE,MAAM,MAAiB,GAC3B,MAAM,CA2BR;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CA2C9F;AAWD,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAMtD;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAOlF"}
|
package/dist/lib/output.js
CHANGED
|
@@ -1,14 +1,133 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Output formatting for Scoutline
|
|
2
|
+
* Output formatting for Scoutline.
|
|
3
|
+
*
|
|
4
|
+
* This Module exposes the pure, invocation-local output contract from
|
|
5
|
+
* DESIGN.md §3: OUTPUT_MODES, OutputMode, isOutputMode,
|
|
6
|
+
* formatSuccessOutput, and formatErrorOutput. The pure `success` and
|
|
7
|
+
* `error` response builders are retained as utility constructors.
|
|
8
|
+
*
|
|
9
|
+
* P1-10 removed the mutable output surface: there is no module-level output
|
|
10
|
+
* mode, no mode setter/getter, no side-effecting success/error writers, no
|
|
11
|
+
* output-mode environment mutation, and no console writes or process
|
|
12
|
+
* termination here. Command presentation and process writes flow through
|
|
13
|
+
* `invokeCommand` and the Node Adapter.
|
|
3
14
|
*/
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
15
|
+
import { redactCredentialString, configuredSecrets } from "./redact.js";
|
|
16
|
+
export const OUTPUT_MODES = [
|
|
17
|
+
"data",
|
|
18
|
+
"json",
|
|
19
|
+
"pretty",
|
|
20
|
+
"compact",
|
|
21
|
+
"markdown",
|
|
22
|
+
"refs",
|
|
23
|
+
"tty",
|
|
24
|
+
];
|
|
25
|
+
export function isOutputMode(value) {
|
|
26
|
+
return typeof value === "string" && OUTPUT_MODES.includes(value);
|
|
8
27
|
}
|
|
9
|
-
|
|
10
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Pure success formatter.
|
|
30
|
+
*
|
|
31
|
+
* - `data` mode emits the raw JSON-encoded data (no success envelope).
|
|
32
|
+
* - `json` / `pretty` modes emit the success envelope with the timestamp
|
|
33
|
+
* taken from the injected `now` (defaults to `Date.now`). `pretty` uses
|
|
34
|
+
* 2-space indentation.
|
|
35
|
+
* - Text-oriented modes (`compact`, `markdown`, `refs`, `tty`) return the
|
|
36
|
+
* explicitly selected command presentation override when `data` carries
|
|
37
|
+
* one (i.e. `data.presentations[mode]` is a string). Otherwise they
|
|
38
|
+
* fall back to the JSON-encoded data.
|
|
39
|
+
*
|
|
40
|
+
* The function performs no I/O and mutates no shared state.
|
|
41
|
+
*/
|
|
42
|
+
export function formatSuccessOutput(data, mode, now = Date.now) {
|
|
43
|
+
if (mode === "data") {
|
|
44
|
+
return JSON.stringify(data);
|
|
45
|
+
}
|
|
46
|
+
if (mode === "json" || mode === "pretty") {
|
|
47
|
+
const indent = mode === "pretty" ? 2 : 0;
|
|
48
|
+
return JSON.stringify({ success: true, data, timestamp: now() }, null, indent);
|
|
49
|
+
}
|
|
50
|
+
// Text-oriented modes: prefer an explicitly selected command
|
|
51
|
+
// presentation override carried on `data.presentations`.
|
|
52
|
+
if (data !== null &&
|
|
53
|
+
typeof data === "object" &&
|
|
54
|
+
"presentations" in data &&
|
|
55
|
+
data.presentations !== null &&
|
|
56
|
+
typeof data.presentations === "object") {
|
|
57
|
+
const presentations = data.presentations;
|
|
58
|
+
const override = presentations[mode];
|
|
59
|
+
if (typeof override === "string") {
|
|
60
|
+
return override;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return JSON.stringify(data);
|
|
11
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Pure error formatter. Inspects the value through duck typing so this
|
|
67
|
+
* Module does not have to import from `./errors.js` (avoids a circular
|
|
68
|
+
* dependency with the error hierarchy).
|
|
69
|
+
*
|
|
70
|
+
* Recognises a ScoutlineError-shaped object (one carrying `message` and
|
|
71
|
+
* `code`) and surfaces `help` and `statusCode` when present. Plain
|
|
72
|
+
* `Error` instances and unknown values fall through to `UNKNOWN_ERROR`.
|
|
73
|
+
* `pretty` mode indents; all other modes emit compact JSON.
|
|
74
|
+
*
|
|
75
|
+
* The public envelope contains only the documented fields — `success`,
|
|
76
|
+
* `error`, `code`, optional `help`, optional `statusCode` — so stack,
|
|
77
|
+
* cause, raw response body, and any non-envelope property of the input
|
|
78
|
+
* are never serialised. Credential-shaped substrings inside `help` and
|
|
79
|
+
* `error` are redacted.
|
|
80
|
+
*
|
|
81
|
+
* The optional `secrets` argument lets a caller thread the credentials
|
|
82
|
+
* resolved from an injected environment (e.g. `MainDependencies.env`)
|
|
83
|
+
* into redaction, so a secret that exists only in the injected env —
|
|
84
|
+
* and not in ambient `process.env` — is still redacted (Fixup B — B3).
|
|
85
|
+
* When omitted, configured secrets are read from `process.env`.
|
|
86
|
+
*/
|
|
87
|
+
export function formatErrorOutput(value, mode, secrets) {
|
|
88
|
+
const indent = mode === "pretty" ? 2 : 0;
|
|
89
|
+
const resolvedSecrets = secrets ?? configuredSecrets();
|
|
90
|
+
let payload;
|
|
91
|
+
const isShapedError = value !== null && typeof value === "object" && "message" in value && "code" in value;
|
|
92
|
+
if (isShapedError) {
|
|
93
|
+
const err = value;
|
|
94
|
+
const rawError = typeof err.message === "string" ? err.message : String(err.message);
|
|
95
|
+
payload = {
|
|
96
|
+
success: false,
|
|
97
|
+
error: redactCredentialString(rawError, resolvedSecrets),
|
|
98
|
+
code: typeof err.code === "string" ? err.code : "UNKNOWN_ERROR",
|
|
99
|
+
};
|
|
100
|
+
if (typeof err.help === "string" && err.help.length > 0) {
|
|
101
|
+
payload.help = redactCredentialString(err.help, resolvedSecrets);
|
|
102
|
+
}
|
|
103
|
+
if (typeof err.statusCode === "number") {
|
|
104
|
+
payload.statusCode = err.statusCode;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (value instanceof Error) {
|
|
108
|
+
payload = {
|
|
109
|
+
success: false,
|
|
110
|
+
error: redactCredentialString(value.message, resolvedSecrets),
|
|
111
|
+
code: "UNKNOWN_ERROR",
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
payload = {
|
|
116
|
+
success: false,
|
|
117
|
+
error: redactCredentialString(String(value), resolvedSecrets),
|
|
118
|
+
code: "UNKNOWN_ERROR",
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return JSON.stringify(payload, null, indent);
|
|
122
|
+
}
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
124
|
+
// Pure response builders. These construct plain response objects and perform
|
|
125
|
+
// no I/O. They are retained as utility constructors; the side-effecting
|
|
126
|
+
// mutable output surface (mode setter/getter, the success/error writers, the
|
|
127
|
+
// module-level mode variable, output-mode env mutation, and process
|
|
128
|
+
// termination) was removed in P1-10. Command presentation and process writes
|
|
129
|
+
// now flow exclusively through `invokeCommand` and the Node Adapter.
|
|
130
|
+
// ---------------------------------------------------------------------------
|
|
12
131
|
export function success(data) {
|
|
13
132
|
return {
|
|
14
133
|
success: true,
|
|
@@ -24,36 +143,4 @@ export function error(message, code, help) {
|
|
|
24
143
|
...(help && { help }),
|
|
25
144
|
};
|
|
26
145
|
}
|
|
27
|
-
export function output(response) {
|
|
28
|
-
const pretty = outputMode === "pretty";
|
|
29
|
-
console.log(JSON.stringify(response, null, pretty ? 2 : 0));
|
|
30
|
-
}
|
|
31
|
-
export function outputSuccess(data) {
|
|
32
|
-
// Search-specific text formats; data is expected to be a pre-formatted string.
|
|
33
|
-
if (outputMode === "compact" ||
|
|
34
|
-
outputMode === "markdown" ||
|
|
35
|
-
outputMode === "refs" ||
|
|
36
|
-
outputMode === "tty") {
|
|
37
|
-
if (typeof data === "string") {
|
|
38
|
-
console.log(data);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
console.log(JSON.stringify(data, null, 0));
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (outputMode === "data") {
|
|
45
|
-
if (typeof data === "string") {
|
|
46
|
-
console.log(data);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
console.log(JSON.stringify(data, null, 0));
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
output(success(data));
|
|
53
|
-
}
|
|
54
|
-
export function outputError(message, code, help) {
|
|
55
|
-
const pretty = outputMode === "pretty";
|
|
56
|
-
console.error(JSON.stringify(error(message, code, help), null, pretty ? 2 : 0));
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
146
|
//# sourceMappingURL=output.js.map
|
package/dist/lib/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/lib/output.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/lib/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAExE,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,MAAM;IACN,MAAM;IACN,QAAQ;IACR,SAAS;IACT,UAAU;IACV,MAAM;IACN,KAAK;CACG,CAAC;AAmBX,MAAM,UAAU,YAAY,CAAC,KAAc;I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,CAAC;YAC7D,IAAI,EAAE,eAAe;SACtB,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,GAAG;YACR,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,sBAAsB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC;YAC7D,IAAI,EAAE,eAAe;SACtB,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED,8EAA8E;AAC9E,6EAA6E;AAC7E,wEAAwE;AACxE,6EAA6E;AAC7E,oEAAoE;AACpE,6EAA6E;AAC7E,qEAAqE;AACrE,8EAA8E;AAE9E,MAAM,UAAU,OAAO,CAAI,IAAO;IAChC,OAAO;QACL,OAAO,EAAE,IAAI;QACb,IAAI;QACJ,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;KACtB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,OAAe,EAAE,IAAa,EAAE,IAAa;IACjE,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,OAAO;QACd,GAAG,CAAC,IAAI,IAAI,EAAE,IAAI,EAAE,CAAC;QACrB,GAAG,CAAC,IAAI,IAAI,EAAE,IAAI,EAAE,CAAC;KACtB,CAAC;AACJ,CAAC"}
|
package/dist/lib/redact.d.ts
CHANGED
|
@@ -1,7 +1,66 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Recursive Provider credential redaction (DESIGN.md §16).
|
|
3
|
+
*
|
|
4
|
+
* This Module is the single source of truth for stripping Provider
|
|
5
|
+
* credentials before any value leaves Scoutline's outward boundaries:
|
|
6
|
+
* formatted errors, cached metadata, quota failures, diagnostics output,
|
|
7
|
+
* and fatal shell errors.
|
|
8
|
+
*
|
|
9
|
+
* Redaction properties (Phase 4 P4-01):
|
|
10
|
+
* - Case-insensitive for the canonical credential-shaped keys.
|
|
11
|
+
* - Recursive through nested arrays and plain objects.
|
|
12
|
+
* - Non-mutating — the original input is never modified.
|
|
13
|
+
* - Secret-aware — every configured secret value is replaced inside
|
|
14
|
+
* any string the value tree reaches, not just the configured key.
|
|
15
|
+
* - Empty-safe — empty strings are never treated as a replacement token.
|
|
16
|
+
*
|
|
17
|
+
* The Module retains the legacy `redactSecrets(value, apiKey?)` and
|
|
18
|
+
* `redactTool(tool)` exports so existing call sites keep compiling.
|
|
19
|
+
* New code should pass an explicit array of secrets so every Provider's
|
|
20
|
+
* credential is covered in one pass.
|
|
3
21
|
*/
|
|
4
22
|
import type { Tool } from "@utcp/sdk";
|
|
5
|
-
|
|
6
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Replace credential-shaped substrings inside a single string. Useful
|
|
25
|
+
* for error messages and load-failure texts where the value is a flat
|
|
26
|
+
* string rather than a structured object.
|
|
27
|
+
*
|
|
28
|
+
* Replaces:
|
|
29
|
+
* - Bearer authorization values (any case).
|
|
30
|
+
* - x-api-key assignments (any case; `=`, `:`, or whitespace as the
|
|
31
|
+
* key/value separator — covers both `x-api-key=value` and
|
|
32
|
+
* `x-api-key value`).
|
|
33
|
+
* - Z_AI_API_KEY, ZAI_API_KEY, MINIMAX_API_KEY assignments.
|
|
34
|
+
* - The literal credentials passed in `extraSecrets` (each value is
|
|
35
|
+
* replaced wherever it appears; empty strings are skipped).
|
|
36
|
+
*/
|
|
37
|
+
export declare function redactCredentialString(input: string, extraSecrets?: string | string[]): string;
|
|
38
|
+
/**
|
|
39
|
+
* Resolve the configured Provider credential values from the current
|
|
40
|
+
* process environment. Returned values are deduplicated and empty
|
|
41
|
+
* entries skipped, so callers can pass the result directly to
|
|
42
|
+
* {@link redactSecrets}.
|
|
43
|
+
*/
|
|
44
|
+
export declare function configuredSecrets(env?: NodeJS.ProcessEnv): string[];
|
|
45
|
+
/**
|
|
46
|
+
* Recursively redact credential values from an arbitrary tree.
|
|
47
|
+
*
|
|
48
|
+
* Accepts either a single string (back-compat overload) or an array of
|
|
49
|
+
* secret values. Returns a NEW value tree; the input is never mutated.
|
|
50
|
+
*
|
|
51
|
+
* Key matching is case-insensitive over {@link CREDENTIAL_KEYS}. Plain
|
|
52
|
+
* objects and arrays are descended into. Other object kinds (Date,
|
|
53
|
+
* typed arrays, class instances) are returned as-is so their internal
|
|
54
|
+
* state is not reflected.
|
|
55
|
+
*/
|
|
56
|
+
export declare function redactSecrets(value: unknown, secrets?: string | string[]): unknown;
|
|
57
|
+
/**
|
|
58
|
+
* Redact credential-shaped fields from a Tool's metadata tree.
|
|
59
|
+
*
|
|
60
|
+
* Back-compat: when called with a single argument the function reads
|
|
61
|
+
* the configured Provider credentials from the current process
|
|
62
|
+
* environment. When called with an explicit secrets argument, the
|
|
63
|
+
* caller's value is used instead.
|
|
64
|
+
*/
|
|
65
|
+
export declare function redactTool(tool: Tool, secrets?: string | string[]): Tool;
|
|
7
66
|
//# sourceMappingURL=redact.d.ts.map
|
package/dist/lib/redact.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../src/lib/redact.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../src/lib/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAqBtC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CA0B9F;AAuBD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,EAAE,CAOhF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAiClF;AAQD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAMxE"}
|