scoutline 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -5
- package/bin/scoutline.js +36 -15
- package/dist/capabilities/diagnostics.d.ts +97 -0
- package/dist/capabilities/diagnostics.d.ts.map +1 -0
- package/dist/capabilities/diagnostics.js +88 -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/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/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 +58 -3
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +154 -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 +15 -1
- package/dist/commands/read.d.ts.map +1 -1
- package/dist/commands/read.js +53 -54
- package/dist/commands/read.js.map +1 -1
- package/dist/commands/repo.d.ts +8 -3
- package/dist/commands/repo.d.ts.map +1 -1
- package/dist/commands/repo.js +40 -78
- package/dist/commands/repo.js.map +1 -1
- 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 +42 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +389 -207
- package/dist/index.js.map +1 -1
- package/dist/lib/cache.d.ts +61 -0
- package/dist/lib/cache.d.ts.map +1 -1
- package/dist/lib/cache.js +74 -11
- 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 +65 -10
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +135 -19
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/execution.d.ts +76 -0
- package/dist/lib/execution.d.ts.map +1 -0
- package/dist/lib/execution.js +177 -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 +46 -11
- package/dist/lib/mcp-client.d.ts.map +1 -1
- package/dist/lib/mcp-client.js +92 -27
- 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/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 +47 -0
- package/dist/providers/minimax/adapter.d.ts.map +1 -0
- package/dist/providers/minimax/adapter.js +443 -0
- package/dist/providers/minimax/adapter.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 +34 -0
- package/dist/providers/minimax/media.d.ts.map +1 -0
- package/dist/providers/minimax/media.js +92 -0
- package/dist/providers/minimax/media.js.map +1 -0
- package/dist/providers/minimax/quota-client.d.ts +37 -0
- package/dist/providers/minimax/quota-client.d.ts.map +1 -0
- package/dist/providers/minimax/quota-client.js +78 -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 +29 -0
- package/dist/providers/minimax/vision-attestations.d.ts.map +1 -0
- package/dist/providers/minimax/vision-attestations.js +54 -0
- package/dist/providers/minimax/vision-attestations.js.map +1 -0
- package/dist/providers/minimax/vision-conformance.d.ts +184 -0
- package/dist/providers/minimax/vision-conformance.d.ts.map +1 -0
- package/dist/providers/minimax/vision-conformance.js +369 -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 +22 -0
- package/dist/providers/minimax/vision-revisions.d.ts.map +1 -0
- package/dist/providers/minimax/vision-revisions.js +27 -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 +247 -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 +619 -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/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/package.json +10 -5
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command Invocation Seam (DESIGN.md §2).
|
|
3
|
+
*
|
|
4
|
+
* This Module defines the pure invocation contract that separates
|
|
5
|
+
* command behaviour from process effects. `invokeCommand` owns
|
|
6
|
+
* invocation-local presentation, notice storage, and error conversion.
|
|
7
|
+
* The Node Adapter is the only Module that touches process streams,
|
|
8
|
+
* TTY state, and `process.exitCode`.
|
|
9
|
+
*
|
|
10
|
+
* Requirements: NFR-002, NFR-003, NFR-007.
|
|
11
|
+
*/
|
|
12
|
+
import { formatSuccessOutput, formatErrorOutput } from "./lib/output.js";
|
|
13
|
+
import { getErrorExitCode } from "./lib/errors.js";
|
|
14
|
+
import { redactSecrets, configuredSecrets } from "./lib/redact.js";
|
|
15
|
+
const TEXT_OUTPUT_MODES = ["compact", "markdown", "refs", "tty"];
|
|
16
|
+
function isTextOutputMode(mode) {
|
|
17
|
+
return TEXT_OUTPUT_MODES.includes(mode);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Select the final output string for a successful CommandResult.
|
|
21
|
+
*
|
|
22
|
+
* - `TextCommandResult`: the text is used verbatim regardless of mode.
|
|
23
|
+
* - `DataCommandResult` in a text-oriented mode: a command-supplied
|
|
24
|
+
* presentation override is preferred; otherwise the base data is
|
|
25
|
+
* formatted through `formatSuccessOutput`.
|
|
26
|
+
* - `DataCommandResult` in a data-oriented mode: base data formatted
|
|
27
|
+
* through `formatSuccessOutput` (data → raw JSON, json/pretty →
|
|
28
|
+
* success envelope).
|
|
29
|
+
*/
|
|
30
|
+
function selectOutput(result, outputMode, now) {
|
|
31
|
+
if (result.kind === "text") {
|
|
32
|
+
return result.text;
|
|
33
|
+
}
|
|
34
|
+
if (isTextOutputMode(outputMode)) {
|
|
35
|
+
const override = result.presentations?.[outputMode];
|
|
36
|
+
if (typeof override === "string") {
|
|
37
|
+
return override;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return formatSuccessOutput(result.data, outputMode, now);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Run command behaviour through the invocation seam.
|
|
44
|
+
*
|
|
45
|
+
* 1. Create invocation-local context and notice storage.
|
|
46
|
+
* 2. Run command behaviour through `runQuietly`.
|
|
47
|
+
* 3. `runQuietly` restores dependency logging before returning.
|
|
48
|
+
* 4. Flush notices to stderr in encounter order.
|
|
49
|
+
* 5. Select a presentation override or the base data.
|
|
50
|
+
* 6. Write one final successful value to stdout.
|
|
51
|
+
* 7. Convert a thrown error into one structured stderr value.
|
|
52
|
+
* 8. Return an exit status without terminating the process.
|
|
53
|
+
*
|
|
54
|
+
* The trailing newline is appended at the Node Adapter boundary, not
|
|
55
|
+
* here, so `invokeCommand` itself is process-effect-free.
|
|
56
|
+
*/
|
|
57
|
+
export async function invokeCommand(adapter, behavior, outputMode, now = Date.now, secrets) {
|
|
58
|
+
const notices = [];
|
|
59
|
+
const context = {
|
|
60
|
+
stdinIsTTY: adapter.stdinIsTTY,
|
|
61
|
+
readStdin: () => adapter.readStdin(),
|
|
62
|
+
notice: (message) => {
|
|
63
|
+
notices.push(message);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
let result;
|
|
67
|
+
try {
|
|
68
|
+
result = await adapter.runQuietly(() => behavior(context));
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
for (const notice of notices) {
|
|
72
|
+
adapter.writeStderr(notice);
|
|
73
|
+
}
|
|
74
|
+
// Recursively redact the thrown value at the outward boundary so any
|
|
75
|
+
// credential-shaped field embedded in the error tree — whether in
|
|
76
|
+
// `message`, `cause`, or any custom field — is replaced with the
|
|
77
|
+
// redaction marker before formatting. `formatErrorOutput` then
|
|
78
|
+
// performs an additional string-level pass on the message/help
|
|
79
|
+
// fields it actually serialises.
|
|
80
|
+
//
|
|
81
|
+
// B3: secrets resolved from an injected env (MainDependencies.env)
|
|
82
|
+
// are honoured here so a credential that exists only in the injected
|
|
83
|
+
// env is redacted even when absent from ambient process.env.
|
|
84
|
+
const resolvedSecrets = secrets ?? configuredSecrets();
|
|
85
|
+
const redactedError = redactSecrets(error, resolvedSecrets);
|
|
86
|
+
adapter.writeStderr(formatErrorOutput(redactedError, outputMode, resolvedSecrets));
|
|
87
|
+
return getErrorExitCode(error);
|
|
88
|
+
}
|
|
89
|
+
for (const notice of notices) {
|
|
90
|
+
adapter.writeStderr(notice);
|
|
91
|
+
}
|
|
92
|
+
adapter.writeStdout(selectOutput(result, outputMode, now));
|
|
93
|
+
return result.exitCode ?? 0;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=command-invocation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-invocation.js","sourceRoot":"","sources":["../src/command-invocation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAsCnE,MAAM,iBAAiB,GAA8B,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAE5F,SAAS,gBAAgB,CAAC,IAAgB;IACxC,OAAQ,iBAAuC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,YAAY,CAAC,MAAqB,EAAE,UAAsB,EAAE,GAAiB;IACpF,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC3B,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,IAAI,gBAAgB,CAAC,UAAU,CAAC,EAAE,CAAC;QACjC,MAAM,Q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e,CAAY,CAAC;QACvE,OAAO,CAAC,WAAW,CAAC,iBAAiB,CAAC,aAAa,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC;QACnF,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;IAE3D,OAAO,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC;AAC9B,CAAC"}
|
package/dist/commands/code.d.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Code Mode commands for tool chaining
|
|
3
|
+
*
|
|
4
|
+
* P1-07: each command returns a CommandResult instead of writing
|
|
5
|
+
* directly to stdout/stderr. stdin is read through CommandContext rather
|
|
6
|
+
* than the process stream. No Provider selection is added; Phase 0
|
|
7
|
+
* Code Mode semantics (run, eval, logs, timeout, interfaces, prompt
|
|
8
|
+
* template) are preserved.
|
|
3
9
|
*/
|
|
10
|
+
import type { CommandContext, CommandResult } from "../command-invocation.js";
|
|
4
11
|
export interface CodeRunOptions {
|
|
5
12
|
timeout?: number;
|
|
6
13
|
includeLogs?: boolean;
|
|
7
14
|
}
|
|
8
|
-
export declare function runCodeFile(filePath: string, options?: CodeRunOptions): Promise<
|
|
9
|
-
export declare function evalCode(code: string, options?: CodeRunOptions): Promise<
|
|
10
|
-
export declare function printInterfaces(): Promise<
|
|
11
|
-
export declare function printPromptTemplate():
|
|
15
|
+
export declare function runCodeFile(filePath: string, options?: CodeRunOptions, context?: CommandContext): Promise<CommandResult>;
|
|
16
|
+
export declare function evalCode(code: string, options?: CodeRunOptions, context?: CommandContext): Promise<CommandResult>;
|
|
17
|
+
export declare function printInterfaces(context?: CommandContext): Promise<CommandResult>;
|
|
18
|
+
export declare function printPromptTemplate(context?: CommandContext): CommandResult;
|
|
12
19
|
export declare const CODE_HELP: string;
|
|
13
20
|
//# sourceMappingURL=code.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../src/commands/code.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../src/commands/code.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9E,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,cAAmB,EAC5B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,aAAa,CAAC,CAWxB;AAED,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,cAAmB,EAC5B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,aAAa,CAAC,CASxB;AAED,wBAAsB,eAAe,CACnC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,aAAa,CAAC,CAQxB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,aAAa,CAE3E;AAGD,eAAO,MAAM,SAAS,QAkBd,CAAC"}
|
package/dist/commands/code.js
CHANGED
|
@@ -1,75 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Code Mode commands for tool chaining
|
|
3
|
+
*
|
|
4
|
+
* P1-07: each command returns a CommandResult instead of writing
|
|
5
|
+
* directly to stdout/stderr. stdin is read through CommandContext rather
|
|
6
|
+
* than the process stream. No Provider selection is added; Phase 0
|
|
7
|
+
* Code Mode semantics (run, eval, logs, timeout, interfaces, prompt
|
|
8
|
+
* template) are preserved.
|
|
3
9
|
*/
|
|
4
10
|
import * as fs from "node:fs/promises";
|
|
5
11
|
import { ZaiCodeModeClient } from "../lib/code-mode.js";
|
|
6
|
-
|
|
7
|
-
import { formatErrorOutput } from "../lib/errors.js";
|
|
8
|
-
import { silenceConsole, restoreConsole } from "../lib/silence.js";
|
|
9
|
-
export async function runCodeFile(filePath, options = {}) {
|
|
12
|
+
export async function runCodeFile(filePath, options = {}, context) {
|
|
10
13
|
const code = await fs.readFile(filePath, "utf8");
|
|
11
|
-
silenceConsole();
|
|
12
14
|
const codeClient = new ZaiCodeModeClient();
|
|
13
15
|
try {
|
|
14
16
|
const result = await codeClient.callToolChain(code, options.timeout);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
outputSuccess(result.result);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
restoreConsole();
|
|
24
|
-
console.error(formatErrorOutput(error));
|
|
25
|
-
process.exit(1);
|
|
17
|
+
const data = options.includeLogs ? result : result.result;
|
|
18
|
+
return { kind: "data", data };
|
|
26
19
|
}
|
|
27
20
|
finally {
|
|
28
21
|
await codeClient.close().catch(() => { });
|
|
29
|
-
restoreConsole();
|
|
30
22
|
}
|
|
31
23
|
}
|
|
32
|
-
export async function evalCode(code, options = {}) {
|
|
33
|
-
silenceConsole();
|
|
24
|
+
export async function evalCode(code, options = {}, context) {
|
|
34
25
|
const codeClient = new ZaiCodeModeClient();
|
|
35
26
|
try {
|
|
36
27
|
const result = await codeClient.callToolChain(code, options.timeout);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
outputSuccess(result.result);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
restoreConsole();
|
|
46
|
-
console.error(formatErrorOutput(error));
|
|
47
|
-
process.exit(1);
|
|
28
|
+
const data = options.includeLogs ? result : result.result;
|
|
29
|
+
return { kind: "data", data };
|
|
48
30
|
}
|
|
49
31
|
finally {
|
|
50
32
|
await codeClient.close().catch(() => { });
|
|
51
|
-
restoreConsole();
|
|
52
33
|
}
|
|
53
34
|
}
|
|
54
|
-
export async function printInterfaces() {
|
|
55
|
-
silenceConsole();
|
|
35
|
+
export async function printInterfaces(context) {
|
|
56
36
|
const codeClient = new ZaiCodeModeClient();
|
|
57
37
|
try {
|
|
58
38
|
const interfaces = await codeClient.getAllInterfaces();
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
restoreConsole();
|
|
63
|
-
console.error(formatErrorOutput(error));
|
|
64
|
-
process.exit(1);
|
|
39
|
+
return { kind: "data", data: interfaces };
|
|
65
40
|
}
|
|
66
41
|
finally {
|
|
67
42
|
await codeClient.close().catch(() => { });
|
|
68
|
-
restoreConsole();
|
|
69
43
|
}
|
|
70
44
|
}
|
|
71
|
-
export function printPromptTemplate() {
|
|
72
|
-
|
|
45
|
+
export function printPromptTemplate(context) {
|
|
46
|
+
return { kind: "data", data: ZaiCodeModeClient.getPromptTemplate() };
|
|
73
47
|
}
|
|
74
48
|
// Help text
|
|
75
49
|
export const CODE_HELP = `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.js","sourceRoot":"","sources":["../../src/commands/code.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"code.js","sourceRoot":"","sources":["../../src/commands/code.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAQxD,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,QAAgB,EAChB,OAAO,GAAmB,EAAE,EAC5B,OAAwB;IAExB,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,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AAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAC5C,CAAC;YAAS,CAAC;QACT,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,OAAwB;IAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,CAAC,iBAAiB,EAAE,EAAE,CAAC;AACvE,CAAC;AAED,YAAY;AACZ,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;CAkBxB,CAAC,IAAI,EAAE,CAAC"}
|
|
@@ -1,10 +1,65 @@
|
|
|
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
|
*/
|
|
20
|
+
import type { CommandResult } from "../command-invocation.js";
|
|
21
|
+
import type { DiagnosticsReport } from "../capabilities/diagnostics.js";
|
|
22
|
+
import type { ProviderDescriptor, ProviderId } from "../providers/types.js";
|
|
23
|
+
export interface DoctorDiagnosticsDependencies {
|
|
24
|
+
readonly noTools: boolean;
|
|
25
|
+
readonly effectiveProvider: ProviderId;
|
|
26
|
+
readonly descriptors: readonly ProviderDescriptor[];
|
|
27
|
+
readonly env: NodeJS.ProcessEnv;
|
|
28
|
+
readonly sleep: (ms: number) => Promise<void>;
|
|
29
|
+
readonly random: () => number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Build a schema-version-1 {@link DiagnosticsReport}. Report metadata is
|
|
33
|
+
* built from static descriptors without constructing any Adapter. Under
|
|
34
|
+
* `--no-tools` the command returns after metadata + configured-state
|
|
35
|
+
* evaluation. Otherwise each configured Provider is probed through
|
|
36
|
+
* shared execution with settled collection, preserving registry order
|
|
37
|
+
* and normalized redacted failures.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildDiagnosticsReport(deps: DoctorDiagnosticsDependencies): Promise<DiagnosticsReport>;
|
|
40
|
+
/**
|
|
41
|
+
* Compute the doctor exit code from a finalized report. Exit 1 when the
|
|
42
|
+
* effective Provider is unconfigured or any configured probe errored;
|
|
43
|
+
* otherwise exit 0. A tools-disabled or not-configured skip on a
|
|
44
|
+
* non-effective Provider never fails the report.
|
|
45
|
+
*/
|
|
46
|
+
export declare function doctorExitCode(report: DiagnosticsReport): number;
|
|
4
47
|
export interface DoctorOptions {
|
|
5
48
|
noTools?: boolean;
|
|
6
|
-
enableVision?: boolean;
|
|
7
49
|
}
|
|
8
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Injectable dependencies for the doctor command. `buildReport` resolves
|
|
52
|
+
* the diagnostics report; the command only wraps it for presentation and
|
|
53
|
+
* exit-code selection.
|
|
54
|
+
*/
|
|
55
|
+
export interface DoctorCommandDependencies {
|
|
56
|
+
readonly buildReport: () => Promise<DiagnosticsReport>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Run the doctor command. Returns the diagnostics report as base data
|
|
60
|
+
* with a computed exit code (1 when the effective Provider is
|
|
61
|
+
* unconfigured or any configured probe failed; otherwise 0).
|
|
62
|
+
*/
|
|
63
|
+
export declare function doctor(deps: DoctorCommandDependencies): Promise<CommandResult<DiagnosticsReport>>;
|
|
9
64
|
export declare const DOCTOR_HELP: string;
|
|
10
65
|
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAEV,iBAAiB,EAElB,MAAM,gCAAgC,CAAC;AASxC,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAsB,MAAM,uBAAuB,CAAC;AAMhG,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,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;AA6CD;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,6BAA6B,GAClC,OAAO,CAAC,iBAAiB,CAAC,CA4B5B;AA4CD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAKhE;AAMD,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,WAAW,EAAE,MAAM,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACxD;AAED;;;;GAIG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAO3C;AAED,eAAO,MAAM,WAAW,QAqChB,CAAC"}
|
package/dist/commands/doctor.js
CHANGED
|
@@ -1,70 +1,172 @@
|
|
|
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 { SHARED_CAPABILITIES, ZAI_ONLY_CAPABILITIES, 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}. Report metadata is
|
|
47
|
+
* built from static descriptors without constructing any Adapter. Under
|
|
48
|
+
* `--no-tools` the command returns after metadata + configured-state
|
|
49
|
+
* evaluation. Otherwise each configured Provider is probed through
|
|
50
|
+
* shared execution with settled collection, preserving registry order
|
|
51
|
+
* and normalized redacted failures.
|
|
52
|
+
*/
|
|
53
|
+
export async function buildDiagnosticsReport(deps) {
|
|
54
|
+
const secrets = configuredSecrets(deps.env);
|
|
55
|
+
const baseEntries = deps.descriptors.map((descriptor) => ({
|
|
56
|
+
provider: descriptor.id,
|
|
57
|
+
configured: descriptor.isConfigured(deps.env),
|
|
58
|
+
capabilities: [...descriptor.capabilities()],
|
|
59
|
+
}));
|
|
60
|
+
const providers = deps.noTools
|
|
61
|
+
? baseEntries.map((entry) => ({
|
|
62
|
+
...entry,
|
|
63
|
+
status: "skipped",
|
|
64
|
+
reason: entry.configured ? "tools-disabled" : "not-configured",
|
|
65
|
+
}))
|
|
66
|
+
: await probeEntries(baseEntries, deps, secrets);
|
|
67
|
+
return {
|
|
68
|
+
schemaVersion: 1,
|
|
69
|
+
effectiveProvider: deps.effectiveProvider,
|
|
70
|
+
sharedCapabilities: SHARED_CAPABILITIES,
|
|
71
|
+
zaiOnlyCapabilities: ZAI_ONLY_CAPABILITIES,
|
|
22
72
|
node: {
|
|
23
|
-
version: process.
|
|
24
|
-
visionMcpCompatible: nodeMajor >= 22,
|
|
73
|
+
version: process.version,
|
|
74
|
+
visionMcpCompatible: nodeMajor() >= 22,
|
|
25
75
|
},
|
|
76
|
+
providers,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Probe every configured Provider in registry order using settled
|
|
81
|
+
* collection. Unconfigured entries are skipped (not-configured) and do
|
|
82
|
+
* NOT fail the report. A configured probe failure is normalized and
|
|
83
|
+
* recursively redacted before joining the report; successful entries
|
|
84
|
+
* are preserved alongside it.
|
|
85
|
+
*/
|
|
86
|
+
async function probeEntries(baseEntries, deps, secrets) {
|
|
87
|
+
const configuredIndexes = baseEntries
|
|
88
|
+
.map((entry, index) => (entry.configured ? index : -1))
|
|
89
|
+
.filter((index) => index >= 0);
|
|
90
|
+
const settled = await Promise.allSettled(configuredIndexes.map((index) => probeProvider(deps.descriptors[index], deps.env, deps.sleep, deps.random)));
|
|
91
|
+
let settledCursor = 0;
|
|
92
|
+
return baseEntries.map((entry) => {
|
|
93
|
+
if (!entry.configured) {
|
|
94
|
+
return { ...entry, status: "skipped", reason: "not-configured" };
|
|
95
|
+
}
|
|
96
|
+
const result = settled[settledCursor++];
|
|
97
|
+
if (result.status === "fulfilled") {
|
|
98
|
+
return { ...entry, status: "ok" };
|
|
99
|
+
}
|
|
100
|
+
const redacted = redactSecrets(diagnosticErrorFromError(result.reason), secrets);
|
|
101
|
+
return { ...entry, status: "error", error: redacted };
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
// Exit code
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
/**
|
|
108
|
+
* Compute the doctor exit code from a finalized report. Exit 1 when the
|
|
109
|
+
* effective Provider is unconfigured or any configured probe errored;
|
|
110
|
+
* otherwise exit 0. A tools-disabled or not-configured skip on a
|
|
111
|
+
* non-effective Provider never fails the report.
|
|
112
|
+
*/
|
|
113
|
+
export function doctorExitCode(report) {
|
|
114
|
+
const effective = report.providers.find((p) => p.provider === report.effectiveProvider);
|
|
115
|
+
if (!effective || !effective.configured)
|
|
116
|
+
return 1;
|
|
117
|
+
if (report.providers.some((p) => p.status === "error"))
|
|
118
|
+
return 1;
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Run the doctor command. Returns the diagnostics report as base data
|
|
123
|
+
* with a computed exit code (1 when the effective Provider is
|
|
124
|
+
* unconfigured or any configured probe failed; otherwise 0).
|
|
125
|
+
*/
|
|
126
|
+
export async function doctor(deps) {
|
|
127
|
+
const report = await deps.buildReport();
|
|
128
|
+
return {
|
|
129
|
+
kind: "data",
|
|
130
|
+
data: report,
|
|
131
|
+
exitCode: doctorExitCode(report),
|
|
26
132
|
};
|
|
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
133
|
}
|
|
57
134
|
export const DOCTOR_HELP = `
|
|
58
|
-
Doctor -
|
|
135
|
+
Doctor - Provider-aware environment and connectivity diagnostics
|
|
59
136
|
|
|
60
137
|
Usage: scoutline doctor [options]
|
|
61
138
|
|
|
139
|
+
Reports a schema-version-1 diagnostics report listing every built-in
|
|
140
|
+
Provider (zai, minimax) with its configured state, declared
|
|
141
|
+
Capabilities, and connectivity status. The effective Provider (resolved
|
|
142
|
+
from --provider, SCOUTLINE_PROVIDER, or the default zai) is the
|
|
143
|
+
Provider that serves the shared Capabilities:
|
|
144
|
+
|
|
145
|
+
search, vision.interpret-image, quota, diagnostics
|
|
146
|
+
|
|
147
|
+
Z.AI connectivity is probed through MCP tool discovery; MiniMax
|
|
148
|
+
connectivity through a single raw quota probe that authenticates
|
|
149
|
+
without a generative request.
|
|
150
|
+
|
|
151
|
+
The following Capabilities are Z.AI-only in the base release and are
|
|
152
|
+
not selected by the effective Provider for other families:
|
|
153
|
+
reader, repository-exploration, raw-provider-tools, code-mode,
|
|
154
|
+
image-diff, video-analysis
|
|
155
|
+
|
|
62
156
|
Options:
|
|
63
|
-
--no-tools Skip
|
|
64
|
-
|
|
157
|
+
--no-tools Skip every connectivity probe (metadata-only). Under
|
|
158
|
+
--no-tools no Provider transport is constructed: a
|
|
159
|
+
configured Provider is reported as skipped
|
|
160
|
+
(tools-disabled) and does not fail the report.
|
|
161
|
+
|
|
162
|
+
Exit codes:
|
|
163
|
+
0 All configured probes succeeded (or only tools-disabled skips).
|
|
164
|
+
1 The effective Provider is unconfigured or any configured probe
|
|
165
|
+
failed; successful entries are still reported.
|
|
65
166
|
|
|
66
167
|
Examples:
|
|
67
|
-
scoutline doctor
|
|
68
|
-
scoutline doctor --
|
|
168
|
+
scoutline doctor # full diagnostics
|
|
169
|
+
scoutline doctor --provider minimax
|
|
170
|
+
scoutline doctor --no-tools # metadata only, no transport
|
|
69
171
|
`.trim();
|
|
70
172
|
//# 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":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAQH,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AA+BpE,SAAS,SAAS;IAChB,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjD,OAAO,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,aAAa,CAC1B,UAA8B,EAC9B,GAAsB,EACtB,KAAoC,EACpC,MAAoB;IAEpB,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,GAA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
|
+
*
|
|
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"}
|