scoutline 0.2.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.
Files changed (110) hide show
  1. package/README.md +240 -18
  2. package/dist/capabilities/diagnostics.d.ts +70 -32
  3. package/dist/capabilities/diagnostics.d.ts.map +1 -1
  4. package/dist/capabilities/diagnostics.js +97 -46
  5. package/dist/capabilities/diagnostics.js.map +1 -1
  6. package/dist/capabilities/reader.d.ts +227 -0
  7. package/dist/capabilities/reader.d.ts.map +1 -0
  8. package/dist/capabilities/reader.js +100 -0
  9. package/dist/capabilities/reader.js.map +1 -0
  10. package/dist/capabilities/repository.d.ts +221 -0
  11. package/dist/capabilities/repository.d.ts.map +1 -0
  12. package/dist/capabilities/repository.js +172 -0
  13. package/dist/capabilities/repository.js.map +1 -0
  14. package/dist/commands/cache.d.ts +106 -0
  15. package/dist/commands/cache.d.ts.map +1 -0
  16. package/dist/commands/cache.js +203 -0
  17. package/dist/commands/cache.js.map +1 -0
  18. package/dist/commands/doctor.d.ts +17 -6
  19. package/dist/commands/doctor.d.ts.map +1 -1
  20. package/dist/commands/doctor.js +42 -17
  21. package/dist/commands/doctor.js.map +1 -1
  22. package/dist/commands/read.d.ts +74 -14
  23. package/dist/commands/read.d.ts.map +1 -1
  24. package/dist/commands/read.js +257 -117
  25. package/dist/commands/read.js.map +1 -1
  26. package/dist/commands/repo.d.ts +53 -7
  27. package/dist/commands/repo.d.ts.map +1 -1
  28. package/dist/commands/repo.js +104 -123
  29. package/dist/commands/repo.js.map +1 -1
  30. package/dist/commands/repository-explorer.d.ts +147 -0
  31. package/dist/commands/repository-explorer.d.ts.map +1 -0
  32. package/dist/commands/repository-explorer.js +550 -0
  33. package/dist/commands/repository-explorer.js.map +1 -0
  34. package/dist/index.d.ts +20 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +209 -34
  37. package/dist/index.js.map +1 -1
  38. package/dist/lib/cache.d.ts +123 -18
  39. package/dist/lib/cache.d.ts.map +1 -1
  40. package/dist/lib/cache.js +324 -49
  41. package/dist/lib/cache.js.map +1 -1
  42. package/dist/lib/errors.d.ts +24 -1
  43. package/dist/lib/errors.d.ts.map +1 -1
  44. package/dist/lib/errors.js +33 -2
  45. package/dist/lib/errors.js.map +1 -1
  46. package/dist/lib/execution.d.ts +119 -5
  47. package/dist/lib/execution.d.ts.map +1 -1
  48. package/dist/lib/execution.js +216 -10
  49. package/dist/lib/execution.js.map +1 -1
  50. package/dist/lib/index.d.ts +1 -1
  51. package/dist/lib/index.d.ts.map +1 -1
  52. package/dist/lib/index.js +1 -1
  53. package/dist/lib/index.js.map +1 -1
  54. package/dist/lib/mcp-client.d.ts +29 -5
  55. package/dist/lib/mcp-client.d.ts.map +1 -1
  56. package/dist/lib/mcp-client.js +88 -88
  57. package/dist/lib/mcp-client.js.map +1 -1
  58. package/dist/lib/tool-cache.d.ts +86 -0
  59. package/dist/lib/tool-cache.d.ts.map +1 -0
  60. package/dist/lib/tool-cache.js +123 -0
  61. package/dist/lib/tool-cache.js.map +1 -0
  62. package/dist/providers/minimax/adapter.d.ts +6 -4
  63. package/dist/providers/minimax/adapter.d.ts.map +1 -1
  64. package/dist/providers/minimax/adapter.js +64 -57
  65. package/dist/providers/minimax/adapter.js.map +1 -1
  66. package/dist/providers/minimax/coding-plan-client.d.ts +60 -0
  67. package/dist/providers/minimax/coding-plan-client.d.ts.map +1 -0
  68. package/dist/providers/minimax/coding-plan-client.js +204 -0
  69. package/dist/providers/minimax/coding-plan-client.js.map +1 -0
  70. package/dist/providers/minimax/media.d.ts +60 -6
  71. package/dist/providers/minimax/media.d.ts.map +1 -1
  72. package/dist/providers/minimax/media.js +147 -7
  73. package/dist/providers/minimax/media.js.map +1 -1
  74. package/dist/providers/minimax/quota-client.d.ts +13 -6
  75. package/dist/providers/minimax/quota-client.d.ts.map +1 -1
  76. package/dist/providers/minimax/quota-client.js +5 -0
  77. package/dist/providers/minimax/quota-client.js.map +1 -1
  78. package/dist/providers/minimax/vision-attestations.d.ts +23 -0
  79. package/dist/providers/minimax/vision-attestations.d.ts.map +1 -1
  80. package/dist/providers/minimax/vision-attestations.js +35 -10
  81. package/dist/providers/minimax/vision-attestations.js.map +1 -1
  82. package/dist/providers/minimax/vision-conformance.d.ts +8 -6
  83. package/dist/providers/minimax/vision-conformance.d.ts.map +1 -1
  84. package/dist/providers/minimax/vision-conformance.js +8 -6
  85. package/dist/providers/minimax/vision-conformance.js.map +1 -1
  86. package/dist/providers/minimax/vision-revisions.d.ts +8 -1
  87. package/dist/providers/minimax/vision-revisions.d.ts.map +1 -1
  88. package/dist/providers/minimax/vision-revisions.js +13 -6
  89. package/dist/providers/minimax/vision-revisions.js.map +1 -1
  90. package/dist/providers/selection.d.ts +3 -3
  91. package/dist/providers/selection.js +3 -3
  92. package/dist/providers/types.d.ts +66 -32
  93. package/dist/providers/types.d.ts.map +1 -1
  94. package/dist/providers/types.js.map +1 -1
  95. package/dist/providers/zai/adapter.d.ts.map +1 -1
  96. package/dist/providers/zai/adapter.js +71 -5
  97. package/dist/providers/zai/adapter.js.map +1 -1
  98. package/dist/providers/zai/encoded-error.d.ts +90 -0
  99. package/dist/providers/zai/encoded-error.d.ts.map +1 -0
  100. package/dist/providers/zai/encoded-error.js +169 -0
  101. package/dist/providers/zai/encoded-error.js.map +1 -0
  102. package/dist/providers/zai/reader.d.ts +82 -0
  103. package/dist/providers/zai/reader.d.ts.map +1 -0
  104. package/dist/providers/zai/reader.js +490 -0
  105. package/dist/providers/zai/reader.js.map +1 -0
  106. package/dist/providers/zai/repository.d.ts +76 -0
  107. package/dist/providers/zai/repository.d.ts.map +1 -0
  108. package/dist/providers/zai/repository.js +715 -0
  109. package/dist/providers/zai/repository.js.map +1 -0
  110. package/package.json +3 -3
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Shared encoded MCP error envelope helpers (DESIGN.md §18).
3
+ *
4
+ * The ZRead and WebReader MCP transports occasionally surface a
5
+ * bare-string error envelope of the shape:
6
+ *
7
+ * MCP error -<status>\n
8
+ * error.code: <numeric>\n
9
+ * error.message: <text>
10
+ * <optional additional lines>
11
+ *
12
+ * The Repository Adapter (P6-04) and the Reader Adapter (Ticket 03)
13
+ * both recognise this shape BEFORE attempting any success parsing.
14
+ * Classification is centralized here so the taxonomy stays consistent
15
+ * across Adapter implementations; each Adapter supplies an operation
16
+ * `label` ("repository", "reader", …) that becomes part of the
17
+ * sanitized outward message. Auth-message labels (401/403) are NOT
18
+ * operation-specific and stay stable.
19
+ *
20
+ * Boundary rules:
21
+ * - This module imports normalized errors only; it imports no
22
+ * transport, no capability contract, and no other Adapter.
23
+ * - The raw Provider body, `error.message`, `reset`, etc. are
24
+ * discarded; outward messages and help text are stable sanitized
25
+ * labels.
26
+ *
27
+ * Historical note: P6-04A corrected the original mapping (status 403
28
+ * must keep exact status 403, not collapse to 401) and P6-04B refined
29
+ * the exhausted-quota phrase matching so that the bare word "limit"
30
+ * inside "rate limited" does NOT trigger terminal QuotaError. Those
31
+ * corrections are baked in here.
32
+ */
33
+ import { ApiError, AuthError, QuotaError, ScoutlineError } from "../../lib/errors.js";
34
+ /** Regex that captures the status of an encoded MCP error envelope. */
35
+ export const ENCODED_MCP_ERROR_RE = /^MCP error -(\d+)\b/;
36
+ /**
37
+ * Test whether `raw` looks like an encoded MCP error envelope. Returning
38
+ * `true` forces the caller into the error classification path before any
39
+ * success parser runs. The presence of a numeric status on the first
40
+ * line is the only requirement; the body lines are still parsed lazily.
41
+ */
42
+ export function looksLikeEncodedMcpError(raw) {
43
+ return typeof raw === "string" && ENCODED_MCP_ERROR_RE.test(raw);
44
+ }
45
+ /**
46
+ * Extract the numeric status code from an encoded MCP error envelope.
47
+ * Returns `null` when the prefix is not present or the trailing digits
48
+ * do not parse to a finite integer.
49
+ */
50
+ export function extractEncodedStatus(raw) {
51
+ const m = raw.match(ENCODED_MCP_ERROR_RE);
52
+ if (!m)
53
+ return null;
54
+ const n = Number.parseInt(m[1], 10);
55
+ return Number.isFinite(n) ? n : null;
56
+ }
57
+ /** Extract the documented `error.code:` numeric value, if present. */
58
+ export function extractEncodedCode(raw) {
59
+ const m = raw.match(/^error\.code:\s*(\d+)/m);
60
+ if (!m)
61
+ return null;
62
+ const n = Number.parseInt(m[1], 10);
63
+ return Number.isFinite(n) ? n : null;
64
+ }
65
+ /** Extract the documented `error.message:` line text, if present. */
66
+ export function extractEncodedMessage(raw) {
67
+ const m = raw.match(/^error\.message:\s*([^\n]+)/m);
68
+ return m ? m[1] : null;
69
+ }
70
+ /**
71
+ * Classify an encoded MCP error into a normalized error.
72
+ *
73
+ * The caller MUST have established that the response is an encoded
74
+ * envelope (via {@link looksLikeEncodedMcpError}). This function NEVER
75
+ * embeds the raw Provider body, message, or help into the outward text;
76
+ * it uses stable sanitized labels instead.
77
+ *
78
+ * `label` is the operation name used in the outward ApiError / QuotaError
79
+ * messages (e.g. "repository", "reader"). Auth messages (401, 403) do
80
+ * not carry the label — they read "Z.AI authentication failed" regardless
81
+ * of which Adapter surfaced them.
82
+ *
83
+ * Mapping (DESIGN.md §18; corrected by P6-04A, refined by P6-04B):
84
+ * - code 1310 OR explicit exhausted/limit/quota meaning
85
+ * -> terminal QuotaError
86
+ * (REGARDLESS of the encoded
87
+ * status line; a non-429 line
88
+ * with code 1310 is still an
89
+ * exhausted-quota failure);
90
+ * - 401 -> AuthError, status 401, terminal;
91
+ * - 403 -> normalized ScoutlineError
92
+ * with code AUTH_ERROR and
93
+ * statusCode 403, terminal
94
+ * (avoids widening the
95
+ * global AuthError
96
+ * constructor);
97
+ * - 429 (without exhausted quota) -> ApiError, status 429,
98
+ * retryable through the shared
99
+ * taxonomy;
100
+ * - 5xx -> ApiError matching status,
101
+ * retryable;
102
+ * - other 4xx -> ApiError matching status,
103
+ * terminal;
104
+ * - malformed envelope (no parseable status)
105
+ * -> ApiError 502, retryable.
106
+ */
107
+ export function classifyEncodedMcpError(raw, label) {
108
+ const status = extractEncodedStatus(raw);
109
+ if (status === null) {
110
+ // Malformed envelope: no parseable status. Retryable, sanitized.
111
+ return new ApiError(`Z.AI ${label} request failed`, 502);
112
+ }
113
+ const code = extractEncodedCode(raw);
114
+ const message = extractEncodedMessage(raw);
115
+ const lowerMessage = (message ?? "").toLowerCase();
116
+ // Exhausted quota: code 1310 OR explicit exhausted/quota/limit-reaching
117
+ // meaning. This branches BEFORE the status mapping so a non-429 encoded
118
+ // status line carrying code 1310 or an explicit exhausted message still
119
+ // becomes terminal `QuotaError`.
120
+ //
121
+ // The bare word "limit" is intentionally NOT matched on its own:
122
+ // "rate limited" is a transient retryable 429, not exhausted quota.
123
+ // "exhausted", "quota", and the multi-word phrases "limit reached" /
124
+ // "limit exceeded" are specific to the exhaustion context (P6-04B):
125
+ // - "Weekly/Monthly Limit Exhausted" -> "exhausted"
126
+ // - "Quota has been exhausted" -> "quota"
127
+ // - "Monthly limit reached" -> "limit reached"
128
+ // - "usage limit exceeded" -> "limit exceeded"
129
+ // Code 1310 is the authoritative numeric signal.
130
+ const isExhausted = code === 1310 ||
131
+ lowerMessage.includes("exhausted") ||
132
+ lowerMessage.includes("quota") ||
133
+ lowerMessage.includes("limit reached") ||
134
+ lowerMessage.includes("limit exceeded");
135
+ if (isExhausted) {
136
+ return new QuotaError(`Z.AI ${label} quota has been exhausted`, "Check your Z.AI quota and try again later");
137
+ }
138
+ if (status === 401) {
139
+ return new AuthError("Z.AI authentication failed");
140
+ }
141
+ if (status === 403) {
142
+ // 403 maps to AUTH_ERROR with status 403, terminal. Constructing
143
+ // a localized normalized ScoutlineError (rather than widening
144
+ // the global AuthError constructor) preserves the documented exact
145
+ // status code without affecting legacy call sites elsewhere in the
146
+ // codebase.
147
+ return new ScoutlineError("Z.AI authentication failed", "AUTH_ERROR", {
148
+ statusCode: 403,
149
+ retryable: false,
150
+ exitCode: 1,
151
+ });
152
+ }
153
+ // 5xx and other 429 -> retryable; other 4xx -> terminal. The retry
154
+ // classifier in `lib/execution.ts` reads `retryable` via the explicit
155
+ // ApiError flag, but the per-status mapping here matches DESIGN.md §10
156
+ // so the constructed errors carry the right shape regardless.
157
+ if (status === 429) {
158
+ return new ApiError(`Z.AI ${label} request failed`, 429);
159
+ }
160
+ if (status >= 500 && status <= 599) {
161
+ return new ApiError(`Z.AI ${label} request failed`, status);
162
+ }
163
+ if (status >= 400 && status <= 499) {
164
+ return new ApiError(`Z.AI ${label} request failed`, status);
165
+ }
166
+ // Unrecognized numeric status (e.g. 0, negative) -> retryable 502.
167
+ return new ApiError(`Z.AI ${label} request failed`, 502);
168
+ }
169
+ //# sourceMappingURL=encoded-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoded-error.js","sourceRoot":"","sources":["../../../src/providers/zai/encoded-error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEtF,uEAAuE;AACvE,MAAM,CAAC,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAY;IACnD,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAC1C,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACpC,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACvC,CAAC;AAED,sEAAsE;AACtE,MAAM,U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AAE,MAAM,CAAC,CAAC;IAC9D,CAAC;IAED,mEAAmE;IACnE,OAAO,IAAI,QAAQ,CAAC,QAAQ,KAAK,iBAAiB,EAAE,GAAG,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Z.AI Reader Adapter (DESIGN.md §18; reader-migration-tech-plan D4;
3
+ * PRD FR-??? — reader migration Ticket 03).
4
+ *
5
+ * Owns the Provider-facing half of the provider-neutral Reader
6
+ * Capability defined in `src/capabilities/reader.ts`:
7
+ *
8
+ * - URL rewrite (gist.github.com/<user>/<id> -> /raw) applied BEFORE
9
+ * invocation; the rewritten URL surfaces as `finalUrl` in the
10
+ * result. The rewrite is Z.AI-specific because Z.AI's WebReader
11
+ * MCP recognizes the rewritten URL.
12
+ * - a total parser for the characterized Z.AI WebReader response
13
+ * (`ReaderRawResponse`: object on success, bare string for MCP-
14
+ * level error envelopes);
15
+ * - encoded MCP error classification BEFORE success parsing
16
+ * (`quota` is terminal `QUOTA_ERROR`; the rest of the taxonomy
17
+ * uses the shared retry/terminal classification); the parsing
18
+ * helpers live in `./encoded-error.ts` and are shared with
19
+ * `./repository.ts`;
20
+ * - a single resolved-credential fingerprint per cache identity and
21
+ * exact per-operation legacy cache candidate using Ticket 01's
22
+ * `buildLegacyReaderCacheKey` helper;
23
+ * - `decodeCached` delegates to Ticket 01's total decoder
24
+ * (`decodeReaderFetchResult`);
25
+ * - a fresh transport per invocation attempt and exactly one
26
+ * best-effort close in `finally`; close failure never replaces
27
+ * success nor masks the primary failure;
28
+ * - no leakage of raw WebReader response types outside this module.
29
+ *
30
+ * Boundary rules (ARCHITECTURE.md §2):
31
+ * - May import capability types, normalized errors, the Z.AI MCP
32
+ * tool-name helpers, the legacy cache-key helper, the shared
33
+ * `ZaiAdapterClientPort` typed client port, and the shared
34
+ * encoded-error helpers.
35
+ * - Must NOT import another Provider's Adapter, command
36
+ * presentation, or extract/maxChars projection logic.
37
+ *
38
+ * Scope:
39
+ * - implements the single `reader-fetch` operation only. URL scheme
40
+ * validation, `--extract`, `--max-chars`, and `--full-envelope`
41
+ * belong to the command layer (Ticket 04 cuts the handler over).
42
+ * - descriptor metadata sequencing: Ticket 03 introduces this Adapter
43
+ * handle and wires it through `ProviderAdapter.reader` WITHOUT
44
+ * advertising `reader` on `createZaiDescriptor.capabilities()`;
45
+ * Ticket 04 then flips the descriptor to advertise `reader` so
46
+ * Provider selection and Doctor inventory derive from a single
47
+ * source of truth, AND cuts `commands/read.ts` over to dispatch
48
+ * through `adapter.reader.fetch`. This module owns no registry,
49
+ * selection, or command cutover.
50
+ */
51
+ import type { ZaiAdapterClientPort, ZaiMcpClientOptions } from "../types.js";
52
+ import { type ReaderCapability } from "../../capabilities/reader.js";
53
+ /**
54
+ * Production close bound (ms). Matches the existing
55
+ * `ZaiMcpClient.close(timeoutMs = 2000)` semantic; the Adapter races
56
+ * the close against a 2 second timer that resolves silently so a stuck
57
+ * close cannot stall the attempt. Tests may inject a shorter bound via
58
+ * {@link ZaiReaderCapabilityOptions.closeTimeoutMs}.
59
+ */
60
+ export declare const ZAI_READER_CLOSE_BOUND_MS = 2000;
61
+ /**
62
+ * Options accepted by {@link createZaiReaderCapability}.
63
+ *
64
+ * `closeTimeoutMs` defaults to {@link ZAI_READER_CLOSE_BOUND_MS}
65
+ * (2000 ms) — the existing `ZaiMcpClient.close(timeoutMs = 2000)`
66
+ * semantic. Tests may inject a shorter bound to bound a never-
67
+ * resolving `close()` without waiting for the production default.
68
+ */
69
+ export interface ZaiReaderCapabilityOptions {
70
+ readonly env: NodeJS.ProcessEnv;
71
+ readonly clientFactory: (options: ZaiMcpClientOptions) => ZaiAdapterClientPort;
72
+ readonly closeTimeoutMs?: number;
73
+ }
74
+ /**
75
+ * Build the Z.AI Reader Capability. The capability is composed of a
76
+ * single typed `ReaderOperation` descriptor (`fetch`); the Adapter
77
+ * owns credentials, transport lifecycle, raw request/response mapping,
78
+ * URL rewrite, and error normalization. No transport, credential
79
+ * resolution, or I/O happens during construction.
80
+ */
81
+ export declare function createZaiReaderCapability(options: ZaiReaderCapabilityOptions): ReaderCapability;
82
+ //# sourceMappingURL=reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../../src/providers/zai/reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAM7E,OAAO,EAGL,KAAK,gBAAgB,EAItB,MAAM,8BAA8B,CAAC;AAEtC;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAie9C;;;;;;;GAOG;AACH,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,oBAAoB,CAAC;IAC/E,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,0BAA0B,GAAG,gBAAgB,CAS/F"}