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
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
- **Repo** - Search and read GitHub repository code via ZRead
|
|
22
22
|
- **Tools** - MCP tool discovery, schemas, and raw calls
|
|
23
23
|
- **Code Mode** - TypeScript tool chaining for agent automation
|
|
24
|
+
- **Provider selection** - Run shared capabilities through Z.AI or MiniMax Token Plan
|
|
24
25
|
|
|
25
26
|
## Quick Start
|
|
26
27
|
|
|
@@ -32,7 +33,14 @@ npx scoutline vision analyze ./screenshot.png "What errors do you see?"
|
|
|
32
33
|
npx scoutline search "React 19 new features" --count 5
|
|
33
34
|
```
|
|
34
35
|
|
|
35
|
-
Get your API key at: https://z.ai/manage-apikey/apikey-list
|
|
36
|
+
Get your Z.AI API key at: https://z.ai/manage-apikey/apikey-list
|
|
37
|
+
|
|
38
|
+
To use MiniMax instead:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
export MINIMAX_API_KEY="your-minimax-key"
|
|
42
|
+
npx scoutline --provider minimax search "latest LLM benchmarks"
|
|
43
|
+
```
|
|
36
44
|
|
|
37
45
|
## Installation
|
|
38
46
|
|
|
@@ -63,6 +71,125 @@ Or use directly with npx:
|
|
|
63
71
|
npx scoutline --help
|
|
64
72
|
```
|
|
65
73
|
|
|
74
|
+
## Provider Selection
|
|
75
|
+
|
|
76
|
+
Shared commands (`search`, `vision`, `quota`, `doctor`) accept a global
|
|
77
|
+
`--provider <zai|minimax>` flag. Resolution precedence:
|
|
78
|
+
|
|
79
|
+
1. Explicit `--provider <zai|minimax>` on the command line
|
|
80
|
+
2. `SCOUTLINE_PROVIDER` environment variable
|
|
81
|
+
3. Compatibility default `zai`
|
|
82
|
+
|
|
83
|
+
Examples:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# 1. Flag wins over everything
|
|
87
|
+
scoutline --provider minimax search "React 19 features"
|
|
88
|
+
|
|
89
|
+
# 2. Environment variable when no flag is supplied
|
|
90
|
+
export SCOUTLINE_PROVIDER=minimax
|
|
91
|
+
scoutline quota
|
|
92
|
+
|
|
93
|
+
# 3. Default Z.AI when nothing is supplied
|
|
94
|
+
scoutline search "TypeScript best practices"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Provider selection is **never** inferred from which credentials are present;
|
|
98
|
+
empty credentials leave the Provider unconfigured and shared capabilities will
|
|
99
|
+
fail with `AUTH_ERROR` or `CONFIGURATION_ERROR`. Unknown Provider IDs fail
|
|
100
|
+
fast with `VALIDATION_ERROR`.
|
|
101
|
+
|
|
102
|
+
`scoutline read`, `scoutline repo`, `scoutline tools`, `scoutline tool`,
|
|
103
|
+
`scoutline call`, and `scoutline code` accept the flag but ignore it; they
|
|
104
|
+
remain Z.AI-only in the base release.
|
|
105
|
+
|
|
106
|
+
## Capability Matrix
|
|
107
|
+
|
|
108
|
+
| Capability | Z.AI | MiniMax | Notes |
|
|
109
|
+
| --- | --- | --- | --- |
|
|
110
|
+
| `search` | Yes | Yes | MiniMax rejects domain/recency/content-size/location controls |
|
|
111
|
+
| `vision.interpret-image` (analyze) | Yes | Yes | Provider-specific media limits; uncached |
|
|
112
|
+
| `vision.ui-artifact` (ui-to-code) | Yes | Available | Live-attested; conformance-gated |
|
|
113
|
+
| `vision.extract-text` | Yes | Pending | Implemented, pending live conformance |
|
|
114
|
+
| `vision.diagnose-error` | Yes | Available | Live-attested; conformance-gated |
|
|
115
|
+
| `vision.diagram` | Yes | Pending | Implemented, pending live conformance |
|
|
116
|
+
| `vision.chart` | Yes | Pending | Implemented, pending live conformance |
|
|
117
|
+
| `vision.diff` (image diff) | Yes | No | Base-release Z.AI-only |
|
|
118
|
+
| `vision.video` | Yes | No | Base-release Z.AI-only |
|
|
119
|
+
| `quota` | Yes | Yes | Normalized `QuotaDashboard` (ADR-0001) |
|
|
120
|
+
| `diagnostics` (`doctor`) | Yes | Yes | Lists both Providers; probes configured |
|
|
121
|
+
| `read` (Reader) | Yes | No | Base-release Z.AI-only |
|
|
122
|
+
| `repo` (Repository exploration) | Yes | No | Base-release Z.AI-only |
|
|
123
|
+
| `tools`, `tool`, `call` (Raw tools) | Yes | No | Base-release Z.AI-only |
|
|
124
|
+
| `code` (Code Mode) | Yes | No | Base-release Z.AI-only |
|
|
125
|
+
|
|
126
|
+
Media limits for general single-image interpretation:
|
|
127
|
+
|
|
128
|
+
| Provider | Formats | Maximum |
|
|
129
|
+
| --- | --- | --- |
|
|
130
|
+
| Z.AI | JPG, JPEG, PNG | 5 MiB |
|
|
131
|
+
| MiniMax | JPG, JPEG, PNG, WebP | 50 MiB |
|
|
132
|
+
|
|
133
|
+
Vision results are never written to the local response cache.
|
|
134
|
+
|
|
135
|
+
### Specialized MiniMax Vision Mappings
|
|
136
|
+
|
|
137
|
+
The five specialized MiniMax Vision operations (`ui-artifact`,
|
|
138
|
+
`extract-text`, `diagnose-error`, `diagram`, `chart`) are **implemented**
|
|
139
|
+
in this release. Each operation has a dedicated prompt-composition Module
|
|
140
|
+
under `packages/scoutline/src/providers/minimax/vision-mappings/` and a
|
|
141
|
+
generated mapping revision committed to source.
|
|
142
|
+
|
|
143
|
+
Runtime support for these operations is gated by the compiled conformance
|
|
144
|
+
registry (`src/providers/minimax/vision-conformance.ts`). A specialized
|
|
145
|
+
operation is only routable through MiniMax when **every** condition holds:
|
|
146
|
+
|
|
147
|
+
- offline conformance state is `pass`,
|
|
148
|
+
- live conformance state is `pass`,
|
|
149
|
+
- a sanitized compiled attestation matches the operation, fixture version,
|
|
150
|
+
Implementation identity, and generated mapping revision.
|
|
151
|
+
|
|
152
|
+
In the current release, `ui-artifact` and `diagnose-error` have offline
|
|
153
|
+
`pass`, live `pass`, and compiled attestations — they are **supported at
|
|
154
|
+
runtime** through MiniMax. The remaining three operations (`extract-text`,
|
|
155
|
+
`diagram`, `chart`) have offline `pass` and live `pending`; they are
|
|
156
|
+
**unsupported at runtime** and surface `UNSUPPORTED_CAPABILITY`. The CLI
|
|
157
|
+
falls back to Z.AI (the Z.AI Provider supports every operation in the
|
|
158
|
+
base release).
|
|
159
|
+
|
|
160
|
+
No environment variable, flag, or configuration value can promote a
|
|
161
|
+
mapping to supported. Support is driven exclusively by the compiled
|
|
162
|
+
registry state.
|
|
163
|
+
|
|
164
|
+
#### Enabling live support
|
|
165
|
+
|
|
166
|
+
Live support is gated on a per-operation live attestation. The
|
|
167
|
+
attestation script requires explicit opt-in and `MINIMAX_API_KEY`:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
SCOUTLINE_LIVE_TESTS=1 node scripts/attest-minimax-vision.mjs --operation chart
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Replace `chart` with `ui-artifact`, `extract-text`, `diagnose-error`,
|
|
174
|
+
or `diagram`. The script runs one fixture against the live Provider,
|
|
175
|
+
evaluates the semantic assertions in memory, and either:
|
|
176
|
+
|
|
177
|
+
- writes a sanitized attestation entry to
|
|
178
|
+
`src/providers/minimax/vision-attestations.ts`, flips the registry's
|
|
179
|
+
`live` state to `pass`, and verifies runtime support becomes `true`;
|
|
180
|
+
OR
|
|
181
|
+
- sets the registry's `live` state to `fail` if the semantics do not
|
|
182
|
+
hold. No success attestation is written and the mapping remains
|
|
183
|
+
unsupported.
|
|
184
|
+
|
|
185
|
+
The next `npm run build` recompiles the registry with the new
|
|
186
|
+
attestation and the operation becomes routable through MiniMax.
|
|
187
|
+
|
|
188
|
+
Help text, `doctor`, and the Adapter's descriptor metadata all derive
|
|
189
|
+
from the same registry, so once a mapping is promoted it appears on
|
|
190
|
+
every runtime surface automatically — there is no second support list
|
|
191
|
+
to update.
|
|
192
|
+
|
|
66
193
|
## Usage
|
|
67
194
|
|
|
68
195
|
The CLI is self-documenting. Use `--help` at any level:
|
|
@@ -72,11 +199,17 @@ scoutline --help # All commands
|
|
|
72
199
|
scoutline vision --help # Vision commands
|
|
73
200
|
scoutline search --help # Search options
|
|
74
201
|
scoutline repo --help # GitHub repo commands
|
|
202
|
+
scoutline doctor --help # Provider diagnostics
|
|
203
|
+
scoutline quota --help # Plan usage
|
|
75
204
|
```
|
|
76
205
|
|
|
77
206
|
### Examples
|
|
78
207
|
|
|
79
208
|
```bash
|
|
209
|
+
# Provider selection
|
|
210
|
+
scoutline --provider minimax search "AI policy news"
|
|
211
|
+
scoutline --provider zai search "internal docs"
|
|
212
|
+
|
|
80
213
|
# Vision - analyze images
|
|
81
214
|
scoutline vision analyze ./image.png "Describe this"
|
|
82
215
|
scoutline vision ui-to-code ./design.png --output code
|
|
@@ -98,9 +231,14 @@ scoutline repo read anthropics/anthropic-sdk-python README.md
|
|
|
98
231
|
scoutline repo search openai/codex "config" --language en
|
|
99
232
|
scoutline repo tree openai/codex --path codex-rs --depth 2
|
|
100
233
|
|
|
234
|
+
# Quota - effective or all providers
|
|
235
|
+
scoutline quota # effective Provider
|
|
236
|
+
scoutline quota --all-providers # every configured Provider
|
|
237
|
+
|
|
101
238
|
# Doctor - check setup
|
|
102
|
-
scoutline doctor
|
|
103
|
-
scoutline doctor --no-
|
|
239
|
+
scoutline doctor # full diagnostics
|
|
240
|
+
scoutline doctor --no-tools # metadata only, no transport
|
|
241
|
+
scoutline doctor --provider minimax # MiniMax connectivity
|
|
104
242
|
```
|
|
105
243
|
|
|
106
244
|
## Output Format
|
|
@@ -115,14 +253,41 @@ Default output is **data-only** for token efficiency. Use `--output-format json`
|
|
|
115
253
|
}
|
|
116
254
|
```
|
|
117
255
|
|
|
256
|
+
Quota output is a schema-version-1 `QuotaDashboard`:
|
|
257
|
+
|
|
258
|
+
```json
|
|
259
|
+
{
|
|
260
|
+
"schemaVersion": 1,
|
|
261
|
+
"effectiveProvider": "zai",
|
|
262
|
+
"providers": [
|
|
263
|
+
{
|
|
264
|
+
"provider": "zai",
|
|
265
|
+
"status": "ok",
|
|
266
|
+
"categories": [
|
|
267
|
+
{ "name": "requests", "unit": "requests", "current": { "remainingPercent": 87.5 } },
|
|
268
|
+
{ "name": "tokens", "unit": "tokens", "current": { "remainingPercent": 64.2 } }
|
|
269
|
+
]
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Doctor output is a schema-version-1 `DiagnosticsReport` listing every built-in
|
|
276
|
+
Provider with its configured state, declared capabilities, and probe status.
|
|
277
|
+
|
|
118
278
|
## Notes
|
|
119
279
|
|
|
120
280
|
- `repo search` defaults to English results. Use `--language zh` for Chinese.
|
|
121
281
|
- `repo tree` supports `--path` (directory scope) and `--depth` (expand subtrees).
|
|
122
|
-
- `
|
|
282
|
+
- `quota --all-providers` exits 1 if any configured Provider fails; successful
|
|
283
|
+
entries are still reported.
|
|
284
|
+
- `doctor` exits 1 when the effective Provider is unconfigured or any
|
|
285
|
+
configured probe fails; successful entries are still reported.
|
|
123
286
|
- `read` supports `--with-images-summary`, `--no-gfm`, and `--keep-img-data-url` for richer parsing control.
|
|
124
287
|
- Vision tool calls automatically retry transient 5xx/network errors (default: 2 retries). Configure with `ZAI_MCP_VISION_RETRY_COUNT` (or `ZAI_MCP_RETRY_COUNT` for all tools).
|
|
125
288
|
- Tool discovery can be cached to speed `tools`/`tool`/`doctor` (default: on, 24h TTL). Configure with `ZAI_MCP_TOOL_CACHE`, `ZAI_MCP_TOOL_CACHE_TTL_MS`, `ZAI_MCP_CACHE_DIR`.
|
|
289
|
+
- The response cache uses provider-partitioned keys; legacy `zai-cli` cache
|
|
290
|
+
entries remain readable for Z.AI but are never migrated.
|
|
126
291
|
|
|
127
292
|
## Contributing
|
|
128
293
|
|
|
@@ -143,4 +308,4 @@ MIT - see [LICENSE](https://github.com/vikasagarwal101/scoutline/blob/main/LICEN
|
|
|
143
308
|
## Links
|
|
144
309
|
|
|
145
310
|
- [GitHub Repository](https://github.com/vikasagarwal101/scoutline)
|
|
146
|
-
- [Documentation](https://github.com/vikasagarwal101/scoutline/tree/main/docs)
|
|
311
|
+
- [Documentation](https://github.com/vikasagarwal101/scoutline/tree/main/docs)
|
package/bin/scoutline.js
CHANGED
|
@@ -1,17 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import("../dist/index.js")
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
import("../dist/index.js")
|
|
4
|
+
.then(async ({ main }) => {
|
|
5
|
+
const { createNodeCommandInvocationAdapter } =
|
|
6
|
+
await import("../dist/node-command-invocation-adapter.js");
|
|
7
|
+
const adapter = createNodeCommandInvocationAdapter();
|
|
8
|
+
const status = await main(process.argv.slice(2), {
|
|
9
|
+
invocation: adapter,
|
|
10
|
+
env: process.env,
|
|
11
|
+
});
|
|
12
|
+
adapter.setExitCode(status);
|
|
13
|
+
})
|
|
14
|
+
.catch(async (err) => {
|
|
15
|
+
try {
|
|
16
|
+
const { formatLoadFailure } = await import(
|
|
17
|
+
"../dist/node-command-invocation-adapter.js"
|
|
18
|
+
);
|
|
19
|
+
console.error(formatLoadFailure(err));
|
|
20
|
+
} catch {
|
|
21
|
+
// If the dist module is unavailable for any reason, fall back to a
|
|
22
|
+
// best-effort envelope. We do not let a missing helper hide the
|
|
23
|
+
// original load error from the user.
|
|
24
|
+
console.error(
|
|
25
|
+
JSON.stringify(
|
|
26
|
+
{
|
|
27
|
+
success: false,
|
|
28
|
+
error: err && err.message ? err.message : String(err),
|
|
29
|
+
code: "LOAD_ERROR",
|
|
30
|
+
help: 'Make sure to run "npm run build" before running scoutline',
|
|
31
|
+
},
|
|
32
|
+
null,
|
|
33
|
+
2,
|
|
34
|
+
),
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
process.exit(1);
|
|
38
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diagnostics Capability Contract (DESIGN.md §14, P4-04).
|
|
3
|
+
*
|
|
4
|
+
* Defines the schema-version-1 diagnostics report every `doctor`
|
|
5
|
+
* invocation returns, plus the capability contract each Provider
|
|
6
|
+
* Adapter implements so its connectivity can be probed without a
|
|
7
|
+
* generative request.
|
|
8
|
+
*
|
|
9
|
+
* The report is built by the doctor command from static descriptor
|
|
10
|
+
* metadata plus the success/failure of each configured Provider probe.
|
|
11
|
+
* Each Adapter performs exactly ONE connectivity attempt; shared
|
|
12
|
+
* execution owns the retry policy.
|
|
13
|
+
*
|
|
14
|
+
* Boundary rules (ARCHITECTURE.md §2):
|
|
15
|
+
* - Imports Provider identity types, shared errors, the Vision
|
|
16
|
+
* operation→capability mapping, and the MiniMax specialized Vision
|
|
17
|
+
* conformance registry metadata (a pure snapshot, no transport).
|
|
18
|
+
* - Imports no Provider transport, no Provider Adapter, no command
|
|
19
|
+
* presentation.
|
|
20
|
+
*
|
|
21
|
+
* Normalization rules (DESIGN.md §14):
|
|
22
|
+
* - Z.AI connectivity uses tool discovery (list tools from UTCP).
|
|
23
|
+
* - MiniMax connectivity uses a raw single-attempt quota probe
|
|
24
|
+
* (Adapter-local quota client), NOT `QuotaCapability.invoke()`,
|
|
25
|
+
* because it authenticates without a generative request.
|
|
26
|
+
* - For the base release `sharedCapabilities` is Search, general
|
|
27
|
+
* single-image interpretation, quota, and diagnostics.
|
|
28
|
+
* - `zaiOnlyCapabilities` is Reader, repository exploration, raw
|
|
29
|
+
* provider tools, Code Mode, image diff, and video analysis.
|
|
30
|
+
*/
|
|
31
|
+
import type { ProviderCapability, ProviderId } from "../providers/types.js";
|
|
32
|
+
import { type ScoutlineErrorCode } from "../lib/errors.js";
|
|
33
|
+
export interface DiagnosticOptions {
|
|
34
|
+
readonly probe: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface ProviderDiagnostic {
|
|
37
|
+
readonly provider: ProviderId;
|
|
38
|
+
readonly configured: boolean;
|
|
39
|
+
readonly capabilities: readonly ProviderCapability[];
|
|
40
|
+
readonly status: "ok" | "error" | "skipped";
|
|
41
|
+
readonly reason?: "not-configured" | "tools-disabled";
|
|
42
|
+
readonly error?: {
|
|
43
|
+
code: ScoutlineErrorCode;
|
|
44
|
+
message: string;
|
|
45
|
+
help?: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export interface DiagnosticsReport {
|
|
49
|
+
readonly schemaVersion: 1;
|
|
50
|
+
readonly effectiveProvider: ProviderId;
|
|
51
|
+
readonly sharedCapabilities: readonly ProviderCapability[];
|
|
52
|
+
readonly zaiOnlyCapabilities: readonly string[];
|
|
53
|
+
readonly node: {
|
|
54
|
+
readonly version: string;
|
|
55
|
+
readonly visionMcpCompatible: boolean;
|
|
56
|
+
};
|
|
57
|
+
readonly providers: readonly ProviderDiagnostic[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Capability each Provider Adapter implements for connectivity
|
|
61
|
+
* diagnostics. `invoke` resolves on a successful single connectivity
|
|
62
|
+
* attempt and throws a normalized {@link ScoutlineError} on failure;
|
|
63
|
+
* the doctor command catches the throw and records a redacted error
|
|
64
|
+
* entry. Returning `void` keeps the report builder the single owner of
|
|
65
|
+
* report shape.
|
|
66
|
+
*/
|
|
67
|
+
export interface DiagnosticsCapability {
|
|
68
|
+
invoke(options: DiagnosticOptions): Promise<void>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Capabilities supported by every Provider in the base release (DESIGN.md
|
|
72
|
+
* §14, §15). The four base capabilities are static; specialized Vision
|
|
73
|
+
* operations move into shared metadata only when their compiled
|
|
74
|
+
* conformance registry entry is supported. At P5-02 every specialized
|
|
75
|
+
* entry is pending, so this list reduces to the base four. P5-03's
|
|
76
|
+
* attested mappings automatically extend this list through the single
|
|
77
|
+
* registry query — there is no parallel support list to maintain.
|
|
78
|
+
*/
|
|
79
|
+
export declare const SHARED_CAPABILITIES: readonly ProviderCapability[];
|
|
80
|
+
/**
|
|
81
|
+
* Capabilities that remain Z.AI-only in the base release (DESIGN.md §14),
|
|
82
|
+
* in the documented order: Reader, repository exploration, raw provider
|
|
83
|
+
* tools, Code Mode, image diff, and video analysis.
|
|
84
|
+
*/
|
|
85
|
+
export declare const ZAI_ONLY_CAPABILITIES: readonly string[];
|
|
86
|
+
/**
|
|
87
|
+
* Map a thrown error into a normalized diagnostic error entry. The
|
|
88
|
+
* caller is responsible for recursive redaction before the entry
|
|
89
|
+
* crosses an outward boundary (the doctor command does this in
|
|
90
|
+
* {@link buildDiagnosticsReport}).
|
|
91
|
+
*/
|
|
92
|
+
export declare function diagnosticErrorFromError(error: unknown): {
|
|
93
|
+
code: ScoutlineErrorCode;
|
|
94
|
+
message: string;
|
|
95
|
+
help?: string;
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/capabilities/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAQ3E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACrD,QAAQ,CAAC,MAAM,EAAE,IAAI,GAAG,OAAO,GAAG,SAAS,CAAC;IAC5C,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,CAAC;IACtD,QAAQ,CAAC,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,kBAAkB,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/E;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;IAC1B,QAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC;IACvC,QAAQ,CAAC,kBAAkB,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAC3D,QAAQ,CAAC,mBAAmB,EAAE,SAAS,MAAM,EAAE,CAAC;IAChD,QAAQ,CAAC,IAAI,EAAE;QACb,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;KACvC,CAAC;IACF,QAAQ,CAAC,SAAS,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACnD;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD;AAMD;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,kBAAkB,EAA8B,CAAC;AAU5F;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAOlD,CAAC;AAMF;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG;IACxD,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAYA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diagnostics Capability Contract (DESIGN.md §14, P4-04).
|
|
3
|
+
*
|
|
4
|
+
* Defines the schema-version-1 diagnostics report every `doctor`
|
|
5
|
+
* invocation returns, plus the capability contract each Provider
|
|
6
|
+
* Adapter implements so its connectivity can be probed without a
|
|
7
|
+
* generative request.
|
|
8
|
+
*
|
|
9
|
+
* The report is built by the doctor command from static descriptor
|
|
10
|
+
* metadata plus the success/failure of each configured Provider probe.
|
|
11
|
+
* Each Adapter performs exactly ONE connectivity attempt; shared
|
|
12
|
+
* execution owns the retry policy.
|
|
13
|
+
*
|
|
14
|
+
* Boundary rules (ARCHITECTURE.md §2):
|
|
15
|
+
* - Imports Provider identity types, shared errors, the Vision
|
|
16
|
+
* operation→capability mapping, and the MiniMax specialized Vision
|
|
17
|
+
* conformance registry metadata (a pure snapshot, no transport).
|
|
18
|
+
* - Imports no Provider transport, no Provider Adapter, no command
|
|
19
|
+
* presentation.
|
|
20
|
+
*
|
|
21
|
+
* Normalization rules (DESIGN.md §14):
|
|
22
|
+
* - Z.AI connectivity uses tool discovery (list tools from UTCP).
|
|
23
|
+
* - MiniMax connectivity uses a raw single-attempt quota probe
|
|
24
|
+
* (Adapter-local quota client), NOT `QuotaCapability.invoke()`,
|
|
25
|
+
* because it authenticates without a generative request.
|
|
26
|
+
* - For the base release `sharedCapabilities` is Search, general
|
|
27
|
+
* single-image interpretation, quota, and diagnostics.
|
|
28
|
+
* - `zaiOnlyCapabilities` is Reader, repository exploration, raw
|
|
29
|
+
* provider tools, Code Mode, image diff, and video analysis.
|
|
30
|
+
*/
|
|
31
|
+
import { ScoutlineError } from "../lib/errors.js";
|
|
32
|
+
import { visionOperationToCapability } from "./vision.js";
|
|
33
|
+
import { listSupportedMiniMaxVisionOperations } from "../providers/minimax/vision-conformance.js";
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
// Static base-release metadata
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
/**
|
|
38
|
+
* Capabilities supported by every Provider in the base release (DESIGN.md
|
|
39
|
+
* §14, §15). The four base capabilities are static; specialized Vision
|
|
40
|
+
* operations move into shared metadata only when their compiled
|
|
41
|
+
* conformance registry entry is supported. At P5-02 every specialized
|
|
42
|
+
* entry is pending, so this list reduces to the base four. P5-03's
|
|
43
|
+
* attested mappings automatically extend this list through the single
|
|
44
|
+
* registry query — there is no parallel support list to maintain.
|
|
45
|
+
*/
|
|
46
|
+
export const SHARED_CAPABILITIES = buildSharedCapabilities();
|
|
47
|
+
function buildSharedCapabilities() {
|
|
48
|
+
const caps = ["search", "vision.interpret-image", "quota", "diagnostics"];
|
|
49
|
+
for (const op of listSupportedMiniMaxVisionOperations()) {
|
|
50
|
+
caps.push(visionOperationToCapability(op));
|
|
51
|
+
}
|
|
52
|
+
return Object.freeze(caps);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Capabilities that remain Z.AI-only in the base release (DESIGN.md §14),
|
|
56
|
+
* in the documented order: Reader, repository exploration, raw provider
|
|
57
|
+
* tools, Code Mode, image diff, and video analysis.
|
|
58
|
+
*/
|
|
59
|
+
export const ZAI_ONLY_CAPABILITIES = [
|
|
60
|
+
"reader",
|
|
61
|
+
"repository-exploration",
|
|
62
|
+
"raw-provider-tools",
|
|
63
|
+
"code-mode",
|
|
64
|
+
"image-diff",
|
|
65
|
+
"video-analysis",
|
|
66
|
+
];
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
// Failure normalization
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
/**
|
|
71
|
+
* Map a thrown error into a normalized diagnostic error entry. The
|
|
72
|
+
* caller is responsible for recursive redaction before the entry
|
|
73
|
+
* crosses an outward boundary (the doctor command does this in
|
|
74
|
+
* {@link buildDiagnosticsReport}).
|
|
75
|
+
*/
|
|
76
|
+
export function diagnosticErrorFromError(error) {
|
|
77
|
+
const code = error instanceof ScoutlineError ? error.code : "UNKNOWN_ERROR";
|
|
78
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
79
|
+
const result = {
|
|
80
|
+
code,
|
|
81
|
+
message,
|
|
82
|
+
};
|
|
83
|
+
if (error instanceof ScoutlineError && error.help) {
|
|
84
|
+
result.help = error.help;
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../src/capabilities/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,cAAc,EAA2B,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,oCAAoC,EAAE,MAAM,4CAA4C,CAAC;AA2ClG,8EAA8E;AAC9E,+BAA+B;AAC/B,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAkC,uBAAuB,EAAE,CAAC;AAE5F,SAAS,uBAAuB;IAC9B,MAAM,IAAI,GAAyB,CAAC,QAAQ,EAAE,wBAAwB,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;IAChG,KAAK,MAAM,EAAE,IAAI,oCAAoC,EAAE,EAAE,CAAC;QACxD,IAAI,CAAC,IAAI,CAAC,2BAA2B,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAsB;IACtD,QAAQ;IACR,wBAAwB;IACxB,oBAAoB;IACpB,WAAW;IACX,YAAY;IACZ,gBAAgB;CACjB,CAAC;AAEF,8EAA8E;AAC9E,wBAAwB;AACxB,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAc;IAKrD,MAAM,IAAI,GACR,KAAK,YAAY,cAAc,CAAC,CAAC,CAAE,KAAK,CAAC,IAA2B,CAAC,CAAC,CAAC,eAAe,CAAC;IACzF,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,MAAM,MAAM,GAAiE;QAC3E,IAAI;QACJ,OAAO;KACR,CAAC;IACF,IAAI,KAAK,YAAY,cAAc,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QAClD,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IAC3B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quota Capability Contract (DESIGN.md §13, ADR-0001).
|
|
3
|
+
*
|
|
4
|
+
* Defines the normalized Provider-quota Interface shared by every
|
|
5
|
+
* Provider that reports plan usage. Each Adapter maps its Provider
|
|
6
|
+
* response shape into named quota categories with current and optional
|
|
7
|
+
* weekly windows, optional counts, a remaining percentage, and a reset
|
|
8
|
+
* time so callers do not need Provider-specific knowledge.
|
|
9
|
+
*
|
|
10
|
+
* Normalization rules (DESIGN.md §13):
|
|
11
|
+
* - Percentages are REMAINING percentages clamped to 0..100.
|
|
12
|
+
* - A valid explicit remaining percentage wins; otherwise derive
|
|
13
|
+
* `(remaining / limit) * 100` from finite nonnegative counts where
|
|
14
|
+
* used is not greater than limit.
|
|
15
|
+
* - Invalid optional counts are omitted together (not set to zero).
|
|
16
|
+
* - A category that has neither a valid percentage nor valid counts
|
|
17
|
+
* is rejected with `QUOTA_ERROR`.
|
|
18
|
+
* - Nonempty names, finite values, and ISO dates are mandatory.
|
|
19
|
+
*
|
|
20
|
+
* This module imports only Provider identity types and shared errors;
|
|
21
|
+
* it imports no Provider transport and no Provider Adapter.
|
|
22
|
+
*/
|
|
23
|
+
import type { ProviderId } from "../providers/types.js";
|
|
24
|
+
import { type ScoutlineErrorCode } from "../lib/errors.js";
|
|
25
|
+
export interface QuotaWindow {
|
|
26
|
+
durationSeconds?: number;
|
|
27
|
+
used?: number;
|
|
28
|
+
limit?: number;
|
|
29
|
+
remaining?: number;
|
|
30
|
+
remainingPercent: number;
|
|
31
|
+
resetsAt?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface QuotaCategory {
|
|
34
|
+
name: string;
|
|
35
|
+
unit: "requests" | "tokens";
|
|
36
|
+
current: QuotaWindow;
|
|
37
|
+
weekly?: QuotaWindow;
|
|
38
|
+
}
|
|
39
|
+
export interface ProviderQuotaSuccess {
|
|
40
|
+
provider: ProviderId;
|
|
41
|
+
status: "ok";
|
|
42
|
+
plan?: string;
|
|
43
|
+
categories: QuotaCategory[];
|
|
44
|
+
}
|
|
45
|
+
export interface ProviderQuotaFailure {
|
|
46
|
+
provider: ProviderId;
|
|
47
|
+
status: "error";
|
|
48
|
+
error: {
|
|
49
|
+
code: ScoutlineErrorCode;
|
|
50
|
+
message: string;
|
|
51
|
+
help?: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export interface QuotaDashboard {
|
|
55
|
+
schemaVersion: 1;
|
|
56
|
+
effectiveProvider: ProviderId;
|
|
57
|
+
providers: Array<ProviderQuotaSuccess | ProviderQuotaFailure>;
|
|
58
|
+
}
|
|
59
|
+
export interface QuotaCapability {
|
|
60
|
+
invoke(): Promise<ProviderQuotaSuccess>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Inputs to {@link buildQuotaWindow}. Every field is optional except
|
|
64
|
+
* that at least one of `explicitRemainingPercent` or a valid count set
|
|
65
|
+
* (`used` + `limit`) must be present, otherwise the window is
|
|
66
|
+
* unrecoverable and `QUOTA_ERROR` is thrown.
|
|
67
|
+
*/
|
|
68
|
+
export interface QuotaWindowInputs {
|
|
69
|
+
durationSeconds?: number;
|
|
70
|
+
used?: number;
|
|
71
|
+
limit?: number;
|
|
72
|
+
resetsAtEpochMs?: number;
|
|
73
|
+
/**
|
|
74
|
+
* A Provider-supplied REMAINING percentage (already in remaining
|
|
75
|
+
* terms, not used terms). A finite value wins over count-derived
|
|
76
|
+
* derivation and is then clamped to 0..100.
|
|
77
|
+
*/
|
|
78
|
+
explicitRemainingPercent?: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Build a normalized {@link QuotaWindow} from Provider inputs.
|
|
82
|
+
*
|
|
83
|
+
* Resolution order for `remainingPercent`:
|
|
84
|
+
* 1. A finite explicit remaining percentage wins (then clamped).
|
|
85
|
+
* 2. Otherwise derive from valid counts.
|
|
86
|
+
* 3. Otherwise throw `QUOTA_ERROR` — the category is unrecoverable.
|
|
87
|
+
*
|
|
88
|
+
* Invalid optional counts are omitted together; valid counts populate
|
|
89
|
+
* `used`, `limit`, and a derived `remaining`. `durationSeconds` and
|
|
90
|
+
* `resetsAt` are included only when finite/ISO-valid.
|
|
91
|
+
*/
|
|
92
|
+
export declare function buildQuotaWindow(inputs: QuotaWindowInputs): QuotaWindow;
|
|
93
|
+
/**
|
|
94
|
+
* Map a thrown error into a normalized {@link ProviderQuotaFailure}. The
|
|
95
|
+
* caller is responsible for recursive redaction before the failure
|
|
96
|
+
* crosses an outward boundary (all-provider quota does this in P4-03).
|
|
97
|
+
*/
|
|
98
|
+
export declare function quotaFailureFromError(provider: ProviderId, error: unknown): ProviderQuotaFailure;
|
|
99
|
+
//# sourceMappingURL=quota.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quota.d.ts","sourceRoot":"","sources":["../../src/capabilities/quota.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAM3E,MAAM,WAAW,WAAW;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,GAAG,QAAQ,CAAC;IAC5B,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,UAAU,CAAC;IACrB,MAAM,EAAE,IAAI,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,aAAa,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,UAAU,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE;QAAE,IAAI,EAAE,kBAAkB,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACrE;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,CAAC,CAAC;IACjB,iBAAiB,EAAE,UAAU,CAAC;IAC9B,SAAS,EAAE,KAAK,CAAC,oBAAoB,GAAG,oBAAoB,CAAC,CAAC;CAC/D;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACzC;AAMD;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAkDD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW,CAoCvE;AAMD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,oBAAoB,CAahG"}
|