scoutline 0.23.0 → 0.24.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 (47) hide show
  1. package/README.md +49 -1
  2. package/dist/capabilities/investigation.d.ts +134 -0
  3. package/dist/capabilities/investigation.d.ts.map +1 -0
  4. package/dist/capabilities/investigation.js +278 -0
  5. package/dist/capabilities/investigation.js.map +1 -0
  6. package/dist/commands/investigate.d.ts +232 -0
  7. package/dist/commands/investigate.d.ts.map +1 -0
  8. package/dist/commands/investigate.js +838 -0
  9. package/dist/commands/investigate.js.map +1 -0
  10. package/dist/commands/vision.d.ts.map +1 -1
  11. package/dist/commands/vision.js +15 -2
  12. package/dist/commands/vision.js.map +1 -1
  13. package/dist/index.d.ts +21 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +373 -6
  16. package/dist/index.js.map +1 -1
  17. package/dist/lib/investigate-claims.d.ts +90 -0
  18. package/dist/lib/investigate-claims.d.ts.map +1 -0
  19. package/dist/lib/investigate-claims.js +188 -0
  20. package/dist/lib/investigate-claims.js.map +1 -0
  21. package/dist/lib/investigate-extract.d.ts +35 -0
  22. package/dist/lib/investigate-extract.d.ts.map +1 -0
  23. package/dist/lib/investigate-extract.js +101 -0
  24. package/dist/lib/investigate-extract.js.map +1 -0
  25. package/dist/lib/investigate-planner.d.ts +58 -0
  26. package/dist/lib/investigate-planner.d.ts.map +1 -0
  27. package/dist/lib/investigate-planner.js +141 -0
  28. package/dist/lib/investigate-planner.js.map +1 -0
  29. package/dist/providers/registry.d.ts.map +1 -1
  30. package/dist/providers/registry.js +4 -1
  31. package/dist/providers/registry.js.map +1 -1
  32. package/dist/providers/types.d.ts +30 -1
  33. package/dist/providers/types.d.ts.map +1 -1
  34. package/dist/providers/types.js.map +1 -1
  35. package/dist/providers/zai/adapter.d.ts.map +1 -1
  36. package/dist/providers/zai/adapter.js +217 -3
  37. package/dist/providers/zai/adapter.js.map +1 -1
  38. package/dist/providers/zai/layout-parsing.d.ts +76 -0
  39. package/dist/providers/zai/layout-parsing.d.ts.map +1 -0
  40. package/dist/providers/zai/layout-parsing.js +151 -0
  41. package/dist/providers/zai/layout-parsing.js.map +1 -0
  42. package/dist/providers/zai/media.d.ts +19 -0
  43. package/dist/providers/zai/media.d.ts.map +1 -1
  44. package/dist/providers/zai/media.js +61 -0
  45. package/dist/providers/zai/media.js.map +1 -1
  46. package/package.json +1 -1
  47. package/skills/scoutline/SKILL.md +71 -1
