@fro.bot/systematic 3.9.1 → 3.10.1

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.
@@ -1,83 +0,0 @@
1
- interface ConnectedProvider {
2
- id: string;
3
- models: Record<string, unknown>;
4
- }
5
- interface ProvidersResponse {
6
- providers: ConnectedProvider[];
7
- default: Record<string, string>;
8
- }
9
- interface ClientConfigApi {
10
- providers: () => Promise<{
11
- data: ProvidersResponse;
12
- error: undefined;
13
- } | {
14
- data: undefined;
15
- error: unknown;
16
- }>;
17
- }
18
- export interface OpencodeClientLike {
19
- config: ClientConfigApi;
20
- }
21
- /**
22
- * Outcome of model availability discovery.
23
- *
24
- * - `api`: The OpenCode server's `/config/providers` endpoint responded with
25
- * a connected-providers payload AND `models` is non-empty. An authoritatively
26
- * empty response (`data.providers = []`, or providers present with zero
27
- * models) collapses to `'unknown'` instead — see below — because the
28
- * operational consequence is identical and downstream consumers should treat
29
- * both cases the same way.
30
- * - `cache`: The API call failed (error envelope, thrown, or timed out) and
31
- * the local `models.json` cache was readable AND non-empty. `models`
32
- * reflects whatever OpenCode last wrote to disk. A cache that loads
33
- * successfully but produces a zero-size set collapses to `'unknown'` for
34
- * the same operational reason an empty API response does.
35
- * - `unknown`: Either both the API call and the cache fallback failed (cache
36
- * missing, unreadable, corrupt, or schema-mismatched), OR the API call
37
- * succeeded with zero usable models. Resolution should degrade gracefully —
38
- * callers should treat `unknown` as a signal to skip source-default model
39
- * pinning so users do not get agents pinned to inaccessible models.
40
- * `models` is the empty set.
41
- */
42
- export type DiscoveryStatus = 'api' | 'cache' | 'unknown';
43
- export interface ModelAvailability {
44
- status: DiscoveryStatus;
45
- /**
46
- * Set of `${providerId}/${modelId}` strings. Typed `ReadonlySet` because
47
- * callers must not mutate the returned collection — mutation would corrupt
48
- * future calls in the same process. Each `ModelAvailability` is a fresh
49
- * instance (see `emptyAvailability()`), so mutation via cast cannot
50
- * propagate, but the type makes intent explicit.
51
- */
52
- models: ReadonlySet<string>;
53
- }
54
- interface AvailabilityOptions {
55
- /**
56
- * Maximum time to wait for `client.config.providers()` before falling
57
- * back to the local cache. Defaults to 1500ms — a startup-budget value
58
- * that prevents a slow/half-open OpenCode server from holding the plugin
59
- * indefinitely.
60
- *
61
- * Set to `null` to disable the timeout entirely (not recommended).
62
- */
63
- apiTimeoutMs?: number | null;
64
- }
65
- /**
66
- * Discover the set of `provider/model` keys the OpenCode server considers
67
- * connected (or, on API failure, the set last written to the on-disk
68
- * `models.json` cache).
69
- *
70
- * The returned `status` lets callers distinguish three discovery outcomes:
71
- * - `api`: live answer; safe to pin source-default models against it
72
- * - `cache`: degraded but informed; the cached `provider/model` keys are
73
- * plausibly still authoritative
74
- * - `unknown`: both the API and the cache failed; callers should fall back
75
- * to OpenCode's parent-model inheritance rather than pinning a source
76
- * default the user may not have access to
77
- *
78
- * The API call is bounded by `apiTimeoutMs` (default 1500ms). On timeout,
79
- * thrown error, error-envelope response, or undefined data, the cache
80
- * fallback runs. The function never rejects.
81
- */
82
- export declare function getAvailableModels(client: OpencodeClientLike, options?: AvailabilityOptions): Promise<ModelAvailability>;
83
- export {};
@@ -1,117 +0,0 @@
1
- /**
2
- * Provider-grouped source category model defaults for Systematic bundled agents.
3
- *
4
- * This module owns the canonical shape, Zod schema, and constant for the
5
- * per-category model resolution chain. The resolution algorithm walks
6
- * the provider list in order and picks the first available provider/model pair.
7
- *
8
- * Provider catalog is constrained to the 7 IDs with empirical OMO usage-frequency
9
- * justification: vercel=80, opencode=55, github-copilot=39, opencode-go=26,
10
- * openai=20, anthropic=18, google=10.
11
- */
12
- import { z } from 'zod';
13
- /**
14
- * Zod literal union of the 7 supported provider IDs.
15
- * Ordered by OMO empirical usage frequency (highest first).
16
- */
17
- export declare const ProviderID: z.ZodUnion<readonly [z.ZodLiteral<"vercel">, z.ZodLiteral<"opencode">, z.ZodLiteral<"github-copilot">, z.ZodLiteral<"opencode-go">, z.ZodLiteral<"openai">, z.ZodLiteral<"anthropic">, z.ZodLiteral<"google">]>;
18
- export type ProviderID = z.infer<typeof ProviderID>;
19
- /**
20
- * Zod schema for the full source category model defaults map.
21
- *
22
- * Schema is **pure** — it validates only structural correctness:
23
- * - Shape correctness (CategoryDefaultSchema per value)
24
- * - Provider lists non-empty (enforced by CategoryDefaultSchema)
25
- * - Model lists non-empty (enforced by ProviderEntrySchema)
26
- * - (model, variant) pairs unique within a provider entry
27
- * - Provider IDs unique within a category
28
- * - variant is non-empty, whitespace-free, max 128 chars
29
- * - `rationale` and `whenToOverride` reject pipe (`|`) and newline characters
30
- * so the generator produces well-formed Markdown tables
31
- *
32
- * Filesystem coverage (every key resolves to a real `agents/<category>/`
33
- * directory) is NOT checked here. Use `assertCategoryCoverageOnDisk` to
34
- * enforce that invariant from tests where it matters; the production
35
- * runtime path uses `assertSourceCategoryModelCoverage` from
36
- * `agent-overlays.ts` against an in-memory inventory rather than reading
37
- * disk again.
38
- */
39
- export declare const SourceCategoryDefaultsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
40
- rationale: z.ZodString;
41
- whenToOverride: z.ZodOptional<z.ZodString>;
42
- providers: z.ZodArray<z.ZodObject<{
43
- provider: z.ZodUnion<readonly [z.ZodLiteral<"vercel">, z.ZodLiteral<"opencode">, z.ZodLiteral<"github-copilot">, z.ZodLiteral<"opencode-go">, z.ZodLiteral<"openai">, z.ZodLiteral<"anthropic">, z.ZodLiteral<"google">]>;
44
- models: z.ZodArray<z.ZodObject<{
45
- model: z.ZodString;
46
- variant: z.ZodOptional<z.ZodString>;
47
- }, z.core.$strict>>;
48
- }, z.core.$strict>>;
49
- }, z.core.$strict>>;
50
- /**
51
- * Verify that every category key in `categories` maps to a real
52
- * `agents/<category>/` directory on disk under `agentsDir` (defaulting to
53
- * the package's bundled-agents directory). Throws with a useful message if
54
- * any keys are unrecognized.
55
- *
56
- * Use from tests to lock the SOURCE_CATEGORY_MODEL_DEFAULTS ↔ agents/
57
- * directory layout contract. The production runtime path validates the
58
- * inverse direction (every bundled-agent category has a source default)
59
- * via `assertSourceCategoryModelCoverage` in `agent-overlays.ts`.
60
- */
61
- export declare function assertCategoryCoverageOnDisk(categories: readonly string[], agentsDir?: string): void;
62
- export interface ModelEntry {
63
- model: string;
64
- variant?: string;
65
- }
66
- export interface ProviderEntry {
67
- provider: ProviderID;
68
- models: ModelEntry[];
69
- }
70
- export interface CategoryDefault {
71
- rationale: string;
72
- whenToOverride?: string;
73
- providers: ProviderEntry[];
74
- }
75
- export type SourceCategoryDefaults = Record<string, CategoryDefault>;
76
- /**
77
- * Provider-grouped source model defaults for the 5 Systematic agent categories.
78
- *
79
- * Provider chains are ordered by OMO category-fit reasoning. The resolver
80
- * walks providers in order and picks the first available provider/model pair.
81
- * If no provider is available, the first entry of the first provider is used as
82
- * the last-resort fallback.
83
- *
84
- * Model choices translate the existing flat-string-array constant in agent-overlays.ts
85
- * to the new provider-grouped shape, with variant annotations where applicable.
86
- */
87
- export declare const SOURCE_CATEGORY_MODEL_DEFAULTS: SourceCategoryDefaults;
88
- /**
89
- * Format the SOURCE_CATEGORY_MODEL_DEFAULTS as a GitHub-flavored markdown table
90
- * for injection into documentation.
91
- *
92
- * Columns: Category | Chain | Rationale | When to Override
93
- *
94
- * Chain format: comma-separated `provider/model[+variant]` for the first 2–3
95
- * provider entries (first model per provider). Appends `, …` when there are
96
- * more than 3 provider entries.
97
- *
98
- * Returns a string ending with `\n` for clean concatenation.
99
- */
100
- export declare function formatForDocs(): string;
101
- /**
102
- * Walk the provider-grouped shape for a category and return the first available
103
- * provider/model pair from the availability set.
104
- *
105
- * Algorithm:
106
- * 1. Look up the category. Unknown category is a programmer error — throw.
107
- * 2. Walk providers in declared order. For each provider, walk its models in
108
- * declared order and test `${provider}/${model}` membership in availabilitySet.
109
- * 3. On first hit, return { provider, model, variant? }.
110
- * 4. Last-resort fallback (no available model anywhere): return the first model
111
- * entry of the first provider entry, including its variant if present.
112
- */
113
- export declare function resolveSourceModel(category: string, availabilitySet: ReadonlySet<string>): {
114
- provider: ProviderID;
115
- model: string;
116
- variant?: string;
117
- };