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
package/dist/commands/doctor.js
CHANGED
|
@@ -1,70 +1,197 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Doctor command
|
|
2
|
+
* Doctor command — Provider-aware diagnostics (P4-04, DESIGN.md §14).
|
|
3
|
+
*
|
|
4
|
+
* The command is presentation-only: it receives a report builder through
|
|
5
|
+
* injected dependencies and wraps the resulting {@link DiagnosticsReport}
|
|
6
|
+
* as base data with a computed exit code. Provider resolution, capability
|
|
7
|
+
* probing, settled collection, and failure redaction live in
|
|
8
|
+
* {@link buildDiagnosticsReport} so the command never imports a Provider
|
|
9
|
+
* transport (ZaiMcpClient, monitor client, or environment credential
|
|
10
|
+
* reads) directly.
|
|
11
|
+
*
|
|
12
|
+
* Exit semantics (DESIGN.md §14):
|
|
13
|
+
* - Missing effective Provider credentials -> exit 1.
|
|
14
|
+
* - Any configured probe error -> exit 1 (successful entries preserved).
|
|
15
|
+
* - All configured probes succeed, or only tools-disabled skips -> exit 0.
|
|
16
|
+
*
|
|
17
|
+
* Under `--no-tools` the command returns after metadata + configured-state
|
|
18
|
+
* evaluation and constructs no Adapter and no transport (FR-034).
|
|
3
19
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
function
|
|
20
|
+
import { deriveSharedCapabilities, deriveZaiOnlyCapabilities, diagnosticErrorFromError, } from "../capabilities/diagnostics.js";
|
|
21
|
+
import { executeProviderOperation } from "../lib/execution.js";
|
|
22
|
+
import { UnsupportedCapabilityError } from "../lib/errors.js";
|
|
23
|
+
import { redactSecrets, configuredSecrets } from "../lib/redact.js";
|
|
24
|
+
function nodeMajor() {
|
|
9
25
|
const [major] = process.versions.node.split(".");
|
|
10
26
|
return parseInt(major, 10);
|
|
11
27
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Probe one Provider's connectivity through shared execution. The Adapter
|
|
30
|
+
* transport performs a single attempt (Z.AI tool discovery or MiniMax raw
|
|
31
|
+
* quota probe); the retry policy lives in
|
|
32
|
+
* `executeProviderOperation("diagnostics", ...)`.
|
|
33
|
+
*/
|
|
34
|
+
async function probeProvider(descriptor, env, sleep, random) {
|
|
35
|
+
const adapter = descriptor.create({ env });
|
|
36
|
+
const capability = adapter.diagnostics;
|
|
37
|
+
if (!capability) {
|
|
38
|
+
throw new UnsupportedCapabilityError(descriptor.id, "diagnostics");
|
|
39
|
+
}
|
|
40
|
+
return executeProviderOperation("diagnostics", () => capability.invoke({ probe: true }), {
|
|
41
|
+
sleep,
|
|
42
|
+
random,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Build a schema-version-1 {@link DiagnosticsReport}. Inventory
|
|
47
|
+
* (`sharedCapabilities`, `zaiOnlyCapabilities`) is derived purely from
|
|
48
|
+
* `deps.descriptors` — no descriptor.create(), no transport, no
|
|
49
|
+
* production registry import. Under `--no-tools` the command returns
|
|
50
|
+
* after metadata + configured-state evaluation. Otherwise each
|
|
51
|
+
* configured Provider is probed through shared execution with settled
|
|
52
|
+
* collection, preserving registry order and normalized redacted
|
|
53
|
+
* failures.
|
|
54
|
+
*/
|
|
55
|
+
export async function buildDiagnosticsReport(deps) {
|
|
56
|
+
const secrets = configuredSecrets(deps.env);
|
|
57
|
+
const baseEntries = deps.descriptors.map((descriptor) => ({
|
|
58
|
+
provider: descriptor.id,
|
|
59
|
+
configured: descriptor.isConfigured(deps.env),
|
|
60
|
+
capabilities: [...descriptor.capabilities()],
|
|
61
|
+
}));
|
|
62
|
+
const providers = deps.noTools
|
|
63
|
+
? baseEntries.map((entry) => ({
|
|
64
|
+
...entry,
|
|
65
|
+
status: "skipped",
|
|
66
|
+
reason: entry.configured ? "tools-disabled" : "not-configured",
|
|
67
|
+
}))
|
|
68
|
+
: await probeEntries(baseEntries, deps, secrets);
|
|
69
|
+
// L1 fix: the cache summary is formatted by the CLI handler and
|
|
70
|
+
// threaded through deps.cacheSummary. The report builder only embeds
|
|
71
|
+
// it; it never reads `cacheStats()` itself.
|
|
72
|
+
const cache = deps.cacheSummary === undefined ? undefined : { summary: deps.cacheSummary };
|
|
73
|
+
return {
|
|
74
|
+
schemaVersion: 1,
|
|
75
|
+
effectiveProvider: deps.effectiveProvider,
|
|
76
|
+
sharedCapabilities: deriveSharedCapabilities(deps.descriptors),
|
|
77
|
+
zaiOnlyCapabilities: deriveZaiOnlyCapabilities(deps.descriptors),
|
|
22
78
|
node: {
|
|
23
|
-
version: process.
|
|
24
|
-
visionMcpCompatible: nodeMajor >= 22,
|
|
79
|
+
version: process.version,
|
|
80
|
+
visionMcpCompatible: nodeMajor() >= 22,
|
|
25
81
|
},
|
|
82
|
+
providers,
|
|
83
|
+
...(cache !== undefined ? { cache } : {}),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Probe every configured Provider in registry order using settled
|
|
88
|
+
* collection. Unconfigured entries are skipped (not-configured) and do
|
|
89
|
+
* NOT fail the report. A configured probe failure is normalized and
|
|
90
|
+
* recursively redacted before joining the report; successful entries
|
|
91
|
+
* are preserved alongside it.
|
|
92
|
+
*/
|
|
93
|
+
async function probeEntries(baseEntries, deps, secrets) {
|
|
94
|
+
const configuredIndexes = baseEntries
|
|
95
|
+
.map((entry, index) => (entry.configured ? index : -1))
|
|
96
|
+
.filter((index) => index >= 0);
|
|
97
|
+
const settled = await Promise.allSettled(configuredIndexes.map((index) => probeProvider(deps.descriptors[index], deps.env, deps.sleep, deps.random)));
|
|
98
|
+
let settledCursor = 0;
|
|
99
|
+
return baseEntries.map((entry) => {
|
|
100
|
+
if (!entry.configured) {
|
|
101
|
+
return { ...entry, status: "skipped", reason: "not-configured" };
|
|
102
|
+
}
|
|
103
|
+
const result = settled[settledCursor++];
|
|
104
|
+
if (result.status === "fulfilled") {
|
|
105
|
+
return { ...entry, status: "ok" };
|
|
106
|
+
}
|
|
107
|
+
const redacted = redactSecrets(diagnosticErrorFromError(result.reason), secrets);
|
|
108
|
+
return { ...entry, status: "error", error: redacted };
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
// ---------------------------------------------------------------------------
|
|
112
|
+
// Exit code
|
|
113
|
+
// ---------------------------------------------------------------------------
|
|
114
|
+
/**
|
|
115
|
+
* Compute the doctor exit code from a finalized report. Exit 1 when the
|
|
116
|
+
* effective Provider is unconfigured or any configured probe errored;
|
|
117
|
+
* otherwise exit 0. A tools-disabled or not-configured skip on a
|
|
118
|
+
* non-effective Provider never fails the report.
|
|
119
|
+
*/
|
|
120
|
+
export function doctorExitCode(report) {
|
|
121
|
+
const effective = report.providers.find((p) => p.provider === report.effectiveProvider);
|
|
122
|
+
if (!effective || !effective.configured)
|
|
123
|
+
return 1;
|
|
124
|
+
if (report.providers.some((p) => p.status === "error"))
|
|
125
|
+
return 1;
|
|
126
|
+
return 0;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Run the doctor command. Returns the diagnostics report as base data
|
|
130
|
+
* with a computed exit code (1 when the effective Provider is
|
|
131
|
+
* unconfigured or any configured probe failed; otherwise 0).
|
|
132
|
+
*/
|
|
133
|
+
export async function doctor(deps) {
|
|
134
|
+
const report = await deps.buildReport();
|
|
135
|
+
return {
|
|
136
|
+
kind: "data",
|
|
137
|
+
data: report,
|
|
138
|
+
exitCode: doctorExitCode(report),
|
|
26
139
|
};
|
|
27
|
-
if (options.noTools || !apiKey) {
|
|
28
|
-
outputSuccess(report);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
silenceConsole();
|
|
32
|
-
const client = new ZaiMcpClient({ enableVision: options.enableVision });
|
|
33
|
-
try {
|
|
34
|
-
const tools = await client.listTools();
|
|
35
|
-
const byServer = tools.reduce((acc, tool) => {
|
|
36
|
-
const parts = tool.name.split(".");
|
|
37
|
-
const server = parts.length >= 2 ? parts[1] : "unknown";
|
|
38
|
-
acc[server] = (acc[server] || 0) + 1;
|
|
39
|
-
return acc;
|
|
40
|
-
}, {});
|
|
41
|
-
report.mcp = {
|
|
42
|
-
toolCount: tools.length,
|
|
43
|
-
servers: byServer,
|
|
44
|
-
};
|
|
45
|
-
outputSuccess(report);
|
|
46
|
-
}
|
|
47
|
-
catch (error) {
|
|
48
|
-
restoreConsole();
|
|
49
|
-
console.error(formatErrorOutput(error));
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
finally {
|
|
53
|
-
await client.close().catch(() => { });
|
|
54
|
-
restoreConsole();
|
|
55
|
-
}
|
|
56
140
|
}
|
|
57
141
|
export const DOCTOR_HELP = `
|
|
58
|
-
Doctor -
|
|
142
|
+
Doctor - Provider-aware environment and connectivity diagnostics
|
|
59
143
|
|
|
60
144
|
Usage: scoutline doctor [options]
|
|
61
145
|
|
|
146
|
+
Reports a schema-version-1 diagnostics report listing every built-in
|
|
147
|
+
Provider (zai, minimax) with its configured state, declared
|
|
148
|
+
Capabilities, and connectivity status. The effective Provider (resolved
|
|
149
|
+
from --provider, SCOUTLINE_PROVIDER, or the default zai) is the
|
|
150
|
+
Provider that serves the shared Capabilities shared across every
|
|
151
|
+
built-in descriptor. The sharedCapabilities and zaiOnlyCapabilities
|
|
152
|
+
fields are derived from descriptor metadata, so they always reflect
|
|
153
|
+
the descriptors passed to this command.
|
|
154
|
+
|
|
155
|
+
Z.AI connectivity is probed through MCP tool discovery; MiniMax
|
|
156
|
+
connectivity through a single raw quota probe that authenticates
|
|
157
|
+
without a generative request.
|
|
158
|
+
|
|
159
|
+
Repository exploration is a Provider Capability. Z.AI descriptor
|
|
160
|
+
metadata advertises repository-exploration and the Z.AI Adapter
|
|
161
|
+
supplies it; MiniMax advertises and supplies neither. The
|
|
162
|
+
sharedCapabilities and zaiOnlyCapabilities fields above reflect that
|
|
163
|
+
descriptor state (repository-exploration currently appears in
|
|
164
|
+
zaiOnlyCapabilities).
|
|
165
|
+
|
|
166
|
+
Reader is a Provider Capability. Z.AI descriptor metadata advertises
|
|
167
|
+
reader and the Z.AI Adapter supplies it; MiniMax advertises and
|
|
168
|
+
supplies neither. reader currently appears in zaiOnlyCapabilities
|
|
169
|
+
alongside repository-exploration.
|
|
170
|
+
|
|
171
|
+
Public 'repo' and 'read' commands participate in Provider selection.
|
|
172
|
+
They honour --provider / SCOUTLINE_PROVIDER / the default zai, route
|
|
173
|
+
through the Z.AI Adapter's Repository and Reader Capabilities
|
|
174
|
+
respectively, and return UNSUPPORTED_CAPABILITY when the selected
|
|
175
|
+
Provider does not advertise the requested capability (e.g.
|
|
176
|
+
'repo --provider minimax' or 'read --provider minimax' fail without
|
|
177
|
+
falling back to Z.AI). A supported-but-unconfigured Z.AI returns
|
|
178
|
+
ConfigurationError; supported-and-configured Z.AI dispatches through
|
|
179
|
+
the Repository Explorer / Reader Adapter.
|
|
180
|
+
|
|
62
181
|
Options:
|
|
63
|
-
--no-tools Skip
|
|
64
|
-
|
|
182
|
+
--no-tools Skip every connectivity probe (metadata-only). Under
|
|
183
|
+
--no-tools no Provider transport is constructed: a
|
|
184
|
+
configured Provider is reported as skipped
|
|
185
|
+
(tools-disabled) and does not fail the report.
|
|
186
|
+
|
|
187
|
+
Exit codes:
|
|
188
|
+
0 All configured probes succeeded (or only tools-disabled skips).
|
|
189
|
+
1 The effective Provider is unconfigured or any configured probe
|
|
190
|
+
failed; successful entries are still reported.
|
|
65
191
|
|
|
66
192
|
Examples:
|
|
67
|
-
scoutline doctor
|
|
68
|
-
scoutline doctor --
|
|
193
|
+
scoutline doctor # full diagnostics
|
|
194
|
+
scoutline doctor --provider minimax
|
|
195
|
+
scoutline doctor --no-tools # metadata only, no transport
|
|
69
196
|
`.trim();
|
|
70
197
|
//# sourceMappingURL=doctor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mapp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9E,YAAY;AACZ,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAyB;IACtD,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,iBAAiB,CAAC,CAAC;IACxF,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,UAAU;QAAE,OAAO,CAAC,CAAC;IAClD,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,CAAC,CAAC;IACjE,OAAO,CAAC,CAAC;AACX,CAAC;AAmBD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,IAA+B;IAE/B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;IACxC,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC;KACjC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuD1B,CAAC,IAAI,EAAE,CAAC"}
|
package/dist/commands/quota.d.ts
CHANGED
|
@@ -1,9 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Quota command —
|
|
2
|
+
* Quota command — Provider-neutral quota dashboard (P4-03, ADR-0001).
|
|
3
|
+
*
|
|
4
|
+
* The command is presentation-only: it receives a dashboard builder
|
|
5
|
+
* through injected dependencies and wraps the resulting
|
|
6
|
+
* {@link QuotaDashboard} as base data with a TTY presentation override.
|
|
7
|
+
* Provider resolution, capability invocation, settled collection, and
|
|
8
|
+
* failure redaction live in {@link buildQuotaDashboard} so the command
|
|
9
|
+
* never imports a Provider monitor client or maps a Provider response.
|
|
10
|
+
*
|
|
11
|
+
* Default mode (effective Provider) propagates quota failures through
|
|
12
|
+
* the ordinary error path (thrown → invokeCommand). All-provider mode
|
|
13
|
+
* (`--all-providers`) uses settled collection, emits successful and
|
|
14
|
+
* failed entries, and yields exit 1 when any configured Provider fails.
|
|
3
15
|
*/
|
|
16
|
+
import type { CommandResult } from "../command-invocation.js";
|
|
17
|
+
import type { QuotaDashboard } from "../capabilities/quota.js";
|
|
18
|
+
import type { ProviderDescriptor, ProviderId } from "../providers/types.js";
|
|
19
|
+
export interface QuotaDashboardDependencies {
|
|
20
|
+
readonly allProviders: boolean;
|
|
21
|
+
readonly effectiveProvider: ProviderId;
|
|
22
|
+
readonly descriptors: readonly ProviderDescriptor[];
|
|
23
|
+
readonly env: NodeJS.ProcessEnv;
|
|
24
|
+
readonly sleep: (ms: number) => Promise<void>;
|
|
25
|
+
readonly random: () => number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Build a {@link QuotaDashboard} for the selected mode. The effective
|
|
29
|
+
* Provider is resolved by the dispatcher (`index.ts`) and passed in as
|
|
30
|
+
* metadata; config validation happens here.
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildQuotaDashboard(deps: QuotaDashboardDependencies): Promise<QuotaDashboard>;
|
|
4
33
|
export interface QuotaOptions {
|
|
5
|
-
|
|
34
|
+
allProviders?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Injectable dependencies for the quota command. `buildDashboard`
|
|
38
|
+
* resolves the effective/all-provider dashboard; the command only wraps
|
|
39
|
+
* it for presentation and exit-code selection.
|
|
40
|
+
*/
|
|
41
|
+
export interface QuotaCommandDependencies {
|
|
42
|
+
readonly buildDashboard: () => Promise<QuotaDashboard>;
|
|
6
43
|
}
|
|
7
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Run the quota command. Returns the dashboard as base data with a TTY
|
|
46
|
+
* presentation override. Exit code is 1 when any dashboard entry failed
|
|
47
|
+
* (all-provider mode); otherwise 0.
|
|
48
|
+
*/
|
|
49
|
+
export declare function quota(deps: QuotaCommandDependencies): Promise<CommandResult<QuotaDashboard>>;
|
|
8
50
|
export declare const QUOTA_HELP: string;
|
|
9
51
|
//# sourceMappingURL=quota.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota.d.ts","sourceRoot":"","sources":["../../src/commands/quota.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"quota.d.ts","sourceRoot":"","sources":["../../src/commands/quota.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAIV,cAAc,EACf,MAAM,0BAA0B,CAAC;AAIlC,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAS5E,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC;IACvC,QAAQ,CAAC,WAAW,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACpD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,QAAQ,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC;CAC/B;AAqFD;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,0BAA0B,GAC/B,OAAO,CAAC,cAAc,CAAC,CAEzB;AAMD,MAAM,WAAW,YAAY;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,cAAc,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;CACxD;AAED;;;;GAIG;AACH,wBAAsB,KAAK,CACzB,IAAI,EAAE,wBAAwB,GAC7B,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,CASxC;AAED,eAAO,MAAM,UAAU,QA2Bf,CAAC"}
|
package/dist/commands/quota.js
CHANGED
|
@@ -1,77 +1,133 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Quota command —
|
|
2
|
+
* Quota command — Provider-neutral quota dashboard (P4-03, ADR-0001).
|
|
3
|
+
*
|
|
4
|
+
* The command is presentation-only: it receives a dashboard builder
|
|
5
|
+
* through injected dependencies and wraps the resulting
|
|
6
|
+
* {@link QuotaDashboard} as base data with a TTY presentation override.
|
|
7
|
+
* Provider resolution, capability invocation, settled collection, and
|
|
8
|
+
* failure redaction live in {@link buildQuotaDashboard} so the command
|
|
9
|
+
* never imports a Provider monitor client or maps a Provider response.
|
|
10
|
+
*
|
|
11
|
+
* Default mode (effective Provider) propagates quota failures through
|
|
12
|
+
* the ordinary error path (thrown → invokeCommand). All-provider mode
|
|
13
|
+
* (`--all-providers`) uses settled collection, emits successful and
|
|
14
|
+
* failed entries, and yields exit 1 when any configured Provider fails.
|
|
3
15
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
windowHours: timeLimit.unit,
|
|
22
|
-
resetsAt: timeLimit.nextResetTime
|
|
23
|
-
? new Date(timeLimit.nextResetTime).toISOString()
|
|
24
|
-
: null,
|
|
25
|
-
resetsIn: timeLimit.nextResetTime ? formatResetTime(timeLimit.nextResetTime) : null,
|
|
26
|
-
byTool: timeLimit.usageDetails,
|
|
27
|
-
}
|
|
28
|
-
: null,
|
|
29
|
-
tokens: tokensLimit
|
|
30
|
-
? {
|
|
31
|
-
percentage: tokensLimit.percentage,
|
|
32
|
-
resetsAt: tokensLimit.nextResetTime
|
|
33
|
-
? new Date(tokensLimit.nextResetTime).toISOString()
|
|
34
|
-
: null,
|
|
35
|
-
resetsIn: tokensLimit.nextResetTime ? formatResetTime(tokensLimit.nextResetTime) : null,
|
|
36
|
-
}
|
|
37
|
-
: null,
|
|
38
|
-
};
|
|
39
|
-
const mode = getOutputMode();
|
|
40
|
-
if (mode === "tty") {
|
|
41
|
-
outputSuccess(formatQuotaPretty(formatted));
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
outputSuccess(formatted);
|
|
45
|
-
}
|
|
16
|
+
import { quotaFailureFromError } from "../capabilities/quota.js";
|
|
17
|
+
import { executeProviderOperation } from "../lib/execution.js";
|
|
18
|
+
import { ConfigurationError, UnsupportedCapabilityError } from "../lib/errors.js";
|
|
19
|
+
import { getProviderDescriptor } from "../providers/selection.js";
|
|
20
|
+
import { redactSecrets, configuredSecrets } from "../lib/redact.js";
|
|
21
|
+
import { formatQuotaDashboard } from "../lib/tty.js";
|
|
22
|
+
/**
|
|
23
|
+
* Invoke one Provider's quota Capability through shared execution. The
|
|
24
|
+
* Adapter transport performs a single attempt; the retry policy lives
|
|
25
|
+
* in `executeProviderOperation("quota", ...)`. Quota never uses the
|
|
26
|
+
* response cache.
|
|
27
|
+
*/
|
|
28
|
+
async function invokeProviderQuota(descriptor, env, sleep, random) {
|
|
29
|
+
const adapter = descriptor.create({ env });
|
|
30
|
+
const capability = adapter.quota;
|
|
31
|
+
if (!capability) {
|
|
32
|
+
throw new UnsupportedCapabilityError(descriptor.id, "quota");
|
|
46
33
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
34
|
+
return executeProviderOperation("quota", () => capability.invoke(), { sleep, random });
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Default-mode dashboard. Resolves the effective Provider, requires it
|
|
38
|
+
* to be configured (ConfigurationError, exit 3, before transport), then
|
|
39
|
+
* invokes its quota Capability. Failures propagate through the ordinary
|
|
40
|
+
* error path.
|
|
41
|
+
*/
|
|
42
|
+
async function buildDefaultDashboard(deps) {
|
|
43
|
+
const descriptor = getProviderDescriptor(deps.effectiveProvider, deps.descriptors);
|
|
44
|
+
if (!descriptor.isConfigured(deps.env)) {
|
|
45
|
+
throw new ConfigurationError(`Provider "${deps.effectiveProvider}" is not configured. Set Z_AI_API_KEY or MINIMAX_API_KEY.`);
|
|
46
|
+
}
|
|
47
|
+
const success = await invokeProviderQuota(descriptor, deps.env, deps.sleep, deps.random);
|
|
48
|
+
return {
|
|
49
|
+
schemaVersion: 1,
|
|
50
|
+
effectiveProvider: deps.effectiveProvider,
|
|
51
|
+
providers: [success],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* All-provider dashboard. Queries every configured Provider in static
|
|
56
|
+
* registry order using settled collection. No unconfigured Provider is
|
|
57
|
+
* invoked; the effective Provider is dashboard metadata only. Failures
|
|
58
|
+
* are normalized and recursively redacted before joining the dashboard.
|
|
59
|
+
* No configured Provider is a configuration failure, not an empty
|
|
60
|
+
* success.
|
|
61
|
+
*/
|
|
62
|
+
async function buildAllProvidersDashboard(deps) {
|
|
63
|
+
const configured = deps.descriptors.filter((d) => d.isConfigured(deps.env));
|
|
64
|
+
if (configured.length === 0) {
|
|
65
|
+
throw new ConfigurationError("No provider is configured. Set Z_AI_API_KEY and/or MINIMAX_API_KEY.");
|
|
50
66
|
}
|
|
67
|
+
const secrets = configuredSecrets(deps.env);
|
|
68
|
+
const settled = await Promise.allSettled(configured.map((d) => invokeProviderQuota(d, deps.env, deps.sleep, deps.random)));
|
|
69
|
+
const providers = configured.map((d, i) => {
|
|
70
|
+
const result = settled[i];
|
|
71
|
+
if (result.status === "fulfilled") {
|
|
72
|
+
return result.value;
|
|
73
|
+
}
|
|
74
|
+
return redactSecrets(quotaFailureFromError(d.id, result.reason), secrets);
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
schemaVersion: 1,
|
|
78
|
+
effectiveProvider: deps.effectiveProvider,
|
|
79
|
+
providers,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Build a {@link QuotaDashboard} for the selected mode. The effective
|
|
84
|
+
* Provider is resolved by the dispatcher (`index.ts`) and passed in as
|
|
85
|
+
* metadata; config validation happens here.
|
|
86
|
+
*/
|
|
87
|
+
export async function buildQuotaDashboard(deps) {
|
|
88
|
+
return deps.allProviders ? buildAllProvidersDashboard(deps) : buildDefaultDashboard(deps);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Run the quota command. Returns the dashboard as base data with a TTY
|
|
92
|
+
* presentation override. Exit code is 1 when any dashboard entry failed
|
|
93
|
+
* (all-provider mode); otherwise 0.
|
|
94
|
+
*/
|
|
95
|
+
export async function quota(deps) {
|
|
96
|
+
const dashboard = await deps.buildDashboard();
|
|
97
|
+
const hasFailure = dashboard.providers.some((p) => p.status === "error");
|
|
98
|
+
return {
|
|
99
|
+
kind: "data",
|
|
100
|
+
data: dashboard,
|
|
101
|
+
presentations: { tty: formatQuotaDashboard(dashboard) },
|
|
102
|
+
exitCode: hasFailure ? 1 : 0,
|
|
103
|
+
};
|
|
51
104
|
}
|
|
52
105
|
export const QUOTA_HELP = `
|
|
53
|
-
Quota Command -
|
|
106
|
+
Quota Command - Provider-normalized plan usage dashboard
|
|
54
107
|
|
|
55
108
|
Usage: scoutline quota [options]
|
|
56
109
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
- Token budget percentage + reset time
|
|
110
|
+
Reports plan usage for the effective Provider (or every configured
|
|
111
|
+
Provider with --all-providers) as a normalized, schema-version-1
|
|
112
|
+
dashboard (ADR-0001). Each entry carries named quota categories with
|
|
113
|
+
current and optional weekly windows, counts, remaining percentage, and
|
|
114
|
+
ISO reset time. No Provider-specific field crosses the Interface.
|
|
63
115
|
|
|
64
116
|
Options:
|
|
65
|
-
|
|
117
|
+
--all-providers Query every configured Provider in registry order.
|
|
118
|
+
Successful and failed entries both appear; the
|
|
119
|
+
command exits 1 when any Provider fails.
|
|
66
120
|
|
|
67
121
|
Examples:
|
|
68
|
-
scoutline quota
|
|
69
|
-
scoutline quota -
|
|
70
|
-
scoutline quota -O
|
|
122
|
+
scoutline quota # effective Provider usage
|
|
123
|
+
scoutline quota --all-providers # every configured Provider
|
|
124
|
+
scoutline quota -O pretty # human-readable with progress bars
|
|
125
|
+
scoutline quota -O json # envelope-wrapped for scripts
|
|
71
126
|
|
|
72
127
|
Notes:
|
|
73
|
-
-
|
|
74
|
-
|
|
75
|
-
|
|
128
|
+
- Quota is never cached by the local response cache.
|
|
129
|
+
- Default-mode failures propagate as ordinary errors (exit 3 for an
|
|
130
|
+
unconfigured effective Provider).
|
|
131
|
+
- All-provider mode never invokes an unconfigured Provider.
|
|
76
132
|
`.trim();
|
|
77
133
|
//# sourceMappingURL=quota.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota.js","sourceRoot":"","sources":["../../src/commands/quota.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"quota.js","sourceRoot":"","sources":["../../src/commands/quota.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAElF,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAmBrD;;;;;GAKG;AACH,KAAK,UAAU,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I,CAAC,cAAc,EAAE,CAAC;IAC9C,MAAM,UAAU,GAAG,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC;IACzE,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,SAAS;QACf,aAAa,EAAE,EAAE,GAAG,EAAE,oBAAoB,CAAC,SAAS,CAAC,EAAE;QACvD,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC7B,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BzB,CAAC,IAAI,EAAE,CAAC"}
|
package/dist/commands/read.d.ts
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Web reader command
|
|
2
|
+
* Web reader command — thin handler over the Reader Capability
|
|
3
|
+
* (DESIGN.md §18, reader-migration-core-flows, reader-migration-tech-plan
|
|
4
|
+
* Ticket 04).
|
|
5
|
+
*
|
|
6
|
+
* The handler applies parse-level validation only (URL scheme, --extract
|
|
7
|
+
* mode), delegates to `capability.fetch(request)` through shared
|
|
8
|
+
* execution, then projects the normalized `ReaderFetchResult` into the
|
|
9
|
+
* public v1 envelope(s) (content read vs extract read). The Adapter
|
|
10
|
+
* (providers/zai/reader.ts) owns URL rewrite, credentials, transport,
|
|
11
|
+
* raw response parsing, cache identity, and retry/terminal
|
|
12
|
+
* classification; the handler owns projection (`--max-chars` truncation,
|
|
13
|
+
* `--extract` slicing), output-mode presentation, and the
|
|
14
|
+
* schema-version-1 envelope migration.
|
|
15
|
+
*
|
|
16
|
+
* Provider selection, capability support, configuration, Adapter
|
|
17
|
+
* construction, and adapter.reader agreement live in `src/index.ts`.
|
|
18
|
+
*
|
|
19
|
+
* Handler interface (P6-07A pattern): `deps: ReadHandlerDependencies`
|
|
20
|
+
* is REQUIRED — production and direct tests cross the same compile-
|
|
21
|
+
* checked Interface. An optional trailing `CommandContext` follows when
|
|
22
|
+
* a caller wants to surface per-invocation context; the handler does
|
|
23
|
+
* not currently read it. A `CommandContext` is NOT a valid substitute
|
|
24
|
+
* for `deps`.
|
|
25
|
+
*
|
|
26
|
+
* Output-mode behavior (core-flows table):
|
|
27
|
+
*
|
|
28
|
+
* - data: the envelope object (content or extract).
|
|
29
|
+
* - json / pretty: standard `{success, data, timestamp}` envelope.
|
|
30
|
+
* - compact / markdown / refs / tty:
|
|
31
|
+
* * content read → the `content` string directly (presentations).
|
|
32
|
+
* * extract read → JSON fallback (the extract envelope object);
|
|
33
|
+
* no presentation override because extracted items are data,
|
|
34
|
+
* not prose.
|
|
35
|
+
*
|
|
36
|
+
* `--full-envelope` is silently accepted and ignored (D3): the v1
|
|
37
|
+
* envelope is always returned.
|
|
3
38
|
*/
|
|
39
|
+
import type { CommandContext, CommandResult } from "../command-invocation.js";
|
|
40
|
+
import type { ReaderCapability } from "../capabilities/reader.js";
|
|
41
|
+
import type { ExecutionDependencies } from "../lib/execution.js";
|
|
4
42
|
import { type ExtractMode } from "../lib/extract.js";
|
|
5
43
|
export interface ReadOptions {
|
|
6
44
|
format?: "markdown" | "text";
|
|
@@ -12,9 +50,45 @@ export interface ReadOptions {
|
|
|
12
50
|
keepImgDataUrl?: boolean;
|
|
13
51
|
withImagesSummary?: boolean;
|
|
14
52
|
maxChars?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Silently accepted and ignored at v1 (core-flows D3). The envelope
|
|
55
|
+
* is always returned. Retained on the options type so callers and
|
|
56
|
+
* `handleRead` parse it without errors; it never reaches the Adapter
|
|
57
|
+
* request, the cache identity, or the projection.
|
|
58
|
+
*/
|
|
15
59
|
fullEnvelope?: boolean;
|
|
16
60
|
extract?: ExtractMode;
|
|
17
61
|
}
|
|
18
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Dependencies injected by `src/index.ts` after Provider selection,
|
|
64
|
+
* capability support check, configuration check, Adapter construction,
|
|
65
|
+
* and adapter.reader agreement. The handler never resolves a Provider
|
|
66
|
+
* descriptor itself. Required — a caller that omits `deps` is malformed
|
|
67
|
+
* and fails loudly (a `CommandContext` is NOT a valid substitute).
|
|
68
|
+
*/
|
|
69
|
+
export interface ReadHandlerDependencies {
|
|
70
|
+
readonly capability: ReaderCapability;
|
|
71
|
+
readonly execution: ExecutionDependencies;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Read web page content through the injected Reader Capability.
|
|
75
|
+
*
|
|
76
|
+
* Ordering:
|
|
77
|
+
* 1. Parse-level validation (URL scheme, --extract mode). Throws
|
|
78
|
+
* `ValidationError` BEFORE the Adapter or shared execution is
|
|
79
|
+
* reached.
|
|
80
|
+
* 2. Build the Provider-neutral request and delegate to
|
|
81
|
+
* `executeProviderOperation` with shared cache + retry policy.
|
|
82
|
+
* 3. Project the normalized result:
|
|
83
|
+
* - `--extract` slicing into the extract envelope (sets `mode`,
|
|
84
|
+
* `items`, `originalItemCount`); `--max-chars` is IGNORED.
|
|
85
|
+
* - Otherwise, `--max-chars` truncation on `content` (sets
|
|
86
|
+
* `truncated`, `originalContentLength`).
|
|
87
|
+
* 4. Set presentations so text-oriented modes (compact/markdown/
|
|
88
|
+
* refs/tty) emit `content` directly for content reads. Extract
|
|
89
|
+
* reads omit presentations; text modes then fall back to JSON
|
|
90
|
+
* (the extract envelope), matching the core-flows table.
|
|
91
|
+
*/
|
|
92
|
+
export declare function read(url: string, options: ReadOptions | undefined, deps: ReadHandlerDependencies, _context?: CommandContext): Promise<CommandResult>;
|
|
19
93
|
export declare const READ_HELP: string;
|
|
20
94
|
//# sourceMappingURL=read.d.ts.map
|