@@ -0,0 +1,232 @@
1
+ /**
2
+ * Investigation orchestrator (investigate-pipeline lane, Ticket T4;
3
+ * docs/plans/investigate-pipeline DESIGN.md D3, PRD AC-3/AC-4/AC-9/
4
+ * AC-10; ADR-0013).
5
+ *
6
+ * Thin, data-returning composition of the seams `search` and `read`
7
+ * already export — no bespoke merge fork, no local fan-out copy, no
8
+ * transport of its own:
9
+ *
10
+ * 1. planSubQueries (T2, injected loadContextText — no filesystem).
11
+ * 2. resolveFanoutPlan over the resolved provider pin (AC-1 tiers,
12
+ * the same inputs handleSearch passes).
13
+ * 3. Grid execution through the exported seams: fan-out mode runs
14
+ * executeFanoutPlan; single mode runs the exported search() with
15
+ * {merge: N > 1} over the escaped-pipe join of the sub-queries
16
+ * (the exact context-mode join precedent, index.ts handleSearch).
17
+ * 4. Top --sources distinct sources = the first K rows of the merged
18
+ * FormattedResult[] (mergeResults already collapsed near-dup
19
+ * clusters to representatives — a near-dup pair IS one row).
20
+ * 5. Reads: bounded-concurrency pool (default 4) over the reader
21
+ * capability seam via executeReaderOperation, one client per
22
+ * read (descriptor.create per read), closed in `finally`.
23
+ * 6. extractPassages (T3) per read result.
24
+ * 7. EvidencePack assembly per the T1 types.
25
+ *
26
+ * `--synthesize` (T7, PRD AC-7, DESIGN D6, ADR-0013 §2) is the explicit
27
+ * Z.AI-only escape hatch and is ADDITIVE-ONLY BY CONSTRUCTION: the pack
28
+ * is fully assembled (searches, reads, extraction, coverage) BEFORE the
29
+ * synthesis dep is ever called, so the brief can only ever be ADDED as
30
+ * the LAST key — a failed synthesis is the invocation's terminal error
31
+ * and never degrades, shrinks, or reorders the pack. The command holds
32
+ * no transport: construction is handler-seam wiring, exactly like every
33
+ * other capability, and the dep is injected.
34
+ *
35
+ * Reader supplier selection mirrors handleRead: the FIRST descriptor
36
+ * in registry order whose injected `readerCapabilityFor` resolves a
37
+ * ReaderCapability serves every read (the same first-configured-capable
38
+ * order read uses; cross-provider fallback per failed read is the
39
+ * index.ts handler seam's business, T6). A supplier that rejects a
40
+ * source terminally classifies as `reader-failed:<code>`; a supplier
41
+ * that cannot serve the capability at all classifies as
42
+ * `no-reader-supplier`. Unread rows carry reason codes only
43
+ * (redacted, house rule); the pool continues past them;
44
+ * `sourcesRead` counts successes only.
45
+ *
46
+ * Consumption linearity: every billable arm and read attempt records
47
+ * exactly one event (N×M + K) because the shared executors emit per
48
+ * invoke and the orchestrator never double-reads a URL.
49
+ *
50
+ * `--isolated` is ACCEPTED, never rejected: the pid-segment cache
51
+ * behavior is the main() handler seam's job (T6) — the command has no
52
+ * cache-directory logic of its own; the injected cache IS the
53
+ * (possibly isolated) production cache. Journal entry/marker WRITING
54
+ * lives at the index.ts descriptor seam (journalingDescriptors /
55
+ * captureServingDescriptors): this command consumes the injected
56
+ * descriptor list verbatim, so capture-wrapped descriptors keep
57
+ * stamping servedFrom/cacheKey cells the journal hook consumes — the
58
+ * T4-level guarantee (asserted by the seam-passthrough test); journal
59
+ * wiring itself is deferred to T6 (journal.ts / index.ts untouched).
60
+ */
61
+ import type { CommandContext, CommandResult } from "../command-invocation.js";
62
+ import type { ReaderCapability } from "../capabilities/reader.js";
63
+ import type { FusionMode } from "../lib/config-store.js";
64
+ import { type ResponseCache } from "../lib/cache.js";
65
+ import type { RetryPolicy } from "../lib/execution.js";
66
+ import type { ConsumptionSink } from "../lib/consumption.js";
67
+ import type { ProviderDescriptor, ProviderId } from "../providers/types.js";
68
+ import { type LadderRule } from "../lib/output-budget.js";
69
+ /**
70
+ * `--synthesize` escape hatch (T7). The deterministic brief prompt: the
71
+ * bare question, the planned sub-query grid, and the extracted passage
72
+ * quotes (bounded). No clock, no randomness — identical fixtures produce
73
+ * a byte-identical prompt.
74
+ */
75
+ export interface SynthesisPrompt {
76
+ readonly question: string;
77
+ readonly subQueries: readonly string[];
78
+ /** Extracted passage quotes, in pack order, capped at
79
+ * {@link SYNTHESIS_QUOTE_CAP}. */
80
+ readonly quotes: readonly string[];
81
+ }
82
+ /**
83
+ * Passage-quote cap for the brief prompt. Bounded so the prompt cannot
84
+ * grow with the read pool: 20 quotes ≈ the first few sources' passages,
85
+ * well inside the Z.AI chat context even at the passage cap (5 per
86
+ * source). Deterministic (first N in pack order), never sampled.
87
+ */
88
+ export declare const SYNTHESIS_QUOTE_CAP = 20;
89
+ /**
90
+ * The synthesis dep shape. `synthesize?` is threaded from the handler
91
+ * seam (index.ts), which owns the transport — the command never
92
+ * constructs one. Production passes a Z.AI chat-completions caller;
93
+ * tests pass a fixture.
94
+ */
95
+ export type SynthesizeBrief = (prompt: SynthesisPrompt) => Promise<string>;
96
+ /**
97
+ * `investigate --help` (T6/T7). The command's rejected-flag contract is
98
+ * part of the surface: --depth/--arms/--budget-tokens DO NOT EXIST (PRD
99
+ * AC-1 — the rejection is the feature), and --context-stdin is
100
+ * deliberately not investigate's (search-only spelling; pipes and
101
+ * --context cover the sub-query sources).
102
+ */
103
+ export declare const INVESTIGATE_HELP: string;
104
+ export interface InvestigateOptions {
105
+ /**
106
+ * Raw `--provider` value (comma-list / "all" / single id), threaded
107
+ * to resolveFanoutPlan verbatim — the same tier grammar search uses.
108
+ */
109
+ readonly provider?: string;
110
+ /** `--context` file path; selects the planner's context tier. */
111
+ readonly contextFile?: string;
112
+ /**
113
+ * `--sources`: how many distinct post-cluster sources to read.
114
+ * Positive integer; default 5. 0/negative/non-integers are
115
+ * VALIDATION_ERROR (validation at the trust boundary).
116
+ */
117
+ readonly sources?: number;
118
+ /**
119
+ * ACCEPTED, never rejected (PRD AC-9: no ISOLATED_REJECTED path).
120
+ * The pid-segment cache behavior belongs to the main() handler seam
121
+ * (T6) — this command has no cache-directory logic of its own; the
122
+ * injected cache IS the (possibly isolated) production cache.
123
+ */
124
+ readonly isolated?: boolean;
125
+ /** `--no-cache`: threaded to every underlying search + read. */
126
+ readonly noCache?: boolean;
127
+ /**
128
+ * `--no-journal`: threaded through ONLY as far as the command seam
129
+ * allows (the underlying ops take no such option — journaling is
130
+ * wired at the index.ts descriptor/hook seam). T6 owns the real
131
+ * suppression; recorded here so the option never fails the parse.
132
+ */
133
+ readonly noJournal?: boolean;
134
+ /**
135
+ * `--max-chars` (T5, D7): whole-envelope Output Budget over the
136
+ * EvidencePack via INVESTIGATE_LADDER. Strict positive integer
137
+ * (parseBriefMaxChars class); 0/negative/fractional values are
138
+ * VALIDATION_ERROR at the trust boundary.
139
+ */
140
+ readonly maxChars?: number;
141
+ /**
142
+ * `--synthesize` (T7, PRD AC-7): attach an additive `brief` to the
143
+ * pack via the injected {@link InvestigateExecutionDependencies.
144
+ * synthesize} dep. Z.AI-only (the notice lives at the handler seam,
145
+ * where the raw provider pin is visible). Set without a dep is a
146
+ * wiring bug — the command throws rather than silently skipping.
147
+ */
148
+ readonly synthesize?: boolean;
149
+ /**
150
+ * investigate-verify lane (DESIGN D3, PRD AC-1): claim-corroboration
151
+ * mode. The positional becomes the statement; `splitClaims` owns the
152
+ * grid (one verbatim sub-query per sentence-claim, ≤ 8 — the R1
153
+ * fail-loud cap); the planner module is NOT invoked. `--context` +
154
+ * `--verify` is pair-rejected at the index.ts parse seam; `|` is
155
+ * literal text (claims split on sentences, never pipes).
156
+ */
157
+ readonly verify?: boolean;
158
+ }
159
+ /**
160
+ * INVESTIGATE_LADDER (D7 budget order; verify lane D6 extension):
161
+ * passages trim FIRST (quote truncate, charRange adjusts — the
162
+ * round-trip pin survives), then LATE sources drop whole, then —
163
+ * verify packs only — evidence pointers drop per claim (whole).
164
+ * question/subQueries/coverage and verify claim text/verdicts/cue
165
+ * counts are never cut — expressed by omission (no rule touches
166
+ * them).
167
+ */
168
+ export declare const INVESTIGATE_LADDER: readonly [LadderRule<unknown>, LadderRule<unknown>, LadderRule<unknown>];
169
+ export interface InvestigateExecutionDependencies {
170
+ /**
171
+ * Live provider registry — the same `HandlerDependencies.
172
+ * providerDescriptors` list handleSearch consumes (possibly the
173
+ * capture-wrapped journalingDescriptors list; this command never
174
+ * unwraps it, so journal servedFrom/cacheKey stamping survives).
175
+ */
176
+ readonly descriptors: readonly ProviderDescriptor[];
177
+ /** The resolved env (env + file-configured keys). Input only. */
178
+ readonly env: NodeJS.ProcessEnv;
179
+ /** Whether `fanout` is enabled in the active config. */
180
+ readonly configFanout: boolean;
181
+ /** Resolved per-capability routing table. */
182
+ readonly routing?: Readonly<Record<string, readonly ProviderId[]>>;
183
+ /** Shared response cache for search arms AND reads. */
184
+ readonly cache: ResponseCache;
185
+ readonly sleep: (ms: number) => Promise<void>;
186
+ readonly random: () => number;
187
+ readonly retryPolicy?: RetryPolicy;
188
+ /** Usage-ledger sink — N×M + K linearity pins on it. */
189
+ readonly consume?: ConsumptionSink;
190
+ /** Clock for consumption events. */
191
+ readonly now?: () => number;
192
+ /**
193
+ * Fusion ranking mode — resolved ONCE at the handler seam (env >
194
+ * config > "rrf"), exactly how handleSearch threads it. Omitted
195
+ * (direct tests) → "rrf".
196
+ */
197
+ readonly fusionMode?: FusionMode;
198
+ /**
199
+ * Wall clock for `fetchedAt` (ISO-8601 UTC-Z, D5). Injected for
200
+ * byte-identical determinism pins; defaults to `() => new Date()`.
201
+ */
202
+ nowWall?: () => Date;
203
+ /**
204
+ * Read-pool concurrency bound (default 4). Overridable in deps so
205
+ * tests can pin the pool shape without timers.
206
+ */
207
+ readConcurrency?: number;
208
+ /** Injected context reader (production: readContextSource-shaped). */
209
+ loadContextText(filePath: string): Promise<string>;
210
+ /**
211
+ * Reader supplier seam: resolve the ReaderCapability a provider
212
+ * descriptor serves, or `undefined` when it has none. Production
213
+ * mirrors handleRead's shape — `descriptor.create({ env }).reader` —
214
+ * so selection follows the same first-configured-capable order read
215
+ * uses (the registry order the descriptor list already carries).
216
+ */
217
+ readerCapabilityFor(descriptor: ProviderDescriptor): ReaderCapability | undefined;
218
+ /**
219
+ * T5: resolved secrets for the compaction artifact's redaction (the
220
+ * save seam's contract — the caller redacts before persisting).
221
+ * Omitted (direct tests, no secrets) → no-op redaction.
222
+ */
223
+ readonly secrets?: string[];
224
+ /**
225
+ * T7: the synthesis transport (handler-seam wiring — this command
226
+ * never constructs one). Consulted ONLY when `--synthesize` is set,
227
+ * and only AFTER the pack is fully assembled.
228
+ */
229
+ synthesize?: SynthesizeBrief;
230
+ }
231
+ export declare function investigate(question: string, options: InvestigateOptions | undefined, deps: InvestigateExecutionDependencies, context?: CommandContext): Promise<CommandResult>;
232
+ //# sourceMappingURL=investigate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"investigate.d.ts","sourceRoot":"","sources":["../../src/commands/investigate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAqB,MAAM,2BAA2B,CAAC;AAErF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAyB,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAG5E,OAAO,EAAsC,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAkB9F;;;;;GAKG;AACH,MA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