zidane 4.1.3 → 4.1.5
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 +3 -3
- package/dist/index.js +1 -1
- package/dist/{providers-CX-R-Oy-.js → providers-CCDvIXGJ.js} +26 -5
- package/dist/providers-CCDvIXGJ.js.map +1 -0
- package/dist/providers.js +1 -1
- package/dist/tui.d.ts +257 -68
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +826 -187
- package/dist/tui.js.map +1 -1
- package/package.json +1 -1
- package/dist/providers-CX-R-Oy-.js.map +0 -1
package/dist/tui.d.ts
CHANGED
|
@@ -1,13 +1,143 @@
|
|
|
1
1
|
import { Et as SessionTurn, H as Provider, It as TurnUsage, Mt as ToolResultContent, O as SessionStore } from "./agent-BoV5Twdl.js";
|
|
2
2
|
import { P as Preset } from "./index-28otmfLX.js";
|
|
3
|
+
import { OAuthCredentials, OAuthProviderInterface } from "@mariozechner/pi-ai/oauth";
|
|
3
4
|
import { SyntaxStyle } from "@opentui/core";
|
|
4
5
|
import * as _$react from "react";
|
|
5
6
|
import { Dispatch, ReactNode, SetStateAction } from "react";
|
|
6
7
|
|
|
8
|
+
//#region src/tui/providers.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Structural model metadata — compatible with pi-ai's `Model` interface but
|
|
11
|
+
* not coupled to it, so hosts can pass either pi-ai-shaped objects or a
|
|
12
|
+
* custom registry of their own.
|
|
13
|
+
*
|
|
14
|
+
* Deliberately a structural duplicate of pi-ai's `Model` rather than a
|
|
15
|
+
* re-export: keeps the public API stable when pi-ai bumps shape, and lets
|
|
16
|
+
* hosts implement their own registry without depending on pi-ai's types.
|
|
17
|
+
*
|
|
18
|
+
* Lives here (rather than `./config`) because `ProviderDescriptor.models`
|
|
19
|
+
* needs it — pushing it to `config.tsx` created an import cycle.
|
|
20
|
+
*/
|
|
21
|
+
interface ModelInfo {
|
|
22
|
+
id: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
contextWindow: number;
|
|
25
|
+
maxTokens?: number;
|
|
26
|
+
reasoning?: boolean;
|
|
27
|
+
input?: readonly ('text' | 'image')[];
|
|
28
|
+
cost?: {
|
|
29
|
+
input: number;
|
|
30
|
+
output: number;
|
|
31
|
+
cacheRead?: number;
|
|
32
|
+
cacheWrite?: number;
|
|
33
|
+
};
|
|
34
|
+
provider?: string;
|
|
35
|
+
}
|
|
36
|
+
interface ProviderDescriptor {
|
|
37
|
+
/**
|
|
38
|
+
* Unique identifier. Used as the registry key, persisted in `state.json`
|
|
39
|
+
* as the resumed provider, and (by default) as the credential-file key.
|
|
40
|
+
*/
|
|
41
|
+
key: string;
|
|
42
|
+
/** Display name shown in the TUI's provider picker and labels. */
|
|
43
|
+
label: string;
|
|
44
|
+
/**
|
|
45
|
+
* Factory that builds a fresh `Provider` instance. Called on every session
|
|
46
|
+
* activation. Some factories (e.g. zidane's built-in `anthropic`) eagerly
|
|
47
|
+
* resolve credentials at construction time and throw when none are
|
|
48
|
+
* configured — set {@link defaultModel} on the descriptor to avoid the TUI
|
|
49
|
+
* calling the factory before the user has picked + authed a provider.
|
|
50
|
+
*/
|
|
51
|
+
factory: () => Provider;
|
|
52
|
+
/**
|
|
53
|
+
* Default model id to seed the picker with. When omitted, the TUI falls
|
|
54
|
+
* back to `descriptor.factory().meta.defaultModel`, which constructs the
|
|
55
|
+
* provider — fine for lazy-credential factories, but breaks for factories
|
|
56
|
+
* that throw on missing credentials before the wizard runs. Setting this
|
|
57
|
+
* eagerly lets the TUI render the auth wizard without ever instantiating
|
|
58
|
+
* the provider.
|
|
59
|
+
*/
|
|
60
|
+
defaultModel?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Env var checked when detecting whether the user has an API key
|
|
63
|
+
* configured for this provider. Optional — set to `undefined` when the
|
|
64
|
+
* provider only supports OAuth (or only credentials via a custom path).
|
|
65
|
+
*/
|
|
66
|
+
envKey?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Key under which credentials live in `credentials.json`. Defaults to
|
|
69
|
+
* `key`. The only built-in that overrides this is OpenAI Codex
|
|
70
|
+
* (`openai` → `openai-codex`) to stay compatible with the harness
|
|
71
|
+
* provider's existing lookup.
|
|
72
|
+
*/
|
|
73
|
+
credentialFileKey?: string;
|
|
74
|
+
/** Placeholder shown in the wizard's API-key input. */
|
|
75
|
+
apiKeyPlaceholder?: string;
|
|
76
|
+
/**
|
|
77
|
+
* pi-ai (or compat) OAuth provider. When present, the wizard offers an
|
|
78
|
+
* OAuth option in addition to API key.
|
|
79
|
+
*/
|
|
80
|
+
oauthProvider?: OAuthProviderInterface;
|
|
81
|
+
/**
|
|
82
|
+
* Optional copy appended to the wizard's "OAuth" method description.
|
|
83
|
+
* Use to communicate why a user might pick OAuth (e.g. subscription tier,
|
|
84
|
+
* org-wide SSO). Shown after `browser-based sign-in`. Skip the leading
|
|
85
|
+
* space — the wizard adds it. Example: `'Claude Pro/Max subscription'`.
|
|
86
|
+
*/
|
|
87
|
+
oauthHint?: string;
|
|
88
|
+
/**
|
|
89
|
+
* pi-ai provider id used to look up models in pi-ai's built-in registry.
|
|
90
|
+
* Defaults to `key`. Only Codex differs (`openai` → `openai-codex`).
|
|
91
|
+
*/
|
|
92
|
+
piProviderId?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Override the model list returned for this provider's picker. When set,
|
|
95
|
+
* skips pi-ai's registry entirely. Useful for hosts maintaining their
|
|
96
|
+
* own model catalogue or for custom providers pi-ai doesn't know about.
|
|
97
|
+
*/
|
|
98
|
+
models?: readonly ModelInfo[];
|
|
99
|
+
}
|
|
100
|
+
/** Convenience accessor — returns `credentialFileKey ?? key`. */
|
|
101
|
+
declare function credKeyOf(desc: ProviderDescriptor): string;
|
|
102
|
+
/** Convenience accessor — returns `piProviderId ?? key`. */
|
|
103
|
+
declare function piIdOf(desc: ProviderDescriptor): string;
|
|
104
|
+
declare const anthropicDescriptor: ProviderDescriptor;
|
|
105
|
+
declare const openaiDescriptor: ProviderDescriptor;
|
|
106
|
+
declare const openrouterDescriptor: ProviderDescriptor;
|
|
107
|
+
declare const cerebrasDescriptor: ProviderDescriptor;
|
|
108
|
+
/**
|
|
109
|
+
* Default provider registry. Passed verbatim when `runTui` is invoked without
|
|
110
|
+
* an explicit `providers` option. Hosts that want to override per-provider
|
|
111
|
+
* metadata can spread this and replace specific entries:
|
|
112
|
+
*
|
|
113
|
+
* ```ts
|
|
114
|
+
* runTui({ providers: { ...BUILTIN_PROVIDERS, anthropic: myOwnAnthropicDescriptor } })
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
declare const BUILTIN_PROVIDERS: Readonly<Record<string, ProviderDescriptor>>;
|
|
118
|
+
/**
|
|
119
|
+
* Resolve the model list for a given provider. Honors `descriptor.models`
|
|
120
|
+
* when set; otherwise queries pi-ai via `descriptor.piProviderId`. Returns
|
|
121
|
+
* `[]` for descriptors with no known mapping (custom providers without a
|
|
122
|
+
* model list) — callers should hide the model picker in that case.
|
|
123
|
+
*/
|
|
124
|
+
declare function modelsForDescriptor(descriptor: ProviderDescriptor): readonly ModelInfo[];
|
|
125
|
+
/**
|
|
126
|
+
* Look up the model's max context window via the descriptor's model source.
|
|
127
|
+
* Returns `null` when the model isn't known (custom slugs, providers without
|
|
128
|
+
* a registry); callers should hide the context indicator in that case.
|
|
129
|
+
*/
|
|
130
|
+
declare function getContextWindow(descriptor: ProviderDescriptor, modelId: string): number | null;
|
|
131
|
+
//#endregion
|
|
7
132
|
//#region src/tui/auth.d.ts
|
|
8
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Provider identifier as known to the TUI. Built-in keys are `anthropic`,
|
|
135
|
+
* `openai`, `openrouter`, `cerebras`, but hosts can register additional
|
|
136
|
+
* keys via {@link ProviderDescriptor} — so the type is open.
|
|
137
|
+
*/
|
|
138
|
+
type ProviderKey = string;
|
|
9
139
|
interface AuthMethod {
|
|
10
|
-
source: 'env' | 'oauth';
|
|
140
|
+
source: 'env' | 'oauth' | 'apikey';
|
|
11
141
|
/** Human-readable detail (env var name, expiry timestamp, …). */
|
|
12
142
|
detail: string;
|
|
13
143
|
}
|
|
@@ -18,17 +148,20 @@ interface ProviderAuth {
|
|
|
18
148
|
available: boolean;
|
|
19
149
|
methods: AuthMethod[];
|
|
20
150
|
}
|
|
21
|
-
declare function envKeyFor(key: ProviderKey): string;
|
|
22
151
|
/**
|
|
23
|
-
* Detect available auth
|
|
152
|
+
* Detect available auth for every registered provider.
|
|
24
153
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
154
|
+
* Resolution order per provider (a method appears in `methods` for each
|
|
155
|
+
* layer that has a credential — the agent itself resolves them in the same
|
|
156
|
+
* order via its provider factories):
|
|
157
|
+
*
|
|
158
|
+
* 1. `kind: 'apikey'` from `credentials.json` (injected into env at TUI launch)
|
|
159
|
+
* 2. explicit env var (descriptor's `envKey`)
|
|
160
|
+
* 3. `kind: 'oauth'` from `credentials.json` (or legacy `cwd/.credentials.json`)
|
|
28
161
|
*
|
|
29
162
|
* Pure read — never refreshes or rewrites the credentials file.
|
|
30
163
|
*/
|
|
31
|
-
declare function detectAuth(env?: Record<string, string | undefined>): ProviderAuth[];
|
|
164
|
+
declare function detectAuth(dataDir: string, registry: Readonly<Record<string, ProviderDescriptor>>, env?: Record<string, string | undefined>): ProviderAuth[];
|
|
32
165
|
//#endregion
|
|
33
166
|
//#region src/tui/types.d.ts
|
|
34
167
|
type Screen = 'auth' | 'sessions' | 'chat';
|
|
@@ -107,35 +240,16 @@ declare function lastContextSizeFromTurns(turns: SessionTurn[]): number;
|
|
|
107
240
|
//#endregion
|
|
108
241
|
//#region src/tui/config.d.ts
|
|
109
242
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* Deliberately a structural duplicate of `pi-ai`'s `Model` rather than a
|
|
115
|
-
* re-export: keeps the public API stable when pi-ai bumps shape, and lets
|
|
116
|
-
* hosts implement their own registry without depending on pi-ai's types.
|
|
243
|
+
* Provider registry — a map keyed by `descriptor.key`. Passed verbatim to the
|
|
244
|
+
* TUI; there is no implicit merge with built-ins. Hosts that want the four
|
|
245
|
+
* default providers spread {@link BUILTIN_PROVIDERS}; hosts that only want
|
|
246
|
+
* their own pass exactly their own.
|
|
117
247
|
*/
|
|
118
|
-
|
|
119
|
-
id: string;
|
|
120
|
-
name?: string;
|
|
121
|
-
contextWindow: number;
|
|
122
|
-
maxTokens?: number;
|
|
123
|
-
reasoning?: boolean;
|
|
124
|
-
input?: readonly ('text' | 'image')[];
|
|
125
|
-
cost?: {
|
|
126
|
-
input: number;
|
|
127
|
-
output: number;
|
|
128
|
-
cacheRead?: number;
|
|
129
|
-
cacheWrite?: number;
|
|
130
|
-
};
|
|
131
|
-
provider?: string;
|
|
132
|
-
}
|
|
133
|
-
type ProviderRegistry = Partial<Record<ProviderKey, () => Provider>>;
|
|
134
|
-
type ModelRegistry = Partial<Record<ProviderKey, readonly ModelInfo[]>>;
|
|
248
|
+
type ProviderRegistry = Readonly<Record<string, ProviderDescriptor>>;
|
|
135
249
|
/**
|
|
136
250
|
* Options accepted by `runTui()` and `resolveConfig()`. Every field is optional
|
|
137
|
-
* —
|
|
138
|
-
*
|
|
251
|
+
* — defaults boot a working chat against the built-in providers with sessions
|
|
252
|
+
* stored under `~/.zidane/`.
|
|
139
253
|
*/
|
|
140
254
|
interface TuiOptions {
|
|
141
255
|
/**
|
|
@@ -150,9 +264,15 @@ interface TuiOptions {
|
|
|
150
264
|
*/
|
|
151
265
|
storageDir?: string;
|
|
152
266
|
/**
|
|
153
|
-
* Provider
|
|
154
|
-
*
|
|
155
|
-
*
|
|
267
|
+
* Provider registry. Each value is a {@link ProviderDescriptor} carrying
|
|
268
|
+
* label + factory + credential metadata. **No automatic merge** — hosts
|
|
269
|
+
* pass exactly what they want.
|
|
270
|
+
*
|
|
271
|
+
* - Omitted → {@link BUILTIN_PROVIDERS} (anthropic + openai + openrouter + cerebras).
|
|
272
|
+
* - `providers: BUILTIN_PROVIDERS` → same as omitted, but explicit.
|
|
273
|
+
* - `providers: { anthropic: anthropicDescriptor }` → only Anthropic.
|
|
274
|
+
* - `providers: { ...BUILTIN_PROVIDERS, mine: customDescriptor }` → built-ins + custom.
|
|
275
|
+
* - `providers: { mine: customDescriptor }` → custom-only, **no built-ins**.
|
|
156
276
|
*/
|
|
157
277
|
providers?: ProviderRegistry;
|
|
158
278
|
/**
|
|
@@ -164,12 +284,6 @@ interface TuiOptions {
|
|
|
164
284
|
* `<storageDir>/<prefix>/sessions.db`.
|
|
165
285
|
*/
|
|
166
286
|
store?: SessionStore;
|
|
167
|
-
/**
|
|
168
|
-
* Per-provider model registry for the in-app model picker. Each list should
|
|
169
|
-
* be in pi-ai's `Model`-compatible shape (see `ModelInfo`). If omitted, the
|
|
170
|
-
* picker falls back to pi-ai's built-in registry via `getModels()`.
|
|
171
|
-
*/
|
|
172
|
-
models?: ModelRegistry;
|
|
173
287
|
}
|
|
174
288
|
interface ResolvedConfig {
|
|
175
289
|
prefix: string;
|
|
@@ -265,6 +379,66 @@ declare function Transcript({
|
|
|
265
379
|
*/
|
|
266
380
|
declare function marginTopFor(event: StreamEvent, previous: StreamEvent | undefined): number;
|
|
267
381
|
//#endregion
|
|
382
|
+
//#region src/tui/credentials.d.ts
|
|
383
|
+
interface ApiKeyCredential {
|
|
384
|
+
kind: 'apikey';
|
|
385
|
+
value: string;
|
|
386
|
+
}
|
|
387
|
+
interface OAuthCredential {
|
|
388
|
+
kind: 'oauth';
|
|
389
|
+
access: string;
|
|
390
|
+
refresh?: string;
|
|
391
|
+
expires?: number;
|
|
392
|
+
/** Provider-specific extras (e.g. OpenAI Codex `accountId`). */
|
|
393
|
+
[extra: string]: unknown;
|
|
394
|
+
}
|
|
395
|
+
type ProviderCredential = ApiKeyCredential | OAuthCredential;
|
|
396
|
+
/** Top-level shape of `credentials.json` — keys are credential-file keys. */
|
|
397
|
+
type CredentialsFile = Record<string, ProviderCredential>;
|
|
398
|
+
/**
|
|
399
|
+
* Resolve the credentials file path given the resolved TUI data directory
|
|
400
|
+
* (typically `~/.zidane`, i.e. `config.paths.dir`).
|
|
401
|
+
*
|
|
402
|
+
* Matches the convention used elsewhere in the TUI (sessions.db, state.json)
|
|
403
|
+
* so a single `ZIDANE_STORAGE_DIR` override moves the entire data root.
|
|
404
|
+
*/
|
|
405
|
+
declare function credentialsPath(dataDir: string): string;
|
|
406
|
+
/**
|
|
407
|
+
* Read credentials from disk.
|
|
408
|
+
*
|
|
409
|
+
* Returns `{}` when the file is missing or corrupt (last-ditch tolerance —
|
|
410
|
+
* a hand-edit gone wrong shouldn't lock the user out of re-authing). On first
|
|
411
|
+
* call with no file present, attempts a migration from `cwd/.credentials.json`
|
|
412
|
+
* (the legacy location used by `bun run auth`).
|
|
413
|
+
*/
|
|
414
|
+
declare function readCredentials(dataDir: string): CredentialsFile;
|
|
415
|
+
/** Read a single provider's credential (translating via the descriptor). */
|
|
416
|
+
declare function readProviderCredential(dataDir: string, descriptor: ProviderDescriptor): ProviderCredential | undefined;
|
|
417
|
+
/**
|
|
418
|
+
* Write credentials atomically (write-then-rename) with mode 0o600.
|
|
419
|
+
*
|
|
420
|
+
* Atomic on the same filesystem — readers either see the previous file or the
|
|
421
|
+
* new one, never a half-written intermediate. Creates the parent dir if needed
|
|
422
|
+
* (first launch on a fresh machine: `~/.zidane/` may not exist yet).
|
|
423
|
+
*/
|
|
424
|
+
declare function writeCredentials(dataDir: string, creds: CredentialsFile): void;
|
|
425
|
+
declare function setProviderCredential(dataDir: string, descriptor: ProviderDescriptor, cred: ProviderCredential): void;
|
|
426
|
+
declare function removeProviderCredential(dataDir: string, descriptor: ProviderDescriptor): void;
|
|
427
|
+
/**
|
|
428
|
+
* Inject API-key credentials into `process.env` so the harness providers pick
|
|
429
|
+
* them up via their existing env-var resolution. Called once at TUI launch
|
|
430
|
+
* after the credentials file has been resolved. OAuth credentials are NOT
|
|
431
|
+
* injected — those reach providers via `ZIDANE_CREDENTIALS_PATH` + the file
|
|
432
|
+
* reader in `src/providers/oauth.ts`.
|
|
433
|
+
*
|
|
434
|
+
* Does not overwrite env vars that are already set — explicit user-provided
|
|
435
|
+
* env values win over stored API keys.
|
|
436
|
+
*
|
|
437
|
+
* Descriptors without an `envKey` (OAuth-only providers, custom providers
|
|
438
|
+
* that bypass env-var resolution) are skipped silently.
|
|
439
|
+
*/
|
|
440
|
+
declare function applyApiKeyEnv(dataDir: string, registry: Readonly<Record<string, ProviderDescriptor>>): void;
|
|
441
|
+
//#endregion
|
|
268
442
|
//#region src/tui/format.d.ts
|
|
269
443
|
/** Compact token formatter — 12_415 → "12.4k", 1_234_567 → "1.23M". */
|
|
270
444
|
declare function fmtTokens(n: number): string;
|
|
@@ -328,9 +502,10 @@ declare function Modal({
|
|
|
328
502
|
//#endregion
|
|
329
503
|
//#region src/tui/model-picker.d.ts
|
|
330
504
|
/**
|
|
331
|
-
* Modal that lists the available models for the current provider and lets
|
|
332
|
-
* user pick one. Options come from
|
|
333
|
-
*
|
|
505
|
+
* Modal that lists the available models for the current provider and lets
|
|
506
|
+
* the user pick one. Options come from the active `ProviderDescriptor` —
|
|
507
|
+
* either its declared `models` list or, when absent, pi-ai's built-in
|
|
508
|
+
* registry looked up via `piProviderId`.
|
|
334
509
|
*
|
|
335
510
|
* Each row shows: `● selected · name (ctx N · reasoning · vision)`.
|
|
336
511
|
*/
|
|
@@ -344,30 +519,33 @@ declare function ModelPickerModal({
|
|
|
344
519
|
onPick: (modelId: string) => void;
|
|
345
520
|
}): _$react.ReactNode;
|
|
346
521
|
//#endregion
|
|
347
|
-
//#region src/tui/
|
|
522
|
+
//#region src/tui/oauth.d.ts
|
|
523
|
+
declare function supportsOAuth(descriptor: ProviderDescriptor): boolean;
|
|
524
|
+
interface OAuthFlowOptions {
|
|
525
|
+
/** Called when the provider emits its login URL — typically right after the callback server starts. */
|
|
526
|
+
onUrl: (url: string, instructions?: string) => void;
|
|
527
|
+
/** Called when the provider needs a code entered manually (rare; only when callback server fails). */
|
|
528
|
+
onCodeRequest?: () => Promise<string>;
|
|
529
|
+
/** Called with each progress message from the OAuth flow (token exchange, etc.). */
|
|
530
|
+
onProgress?: (message: string) => void;
|
|
531
|
+
/** Abort the in-flight login (e.g. user pressed esc). */
|
|
532
|
+
signal?: AbortSignal;
|
|
533
|
+
}
|
|
348
534
|
/**
|
|
349
|
-
*
|
|
535
|
+
* Run the OAuth login flow for a provider.
|
|
350
536
|
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*/
|
|
355
|
-
declare const FACTORIES: Record<ProviderKey, () => Provider>;
|
|
356
|
-
/** zidane provider key → pi-ai provider id (some don't match 1:1). */
|
|
357
|
-
declare const PI_PROVIDER_ID: Record<ProviderKey, string>;
|
|
358
|
-
/**
|
|
359
|
-
* Look up the model's max context window via pi-ai's model registry.
|
|
360
|
-
* Returns `null` when the model isn't known (e.g. a custom openrouter slug);
|
|
361
|
-
* callers should hide the context indicator in that case.
|
|
537
|
+
* Returns the OAuth credentials on success; caller persists them via
|
|
538
|
+
* `setProviderCredential(dataDir, descriptor, { kind: 'oauth', ...credentials })`.
|
|
539
|
+
* Throws when the descriptor has no `oauthProvider` configured.
|
|
362
540
|
*/
|
|
363
|
-
declare function
|
|
541
|
+
declare function runOAuthLogin(descriptor: ProviderDescriptor, options: OAuthFlowOptions): Promise<OAuthCredentials>;
|
|
364
542
|
//#endregion
|
|
365
543
|
//#region src/tui/screens.d.ts
|
|
366
544
|
declare function AuthScreen({
|
|
367
545
|
onPick
|
|
368
546
|
}: {
|
|
369
547
|
onPick: (p: ProviderAuth) => void;
|
|
370
|
-
}):
|
|
548
|
+
}): ReactNode;
|
|
371
549
|
declare function SessionsScreen({
|
|
372
550
|
sessions,
|
|
373
551
|
currentId,
|
|
@@ -378,7 +556,7 @@ declare function SessionsScreen({
|
|
|
378
556
|
currentId: string | null;
|
|
379
557
|
onPick: (id: string) => void;
|
|
380
558
|
onCreate: () => void;
|
|
381
|
-
}):
|
|
559
|
+
}): ReactNode;
|
|
382
560
|
declare function ChatScreen({
|
|
383
561
|
events,
|
|
384
562
|
busy,
|
|
@@ -391,7 +569,7 @@ declare function ChatScreen({
|
|
|
391
569
|
settings: Settings;
|
|
392
570
|
onSubmit: (prompt: string) => void;
|
|
393
571
|
session: SessionMeta | null;
|
|
394
|
-
}):
|
|
572
|
+
}): ReactNode;
|
|
395
573
|
//#endregion
|
|
396
574
|
//#region src/tui/settings.d.ts
|
|
397
575
|
declare const DEFAULT_SETTINGS: Settings;
|
|
@@ -409,7 +587,19 @@ declare function SettingsProvider({
|
|
|
409
587
|
children: ReactNode;
|
|
410
588
|
}): ReactNode;
|
|
411
589
|
declare function useSettings(): SettingsContextValue;
|
|
412
|
-
|
|
590
|
+
interface SettingsActions {
|
|
591
|
+
/**
|
|
592
|
+
* Re-open the auth screen so the user can switch providers or run the
|
|
593
|
+
* wizard for a new/existing one. Wiring this callback adds a
|
|
594
|
+
* "Re-configure providers" row to the modal.
|
|
595
|
+
*/
|
|
596
|
+
onReauth?: () => void;
|
|
597
|
+
}
|
|
598
|
+
declare function SettingsModal({
|
|
599
|
+
actions
|
|
600
|
+
}?: {
|
|
601
|
+
actions?: SettingsActions;
|
|
602
|
+
}): ReactNode;
|
|
413
603
|
//#endregion
|
|
414
604
|
//#region src/tui/streaming.d.ts
|
|
415
605
|
/** Flip any trailing streaming markdown blocks (any owner) to finalized. */
|
|
@@ -516,18 +706,17 @@ declare const MD_STYLE: SyntaxStyle;
|
|
|
516
706
|
* to `runTui({ storageDir, prefix })`.
|
|
517
707
|
*
|
|
518
708
|
* ```ts
|
|
519
|
-
* import { runTui } from 'zidane/tui'
|
|
709
|
+
* import { BUILTIN_PROVIDERS, runTui } from 'zidane/tui'
|
|
520
710
|
* import { createRemoteStore } from 'zidane/session' // for the `store` option
|
|
521
711
|
*
|
|
522
712
|
* await runTui() // ~/.zidane/sessions.db + state.json
|
|
523
713
|
* await runTui({ prefix: '.myapp' }) // ~/.myapp/...
|
|
524
714
|
* await runTui({ storageDir: '/data', prefix: 'myapp' })
|
|
525
|
-
* await runTui({ providers: {
|
|
715
|
+
* await runTui({ providers: { ...BUILTIN_PROVIDERS, mine: myDescriptor } })
|
|
526
716
|
* await runTui({ store: createRemoteStore({ url: '…' }) })
|
|
527
|
-
* await runTui({ models: { anthropic: [{ id: 'claude-foo', contextWindow: 200_000 }] } })
|
|
528
717
|
* ```
|
|
529
718
|
*/
|
|
530
719
|
declare function runTui(options?: TuiOptions): Promise<never>;
|
|
531
720
|
//#endregion
|
|
532
|
-
export { App, type AuthMethod, AuthScreen, COLOR, ChatScreen, ConfigProvider, type ContextUsage,
|
|
721
|
+
export { type ApiKeyCredential, App, type AuthMethod, AuthScreen, BUILTIN_PROVIDERS, COLOR, ChatScreen, ConfigProvider, type ContextUsage, type CredentialsFile, DEFAULT_SETTINGS, Footer, type Hint, MD_STYLE, Modal, type ModalProps, ModalRoot, type ModelInfo, ModelPickerModal, type OAuthCredential, type OAuthFlowOptions, type Owner, type Picked, type ProviderAuth, type ProviderCredential, type ProviderDescriptor, type ProviderKey, type ProviderRegistry, type ResolvedConfig, SELECT_THEME, type Screen, type SessionMeta, SessionsScreen, type Settings, SettingsModal, SettingsProvider, Spinner, type StateStoreApi, type StreamBuffer, type StreamEvent, type StreamSource, Transcript, type TuiOptions, type TuiState, ageString, anthropicDescriptor, applyApiKeyEnv, cerebrasDescriptor, createStateStore, createTuiStore, credKeyOf, credentialsPath, detectAuth, eventsFromTurns, finalizeStreamingMarkdown, finalizeStreamingMarkdownForOwner, fmtTokens, getContextWindow, lastContextSizeFromTurns, listSessionMeta, loadState, marginTopFor, modelsForDescriptor, onInputSubmit, openaiDescriptor, openrouterDescriptor, piIdOf, readCredentials, readProviderCredential, removeProviderCredential, resolveConfig, runOAuthLogin, runTui, saveState, setProviderCredential, shortId, supportsOAuth, titleFromTurns, toolCallPreview, toolResultText, turnContextSize, useConfig, useModal, useModalAwareFocus, useSettings, useStreamBuffer, writeCredentials };
|
|
533
722
|
//# sourceMappingURL=tui.d.ts.map
|
package/dist/tui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tui.d.ts","names":[],"sources":["../src/tui/auth.ts","../src/tui/types.ts","../src/tui/store.ts","../src/tui/config.tsx","../src/tui/app.tsx","../src/tui/components.tsx","../src/tui/format.ts","../src/tui/modal.tsx","../src/tui/model-picker.tsx","../src/tui/
|
|
1
|
+
{"version":3,"file":"tui.d.ts","names":[],"sources":["../src/tui/providers.ts","../src/tui/auth.ts","../src/tui/types.ts","../src/tui/store.ts","../src/tui/config.tsx","../src/tui/app.tsx","../src/tui/components.tsx","../src/tui/credentials.ts","../src/tui/format.ts","../src/tui/modal.tsx","../src/tui/model-picker.tsx","../src/tui/oauth.ts","../src/tui/screens.tsx","../src/tui/settings.tsx","../src/tui/streaming.ts","../src/tui/theme.ts","../src/tui/index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;UA4BiB,SAAA;EACf,EAAA;EACA,IAAA;EACA,aAAA;EACA,SAAA;EACA,SAAA;EACA,KAAA;EACA,IAAA;IAAS,KAAA;IAAe,MAAA;IAAgB,SAAA;IAAoB,UAAA;EAAA;EAC5D,QAAA;AAAA;AAAA,UAGe,kBAAA;EA8Bf;;;;EAzBA,GAAA;EA8CA;EA5CA,KAAA;EAuDA;;;;AAIF;;;EAnDE,OAAA,QAAe,QAAA;EAmDiC;AAKlD;;;;;AAQA;;EAvDE,YAAA;EAuDgC;;AAWlC;;;EA5DE,MAAA;EAsED;AAED;;;;;EAjEE,iBAAA;EAiFD;EA/EC,iBAAA;EAwE+B;;AAkBjC;;EArFE,aAAA,GAAgB,sBAAA;EAqFsC;;;;;;EA9EtD,SAAA;EA8EsD;;;AAiBxD;EA1FE,YAAA;;;;;;EAMA,MAAA,YAAkB,SAAA;AAAA;AAoGpB;AAAA,iBAhGgB,SAAA,CAAU,IAAA,EAAM,kBAAA;;iBAKhB,MAAA,CAAO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